Test interaction between Workgroup explicit layout and zero initialization
authorCaio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Sat, 16 Jan 2021 07:31:56 +0000 (23:31 -0800)
committerAlexander Galazin <Alexander.Galazin@arm.com>
Fri, 2 Apr 2021 08:50:57 +0000 (08:50 +0000)
Test interaction between VK_KHR_workgroup_memory_explicit_layout and
VK_KHR_zero_initialize_workgroup_memory.  Tests use SPIR-V ASM since
there's no syntax in GLSL to initialize a block.

Component: Vulkan
VK-GL-CTS Issue: 2524
New Tests: dEQP-VK.compute.workgroup_memory_explicit_layout.zero_ext.*

Change-Id: I015ba350bd15472d06b3bee657ce67f283e8e1e7

android/cts/master/vk-master-2021-03-01.txt
android/cts/master/vk-master.txt
external/vulkancts/data/vulkan/amber/compute/workgroup_memory_explicit_layout/zero_ext_block.amber [new file with mode: 0644]
external/vulkancts/data/vulkan/amber/compute/workgroup_memory_explicit_layout/zero_ext_block_with_offset.amber [new file with mode: 0644]
external/vulkancts/data/vulkan/amber/compute/workgroup_memory_explicit_layout/zero_ext_other_block.amber [new file with mode: 0644]
external/vulkancts/modules/vulkan/compute/vktComputeWorkgroupMemoryExplicitLayoutTests.cpp
external/vulkancts/mustpass/master/vk-default.txt

index f122c89..5d260fa 100644 (file)
@@ -115967,6 +115967,9 @@ dEQP-VK.compute.workgroup_memory_explicit_layout.size.65536
 dEQP-VK.compute.workgroup_memory_explicit_layout.copy_memory.basic
 dEQP-VK.compute.workgroup_memory_explicit_layout.copy_memory.two_invocations
 dEQP-VK.compute.workgroup_memory_explicit_layout.copy_memory.variable_pointers
+dEQP-VK.compute.workgroup_memory_explicit_layout.zero_ext.block
+dEQP-VK.compute.workgroup_memory_explicit_layout.zero_ext.other_block
+dEQP-VK.compute.workgroup_memory_explicit_layout.zero_ext.block_with_offset
 dEQP-VK.image.swapchain_mutable.headless.2d.r8g8b8a8_unorm_r8g8b8a8_snorm_clear_copy_format_list
 dEQP-VK.image.swapchain_mutable.headless.2d.r8g8b8a8_unorm_r8g8b8a8_snorm_clear_load_format_list
 dEQP-VK.image.swapchain_mutable.headless.2d.r8g8b8a8_unorm_r8g8b8a8_snorm_clear_texture_format_list
index 6e14084..967172c 100644 (file)
@@ -530254,6 +530254,9 @@ dEQP-VK.compute.workgroup_memory_explicit_layout.size.65536
 dEQP-VK.compute.workgroup_memory_explicit_layout.copy_memory.basic
 dEQP-VK.compute.workgroup_memory_explicit_layout.copy_memory.two_invocations
 dEQP-VK.compute.workgroup_memory_explicit_layout.copy_memory.variable_pointers
+dEQP-VK.compute.workgroup_memory_explicit_layout.zero_ext.block
+dEQP-VK.compute.workgroup_memory_explicit_layout.zero_ext.other_block
+dEQP-VK.compute.workgroup_memory_explicit_layout.zero_ext.block_with_offset
 dEQP-VK.image.store.with_format.1d.r32g32b32a32_sfloat
 dEQP-VK.image.store.with_format.1d.r16g16b16a16_sfloat
 dEQP-VK.image.store.with_format.1d.r32_sfloat
