Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/KhronosGroup/SPIRV-Tools.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorSpencer Fricke <spencerfricke@gmail.com>2022-09-07 22:12:07 +0300
committerGitHub <noreply@github.com>2022-09-07 22:12:07 +0300
commit59cf5b1346d8b029add67a919f801c29ea13cc49 (patch)
tree03807ae8681cea25f56a84f98763962bb24a4bd8 /test
parent934a0597874e93b2440e196cf5b45a830513c2db (diff)
spirv-val: consider OpEmitMeshTasksEXT a terminator instruction (#4923)
Diffstat (limited to 'test')
-rw-r--r--test/val/CMakeLists.txt1
-rw-r--r--test/val/val_mesh_shading_test.cpp95
2 files changed, 96 insertions, 0 deletions
diff --git a/test/val/CMakeLists.txt b/test/val/CMakeLists.txt
index e73e0f4af..8d00560bc 100644
--- a/test/val/CMakeLists.txt
+++ b/test/val/CMakeLists.txt
@@ -77,6 +77,7 @@ add_spvtools_unittest(TARGET val_fghijklmnop
val_literals_test.cpp
val_logicals_test.cpp
val_memory_test.cpp
+ val_mesh_shading_test.cpp
val_misc_test.cpp
val_modes_test.cpp
val_non_semantic_test.cpp
diff --git a/test/val/val_mesh_shading_test.cpp b/test/val/val_mesh_shading_test.cpp
new file mode 100644
index 000000000..d10f40d87
--- /dev/null
+++ b/test/val/val_mesh_shading_test.cpp
@@ -0,0 +1,95 @@
+// Copyright (c) 2022 The Khronos Group Inc.
+//
+// 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.
+
+// Tests instructions from SPV_EXT_mesh_shader
+
+#include <sstream>
+#include <string>
+
+#include "gmock/gmock.h"
+#include "test/val/val_fixtures.h"
+
+namespace spvtools {
+namespace val {
+namespace {
+
+using ::testing::HasSubstr;
+using ::testing::Values;
+
+using ValidateMeshShading = spvtest::ValidateBase<bool>;
+
+TEST_F(ValidateMeshShading, EmitMeshTasksEXTNotLastInstructionUniversal) {
+ const std::string body = R"(
+ OpCapability MeshShadingEXT
+ OpExtension "SPV_EXT_mesh_shader"
+ OpMemoryModel Logical GLSL450
+ OpEntryPoint TaskEXT %main "main" %p
+ OpExecutionModeId %main LocalSizeId %uint_1 %uint_1 %uint_1
+ %void = OpTypeVoid
+ %func = OpTypeFunction %void
+ %uint = OpTypeInt 32 0
+ %uint_1 = OpConstant %uint 1
+ %float = OpTypeFloat 32
+ %arr_float = OpTypeArray %float %uint_1
+ %Payload = OpTypeStruct %arr_float
+%ptr_Payload = OpTypePointer TaskPayloadWorkgroupEXT %Payload
+ %p = OpVariable %ptr_Payload TaskPayloadWorkgroupEXT
+ %main = OpFunction %void None %func
+ %label1 = OpLabel
+ OpEmitMeshTasksEXT %uint_1 %uint_1 %uint_1 %p
+ OpBranch %label2
+ %label2 = OpLabel
+ OpReturn
+ OpFunctionEnd
+)";
+
+ CompileSuccessfully(body, SPV_ENV_UNIVERSAL_1_4);
+ EXPECT_EQ(SPV_ERROR_INVALID_LAYOUT,
+ ValidateInstructions(SPV_ENV_UNIVERSAL_1_4));
+ EXPECT_THAT(getDiagnosticString(),
+ HasSubstr("Branch must appear in a block"));
+}
+
+TEST_F(ValidateMeshShading, EmitMeshTasksEXTNotLastInstructionVulkan) {
+ const std::string body = R"(
+ OpCapability MeshShadingEXT
+ OpExtension "SPV_EXT_mesh_shader"
+ OpMemoryModel Logical GLSL450
+ OpEntryPoint TaskEXT %main "main" %p
+ OpExecutionModeId %main LocalSizeId %uint_1 %uint_1 %uint_1
+ %void = OpTypeVoid
+ %func = OpTypeFunction %void
+ %uint = OpTypeInt 32 0
+ %uint_1 = OpConstant %uint 1
+ %float = OpTypeFloat 32
+ %arr_float = OpTypeArray %float %uint_1
+ %Payload = OpTypeStruct %arr_float
+%ptr_Payload = OpTypePointer TaskPayloadWorkgroupEXT %Payload
+ %p = OpVariable %ptr_Payload TaskPayloadWorkgroupEXT
+ %main = OpFunction %void None %func
+ %label1 = OpLabel
+ OpEmitMeshTasksEXT %uint_1 %uint_1 %uint_1 %p
+ OpReturn
+ OpFunctionEnd
+)";
+
+ CompileSuccessfully(body, SPV_ENV_VULKAN_1_2);
+ EXPECT_EQ(SPV_ERROR_INVALID_LAYOUT, ValidateInstructions(SPV_ENV_VULKAN_1_2));
+ EXPECT_THAT(getDiagnosticString(),
+ HasSubstr("Return must appear in a block"));
+}
+
+} // namespace
+} // namespace val
+} // namespace spvtools