d3d12: Notify contexts about deletion of bos
Reviewed-by: Bill Kristiansen <billkris@microsoft.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17688>
This commit is contained in:
parent
375e8b2f4b
commit
6a8070bcef
|
@ -216,6 +216,9 @@ d3d12_end_batch(struct d3d12_context *ctx, struct d3d12_batch *batch)
|
|||
screen->cmdqueue->ExecuteCommandLists(1, cmdlists);
|
||||
batch->fence = d3d12_create_fence(screen);
|
||||
|
||||
/* TODO clean up resource state based on destroyed resources */
|
||||
util_dynarray_clear(&ctx->recently_destroyed_bos);
|
||||
|
||||
mtx_unlock(&screen->submit_mutex);
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
*/
|
||||
|
||||
#include "d3d12_bufmgr.h"
|
||||
#include "d3d12_context.h"
|
||||
#include "d3d12_format.h"
|
||||
#include "d3d12_screen.h"
|
||||
|
||||
|
@ -182,6 +183,7 @@ d3d12_bo_wrap_buffer(struct d3d12_screen *screen, struct pb_buffer *buf)
|
|||
bo->buffer = buf;
|
||||
bo->trans_state = NULL; /* State from base BO will be used */
|
||||
bo->unique_id = p_atomic_inc_return(&screen->resource_id_generator);
|
||||
bo->residency_status = d3d12_evicted;
|
||||
|
||||
return bo;
|
||||
}
|
||||
|
@ -197,17 +199,25 @@ d3d12_bo_unreference(struct d3d12_bo *bo)
|
|||
if (pipe_reference_described(&bo->reference, NULL,
|
||||
(debug_reference_descriptor)
|
||||
d3d12_debug_describe_bo)) {
|
||||
if (bo->buffer) {
|
||||
if (bo->buffer)
|
||||
pb_reference(&bo->buffer, NULL);
|
||||
} else {
|
||||
mtx_lock(&bo->screen->submit_mutex);
|
||||
if (bo->residency_status != d3d12_evicted) {
|
||||
list_del(&bo->residency_list_entry);
|
||||
}
|
||||
mtx_unlock(&bo->screen->submit_mutex);
|
||||
|
||||
mtx_lock(&bo->screen->submit_mutex);
|
||||
|
||||
if (bo->residency_status != d3d12_evicted)
|
||||
list_del(&bo->residency_list_entry);
|
||||
|
||||
/* MSVC's offsetof fails when the name is ambiguous between struct and function */
|
||||
typedef struct d3d12_context d3d12_context_type;
|
||||
list_for_each_entry(d3d12_context_type, ctx, &bo->screen->context_list, context_list_entry)
|
||||
util_dynarray_append(&ctx->recently_destroyed_bos, uint64_t, bo->unique_id);
|
||||
|
||||
mtx_unlock(&bo->screen->submit_mutex);
|
||||
|
||||
if (bo->trans_state)
|
||||
delete bo->trans_state;
|
||||
if (bo->res)
|
||||
bo->res->Release();
|
||||
}
|
||||
FREE(bo);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -102,6 +102,7 @@ d3d12_context_destroy(struct pipe_context *pctx)
|
|||
d3d12_compute_transform_cache_destroy(ctx);
|
||||
pipe_resource_reference(&ctx->pstipple.texture, nullptr);
|
||||
pipe_sampler_view_reference(&ctx->pstipple.sampler_view, nullptr);
|
||||
util_dynarray_fini(&ctx->recently_destroyed_bos);
|
||||
FREE(ctx->pstipple.sampler_cso);
|
||||
|
||||
u_suballocator_destroy(&ctx->query_allocator);
|
||||
|
|
|
@ -179,6 +179,8 @@ struct d3d12_context {
|
|||
struct d3d12_batch batches[4];
|
||||
unsigned current_batch_idx;
|
||||
|
||||
struct util_dynarray recently_destroyed_bos;
|
||||
|
||||
struct pipe_constant_buffer cbufs[PIPE_SHADER_TYPES][PIPE_MAX_CONSTANT_BUFFERS];
|
||||
struct pipe_framebuffer_state fb;
|
||||
struct pipe_vertex_buffer vbs[PIPE_MAX_ATTRIBS];
|
||||
|
|
Loading…
Reference in New Issue