diff --git a/external/vulkancts/data/vulkan/amber/compute/workgroup_memory_explicit_layout/zero_ext_block.amber b/external/vulkancts/data/vulkan/amber/compute/workgroup_memory_explicit_layout/zero_ext_block.amber
new file mode 100644 (file)
index 0000000..5ef39ed
--- /dev/null
@@ -0,0 +1,106 @@
+#!amber
+# Copyright 2021 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+DEVICE_EXTENSION VK_KHR_spirv_1_4
+DEVICE_EXTENSION VK_KHR_workgroup_memory_explicit_layout
+DEVICE_EXTENSION VK_KHR_zero_initialize_workgroup_memory
+
+SHADER compute compute_shader SPIRV-ASM
+
+OpCapability Shader
+OpCapability WorkgroupMemoryExplicitLayoutKHR
+OpExtension "SPV_KHR_workgroup_memory_explicit_layout"
+OpMemoryModel Logical GLSL450
+OpEntryPoint GLCompute %main "main" %index %push_constants %output_buffer %wg
+OpExecutionMode %main LocalSize 128 4 1
+
+OpDecorate %index BuiltIn LocalInvocationIndex
+OpDecorate %buffer_type Block
+OpMemberDecorate %buffer_type 0 Offset 0
+OpDecorate %array ArrayStride 4
+OpDecorate %output_buffer DescriptorSet 0
+OpDecorate %output_buffer Binding 1
+OpDecorate %wg Aliased
+OpMemberDecorate %push_constants_type 0 Offset 0
+OpDecorate %push_constants_type Block
+
+%uint = OpTypeInt 32 0
+%const_uint_0 = OpConstant %uint 0
+%const_uint_32 = OpConstant %uint 32
+%uint_input_ptr = OpTypePointer Input %uint
+%uint_pc_ptr = OpTypePointer PushConstant %uint
+
+%bool = OpTypeBool
+%void = OpTypeVoid
+%main_type = OpTypeFunction %void
+%array = OpTypeArray %uint %const_uint_32
+%buffer_type = OpTypeStruct %array
+%output_buffer_ptr = OpTypePointer StorageBuffer %buffer_type
+%wg_ptr = OpTypePointer Workgroup %buffer_type
+%push_constants_type = OpTypeStruct %uint
+%push_constants_type_ptr = OpTypePointer PushConstant %push_constants_type
+%null_buffer = OpConstantNull %buffer_type
+
+;;; Workgroup variable has a "null initializer".
+
+%wg = OpVariable %wg_ptr Workgroup %null_buffer
+%output_buffer = OpVariable %output_buffer_ptr StorageBuffer
+
+%index = OpVariable %uint_input_ptr Input
+%push_constants = OpVariable %push_constants_type_ptr PushConstant
+
+%main = OpFunction %void None %main_type
+%entry = OpLabel
+
+;;; Look up in the push constant to select which invocation will do
+;;; the work.
+
+%index_val = OpLoad %uint %index
+%worker_ptr = OpAccessChain %uint_pc_ptr %push_constants %const_uint_0
+%worker = OpLoad %uint %worker_ptr
+%is_worker = OpIEqual %bool %index_val %worker
+
+OpSelectionMerge %after_copy None
+OpBranchConditional %is_worker %copy %after_copy
+%copy = OpLabel
+
+OpCopyMemory %output_buffer %wg
+
+OpBranch %after_copy
+%after_copy = OpLabel
+
+OpReturn
+OpFunctionEnd
+
+END
+
+BUFFER output_buffer DATA_TYPE uint32 SIZE 32 FILL 99
+
+BUFFER expected_buffer DATA_TYPE uint32 SIZE 32 FILL 0
+
+BUFFER const_buf DATA_TYPE uint32 DATA
+30
+END
+
+PIPELINE compute pipeline
+  ATTACH compute_shader
+
+  BIND BUFFER const_buf AS push_constant
+  BIND BUFFER output_buffer AS storage DESCRIPTOR_SET 0 BINDING 1
+END
+
+RUN pipeline 1 1 1
+
+EXPECT output_buffer EQ_BUFFER expected_buffer
diff --git a/external/vulkancts/data/vulkan/amber/compute/workgroup_memory_explicit_layout/zero_ext_block_with_offset.amber b/external/vulkancts/data/vulkan/amber/compute/workgroup_memory_explicit_layout/zero_ext_block_with_offset.amber
new file mode 100644 (file)
index 0000000..61f15c0
--- /dev/null
@@ -0,0 +1,128 @@
+#!amber
+# Copyright 2021 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+DEVICE_EXTENSION VK_KHR_spirv_1_4
+DEVICE_EXTENSION VK_KHR_workgroup_memory_explicit_layout
+DEVICE_EXTENSION VK_KHR_zero_initialize_workgroup_memory
+
+SHADER compute compute_shader SPIRV-ASM
+
+OpCapability Shader
+OpCapability WorkgroupMemoryExplicitLayoutKHR
+OpExtension "SPV_KHR_workgroup_memory_explicit_layout"
+OpMemoryModel Logical GLSL450
+OpEntryPoint GLCompute %main "main" %index %push_constants %output_buffer %wg %offset_wg
+OpExecutionMode %main LocalSize 128 4 1
+
+OpDecorate %index BuiltIn LocalInvocationIndex
+OpDecorate %buffer_type Block
+OpDecorate %offset_buffer_type Block
+OpMemberDecorate %buffer_type 0 Offset 0
+OpMemberDecorate %offset_buffer_type 0 Offset 64
+OpDecorate %array ArrayStride 4
+OpDecorate %output_buffer DescriptorSet 0
+OpDecorate %output_buffer Binding 1
+OpDecorate %wg Aliased
+OpDecorate %offset_wg Aliased
+OpMemberDecorate %push_constants_type 0 Offset 0
+OpDecorate %push_constants_type Block
+
+%uint = OpTypeInt 32 0
+%const_uint_0 = OpConstant %uint 0
+%const_uint_32 = OpConstant %uint 32
+%uint_input_ptr = OpTypePointer Input %uint
+%uint_pc_ptr = OpTypePointer PushConstant %uint
+
+%bool = OpTypeBool
+%void = OpTypeVoid
+%main_type = OpTypeFunction %void
+%array = OpTypeArray %uint %const_uint_32
+%buffer_type = OpTypeStruct %array
+%offset_buffer_type = OpTypeStruct %array
+%output_buffer_ptr = OpTypePointer StorageBuffer %buffer_type
+%wg_ptr = OpTypePointer Workgroup %buffer_type
+%offset_wg_ptr = OpTypePointer Workgroup %offset_buffer_type
+%push_constants_type = OpTypeStruct %uint
+%push_constants_type_ptr = OpTypePointer PushConstant %push_constants_type
+%null_offset_buffer = OpConstantNull %offset_buffer_type
+
+;;; One variable has a "null initializer" and the other not.
+
+%wg = OpVariable %wg_ptr Workgroup
+%offset_wg = OpVariable %offset_wg_ptr Workgroup %null_offset_buffer
+%output_buffer = OpVariable %output_buffer_ptr StorageBuffer
+
+%index = OpVariable %uint_input_ptr Input
+%push_constants = OpVariable %push_constants_type_ptr PushConstant
+
+%main = OpFunction %void None %main_type
+%entry = OpLabel
+
+;;; Look up in the push constant to select which invocation will do
+;;; the work.
+
+%index_val = OpLoad %uint %index
+%worker_ptr = OpAccessChain %uint_pc_ptr %push_constants %const_uint_0
+%worker = OpLoad %uint %worker_ptr
+%is_worker = OpIEqual %bool %index_val %worker
+
+OpSelectionMerge %after_copy None
+OpBranchConditional %is_worker %copy %after_copy
+%copy = OpLabel
+
+;;; Copying variable to output.  Because the aliasing at least half of
+;;; it should be zero initialized.
+
+OpCopyMemory %output_buffer %wg
+
+OpBranch %after_copy
+%after_copy = OpLabel
+
+OpReturn
+OpFunctionEnd
+
+END
+
+BUFFER output_buffer DATA_TYPE uint32 SIZE 32 FILL 99
+
+BUFFER const_buf DATA_TYPE uint32 DATA
+30
+END
+
+PIPELINE compute pipeline
+  ATTACH compute_shader
+
+  BIND BUFFER const_buf AS push_constant
+  BIND BUFFER output_buffer AS storage DESCRIPTOR_SET 0 BINDING 1
+END
+
+RUN pipeline 1 1 1
+
+EXPECT output_buffer IDX 64 EQ 0
+EXPECT output_buffer IDX 68 EQ 0
+EXPECT output_buffer IDX 72 EQ 0
+EXPECT output_buffer IDX 76 EQ 0
+EXPECT output_buffer IDX 80 EQ 0
+EXPECT output_buffer IDX 84 EQ 0
+EXPECT output_buffer IDX 88 EQ 0
+EXPECT output_buffer IDX 92 EQ 0
+EXPECT output_buffer IDX 96 EQ 0
+EXPECT output_buffer IDX 100 EQ 0
+EXPECT output_buffer IDX 104 EQ 0
+EXPECT output_buffer IDX 108 EQ 0
+EXPECT output_buffer IDX 112 EQ 0
+EXPECT output_buffer IDX 116 EQ 0
+EXPECT output_buffer IDX 120 EQ 0
+EXPECT output_buffer IDX 124 EQ 0
diff --git a/external/vulkancts/data/vulkan/amber/compute/workgroup_memory_explicit_layout/zero_ext_other_block.amber b/external/vulkancts/data/vulkan/amber/compute/workgroup_memory_explicit_layout/zero_ext_other_block.amber
new file mode 100644 (file)
index 0000000..e224183
--- /dev/null
@@ -0,0 +1,111 @@
+#!amber
+# Copyright 2021 Intel Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+DEVICE_EXTENSION VK_KHR_spirv_1_4
+DEVICE_EXTENSION VK_KHR_workgroup_memory_explicit_layout
+DEVICE_EXTENSION VK_KHR_zero_initialize_workgroup_memory
+
+SHADER compute compute_shader SPIRV-ASM
+
+OpCapability Shader
+OpCapability WorkgroupMemoryExplicitLayoutKHR
+OpExtension "SPV_KHR_workgroup_memory_explicit_layout"
+OpMemoryModel Logical GLSL450
+OpEntryPoint GLCompute %main "main" %index %push_constants %output_buffer %wg %other_wg
+OpExecutionMode %main LocalSize 128 4 1
+
+OpDecorate %index BuiltIn LocalInvocationIndex
+OpDecorate %buffer_type Block
+OpMemberDecorate %buffer_type 0 Offset 0
+OpDecorate %array ArrayStride 4
+OpDecorate %output_buffer DescriptorSet 0
+OpDecorate %output_buffer Binding 1
+OpDecorate %wg Aliased
+OpDecorate %other_wg Aliased
+OpMemberDecorate %push_constants_type 0 Offset 0
+OpDecorate %push_constants_type Block
+
+%uint = OpTypeInt 32 0
+%const_uint_0 = OpConstant %uint 0
+%const_uint_32 = OpConstant %uint 32
+%uint_input_ptr = OpTypePointer Input %uint
+%uint_pc_ptr = OpTypePointer PushConstant %uint
+
+%bool = OpTypeBool
+%void = OpTypeVoid
+%main_type = OpTypeFunction %void
+%array = OpTypeArray %uint %const_uint_32
+%buffer_type = OpTypeStruct %array
+%output_buffer_ptr = OpTypePointer StorageBuffer %buffer_type
+%wg_ptr = OpTypePointer Workgroup %buffer_type
+%push_constants_type = OpTypeStruct %uint
+%push_constants_type_ptr = OpTypePointer PushConstant %push_constants_type
+%null_buffer = OpConstantNull %buffer_type
+
+;;; One variable has a "null initializer" and the other not.
+
+%wg = OpVariable %wg_ptr Workgroup %null_buffer
+%other_wg = OpVariable %wg_ptr Workgroup
+%output_buffer = OpVariable %output_buffer_ptr StorageBuffer
+
+%index = OpVariable %uint_input_ptr Input
+%push_constants = OpVariable %push_constants_type_ptr PushConstant
+
+%main = OpFunction %void None %main_type
+%entry = OpLabel
+
+;;; Look up in the push constant to select which invocation will do
+;;; the work.
+
+%index_val = OpLoad %uint %index
+%worker_ptr = OpAccessChain %uint_pc_ptr %push_constants %const_uint_0
+%worker = OpLoad %uint %worker_ptr
+%is_worker = OpIEqual %bool %index_val %worker
+
+OpSelectionMerge %after_copy None
+OpBranchConditional %is_worker %copy %after_copy
+%copy = OpLabel
+
+;;; Copying the other variable to output.  Because the aliasing, it
+;;; should be zero initalized too.
+
+OpCopyMemory %output_buffer %other_wg
+
+OpBranch %after_copy
+%after_copy = OpLabel
+
+OpReturn
+OpFunctionEnd
+
+END
+
+BUFFER output_buffer DATA_TYPE uint32 SIZE 32 FILL 99
+
+BUFFER expected_buffer DATA_TYPE uint32 SIZE 32 FILL 0
+
+BUFFER const_buf DATA_TYPE uint32 DATA
+30
+END
+
+PIPELINE compute pipeline
+  ATTACH compute_shader
+
+  BIND BUFFER const_buf AS push_constant
+  BIND BUFFER output_buffer AS storage DESCRIPTOR_SET 0 BINDING 1
+END
+
+RUN pipeline 1 1 1
+
+EXPECT output_buffer EQ_BUFFER expected_buffer
index d670ffc..2e310a4 100644 (file)
@@ -1350,6 +1350,15 @@ void AddCopyMemoryTests(tcu::TestCaseGroup* group)
                                                                                { "VariablePointerFeatures.variablePointers" }));
 }
 
