From 1c9e0450240d6ddce49d373f3ab38f33796708d7 Mon Sep 17 00:00:00 2001 From: Yunchao He Date: Mon, 29 Jun 2020 19:00:05 +0000 Subject: [PATCH] Fix a bug in PassResourceUsageTracker.cpp In a render/compute pass, if a texture is used as the same usages across its subresources, and it is also used as different usages across its subresources. We should mark that it is not used as the same usages across its subresources for this pass, and we need to visit every single subresource to track its usages transition. Bug: dawn:462 Change-Id: Ide0770db62a3b7b85664757b21eb3280a0bb646c Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/23300 Commit-Queue: Yunchao He Reviewed-by: Austin Eng --- src/dawn_native/PassResourceUsage.h | 4 ++-- src/dawn_native/PassResourceUsageTracker.cpp | 2 +- src/tests/end2end/MultisampledRenderingTests.cpp | 6 ------ 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/dawn_native/PassResourceUsage.h b/src/dawn_native/PassResourceUsage.h index 9271114bc5..e7b0c1bd0c 100644 --- a/src/dawn_native/PassResourceUsage.h +++ b/src/dawn_native/PassResourceUsage.h @@ -45,8 +45,8 @@ namespace dawn_native { // the vector to record every single subresource's Usages. The texture usage is enough. And we // can decompress texture usage to a vector if necessary. struct PassTextureUsage { - wgpu::TextureUsage usage; - bool sameUsagesAcrossSubresources; + wgpu::TextureUsage usage = wgpu::TextureUsage::None; + bool sameUsagesAcrossSubresources = true; std::vector subresourceUsages; }; diff --git a/src/dawn_native/PassResourceUsageTracker.cpp b/src/dawn_native/PassResourceUsageTracker.cpp index f5e4a5664e..bd176dfcb2 100644 --- a/src/dawn_native/PassResourceUsageTracker.cpp +++ b/src/dawn_native/PassResourceUsageTracker.cpp @@ -43,7 +43,7 @@ namespace dawn_native { // Set parameters for the whole texture textureUsage.usage |= usage; uint32_t subresourceCount = texture->GetSubresourceCount(); - textureUsage.sameUsagesAcrossSubresources = levelCount * layerCount == subresourceCount; + textureUsage.sameUsagesAcrossSubresources &= levelCount * layerCount == subresourceCount; // Set usages for subresources if (!textureUsage.subresourceUsages.size()) { diff --git a/src/tests/end2end/MultisampledRenderingTests.cpp b/src/tests/end2end/MultisampledRenderingTests.cpp index 9192fca408..ef03bf2f89 100644 --- a/src/tests/end2end/MultisampledRenderingTests.cpp +++ b/src/tests/end2end/MultisampledRenderingTests.cpp @@ -422,9 +422,6 @@ TEST_P(MultisampledRenderingTest, ResolveOneMultisampledTextureTwice) { // Test using a layer of a 2D texture as resolve target works correctly. TEST_P(MultisampledRenderingTest, ResolveIntoOneMipmapLevelOf2DTexture) { - // TODO(dawn:462): Investigate backend validation failure. - DAWN_SKIP_TEST_IF(IsD3D12() && IsBackendValidationEnabled()); - constexpr uint32_t kBaseMipLevel = 2; wgpu::TextureViewDescriptor textureViewDescriptor; @@ -462,9 +459,6 @@ TEST_P(MultisampledRenderingTest, ResolveIntoOneMipmapLevelOf2DTexture) { // Test using a level or a layer of a 2D array texture as resolve target works correctly. TEST_P(MultisampledRenderingTest, ResolveInto2DArrayTexture) { - // TODO(dawn:462): Investigate backend validation failure. - DAWN_SKIP_TEST_IF(IsD3D12() && IsBackendValidationEnabled()); - wgpu::TextureView multisampledColorView2 = CreateTextureForOutputAttachment(kColorFormat, kSampleCount).CreateView();