yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
cfef0c6f6
master
1//TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute 2//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute 3//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 4//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute 5//TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute -render-features half 6 7//TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0], stride=4):out,name outputBuffer 8RWStructuredBuffer<uint> outputBuffer; 9 10[numthreads(8, 1, 1)] 11void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) 12{ 13 int idx = int(dispatchThreadID.x); 14 15 // We want to test 0 16 float value = 0.0f; 17 // Produces some somewhat interesting numbers 18 if (idx != 0) 19 { 20 value = (3 << idx); 21 22 if ((idx & 1) != 0) 23 { 24 value = -value; 25 } 26 27 // Do the recip 28 if ((idx & 4) != 0) 29 { 30 value = 1.0f / value; 31 } 32 } 33 34 uint r = f32tof16(value); 35 36 outputBuffer[idx] = r; 37}