Mesa (main): lavapipe: clamp attachment clear rect sizes

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Oct 19 01:31:46 UTC 2021


Module: Mesa
Branch: main
Commit: 4cad3da409e703ad4fb828c9fe176f3ae6146535
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=4cad3da409e703ad4fb828c9fe176f3ae6146535

Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date:   Mon Oct  4 11:48:55 2021 -0400

lavapipe: clamp attachment clear rect sizes

this is a spec violation, but crashing isn't cool, so do a little clamping

Reviewed-by: Dave Airlie <airlied at redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13349>

---

 src/gallium/frontends/lavapipe/lvp_execute.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/gallium/frontends/lavapipe/lvp_execute.c b/src/gallium/frontends/lavapipe/lvp_execute.c
index 5f2dde2faff..426dea54ac4 100644
--- a/src/gallium/frontends/lavapipe/lvp_execute.c
+++ b/src/gallium/frontends/lavapipe/lvp_execute.c
@@ -2996,6 +2996,9 @@ static void handle_clear_attachments(struct vk_cmd_queue_entry *cmd,
       for (uint32_t r = 0; r < cmd->u.clear_attachments.rect_count; r++) {
 
          VkClearRect *rect = &cmd->u.clear_attachments.rects[r];
+         /* avoid crashing on spec violations */
+         rect->rect.extent.width = MIN2(rect->rect.extent.width, state->framebuffer.width - rect->rect.offset.x);
+         rect->rect.extent.height = MIN2(rect->rect.extent.height, state->framebuffer.height - rect->rect.offset.y);
          if (subpass->view_mask) {
             u_foreach_bit(i, subpass->view_mask)
                clear_attachment_layers(state, imgv, &rect->rect,



More information about the mesa-commit mailing list