From da6dccd7c55d64cfbf3b01340e1e662feac059f7 Mon Sep 17 00:00:00 2001 From: Corentin Wallez Date: Fri, 29 May 2020 07:37:48 +0000 Subject: [PATCH] Metal: Fix clearing of subresource mipmaps. On Intel the lazy-clearing optimization that bundled multiple subresources at once to lazy-clear failed when multiple different mip-levels were bundled together. The rendering was "clipped" to the size of the smalled miplevel, resulting in some mip levels not being fully cleared. Bug: Change-Id: Icfafbeae25bd426119a0b499237052c87eafe93e Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/22341 Reviewed-by: Austin Eng Reviewed-by: Stephen White Reviewed-by: Corentin Wallez Commit-Queue: Corentin Wallez --- src/dawn_native/metal/TextureMTL.mm | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/dawn_native/metal/TextureMTL.mm b/src/dawn_native/metal/TextureMTL.mm index 46fe75b6bc..ece02145d9 100644 --- a/src/dawn_native/metal/TextureMTL.mm +++ b/src/dawn_native/metal/TextureMTL.mm @@ -421,12 +421,13 @@ namespace dawn_native { namespace metal { } } else { ASSERT(GetFormat().IsColor()); - MTLRenderPassDescriptor* descriptor = nil; - uint32_t attachment = 0; - - // Create multiple render passes with each subresource as a color attachment to - // clear them all. for (uint32_t level = baseMipLevel; level < baseMipLevel + levelCount; ++level) { + // Create multiple render passes with each subresource as a color attachment to + // clear them all. Only do this for array layers to ensure all attachments have + // the same size. + MTLRenderPassDescriptor* descriptor = nil; + uint32_t attachment = 0; + for (uint32_t arrayLayer = baseArrayLayer; arrayLayer < baseArrayLayer + layerCount; arrayLayer++) { if (clearValue == TextureBase::ClearValue::Zero && @@ -456,11 +457,11 @@ namespace dawn_native { namespace metal { descriptor = nil; } } - } - if (descriptor != nil) { - commandContext->BeginRender(descriptor); - commandContext->EndRender(); + if (descriptor != nil) { + commandContext->BeginRender(descriptor); + commandContext->EndRender(); + } } } } else {