summaryrefslogtreecommitdiffstats
path: root/tests/glsl-intrinsic/shader-invocation-control/shader-invocation-control.slang
blob: 4edb249f8c62ea186e926187960c2895623a4a2f (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
39
40
//TEST:SIMPLE(filecheck=CHECK_GLSL):  -allow-glsl -stage compute -entry computeMain -target glsl
//TEST:SIMPLE(filecheck=CHECK_SPV):  -allow-glsl -stage compute -entry computeMain -target spirv -emit-spirv-directly
//TEST(compute, vulkan):COMPARE_COMPUTE(filecheck-buffer=BUF):-vk -compute -entry computeMain -allow-glsl
//TEST(compute, vulkan):COMPARE_COMPUTE(filecheck-buffer=BUF):-vk -compute -entry computeMain -allow-glsl -emit-spirv-directly

#version 460

groupshared uint raceConditionShared;

//TEST_INPUT:ubuffer(data=[0], stride=4):out,name=outputBuffer
buffer MyBlockName2
{
    uint data[];
} outputBuffer;

layout(local_size_x = 4) in;
bool testBarrier()
{
    for (int i = 0; i < 4; i++)
    {
        raceConditionShared = 3;
        barrier();
        raceConditionShared = 1;
        if (raceConditionShared != 1)
            return false;
    }
    return true
        && raceConditionShared == 1
        ;
}

void computeMain()
{
    outputBuffer.data[0] = true
        && testBarrier()
        ;
    // CHECK_GLSL: void main(
    // CHECK_SPV: OpEntryPoint
    // BUF: 1
}