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): -target spirv 2 3struct WithTexture 4{ 5 float4 color; 6 Texture2D tex; 7 float scale; 8} 9 10struct WithSampler 11{ 12 SamplerState sampler; 13 float2 uv; 14} 15 16struct Nested 17{ 18 WithTexture data; 19 float value; 20} 21 22//CHECK-DAG: ([[# @LINE+1]]): error 38204 23StructuredBuffer<WithTexture> bufferWithTexture; 24 25//CHECK-DAG: ([[# @LINE+1]]): error 38204 26StructuredBuffer<WithSampler> bufferWithSampler; 27 28//CHECK-DAG: ([[# @LINE+1]]): error 38204 29StructuredBuffer<Nested> bufferNested; 30 31RWStructuredBuffer<float4> output; 32 33[numthreads(4, 1, 1)] 34void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) 35{ 36 uint i = dispatchThreadID.x; 37 38 // Use all struct members from all buffers 39 float4 result = bufferWithTexture[i].color * bufferWithTexture[i].scale 40 + bufferWithTexture[i].tex.Sample(bufferWithSampler[i].sampler, bufferWithSampler[i].uv) 41 + bufferNested[i].data.tex.Sample(bufferWithSampler[0].sampler, float2(0, 0)) * bufferNested[i].data.scale 42 + float4(bufferNested[i].value, 0, 0, 0); 43 44 output[i] = result; 45} 46