mirror of
https://github.com/openharmony/third_party_spirv-tools.git
synced 2026-07-21 03:35:25 -04:00
spirv-val: Add Vulkan image gather offset VUID (#4118)
This commit is contained in:
@@ -441,6 +441,17 @@ spv_result_t ValidateImageOperands(ValidationState_t& _,
|
||||
<< "Expected Image Operand Offset to have " << plane_size
|
||||
<< " components, but given " << offset_size;
|
||||
}
|
||||
|
||||
if (spvIsVulkanEnv(_.context()->target_env)) {
|
||||
if (opcode != SpvOpImageGather && opcode != SpvOpImageDrefGather &&
|
||||
opcode != SpvOpImageSparseGather &&
|
||||
opcode != SpvOpImageSparseDrefGather) {
|
||||
return _.diag(SPV_ERROR_INVALID_DATA, inst)
|
||||
<< _.VkErrorID(4663)
|
||||
<< "Image Operand Offset can only be used with "
|
||||
"OpImage*Gather operations";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (mask & SpvImageOperandsConstOffsetsMask) {
|
||||
|
||||
@@ -1700,6 +1700,8 @@ std::string ValidationState_t::VkErrorID(uint32_t id,
|
||||
return VUID_WRAP(VUID-StandaloneSpirv-OpImageTexelPointer-04658);
|
||||
case 4662:
|
||||
return VUID_WRAP(VUID-StandaloneSpirv-Offset-04662);
|
||||
case 4663:
|
||||
return VUID_WRAP(VUID-StandaloneSpirv-Offset-04663);
|
||||
case 4669:
|
||||
return VUID_WRAP(VUID-StandaloneSpirv-GLSLShared-04669);
|
||||
case 4675:
|
||||
|
||||
@@ -1767,6 +1767,24 @@ TEST_F(ValidateImage, SampleImplicitLodOffsetWrongSize) {
|
||||
"Expected Image Operand Offset to have 2 components, but given 3"));
|
||||
}
|
||||
|
||||
TEST_F(ValidateImage, SampleImplicitLodVulkanOffsetWrongSize) {
|
||||
const std::string body = R"(
|
||||
%img = OpLoad %type_image_f32_2d_0001 %uniform_image_f32_2d_0001
|
||||
%sampler = OpLoad %type_sampler %uniform_sampler
|
||||
%simg = OpSampledImage %type_sampled_image_f32_2d_0001 %img %sampler
|
||||
%res4 = OpImageSampleImplicitLod %f32vec4 %simg %f32vec4_0000 Offset %s32vec2_01
|
||||
)";
|
||||
|
||||
CompileSuccessfully(
|
||||
GenerateShaderCode(body, "", "Fragment", "", SPV_ENV_VULKAN_1_0).c_str());
|
||||
ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_0));
|
||||
EXPECT_THAT(getDiagnosticString(),
|
||||
AnyVUID("VUID-StandaloneSpirv-Offset-04663"));
|
||||
EXPECT_THAT(getDiagnosticString(),
|
||||
HasSubstr("Image Operand Offset can only be used with "
|
||||
"OpImage*Gather operations"));
|
||||
}
|
||||
|
||||
TEST_F(ValidateImage, SampleImplicitLodMoreThanOneOffset) {
|
||||
const std::string body = R"(
|
||||
%img = OpLoad %type_image_f32_2d_0001 %uniform_image_f32_2d_0001
|
||||
|
||||
Reference in New Issue
Block a user