spirv: add some tests for volatile/available/visible
Signed-off-by: Rhys Perry <pendingchaos02@gmail.com> Acked-by: Jason Ekstrand <jason@jlekstrand.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6090>
This commit is contained in:
@@ -56,7 +56,7 @@ subdir('spirv')
|
|||||||
|
|
||||||
subdir('nir')
|
subdir('nir')
|
||||||
|
|
||||||
# This is here because putting it in spirv/meson.build would create a circular
|
# These are here because putting it in spirv/meson.build would create a circular
|
||||||
# dependency with nir/meson.build.
|
# dependency with nir/meson.build.
|
||||||
spirv2nir = executable(
|
spirv2nir = executable(
|
||||||
'spirv2nir',
|
'spirv2nir',
|
||||||
@@ -69,4 +69,32 @@ spirv2nir = executable(
|
|||||||
install : with_tools.contains('nir'),
|
install : with_tools.contains('nir'),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if with_tests
|
||||||
|
test(
|
||||||
|
'avail_vis',
|
||||||
|
executable(
|
||||||
|
'avail_vis',
|
||||||
|
files('spirv/tests/avail_vis.cpp'),
|
||||||
|
c_args : [c_msvc_compat_args, no_override_init_args],
|
||||||
|
gnu_symbol_visibility : 'hidden',
|
||||||
|
include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux],
|
||||||
|
dependencies : [dep_thread, idep_gtest, idep_nir, idep_mesautil],
|
||||||
|
),
|
||||||
|
suite : ['compiler', 'spirv'],
|
||||||
|
)
|
||||||
|
|
||||||
|
test(
|
||||||
|
'volatile',
|
||||||
|
executable(
|
||||||
|
'volatile',
|
||||||
|
files('spirv/tests/volatile.cpp'),
|
||||||
|
c_args : [c_msvc_compat_args, no_override_init_args],
|
||||||
|
gnu_symbol_visibility : 'hidden',
|
||||||
|
include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux],
|
||||||
|
dependencies : [dep_thread, idep_gtest, idep_nir, idep_mesautil],
|
||||||
|
),
|
||||||
|
suite : ['compiler', 'spirv'],
|
||||||
|
)
|
||||||
|
endif
|
||||||
|
|
||||||
subdir('glsl')
|
subdir('glsl')
|
||||||
|
420
src/compiler/spirv/tests/avail_vis.cpp
Normal file
420
src/compiler/spirv/tests/avail_vis.cpp
Normal file
@@ -0,0 +1,420 @@
|
|||||||
|
/*
|
||||||
|
* Copyright © 2020 Valve Corporation
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
* copy of this software and associated documentation files (the "Software"),
|
||||||
|
* to deal in the Software without restriction, including without limitation
|
||||||
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
|
* and/or sell copies of the Software, and to permit persons to whom the
|
||||||
|
* Software is furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice (including the next
|
||||||
|
* paragraph) shall be included in all copies or substantial portions of the
|
||||||
|
* Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||||
|
* IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
#include "helpers.h"
|
||||||
|
|
||||||
|
TEST_F(spirv_test, opload_vis)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
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);
|
||||||
|
|
||||||
|
nir_intrinsic_instr *intrinsic = find_intrinsic(nir_intrinsic_scoped_barrier, 0);
|
||||||
|
ASSERT_NE(intrinsic, nullptr);
|
||||||
|
|
||||||
|
EXPECT_EQ(nir_intrinsic_memory_semantics(intrinsic), NIR_MEMORY_MAKE_VISIBLE | NIR_MEMORY_ACQUIRE);
|
||||||
|
EXPECT_NE(nir_intrinsic_memory_modes(intrinsic) & nir_var_mem_ssbo, 0);
|
||||||
|
EXPECT_EQ(nir_intrinsic_memory_scope(intrinsic), NIR_SCOPE_DEVICE);
|
||||||
|
EXPECT_EQ(nir_intrinsic_execution_scope(intrinsic), NIR_SCOPE_NONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(spirv_test, opstore_avail)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
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);
|
||||||
|
|
||||||
|
nir_intrinsic_instr *intrinsic = find_intrinsic(nir_intrinsic_scoped_barrier, 0);
|
||||||
|
ASSERT_NE(intrinsic, nullptr);
|
||||||
|
|
||||||
|
EXPECT_EQ(nir_intrinsic_memory_semantics(intrinsic), NIR_MEMORY_MAKE_AVAILABLE | NIR_MEMORY_RELEASE);
|
||||||
|
EXPECT_NE(nir_intrinsic_memory_modes(intrinsic) & nir_var_mem_ssbo, 0);
|
||||||
|
EXPECT_EQ(nir_intrinsic_memory_scope(intrinsic), NIR_SCOPE_DEVICE);
|
||||||
|
EXPECT_EQ(nir_intrinsic_execution_scope(intrinsic), NIR_SCOPE_NONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(spirv_test, opcopymemory_visavail_both_combined)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
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);
|
||||||
|
|
||||||
|
nir_intrinsic_instr *first = find_intrinsic(nir_intrinsic_scoped_barrier, 0);
|
||||||
|
nir_intrinsic_instr *second = find_intrinsic(nir_intrinsic_scoped_barrier, 1);
|
||||||
|
ASSERT_NE(first, nullptr);
|
||||||
|
ASSERT_NE(second, nullptr);
|
||||||
|
|
||||||
|
EXPECT_EQ(nir_intrinsic_memory_semantics(first), NIR_MEMORY_MAKE_VISIBLE | NIR_MEMORY_ACQUIRE);
|
||||||
|
EXPECT_NE(nir_intrinsic_memory_modes(first) & nir_var_mem_ssbo, 0);
|
||||||
|
EXPECT_EQ(nir_intrinsic_memory_scope(first), NIR_SCOPE_WORKGROUP);
|
||||||
|
EXPECT_EQ(nir_intrinsic_execution_scope(first), NIR_SCOPE_NONE);
|
||||||
|
|
||||||
|
EXPECT_EQ(nir_intrinsic_memory_semantics(second), NIR_MEMORY_MAKE_AVAILABLE | NIR_MEMORY_RELEASE);
|
||||||
|
EXPECT_NE(nir_intrinsic_memory_modes(second) & nir_var_mem_ssbo, 0);
|
||||||
|
EXPECT_EQ(nir_intrinsic_memory_scope(second), NIR_SCOPE_DEVICE);
|
||||||
|
EXPECT_EQ(nir_intrinsic_execution_scope(first), NIR_SCOPE_NONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(spirv_test, opcopymemory_visavail_both_separate)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
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);
|
||||||
|
|
||||||
|
nir_intrinsic_instr *first = find_intrinsic(nir_intrinsic_scoped_barrier, 0);
|
||||||
|
nir_intrinsic_instr *second = find_intrinsic(nir_intrinsic_scoped_barrier, 1);
|
||||||
|
ASSERT_NE(first, nullptr);
|
||||||
|
ASSERT_NE(second, nullptr);
|
||||||
|
|
||||||
|
EXPECT_EQ(nir_intrinsic_memory_semantics(first), NIR_MEMORY_MAKE_VISIBLE | NIR_MEMORY_ACQUIRE);
|
||||||
|
EXPECT_NE(nir_intrinsic_memory_modes(first) & nir_var_mem_ssbo, 0);
|
||||||
|
EXPECT_EQ(nir_intrinsic_memory_scope(first), NIR_SCOPE_WORKGROUP);
|
||||||
|
EXPECT_EQ(nir_intrinsic_execution_scope(first), NIR_SCOPE_NONE);
|
||||||
|
|
||||||
|
EXPECT_EQ(nir_intrinsic_memory_semantics(second), NIR_MEMORY_MAKE_AVAILABLE | NIR_MEMORY_RELEASE);
|
||||||
|
EXPECT_NE(nir_intrinsic_memory_modes(second) & nir_var_mem_ssbo, 0);
|
||||||
|
EXPECT_EQ(nir_intrinsic_memory_scope(second), NIR_SCOPE_DEVICE);
|
||||||
|
EXPECT_EQ(nir_intrinsic_execution_scope(second), NIR_SCOPE_NONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(spirv_test, opcopymemory_avail)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
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);
|
||||||
|
|
||||||
|
nir_intrinsic_instr *intrinsic = find_intrinsic(nir_intrinsic_scoped_barrier, 0);
|
||||||
|
ASSERT_NE(intrinsic, nullptr);
|
||||||
|
|
||||||
|
EXPECT_EQ(nir_intrinsic_memory_semantics(intrinsic), NIR_MEMORY_MAKE_AVAILABLE | NIR_MEMORY_RELEASE);
|
||||||
|
EXPECT_NE(nir_intrinsic_memory_modes(intrinsic) & nir_var_mem_ssbo, 0);
|
||||||
|
EXPECT_EQ(nir_intrinsic_memory_scope(intrinsic), NIR_SCOPE_DEVICE);
|
||||||
|
EXPECT_EQ(nir_intrinsic_execution_scope(intrinsic), NIR_SCOPE_NONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(spirv_test, opcopymemory_vis)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
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);
|
||||||
|
|
||||||
|
nir_intrinsic_instr *intrinsic = find_intrinsic(nir_intrinsic_scoped_barrier, 0);
|
||||||
|
ASSERT_NE(intrinsic, nullptr);
|
||||||
|
|
||||||
|
EXPECT_EQ(nir_intrinsic_memory_semantics(intrinsic), NIR_MEMORY_MAKE_VISIBLE | NIR_MEMORY_ACQUIRE);
|
||||||
|
EXPECT_NE(nir_intrinsic_memory_modes(intrinsic) & nir_var_mem_ssbo, 0);
|
||||||
|
EXPECT_EQ(nir_intrinsic_memory_scope(intrinsic), NIR_SCOPE_WORKGROUP);
|
||||||
|
EXPECT_EQ(nir_intrinsic_execution_scope(intrinsic), NIR_SCOPE_NONE);
|
||||||
|
}
|
85
src/compiler/spirv/tests/helpers.h
Normal file
85
src/compiler/spirv/tests/helpers.h
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
/*
|
||||||
|
* Copyright © 2020 Valve Corporation
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
* copy of this software and associated documentation files (the "Software"),
|
||||||
|
* to deal in the Software without restriction, including without limitation
|
||||||
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
|
* and/or sell copies of the Software, and to permit persons to whom the
|
||||||
|
* Software is furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice (including the next
|
||||||
|
* paragraph) shall be included in all copies or substantial portions of the
|
||||||
|
* Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||||
|
* IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
#ifndef SPIRV_TEST_HELPERS_H
|
||||||
|
#define SPIRV_TEST_HELPERS_H
|
||||||
|
|
||||||
|
#include <gtest/gtest.h>
|
||||||
|
#include "compiler/spirv/nir_spirv.h"
|
||||||
|
#include "compiler/nir/nir.h"
|
||||||
|
|
||||||
|
class spirv_test : public ::testing::Test {
|
||||||
|
protected:
|
||||||
|
spirv_test()
|
||||||
|
{
|
||||||
|
glsl_type_singleton_init_or_ref();
|
||||||
|
}
|
||||||
|
|
||||||
|
~spirv_test()
|
||||||
|
{
|
||||||
|
ralloc_free(shader);
|
||||||
|
glsl_type_singleton_decref();
|
||||||
|
}
|
||||||
|
|
||||||
|
void get_nir(size_t num_words, const uint32_t *words)
|
||||||
|
{
|
||||||
|
spirv_to_nir_options spirv_options;
|
||||||
|
memset(&spirv_options, 0, sizeof(spirv_options));
|
||||||
|
spirv_options.environment = NIR_SPIRV_VULKAN;
|
||||||
|
spirv_options.caps.vk_memory_model = true;
|
||||||
|
spirv_options.caps.vk_memory_model_device_scope = true;
|
||||||
|
spirv_options.ubo_addr_format = nir_address_format_32bit_index_offset;
|
||||||
|
spirv_options.ssbo_addr_format = nir_address_format_32bit_index_offset;
|
||||||
|
spirv_options.phys_ssbo_addr_format = nir_address_format_64bit_global;
|
||||||
|
spirv_options.push_const_addr_format = nir_address_format_32bit_offset;
|
||||||
|
spirv_options.shared_addr_format = nir_address_format_32bit_offset;
|
||||||
|
|
||||||
|
nir_shader_compiler_options nir_options;
|
||||||
|
memset(&nir_options, 0, sizeof(nir_options));
|
||||||
|
nir_options.use_scoped_barrier = true;
|
||||||
|
|
||||||
|
shader = spirv_to_nir(words, num_words, NULL, 0,
|
||||||
|
MESA_SHADER_COMPUTE, "main", &spirv_options, &nir_options);
|
||||||
|
}
|
||||||
|
|
||||||
|
nir_intrinsic_instr *find_intrinsic(nir_intrinsic_op op, unsigned index=0)
|
||||||
|
{
|
||||||
|
nir_function_impl *impl = nir_shader_get_entrypoint(shader);
|
||||||
|
nir_foreach_block(block, impl) {
|
||||||
|
nir_foreach_instr(instr, block) {
|
||||||
|
if (instr->type != nir_instr_type_intrinsic ||
|
||||||
|
nir_instr_as_intrinsic(instr)->intrinsic != op)
|
||||||
|
continue;
|
||||||
|
if (index == 0)
|
||||||
|
return nir_instr_as_intrinsic(instr);
|
||||||
|
else
|
||||||
|
index--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
nir_shader *shader;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* SPIRV_TEST_HELPERS_H */
|
575
src/compiler/spirv/tests/volatile.cpp
Normal file
575
src/compiler/spirv/tests/volatile.cpp
Normal file
@@ -0,0 +1,575 @@
|
|||||||
|
/*
|
||||||
|
* Copyright © 2020 Valve Corporation
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
* copy of this software and associated documentation files (the "Software"),
|
||||||
|
* to deal in the Software without restriction, including without limitation
|
||||||
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
|
* and/or sell copies of the Software, and to permit persons to whom the
|
||||||
|
* Software is furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice (including the next
|
||||||
|
* paragraph) shall be included in all copies or substantial portions of the
|
||||||
|
* Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||||
|
* IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
#include "helpers.h"
|
||||||
|
|
||||||
|
TEST_F(spirv_test, opload_volatile)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
OpCapability Shader
|
||||||
|
%1 = OpExtInstImport "GLSL.std.450"
|
||||||
|
OpMemoryModel Logical GLSL450
|
||||||
|
OpEntryPoint GLCompute %4 "main"
|
||||||
|
OpExecutionMode %4 LocalSize 1 1 1
|
||||||
|
OpMemberDecorate %_struct_7 0 Offset 0
|
||||||
|
OpDecorate %_struct_7 BufferBlock
|
||||||
|
OpDecorate %9 DescriptorSet 0
|
||||||
|
OpDecorate %9 Binding 0
|
||||||
|
%void = OpTypeVoid
|
||||||
|
%3 = OpTypeFunction %void
|
||||||
|
%uint = OpTypeInt 32 0
|
||||||
|
%_struct_7 = OpTypeStruct %uint
|
||||||
|
%_ptr_Uniform__struct_7 = OpTypePointer Uniform %_struct_7
|
||||||
|
%9 = OpVariable %_ptr_Uniform__struct_7 Uniform
|
||||||
|
%int = OpTypeInt 32 1
|
||||||
|
%int_0 = OpConstant %int 0
|
||||||
|
%_ptr_Uniform_uint = OpTypePointer Uniform %uint
|
||||||
|
%4 = OpFunction %void None %3
|
||||||
|
%5 = OpLabel
|
||||||
|
%13 = OpAccessChain %_ptr_Uniform_uint %9 %int_0
|
||||||
|
%14 = OpLoad %uint %13 Volatile
|
||||||
|
OpStore %13 %14
|
||||||
|
OpReturn
|
||||||
|
OpFunctionEnd
|
||||||
|
*/
|
||||||
|
static const uint32_t words[] = {
|
||||||
|
0x07230203, 0x00010300, 0x00070000, 0x0000000f, 0x00000000, 0x00020011,
|
||||||
|
0x00000001, 0x0006000b, 0x00000001, 0x4c534c47, 0x6474732e, 0x3035342e,
|
||||||
|
0x00000000, 0x0003000e, 0x00000000, 0x00000001, 0x0005000f, 0x00000005,
|
||||||
|
0x00000002, 0x6e69616d, 0x00000000, 0x00060010, 0x00000002, 0x00000011,
|
||||||
|
0x00000001, 0x00000001, 0x00000001, 0x00050048, 0x00000003, 0x00000000,
|
||||||
|
0x00000023, 0x00000000, 0x00030047, 0x00000003, 0x00000003, 0x00040047,
|
||||||
|
0x00000004, 0x00000022, 0x00000000, 0x00040047, 0x00000004, 0x00000021,
|
||||||
|
0x00000000, 0x00020013, 0x00000005, 0x00030021, 0x00000006, 0x00000005,
|
||||||
|
0x00040015, 0x00000007, 0x00000020, 0x00000000, 0x0003001e, 0x00000003,
|
||||||
|
0x00000007, 0x00040020, 0x00000008, 0x00000002, 0x00000003, 0x0004003b,
|
||||||
|
0x00000008, 0x00000004, 0x00000002, 0x00040015, 0x00000009, 0x00000020,
|
||||||
|
0x00000001, 0x0004002b, 0x00000009, 0x0000000a, 0x00000000, 0x00040020,
|
||||||
|
0x0000000b, 0x00000002, 0x00000007, 0x00050036, 0x00000005, 0x00000002,
|
||||||
|
0x00000000, 0x00000006, 0x000200f8, 0x0000000c, 0x00050041, 0x0000000b,
|
||||||
|
0x0000000d, 0x00000004, 0x0000000a, 0x0005003d, 0x00000007, 0x0000000e,
|
||||||
|
0x0000000d, 0x00000001, 0x0003003e, 0x0000000d, 0x0000000e, 0x000100fd,
|
||||||
|
0x00010038,
|
||||||
|
};
|
||||||
|
|
||||||
|
get_nir(sizeof(words) / sizeof(words[0]), words);
|
||||||
|
|
||||||
|
nir_intrinsic_instr *intrinsic = find_intrinsic(nir_intrinsic_load_deref);
|
||||||
|
ASSERT_NE(intrinsic, nullptr);
|
||||||
|
EXPECT_NE(nir_intrinsic_access(intrinsic) & ACCESS_VOLATILE, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(spirv_test, opstore_volatile)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
OpCapability Shader
|
||||||
|
%1 = OpExtInstImport "GLSL.std.450"
|
||||||
|
OpMemoryModel Logical GLSL450
|
||||||
|
OpEntryPoint GLCompute %4 "main"
|
||||||
|
OpExecutionMode %4 LocalSize 1 1 1
|
||||||
|
OpMemberDecorate %_struct_7 0 Offset 0
|
||||||
|
OpDecorate %_struct_7 BufferBlock
|
||||||
|
OpDecorate %9 DescriptorSet 0
|
||||||
|
OpDecorate %9 Binding 0
|
||||||
|
%void = OpTypeVoid
|
||||||
|
%3 = OpTypeFunction %void
|
||||||
|
%uint = OpTypeInt 32 0
|
||||||
|
%_struct_7 = OpTypeStruct %uint
|
||||||
|
%_ptr_Uniform__struct_7 = OpTypePointer Uniform %_struct_7
|
||||||
|
%9 = OpVariable %_ptr_Uniform__struct_7 Uniform
|
||||||
|
%int = OpTypeInt 32 1
|
||||||
|
%int_0 = OpConstant %int 0
|
||||||
|
%_ptr_Uniform_uint = OpTypePointer Uniform %uint
|
||||||
|
%4 = OpFunction %void None %3
|
||||||
|
%5 = OpLabel
|
||||||
|
%13 = OpAccessChain %_ptr_Uniform_uint %9 %int_0
|
||||||
|
%14 = OpLoad %uint %13
|
||||||
|
OpStore %13 %14 Volatile
|
||||||
|
OpReturn
|
||||||
|
OpFunctionEnd
|
||||||
|
*/
|
||||||
|
static const uint32_t words[] = {
|
||||||
|
0x07230203, 0x00010300, 0x00070000, 0x0000000f, 0x00000000, 0x00020011,
|
||||||
|
0x00000001, 0x0006000b, 0x00000001, 0x4c534c47, 0x6474732e, 0x3035342e,
|
||||||
|
0x00000000, 0x0003000e, 0x00000000, 0x00000001, 0x0005000f, 0x00000005,
|
||||||
|
0x00000002, 0x6e69616d, 0x00000000, 0x00060010, 0x00000002, 0x00000011,
|
||||||
|
0x00000001, 0x00000001, 0x00000001, 0x00050048, 0x00000003, 0x00000000,
|
||||||
|
0x00000023, 0x00000000, 0x00030047, 0x00000003, 0x00000003, 0x00040047,
|
||||||
|
0x00000004, 0x00000022, 0x00000000, 0x00040047, 0x00000004, 0x00000021,
|
||||||
|
0x00000000, 0x00020013, 0x00000005, 0x00030021, 0x00000006, 0x00000005,
|
||||||
|
0x00040015, 0x00000007, 0x00000020, 0x00000000, 0x0003001e, 0x00000003,
|
||||||
|
0x00000007, 0x00040020, 0x00000008, 0x00000002, 0x00000003, 0x0004003b,
|
||||||
|
0x00000008, 0x00000004, 0x00000002, 0x00040015, 0x00000009, 0x00000020,
|
||||||
|
0x00000001, 0x0004002b, 0x00000009, 0x0000000a, 0x00000000, 0x00040020,
|
||||||
|
0x0000000b, 0x00000002, 0x00000007, 0x00050036, 0x00000005, 0x00000002,
|
||||||
|
0x00000000, 0x00000006, 0x000200f8, 0x0000000c, 0x00050041, 0x0000000b,
|
||||||
|
0x0000000d, 0x00000004, 0x0000000a, 0x0004003d, 0x00000007, 0x0000000e,
|
||||||
|
0x0000000d, 0x0004003e, 0x0000000d, 0x0000000e, 0x00000001, 0x000100fd,
|
||||||
|
0x00010038,
|
||||||
|
};
|
||||||
|
|
||||||
|
get_nir(sizeof(words) / sizeof(words[0]), words);
|
||||||
|
|
||||||
|
nir_intrinsic_instr *intrinsic = find_intrinsic(nir_intrinsic_store_deref);
|
||||||
|
ASSERT_NE(intrinsic, nullptr);
|
||||||
|
EXPECT_NE(nir_intrinsic_access(intrinsic) & ACCESS_VOLATILE, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(spirv_test, opcopymemory_volatile_both)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
OpCapability Shader
|
||||||
|
%1 = OpExtInstImport "GLSL.std.450"
|
||||||
|
OpMemoryModel Logical GLSL450
|
||||||
|
OpEntryPoint GLCompute %4 "main"
|
||||||
|
OpExecutionMode %4 LocalSize 1 1 1
|
||||||
|
OpMemberDecorate %_struct_7 0 Offset 0
|
||||||
|
OpDecorate %_struct_7 BufferBlock
|
||||||
|
OpDecorate %9 DescriptorSet 0
|
||||||
|
OpDecorate %9 Binding 0
|
||||||
|
%void = OpTypeVoid
|
||||||
|
%3 = OpTypeFunction %void
|
||||||
|
%uint = OpTypeInt 32 0
|
||||||
|
%_struct_7 = OpTypeStruct %uint
|
||||||
|
%_ptr_Uniform__struct_7 = OpTypePointer Uniform %_struct_7
|
||||||
|
%9 = OpVariable %_ptr_Uniform__struct_7 Uniform
|
||||||
|
%int = OpTypeInt 32 1
|
||||||
|
%int_0 = OpConstant %int 0
|
||||||
|
%_ptr_Uniform_uint = OpTypePointer Uniform %uint
|
||||||
|
%4 = OpFunction %void None %3
|
||||||
|
%5 = OpLabel
|
||||||
|
%13 = OpAccessChain %_ptr_Uniform_uint %9 %int_0
|
||||||
|
OpCopyMemory %13 %13 Volatile
|
||||||
|
OpReturn
|
||||||
|
OpFunctionEnd
|
||||||
|
*/
|
||||||
|
static const uint32_t words[] = {
|
||||||
|
0x07230203, 0x00010300, 0x00070000, 0x0000000e, 0x00000000, 0x00020011,
|
||||||
|
0x00000001, 0x0006000b, 0x00000001, 0x4c534c47, 0x6474732e, 0x3035342e,
|
||||||
|
0x00000000, 0x0003000e, 0x00000000, 0x00000001, 0x0005000f, 0x00000005,
|
||||||
|
0x00000002, 0x6e69616d, 0x00000000, 0x00060010, 0x00000002, 0x00000011,
|
||||||
|
0x00000001, 0x00000001, 0x00000001, 0x00050048, 0x00000003, 0x00000000,
|
||||||
|
0x00000023, 0x00000000, 0x00030047, 0x00000003, 0x00000003, 0x00040047,
|
||||||
|
0x00000004, 0x00000022, 0x00000000, 0x00040047, 0x00000004, 0x00000021,
|
||||||
|
0x00000000, 0x00020013, 0x00000005, 0x00030021, 0x00000006, 0x00000005,
|
||||||
|
0x00040015, 0x00000007, 0x00000020, 0x00000000, 0x0003001e, 0x00000003,
|
||||||
|
0x00000007, 0x00040020, 0x00000008, 0x00000002, 0x00000003, 0x0004003b,
|
||||||
|
0x00000008, 0x00000004, 0x00000002, 0x00040015, 0x00000009, 0x00000020,
|
||||||
|
0x00000001, 0x0004002b, 0x00000009, 0x0000000a, 0x00000000, 0x00040020,
|
||||||
|
0x0000000b, 0x00000002, 0x00000007, 0x00050036, 0x00000005, 0x00000002,
|
||||||
|
0x00000000, 0x00000006, 0x000200f8, 0x0000000c, 0x00050041, 0x0000000b,
|
||||||
|
0x0000000d, 0x00000004, 0x0000000a, 0x0004003f, 0x0000000d, 0x0000000d,
|
||||||
|
0x00000001, 0x000100fd, 0x00010038,
|
||||||
|
};
|
||||||
|
|
||||||
|
get_nir(sizeof(words) / sizeof(words[0]), words);
|
||||||
|
|
||||||
|
nir_intrinsic_instr *intrinsic = find_intrinsic(nir_intrinsic_load_deref);
|
||||||
|
ASSERT_NE(intrinsic, nullptr);
|
||||||
|
EXPECT_NE(nir_intrinsic_access(intrinsic) & ACCESS_VOLATILE, 0);
|
||||||
|
|
||||||
|
intrinsic = find_intrinsic(nir_intrinsic_store_deref);
|
||||||
|
ASSERT_NE(intrinsic, nullptr);
|
||||||
|
EXPECT_NE(nir_intrinsic_access(intrinsic) & ACCESS_VOLATILE, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(spirv_test, opcopymemory_volatile_target)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
OpCapability Shader
|
||||||
|
%1 = OpExtInstImport "GLSL.std.450"
|
||||||
|
OpMemoryModel Logical GLSL450
|
||||||
|
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
|
||||||
|
%4 = OpFunction %void None %3
|
||||||
|
%5 = OpLabel
|
||||||
|
%13 = OpAccessChain %_ptr_StorageBuffer_uint %9 %int_0
|
||||||
|
OpCopyMemory %13 %13 Volatile None
|
||||||
|
OpReturn
|
||||||
|
OpFunctionEnd
|
||||||
|
*/
|
||||||
|
static const uint32_t words[] = {
|
||||||
|
0x07230203, 0x00010500, 0x00070000, 0x0000000e, 0x00000000, 0x00020011,
|
||||||
|
0x00000001, 0x0006000b, 0x00000001, 0x4c534c47, 0x6474732e, 0x3035342e,
|
||||||
|
0x00000000, 0x0003000e, 0x00000000, 0x00000001, 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, 0x00050036, 0x00000005,
|
||||||
|
0x00000002, 0x00000000, 0x00000006, 0x000200f8, 0x0000000c, 0x00050041,
|
||||||
|
0x0000000b, 0x0000000d, 0x00000003, 0x0000000a, 0x0005003f, 0x0000000d,
|
||||||
|
0x0000000d, 0x00000001, 0x00000000, 0x000100fd, 0x00010038,
|
||||||
|
};
|
||||||
|
|
||||||
|
get_nir(sizeof(words) / sizeof(words[0]), words);
|
||||||
|
|
||||||
|
nir_intrinsic_instr *intrinsic = find_intrinsic(nir_intrinsic_load_deref);
|
||||||
|
ASSERT_NE(intrinsic, nullptr);
|
||||||
|
EXPECT_EQ(nir_intrinsic_access(intrinsic) & ACCESS_VOLATILE, 0);
|
||||||
|
|
||||||
|
intrinsic = find_intrinsic(nir_intrinsic_store_deref);
|
||||||
|
ASSERT_NE(intrinsic, nullptr);
|
||||||
|
EXPECT_NE(nir_intrinsic_access(intrinsic) & ACCESS_VOLATILE, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(spirv_test, opcopymemory_volatile_source)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
OpCapability Shader
|
||||||
|
%1 = OpExtInstImport "GLSL.std.450"
|
||||||
|
OpMemoryModel Logical GLSL450
|
||||||
|
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
|
||||||
|
%4 = OpFunction %void None %3
|
||||||
|
%5 = OpLabel
|
||||||
|
%13 = OpAccessChain %_ptr_StorageBuffer_uint %9 %int_0
|
||||||
|
OpCopyMemory %13 %13 None Volatile
|
||||||
|
OpReturn
|
||||||
|
OpFunctionEnd
|
||||||
|
*/
|
||||||
|
static const uint32_t words[] = {
|
||||||
|
0x07230203, 0x00010500, 0x00070000, 0x0000000e, 0x00000000, 0x00020011,
|
||||||
|
0x00000001, 0x0006000b, 0x00000001, 0x4c534c47, 0x6474732e, 0x3035342e,
|
||||||
|
0x00000000, 0x0003000e, 0x00000000, 0x00000001, 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, 0x00050036, 0x00000005,
|
||||||
|
0x00000002, 0x00000000, 0x00000006, 0x000200f8, 0x0000000c, 0x00050041,
|
||||||
|
0x0000000b, 0x0000000d, 0x00000003, 0x0000000a, 0x0005003f, 0x0000000d,
|
||||||
|
0x0000000d, 0x00000000, 0x00000001, 0x000100fd, 0x00010038,
|
||||||
|
};
|
||||||
|
|
||||||
|
get_nir(sizeof(words) / sizeof(words[0]), words);
|
||||||
|
|
||||||
|
nir_intrinsic_instr *intrinsic = find_intrinsic(nir_intrinsic_load_deref);
|
||||||
|
ASSERT_NE(intrinsic, nullptr);
|
||||||
|
EXPECT_NE(nir_intrinsic_access(intrinsic) & ACCESS_VOLATILE, 0);
|
||||||
|
|
||||||
|
intrinsic = find_intrinsic(nir_intrinsic_store_deref);
|
||||||
|
ASSERT_NE(intrinsic, nullptr);
|
||||||
|
EXPECT_EQ(nir_intrinsic_access(intrinsic) & ACCESS_VOLATILE, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(spirv_test, opimageread_volatile)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
OpCapability Shader
|
||||||
|
OpCapability VulkanMemoryModel
|
||||||
|
%1 = OpExtInstImport "GLSL.std.450"
|
||||||
|
OpMemoryModel Logical Vulkan
|
||||||
|
OpEntryPoint GLCompute %4 "main" %9
|
||||||
|
OpExecutionMode %4 LocalSize 1 1 1
|
||||||
|
OpDecorate %9 DescriptorSet 0
|
||||||
|
OpDecorate %9 Binding 1
|
||||||
|
%void = OpTypeVoid
|
||||||
|
%3 = OpTypeFunction %void
|
||||||
|
%uint = OpTypeInt 32 0
|
||||||
|
%7 = OpTypeImage %uint 2D 0 0 0 2 R32ui
|
||||||
|
%_ptr_UniformConstant_7 = OpTypePointer UniformConstant %7
|
||||||
|
%9 = OpVariable %_ptr_UniformConstant_7 UniformConstant
|
||||||
|
%int = OpTypeInt 32 1
|
||||||
|
%v2int = OpTypeVector %int 2
|
||||||
|
%int_0 = OpConstant %int 0
|
||||||
|
%14 = OpConstantComposite %v2int %int_0 %int_0
|
||||||
|
%v4uint = OpTypeVector %uint 4
|
||||||
|
%v3uint = OpTypeVector %uint 3
|
||||||
|
%uint_1 = OpConstant %uint 1
|
||||||
|
%4 = OpFunction %void None %3
|
||||||
|
%5 = OpLabel
|
||||||
|
%10 = OpLoad %7 %9
|
||||||
|
%15 = OpLoad %7 %9
|
||||||
|
%17 = OpImageRead %v4uint %15 %14 VolatileTexel
|
||||||
|
OpImageWrite %10 %14 %17
|
||||||
|
OpReturn
|
||||||
|
OpFunctionEnd
|
||||||
|
*/
|
||||||
|
static const uint32_t words[] = {
|
||||||
|
0x07230203, 0x00010500, 0x00070000, 0x00000014, 0x00000000, 0x00020011,
|
||||||
|
0x00000001, 0x00020011, 0x000014e1, 0x0006000b, 0x00000001, 0x4c534c47,
|
||||||
|
0x6474732e, 0x3035342e, 0x00000000, 0x0003000e, 0x00000000, 0x00000003,
|
||||||
|
0x0006000f, 0x00000005, 0x00000002, 0x6e69616d, 0x00000000, 0x00000003,
|
||||||
|
0x00060010, 0x00000002, 0x00000011, 0x00000001, 0x00000001, 0x00000001,
|
||||||
|
0x00040047, 0x00000003, 0x00000022, 0x00000000, 0x00040047, 0x00000003,
|
||||||
|
0x00000021, 0x00000001, 0x00020013, 0x00000004, 0x00030021, 0x00000005,
|
||||||
|
0x00000004, 0x00040015, 0x00000006, 0x00000020, 0x00000000, 0x00090019,
|
||||||
|
0x00000007, 0x00000006, 0x00000001, 0x00000000, 0x00000000, 0x00000000,
|
||||||
|
0x00000002, 0x00000021, 0x00040020, 0x00000008, 0x00000000, 0x00000007,
|
||||||
|
0x0004003b, 0x00000008, 0x00000003, 0x00000000, 0x00040015, 0x00000009,
|
||||||
|
0x00000020, 0x00000001, 0x00040017, 0x0000000a, 0x00000009, 0x00000002,
|
||||||
|
0x0004002b, 0x00000009, 0x0000000b, 0x00000000, 0x0005002c, 0x0000000a,
|
||||||
|
0x0000000c, 0x0000000b, 0x0000000b, 0x00040017, 0x0000000d, 0x00000006,
|
||||||
|
0x00000004, 0x00040017, 0x0000000e, 0x00000006, 0x00000003, 0x0004002b,
|
||||||
|
0x00000006, 0x0000000f, 0x00000001, 0x00050036, 0x00000004, 0x00000002,
|
||||||
|
0x00000000, 0x00000005, 0x000200f8, 0x00000010, 0x0004003d, 0x00000007,
|
||||||
|
0x00000011, 0x00000003, 0x0004003d, 0x00000007, 0x00000012, 0x00000003,
|
||||||
|
0x00060062, 0x0000000d, 0x00000013, 0x00000012, 0x0000000c, 0x00000800,
|
||||||
|
0x00040063, 0x00000011, 0x0000000c, 0x00000013, 0x000100fd, 0x00010038,
|
||||||
|
};
|
||||||
|
|
||||||
|
get_nir(sizeof(words) / sizeof(words[0]), words);
|
||||||
|
|
||||||
|
nir_intrinsic_instr *intrinsic = find_intrinsic(nir_intrinsic_image_deref_load, 0);
|
||||||
|
ASSERT_NE(intrinsic, nullptr);
|
||||||
|
EXPECT_NE(nir_intrinsic_access(intrinsic) & ACCESS_VOLATILE, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(spirv_test, opimagewrite_volatile)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
OpCapability Shader
|
||||||
|
OpCapability VulkanMemoryModel
|
||||||
|
%1 = OpExtInstImport "GLSL.std.450"
|
||||||
|
OpMemoryModel Logical Vulkan
|
||||||
|
OpEntryPoint GLCompute %4 "main" %9
|
||||||
|
OpExecutionMode %4 LocalSize 1 1 1
|
||||||
|
OpDecorate %9 DescriptorSet 0
|
||||||
|
OpDecorate %9 Binding 1
|
||||||
|
%void = OpTypeVoid
|
||||||
|
%3 = OpTypeFunction %void
|
||||||
|
%uint = OpTypeInt 32 0
|
||||||
|
%7 = OpTypeImage %uint 2D 0 0 0 2 R32ui
|
||||||
|
%_ptr_UniformConstant_7 = OpTypePointer UniformConstant %7
|
||||||
|
%9 = OpVariable %_ptr_UniformConstant_7 UniformConstant
|
||||||
|
%int = OpTypeInt 32 1
|
||||||
|
%v2int = OpTypeVector %int 2
|
||||||
|
%int_0 = OpConstant %int 0
|
||||||
|
%14 = OpConstantComposite %v2int %int_0 %int_0
|
||||||
|
%v4uint = OpTypeVector %uint 4
|
||||||
|
%v3uint = OpTypeVector %uint 3
|
||||||
|
%uint_1 = OpConstant %uint 1
|
||||||
|
%4 = OpFunction %void None %3
|
||||||
|
%5 = OpLabel
|
||||||
|
%10 = OpLoad %7 %9
|
||||||
|
%15 = OpLoad %7 %9
|
||||||
|
%17 = OpImageRead %v4uint %15 %14
|
||||||
|
OpImageWrite %10 %14 %17 VolatileTexel
|
||||||
|
OpReturn
|
||||||
|
OpFunctionEnd
|
||||||
|
*/
|
||||||
|
static const uint32_t words[] = {
|
||||||
|
0x07230203, 0x00010500, 0x00070000, 0x00000014, 0x00000000, 0x00020011,
|
||||||
|
0x00000001, 0x00020011, 0x000014e1, 0x0006000b, 0x00000001, 0x4c534c47,
|
||||||
|
0x6474732e, 0x3035342e, 0x00000000, 0x0003000e, 0x00000000, 0x00000003,
|
||||||
|
0x0006000f, 0x00000005, 0x00000002, 0x6e69616d, 0x00000000, 0x00000003,
|
||||||
|
0x00060010, 0x00000002, 0x00000011, 0x00000001, 0x00000001, 0x00000001,
|
||||||
|
0x00040047, 0x00000003, 0x00000022, 0x00000000, 0x00040047, 0x00000003,
|
||||||
|
0x00000021, 0x00000001, 0x00020013, 0x00000004, 0x00030021, 0x00000005,
|
||||||
|
0x00000004, 0x00040015, 0x00000006, 0x00000020, 0x00000000, 0x00090019,
|
||||||
|
0x00000007, 0x00000006, 0x00000001, 0x00000000, 0x00000000, 0x00000000,
|
||||||
|
0x00000002, 0x00000021, 0x00040020, 0x00000008, 0x00000000, 0x00000007,
|
||||||
|
0x0004003b, 0x00000008, 0x00000003, 0x00000000, 0x00040015, 0x00000009,
|
||||||
|
0x00000020, 0x00000001, 0x00040017, 0x0000000a, 0x00000009, 0x00000002,
|
||||||
|
0x0004002b, 0x00000009, 0x0000000b, 0x00000000, 0x0005002c, 0x0000000a,
|
||||||
|
0x0000000c, 0x0000000b, 0x0000000b, 0x00040017, 0x0000000d, 0x00000006,
|
||||||
|
0x00000004, 0x00040017, 0x0000000e, 0x00000006, 0x00000003, 0x0004002b,
|
||||||
|
0x00000006, 0x0000000f, 0x00000001, 0x00050036, 0x00000004, 0x00000002,
|
||||||
|
0x00000000, 0x00000005, 0x000200f8, 0x00000010, 0x0004003d, 0x00000007,
|
||||||
|
0x00000011, 0x00000003, 0x0004003d, 0x00000007, 0x00000012, 0x00000003,
|
||||||
|
0x00050062, 0x0000000d, 0x00000013, 0x00000012, 0x0000000c, 0x00050063,
|
||||||
|
0x00000011, 0x0000000c, 0x00000013, 0x00000800, 0x000100fd, 0x00010038,
|
||||||
|
};
|
||||||
|
|
||||||
|
get_nir(sizeof(words) / sizeof(words[0]), words);
|
||||||
|
|
||||||
|
nir_intrinsic_instr *intrinsic = find_intrinsic(nir_intrinsic_image_deref_store, 0);
|
||||||
|
ASSERT_NE(intrinsic, nullptr);
|
||||||
|
EXPECT_NE(nir_intrinsic_access(intrinsic) & ACCESS_VOLATILE, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(spirv_test, opatomicload_image_volatile)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
OpCapability Shader
|
||||||
|
OpCapability VulkanMemoryModel
|
||||||
|
OpCapability VulkanMemoryModelDeviceScope
|
||||||
|
%1 = OpExtInstImport "GLSL.std.450"
|
||||||
|
OpMemoryModel Logical Vulkan
|
||||||
|
OpEntryPoint GLCompute %2 "main" %3
|
||||||
|
OpExecutionMode %2 LocalSize 1 1 1
|
||||||
|
OpDecorate %3 DescriptorSet 0
|
||||||
|
OpDecorate %3 Binding 1
|
||||||
|
%void = OpTypeVoid
|
||||||
|
%7 = OpTypeFunction %void
|
||||||
|
%uint = OpTypeInt 32 0
|
||||||
|
%10 = OpTypeImage %uint 2D 0 0 0 2 R32ui
|
||||||
|
%_ptr_UniformConstant_10 = OpTypePointer UniformConstant %10
|
||||||
|
%3 = OpVariable %_ptr_UniformConstant_10 UniformConstant
|
||||||
|
%int = OpTypeInt 32 1
|
||||||
|
%v2int = OpTypeVector %int 2
|
||||||
|
%int_0 = OpConstant %int 0
|
||||||
|
%15 = OpConstantComposite %v2int %int_0 %int_0
|
||||||
|
%int_1 = OpConstant %int 1
|
||||||
|
%uint_0 = OpConstant %uint 0
|
||||||
|
%_ptr_Image_uint = OpTypePointer Image %uint
|
||||||
|
%uint_1 = OpConstant %uint 1
|
||||||
|
%uint_2048 = OpConstant %uint 2048
|
||||||
|
%uint_34816 = OpConstant %uint 34816
|
||||||
|
%v3uint = OpTypeVector %uint 3
|
||||||
|
%2 = OpFunction %void None %7
|
||||||
|
%29 = OpLabel
|
||||||
|
%30 = OpImageTexelPointer %_ptr_Image_uint %3 %15 %uint_0
|
||||||
|
%31 = OpAtomicLoad %uint %30 %int_1 %uint_34816
|
||||||
|
OpAtomicStore %30 %int_1 %uint_2048 %31
|
||||||
|
OpReturn
|
||||||
|
OpFunctionEnd
|
||||||
|
*/
|
||||||
|
static const uint32_t words[] = {
|
||||||
|
0x07230203, 0x00010500, 0x00070000, 0x00000017, 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, 0x00040047, 0x00000003, 0x00000022, 0x00000000,
|
||||||
|
0x00040047, 0x00000003, 0x00000021, 0x00000001, 0x00020013, 0x00000004,
|
||||||
|
0x00030021, 0x00000005, 0x00000004, 0x00040015, 0x00000006, 0x00000020,
|
||||||
|
0x00000000, 0x00090019, 0x00000007, 0x00000006, 0x00000001, 0x00000000,
|
||||||
|
0x00000000, 0x00000000, 0x00000002, 0x00000021, 0x00040020, 0x00000008,
|
||||||
|
0x00000000, 0x00000007, 0x0004003b, 0x00000008, 0x00000003, 0x00000000,
|
||||||
|
0x00040015, 0x00000009, 0x00000020, 0x00000001, 0x00040017, 0x0000000a,
|
||||||
|
0x00000009, 0x00000002, 0x0004002b, 0x00000009, 0x0000000b, 0x00000000,
|
||||||
|
0x0005002c, 0x0000000a, 0x0000000c, 0x0000000b, 0x0000000b, 0x0004002b,
|
||||||
|
0x00000009, 0x0000000d, 0x00000001, 0x0004002b, 0x00000006, 0x0000000e,
|
||||||
|
0x00000000, 0x00040020, 0x0000000f, 0x0000000b, 0x00000006, 0x0004002b,
|
||||||
|
0x00000006, 0x00000010, 0x00000001, 0x0004002b, 0x00000006, 0x00000011,
|
||||||
|
0x00000800, 0x0004002b, 0x00000006, 0x00000012, 0x00008800, 0x00040017,
|
||||||
|
0x00000013, 0x00000006, 0x00000003, 0x00050036, 0x00000004, 0x00000002,
|
||||||
|
0x00000000, 0x00000005, 0x000200f8, 0x00000014, 0x0006003c, 0x0000000f,
|
||||||
|
0x00000015, 0x00000003, 0x0000000c, 0x0000000e, 0x000600e3, 0x00000006,
|
||||||
|
0x00000016, 0x00000015, 0x0000000d, 0x00000012, 0x000500e4, 0x00000015,
|
||||||
|
0x0000000d, 0x00000011, 0x00000016, 0x000100fd, 0x00010038,
|
||||||
|
};
|
||||||
|
|
||||||
|
get_nir(sizeof(words) / sizeof(words[0]), words);
|
||||||
|
|
||||||
|
nir_intrinsic_instr *intrinsic = find_intrinsic(nir_intrinsic_image_deref_load, 0);
|
||||||
|
ASSERT_NE(intrinsic, nullptr);
|
||||||
|
EXPECT_NE(nir_intrinsic_access(intrinsic) & ACCESS_VOLATILE, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(spirv_test, opatomicstore_image_volatile)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
OpCapability Shader
|
||||||
|
OpCapability VulkanMemoryModel
|
||||||
|
OpCapability VulkanMemoryModelDeviceScope
|
||||||
|
%1 = OpExtInstImport "GLSL.std.450"
|
||||||
|
OpMemoryModel Logical Vulkan
|
||||||
|
OpEntryPoint GLCompute %2 "main" %3
|
||||||
|
OpExecutionMode %2 LocalSize 1 1 1
|
||||||
|
OpDecorate %3 DescriptorSet 0
|
||||||
|
OpDecorate %3 Binding 1
|
||||||
|
%void = OpTypeVoid
|
||||||
|
%7 = OpTypeFunction %void
|
||||||
|
%uint = OpTypeInt 32 0
|
||||||
|
%10 = OpTypeImage %uint 2D 0 0 0 2 R32ui
|
||||||
|
%_ptr_UniformConstant_10 = OpTypePointer UniformConstant %10
|
||||||
|
%3 = OpVariable %_ptr_UniformConstant_10 UniformConstant
|
||||||
|
%int = OpTypeInt 32 1
|
||||||
|
%v2int = OpTypeVector %int 2
|
||||||
|
%int_0 = OpConstant %int 0
|
||||||
|
%15 = OpConstantComposite %v2int %int_0 %int_0
|
||||||
|
%int_1 = OpConstant %int 1
|
||||||
|
%uint_0 = OpConstant %uint 0
|
||||||
|
%_ptr_Image_uint = OpTypePointer Image %uint
|
||||||
|
%uint_1 = OpConstant %uint 1
|
||||||
|
%uint_2048 = OpConstant %uint 2048
|
||||||
|
%uint_34816 = OpConstant %uint 34816
|
||||||
|
%v3uint = OpTypeVector %uint 3
|
||||||
|
%2 = OpFunction %void None %7
|
||||||
|
%29 = OpLabel
|
||||||
|
%30 = OpImageTexelPointer %_ptr_Image_uint %3 %15 %uint_0
|
||||||
|
%31 = OpAtomicLoad %uint %30 %int_1 %uint_2048
|
||||||
|
OpAtomicStore %30 %int_1 %uint_34816 %31
|
||||||
|
OpReturn
|
||||||
|
OpFunctionEnd
|
||||||
|
*/
|
||||||
|
static const uint32_t words[] = {
|
||||||
|
0x07230203, 0x00010500, 0x00070000, 0x00000017, 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, 0x00040047, 0x00000003, 0x00000022, 0x00000000,
|
||||||
|
0x00040047, 0x00000003, 0x00000021, 0x00000001, 0x00020013, 0x00000004,
|
||||||
|
0x00030021, 0x00000005, 0x00000004, 0x00040015, 0x00000006, 0x00000020,
|
||||||
|
0x00000000, 0x00090019, 0x00000007, 0x00000006, 0x00000001, 0x00000000,
|
||||||
|
0x00000000, 0x00000000, 0x00000002, 0x00000021, 0x00040020, 0x00000008,
|
||||||
|
0x00000000, 0x00000007, 0x0004003b, 0x00000008, 0x00000003, 0x00000000,
|
||||||
|
0x00040015, 0x00000009, 0x00000020, 0x00000001, 0x00040017, 0x0000000a,
|
||||||
|
0x00000009, 0x00000002, 0x0004002b, 0x00000009, 0x0000000b, 0x00000000,
|
||||||
|
0x0005002c, 0x0000000a, 0x0000000c, 0x0000000b, 0x0000000b, 0x0004002b,
|
||||||
|
0x00000009, 0x0000000d, 0x00000001, 0x0004002b, 0x00000006, 0x0000000e,
|
||||||
|
0x00000000, 0x00040020, 0x0000000f, 0x0000000b, 0x00000006, 0x0004002b,
|
||||||
|
0x00000006, 0x00000010, 0x00000001, 0x0004002b, 0x00000006, 0x00000011,
|
||||||
|
0x00000800, 0x0004002b, 0x00000006, 0x00000012, 0x00008800, 0x00040017,
|
||||||
|
0x00000013, 0x00000006, 0x00000003, 0x00050036, 0x00000004, 0x00000002,
|
||||||
|
0x00000000, 0x00000005, 0x000200f8, 0x00000014, 0x0006003c, 0x0000000f,
|
||||||
|
0x00000015, 0x00000003, 0x0000000c, 0x0000000e, 0x000600e3, 0x00000006,
|
||||||
|
0x00000016, 0x00000015, 0x0000000d, 0x00000011, 0x000500e4, 0x00000015,
|
||||||
|
0x0000000d, 0x00000012, 0x00000016, 0x000100fd, 0x00010038,
|
||||||
|
};
|
||||||
|
|
||||||
|
get_nir(sizeof(words) / sizeof(words[0]), words);
|
||||||
|
|
||||||
|
nir_intrinsic_instr *intrinsic = find_intrinsic(nir_intrinsic_image_deref_store, 0);
|
||||||
|
ASSERT_NE(intrinsic, nullptr);
|
||||||
|
EXPECT_NE(nir_intrinsic_access(intrinsic) & ACCESS_VOLATILE, 0);
|
||||||
|
}
|
Reference in New Issue
Block a user