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 can defer buffer loads by ruling out potential aliasing writes. 4 5struct Bottom 6{ 7 float bigArray[1024]; 8 9 float bottomGetValue(int index) 10 { 11 // RWStructuredBuffer is considered to not alias with anything else. 12 // this write should not prevent deferring loading bigArray. 13 gOther[0] = 100; 14 // this write should not prevent deferring loading bigArray. 15 gSharedVar = 1; 16 // this write should not prevent deferring loading bigArray. 17 gStaticVar = 2; 18 19 // We should return the value from bigArray from a previously loaded value of `this`. 20 return bigArray[index]; 21 } 22} 23 24struct Root 25{ 26 Bottom bottom1; 27 Bottom bottom2; 28} 29 30uniform Root* gRoot; 31uniform RWStructuredBuffer<int> gOther; 32static int gStaticVar; 33groupshared int gSharedVar; 34 35 36RWStructuredBuffer<float> outputBuffer; 37 38[shader("compute")] 39[numthreads(1, 1, 1)] 40void compute_main(uint3 tid: SV_DispatchThreadID) 41{ 42 // SPV: OpEntryPoint 43 // SPV-NOT: OpLoad %Bottom_natural 44 outputBuffer[0] = gRoot.bottom1.bottomGetValue(0); 45}