Commit 59e8624f authored by Mike Blumenkrantz's avatar Mike Blumenkrantz 🏋
Browse files

zink: enforce context-unsetting for surfaces on context destroy

surfaces can be shared between contexts in various ways, so zink needs to
ensure that any time a context (or even the threaded context) is destroyed,
the surface->context pointer is replaced with a non-dead one so that things won't
explode later on

fixes some obscure renderdoc test case
parent b93798bc
Pipeline #310936 waiting for manual action with stages
in 24 seconds
......@@ -139,6 +139,18 @@ zink_context_destroy(struct pipe_context *pctx)
/* TODO: if/when pipe_surface stops being context-based, delete all this */
_mesa_set_remove_key(&screen->contexts, ctx);
if (p_atomic_dec_return(&screen->base.num_contexts) > 0) {
/* if multiple contexts, replace surface->context pointers with valid ones */
struct set_entry *he = _mesa_set_random_entry(&screen->contexts, NULL);
struct pipe_context *replacement = he ? (struct pipe_context*)he->key : NULL;
hash_table_foreach(&screen->surface_cache, entry) {
struct zink_surface *surface = entry->data;
if (surface->base.context == pctx || surface->base.context == &ctx->tc->base)
surface->base.context = replacement;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment