mirror of
https://gitee.com/openharmony/third_party_spirv-tools
synced 2024-11-23 23:39:40 +00:00
Validate OpenCL environment rules for OpImageWrite (#2619)
Fixes #2593. Signed-off-by: Kevin Petit <kevin.petit@arm.com>
This commit is contained in:
parent
b0504239ab
commit
07a1019717
@ -1517,7 +1517,15 @@ spv_result_t ValidateImageWrite(ValidationState_t& _, const Instruction* inst) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inst->words().size() <= 4) return SPV_SUCCESS;
|
if (inst->words().size() <= 4) {
|
||||||
|
return SPV_SUCCESS;
|
||||||
|
} else {
|
||||||
|
if (spvIsOpenCLEnv(_.context()->target_env)) {
|
||||||
|
return _.diag(SPV_ERROR_INVALID_DATA, inst)
|
||||||
|
<< "Optional Image Operands are not allowed in the OpenCL "
|
||||||
|
<< "environment.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const uint32_t mask = inst->word(4);
|
const uint32_t mask = inst->word(4);
|
||||||
if (spv_result_t result =
|
if (spv_result_t result =
|
||||||
|
@ -147,6 +147,43 @@ TEST_F(ValidateOpenCL, NoAccessQualifierImageBad) {
|
|||||||
"\n %2 = OpTypeImage %void 3D 0 0 0 0 Unknown\n"));
|
"\n %2 = OpTypeImage %void 3D 0 0 0 0 Unknown\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(ValidateOpenCL, ImageWriteWithOptionalImageOperandsBad) {
|
||||||
|
std::string spirv = R"(
|
||||||
|
OpCapability Addresses
|
||||||
|
OpCapability Kernel
|
||||||
|
OpCapability ImageBasic
|
||||||
|
OpMemoryModel Physical64 OpenCL
|
||||||
|
OpEntryPoint Kernel %5 "test"
|
||||||
|
%uint = OpTypeInt 32 0
|
||||||
|
%uint_7 = OpConstant %uint 7
|
||||||
|
%uint_3 = OpConstant %uint 3
|
||||||
|
%uint_1 = OpConstant %uint 1
|
||||||
|
%uint_2 = OpConstant %uint 2
|
||||||
|
%uint_4 = OpConstant %uint 4
|
||||||
|
%void = OpTypeVoid
|
||||||
|
%3 = OpTypeImage %void 2D 0 0 0 0 Unknown WriteOnly
|
||||||
|
%4 = OpTypeFunction %void %3
|
||||||
|
%v2uint = OpTypeVector %uint 2
|
||||||
|
%v4uint = OpTypeVector %uint 4
|
||||||
|
%12 = OpConstantComposite %v2uint %uint_7 %uint_3
|
||||||
|
%17 = OpConstantComposite %v4uint %uint_1 %uint_2 %uint_3 %uint_4
|
||||||
|
%5 = OpFunction %void None %4
|
||||||
|
%img = OpFunctionParameter %3
|
||||||
|
%entry = OpLabel
|
||||||
|
OpImageWrite %img %12 %17 ConstOffset %12
|
||||||
|
OpReturn
|
||||||
|
OpFunctionEnd
|
||||||
|
)";
|
||||||
|
|
||||||
|
CompileSuccessfully(spirv);
|
||||||
|
|
||||||
|
EXPECT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_OPENCL_1_2));
|
||||||
|
EXPECT_THAT(getDiagnosticString(),
|
||||||
|
HasSubstr("Optional Image Operands are not allowed in the "
|
||||||
|
"OpenCL environment."
|
||||||
|
"\n OpImageWrite %15 %13 %14 ConstOffset %13\n"));
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace val
|
} // namespace val
|
||||||
} // namespace spvtools
|
} // namespace spvtools
|
||||||
|
Loading…
Reference in New Issue
Block a user