spirv-val: allow DebugInfoNone for DebugTypeComposite.Size (#3374)

This commit is contained in:
Jaebaek Seo 2020-05-25 10:02:39 -04:00 committed by GitHub
parent 4386ef4234
commit 9cb2571a18
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 1 deletions

View File

@ -2300,7 +2300,14 @@ spv_result_t ValidateExtInst(ValidationState_t& _, const Instruction* inst) {
ValidateOperandLexicalScope(_, "Parent", inst, 10, ext_inst_name);
if (validate_parent != SPV_SUCCESS) return validate_parent;
CHECK_OPERAND("Linkage Name", SpvOpString, 11);
CHECK_OPERAND("Size", SpvOpConstant, 12);
if (!DoesDebugInfoOperandMatchExpectation(
_,
[](OpenCLDebugInfo100Instructions dbg_inst) {
return dbg_inst == OpenCLDebugInfo100DebugInfoNone;
},
inst, 12)) {
CHECK_OPERAND("Size", SpvOpConstant, 12);
}
for (uint32_t word_index = 14; word_index < num_words; ++word_index) {
if (!DoesDebugInfoOperandMatchExpectation(
_,

View File

@ -889,6 +889,31 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugScopeBeforeOpVariableInFunction) {
ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
}
TEST_F(ValidateOpenCL100DebugInfo, DebugTypeCompositeSizeDebugInfoNone) {
const std::string src = R"(
%src = OpString "simple.hlsl"
%code = OpString "OpaqueType foo;
main() {}
"
%ty_name = OpString "struct VS_OUTPUT"
)";
const std::string dbg_inst_header = R"(
%dbg_none = OpExtInst %void %DbgExt DebugInfoNone
%dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
%comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL
%opaque = OpExtInst %void %DbgExt DebugTypeComposite %ty_name Class %dbg_src 1 1 %comp_unit %ty_name %dbg_none FlagIsPublic
)";
const std::string extension = R"(
%DbgExt = OpExtInstImport "OpenCL.DebugInfo.100"
)";
CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, "", dbg_inst_header,
"", extension, "Vertex"));
ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
}
TEST_F(ValidateOpenCL100DebugInfo, DebugTypeCompositeForwardReference) {
const std::string src = R"(
%src = OpString "simple.hlsl"