diff --git a/ComputeSharp.sln b/ComputeSharp.sln index f1f78326..5bd3f951 100644 --- a/ComputeSharp.sln +++ b/ComputeSharp.sln @@ -77,6 +77,10 @@ Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "TerraFX.Interop.Windows.Dyn EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ComputeSharp.D2D1Interop", "src\ComputeSharp.D2D1Interop\ComputeSharp.D2D1Interop.csproj", "{4D7D9BA8-A821-4B1C-9EE2-CBCF5849906E}" EndProject +Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "TerraFX.Interop.Windows.D2D1Interop", "src\TerraFX.Interop.Windows.D2D1Interop\TerraFX.Interop.Windows.D2D1Interop.shproj", "{9DA1DA9F-F8B2-4B25-BE80-C21F773029E3}" +EndProject +Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "ComputeSharp.D2D1Interop.NetStandard", "src\ComputeSharp.D2D1Interop.NetStandard\ComputeSharp.D2D1Interop.NetStandard.shproj", "{2608EB41-F98B-4BE5-9F4D-68FED6115088}" +EndProject Global GlobalSection(SharedMSBuildProjectFiles) = preSolution samples\ComputeSharp.SwapChain.Core.Shared\ComputeSharp.SwapChain.Core.Shared.projitems*{0071701e-b9c5-4098-be5f-ef556c4553c6}*SharedItemsImports = 5 @@ -84,13 +88,17 @@ Global samples\ComputeSharp.SwapChain.Shaders.Shared\ComputeSharp.SwapChain.Shaders.Shared.projitems*{0800bd51-499d-44c2-9417-fd1f7fdfe9c4}*SharedItemsImports = 13 src\ComputeSharp.UI\ComputeSharp.UI.projitems*{0c82ede1-5b8a-4df3-87da-700b29d5e265}*SharedItemsImports = 13 src\TerraFX.Interop.Windows.Dynamic\TerraFX.Interop.Windows.Dynamic.projitems*{158f984d-cd96-4062-bd02-2268946031a0}*SharedItemsImports = 13 + src\ComputeSharp.D2D1Interop.NetStandard\ComputeSharp.D2D1Interop.NetStandard.projitems*{2608eb41-f98b-4be5-9f4d-68fed6115088}*SharedItemsImports = 13 src\ComputeSharp.NetStandard\ComputeSharp.NetStandard.projitems*{314eb353-e7e3-4146-8111-685cc83ec1de}*SharedItemsImports = 5 src\TerraFX.Interop.Windows\TerraFX.Interop.Windows.projitems*{314eb353-e7e3-4146-8111-685cc83ec1de}*SharedItemsImports = 5 + src\ComputeSharp.D2D1Interop.NetStandard\ComputeSharp.D2D1Interop.NetStandard.projitems*{4d7d9ba8-a821-4b1c-9ee2-cbcf5849906e}*SharedItemsImports = 5 + src\TerraFX.Interop.Windows.D2D1Interop\TerraFX.Interop.Windows.D2D1Interop.projitems*{4d7d9ba8-a821-4b1c-9ee2-cbcf5849906e}*SharedItemsImports = 5 src\TerraFX.Interop.Windows\TerraFX.Interop.Windows.projitems*{514ff00e-bbf0-4d55-a47c-eeeb6208adce}*SharedItemsImports = 13 samples\ComputeSharp.Sample.Shared\ComputeSharp.Sample.Shared.projitems*{7048deea-0a6f-46a0-b951-b682a8f1cb75}*SharedItemsImports = 5 samples\ComputeSharp.SwapChain.Core.Shared\ComputeSharp.SwapChain.Core.Shared.projitems*{751bb05b-563d-4b3a-94c6-15e2d79d35ea}*SharedItemsImports = 13 src\TerraFX.Interop.Windows.Dynamic\TerraFX.Interop.Windows.Dynamic.projitems*{76c66257-fdaa-47ab-85e7-ef757eab10c0}*SharedItemsImports = 5 samples\ComputeSharp.Sample.Shared\ComputeSharp.Sample.Shared.projitems*{8cefc324-ca6c-4845-9ad9-70b92bd87057}*SharedItemsImports = 13 + src\TerraFX.Interop.Windows.D2D1Interop\TerraFX.Interop.Windows.D2D1Interop.projitems*{9da1da9f-f8b2-4b25-be80-c21f773029e3}*SharedItemsImports = 13 src\ComputeSharp.NetStandard\ComputeSharp.NetStandard.projitems*{a5997814-d8d2-4541-87ac-c3e53caa67c0}*SharedItemsImports = 13 src\ComputeSharp.UI\ComputeSharp.UI.projitems*{afaafdc9-be42-45d4-8c79-0ee8c8edbf52}*SharedItemsImports = 5 samples\ComputeSharp.SwapChain.Shaders.Shared\ComputeSharp.SwapChain.Shaders.Shared.projitems*{e7c9247d-016b-4819-af9f-0e9b3591e04b}*SharedItemsImports = 5 @@ -375,7 +383,8 @@ Global {751BB05B-563D-4B3A-94C6-15E2D79D35EA} = {0ED8F632-5E17-46BE-8CC3-B14A82D4AEB1} {4A8FCE22-851C-442A-8BC9-3EC3FD00B637} = {F8EFBB27-4EE2-4463-A75B-7EFDFB55D0F7} {158F984D-CD96-4062-BD02-2268946031A0} = {8DCE343F-BA78-4FE1-B562-B57C603A8BAA} - {6892B4F9-163D-4F08-9910-114C2A3B986F} = {8DCE343F-BA78-4FE1-B562-B57C603A8BAA} + {9DA1DA9F-F8B2-4B25-BE80-C21F773029E3} = {8DCE343F-BA78-4FE1-B562-B57C603A8BAA} + {2608EB41-F98B-4BE5-9F4D-68FED6115088} = {8DCE343F-BA78-4FE1-B562-B57C603A8BAA} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {4664C5E3-0340-4E22-BCFD-98AAEDF5F2DC} diff --git a/src/ComputeSharp.D2D1Interop.NetStandard/ComputeSharp.D2D1Interop.NetStandard.projitems b/src/ComputeSharp.D2D1Interop.NetStandard/ComputeSharp.D2D1Interop.NetStandard.projitems new file mode 100644 index 00000000..f8dad006 --- /dev/null +++ b/src/ComputeSharp.D2D1Interop.NetStandard/ComputeSharp.D2D1Interop.NetStandard.projitems @@ -0,0 +1,14 @@ + + + + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) + true + 2608eb41-f98b-4be5-9f4d-68fed6115088 + + + ComputeSharp.D2D1Interop.NetStandard + + + + + \ No newline at end of file diff --git a/src/ComputeSharp.D2D1Interop.NetStandard/ComputeSharp.D2D1Interop.NetStandard.shproj b/src/ComputeSharp.D2D1Interop.NetStandard/ComputeSharp.D2D1Interop.NetStandard.shproj new file mode 100644 index 00000000..a0343881 --- /dev/null +++ b/src/ComputeSharp.D2D1Interop.NetStandard/ComputeSharp.D2D1Interop.NetStandard.shproj @@ -0,0 +1,13 @@ + + + + 2608eb41-f98b-4be5-9f4d-68fed6115088 + 14.0 + + + + + + + + diff --git a/src/ComputeSharp.D2D1Interop.NetStandard/System.Runtime.CompilerServices/RuntimeHelpers.cs b/src/ComputeSharp.D2D1Interop.NetStandard/System.Runtime.CompilerServices/RuntimeHelpers.cs new file mode 100644 index 00000000..3f99a60d --- /dev/null +++ b/src/ComputeSharp.D2D1Interop.NetStandard/System.Runtime.CompilerServices/RuntimeHelpers.cs @@ -0,0 +1,18 @@ +using System; +using System.Runtime.InteropServices; + +namespace ComputeSharp.D2D1Interop.NetStandard.System.Runtime.CompilerServices; + +/// +/// A polyfill type that mirrors some methods from on .NET 5. +/// +internal static class RuntimeHelpers +{ + /// + /// Allocates some memory tied to the lifetime of a specific type. + /// + /// The type to associate the memory to. + /// The size in byte of the memory to allocate. + /// A pointer to the allocated memory. + public static IntPtr AllocateTypeAssociatedMemory(Type type, int size) => Marshal.AllocHGlobal(size); +} \ No newline at end of file diff --git a/src/ComputeSharp.D2D1Interop/ComputeSharp.D2D1Interop.csproj b/src/ComputeSharp.D2D1Interop/ComputeSharp.D2D1Interop.csproj index 16e8e2af..2c78a08b 100644 --- a/src/ComputeSharp.D2D1Interop/ComputeSharp.D2D1Interop.csproj +++ b/src/ComputeSharp.D2D1Interop/ComputeSharp.D2D1Interop.csproj @@ -8,10 +8,12 @@ - true true + + + false - - - + + + diff --git a/src/ComputeSharp.D2D1Interop/Extensions/ComPtrExtensions.cs b/src/ComputeSharp.D2D1Interop/Extensions/ComPtrExtensions.cs index 6abbb717..f2f181b6 100644 --- a/src/ComputeSharp.D2D1Interop/Extensions/ComPtrExtensions.cs +++ b/src/ComputeSharp.D2D1Interop/Extensions/ComPtrExtensions.cs @@ -18,7 +18,7 @@ internal static class ComPtrExtensions /// This method is only valid when the current instance is on the stack or pinned. [MethodImpl(MethodImplOptions.AggressiveInlining)] public static unsafe void** GetVoidAddressOf(this in ComPtr ptr) - where T : unmanaged, IUnknown.Interface + where T : unmanaged { return (void**)Unsafe.AsPointer(ref Unsafe.AsRef(in ptr)); } @@ -31,7 +31,7 @@ internal static class ComPtrExtensions /// The moved instance. [MethodImpl(MethodImplOptions.AggressiveInlining)] public static unsafe ComPtr Move(this in ComPtr ptr) - where T : unmanaged, IUnknown.Interface + where T : unmanaged { ComPtr copy = default; diff --git a/src/TerraFX.Interop.Windows.D2D1Interop/DirectX/um/d2d1effectauthor/ID2D1DrawInfo.cs b/src/TerraFX.Interop.Windows.D2D1Interop/DirectX/um/d2d1effectauthor/ID2D1DrawInfo.cs new file mode 100644 index 00000000..1d6dce80 --- /dev/null +++ b/src/TerraFX.Interop.Windows.D2D1Interop/DirectX/um/d2d1effectauthor/ID2D1DrawInfo.cs @@ -0,0 +1,29 @@ +// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information. + +// Ported from um/d2d1effectauthor.h in the Windows SDK for Windows 10.0.22000.0 +// Original source is Copyright © Microsoft. All rights reserved. + +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using TerraFX.Interop.Windows; + +#pragma warning disable CS0649 + +namespace TerraFX.Interop.DirectX +{ + [Guid("693CE632-7F2F-45DE-93FE-18D88B37AA21")] + [NativeTypeName("struct ID2D1DrawInfo : ID2D1RenderInfo")] + [NativeInheritance("ID2D1RenderInfo")] + internal unsafe partial struct ID2D1DrawInfo + { + public void** lpVtbl; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + [VtblIndex(7)] + public HRESULT SetPixelShaderConstantBuffer([NativeTypeName("const BYTE *")] byte* buffer, [NativeTypeName("UINT32")] uint bufferCount) + { + return ((delegate* unmanaged)(lpVtbl[7]))((ID2D1DrawInfo*)Unsafe.AsPointer(ref this), buffer, bufferCount); + } + } +} \ No newline at end of file diff --git a/src/TerraFX.Interop.Windows.D2D1Interop/DirectX/um/d3d11shadeer/D3D11_SHADER_DESC.cs b/src/TerraFX.Interop.Windows.D2D1Interop/DirectX/um/d3d11shadeer/D3D11_SHADER_DESC.cs new file mode 100644 index 00000000..2bb5b6cf --- /dev/null +++ b/src/TerraFX.Interop.Windows.D2D1Interop/DirectX/um/d3d11shadeer/D3D11_SHADER_DESC.cs @@ -0,0 +1,87 @@ +// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information. + +// Ported from um/d3d11shader.h in the Windows SDK for Windows 10.0.22000.0 +// Original source is Copyright © Microsoft. All rights reserved. + +namespace TerraFX.Interop.DirectX +{ + internal unsafe partial struct D3D11_SHADER_DESC + { + public uint Version; + + [NativeTypeName("LPCSTR")] + public sbyte* Creator; + + public uint Flags; + + public uint ConstantBuffers; + + public uint BoundResources; + + public uint InputParameters; + + public uint OutputParameters; + + public uint InstructionCount; + + public uint TempRegisterCount; + + public uint TempArrayCount; + + public uint DefCount; + + public uint DclCount; + + public uint TextureNormalInstructions; + + public uint TextureLoadInstructions; + + public uint TextureCompInstructions; + + public uint TextureBiasInstructions; + + public uint TextureGradientInstructions; + + public uint FloatInstructionCount; + + public uint IntInstructionCount; + + public uint UintInstructionCount; + + public uint StaticFlowControlCount; + + public uint DynamicFlowControlCount; + + public uint MacroInstructionCount; + + public uint ArrayInstructionCount; + + public uint CutInstructionCount; + + public uint EmitInstructionCount; + + public D3D_PRIMITIVE_TOPOLOGY GSOutputTopology; + + public uint GSMaxOutputVertexCount; + + public D3D_PRIMITIVE InputPrimitive; + + public uint PatchConstantParameters; + + public uint cGSInstanceCount; + + public uint cControlPoints; + + public D3D_TESSELLATOR_OUTPUT_PRIMITIVE HSOutputPrimitive; + + public D3D_TESSELLATOR_PARTITIONING HSPartitioning; + + public D3D_TESSELLATOR_DOMAIN TessellatorDomain; + + public uint cBarrierInstructions; + + public uint cInterlockedInstructions; + + public uint cTextureStoreInstructions; + } +} \ No newline at end of file diff --git a/src/TerraFX.Interop.Windows.D2D1Interop/DirectX/um/d3d11shadeer/ID3D11ShaderReflection.cs b/src/TerraFX.Interop.Windows.D2D1Interop/DirectX/um/d3d11shadeer/ID3D11ShaderReflection.cs new file mode 100644 index 00000000..fa515209 --- /dev/null +++ b/src/TerraFX.Interop.Windows.D2D1Interop/DirectX/um/d3d11shadeer/ID3D11ShaderReflection.cs @@ -0,0 +1,112 @@ +// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information. + +// Ported from um/d3d11shader.h in the Windows SDK for Windows 10.0.22000.0 +// Original source is Copyright © Microsoft. All rights reserved. + +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using TerraFX.Interop.Windows; + +#pragma warning disable CS0649 + +namespace TerraFX.Interop.DirectX +{ + [Guid("8D536CA1-0CCA-4956-A837-786963755584")] + [NativeTypeName("struct ID3D11ShaderReflection : IUnknown")] + [NativeInheritance("IUnknown")] + internal unsafe partial struct ID3D11ShaderReflection + { + public void** lpVtbl; + + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + [VtblIndex(0)] + public HRESULT QueryInterface([NativeTypeName("const IID &")] Guid* riid, void** ppvObject) + { + return ((delegate* unmanaged)(lpVtbl[0]))((ID3D11ShaderReflection*)Unsafe.AsPointer(ref this), riid, ppvObject); + } + + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + [VtblIndex(1)] + [return: NativeTypeName("ULONG")] + public uint AddRef() + { + return ((delegate* unmanaged)(lpVtbl[1]))((ID3D11ShaderReflection*)Unsafe.AsPointer(ref this)); + } + + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + [VtblIndex(2)] + [return: NativeTypeName("ULONG")] + public uint Release() + { + return ((delegate* unmanaged)(lpVtbl[2]))((ID3D11ShaderReflection*)Unsafe.AsPointer(ref this)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + [VtblIndex(3)] + public HRESULT GetDesc(D3D11_SHADER_DESC* pDesc) + { + return ((delegate* unmanaged)(lpVtbl[3]))((ID3D11ShaderReflection*)Unsafe.AsPointer(ref this), pDesc); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + [VtblIndex(12)] + public uint GetMovInstructionCount() + { + return ((delegate* unmanaged)(lpVtbl[12]))((ID3D11ShaderReflection*)Unsafe.AsPointer(ref this)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + [VtblIndex(13)] + public uint GetMovcInstructionCount() + { + return ((delegate* unmanaged)(lpVtbl[13]))((ID3D11ShaderReflection*)Unsafe.AsPointer(ref this)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + [VtblIndex(14)] + public uint GetConversionInstructionCount() + { + return ((delegate* unmanaged)(lpVtbl[14]))((ID3D11ShaderReflection*)Unsafe.AsPointer(ref this)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + [VtblIndex(15)] + public uint GetBitwiseInstructionCount() + { + return ((delegate* unmanaged)(lpVtbl[15]))((ID3D11ShaderReflection*)Unsafe.AsPointer(ref this)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + [VtblIndex(16)] + public D3D_PRIMITIVE GetGSInputPrimitive() + { + return ((delegate* unmanaged)(lpVtbl[16]))((ID3D11ShaderReflection*)Unsafe.AsPointer(ref this)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + [VtblIndex(18)] + public uint GetNumInterfaceSlots() + { + return ((delegate* unmanaged)(lpVtbl[18]))((ID3D11ShaderReflection*)Unsafe.AsPointer(ref this)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + [VtblIndex(20)] + public uint GetThreadGroupSize(uint* pSizeX, uint* pSizeY, uint* pSizeZ) + { + return ((delegate* unmanaged)(lpVtbl[20]))((ID3D11ShaderReflection*)Unsafe.AsPointer(ref this), pSizeX, pSizeY, pSizeZ); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + [VtblIndex(21)] + [return: NativeTypeName("UINT64")] + public ulong GetRequiresFlags() + { + return ((delegate* unmanaged)(lpVtbl[21]))((ID3D11ShaderReflection*)Unsafe.AsPointer(ref this)); + } + } +} \ No newline at end of file diff --git a/src/TerraFX.Interop.Windows.D2D1Interop/DirectX/um/d3dcommon/D3D_SHADER_MACRO.cs b/src/TerraFX.Interop.Windows.D2D1Interop/DirectX/um/d3dcommon/D3D_SHADER_MACRO.cs new file mode 100644 index 00000000..d1c4c0ec --- /dev/null +++ b/src/TerraFX.Interop.Windows.D2D1Interop/DirectX/um/d3dcommon/D3D_SHADER_MACRO.cs @@ -0,0 +1,16 @@ +// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information. + +// Ported from d3dcommon.h in Microsoft.Direct3D.D3D12 v1.600.10 +// Original source is Copyright © Microsoft. Licensed under the MIT license + +namespace TerraFX.Interop.DirectX +{ + internal unsafe partial struct D3D_SHADER_MACRO + { + [NativeTypeName("LPCSTR")] + public sbyte* Name; + + [NativeTypeName("LPCSTR")] + public sbyte* Definition; + } +} \ No newline at end of file diff --git a/src/TerraFX.Interop.Windows.D2D1Interop/DirectX/um/d3dcompiler/D3DCOMPILE.cs b/src/TerraFX.Interop.Windows.D2D1Interop/DirectX/um/d3dcompiler/D3DCOMPILE.cs new file mode 100644 index 00000000..a7841e13 --- /dev/null +++ b/src/TerraFX.Interop.Windows.D2D1Interop/DirectX/um/d3dcompiler/D3DCOMPILE.cs @@ -0,0 +1,112 @@ +// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information. + +// Ported from um/d3dcompiler.h in the Windows SDK for Windows 10.0.22000.0 +// Original source is Copyright © Microsoft. All rights reserved. + +namespace TerraFX.Interop.DirectX +{ + internal static partial class D3DCOMPILE + { + [NativeTypeName("#define D3DCOMPILE_DEBUG (1 << 0)")] + public const int D3DCOMPILE_DEBUG = (1 << 0); + + [NativeTypeName("#define D3DCOMPILE_SKIP_VALIDATION (1 << 1)")] + public const int D3DCOMPILE_SKIP_VALIDATION = (1 << 1); + + [NativeTypeName("#define D3DCOMPILE_SKIP_OPTIMIZATION (1 << 2)")] + public const int D3DCOMPILE_SKIP_OPTIMIZATION = (1 << 2); + + [NativeTypeName("#define D3DCOMPILE_PACK_MATRIX_ROW_MAJOR (1 << 3)")] + public const int D3DCOMPILE_PACK_MATRIX_ROW_MAJOR = (1 << 3); + + [NativeTypeName("#define D3DCOMPILE_PACK_MATRIX_COLUMN_MAJOR (1 << 4)")] + public const int D3DCOMPILE_PACK_MATRIX_COLUMN_MAJOR = (1 << 4); + + [NativeTypeName("#define D3DCOMPILE_PARTIAL_PRECISION (1 << 5)")] + public const int D3DCOMPILE_PARTIAL_PRECISION = (1 << 5); + + [NativeTypeName("#define D3DCOMPILE_FORCE_VS_SOFTWARE_NO_OPT (1 << 6)")] + public const int D3DCOMPILE_FORCE_VS_SOFTWARE_NO_OPT = (1 << 6); + + [NativeTypeName("#define D3DCOMPILE_FORCE_PS_SOFTWARE_NO_OPT (1 << 7)")] + public const int D3DCOMPILE_FORCE_PS_SOFTWARE_NO_OPT = (1 << 7); + + [NativeTypeName("#define D3DCOMPILE_NO_PRESHADER (1 << 8)")] + public const int D3DCOMPILE_NO_PRESHADER = (1 << 8); + + [NativeTypeName("#define D3DCOMPILE_AVOID_FLOW_CONTROL (1 << 9)")] + public const int D3DCOMPILE_AVOID_FLOW_CONTROL = (1 << 9); + + [NativeTypeName("#define D3DCOMPILE_PREFER_FLOW_CONTROL (1 << 10)")] + public const int D3DCOMPILE_PREFER_FLOW_CONTROL = (1 << 10); + + [NativeTypeName("#define D3DCOMPILE_ENABLE_STRICTNESS (1 << 11)")] + public const int D3DCOMPILE_ENABLE_STRICTNESS = (1 << 11); + + [NativeTypeName("#define D3DCOMPILE_ENABLE_BACKWARDS_COMPATIBILITY (1 << 12)")] + public const int D3DCOMPILE_ENABLE_BACKWARDS_COMPATIBILITY = (1 << 12); + + [NativeTypeName("#define D3DCOMPILE_IEEE_STRICTNESS (1 << 13)")] + public const int D3DCOMPILE_IEEE_STRICTNESS = (1 << 13); + + [NativeTypeName("#define D3DCOMPILE_OPTIMIZATION_LEVEL0 (1 << 14)")] + public const int D3DCOMPILE_OPTIMIZATION_LEVEL0 = (1 << 14); + + [NativeTypeName("#define D3DCOMPILE_OPTIMIZATION_LEVEL1 0")] + public const int D3DCOMPILE_OPTIMIZATION_LEVEL1 = 0; + + [NativeTypeName("#define D3DCOMPILE_OPTIMIZATION_LEVEL2 ((1 << 14) | (1 << 15))")] + public const int D3DCOMPILE_OPTIMIZATION_LEVEL2 = ((1 << 14) | (1 << 15)); + + [NativeTypeName("#define D3DCOMPILE_OPTIMIZATION_LEVEL3 (1 << 15)")] + public const int D3DCOMPILE_OPTIMIZATION_LEVEL3 = (1 << 15); + + [NativeTypeName("#define D3DCOMPILE_RESERVED16 (1 << 16)")] + public const int D3DCOMPILE_RESERVED16 = (1 << 16); + + [NativeTypeName("#define D3DCOMPILE_RESERVED17 (1 << 17)")] + public const int D3DCOMPILE_RESERVED17 = (1 << 17); + + [NativeTypeName("#define D3DCOMPILE_WARNINGS_ARE_ERRORS (1 << 18)")] + public const int D3DCOMPILE_WARNINGS_ARE_ERRORS = (1 << 18); + + [NativeTypeName("#define D3DCOMPILE_RESOURCES_MAY_ALIAS (1 << 19)")] + public const int D3DCOMPILE_RESOURCES_MAY_ALIAS = (1 << 19); + + [NativeTypeName("#define D3DCOMPILE_ENABLE_UNBOUNDED_DESCRIPTOR_TABLES (1 << 20)")] + public const int D3DCOMPILE_ENABLE_UNBOUNDED_DESCRIPTOR_TABLES = (1 << 20); + + [NativeTypeName("#define D3DCOMPILE_ALL_RESOURCES_BOUND (1 << 21)")] + public const int D3DCOMPILE_ALL_RESOURCES_BOUND = (1 << 21); + + [NativeTypeName("#define D3DCOMPILE_DEBUG_NAME_FOR_SOURCE (1 << 22)")] + public const int D3DCOMPILE_DEBUG_NAME_FOR_SOURCE = (1 << 22); + + [NativeTypeName("#define D3DCOMPILE_DEBUG_NAME_FOR_BINARY (1 << 23)")] + public const int D3DCOMPILE_DEBUG_NAME_FOR_BINARY = (1 << 23); + + [NativeTypeName("#define D3DCOMPILE_EFFECT_CHILD_EFFECT (1 << 0)")] + public const int D3DCOMPILE_EFFECT_CHILD_EFFECT = (1 << 0); + + [NativeTypeName("#define D3DCOMPILE_EFFECT_ALLOW_SLOW_OPS (1 << 1)")] + public const int D3DCOMPILE_EFFECT_ALLOW_SLOW_OPS = (1 << 1); + + [NativeTypeName("#define D3DCOMPILE_FLAGS2_FORCE_ROOT_SIGNATURE_LATEST 0")] + public const int D3DCOMPILE_FLAGS2_FORCE_ROOT_SIGNATURE_LATEST = 0; + + [NativeTypeName("#define D3DCOMPILE_FLAGS2_FORCE_ROOT_SIGNATURE_1_0 (1 << 4)")] + public const int D3DCOMPILE_FLAGS2_FORCE_ROOT_SIGNATURE_1_0 = (1 << 4); + + [NativeTypeName("#define D3DCOMPILE_FLAGS2_FORCE_ROOT_SIGNATURE_1_1 (1 << 5)")] + public const int D3DCOMPILE_FLAGS2_FORCE_ROOT_SIGNATURE_1_1 = (1 << 5); + + [NativeTypeName("#define D3DCOMPILE_SECDATA_MERGE_UAV_SLOTS 0x00000001")] + public const int D3DCOMPILE_SECDATA_MERGE_UAV_SLOTS = 0x00000001; + + [NativeTypeName("#define D3DCOMPILE_SECDATA_PRESERVE_TEMPLATE_SLOTS 0x00000002")] + public const int D3DCOMPILE_SECDATA_PRESERVE_TEMPLATE_SLOTS = 0x00000002; + + [NativeTypeName("#define D3DCOMPILE_SECDATA_REQUIRE_TEMPLATE_MATCH 0x00000004")] + public const int D3DCOMPILE_SECDATA_REQUIRE_TEMPLATE_MATCH = 0x00000004; + } +} \ No newline at end of file diff --git a/src/TerraFX.Interop.Windows.D2D1Interop/DirectX/um/d3dcompiler/D3D_BLOB_PART.cs b/src/TerraFX.Interop.Windows.D2D1Interop/DirectX/um/d3dcompiler/D3D_BLOB_PART.cs new file mode 100644 index 00000000..f61ad7ee --- /dev/null +++ b/src/TerraFX.Interop.Windows.D2D1Interop/DirectX/um/d3dcompiler/D3D_BLOB_PART.cs @@ -0,0 +1,44 @@ +// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information. + +// Ported from um/d3dcompiler.h in the Windows SDK for Windows 10.0.22000.0 +// Original source is Copyright © Microsoft. All rights reserved. + +namespace TerraFX.Interop.DirectX +{ + internal enum D3D_BLOB_PART + { + D3D_BLOB_INPUT_SIGNATURE_BLOB, + + D3D_BLOB_OUTPUT_SIGNATURE_BLOB, + + D3D_BLOB_INPUT_AND_OUTPUT_SIGNATURE_BLOB, + + D3D_BLOB_PATCH_CONSTANT_SIGNATURE_BLOB, + + D3D_BLOB_ALL_SIGNATURE_BLOB, + + D3D_BLOB_DEBUG_INFO, + + D3D_BLOB_LEGACY_SHADER, + + D3D_BLOB_XNA_PREPASS_SHADER, + + D3D_BLOB_XNA_SHADER, + + D3D_BLOB_PDB, + + D3D_BLOB_PRIVATE_DATA, + + D3D_BLOB_ROOT_SIGNATURE, + + D3D_BLOB_DEBUG_NAME, + + D3D_BLOB_TEST_ALTERNATE_SHADER = 0x8000, + + D3D_BLOB_TEST_COMPILE_DETAILS, + + D3D_BLOB_TEST_COMPILE_PERF, + + D3D_BLOB_TEST_COMPILE_REPORT, + } +} \ No newline at end of file diff --git a/src/TerraFX.Interop.Windows.D2D1Interop/DirectX/um/d3dcompiler/DirectX.cs b/src/TerraFX.Interop.Windows.D2D1Interop/DirectX/um/d3dcompiler/DirectX.cs new file mode 100644 index 00000000..ba483f7e --- /dev/null +++ b/src/TerraFX.Interop.Windows.D2D1Interop/DirectX/um/d3dcompiler/DirectX.cs @@ -0,0 +1,23 @@ +// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information. + +// Ported from um/d3dcompiler.h in the Windows SDK for Windows 10.0.22000.0 +// Original source is Copyright © Microsoft. All rights reserved. + +using System; +using System.Runtime.InteropServices; +using TerraFX.Interop.Windows; + +namespace TerraFX.Interop.DirectX +{ + internal static unsafe partial class DirectX + { + [DllImport("d3dcompiler_47", ExactSpelling = true)] + public static extern HRESULT D3DCompile([NativeTypeName("LPCVOID")] void* pSrcData, [NativeTypeName("SIZE_T")] nuint SrcDataSize, [NativeTypeName("LPCSTR")] sbyte* pSourceName, [NativeTypeName("const D3D_SHADER_MACRO *")] D3D_SHADER_MACRO* pDefines, [NativeTypeName("const ID3DInclude *")] void* pInclude, [NativeTypeName("LPCSTR")] sbyte* pEntrypoint, [NativeTypeName("LPCSTR")] sbyte* pTarget, uint Flags1, uint Flags2, ID3DBlob** ppCode, ID3DBlob** ppErrorMsgs); + + [DllImport("d3dcompiler_47", ExactSpelling = true)] + public static extern HRESULT D3DReflect([NativeTypeName("LPCVOID")] void* pSrcData, [NativeTypeName("SIZE_T")] nuint SrcDataSize, [NativeTypeName("const IID &")] Guid* pInterface, void** ppReflector); + + [DllImport("d3dcompiler_47", ExactSpelling = true)] + public static extern HRESULT D3DSetBlobPart([NativeTypeName("LPCVOID")] void* pSrcData, [NativeTypeName("SIZE_T")] nuint SrcDataSize, D3D_BLOB_PART Part, uint Flags, [NativeTypeName("LPCVOID")] void* pPart, [NativeTypeName("SIZE_T")] nuint PartSize, ID3DBlob** ppNewShader); + } +} \ No newline at end of file diff --git a/src/TerraFX.Interop.Windows.D2D1Interop/TerraFX.Interop.Windows.D2D1Interop.projitems b/src/TerraFX.Interop.Windows.D2D1Interop/TerraFX.Interop.Windows.D2D1Interop.projitems new file mode 100644 index 00000000..c2cd1a61 --- /dev/null +++ b/src/TerraFX.Interop.Windows.D2D1Interop/TerraFX.Interop.Windows.D2D1Interop.projitems @@ -0,0 +1,35 @@ + + + + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) + true + 9da1da9f-f8b2-4b25-be80-c21f773029e3 + + + TerraFX.Interop.Windows.D2D1Interop + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/TerraFX.Interop.Windows.D2D1Interop/TerraFX.Interop.Windows.D2D1Interop.shproj b/src/TerraFX.Interop.Windows.D2D1Interop/TerraFX.Interop.Windows.D2D1Interop.shproj new file mode 100644 index 00000000..00af33c8 --- /dev/null +++ b/src/TerraFX.Interop.Windows.D2D1Interop/TerraFX.Interop.Windows.D2D1Interop.shproj @@ -0,0 +1,13 @@ + + + + 9da1da9f-f8b2-4b25-be80-c21f773029e3 + 14.0 + + + + + + + + diff --git a/src/TerraFX.Interop.Windows.D2D1Interop/Windows/shared/uuids/Windows.Manual.cs b/src/TerraFX.Interop.Windows.D2D1Interop/Windows/shared/uuids/Windows.Manual.cs new file mode 100644 index 00000000..779ae778 --- /dev/null +++ b/src/TerraFX.Interop.Windows.D2D1Interop/Windows/shared/uuids/Windows.Manual.cs @@ -0,0 +1,90 @@ +// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information. + +// Ported from shared/uuids.h in the Windows SDK for Windows 10.0.20348.0 +// Original source is Copyright © Microsoft. All rights reserved. + +using System; +using System.ComponentModel; +using System.Runtime.CompilerServices; +#if NET6_0_OR_GREATER +using RuntimeHelpers = System.Runtime.CompilerServices.RuntimeHelpers; +#else +using RuntimeHelpers = ComputeSharp.D2D1Interop.NetStandard.System.Runtime.CompilerServices.RuntimeHelpers; +#endif + +namespace TerraFX.Interop.Windows +{ + internal static partial class Windows + { + /// Retrieves the GUID of of a specified type. + /// A value of type . + /// The type to retrieve the GUID for. + /// A value wrapping a pointer to the GUID data for the input type. This value can be either converted to a pointer, or implicitly assigned to a value. + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static unsafe UuidOfType __uuidof(T value) // for type inference similar to C++'s __uuidof + where T : unmanaged + { + return new UuidOfType(UUID.RIID); + } + + /// Retrieves the GUID of of a specified type. + /// A pointer to a value of type . + /// The type to retrieve the GUID for. + /// A value wrapping a pointer to the GUID data for the input type. This value can be either converted to a pointer, or implicitly assigned to a value. + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static unsafe UuidOfType __uuidof(T* value) // for type inference similar to C++'s __uuidof + where T : unmanaged + { + return new UuidOfType(UUID.RIID); + } + + /// Retrieves the GUID of of a specified type. + /// The type to retrieve the GUID for. + /// A value wrapping a pointer to the GUID data for the input type. This value can be either converted to a pointer, or implicitly assigned to a value. + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static unsafe UuidOfType __uuidof() + where T : unmanaged + { + return new UuidOfType(UUID.RIID); + } + + /// A proxy type that wraps a pointer to GUID data. Values of this type can be implicitly converted to and assigned to * or parameters. + [EditorBrowsable(EditorBrowsableState.Never)] + public readonly unsafe ref struct UuidOfType + { + private readonly Guid* riid; + + internal UuidOfType(Guid* riid) + { + this.riid = riid; + } + + /// Reads a value from the GUID buffer for a given instance. + /// The input instance to read data for. + public static implicit operator Guid(UuidOfType guid) => *guid.riid; + + /// Returns the * pointer to the GUID buffer for a given instance. + /// The input instance to read data for. + public static implicit operator Guid*(UuidOfType guid) => guid.riid; + } + + /// A helper type to provide static GUID buffers for specific types. + /// The type to allocate a GUID buffer for. + private static unsafe class UUID + where T : unmanaged + { + /// The pointer to the value for the current type. + /// The target memory area should never be written to. + public static readonly Guid* RIID = CreateRIID(); + + /// Allocates memory for a value and initializes it. + /// A pointer to memory holding the value for the current type. + private static Guid* CreateRIID() + { + var p = (Guid*)RuntimeHelpers.AllocateTypeAssociatedMemory(typeof(T), sizeof(Guid)); + *p = typeof(T).GUID; + return p; + } + } + } +} diff --git a/src/TerraFX.Interop.Windows/DirectX/um/d3d11shader/D3D.cs b/src/TerraFX.Interop.Windows/DirectX/um/d3d11shader/D3D.cs index 1bb7a5a9..2f63108a 100644 --- a/src/TerraFX.Interop.Windows/DirectX/um/d3d11shader/D3D.cs +++ b/src/TerraFX.Interop.Windows/DirectX/um/d3d11shader/D3D.cs @@ -5,7 +5,7 @@ namespace TerraFX.Interop.DirectX { - public static partial class D3D + internal static partial class D3D { [NativeTypeName("#define D3D_SHADER_REQUIRES_DOUBLES 0x00000001")] public const int D3D_SHADER_REQUIRES_DOUBLES = 0x00000001; diff --git a/src/TerraFX.Interop.Windows/DirectX/um/d3dcommon/ID3DBlob.cs b/src/TerraFX.Interop.Windows/DirectX/um/d3dcommon/ID3DBlob.cs index d4f4c705..5eebe81e 100644 --- a/src/TerraFX.Interop.Windows/DirectX/um/d3dcommon/ID3DBlob.cs +++ b/src/TerraFX.Interop.Windows/DirectX/um/d3dcommon/ID3DBlob.cs @@ -8,6 +8,8 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using TerraFX.Interop.Windows; +#pragma warning disable CS0649 + namespace TerraFX.Interop.DirectX { [Guid("8BA5FB08-5195-40E2-AC58-0D989C3A0102")] diff --git a/src/TerraFX.Interop.Windows/Windows/um/Unknwnbase/IUnknown.cs b/src/TerraFX.Interop.Windows/Windows/um/Unknwnbase/IUnknown.cs index f5226076..10af550b 100644 --- a/src/TerraFX.Interop.Windows/Windows/um/Unknwnbase/IUnknown.cs +++ b/src/TerraFX.Interop.Windows/Windows/um/Unknwnbase/IUnknown.cs @@ -7,6 +7,8 @@ using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; +#pragma warning disable CS0649 + namespace TerraFX.Interop.Windows { [Guid("00000000-0000-0000-C000-000000000046")]