From dab4295cd520caf069bfbd299fb51e29ee6fd7ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Mon, 1 Apr 2024 23:59:44 -0400 Subject: [PATCH] radeonsi: fix initialization of occlusion query buffers for disabled RBs GFX9+ should assume the enabled RB results are packed (no holes). Same as PAL. Reviewed-by: Pierre-Eric Pelloux-Prayer Part-of: --- src/gallium/drivers/radeonsi/si_query.c | 30 +++++++++++++++++-------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/src/gallium/drivers/radeonsi/si_query.c b/src/gallium/drivers/radeonsi/si_query.c index 55e768d7c15..c38c854cd61 100644 --- a/src/gallium/drivers/radeonsi/si_query.c +++ b/src/gallium/drivers/radeonsi/si_query.c @@ -589,20 +589,32 @@ static bool si_query_hw_prepare_buffer(struct si_context *sctx, struct si_query_ query->b.type == PIPE_QUERY_OCCLUSION_PREDICATE || query->b.type == PIPE_QUERY_OCCLUSION_PREDICATE_CONSERVATIVE) { unsigned max_rbs = screen->info.max_render_backends; - uint64_t enabled_rb_mask = screen->info.enabled_rb_mask; - unsigned num_results; - unsigned i, j; + unsigned num_results = qbuf->buf->b.b.width0 / query->result_size; - /* Set top bits for unused backends. */ - num_results = qbuf->buf->b.b.width0 / query->result_size; - for (j = 0; j < num_results; j++) { - for (i = 0; i < max_rbs; i++) { - if (!(enabled_rb_mask & (1ull << i))) { + if (screen->info.gfx_level >= GFX9) { + unsigned num_rbs = screen->info.num_rb; + + for (unsigned j = 0; j < num_results; j++) { + /* Results of enabled RBs are packed, so the disabled ones are always at the end. */ + for (unsigned i = num_rbs; i < max_rbs; i++) { results[(i * 4) + 1] = 0x80000000; results[(i * 4) + 3] = 0x80000000; } + results += 4 * max_rbs; + } + } else { + uint64_t enabled_rb_mask = screen->info.enabled_rb_mask; + + /* Set top bits for unused backends. */ + for (unsigned j = 0; j < num_results; j++) { + for (unsigned i = 0; i < max_rbs; i++) { + if (!(enabled_rb_mask & (1ull << i))) { + results[(i * 4) + 1] = 0x80000000; + results[(i * 4) + 3] = 0x80000000; + } + } + results += 4 * max_rbs; } - results += 4 * max_rbs; } }