1/* 2 * Copyright © 2020 Valve Corporation 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a 5 * copy of this software and associated documentation files (the "Software"), 6 * to deal in the Software without restriction, including without limitation 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 * and/or sell copies of the Software, and to permit persons to whom the 9 * Software is furnished to do so, subject to the following conditions: 10 * 11 * The above copyright notice and this permission notice (including the next 12 * paragraph) shall be included in all copies or substantial portions of the 13 * Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21 * IN THE SOFTWARE. 22 */ 23#include "helpers.h" 24 25TEST_F(spirv_test, opload_vis) 26{ 27 /* 28 OpCapability Shader 29 OpCapability VulkanMemoryModel 30 OpCapability VulkanMemoryModelDeviceScope 31 %1 = OpExtInstImport "GLSL.std.450" 32 OpMemoryModel Logical Vulkan 33 OpEntryPoint GLCompute %4 "main" %9 34 OpExecutionMode %4 LocalSize 1 1 1 35 OpMemberDecorate %_struct_7 0 Offset 0 36 OpDecorate %_struct_7 Block 37 OpDecorate %9 DescriptorSet 0 38 OpDecorate %9 Binding 0 39 %void = OpTypeVoid 40 %3 = OpTypeFunction %void 41 %uint = OpTypeInt 32 0 42 %_struct_7 = OpTypeStruct %uint 43%_ptr_StorageBuffer__struct_7 = OpTypePointer StorageBuffer %_struct_7 44 %9 = OpVariable %_ptr_StorageBuffer__struct_7 StorageBuffer 45 %int = OpTypeInt 32 1 46 %int_0 = OpConstant %int 0 47%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint 48 %device = OpConstant %int 1 49 %4 = OpFunction %void None %3 50 %5 = OpLabel 51 %13 = OpAccessChain %_ptr_StorageBuffer_uint %9 %int_0 52 %14 = OpLoad %uint %13 NonPrivatePointer|MakePointerVisible %device 53 OpStore %13 %14 54 OpReturn 55 OpFunctionEnd 56 */ 57 static const uint32_t words[] = { 58 0x07230203, 0x00010500, 0x00070000, 0x00000010, 0x00000000, 0x00020011, 59 0x00000001, 0x00020011, 0x000014e1, 0x00020011, 0x000014e2, 0x0006000b, 60 0x00000001, 0x4c534c47, 0x6474732e, 0x3035342e, 0x00000000, 0x0003000e, 61 0x00000000, 0x00000003, 0x0006000f, 0x00000005, 0x00000002, 0x6e69616d, 62 0x00000000, 0x00000003, 0x00060010, 0x00000002, 0x00000011, 0x00000001, 63 0x00000001, 0x00000001, 0x00050048, 0x00000004, 0x00000000, 0x00000023, 64 0x00000000, 0x00030047, 0x00000004, 0x00000002, 0x00040047, 0x00000003, 65 0x00000022, 0x00000000, 0x00040047, 0x00000003, 0x00000021, 0x00000000, 66 0x00020013, 0x00000005, 0x00030021, 0x00000006, 0x00000005, 0x00040015, 67 0x00000007, 0x00000020, 0x00000000, 0x0003001e, 0x00000004, 0x00000007, 68 0x00040020, 0x00000008, 0x0000000c, 0x00000004, 0x0004003b, 0x00000008, 69 0x00000003, 0x0000000c, 0x00040015, 0x00000009, 0x00000020, 0x00000001, 70 0x0004002b, 0x00000009, 0x0000000a, 0x00000000, 0x00040020, 0x0000000b, 71 0x0000000c, 0x00000007, 0x0004002b, 0x00000009, 0x0000000c, 0x00000001, 72 0x00050036, 0x00000005, 0x00000002, 0x00000000, 0x00000006, 0x000200f8, 73 0x0000000d, 0x00050041, 0x0000000b, 0x0000000e, 0x00000003, 0x0000000a, 74 0x0006003d, 0x00000007, 0x0000000f, 0x0000000e, 0x00000030, 0x0000000c, 75 0x0003003e, 0x0000000e, 0x0000000f, 0x000100fd, 0x00010038, 76 }; 77 78 get_nir(sizeof(words) / sizeof(words[0]), words); 79 80 nir_intrinsic_instr *intrinsic = find_intrinsic(nir_intrinsic_scoped_barrier, 0); 81 ASSERT_NE(intrinsic, nullptr); 82 83 EXPECT_EQ(nir_intrinsic_memory_semantics(intrinsic), NIR_MEMORY_MAKE_VISIBLE | NIR_MEMORY_ACQUIRE); 84 EXPECT_NE(nir_intrinsic_memory_modes(intrinsic) & nir_var_mem_ssbo, 0); 85 EXPECT_EQ(nir_intrinsic_memory_scope(intrinsic), NIR_SCOPE_DEVICE); 86 EXPECT_EQ(nir_intrinsic_execution_scope(intrinsic), NIR_SCOPE_NONE); 87} 88 89TEST_F(spirv_test, opstore_avail) 90{ 91 /* 92 OpCapability Shader 93 OpCapability VulkanMemoryModel 94 OpCapability VulkanMemoryModelDeviceScope 95 %1 = OpExtInstImport "GLSL.std.450" 96 OpMemoryModel Logical Vulkan 97 OpEntryPoint GLCompute %4 "main" %9 98 OpExecutionMode %4 LocalSize 1 1 1 99 OpMemberDecorate %_struct_7 0 Offset 0 100 OpDecorate %_struct_7 Block 101 OpDecorate %9 DescriptorSet 0 102 OpDecorate %9 Binding 0 103 %void = OpTypeVoid 104 %3 = OpTypeFunction %void 105 %uint = OpTypeInt 32 0 106 %_struct_7 = OpTypeStruct %uint 107%_ptr_StorageBuffer__struct_7 = OpTypePointer StorageBuffer %_struct_7 108 %9 = OpVariable %_ptr_StorageBuffer__struct_7 StorageBuffer 109 %int = OpTypeInt 32 1 110 %int_0 = OpConstant %int 0 111%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint 112 %device = OpConstant %int 1 113 %4 = OpFunction %void None %3 114 %5 = OpLabel 115 %13 = OpAccessChain %_ptr_StorageBuffer_uint %9 %int_0 116 %14 = OpLoad %uint %13 117 OpStore %13 %14 NonPrivatePointer|MakePointerAvailable %device 118 OpReturn 119 OpFunctionEnd 120 */ 121 static const uint32_t words[] = { 122 0x07230203, 0x00010500, 0x00070000, 0x00000010, 0x00000000, 0x00020011, 123 0x00000001, 0x00020011, 0x000014e1, 0x00020011, 0x000014e2, 0x0006000b, 124 0x00000001, 0x4c534c47, 0x6474732e, 0x3035342e, 0x00000000, 0x0003000e, 125 0x00000000, 0x00000003, 0x0006000f, 0x00000005, 0x00000002, 0x6e69616d, 126 0x00000000, 0x00000003, 0x00060010, 0x00000002, 0x00000011, 0x00000001, 127 0x00000001, 0x00000001, 0x00050048, 0x00000004, 0x00000000, 0x00000023, 128 0x00000000, 0x00030047, 0x00000004, 0x00000002, 0x00040047, 0x00000003, 129 0x00000022, 0x00000000, 0x00040047, 0x00000003, 0x00000021, 0x00000000, 130 0x00020013, 0x00000005, 0x00030021, 0x00000006, 0x00000005, 0x00040015, 131 0x00000007, 0x00000020, 0x00000000, 0x0003001e, 0x00000004, 0x00000007, 132 0x00040020, 0x00000008, 0x0000000c, 0x00000004, 0x0004003b, 0x00000008, 133 0x00000003, 0x0000000c, 0x00040015, 0x00000009, 0x00000020, 0x00000001, 134 0x0004002b, 0x00000009, 0x0000000a, 0x00000000, 0x00040020, 0x0000000b, 135 0x0000000c, 0x00000007, 0x0004002b, 0x00000009, 0x0000000c, 0x00000001, 136 0x00050036, 0x00000005, 0x00000002, 0x00000000, 0x00000006, 0x000200f8, 137 0x0000000d, 0x00050041, 0x0000000b, 0x0000000e, 0x00000003, 0x0000000a, 138 0x0004003d, 0x00000007, 0x0000000f, 0x0000000e, 0x0005003e, 0x0000000e, 139 0x0000000f, 0x00000028, 0x0000000c, 0x000100fd, 0x00010038, 140 }; 141 142 get_nir(sizeof(words) / sizeof(words[0]), words); 143 144 nir_intrinsic_instr *intrinsic = find_intrinsic(nir_intrinsic_scoped_barrier, 0); 145 ASSERT_NE(intrinsic, nullptr); 146 147 EXPECT_EQ(nir_intrinsic_memory_semantics(intrinsic), NIR_MEMORY_MAKE_AVAILABLE | NIR_MEMORY_RELEASE); 148 EXPECT_NE(nir_intrinsic_memory_modes(intrinsic) & nir_var_mem_ssbo, 0); 149 EXPECT_EQ(nir_intrinsic_memory_scope(intrinsic), NIR_SCOPE_DEVICE); 150 EXPECT_EQ(nir_intrinsic_execution_scope(intrinsic), NIR_SCOPE_NONE); 151} 152 153TEST_F(spirv_test, opcopymemory_visavail_both_combined) 154{ 155 /* 156 OpCapability Shader 157 OpCapability VulkanMemoryModel 158 OpCapability VulkanMemoryModelDeviceScope 159 %1 = OpExtInstImport "GLSL.std.450" 160 OpMemoryModel Logical Vulkan 161 OpEntryPoint GLCompute %4 "main" %9 162 OpExecutionMode %4 LocalSize 1 1 1 163 OpMemberDecorate %_struct_7 0 Offset 0 164 OpDecorate %_struct_7 Block 165 OpDecorate %9 DescriptorSet 0 166 OpDecorate %9 Binding 0 167 %void = OpTypeVoid 168 %3 = OpTypeFunction %void 169 %uint = OpTypeInt 32 0 170 %_struct_7 = OpTypeStruct %uint 171%_ptr_StorageBuffer__struct_7 = OpTypePointer StorageBuffer %_struct_7 172 %9 = OpVariable %_ptr_StorageBuffer__struct_7 StorageBuffer 173 %int = OpTypeInt 32 1 174 %int_0 = OpConstant %int 0 175%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint 176 %device = OpConstant %int 1 177 %workgroup = OpConstant %int 2 178 %4 = OpFunction %void None %3 179 %5 = OpLabel 180 %13 = OpAccessChain %_ptr_StorageBuffer_uint %9 %int_0 181 OpCopyMemory %13 %13 NonPrivatePointer|MakePointerAvailable|MakePointerVisible %device %workgroup 182 OpReturn 183 OpFunctionEnd 184 */ 185 static const uint32_t words[] = { 186 0x07230203, 0x00010500, 0x00070000, 0x00000010, 0x00000000, 0x00020011, 187 0x00000001, 0x00020011, 0x000014e1, 0x00020011, 0x000014e2, 0x0006000b, 188 0x00000001, 0x4c534c47, 0x6474732e, 0x3035342e, 0x00000000, 0x0003000e, 189 0x00000000, 0x00000003, 0x0006000f, 0x00000005, 0x00000002, 0x6e69616d, 190 0x00000000, 0x00000003, 0x00060010, 0x00000002, 0x00000011, 0x00000001, 191 0x00000001, 0x00000001, 0x00050048, 0x00000004, 0x00000000, 0x00000023, 192 0x00000000, 0x00030047, 0x00000004, 0x00000002, 0x00040047, 0x00000003, 193 0x00000022, 0x00000000, 0x00040047, 0x00000003, 0x00000021, 0x00000000, 194 0x00020013, 0x00000005, 0x00030021, 0x00000006, 0x00000005, 0x00040015, 195 0x00000007, 0x00000020, 0x00000000, 0x0003001e, 0x00000004, 0x00000007, 196 0x00040020, 0x00000008, 0x0000000c, 0x00000004, 0x0004003b, 0x00000008, 197 0x00000003, 0x0000000c, 0x00040015, 0x00000009, 0x00000020, 0x00000001, 198 0x0004002b, 0x00000009, 0x0000000a, 0x00000000, 0x00040020, 0x0000000b, 199 0x0000000c, 0x00000007, 0x0004002b, 0x00000009, 0x0000000c, 0x00000001, 200 0x0004002b, 0x00000009, 0x0000000d, 0x00000002, 0x00050036, 0x00000005, 201 0x00000002, 0x00000000, 0x00000006, 0x000200f8, 0x0000000e, 0x00050041, 202 0x0000000b, 0x0000000f, 0x00000003, 0x0000000a, 0x0006003f, 0x0000000f, 203 0x0000000f, 0x00000038, 0x0000000c, 0x0000000d, 0x000100fd, 0x00010038, 204 }; 205 206 get_nir(sizeof(words) / sizeof(words[0]), words); 207 208 nir_intrinsic_instr *first = find_intrinsic(nir_intrinsic_scoped_barrier, 0); 209 nir_intrinsic_instr *second = find_intrinsic(nir_intrinsic_scoped_barrier, 1); 210 ASSERT_NE(first, nullptr); 211 ASSERT_NE(second, nullptr); 212 213 EXPECT_EQ(nir_intrinsic_memory_semantics(first), NIR_MEMORY_MAKE_VISIBLE | NIR_MEMORY_ACQUIRE); 214 EXPECT_NE(nir_intrinsic_memory_modes(first) & nir_var_mem_ssbo, 0); 215 EXPECT_EQ(nir_intrinsic_memory_scope(first), NIR_SCOPE_WORKGROUP); 216 EXPECT_EQ(nir_intrinsic_execution_scope(first), NIR_SCOPE_NONE); 217 218 EXPECT_EQ(nir_intrinsic_memory_semantics(second), NIR_MEMORY_MAKE_AVAILABLE | NIR_MEMORY_RELEASE); 219 EXPECT_NE(nir_intrinsic_memory_modes(second) & nir_var_mem_ssbo, 0); 220 EXPECT_EQ(nir_intrinsic_memory_scope(second), NIR_SCOPE_DEVICE); 221 EXPECT_EQ(nir_intrinsic_execution_scope(first), NIR_SCOPE_NONE); 222} 223 224TEST_F(spirv_test, opcopymemory_visavail_both_separate) 225{ 226 /* 227 OpCapability Shader 228 OpCapability VulkanMemoryModel 229 OpCapability VulkanMemoryModelDeviceScope 230 %1 = OpExtInstImport "GLSL.std.450" 231 OpMemoryModel Logical Vulkan 232 OpEntryPoint GLCompute %4 "main" %9 233 OpExecutionMode %4 LocalSize 1 1 1 234 OpMemberDecorate %_struct_7 0 Offset 0 235 OpDecorate %_struct_7 Block 236 OpDecorate %9 DescriptorSet 0 237 OpDecorate %9 Binding 0 238 %void = OpTypeVoid 239 %3 = OpTypeFunction %void 240 %uint = OpTypeInt 32 0 241 %_struct_7 = OpTypeStruct %uint 242%_ptr_StorageBuffer__struct_7 = OpTypePointer StorageBuffer %_struct_7 243 %9 = OpVariable %_ptr_StorageBuffer__struct_7 StorageBuffer 244 %int = OpTypeInt 32 1 245 %int_0 = OpConstant %int 0 246%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint 247 %device = OpConstant %int 1 248 %workgroup = OpConstant %int 2 249 %4 = OpFunction %void None %3 250 %5 = OpLabel 251 %13 = OpAccessChain %_ptr_StorageBuffer_uint %9 %int_0 252 OpCopyMemory %13 %13 NonPrivatePointer|MakePointerAvailable %device NonPrivatePointer|MakePointerVisible %workgroup 253 OpReturn 254 OpFunctionEnd 255 */ 256 static const uint32_t words[] = { 257 0x07230203, 0x00010500, 0x00070000, 0x00000010, 0x00000000, 0x00020011, 258 0x00000001, 0x00020011, 0x000014e1, 0x00020011, 0x000014e2, 0x0006000b, 259 0x00000001, 0x4c534c47, 0x6474732e, 0x3035342e, 0x00000000, 0x0003000e, 260 0x00000000, 0x00000003, 0x0006000f, 0x00000005, 0x00000002, 0x6e69616d, 261 0x00000000, 0x00000003, 0x00060010, 0x00000002, 0x00000011, 0x00000001, 262 0x00000001, 0x00000001, 0x00050048, 0x00000004, 0x00000000, 0x00000023, 263 0x00000000, 0x00030047, 0x00000004, 0x00000002, 0x00040047, 0x00000003, 264 0x00000022, 0x00000000, 0x00040047, 0x00000003, 0x00000021, 0x00000000, 265 0x00020013, 0x00000005, 0x00030021, 0x00000006, 0x00000005, 0x00040015, 266 0x00000007, 0x00000020, 0x00000000, 0x0003001e, 0x00000004, 0x00000007, 267 0x00040020, 0x00000008, 0x0000000c, 0x00000004, 0x0004003b, 0x00000008, 268 0x00000003, 0x0000000c, 0x00040015, 0x00000009, 0x00000020, 0x00000001, 269 0x0004002b, 0x00000009, 0x0000000a, 0x00000000, 0x00040020, 0x0000000b, 270 0x0000000c, 0x00000007, 0x0004002b, 0x00000009, 0x0000000c, 0x00000001, 271 0x0004002b, 0x00000009, 0x0000000d, 0x00000002, 0x00050036, 0x00000005, 272 0x00000002, 0x00000000, 0x00000006, 0x000200f8, 0x0000000e, 0x00050041, 273 0x0000000b, 0x0000000f, 0x00000003, 0x0000000a, 0x0007003f, 0x0000000f, 274 0x0000000f, 0x00000028, 0x0000000c, 0x00000030, 0x0000000d, 0x000100fd, 275 0x00010038, 276 }; 277 278 get_nir(sizeof(words) / sizeof(words[0]), words); 279 280 nir_intrinsic_instr *first = find_intrinsic(nir_intrinsic_scoped_barrier, 0); 281 nir_intrinsic_instr *second = find_intrinsic(nir_intrinsic_scoped_barrier, 1); 282 ASSERT_NE(first, nullptr); 283 ASSERT_NE(second, nullptr); 284 285 EXPECT_EQ(nir_intrinsic_memory_semantics(first), NIR_MEMORY_MAKE_VISIBLE | NIR_MEMORY_ACQUIRE); 286 EXPECT_NE(nir_intrinsic_memory_modes(first) & nir_var_mem_ssbo, 0); 287 EXPECT_EQ(nir_intrinsic_memory_scope(first), NIR_SCOPE_WORKGROUP); 288 EXPECT_EQ(nir_intrinsic_execution_scope(first), NIR_SCOPE_NONE); 289 290 EXPECT_EQ(nir_intrinsic_memory_semantics(second), NIR_MEMORY_MAKE_AVAILABLE | NIR_MEMORY_RELEASE); 291 EXPECT_NE(nir_intrinsic_memory_modes(second) & nir_var_mem_ssbo, 0); 292 EXPECT_EQ(nir_intrinsic_memory_scope(second), NIR_SCOPE_DEVICE); 293 EXPECT_EQ(nir_intrinsic_execution_scope(second), NIR_SCOPE_NONE); 294} 295 296TEST_F(spirv_test, opcopymemory_avail) 297{ 298 /* 299 OpCapability Shader 300 OpCapability VulkanMemoryModel 301 OpCapability VulkanMemoryModelDeviceScope 302 %1 = OpExtInstImport "GLSL.std.450" 303 OpMemoryModel Logical Vulkan 304 OpEntryPoint GLCompute %4 "main" %9 305 OpExecutionMode %4 LocalSize 1 1 1 306 OpMemberDecorate %_struct_7 0 Offset 0 307 OpDecorate %_struct_7 Block 308 OpDecorate %9 DescriptorSet 0 309 OpDecorate %9 Binding 0 310 %void = OpTypeVoid 311 %3 = OpTypeFunction %void 312 %uint = OpTypeInt 32 0 313 %_struct_7 = OpTypeStruct %uint 314%_ptr_StorageBuffer__struct_7 = OpTypePointer StorageBuffer %_struct_7 315 %9 = OpVariable %_ptr_StorageBuffer__struct_7 StorageBuffer 316 %int = OpTypeInt 32 1 317 %int_0 = OpConstant %int 0 318%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint 319 %device = OpConstant %int 1 320 %4 = OpFunction %void None %3 321 %5 = OpLabel 322 %13 = OpAccessChain %_ptr_StorageBuffer_uint %9 %int_0 323 OpCopyMemory %13 %13 NonPrivatePointer|MakePointerAvailable %device 324 OpReturn 325 OpFunctionEnd 326 */ 327 static const uint32_t words[] = { 328 0x07230203, 0x00010500, 0x00070000, 0x0000000f, 0x00000000, 0x00020011, 329 0x00000001, 0x00020011, 0x000014e1, 0x00020011, 0x000014e2, 0x0006000b, 330 0x00000001, 0x4c534c47, 0x6474732e, 0x3035342e, 0x00000000, 0x0003000e, 331 0x00000000, 0x00000003, 0x0006000f, 0x00000005, 0x00000002, 0x6e69616d, 332 0x00000000, 0x00000003, 0x00060010, 0x00000002, 0x00000011, 0x00000001, 333 0x00000001, 0x00000001, 0x00050048, 0x00000004, 0x00000000, 0x00000023, 334 0x00000000, 0x00030047, 0x00000004, 0x00000002, 0x00040047, 0x00000003, 335 0x00000022, 0x00000000, 0x00040047, 0x00000003, 0x00000021, 0x00000000, 336 0x00020013, 0x00000005, 0x00030021, 0x00000006, 0x00000005, 0x00040015, 337 0x00000007, 0x00000020, 0x00000000, 0x0003001e, 0x00000004, 0x00000007, 338 0x00040020, 0x00000008, 0x0000000c, 0x00000004, 0x0004003b, 0x00000008, 339 0x00000003, 0x0000000c, 0x00040015, 0x00000009, 0x00000020, 0x00000001, 340 0x0004002b, 0x00000009, 0x0000000a, 0x00000000, 0x00040020, 0x0000000b, 341 0x0000000c, 0x00000007, 0x0004002b, 0x00000009, 0x0000000c, 0x00000001, 342 0x00050036, 0x00000005, 0x00000002, 0x00000000, 0x00000006, 0x000200f8, 343 0x0000000d, 0x00050041, 0x0000000b, 0x0000000e, 0x00000003, 0x0000000a, 344 0x0005003f, 0x0000000e, 0x0000000e, 0x00000028, 0x0000000c, 0x000100fd, 345 0x00010038, 346 }; 347 348 get_nir(sizeof(words) / sizeof(words[0]), words); 349 350 nir_intrinsic_instr *intrinsic = find_intrinsic(nir_intrinsic_scoped_barrier, 0); 351 ASSERT_NE(intrinsic, nullptr); 352 353 EXPECT_EQ(nir_intrinsic_memory_semantics(intrinsic), NIR_MEMORY_MAKE_AVAILABLE | NIR_MEMORY_RELEASE); 354 EXPECT_NE(nir_intrinsic_memory_modes(intrinsic) & nir_var_mem_ssbo, 0); 355 EXPECT_EQ(nir_intrinsic_memory_scope(intrinsic), NIR_SCOPE_DEVICE); 356 EXPECT_EQ(nir_intrinsic_execution_scope(intrinsic), NIR_SCOPE_NONE); 357} 358 359TEST_F(spirv_test, opcopymemory_vis) 360{ 361 /* 362 OpCapability Shader 363 OpCapability VulkanMemoryModel 364 OpCapability VulkanMemoryModelDeviceScope 365 %1 = OpExtInstImport "GLSL.std.450" 366 OpMemoryModel Logical Vulkan 367 OpEntryPoint GLCompute %4 "main" %9 368 OpExecutionMode %4 LocalSize 1 1 1 369 OpMemberDecorate %_struct_7 0 Offset 0 370 OpDecorate %_struct_7 Block 371 OpDecorate %9 DescriptorSet 0 372 OpDecorate %9 Binding 0 373 %void = OpTypeVoid 374 %3 = OpTypeFunction %void 375 %uint = OpTypeInt 32 0 376 %_struct_7 = OpTypeStruct %uint 377%_ptr_StorageBuffer__struct_7 = OpTypePointer StorageBuffer %_struct_7 378 %9 = OpVariable %_ptr_StorageBuffer__struct_7 StorageBuffer 379 %int = OpTypeInt 32 1 380 %int_0 = OpConstant %int 0 381%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint 382 %workgroup = OpConstant %int 2 383 %4 = OpFunction %void None %3 384 %5 = OpLabel 385 %13 = OpAccessChain %_ptr_StorageBuffer_uint %9 %int_0 386 OpCopyMemory %13 %13 NonPrivatePointer|MakePointerVisible %workgroup 387 OpReturn 388 OpFunctionEnd 389 */ 390 static const uint32_t words[] = { 391 0x07230203, 0x00010500, 0x00070000, 0x0000000f, 0x00000000, 0x00020011, 392 0x00000001, 0x00020011, 0x000014e1, 0x00020011, 0x000014e2, 0x0006000b, 393 0x00000001, 0x4c534c47, 0x6474732e, 0x3035342e, 0x00000000, 0x0003000e, 394 0x00000000, 0x00000003, 0x0006000f, 0x00000005, 0x00000002, 0x6e69616d, 395 0x00000000, 0x00000003, 0x00060010, 0x00000002, 0x00000011, 0x00000001, 396 0x00000001, 0x00000001, 0x00050048, 0x00000004, 0x00000000, 0x00000023, 397 0x00000000, 0x00030047, 0x00000004, 0x00000002, 0x00040047, 0x00000003, 398 0x00000022, 0x00000000, 0x00040047, 0x00000003, 0x00000021, 0x00000000, 399 0x00020013, 0x00000005, 0x00030021, 0x00000006, 0x00000005, 0x00040015, 400 0x00000007, 0x00000020, 0x00000000, 0x0003001e, 0x00000004, 0x00000007, 401 0x00040020, 0x00000008, 0x0000000c, 0x00000004, 0x0004003b, 0x00000008, 402 0x00000003, 0x0000000c, 0x00040015, 0x00000009, 0x00000020, 0x00000001, 403 0x0004002b, 0x00000009, 0x0000000a, 0x00000000, 0x00040020, 0x0000000b, 404 0x0000000c, 0x00000007, 0x0004002b, 0x00000009, 0x0000000c, 0x00000002, 405 0x00050036, 0x00000005, 0x00000002, 0x00000000, 0x00000006, 0x000200f8, 406 0x0000000d, 0x00050041, 0x0000000b, 0x0000000e, 0x00000003, 0x0000000a, 407 0x0005003f, 0x0000000e, 0x0000000e, 0x00000030, 0x0000000c, 0x000100fd, 408 0x00010038, 409 }; 410 411 get_nir(sizeof(words) / sizeof(words[0]), words); 412 413 nir_intrinsic_instr *intrinsic = find_intrinsic(nir_intrinsic_scoped_barrier, 0); 414 ASSERT_NE(intrinsic, nullptr); 415 416 EXPECT_EQ(nir_intrinsic_memory_semantics(intrinsic), NIR_MEMORY_MAKE_VISIBLE | NIR_MEMORY_ACQUIRE); 417 EXPECT_NE(nir_intrinsic_memory_modes(intrinsic) & nir_var_mem_ssbo, 0); 418 EXPECT_EQ(nir_intrinsic_memory_scope(intrinsic), NIR_SCOPE_WORKGROUP); 419 EXPECT_EQ(nir_intrinsic_execution_scope(intrinsic), NIR_SCOPE_NONE); 420} 421