Add unit test for shader with no reflection metadata
このコミットが含まれているのは:
1 親
fb0a1a441a
コミット
18e9a5ac72
2ファイル変更
+50
-2
検索条件に一致するファイルはありません
@@ -131,8 +131,8 @@ public enum CompileOptions
|
||||
ResourcesMayAlias = 1 << 13,
|
||||
|
||||
/// <summary>
|
||||
/// 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 fail at runtime. Recommend if not reflection is done.
|
||||
/// 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.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This flag maps to <c>-Qstrip_reflect</c>.
|
||||
|
||||
@@ -559,6 +559,54 @@ namespace ComputeSharp.Tests
|
||||
this.buffer[ThreadIds.X] *= x;
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ShaderWithStrippedReflectionData()
|
||||
{
|
||||
ShaderInfo info1 = ReflectionServices.GetShaderInfo<ShaderWithStrippedReflectionData1>();
|
||||
|
||||
// With no reflection data available, the instruction count is just 0
|
||||
Assert.AreEqual(0u, info1.InstructionCount);
|
||||
|
||||
ShaderInfo info2 = ReflectionServices.GetShaderInfo<ShaderWithStrippedReflectionData2>();
|
||||
|
||||
// Sanity check, here instead we should have some valid count
|
||||
Assert.AreNotEqual(0u, info2.InstructionCount);
|
||||
|
||||
// Verify that the bytecode with stripped reflection is much smaller
|
||||
Assert.IsTrue(info1.HlslBytecode.Length < 1800);
|
||||
Assert.IsTrue(info2.HlslBytecode.Length > 3300);
|
||||
}
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[CompileOptions(CompileOptions.Default | CompileOptions.StripReflectionData)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct ShaderWithStrippedReflectionData1 : IComputeShader
|
||||
{
|
||||
public readonly ReadWriteBuffer<float> buffer;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void Execute()
|
||||
{
|
||||
this.buffer[ThreadIds.X] = ThreadIds.X;
|
||||
}
|
||||
}
|
||||
|
||||
[AutoConstructor]
|
||||
[EmbeddedBytecode(DispatchAxis.X)]
|
||||
[CompileOptions(CompileOptions.Default)]
|
||||
[GeneratedComputeShaderDescriptor]
|
||||
internal readonly partial struct ShaderWithStrippedReflectionData2 : IComputeShader
|
||||
{
|
||||
public readonly ReadWriteBuffer<float> buffer;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void Execute()
|
||||
{
|
||||
this.buffer[ThreadIds.X] = ThreadIds.X;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする