1bf215546Sopenharmony_ci/*
2bf215546Sopenharmony_ci * Copyright © 2020 Valve Corporation
3bf215546Sopenharmony_ci *
4bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a
5bf215546Sopenharmony_ci * copy of this software and associated documentation files (the "Software"),
6bf215546Sopenharmony_ci * to deal in the Software without restriction, including without limitation
7bf215546Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8bf215546Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the
9bf215546Sopenharmony_ci * Software is furnished to do so, subject to the following conditions:
10bf215546Sopenharmony_ci *
11bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the next
12bf215546Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the
13bf215546Sopenharmony_ci * Software.
14bf215546Sopenharmony_ci *
15bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16bf215546Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18bf215546Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19bf215546Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20bf215546Sopenharmony_ci * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21bf215546Sopenharmony_ci * IN THE SOFTWARE.
22bf215546Sopenharmony_ci */
23bf215546Sopenharmony_ci#include "helpers.h"
24bf215546Sopenharmony_ci
25bf215546Sopenharmony_ciTEST_F(spirv_test, opload_volatile)
26bf215546Sopenharmony_ci{
27bf215546Sopenharmony_ci   /*
28bf215546Sopenharmony_ci               OpCapability Shader
29bf215546Sopenharmony_ci          %1 = OpExtInstImport "GLSL.std.450"
30bf215546Sopenharmony_ci               OpMemoryModel Logical GLSL450
31bf215546Sopenharmony_ci               OpEntryPoint GLCompute %4 "main"
32bf215546Sopenharmony_ci               OpExecutionMode %4 LocalSize 1 1 1
33bf215546Sopenharmony_ci               OpMemberDecorate %_struct_7 0 Offset 0
34bf215546Sopenharmony_ci               OpDecorate %_struct_7 BufferBlock
35bf215546Sopenharmony_ci               OpDecorate %9 DescriptorSet 0
36bf215546Sopenharmony_ci               OpDecorate %9 Binding 0
37bf215546Sopenharmony_ci       %void = OpTypeVoid
38bf215546Sopenharmony_ci          %3 = OpTypeFunction %void
39bf215546Sopenharmony_ci       %uint = OpTypeInt 32 0
40bf215546Sopenharmony_ci  %_struct_7 = OpTypeStruct %uint
41bf215546Sopenharmony_ci%_ptr_Uniform__struct_7 = OpTypePointer Uniform %_struct_7
42bf215546Sopenharmony_ci          %9 = OpVariable %_ptr_Uniform__struct_7 Uniform
43bf215546Sopenharmony_ci        %int = OpTypeInt 32 1
44bf215546Sopenharmony_ci      %int_0 = OpConstant %int 0
45bf215546Sopenharmony_ci%_ptr_Uniform_uint = OpTypePointer Uniform %uint
46bf215546Sopenharmony_ci          %4 = OpFunction %void None %3
47bf215546Sopenharmony_ci          %5 = OpLabel
48bf215546Sopenharmony_ci         %13 = OpAccessChain %_ptr_Uniform_uint %9 %int_0
49bf215546Sopenharmony_ci         %14 = OpLoad %uint %13 Volatile
50bf215546Sopenharmony_ci               OpStore %13 %14
51bf215546Sopenharmony_ci               OpReturn
52bf215546Sopenharmony_ci               OpFunctionEnd
53bf215546Sopenharmony_ci   */
54bf215546Sopenharmony_ci   static const uint32_t words[] = {
55bf215546Sopenharmony_ci      0x07230203, 0x00010300, 0x00070000, 0x0000000f, 0x00000000, 0x00020011,
56bf215546Sopenharmony_ci      0x00000001, 0x0006000b, 0x00000001, 0x4c534c47, 0x6474732e, 0x3035342e,
57bf215546Sopenharmony_ci      0x00000000, 0x0003000e, 0x00000000, 0x00000001, 0x0005000f, 0x00000005,
58bf215546Sopenharmony_ci      0x00000002, 0x6e69616d, 0x00000000, 0x00060010, 0x00000002, 0x00000011,
59bf215546Sopenharmony_ci      0x00000001, 0x00000001, 0x00000001, 0x00050048, 0x00000003, 0x00000000,
60bf215546Sopenharmony_ci      0x00000023, 0x00000000, 0x00030047, 0x00000003, 0x00000003, 0x00040047,
61bf215546Sopenharmony_ci      0x00000004, 0x00000022, 0x00000000, 0x00040047, 0x00000004, 0x00000021,
62bf215546Sopenharmony_ci      0x00000000, 0x00020013, 0x00000005, 0x00030021, 0x00000006, 0x00000005,
63bf215546Sopenharmony_ci      0x00040015, 0x00000007, 0x00000020, 0x00000000, 0x0003001e, 0x00000003,
64bf215546Sopenharmony_ci      0x00000007, 0x00040020, 0x00000008, 0x00000002, 0x00000003, 0x0004003b,
65bf215546Sopenharmony_ci      0x00000008, 0x00000004, 0x00000002, 0x00040015, 0x00000009, 0x00000020,
66bf215546Sopenharmony_ci      0x00000001, 0x0004002b, 0x00000009, 0x0000000a, 0x00000000, 0x00040020,
67bf215546Sopenharmony_ci      0x0000000b, 0x00000002, 0x00000007, 0x00050036, 0x00000005, 0x00000002,
68bf215546Sopenharmony_ci      0x00000000, 0x00000006, 0x000200f8, 0x0000000c, 0x00050041, 0x0000000b,
69bf215546Sopenharmony_ci      0x0000000d, 0x00000004, 0x0000000a, 0x0005003d, 0x00000007, 0x0000000e,
70bf215546Sopenharmony_ci      0x0000000d, 0x00000001, 0x0003003e, 0x0000000d, 0x0000000e, 0x000100fd,
71bf215546Sopenharmony_ci      0x00010038,
72bf215546Sopenharmony_ci   };
73bf215546Sopenharmony_ci
74bf215546Sopenharmony_ci   get_nir(sizeof(words) / sizeof(words[0]), words);
75bf215546Sopenharmony_ci
76bf215546Sopenharmony_ci   nir_intrinsic_instr *intrinsic = find_intrinsic(nir_intrinsic_load_deref);
77bf215546Sopenharmony_ci   ASSERT_NE(intrinsic, nullptr);
78bf215546Sopenharmony_ci   EXPECT_NE(nir_intrinsic_access(intrinsic) & ACCESS_VOLATILE, 0);
79bf215546Sopenharmony_ci}
80bf215546Sopenharmony_ci
81bf215546Sopenharmony_ciTEST_F(spirv_test, opstore_volatile)
82bf215546Sopenharmony_ci{
83bf215546Sopenharmony_ci   /*
84bf215546Sopenharmony_ci               OpCapability Shader
85bf215546Sopenharmony_ci          %1 = OpExtInstImport "GLSL.std.450"
86bf215546Sopenharmony_ci               OpMemoryModel Logical GLSL450
87bf215546Sopenharmony_ci               OpEntryPoint GLCompute %4 "main"
88bf215546Sopenharmony_ci               OpExecutionMode %4 LocalSize 1 1 1
89bf215546Sopenharmony_ci               OpMemberDecorate %_struct_7 0 Offset 0
90bf215546Sopenharmony_ci               OpDecorate %_struct_7 BufferBlock
91bf215546Sopenharmony_ci               OpDecorate %9 DescriptorSet 0
92bf215546Sopenharmony_ci               OpDecorate %9 Binding 0
93bf215546Sopenharmony_ci       %void = OpTypeVoid
94bf215546Sopenharmony_ci          %3 = OpTypeFunction %void
95bf215546Sopenharmony_ci       %uint = OpTypeInt 32 0
96bf215546Sopenharmony_ci  %_struct_7 = OpTypeStruct %uint
97bf215546Sopenharmony_ci%_ptr_Uniform__struct_7 = OpTypePointer Uniform %_struct_7
98bf215546Sopenharmony_ci          %9 = OpVariable %_ptr_Uniform__struct_7 Uniform
99bf215546Sopenharmony_ci        %int = OpTypeInt 32 1
100bf215546Sopenharmony_ci      %int_0 = OpConstant %int 0
101bf215546Sopenharmony_ci%_ptr_Uniform_uint = OpTypePointer Uniform %uint
102bf215546Sopenharmony_ci          %4 = OpFunction %void None %3
103bf215546Sopenharmony_ci          %5 = OpLabel
104bf215546Sopenharmony_ci         %13 = OpAccessChain %_ptr_Uniform_uint %9 %int_0
105bf215546Sopenharmony_ci         %14 = OpLoad %uint %13
106bf215546Sopenharmony_ci               OpStore %13 %14 Volatile
107bf215546Sopenharmony_ci               OpReturn
108bf215546Sopenharmony_ci               OpFunctionEnd
109bf215546Sopenharmony_ci   */
110bf215546Sopenharmony_ci   static const uint32_t words[] = {
111bf215546Sopenharmony_ci      0x07230203, 0x00010300, 0x00070000, 0x0000000f, 0x00000000, 0x00020011,
112bf215546Sopenharmony_ci      0x00000001, 0x0006000b, 0x00000001, 0x4c534c47, 0x6474732e, 0x3035342e,
113bf215546Sopenharmony_ci      0x00000000, 0x0003000e, 0x00000000, 0x00000001, 0x0005000f, 0x00000005,
114bf215546Sopenharmony_ci      0x00000002, 0x6e69616d, 0x00000000, 0x00060010, 0x00000002, 0x00000011,
115bf215546Sopenharmony_ci      0x00000001, 0x00000001, 0x00000001, 0x00050048, 0x00000003, 0x00000000,
116bf215546Sopenharmony_ci      0x00000023, 0x00000000, 0x00030047, 0x00000003, 0x00000003, 0x00040047,
117bf215546Sopenharmony_ci      0x00000004, 0x00000022, 0x00000000, 0x00040047, 0x00000004, 0x00000021,
118bf215546Sopenharmony_ci      0x00000000, 0x00020013, 0x00000005, 0x00030021, 0x00000006, 0x00000005,
119bf215546Sopenharmony_ci      0x00040015, 0x00000007, 0x00000020, 0x00000000, 0x0003001e, 0x00000003,
120bf215546Sopenharmony_ci      0x00000007, 0x00040020, 0x00000008, 0x00000002, 0x00000003, 0x0004003b,
121bf215546Sopenharmony_ci      0x00000008, 0x00000004, 0x00000002, 0x00040015, 0x00000009, 0x00000020,
122bf215546Sopenharmony_ci      0x00000001, 0x0004002b, 0x00000009, 0x0000000a, 0x00000000, 0x00040020,
123bf215546Sopenharmony_ci      0x0000000b, 0x00000002, 0x00000007, 0x00050036, 0x00000005, 0x00000002,
124bf215546Sopenharmony_ci      0x00000000, 0x00000006, 0x000200f8, 0x0000000c, 0x00050041, 0x0000000b,
125bf215546Sopenharmony_ci      0x0000000d, 0x00000004, 0x0000000a, 0x0004003d, 0x00000007, 0x0000000e,
126bf215546Sopenharmony_ci      0x0000000d, 0x0004003e, 0x0000000d, 0x0000000e, 0x00000001, 0x000100fd,
127bf215546Sopenharmony_ci      0x00010038,
128bf215546Sopenharmony_ci   };
129bf215546Sopenharmony_ci
130bf215546Sopenharmony_ci   get_nir(sizeof(words) / sizeof(words[0]), words);
131bf215546Sopenharmony_ci
132bf215546Sopenharmony_ci   nir_intrinsic_instr *intrinsic = find_intrinsic(nir_intrinsic_store_deref);
133bf215546Sopenharmony_ci   ASSERT_NE(intrinsic, nullptr);
134bf215546Sopenharmony_ci   EXPECT_NE(nir_intrinsic_access(intrinsic) & ACCESS_VOLATILE, 0);
135bf215546Sopenharmony_ci}
136bf215546Sopenharmony_ci
137bf215546Sopenharmony_ciTEST_F(spirv_test, opcopymemory_volatile_both)
138bf215546Sopenharmony_ci{
139bf215546Sopenharmony_ci   /*
140bf215546Sopenharmony_ci               OpCapability Shader
141bf215546Sopenharmony_ci          %1 = OpExtInstImport "GLSL.std.450"
142bf215546Sopenharmony_ci               OpMemoryModel Logical GLSL450
143bf215546Sopenharmony_ci               OpEntryPoint GLCompute %4 "main"
144bf215546Sopenharmony_ci               OpExecutionMode %4 LocalSize 1 1 1
145bf215546Sopenharmony_ci               OpMemberDecorate %_struct_7 0 Offset 0
146bf215546Sopenharmony_ci               OpDecorate %_struct_7 BufferBlock
147bf215546Sopenharmony_ci               OpDecorate %9 DescriptorSet 0
148bf215546Sopenharmony_ci               OpDecorate %9 Binding 0
149bf215546Sopenharmony_ci       %void = OpTypeVoid
150bf215546Sopenharmony_ci          %3 = OpTypeFunction %void
151bf215546Sopenharmony_ci       %uint = OpTypeInt 32 0
152bf215546Sopenharmony_ci  %_struct_7 = OpTypeStruct %uint
153bf215546Sopenharmony_ci%_ptr_Uniform__struct_7 = OpTypePointer Uniform %_struct_7
154bf215546Sopenharmony_ci          %9 = OpVariable %_ptr_Uniform__struct_7 Uniform
155bf215546Sopenharmony_ci        %int = OpTypeInt 32 1
156bf215546Sopenharmony_ci      %int_0 = OpConstant %int 0
157bf215546Sopenharmony_ci%_ptr_Uniform_uint = OpTypePointer Uniform %uint
158bf215546Sopenharmony_ci          %4 = OpFunction %void None %3
159bf215546Sopenharmony_ci          %5 = OpLabel
160bf215546Sopenharmony_ci         %13 = OpAccessChain %_ptr_Uniform_uint %9 %int_0
161bf215546Sopenharmony_ci               OpCopyMemory %13 %13 Volatile
162bf215546Sopenharmony_ci               OpReturn
163bf215546Sopenharmony_ci               OpFunctionEnd
164bf215546Sopenharmony_ci   */
165bf215546Sopenharmony_ci   static const uint32_t words[] = {
166bf215546Sopenharmony_ci      0x07230203, 0x00010300, 0x00070000, 0x0000000e, 0x00000000, 0x00020011,
167bf215546Sopenharmony_ci      0x00000001, 0x0006000b, 0x00000001, 0x4c534c47, 0x6474732e, 0x3035342e,
168bf215546Sopenharmony_ci      0x00000000, 0x0003000e, 0x00000000, 0x00000001, 0x0005000f, 0x00000005,
169bf215546Sopenharmony_ci      0x00000002, 0x6e69616d, 0x00000000, 0x00060010, 0x00000002, 0x00000011,
170bf215546Sopenharmony_ci      0x00000001, 0x00000001, 0x00000001, 0x00050048, 0x00000003, 0x00000000,
171bf215546Sopenharmony_ci      0x00000023, 0x00000000, 0x00030047, 0x00000003, 0x00000003, 0x00040047,
172bf215546Sopenharmony_ci      0x00000004, 0x00000022, 0x00000000, 0x00040047, 0x00000004, 0x00000021,
173bf215546Sopenharmony_ci      0x00000000, 0x00020013, 0x00000005, 0x00030021, 0x00000006, 0x00000005,
174bf215546Sopenharmony_ci      0x00040015, 0x00000007, 0x00000020, 0x00000000, 0x0003001e, 0x00000003,
175bf215546Sopenharmony_ci      0x00000007, 0x00040020, 0x00000008, 0x00000002, 0x00000003, 0x0004003b,
176bf215546Sopenharmony_ci      0x00000008, 0x00000004, 0x00000002, 0x00040015, 0x00000009, 0x00000020,
177bf215546Sopenharmony_ci      0x00000001, 0x0004002b, 0x00000009, 0x0000000a, 0x00000000, 0x00040020,
178bf215546Sopenharmony_ci      0x0000000b, 0x00000002, 0x00000007, 0x00050036, 0x00000005, 0x00000002,
179bf215546Sopenharmony_ci      0x00000000, 0x00000006, 0x000200f8, 0x0000000c, 0x00050041, 0x0000000b,
180bf215546Sopenharmony_ci      0x0000000d, 0x00000004, 0x0000000a, 0x0004003f, 0x0000000d, 0x0000000d,
181bf215546Sopenharmony_ci      0x00000001, 0x000100fd, 0x00010038,
182bf215546Sopenharmony_ci   };
183bf215546Sopenharmony_ci
184bf215546Sopenharmony_ci   get_nir(sizeof(words) / sizeof(words[0]), words);
185bf215546Sopenharmony_ci
186bf215546Sopenharmony_ci   nir_intrinsic_instr *intrinsic = find_intrinsic(nir_intrinsic_load_deref);
187bf215546Sopenharmony_ci   ASSERT_NE(intrinsic, nullptr);
188bf215546Sopenharmony_ci   EXPECT_NE(nir_intrinsic_access(intrinsic) & ACCESS_VOLATILE, 0);
189bf215546Sopenharmony_ci
190bf215546Sopenharmony_ci   intrinsic = find_intrinsic(nir_intrinsic_store_deref);
191bf215546Sopenharmony_ci   ASSERT_NE(intrinsic, nullptr);
192bf215546Sopenharmony_ci   EXPECT_NE(nir_intrinsic_access(intrinsic) & ACCESS_VOLATILE, 0);
193bf215546Sopenharmony_ci}
194bf215546Sopenharmony_ci
195bf215546Sopenharmony_ciTEST_F(spirv_test, opcopymemory_volatile_target)
196bf215546Sopenharmony_ci{
197bf215546Sopenharmony_ci   /*
198bf215546Sopenharmony_ci               OpCapability Shader
199bf215546Sopenharmony_ci          %1 = OpExtInstImport "GLSL.std.450"
200bf215546Sopenharmony_ci               OpMemoryModel Logical GLSL450
201bf215546Sopenharmony_ci               OpEntryPoint GLCompute %4 "main" %9
202bf215546Sopenharmony_ci               OpExecutionMode %4 LocalSize 1 1 1
203bf215546Sopenharmony_ci               OpMemberDecorate %_struct_7 0 Offset 0
204bf215546Sopenharmony_ci               OpDecorate %_struct_7 Block
205bf215546Sopenharmony_ci               OpDecorate %9 DescriptorSet 0
206bf215546Sopenharmony_ci               OpDecorate %9 Binding 0
207bf215546Sopenharmony_ci       %void = OpTypeVoid
208bf215546Sopenharmony_ci          %3 = OpTypeFunction %void
209bf215546Sopenharmony_ci       %uint = OpTypeInt 32 0
210bf215546Sopenharmony_ci  %_struct_7 = OpTypeStruct %uint
211bf215546Sopenharmony_ci%_ptr_StorageBuffer__struct_7 = OpTypePointer StorageBuffer %_struct_7
212bf215546Sopenharmony_ci          %9 = OpVariable %_ptr_StorageBuffer__struct_7 StorageBuffer
213bf215546Sopenharmony_ci        %int = OpTypeInt 32 1
214bf215546Sopenharmony_ci      %int_0 = OpConstant %int 0
215bf215546Sopenharmony_ci%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint
216bf215546Sopenharmony_ci          %4 = OpFunction %void None %3
217bf215546Sopenharmony_ci          %5 = OpLabel
218bf215546Sopenharmony_ci         %13 = OpAccessChain %_ptr_StorageBuffer_uint %9 %int_0
219bf215546Sopenharmony_ci               OpCopyMemory %13 %13 Volatile None
220bf215546Sopenharmony_ci               OpReturn
221bf215546Sopenharmony_ci               OpFunctionEnd
222bf215546Sopenharmony_ci   */
223bf215546Sopenharmony_ci   static const uint32_t words[] = {
224bf215546Sopenharmony_ci      0x07230203, 0x00010500, 0x00070000, 0x0000000e, 0x00000000, 0x00020011,
225bf215546Sopenharmony_ci      0x00000001, 0x0006000b, 0x00000001, 0x4c534c47, 0x6474732e, 0x3035342e,
226bf215546Sopenharmony_ci      0x00000000, 0x0003000e, 0x00000000, 0x00000001, 0x0006000f, 0x00000005,
227bf215546Sopenharmony_ci      0x00000002, 0x6e69616d, 0x00000000, 0x00000003, 0x00060010, 0x00000002,
228bf215546Sopenharmony_ci      0x00000011, 0x00000001, 0x00000001, 0x00000001, 0x00050048, 0x00000004,
229bf215546Sopenharmony_ci      0x00000000, 0x00000023, 0x00000000, 0x00030047, 0x00000004, 0x00000002,
230bf215546Sopenharmony_ci      0x00040047, 0x00000003, 0x00000022, 0x00000000, 0x00040047, 0x00000003,
231bf215546Sopenharmony_ci      0x00000021, 0x00000000, 0x00020013, 0x00000005, 0x00030021, 0x00000006,
232bf215546Sopenharmony_ci      0x00000005, 0x00040015, 0x00000007, 0x00000020, 0x00000000, 0x0003001e,
233bf215546Sopenharmony_ci      0x00000004, 0x00000007, 0x00040020, 0x00000008, 0x0000000c, 0x00000004,
234bf215546Sopenharmony_ci      0x0004003b, 0x00000008, 0x00000003, 0x0000000c, 0x00040015, 0x00000009,
235bf215546Sopenharmony_ci      0x00000020, 0x00000001, 0x0004002b, 0x00000009, 0x0000000a, 0x00000000,
236bf215546Sopenharmony_ci      0x00040020, 0x0000000b, 0x0000000c, 0x00000007, 0x00050036, 0x00000005,
237bf215546Sopenharmony_ci      0x00000002, 0x00000000, 0x00000006, 0x000200f8, 0x0000000c, 0x00050041,
238bf215546Sopenharmony_ci      0x0000000b, 0x0000000d, 0x00000003, 0x0000000a, 0x0005003f, 0x0000000d,
239bf215546Sopenharmony_ci      0x0000000d, 0x00000001, 0x00000000, 0x000100fd, 0x00010038,
240bf215546Sopenharmony_ci   };
241bf215546Sopenharmony_ci
242bf215546Sopenharmony_ci   get_nir(sizeof(words) / sizeof(words[0]), words);
243bf215546Sopenharmony_ci
244bf215546Sopenharmony_ci   nir_intrinsic_instr *intrinsic = find_intrinsic(nir_intrinsic_load_deref);
245bf215546Sopenharmony_ci   ASSERT_NE(intrinsic, nullptr);
246bf215546Sopenharmony_ci   EXPECT_EQ(nir_intrinsic_access(intrinsic) & ACCESS_VOLATILE, 0);
247bf215546Sopenharmony_ci
248bf215546Sopenharmony_ci   intrinsic = find_intrinsic(nir_intrinsic_store_deref);
249bf215546Sopenharmony_ci   ASSERT_NE(intrinsic, nullptr);
250bf215546Sopenharmony_ci   EXPECT_NE(nir_intrinsic_access(intrinsic) & ACCESS_VOLATILE, 0);
251bf215546Sopenharmony_ci}
252bf215546Sopenharmony_ci
253bf215546Sopenharmony_ciTEST_F(spirv_test, opcopymemory_volatile_source)
254bf215546Sopenharmony_ci{
255bf215546Sopenharmony_ci   /*
256bf215546Sopenharmony_ci               OpCapability Shader
257bf215546Sopenharmony_ci          %1 = OpExtInstImport "GLSL.std.450"
258bf215546Sopenharmony_ci               OpMemoryModel Logical GLSL450
259bf215546Sopenharmony_ci               OpEntryPoint GLCompute %4 "main" %9
260bf215546Sopenharmony_ci               OpExecutionMode %4 LocalSize 1 1 1
261bf215546Sopenharmony_ci               OpMemberDecorate %_struct_7 0 Offset 0
262bf215546Sopenharmony_ci               OpDecorate %_struct_7 Block
263bf215546Sopenharmony_ci               OpDecorate %9 DescriptorSet 0
264bf215546Sopenharmony_ci               OpDecorate %9 Binding 0
265bf215546Sopenharmony_ci       %void = OpTypeVoid
266bf215546Sopenharmony_ci          %3 = OpTypeFunction %void
267bf215546Sopenharmony_ci       %uint = OpTypeInt 32 0
268bf215546Sopenharmony_ci  %_struct_7 = OpTypeStruct %uint
269bf215546Sopenharmony_ci%_ptr_StorageBuffer__struct_7 = OpTypePointer StorageBuffer %_struct_7
270bf215546Sopenharmony_ci          %9 = OpVariable %_ptr_StorageBuffer__struct_7 StorageBuffer
271bf215546Sopenharmony_ci        %int = OpTypeInt 32 1
272bf215546Sopenharmony_ci      %int_0 = OpConstant %int 0
273bf215546Sopenharmony_ci%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint
274bf215546Sopenharmony_ci          %4 = OpFunction %void None %3
275bf215546Sopenharmony_ci          %5 = OpLabel
276bf215546Sopenharmony_ci         %13 = OpAccessChain %_ptr_StorageBuffer_uint %9 %int_0
277bf215546Sopenharmony_ci               OpCopyMemory %13 %13 None Volatile
278bf215546Sopenharmony_ci               OpReturn
279bf215546Sopenharmony_ci               OpFunctionEnd
280bf215546Sopenharmony_ci   */
281bf215546Sopenharmony_ci   static const uint32_t words[] = {
282bf215546Sopenharmony_ci      0x07230203, 0x00010500, 0x00070000, 0x0000000e, 0x00000000, 0x00020011,
283bf215546Sopenharmony_ci      0x00000001, 0x0006000b, 0x00000001, 0x4c534c47, 0x6474732e, 0x3035342e,
284bf215546Sopenharmony_ci      0x00000000, 0x0003000e, 0x00000000, 0x00000001, 0x0006000f, 0x00000005,
285bf215546Sopenharmony_ci      0x00000002, 0x6e69616d, 0x00000000, 0x00000003, 0x00060010, 0x00000002,
286bf215546Sopenharmony_ci      0x00000011, 0x00000001, 0x00000001, 0x00000001, 0x00050048, 0x00000004,
287bf215546Sopenharmony_ci      0x00000000, 0x00000023, 0x00000000, 0x00030047, 0x00000004, 0x00000002,
288bf215546Sopenharmony_ci      0x00040047, 0x00000003, 0x00000022, 0x00000000, 0x00040047, 0x00000003,
289bf215546Sopenharmony_ci      0x00000021, 0x00000000, 0x00020013, 0x00000005, 0x00030021, 0x00000006,
290bf215546Sopenharmony_ci      0x00000005, 0x00040015, 0x00000007, 0x00000020, 0x00000000, 0x0003001e,
291bf215546Sopenharmony_ci      0x00000004, 0x00000007, 0x00040020, 0x00000008, 0x0000000c, 0x00000004,
292bf215546Sopenharmony_ci      0x0004003b, 0x00000008, 0x00000003, 0x0000000c, 0x00040015, 0x00000009,
293bf215546Sopenharmony_ci      0x00000020, 0x00000001, 0x0004002b, 0x00000009, 0x0000000a, 0x00000000,
294bf215546Sopenharmony_ci      0x00040020, 0x0000000b, 0x0000000c, 0x00000007, 0x00050036, 0x00000005,
295bf215546Sopenharmony_ci      0x00000002, 0x00000000, 0x00000006, 0x000200f8, 0x0000000c, 0x00050041,
296bf215546Sopenharmony_ci      0x0000000b, 0x0000000d, 0x00000003, 0x0000000a, 0x0005003f, 0x0000000d,
297bf215546Sopenharmony_ci      0x0000000d, 0x00000000, 0x00000001, 0x000100fd, 0x00010038,
298bf215546Sopenharmony_ci   };
299bf215546Sopenharmony_ci
300bf215546Sopenharmony_ci   get_nir(sizeof(words) / sizeof(words[0]), words);
301bf215546Sopenharmony_ci
302bf215546Sopenharmony_ci   nir_intrinsic_instr *intrinsic = find_intrinsic(nir_intrinsic_load_deref);
303bf215546Sopenharmony_ci   ASSERT_NE(intrinsic, nullptr);
304bf215546Sopenharmony_ci   EXPECT_NE(nir_intrinsic_access(intrinsic) & ACCESS_VOLATILE, 0);
305bf215546Sopenharmony_ci
306bf215546Sopenharmony_ci   intrinsic = find_intrinsic(nir_intrinsic_store_deref);
307bf215546Sopenharmony_ci   ASSERT_NE(intrinsic, nullptr);
308bf215546Sopenharmony_ci   EXPECT_EQ(nir_intrinsic_access(intrinsic) & ACCESS_VOLATILE, 0);
309bf215546Sopenharmony_ci}
310bf215546Sopenharmony_ci
311bf215546Sopenharmony_ciTEST_F(spirv_test, opimageread_volatile)
312bf215546Sopenharmony_ci{
313bf215546Sopenharmony_ci   /*
314bf215546Sopenharmony_ci               OpCapability Shader
315bf215546Sopenharmony_ci               OpCapability VulkanMemoryModel
316bf215546Sopenharmony_ci          %1 = OpExtInstImport "GLSL.std.450"
317bf215546Sopenharmony_ci               OpMemoryModel Logical Vulkan
318bf215546Sopenharmony_ci               OpEntryPoint GLCompute %4 "main" %9
319bf215546Sopenharmony_ci               OpExecutionMode %4 LocalSize 1 1 1
320bf215546Sopenharmony_ci               OpDecorate %9 DescriptorSet 0
321bf215546Sopenharmony_ci               OpDecorate %9 Binding 1
322bf215546Sopenharmony_ci       %void = OpTypeVoid
323bf215546Sopenharmony_ci          %3 = OpTypeFunction %void
324bf215546Sopenharmony_ci       %uint = OpTypeInt 32 0
325bf215546Sopenharmony_ci          %7 = OpTypeImage %uint 2D 0 0 0 2 R32ui
326bf215546Sopenharmony_ci%_ptr_UniformConstant_7 = OpTypePointer UniformConstant %7
327bf215546Sopenharmony_ci          %9 = OpVariable %_ptr_UniformConstant_7 UniformConstant
328bf215546Sopenharmony_ci        %int = OpTypeInt 32 1
329bf215546Sopenharmony_ci      %v2int = OpTypeVector %int 2
330bf215546Sopenharmony_ci      %int_0 = OpConstant %int 0
331bf215546Sopenharmony_ci         %14 = OpConstantComposite %v2int %int_0 %int_0
332bf215546Sopenharmony_ci     %v4uint = OpTypeVector %uint 4
333bf215546Sopenharmony_ci     %v3uint = OpTypeVector %uint 3
334bf215546Sopenharmony_ci     %uint_1 = OpConstant %uint 1
335bf215546Sopenharmony_ci          %4 = OpFunction %void None %3
336bf215546Sopenharmony_ci          %5 = OpLabel
337bf215546Sopenharmony_ci         %10 = OpLoad %7 %9
338bf215546Sopenharmony_ci         %15 = OpLoad %7 %9
339bf215546Sopenharmony_ci         %17 = OpImageRead %v4uint %15 %14 VolatileTexel
340bf215546Sopenharmony_ci               OpImageWrite %10 %14 %17
341bf215546Sopenharmony_ci               OpReturn
342bf215546Sopenharmony_ci               OpFunctionEnd
343bf215546Sopenharmony_ci   */
344bf215546Sopenharmony_ci   static const uint32_t words[] = {
345bf215546Sopenharmony_ci      0x07230203, 0x00010500, 0x00070000, 0x00000014, 0x00000000, 0x00020011,
346bf215546Sopenharmony_ci      0x00000001, 0x00020011, 0x000014e1, 0x0006000b, 0x00000001, 0x4c534c47,
347bf215546Sopenharmony_ci      0x6474732e, 0x3035342e, 0x00000000, 0x0003000e, 0x00000000, 0x00000003,
348bf215546Sopenharmony_ci      0x0006000f, 0x00000005, 0x00000002, 0x6e69616d, 0x00000000, 0x00000003,
349bf215546Sopenharmony_ci      0x00060010, 0x00000002, 0x00000011, 0x00000001, 0x00000001, 0x00000001,
350bf215546Sopenharmony_ci      0x00040047, 0x00000003, 0x00000022, 0x00000000, 0x00040047, 0x00000003,
351bf215546Sopenharmony_ci      0x00000021, 0x00000001, 0x00020013, 0x00000004, 0x00030021, 0x00000005,
352bf215546Sopenharmony_ci      0x00000004, 0x00040015, 0x00000006, 0x00000020, 0x00000000, 0x00090019,
353bf215546Sopenharmony_ci      0x00000007, 0x00000006, 0x00000001, 0x00000000, 0x00000000, 0x00000000,
354bf215546Sopenharmony_ci      0x00000002, 0x00000021, 0x00040020, 0x00000008, 0x00000000, 0x00000007,
355bf215546Sopenharmony_ci      0x0004003b, 0x00000008, 0x00000003, 0x00000000, 0x00040015, 0x00000009,
356bf215546Sopenharmony_ci      0x00000020, 0x00000001, 0x00040017, 0x0000000a, 0x00000009, 0x00000002,
357bf215546Sopenharmony_ci      0x0004002b, 0x00000009, 0x0000000b, 0x00000000, 0x0005002c, 0x0000000a,
358bf215546Sopenharmony_ci      0x0000000c, 0x0000000b, 0x0000000b, 0x00040017, 0x0000000d, 0x00000006,
359bf215546Sopenharmony_ci      0x00000004, 0x00040017, 0x0000000e, 0x00000006, 0x00000003, 0x0004002b,
360bf215546Sopenharmony_ci      0x00000006, 0x0000000f, 0x00000001, 0x00050036, 0x00000004, 0x00000002,
361bf215546Sopenharmony_ci      0x00000000, 0x00000005, 0x000200f8, 0x00000010, 0x0004003d, 0x00000007,
362bf215546Sopenharmony_ci      0x00000011, 0x00000003, 0x0004003d, 0x00000007, 0x00000012, 0x00000003,
363bf215546Sopenharmony_ci      0x00060062, 0x0000000d, 0x00000013, 0x00000012, 0x0000000c, 0x00000800,
364bf215546Sopenharmony_ci      0x00040063, 0x00000011, 0x0000000c, 0x00000013, 0x000100fd, 0x00010038,
365bf215546Sopenharmony_ci   };
366bf215546Sopenharmony_ci
367bf215546Sopenharmony_ci   get_nir(sizeof(words) / sizeof(words[0]), words);
368bf215546Sopenharmony_ci
369bf215546Sopenharmony_ci   nir_intrinsic_instr *intrinsic = find_intrinsic(nir_intrinsic_image_deref_load, 0);
370bf215546Sopenharmony_ci   ASSERT_NE(intrinsic, nullptr);
371bf215546Sopenharmony_ci   EXPECT_NE(nir_intrinsic_access(intrinsic) & ACCESS_VOLATILE, 0);
372bf215546Sopenharmony_ci}
373bf215546Sopenharmony_ci
374bf215546Sopenharmony_ciTEST_F(spirv_test, opimagewrite_volatile)
375bf215546Sopenharmony_ci{
376bf215546Sopenharmony_ci   /*
377bf215546Sopenharmony_ci               OpCapability Shader
378bf215546Sopenharmony_ci               OpCapability VulkanMemoryModel
379bf215546Sopenharmony_ci          %1 = OpExtInstImport "GLSL.std.450"
380bf215546Sopenharmony_ci               OpMemoryModel Logical Vulkan
381bf215546Sopenharmony_ci               OpEntryPoint GLCompute %4 "main" %9
382bf215546Sopenharmony_ci               OpExecutionMode %4 LocalSize 1 1 1
383bf215546Sopenharmony_ci               OpDecorate %9 DescriptorSet 0
384bf215546Sopenharmony_ci               OpDecorate %9 Binding 1
385bf215546Sopenharmony_ci       %void = OpTypeVoid
386bf215546Sopenharmony_ci          %3 = OpTypeFunction %void
387bf215546Sopenharmony_ci       %uint = OpTypeInt 32 0
388bf215546Sopenharmony_ci          %7 = OpTypeImage %uint 2D 0 0 0 2 R32ui
389bf215546Sopenharmony_ci%_ptr_UniformConstant_7 = OpTypePointer UniformConstant %7
390bf215546Sopenharmony_ci          %9 = OpVariable %_ptr_UniformConstant_7 UniformConstant
391bf215546Sopenharmony_ci        %int = OpTypeInt 32 1
392bf215546Sopenharmony_ci      %v2int = OpTypeVector %int 2
393bf215546Sopenharmony_ci      %int_0 = OpConstant %int 0
394bf215546Sopenharmony_ci         %14 = OpConstantComposite %v2int %int_0 %int_0
395bf215546Sopenharmony_ci     %v4uint = OpTypeVector %uint 4
396bf215546Sopenharmony_ci     %v3uint = OpTypeVector %uint 3
397bf215546Sopenharmony_ci     %uint_1 = OpConstant %uint 1
398bf215546Sopenharmony_ci          %4 = OpFunction %void None %3
399bf215546Sopenharmony_ci          %5 = OpLabel
400bf215546Sopenharmony_ci         %10 = OpLoad %7 %9
401bf215546Sopenharmony_ci         %15 = OpLoad %7 %9
402bf215546Sopenharmony_ci         %17 = OpImageRead %v4uint %15 %14
403bf215546Sopenharmony_ci               OpImageWrite %10 %14 %17 VolatileTexel
404bf215546Sopenharmony_ci               OpReturn
405bf215546Sopenharmony_ci               OpFunctionEnd
406bf215546Sopenharmony_ci   */
407bf215546Sopenharmony_ci   static const uint32_t words[] = {
408bf215546Sopenharmony_ci      0x07230203, 0x00010500, 0x00070000, 0x00000014, 0x00000000, 0x00020011,
409bf215546Sopenharmony_ci      0x00000001, 0x00020011, 0x000014e1, 0x0006000b, 0x00000001, 0x4c534c47,
410bf215546Sopenharmony_ci      0x6474732e, 0x3035342e, 0x00000000, 0x0003000e, 0x00000000, 0x00000003,
411bf215546Sopenharmony_ci      0x0006000f, 0x00000005, 0x00000002, 0x6e69616d, 0x00000000, 0x00000003,
412bf215546Sopenharmony_ci      0x00060010, 0x00000002, 0x00000011, 0x00000001, 0x00000001, 0x00000001,
413bf215546Sopenharmony_ci      0x00040047, 0x00000003, 0x00000022, 0x00000000, 0x00040047, 0x00000003,
414bf215546Sopenharmony_ci      0x00000021, 0x00000001, 0x00020013, 0x00000004, 0x00030021, 0x00000005,
415bf215546Sopenharmony_ci      0x00000004, 0x00040015, 0x00000006, 0x00000020, 0x00000000, 0x00090019,
416bf215546Sopenharmony_ci      0x00000007, 0x00000006, 0x00000001, 0x00000000, 0x00000000, 0x00000000,
417bf215546Sopenharmony_ci      0x00000002, 0x00000021, 0x00040020, 0x00000008, 0x00000000, 0x00000007,
418bf215546Sopenharmony_ci      0x0004003b, 0x00000008, 0x00000003, 0x00000000, 0x00040015, 0x00000009,
419bf215546Sopenharmony_ci      0x00000020, 0x00000001, 0x00040017, 0x0000000a, 0x00000009, 0x00000002,
420bf215546Sopenharmony_ci      0x0004002b, 0x00000009, 0x0000000b, 0x00000000, 0x0005002c, 0x0000000a,
421bf215546Sopenharmony_ci      0x0000000c, 0x0000000b, 0x0000000b, 0x00040017, 0x0000000d, 0x00000006,
422bf215546Sopenharmony_ci      0x00000004, 0x00040017, 0x0000000e, 0x00000006, 0x00000003, 0x0004002b,
423bf215546Sopenharmony_ci      0x00000006, 0x0000000f, 0x00000001, 0x00050036, 0x00000004, 0x00000002,
424bf215546Sopenharmony_ci      0x00000000, 0x00000005, 0x000200f8, 0x00000010, 0x0004003d, 0x00000007,
425bf215546Sopenharmony_ci      0x00000011, 0x00000003, 0x0004003d, 0x00000007, 0x00000012, 0x00000003,
426bf215546Sopenharmony_ci      0x00050062, 0x0000000d, 0x00000013, 0x00000012, 0x0000000c, 0x00050063,
427bf215546Sopenharmony_ci      0x00000011, 0x0000000c, 0x00000013, 0x00000800, 0x000100fd, 0x00010038,
428bf215546Sopenharmony_ci   };
429bf215546Sopenharmony_ci
430bf215546Sopenharmony_ci   get_nir(sizeof(words) / sizeof(words[0]), words);
431bf215546Sopenharmony_ci
432bf215546Sopenharmony_ci   nir_intrinsic_instr *intrinsic = find_intrinsic(nir_intrinsic_image_deref_store, 0);
433bf215546Sopenharmony_ci   ASSERT_NE(intrinsic, nullptr);
434bf215546Sopenharmony_ci   EXPECT_NE(nir_intrinsic_access(intrinsic) & ACCESS_VOLATILE, 0);
435bf215546Sopenharmony_ci}
436bf215546Sopenharmony_ci
437bf215546Sopenharmony_ciTEST_F(spirv_test, opatomicload_image_volatile)
438bf215546Sopenharmony_ci{
439bf215546Sopenharmony_ci   /*
440bf215546Sopenharmony_ci               OpCapability Shader
441bf215546Sopenharmony_ci               OpCapability VulkanMemoryModel
442bf215546Sopenharmony_ci               OpCapability VulkanMemoryModelDeviceScope
443bf215546Sopenharmony_ci          %1 = OpExtInstImport "GLSL.std.450"
444bf215546Sopenharmony_ci               OpMemoryModel Logical Vulkan
445bf215546Sopenharmony_ci               OpEntryPoint GLCompute %2 "main" %3
446bf215546Sopenharmony_ci               OpExecutionMode %2 LocalSize 1 1 1
447bf215546Sopenharmony_ci               OpDecorate %3 DescriptorSet 0
448bf215546Sopenharmony_ci               OpDecorate %3 Binding 1
449bf215546Sopenharmony_ci       %void = OpTypeVoid
450bf215546Sopenharmony_ci          %7 = OpTypeFunction %void
451bf215546Sopenharmony_ci       %uint = OpTypeInt 32 0
452bf215546Sopenharmony_ci         %10 = OpTypeImage %uint 2D 0 0 0 2 R32ui
453bf215546Sopenharmony_ci%_ptr_UniformConstant_10 = OpTypePointer UniformConstant %10
454bf215546Sopenharmony_ci          %3 = OpVariable %_ptr_UniformConstant_10 UniformConstant
455bf215546Sopenharmony_ci        %int = OpTypeInt 32 1
456bf215546Sopenharmony_ci      %v2int = OpTypeVector %int 2
457bf215546Sopenharmony_ci      %int_0 = OpConstant %int 0
458bf215546Sopenharmony_ci         %15 = OpConstantComposite %v2int %int_0 %int_0
459bf215546Sopenharmony_ci      %int_1 = OpConstant %int 1
460bf215546Sopenharmony_ci     %uint_0 = OpConstant %uint 0
461bf215546Sopenharmony_ci%_ptr_Image_uint = OpTypePointer Image %uint
462bf215546Sopenharmony_ci     %uint_1 = OpConstant %uint 1
463bf215546Sopenharmony_ci  %uint_2048 = OpConstant %uint 2048
464bf215546Sopenharmony_ci %uint_34816 = OpConstant %uint 34816
465bf215546Sopenharmony_ci     %v3uint = OpTypeVector %uint 3
466bf215546Sopenharmony_ci          %2 = OpFunction %void None %7
467bf215546Sopenharmony_ci         %29 = OpLabel
468bf215546Sopenharmony_ci         %30 = OpImageTexelPointer %_ptr_Image_uint %3 %15 %uint_0
469bf215546Sopenharmony_ci         %31 = OpAtomicLoad %uint %30 %int_1 %uint_34816
470bf215546Sopenharmony_ci               OpAtomicStore %30 %int_1 %uint_2048 %31
471bf215546Sopenharmony_ci               OpReturn
472bf215546Sopenharmony_ci               OpFunctionEnd
473bf215546Sopenharmony_ci   */
474bf215546Sopenharmony_ci   static const uint32_t words[] = {
475bf215546Sopenharmony_ci      0x07230203, 0x00010500, 0x00070000, 0x00000017, 0x00000000, 0x00020011,
476bf215546Sopenharmony_ci      0x00000001, 0x00020011, 0x000014e1, 0x00020011, 0x000014e2, 0x0006000b,
477bf215546Sopenharmony_ci      0x00000001, 0x4c534c47, 0x6474732e, 0x3035342e, 0x00000000, 0x0003000e,
478bf215546Sopenharmony_ci      0x00000000, 0x00000003, 0x0006000f, 0x00000005, 0x00000002, 0x6e69616d,
479bf215546Sopenharmony_ci      0x00000000, 0x00000003, 0x00060010, 0x00000002, 0x00000011, 0x00000001,
480bf215546Sopenharmony_ci      0x00000001, 0x00000001, 0x00040047, 0x00000003, 0x00000022, 0x00000000,
481bf215546Sopenharmony_ci      0x00040047, 0x00000003, 0x00000021, 0x00000001, 0x00020013, 0x00000004,
482bf215546Sopenharmony_ci      0x00030021, 0x00000005, 0x00000004, 0x00040015, 0x00000006, 0x00000020,
483bf215546Sopenharmony_ci      0x00000000, 0x00090019, 0x00000007, 0x00000006, 0x00000001, 0x00000000,
484bf215546Sopenharmony_ci      0x00000000, 0x00000000, 0x00000002, 0x00000021, 0x00040020, 0x00000008,
485bf215546Sopenharmony_ci      0x00000000, 0x00000007, 0x0004003b, 0x00000008, 0x00000003, 0x00000000,
486bf215546Sopenharmony_ci      0x00040015, 0x00000009, 0x00000020, 0x00000001, 0x00040017, 0x0000000a,
487bf215546Sopenharmony_ci      0x00000009, 0x00000002, 0x0004002b, 0x00000009, 0x0000000b, 0x00000000,
488bf215546Sopenharmony_ci      0x0005002c, 0x0000000a, 0x0000000c, 0x0000000b, 0x0000000b, 0x0004002b,
489bf215546Sopenharmony_ci      0x00000009, 0x0000000d, 0x00000001, 0x0004002b, 0x00000006, 0x0000000e,
490bf215546Sopenharmony_ci      0x00000000, 0x00040020, 0x0000000f, 0x0000000b, 0x00000006, 0x0004002b,
491bf215546Sopenharmony_ci      0x00000006, 0x00000010, 0x00000001, 0x0004002b, 0x00000006, 0x00000011,
492bf215546Sopenharmony_ci      0x00000800, 0x0004002b, 0x00000006, 0x00000012, 0x00008800, 0x00040017,
493bf215546Sopenharmony_ci      0x00000013, 0x00000006, 0x00000003, 0x00050036, 0x00000004, 0x00000002,
494bf215546Sopenharmony_ci      0x00000000, 0x00000005, 0x000200f8, 0x00000014, 0x0006003c, 0x0000000f,
495bf215546Sopenharmony_ci      0x00000015, 0x00000003, 0x0000000c, 0x0000000e, 0x000600e3, 0x00000006,
496bf215546Sopenharmony_ci      0x00000016, 0x00000015, 0x0000000d, 0x00000012, 0x000500e4, 0x00000015,
497bf215546Sopenharmony_ci      0x0000000d, 0x00000011, 0x00000016, 0x000100fd, 0x00010038,
498bf215546Sopenharmony_ci   };
499bf215546Sopenharmony_ci
500bf215546Sopenharmony_ci   get_nir(sizeof(words) / sizeof(words[0]), words);
501bf215546Sopenharmony_ci
502bf215546Sopenharmony_ci   nir_intrinsic_instr *intrinsic = find_intrinsic(nir_intrinsic_image_deref_load, 0);
503bf215546Sopenharmony_ci   ASSERT_NE(intrinsic, nullptr);
504bf215546Sopenharmony_ci   EXPECT_NE(nir_intrinsic_access(intrinsic) & ACCESS_VOLATILE, 0);
505bf215546Sopenharmony_ci}
506bf215546Sopenharmony_ci
507bf215546Sopenharmony_ciTEST_F(spirv_test, opatomicstore_image_volatile)
508bf215546Sopenharmony_ci{
509bf215546Sopenharmony_ci   /*
510bf215546Sopenharmony_ci               OpCapability Shader
511bf215546Sopenharmony_ci               OpCapability VulkanMemoryModel
512bf215546Sopenharmony_ci               OpCapability VulkanMemoryModelDeviceScope
513bf215546Sopenharmony_ci          %1 = OpExtInstImport "GLSL.std.450"
514bf215546Sopenharmony_ci               OpMemoryModel Logical Vulkan
515bf215546Sopenharmony_ci               OpEntryPoint GLCompute %2 "main" %3
516bf215546Sopenharmony_ci               OpExecutionMode %2 LocalSize 1 1 1
517bf215546Sopenharmony_ci               OpDecorate %3 DescriptorSet 0
518bf215546Sopenharmony_ci               OpDecorate %3 Binding 1
519bf215546Sopenharmony_ci       %void = OpTypeVoid
520bf215546Sopenharmony_ci          %7 = OpTypeFunction %void
521bf215546Sopenharmony_ci       %uint = OpTypeInt 32 0
522bf215546Sopenharmony_ci         %10 = OpTypeImage %uint 2D 0 0 0 2 R32ui
523bf215546Sopenharmony_ci%_ptr_UniformConstant_10 = OpTypePointer UniformConstant %10
524bf215546Sopenharmony_ci          %3 = OpVariable %_ptr_UniformConstant_10 UniformConstant
525bf215546Sopenharmony_ci        %int = OpTypeInt 32 1
526bf215546Sopenharmony_ci      %v2int = OpTypeVector %int 2
527bf215546Sopenharmony_ci      %int_0 = OpConstant %int 0
528bf215546Sopenharmony_ci         %15 = OpConstantComposite %v2int %int_0 %int_0
529bf215546Sopenharmony_ci      %int_1 = OpConstant %int 1
530bf215546Sopenharmony_ci     %uint_0 = OpConstant %uint 0
531bf215546Sopenharmony_ci%_ptr_Image_uint = OpTypePointer Image %uint
532bf215546Sopenharmony_ci     %uint_1 = OpConstant %uint 1
533bf215546Sopenharmony_ci  %uint_2048 = OpConstant %uint 2048
534bf215546Sopenharmony_ci %uint_34816 = OpConstant %uint 34816
535bf215546Sopenharmony_ci     %v3uint = OpTypeVector %uint 3
536bf215546Sopenharmony_ci          %2 = OpFunction %void None %7
537bf215546Sopenharmony_ci         %29 = OpLabel
538bf215546Sopenharmony_ci         %30 = OpImageTexelPointer %_ptr_Image_uint %3 %15 %uint_0
539bf215546Sopenharmony_ci         %31 = OpAtomicLoad %uint %30 %int_1 %uint_2048
540bf215546Sopenharmony_ci               OpAtomicStore %30 %int_1 %uint_34816 %31
541bf215546Sopenharmony_ci               OpReturn
542bf215546Sopenharmony_ci               OpFunctionEnd
543bf215546Sopenharmony_ci   */
544bf215546Sopenharmony_ci   static const uint32_t words[] = {
545bf215546Sopenharmony_ci      0x07230203, 0x00010500, 0x00070000, 0x00000017, 0x00000000, 0x00020011,
546bf215546Sopenharmony_ci      0x00000001, 0x00020011, 0x000014e1, 0x00020011, 0x000014e2, 0x0006000b,
547bf215546Sopenharmony_ci      0x00000001, 0x4c534c47, 0x6474732e, 0x3035342e, 0x00000000, 0x0003000e,
548bf215546Sopenharmony_ci      0x00000000, 0x00000003, 0x0006000f, 0x00000005, 0x00000002, 0x6e69616d,
549bf215546Sopenharmony_ci      0x00000000, 0x00000003, 0x00060010, 0x00000002, 0x00000011, 0x00000001,
550bf215546Sopenharmony_ci      0x00000001, 0x00000001, 0x00040047, 0x00000003, 0x00000022, 0x00000000,
551bf215546Sopenharmony_ci      0x00040047, 0x00000003, 0x00000021, 0x00000001, 0x00020013, 0x00000004,
552bf215546Sopenharmony_ci      0x00030021, 0x00000005, 0x00000004, 0x00040015, 0x00000006, 0x00000020,
553bf215546Sopenharmony_ci      0x00000000, 0x00090019, 0x00000007, 0x00000006, 0x00000001, 0x00000000,
554bf215546Sopenharmony_ci      0x00000000, 0x00000000, 0x00000002, 0x00000021, 0x00040020, 0x00000008,
555bf215546Sopenharmony_ci      0x00000000, 0x00000007, 0x0004003b, 0x00000008, 0x00000003, 0x00000000,
556bf215546Sopenharmony_ci      0x00040015, 0x00000009, 0x00000020, 0x00000001, 0x00040017, 0x0000000a,
557bf215546Sopenharmony_ci      0x00000009, 0x00000002, 0x0004002b, 0x00000009, 0x0000000b, 0x00000000,
558bf215546Sopenharmony_ci      0x0005002c, 0x0000000a, 0x0000000c, 0x0000000b, 0x0000000b, 0x0004002b,
559bf215546Sopenharmony_ci      0x00000009, 0x0000000d, 0x00000001, 0x0004002b, 0x00000006, 0x0000000e,
560bf215546Sopenharmony_ci      0x00000000, 0x00040020, 0x0000000f, 0x0000000b, 0x00000006, 0x0004002b,
561bf215546Sopenharmony_ci      0x00000006, 0x00000010, 0x00000001, 0x0004002b, 0x00000006, 0x00000011,
562bf215546Sopenharmony_ci      0x00000800, 0x0004002b, 0x00000006, 0x00000012, 0x00008800, 0x00040017,
563bf215546Sopenharmony_ci      0x00000013, 0x00000006, 0x00000003, 0x00050036, 0x00000004, 0x00000002,
564bf215546Sopenharmony_ci      0x00000000, 0x00000005, 0x000200f8, 0x00000014, 0x0006003c, 0x0000000f,
565bf215546Sopenharmony_ci      0x00000015, 0x00000003, 0x0000000c, 0x0000000e, 0x000600e3, 0x00000006,
566bf215546Sopenharmony_ci      0x00000016, 0x00000015, 0x0000000d, 0x00000011, 0x000500e4, 0x00000015,
567bf215546Sopenharmony_ci      0x0000000d, 0x00000012, 0x00000016, 0x000100fd, 0x00010038,
568bf215546Sopenharmony_ci   };
569bf215546Sopenharmony_ci
570bf215546Sopenharmony_ci   get_nir(sizeof(words) / sizeof(words[0]), words);
571bf215546Sopenharmony_ci
572bf215546Sopenharmony_ci   nir_intrinsic_instr *intrinsic = find_intrinsic(nir_intrinsic_image_deref_store, 0);
573bf215546Sopenharmony_ci   ASSERT_NE(intrinsic, nullptr);
574bf215546Sopenharmony_ci   EXPECT_NE(nir_intrinsic_access(intrinsic) & ACCESS_VOLATILE, 0);
575bf215546Sopenharmony_ci}
576