From 607e517a1169fc34d9ba2284a2b8fe3bcd4a9ba1 Mon Sep 17 00:00:00 2001 From: Boris Brezillon Date: Tue, 24 Sep 2024 16:00:21 +0200 Subject: [PATCH] panvk: Store attachment image views in the graphics state Will be needed if we want to re-use pre-emitted texture payloads in the FB preload path. With this in place, we no longer need the src_iview in the resolve info struct. Signed-off-by: Boris Brezillon Acked-by: Eric R. Smith Reviewed-by: Mary Guillemard Part-of: --- src/panfrost/vulkan/csf/panvk_cmd_buffer.h | 3 ++- src/panfrost/vulkan/csf/panvk_vX_cmd_draw.c | 17 +++++++++++------ src/panfrost/vulkan/jm/panvk_cmd_buffer.h | 3 ++- src/panfrost/vulkan/jm/panvk_vX_cmd_draw.c | 17 +++++++++++------ 4 files changed, 26 insertions(+), 14 deletions(-) diff --git a/src/panfrost/vulkan/csf/panvk_cmd_buffer.h b/src/panfrost/vulkan/csf/panvk_cmd_buffer.h index b6bc089b322..31a6e3fc8a4 100644 --- a/src/panfrost/vulkan/csf/panvk_cmd_buffer.h +++ b/src/panfrost/vulkan/csf/panvk_cmd_buffer.h @@ -321,7 +321,6 @@ struct panvk_attrib_buf { struct panvk_resolve_attachment { VkResolveModeFlagBits mode; - struct panvk_image_view *src_iview; struct panvk_image_view *dst_iview; }; @@ -377,6 +376,7 @@ struct panvk_cmd_graphics_state { enum vk_rp_attachment_flags bound_attachments; struct { + struct panvk_image_view *iviews[MAX_RTS]; VkFormat fmts[MAX_RTS]; uint8_t samples[MAX_RTS]; struct panvk_resolve_attachment resolve[MAX_RTS]; @@ -385,6 +385,7 @@ struct panvk_cmd_graphics_state { struct pan_image_view zs_pview; struct { + struct panvk_image_view *iview; struct panvk_resolve_attachment resolve; } z_attachment, s_attachment; diff --git a/src/panfrost/vulkan/csf/panvk_vX_cmd_draw.c b/src/panfrost/vulkan/csf/panvk_vX_cmd_draw.c index 8425e4c3b5f..05e8624ca01 100644 --- a/src/panfrost/vulkan/csf/panvk_vX_cmd_draw.c +++ b/src/panfrost/vulkan/csf/panvk_vX_cmd_draw.c @@ -1613,6 +1613,7 @@ panvk_cmd_begin_rendering_init_state(struct panvk_cmd_buffer *cmdbuf, cmdbuf->state.gfx.render.bound_attachments |= MESA_VK_RP_ATTACHMENT_COLOR_BIT(i); + cmdbuf->state.gfx.render.color_attachments.iviews[i] = iview; cmdbuf->state.gfx.render.color_attachments.fmts[i] = iview->vk.format; cmdbuf->state.gfx.render.color_attachments.samples[i] = img->vk.samples; att_width = MAX2(iview_size.width, att_width); @@ -1641,7 +1642,6 @@ panvk_cmd_begin_rendering_init_state(struct panvk_cmd_buffer *cmdbuf, VK_FROM_HANDLE(panvk_image_view, resolve_iview, att->resolveImageView); resolve_info->mode = att->resolveMode; - resolve_info->src_iview = iview; resolve_info->dst_iview = resolve_iview; } } @@ -1663,6 +1663,7 @@ panvk_cmd_begin_rendering_init_state(struct panvk_cmd_buffer *cmdbuf, fbinfo->zs.view.zs = &iview->pview; fbinfo->nr_samples = MAX2( fbinfo->nr_samples, pan_image_view_get_nr_samples(&iview->pview)); + cmdbuf->state.gfx.render.z_attachment.iview = iview; if (vk_format_has_stencil(img->vk.format)) fbinfo->zs.preload.s = true; @@ -1681,7 +1682,6 @@ panvk_cmd_begin_rendering_init_state(struct panvk_cmd_buffer *cmdbuf, att->resolveImageView); resolve_info->mode = att->resolveMode; - resolve_info->src_iview = iview; resolve_info->dst_iview = resolve_iview; } } @@ -1713,6 +1713,7 @@ panvk_cmd_begin_rendering_init_state(struct panvk_cmd_buffer *cmdbuf, &iview->pview != fbinfo->zs.view.zs ? &iview->pview : NULL; fbinfo->nr_samples = MAX2( fbinfo->nr_samples, pan_image_view_get_nr_samples(&iview->pview)); + cmdbuf->state.gfx.render.s_attachment.iview = iview; if (vk_format_has_depth(img->vk.format)) { assert(fbinfo->zs.view.zs == NULL || @@ -1740,7 +1741,6 @@ panvk_cmd_begin_rendering_init_state(struct panvk_cmd_buffer *cmdbuf, att->resolveImageView); resolve_info->mode = att->resolveMode; - resolve_info->src_iview = iview; resolve_info->dst_iview = resolve_iview; } } @@ -1898,10 +1898,12 @@ resolve_attachments(struct panvk_cmd_buffer *cmdbuf) for (uint32_t i = 0; i < color_att_count; i++) { const struct panvk_resolve_attachment *resolve_info = &cmdbuf->state.gfx.render.color_attachments.resolve[i]; + struct panvk_image_view *src_iview = + cmdbuf->state.gfx.render.color_attachments.iviews[i]; color_atts[i] = (VkRenderingAttachmentInfo){ .sType = VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO, - .imageView = panvk_image_view_to_handle(resolve_info->src_iview), + .imageView = panvk_image_view_to_handle(src_iview), .imageLayout = VK_IMAGE_LAYOUT_GENERAL, .resolveMode = resolve_info->mode, .resolveImageView = @@ -1915,9 +1917,11 @@ resolve_attachments(struct panvk_cmd_buffer *cmdbuf) const struct panvk_resolve_attachment *resolve_info = &cmdbuf->state.gfx.render.z_attachment.resolve; + struct panvk_image_view *src_iview = + cmdbuf->state.gfx.render.z_attachment.iview; VkRenderingAttachmentInfo z_att = { .sType = VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO, - .imageView = panvk_image_view_to_handle(resolve_info->src_iview), + .imageView = panvk_image_view_to_handle(src_iview), .imageLayout = VK_IMAGE_LAYOUT_GENERAL, .resolveMode = resolve_info->mode, .resolveImageView = panvk_image_view_to_handle(resolve_info->dst_iview), @@ -1928,10 +1932,11 @@ resolve_attachments(struct panvk_cmd_buffer *cmdbuf) needs_resolve = true; resolve_info = &cmdbuf->state.gfx.render.s_attachment.resolve; + src_iview = cmdbuf->state.gfx.render.s_attachment.iview; VkRenderingAttachmentInfo s_att = { .sType = VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO, - .imageView = panvk_image_view_to_handle(resolve_info->src_iview), + .imageView = panvk_image_view_to_handle(src_iview), .imageLayout = VK_IMAGE_LAYOUT_GENERAL, .resolveMode = resolve_info->mode, .resolveImageView = panvk_image_view_to_handle(resolve_info->dst_iview), diff --git a/src/panfrost/vulkan/jm/panvk_cmd_buffer.h b/src/panfrost/vulkan/jm/panvk_cmd_buffer.h index a0eba523662..36a9eec2ba8 100644 --- a/src/panfrost/vulkan/jm/panvk_cmd_buffer.h +++ b/src/panfrost/vulkan/jm/panvk_cmd_buffer.h @@ -82,7 +82,6 @@ struct panvk_attrib_buf { struct panvk_resolve_attachment { VkResolveModeFlagBits mode; - struct panvk_image_view *src_iview; struct panvk_image_view *dst_iview; }; @@ -137,6 +136,7 @@ struct panvk_cmd_graphics_state { enum vk_rp_attachment_flags bound_attachments; struct { + struct panvk_image_view *iviews[MAX_RTS]; VkFormat fmts[MAX_RTS]; uint8_t samples[MAX_RTS]; struct panvk_resolve_attachment resolve[MAX_RTS]; @@ -145,6 +145,7 @@ struct panvk_cmd_graphics_state { struct pan_image_view zs_pview; struct { + struct panvk_image_view *iview; struct panvk_resolve_attachment resolve; } z_attachment, s_attachment; diff --git a/src/panfrost/vulkan/jm/panvk_vX_cmd_draw.c b/src/panfrost/vulkan/jm/panvk_vX_cmd_draw.c index 1afab7a76a8..7b7a11f860a 100644 --- a/src/panfrost/vulkan/jm/panvk_vX_cmd_draw.c +++ b/src/panfrost/vulkan/jm/panvk_vX_cmd_draw.c @@ -1563,6 +1563,7 @@ panvk_cmd_begin_rendering_init_state(struct panvk_cmd_buffer *cmdbuf, cmdbuf->state.gfx.render.bound_attachments |= MESA_VK_RP_ATTACHMENT_COLOR_BIT(i); + cmdbuf->state.gfx.render.color_attachments.iviews[i] = iview; cmdbuf->state.gfx.render.color_attachments.fmts[i] = iview->vk.format; cmdbuf->state.gfx.render.color_attachments.samples[i] = img->vk.samples; att_width = MAX2(iview_size.width, att_width); @@ -1593,7 +1594,6 @@ panvk_cmd_begin_rendering_init_state(struct panvk_cmd_buffer *cmdbuf, VK_FROM_HANDLE(panvk_image_view, resolve_iview, att->resolveImageView); resolve_info->mode = att->resolveMode; - resolve_info->src_iview = iview; resolve_info->dst_iview = resolve_iview; } } @@ -1617,6 +1617,7 @@ panvk_cmd_begin_rendering_init_state(struct panvk_cmd_buffer *cmdbuf, fbinfo->zs.view.zs = &iview->pview; fbinfo->nr_samples = MAX2( fbinfo->nr_samples, pan_image_view_get_nr_samples(&iview->pview)); + cmdbuf->state.gfx.render.z_attachment.iview = iview; if (vk_format_has_stencil(img->vk.format)) fbinfo->zs.preload.s = true; @@ -1635,7 +1636,6 @@ panvk_cmd_begin_rendering_init_state(struct panvk_cmd_buffer *cmdbuf, att->resolveImageView); resolve_info->mode = att->resolveMode; - resolve_info->src_iview = iview; resolve_info->dst_iview = resolve_iview; } } @@ -1670,6 +1670,7 @@ panvk_cmd_begin_rendering_init_state(struct panvk_cmd_buffer *cmdbuf, &iview->pview != fbinfo->zs.view.zs ? &iview->pview : NULL; fbinfo->nr_samples = MAX2( fbinfo->nr_samples, pan_image_view_get_nr_samples(&iview->pview)); + cmdbuf->state.gfx.render.s_attachment.iview = iview; if (vk_format_has_depth(img->vk.format)) { assert(fbinfo->zs.view.zs == NULL || @@ -1697,7 +1698,6 @@ panvk_cmd_begin_rendering_init_state(struct panvk_cmd_buffer *cmdbuf, att->resolveImageView); resolve_info->mode = att->resolveMode; - resolve_info->src_iview = iview; resolve_info->dst_iview = resolve_iview; } } @@ -1869,10 +1869,12 @@ resolve_attachments(struct panvk_cmd_buffer *cmdbuf) for (uint32_t i = 0; i < color_att_count; i++) { const struct panvk_resolve_attachment *resolve_info = &cmdbuf->state.gfx.render.color_attachments.resolve[i]; + struct panvk_image_view *src_iview = + cmdbuf->state.gfx.render.color_attachments.iviews[i]; color_atts[i] = (VkRenderingAttachmentInfo){ .sType = VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO, - .imageView = panvk_image_view_to_handle(resolve_info->src_iview), + .imageView = panvk_image_view_to_handle(src_iview), .imageLayout = VK_IMAGE_LAYOUT_GENERAL, .resolveMode = resolve_info->mode, .resolveImageView = @@ -1886,9 +1888,11 @@ resolve_attachments(struct panvk_cmd_buffer *cmdbuf) const struct panvk_resolve_attachment *resolve_info = &cmdbuf->state.gfx.render.z_attachment.resolve; + struct panvk_image_view *src_iview = + cmdbuf->state.gfx.render.z_attachment.iview; VkRenderingAttachmentInfo z_att = { .sType = VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO, - .imageView = panvk_image_view_to_handle(resolve_info->src_iview), + .imageView = panvk_image_view_to_handle(src_iview), .imageLayout = VK_IMAGE_LAYOUT_GENERAL, .resolveMode = resolve_info->mode, .resolveImageView = panvk_image_view_to_handle(resolve_info->dst_iview), @@ -1899,10 +1903,11 @@ resolve_attachments(struct panvk_cmd_buffer *cmdbuf) needs_resolve = true; resolve_info = &cmdbuf->state.gfx.render.s_attachment.resolve; + src_iview = cmdbuf->state.gfx.render.s_attachment.iview; VkRenderingAttachmentInfo s_att = { .sType = VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO, - .imageView = panvk_image_view_to_handle(resolve_info->src_iview), + .imageView = panvk_image_view_to_handle(src_iview), .imageLayout = VK_IMAGE_LAYOUT_GENERAL, .resolveMode = resolve_info->mode, .resolveImageView = panvk_image_view_to_handle(resolve_info->dst_iview),