yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
69cb6e8f3
master
1// used-parameters.slang 2 3// Tests post-emit analysis of shader parameters to find out if they are used or not. 4 5//TEST:REFLECTION:-stage compute -entry main -target hlsl 6 7 8struct S 9{ 10 uint2 Size; 11}; 12 13ConstantBuffer<S> UsedCB; 14ConstantBuffer<S> UnusedCB; 15 16Texture2D UsedTexture; 17Texture2D UnusedTexture; 18 19Buffer<uint> UsedBuffer; 20Buffer<uint> UnusedBuffer; 21 22StructuredBuffer<uint> UsedStructuredBuffer; 23StructuredBuffer<uint> UnusedStructuredBuffer; 24 25RWTexture2D UsedRWTexture; 26RWTexture2D UnusedRWTexture; 27 28RWBuffer<uint> UsedRWBuffer; 29RWBuffer<uint> UnusedRWBuffer; 30 31RWStructuredBuffer<uint> UsedRWStructuredBuffer; 32RWStructuredBuffer<uint> UnusedRWStructuredBuffer; 33 34SamplerState UsedSampler; 35SamplerState UnusedSampler; 36 37uniform uint UsedUniform; 38uniform uint UnusedUniform; 39 40[numthreads(1, 1, 1)] 41void main(uint3 dispatchThreadID : SV_DispatchThreadID) 42{ 43 float A = UsedTexture[dispatchThreadID.xy].x; 44 uint B = UsedBuffer[dispatchThreadID.x]; 45 uint C = UsedStructuredBuffer[dispatchThreadID.y]; 46 float D = UsedRWTexture[dispatchThreadID.xy].x; 47 uint E = UsedRWBuffer[dispatchThreadID.y]; 48 float F = UsedTexture.SampleLevel(UsedSampler, float2(dispatchThreadID.xy) / float2(UsedCB.Size), 0).x; 49 uint G = UsedUniform; 50 51 UsedRWStructuredBuffer[dispatchThreadID.x + dispatchThreadID.y * UsedCB.Size.x] = uint(A) + B + C + uint(D) + E + uint(F) + G; 52}