yum-mirror/slang

Making it easier to work with shaders

git clone https://git.yummers.dev/yum-mirror/slang

James Helferty (NVIDIA)render-test: Change D3D12 default to sm_6_5 (#8320)f02b08490

master
1.7 KiB40 linesraw
1//TEST_CATEGORY(wave-mask, 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_5 -shaderobj -render-feature hardware-device
5//DISABLE_TEST(vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj
6//TEST:COMPARE_COMPUTE_EX:-cuda -compute -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 WaveMask mask = 0xff;
15    
16    const int idx = int(dispatchThreadID.x);
17    
18    // NOTE! dxc only supports bit ops on uint and associated types NOT int
19    // Also GLSL does not have built in support for int matrices. So we'll just try with float for now    
20    // GLSL does not support matrix types for Wave like intrinsics   
21       
22    matrix<int, 2, 2> v0 = matrix<int, 2, 2>(idx + 1, idx + 2, idx + 3, idx + 4);   
23    matrix<float, 2, 2> v1 = matrix<float, 2, 2>(v0) + matrix<float, 2, 2>(1, 1, 1, 1);
24    
25    
26    matrix<uint, 2, 2> uv0 = matrix<uint, 2, 2>(v0[0][0], v0[0][1], v0[1][0], v0[0][1]);
27    
28    matrix<int, 2, 2> r0 = WaveMaskSum(mask, v0);
29    matrix<float, 2, 2> r1 = WaveMaskSum(mask, v1);
30    matrix<uint, 2, 2> r2 = WaveMaskBitXor(mask, uv0);
31    matrix<uint, 2, 2> r3 = WaveMaskBitOr(mask, uv0);
32    matrix<uint, 2, 2> r4 = WaveMaskBitAnd(mask, uv0);
33    
34    matrix<uint, 2, 2> r5 = r2 + r3 + r4;
35    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])); 
36    
37    matrix<int, 2, 2> r = r0 + matrix<int, 2, 2>(r1) + r6;
38   
39    outputBuffer[idx] = r[0][0] + r[0][1] + r[1][0] + r[1][1];
40}