Allow using write-only storage textures in fragment shader stage

This patch enables the use of write-only storage textures in fragment
shader stage after the new decision in WebGPU CG.

BUG=dawn:267
TEST=dawn_unittests

Change-Id: Ia1884e5d1a8e63cf992d3518df7375c2b3a72c41
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/19784
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
This commit is contained in:
Jiawei Shao 2020-04-21 00:43:30 +00:00 committed by Commit Bot service account
parent 7817a9aafe
commit d543d58760
3 changed files with 8 additions and 11 deletions

View File

@ -38,10 +38,9 @@ namespace dawn_native {
}
case wgpu::BindingType::WriteonlyStorageTexture: {
if ((shaderStageVisibility &
(wgpu::ShaderStage::Vertex | wgpu::ShaderStage::Fragment)) != 0) {
if ((shaderStageVisibility & wgpu::ShaderStage::Vertex) != 0) {
return DAWN_VALIDATION_ERROR(
"write-only storage texture binding is only supported in compute shader");
"write-only storage texture binding is not supported in vertex shader");
}
break;
}

View File

@ -36,10 +36,8 @@ namespace dawn_native {
// TODO(jiawei.shao@intel.com): support read-only and read-write storage textures.
switch (bindingType) {
case wgpu::BindingType::StorageBuffer:
return wgpu::ShaderStage::Fragment | wgpu::ShaderStage::Compute;
case wgpu::BindingType::WriteonlyStorageTexture:
return wgpu::ShaderStage::Compute;
return wgpu::ShaderStage::Fragment | wgpu::ShaderStage::Compute;
case wgpu::BindingType::StorageTexture:
UNREACHABLE();

View File

@ -188,8 +188,8 @@ class StorageTextureValidationTests : public ValidationTest {
wgpu::BindingType::ReadonlyStorageTexture, wgpu::BindingType::WriteonlyStorageTexture};
};
// Validate read-only storage textures can be declared in vertex and fragment
// shaders, while writeonly storage textures can't.
// Validate read-only storage textures can be declared in vertex and fragment shaders, while
// writeonly storage textures cannot be used in vertex shaders.
TEST_F(StorageTextureValidationTests, RenderPipeline) {
// Readonly storage texture can be declared in a vertex shader.
{
@ -243,7 +243,7 @@ TEST_F(StorageTextureValidationTests, RenderPipeline) {
ASSERT_DEVICE_ERROR(device.CreateRenderPipeline(&descriptor));
}
// Write-only storage textures cannot be declared in a fragment shader.
// Write-only storage textures can be declared in a fragment shader.
{
wgpu::ShaderModule fsModule =
utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, R"(
@ -257,7 +257,7 @@ TEST_F(StorageTextureValidationTests, RenderPipeline) {
descriptor.layout = nullptr;
descriptor.vertexStage.module = mDefaultVSModule;
descriptor.cFragmentStage.module = fsModule;
ASSERT_DEVICE_ERROR(device.CreateRenderPipeline(&descriptor));
device.CreateRenderPipeline(&descriptor);
}
}
@ -374,7 +374,7 @@ TEST_F(StorageTextureValidationTests, BindGroupLayoutWithStorageTextureBindingTy
{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::WriteonlyStorageTexture, true},
{wgpu::ShaderStage::Fragment, wgpu::BindingType::StorageTexture, false},
{wgpu::ShaderStage::Compute, wgpu::BindingType::ReadonlyStorageTexture, true},
{wgpu::ShaderStage::Compute, wgpu::BindingType::WriteonlyStorageTexture, true},