yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
f02b08490
master
1//TEST(compute):COMPARE_COMPUTE: -shaderobj 2//TEST(compute):COMPARE_COMPUTE:-dx12 -shaderobj 3//TEST(compute):COMPARE_COMPUTE:-dx12 -shaderobj 4//TEST(compute):COMPARE_COMPUTE:-cpu -shaderobj 5//TEST(compute):COMPARE_COMPUTE:-cuda -shaderobj 6// Note VK output is not loop unrolled 7//TEST(compute):COMPARE_COMPUTE:-vk -shaderobj 8//DISABLE_TEST(compute):COMPARE_COMPUTE:-slang -shaderobj -mtl 9// Not supported in WGSL: Arrays of textures or buffers 10//DISABLE_TEST(compute):COMPARE_COMPUTE:-wgpu 11 12//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out, name buffers[0] 13//TEST_INPUT:ubuffer(data=[0 1 2 3], stride=4):name buffers[1] 14//TEST_INPUT:ubuffer(data=[1 2 3 0], stride=4):name buffers[2] 15 16// Check that we propagate the `[unroll]` attribute 17// through to HLSL output correctly. 18// 19// If we neglect to generate the attribute in the output, 20// it will generate a warning output from fxc, and the 21// test will fail to match the expected output. 22 23RWStructuredBuffer<int> buffers[3]; 24 25[numthreads(4, 1, 1)] 26void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) 27{ 28 uint tid = dispatchThreadID.x; 29 30 // Note: using `unroll` as a variable name to validate that 31 // the lookup process for attribute names doesn't run into 32 // problems because of local declarations with the same name. 33 int unroll = buffers[2][tid]; 34 35 [unroll] 36 for(int ii = 0; ii < 2; ii++) 37 { 38 unroll = buffers[ii + 1][unroll]; 39 } 40 41 buffers[0][tid] = unroll; 42}