yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
8813c6105
master
1//TEST:SIMPLE(filecheck=CHECK):-target spirv -entry computeMain -profile cs_5_1 -line-directive-mode none -source-embed-style default -emit-spirv-via-glsl 2 3//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer 4RWStructuredBuffer<int> outputBuffer; 5 6// CHECK: const uint32_t data[] = 7// CHECK: 0x07230203, 0x00010000, 8// CHECK: const size_t data_sizeInBytes = 9 10int calcThing(int offset) 11{ 12 int total = 0; 13 int another[2] = { 1, 2}; 14 15 for (int k = 0; k < 20; ++k) 16 { 17 for (int i = 0; i < 17; ++i) 18 { 19 another[i & 1] += k + i; 20 } 21 22 total += another[k & 1]; 23 24 if ((k + 7) % 5 == 4) 25 { 26 return 1; 27 } 28 } 29 30 if (total > 4) 31 { 32 total = -total; 33 } 34 35 return total; 36} 37 38[numthreads(4, 1, 1)] 39void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) 40{ 41 int index = int(dispatchThreadID.x); 42 43 outputBuffer[index] = calcThing(index); 44}