summaryrefslogtreecommitdiffstats
path: root/tests/spirv/capability-uniform-and-storage.slang
blob: 665a6b91a68337785bf081ce038bd7fb0e483979 (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
54
55
56
57
58
59
60
61
62
63
64
65
//TEST:SIMPLE(filecheck=CHECK8): -target spirv -profile spirv_1_3 -DIN_UINT8
//TEST:SIMPLE(filecheck=CHECK16): -target spirv -profile spirv_1_3 -DIN_UINT16
//TEST:SIMPLE(filecheck=CHECK16): -target spirv -profile spirv_1_3 -DIN_HALF
//TEST:SIMPLE(filecheck=CHECKBOTH): -target spirv -profile spirv_1_3 -DIN_UINT8 -DIN_HALF
//TEST:SIMPLE(filecheck=CHECK8): -target spirv -profile spirv_1_3 -DOUT_UINT8
//TEST:SIMPLE(filecheck=CHECK16): -target spirv -profile spirv_1_3 -DOUT_UINT16
//TEST:SIMPLE(filecheck=CHECK16): -target spirv -profile spirv_1_3 -DOUT_HALF
//TEST:SIMPLE(filecheck=CHECK16): -target spirv -profile spirv_1_3 -DOUT_HALF -DATOMIC
//TEST:SIMPLE(filecheck=CHECK): -target spirv -profile spirv_1_3

//CHECK8: OpCapability UniformAndStorageBuffer8BitAccess
//CHECK8-NOT: OpCapability UniformAndStorageBuffer16BitAccess
//CHECK16: OpCapability UniformAndStorageBuffer16BitAccess
//CHECK16-NOT: OpCapability UniformAndStorageBuffer8BitAccess
//CHECKBOTH-DAG: OpCapability UniformAndStorageBuffer8BitAccess
//CHECKBOTH-DAG: OpCapability UniformAndStorageBuffer16BitAccess
//CHECK-NOT: OpCapability UniformAndStorageBuffer8BitAccess
//CHECK-NOT: OpCapability UniformAndStorageBuffer16BitAccess


uniform struct {
#if defined(IN_HALF)
    half4 data;
#else
    float4 data;
#endif
#if defined(IN_UINT8)
    uint8_t index;
#elif defined(IN_UINT16)
    uint16_t index;
#else
    uint32_t index;
#endif
} inputBuffer;

#if defined(OUT_HALF)
#define OUT_FLOAT_TYPE half
#else
#define OUT_FLOAT_TYPE float
#endif
#if defined(OUT_UINT8)
#define OUT_UINT_TYPE uint8_t
#elif defined(OUT_UINT16)
#define OUT_UINT_TYPE uint16_t
#else
#define OUT_UINT_TYPE uint32_t
#endif

struct st {
#if defined(ATOMIC)
    Atomic<OUT_FLOAT_TYPE> data;
#else
    OUT_FLOAT_TYPE data;
#endif
    OUT_UINT_TYPE index;
};
RWStructuredBuffer<st> outputBuffer;

[shader("compute")]
[numthreads(1, 1, 1)]
void computeMain()
{
    outputBuffer[0].data = OUT_FLOAT_TYPE(inputBuffer.data.x);
    outputBuffer[1].index = OUT_UINT_TYPE(inputBuffer.index);
}