Validate creating bind group layout with storage textures

This patch adds the validation on the creation of the bind group
layout with read-only storage texture, write-only storage texture
and read-write storage texture. Currently read-write storage textures
are not supported in any shader stages.

This patch also fixes chromium:1061156.

BUG=chromium:1061156, dawn:267
TEST=dawn_unittests, dawn_end2end_tests

Change-Id: Ib42678719df48565a46e39f21c34ec640960dcdc
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/16920
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
Jiawei Shao
2020-03-16 10:53:36 +00:00
committed by Commit Bot service account
parent 463c394905
commit 1a56ce54e0
5 changed files with 116 additions and 44 deletions

View File

@@ -205,3 +205,36 @@ TEST_F(StorageTextureValidationTests, ReadWriteStorageTexture) {
ASSERT_DEVICE_ERROR(device.CreateComputePipeline(&descriptor));
}
}
// Test that using read-only storage texture and write-only storage texture in
// BindGroupLayout is valid, while using read-write storage texture is not allowed now.
TEST_F(StorageTextureValidationTests, BindGroupLayoutWithStorageTextureBindingType) {
struct TestSpec {
wgpu::ShaderStage stage;
wgpu::BindingType type;
bool valid;
};
constexpr std::array<TestSpec, 9> kTestSpecs = {
{{wgpu::ShaderStage::Vertex, wgpu::BindingType::ReadonlyStorageTexture, true},
{wgpu::ShaderStage::Vertex, wgpu::BindingType::WriteonlyStorageTexture, false},
{wgpu::ShaderStage::Vertex, wgpu::BindingType::StorageTexture, false},
{wgpu::ShaderStage::Fragment, wgpu::BindingType::ReadonlyStorageTexture, true},
{wgpu::ShaderStage::Fragment, wgpu::BindingType::WriteonlyStorageTexture, false},
{wgpu::ShaderStage::Fragment, wgpu::BindingType::StorageTexture, false},
{wgpu::ShaderStage::Compute, wgpu::BindingType::ReadonlyStorageTexture, true},
{wgpu::ShaderStage::Compute, wgpu::BindingType::WriteonlyStorageTexture, true},
{wgpu::ShaderStage::Compute, wgpu::BindingType::StorageTexture, false}}};
for (const auto& testSpec : kTestSpecs) {
wgpu::BindGroupLayoutBinding binding = {0, testSpec.stage, testSpec.type};
wgpu::BindGroupLayoutDescriptor descriptor;
descriptor.bindingCount = 1;
descriptor.bindings = &binding;
if (testSpec.valid) {
device.CreateBindGroupLayout(&descriptor);
} else {
ASSERT_DEVICE_ERROR(device.CreateBindGroupLayout(&descriptor));
}
}
}