summaryrefslogtreecommitdiffstats
path: root/tests/language-feature/spirv-asm/id-wrap.slang
blob: 178ce344eec42edf3260e3e4283ff7f96ce55892 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -shaderobj -emit-spirv-directly

//TEST_INPUT:ubuffer(data=[1 2 3 4], stride=4):out,name=outputBuffer
RWStructuredBuffer<int> outputBuffer;

// CHECK:      2
// CHECK-NEXT: 4
// CHECK-NEXT: 6
// CHECK-NEXT: 8

//
// This test tests that we correctly wrap constants in ids when required and
// can look up names through that wrapped operand kind
//
[numthreads(4, 1, 1)]
void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
{
    int i = dispatchThreadID.x;
    int n = outputBuffer[i];
    int r = spirv_asm
    {
        OpConstant $$int %two 2;
        // A dummy barrier, this tests that we can look up these names without
        // their Scope and MemorySemantics prefixes, and correctly wrap them in
        // OpConstant.
        OpMemoryBarrier Invocation
            // Test that an unqualified enum works
              AcquireRelease
            // Test that a decimal integer literal works
            | 64
            // Test that a hex integer literal works
            | 0x800
            // Test that an explicit scope works
            | MemorySemanticsAtomicCounterMemory;
        OpIMul $$int result $n %two
    };
    outputBuffer[i] = r;
}