diff --git a/src/gallium/drivers/d3d12/d3d12_context.cpp b/src/gallium/drivers/d3d12/d3d12_context.cpp index d60c44d5475..78fc5ef0c21 100644 --- a/src/gallium/drivers/d3d12/d3d12_context.cpp +++ b/src/gallium/drivers/d3d12/d3d12_context.cpp @@ -71,6 +71,11 @@ d3d12_context_destroy(struct pipe_context *pctx) { struct d3d12_context *ctx = d3d12_context(pctx); + struct d3d12_screen *screen = d3d12_screen(pctx->screen); + mtx_lock(&screen->submit_mutex); + list_del(&ctx->context_list_entry); + mtx_unlock(&screen->submit_mutex); + #ifdef _WIN32 if (ctx->dxil_validator) dxil_destroy_validator(ctx->dxil_validator); @@ -2631,6 +2636,10 @@ d3d12_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags) return NULL; } + mtx_lock(&screen->submit_mutex); + list_addtail(&ctx->context_list_entry, &screen->context_list); + mtx_unlock(&screen->submit_mutex); + if (flags & PIPE_CONTEXT_PREFER_THREADED) return threaded_context_create(&ctx->base, &screen->transfer_pool, diff --git a/src/gallium/drivers/d3d12/d3d12_context.h b/src/gallium/drivers/d3d12/d3d12_context.h index c76999191bb..3c366f9d16d 100644 --- a/src/gallium/drivers/d3d12/d3d12_context.h +++ b/src/gallium/drivers/d3d12/d3d12_context.h @@ -162,6 +162,7 @@ struct d3d12_context { struct pipe_context base; struct slab_child_pool transfer_pool; struct slab_child_pool transfer_pool_unsync; + struct list_head context_list_entry; struct threaded_context *threaded_context; struct primconvert_context *primconvert; struct blitter_context *blitter; diff --git a/src/gallium/drivers/d3d12/d3d12_screen.cpp b/src/gallium/drivers/d3d12/d3d12_screen.cpp index 11dc0c35b2d..3306610307c 100644 --- a/src/gallium/drivers/d3d12/d3d12_screen.cpp +++ b/src/gallium/drivers/d3d12/d3d12_screen.cpp @@ -1149,6 +1149,8 @@ d3d12_init_screen_base(struct d3d12_screen *screen, struct sw_winsys *winsys, LU mtx_init(&screen->descriptor_pool_mutex, mtx_plain); mtx_init(&screen->submit_mutex, mtx_plain); + list_inithead(&screen->context_list); + screen->base.get_vendor = d3d12_get_vendor; screen->base.get_device_vendor = d3d12_get_device_vendor; screen->base.get_param = d3d12_get_param; diff --git a/src/gallium/drivers/d3d12/d3d12_screen.h b/src/gallium/drivers/d3d12/d3d12_screen.h index 500dc08d4c0..54cb32d07a9 100644 --- a/src/gallium/drivers/d3d12/d3d12_screen.h +++ b/src/gallium/drivers/d3d12/d3d12_screen.h @@ -77,6 +77,8 @@ struct d3d12_screen { ID3D12Fence *residency_fence; uint64_t residency_fence_value; + struct list_head context_list; + struct slab_parent_pool transfer_pool; struct pb_manager *bufmgr; struct pb_manager *cache_bufmgr;