zink: make void clears more robust

void clears are intended to be the first clear applied to a surface,
so ensure that these don't clobber any scissored clears

cc: mesa-stable

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18627>
This commit is contained in:
Mike Blumenkrantz 2022-09-02 10:26:25 -04:00 committed by Marge Bot
parent d7c64ffcb8
commit 13a19ad90c

View file

@ -247,7 +247,30 @@ zink_clear(struct pipe_context *pctx,
union pipe_color_union color;
color.f[0] = color.f[1] = color.f[2] = 0;
color.f[3] = 1.0;
pctx->clear(pctx, void_clears, NULL, &color, 0, 0);
for (unsigned i = 0; i < fb->nr_cbufs; i++) {
if ((void_clears & (PIPE_CLEAR_COLOR0 << i)) && fb->cbufs[i]) {
struct zink_framebuffer_clear *fb_clear = &ctx->fb_clears[i];
unsigned num_clears = zink_fb_clear_count(fb_clear);
if (num_clears) {
if (zink_fb_clear_first_needs_explicit(fb_clear)) {
/* a scissored clear exists:
* - extend the clear array
* - shift existing clears back by one position
* - inject void clear base of array
*/
add_new_clear(fb_clear);
struct zink_framebuffer_clear_data *clear = fb_clear->clears.data;
memcpy(clear + 1, clear, num_clears);
memcpy(&clear->color, &color, sizeof(color));
} else {
/* no void clear needed */
}
void_clears &= ~(PIPE_CLEAR_COLOR0 << i);
}
}
}
if (void_clears)
pctx->clear(pctx, void_clears, NULL, &color, 0, 0);
}
if (buffers & PIPE_CLEAR_COLOR) {