drisw: clamp damage region to texture bounds

Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28242>
This commit is contained in:
Lucas Fryzek 2024-03-19 08:29:02 -04:00 committed by Marge Bot
parent 85a91f461c
commit 912e203a53

View file

@ -246,7 +246,15 @@ drisw_swap_buffers_with_damage(struct dri_drawable *drawable, int nrects, const
for (unsigned int i = 0; i < nrects; i++) {
const int *rect = &rects[i * 4];
u_box_2d(rect[0], ptex->height0 - rect[1] - rect[3], rect[2], rect[3], &stack_boxes[i]);
int w = MIN2(rect[2], ptex->width0);
int h = MIN2(rect[3], ptex->height0);
int x = CLAMP(rect[0], 0, ptex->width0);
int y = CLAMP(ptex->height0 - rect[1] - h, 0, ptex->height0);
if (h > ptex->height0 - y)
h = ptex->height0 - y;
u_box_2d(x, y, w, h, &stack_boxes[i]);
}
}