mirror of
https://github.com/KhronosGroup/SPIRV-Tools
synced 2024-11-22 19:50:05 +00:00
spirv-opt: Add OpExecutionModeId support (#4719)
Needed for Vulkan1.3 adding LocalSizeId support
This commit is contained in:
parent
72e4475b41
commit
471428a04f
@ -189,7 +189,8 @@ bool IrLoader::AddInstruction(const spv_parsed_instruction_t* inst) {
|
|||||||
module_->SetMemoryModel(std::move(spv_inst));
|
module_->SetMemoryModel(std::move(spv_inst));
|
||||||
} else if (opcode == SpvOpEntryPoint) {
|
} else if (opcode == SpvOpEntryPoint) {
|
||||||
module_->AddEntryPoint(std::move(spv_inst));
|
module_->AddEntryPoint(std::move(spv_inst));
|
||||||
} else if (opcode == SpvOpExecutionMode) {
|
} else if (opcode == SpvOpExecutionMode ||
|
||||||
|
opcode == SpvOpExecutionModeId) {
|
||||||
module_->AddExecutionMode(std::move(spv_inst));
|
module_->AddExecutionMode(std::move(spv_inst));
|
||||||
} else if (IsDebug1Inst(opcode)) {
|
} else if (IsDebug1Inst(opcode)) {
|
||||||
module_->AddDebug1Inst(std::move(spv_inst));
|
module_->AddDebug1Inst(std::move(spv_inst));
|
||||||
|
@ -128,6 +128,51 @@ TEST_F(FreezeSpecConstantValueRemoveDecorationTest,
|
|||||||
/* skip_nop = */ true);
|
/* skip_nop = */ true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(FreezeSpecConstantValueRemoveDecorationTest,
|
||||||
|
RemoveDecorationForLocalSizeIdWithSpecId) {
|
||||||
|
std::vector<const char*> text = {
|
||||||
|
// clang-format off
|
||||||
|
"OpCapability Shader",
|
||||||
|
"%1 = OpExtInstImport \"GLSL.std.450\"",
|
||||||
|
"OpMemoryModel Logical GLSL450",
|
||||||
|
"OpEntryPoint GLCompute %2 \"main\"",
|
||||||
|
"OpExecutionModeId %2 LocalSizeId %uint_32 %uint_1 %uint_1_0",
|
||||||
|
"OpSource GLSL 450",
|
||||||
|
"OpDecorate %3 SpecId 18",
|
||||||
|
"OpDecorate %5 SpecId 19",
|
||||||
|
"%void = OpTypeVoid",
|
||||||
|
"%9 = OpTypeFunction %void",
|
||||||
|
"%uint = OpTypeInt 32 0",
|
||||||
|
"%uint_32 = OpSpecConstant %uint 32",
|
||||||
|
"%uint_1 = OpConstant %uint 1",
|
||||||
|
"%uint_1_0 = OpSpecConstant %uint 1",
|
||||||
|
"%2 = OpFunction %void None %9",
|
||||||
|
"%11 = OpLabel",
|
||||||
|
"OpReturn",
|
||||||
|
"OpFunctionEnd",
|
||||||
|
// clang-format on
|
||||||
|
};
|
||||||
|
std::string expected_disassembly = SelectiveJoin(text, [](const char* line) {
|
||||||
|
return std::string(line).find("SpecId") != std::string::npos;
|
||||||
|
});
|
||||||
|
std::vector<std::pair<const char*, const char*>> replacement_pairs = {
|
||||||
|
{"%uint_32 = OpSpecConstant %uint 32", "%uint_32 = OpConstant %uint 32"},
|
||||||
|
{"%uint_1_0 = OpSpecConstant %uint 1", "%uint_1_0 = OpConstant %uint 1"},
|
||||||
|
};
|
||||||
|
for (auto& p : replacement_pairs) {
|
||||||
|
EXPECT_TRUE(FindAndReplace(&expected_disassembly, p.first, p.second))
|
||||||
|
<< "text:\n"
|
||||||
|
<< expected_disassembly << "\n"
|
||||||
|
<< "find_str:\n"
|
||||||
|
<< p.first << "\n"
|
||||||
|
<< "replace_str:\n"
|
||||||
|
<< p.second << "\n";
|
||||||
|
}
|
||||||
|
SinglePassRunAndCheck<FreezeSpecConstantValuePass>(JoinAllInsts(text),
|
||||||
|
expected_disassembly,
|
||||||
|
/* skip_nop = */ true);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace opt
|
} // namespace opt
|
||||||
} // namespace spvtools
|
} // namespace spvtools
|
||||||
|
Loading…
Reference in New Issue
Block a user