diff --git a/src/ComputeSharp.D2D1.SourceGenerators/NativeMethods.txt b/src/ComputeSharp.D2D1.SourceGenerators/NativeMethods.txt
index f4fdf2c2..a1c61091 100644
--- a/src/ComputeSharp.D2D1.SourceGenerators/NativeMethods.txt
+++ b/src/ComputeSharp.D2D1.SourceGenerators/NativeMethods.txt
@@ -1,5 +1,6 @@
D3DCompile
D3DSetBlobPart
+D3DStripShader
D2D1_BUFFER_PRECISION
D2D1_CHANNEL_DEPTH
D2D1_FILTER
@@ -19,6 +20,7 @@ D3DCOMPILE_OPTIMIZATION_LEVEL1
D3DCOMPILE_OPTIMIZATION_LEVEL2
D3DCOMPILE_OPTIMIZATION_LEVEL3
D3DCOMPILE_WARNINGS_ARE_ERRORS
+D3DCOMPILER_STRIP_FLAGS
IUnknown
S_OK
S_FALSE
\ No newline at end of file
diff --git a/src/ComputeSharp.D2D1/Attributes/Enums/D2D1CompileOptions.cs b/src/ComputeSharp.D2D1/Attributes/Enums/D2D1CompileOptions.cs
index 9a9d439a..62d90117 100644
--- a/src/ComputeSharp.D2D1/Attributes/Enums/D2D1CompileOptions.cs
+++ b/src/ComputeSharp.D2D1/Attributes/Enums/D2D1CompileOptions.cs
@@ -155,6 +155,16 @@ public enum D2D1CompileOptions
///
WarningsAreErrors = (int)D3DCOMPILE.D3DCOMPILE_WARNINGS_ARE_ERRORS,
+ ///
+ /// Strips the reflection data from the generated shader bytecode. The bytecode size will be smaller, but trying
+ /// to perform reflection on the shader will return inaccurate results. It is recommend if not reflection is used.
+ ///
+ ///
+ /// This flag maps to D3DCOMPILER_STRIP_REFLECTION_DATA, when passed as input to D3DStripShader.
+ /// For more info, see .
+ ///
+ StripReflectionData = 1 << 30,
+
///
/// This flag enables the support for shader linking. Specifically, when set, this flag causes the APIs from
/// to compile the input shader twice: once as a full D2D1 shader, and once
diff --git a/src/ComputeSharp.D2D1/Shaders/Interop/D2D1ShaderCompiler.cs b/src/ComputeSharp.D2D1/Shaders/Interop/D2D1ShaderCompiler.cs
index 9480ecee..8a8400b8 100644
--- a/src/ComputeSharp.D2D1/Shaders/Interop/D2D1ShaderCompiler.cs
+++ b/src/ComputeSharp.D2D1/Shaders/Interop/D2D1ShaderCompiler.cs
@@ -65,11 +65,13 @@ public static class D2D1ShaderCompiler
D2D1ShaderProfile shaderProfile,
D2D1CompileOptions options)
{
- // Check linking support
+ // Check the additional compile options (not provided by FXC directly)
bool enableLinking = (options & D2D1CompileOptions.EnableLinking) == D2D1CompileOptions.EnableLinking;
+ bool stripReflectionData = (options & D2D1CompileOptions.StripReflectionData) == D2D1CompileOptions.StripReflectionData;
- // Remove the linking flag to make the options blittable to flags
+ // Remove the additional options to make them blittable to flags
options &= ~D2D1CompileOptions.EnableLinking;
+ options &= ~D2D1CompileOptions.StripReflectionData;
// Compile the standalone D2D1 full shader
using ComPtr d3DBlobFullShader = D3DCompiler.Compile(
@@ -78,7 +80,8 @@ public static class D2D1ShaderCompiler
d2DEntry: entryPointAscii,
entryPoint: entryPointAscii,
target: ASCII.GetPixelShaderProfile(shaderProfile),
- flags: (uint)options);
+ flags: (uint)options,
+ stripReflectionData: stripReflectionData);
if (!enableLinking)
{
@@ -95,7 +98,8 @@ public static class D2D1ShaderCompiler
d2DEntry: entryPointAscii,
entryPoint: default,
target: ASCII.GetLibraryProfile(shaderProfile),
- flags: (uint)options);
+ flags: (uint)options,
+ stripReflectionData: stripReflectionData);
// Embed it as private data if requested
using ComPtr d3DBlobLinked = D3DCompiler.SetD3DPrivateData(d3DBlobFullShader.Get(), d3DBlobFunction.Get());
diff --git a/src/ComputeSharp.D2D1/Shaders/Translation/D3DCompiler.cs b/src/ComputeSharp.D2D1/Shaders/Translation/D3DCompiler.cs
index e550bad5..f1ab48c0 100644
--- a/src/ComputeSharp.D2D1/Shaders/Translation/D3DCompiler.cs
+++ b/src/ComputeSharp.D2D1/Shaders/Translation/D3DCompiler.cs
@@ -50,6 +50,12 @@ internal static unsafe partial class D3DCompiler
writtenBytes = Encoding.ASCII.GetBytes(source, buffer);
#endif
+ bool enableLinking = (options & D2D1CompileOptions.EnableLinking) == D2D1CompileOptions.EnableLinking;
+ bool stripReflectionData = (options & D2D1CompileOptions.StripReflectionData) == D2D1CompileOptions.StripReflectionData;
+
+ options &= ~D2D1CompileOptions.EnableLinking;
+ options &= ~D2D1CompileOptions.StripReflectionData;
+
try
{
// Compile the standalone D2D1 full shader
@@ -59,9 +65,10 @@ internal static unsafe partial class D3DCompiler
d2DEntry: ASCII.Execute,
entryPoint: ASCII.Execute,
target: ASCII.GetPixelShaderProfile(shaderProfile),
- flags: (uint)(options & ~D2D1CompileOptions.EnableLinking));
+ flags: (uint)options,
+ stripReflectionData: stripReflectionData);
- if ((options & D2D1CompileOptions.EnableLinking) == 0)
+ if (!enableLinking)
{
return d3DBlobFullShader.Move();
}
@@ -73,7 +80,8 @@ internal static unsafe partial class D3DCompiler
d2DEntry: ASCII.Execute,
entryPoint: default,
target: ASCII.GetLibraryProfile(shaderProfile),
- flags: (uint)(options & ~D2D1CompileOptions.EnableLinking));
+ flags: (uint)options,
+ stripReflectionData: stripReflectionData);
// Embed it as private data if requested
using ComPtr d3DBlobLinked = SetD3DPrivateData(d3DBlobFullShader.Get(), d3DBlobFunction.Get());
@@ -95,6 +103,7 @@ internal static unsafe partial class D3DCompiler
/// The entry point for the shader.
/// The shader target to use to compile the input source.
/// The compilationm flag to use.
+ /// Whether to strip reflection data from the shader bytecode.
/// The bytecode for the compiled shader.
/// Thrown if the compilation fails.
public static ComPtr Compile(
@@ -103,7 +112,8 @@ internal static unsafe partial class D3DCompiler
ReadOnlySpan d2DEntry,
ReadOnlySpan entryPoint,
ReadOnlySpan target,
- uint flags)
+ uint flags,
+ bool stripReflectionData)
{
using ComPtr d3DBlobBytecode = default;
using ComPtr d3DBlobErrors = default;
@@ -181,6 +191,20 @@ internal static unsafe partial class D3DCompiler
// there would always be a message), but better safe than sorry.
hResult.Assert();
+ // If requested, strip the reflection data and return that bytecode blob
+ if (stripReflectionData)
+ {
+ using ComPtr d3DBlobBytecodeNoReflection = default;
+
+ DirectX.D3DStripShader(
+ pShaderBytecode: d3DBlobBytecode.Get()->GetBufferPointer(),
+ BytecodeLength: d3DBlobBytecode.Get()->GetBufferSize(),
+ uStripFlags: (uint)D3DCOMPILER_STRIP_FLAGS.D3DCOMPILER_STRIP_REFLECTION_DATA,
+ ppStrippedBlob: d3DBlobBytecodeNoReflection.GetAddressOf()).Assert();
+
+ return d3DBlobBytecodeNoReflection.Move();
+ }
+
return d3DBlobBytecode.Move();
}
diff --git a/src/ComputeSharp.Win32.D2D1/ComputeSharp.Win32.D2D1.projitems b/src/ComputeSharp.Win32.D2D1/ComputeSharp.Win32.D2D1.projitems
index 11abcfc6..ee329928 100644
--- a/src/ComputeSharp.Win32.D2D1/ComputeSharp.Win32.D2D1.projitems
+++ b/src/ComputeSharp.Win32.D2D1/ComputeSharp.Win32.D2D1.projitems
@@ -48,6 +48,7 @@
+
diff --git a/src/ComputeSharp.Win32.D2D1/DirectX/um/d2d1/D2D1_EXTEND_MODE.cs b/src/ComputeSharp.Win32.D2D1/DirectX/um/d2d1/D2D1_EXTEND_MODE.cs
index 9f9d611c..fd20c76c 100644
--- a/src/ComputeSharp.Win32.D2D1/DirectX/um/d2d1/D2D1_EXTEND_MODE.cs
+++ b/src/ComputeSharp.Win32.D2D1/DirectX/um/d2d1/D2D1_EXTEND_MODE.cs
@@ -8,10 +8,7 @@ namespace ComputeSharp.Win32;
internal enum D2D1_EXTEND_MODE : uint
{
D2D1_EXTEND_MODE_CLAMP = 0,
-
D2D1_EXTEND_MODE_WRAP = 1,
-
D2D1_EXTEND_MODE_MIRROR = 2,
-
D2D1_EXTEND_MODE_FORCE_DWORD = 0xffffffff,
}
\ No newline at end of file
diff --git a/src/ComputeSharp.Win32.D2D1/DirectX/um/d3dcompiler/D3DCOMPILER_STRIP_FLAGS.cs b/src/ComputeSharp.Win32.D2D1/DirectX/um/d3dcompiler/D3DCOMPILER_STRIP_FLAGS.cs
new file mode 100644
index 00000000..6402ffdd
--- /dev/null
+++ b/src/ComputeSharp.Win32.D2D1/DirectX/um/d3dcompiler/D3DCOMPILER_STRIP_FLAGS.cs
@@ -0,0 +1,19 @@
+// 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.22621.0
+// Original source is Copyright © Microsoft. All rights reserved.
+
+using System;
+
+namespace ComputeSharp.Win32;
+
+[Flags]
+internal enum D3DCOMPILER_STRIP_FLAGS
+{
+ D3DCOMPILER_STRIP_REFLECTION_DATA = 0x00000001,
+ D3DCOMPILER_STRIP_DEBUG_INFO = 0x00000002,
+ D3DCOMPILER_STRIP_TEST_BLOBS = 0x00000004,
+ D3DCOMPILER_STRIP_PRIVATE_DATA = 0x00000008,
+ D3DCOMPILER_STRIP_ROOT_SIGNATURE = 0x00000010,
+ D3DCOMPILER_STRIP_FORCE_DWORD = 0x7fffffff,
+}
\ No newline at end of file
diff --git a/src/ComputeSharp.Win32.D2D1/DirectX/um/d3dcompiler/D3D_BLOB_PART.cs b/src/ComputeSharp.Win32.D2D1/DirectX/um/d3dcompiler/D3D_BLOB_PART.cs
index 9beee6f1..37e2b2b8 100644
--- a/src/ComputeSharp.Win32.D2D1/DirectX/um/d3dcompiler/D3D_BLOB_PART.cs
+++ b/src/ComputeSharp.Win32.D2D1/DirectX/um/d3dcompiler/D3D_BLOB_PART.cs
@@ -8,36 +8,20 @@ namespace ComputeSharp.Win32;
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/ComputeSharp.Win32.D2D1/DirectX/um/d3dcompiler/DirectX.cs b/src/ComputeSharp.Win32.D2D1/DirectX/um/d3dcompiler/DirectX.cs
index 9d7f46da..ed495995 100644
--- a/src/ComputeSharp.Win32.D2D1/DirectX/um/d3dcompiler/DirectX.cs
+++ b/src/ComputeSharp.Win32.D2D1/DirectX/um/d3dcompiler/DirectX.cs
@@ -18,4 +18,7 @@ internal static unsafe partial class DirectX
[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);
+
+ [DllImport("d3dcompiler_47", ExactSpelling = true)]
+ public static extern HRESULT D3DStripShader([NativeTypeName("LPCVOID")] void* pShaderBytecode, [NativeTypeName("SIZE_T")] nuint BytecodeLength, uint uStripFlags, ID3DBlob** ppStrippedBlob);
}
\ No newline at end of file
diff --git a/src/ComputeSharp.Win32.D3D12/DirectX/shared/dxgitype/DXGI_MODE_SCALING.cs b/src/ComputeSharp.Win32.D3D12/DirectX/shared/dxgitype/DXGI_MODE_SCALING.cs
index b6217c2f..110677b8 100644
--- a/src/ComputeSharp.Win32.D3D12/DirectX/shared/dxgitype/DXGI_MODE_SCALING.cs
+++ b/src/ComputeSharp.Win32.D3D12/DirectX/shared/dxgitype/DXGI_MODE_SCALING.cs
@@ -8,8 +8,6 @@ namespace ComputeSharp.Win32;
internal enum DXGI_MODE_SCALING
{
DXGI_MODE_SCALING_UNSPECIFIED = 0,
-
DXGI_MODE_SCALING_CENTERED = 1,
-
DXGI_MODE_SCALING_STRETCHED = 2,
}
\ No newline at end of file
diff --git a/src/ComputeSharp.Win32.D3D12/DirectX/shared/dxgitype/DXGI_MODE_SCANLINE_ORDER.cs b/src/ComputeSharp.Win32.D3D12/DirectX/shared/dxgitype/DXGI_MODE_SCANLINE_ORDER.cs
index c33c46f5..26dce978 100644
--- a/src/ComputeSharp.Win32.D3D12/DirectX/shared/dxgitype/DXGI_MODE_SCANLINE_ORDER.cs
+++ b/src/ComputeSharp.Win32.D3D12/DirectX/shared/dxgitype/DXGI_MODE_SCANLINE_ORDER.cs
@@ -8,10 +8,7 @@ namespace ComputeSharp.Win32;
internal enum DXGI_MODE_SCANLINE_ORDER
{
DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED = 0,
-
DXGI_MODE_SCANLINE_ORDER_PROGRESSIVE = 1,
-
DXGI_MODE_SCANLINE_ORDER_UPPER_FIELD_FIRST = 2,
-
DXGI_MODE_SCANLINE_ORDER_LOWER_FIELD_FIRST = 3,
}
\ No newline at end of file
diff --git a/src/ComputeSharp.Win32.D3D12/Windows/shared/wtypes/STATFLAG.cs b/src/ComputeSharp.Win32.D3D12/Windows/shared/wtypes/STATFLAG.cs
index febe6b16..18386b92 100644
--- a/src/ComputeSharp.Win32.D3D12/Windows/shared/wtypes/STATFLAG.cs
+++ b/src/ComputeSharp.Win32.D3D12/Windows/shared/wtypes/STATFLAG.cs
@@ -8,8 +8,6 @@ namespace ComputeSharp.Win32;
internal enum STATFLAG
{
STATFLAG_DEFAULT = 0,
-
STATFLAG_NONAME = 1,
-
STATFLAG_NOOPEN = 2,
}
\ No newline at end of file
diff --git a/src/ComputeSharp.Win32.D3D12/Windows/um/objidlbase/STGTY.cs b/src/ComputeSharp.Win32.D3D12/Windows/um/objidlbase/STGTY.cs
index 8e9389f8..79aa9fe5 100644
--- a/src/ComputeSharp.Win32.D3D12/Windows/um/objidlbase/STGTY.cs
+++ b/src/ComputeSharp.Win32.D3D12/Windows/um/objidlbase/STGTY.cs
@@ -8,10 +8,7 @@ namespace ComputeSharp.Win32;
internal enum STGTY
{
STGTY_STORAGE = 1,
-
STGTY_STREAM = 2,
-
STGTY_LOCKBYTES = 3,
-
STGTY_PROPERTY = 4,
}
\ No newline at end of file
diff --git a/src/ComputeSharp/Attributes/Enums/CompileOptions.cs b/src/ComputeSharp/Attributes/Enums/CompileOptions.cs
index 77ff9663..eb09e695 100644
--- a/src/ComputeSharp/Attributes/Enums/CompileOptions.cs
+++ b/src/ComputeSharp/Attributes/Enums/CompileOptions.cs
@@ -131,8 +131,8 @@ public enum CompileOptions
ResourcesMayAlias = 1 << 13,
///
- /// Strips the reflection data from the generated shader bytecode. The bytecode size will be significantly lower, but
- /// trying to perform reflection on the shader will return inaccurate results. Recommend if not reflection is done.
+ /// Strips the reflection data from the generated shader bytecode. The bytecode size will be significantly smaller, but
+ /// trying to perform reflection on the shader will return inaccurate results. It is recommend if not reflection is used.
///
///
/// This flag maps to -Qstrip_reflect.
diff --git a/tests/ComputeSharp.D2D1.Tests/D2D1PixelShaderTests.cs b/tests/ComputeSharp.D2D1.Tests/D2D1PixelShaderTests.cs
index a3c7fcb8..9f2e9940 100644
--- a/tests/ComputeSharp.D2D1.Tests/D2D1PixelShaderTests.cs
+++ b/tests/ComputeSharp.D2D1.Tests/D2D1PixelShaderTests.cs
@@ -616,6 +616,98 @@ namespace ComputeSharp.D2D1.Tests
}
}
+ [TestMethod]
+ public void LoadBytecode_EnableLinkingIsAppliedCorrectly()
+ {
+ ReadOnlyMemory hlslBytecode1 = D2D1PixelShader.LoadBytecode(out _, out D2D1CompileOptions compileOptions1);
+ ReadOnlyMemory hlslBytecode2 = D2D1PixelShader.LoadBytecode(out _, out D2D1CompileOptions compileOptions2);
+
+ Assert.AreEqual(D2D1CompileOptions.Default | D2D1CompileOptions.PackMatrixRowMajor, compileOptions1);
+ Assert.AreEqual(D2D1CompileOptions.Default | D2D1CompileOptions.EnableLinking | D2D1CompileOptions.PackMatrixRowMajor, compileOptions2);
+
+ Assert.IsTrue(MemoryMarshal.TryGetMemoryManager(hlslBytecode1, out MemoryManager? manager1));
+ Assert.IsTrue(manager1!.GetType().Name.Contains("HlslBytecodeMemoryManager"));
+
+ Assert.IsTrue(MemoryMarshal.TryGetMemoryManager(hlslBytecode2, out MemoryManager? manager2));
+ Assert.IsTrue(manager2!.GetType().Name.Contains("HlslBytecodeMemoryManager"));
+
+ // Same checks as in D2D1ShaderCompilerTests.CompileInvertEffectWithDefaultOptionsAndLinking
+ Assert.IsTrue(hlslBytecode1.Length > 700);
+ Assert.IsTrue(hlslBytecode2.Length > 1400);
+ Assert.IsTrue(hlslBytecode2.Length > hlslBytecode1.Length);
+ Assert.IsTrue((hlslBytecode2.Length - hlslBytecode1.Length) > 700);
+ }
+
+ [D2DInputCount(1)]
+ [D2DInputSimple(0)]
+ [D2DShaderProfile(D2D1ShaderProfile.PixelShader50)]
+ [D2DCompileOptions(D2D1CompileOptions.Default)]
+ [D2DGeneratedPixelShaderDescriptor]
+ public readonly partial struct ReferenceShaderWithDefaultCompileOptions : ID2D1PixelShader
+ {
+ public float4 Execute()
+ {
+ float4 color = D2D.GetInput(0);
+ float3 rgb = Hlsl.Saturate(1.0f - color.RGB);
+
+ return new(rgb, 1);
+ }
+ }
+
+ [D2DInputCount(1)]
+ [D2DInputSimple(0)]
+ [D2DShaderProfile(D2D1ShaderProfile.PixelShader50)]
+ [D2DCompileOptions(D2D1CompileOptions.Default | D2D1CompileOptions.EnableLinking)]
+ [D2DGeneratedPixelShaderDescriptor]
+ public readonly partial struct ReferenceShaderWithEnableLinking : ID2D1PixelShader
+ {
+ public float4 Execute()
+ {
+ float4 color = D2D.GetInput(0);
+ float3 rgb = Hlsl.Saturate(1.0f - color.RGB);
+
+ return new(rgb, 1);
+ }
+ }
+
+ [TestMethod]
+ public void LoadBytecode_StripReflectionDataIsAppliedCorrectly()
+ {
+ ReadOnlyMemory hlslBytecode1 = D2D1PixelShader.LoadBytecode(out _, out D2D1CompileOptions compileOptions1);
+ ReadOnlyMemory hlslBytecode2 = D2D1PixelShader.LoadBytecode(out _, out D2D1CompileOptions compileOptions2);
+
+ Assert.AreEqual(D2D1CompileOptions.Default | D2D1CompileOptions.PackMatrixRowMajor, compileOptions1);
+ Assert.AreEqual(D2D1CompileOptions.Default | D2D1CompileOptions.StripReflectionData | D2D1CompileOptions.PackMatrixRowMajor, compileOptions2);
+
+ Assert.IsTrue(MemoryMarshal.TryGetMemoryManager(hlslBytecode1, out MemoryManager? manager1));
+ Assert.IsTrue(manager1!.GetType().Name.Contains("HlslBytecodeMemoryManager"));
+
+ Assert.IsTrue(MemoryMarshal.TryGetMemoryManager(hlslBytecode2, out MemoryManager? manager2));
+ Assert.IsTrue(manager2!.GetType().Name.Contains("HlslBytecodeMemoryManager"));
+
+ // Same checks as in D2D1ShaderCompilerTests.CompileInvertEffectWithDefaultOptionsAndStripReflectionData
+ Assert.IsTrue(hlslBytecode1.Length > 700);
+ Assert.IsTrue(hlslBytecode2.Length > 400);
+ Assert.IsTrue(hlslBytecode1.Length > hlslBytecode2.Length);
+ Assert.IsTrue((hlslBytecode1.Length - hlslBytecode2.Length) > 300);
+ }
+
+ [D2DInputCount(1)]
+ [D2DInputSimple(0)]
+ [D2DShaderProfile(D2D1ShaderProfile.PixelShader50)]
+ [D2DCompileOptions(D2D1CompileOptions.Default | D2D1CompileOptions.StripReflectionData)]
+ [D2DGeneratedPixelShaderDescriptor]
+ public readonly partial struct ReferenceShaderWithStripReflectionData : ID2D1PixelShader
+ {
+ public float4 Execute()
+ {
+ float4 color = D2D.GetInput(0);
+ float3 rgb = Hlsl.Saturate(1.0f - color.RGB);
+
+ return new(rgb, 1);
+ }
+ }
+
[TestMethod]
public void GetConstantBufferSize_Empty()
{
diff --git a/tests/ComputeSharp.D2D1.Tests/D2D1ShaderCompilerTests.cs b/tests/ComputeSharp.D2D1.Tests/D2D1ShaderCompilerTests.cs
index 1594f759..64dfdfcd 100644
--- a/tests/ComputeSharp.D2D1.Tests/D2D1ShaderCompilerTests.cs
+++ b/tests/ComputeSharp.D2D1.Tests/D2D1ShaderCompilerTests.cs
@@ -78,12 +78,56 @@ public partial class D2D1ShaderCompilerTests
""";
ReadOnlyMemory bytecode = D2D1ShaderCompiler.Compile(
+ source.AsSpan(),
+ "PSMain".AsSpan(),
+ D2D1ShaderProfile.PixelShader40Level93,
+ D2D1CompileOptions.Default);
+
+ ReadOnlyMemory bytecodeWithLinking = D2D1ShaderCompiler.Compile(
source.AsSpan(),
"PSMain".AsSpan(),
D2D1ShaderProfile.PixelShader40Level93,
D2D1CompileOptions.Default | D2D1CompileOptions.EnableLinking);
- Assert.IsTrue(bytecode.Length > 0);
+ Assert.IsTrue(bytecode.Length > 800);
+ Assert.IsTrue(bytecodeWithLinking.Length > 1600);
+ Assert.IsTrue(bytecodeWithLinking.Length > bytecode.Length);
+ Assert.IsTrue((bytecodeWithLinking.Length - bytecode.Length) > 800);
+ }
+
+ [TestMethod]
+ public void CompileInvertEffectWithDefaultOptionsAndStripReflectionData()
+ {
+ const string source = """
+ #define D2D_INPUT_COUNT 1
+ #define D2D_INPUT0_SIMPLE
+
+ #include "d2d1effecthelpers.hlsli"
+
+ D2D_PS_ENTRY(PSMain)
+ {
+ float4 color = D2DGetInput(0);
+ float3 rgb = saturate(1.0 - color.rgb);
+ return float4(rgb, 1);
+ }
+ """;
+
+ ReadOnlyMemory bytecode = D2D1ShaderCompiler.Compile(
+ source.AsSpan(),
+ "PSMain".AsSpan(),
+ D2D1ShaderProfile.PixelShader40Level93,
+ D2D1CompileOptions.Default);
+
+ ReadOnlyMemory bytecodeWithStripReflectionData = D2D1ShaderCompiler.Compile(
+ source.AsSpan(),
+ "PSMain".AsSpan(),
+ D2D1ShaderProfile.PixelShader40Level93,
+ D2D1CompileOptions.Default | D2D1CompileOptions.StripReflectionData);
+
+ Assert.IsTrue(bytecode.Length > 800);
+ Assert.IsTrue(bytecodeWithStripReflectionData.Length > 500);
+ Assert.IsTrue(bytecode.Length > bytecodeWithStripReflectionData.Length);
+ Assert.IsTrue((bytecode.Length - bytecodeWithStripReflectionData.Length) > 200);
}
[TestMethod]