d3d12: Check queues are registered before unregistering in unregister_work_queue

Reviewed-by: Pohsiang (John) Hsu <pohhsu@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40860>
This commit is contained in:
Silvio Vilerino 2026-04-07 12:06:05 -04:00 committed by Pohsiang (John) Hsu
parent 1f0370616a
commit 6d1b209d0c

View file

@ -292,13 +292,17 @@ d3d12_video_encoder_destroy(struct pipe_video_codec *codec)
struct d3d12_context* ctx = d3d12_context(pD3D12Enc->base.context);
if (ctx->priority_manager)
{
if (ctx->priority_manager->unregister_work_queue(ctx->priority_manager, pD3D12Enc->m_spEncodeCommandQueue.Get()) != 0)
// Command queues may be NULL when destroy is called from a failed creation path before initialization reached
// the point of registering the command queues, so check for nullptr before trying to unregister from priority manager
if (pD3D12Enc->m_spEncodeCommandQueue &&
ctx->priority_manager->unregister_work_queue(ctx->priority_manager, pD3D12Enc->m_spEncodeCommandQueue.Get()) != 0)
{
debug_printf("D3D12: Failed to unregister command queue with frontend priority manager\n");
assert(false);
}
if (ctx->priority_manager->unregister_work_queue(ctx->priority_manager, pD3D12Enc->m_spResolveCommandQueue.Get()) != 0)
if (pD3D12Enc->m_spResolveCommandQueue &&
ctx->priority_manager->unregister_work_queue(ctx->priority_manager, pD3D12Enc->m_spResolveCommandQueue.Get()) != 0)
{
debug_printf("D3D12: Failed to unregister command queue with frontend priority manager\n");
assert(false);