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 <enga@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
Corentin Wallez 2020-05-29 07:37:48 +00:00 committed by Commit Bot service account
parent 454c699d47
commit da6dccd7c5
1 changed files with 10 additions and 9 deletions

View File

@ -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 {