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>
This commit is contained in:
Jiawei Shao 2020-05-21 10:38:36 +00:00 committed by Commit Bot service account
parent 8a3cc5c4df
commit 214c71769b
2 changed files with 17 additions and 0 deletions

View File

@ -572,6 +572,10 @@ namespace dawn_native {
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,

View File

@ -115,3 +115,16 @@ TEST_F(ShaderModuleValidationTest, NoChainedDescriptor) {
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));
}