Disallow using combined textures and samplers in shaders

This patch adds a validation to disallow declaraing combined textures
and samplers in shaders.

SPVC doesn't provide a way to extract the information of combined
textures and samplers from shaders, so currently we cannot add the
related validation when we use SPVC.

BUG=dawn:423
TEST=dawn_unittests

Change-Id: I81f05dc6adb57fbc981ee1a651e160c096315551
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/22000
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
diff --git a/src/dawn_native/ShaderModule.cpp b/src/dawn_native/ShaderModule.cpp
index 68da595..7641053 100644
--- a/src/dawn_native/ShaderModule.cpp
+++ b/src/dawn_native/ShaderModule.cpp
@@ -572,6 +572,10 @@
             return DAWN_VALIDATION_ERROR("Push constants aren't supported.");
         }
 
+        if (resources.sampled_images.size() > 0) {
+            return DAWN_VALIDATION_ERROR("Combined images and samplers aren't supported.");
+        }
+
         // Fill in bindingInfo with the SPIRV bindings
         auto ExtractResourcesBinding =
             [this](const spirv_cross::SmallVector<spirv_cross::Resource>& resources,
diff --git a/src/tests/unittests/validation/ShaderModuleValidationTests.cpp b/src/tests/unittests/validation/ShaderModuleValidationTests.cpp
index 6a037e9..bb08ecc 100644
--- a/src/tests/unittests/validation/ShaderModuleValidationTests.cpp
+++ b/src/tests/unittests/validation/ShaderModuleValidationTests.cpp
@@ -115,3 +115,16 @@
   wgpu::ShaderModuleDescriptor desc = {};
   ASSERT_DEVICE_ERROR(device.CreateShaderModule(&desc));
 }
+
+// Test that it is not allowed to use combined texture and sampler.
+// TODO(jiawei.shao@intel.com): support extracting  combined texture and sampler in spvc.
+TEST_F(ShaderModuleValidationTest, CombinedTextureAndSampler) {
+    const char* shader = R"(
+        #version 450
+        layout (set = 0, binding = 0) uniform sampler2D texture;
+        void main() {
+        })";
+
+    ASSERT_DEVICE_ERROR(
+        utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, shader));
+}