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.2 KiB46 linesraw
1//TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute -shaderobj
2//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj
3//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -shaderobj
4//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj
5//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-cuda -compute -shaderobj
6
7//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer
8RWStructuredBuffer<int> outputBuffer;
9
10[numthreads(4, 1, 1)]
11void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
12{
13    int idx = int(dispatchThreadID.x);
14
15    int3 a = { idx + 10, idx - 9, idx + 3};
16    int3 b = { idx * 2, idx * 3, idx * 10};
17    
18    int3 t = { 0, 0, 0};
19    
20    t += max(a, b);
21    t += min(a, b);
22    t += abs(a);
23    t += b % 5;
24    
25    t += clamp(a, int3(10), int3(23));
26   
27    // Swizzle
28    t += a.zyx;
29    // Swizzle from scalar
30    t += idx.xxx;
31    
32    {   
33        t += int3(a[idx % 3], a[0], b[2]);
34    }
35   
36    // Writes 
37    {   
38        int3 v = int3(b[(idx + 1) % 3], b[(idx + 2) % 3], b[(idx + 3) % 3]);
39        v[1] += v[0];
40        v[idx & 1] += v[2];
41    
42        t += v;
43    }
44   
45    outputBuffer[idx] = t.x + t.y + t.z;
46}