spirv-val: Label new Vulkan OpPtrAccessChain VUs (#4975)

This commit is contained in:
Spencer Fricke 2022-10-27 23:10:27 +09:00 committed by GitHub
parent b49a2caa7c
commit 9f3a4afae4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 0 deletions

View File

@ -1436,12 +1436,14 @@ spv_result_t ValidatePtrAccessChain(ValidationState_t& _,
if (base_type_storage_class == SpvStorageClassWorkgroup) {
if (!_.HasCapability(SpvCapabilityVariablePointers)) {
return _.diag(SPV_ERROR_INVALID_DATA, inst)
<< _.VkErrorID(7651)
<< "OpPtrAccessChain Base operand pointing to Workgroup "
"storage class must use VariablePointers capability";
}
} else if (base_type_storage_class == SpvStorageClassStorageBuffer) {
if (!_.features().variable_pointers) {
return _.diag(SPV_ERROR_INVALID_DATA, inst)
<< _.VkErrorID(7652)
<< "OpPtrAccessChain Base operand pointing to StorageBuffer "
"storage class must use VariablePointers or "
"VariablePointersStorageBuffer capability";
@ -1449,6 +1451,7 @@ spv_result_t ValidatePtrAccessChain(ValidationState_t& _,
} else if (base_type_storage_class !=
SpvStorageClassPhysicalStorageBuffer) {
return _.diag(SPV_ERROR_INVALID_DATA, inst)
<< _.VkErrorID(7650)
<< "OpPtrAccessChain Base operand must point to Workgroup, "
"StorageBuffer, or PhysicalStorageBuffer storage class";
}

View File

@ -2144,6 +2144,12 @@ std::string ValidationState_t::VkErrorID(uint32_t id,
return VUID_WRAP(VUID-StandaloneSpirv-ExecutionModel-07320);
case 7290:
return VUID_WRAP(VUID-StandaloneSpirv-Input-07290);
case 7650:
return VUID_WRAP(VUID-StandaloneSpirv-Base-07650);
case 7651:
return VUID_WRAP(VUID-StandaloneSpirv-Base-07651);
case 7652:
return VUID_WRAP(VUID-StandaloneSpirv-Base-07652);
default:
return ""; // unknown id
}

View File

@ -4856,6 +4856,8 @@ TEST_F(ValidateMemory, VulkanPtrAccessChainStorageBufferCapability) {
CompileSuccessfully(spirv, SPV_ENV_VULKAN_1_2);
EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_2));
EXPECT_THAT(getDiagnosticString(),
AnyVUID("VUID-StandaloneSpirv-Base-07652"));
EXPECT_THAT(getDiagnosticString(),
HasSubstr("OpPtrAccessChain Base operand pointing to "
"StorageBuffer storage class must use VariablePointers "
@ -4891,6 +4893,8 @@ TEST_F(ValidateMemory, VulkanPtrAccessChainWorkgroupCapability) {
CompileSuccessfully(spirv, SPV_ENV_VULKAN_1_2);
EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_2));
EXPECT_THAT(getDiagnosticString(),
AnyVUID("VUID-StandaloneSpirv-Base-07651"));
EXPECT_THAT(getDiagnosticString(),
HasSubstr("OpPtrAccessChain Base operand pointing to Workgroup "
"storage class must use VariablePointers capability"));