+void AddZeroInitializeExtensionTests(tcu::TestCaseGroup* group)
+{
+       tcu::TestContext& testCtx = group->getTestContext();
+
+       group->addChild(CreateAmberTestCase(testCtx, "block", "", "zero_ext_block.amber"));
+       group->addChild(CreateAmberTestCase(testCtx, "other_block", "", "zero_ext_other_block.amber"));
+       group->addChild(CreateAmberTestCase(testCtx, "block_with_offset", "", "zero_ext_block_with_offset.amber"));
+}
+
 } // anonymous
 
 tcu::TestCaseGroup* createWorkgroupMemoryExplicitLayoutTests(tcu::TestContext& testCtx)
@@ -1376,6 +1385,10 @@ tcu::TestCaseGroup* createWorkgroupMemoryExplicitLayoutTests(tcu::TestContext& t
        AddCopyMemoryTests(copy_memory);
        tests->addChild(copy_memory);
 
+       tcu::TestCaseGroup* zero_ext = new tcu::TestCaseGroup(testCtx, "zero_ext", "Test interaction with VK_KHR_zero_initialize_workgroup_memory");
+       AddZeroInitializeExtensionTests(zero_ext);
+       tests->addChild(zero_ext);
+
        return tests.release();
 }
 
index a863589..f3fb03a 100644 (file)
@@ -530290,6 +530290,9 @@ dEQP-VK.compute.workgroup_memory_explicit_layout.size.65536
 dEQP-VK.compute.workgroup_memory_explicit_layout.copy_memory.basic
 dEQP-VK.compute.workgroup_memory_explicit_layout.copy_memory.two_invocations
 dEQP-VK.compute.workgroup_memory_explicit_layout.copy_memory.variable_pointers
+dEQP-VK.compute.workgroup_memory_explicit_layout.zero_ext.block
+dEQP-VK.compute.workgroup_memory_explicit_layout.zero_ext.other_block
+dEQP-VK.compute.workgroup_memory_explicit_layout.zero_ext.block_with_offset
 dEQP-VK.image.store.with_format.1d.r32g32b32a32_sfloat
 dEQP-VK.image.store.with_format.1d.r16g16b16a16_sfloat
 dEQP-VK.image.store.with_format.1d.r32_sfloat