mesa/st: clamp scissored clear regions to fb size

these should never be larger than the fb and drivers shouldn't have to
care about it

Fixes: 1c8bcad81a ("gallium: add pipe cap for scissored clears and pass scissor state to clear() hook")

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9344>
(cherry picked from commit c5e72eb09d)
This commit is contained in:
Mike Blumenkrantz 2021-03-01 14:52:25 -05:00 committed by Dylan Baker
parent 0602af57bc
commit 7b59be1c70
2 changed files with 6 additions and 1 deletions

View file

@ -3415,7 +3415,7 @@
"description": "mesa/st: clamp scissored clear regions to fb size",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"master_sha": null,
"because_sha": "1c8bcad81a7ce106b37f1ee4a75b817651d6545e"
},

View file

@ -534,6 +534,11 @@ st_Clear(struct gl_context *ctx, GLbitfield mask)
scissor_state.miny = MAX2(miny, 0);
scissor_state.maxy = MAX2(maxy, 0);
}
if (have_scissor_buffers) {
const struct gl_framebuffer *fb = ctx->DrawBuffer;
scissor_state.maxx = MIN2(scissor_state.maxx, fb->Width);
scissor_state.maxy = MIN2(scissor_state.maxy, fb->Height);
}
/* We can't translate the clear color to the colorbuffer format,
* because different colorbuffers may have different formats.
*/