diff options
| author | Alexey Panteleev <alpanteleev@nvidia.com> | 2022-05-18 10:57:37 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-05-18 10:57:37 -0700 |
| commit | 69cb6e8f300d77e74bd2c7dfe15d12e10b38f512 (patch) | |
| tree | c2d23f2883acb28407106a096b55c64111f098b1 /tests/reflection/used-parameters.slang | |
| parent | 1148564b9cdbbc8fec4fbecf65b0af60aa6af344 (diff) | |
Support for querying which parameters are used in emitted code (#2239)
See https://github.com/shader-slang/slang/issues/2213
Diffstat (limited to 'tests/reflection/used-parameters.slang')
| -rw-r--r-- | tests/reflection/used-parameters.slang | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/tests/reflection/used-parameters.slang b/tests/reflection/used-parameters.slang new file mode 100644 index 000000000..efb605a14 --- /dev/null +++ b/tests/reflection/used-parameters.slang @@ -0,0 +1,52 @@ +// used-parameters.slang + +// Tests post-emit analysis of shader parameters to find out if they are used or not. + +//TEST:REFLECTION:-stage compute -entry main -target hlsl + + +struct S +{ + uint2 Size; +}; + +ConstantBuffer<S> UsedCB; +ConstantBuffer<S> UnusedCB; + +Texture2D UsedTexture; +Texture2D UnusedTexture; + +Buffer<uint> UsedBuffer; +Buffer<uint> UnusedBuffer; + +StructuredBuffer<uint> UsedStructuredBuffer; +StructuredBuffer<uint> UnusedStructuredBuffer; + +RWTexture2D UsedRWTexture; +RWTexture2D UnusedRWTexture; + +RWBuffer<uint> UsedRWBuffer; +RWBuffer<uint> UnusedRWBuffer; + +RWStructuredBuffer<uint> UsedRWStructuredBuffer; +RWStructuredBuffer<uint> UnusedRWStructuredBuffer; + +SamplerState UsedSampler; +SamplerState UnusedSampler; + +uniform uint UsedUniform; +uniform uint UnusedUniform; + +[numthreads(1, 1, 1)] +void main(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + float A = UsedTexture[dispatchThreadID.xy].x; + uint B = UsedBuffer[dispatchThreadID.x]; + uint C = UsedStructuredBuffer[dispatchThreadID.y]; + float D = UsedRWTexture[dispatchThreadID.xy].x; + uint E = UsedRWBuffer[dispatchThreadID.y]; + float F = UsedTexture.SampleLevel(UsedSampler, float2(dispatchThreadID.xy) / float2(UsedCB.Size), 0).x; + uint G = UsedUniform; + + UsedRWStructuredBuffer[dispatchThreadID.x + dispatchThreadID.y * UsedCB.Size.x] = uint(A) + B + C + uint(D) + E + uint(F) + G; +}
\ No newline at end of file |
