yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
5c9f011fa
master
1//TEST:COMPARE_COMPUTE(filecheck-buffer=CHECK): -output-using-type 2 3//TEST_INPUT:set buffer = ubuffer(data=[0 0 0 0], stride=4) 4RWStructuredBuffer<float> buffer; 5 6struct Foo<let D : int> 7{ 8 float load() 9 { 10 int idx[D]; 11 [ForceUnroll] 12 for (int i = 0; i < D; ++i) 13 idx[i] = 0; 14 [ForceUnroll] 15 for (int i = 0; i < D-2; ++i) 16 idx[i] = 0; 17 float result = 100.0; 18 [ForceUnroll] 19 for (int i = 0; i < 1; i++) 20 result += buffer[idx[0]]; 21 22 return result; 23 } 24} 25 26//TEST_INPUT:set result = out ubuffer(data=[0 0 0 0], stride=4) 27uniform RWStructuredBuffer<float> result; 28 29[shader("compute")] 30void computeMain(uint3 dispatchThreadID: SV_DispatchThreadID) 31{ 32 Foo<2> biases = {}; 33 34 // Test that we can unroll loops of 0 iterations. 35 result[0] = biases.load(); 36 37 // CHECK: 100.0 38}