From 0aab06e6d39e3832d42c714629b05926f53c1c00 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Mon, 5 Jul 2021 12:45:13 +1000 Subject: [PATCH] crocus: fixup index buffer dirtying. This fixes a possible problem if a non-indexed draw comes in first in a new batch, then the batch might not emit the index buffer. I'm unsure if we see this, I just spotted it trying to fix alacritty Part-of: --- src/gallium/drivers/crocus/crocus_state.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/gallium/drivers/crocus/crocus_state.c b/src/gallium/drivers/crocus/crocus_state.c index df858c8..f415be4 100644 --- a/src/gallium/drivers/crocus/crocus_state.c +++ b/src/gallium/drivers/crocus/crocus_state.c @@ -7723,13 +7723,10 @@ crocus_upload_render_state(struct crocus_context *ice, #if GFX_VER >= 7 bool use_predicate = ice->state.predicate == CROCUS_PREDICATE_STATE_USE_BIT; #endif - bool emit_index = false; + batch->no_wrap = true; + batch->contains_draw = true; - if (!batch->contains_draw) { - emit_index = true; - batch->contains_draw = true; - } crocus_update_surface_base_address(batch); crocus_upload_dirty_render_state(ice, batch, draw); @@ -7738,6 +7735,7 @@ crocus_upload_render_state(struct crocus_context *ice, if (draw->index_size > 0) { unsigned offset; unsigned size; + bool emit_index = false; if (draw->has_user_indices) { unsigned start_offset = draw->index_size * sc->start; @@ -7750,9 +7748,9 @@ crocus_upload_render_state(struct crocus_context *ice, emit_index = true; } else { struct crocus_resource *res = (void *) draw->index.resource; - res->bind_history |= PIPE_BIND_INDEX_BUFFER; if (ice->state.index_buffer.res != draw->index.resource) { + res->bind_history |= PIPE_BIND_INDEX_BUFFER; pipe_resource_reference(&ice->state.index_buffer.res, draw->index.resource); emit_index = true; @@ -8990,6 +8988,9 @@ crocus_state_finish_batch(struct crocus_batch *batch) static void crocus_batch_reset_dirty(struct crocus_batch *batch) { + /* unreference any index buffer so it get reemitted. */ + pipe_resource_reference(&batch->ice->state.index_buffer.res, NULL); + /* for GEN4/5 need to reemit anything that ends up in the state batch that points to anything in the state batch * as the old state batch won't still be available. */ -- 2.7.4