diff --git a/src/ComputeSharp.D2D1Interop.NetStandard/ComputeSharp.D2D1Interop.NetStandard.projitems b/src/ComputeSharp.D2D1Interop.NetStandard/ComputeSharp.D2D1Interop.NetStandard.projitems
index 6221a613..1148036b 100644
--- a/src/ComputeSharp.D2D1Interop.NetStandard/ComputeSharp.D2D1Interop.NetStandard.projitems
+++ b/src/ComputeSharp.D2D1Interop.NetStandard/ComputeSharp.D2D1Interop.NetStandard.projitems
@@ -10,8 +10,10 @@
-
-
+
+
+
+
\ No newline at end of file
diff --git a/src/ComputeSharp.D2D1Interop.NetStandard/System/Runtime.CompilerServices/RuntimeHelpers.cs b/src/ComputeSharp.D2D1Interop.NetStandard/System/Runtime/CompilerServices/RuntimeHelpers.cs
similarity index 100%
rename from src/ComputeSharp.D2D1Interop.NetStandard/System/Runtime.CompilerServices/RuntimeHelpers.cs
rename to src/ComputeSharp.D2D1Interop.NetStandard/System/Runtime/CompilerServices/RuntimeHelpers.cs
diff --git a/src/ComputeSharp.D2D1Interop/ComputeSharp.D2D1Interop.csproj b/src/ComputeSharp.D2D1Interop/ComputeSharp.D2D1Interop.csproj
index 97d76ead..6679dc5a 100644
--- a/src/ComputeSharp.D2D1Interop/ComputeSharp.D2D1Interop.csproj
+++ b/src/ComputeSharp.D2D1Interop/ComputeSharp.D2D1Interop.csproj
@@ -5,6 +5,12 @@
ComputeSharp.D2D1Interop.xml
AnyCPU;x64;ARM64
+
+
+
+
+
+
diff --git a/src/ComputeSharp.D2D1Interop/Shaders/Translation/D2D1ShaderCompiler.ID3DInclude.cs b/src/ComputeSharp.D2D1Interop/Shaders/Translation/D2D1ShaderCompiler.ID3DInclude.cs
new file mode 100644
index 00000000..e1e0ac8c
--- /dev/null
+++ b/src/ComputeSharp.D2D1Interop/Shaders/Translation/D2D1ShaderCompiler.ID3DInclude.cs
@@ -0,0 +1,149 @@
+using System;
+using System.IO;
+using System.Reflection;
+using System.Runtime.InteropServices;
+using TerraFX.Interop.DirectX;
+using TerraFX.Interop.Windows;
+#if NET6_0_OR_GREATER
+using RuntimeHelpers = System.Runtime.CompilerServices.RuntimeHelpers;
+#else
+using RuntimeHelpers = ComputeSharp.D2D1Interop.NetStandard.System.Runtime.CompilerServices.RuntimeHelpers;
+using UnmanagedCallersOnlyAttribute = ComputeSharp.NetStandard.System.Runtime.InteropServices.UnmanagedCallersOnlyAttribute;
+#endif
+
+namespace ComputeSharp.D2D1Interop.Shaders.Translation;
+
+///
+partial class D2D1ShaderCompiler
+{
+ ///
+ /// A custom fallback implementation to use on systems with no support for it.
+ ///
+ private unsafe struct ID3DIncludeForD2DHelpers
+ {
+#if !NET6_0_OR_GREATER
+ ///
+ [UnmanagedFunctionPointer(CallingConvention.StdCall)]
+ private delegate int OpenDelegate(ID3DIncludeForD2DHelpers* @this, D3D_INCLUDE_TYPE IncludeType, sbyte* pFileName, void* pParentData, void** ppData, uint* pBytes);
+
+ ///
+ [UnmanagedFunctionPointer(CallingConvention.StdCall)]
+ private delegate int CloseDelegate(ID3DIncludeForD2DHelpers* @this, void* pData);
+
+ ///
+ /// A cached instance wrapping .
+ ///
+ private static readonly OpenDelegate OpenWrapper = Open;
+
+ ///
+ /// A cached instance wrapping .
+ ///
+ private static readonly CloseDelegate CloseWrapper = Close;
+#endif
+
+ ///
+ /// The shared method table pointer for all instances.
+ ///
+ private static readonly void** Vtbl = InitVtbl();
+
+ ///
+ /// A pointer to a buffer with the contents of d2d1effecthelpers.hlsli.
+ ///
+ private static void* d2D1EffectHelpersData;
+
+ ///
+ /// The size of the buffer in .
+ ///
+ private static int d2D1EffectHelpersSize;
+
+ ///
+ /// Builds the custom method table pointer for .
+ ///
+ /// The method table pointer for .
+ private static void** InitVtbl()
+ {
+ void** lpVtbl = (void**)RuntimeHelpers.AllocateTypeAssociatedMemory(typeof(ID3DIncludeForD2DHelpers), sizeof(void*) * 2);
+
+#if NET6_0_OR_GREATER
+ lpVtbl[0] = (delegate* unmanaged)&Open;
+ lpVtbl[1] = (delegate* unmanaged)&Close;
+#else
+ lpVtbl[0] = (void*)Marshal.GetFunctionPointerForDelegate(OpenWrapper);
+ lpVtbl[1] = (void*)Marshal.GetFunctionPointerForDelegate(CloseWrapper);
+#endif
+
+ return lpVtbl;
+ }
+
+ ///
+ /// The method table pointer for the current instance.
+ ///
+ private void** lpVtbl;
+
+ ///
+ /// Creates and initializes a new instance.
+ ///
+ /// A pointer to a new instance.
+ public static ID3DIncludeForD2DHelpers* Create()
+ {
+ ID3DIncludeForD2DHelpers* @this = (ID3DIncludeForD2DHelpers*)NativeMemory.Alloc((nuint)sizeof(ID3DIncludeForD2DHelpers));
+
+ @this->lpVtbl = Vtbl;
+
+ return @this;
+ }
+
+ ///
+ [UnmanagedCallersOnly]
+ public static int Open(ID3DIncludeForD2DHelpers* @this, D3D_INCLUDE_TYPE IncludeType, sbyte* pFileName, void* pParentData, void** ppData, uint* pBytes)
+ {
+ if (new string(pFileName) == "d2d1effecthelpers.hlsli")
+ {
+ // Load the header if needed
+ if (d2D1EffectHelpersData is null)
+ {
+ d2D1EffectHelpersData = LoadD2D1EffectHelpersHeader(out d2D1EffectHelpersSize);
+ }
+
+ *ppData = d2D1EffectHelpersData;
+ *pBytes = (uint)d2D1EffectHelpersSize;
+
+ return S.S_OK;
+ }
+
+ return S.S_FALSE;
+ }
+
+ ///
+ [UnmanagedCallersOnly]
+ public static int Close(ID3DIncludeForD2DHelpers* @this, void* pData)
+ {
+ return S.S_OK;
+ }
+
+ ///
+ /// Loads the d2d1effecthelpers.hlsli header into a persistent buffer.
+ ///
+ /// The size of the header.
+ /// A pointer to a buffer with the contents of d2d1effecthelpers.hlsli.
+ private static void* LoadD2D1EffectHelpersHeader(out int size)
+ {
+ const string headerFilename = "ComputeSharp.D2D1Interop.Shaders.Translation.Headers.d2d1effecthelpers.hlsli";
+
+ using Stream source = Assembly.GetExecutingAssembly().GetManifestResourceStream(headerFilename)!;
+ using MemoryStream destination = new();
+
+ source.CopyTo(destination);
+
+ byte[] buffer = destination.GetBuffer();
+
+ size = (int)destination.Position;
+
+ void* pointer = NativeMemory.Alloc((nuint)size);
+
+ buffer.AsSpan(0, size).CopyTo(new Span(pointer, size));
+
+ return pointer;
+ }
+ }
+}
diff --git a/src/ComputeSharp.D2D1Interop/Shaders/Translation/D2D1ShaderCompiler.cs b/src/ComputeSharp.D2D1Interop/Shaders/Translation/D2D1ShaderCompiler.cs
index aaf9553b..0450f179 100644
--- a/src/ComputeSharp.D2D1Interop/Shaders/Translation/D2D1ShaderCompiler.cs
+++ b/src/ComputeSharp.D2D1Interop/Shaders/Translation/D2D1ShaderCompiler.cs
@@ -19,8 +19,13 @@ namespace ComputeSharp.D2D1Interop.Shaders.Translation;
///
/// A that uses the FXC APIs to compile D2D1 pixel shaders.
///
-internal static unsafe class D2D1ShaderCompiler
+internal static unsafe partial class D2D1ShaderCompiler
{
+ ///
+ /// The instance to load d2d1effecthelpers.hlsli.
+ ///
+ private static readonly ID3DIncludeForD2DHelpers* D3DIncludeForD2D1EffectHelpers = ID3DIncludeForD2DHelpers.Create();
+
///
/// Compiles a new HLSL shader from the input source code.
///
@@ -88,7 +93,7 @@ internal static unsafe class D2D1ShaderCompiler
SrcDataSize: (nuint)writtenBytes,
pSourceName: null,
pDefines: macros,
- pInclude: null,
+ pInclude: D3DIncludeForD2D1EffectHelpers,
pEntrypoint: (sbyte*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(ASCII.Execute)),
pTarget: (sbyte*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(ASCII.ps_5_0)),
Flags1: D3DCOMPILE.D3DCOMPILE_OPTIMIZATION_LEVEL3 | D3DCOMPILE.D3DCOMPILE_WARNINGS_ARE_ERRORS,
@@ -153,7 +158,7 @@ internal static unsafe class D2D1ShaderCompiler
SrcDataSize: (nuint)writtenBytes,
pSourceName: null,
pDefines: macros,
- pInclude: null,
+ pInclude: D3DIncludeForD2D1EffectHelpers,
pEntrypoint: null,
pTarget: (sbyte*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(ASCII.lib_5_0)),
Flags1: D3DCOMPILE.D3DCOMPILE_OPTIMIZATION_LEVEL3 | D3DCOMPILE.D3DCOMPILE_WARNINGS_ARE_ERRORS,
diff --git a/src/ComputeSharp.D2D1Interop/Shaders/Translation/Headers/d2d1effecthelpers.hlsli b/src/ComputeSharp.D2D1Interop/Shaders/Translation/Headers/d2d1effecthelpers.hlsli
new file mode 100644
index 00000000..aaa56597
--- /dev/null
+++ b/src/ComputeSharp.D2D1Interop/Shaders/Translation/Headers/d2d1effecthelpers.hlsli
@@ -0,0 +1,316 @@
+//---------------------------------------------------------------------------
+// Copyright (c) Microsoft Corporation. All rights reserved.
+//
+// This file is automatically generated. Please do not edit it directly.
+//
+//---------------------------------------------------------------------------
+
+// File contents:
+// - Helpers methods for authoring D2D Effect shader code.
+// These are located at the end of the file (D2DGetInput, etc.).
+// - The top portion contains definitions and initialization required by the helpers.
+// These elements are prefaced with "__D2D" and can be safely ignored.
+//
+// To use these helpers, the following values must be defined before inclusion:
+// D2D_INPUT_COUNT - The number of texture inputs to the effect.
+// D2D_INPUT[N]_SIMPLE or D2D_INPUT[N]_COMPLEX - How the effect will sample each input. (If unspecificed, defaults to _COMPLEX.)
+// D2D_ENTRY - The name of the entry point being compiled. This will usually be defined on the command line at compilation time.
+//
+// The following values can be optionally defined:
+// D2D_FUNCTION - Compile the entry point as an export function. This will usually be defined on the command line at compilation time.
+// D2D_FULL_SHADER - Compile the entry point as a full shader. This will usually be defined on the command line at compilation time.
+// D2D_FULL_SHADER_ONLY - Only compile the in-scope entry points to full shaders, never to export functions.
+//
+
+#define __D2D_DEFINE_PS_GLOBALS(inputIndex) \
+Texture2D InputTexture##inputIndex : register(t##inputIndex); \
+SamplerState InputSampler##inputIndex : register(s##inputIndex); \
+
+// Define a texture and sampler pair for each D2D effect input.
+#if (D2D_INPUT_COUNT >= 1)
+__D2D_DEFINE_PS_GLOBALS(0)
+#endif
+#if (D2D_INPUT_COUNT >= 2)
+__D2D_DEFINE_PS_GLOBALS(1)
+#endif
+#if (D2D_INPUT_COUNT >= 3)
+__D2D_DEFINE_PS_GLOBALS(2)
+#endif
+#if (D2D_INPUT_COUNT >= 4)
+__D2D_DEFINE_PS_GLOBALS(3)
+#endif
+#if (D2D_INPUT_COUNT >= 5)
+__D2D_DEFINE_PS_GLOBALS(4)
+#endif
+#if (D2D_INPUT_COUNT >= 6)
+__D2D_DEFINE_PS_GLOBALS(5)
+#endif
+#if (D2D_INPUT_COUNT >= 7)
+__D2D_DEFINE_PS_GLOBALS(6)
+#endif
+#if (D2D_INPUT_COUNT >= 8)
+__D2D_DEFINE_PS_GLOBALS(7)
+#endif
+
+#define __D2D_MAXIMUM_INPUT_COUNT 8
+
+// Validate that all required shader information has been defined.
+#ifndef D2D_INPUT_COUNT
+#error D2D_INPUT_COUNT is undefined.
+#endif
+
+#if (D2D_INPUT_COUNT > __D2D_MAXIMUM_INPUT_COUNT)
+#error D2D_INPUT_COUNT exceeds the maximum input count.
+#endif
+
+// Define global statics to hold the values needed by intrinsic methods.
+// These values are initialized by the entry point wrapper before calling into the
+// effect's shader implementation.
+#if !defined(D2D_FUNCTION) || defined(D2D_REQUIRES_SCENE_POSITION)
+static float4 __d2dstatic_scenePos = float4(0, 0, 0, 0);
+#endif
+
+#define __D2D_DEFINE_INPUT_STATICS(inputIndex) \
+static float4 __d2dstatic_input##inputIndex = float4(0, 0, 0, 0); \
+static float4 __d2dstatic_uv##inputIndex = float4(0, 0, 0, 0); \
+
+#if (D2D_INPUT_COUNT >= 1)
+__D2D_DEFINE_INPUT_STATICS(0)
+#endif
+#if (D2D_INPUT_COUNT >= 2)
+__D2D_DEFINE_INPUT_STATICS(1)
+#endif
+#if (D2D_INPUT_COUNT >= 3)
+__D2D_DEFINE_INPUT_STATICS(2)
+#endif
+#if (D2D_INPUT_COUNT >= 4)
+__D2D_DEFINE_INPUT_STATICS(3)
+#endif
+#if (D2D_INPUT_COUNT >= 5)
+__D2D_DEFINE_INPUT_STATICS(4)
+#endif
+#if (D2D_INPUT_COUNT >= 6)
+__D2D_DEFINE_INPUT_STATICS(5)
+#endif
+#if (D2D_INPUT_COUNT >= 7)
+__D2D_DEFINE_INPUT_STATICS(6)
+#endif
+#if (D2D_INPUT_COUNT >= 8)
+__D2D_DEFINE_INPUT_STATICS(7)
+#endif
+
+// Define the scene position parameter according to whether the shader requires it,
+// and whether it is the only parameter.
+// The scene position input always needs to be defined for full shaders.
+#if (!defined(D2D_FUNCTION) || defined(D2D_REQUIRES_SCENE_POSITION))
+#if (D2D_INPUT_COUNT == 0)
+#define __D2D_SCENE_POS float4 __d2dinput_scenePos : SCENE_POSITION
+#define __D2D_INIT_STATIC_SCENE_POS __d2dstatic_scenePos = __d2dinput_scenePos
+#else
+#define __D2D_SCENE_POS float4 __d2dinput_scenePos : SCENE_POSITION,
+#define __D2D_INIT_STATIC_SCENE_POS __d2dstatic_scenePos = __d2dinput_scenePos;
+ #endif
+#else
+ #define __D2D_SCENE_POS
+ #define __D2D_INIT_STATIC_SCENE_POS
+#endif
+
+// When compiling a function version, simple and complex inputs have different definitions.
+// When compiling a full shader, they have the same definition.
+// Access to input parameters also differs between functions and full shaders.
+#if defined(D2D_FUNCTION)
+#define __D2D_SIMPLE_INPUT(index) float4 __d2dinput_color##index : INPUT##index
+#define __D2D_INIT_SIMPLE_STATIC(index) __d2dstatic_input##index = __d2dinput_color##index
+#else
+#define __D2D_SIMPLE_INPUT(index) float4 __d2dinput_uv##index : TEXCOORD##index
+#define __D2D_INIT_SIMPLE_STATIC(index) __d2dstatic_uv##index = __d2dinput_uv##index
+#endif
+
+#define __D2D_COMPLEX_INPUT(index) float4 __d2dinput_uv##index : TEXCOORD##index
+#define __D2D_INIT_COMPLEX_STATIC(index) __d2dstatic_uv##index = __d2dinput_uv##index
+
+#define __D2D_SAMPLE_INPUT(index) InputTexture##index.Sample(InputSampler##index, __d2dstatic_uv##index.xy)
+
+// Define each input as either simple or complex.
+#if defined(D2D_INPUT0_SIMPLE)
+#define __D2D_INPUT0 __D2D_SIMPLE_INPUT(0)
+#define __D2D_INIT_STATIC0 __D2D_INIT_SIMPLE_STATIC(0)
+#define __D2D_GET_INPUT0 __d2dstatic_input0
+#else
+#define __D2D_INPUT0 __D2D_COMPLEX_INPUT(0)
+#define __D2D_INIT_STATIC0 __D2D_INIT_COMPLEX_STATIC(0)
+#define __D2D_GET_INPUT0 __D2D_SAMPLE_INPUT(0)
+#endif
+#if defined(D2D_INPUT1_SIMPLE)
+#define __D2D_INPUT1 __D2D_SIMPLE_INPUT(1)
+#define __D2D_INIT_STATIC1 __D2D_INIT_SIMPLE_STATIC(1)
+#define __D2D_GET_INPUT1 __d2dstatic_input1
+#else
+#define __D2D_INPUT1 __D2D_COMPLEX_INPUT(1)
+#define __D2D_INIT_STATIC1 __D2D_INIT_COMPLEX_STATIC(1)
+#define __D2D_GET_INPUT1 __D2D_SAMPLE_INPUT(1)
+#endif
+#if defined(D2D_INPUT2_SIMPLE)
+#define __D2D_INPUT2 __D2D_SIMPLE_INPUT(2)
+#define __D2D_INIT_STATIC2 __D2D_INIT_SIMPLE_STATIC(2)
+#define __D2D_GET_INPUT2 __d2dstatic_input2
+#else
+#define __D2D_INPUT2 __D2D_COMPLEX_INPUT(2)
+#define __D2D_INIT_STATIC2 __D2D_INIT_COMPLEX_STATIC(2)
+#define __D2D_GET_INPUT2 __D2D_SAMPLE_INPUT(2)
+#endif
+#if defined(D2D_INPUT3_SIMPLE)
+#define __D2D_INPUT3 __D2D_SIMPLE_INPUT(3)
+#define __D2D_INIT_STATIC3 __D2D_INIT_SIMPLE_STATIC(3)
+#define __D2D_GET_INPUT3 __d2dstatic_input3
+#else
+#define __D2D_INPUT3 __D2D_COMPLEX_INPUT(3)
+#define __D2D_INIT_STATIC3 __D2D_INIT_COMPLEX_STATIC(3)
+#define __D2D_GET_INPUT3 __D2D_SAMPLE_INPUT(3)
+#endif
+#if defined(D2D_INPUT4_SIMPLE)
+#define __D2D_INPUT4 __D2D_SIMPLE_INPUT(4)
+#define __D2D_INIT_STATIC4 __D2D_INIT_SIMPLE_STATIC(4)
+#define __D2D_GET_INPUT4 __d2dstatic_input4
+#else
+#define __D2D_INPUT4 __D2D_COMPLEX_INPUT(4)
+#define __D2D_INIT_STATIC4 __D2D_INIT_COMPLEX_STATIC(4)
+#define __D2D_GET_INPUT4 __D2D_SAMPLE_INPUT(4)
+#endif
+#if defined(D2D_INPUT5_SIMPLE)
+#define __D2D_INPUT5 __D2D_SIMPLE_INPUT(5)
+#define __D2D_INIT_STATIC5 __D2D_INIT_SIMPLE_STATIC(5)
+#define __D2D_GET_INPUT5 __d2dstatic_input5
+#else
+#define __D2D_INPUT5 __D2D_COMPLEX_INPUT(5)
+#define __D2D_INIT_STATIC5 __D2D_INIT_COMPLEX_STATIC(5)
+#define __D2D_GET_INPUT5 __D2D_SAMPLE_INPUT(5)
+#endif
+#if defined(D2D_INPUT6_SIMPLE)
+#define __D2D_INPUT6 __D2D_SIMPLE_INPUT(6)
+#define __D2D_INIT_STATIC6 __D2D_INIT_SIMPLE_STATIC(6)
+#define __D2D_GET_INPUT6 __d2dstatic_input6
+#else
+#define __D2D_INPUT6 __D2D_COMPLEX_INPUT(6)
+#define __D2D_INIT_STATIC6 __D2D_INIT_COMPLEX_STATIC(6)
+#define __D2D_GET_INPUT6 __D2D_SAMPLE_INPUT(6)
+#endif
+#if defined(D2D_INPUT7_SIMPLE)
+#define __D2D_INPUT7 __D2D_SIMPLE_INPUT(7)
+#define __D2D_INIT_STATIC7 __D2D_INIT_SIMPLE_STATIC(7)
+#define __D2D_GET_INPUT7 __d2dstatic_input7
+#else
+#define __D2D_INPUT7 __D2D_COMPLEX_INPUT(7)
+#define __D2D_INIT_STATIC7 __D2D_INIT_COMPLEX_STATIC(7)
+#define __D2D_GET_INPUT7 __D2D_SAMPLE_INPUT(7)
+#endif
+#if defined(D2D_INPUT8_SIMPLE)
+#define __D2D_INPUT8 __D2D_SIMPLE_INPUT(8)
+#define __D2D_INIT_STATIC8 __D2D_INIT_SIMPLE_STATIC(8)
+#define __D2D_GET_INPUT8 __d2dstatic_input8
+#else
+#define __D2D_INPUT8 __D2D_COMPLEX_INPUT(8)
+#define __D2D_INIT_STATIC8 __D2D_INIT_COMPLEX_STATIC(8)
+#define __D2D_GET_INPUT8 __D2D_SAMPLE_INPUT(8)
+#endif
+
+// Define the export function inputs based on the defined input count and types.
+#if (D2D_INPUT_COUNT == 0)
+#define __D2D_FUNCTION_INPUTS __D2D_SCENE_POS
+#define __D2D_INIT_STATICS __D2D_INIT_STATIC_SCENE_POS
+#elif (D2D_INPUT_COUNT == 1)
+#define __D2D_FUNCTION_INPUTS __D2D_SCENE_POS __D2D_INPUT0
+#define __D2D_INIT_STATICS __D2D_INIT_STATIC_SCENE_POS __D2D_INIT_STATIC0
+#elif (D2D_INPUT_COUNT == 2)
+#define __D2D_FUNCTION_INPUTS __D2D_SCENE_POS __D2D_INPUT0, __D2D_INPUT1
+#define __D2D_INIT_STATICS __D2D_INIT_STATIC_SCENE_POS __D2D_INIT_STATIC0; __D2D_INIT_STATIC1
+#elif (D2D_INPUT_COUNT == 3)
+#define __D2D_FUNCTION_INPUTS __D2D_SCENE_POS __D2D_INPUT0, __D2D_INPUT1, __D2D_INPUT2
+#define __D2D_INIT_STATICS __D2D_INIT_STATIC_SCENE_POS __D2D_INIT_STATIC0; __D2D_INIT_STATIC1; __D2D_INIT_STATIC2
+#elif (D2D_INPUT_COUNT == 4)
+#define __D2D_FUNCTION_INPUTS __D2D_SCENE_POS __D2D_INPUT0, __D2D_INPUT1, __D2D_INPUT2, __D2D_INPUT3
+#define __D2D_INIT_STATICS __D2D_INIT_STATIC_SCENE_POS __D2D_INIT_STATIC0; __D2D_INIT_STATIC1; __D2D_INIT_STATIC2; __D2D_INIT_STATIC3
+#elif (D2D_INPUT_COUNT == 5)
+#define __D2D_FUNCTION_INPUTS __D2D_SCENE_POS __D2D_INPUT0, __D2D_INPUT1, __D2D_INPUT2, __D2D_INPUT3, __D2D_INPUT4
+#define __D2D_INIT_STATICS __D2D_INIT_STATIC_SCENE_POS __D2D_INIT_STATIC0; __D2D_INIT_STATIC1; __D2D_INIT_STATIC2; __D2D_INIT_STATIC3; __D2D_INIT_STATIC4
+#elif (D2D_INPUT_COUNT == 6)
+#define __D2D_FUNCTION_INPUTS __D2D_SCENE_POS __D2D_INPUT0, __D2D_INPUT1, __D2D_INPUT2, __D2D_INPUT3, __D2D_INPUT4, __D2D_INPUT5
+#define __D2D_INIT_STATICS __D2D_INIT_STATIC_SCENE_POS __D2D_INIT_STATIC0; __D2D_INIT_STATIC1; __D2D_INIT_STATIC2; __D2D_INIT_STATIC3; __D2D_INIT_STATIC4; __D2D_INIT_STATIC5
+#elif (D2D_INPUT_COUNT == 7)
+#define __D2D_FUNCTION_INPUTS __D2D_SCENE_POS __D2D_INPUT0, __D2D_INPUT1, __D2D_INPUT2, __D2D_INPUT3, __D2D_INPUT4, __D2D_INPUT5, __D2D_INPUT6
+#define __D2D_INIT_STATICS __D2D_INIT_STATIC_SCENE_POS __D2D_INIT_STATIC0; __D2D_INIT_STATIC1; __D2D_INIT_STATIC2; __D2D_INIT_STATIC3; __D2D_INIT_STATIC4; __D2D_INIT_STATIC5; __D2D_INIT_STATIC6
+#elif (D2D_INPUT_COUNT == 8)
+#define __D2D_FUNCTION_INPUTS __D2D_SCENE_POS __D2D_INPUT0, __D2D_INPUT1, __D2D_INPUT2, __D2D_INPUT3, __D2D_INPUT4, __D2D_INPUT5, __D2D_INPUT6, __D2D_INPUT7
+#define __D2D_INIT_STATICS __D2D_INIT_STATIC_SCENE_POS __D2D_INIT_STATIC0; __D2D_INIT_STATIC1; __D2D_INIT_STATIC2; __D2D_INIT_STATIC3; __D2D_INIT_STATIC4; __D2D_INIT_STATIC5; __D2D_INIT_STATIC6; __D2D_INIT_STATIC7
+#endif
+
+#if !defined(CONCAT)
+#define CONCAT(str1, str2) str1##str2
+#endif
+
+// Rename the entry point target function so that the actual entry point can use the name.
+// This expansion is the same for both full shaders and functions.
+#define D2D_PS_ENTRY(name) float4 CONCAT(name, _Impl)()
+
+// If neither D2D_FUNCTION or D2D_FULL_SHADER is defined, behave as if D2D_FULL_SHADER is defined.
+#if defined(D2D_FUNCTION) && !defined(D2D_FULL_SHADER_ONLY)
+
+ // Replaces simple samples with either static variable or an actual sample,
+ // depending on whether the input is declared as simple or complex.
+ #define D2DGetInput(index) __D2D_GET_INPUT##index
+
+ #if !defined(D2D_CUSTOM_ENTRY)
+ // Declare function prototype for the target function so that it can be referenced before definition.
+ // D2D_ENTRY is a macro whose actual name resolves to the effect's target "entry point" function.
+ float4 CONCAT(D2D_ENTRY, _Impl)();
+
+ // This is the actual entry point definition, which forwards the call to the target function.
+ export float4 D2D_func_entry(__D2D_FUNCTION_INPUTS)
+ {
+ __D2D_INIT_STATICS;
+ return CONCAT(D2D_ENTRY, _Impl)();
+ }
+
+ #endif
+
+#else // !defined(D2D_FUNCTION)
+
+ // Replaces simple samples with actual samples.
+ #define D2DGetInput(index) __D2D_SAMPLE_INPUT(index)
+
+ #if !defined(D2D_CUSTOM_ENTRY)
+ // Declare function prototype for the target function so that it can be referenced before definition.
+ // D2D_ENTRY is a macro whose actual name resolves to the effect's target "entry point" function.
+ float4 CONCAT(D2D_ENTRY, _Impl)();
+
+ // This is the actual entry point definition, which forwards the call to the target function.
+ float4 D2D_ENTRY (float4 pos : SV_POSITION, __D2D_FUNCTION_INPUTS) : SV_TARGET
+ {
+ __D2D_INIT_STATICS;
+ return CONCAT(D2D_ENTRY, _Impl)();
+ }
+
+ #endif
+
+#endif // D2D_FUNCTION
+
+//===============================================================
+// Along with D2DGetInput defined above, the following macros and
+// methods define D2D intrinsics for use in effect shader code.
+//===============================================================
+
+#if !defined(D2D_FUNCTION) || defined(D2D_REQUIRES_SCENE_POSITION)
+inline float4 D2DGetScenePosition()
+{
+ return __d2dstatic_scenePos;
+}
+#endif
+
+#define D2DGetInputCoordinate(index) __d2dstatic_uv##index
+
+#define D2DSampleInput(index, position) InputTexture##index.Sample(InputSampler##index, position)
+
+#define D2DSampleInputAtOffset(index, offset) InputTexture##index.Sample(InputSampler##index, __d2dstatic_uv##index.xy + offset * __d2dstatic_uv##index.zw)
+
+#define D2DSampleInputAtPosition(index, pos) InputTexture##index.Sample(InputSampler##index, __d2dstatic_uv##index.xy + __d2dstatic_uv##index.zw * (pos - __d2dstatic_scenePos.xy))
+
diff --git a/src/TerraFX.Interop.Windows.D2D1Interop/DirectX/um/d3dcommon/D3D_INCLUDE_TYPE.cs b/src/TerraFX.Interop.Windows.D2D1Interop/DirectX/um/d3dcommon/D3D_INCLUDE_TYPE.cs
new file mode 100644
index 00000000..65ca6cc7
--- /dev/null
+++ b/src/TerraFX.Interop.Windows.D2D1Interop/DirectX/um/d3dcommon/D3D_INCLUDE_TYPE.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 enum D3D_INCLUDE_TYPE
+ {
+ D3D_INCLUDE_LOCAL = 0,
+ D3D_INCLUDE_SYSTEM = (D3D_INCLUDE_LOCAL + 1),
+ D3D10_INCLUDE_LOCAL = D3D_INCLUDE_LOCAL,
+ D3D10_INCLUDE_SYSTEM = D3D_INCLUDE_SYSTEM,
+ D3D_INCLUDE_FORCE_DWORD = 0x7fffffff,
+ }
+}
\ No newline at end of file
diff --git a/src/TerraFX.Interop.Windows.D2D1Interop/DirectX/um/d3dcommon/ID3DInclude.cs b/src/TerraFX.Interop.Windows.D2D1Interop/DirectX/um/d3dcommon/ID3DInclude.cs
new file mode 100644
index 00000000..c62f93b2
--- /dev/null
+++ b/src/TerraFX.Interop.Windows.D2D1Interop/DirectX/um/d3dcommon/ID3DInclude.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 d3dcommon.h in Microsoft.Direct3D.D3D12 v1.600.10
+// Original source is Copyright © Microsoft. Licensed under the MIT license
+
+using System.Runtime.CompilerServices;
+using TerraFX.Interop.Windows;
+
+namespace TerraFX.Interop.DirectX
+{
+ internal unsafe partial struct ID3DInclude
+ {
+ public void** lpVtbl;
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ [VtblIndex(0)]
+ public HRESULT Open(D3D_INCLUDE_TYPE IncludeType, [NativeTypeName("LPCSTR")] sbyte* pFileName, [NativeTypeName("LPCVOID")] void* pParentData, [NativeTypeName("LPCVOID *")] void** ppData, uint* pBytes)
+ {
+ return ((delegate* unmanaged[Stdcall])(lpVtbl[0]))((ID3DInclude*)Unsafe.AsPointer(ref this), IncludeType, pFileName, pParentData, ppData, pBytes);
+ }
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ [VtblIndex(1)]
+ public HRESULT Close([NativeTypeName("LPCVOID")] void* pData)
+ {
+ return ((delegate* unmanaged[Stdcall])(lpVtbl[1]))((ID3DInclude*)Unsafe.AsPointer(ref this), pData);
+ }
+ }
+}
\ 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
index c2cd1a61..79eec306 100644
--- a/src/TerraFX.Interop.Windows.D2D1Interop/TerraFX.Interop.Windows.D2D1Interop.projitems
+++ b/src/TerraFX.Interop.Windows.D2D1Interop/TerraFX.Interop.Windows.D2D1Interop.projitems
@@ -10,8 +10,10 @@
+
+