From 2f51bfc74a0aa441f29e3112b19804126997957e Mon Sep 17 00:00:00 2001 From: Yunchao He Date: Thu, 8 Jul 2021 07:12:24 +0000 Subject: [PATCH] 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 Reviewed-by: Austin Eng --- src/tests/end2end/StorageTextureTests.cpp | 33 ------------------- .../StorageTextureValidationTests.cpp | 26 +++++++++------ 2 files changed, 16 insertions(+), 43 deletions(-) diff --git a/src/tests/end2end/StorageTextureTests.cpp b/src/tests/end2end/StorageTextureTests.cpp index 94b03cd76e..6351974afd 100644 --- a/src/tests/end2end/StorageTextureTests.cpp +++ b/src/tests/end2end/StorageTextureTests.cpp @@ -655,39 +655,6 @@ fn IsEqualTo(pixel : vec4, expected : vec4) -> bool { 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 919ad601a3..6868daeb9b 100644 --- a/src/tests/unittests/validation/StorageTextureValidationTests.cpp +++ b/src/tests/unittests/validation/StorageTextureValidationTests.cpp @@ -95,9 +95,10 @@ class StorageTextureValidationTests : public ValidationTest { 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 @@ TEST_F(StorageTextureValidationTests, StorageTextureFormatInBindGroup) { // 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 kSupportedDimensions = { - wgpu::TextureViewDimension::e2D, wgpu::TextureViewDimension::e2DArray}; - - wgpu::Texture texture = - CreateTexture(wgpu::TextureUsage::Storage, kStorageTextureFormat, 1, kArrayLayerCount); + constexpr std::array kSupportedDimensions = { + wgpu::TextureViewDimension::e2D, wgpu::TextureViewDimension::e2DArray, + wgpu::TextureViewDimension::e3D}; wgpu::TextureViewDescriptor kDefaultTextureViewDescriptor; kDefaultTextureViewDescriptor.format = kStorageTextureFormat; @@ -720,6 +718,14 @@ TEST_F(StorageTextureValidationTests, StorageTextureViewDimensionInBindGroup) { 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);