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>
diff --git a/src/dawn_native/BindGroupLayout.cpp b/src/dawn_native/BindGroupLayout.cpp
index 907462a..891fb89 100644
--- a/src/dawn_native/BindGroupLayout.cpp
+++ b/src/dawn_native/BindGroupLayout.cpp
@@ -38,10 +38,9 @@
}
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;
}
diff --git a/src/dawn_native/PipelineLayout.cpp b/src/dawn_native/PipelineLayout.cpp
index 6dc39c7..7626c04 100644
--- a/src/dawn_native/PipelineLayout.cpp
+++ b/src/dawn_native/PipelineLayout.cpp
@@ -36,10 +36,8 @@
// 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();
diff --git a/src/tests/unittests/validation/StorageTextureValidationTests.cpp b/src/tests/unittests/validation/StorageTextureValidationTests.cpp
index 910a650..af6e8eb 100644
--- a/src/tests/unittests/validation/StorageTextureValidationTests.cpp
+++ b/src/tests/unittests/validation/StorageTextureValidationTests.cpp
@@ -188,8 +188,8 @@
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 @@
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 @@
descriptor.layout = nullptr;
descriptor.vertexStage.module = mDefaultVSModule;
descriptor.cFragmentStage.module = fsModule;
- ASSERT_DEVICE_ERROR(device.CreateRenderPipeline(&descriptor));
+ device.CreateRenderPipeline(&descriptor);
}
}
@@ -374,7 +374,7 @@
{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},