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>
diff --git a/src/reader/spirv/parser_impl.cc b/src/reader/spirv/parser_impl.cc
index ebb3234..bcb7fd2 100644
--- a/src/reader/spirv/parser_impl.cc
+++ b/src/reader/spirv/parser_impl.cc
@@ -1751,6 +1751,10 @@
              "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 5844e1b..377df07 100644
--- a/src/reader/spirv/parser_impl_handle_test.cc
+++ b/src/reader/spirv/parser_impl_handle_test.cc
@@ -4478,6 +4478,33 @@
          "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