From cf8a61a0711ea69de86c3345558019dd118c8218 Mon Sep 17 00:00:00 2001 From: Wujian Sun Date: Thu, 21 May 2026 16:39:40 +0800 Subject: [PATCH] mesa: Fix clipping order in _mesa_clip_blit() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Wujian Sun Part-of: --- src/mesa/main/image.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c index 728f78aebc5..1ed39001ebb 100644 --- a/src/mesa/main/image.c +++ b/src/mesa/main/image.c @@ -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);