Skip to content

Commit 2904985

Browse files
spirv-val: Add Vulkan check for Rect Dim in OpTypeImage (KhronosGroup#5644)
1 parent 02470f6 commit 2904985

3 files changed

Lines changed: 26 additions & 1 deletion

File tree

source/val/validate_image.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -914,7 +914,15 @@ spv_result_t ValidateTypeImage(ValidationState_t& _, const Instruction* inst) {
914914

915915
if (info.dim == spv::Dim::SubpassData && info.arrayed != 0) {
916916
return _.diag(SPV_ERROR_INVALID_DATA, inst)
917-
<< _.VkErrorID(6214) << "Dim SubpassData requires Arrayed to be 0";
917+
<< _.VkErrorID(6214)
918+
<< "Dim SubpassData requires Arrayed to be 0 in the Vulkan "
919+
"environment";
920+
}
921+
922+
if (info.dim == spv::Dim::Rect) {
923+
return _.diag(SPV_ERROR_INVALID_DATA, inst)
924+
<< _.VkErrorID(9638)
925+
<< "Dim must not be Rect in the Vulkan environment";
918926
}
919927
}
920928

source/val/validation_state.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2351,6 +2351,8 @@ std::string ValidationState_t::VkErrorID(uint32_t id,
23512351
return VUID_WRAP(VUID-StandaloneSpirv-OpEntryPoint-08722);
23522352
case 8973:
23532353
return VUID_WRAP(VUID-StandaloneSpirv-Pointer-08973);
2354+
case 9638:
2355+
return VUID_WRAP(VUID-StandaloneSpirv-OpTypeImage-09638);
23542356
default:
23552357
return ""; // unknown id
23562358
}

test/val/val_image_test.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -786,6 +786,21 @@ TEST_F(ValidateImage, TypeImageWrongArrayForSubpassDataVulkan) {
786786
HasSubstr("Dim SubpassData requires Arrayed to be 0"));
787787
}
788788

789+
TEST_F(ValidateImage, TypeImageDimRectVulkan) {
790+
const std::string code = GetShaderHeader("OpCapability InputAttachment\n") +
791+
R"(
792+
%img_type = OpTypeImage %f32 Rect 0 1 0 2 Unknown
793+
)" + TrivialMain();
794+
795+
CompileSuccessfully(code.c_str());
796+
ASSERT_EQ(SPV_ERROR_INVALID_CAPABILITY,
797+
ValidateInstructions(SPV_ENV_VULKAN_1_0));
798+
// Can't actually hit VUID-StandaloneSpirv-OpTypeImage-09638
799+
EXPECT_THAT(
800+
getDiagnosticString(),
801+
AnyVUID("TypeImage requires one of these capabilities: SampledRect"));
802+
}
803+
789804
TEST_F(ValidateImage, TypeImageWrongSampledTypeForTileImageDataEXT) {
790805
const std::string code = GetShaderHeader(
791806
"OpCapability TileImageColorReadAccessEXT\n"

0 commit comments

Comments
 (0)