summaryrefslogtreecommitdiffstats
path: root/tests/glsl-intrinsic/image/imageAsParamWithMemoryQualifiers.slang
blob: b0592980a77d51ab6090fc73e7ba9034af047be7 (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
41
42
43
44
45
46
47
48
49
50
51
52
53
//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

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

layout(local_size_x = 4) in;

// The memory qualifier `restrict` is allowed to be dropped
// when passing a variable into a function as an argument.

//CHECK_SPV: OpEntryPoint

//CHECK_GLSL: {{(restrict|writeonly|readonly)}} {{(restrict|writeonly|readonly)}} {{(restrict|writeonly|readonly)}}
//CHECK_SPV: OpDecorate %{{.*}} {{(Restrict|NonWritable|NonReadable)}}
//CHECK_SPV: OpDecorate %{{.*}} {{(Restrict|NonWritable|NonReadable)}}
//CHECK_SPV: OpDecorate %{{.*}} {{(Restrict|NonWritable|NonReadable)}}
//TEST_INPUT: set someImage = RWTexture2D(format=RGBA16Float, size=1, content=one, mipMaps = 1)
uniform layout(binding=0,rgba16f) restrict writeonly readonly image2D someImage;

//CHECK_GLSL: writeonly
//CHECK_SPV: OpDecorate {{.*}} {{(Restrict|NonWritable|NonReadable)}}
//TEST_INPUT: set someImage2 = RWTexture2D(format=RGBA16Float, size=1, content=one, mipMaps = 1)
uniform layout(binding=1,rgba16f) writeonly image2D someImage2;

bool checkAllImageSizesParamSameQualifiers(writeonly readonly image2D val)
{
    return true
        && imageSize(val) == ivec2(1)
        ;
}
bool checkAllImageSizesParamMoreQualifiers(readonly writeonly image2D val)
{
    return true
        && imageSize(val) == ivec2(1)
        ;
}

// CHECK_GLSL: void main(
void computeMain()
{
    outputBuffer.data[0] = true
        && checkAllImageSizesParamSameQualifiers(someImage)
        && checkAllImageSizesParamMoreQualifiers(someImage2)
        ;
    // BUF: 1

}