d3d12: Cache ID3D12VideoDevice4 instance if supported

Reviewed-by: Pohsiang (John) Hsu <pohhsu@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37982>
This commit is contained in:
Silvio Vilerino
2025-10-18 09:45:36 -04:00
committed by Pohsiang (John) Hsu
parent 702e299f33
commit a51c3b5bd0
2 changed files with 9 additions and 4 deletions
@@ -971,9 +971,8 @@ d3d12_video_encoder_reconfigure_encoder_objects(struct d3d12_video_encoder *pD3D
}
HRESULT hr = S_OK;
ComPtr<ID3D12VideoDevice4> spVideoDevice4;
if (SUCCEEDED(pD3D12Enc->m_spD3D12VideoDevice->QueryInterface(
IID_PPV_ARGS(spVideoDevice4.GetAddressOf()))))
// Use cached ID3D12VideoDevice4 interface if available
if (pD3D12Enc->m_spD3D12VideoDevice4)
{
D3D12_VIDEO_ENCODER_HEAP_FLAGS heapFlags = D3D12_VIDEO_ENCODER_HEAP_FLAG_NONE;
if (pD3D12Enc->m_currentEncodeCapabilities.m_currentResolutionSupportCaps.DirtyRegions.DirtyRegionsSupportFlags) {
@@ -1018,7 +1017,7 @@ d3d12_video_encoder_reconfigure_encoder_objects(struct d3d12_video_encoder *pD3D
// Create encoder heap
pD3D12Enc->m_spVideoEncoderHeap.Reset();
ComPtr<ID3D12VideoEncoderHeap1> spVideoEncoderHeap1;
hr = spVideoDevice4->CreateVideoEncoderHeap1(&heapDesc1,
hr = pD3D12Enc->m_spD3D12VideoDevice4->CreateVideoEncoderHeap1(&heapDesc1,
IID_PPV_ARGS(spVideoEncoderHeap1.GetAddressOf()));
if (SUCCEEDED(hr))
{
@@ -2554,6 +2553,11 @@ d3d12_video_encoder_create_encoder(struct pipe_context *context, const struct pi
goto failed;
}
// Cache ID3D12VideoDevice4 interface
pD3D12Enc->m_spD3D12VideoDevice->QueryInterface(
IID_PPV_ARGS(pD3D12Enc->m_spD3D12VideoDevice4.GetAddressOf()));
// Note: m_spD3D12VideoDevice4 may be nullptr if the interface is not supported
pD3D12Enc->m_MaxOutputBitstreamSize = d3d12_video_encoder_calculate_max_output_compressed_bitstream_size(
codec->width,
codec->height,
@@ -587,6 +587,7 @@ struct d3d12_video_encoder
bool m_bPendingWorkNotFlushed = false;
ComPtr<ID3D12VideoDevice3> m_spD3D12VideoDevice;
ComPtr<ID3D12VideoDevice4> m_spD3D12VideoDevice4;
ComPtr<ID3D12VideoEncoder> m_spVideoEncoder;
ComPtr<ID3D12VideoEncoderHeap> m_spVideoEncoderHeap;
ComPtr<ID3D12CommandQueue> m_spEncodeCommandQueue;