mediafoundation: in slice generation mode, send METransformNeedInput

once per frame.

Reviewed-by: Sil Vilerino <sivileri@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40099>
This commit is contained in:
Pohsiang (John) Hsu 2026-02-23 17:23:24 -08:00 committed by Marge Bot
parent 745f69aa1e
commit 1b1cde9d39

View file

@ -1958,6 +1958,7 @@ CDX12EncHMFT::xThreadProc( void *pCtx )
if( !pThis->m_bLowLatency && !pThis->m_bFlushing && !pThis->m_bDraining ) if( !pThis->m_bLowLatency && !pThis->m_bFlushing && !pThis->m_bDraining )
{ {
pThis->m_dwNeedInputCount++; pThis->m_dwNeedInputCount++;
HMFT_ETW_EVENT_INFO( "METransformNeedInput", pThis );
HRESULT hr = pThis->QueueEvent( METransformNeedInput, GUID_NULL, S_OK, nullptr ); HRESULT hr = pThis->QueueEvent( METransformNeedInput, GUID_NULL, S_OK, nullptr );
if( FAILED( hr ) ) if( FAILED( hr ) )
{ {
@ -2428,6 +2429,7 @@ CDX12EncHMFT::ProcessMessage( MFT_MESSAGE_TYPE eMessage, ULONG_PTR ulParam )
m_bStreaming = true; m_bStreaming = true;
m_bDraining = false; m_bDraining = false;
m_bFlushing = false; m_bFlushing = false;
HMFT_ETW_EVENT_INFO( "METransformNeedInput", this );
CHECKHR_GOTO( QueueEvent( METransformNeedInput, GUID_NULL, S_OK, nullptr ), done ); CHECKHR_GOTO( QueueEvent( METransformNeedInput, GUID_NULL, S_OK, nullptr ), done );
m_dwNeedInputCount++; m_dwNeedInputCount++;
break; break;
@ -2733,6 +2735,7 @@ CDX12EncHMFT::ProcessInput( DWORD dwInputStreamIndex, IMFSample *pSample, DWORD
if( queueSize < MFT_INPUT_QUEUE_DEPTH ) if( queueSize < MFT_INPUT_QUEUE_DEPTH )
{ {
m_dwNeedInputCount++; m_dwNeedInputCount++;
HMFT_ETW_EVENT_INFO( "METransformNeedInput", this );
hr = QueueEvent( METransformNeedInput, GUID_NULL, S_OK, nullptr ); hr = QueueEvent( METransformNeedInput, GUID_NULL, S_OK, nullptr );
if( FAILED( hr ) ) if( FAILED( hr ) )
{ {
@ -2797,16 +2800,32 @@ CDX12EncHMFT::ProcessOutput( DWORD dwFlags, DWORD cOutputBufferCount, MFT_OUTPUT
if( m_bLowLatency ) if( m_bLowLatency )
{ {
bool sendNeedInput = true;
// For low-latency, some callers (like RDP) require a ping-pong pattern of: // For low-latency, some callers (like RDP) require a ping-pong pattern of:
// - METransformNeedInput // - METransformNeedInput
// - METransformHaveOutput // - METransformHaveOutput
// So we want to say METransformNeedInput as part of ProcessOutput() // So we want to say METransformNeedInput as part of ProcessOutput()
m_dwNeedInputCount++; if( m_uiSliceGenerationMode )
hr = QueueEvent( METransformNeedInput, GUID_NULL, S_OK, nullptr );
if( FAILED( hr ) )
{ {
m_dwNeedInputCount--; UINT32 isLastSlice = FALSE;
goto done; if( SUCCEEDED( pOutputSamples[0].pSample->GetUINT32( MFSampleExtension_LastSlice, &isLastSlice ) ) )
{
if (!isLastSlice)
{
sendNeedInput = false;
}
}
}
if( sendNeedInput )
{
m_dwNeedInputCount++;
HMFT_ETW_EVENT_INFO( "METransformNeedInput", this );
hr = QueueEvent( METransformNeedInput, GUID_NULL, S_OK, nullptr );
if( FAILED( hr ) )
{
m_dwNeedInputCount--;
goto done;
}
} }
} }