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
2.2 KiB75 linesraw
1//TEST_CATEGORY(wave, compute)
2//DISABLE_TEST:COMPARE_COMPUTE_EX:-cpu -compute -shaderobj
3//DISABLE_TEST:COMPARE_COMPUTE_EX:-slang -compute -shaderobj
4
5//TEST:COMPARE_COMPUTE_EX:-slang -compute -dx12 -profile sm_6_5 -shaderobj
6//TEST:COMPARE_COMPUTE_EX:-vk -compute -shaderobj
7//TEST:COMPARE_COMPUTE_EX:-cuda -compute -capability cuda_sm_7_0 -shaderobj
8
9//TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0], stride=4):out,name outputBuffer
10RWStructuredBuffer<uint> outputBuffer;
11
12[numthreads(8, 1, 1)]
13[shader("compute")]
14void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
15{
16    uint index = int(dispatchThreadID.x);
17
18    // Split into two groups.
19    uint4 mask = 0b00001111;
20    if (index >=  4)
21    {
22        mask = 0b11110000;
23    }
24
25    //
26    // WaveMultiPrefixSum.
27    // Results in hex: [0 1 3 7], [0 10 30 70]
28    //
29    uint sumValue = WaveMultiPrefixSum(1 << index, mask);
30    const uint sumBaseIndex = 0;
31    outputBuffer[sumBaseIndex + index] = sumValue;
32
33    //
34    // WaveMultiPrefixProduct.
35    // Results in hex: [1 1 2 8], [1 10 200 8000]
36    //
37    uint productValue = WaveMultiPrefixProduct(1 << index, mask);
38    const uint productBaseIndex = 8;
39    outputBuffer[productBaseIndex + index] = productValue;
40
41    //
42    // WaveMultiPrefixBitAnd.
43    // This prefix operation starts with all bits set.
44    // Results in hex: [FFFFFFFF 1 1 1], [FFFFFFFF F F F]
45    //
46    uint andBits = 0b1;
47    if (index >= 4)
48    {
49        andBits = 0b1111;
50    }
51    uint andValue = WaveMultiPrefixBitAnd(andBits, mask);
52    const uint andBaseIndex = 16;
53    outputBuffer[andBaseIndex + index] = andValue;
54
55    //
56    // WaveMultiPrefixBitOr.
57    // Results in hex: [0 1 3 7], [0 10 30 70]
58    //
59    uint orValue = WaveMultiPrefixBitOr(1 << index, mask);
60    const uint orBaseIndex = 24;
61    outputBuffer[orBaseIndex + index] = orValue;
62
63    //
64    // WaveMultiPrefixBitXor.
65    // Results in hex: [0 1 3 7], [0 F 0 F]
66    //
67    uint xorBits = (1 << index);
68    if (index >= 4)
69    {
70        xorBits = 0b1111;
71    }
72    uint xorValue = WaveMultiPrefixBitXor(xorBits, mask);
73    const uint xorBaseIndex = 32;
74    outputBuffer[xorBaseIndex + index] = xorValue;
75}