Add unit test for D2D shader reflection stripping

このコミットが含まれているのは:
Sergio Pedri committed 2023-12-07 12:01:19 +01:00
1 親 3c040b79b0
コミット 2d952769ee
1ファイル変更
+45 -1
+45 -1
ファイルの表示
@@ -78,12 +78,56 @@ public partial class D2D1ShaderCompilerTests
""";
ReadOnlyMemory<byte> bytecode = D2D1ShaderCompiler.Compile(
source.AsSpan(),
"PSMain".AsSpan(),
D2D1ShaderProfile.PixelShader40Level93,
D2D1CompileOptions.Default);
ReadOnlyMemory<byte> 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<byte> bytecode = D2D1ShaderCompiler.Compile(
source.AsSpan(),
"PSMain".AsSpan(),
D2D1ShaderProfile.PixelShader40Level93,
D2D1CompileOptions.Default);
ReadOnlyMemory<byte> 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]