yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
e4611e2e3
master
1//TEST:SIMPLE(filecheck=SPV): -target spirv -O0 2 3// Test that we are not deferring buffer loads due to potential aliasing writes. 4 5struct Bottom 6{ 7 float bigArray[1024]; 8 9 float bottomGetValue(int index) 10 { 11 // this write may cause data stored at gRoot to be modified, 12 // thus bigArray[index] may be different from what it was before the call to 13 // bottomGetValue. So we should not defer loading bigArray until after this write. 14 *gOther = 100; 15 16 // We should return the value from bigArray from a previously loaded value of `this`. 17 return bigArray[index]; 18 } 19} 20 21struct Root 22{ 23 Bottom bottom1; 24 Bottom bottom2; 25} 26 27uniform Root* gRoot; 28uniform int* gOther; 29 30RWStructuredBuffer<float> outputBuffer; 31 32[shader("compute")] 33[numthreads(1, 1, 1)] 34void compute_main(uint3 tid: SV_DispatchThreadID) 35{ 36 // SPV: OpLoad %Bottom_natural 37 outputBuffer[0] = gRoot.bottom1.bottomGetValue(0); 38}