diff --git a/.pick_status.json b/.pick_status.json index 3e12c076889..c537f139cea 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -1254,7 +1254,7 @@ "description": "zink: don't destroy the current batch state on context destroy", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "b06f6e00fba6e33c28a198a1bb14b89e9dfbb4ae", "notes": null diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c index 0a8c44e837b..6616be2f612 100644 --- a/src/gallium/drivers/zink/zink_context.c +++ b/src/gallium/drivers/zink/zink_context.c @@ -187,21 +187,31 @@ zink_context_destroy(struct pipe_context *pctx) screen->free_batch_states = ctx->batch_states; screen->last_free_batch_state = screen->free_batch_states; } - while (screen->last_free_batch_state->next) - screen->last_free_batch_state = screen->last_free_batch_state->next; } + while (screen->last_free_batch_state && screen->last_free_batch_state->next) + screen->last_free_batch_state = screen->last_free_batch_state->next; if (ctx->free_batch_states) { if (screen->free_batch_states) screen->last_free_batch_state->next = ctx->free_batch_states; - else + else { screen->free_batch_states = ctx->free_batch_states; - screen->last_free_batch_state = ctx->last_free_batch_state; + screen->last_free_batch_state = ctx->last_free_batch_state; + } } - simple_mtx_unlock(&screen->free_batch_states_lock); + while (screen->last_free_batch_state && screen->last_free_batch_state->next) + screen->last_free_batch_state = screen->last_free_batch_state->next; if (ctx->batch.state) { zink_clear_batch_state(ctx, ctx->batch.state); - zink_batch_state_destroy(screen, ctx->batch.state); + if (screen->free_batch_states) + screen->last_free_batch_state->next = ctx->batch.state; + else { + screen->free_batch_states = ctx->batch.state; + screen->last_free_batch_state = screen->free_batch_states; + } } + while (screen->last_free_batch_state && screen->last_free_batch_state->next) + screen->last_free_batch_state = screen->last_free_batch_state->next; + simple_mtx_unlock(&screen->free_batch_states_lock); for (unsigned i = 0; i < 2; i++) { util_idalloc_fini(&ctx->di.bindless[i].tex_slots);