From 4651a6ee8b53c6a089048fd57e33eb37fa20f24a Mon Sep 17 00:00:00 2001 From: David Neto Date: Tue, 12 Jan 2021 15:24:18 +0000 Subject: [PATCH] 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 Reviewed-by: dan sinclair Commit-Queue: David Neto Auto-Submit: David Neto --- src/reader/spirv/parser_impl.cc | 4 +++ src/reader/spirv/parser_impl_handle_test.cc | 27 +++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/src/reader/spirv/parser_impl.cc b/src/reader/spirv/parser_impl.cc index ebb32342c9..bcb7fd21b9 100644 --- a/src/reader/spirv/parser_impl.cc +++ b/src/reader/spirv/parser_impl.cc @@ -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: " diff --git a/src/reader/spirv/parser_impl_handle_test.cc b/src/reader/spirv/parser_impl_handle_test.cc index 5844e1bf86..377df07c75 100644 --- a/src/reader/spirv/parser_impl_handle_test.cc +++ b/src/reader/spirv/parser_impl_handle_test.cc @@ -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