From 45657fb70fea9f214e5a772fa2dd7537898d2d85 Mon Sep 17 00:00:00 2001 From: Rebecca Mckeever Date: Tue, 28 Jan 2025 14:21:12 -0800 Subject: [PATCH] panvk: Move mali_texture_packed structs in panvk_image_view to a union Signed-off-by: Rebecca Mckeever Reviewed-by: Boris Brezillon Part-of: --- src/panfrost/vulkan/panvk_image_view.h | 13 +++++++++++-- src/panfrost/vulkan/panvk_vX_cmd_fb_preload.c | 8 ++++---- src/panfrost/vulkan/panvk_vX_image_view.c | 2 +- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/panfrost/vulkan/panvk_image_view.h b/src/panfrost/vulkan/panvk_image_view.h index 59f1c13fef4..5613d3bfef6 100644 --- a/src/panfrost/vulkan/panvk_image_view.h +++ b/src/panfrost/vulkan/panvk_image_view.h @@ -28,8 +28,13 @@ struct panvk_image_view { struct panvk_priv_mem mem; struct { - struct mali_texture_packed tex; - struct mali_texture_packed other_aspect_tex; + union { + struct mali_texture_packed tex; + struct { + struct mali_texture_packed tex; + struct mali_texture_packed other_aspect_tex; + } zs; + }; #if PAN_ARCH <= 7 /* Valhall passes a texture descriptor to the LEA_TEX instruction. */ @@ -41,4 +46,8 @@ struct panvk_image_view { VK_DEFINE_NONDISP_HANDLE_CASTS(panvk_image_view, vk.base, VkImageView, VK_OBJECT_TYPE_IMAGE_VIEW); +static_assert(offsetof(struct panvk_image_view, descs.zs.tex) == + offsetof(struct panvk_image_view, descs.tex), + "ZS texture descriptor must alias with color texture descriptor"); + #endif diff --git a/src/panfrost/vulkan/panvk_vX_cmd_fb_preload.c b/src/panfrost/vulkan/panvk_vX_cmd_fb_preload.c index 28d96508def..c400f17b71b 100644 --- a/src/panfrost/vulkan/panvk_vX_cmd_fb_preload.c +++ b/src/panfrost/vulkan/panvk_vX_cmd_fb_preload.c @@ -268,8 +268,8 @@ fill_textures(struct panvk_cmd_buffer *cmdbuf, struct pan_fb_info *fbinfo, ?: cmdbuf->state.gfx.render.s_attachment.iview; textures[idx++] = vk_format_has_depth(iview->vk.view_format) - ? iview->descs.tex - : iview->descs.other_aspect_tex; + ? iview->descs.zs.tex + : iview->descs.zs.other_aspect_tex; } if (key->aspects & VK_IMAGE_ASPECT_STENCIL_BIT) { @@ -278,8 +278,8 @@ fill_textures(struct panvk_cmd_buffer *cmdbuf, struct pan_fb_info *fbinfo, ?: cmdbuf->state.gfx.render.z_attachment.iview; textures[idx++] = vk_format_has_depth(iview->vk.view_format) - ? iview->descs.other_aspect_tex - : iview->descs.tex; + ? iview->descs.zs.other_aspect_tex + : iview->descs.zs.tex; } } diff --git a/src/panfrost/vulkan/panvk_vX_image_view.c b/src/panfrost/vulkan/panvk_vX_image_view.c index 6aa820213eb..c66bccb5b99 100644 --- a/src/panfrost/vulkan/panvk_vX_image_view.c +++ b/src/panfrost/vulkan/panvk_vX_image_view.c @@ -161,7 +161,7 @@ prepare_tex_descs(struct panvk_image_view *view) ptr.cpu += alloc_info.size / 2; ptr.gpu += alloc_info.size / 2; - GENX(panfrost_new_texture)(&pview, &view->descs.other_aspect_tex, &ptr); + GENX(panfrost_new_texture)(&pview, &view->descs.zs.other_aspect_tex, &ptr); return VK_SUCCESS; }