spirv-val: Label VUID 04643 (#4202)

This commit is contained in:
sfricke-samsung 2021-03-19 06:02:48 -07:00 committed by GitHub
parent 2b0d16a059
commit 8f421ced3e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 34 additions and 6 deletions

View File

@ -466,6 +466,7 @@ spv_result_t ValidateVariable(ValidationState_t& _, const Instruction* inst) {
if (!_.IsValidStorageClass(storage_class)) {
return _.diag(SPV_ERROR_INVALID_BINARY, inst)
<< _.VkErrorID(4643)
<< "Invalid storage class for target environment";
}

View File

@ -463,6 +463,7 @@ spv_result_t ValidateTypePointer(ValidationState_t& _,
if (!_.IsValidStorageClass(storage_class)) {
return _.diag(SPV_ERROR_INVALID_BINARY, inst)
<< _.VkErrorID(4643)
<< "Invalid storage class for target environment";
}

View File

@ -1255,12 +1255,12 @@ bool ValidationState_t::IsValidStorageClass(
case SpvStorageClassFunction:
case SpvStorageClassPushConstant:
case SpvStorageClassPhysicalStorageBuffer:
case SpvStorageClassRayPayloadNV:
case SpvStorageClassIncomingRayPayloadNV:
case SpvStorageClassHitAttributeNV:
case SpvStorageClassCallableDataNV:
case SpvStorageClassIncomingCallableDataNV:
case SpvStorageClassShaderRecordBufferNV:
case SpvStorageClassRayPayloadKHR:
case SpvStorageClassIncomingRayPayloadKHR:
case SpvStorageClassHitAttributeKHR:
case SpvStorageClassCallableDataKHR:
case SpvStorageClassIncomingCallableDataKHR:
case SpvStorageClassShaderRecordBufferKHR:
return true;
default:
return false;
@ -1694,6 +1694,8 @@ std::string ValidationState_t::VkErrorID(uint32_t id,
return VUID_WRAP(VUID-StandaloneSpirv-None-04641);
case 4642:
return VUID_WRAP(VUID-StandaloneSpirv-None-04642);
case 4643:
return VUID_WRAP(VUID-StandaloneSpirv-None-04643);
case 4651:
return VUID_WRAP(VUID-StandaloneSpirv-OpVariable-04651);
case 4652:

View File

@ -273,6 +273,30 @@ TEST_F(ValidateMisc, UndefVoid) {
EXPECT_THAT(getDiagnosticString(),
HasSubstr("Cannot create undefined values with void type"));
}
TEST_F(ValidateMisc, VulkanInvalidStorageClass) {
const std::string spirv = R"(
OpCapability Shader
OpMemoryModel Logical GLSL450
OpEntryPoint Vertex %func "shader"
%int = OpTypeInt 32 0
%ptr = OpTypePointer CrossWorkgroup %int
%var = OpVariable %ptr CrossWorkgroup
%void = OpTypeVoid
%void_f = OpTypeFunction %void
%func = OpFunction %void None %void_f
%label = OpLabel
OpReturn
OpFunctionEnd
)";
CompileSuccessfully(spirv, SPV_ENV_VULKAN_1_0);
ASSERT_EQ(SPV_ERROR_INVALID_BINARY, ValidateInstructions(SPV_ENV_VULKAN_1_0));
EXPECT_THAT(getDiagnosticString(),
AnyVUID("VUID-StandaloneSpirv-None-04643"));
EXPECT_THAT(getDiagnosticString(),
HasSubstr("Invalid storage class for target environment"));
}
} // namespace
} // namespace val
} // namespace spvtools