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 <boris.brezillon@collabora.com>
Acked-by: Eric R. Smith <eric.smith@collabora.com>
Reviewed-by: Mary Guillemard <mary.guillemard@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31441>
This commit is contained in:
Boris Brezillon 2024-09-24 16:00:21 +02:00 committed by Marge Bot
parent a676d7ffb2
commit 607e517a11
4 changed files with 26 additions and 14 deletions

View file

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

View file

@ -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),

View file

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

View file

@ -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),