d3d12: Add a list of contexts alive for the current screen

When a resource is destroyed, we'll need to let the contexts know.
This is guarded by the submit mutex, because we'll already be holding
that for at least one place where we want to iterate this list, and
it's low-frequency enough that re-using it is simpler than adding more
locks and creating confusing lock ordering.

Reviewed-by: Bill Kristiansen <billkris@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17688>
This commit is contained in:
Jesse Natalie 2022-07-19 15:07:42 -07:00 committed by Marge Bot
parent 17c3f4f3e1
commit b72ec453bd
4 changed files with 14 additions and 0 deletions

View file

@ -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,

View file

@ -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;

View file

@ -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;

View file

@ -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;