Module: Mesa Branch: main Commit: 2c6cadb5ea93d67050c2044e84d161280d4d5f11 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=2c6cadb5ea93d67050c2044e84d161280d4d5f11
Author: Karmjit Mahil <[email protected]> Date: Wed Jul 19 13:13:09 2023 +0100 pvr: Fix packing issue with max_{x,y}_clip The spec. guarantees the framebuffer width and height to be `> 0` but the same is not true for the render area. Previously a render area of `0` size would wrap around due to the `- 1` so we now check for `0`. Fixes: pvr_packet_helpers.h:79: __pvr_uint: Assertion `v <= max' failed. on dEQP-VK.api.pipeline.renderpass.framebuffer_compatible_renderpass Signed-off-by: Karmjit Mahil <[email protected]> Reviewed-by: Luigi Santivetti <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24329> --- src/imagination/vulkan/pvr_cmd_buffer.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/imagination/vulkan/pvr_cmd_buffer.c b/src/imagination/vulkan/pvr_cmd_buffer.c index b4db621650e..031ca598581 100644 --- a/src/imagination/vulkan/pvr_cmd_buffer.c +++ b/src/imagination/vulkan/pvr_cmd_buffer.c @@ -1017,16 +1017,18 @@ static void pvr_setup_pbe_state( break; } +#define PVR_DEC_IF_NOT_ZERO(_v) (((_v) > 0) ? (_v)-1 : 0) + render_params.min_x_clip = MAX2(0, render_area->offset.x); render_params.min_y_clip = MAX2(0, render_area->offset.y); - render_params.max_x_clip = - MIN2(framebuffer->width, - render_area->offset.x + render_area->extent.width) - - 1; - render_params.max_y_clip = - MIN2(framebuffer->height, - render_area->offset.y + render_area->extent.height) - - 1; + render_params.max_x_clip = MIN2( + framebuffer->width - 1, + PVR_DEC_IF_NOT_ZERO(render_area->offset.x + render_area->extent.width)); + render_params.max_y_clip = MIN2( + framebuffer->height - 1, + PVR_DEC_IF_NOT_ZERO(render_area->offset.y + render_area->extent.height)); + +#undef PVR_DEC_IF_NOT_ZERO render_params.slice = 0; render_params.mrt_index = mrt_index;
