mesa: Fix clipping order in _mesa_clip_blit()

The source and destination clipping were performed in the wrong order.
We should first clip the source rectangle against the source buffer
bounds, then clip the destination rectangle against the destination
buffer bounds (including scissor).

Fixed the webgl 2.0.0 test case:
conformance2/rendering/blitframebuffer-filter-outofbounds.html

Reviewed-by: Marek Olšák <maraeo@gmail.com>
Signed-off-by: Wujian Sun <wujian.sun_1@nxp.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41718>
This commit is contained in:
Wujian Sun 2026-05-21 16:39:40 +08:00 committed by Marge Bot
parent b22315f9a9
commit cf8a61a071

View file

@ -809,21 +809,21 @@ _mesa_clip_blit(struct gl_context *ctx,
return GL_FALSE;
/*
* dest clip
*/
clip_right_or_top(srcX0, srcX1, dstX0, dstX1, dstXmax);
clip_right_or_top(srcY0, srcY1, dstY0, dstY1, dstYmax);
clip_left_or_bottom(srcX0, srcX1, dstX0, dstX1, dstXmin);
clip_left_or_bottom(srcY0, srcY1, dstY0, dstY1, dstYmin);
/*
* src clip (just swap src/dst values from above)
* src clip
*/
clip_right_or_top(dstX0, dstX1, srcX0, srcX1, srcXmax);
clip_right_or_top(dstY0, dstY1, srcY0, srcY1, srcYmax);
clip_left_or_bottom(dstX0, dstX1, srcX0, srcX1, srcXmin);
clip_left_or_bottom(dstY0, dstY1, srcY0, srcY1, srcYmin);
/*
* dest clip (just swap src/dst values from above)
*/
clip_right_or_top(srcX0, srcX1, dstX0, dstX1, dstXmax);
clip_right_or_top(srcY0, srcY1, dstY0, dstY1, dstYmax);
clip_left_or_bottom(srcX0, srcX1, dstX0, dstX1, dstXmin);
clip_left_or_bottom(srcY0, srcY1, dstY0, dstY1, dstYmin);
/*
printf("PostClipX: src: %d .. %d dst: %d .. %d\n",
*srcX0, *srcX1, *dstX0, *dstX1);