mirror of
https://github.com/KhronosGroup/SPIRV-Tools
synced 2024-10-18 19:20:05 +00:00
restrict opcodes targeting OpDecorationGroup
This commit is contained in:
parent
97990dc907
commit
13e6598947
@ -180,6 +180,27 @@ bool idUsage::isValid<SpvOpMemberDecorate>(const spv_instruction_t* inst,
|
||||
return true;
|
||||
}
|
||||
|
||||
template <>
|
||||
bool idUsage::isValid<SpvOpDecorationGroup>(const spv_instruction_t* inst,
|
||||
const spv_opcode_desc) {
|
||||
auto decorationGroupIndex = 1;
|
||||
auto decorationGroup = module_.FindDef(inst->words[decorationGroupIndex]);
|
||||
|
||||
for (auto pair : decorationGroup->uses()) {
|
||||
auto use = pair.first;
|
||||
if (use->opcode() != SpvOpDecorate &&
|
||||
use->opcode() != SpvOpGroupDecorate &&
|
||||
use->opcode() != SpvOpGroupMemberDecorate &&
|
||||
use->opcode() != SpvOpName ) {
|
||||
DIAG(decorationGroupIndex) << "Result id of OpDecorationGroup can only "
|
||||
<< "be targeted by OpName, OpGroupDecorate, "
|
||||
<< "OpDecorate, and OpGroupMemberDecorate";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
template <>
|
||||
bool idUsage::isValid<SpvOpGroupDecorate>(const spv_instruction_t* inst,
|
||||
const spv_opcode_desc) {
|
||||
@ -2362,6 +2383,7 @@ bool idUsage::isValid(const spv_instruction_t* inst) {
|
||||
CASE(OpLine)
|
||||
CASE(OpDecorate)
|
||||
CASE(OpMemberDecorate)
|
||||
CASE(OpDecorationGroup)
|
||||
CASE(OpGroupDecorate)
|
||||
CASE(OpGroupMemberDecorate)
|
||||
TODO(OpExtInst)
|
||||
|
@ -218,6 +218,20 @@ TEST_F(ValidateIdWithMessage, OpGroupDecorateGood) {
|
||||
CompileSuccessfully(spirv.c_str());
|
||||
EXPECT_EQ(SPV_SUCCESS, ValidateInstructions());
|
||||
}
|
||||
TEST_F(ValidateIdWithMessage, OpDecorationGroupBad) {
|
||||
string spirv = kGLSL450MemoryModel + R"(
|
||||
%1 = OpDecorationGroup
|
||||
OpDecorate %1 Uniform
|
||||
OpDecorate %1 GLSLShared
|
||||
OpMemberDecorate %1 0 Constant
|
||||
)";
|
||||
CompileSuccessfully(spirv.c_str());
|
||||
EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions());
|
||||
EXPECT_THAT(getDiagnosticString(),
|
||||
HasSubstr("Result id of OpDecorationGroup can only "
|
||||
"be targeted by OpName, OpGroupDecorate, "
|
||||
"OpDecorate, and OpGroupMemberDecorate"));
|
||||
}
|
||||
TEST_F(ValidateIdWithMessage, OpGroupDecorateDecorationGroupBad) {
|
||||
string spirv = R"(
|
||||
OpCapability Shader
|
||||
|
Loading…
Reference in New Issue
Block a user