yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
a766d2744
master
1//DIAGNOSTIC_TEST:SIMPLE(filecheck=CHECK): -spirv 2 3struct WithStaticTexture 4{ 5 float4 color; 6 static Texture2D tex; 7 float scale; 8} 9 10struct WithStaticSampler 11{ 12 static SamplerState sampler; 13 float2 uv; 14} 15 16struct NestedWithStatic 17{ 18 WithStaticTexture data; 19 float value; 20} 21 22// These should NOT produce error 38204 because resources are static 23//CHECK-NOT: error 38204 24StructuredBuffer<WithStaticTexture> bufferWithStaticTexture; 25 26//CHECK-NOT: error 38204 27StructuredBuffer<WithStaticSampler> bufferWithStaticSampler; 28 29//CHECK-NOT: error 38204 30StructuredBuffer<NestedWithStatic> bufferNestedStatic; 31 32RWStructuredBuffer<float4> output; 33 34Texture2D tex; 35SamplerState sampler; 36 37[numthreads(4, 1, 1)] 38void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) 39{ 40 uint i = dispatchThreadID.x; 41 42 WithStaticTexture.tex = tex; 43 WithStaticSampler.sampler = sampler; 44 45 // Use all non-static members and static resources 46 float4 result = bufferWithStaticTexture[i].color * bufferWithStaticTexture[i].scale 47 + WithStaticTexture.tex.Sample(WithStaticSampler.sampler, bufferWithStaticSampler[i].uv) 48 + bufferNestedStatic[i].data.color * bufferNestedStatic[i].data.scale 49 + float4(bufferNestedStatic[i].value, 0, 0, 0); 50 51 output[i] = result; 52} 53