summaryrefslogtreecommitdiff
path: root/tests/metal/atomic-texture-texture1d.slang
blob: 746021fd6d6366e52c1fcb3912f16354a552d81e (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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
//TEST:SIMPLE(filecheck=METAL): -target metal -stage compute -entry computeMain
//TEST:SIMPLE(filecheck=METALLIB): -target metallib -stage compute -entry computeMain

//METALLIB: @computeMain

RWTexture1D<uint> uintTexture1D;
RWTexture1D<int> intTexture1D;

RWTexture1DArray<uint> uintTexture1DArray;
RWTexture1DArray<int> intTexture1DArray;

void test()
{
    int valInt = 1;
    int originalValueInt;
    int compareValueInt = 1;

    uint valUInt = 1;
    uint originalValueUInt;
    int compareValueUInt = 1;

    // Texture1D
// METAL: .atomic_fetch_add
// METAL: .atomic_fetch_and
// METAL: .atomic_fetch_max
// METAL: .atomic_fetch_min
// METAL: .atomic_fetch_or
// METAL: .atomic_fetch_xor
// METAL: .atomic_fetch_add
// METAL: .atomic_fetch_and
// METAL: .atomic_fetch_max
// METAL: .atomic_fetch_min
// METAL: .atomic_fetch_or
// METAL: .atomic_fetch_xor
// METAL: .atomic_exchange
// METAL: .atomic_compare_exchange_weak
// METAL: .atomic_compare_exchange_weak

// METAL: .atomic_fetch_add
// METAL: .atomic_fetch_and
// METAL: .atomic_fetch_max
// METAL: .atomic_fetch_min
// METAL: .atomic_fetch_or
// METAL: .atomic_fetch_xor
// METAL: .atomic_fetch_add
// METAL: .atomic_fetch_and
// METAL: .atomic_fetch_max
// METAL: .atomic_fetch_min
// METAL: .atomic_fetch_or
// METAL: .atomic_fetch_xor
// METAL: .atomic_exchange
// METAL: .atomic_compare_exchange_weak
// METAL: .atomic_compare_exchange_weak
	InterlockedAdd(intTexture1D[0], valInt);
	InterlockedAnd(intTexture1D[0], valInt);
	InterlockedMax(intTexture1D[0], valInt);
	InterlockedMin(intTexture1D[0], valInt);
	InterlockedOr(intTexture1D[0], valInt);
	InterlockedXor(intTexture1D[0], valInt);
	InterlockedAdd(intTexture1D[0], valInt, originalValueInt);
	InterlockedAnd(intTexture1D[0], valInt, originalValueInt);
	InterlockedMax(intTexture1D[0], valInt, originalValueInt);
	InterlockedMin(intTexture1D[0], valInt, originalValueInt);
	InterlockedOr(intTexture1D[0], valInt, originalValueInt);
	InterlockedXor(intTexture1D[0], valInt, originalValueInt);
	InterlockedExchange(intTexture1D[0], valInt, originalValueInt);
	InterlockedCompareExchange(intTexture1D[0], valInt, compareValueInt, originalValueInt);
	InterlockedCompareStore(intTexture1D[0], valInt, compareValueUInt);

	InterlockedAdd(uintTexture1D[0], valUInt);
	InterlockedAnd(uintTexture1D[0], valUInt);
	InterlockedMax(uintTexture1D[0], valUInt);
	InterlockedMin(uintTexture1D[0], valUInt);
	InterlockedOr(uintTexture1D[0], valUInt);
	InterlockedXor(uintTexture1D[0], valUInt);
	InterlockedAdd(uintTexture1D[0], valUInt, originalValueUInt);
	InterlockedAnd(uintTexture1D[0], valUInt, originalValueUInt);
	InterlockedMax(uintTexture1D[0], valUInt, originalValueUInt);
	InterlockedMin(uintTexture1D[0], valUInt, originalValueUInt);
	InterlockedOr(uintTexture1D[0], valUInt, originalValueUInt);
	InterlockedXor(uintTexture1D[0], valUInt, originalValueUInt);
	InterlockedExchange(uintTexture1D[0], valUInt, originalValueUInt);
	InterlockedCompareExchange(uintTexture1D[0], valUInt, compareValueUInt, originalValueUInt);
	InterlockedCompareStore(uintTexture1D[0], valUInt, compareValueUInt);

    // Texture1DArray
// METAL: .atomic_fetch_add
// METAL: .atomic_fetch_and
// METAL: .atomic_fetch_max
// METAL: .atomic_fetch_min
// METAL: .atomic_fetch_or
// METAL: .atomic_fetch_xor
// METAL: .atomic_fetch_add
// METAL: .atomic_fetch_and
// METAL: .atomic_fetch_max
// METAL: .atomic_fetch_min
// METAL: .atomic_fetch_or
// METAL: .atomic_fetch_xor
// METAL: .atomic_exchange
// METAL: .atomic_compare_exchange_weak
// METAL: .atomic_compare_exchange_weak

// METAL: .atomic_fetch_add
// METAL: .atomic_fetch_and
// METAL: .atomic_fetch_max
// METAL: .atomic_fetch_min
// METAL: .atomic_fetch_or
// METAL: .atomic_fetch_xor
// METAL: .atomic_fetch_add
// METAL: .atomic_fetch_and
// METAL: .atomic_fetch_max
// METAL: .atomic_fetch_min
// METAL: .atomic_fetch_or
// METAL: .atomic_fetch_xor
// METAL: .atomic_exchange
// METAL: .atomic_compare_exchange_weak
// METAL: .atomic_compare_exchange_weak
	InterlockedAdd(intTexture1DArray[0], valInt);
	InterlockedAnd(intTexture1DArray[0], valInt);
	InterlockedMax(intTexture1DArray[0], valInt);
	InterlockedMin(intTexture1DArray[0], valInt);
	InterlockedOr(intTexture1DArray[0], valInt);
	InterlockedXor(intTexture1DArray[0], valInt);
	InterlockedAdd(intTexture1DArray[0], valInt, originalValueInt);
	InterlockedAnd(intTexture1DArray[0], valInt, originalValueInt);
	InterlockedMax(intTexture1DArray[0], valInt, originalValueInt);
	InterlockedMin(intTexture1DArray[0], valInt, originalValueInt);
	InterlockedOr(intTexture1DArray[0], valInt, originalValueInt);
	InterlockedXor(intTexture1DArray[0], valInt, originalValueInt);
	InterlockedExchange(intTexture1DArray[0], valInt, originalValueInt);
	InterlockedCompareExchange(intTexture1DArray[0], valInt, compareValueInt, originalValueInt);
	InterlockedCompareStore(intTexture1DArray[0], valUInt, compareValueUInt);

	InterlockedAdd(uintTexture1DArray[0], valUInt);
	InterlockedAnd(uintTexture1DArray[0], valUInt);
	InterlockedMax(uintTexture1DArray[0], valUInt);
	InterlockedMin(uintTexture1DArray[0], valUInt);
	InterlockedOr(uintTexture1DArray[0], valUInt);
	InterlockedXor(uintTexture1DArray[0], valUInt);
	InterlockedAdd(uintTexture1DArray[0], valUInt, originalValueUInt);
	InterlockedAnd(uintTexture1DArray[0], valUInt, originalValueUInt);
	InterlockedMax(uintTexture1DArray[0], valUInt, originalValueUInt);
	InterlockedMin(uintTexture1DArray[0], valUInt, originalValueUInt);
	InterlockedOr(uintTexture1DArray[0], valUInt, originalValueUInt);
	InterlockedXor(uintTexture1DArray[0], valUInt, originalValueUInt);
	InterlockedExchange(uintTexture1DArray[0], valUInt, originalValueUInt);
	InterlockedCompareExchange(uintTexture1DArray[0], valUInt, compareValueUInt, originalValueUInt);
	InterlockedCompareStore(uintTexture1DArray[0], valUInt, compareValueUInt);
}

[numthreads(1, 1, 1)]
void computeMain()
{
    test();
}