Use local D3D12 bindings for ComputeSharp
このコミットが含まれているのは:
1 親
eccc297d8d
コミット
d89bade85a
12ファイル変更
+37
-54
検索条件に一致するファイルはありません
@@ -491,6 +491,7 @@ Global
|
||||
samples\ComputeSharp.SwapChain.Shaders.Shared\ComputeSharp.SwapChain.Shaders.Shared.projitems*{0800bd51-499d-44c2-9417-fd1f7fdfe9c4}*SharedItemsImports = 13
|
||||
samples\ComputeSharp.SwapChain.Shaders.D2D1.Shared\ComputeSharp.SwapChain.Shaders.D2D1.Shared.projitems*{209c95a3-fa53-431b-b688-3299ca6c29d2}*SharedItemsImports = 5
|
||||
src\ComputeSharp.CodeFixing\ComputeSharp.CodeFixing.projitems*{29f6e256-ba0e-4f3b-854e-50839d67c6dd}*SharedItemsImports = 13
|
||||
src\ComputeSharp.Win32.D3D12\ComputeSharp.Win32.D3D12.projitems*{314eb353-e7e3-4146-8111-685cc83ec1de}*SharedItemsImports = 5
|
||||
src\ComputeSharp.Win32.D2D1\ComputeSharp.Win32.D2D1.projitems*{4d7d9ba8-a821-4b1c-9ee2-cbcf5849906e}*SharedItemsImports = 5
|
||||
src\ComputeSharp.Win32.D3D12\ComputeSharp.Win32.D3D12.projitems*{514ff00e-bbf0-4d55-a47c-eeeb6208adce}*SharedItemsImports = 13
|
||||
src\ComputeSharp.SourceGeneration\ComputeSharp.SourceGeneration.projitems*{51d5a422-d3a5-4c4d-8a6d-a048940bf279}*SharedItemsImports = 13
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace ComputeSharp.Win32;
|
||||
internal static unsafe partial class Windows
|
||||
{
|
||||
[DllImport("kernel32", ExactSpelling = true)]
|
||||
public static extern BOOL RegisterWaitForSingleObject([NativeTypeName("PHANDLE")] HANDLE* phNewWaitObject, HANDLE hObject, [NativeTypeName("WAITORTIMERCALLBACK")] void* Callback, [NativeTypeName("PVOID")] void* Context, [NativeTypeName("ULONG")] uint dwMilliseconds, [NativeTypeName("ULONG")] uint dwFlags);
|
||||
public static extern BOOL RegisterWaitForSingleObject([NativeTypeName("PHANDLE")] HANDLE* phNewWaitObject, HANDLE hObject, [NativeTypeName("WAITORTIMERCALLBACK")] delegate* unmanaged<void*, byte, void> Callback, [NativeTypeName("PVOID")] void* Context, [NativeTypeName("ULONG")] uint dwMilliseconds, [NativeTypeName("ULONG")] uint dwFlags);
|
||||
|
||||
[DllImport("kernel32", ExactSpelling = true)]
|
||||
public static extern BOOL UnregisterWait(HANDLE WaitHandle);
|
||||
|
||||
@@ -16,10 +16,6 @@
|
||||
<ProjectReference Include="..\ComputeSharp.Core\ComputeSharp.Core.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="TerraFX.Interop.Windows" Version="10.0.22621.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<!-- Include the ILLink file (to properly trim configuration switches in publish builds) -->
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Properties\ILLink.Substitutions.xml" LogicalName="ILLink.Substitutions.xml" />
|
||||
@@ -29,4 +25,7 @@
|
||||
<ItemGroup>
|
||||
<Service Include="{508349b6-6b84-4df5-91f0-309beebad82d}" />
|
||||
</ItemGroup>
|
||||
|
||||
<!-- Shared ComputeSharp.Win32.D3D12 with D3D12 bindings -->
|
||||
<Import Project="..\ComputeSharp.Win32.D3D12\ComputeSharp.Win32.D3D12.projitems" Label="Shared" />
|
||||
</Project>
|
||||
@@ -17,7 +17,7 @@ internal static class ComPtrExtensions
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static unsafe ComPtr<T> Move<T>(this in ComPtr<T> ptr)
|
||||
#if NET6_0_OR_GREATER
|
||||
where T : unmanaged, IUnknown.Interface
|
||||
where T : unmanaged//, IUnknown.Interface
|
||||
#else
|
||||
where T : unmanaged
|
||||
#endif
|
||||
|
||||
@@ -3,9 +3,6 @@ using System.Buffers;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
#if NET6_0_OR_GREATER
|
||||
using TerraFX.Interop;
|
||||
#endif
|
||||
using TerraFX.Interop.Windows;
|
||||
using static TerraFX.Interop.Windows.E;
|
||||
using static TerraFX.Interop.Windows.IID;
|
||||
@@ -40,12 +37,12 @@ unsafe partial class IWICStreamExtensions
|
||||
/// </summary>
|
||||
private unsafe partial struct IBufferWriterWrapper
|
||||
#if NET6_0_OR_GREATER
|
||||
: IUnknown.Interface
|
||||
//: IUnknown.Interface
|
||||
#endif
|
||||
{
|
||||
#if NET6_0_OR_GREATER
|
||||
/// <inheritdoc/>
|
||||
static Guid* INativeGuid.NativeGuid => (Guid*)default(NotSupportedException).Throw<nint>();
|
||||
///// <inheritdoc/>
|
||||
//static Guid* INativeGuid.NativeGuid => (Guid*)default(NotSupportedException).Throw<nint>();
|
||||
#else
|
||||
/// <inheritdoc cref="QueryInterface"/>
|
||||
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
|
||||
|
||||
@@ -3,9 +3,6 @@ using System.IO;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
#if NET6_0_OR_GREATER
|
||||
using TerraFX.Interop;
|
||||
#endif
|
||||
using TerraFX.Interop.Windows;
|
||||
using static TerraFX.Interop.Windows.E;
|
||||
using static TerraFX.Interop.Windows.IID;
|
||||
@@ -42,12 +39,12 @@ internal static unsafe partial class IWICStreamExtensions
|
||||
/// </summary>
|
||||
private unsafe partial struct IStreamWrapper
|
||||
#if NET6_0_OR_GREATER
|
||||
: IUnknown.Interface
|
||||
//: IUnknown.Interface
|
||||
#endif
|
||||
{
|
||||
#if NET6_0_OR_GREATER
|
||||
/// <inheritdoc/>
|
||||
static Guid* INativeGuid.NativeGuid => (Guid*)default(NotSupportedException).Throw<nint>();
|
||||
///// <inheritdoc/>
|
||||
//static Guid* INativeGuid.NativeGuid => (Guid*)default(NotSupportedException).Throw<nint>();
|
||||
#else
|
||||
/// <inheritdoc cref="QueryInterface"/>
|
||||
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
|
||||
|
||||
@@ -6,6 +6,8 @@ using ComputeSharp.Core.Extensions;
|
||||
using ComputeSharp.Graphics.Extensions;
|
||||
using TerraFX.Interop.Windows;
|
||||
|
||||
#pragma warning disable CA1416
|
||||
|
||||
namespace ComputeSharp.Graphics.Helpers;
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
#if NET6_0_OR_GREATER
|
||||
using TerraFX.Interop;
|
||||
#endif
|
||||
using TerraFX.Interop.DirectX;
|
||||
using TerraFX.Interop.Windows;
|
||||
|
||||
@@ -17,7 +14,7 @@ namespace ComputeSharp.Interop.Allocation;
|
||||
[Guid("D42D5782-2DE7-4539-A817-482E3AA01E2E")]
|
||||
internal unsafe struct ID3D12Allocation
|
||||
#if NET6_0_OR_GREATER
|
||||
: IUnknown.Interface
|
||||
//: IUnknown.Interface
|
||||
#endif
|
||||
{
|
||||
/// <summary>
|
||||
@@ -45,8 +42,8 @@ internal unsafe struct ID3D12Allocation
|
||||
}
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
/// <inheritdoc/>
|
||||
static Guid* INativeGuid.NativeGuid => (Guid*)Unsafe.AsPointer(ref Unsafe.AsRef(in Guid));
|
||||
///// <inheritdoc/>
|
||||
//static Guid* INativeGuid.NativeGuid => (Guid*)Unsafe.AsPointer(ref Unsafe.AsRef(in Guid));
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
#if NET6_0_OR_GREATER
|
||||
using TerraFX.Interop;
|
||||
#endif
|
||||
using TerraFX.Interop.DirectX;
|
||||
using TerraFX.Interop.Windows;
|
||||
|
||||
@@ -17,7 +14,7 @@ namespace ComputeSharp.Interop.Allocation;
|
||||
[Guid("2D5E55D2-9244-431F-868E-0D90AAB6E575")]
|
||||
internal unsafe struct ID3D12MemoryAllocator
|
||||
#if NET6_0_OR_GREATER
|
||||
: IUnknown.Interface
|
||||
//: IUnknown.Interface
|
||||
#endif
|
||||
{
|
||||
/// <summary>
|
||||
@@ -45,8 +42,8 @@ internal unsafe struct ID3D12MemoryAllocator
|
||||
}
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
/// <inheritdoc/>
|
||||
static Guid* INativeGuid.NativeGuid => (Guid*)Unsafe.AsPointer(ref Unsafe.AsRef(in Guid));
|
||||
///// <inheritdoc/>
|
||||
//static Guid* INativeGuid.NativeGuid => (Guid*)Unsafe.AsPointer(ref Unsafe.AsRef(in Guid));
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
#if NET6_0_OR_GREATER
|
||||
using TerraFX.Interop;
|
||||
#endif
|
||||
using TerraFX.Interop.DirectX;
|
||||
using TerraFX.Interop.Windows;
|
||||
|
||||
@@ -17,7 +14,7 @@ namespace ComputeSharp.Interop.Allocation;
|
||||
[Guid("CC1E74A7-786D-40F4-8AE2-F8B7A255587E")]
|
||||
internal unsafe struct ID3D12MemoryAllocatorFactory
|
||||
#if NET6_0_OR_GREATER
|
||||
: IUnknown.Interface
|
||||
//: IUnknown.Interface
|
||||
#endif
|
||||
{
|
||||
/// <summary>
|
||||
@@ -45,8 +42,8 @@ internal unsafe struct ID3D12MemoryAllocatorFactory
|
||||
}
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
/// <inheritdoc/>
|
||||
static Guid* INativeGuid.NativeGuid => (Guid*)Unsafe.AsPointer(ref Unsafe.AsRef(in Guid));
|
||||
///// <inheritdoc/>
|
||||
//static Guid* INativeGuid.NativeGuid => (Guid*)Unsafe.AsPointer(ref Unsafe.AsRef(in Guid));
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -21,17 +21,17 @@ internal static unsafe class ID3D12DeviceExtensions
|
||||
/// <param name="d3D12Root32BitConstantsCount">The number of 32 bit root constants to load.</param>
|
||||
/// <param name="d3D12DescriptorRanges1">The input descriptor ranges for the signature to create.</param>
|
||||
/// <param name="isStaticSamplerUsed">Indicates whether or not a static sampler is used.</param>
|
||||
/// <returns>A pointer to the newly allocated <see cref="ID3D12RootSignature"/> instance.</returns>
|
||||
/// <param name="d3D12RootSignature">The newly allocated <see cref="ID3D12RootSignature"/> instance.</param>
|
||||
/// <exception cref="Exception">Thrown when the creation of the root signature fails.</exception>
|
||||
public static ComPtr<ID3D12RootSignature> CreateRootSignature(
|
||||
public static void CreateRootSignature(
|
||||
this ref ID3D12Device d3D12Device,
|
||||
int d3D12Root32BitConstantsCount,
|
||||
ReadOnlySpan<D3D12_DESCRIPTOR_RANGE1> d3D12DescriptorRanges1,
|
||||
bool isStaticSamplerUsed)
|
||||
bool isStaticSamplerUsed,
|
||||
ID3D12RootSignature** d3D12RootSignature)
|
||||
{
|
||||
using ComPtr<ID3DBlob> d3D3Blob = default;
|
||||
using ComPtr<ID3DBlob> d3D3BlobError = default;
|
||||
using ComPtr<ID3D12RootSignature> d3D12RootSignature = default;
|
||||
|
||||
fixed (D3D12_DESCRIPTOR_RANGE1* d3D12DescriptorRange1 = d3D12DescriptorRanges1)
|
||||
{
|
||||
@@ -83,9 +83,7 @@ internal static unsafe class ID3D12DeviceExtensions
|
||||
d3D3Blob.Get()->GetBufferPointer(),
|
||||
d3D3Blob.Get()->GetBufferSize(),
|
||||
Windows.__uuidof<ID3D12RootSignature>(),
|
||||
(void**)d3D12RootSignature.GetAddressOf()).Assert();
|
||||
|
||||
return d3D12RootSignature.Move();
|
||||
(void**)d3D12RootSignature).Assert();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -94,15 +92,14 @@ internal static unsafe class ID3D12DeviceExtensions
|
||||
/// <param name="d3D12Device">The target <see cref="ID3D12Device"/> to use to create the pipeline state.</param>
|
||||
/// <param name="d3D12RootSignature">The input root signature to use to create the pipeline state.</param>
|
||||
/// <param name="d3D12ShaderBytecode">The shader bytecode to use for the pipeline state.</param>
|
||||
/// <returns>A pointer to the newly allocated <see cref="ID3D12PipelineState"/> instance.</returns>
|
||||
/// <param name="d3D12PipelineState">The newly allocated <see cref="ID3D12PipelineState"/> instance.</param>
|
||||
/// <exception cref="Exception">Thrown when the creation of the pipeline state fails.</exception>
|
||||
public static ComPtr<ID3D12PipelineState> CreateComputePipelineState(
|
||||
public static void CreateComputePipelineState(
|
||||
this ref ID3D12Device d3D12Device,
|
||||
ID3D12RootSignature* d3D12RootSignature,
|
||||
D3D12_SHADER_BYTECODE d3D12ShaderBytecode)
|
||||
D3D12_SHADER_BYTECODE d3D12ShaderBytecode,
|
||||
ID3D12PipelineState** d3D12PipelineState)
|
||||
{
|
||||
using ComPtr<ID3D12PipelineState> d3D12PipelineState = default;
|
||||
|
||||
D3D12_COMPUTE_PIPELINE_STATE_DESC d3D12ComputePipelineStateDescription;
|
||||
d3D12ComputePipelineStateDescription.pRootSignature = d3D12RootSignature;
|
||||
d3D12ComputePipelineStateDescription.CS = d3D12ShaderBytecode;
|
||||
@@ -113,8 +110,6 @@ internal static unsafe class ID3D12DeviceExtensions
|
||||
d3D12Device.CreateComputePipelineState(
|
||||
&d3D12ComputePipelineStateDescription,
|
||||
Windows.__uuidof<ID3D12PipelineState>(),
|
||||
(void**)d3D12PipelineState.GetAddressOf()).Assert();
|
||||
|
||||
return d3D12PipelineState.Move();
|
||||
(void**)d3D12PipelineState).Assert();
|
||||
}
|
||||
}
|
||||
@@ -98,10 +98,11 @@ internal static unsafe class PipelineDataLoader<T>
|
||||
int root32BitConstantCount = shader.ConstantBufferSize / sizeof(int);
|
||||
|
||||
// Create the D3D12 root signature
|
||||
*d3D12RootSignature = d3D12Device->CreateRootSignature(
|
||||
d3D12Device->CreateRootSignature(
|
||||
root32BitConstantCount,
|
||||
d3D12DescriptorRanges,
|
||||
shader.IsStaticSamplerRequired).Get();
|
||||
shader.IsStaticSamplerRequired,
|
||||
d3D12RootSignature);
|
||||
|
||||
// Return the array to the pool if no exceptions have been thrown
|
||||
if (d3D12DescriptorRangesArray is not null)
|
||||
@@ -124,7 +125,7 @@ internal static unsafe class PipelineDataLoader<T>
|
||||
{
|
||||
D3D12_SHADER_BYTECODE d3D12ShaderBytecode = new(hlslBytecodePtr, (nuint)shader.HlslBytecode.Length);
|
||||
|
||||
*d3D12PipelineState = d3D12Device->CreateComputePipelineState(d3D12RootSignature, d3D12ShaderBytecode);
|
||||
d3D12Device->CreateComputePipelineState(d3D12RootSignature, d3D12ShaderBytecode, d3D12PipelineState);
|
||||
}
|
||||
}
|
||||
}
|
||||
新しいイシューから参照
ユーザーをブロックする