From 904a4ab3648db7717dfaedd2588948e3b6a4d90d Mon Sep 17 00:00:00 2001 From: "Eric R. Smith" Date: Thu, 24 Jul 2025 13:19:44 +0000 Subject: [PATCH] panvk: use minimum attachment size for frame buffer size We were using the maximum of all attachment sizes as the bounding box for the frame buffer. But in fact we want the minimum, as we do not want to draw outside of any attachment boundaries. Reviewed-by: Lars-Ivar Hesselberg Simonsen Reviewed-by: Mary Guillemard Part-of: --- src/panfrost/vulkan/panvk_vX_cmd_draw.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/panfrost/vulkan/panvk_vX_cmd_draw.c b/src/panfrost/vulkan/panvk_vX_cmd_draw.c index 86bceb607c1..9d6e624809a 100644 --- a/src/panfrost/vulkan/panvk_vX_cmd_draw.c +++ b/src/panfrost/vulkan/panvk_vX_cmd_draw.c @@ -252,7 +252,7 @@ panvk_per_arch(cmd_init_render_state)(struct panvk_cmd_buffer *cmdbuf, to_panvk_physical_device(cmdbuf->vk.base.device->physical); struct panvk_cmd_graphics_state *state = &cmdbuf->state.gfx; struct pan_fb_info *fbinfo = &state->render.fb.info; - uint32_t att_width = 0, att_height = 0; + uint32_t att_width = UINT32_MAX, att_height = UINT32_MAX; state->render.flags = pRenderingInfo->flags; @@ -298,8 +298,8 @@ panvk_per_arch(cmd_init_render_state)(struct panvk_cmd_buffer *cmdbuf, continue; render_state_set_color_attachment(cmdbuf, att, i); - att_width = MAX2(iview->vk.extent.width, att_width); - att_height = MAX2(iview->vk.extent.height, att_height); + att_width = MIN2(iview->vk.extent.width, att_width); + att_height = MIN2(iview->vk.extent.height, att_height); } if (pRenderingInfo->pDepthAttachment && @@ -310,8 +310,8 @@ panvk_per_arch(cmd_init_render_state)(struct panvk_cmd_buffer *cmdbuf, if (iview) { assert(iview->vk.image->aspects & VK_IMAGE_ASPECT_DEPTH_BIT); render_state_set_z_attachment(cmdbuf, att); - att_width = MAX2(iview->vk.extent.width, att_width); - att_height = MAX2(iview->vk.extent.height, att_height); + att_width = MIN2(iview->vk.extent.width, att_width); + att_height = MIN2(iview->vk.extent.height, att_height); } } @@ -323,8 +323,8 @@ panvk_per_arch(cmd_init_render_state)(struct panvk_cmd_buffer *cmdbuf, if (iview) { assert(iview->vk.image->aspects & VK_IMAGE_ASPECT_STENCIL_BIT); render_state_set_s_attachment(cmdbuf, att); - att_width = MAX2(iview->vk.extent.width, att_width); - att_height = MAX2(iview->vk.extent.height, att_height); + att_width = MIN2(iview->vk.extent.width, att_width); + att_height = MIN2(iview->vk.extent.height, att_height); } }