mediafoundation: Use d3d12 extension set_video_encoder_max_async_queue_depth to save memory in low latency (no async/in flight frames)

Reviewed-by: Pohsiang (John) Hsu <pohhsu@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37565>
This commit is contained in:
Silvio Vilerino
2025-09-24 16:27:09 -04:00
committed by Marge Bot
parent d7c4131963
commit d4f44edbff

View File

@@ -542,6 +542,20 @@ CDX12EncHMFT::OnOutputTypeChanged()
{
CleanupEncoder();
}
if( m_gpuFeatureFlags.m_bDisableAsync )
{
MFE_INFO( "[dx12 hmft 0x%p] Async is disabled due to lack of GPU support.", this );
m_bLowLatency = TRUE;
}
else
{
if( SUCCEEDED( m_spMFAttributes->GetUINT32( MF_LOW_LATENCY, &uiLowLatency ) ) )
{
m_bLowLatency = ( uiLowLatency == 0 ? FALSE : TRUE );
}
}
CHECKHR_GOTO( InitializeEncoder( m_outputPipeProfile, m_uiOutputWidth, m_uiOutputHeight ), done );
if( bResolutionChange )
@@ -557,19 +571,6 @@ CDX12EncHMFT::OnOutputTypeChanged()
m_bUseBitsusedMapAllocator );
}
if( m_gpuFeatureFlags.m_bDisableAsync )
{
MFE_INFO( "[dx12 hmft 0x%p] Async is disabled due to lack of GPU support.", this );
m_bLowLatency = TRUE;
}
else
{
if( SUCCEEDED( m_spMFAttributes->GetUINT32( MF_LOW_LATENCY, &uiLowLatency ) ) )
{
m_bLowLatency = ( uiLowLatency == 0 ? FALSE : TRUE );
}
}
// Indicate that we'll be adding MF_NALU_LENGTH_INFORMATION on each output sample that comes
// MFSampleExtension_NALULengthInfo is equivalent to MF_NALU_LENGTH_INFORMATION
(void) m_spOutputType->SetUINT32( MF_NALU_LENGTH_SET, 1 );
@@ -942,6 +943,15 @@ CDX12EncHMFT::InitializeEncoder( pipe_video_profile videoProfile, UINT32 Width,
}
}
#if ( USE_D3D12_PREVIEW_HEADERS && ( D3D12_PREVIEW_SDK_VERSION >= 717 ) )
struct d3d12_interop_device_info1 screen_interop_info = {};
if ((m_pPipeContext->screen->interop_query_device_info(m_pPipeContext->screen, sizeof(d3d12_interop_device_info1), &screen_interop_info) != 0) &&
(screen_interop_info.set_video_encoder_max_async_queue_depth != nullptr))
{
screen_interop_info.set_video_encoder_max_async_queue_depth(m_pPipeContext, (m_bLowLatency ? 1 : MFT_INPUT_QUEUE_DEPTH));
}
#endif // ( USE_D3D12_PREVIEW_HEADERS && ( D3D12_PREVIEW_SDK_VERSION >= 717 ) )
CHECKNULL_GOTO( m_pPipeVideoCodec = m_pPipeContext->create_video_codec( m_pPipeContext, &encoderSettings ),
MF_E_UNEXPECTED,
done );