spirv-val: Loosen restriction on base type of DebugTypePointer and DebugTypeQualifier (#5479)

* Allow base type for DebugTypePointer and DebugTypeQualifier to be any DebugType
This commit is contained in:
Sajjad Mirza 2023-11-17 07:22:46 -08:00 committed by GitHub
parent 0df791f97a
commit 246e6d4c68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 20 deletions

View File

@ -482,8 +482,8 @@ spv_result_t ValidateClspvReflectionArgumentBuffer(ValidationState_t& _,
return SPV_SUCCESS;
}
spv_result_t ValidateClspvReflectionArgumentOffsetBuffer(ValidationState_t& _,
const Instruction* inst) {
spv_result_t ValidateClspvReflectionArgumentOffsetBuffer(
ValidationState_t& _, const Instruction* inst) {
const auto num_operands = inst->operands().size();
if (auto error = ValidateKernelDecl(_, inst)) {
return error;
@ -802,7 +802,7 @@ spv_result_t ValidateClspvReflectionPushConstantData(ValidationState_t& _,
}
spv_result_t ValidateClspvReflectionPrintfInfo(ValidationState_t& _,
const Instruction* inst) {
const Instruction* inst) {
if (!IsUint32Constant(_, inst->GetOperandAs<uint32_t>(4))) {
return _.diag(SPV_ERROR_INVALID_ID, inst)
<< "PrintfID must be a 32-bit unsigned integer OpConstant";
@ -823,8 +823,8 @@ spv_result_t ValidateClspvReflectionPrintfInfo(ValidationState_t& _,
return SPV_SUCCESS;
}
spv_result_t ValidateClspvReflectionPrintfStorageBuffer(ValidationState_t& _,
const Instruction* inst) {
spv_result_t ValidateClspvReflectionPrintfStorageBuffer(
ValidationState_t& _, const Instruction* inst) {
if (!IsUint32Constant(_, inst->GetOperandAs<uint32_t>(4))) {
return _.diag(SPV_ERROR_INVALID_ID, inst)
<< "DescriptorSet must be a 32-bit unsigned integer OpConstant";
@ -843,8 +843,8 @@ spv_result_t ValidateClspvReflectionPrintfStorageBuffer(ValidationState_t& _,
return SPV_SUCCESS;
}
spv_result_t ValidateClspvReflectionPrintfPushConstant(ValidationState_t& _,
const Instruction* inst) {
spv_result_t ValidateClspvReflectionPrintfPushConstant(
ValidationState_t& _, const Instruction* inst) {
if (!IsUint32Constant(_, inst->GetOperandAs<uint32_t>(4))) {
return _.diag(SPV_ERROR_INVALID_ID, inst)
<< "Offset must be a 32-bit unsigned integer OpConstant";
@ -3168,16 +3168,16 @@ spv_result_t ValidateExtInst(ValidationState_t& _, const Instruction* inst) {
break;
}
case CommonDebugInfoDebugTypePointer: {
auto validate_base_type =
ValidateOperandBaseType(_, inst, 5, ext_inst_name);
auto validate_base_type = ValidateOperandDebugType(
_, "Base Type", inst, 5, ext_inst_name, false);
if (validate_base_type != SPV_SUCCESS) return validate_base_type;
CHECK_CONST_UINT_OPERAND("Storage Class", 6);
CHECK_CONST_UINT_OPERAND("Flags", 7);
break;
}
case CommonDebugInfoDebugTypeQualifier: {
auto validate_base_type =
ValidateOperandBaseType(_, inst, 5, ext_inst_name);
auto validate_base_type = ValidateOperandDebugType(
_, "Base Type", inst, 5, ext_inst_name, false);
if (validate_base_type != SPV_SUCCESS) return validate_base_type;
CHECK_CONST_UINT_OPERAND("Type Qualifier", 6);
break;

View File

@ -1012,9 +1012,9 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugTypePointerFail) {
CompileSuccessfully(GenerateShaderCodeForDebugInfo(
src, size_const, dbg_inst_header, "", extension, "Vertex"));
ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
EXPECT_THAT(getDiagnosticString(),
HasSubstr("expected operand Base Type must be a result id of "
"DebugTypeBasic"));
EXPECT_THAT(
getDiagnosticString(),
HasSubstr("expected operand Base Type is not a valid debug type"));
}
TEST_F(ValidateOpenCL100DebugInfo, DebugTypeQualifier) {
@ -1077,9 +1077,9 @@ TEST_F(ValidateOpenCL100DebugInfo, DebugTypeQualifierFail) {
CompileSuccessfully(GenerateShaderCodeForDebugInfo(
src, size_const, dbg_inst_header, "", extension, "Vertex"));
ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
EXPECT_THAT(getDiagnosticString(),
HasSubstr("expected operand Base Type must be a result id of "
"DebugTypeBasic"));
EXPECT_THAT(
getDiagnosticString(),
HasSubstr("expected operand Base Type is not a valid debug type"));
}
TEST_F(ValidateVulkan100DebugInfo, DebugTypeQualifier) {
const std::string src = R"(
@ -1147,9 +1147,9 @@ OpExtension "SPV_KHR_non_semantic_info"
CompileSuccessfully(GenerateShaderCodeForDebugInfo(
src, constants, dbg_inst_header, "", extension, "Vertex"));
ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
EXPECT_THAT(getDiagnosticString(),
HasSubstr("expected operand Base Type must be a result id of "
"DebugTypeBasic"));
EXPECT_THAT(
getDiagnosticString(),
HasSubstr("expected operand Base Type is not a valid debug type"));
}
TEST_F(ValidateOpenCL100DebugInfo, DebugTypeArray) {