yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
f02b08490
master
1//DISABLED_TEST(compute, vulkan):COMPARE_COMPUTE_EX():-vk -compute -shaderobj -output-using-type -render-features wave-ops 2//DISABLED_TEST(compute):COMPARE_COMPUTE_EX():-dx12 -profile sm_6_5 -compute -shaderobj -output-using-type -render-features wave-ops 3 4// 5// This test checks whether adjacent calls to saturated_cooperation are fused 6// 7 8//TEST_INPUT:ubuffer(data=[0 3 2 2], stride=4):out,name=outputBuffer 9RWStructuredBuffer<uint> outputBuffer; 10 11static int count = 0; 12 13int cooperate(float x, int i) 14{ 15 count += i; 16 return int(x) * 2; 17} 18 19int fallback(float x, int) 20{ 21 count += 100; 22 return int(x) * 3; 23} 24 25int cooperate2(float x, float f) 26{ 27 count *= int(f); 28 return int(x) * 2; 29} 30 31int fallback2(float x, float) 32{ 33 count += 100; 34 return int(x) * 3; 35} 36 37// Make sure that we have enough invocations to saturate the first workgroup 38[numthreads(128, 1, 1)] 39void computeMain(uint tig : SV_GroupIndex) 40{ 41 // The values we're cooperating over are {0, 2, 3} 42 // We track the number of sets evaluated in the "count" variable, and write 43 // that at index 0 44 // 45 // If these are not fused, then we'd expect count to be incremented three 46 // times then doubled three times. What we want to see is 47 // 0, +1, *2, +1, *2, +1, *2 = 14 48 let i = tig < 4 ? float(outputBuffer[tig]) : 0; 49 let y = saturated_cooperation(cooperate, fallback, i, 1); 50 let x = saturated_cooperation(cooperate2, fallback2, i, 2.f); 51 if(tig < 4) 52 outputBuffer[tig] = tig == 0 ? count : x; 53 54}