yum-mirror/slang

Making it easier to work with shaders

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

jsmall-nvidiaFix for operator assignment issue (#2951)c5b0708ea

master
1.1 KiB47 linesraw
1//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj -vk
2//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj 
3//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj -cpu
4
5
6//TEST_INPUT:ubuffer(data=[0 0 0 0 0 0], stride=4):out,name outputBuffer
7RWStructuredBuffer<uint> outputBuffer;
8
9
10void silly<T : __BuiltinIntegerType, let N : int>(vector<T, N> a, inout vector<T, N> b)
11{
12    b *= a;
13}
14
15void silly2<T : __BuiltinIntegerType, let N : int>(vector<T, N> a, out vector<T, N> b)
16{
17    b = a;
18}
19
20
21[numthreads(4, 1, 1)]
22void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
23{
24    int2 v = int2(0, 0);
25    uint2 u = uint2(0, 0);
26
27    int idx = int(dispatchThreadID.x);
28    
29    uint2 uidx = uint2(idx, idx * idx);
30
31    v += uidx;
32    u += idx;
33
34    silly(u, v);
35    silly(v, u);
36
37    // Check that detects issues with undefined variables.
38
39    int2 undef1, undef2;          // undefined
40    // Downstream compilers detect this
41    //silly(u, undef1);
42    silly2(u, undef2);
43    
44    uint2 added = (u + v + undef2);
45
46    outputBuffer[idx] = added.x + added.y;
47}