yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
ffd58977b
master
1//TEST_CATEGORY(wave, compute) 2//DISABLE_TEST:COMPARE_COMPUTE_EX:-cpu -compute -shaderobj 3//DISABLE_TEST:COMPARE_COMPUTE_EX:-slang -compute -shaderobj 4//TEST:COMPARE_COMPUTE_EX:-slang -compute -dx12 -profile cs_6_0 -shaderobj -render-feature hardware-device 5//TEST(vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj -render-feature hardware-device 6//TEST:COMPARE_COMPUTE_EX:-cuda -compute -capability cuda_sm_7_0 -shaderobj 7//TEST:COMPARE_COMPUTE_EX:-metal -compute -shaderobj 8 9// WGSL doesn't support wave functions in a dynamic control flow; it works with uniform control flow. 10//DISABLE_TEST:COMPARE_COMPUTE_EX:-wgpu -compute -shaderobj 11 12//TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0], stride=4):out,name outputBuffer 13RWStructuredBuffer<int> outputBuffer; 14 15[numthreads(8, 1, 1)] 16void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) 17{ 18 const int idx = int(dispatchThreadID.x); 19 20#if 1 21 if (idx < 3) 22 { 23 // Diverge!! 24 outputBuffer[idx] = -1; // thread 0, 1 and 2 will get 0xFFFFFFFF 25 return; 26 } 27 28 // thread 2, 3, 4, 5, 6, 7 will get the result of 2 * 3 * 4 * 5 * 6 * 7 29 // which is 2520, which is 9D8 in hex 30 outputBuffer[idx] = WaveActiveProduct(idx); 31#else 32 33 /// NOTE! Can't say I totally understand WaveActiveProduct. 34 /// The following returns 0x240 on CUDA - which is what I'd expect 35 /// On DX12, it returns 0 36 37 outputBuffer[idx] = WaveActiveProduct((idx & 3) + 1); 38#endif 39}