mirror of
https://github.com/KhronosGroup/SPIRV-Tools
synced 2024-10-18 19:20:05 +00:00
validate StorageImageMultisampled capability (#4062)
* validate StorageImageMultisampled capability The StorageImageMultisampled capability is required when declaring an image type with with Multisampled==1 and it's a storage image (Sampled == 2) Fixes #4061 * Allow SubpassData with Multisampled and Sampled==2
This commit is contained in:
parent
3b85234542
commit
7170218b8d
@ -829,6 +829,15 @@ spv_result_t ValidateTypeImage(ValidationState_t& _, const Instruction* inst) {
|
||||
}
|
||||
}
|
||||
|
||||
if (info.multisampled && (info.sampled == 2) &&
|
||||
(info.dim != SpvDimSubpassData)) {
|
||||
if (!_.HasCapability(SpvCapabilityStorageImageMultisample)) {
|
||||
return _.diag(SPV_ERROR_INVALID_DATA, inst)
|
||||
<< "Capability StorageImageMultisample is required when using "
|
||||
"multisampled storage image";
|
||||
}
|
||||
}
|
||||
|
||||
return SPV_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -584,6 +584,43 @@ TEST_F(ValidateImage, TypeImageWrongFormatForSubpassData) {
|
||||
HasSubstr("Dim SubpassData requires format Unknown"));
|
||||
}
|
||||
|
||||
TEST_F(ValidateImage, TypeImageMultisampleStorageImage_MissingCapability) {
|
||||
const std::string code = GetShaderHeader("", false) +
|
||||
R"(
|
||||
%img_type = OpTypeImage %f32 2D 0 0 1 2 Rgba32f
|
||||
)";
|
||||
|
||||
CompileSuccessfully(code.c_str());
|
||||
ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions()) << code;
|
||||
EXPECT_THAT(getDiagnosticString(),
|
||||
HasSubstr("Capability StorageImageMultisample is required when "
|
||||
"using multisampled storage image"));
|
||||
}
|
||||
|
||||
TEST_F(ValidateImage, TypeImageMultisampleStorageImage_UsesCapability) {
|
||||
const std::string code =
|
||||
GetShaderHeader("OpCapability StorageImageMultisample\n", false) +
|
||||
R"(
|
||||
%img_type = OpTypeImage %f32 2D 0 0 1 2 Rgba32f
|
||||
)";
|
||||
|
||||
CompileSuccessfully(code.c_str());
|
||||
ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()) << code;
|
||||
EXPECT_THAT(getDiagnosticString(), Eq(""));
|
||||
}
|
||||
|
||||
TEST_F(ValidateImage, TypeImageMultisampleSubpassData_OK) {
|
||||
const std::string code =
|
||||
GetShaderHeader("OpCapability InputAttachment\n", false) +
|
||||
R"(
|
||||
%img_type = OpTypeImage %f32 SubpassData 0 0 1 2 Unknown
|
||||
)";
|
||||
|
||||
CompileSuccessfully(code.c_str());
|
||||
ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()) << code;
|
||||
EXPECT_THAT(getDiagnosticString(), Eq(""));
|
||||
}
|
||||
|
||||
TEST_F(ValidateImage, TypeSampledImageNotImage) {
|
||||
const std::string code = GetShaderHeader("", false) + R"(
|
||||
%simg_type = OpTypeSampledImage %f32
|
||||
|
Loading…
Reference in New Issue
Block a user