spirv-reader: explicitly reject combined-image-sampler

This was already rejected, but with a not-very-useful message.
Error out more consciously and issue a higher level, more informative
error message.

Fixed: tint:442
Change-Id: I3643b98d17f55b44b9dcf86aa828010bb39fcd8e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/37242
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: David Neto <dneto@google.com>
Auto-Submit: David Neto <dneto@google.com>
This commit is contained in:
David Neto 2021-01-12 15:24:18 +00:00 committed by Commit Bot service account
parent 987376cd21
commit 4651a6ee8b
2 changed files with 31 additions and 0 deletions

View File

@ -1751,6 +1751,10 @@ ParserImpl::GetSpirvTypeForHandleMemoryObjectDeclaration(
"translate variable or function parameter: "
<< var.PrettyPrint();
return nullptr;
case SpvOpTypeSampledImage:
Fail() << "WGSL does not support combined image-samplers: "
<< var.PrettyPrint();
return nullptr;
default:
Fail() << "invalid type for image or sampler variable or function "
"parameter: "

View File

@ -4478,6 +4478,33 @@ INSTANTIATE_TEST_SUITE_P(
"gradient: ",
{}}}));
TEST_F(SpvParserTest, CombinedImageSampler_IsError) {
const auto assembly = Preamble() + R"(
OpEntryPoint Fragment %100 "main"
OpExecutionMode %100 OriginUpperLeft
OpDecorate %var DescriptorSet 0
OpDecorate %var Binding 0
%float = OpTypeFloat 32
%im = OpTypeImage %float 2D 0 0 0 1 Unknown
%si = OpTypeSampledImage %im
%ptr_si = OpTypePointer UniformConstant %si
%var = OpVariable %ptr_si UniformConstant
%void = OpTypeVoid
%voidfn = OpTypeFunction %void
%100 = OpFunction %void None %voidfn
%entry = OpLabel
OpReturn
OpFunctionEnd
)";
auto p = parser(test::Assemble(assembly));
std::cout << assembly;
EXPECT_FALSE(p->BuildAndParseInternalModule()) << assembly;
EXPECT_THAT(p->error(),
HasSubstr("WGSL does not support combined image-samplers: "));
}
} // namespace
} // namespace spirv
} // namespace reader