17ec681f3Smrg/* 27ec681f3Smrg * Copyright © 2020 Valve Corporation 37ec681f3Smrg * 47ec681f3Smrg * Permission is hereby granted, free of charge, to any person obtaining a 57ec681f3Smrg * copy of this software and associated documentation files (the "Software"), 67ec681f3Smrg * to deal in the Software without restriction, including without limitation 77ec681f3Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 87ec681f3Smrg * and/or sell copies of the Software, and to permit persons to whom the 97ec681f3Smrg * Software is furnished to do so, subject to the following conditions: 107ec681f3Smrg * 117ec681f3Smrg * The above copyright notice and this permission notice (including the next 127ec681f3Smrg * paragraph) shall be included in all copies or substantial portions of the 137ec681f3Smrg * Software. 147ec681f3Smrg * 157ec681f3Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 167ec681f3Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 177ec681f3Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 187ec681f3Smrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 197ec681f3Smrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 207ec681f3Smrg * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 217ec681f3Smrg * IN THE SOFTWARE. 227ec681f3Smrg */ 237ec681f3Smrg#include "helpers.h" 247ec681f3Smrg 257ec681f3SmrgTEST_F(spirv_test, opload_vis) 267ec681f3Smrg{ 277ec681f3Smrg /* 287ec681f3Smrg OpCapability Shader 297ec681f3Smrg OpCapability VulkanMemoryModel 307ec681f3Smrg OpCapability VulkanMemoryModelDeviceScope 317ec681f3Smrg %1 = OpExtInstImport "GLSL.std.450" 327ec681f3Smrg OpMemoryModel Logical Vulkan 337ec681f3Smrg OpEntryPoint GLCompute %4 "main" %9 347ec681f3Smrg OpExecutionMode %4 LocalSize 1 1 1 357ec681f3Smrg OpMemberDecorate %_struct_7 0 Offset 0 367ec681f3Smrg OpDecorate %_struct_7 Block 377ec681f3Smrg OpDecorate %9 DescriptorSet 0 387ec681f3Smrg OpDecorate %9 Binding 0 397ec681f3Smrg %void = OpTypeVoid 407ec681f3Smrg %3 = OpTypeFunction %void 417ec681f3Smrg %uint = OpTypeInt 32 0 427ec681f3Smrg %_struct_7 = OpTypeStruct %uint 437ec681f3Smrg%_ptr_StorageBuffer__struct_7 = OpTypePointer StorageBuffer %_struct_7 447ec681f3Smrg %9 = OpVariable %_ptr_StorageBuffer__struct_7 StorageBuffer 457ec681f3Smrg %int = OpTypeInt 32 1 467ec681f3Smrg %int_0 = OpConstant %int 0 477ec681f3Smrg%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint 487ec681f3Smrg %device = OpConstant %int 1 497ec681f3Smrg %4 = OpFunction %void None %3 507ec681f3Smrg %5 = OpLabel 517ec681f3Smrg %13 = OpAccessChain %_ptr_StorageBuffer_uint %9 %int_0 527ec681f3Smrg %14 = OpLoad %uint %13 NonPrivatePointer|MakePointerVisible %device 537ec681f3Smrg OpStore %13 %14 547ec681f3Smrg OpReturn 557ec681f3Smrg OpFunctionEnd 567ec681f3Smrg */ 577ec681f3Smrg static const uint32_t words[] = { 587ec681f3Smrg 0x07230203, 0x00010500, 0x00070000, 0x00000010, 0x00000000, 0x00020011, 597ec681f3Smrg 0x00000001, 0x00020011, 0x000014e1, 0x00020011, 0x000014e2, 0x0006000b, 607ec681f3Smrg 0x00000001, 0x4c534c47, 0x6474732e, 0x3035342e, 0x00000000, 0x0003000e, 617ec681f3Smrg 0x00000000, 0x00000003, 0x0006000f, 0x00000005, 0x00000002, 0x6e69616d, 627ec681f3Smrg 0x00000000, 0x00000003, 0x00060010, 0x00000002, 0x00000011, 0x00000001, 637ec681f3Smrg 0x00000001, 0x00000001, 0x00050048, 0x00000004, 0x00000000, 0x00000023, 647ec681f3Smrg 0x00000000, 0x00030047, 0x00000004, 0x00000002, 0x00040047, 0x00000003, 657ec681f3Smrg 0x00000022, 0x00000000, 0x00040047, 0x00000003, 0x00000021, 0x00000000, 667ec681f3Smrg 0x00020013, 0x00000005, 0x00030021, 0x00000006, 0x00000005, 0x00040015, 677ec681f3Smrg 0x00000007, 0x00000020, 0x00000000, 0x0003001e, 0x00000004, 0x00000007, 687ec681f3Smrg 0x00040020, 0x00000008, 0x0000000c, 0x00000004, 0x0004003b, 0x00000008, 697ec681f3Smrg 0x00000003, 0x0000000c, 0x00040015, 0x00000009, 0x00000020, 0x00000001, 707ec681f3Smrg 0x0004002b, 0x00000009, 0x0000000a, 0x00000000, 0x00040020, 0x0000000b, 717ec681f3Smrg 0x0000000c, 0x00000007, 0x0004002b, 0x00000009, 0x0000000c, 0x00000001, 727ec681f3Smrg 0x00050036, 0x00000005, 0x00000002, 0x00000000, 0x00000006, 0x000200f8, 737ec681f3Smrg 0x0000000d, 0x00050041, 0x0000000b, 0x0000000e, 0x00000003, 0x0000000a, 747ec681f3Smrg 0x0006003d, 0x00000007, 0x0000000f, 0x0000000e, 0x00000030, 0x0000000c, 757ec681f3Smrg 0x0003003e, 0x0000000e, 0x0000000f, 0x000100fd, 0x00010038, 767ec681f3Smrg }; 777ec681f3Smrg 787ec681f3Smrg get_nir(sizeof(words) / sizeof(words[0]), words); 797ec681f3Smrg 807ec681f3Smrg nir_intrinsic_instr *intrinsic = find_intrinsic(nir_intrinsic_scoped_barrier, 0); 817ec681f3Smrg ASSERT_NE(intrinsic, nullptr); 827ec681f3Smrg 837ec681f3Smrg EXPECT_EQ(nir_intrinsic_memory_semantics(intrinsic), NIR_MEMORY_MAKE_VISIBLE | NIR_MEMORY_ACQUIRE); 847ec681f3Smrg EXPECT_NE(nir_intrinsic_memory_modes(intrinsic) & nir_var_mem_ssbo, 0); 857ec681f3Smrg EXPECT_EQ(nir_intrinsic_memory_scope(intrinsic), NIR_SCOPE_DEVICE); 867ec681f3Smrg EXPECT_EQ(nir_intrinsic_execution_scope(intrinsic), NIR_SCOPE_NONE); 877ec681f3Smrg} 887ec681f3Smrg 897ec681f3SmrgTEST_F(spirv_test, opstore_avail) 907ec681f3Smrg{ 917ec681f3Smrg /* 927ec681f3Smrg OpCapability Shader 937ec681f3Smrg OpCapability VulkanMemoryModel 947ec681f3Smrg OpCapability VulkanMemoryModelDeviceScope 957ec681f3Smrg %1 = OpExtInstImport "GLSL.std.450" 967ec681f3Smrg OpMemoryModel Logical Vulkan 977ec681f3Smrg OpEntryPoint GLCompute %4 "main" %9 987ec681f3Smrg OpExecutionMode %4 LocalSize 1 1 1 997ec681f3Smrg OpMemberDecorate %_struct_7 0 Offset 0 1007ec681f3Smrg OpDecorate %_struct_7 Block 1017ec681f3Smrg OpDecorate %9 DescriptorSet 0 1027ec681f3Smrg OpDecorate %9 Binding 0 1037ec681f3Smrg %void = OpTypeVoid 1047ec681f3Smrg %3 = OpTypeFunction %void 1057ec681f3Smrg %uint = OpTypeInt 32 0 1067ec681f3Smrg %_struct_7 = OpTypeStruct %uint 1077ec681f3Smrg%_ptr_StorageBuffer__struct_7 = OpTypePointer StorageBuffer %_struct_7 1087ec681f3Smrg %9 = OpVariable %_ptr_StorageBuffer__struct_7 StorageBuffer 1097ec681f3Smrg %int = OpTypeInt 32 1 1107ec681f3Smrg %int_0 = OpConstant %int 0 1117ec681f3Smrg%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint 1127ec681f3Smrg %device = OpConstant %int 1 1137ec681f3Smrg %4 = OpFunction %void None %3 1147ec681f3Smrg %5 = OpLabel 1157ec681f3Smrg %13 = OpAccessChain %_ptr_StorageBuffer_uint %9 %int_0 1167ec681f3Smrg %14 = OpLoad %uint %13 1177ec681f3Smrg OpStore %13 %14 NonPrivatePointer|MakePointerAvailable %device 1187ec681f3Smrg OpReturn 1197ec681f3Smrg OpFunctionEnd 1207ec681f3Smrg */ 1217ec681f3Smrg static const uint32_t words[] = { 1227ec681f3Smrg 0x07230203, 0x00010500, 0x00070000, 0x00000010, 0x00000000, 0x00020011, 1237ec681f3Smrg 0x00000001, 0x00020011, 0x000014e1, 0x00020011, 0x000014e2, 0x0006000b, 1247ec681f3Smrg 0x00000001, 0x4c534c47, 0x6474732e, 0x3035342e, 0x00000000, 0x0003000e, 1257ec681f3Smrg 0x00000000, 0x00000003, 0x0006000f, 0x00000005, 0x00000002, 0x6e69616d, 1267ec681f3Smrg 0x00000000, 0x00000003, 0x00060010, 0x00000002, 0x00000011, 0x00000001, 1277ec681f3Smrg 0x00000001, 0x00000001, 0x00050048, 0x00000004, 0x00000000, 0x00000023, 1287ec681f3Smrg 0x00000000, 0x00030047, 0x00000004, 0x00000002, 0x00040047, 0x00000003, 1297ec681f3Smrg 0x00000022, 0x00000000, 0x00040047, 0x00000003, 0x00000021, 0x00000000, 1307ec681f3Smrg 0x00020013, 0x00000005, 0x00030021, 0x00000006, 0x00000005, 0x00040015, 1317ec681f3Smrg 0x00000007, 0x00000020, 0x00000000, 0x0003001e, 0x00000004, 0x00000007, 1327ec681f3Smrg 0x00040020, 0x00000008, 0x0000000c, 0x00000004, 0x0004003b, 0x00000008, 1337ec681f3Smrg 0x00000003, 0x0000000c, 0x00040015, 0x00000009, 0x00000020, 0x00000001, 1347ec681f3Smrg 0x0004002b, 0x00000009, 0x0000000a, 0x00000000, 0x00040020, 0x0000000b, 1357ec681f3Smrg 0x0000000c, 0x00000007, 0x0004002b, 0x00000009, 0x0000000c, 0x00000001, 1367ec681f3Smrg 0x00050036, 0x00000005, 0x00000002, 0x00000000, 0x00000006, 0x000200f8, 1377ec681f3Smrg 0x0000000d, 0x00050041, 0x0000000b, 0x0000000e, 0x00000003, 0x0000000a, 1387ec681f3Smrg 0x0004003d, 0x00000007, 0x0000000f, 0x0000000e, 0x0005003e, 0x0000000e, 1397ec681f3Smrg 0x0000000f, 0x00000028, 0x0000000c, 0x000100fd, 0x00010038, 1407ec681f3Smrg }; 1417ec681f3Smrg 1427ec681f3Smrg get_nir(sizeof(words) / sizeof(words[0]), words); 1437ec681f3Smrg 1447ec681f3Smrg nir_intrinsic_instr *intrinsic = find_intrinsic(nir_intrinsic_scoped_barrier, 0); 1457ec681f3Smrg ASSERT_NE(intrinsic, nullptr); 1467ec681f3Smrg 1477ec681f3Smrg EXPECT_EQ(nir_intrinsic_memory_semantics(intrinsic), NIR_MEMORY_MAKE_AVAILABLE | NIR_MEMORY_RELEASE); 1487ec681f3Smrg EXPECT_NE(nir_intrinsic_memory_modes(intrinsic) & nir_var_mem_ssbo, 0); 1497ec681f3Smrg EXPECT_EQ(nir_intrinsic_memory_scope(intrinsic), NIR_SCOPE_DEVICE); 1507ec681f3Smrg EXPECT_EQ(nir_intrinsic_execution_scope(intrinsic), NIR_SCOPE_NONE); 1517ec681f3Smrg} 1527ec681f3Smrg 1537ec681f3SmrgTEST_F(spirv_test, opcopymemory_visavail_both_combined) 1547ec681f3Smrg{ 1557ec681f3Smrg /* 1567ec681f3Smrg OpCapability Shader 1577ec681f3Smrg OpCapability VulkanMemoryModel 1587ec681f3Smrg OpCapability VulkanMemoryModelDeviceScope 1597ec681f3Smrg %1 = OpExtInstImport "GLSL.std.450" 1607ec681f3Smrg OpMemoryModel Logical Vulkan 1617ec681f3Smrg OpEntryPoint GLCompute %4 "main" %9 1627ec681f3Smrg OpExecutionMode %4 LocalSize 1 1 1 1637ec681f3Smrg OpMemberDecorate %_struct_7 0 Offset 0 1647ec681f3Smrg OpDecorate %_struct_7 Block 1657ec681f3Smrg OpDecorate %9 DescriptorSet 0 1667ec681f3Smrg OpDecorate %9 Binding 0 1677ec681f3Smrg %void = OpTypeVoid 1687ec681f3Smrg %3 = OpTypeFunction %void 1697ec681f3Smrg %uint = OpTypeInt 32 0 1707ec681f3Smrg %_struct_7 = OpTypeStruct %uint 1717ec681f3Smrg%_ptr_StorageBuffer__struct_7 = OpTypePointer StorageBuffer %_struct_7 1727ec681f3Smrg %9 = OpVariable %_ptr_StorageBuffer__struct_7 StorageBuffer 1737ec681f3Smrg %int = OpTypeInt 32 1 1747ec681f3Smrg %int_0 = OpConstant %int 0 1757ec681f3Smrg%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint 1767ec681f3Smrg %device = OpConstant %int 1 1777ec681f3Smrg %workgroup = OpConstant %int 2 1787ec681f3Smrg %4 = OpFunction %void None %3 1797ec681f3Smrg %5 = OpLabel 1807ec681f3Smrg %13 = OpAccessChain %_ptr_StorageBuffer_uint %9 %int_0 1817ec681f3Smrg OpCopyMemory %13 %13 NonPrivatePointer|MakePointerAvailable|MakePointerVisible %device %workgroup 1827ec681f3Smrg OpReturn 1837ec681f3Smrg OpFunctionEnd 1847ec681f3Smrg */ 1857ec681f3Smrg static const uint32_t words[] = { 1867ec681f3Smrg 0x07230203, 0x00010500, 0x00070000, 0x00000010, 0x00000000, 0x00020011, 1877ec681f3Smrg 0x00000001, 0x00020011, 0x000014e1, 0x00020011, 0x000014e2, 0x0006000b, 1887ec681f3Smrg 0x00000001, 0x4c534c47, 0x6474732e, 0x3035342e, 0x00000000, 0x0003000e, 1897ec681f3Smrg 0x00000000, 0x00000003, 0x0006000f, 0x00000005, 0x00000002, 0x6e69616d, 1907ec681f3Smrg 0x00000000, 0x00000003, 0x00060010, 0x00000002, 0x00000011, 0x00000001, 1917ec681f3Smrg 0x00000001, 0x00000001, 0x00050048, 0x00000004, 0x00000000, 0x00000023, 1927ec681f3Smrg 0x00000000, 0x00030047, 0x00000004, 0x00000002, 0x00040047, 0x00000003, 1937ec681f3Smrg 0x00000022, 0x00000000, 0x00040047, 0x00000003, 0x00000021, 0x00000000, 1947ec681f3Smrg 0x00020013, 0x00000005, 0x00030021, 0x00000006, 0x00000005, 0x00040015, 1957ec681f3Smrg 0x00000007, 0x00000020, 0x00000000, 0x0003001e, 0x00000004, 0x00000007, 1967ec681f3Smrg 0x00040020, 0x00000008, 0x0000000c, 0x00000004, 0x0004003b, 0x00000008, 1977ec681f3Smrg 0x00000003, 0x0000000c, 0x00040015, 0x00000009, 0x00000020, 0x00000001, 1987ec681f3Smrg 0x0004002b, 0x00000009, 0x0000000a, 0x00000000, 0x00040020, 0x0000000b, 1997ec681f3Smrg 0x0000000c, 0x00000007, 0x0004002b, 0x00000009, 0x0000000c, 0x00000001, 2007ec681f3Smrg 0x0004002b, 0x00000009, 0x0000000d, 0x00000002, 0x00050036, 0x00000005, 2017ec681f3Smrg 0x00000002, 0x00000000, 0x00000006, 0x000200f8, 0x0000000e, 0x00050041, 2027ec681f3Smrg 0x0000000b, 0x0000000f, 0x00000003, 0x0000000a, 0x0006003f, 0x0000000f, 2037ec681f3Smrg 0x0000000f, 0x00000038, 0x0000000c, 0x0000000d, 0x000100fd, 0x00010038, 2047ec681f3Smrg }; 2057ec681f3Smrg 2067ec681f3Smrg get_nir(sizeof(words) / sizeof(words[0]), words); 2077ec681f3Smrg 2087ec681f3Smrg nir_intrinsic_instr *first = find_intrinsic(nir_intrinsic_scoped_barrier, 0); 2097ec681f3Smrg nir_intrinsic_instr *second = find_intrinsic(nir_intrinsic_scoped_barrier, 1); 2107ec681f3Smrg ASSERT_NE(first, nullptr); 2117ec681f3Smrg ASSERT_NE(second, nullptr); 2127ec681f3Smrg 2137ec681f3Smrg EXPECT_EQ(nir_intrinsic_memory_semantics(first), NIR_MEMORY_MAKE_VISIBLE | NIR_MEMORY_ACQUIRE); 2147ec681f3Smrg EXPECT_NE(nir_intrinsic_memory_modes(first) & nir_var_mem_ssbo, 0); 2157ec681f3Smrg EXPECT_EQ(nir_intrinsic_memory_scope(first), NIR_SCOPE_WORKGROUP); 2167ec681f3Smrg EXPECT_EQ(nir_intrinsic_execution_scope(first), NIR_SCOPE_NONE); 2177ec681f3Smrg 2187ec681f3Smrg EXPECT_EQ(nir_intrinsic_memory_semantics(second), NIR_MEMORY_MAKE_AVAILABLE | NIR_MEMORY_RELEASE); 2197ec681f3Smrg EXPECT_NE(nir_intrinsic_memory_modes(second) & nir_var_mem_ssbo, 0); 2207ec681f3Smrg EXPECT_EQ(nir_intrinsic_memory_scope(second), NIR_SCOPE_DEVICE); 2217ec681f3Smrg EXPECT_EQ(nir_intrinsic_execution_scope(first), NIR_SCOPE_NONE); 2227ec681f3Smrg} 2237ec681f3Smrg 2247ec681f3SmrgTEST_F(spirv_test, opcopymemory_visavail_both_separate) 2257ec681f3Smrg{ 2267ec681f3Smrg /* 2277ec681f3Smrg OpCapability Shader 2287ec681f3Smrg OpCapability VulkanMemoryModel 2297ec681f3Smrg OpCapability VulkanMemoryModelDeviceScope 2307ec681f3Smrg %1 = OpExtInstImport "GLSL.std.450" 2317ec681f3Smrg OpMemoryModel Logical Vulkan 2327ec681f3Smrg OpEntryPoint GLCompute %4 "main" %9 2337ec681f3Smrg OpExecutionMode %4 LocalSize 1 1 1 2347ec681f3Smrg OpMemberDecorate %_struct_7 0 Offset 0 2357ec681f3Smrg OpDecorate %_struct_7 Block 2367ec681f3Smrg OpDecorate %9 DescriptorSet 0 2377ec681f3Smrg OpDecorate %9 Binding 0 2387ec681f3Smrg %void = OpTypeVoid 2397ec681f3Smrg %3 = OpTypeFunction %void 2407ec681f3Smrg %uint = OpTypeInt 32 0 2417ec681f3Smrg %_struct_7 = OpTypeStruct %uint 2427ec681f3Smrg%_ptr_StorageBuffer__struct_7 = OpTypePointer StorageBuffer %_struct_7 2437ec681f3Smrg %9 = OpVariable %_ptr_StorageBuffer__struct_7 StorageBuffer 2447ec681f3Smrg %int = OpTypeInt 32 1 2457ec681f3Smrg %int_0 = OpConstant %int 0 2467ec681f3Smrg%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint 2477ec681f3Smrg %device = OpConstant %int 1 2487ec681f3Smrg %workgroup = OpConstant %int 2 2497ec681f3Smrg %4 = OpFunction %void None %3 2507ec681f3Smrg %5 = OpLabel 2517ec681f3Smrg %13 = OpAccessChain %_ptr_StorageBuffer_uint %9 %int_0 2527ec681f3Smrg OpCopyMemory %13 %13 NonPrivatePointer|MakePointerAvailable %device NonPrivatePointer|MakePointerVisible %workgroup 2537ec681f3Smrg OpReturn 2547ec681f3Smrg OpFunctionEnd 2557ec681f3Smrg */ 2567ec681f3Smrg static const uint32_t words[] = { 2577ec681f3Smrg 0x07230203, 0x00010500, 0x00070000, 0x00000010, 0x00000000, 0x00020011, 2587ec681f3Smrg 0x00000001, 0x00020011, 0x000014e1, 0x00020011, 0x000014e2, 0x0006000b, 2597ec681f3Smrg 0x00000001, 0x4c534c47, 0x6474732e, 0x3035342e, 0x00000000, 0x0003000e, 2607ec681f3Smrg 0x00000000, 0x00000003, 0x0006000f, 0x00000005, 0x00000002, 0x6e69616d, 2617ec681f3Smrg 0x00000000, 0x00000003, 0x00060010, 0x00000002, 0x00000011, 0x00000001, 2627ec681f3Smrg 0x00000001, 0x00000001, 0x00050048, 0x00000004, 0x00000000, 0x00000023, 2637ec681f3Smrg 0x00000000, 0x00030047, 0x00000004, 0x00000002, 0x00040047, 0x00000003, 2647ec681f3Smrg 0x00000022, 0x00000000, 0x00040047, 0x00000003, 0x00000021, 0x00000000, 2657ec681f3Smrg 0x00020013, 0x00000005, 0x00030021, 0x00000006, 0x00000005, 0x00040015, 2667ec681f3Smrg 0x00000007, 0x00000020, 0x00000000, 0x0003001e, 0x00000004, 0x00000007, 2677ec681f3Smrg 0x00040020, 0x00000008, 0x0000000c, 0x00000004, 0x0004003b, 0x00000008, 2687ec681f3Smrg 0x00000003, 0x0000000c, 0x00040015, 0x00000009, 0x00000020, 0x00000001, 2697ec681f3Smrg 0x0004002b, 0x00000009, 0x0000000a, 0x00000000, 0x00040020, 0x0000000b, 2707ec681f3Smrg 0x0000000c, 0x00000007, 0x0004002b, 0x00000009, 0x0000000c, 0x00000001, 2717ec681f3Smrg 0x0004002b, 0x00000009, 0x0000000d, 0x00000002, 0x00050036, 0x00000005, 2727ec681f3Smrg 0x00000002, 0x00000000, 0x00000006, 0x000200f8, 0x0000000e, 0x00050041, 2737ec681f3Smrg 0x0000000b, 0x0000000f, 0x00000003, 0x0000000a, 0x0007003f, 0x0000000f, 2747ec681f3Smrg 0x0000000f, 0x00000028, 0x0000000c, 0x00000030, 0x0000000d, 0x000100fd, 2757ec681f3Smrg 0x00010038, 2767ec681f3Smrg }; 2777ec681f3Smrg 2787ec681f3Smrg get_nir(sizeof(words) / sizeof(words[0]), words); 2797ec681f3Smrg 2807ec681f3Smrg nir_intrinsic_instr *first = find_intrinsic(nir_intrinsic_scoped_barrier, 0); 2817ec681f3Smrg nir_intrinsic_instr *second = find_intrinsic(nir_intrinsic_scoped_barrier, 1); 2827ec681f3Smrg ASSERT_NE(first, nullptr); 2837ec681f3Smrg ASSERT_NE(second, nullptr); 2847ec681f3Smrg 2857ec681f3Smrg EXPECT_EQ(nir_intrinsic_memory_semantics(first), NIR_MEMORY_MAKE_VISIBLE | NIR_MEMORY_ACQUIRE); 2867ec681f3Smrg EXPECT_NE(nir_intrinsic_memory_modes(first) & nir_var_mem_ssbo, 0); 2877ec681f3Smrg EXPECT_EQ(nir_intrinsic_memory_scope(first), NIR_SCOPE_WORKGROUP); 2887ec681f3Smrg EXPECT_EQ(nir_intrinsic_execution_scope(first), NIR_SCOPE_NONE); 2897ec681f3Smrg 2907ec681f3Smrg EXPECT_EQ(nir_intrinsic_memory_semantics(second), NIR_MEMORY_MAKE_AVAILABLE | NIR_MEMORY_RELEASE); 2917ec681f3Smrg EXPECT_NE(nir_intrinsic_memory_modes(second) & nir_var_mem_ssbo, 0); 2927ec681f3Smrg EXPECT_EQ(nir_intrinsic_memory_scope(second), NIR_SCOPE_DEVICE); 2937ec681f3Smrg EXPECT_EQ(nir_intrinsic_execution_scope(second), NIR_SCOPE_NONE); 2947ec681f3Smrg} 2957ec681f3Smrg 2967ec681f3SmrgTEST_F(spirv_test, opcopymemory_avail) 2977ec681f3Smrg{ 2987ec681f3Smrg /* 2997ec681f3Smrg OpCapability Shader 3007ec681f3Smrg OpCapability VulkanMemoryModel 3017ec681f3Smrg OpCapability VulkanMemoryModelDeviceScope 3027ec681f3Smrg %1 = OpExtInstImport "GLSL.std.450" 3037ec681f3Smrg OpMemoryModel Logical Vulkan 3047ec681f3Smrg OpEntryPoint GLCompute %4 "main" %9 3057ec681f3Smrg OpExecutionMode %4 LocalSize 1 1 1 3067ec681f3Smrg OpMemberDecorate %_struct_7 0 Offset 0 3077ec681f3Smrg OpDecorate %_struct_7 Block 3087ec681f3Smrg OpDecorate %9 DescriptorSet 0 3097ec681f3Smrg OpDecorate %9 Binding 0 3107ec681f3Smrg %void = OpTypeVoid 3117ec681f3Smrg %3 = OpTypeFunction %void 3127ec681f3Smrg %uint = OpTypeInt 32 0 3137ec681f3Smrg %_struct_7 = OpTypeStruct %uint 3147ec681f3Smrg%_ptr_StorageBuffer__struct_7 = OpTypePointer StorageBuffer %_struct_7 3157ec681f3Smrg %9 = OpVariable %_ptr_StorageBuffer__struct_7 StorageBuffer 3167ec681f3Smrg %int = OpTypeInt 32 1 3177ec681f3Smrg %int_0 = OpConstant %int 0 3187ec681f3Smrg%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint 3197ec681f3Smrg %device = OpConstant %int 1 3207ec681f3Smrg %4 = OpFunction %void None %3 3217ec681f3Smrg %5 = OpLabel 3227ec681f3Smrg %13 = OpAccessChain %_ptr_StorageBuffer_uint %9 %int_0 3237ec681f3Smrg OpCopyMemory %13 %13 NonPrivatePointer|MakePointerAvailable %device 3247ec681f3Smrg OpReturn 3257ec681f3Smrg OpFunctionEnd 3267ec681f3Smrg */ 3277ec681f3Smrg static const uint32_t words[] = { 3287ec681f3Smrg 0x07230203, 0x00010500, 0x00070000, 0x0000000f, 0x00000000, 0x00020011, 3297ec681f3Smrg 0x00000001, 0x00020011, 0x000014e1, 0x00020011, 0x000014e2, 0x0006000b, 3307ec681f3Smrg 0x00000001, 0x4c534c47, 0x6474732e, 0x3035342e, 0x00000000, 0x0003000e, 3317ec681f3Smrg 0x00000000, 0x00000003, 0x0006000f, 0x00000005, 0x00000002, 0x6e69616d, 3327ec681f3Smrg 0x00000000, 0x00000003, 0x00060010, 0x00000002, 0x00000011, 0x00000001, 3337ec681f3Smrg 0x00000001, 0x00000001, 0x00050048, 0x00000004, 0x00000000, 0x00000023, 3347ec681f3Smrg 0x00000000, 0x00030047, 0x00000004, 0x00000002, 0x00040047, 0x00000003, 3357ec681f3Smrg 0x00000022, 0x00000000, 0x00040047, 0x00000003, 0x00000021, 0x00000000, 3367ec681f3Smrg 0x00020013, 0x00000005, 0x00030021, 0x00000006, 0x00000005, 0x00040015, 3377ec681f3Smrg 0x00000007, 0x00000020, 0x00000000, 0x0003001e, 0x00000004, 0x00000007, 3387ec681f3Smrg 0x00040020, 0x00000008, 0x0000000c, 0x00000004, 0x0004003b, 0x00000008, 3397ec681f3Smrg 0x00000003, 0x0000000c, 0x00040015, 0x00000009, 0x00000020, 0x00000001, 3407ec681f3Smrg 0x0004002b, 0x00000009, 0x0000000a, 0x00000000, 0x00040020, 0x0000000b, 3417ec681f3Smrg 0x0000000c, 0x00000007, 0x0004002b, 0x00000009, 0x0000000c, 0x00000001, 3427ec681f3Smrg 0x00050036, 0x00000005, 0x00000002, 0x00000000, 0x00000006, 0x000200f8, 3437ec681f3Smrg 0x0000000d, 0x00050041, 0x0000000b, 0x0000000e, 0x00000003, 0x0000000a, 3447ec681f3Smrg 0x0005003f, 0x0000000e, 0x0000000e, 0x00000028, 0x0000000c, 0x000100fd, 3457ec681f3Smrg 0x00010038, 3467ec681f3Smrg }; 3477ec681f3Smrg 3487ec681f3Smrg get_nir(sizeof(words) / sizeof(words[0]), words); 3497ec681f3Smrg 3507ec681f3Smrg nir_intrinsic_instr *intrinsic = find_intrinsic(nir_intrinsic_scoped_barrier, 0); 3517ec681f3Smrg ASSERT_NE(intrinsic, nullptr); 3527ec681f3Smrg 3537ec681f3Smrg EXPECT_EQ(nir_intrinsic_memory_semantics(intrinsic), NIR_MEMORY_MAKE_AVAILABLE | NIR_MEMORY_RELEASE); 3547ec681f3Smrg EXPECT_NE(nir_intrinsic_memory_modes(intrinsic) & nir_var_mem_ssbo, 0); 3557ec681f3Smrg EXPECT_EQ(nir_intrinsic_memory_scope(intrinsic), NIR_SCOPE_DEVICE); 3567ec681f3Smrg EXPECT_EQ(nir_intrinsic_execution_scope(intrinsic), NIR_SCOPE_NONE); 3577ec681f3Smrg} 3587ec681f3Smrg 3597ec681f3SmrgTEST_F(spirv_test, opcopymemory_vis) 3607ec681f3Smrg{ 3617ec681f3Smrg /* 3627ec681f3Smrg OpCapability Shader 3637ec681f3Smrg OpCapability VulkanMemoryModel 3647ec681f3Smrg OpCapability VulkanMemoryModelDeviceScope 3657ec681f3Smrg %1 = OpExtInstImport "GLSL.std.450" 3667ec681f3Smrg OpMemoryModel Logical Vulkan 3677ec681f3Smrg OpEntryPoint GLCompute %4 "main" %9 3687ec681f3Smrg OpExecutionMode %4 LocalSize 1 1 1 3697ec681f3Smrg OpMemberDecorate %_struct_7 0 Offset 0 3707ec681f3Smrg OpDecorate %_struct_7 Block 3717ec681f3Smrg OpDecorate %9 DescriptorSet 0 3727ec681f3Smrg OpDecorate %9 Binding 0 3737ec681f3Smrg %void = OpTypeVoid 3747ec681f3Smrg %3 = OpTypeFunction %void 3757ec681f3Smrg %uint = OpTypeInt 32 0 3767ec681f3Smrg %_struct_7 = OpTypeStruct %uint 3777ec681f3Smrg%_ptr_StorageBuffer__struct_7 = OpTypePointer StorageBuffer %_struct_7 3787ec681f3Smrg %9 = OpVariable %_ptr_StorageBuffer__struct_7 StorageBuffer 3797ec681f3Smrg %int = OpTypeInt 32 1 3807ec681f3Smrg %int_0 = OpConstant %int 0 3817ec681f3Smrg%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint 3827ec681f3Smrg %workgroup = OpConstant %int 2 3837ec681f3Smrg %4 = OpFunction %void None %3 3847ec681f3Smrg %5 = OpLabel 3857ec681f3Smrg %13 = OpAccessChain %_ptr_StorageBuffer_uint %9 %int_0 3867ec681f3Smrg OpCopyMemory %13 %13 NonPrivatePointer|MakePointerVisible %workgroup 3877ec681f3Smrg OpReturn 3887ec681f3Smrg OpFunctionEnd 3897ec681f3Smrg */ 3907ec681f3Smrg static const uint32_t words[] = { 3917ec681f3Smrg 0x07230203, 0x00010500, 0x00070000, 0x0000000f, 0x00000000, 0x00020011, 3927ec681f3Smrg 0x00000001, 0x00020011, 0x000014e1, 0x00020011, 0x000014e2, 0x0006000b, 3937ec681f3Smrg 0x00000001, 0x4c534c47, 0x6474732e, 0x3035342e, 0x00000000, 0x0003000e, 3947ec681f3Smrg 0x00000000, 0x00000003, 0x0006000f, 0x00000005, 0x00000002, 0x6e69616d, 3957ec681f3Smrg 0x00000000, 0x00000003, 0x00060010, 0x00000002, 0x00000011, 0x00000001, 3967ec681f3Smrg 0x00000001, 0x00000001, 0x00050048, 0x00000004, 0x00000000, 0x00000023, 3977ec681f3Smrg 0x00000000, 0x00030047, 0x00000004, 0x00000002, 0x00040047, 0x00000003, 3987ec681f3Smrg 0x00000022, 0x00000000, 0x00040047, 0x00000003, 0x00000021, 0x00000000, 3997ec681f3Smrg 0x00020013, 0x00000005, 0x00030021, 0x00000006, 0x00000005, 0x00040015, 4007ec681f3Smrg 0x00000007, 0x00000020, 0x00000000, 0x0003001e, 0x00000004, 0x00000007, 4017ec681f3Smrg 0x00040020, 0x00000008, 0x0000000c, 0x00000004, 0x0004003b, 0x00000008, 4027ec681f3Smrg 0x00000003, 0x0000000c, 0x00040015, 0x00000009, 0x00000020, 0x00000001, 4037ec681f3Smrg 0x0004002b, 0x00000009, 0x0000000a, 0x00000000, 0x00040020, 0x0000000b, 4047ec681f3Smrg 0x0000000c, 0x00000007, 0x0004002b, 0x00000009, 0x0000000c, 0x00000002, 4057ec681f3Smrg 0x00050036, 0x00000005, 0x00000002, 0x00000000, 0x00000006, 0x000200f8, 4067ec681f3Smrg 0x0000000d, 0x00050041, 0x0000000b, 0x0000000e, 0x00000003, 0x0000000a, 4077ec681f3Smrg 0x0005003f, 0x0000000e, 0x0000000e, 0x00000030, 0x0000000c, 0x000100fd, 4087ec681f3Smrg 0x00010038, 4097ec681f3Smrg }; 4107ec681f3Smrg 4117ec681f3Smrg get_nir(sizeof(words) / sizeof(words[0]), words); 4127ec681f3Smrg 4137ec681f3Smrg nir_intrinsic_instr *intrinsic = find_intrinsic(nir_intrinsic_scoped_barrier, 0); 4147ec681f3Smrg ASSERT_NE(intrinsic, nullptr); 4157ec681f3Smrg 4167ec681f3Smrg EXPECT_EQ(nir_intrinsic_memory_semantics(intrinsic), NIR_MEMORY_MAKE_VISIBLE | NIR_MEMORY_ACQUIRE); 4177ec681f3Smrg EXPECT_NE(nir_intrinsic_memory_modes(intrinsic) & nir_var_mem_ssbo, 0); 4187ec681f3Smrg EXPECT_EQ(nir_intrinsic_memory_scope(intrinsic), NIR_SCOPE_WORKGROUP); 4197ec681f3Smrg EXPECT_EQ(nir_intrinsic_execution_scope(intrinsic), NIR_SCOPE_NONE); 4207ec681f3Smrg} 421