From c82ce475d1ecb7a51cc1dc9a8af79690a3c0a85a Mon Sep 17 00:00:00 2001 From: Boris Brezillon Date: Tue, 30 Apr 2024 18:47:50 +0200 Subject: [PATCH] panvk: Skip depth/stencil attachments with non-matching aspect mask Image views passed to the depth or stencil attachment might not have the according depth/stencil aspect set in the image view. In that case, we won't be able to preload or write the attachment, so let's just act as if the attachment wasn't passed. Signed-off-by: Boris Brezillon Acked-by: Erik Faye-Lund Part-of: --- src/panfrost/vulkan/panvk_vX_cmd_buffer.c | 59 ++++++++++++----------- 1 file changed, 32 insertions(+), 27 deletions(-) diff --git a/src/panfrost/vulkan/panvk_vX_cmd_buffer.c b/src/panfrost/vulkan/panvk_vX_cmd_buffer.c index cc57edec6a8..cc3519be7ad 100644 --- a/src/panfrost/vulkan/panvk_vX_cmd_buffer.c +++ b/src/panfrost/vulkan/panvk_vX_cmd_buffer.c @@ -2099,22 +2099,24 @@ panvk_cmd_begin_rendering_init_state(struct panvk_cmd_buffer *cmdbuf, const VkExtent3D iview_size = vk_image_mip_level_extent(&img->vk, iview->vk.base_mip_level); - cmdbuf->state.gfx.render.bound_attachments |= - MESA_VK_RP_ATTACHMENT_DEPTH_BIT; - att_width = MAX2(iview_size.width, att_width); - att_height = MAX2(iview_size.height, att_height); + if (iview->vk.aspects & VK_IMAGE_ASPECT_DEPTH_BIT) { + cmdbuf->state.gfx.render.bound_attachments |= + MESA_VK_RP_ATTACHMENT_DEPTH_BIT; + att_width = MAX2(iview_size.width, att_width); + att_height = MAX2(iview_size.height, att_height); - assert(att->resolveMode == VK_RESOLVE_MODE_NONE); + assert(att->resolveMode == VK_RESOLVE_MODE_NONE); - cmdbuf->state.gfx.render.fb.bos[cmdbuf->state.gfx.render.fb.bo_count++] = - img->bo; - fbinfo->zs.view.zs = &iview->pview; + cmdbuf->state.gfx.render.fb + .bos[cmdbuf->state.gfx.render.fb.bo_count++] = img->bo; + fbinfo->zs.view.zs = &iview->pview; - if (att->loadOp == VK_ATTACHMENT_LOAD_OP_CLEAR) { - fbinfo->zs.clear.z = true; - fbinfo->zs.clear_value.depth = att->clearValue.depthStencil.depth; - } else if (att->loadOp == VK_ATTACHMENT_LOAD_OP_LOAD) { - fbinfo->zs.preload.z = true; + if (att->loadOp == VK_ATTACHMENT_LOAD_OP_CLEAR) { + fbinfo->zs.clear.z = true; + fbinfo->zs.clear_value.depth = att->clearValue.depthStencil.depth; + } else if (att->loadOp == VK_ATTACHMENT_LOAD_OP_LOAD) { + fbinfo->zs.preload.z = true; + } } } @@ -2127,23 +2129,26 @@ panvk_cmd_begin_rendering_init_state(struct panvk_cmd_buffer *cmdbuf, const VkExtent3D iview_size = vk_image_mip_level_extent(&img->vk, iview->vk.base_mip_level); - cmdbuf->state.gfx.render.bound_attachments |= - MESA_VK_RP_ATTACHMENT_STENCIL_BIT; - att_width = MAX2(iview_size.width, att_width); - att_height = MAX2(iview_size.height, att_height); + if (iview->vk.aspects & VK_IMAGE_ASPECT_STENCIL_BIT) { + cmdbuf->state.gfx.render.bound_attachments |= + MESA_VK_RP_ATTACHMENT_STENCIL_BIT; + att_width = MAX2(iview_size.width, att_width); + att_height = MAX2(iview_size.height, att_height); - assert(att->resolveMode == VK_RESOLVE_MODE_NONE); + assert(att->resolveMode == VK_RESOLVE_MODE_NONE); - cmdbuf->state.gfx.render.fb.bos[cmdbuf->state.gfx.render.fb.bo_count++] = - img->bo; - fbinfo->zs.view.s = - &iview->pview != fbinfo->zs.view.zs ? &iview->pview : NULL; + cmdbuf->state.gfx.render.fb + .bos[cmdbuf->state.gfx.render.fb.bo_count++] = img->bo; + fbinfo->zs.view.s = + &iview->pview != fbinfo->zs.view.zs ? &iview->pview : NULL; - if (att->loadOp == VK_ATTACHMENT_LOAD_OP_CLEAR) { - fbinfo->zs.clear.s = true; - fbinfo->zs.clear_value.stencil = att->clearValue.depthStencil.stencil; - } else if (att->loadOp == VK_ATTACHMENT_LOAD_OP_LOAD) { - fbinfo->zs.preload.s = true; + if (att->loadOp == VK_ATTACHMENT_LOAD_OP_CLEAR) { + fbinfo->zs.clear.s = true; + fbinfo->zs.clear_value.stencil = + att->clearValue.depthStencil.stencil; + } else if (att->loadOp == VK_ATTACHMENT_LOAD_OP_LOAD) { + fbinfo->zs.preload.s = true; + } } }