Fix various D3D12 video decode state issues (#4038)

* Fix D3D12 video decode reference resource states

Transition both NV12 planes of active DPB references to VIDEO_DECODE_READ before DecodeFrame and restore their states afterward.
Exclude unused reference slots while preserving DXVA picture indices and use the actual DPB slot count.

* Fix D3D12 scratch descriptor heap lifetime during growth

Defer replaced heap destruction until the command-list fence completes.
Allow the deferred-release queue to retain IUnknown objects so descriptor
heaps can use the same retirement mechanism as resources.

Fixes OBJECT_DELETED_WHILE_STILL_IN_USE (#921) when draw-load growth
replaces a heap referenced by pending native video conversion commands.
This commit is contained in:
Julian Xhokaxhiu
2026-10-11 20:19:48 -07:00
committed by GitHub
parent 671f00991a
commit 61dda020c6
3 changed files with 47 additions and 8 deletions
+7 -2
View File
@@ -4739,7 +4739,12 @@ namespace bgfx { namespace d3d12
, (void**)&heap
) );
DX_RELEASE(m_heap, 0);
if (NULL != m_heap)
{
BX_TRACE("D3D12 scratch heap grow: retired=%p size=%u replacement=%p size=%u queue=%u"
, m_heap, m_size, heap, _num, s_renderD3D12->m_cmd.m_control.m_current);
s_renderD3D12->m_cmd.release(m_heap);
}
m_heap = heap;
m_size = _num;
m_cpuHandleStart = getCPUHandleHeapStart(m_heap);
@@ -5564,7 +5569,7 @@ namespace bgfx { namespace d3d12
return false;
}
void CommandQueueD3D12::release(ID3D12Resource* _ptr)
void CommandQueueD3D12::release(IUnknown* _ptr)
{
m_release[m_control.m_current].push_back(_ptr);
}