Skip to content

Commit

Permalink
spirv-val: Add Vulkan check for Rect Dim in OpTypeImage
Browse files Browse the repository at this point in the history
  • Loading branch information
spencer-lunarg committed Apr 14, 2024
1 parent fe7bae0 commit a699c12
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
10 changes: 9 additions & 1 deletion source/val/validate_image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -914,7 +914,15 @@ spv_result_t ValidateTypeImage(ValidationState_t& _, const Instruction* inst) {

if (info.dim == spv::Dim::SubpassData && info.arrayed != 0) {
return _.diag(SPV_ERROR_INVALID_DATA, inst)
<< _.VkErrorID(6214) << "Dim SubpassData requires Arrayed to be 0";
<< _.VkErrorID(6214)
<< "Dim SubpassData requires Arrayed to be 0 in the Vulkan "
"environment";
}

if (info.dim == spv::Dim::Rect) {
return _.diag(SPV_ERROR_INVALID_DATA, inst)
<< _.VkErrorID(9638)
<< "Dim must not be Rect in the Vulkan environment";
}
}

Expand Down
2 changes: 2 additions & 0 deletions source/val/validation_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2351,6 +2351,8 @@ std::string ValidationState_t::VkErrorID(uint32_t id,
return VUID_WRAP(VUID-StandaloneSpirv-OpEntryPoint-08722);
case 8973:
return VUID_WRAP(VUID-StandaloneSpirv-Pointer-08973);
case 9638:
return VUID_WRAP(VUID-StandaloneSpirv-OpTypeImage-09638);
default:
return ""; // unknown id
}
Expand Down
15 changes: 15 additions & 0 deletions test/val/val_image_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -786,6 +786,21 @@ TEST_F(ValidateImage, TypeImageWrongArrayForSubpassDataVulkan) {
HasSubstr("Dim SubpassData requires Arrayed to be 0"));
}

TEST_F(ValidateImage, TypeImageDimRectVulkan) {
const std::string code = GetShaderHeader("OpCapability InputAttachment\n") +
R"(
%img_type = OpTypeImage %f32 Rect 0 1 0 2 Unknown
)" + TrivialMain();

CompileSuccessfully(code.c_str());
ASSERT_EQ(SPV_ERROR_INVALID_CAPABILITY,
ValidateInstructions(SPV_ENV_VULKAN_1_0));
// Can't actually hit VUID-StandaloneSpirv-OpTypeImage-09638
EXPECT_THAT(
getDiagnosticString(),
AnyVUID("TypeImage requires one of these capabilities: SampledRect"));
}

TEST_F(ValidateImage, TypeImageWrongSampledTypeForTileImageDataEXT) {
const std::string code = GetShaderHeader(
"OpCapability TileImageColorReadAccessEXT\n"
Expand Down

0 comments on commit a699c12

Please sign in to comment.