Implement 3D texture storage binding types
This change adds storage binding type tests for 3D texture. It turns
out that it is working. There is no additional work to be done.
Bug: dawn:547
Change-Id: Ia749200e7d371ad549405ff63c198ea4a27924c0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/57120
Commit-Queue: Yunchao He <yunchao.he@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
diff --git a/src/tests/end2end/StorageTextureTests.cpp b/src/tests/end2end/StorageTextureTests.cpp
index 94b03cd..6351974 100644
--- a/src/tests/end2end/StorageTextureTests.cpp
+++ b/src/tests/end2end/StorageTextureTests.cpp
@@ -655,39 +655,6 @@
const char* kComputeExpectedValue = "1 + x + size.x * (y + size.y * layer)";
};
-// Test that using read-only storage texture and write-only storage texture in BindGroupLayout is
-// valid on all backends. This test is a regression test for chromium:1061156 and passes by not
-// asserting or crashing.
-TEST_P(StorageTextureTests, BindGroupLayoutWithStorageTextureBindingType) {
- // ReadOnly is a valid storage texture binding type to create a bind group
- // layout.
- {
- wgpu::BindGroupLayoutEntry entry;
- entry.binding = 0;
- entry.visibility = wgpu::ShaderStage::Compute;
- entry.storageTexture.access = wgpu::StorageTextureAccess::ReadOnly;
- entry.storageTexture.format = wgpu::TextureFormat::R32Float;
- wgpu::BindGroupLayoutDescriptor descriptor;
- descriptor.entryCount = 1;
- descriptor.entries = &entry;
- device.CreateBindGroupLayout(&descriptor);
- }
-
- // WriteOnly is a valid storage texture binding type to create a bind group
- // layout.
- {
- wgpu::BindGroupLayoutEntry entry;
- entry.binding = 0;
- entry.visibility = wgpu::ShaderStage::Compute;
- entry.storageTexture.access = wgpu::StorageTextureAccess::WriteOnly;
- entry.storageTexture.format = wgpu::TextureFormat::R32Float;
- wgpu::BindGroupLayoutDescriptor descriptor;
- descriptor.entryCount = 1;
- descriptor.entries = &entry;
- device.CreateBindGroupLayout(&descriptor);
- }
-}
-
// Test that read-only storage textures are supported in compute shader.
TEST_P(StorageTextureTests, ReadonlyStorageTextureInComputeShader) {
for (wgpu::TextureFormat format : utils::kAllTextureFormats) {
diff --git a/src/tests/unittests/validation/StorageTextureValidationTests.cpp b/src/tests/unittests/validation/StorageTextureValidationTests.cpp
index 919ad60..6868dae 100644
--- a/src/tests/unittests/validation/StorageTextureValidationTests.cpp
+++ b/src/tests/unittests/validation/StorageTextureValidationTests.cpp
@@ -95,9 +95,10 @@
wgpu::Texture CreateTexture(wgpu::TextureUsage usage,
wgpu::TextureFormat format,
uint32_t sampleCount = 1,
- uint32_t arrayLayerCount = 1) {
+ uint32_t arrayLayerCount = 1,
+ wgpu::TextureDimension dimension = wgpu::TextureDimension::e2D) {
wgpu::TextureDescriptor descriptor;
- descriptor.dimension = wgpu::TextureDimension::e2D;
+ descriptor.dimension = dimension;
descriptor.size = {16, 16, arrayLayerCount};
descriptor.sampleCount = sampleCount;
descriptor.format = format;
@@ -686,16 +687,13 @@
// bind group must match the corresponding bind group binding.
TEST_F(StorageTextureValidationTests, StorageTextureViewDimensionInBindGroup) {
constexpr wgpu::TextureFormat kStorageTextureFormat = wgpu::TextureFormat::R32Float;
- constexpr uint32_t kArrayLayerCount = 6u;
+ constexpr uint32_t kDepthOrArrayLayers = 6u;
- // Currently we only support creating 2D-compatible texture view dimensions.
- // TODO(jiawei.shao@intel.com): test the use of 1D and 3D texture view dimensions when they are
+ // TODO(crbug.com/dawn/814): test the use of 1D texture view dimensions when they are
// supported in Dawn.
- constexpr std::array<wgpu::TextureViewDimension, 2> kSupportedDimensions = {
- wgpu::TextureViewDimension::e2D, wgpu::TextureViewDimension::e2DArray};
-
- wgpu::Texture texture =
- CreateTexture(wgpu::TextureUsage::Storage, kStorageTextureFormat, 1, kArrayLayerCount);
+ constexpr std::array<wgpu::TextureViewDimension, 3> kSupportedDimensions = {
+ wgpu::TextureViewDimension::e2D, wgpu::TextureViewDimension::e2DArray,
+ wgpu::TextureViewDimension::e3D};
wgpu::TextureViewDescriptor kDefaultTextureViewDescriptor;
kDefaultTextureViewDescriptor.format = kStorageTextureFormat;
@@ -720,6 +718,14 @@
for (wgpu::TextureViewDimension dimensionOfTextureView : kSupportedDimensions) {
// Create a texture view with given texture view dimension.
+ wgpu::TextureDimension dimension = wgpu::TextureDimension::e2D;
+ if (dimensionOfTextureView == wgpu::TextureViewDimension::e3D) {
+ dimension = wgpu::TextureDimension::e3D;
+ }
+ wgpu::Texture texture =
+ CreateTexture(wgpu::TextureUsage::Storage, kStorageTextureFormat, 1,
+ kDepthOrArrayLayers, dimension);
+
wgpu::TextureViewDescriptor textureViewDescriptor = kDefaultTextureViewDescriptor;
textureViewDescriptor.dimension = dimensionOfTextureView;
wgpu::TextureView storageTextureView = texture.CreateView(&textureViewDescriptor);