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.8 KiB68 linesraw
1//DISABLED_TEST(compute, vulkan):COMPARE_COMPUTE_EX():-vk -compute -shaderobj -output-using-type -render-features wave-ops
2//DISABLED_TEST(compute):COMPARE_COMPUTE_EX():-dx12 -profile sm_6_5 -compute -shaderobj -output-using-type -render-features wave-ops
3
4//
5// This test checks whether more than 2 adjacent calls to saturated_cooperation
6// are fused, even with operations between them
7//
8
9//TEST_INPUT:ubuffer(data=[0 3 2 2], stride=4):out,name=outputBuffer
10RWStructuredBuffer<int> outputBuffer;
11
12static int count = 0;
13
14int coopAdd(float x, int i)
15{
16    count += i;
17    return int(x) * 2;
18}
19
20int fallback(float x, int)
21{
22    count = -1;
23    return -1;
24}
25
26int coopMul(float x, float f)
27{
28    count *= int(f);
29    return int(x) * 2;
30}
31
32int fallback2(float x, float)
33{
34    count = -1;
35    return -1;
36}
37
38int coopExp(float x, int i)
39{
40    int c = count;
41    count = 1;
42    for(int j = 0; j < i; ++j)
43        count *= c;
44    return int(x) * 2;
45}
46
47// Make sure that we have enough invocations to saturate the first workgroup
48[numthreads(128, 1, 1)]
49void computeMain(uint tig : SV_GroupIndex)
50{
51    // The values we're cooperating over are {0, 2, 3}
52    // We track the number of sets evaluated in the "count" variable, and write
53    // that at index 0
54    //
55    // If these are not fused, then we'd expect count to be incremented three
56    // times then doubled three times. What we want to see is
57    // 0, +1, *2, **2, +1, *2, **2, +1, *2, **2 = 40804
58    let i = tig < 4 ? float(outputBuffer[tig]) : 0;
59    let y = saturated_cooperation(coopAdd, fallback, i, 1);
60    let m = 2.f;
61    let x = saturated_cooperation(coopMul, fallback2, i, m);
62    // Put some calculation between the calls to check that the fusion still takes place
63    let e = min(m*100, 2);
64    let z = saturated_cooperation(coopExp, fallback, i, int(e));
65    if(tig < 4)
66        outputBuffer[tig] = tig == 0 ? count : z;
67
68}