spirv-val: Label VUID 07290 (#4927)

This commit is contained in:
Spencer Fricke 2022-09-17 03:05:40 +09:00 committed by GitHub
parent 8422d8a44b
commit 5f4ce362ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 0 deletions

View File

@ -459,6 +459,7 @@ spv_result_t ValidateVariable(ValidationState_t& _, const Instruction* inst) {
ContainsInvalidBool(_, value_type, storage_input_or_output)) {
if (storage_input_or_output) {
return _.diag(SPV_ERROR_INVALID_ID, inst)
<< _.VkErrorID(7290)
<< "If OpTypeBool is stored in conjunction with OpVariable "
"using Input or Output Storage Classes it requires a BuiltIn "
"decoration";

View File

@ -2110,6 +2110,8 @@ std::string ValidationState_t::VkErrorID(uint32_t id,
return VUID_WRAP(VUID-StandaloneSpirv-Uniform-06925);
case 6997:
return VUID_WRAP(VUID-StandaloneSpirv-SubgroupVoteKHR-06997);
case 7290:
return VUID_WRAP(VUID-StandaloneSpirv-Input-07290);
default:
return ""; // unknown id
}

View File

@ -2278,6 +2278,35 @@ OpFunctionEnd
"or Output Storage Classes it requires a BuiltIn decoration"));
}
TEST_F(ValidateIdWithMessage, OpVariableContainsNoBuiltinBoolBadVulkan) {
std::string spirv = R"(
OpCapability Shader
OpMemoryModel Logical GLSL450
OpEntryPoint Fragment %main "main" %var
OpExecutionMode %main OriginUpperLeft
%bool = OpTypeBool
%input = OpTypeStruct %bool
%_ptr_input = OpTypePointer Input %input
%var = OpVariable %_ptr_input Input
%void = OpTypeVoid
%fnty = OpTypeFunction %void
%main = OpFunction %void None %fnty
%entry = OpLabel
%load = OpLoad %input %var
OpReturn
OpFunctionEnd
)";
CompileSuccessfully(spirv.c_str(), SPV_ENV_VULKAN_1_0);
EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_0));
EXPECT_THAT(getDiagnosticString(),
AnyVUID("VUID-StandaloneSpirv-Input-07290"));
EXPECT_THAT(
getDiagnosticString(),
HasSubstr(
"If OpTypeBool is stored in conjunction with OpVariable using Input "
"or Output Storage Classes it requires a BuiltIn decoration"));
}
TEST_F(ValidateIdWithMessage, OpVariableContainsRayPayloadBoolGood) {
std::string spirv = R"(
OpCapability RayTracingNV