summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsfricke-samsung <46493288+sfricke-samsung@users.noreply.github.com>2021-03-19 06:02:48 -0700
committerGitHub <noreply@github.com>2021-03-19 09:02:48 -0400
commit8f421ced3e052a4b1b16d25ad2e18d089c2332de (patch)
tree40b4ffe8fdeebda9408520f495aec98c1a768ee2
parent2b0d16a05905380232a0f031918d8a5d3d49e5f7 (diff)
downloadSPIRV-Tools-8f421ced3e052a4b1b16d25ad2e18d089c2332de.tar.gz
SPIRV-Tools-8f421ced3e052a4b1b16d25ad2e18d089c2332de.tar.bz2
SPIRV-Tools-8f421ced3e052a4b1b16d25ad2e18d089c2332de.zip
spirv-val: Label VUID 04643 (#4202)
-rw-r--r--source/val/validate_memory.cpp1
-rw-r--r--source/val/validate_type.cpp1
-rw-r--r--source/val/validation_state.cpp14
-rw-r--r--test/val/val_misc_test.cpp24
4 files changed, 34 insertions, 6 deletions
diff --git a/source/val/validate_memory.cpp b/source/val/validate_memory.cpp
index 4dd6d941..a4bc0fab 100644
--- a/source/val/validate_memory.cpp
+++ b/source/val/validate_memory.cpp
@@ -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";
}
diff --git a/source/val/validate_type.cpp b/source/val/validate_type.cpp
index 685064ca..612fc5c2 100644
--- a/source/val/validate_type.cpp
+++ b/source/val/validate_type.cpp
@@ -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";
}
diff --git a/source/val/validation_state.cpp b/source/val/validation_state.cpp
index 1d2d09b1..db86fd25 100644
--- a/source/val/validation_state.cpp
+++ b/source/val/validation_state.cpp
@@ -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:
diff --git a/test/val/val_misc_test.cpp b/test/val/val_misc_test.cpp
index 499b5b28..b0e46bf9 100644
--- a/test/val/val_misc_test.cpp
+++ b/test/val/val_misc_test.cpp
@@ -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