yum-mirror/slang

Making it easier to work with shaders

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

Anders LeinoRefresh of disabled WGPU tests (#5614)93f5d13fc

master
1.5 KiB50 linesraw
1// We can't test on VK or metal, as currently we don't support integer matrix types
2//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj -vk
3//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj 
4//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj -cpu
5//DISABLE_TEST(compute):COMPARE_COMPUTE:-slang -shaderobj -mtl
6// Not supported in WGSL: Integer matrices
7//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-wgpu
8
9//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer
10RWStructuredBuffer<uint> outputBuffer;
11
12void silly<T : __BuiltinIntegerType, let ROWS : int, let COLS : int>(matrix<T, ROWS, COLS> a, inout matrix<T, ROWS, COLS> b)
13{
14    b *= a;
15}
16
17void silly2<T : __BuiltinIntegerType, let ROWS : int, let COLS : int>(matrix<T, ROWS, COLS> a, out matrix<T, ROWS, COLS> b)
18{
19    b = a;
20}
21
22
23[numthreads(4, 1, 1)]
24void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
25{
26    matrix<int, 2, 2> v = { 1, 2, 3, 4};
27    matrix<uint, 2, 2> u = { 5, 6, 7, 8};
28
29    int idx = int(dispatchThreadID.x);
30    
31    matrix<uint, 2, 2> uidx = { idx, idx * idx, idx + idx, idx + 2 };
32
33    v += uidx;
34    u += idx;
35
36    silly(u, v);
37    silly(v, u);
38
39    // Check that detects issues with undefined variables.
40
41    matrix<int, 2, 2> undef1, undef2;          // undefined
42    // Downstream compilers detect this
43    //silly(u, undef1);
44    silly2(u, undef2);
45    
46    matrix<uint, 2, 2> added = (u + v + undef2);
47    uint2 added2 = added[0] + added[1];
48
49    outputBuffer[idx] = added2.x + added2.y;
50}