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.3 KiB37 linesraw
1// NOTE we can't test on VK/gl because we will output imat3 - and imat3 is not supported by glsl.
2// NOTE we also can't do this test on fxc - as it does not allow runtime non constant indexing.
3
4//TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute -shaderobj
5//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj
6//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -shaderobj
7//DISABLE_TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj
8//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-cuda -compute -shaderobj
9
10//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer
11RWStructuredBuffer<int> outputBuffer;
12
13int horizontalAdd(int3 v) { return v.x + v.y + v.z; }
14
15[numthreads(4, 1, 1)]
16void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
17{
18    int idx = int(dispatchThreadID.x);
19
20    matrix<int, 3, 3> a = { { 0, 1, 2}, {2, 4, 6}, {7, 21, 32}};
21    matrix<int, 3, 3> b = { { 4, 9, -1}, {-2, 4, 2}, {31, -3, 7}};
22
23    // Do a dynamic row swap
24    {
25        matrix<int, 3, 3> c = a;
26    
27        int row0 = idx % 3;
28        int row1 = (idx + 1) % 3; 
29        int row2 = (idx + 2) % 3;
30        
31        a[row0] = c[0];
32        a[row1] = c[1];
33        a[row2] = c[2];
34    }
35 
36    outputBuffer[idx] = (a[0].x & 15) + ((a[1].x & 15) << 4) + ((a[2].x & 15) << 8);
37}