mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-20 11:40:10 +01:00
mediafoundation: Remove redundant fence openings in ProcessInput
Reviewed-by: Pohsiang (John) Hsu <pohhsu@microsoft.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38750>
This commit is contained in:
parent
3917a5d12a
commit
9ce3dc81c8
1 changed files with 30 additions and 31 deletions
|
|
@ -1434,8 +1434,19 @@ CDX12EncHMFT::xThreadProc( void *pCtx )
|
||||||
HANDLE fence_handle = (HANDLE) pThis->m_pPipeContext->screen->fence_get_win32_handle( pThis->m_pPipeContext->screen,
|
HANDLE fence_handle = (HANDLE) pThis->m_pPipeContext->screen->fence_get_win32_handle( pThis->m_pPipeContext->screen,
|
||||||
pDX12EncodeContext->pAsyncFence,
|
pDX12EncodeContext->pAsyncFence,
|
||||||
&ResolveStatsCompletionFenceValue );
|
&ResolveStatsCompletionFenceValue );
|
||||||
if( fence_handle )
|
if (!fence_handle ||
|
||||||
CloseHandle( fence_handle );
|
FAILED(pThis->m_spDevice->OpenSharedHandle(fence_handle, IID_PPV_ARGS(pDX12EncodeContext->spAsyncFence.ReleaseAndGetAddressOf()))))
|
||||||
|
{
|
||||||
|
debug_printf( "[dx12 hmft 0x%p] Failed to open frame pAsyncFence\n", pThis );
|
||||||
|
MFE_ERROR( "[dx12 hmft 0x%p] Failed to open frame pAsyncFence", pThis );
|
||||||
|
assert( false );
|
||||||
|
pThis->QueueEvent( MEError, GUID_NULL, E_FAIL, nullptr );
|
||||||
|
bHasEncodingError = TRUE;
|
||||||
|
delete pDX12EncodeContext;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
CloseHandle( fence_handle );
|
||||||
|
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock( pThis->m_encoderLock );
|
std::lock_guard<std::mutex> lock( pThis->m_encoderLock );
|
||||||
|
|
@ -2511,16 +2522,6 @@ CDX12EncHMFT::ProcessInput( DWORD dwInputStreamIndex, IMFSample *pSample, DWORD
|
||||||
&pDX12EncodeContext->encoderPicInfo.base );
|
&pDX12EncodeContext->encoderPicInfo.base );
|
||||||
HMFT_ETW_EVENT_STOP( "PipeEndFrame", this );
|
HMFT_ETW_EVENT_STOP( "PipeEndFrame", this );
|
||||||
|
|
||||||
uint64_t AsyncFenceValue = 0;
|
|
||||||
HANDLE fence_handle = (HANDLE) m_pPipeContext->screen->fence_get_win32_handle( m_pPipeContext->screen,
|
|
||||||
pDX12EncodeContext->pAsyncFence,
|
|
||||||
&AsyncFenceValue );
|
|
||||||
CHECKNULL_GOTO( fence_handle, E_FAIL, done );
|
|
||||||
CHECKHR_GOTO(
|
|
||||||
m_spDevice->OpenSharedHandle( fence_handle, IID_PPV_ARGS( pDX12EncodeContext->spAsyncFence.ReleaseAndGetAddressOf() ) ),
|
|
||||||
done );
|
|
||||||
CloseHandle( fence_handle );
|
|
||||||
|
|
||||||
CHECKBOOL_GOTO( ( m_spDevice->GetDeviceRemovedReason() == S_OK ), DXGI_ERROR_DEVICE_REMOVED, done );
|
CHECKBOOL_GOTO( ( m_spDevice->GetDeviceRemovedReason() == S_OK ), DXGI_ERROR_DEVICE_REMOVED, done );
|
||||||
// NULL returned fence indicates encode error
|
// NULL returned fence indicates encode error
|
||||||
CHECKNULL_GOTO( pDX12EncodeContext->pAsyncFence, MF_E_UNEXPECTED, done );
|
CHECKNULL_GOTO( pDX12EncodeContext->pAsyncFence, MF_E_UNEXPECTED, done );
|
||||||
|
|
@ -2536,28 +2537,9 @@ CDX12EncHMFT::ProcessInput( DWORD dwInputStreamIndex, IMFSample *pSample, DWORD
|
||||||
{
|
{
|
||||||
HMFT_ETW_EVENT_START( "ReconstructedPictureSubmit", this );
|
HMFT_ETW_EVENT_START( "ReconstructedPictureSubmit", this );
|
||||||
|
|
||||||
// Get last slice completion fence
|
|
||||||
pipe_fence_handle *fence_to_wait = nullptr;
|
|
||||||
uint64_t fence_value = 0;
|
|
||||||
assert( m_ScreenInteropInfo.get_video_enc_last_slice_completion_fence );
|
|
||||||
|
|
||||||
m_ScreenInteropInfo.get_video_enc_last_slice_completion_fence( m_pPipeVideoCodec,
|
|
||||||
pDX12EncodeContext->pAsyncCookie,
|
|
||||||
&fence_to_wait );
|
|
||||||
|
|
||||||
if( fence_to_wait )
|
|
||||||
{
|
|
||||||
HANDLE fence_handle =
|
|
||||||
(HANDLE) m_pPipeContext->screen->fence_get_win32_handle( m_pPipeContext->screen, fence_to_wait, &fence_value );
|
|
||||||
if( fence_handle )
|
|
||||||
CloseHandle( fence_handle );
|
|
||||||
}
|
|
||||||
|
|
||||||
struct pipe_video_buffer *src_buffer = pDX12EncodeContext->get_current_dpb_pic_buffer();
|
struct pipe_video_buffer *src_buffer = pDX12EncodeContext->get_current_dpb_pic_buffer();
|
||||||
assert( src_buffer );
|
assert( src_buffer );
|
||||||
|
|
||||||
// TODO: Readonly flags for get handle
|
|
||||||
|
|
||||||
// We only support zero copy read only reconstructed picture in low latency mode
|
// We only support zero copy read only reconstructed picture in low latency mode
|
||||||
// and guarantee the src_buffer won't be modified until the next ProcessInput.
|
// and guarantee the src_buffer won't be modified until the next ProcessInput.
|
||||||
// While technically we could guarantee the recon pic buffer will not be reused/
|
// While technically we could guarantee the recon pic buffer will not be reused/
|
||||||
|
|
@ -2589,6 +2571,23 @@ CDX12EncHMFT::ProcessInput( DWORD dwInputStreamIndex, IMFSample *pSample, DWORD
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
// Get last slice completion fence
|
||||||
|
pipe_fence_handle *fence_to_wait = nullptr;
|
||||||
|
uint64_t fence_value = 0;
|
||||||
|
assert( m_ScreenInteropInfo.get_video_enc_last_slice_completion_fence );
|
||||||
|
|
||||||
|
m_ScreenInteropInfo.get_video_enc_last_slice_completion_fence( m_pPipeVideoCodec,
|
||||||
|
pDX12EncodeContext->pAsyncCookie,
|
||||||
|
&fence_to_wait );
|
||||||
|
|
||||||
|
if( fence_to_wait )
|
||||||
|
{
|
||||||
|
HANDLE fence_handle =
|
||||||
|
(HANDLE) m_pPipeContext->screen->fence_get_win32_handle( m_pPipeContext->screen, fence_to_wait, &fence_value );
|
||||||
|
if( fence_handle )
|
||||||
|
CloseHandle( fence_handle );
|
||||||
|
}
|
||||||
|
|
||||||
assert( m_pPipeVideoBlitter );
|
assert( m_pPipeVideoBlitter );
|
||||||
|
|
||||||
struct winsys_handle whandle = {};
|
struct winsys_handle whandle = {};
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue