From d3f0733d1de1eaabbf534820fbe707e35b485aeb Mon Sep 17 00:00:00 2001 From: Sil Vilerino Date: Fri, 2 Sep 2022 10:42:14 -0400 Subject: [PATCH] d3d12: Avoid local allocations for D3D12_RESOURCE_BARRIER on hot paths Reviewed-by: Giancarlo Devich Part-of: --- src/gallium/drivers/d3d12/d3d12_video_dec.h | 1 + src/gallium/drivers/d3d12/d3d12_video_dec_h264.cpp | 8 +++----- src/gallium/drivers/d3d12/d3d12_video_dec_hevc.cpp | 8 +++----- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/gallium/drivers/d3d12/d3d12_video_dec.h b/src/gallium/drivers/d3d12/d3d12_video_dec.h index 9b592e0..7dc5a43 100644 --- a/src/gallium/drivers/d3d12/d3d12_video_dec.h +++ b/src/gallium/drivers/d3d12/d3d12_video_dec.h @@ -109,6 +109,7 @@ struct d3d12_video_decoder ComPtr m_spDecodeCommandList; std::vector m_transitionsBeforeCloseCmdList; + std::vector m_transitionsStorage; D3D12_VIDEO_DECODER_DESC m_decoderDesc = {}; D3D12_VIDEO_DECODER_HEAP_DESC m_decoderHeapDesc = {}; diff --git a/src/gallium/drivers/d3d12/d3d12_video_dec_h264.cpp b/src/gallium/drivers/d3d12/d3d12_video_dec_h264.cpp index 90e0faf..8a22f7d 100644 --- a/src/gallium/drivers/d3d12/d3d12_video_dec_h264.cpp +++ b/src/gallium/drivers/d3d12/d3d12_video_dec_h264.cpp @@ -113,16 +113,14 @@ d3d12_video_decoder_prepare_current_frame_references_h264(struct d3d12_video_dec // RefFrameList array of the associated picture parameters structure.For more information, see section 6.2. In // all cases, when Index7Bits does not contain a valid index, the value is 127. - std::vector - neededStateTransitions; // Returned by update_entries to perform by the method caller pD3D12Dec->m_spDPBManager->update_entries( d3d12_video_decoder_get_current_dxva_picparams(pD3D12Dec)->RefFrameList, - neededStateTransitions); + pD3D12Dec->m_transitionsStorage); - pD3D12Dec->m_spDecodeCommandList->ResourceBarrier(neededStateTransitions.size(), neededStateTransitions.data()); + pD3D12Dec->m_spDecodeCommandList->ResourceBarrier(pD3D12Dec->m_transitionsStorage.size(), pD3D12Dec->m_transitionsStorage.data()); // Schedule reverse (back to common) transitions before command list closes for current frame - for (auto BarrierDesc : neededStateTransitions) { + for (auto BarrierDesc : pD3D12Dec->m_transitionsStorage) { std::swap(BarrierDesc.Transition.StateBefore, BarrierDesc.Transition.StateAfter); pD3D12Dec->m_transitionsBeforeCloseCmdList.push_back(BarrierDesc); } diff --git a/src/gallium/drivers/d3d12/d3d12_video_dec_hevc.cpp b/src/gallium/drivers/d3d12/d3d12_video_dec_hevc.cpp index bfadd82..0cffcfc 100644 --- a/src/gallium/drivers/d3d12/d3d12_video_dec_hevc.cpp +++ b/src/gallium/drivers/d3d12/d3d12_video_dec_hevc.cpp @@ -105,16 +105,14 @@ d3d12_video_decoder_prepare_current_frame_references_hevc(struct d3d12_video_dec // When Index7Bits is used in the CurrPic and RefPicList members of the picture parameters structure, the value directly specifies the DXVA index of an uncompressed surface. // When Index7Bits is 127 (0x7F), this indicates that it does not contain a valid index. - std::vector - neededStateTransitions; // Returned by update_entries to perform by the method caller pD3D12Dec->m_spDPBManager->update_entries( d3d12_video_decoder_get_current_dxva_picparams(pD3D12Dec)->RefPicList, - neededStateTransitions); + pD3D12Dec->m_transitionsStorage); - pD3D12Dec->m_spDecodeCommandList->ResourceBarrier(neededStateTransitions.size(), neededStateTransitions.data()); + pD3D12Dec->m_spDecodeCommandList->ResourceBarrier(pD3D12Dec->m_transitionsStorage.size(), pD3D12Dec->m_transitionsStorage.data()); // Schedule reverse (back to common) transitions before command list closes for current frame - for (auto BarrierDesc : neededStateTransitions) { + for (auto BarrierDesc : pD3D12Dec->m_transitionsStorage) { std::swap(BarrierDesc.Transition.StateBefore, BarrierDesc.Transition.StateAfter); pD3D12Dec->m_transitionsBeforeCloseCmdList.push_back(BarrierDesc); } -- 2.7.4