From 5ba77c4a5d4d303e779979930c38501fd5297c1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Sun, 21 Mar 2021 11:12:39 -0400 Subject: [PATCH] radeonsi: unset PIPE_CLEAR_* flags for non-existent buffers Reviewed-by: Pierre-Eric Pelloux-Prayer Part-of: --- src/gallium/drivers/radeonsi/si_clear.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/gallium/drivers/radeonsi/si_clear.c b/src/gallium/drivers/radeonsi/si_clear.c index 56d486afc53..6b46fde293d 100644 --- a/src/gallium/drivers/radeonsi/si_clear.c +++ b/src/gallium/drivers/radeonsi/si_clear.c @@ -626,6 +626,16 @@ static void si_clear(struct pipe_context *ctx, unsigned buffers, struct si_texture *zstex = zsbuf ? (struct si_texture *)zsbuf->texture : NULL; bool needs_db_flush = false; + /* Unset clear flags for non-existent buffers. */ + for (unsigned i = 0; i < 8; i++) { + if (i >= fb->nr_cbufs || !fb->cbufs[i]) + buffers &= ~(PIPE_CLEAR_COLOR0 << i); + } + if (!zsbuf) + buffers &= ~PIPE_CLEAR_DEPTHSTENCIL; + else if (!util_format_has_stencil(util_format_description(zsbuf->format))) + buffers &= ~PIPE_CLEAR_STENCIL; + if (buffers & PIPE_CLEAR_COLOR) { si_do_fast_color_clear(sctx, &buffers, color); if (!buffers)