yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
f02b08490
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//DISABLE_TEST(vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj 6//TEST:COMPARE_COMPUTE_EX:-cuda -compute -capability cuda_sm_7_0 -shaderobj 7 8//TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0], stride=4):out,name outputBuffer 9RWStructuredBuffer<int> outputBuffer; 10 11[numthreads(8, 1, 1)] 12void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) 13{ 14 const int idx = int(dispatchThreadID.x); 15 16 // NOTE! dxc only supports bit ops on uint and associated types NOT int 17 // Also GLSL does not have built in support for int matrices. So we'll just try with float for now 18 // GLSL does not support matrix types for Wave like intrinsics 19 20 matrix<int, 2, 2> v0 = matrix<int, 2, 2>(idx + 1, idx + 2, idx + 3, idx + 4); 21 matrix<float, 2, 2> v1 = matrix<float, 2, 2>(v0) + matrix<float, 2, 2>(1, 1, 1, 1); 22 23 24 matrix<uint, 2, 2> uv0 = matrix<uint, 2, 2>(v0[0][0], v0[0][1], v0[1][0], v0[0][1]); 25 26 matrix<int, 2, 2> r0 = WaveActiveSum(v0); 27 matrix<float, 2, 2> r1 = WaveActiveSum(v1); 28 matrix<uint, 2, 2> r2 = WaveActiveBitXor(uv0); 29 matrix<uint, 2, 2> r3 = WaveActiveBitOr(uv0); 30 matrix<uint, 2, 2> r4 = WaveActiveBitAnd(uv0); 31 32 matrix<uint, 2, 2> r5 = r2 + r3 + r4; 33 matrix<int, 2, 2> r6 = matrix<int, 2, 2>(int(r5[0][0]), int(r5[0][1]), int(r5[1][0]), int(r5[1][1])); 34 35 matrix<int, 2, 2> r = r0 + matrix<int, 2, 2>(r1) + r6; 36 37 outputBuffer[idx] = r[0][0] + r[0][1] + r[1][0] + r[1][1]; 38}