yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
1562f98c0
master
1// struct-default-init.slang 2//TEST(compute):COMPARE_COMPUTE: -shaderobj 3//TEST(compute):COMPARE_COMPUTE: -vk -shaderobj 4//TEST(compute):COMPARE_COMPUTE: -cuda -shaderobj 5 6struct Test 7{ 8 int a = 0; 9 int b = 1; 10 int c = 0; 11 int d = 1 + 1; 12} 13 14int test(int inVal) 15{ 16 Test myArray[4] = { 17 { 3, 4, 5, 6 }, 18 { 7, 8, 9, }, 19 { 10, 11 }, 20 { 12, } 21 }; 22 23 Test t = myArray[inVal]; 24 return t.a * 4096 25 + t.b * 256 26 + t.c * 16 27 + t.d; 28} 29 30//TEST_INPUT:ubuffer(data=[9 9 9 9], stride=4):out,name=outputBuffer 31RWStructuredBuffer<int> outputBuffer; 32 33[numthreads(4, 1, 1)] 34void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) 35{ 36 uint tid = dispatchThreadID.x; 37 38 int inVal = int(tid); 39 int outVal = test(inVal); 40 41 outputBuffer[tid] = outVal; 42}