mirror of
https://github.com/KhronosGroup/SPIRV-Tools
synced 2024-10-18 19:20:05 +00:00
spirv-val: Label Vulkan VUID 04734 (#4739)
This commit is contained in:
parent
598bc6744a
commit
d1addc44b2
@ -596,23 +596,23 @@ spv_result_t ValidateVariable(ValidationState_t& _, const Instruction* inst) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Vulkan Appendix A: Check that if contains initializer, then
|
// Initializers in Vulkan are only allowed in some storage clases
|
||||||
// storage class is Output, Private, or Function.
|
if (inst->operands().size() > 3) {
|
||||||
if (inst->operands().size() > 3 && storage_class != SpvStorageClassOutput &&
|
|
||||||
storage_class != SpvStorageClassPrivate &&
|
|
||||||
storage_class != SpvStorageClassFunction) {
|
|
||||||
if (spvIsVulkanEnv(_.context()->target_env)) {
|
|
||||||
if (storage_class == SpvStorageClassWorkgroup) {
|
if (storage_class == SpvStorageClassWorkgroup) {
|
||||||
auto init_id = inst->GetOperandAs<uint32_t>(3);
|
auto init_id = inst->GetOperandAs<uint32_t>(3);
|
||||||
auto init = _.FindDef(init_id);
|
auto init = _.FindDef(init_id);
|
||||||
if (init->opcode() != SpvOpConstantNull) {
|
if (init->opcode() != SpvOpConstantNull) {
|
||||||
return _.diag(SPV_ERROR_INVALID_ID, inst)
|
return _.diag(SPV_ERROR_INVALID_ID, inst)
|
||||||
<< "Variable initializers in Workgroup storage class are "
|
<< _.VkErrorID(4734) << "OpVariable, <id> '"
|
||||||
"limited to OpConstantNull";
|
<< _.getIdName(inst->id())
|
||||||
|
<< "', initializers are limited to OpConstantNull in "
|
||||||
|
"Workgroup "
|
||||||
|
"storage class";
|
||||||
}
|
}
|
||||||
} else {
|
} else if (storage_class != SpvStorageClassOutput &&
|
||||||
|
storage_class != SpvStorageClassPrivate &&
|
||||||
|
storage_class != SpvStorageClassFunction) {
|
||||||
return _.diag(SPV_ERROR_INVALID_ID, inst)
|
return _.diag(SPV_ERROR_INVALID_ID, inst)
|
||||||
<< _.VkErrorID(4651) << "OpVariable, <id> '"
|
<< _.VkErrorID(4651) << "OpVariable, <id> '"
|
||||||
<< _.getIdName(inst->id())
|
<< _.getIdName(inst->id())
|
||||||
|
@ -1882,6 +1882,8 @@ std::string ValidationState_t::VkErrorID(uint32_t id,
|
|||||||
return VUID_WRAP(VUID-StandaloneSpirv-OpMemoryBarrier-04732);
|
return VUID_WRAP(VUID-StandaloneSpirv-OpMemoryBarrier-04732);
|
||||||
case 4733:
|
case 4733:
|
||||||
return VUID_WRAP(VUID-StandaloneSpirv-OpMemoryBarrier-04733);
|
return VUID_WRAP(VUID-StandaloneSpirv-OpMemoryBarrier-04733);
|
||||||
|
case 4734:
|
||||||
|
return VUID_WRAP(VUID-StandaloneSpirv-OpVariable-04734);
|
||||||
case 4780:
|
case 4780:
|
||||||
return VUID_WRAP(VUID-StandaloneSpirv-Result-04780);
|
return VUID_WRAP(VUID-StandaloneSpirv-Result-04780);
|
||||||
case 4915:
|
case 4915:
|
||||||
|
@ -4259,8 +4259,10 @@ OpFunctionEnd
|
|||||||
CompileSuccessfully(spirv.c_str(), SPV_ENV_VULKAN_1_0);
|
CompileSuccessfully(spirv.c_str(), SPV_ENV_VULKAN_1_0);
|
||||||
EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_0));
|
EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_VULKAN_1_0));
|
||||||
EXPECT_THAT(getDiagnosticString(),
|
EXPECT_THAT(getDiagnosticString(),
|
||||||
HasSubstr("Variable initializers in Workgroup storage class are "
|
AnyVUID(" VUID-StandaloneSpirv-OpVariable-04734"));
|
||||||
"limited to OpConstantNull"));
|
EXPECT_THAT(getDiagnosticString(),
|
||||||
|
HasSubstr("OpVariable, <id> '5[%5]', initializers are limited to "
|
||||||
|
"OpConstantNull in Workgroup storage class"));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ValidateMemory, VulkanInitializerWithWorkgroupStorageClassGood) {
|
TEST_F(ValidateMemory, VulkanInitializerWithWorkgroupStorageClassGood) {
|
||||||
|
Loading…
Reference in New Issue
Block a user