Remove MemberDecorateStringGOOGLE during stript-refect. (#2021)

The strip-reflect pass is not removing the reflection decorations that
are decorating members.  With this commit, they will now be removed.

Fixes #2019.
This commit is contained in:
Steven Perron 2018-10-30 16:17:35 -04:00 committed by GitHub
parent 1c1e749f0b
commit 6647884a13
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 0 deletions

View File

@ -39,6 +39,14 @@ Pass::Status StripReflectInfoPass::Process() {
}
break;
case SpvOpMemberDecorateStringGOOGLE:
if (inst.GetSingleWordInOperand(2) == SpvDecorationHlslSemanticGOOGLE) {
to_remove.push_back(&inst);
} else {
other_uses_for_decorate_string = true;
}
break;
case SpvOpDecorateId:
if (inst.GetSingleWordInOperand(1) ==
SpvDecorationHlslCounterBufferGOOGLE) {

View File

@ -64,6 +64,27 @@ OpMemoryModel Logical Simple
SinglePassRunAndCheck<StripReflectInfoPass>(before, after, false);
}
TEST_F(StripLineReflectInfoTest, StripHlslSemanticOnMember) {
// This is a non-sensical example, but exercises the instructions.
std::string before = R"(OpCapability Shader
OpCapability Linkage
OpExtension "SPV_GOOGLE_decorate_string"
OpExtension "SPV_GOOGLE_hlsl_functionality1"
OpMemoryModel Logical Simple
OpMemberDecorateStringGOOGLE %struct 0 HlslSemanticGOOGLE "foobar"
%float = OpTypeFloat 32
%_struct_3 = OpTypeStruct %float
)";
std::string after = R"(OpCapability Shader
OpCapability Linkage
OpMemoryModel Logical Simple
%float = OpTypeFloat 32
%_struct_3 = OpTypeStruct %float
)";
SinglePassRunAndCheck<StripReflectInfoPass>(before, after, false);
}
} // namespace
} // namespace opt
} // namespace spvtools