d3d12: d3d12_video_proc - Use async residency functions

Reviewed-by: Pohsiang (John) Hsu <pohhsu@microsoft.com>
Reviewed-by: Yubo Xie <yuboxie@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38144>
This commit is contained in:
Silvio Vilerino 2025-10-25 10:56:19 -04:00 committed by Marge Bot
parent 5009fe8fd0
commit a22334e632
2 changed files with 18 additions and 2 deletions

View file

@ -339,14 +339,14 @@ d3d12_video_processor_flush(struct pipe_video_codec * codec)
pD3D12Proc->m_OutputArguments.buffer->texture);
// Make the resources permanently resident for video use
d3d12_promote_to_permanent_residency(pD3D12Proc->m_pD3D12Screen, &pD3D12Proc->m_OutputArguments.buffer->texture, 1);
d3d12_promote_to_permanent_residency(pD3D12Proc->m_pD3D12Screen, &pD3D12Proc->m_OutputArguments.buffer->texture, 1, pD3D12Proc->m_spResidencyFence.Get(), &pD3D12Proc->m_ResidencyFenceValue);
for(auto curInput : pD3D12Proc->m_InputBuffers)
{
debug_printf("[d3d12_video_processor] d3d12_video_processor_flush - Promoting the input texture %p to d3d12_permanently_resident.\n",
curInput->texture);
// Make the resources permanently resident for video use
d3d12_promote_to_permanent_residency(pD3D12Proc->m_pD3D12Screen, &curInput->texture, 1);
d3d12_promote_to_permanent_residency(pD3D12Proc->m_pD3D12Screen, &curInput->texture, 1, pD3D12Proc->m_spResidencyFence.Get(), &pD3D12Proc->m_ResidencyFenceValue);
}
HRESULT hr = pD3D12Proc->m_pD3D12Screen->dev->GetDeviceRemovedReason();
@ -384,6 +384,9 @@ d3d12_video_processor_flush(struct pipe_video_codec * codec)
if (input_surface_fence)
d3d12_fence_wait_impl(input_surface_fence, pD3D12Proc->m_spCommandQueue.Get(), pD3D12Proc->input_surface_fence_value);
// Wait on residency fence for this frame to ensure all resources used in video processing are resident
pD3D12Proc->m_spCommandQueue->Wait(pD3D12Proc->m_spResidencyFence.Get(), pD3D12Proc->m_ResidencyFenceValue);
ID3D12CommandList *ppCommandLists[1] = { pD3D12Proc->m_spCommandList.Get() };
pD3D12Proc->m_spCommandQueue->ExecuteCommandLists(1, ppCommandLists);
pD3D12Proc->m_spCommandQueue->Signal(pD3D12Proc->m_spFence.Get(), pD3D12Proc->m_fenceValue);
@ -698,6 +701,17 @@ d3d12_video_processor_create_command_objects(struct d3d12_video_processor *pD3D1
return false;
}
hr = pD3D12Proc->m_pD3D12Screen->dev->CreateFence(0,
D3D12_FENCE_FLAG_SHARED,
IID_PPV_ARGS(&pD3D12Proc->m_spResidencyFence));
if (FAILED(hr)) {
debug_printf(
"[d3d12_video_processor] d3d12_video_processor_create_command_objects - Call to CreateResidencyFence failed with HR %x\n",
(unsigned)hr);
return false;
}
pD3D12Proc->m_spCommandAllocators.resize(D3D12_VIDEO_PROC_ASYNC_DEPTH);
for (uint32_t i = 0; i < pD3D12Proc->m_spCommandAllocators.size() ; i++) {
hr = pD3D12Proc->m_pD3D12Screen->dev->CreateCommandAllocator(

View file

@ -100,7 +100,9 @@ struct d3d12_video_processor
const uint m_NodeIndex = 0u;
ComPtr<ID3D12Fence> m_spFence;
ComPtr<ID3D12Fence> m_spResidencyFence;
uint m_fenceValue = 1u;
uint64_t m_ResidencyFenceValue = 0u;
ComPtr<ID3D12VideoDevice> m_spD3D12VideoDevice;