| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613 |
- // Copyright (c) 2023 Google 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.
- #include "spirv-tools/optimizer.hpp"
- #include "test/opt/pass_fixture.h"
- #include "test/opt/pass_utils.h"
- namespace spvtools {
- namespace opt {
- namespace {
- using InterlockInvocationPlacementTest = PassTest<::testing::Test>;
- TEST_F(InterlockInvocationPlacementTest, CheckUnchangedIfNotFragment) {
- const std::string kTest = R"(
- OpCapability Shader
- OpCapability FragmentShaderSampleInterlockEXT
- OpExtension "SPV_EXT_fragment_shader_interlock"
- OpMemoryModel Logical GLSL450
- OpEntryPoint Vertex %main "main"
- OpExecutionMode %main SampleInterlockOrderedEXT
- OpName %main "main"
- %void = OpTypeVoid
- %1 = OpTypeFunction %void
- %main = OpFunction %void None %1
- %2 = OpLabel
- OpBeginInvocationInterlockEXT
- OpBeginInvocationInterlockEXT
- OpEndInvocationInterlockEXT
- OpBeginInvocationInterlockEXT
- OpEndInvocationInterlockEXT
- OpReturn
- OpFunctionEnd
- )";
- SetTargetEnv(SPV_ENV_VULKAN_1_3);
- EXPECT_EQ(
- Pass::Status::SuccessWithoutChange,
- std::get<1>(SinglePassRunAndDisassemble<InvocationInterlockPlacementPass>(
- kTest, /* skip_nop= */ false, /* do_validation= */ false)));
- }
- TEST_F(InterlockInvocationPlacementTest, CheckUnchangedWithoutCapability) {
- const std::string kTest = R"(
- OpCapability Shader
- OpExtension "SPV_EXT_fragment_shader_interlock"
- OpMemoryModel Logical GLSL450
- OpEntryPoint Fragment %main "main"
- OpExecutionMode %main OriginUpperLeft
- OpExecutionMode %main SampleInterlockOrderedEXT
- OpName %main "main"
- %void = OpTypeVoid
- %1 = OpTypeFunction %void
- %main = OpFunction %void None %1
- %2 = OpLabel
- OpBeginInvocationInterlockEXT
- OpBeginInvocationInterlockEXT
- OpEndInvocationInterlockEXT
- OpBeginInvocationInterlockEXT
- OpEndInvocationInterlockEXT
- OpReturn
- OpFunctionEnd
- )";
- SetTargetEnv(SPV_ENV_VULKAN_1_3);
- EXPECT_EQ(
- Pass::Status::SuccessWithoutChange,
- std::get<1>(SinglePassRunAndDisassemble<InvocationInterlockPlacementPass>(
- kTest, /* skip_nop= */ false, /* do_validation= */ false)));
- }
- TEST_F(InterlockInvocationPlacementTest, CheckSingleBasicBlock) {
- // We're using OpNoLine as a generic standin for any other instruction, to
- // test that begin and end aren't moved.
- const std::string kTest = R"(
- OpCapability Shader
- OpCapability FragmentShaderSampleInterlockEXT
- OpExtension "SPV_EXT_fragment_shader_interlock"
- OpMemoryModel Logical GLSL450
- OpEntryPoint Fragment %main "main"
- OpExecutionMode %main OriginUpperLeft
- OpExecutionMode %main SampleInterlockOrderedEXT
- OpName %main "main"
- %void = OpTypeVoid
- %1 = OpTypeFunction %void
- %main = OpFunction %void None %1
- ; CHECK: OpLabel
- %2 = OpLabel
- ; CHECK-NEXT: OpNoLine
- OpNoLine
- ; CHECK-NEXT: OpBeginInvocationInterlockEXT
- OpBeginInvocationInterlockEXT
- OpBeginInvocationInterlockEXT
- OpEndInvocationInterlockEXT
- OpBeginInvocationInterlockEXT
- ; CHECK-NEXT: OpNoLine
- OpNoLine
- ; CHECK-NEXT: OpEndInvocationInterlockEXT
- OpEndInvocationInterlockEXT
- ; CHECK-NEXT: OpNoLine
- OpNoLine
- ; CHECK-NEXT: OpReturn
- OpReturn
- OpFunctionEnd
- )";
- SetTargetEnv(SPV_ENV_VULKAN_1_3);
- const auto result = SinglePassRunAndMatch<InvocationInterlockPlacementPass>(
- kTest, /* skip_nop= */ false);
- EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange);
- }
- TEST_F(InterlockInvocationPlacementTest, CheckFunctionCallExtractionBegin) {
- const std::string kTest = R"(
- OpCapability Shader
- OpCapability FragmentShaderSampleInterlockEXT
- OpExtension "SPV_EXT_fragment_shader_interlock"
- OpMemoryModel Logical GLSL450
- OpEntryPoint Fragment %main "main"
- OpExecutionMode %main OriginUpperLeft
- OpExecutionMode %main SampleInterlockOrderedEXT
- OpName %main "main"
- %void = OpTypeVoid
- %1 = OpTypeFunction %void
- %foo = OpFunction %void None %1
- ; CHECK: OpLabel
- ; CHECK-NOT: OpBeginInvocationInterlockEXT
- %2 = OpLabel
- OpBeginInvocationInterlockEXT
- OpBeginInvocationInterlockEXT
- OpReturn
- ; CHECK: OpFunctionEnd
- OpFunctionEnd
- %main = OpFunction %void None %1
- ; CHECK: OpLabel
- %3 = OpLabel
- ; CHECK-NEXT: OpBeginInvocationInterlockEXT
- ; CHECK-NEXT: OpFunctionCall
- %4 = OpFunctionCall %void %foo
- ; CHECK-NEXT: OpReturn
- OpReturn
- OpFunctionEnd
- )";
- SetTargetEnv(SPV_ENV_VULKAN_1_3);
- const auto result = SinglePassRunAndMatch<InvocationInterlockPlacementPass>(
- kTest, /* skip_nop= */ false);
- EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange);
- }
- TEST_F(InterlockInvocationPlacementTest, CheckFunctionCallExtractionEnd) {
- const std::string kTest = R"(
- OpCapability Shader
- OpCapability FragmentShaderSampleInterlockEXT
- OpExtension "SPV_EXT_fragment_shader_interlock"
- OpMemoryModel Logical GLSL450
- OpEntryPoint Fragment %main "main"
- OpExecutionMode %main OriginUpperLeft
- OpExecutionMode %main SampleInterlockOrderedEXT
- OpName %main "main"
- %void = OpTypeVoid
- %1 = OpTypeFunction %void
- %foo = OpFunction %void None %1
- ; CHECK: OpLabel
- ; CHECK-NOT: OpEndInvocationInterlockEXT
- %2 = OpLabel
- OpEndInvocationInterlockEXT
- OpEndInvocationInterlockEXT
- OpReturn
- ; CHECK: OpFunctionEnd
- OpFunctionEnd
- %main = OpFunction %void None %1
- ; CHECK: OpLabel
- %3 = OpLabel
- ; CHECK-NEXT: OpFunctionCall
- %4 = OpFunctionCall %void %foo
- ; CHECK-NEXT: OpEndInvocationInterlockEXT
- ; CHECK-NEXT: OpReturn
- OpReturn
- OpFunctionEnd
- )";
- SetTargetEnv(SPV_ENV_VULKAN_1_3);
- const auto result = SinglePassRunAndMatch<InvocationInterlockPlacementPass>(
- kTest, /* skip_nop= */ false);
- EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange);
- }
- TEST_F(InterlockInvocationPlacementTest,
- CheckFunctionCallExtractionRepeatedCall) {
- const std::string kTest = R"(
- OpCapability Shader
- OpCapability FragmentShaderSampleInterlockEXT
- OpExtension "SPV_EXT_fragment_shader_interlock"
- OpMemoryModel Logical GLSL450
- OpEntryPoint Fragment %main "main"
- OpExecutionMode %main OriginUpperLeft
- OpExecutionMode %main SampleInterlockOrderedEXT
- OpName %main "main"
- %void = OpTypeVoid
- %1 = OpTypeFunction %void
- %foo = OpFunction %void None %1
- ; CHECK: OpLabel
- ; CHECK-NOT: OpBeginInvocationInterlockEXT
- ; CHECK-NOT: OpEndInvocationInterlockEXT
- %2 = OpLabel
- OpBeginInvocationInterlockEXT
- OpEndInvocationInterlockEXT
- OpReturn
- ; CHECK: OpFunctionEnd
- OpFunctionEnd
- %main = OpFunction %void None %1
- ; CHECK: OpLabel
- %3 = OpLabel
- ; CHECK-NEXT: OpBeginInvocationInterlockEXT
- ; CHECK-NEXT: OpFunctionCall
- %4 = OpFunctionCall %void %foo
- ; CHECK-NEXT: OpFunctionCall
- %5 = OpFunctionCall %void %foo
- ; CHECK-NEXT: OpEndInvocationInterlockEXT
- ; CHECK-NEXT: OpReturn
- OpReturn
- OpFunctionEnd
- )";
- SetTargetEnv(SPV_ENV_VULKAN_1_3);
- const auto result = SinglePassRunAndMatch<InvocationInterlockPlacementPass>(
- kTest, /* skip_nop= */ false);
- EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange);
- }
- TEST_F(InterlockInvocationPlacementTest,
- CheckFunctionCallExtractionNestedCall) {
- const std::string kTest = R"(
- OpCapability Shader
- OpCapability FragmentShaderSampleInterlockEXT
- OpExtension "SPV_EXT_fragment_shader_interlock"
- OpMemoryModel Logical GLSL450
- OpEntryPoint Fragment %main "main"
- OpExecutionMode %main OriginUpperLeft
- OpExecutionMode %main SampleInterlockOrderedEXT
- OpName %main "main"
- %void = OpTypeVoid
- %1 = OpTypeFunction %void
- %foo = OpFunction %void None %1
- ; CHECK: OpLabel
- ; CHECK-NOT: OpBeginInvocationInterlockEXT
- ; CHECK-NOT: OpEndInvocationInterlockEXT
- %2 = OpLabel
- OpBeginInvocationInterlockEXT
- OpEndInvocationInterlockEXT
- OpReturn
- ; CHECK: OpFunctionEnd
- OpFunctionEnd
- %bar = OpFunction %void None %1
- ; CHECK: OpLabel
- ; CHECK-NOT: OpBeginInvocationInterlockEXT
- ; CHECK-NOT: OpEndInvocationInterlockEXT
- %3 = OpLabel
- %4 = OpFunctionCall %void %foo
- OpReturn
- ; CHECK: OpFunctionEnd
- OpFunctionEnd
- %main = OpFunction %void None %1
- ; CHECK: OpLabel
- %5 = OpLabel
- ; CHECK-NEXT: OpBeginInvocationInterlockEXT
- ; CHECK-NEXT: OpFunctionCall
- %6 = OpFunctionCall %void %bar
- ; CHECK-NEXT: OpEndInvocationInterlockEXT
- ; CHECK-NEXT: OpReturn
- OpReturn
- OpFunctionEnd
- )";
- SetTargetEnv(SPV_ENV_VULKAN_1_3);
- const auto result = SinglePassRunAndMatch<InvocationInterlockPlacementPass>(
- kTest, /* skip_nop= */ false);
- EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange);
- }
- TEST_F(InterlockInvocationPlacementTest, CheckLoopExtraction) {
- // Tests that any begin or end instructions in a loop are moved outside of the
- // loop.
- const std::string kTest = R"(
- OpCapability Shader
- OpCapability FragmentShaderSampleInterlockEXT
- OpExtension "SPV_EXT_fragment_shader_interlock"
- OpMemoryModel Logical GLSL450
- OpEntryPoint Fragment %main "main"
- OpExecutionMode %main OriginUpperLeft
- OpExecutionMode %main SampleInterlockOrderedEXT
- %void = OpTypeVoid
- %bool = OpTypeBool
- %true = OpConstantTrue %bool
- %1 = OpTypeFunction %void
- %main = OpFunction %void None %1
- %2 = OpLabel
- ; CHECK: OpBeginInvocationInterlockEXT
- ; CHECK-NOT: OpBeginInvocationInterlockEXT
- ; CHECK-NOT: OpEndInvocationInterlockEXT
- OpBranch %3
- %3 = OpLabel
- OpLoopMerge %3 %4 None
- ; CHECK: OpBranchConditional
- ; CHECK-NOT: OpBeginInvocationInterlockEXT
- ; CHECK-NOT: OpEndInvocationInterlockEXT
- OpBranchConditional %true %4 %5
- %4 = OpLabel
- OpBeginInvocationInterlockEXT
- OpEndInvocationInterlockEXT
- ; CHECK: OpBranch
- OpBranch %3
- ; CHECK-NEXT: OpLabel
- %5 = OpLabel
- ; CHECK-NEXT: OpEndInvocationInterlockEXT
- ; CHECK-NOT: OpEndInvocationInterlockEXT
- OpEndInvocationInterlockEXT
- OpReturn
- OpFunctionEnd
- )";
- SetTargetEnv(SPV_ENV_VULKAN_1_3);
- const auto result = SinglePassRunAndMatch<InvocationInterlockPlacementPass>(
- kTest, /* skip_nop= */ false);
- EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange);
- }
- TEST_F(InterlockInvocationPlacementTest, CheckAddBeginToElse) {
- // Test that if there is a begin in a single branch of a conditional, begin
- // will be added to the other branch.
- const std::string kTest = R"(
- OpCapability Shader
- OpCapability FragmentShaderSampleInterlockEXT
- OpExtension "SPV_EXT_fragment_shader_interlock"
- OpMemoryModel Logical GLSL450
- OpEntryPoint Fragment %main "main"
- OpExecutionMode %main OriginUpperLeft
- OpExecutionMode %main SampleInterlockOrderedEXT
- OpName %main "main"
- %void = OpTypeVoid
- %bool = OpTypeBool
- %true = OpConstantTrue %bool
- %1 = OpTypeFunction %void
- %main = OpFunction %void None %1
- %2 = OpLabel
- ; CHECK-NOT: OpBeginInvocationInterlockEXT
- OpSelectionMerge %5 None
- ; CHECK: OpBranchConditional
- OpBranchConditional %true %3 %4
- ; CHECK-NEXT: OpLabel
- %3 = OpLabel
- ; CHECK-NEXT: OpBeginInvocationInterlockEXT
- OpBeginInvocationInterlockEXT
- OpEndInvocationInterlockEXT
- ; CHECK-NEXT: OpBranch
- OpBranch %5
- %4 = OpLabel
- ; CHECK: OpBeginInvocationInterlockEXT
- ; CHECK-NEXT: OpBranch
- OpBranch %5
- ; CHECK-NEXT: OpLabel
- %5 = OpLabel
- OpBeginInvocationInterlockEXT
- ; CHECK-NEXT: OpEndInvocationInterlockEXT
- OpEndInvocationInterlockEXT
- OpReturn
- OpFunctionEnd
- )";
- SetTargetEnv(SPV_ENV_VULKAN_1_3);
- const auto result = SinglePassRunAndMatch<InvocationInterlockPlacementPass>(
- kTest, /* skip_nop= */ false);
- EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange);
- }
- TEST_F(InterlockInvocationPlacementTest, CheckAddEndToElse) {
- const std::string kTest = R"(
- OpCapability Shader
- OpCapability FragmentShaderSampleInterlockEXT
- OpExtension "SPV_EXT_fragment_shader_interlock"
- OpMemoryModel Logical GLSL450
- OpEntryPoint Fragment %main "main"
- OpExecutionMode %main OriginUpperLeft
- OpExecutionMode %main SampleInterlockOrderedEXT
- OpName %main "main"
- %void = OpTypeVoid
- %bool = OpTypeBool
- %true = OpConstantTrue %bool
- %1 = OpTypeFunction %void
- %main = OpFunction %void None %1
- %2 = OpLabel
- ; CHECK: OpBeginInvocationInterlockEXT
- OpBeginInvocationInterlockEXT
- ; CHECK-NOT: OpEndInvocationInterlockEXT
- OpEndInvocationInterlockEXT
- OpSelectionMerge %5 None
- ; CHECK: OpBranchConditional
- OpBranchConditional %true %3 %4
- ; CHECK-NEXT: OpLabel
- %3 = OpLabel
- OpBeginInvocationInterlockEXT
- ; CHECK-NEXT: OpEndInvocationInterlockEXT
- OpEndInvocationInterlockEXT
- ; CHECK-NEXT: OpBranch
- OpBranch %5
- %4 = OpLabel
- ; CHECK: OpEndInvocationInterlockEXT
- ; CHECK-NEXT: OpBranch
- OpBranch %5
- ; CHECK-NEXT: OpLabel
- %5 = OpLabel
- ; CHECK-NOT: OpEndInvocationInterlockEXT
- OpReturn
- OpFunctionEnd
- )";
- SetTargetEnv(SPV_ENV_VULKAN_1_3);
- const auto result = SinglePassRunAndMatch<InvocationInterlockPlacementPass>(
- kTest, /* skip_nop= */ false);
- EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange);
- }
- TEST_F(InterlockInvocationPlacementTest, CheckSplitIfWithoutElseBegin) {
- // Test that if there is a begin in the then branch of a conditional, and no
- // else branch, an else branch with a begin will created.
- const std::string kTest = R"(
- OpCapability Shader
- OpCapability FragmentShaderSampleInterlockEXT
- OpExtension "SPV_EXT_fragment_shader_interlock"
- OpMemoryModel Logical GLSL450
- OpEntryPoint Fragment %main "main"
- OpExecutionMode %main OriginUpperLeft
- OpExecutionMode %main SampleInterlockOrderedEXT
- OpName %main "main"
- %void = OpTypeVoid
- %bool = OpTypeBool
- %true = OpConstantTrue %bool
- %1 = OpTypeFunction %void
- %main = OpFunction %void None %1
- %2 = OpLabel
- ; CHECK-NOT: OpBeginInvocationInterlockEXT
- OpSelectionMerge %5 None
- ; CHECK: OpBranchConditional
- OpBranchConditional %true %3 %5
- ; CHECK-NEXT: OpLabel
- ; CHECK-NEXT: OpBeginInvocationInterlockEXT
- ; CHECK-NEXT: OpBranch
- ; CHECK-NEXT: OpLabel
- %3 = OpLabel
- ; CHECK-NEXT: OpBeginInvocationInterlockEXT
- ; CHECK-NOT: OpEndInvocationInterlockEXT
- OpBeginInvocationInterlockEXT
- OpEndInvocationInterlockEXT
- OpBranch %5
- ; CHECK: OpLabel
- %5 = OpLabel
- ; CHECK-NOT: OpBeginInvocationInterlockEXT
- OpBeginInvocationInterlockEXT
- ; CHECK-NEXT: OpEndInvocationInterlockEXT
- OpEndInvocationInterlockEXT
- OpReturn
- OpFunctionEnd
- )";
- SetTargetEnv(SPV_ENV_VULKAN_1_3);
- const auto result = SinglePassRunAndMatch<InvocationInterlockPlacementPass>(
- kTest, /* skip_nop= */ false);
- EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange);
- }
- TEST_F(InterlockInvocationPlacementTest, CheckSplitIfWithoutElseEnd) {
- const std::string kTest = R"(
- OpCapability Shader
- OpCapability FragmentShaderSampleInterlockEXT
- OpExtension "SPV_EXT_fragment_shader_interlock"
- OpMemoryModel Logical GLSL450
- OpEntryPoint Fragment %main "main"
- OpExecutionMode %main OriginUpperLeft
- OpExecutionMode %main SampleInterlockOrderedEXT
- OpName %main "main"
- %void = OpTypeVoid
- %bool = OpTypeBool
- %true = OpConstantTrue %bool
- %1 = OpTypeFunction %void
- %main = OpFunction %void None %1
- %2 = OpLabel
- ; CHECK: OpBeginInvocationInterlockEXT
- OpBeginInvocationInterlockEXT
- ; CHECK-NOT: OpEndInvocationInterlockEXT
- OpEndInvocationInterlockEXT
- ; CHECK-NEXT: OpSelectionMerge [[merge:%\d+]]
- OpSelectionMerge %5 None
- ; CHECK-NEXT: OpBranchConditional %true [[then:%\d+]] [[else:%\d+]]
- OpBranchConditional %true %3 %5
- ; CHECK-NEXT: [[else]] = OpLabel
- ; CHECK-NEXT: OpEndInvocationInterlockEXT
- ; CHECK-NEXT: OpBranch [[merge]]
- ; CHECK-NEXT: [[then]] = OpLabel
- %3 = OpLabel
- ; CHECK-NEXT: OpEndInvocationInterlockEXT
- OpBeginInvocationInterlockEXT
- OpEndInvocationInterlockEXT
- ; CHECK-NEXT: OpBranch [[merge]]
- OpBranch %5
- ; CHECK-NEXT: [[merge]] = OpLabel
- %5 = OpLabel
- ; CHECK-NEXT: OpReturn
- OpReturn
- OpFunctionEnd
- )";
- SetTargetEnv(SPV_ENV_VULKAN_1_3);
- const auto result = SinglePassRunAndMatch<InvocationInterlockPlacementPass>(
- kTest, /* skip_nop= */ false);
- EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange);
- }
- TEST_F(InterlockInvocationPlacementTest, CheckSplitSwitch) {
- // Test that if there is a begin or end in a single branch of a switch, begin
- // or end will be added to all the other branches.
- const std::string kTest = R"(
- OpCapability Shader
- OpCapability FragmentShaderSampleInterlockEXT
- OpExtension "SPV_EXT_fragment_shader_interlock"
- OpMemoryModel Logical GLSL450
- OpEntryPoint Fragment %main "main"
- OpExecutionMode %main OriginUpperLeft
- OpExecutionMode %main SampleInterlockOrderedEXT
- OpName %main "main"
- %void = OpTypeVoid
- %uint = OpTypeInt 32 0
- %uint_1 = OpConstant %uint 1
- %1 = OpTypeFunction %void
- %main = OpFunction %void None %1
- ; CHECK: OpLabel
- %2 = OpLabel
- ; CHECK-NEXT: OpSelectionMerge [[merge:%\d+]]
- OpSelectionMerge %8 None
- ; CHECK-NEXT: OpSwitch %uint_1 [[default:%\d+]] 0 [[case_0:%\d+]] 1 [[case_1:%\d+]] 2 [[case_2:%\d+]]
- OpSwitch %uint_1 %8 0 %4 1 %5 2 %8
- ; CHECK-NEXT: [[case_2]] = OpLabel
- ; CHECK-NEXT: OpBeginInvocationInterlockEXT
- ; CHECK-NEXT: OpBranch [[merge]]
- ; CHECK-NEXT: [[default]] = OpLabel
- ; CHECK-NEXT: OpBeginInvocationInterlockEXT
- ; CHECK-NEXT: OpBranch [[merge]]
- ; CHECK-NEXT: [[case_0]] = OpLabel
- %4 = OpLabel
- ; CHECK-NEXT: OpBeginInvocationInterlockEXT
- ; CHECK-NOT: OpEndInvocationInterlockEXT
- OpBeginInvocationInterlockEXT
- OpEndInvocationInterlockEXT
- ; CHECK-NEXT: OpNoLine
- OpNoLine
- ; CHECK-NEXT: OpBranch [[merge]]
- OpBranch %8
- ; CHECK-NEXT: [[case_1]] = OpLabel
- %5 = OpLabel
- ; CHECK-NEXT: OpBeginInvocationInterlockEXT
- ; CHECK-NOT: OpEndInvocationInterlockEXT
- OpBeginInvocationInterlockEXT
- OpEndInvocationInterlockEXT
- ; CHECK-NEXT: OpNoLine
- OpNoLine
- ; CHECK-NEXT: OpNoLine
- OpNoLine
- ; CHECK-NEXT: OpBranch [[merge]]
- OpBranch %8
- ; CHECK-NEXT: [[merge]] = OpLabel
- %8 = OpLabel
- ; CHECK-NOT: OpBeginInvocationInterlockEXT
- OpBeginInvocationInterlockEXT
- ; CHECK-NEXT: OpEndInvocationInterlockEXT
- OpEndInvocationInterlockEXT
- OpReturn
- OpFunctionEnd
- )";
- SetTargetEnv(SPV_ENV_VULKAN_1_3);
- const auto result = SinglePassRunAndMatch<InvocationInterlockPlacementPass>(
- kTest, /* skip_nop= */ false);
- EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithChange);
- }
- } // namespace
- } // namespace opt
- } // namespace spvtools
|