d3d12: Assign up to 16 simultaneously active contexts unique IDs

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21528>
This commit is contained in:
Giancarlo Devich 2023-02-24 16:19:16 -08:00 committed by Marge Bot
parent bd0e1b3d02
commit 2c00c069fe
4 changed files with 18 additions and 0 deletions

View file

@ -69,6 +69,8 @@ d3d12_context_destroy(struct pipe_context *pctx)
struct d3d12_screen *screen = d3d12_screen(pctx->screen);
mtx_lock(&screen->submit_mutex);
list_del(&ctx->context_list_entry);
if (ctx->id != D3D12_CONTEXT_NO_ID)
screen->context_id_list[screen->context_id_count++] = ctx->id;
mtx_unlock(&screen->submit_mutex);
#ifdef _WIN32
@ -2589,6 +2591,10 @@ d3d12_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags)
mtx_lock(&screen->submit_mutex);
list_addtail(&ctx->context_list_entry, &screen->context_list);
if (screen->context_id_count > 0)
ctx->id = screen->context_id_list[--screen->context_id_count];
else
ctx->id = D3D12_CONTEXT_NO_ID;
mtx_unlock(&screen->submit_mutex);
if (flags & PIPE_CONTEXT_PREFER_THREADED)

View file

@ -158,8 +158,12 @@ struct dxil_validator;
class ResourceStateManager;
#endif
#define D3D12_CONTEXT_NO_ID 0xffffffff
struct d3d12_context {
struct pipe_context base;
unsigned id;
struct slab_child_pool transfer_pool;
struct slab_child_pool transfer_pool_unsync;
struct list_head context_list_entry;

View file

@ -1239,6 +1239,12 @@ d3d12_init_screen_base(struct d3d12_screen *screen, struct sw_winsys *winsys, LU
mtx_init(&screen->submit_mutex, mtx_plain);
list_inithead(&screen->context_list);
screen->context_id_count = 16;
// Fill the array backwards, because we'll pop off the back to assign ids
for (unsigned i = 0; i < 16; ++i)
screen->context_id_list[i] = 15 - i;
slab_create_parent(&screen->transfer_pool, sizeof(struct d3d12_transfer), 16);
screen->base.get_vendor = d3d12_get_vendor;

View file

@ -80,6 +80,8 @@ struct d3d12_screen {
uint64_t residency_fence_value;
struct list_head context_list;
unsigned context_id_list[16];
unsigned context_id_count;
struct slab_parent_pool transfer_pool;
struct pb_manager *bufmgr;