2020-07-27 14:43:40 +01:00
|
|
|
/*
|
|
|
|
|
* Copyright © 2020 Valve Corporation
|
2026-03-07 08:50:25 -08:00
|
|
|
* SPDX-License-Identifier: MIT
|
2020-07-27 14:43:40 +01:00
|
|
|
*/
|
|
|
|
|
#include "helpers.h"
|
|
|
|
|
|
2021-11-18 00:22:44 -08:00
|
|
|
class AvailabilityVisibility : public spirv_test {};
|
|
|
|
|
|
|
|
|
|
TEST_F(AvailabilityVisibility, opload_vis)
|
2020-07-27 14:43:40 +01:00
|
|
|
{
|
|
|
|
|
/*
|
|
|
|
|
OpCapability Shader
|
|
|
|
|
OpCapability VulkanMemoryModel
|
|
|
|
|
OpCapability VulkanMemoryModelDeviceScope
|
|
|
|
|
%1 = OpExtInstImport "GLSL.std.450"
|
|
|
|
|
OpMemoryModel Logical Vulkan
|
|
|
|
|
OpEntryPoint GLCompute %4 "main" %9
|
|
|
|
|
OpExecutionMode %4 LocalSize 1 1 1
|
|
|
|
|
OpMemberDecorate %_struct_7 0 Offset 0
|
|
|
|
|
OpDecorate %_struct_7 Block
|
|
|
|
|
OpDecorate %9 DescriptorSet 0
|
|
|
|
|
OpDecorate %9 Binding 0
|
|
|
|
|
%void = OpTypeVoid
|
|
|
|
|
%3 = OpTypeFunction %void
|
|
|
|
|
%uint = OpTypeInt 32 0
|
|
|
|
|
%_struct_7 = OpTypeStruct %uint
|
|
|
|
|
%_ptr_StorageBuffer__struct_7 = OpTypePointer StorageBuffer %_struct_7
|
|
|
|
|
%9 = OpVariable %_ptr_StorageBuffer__struct_7 StorageBuffer
|
|
|
|
|
%int = OpTypeInt 32 1
|
|
|
|
|
%int_0 = OpConstant %int 0
|
|
|
|
|
%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint
|
|
|
|
|
%device = OpConstant %int 1
|
|
|
|
|
%4 = OpFunction %void None %3
|
|
|
|
|
%5 = OpLabel
|
|
|
|
|
%13 = OpAccessChain %_ptr_StorageBuffer_uint %9 %int_0
|
|
|
|
|
%14 = OpLoad %uint %13 NonPrivatePointer|MakePointerVisible %device
|
|
|
|
|
OpStore %13 %14
|
|
|
|
|
OpReturn
|
|
|
|
|
OpFunctionEnd
|
|
|
|
|
*/
|
|
|
|
|
static const uint32_t words[] = {
|
|
|
|
|
0x07230203, 0x00010500, 0x00070000, 0x00000010, 0x00000000, 0x00020011,
|
|
|
|
|
0x00000001, 0x00020011, 0x000014e1, 0x00020011, 0x000014e2, 0x0006000b,
|
|
|
|
|
0x00000001, 0x4c534c47, 0x6474732e, 0x3035342e, 0x00000000, 0x0003000e,
|
|
|
|
|
0x00000000, 0x00000003, 0x0006000f, 0x00000005, 0x00000002, 0x6e69616d,
|
|
|
|
|
0x00000000, 0x00000003, 0x00060010, 0x00000002, 0x00000011, 0x00000001,
|
|
|
|
|
0x00000001, 0x00000001, 0x00050048, 0x00000004, 0x00000000, 0x00000023,
|
|
|
|
|
0x00000000, 0x00030047, 0x00000004, 0x00000002, 0x00040047, 0x00000003,
|
|
|
|
|
0x00000022, 0x00000000, 0x00040047, 0x00000003, 0x00000021, 0x00000000,
|
|
|
|
|
0x00020013, 0x00000005, 0x00030021, 0x00000006, 0x00000005, 0x00040015,
|
|
|
|
|
0x00000007, 0x00000020, 0x00000000, 0x0003001e, 0x00000004, 0x00000007,
|
|
|
|
|
0x00040020, 0x00000008, 0x0000000c, 0x00000004, 0x0004003b, 0x00000008,
|
|
|
|
|
0x00000003, 0x0000000c, 0x00040015, 0x00000009, 0x00000020, 0x00000001,
|
|
|
|
|
0x0004002b, 0x00000009, 0x0000000a, 0x00000000, 0x00040020, 0x0000000b,
|
|
|
|
|
0x0000000c, 0x00000007, 0x0004002b, 0x00000009, 0x0000000c, 0x00000001,
|
|
|
|
|
0x00050036, 0x00000005, 0x00000002, 0x00000000, 0x00000006, 0x000200f8,
|
|
|
|
|
0x0000000d, 0x00050041, 0x0000000b, 0x0000000e, 0x00000003, 0x0000000a,
|
|
|
|
|
0x0006003d, 0x00000007, 0x0000000f, 0x0000000e, 0x00000030, 0x0000000c,
|
|
|
|
|
0x0003003e, 0x0000000e, 0x0000000f, 0x000100fd, 0x00010038,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
get_nir(sizeof(words) / sizeof(words[0]), words);
|
|
|
|
|
|
2023-07-28 15:08:00 -04:00
|
|
|
nir_intrinsic_instr *intrinsic = find_intrinsic(nir_intrinsic_barrier, 0);
|
2020-07-27 14:43:40 +01:00
|
|
|
ASSERT_NE(intrinsic, nullptr);
|
|
|
|
|
|
2025-07-04 15:47:43 +01:00
|
|
|
EXPECT_EQ(nir_intrinsic_memory_semantics(intrinsic), NIR_MEMORY_MAKE_VISIBLE);
|
2020-07-27 14:43:40 +01:00
|
|
|
EXPECT_NE(nir_intrinsic_memory_modes(intrinsic) & nir_var_mem_ssbo, 0);
|
2023-05-30 12:05:30 -07:00
|
|
|
EXPECT_EQ(nir_intrinsic_memory_scope(intrinsic), SCOPE_DEVICE);
|
|
|
|
|
EXPECT_EQ(nir_intrinsic_execution_scope(intrinsic), SCOPE_NONE);
|
2020-07-27 14:43:40 +01:00
|
|
|
}
|
|
|
|
|
|
2021-11-18 00:22:44 -08:00
|
|
|
TEST_F(AvailabilityVisibility, opstore_avail)
|
2020-07-27 14:43:40 +01:00
|
|
|
{
|
|
|
|
|
/*
|
|
|
|
|
OpCapability Shader
|
|
|
|
|
OpCapability VulkanMemoryModel
|
|
|
|
|
OpCapability VulkanMemoryModelDeviceScope
|
|
|
|
|
%1 = OpExtInstImport "GLSL.std.450"
|
|
|
|
|
OpMemoryModel Logical Vulkan
|
|
|
|
|
OpEntryPoint GLCompute %4 "main" %9
|
|
|
|
|
OpExecutionMode %4 LocalSize 1 1 1
|
|
|
|
|
OpMemberDecorate %_struct_7 0 Offset 0
|
|
|
|
|
OpDecorate %_struct_7 Block
|
|
|
|
|
OpDecorate %9 DescriptorSet 0
|
|
|
|
|
OpDecorate %9 Binding 0
|
|
|
|
|
%void = OpTypeVoid
|
|
|
|
|
%3 = OpTypeFunction %void
|
|
|
|
|
%uint = OpTypeInt 32 0
|
|
|
|
|
%_struct_7 = OpTypeStruct %uint
|
|
|
|
|
%_ptr_StorageBuffer__struct_7 = OpTypePointer StorageBuffer %_struct_7
|
|
|
|
|
%9 = OpVariable %_ptr_StorageBuffer__struct_7 StorageBuffer
|
|
|
|
|
%int = OpTypeInt 32 1
|
|
|
|
|
%int_0 = OpConstant %int 0
|
|
|
|
|
%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint
|
|
|
|
|
%device = OpConstant %int 1
|
|
|
|
|
%4 = OpFunction %void None %3
|
|
|
|
|
%5 = OpLabel
|
|
|
|
|
%13 = OpAccessChain %_ptr_StorageBuffer_uint %9 %int_0
|
|
|
|
|
%14 = OpLoad %uint %13
|
|
|
|
|
OpStore %13 %14 NonPrivatePointer|MakePointerAvailable %device
|
|
|
|
|
OpReturn
|
|
|
|
|
OpFunctionEnd
|
|
|
|
|
*/
|
|
|
|
|
static const uint32_t words[] = {
|
|
|
|
|
0x07230203, 0x00010500, 0x00070000, 0x00000010, 0x00000000, 0x00020011,
|
|
|
|
|
0x00000001, 0x00020011, 0x000014e1, 0x00020011, 0x000014e2, 0x0006000b,
|
|
|
|
|
0x00000001, 0x4c534c47, 0x6474732e, 0x3035342e, 0x00000000, 0x0003000e,
|
|
|
|
|
0x00000000, 0x00000003, 0x0006000f, 0x00000005, 0x00000002, 0x6e69616d,
|
|
|
|
|
0x00000000, 0x00000003, 0x00060010, 0x00000002, 0x00000011, 0x00000001,
|
|
|
|
|
0x00000001, 0x00000001, 0x00050048, 0x00000004, 0x00000000, 0x00000023,
|
|
|
|
|
0x00000000, 0x00030047, 0x00000004, 0x00000002, 0x00040047, 0x00000003,
|
|
|
|
|
0x00000022, 0x00000000, 0x00040047, 0x00000003, 0x00000021, 0x00000000,
|
|
|
|
|
0x00020013, 0x00000005, 0x00030021, 0x00000006, 0x00000005, 0x00040015,
|
|
|
|
|
0x00000007, 0x00000020, 0x00000000, 0x0003001e, 0x00000004, 0x00000007,
|
|
|
|
|
0x00040020, 0x00000008, 0x0000000c, 0x00000004, 0x0004003b, 0x00000008,
|
|
|
|
|
0x00000003, 0x0000000c, 0x00040015, 0x00000009, 0x00000020, 0x00000001,
|
|
|
|
|
0x0004002b, 0x00000009, 0x0000000a, 0x00000000, 0x00040020, 0x0000000b,
|
|
|
|
|
0x0000000c, 0x00000007, 0x0004002b, 0x00000009, 0x0000000c, 0x00000001,
|
|
|
|
|
0x00050036, 0x00000005, 0x00000002, 0x00000000, 0x00000006, 0x000200f8,
|
|
|
|
|
0x0000000d, 0x00050041, 0x0000000b, 0x0000000e, 0x00000003, 0x0000000a,
|
|
|
|
|
0x0004003d, 0x00000007, 0x0000000f, 0x0000000e, 0x0005003e, 0x0000000e,
|
|
|
|
|
0x0000000f, 0x00000028, 0x0000000c, 0x000100fd, 0x00010038,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
get_nir(sizeof(words) / sizeof(words[0]), words);
|
|
|
|
|
|
2023-07-28 15:08:00 -04:00
|
|
|
nir_intrinsic_instr *intrinsic = find_intrinsic(nir_intrinsic_barrier, 0);
|
2020-07-27 14:43:40 +01:00
|
|
|
ASSERT_NE(intrinsic, nullptr);
|
|
|
|
|
|
2025-07-04 15:47:43 +01:00
|
|
|
EXPECT_EQ(nir_intrinsic_memory_semantics(intrinsic), NIR_MEMORY_MAKE_AVAILABLE);
|
2020-07-27 14:43:40 +01:00
|
|
|
EXPECT_NE(nir_intrinsic_memory_modes(intrinsic) & nir_var_mem_ssbo, 0);
|
2023-05-30 12:05:30 -07:00
|
|
|
EXPECT_EQ(nir_intrinsic_memory_scope(intrinsic), SCOPE_DEVICE);
|
|
|
|
|
EXPECT_EQ(nir_intrinsic_execution_scope(intrinsic), SCOPE_NONE);
|
2020-07-27 14:43:40 +01:00
|
|
|
}
|
|
|
|
|
|
2021-11-18 00:22:44 -08:00
|
|
|
TEST_F(AvailabilityVisibility, opcopymemory_visavail_both_combined)
|
2020-07-27 14:43:40 +01:00
|
|
|
{
|
|
|
|
|
/*
|
|
|
|
|
OpCapability Shader
|
|
|
|
|
OpCapability VulkanMemoryModel
|
|
|
|
|
OpCapability VulkanMemoryModelDeviceScope
|
|
|
|
|
%1 = OpExtInstImport "GLSL.std.450"
|
|
|
|
|
OpMemoryModel Logical Vulkan
|
|
|
|
|
OpEntryPoint GLCompute %4 "main" %9
|
|
|
|
|
OpExecutionMode %4 LocalSize 1 1 1
|
|
|
|
|
OpMemberDecorate %_struct_7 0 Offset 0
|
|
|
|
|
OpDecorate %_struct_7 Block
|
|
|
|
|
OpDecorate %9 DescriptorSet 0
|
|
|
|
|
OpDecorate %9 Binding 0
|
|
|
|
|
%void = OpTypeVoid
|
|
|
|
|
%3 = OpTypeFunction %void
|
|
|
|
|
%uint = OpTypeInt 32 0
|
|
|
|
|
%_struct_7 = OpTypeStruct %uint
|
|
|
|
|
%_ptr_StorageBuffer__struct_7 = OpTypePointer StorageBuffer %_struct_7
|
|
|
|
|
%9 = OpVariable %_ptr_StorageBuffer__struct_7 StorageBuffer
|
|
|
|
|
%int = OpTypeInt 32 1
|
|
|
|
|
%int_0 = OpConstant %int 0
|
|
|
|
|
%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint
|
|
|
|
|
%device = OpConstant %int 1
|
|
|
|
|
%workgroup = OpConstant %int 2
|
|
|
|
|
%4 = OpFunction %void None %3
|
|
|
|
|
%5 = OpLabel
|
|
|
|
|
%13 = OpAccessChain %_ptr_StorageBuffer_uint %9 %int_0
|
|
|
|
|
OpCopyMemory %13 %13 NonPrivatePointer|MakePointerAvailable|MakePointerVisible %device %workgroup
|
|
|
|
|
OpReturn
|
|
|
|
|
OpFunctionEnd
|
|
|
|
|
*/
|
|
|
|
|
static const uint32_t words[] = {
|
|
|
|
|
0x07230203, 0x00010500, 0x00070000, 0x00000010, 0x00000000, 0x00020011,
|
|
|
|
|
0x00000001, 0x00020011, 0x000014e1, 0x00020011, 0x000014e2, 0x0006000b,
|
|
|
|
|
0x00000001, 0x4c534c47, 0x6474732e, 0x3035342e, 0x00000000, 0x0003000e,
|
|
|
|
|
0x00000000, 0x00000003, 0x0006000f, 0x00000005, 0x00000002, 0x6e69616d,
|
|
|
|
|
0x00000000, 0x00000003, 0x00060010, 0x00000002, 0x00000011, 0x00000001,
|
|
|
|
|
0x00000001, 0x00000001, 0x00050048, 0x00000004, 0x00000000, 0x00000023,
|
|
|
|
|
0x00000000, 0x00030047, 0x00000004, 0x00000002, 0x00040047, 0x00000003,
|
|
|
|
|
0x00000022, 0x00000000, 0x00040047, 0x00000003, 0x00000021, 0x00000000,
|
|
|
|
|
0x00020013, 0x00000005, 0x00030021, 0x00000006, 0x00000005, 0x00040015,
|
|
|
|
|
0x00000007, 0x00000020, 0x00000000, 0x0003001e, 0x00000004, 0x00000007,
|
|
|
|
|
0x00040020, 0x00000008, 0x0000000c, 0x00000004, 0x0004003b, 0x00000008,
|
|
|
|
|
0x00000003, 0x0000000c, 0x00040015, 0x00000009, 0x00000020, 0x00000001,
|
|
|
|
|
0x0004002b, 0x00000009, 0x0000000a, 0x00000000, 0x00040020, 0x0000000b,
|
|
|
|
|
0x0000000c, 0x00000007, 0x0004002b, 0x00000009, 0x0000000c, 0x00000001,
|
|
|
|
|
0x0004002b, 0x00000009, 0x0000000d, 0x00000002, 0x00050036, 0x00000005,
|
|
|
|
|
0x00000002, 0x00000000, 0x00000006, 0x000200f8, 0x0000000e, 0x00050041,
|
|
|
|
|
0x0000000b, 0x0000000f, 0x00000003, 0x0000000a, 0x0006003f, 0x0000000f,
|
|
|
|
|
0x0000000f, 0x00000038, 0x0000000c, 0x0000000d, 0x000100fd, 0x00010038,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
get_nir(sizeof(words) / sizeof(words[0]), words);
|
|
|
|
|
|
2023-07-28 15:08:00 -04:00
|
|
|
nir_intrinsic_instr *first = find_intrinsic(nir_intrinsic_barrier, 0);
|
|
|
|
|
nir_intrinsic_instr *second = find_intrinsic(nir_intrinsic_barrier, 1);
|
2020-07-27 14:43:40 +01:00
|
|
|
ASSERT_NE(first, nullptr);
|
|
|
|
|
ASSERT_NE(second, nullptr);
|
|
|
|
|
|
2025-07-04 15:47:43 +01:00
|
|
|
EXPECT_EQ(nir_intrinsic_memory_semantics(first), NIR_MEMORY_MAKE_VISIBLE);
|
2020-07-27 14:43:40 +01:00
|
|
|
EXPECT_NE(nir_intrinsic_memory_modes(first) & nir_var_mem_ssbo, 0);
|
2023-05-30 12:05:30 -07:00
|
|
|
EXPECT_EQ(nir_intrinsic_memory_scope(first), SCOPE_WORKGROUP);
|
|
|
|
|
EXPECT_EQ(nir_intrinsic_execution_scope(first), SCOPE_NONE);
|
2020-07-27 14:43:40 +01:00
|
|
|
|
2025-07-04 15:47:43 +01:00
|
|
|
EXPECT_EQ(nir_intrinsic_memory_semantics(second), NIR_MEMORY_MAKE_AVAILABLE);
|
2020-07-27 14:43:40 +01:00
|
|
|
EXPECT_NE(nir_intrinsic_memory_modes(second) & nir_var_mem_ssbo, 0);
|
2023-05-30 12:05:30 -07:00
|
|
|
EXPECT_EQ(nir_intrinsic_memory_scope(second), SCOPE_DEVICE);
|
|
|
|
|
EXPECT_EQ(nir_intrinsic_execution_scope(first), SCOPE_NONE);
|
2020-07-27 14:43:40 +01:00
|
|
|
}
|
|
|
|
|
|
2021-11-18 00:22:44 -08:00
|
|
|
TEST_F(AvailabilityVisibility, opcopymemory_visavail_both_separate)
|
2020-07-27 14:43:40 +01:00
|
|
|
{
|
|
|
|
|
/*
|
|
|
|
|
OpCapability Shader
|
|
|
|
|
OpCapability VulkanMemoryModel
|
|
|
|
|
OpCapability VulkanMemoryModelDeviceScope
|
|
|
|
|
%1 = OpExtInstImport "GLSL.std.450"
|
|
|
|
|
OpMemoryModel Logical Vulkan
|
|
|
|
|
OpEntryPoint GLCompute %4 "main" %9
|
|
|
|
|
OpExecutionMode %4 LocalSize 1 1 1
|
|
|
|
|
OpMemberDecorate %_struct_7 0 Offset 0
|
|
|
|
|
OpDecorate %_struct_7 Block
|
|
|
|
|
OpDecorate %9 DescriptorSet 0
|
|
|
|
|
OpDecorate %9 Binding 0
|
|
|
|
|
%void = OpTypeVoid
|
|
|
|
|
%3 = OpTypeFunction %void
|
|
|
|
|
%uint = OpTypeInt 32 0
|
|
|
|
|
%_struct_7 = OpTypeStruct %uint
|
|
|
|
|
%_ptr_StorageBuffer__struct_7 = OpTypePointer StorageBuffer %_struct_7
|
|
|
|
|
%9 = OpVariable %_ptr_StorageBuffer__struct_7 StorageBuffer
|
|
|
|
|
%int = OpTypeInt 32 1
|
|
|
|
|
%int_0 = OpConstant %int 0
|
|
|
|
|
%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint
|
|
|
|
|
%device = OpConstant %int 1
|
|
|
|
|
%workgroup = OpConstant %int 2
|
|
|
|
|
%4 = OpFunction %void None %3
|
|
|
|
|
%5 = OpLabel
|
|
|
|
|
%13 = OpAccessChain %_ptr_StorageBuffer_uint %9 %int_0
|
|
|
|
|
OpCopyMemory %13 %13 NonPrivatePointer|MakePointerAvailable %device NonPrivatePointer|MakePointerVisible %workgroup
|
|
|
|
|
OpReturn
|
|
|
|
|
OpFunctionEnd
|
|
|
|
|
*/
|
|
|
|
|
static const uint32_t words[] = {
|
|
|
|
|
0x07230203, 0x00010500, 0x00070000, 0x00000010, 0x00000000, 0x00020011,
|
|
|
|
|
0x00000001, 0x00020011, 0x000014e1, 0x00020011, 0x000014e2, 0x0006000b,
|
|
|
|
|
0x00000001, 0x4c534c47, 0x6474732e, 0x3035342e, 0x00000000, 0x0003000e,
|
|
|
|
|
0x00000000, 0x00000003, 0x0006000f, 0x00000005, 0x00000002, 0x6e69616d,
|
|
|
|
|
0x00000000, 0x00000003, 0x00060010, 0x00000002, 0x00000011, 0x00000001,
|
|
|
|
|
0x00000001, 0x00000001, 0x00050048, 0x00000004, 0x00000000, 0x00000023,
|
|
|
|
|
0x00000000, 0x00030047, 0x00000004, 0x00000002, 0x00040047, 0x00000003,
|
|
|
|
|
0x00000022, 0x00000000, 0x00040047, 0x00000003, 0x00000021, 0x00000000,
|
|
|
|
|
0x00020013, 0x00000005, 0x00030021, 0x00000006, 0x00000005, 0x00040015,
|
|
|
|
|
0x00000007, 0x00000020, 0x00000000, 0x0003001e, 0x00000004, 0x00000007,
|
|
|
|
|
0x00040020, 0x00000008, 0x0000000c, 0x00000004, 0x0004003b, 0x00000008,
|
|
|
|
|
0x00000003, 0x0000000c, 0x00040015, 0x00000009, 0x00000020, 0x00000001,
|
|
|
|
|
0x0004002b, 0x00000009, 0x0000000a, 0x00000000, 0x00040020, 0x0000000b,
|
|
|
|
|
0x0000000c, 0x00000007, 0x0004002b, 0x00000009, 0x0000000c, 0x00000001,
|
|
|
|
|
0x0004002b, 0x00000009, 0x0000000d, 0x00000002, 0x00050036, 0x00000005,
|
|
|
|
|
0x00000002, 0x00000000, 0x00000006, 0x000200f8, 0x0000000e, 0x00050041,
|
|
|
|
|
0x0000000b, 0x0000000f, 0x00000003, 0x0000000a, 0x0007003f, 0x0000000f,
|
|
|
|
|
0x0000000f, 0x00000028, 0x0000000c, 0x00000030, 0x0000000d, 0x000100fd,
|
|
|
|
|
0x00010038,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
get_nir(sizeof(words) / sizeof(words[0]), words);
|
|
|
|
|
|
2023-07-28 15:08:00 -04:00
|
|
|
nir_intrinsic_instr *first = find_intrinsic(nir_intrinsic_barrier, 0);
|
|
|
|
|
nir_intrinsic_instr *second = find_intrinsic(nir_intrinsic_barrier, 1);
|
2020-07-27 14:43:40 +01:00
|
|
|
ASSERT_NE(first, nullptr);
|
|
|
|
|
ASSERT_NE(second, nullptr);
|
|
|
|
|
|
2025-07-04 15:47:43 +01:00
|
|
|
EXPECT_EQ(nir_intrinsic_memory_semantics(first), NIR_MEMORY_MAKE_VISIBLE);
|
2020-07-27 14:43:40 +01:00
|
|
|
EXPECT_NE(nir_intrinsic_memory_modes(first) & nir_var_mem_ssbo, 0);
|
2023-05-30 12:05:30 -07:00
|
|
|
EXPECT_EQ(nir_intrinsic_memory_scope(first), SCOPE_WORKGROUP);
|
|
|
|
|
EXPECT_EQ(nir_intrinsic_execution_scope(first), SCOPE_NONE);
|
2020-07-27 14:43:40 +01:00
|
|
|
|
2025-07-04 15:47:43 +01:00
|
|
|
EXPECT_EQ(nir_intrinsic_memory_semantics(second), NIR_MEMORY_MAKE_AVAILABLE);
|
2020-07-27 14:43:40 +01:00
|
|
|
EXPECT_NE(nir_intrinsic_memory_modes(second) & nir_var_mem_ssbo, 0);
|
2023-05-30 12:05:30 -07:00
|
|
|
EXPECT_EQ(nir_intrinsic_memory_scope(second), SCOPE_DEVICE);
|
|
|
|
|
EXPECT_EQ(nir_intrinsic_execution_scope(second), SCOPE_NONE);
|
2020-07-27 14:43:40 +01:00
|
|
|
}
|
|
|
|
|
|
2021-11-18 00:22:44 -08:00
|
|
|
TEST_F(AvailabilityVisibility, opcopymemory_avail)
|
2020-07-27 14:43:40 +01:00
|
|
|
{
|
|
|
|
|
/*
|
|
|
|
|
OpCapability Shader
|
|
|
|
|
OpCapability VulkanMemoryModel
|
|
|
|
|
OpCapability VulkanMemoryModelDeviceScope
|
|
|
|
|
%1 = OpExtInstImport "GLSL.std.450"
|
|
|
|
|
OpMemoryModel Logical Vulkan
|
|
|
|
|
OpEntryPoint GLCompute %4 "main" %9
|
|
|
|
|
OpExecutionMode %4 LocalSize 1 1 1
|
|
|
|
|
OpMemberDecorate %_struct_7 0 Offset 0
|
|
|
|
|
OpDecorate %_struct_7 Block
|
|
|
|
|
OpDecorate %9 DescriptorSet 0
|
|
|
|
|
OpDecorate %9 Binding 0
|
|
|
|
|
%void = OpTypeVoid
|
|
|
|
|
%3 = OpTypeFunction %void
|
|
|
|
|
%uint = OpTypeInt 32 0
|
|
|
|
|
%_struct_7 = OpTypeStruct %uint
|
|
|
|
|
%_ptr_StorageBuffer__struct_7 = OpTypePointer StorageBuffer %_struct_7
|
|
|
|
|
%9 = OpVariable %_ptr_StorageBuffer__struct_7 StorageBuffer
|
|
|
|
|
%int = OpTypeInt 32 1
|
|
|
|
|
%int_0 = OpConstant %int 0
|
|
|
|
|
%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint
|
|
|
|
|
%device = OpConstant %int 1
|
|
|
|
|
%4 = OpFunction %void None %3
|
|
|
|
|
%5 = OpLabel
|
|
|
|
|
%13 = OpAccessChain %_ptr_StorageBuffer_uint %9 %int_0
|
|
|
|
|
OpCopyMemory %13 %13 NonPrivatePointer|MakePointerAvailable %device
|
|
|
|
|
OpReturn
|
|
|
|
|
OpFunctionEnd
|
|
|
|
|
*/
|
|
|
|
|
static const uint32_t words[] = {
|
|
|
|
|
0x07230203, 0x00010500, 0x00070000, 0x0000000f, 0x00000000, 0x00020011,
|
|
|
|
|
0x00000001, 0x00020011, 0x000014e1, 0x00020011, 0x000014e2, 0x0006000b,
|
|
|
|
|
0x00000001, 0x4c534c47, 0x6474732e, 0x3035342e, 0x00000000, 0x0003000e,
|
|
|
|
|
0x00000000, 0x00000003, 0x0006000f, 0x00000005, 0x00000002, 0x6e69616d,
|
|
|
|
|
0x00000000, 0x00000003, 0x00060010, 0x00000002, 0x00000011, 0x00000001,
|
|
|
|
|
0x00000001, 0x00000001, 0x00050048, 0x00000004, 0x00000000, 0x00000023,
|
|
|
|
|
0x00000000, 0x00030047, 0x00000004, 0x00000002, 0x00040047, 0x00000003,
|
|
|
|
|
0x00000022, 0x00000000, 0x00040047, 0x00000003, 0x00000021, 0x00000000,
|
|
|
|
|
0x00020013, 0x00000005, 0x00030021, 0x00000006, 0x00000005, 0x00040015,
|
|
|
|
|
0x00000007, 0x00000020, 0x00000000, 0x0003001e, 0x00000004, 0x00000007,
|
|
|
|
|
0x00040020, 0x00000008, 0x0000000c, 0x00000004, 0x0004003b, 0x00000008,
|
|
|
|
|
0x00000003, 0x0000000c, 0x00040015, 0x00000009, 0x00000020, 0x00000001,
|
|
|
|
|
0x0004002b, 0x00000009, 0x0000000a, 0x00000000, 0x00040020, 0x0000000b,
|
|
|
|
|
0x0000000c, 0x00000007, 0x0004002b, 0x00000009, 0x0000000c, 0x00000001,
|
|
|
|
|
0x00050036, 0x00000005, 0x00000002, 0x00000000, 0x00000006, 0x000200f8,
|
|
|
|
|
0x0000000d, 0x00050041, 0x0000000b, 0x0000000e, 0x00000003, 0x0000000a,
|
|
|
|
|
0x0005003f, 0x0000000e, 0x0000000e, 0x00000028, 0x0000000c, 0x000100fd,
|
|
|
|
|
0x00010038,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
get_nir(sizeof(words) / sizeof(words[0]), words);
|
|
|
|
|
|
2023-07-28 15:08:00 -04:00
|
|
|
nir_intrinsic_instr *intrinsic = find_intrinsic(nir_intrinsic_barrier, 0);
|
2020-07-27 14:43:40 +01:00
|
|
|
ASSERT_NE(intrinsic, nullptr);
|
|
|
|
|
|
2025-07-04 15:47:43 +01:00
|
|
|
EXPECT_EQ(nir_intrinsic_memory_semantics(intrinsic), NIR_MEMORY_MAKE_AVAILABLE);
|
2020-07-27 14:43:40 +01:00
|
|
|
EXPECT_NE(nir_intrinsic_memory_modes(intrinsic) & nir_var_mem_ssbo, 0);
|
2023-05-30 12:05:30 -07:00
|
|
|
EXPECT_EQ(nir_intrinsic_memory_scope(intrinsic), SCOPE_DEVICE);
|
|
|
|
|
EXPECT_EQ(nir_intrinsic_execution_scope(intrinsic), SCOPE_NONE);
|
2020-07-27 14:43:40 +01:00
|
|
|
}
|
|
|
|
|
|
2021-11-18 00:22:44 -08:00
|
|
|
TEST_F(AvailabilityVisibility, opcopymemory_vis)
|
2020-07-27 14:43:40 +01:00
|
|
|
{
|
|
|
|
|
/*
|
|
|
|
|
OpCapability Shader
|
|
|
|
|
OpCapability VulkanMemoryModel
|
|
|
|
|
OpCapability VulkanMemoryModelDeviceScope
|
|
|
|
|
%1 = OpExtInstImport "GLSL.std.450"
|
|
|
|
|
OpMemoryModel Logical Vulkan
|
|
|
|
|
OpEntryPoint GLCompute %4 "main" %9
|
|
|
|
|
OpExecutionMode %4 LocalSize 1 1 1
|
|
|
|
|
OpMemberDecorate %_struct_7 0 Offset 0
|
|
|
|
|
OpDecorate %_struct_7 Block
|
|
|
|
|
OpDecorate %9 DescriptorSet 0
|
|
|
|
|
OpDecorate %9 Binding 0
|
|
|
|
|
%void = OpTypeVoid
|
|
|
|
|
%3 = OpTypeFunction %void
|
|
|
|
|
%uint = OpTypeInt 32 0
|
|
|
|
|
%_struct_7 = OpTypeStruct %uint
|
|
|
|
|
%_ptr_StorageBuffer__struct_7 = OpTypePointer StorageBuffer %_struct_7
|
|
|
|
|
%9 = OpVariable %_ptr_StorageBuffer__struct_7 StorageBuffer
|
|
|
|
|
%int = OpTypeInt 32 1
|
|
|
|
|
%int_0 = OpConstant %int 0
|
|
|
|
|
%_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint
|
|
|
|
|
%workgroup = OpConstant %int 2
|
|
|
|
|
%4 = OpFunction %void None %3
|
|
|
|
|
%5 = OpLabel
|
|
|
|
|
%13 = OpAccessChain %_ptr_StorageBuffer_uint %9 %int_0
|
|
|
|
|
OpCopyMemory %13 %13 NonPrivatePointer|MakePointerVisible %workgroup
|
|
|
|
|
OpReturn
|
|
|
|
|
OpFunctionEnd
|
|
|
|
|
*/
|
|
|
|
|
static const uint32_t words[] = {
|
|
|
|
|
0x07230203, 0x00010500, 0x00070000, 0x0000000f, 0x00000000, 0x00020011,
|
|
|
|
|
0x00000001, 0x00020011, 0x000014e1, 0x00020011, 0x000014e2, 0x0006000b,
|
|
|
|
|
0x00000001, 0x4c534c47, 0x6474732e, 0x3035342e, 0x00000000, 0x0003000e,
|
|
|
|
|
0x00000000, 0x00000003, 0x0006000f, 0x00000005, 0x00000002, 0x6e69616d,
|
|
|
|
|
0x00000000, 0x00000003, 0x00060010, 0x00000002, 0x00000011, 0x00000001,
|
|
|
|
|
0x00000001, 0x00000001, 0x00050048, 0x00000004, 0x00000000, 0x00000023,
|
|
|
|
|
0x00000000, 0x00030047, 0x00000004, 0x00000002, 0x00040047, 0x00000003,
|
|
|
|
|
0x00000022, 0x00000000, 0x00040047, 0x00000003, 0x00000021, 0x00000000,
|
|
|
|
|
0x00020013, 0x00000005, 0x00030021, 0x00000006, 0x00000005, 0x00040015,
|
|
|
|
|
0x00000007, 0x00000020, 0x00000000, 0x0003001e, 0x00000004, 0x00000007,
|
|
|
|
|
0x00040020, 0x00000008, 0x0000000c, 0x00000004, 0x0004003b, 0x00000008,
|
|
|
|
|
0x00000003, 0x0000000c, 0x00040015, 0x00000009, 0x00000020, 0x00000001,
|
|
|
|
|
0x0004002b, 0x00000009, 0x0000000a, 0x00000000, 0x00040020, 0x0000000b,
|
|
|
|
|
0x0000000c, 0x00000007, 0x0004002b, 0x00000009, 0x0000000c, 0x00000002,
|
|
|
|
|
0x00050036, 0x00000005, 0x00000002, 0x00000000, 0x00000006, 0x000200f8,
|
|
|
|
|
0x0000000d, 0x00050041, 0x0000000b, 0x0000000e, 0x00000003, 0x0000000a,
|
|
|
|
|
0x0005003f, 0x0000000e, 0x0000000e, 0x00000030, 0x0000000c, 0x000100fd,
|
|
|
|
|
0x00010038,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
get_nir(sizeof(words) / sizeof(words[0]), words);
|
|
|
|
|
|
2023-07-28 15:08:00 -04:00
|
|
|
nir_intrinsic_instr *intrinsic = find_intrinsic(nir_intrinsic_barrier, 0);
|
2020-07-27 14:43:40 +01:00
|
|
|
ASSERT_NE(intrinsic, nullptr);
|
|
|
|
|
|
2025-07-04 15:47:43 +01:00
|
|
|
EXPECT_EQ(nir_intrinsic_memory_semantics(intrinsic), NIR_MEMORY_MAKE_VISIBLE);
|
2020-07-27 14:43:40 +01:00
|
|
|
EXPECT_NE(nir_intrinsic_memory_modes(intrinsic) & nir_var_mem_ssbo, 0);
|
2023-05-30 12:05:30 -07:00
|
|
|
EXPECT_EQ(nir_intrinsic_memory_scope(intrinsic), SCOPE_WORKGROUP);
|
|
|
|
|
EXPECT_EQ(nir_intrinsic_execution_scope(intrinsic), SCOPE_NONE);
|
2020-07-27 14:43:40 +01:00
|
|
|
}
|