diff --git a/src/gallium/frontends/mediafoundation/codecapi.cpp b/src/gallium/frontends/mediafoundation/codecapi.cpp index ffeec3985bb..37058aea16e 100644 --- a/src/gallium/frontends/mediafoundation/codecapi.cpp +++ b/src/gallium/frontends/mediafoundation/codecapi.cpp @@ -422,16 +422,14 @@ CDX12EncHMFT::IsSupported( const GUID *Api ) } } -#if ( USE_D3D12_PREVIEW_HEADERS && ( D3D12_PREVIEW_SDK_VERSION >= 717 ) ) - if( (*Api == CODECAPI_AVEncWorkGlobalPriority) || (*Api == CODECAPI_AVEncWorkProcessPriority) ) + if( (*Api == CODECAPI_AVEncWorkGlobalPriority) || (*Api == CODECAPI_AVEncWorkProcessPriority) ) + { + if(m_EncoderCapabilities.m_bHWSupportsQueuePriorityManagement) { - if(m_EncoderCapabilities.m_bHWSupportsQueuePriorityManagement) - { - hr = S_OK; - return hr; - } + hr = S_OK; + return hr; } -#endif // ( USE_D3D12_PREVIEW_HEADERS && ( D3D12_PREVIEW_SDK_VERSION >= 717 ) ) + } if( m_EncoderCapabilities.m_TwoPassSupport.bits.supports_1pass_recon_writing_skip ) { @@ -931,7 +929,6 @@ CDX12EncHMFT::GetValue( const GUID *Api, VARIANT *Value ) Value->vt = VT_BOOL; Value->boolVal = m_bRateControlFramePreAnalysisExternalReconDownscale ? VARIANT_TRUE : VARIANT_FALSE; } -#if ( USE_D3D12_PREVIEW_HEADERS && ( D3D12_PREVIEW_SDK_VERSION >= 717 ) ) else if( *Api == CODECAPI_AVEncWorkGlobalPriority ) { Value->vt = VT_UI4; @@ -942,7 +939,6 @@ CDX12EncHMFT::GetValue( const GUID *Api, VARIANT *Value ) Value->vt = VT_UI4; Value->ulVal = (UINT32) m_WorkProcessPriority; } -#endif // ( USE_D3D12_PREVIEW_HEADERS && ( D3D12_PREVIEW_SDK_VERSION >= 717 ) ) else if( *Api == CODECAPI_AVEncVideoInputDeltaQPBlockSettings ) { InputQPSettings hevcDeltaQPSettings; @@ -1659,10 +1655,8 @@ CDX12EncHMFT::SetValue( const GUID *Api, VARIANT *Value ) { CHECKHR_GOTO( E_INVALIDARG, done ); } -#if ( USE_D3D12_PREVIEW_HEADERS && ( D3D12_PREVIEW_SDK_VERSION >= 717 ) ) m_WorkProcessPriority = (D3D12_COMMAND_QUEUE_PROCESS_PRIORITY) (Value->ulVal);; m_bWorkProcessPrioritySet = TRUE; -#endif // ( USE_D3D12_PREVIEW_HEADERS && ( D3D12_PREVIEW_SDK_VERSION >= 717 ) ) } else if( *Api == CODECAPI_AVEncWorkGlobalPriority ) { @@ -1676,10 +1670,8 @@ CDX12EncHMFT::SetValue( const GUID *Api, VARIANT *Value ) { CHECKHR_GOTO( E_INVALIDARG, done ); } -#if ( USE_D3D12_PREVIEW_HEADERS && ( D3D12_PREVIEW_SDK_VERSION >= 717 ) ) m_WorkGlobalPriority = (D3D12_COMMAND_QUEUE_GLOBAL_PRIORITY) Value->ulVal; m_bWorkGlobalPrioritySet = TRUE; -#endif // ( USE_D3D12_PREVIEW_HEADERS && ( D3D12_PREVIEW_SDK_VERSION >= 717 ) ) } else if( *Api == CODECAPI_AVEncVideoOutputQPMapBlockSize ) { diff --git a/src/gallium/frontends/mediafoundation/context.h b/src/gallium/frontends/mediafoundation/context.h index ec2a9ace907..36789547a48 100644 --- a/src/gallium/frontends/mediafoundation/context.h +++ b/src/gallium/frontends/mediafoundation/context.h @@ -38,10 +38,8 @@ typedef class DX12EncodeContext struct pipe_fence_handle *pAsyncFence = NULL; std::vector pOutputBitRes; std::vector pSliceFences; -#if ( USE_D3D12_PREVIEW_HEADERS && ( D3D12_PREVIEW_SDK_VERSION >= 717 ) ) D3D12_VIDEO_ENCODER_COMPRESSED_BITSTREAM_NOTIFICATION_MODE sliceNotificationMode = D3D12_VIDEO_ENCODER_COMPRESSED_BITSTREAM_NOTIFICATION_MODE_FULL_FRAME; -#endif // (USE_D3D12_PREVIEW_HEADERS && (D3D12_PREVIEW_SDK_VERSION >= 717)) pipe_resource *pPipeResourceQPMapStats = nullptr; pipe_resource *pPipeResourceSATDMapStats = nullptr; pipe_resource *pPipeResourceRCBitAllocMapStats = nullptr; diff --git a/src/gallium/frontends/mediafoundation/encode.cpp b/src/gallium/frontends/mediafoundation/encode.cpp index 335dbcd3a66..66a51995f3c 100644 --- a/src/gallium/frontends/mediafoundation/encode.cpp +++ b/src/gallium/frontends/mediafoundation/encode.cpp @@ -477,8 +477,6 @@ CDX12EncHMFT::PrepareForEncode( IMFSample *pSample, LPDX12EncodeContext *ppDX12E pDX12EncodeContext->pVlScreen = m_pVlScreen; // weakref -#if ( USE_D3D12_PREVIEW_HEADERS && ( D3D12_PREVIEW_SDK_VERSION >= 717 ) ) - // // Update the encoder priorities (if any set) // @@ -509,8 +507,6 @@ CDX12EncHMFT::PrepareForEncode( IMFSample *pSample, LPDX12EncodeContext *ppDX12E m_bWorkGlobalPrioritySet = FALSE; } -#endif // ( USE_D3D12_PREVIEW_HEADERS && ( D3D12_PREVIEW_SDK_VERSION >= 717 ) ) - // Call the helper for encoder specific work pDX12EncodeContext->encoderPicInfo.base.in_fence = pPipeEncoderInputFenceHandle; pDX12EncodeContext->encoderPicInfo.base.in_fence_value = pipeEncoderInputFenceHandleValue; @@ -534,7 +530,6 @@ CDX12EncHMFT::PrepareForEncode( IMFSample *pSample, LPDX12EncodeContext *ppDX12E std::max( 1u, pDX12EncodeContext->encoderPicInfo.av1enc.tile_rows * pDX12EncodeContext->encoderPicInfo.av1enc.tile_cols ); #endif -#if ( USE_D3D12_PREVIEW_HEADERS && ( D3D12_PREVIEW_SDK_VERSION >= 717 ) ) pDX12EncodeContext->sliceNotificationMode = D3D12_VIDEO_ENCODER_COMPRESSED_BITSTREAM_NOTIFICATION_MODE_FULL_FRAME; if( m_EncoderCapabilities.m_HWSupportSlicedFences.bits.supported && ( num_output_buffers > 1 ) ) { @@ -551,7 +546,6 @@ CDX12EncHMFT::PrepareForEncode( IMFSample *pSample, LPDX12EncodeContext *ppDX12E } } else -#endif // (USE_D3D12_PREVIEW_HEADERS && (D3D12_PREVIEW_SDK_VERSION >= 717)) { // Buffer byte size for full frame bitstream (when num_output_buffers == 1) templ.width0 = m_uiMaxOutputBitstreamSize; diff --git a/src/gallium/frontends/mediafoundation/encoder_capabilities.cpp b/src/gallium/frontends/mediafoundation/encoder_capabilities.cpp index acd9dea2138..67c0643269b 100644 --- a/src/gallium/frontends/mediafoundation/encoder_capabilities.cpp +++ b/src/gallium/frontends/mediafoundation/encoder_capabilities.cpp @@ -158,9 +158,7 @@ encoder_capabilities::initialize( pipe_screen *pScreen, pipe_video_profile video m_PSNRStatsSupport.value = pScreen->get_video_param( pScreen, videoProfile, PIPE_VIDEO_ENTRYPOINT_ENCODE, PIPE_VIDEO_CAP_ENC_GPU_STATS_PSNR ); -#if ( USE_D3D12_PREVIEW_HEADERS && ( D3D12_PREVIEW_SDK_VERSION >= 717 ) ) d3d12_interop_device_info1 screen_interop_info = {}; bool successQuery = pScreen->interop_query_device_info(pScreen, sizeof(d3d12_interop_device_info1), &screen_interop_info) != 0; m_bHWSupportsQueuePriorityManagement = successQuery && screen_interop_info.set_context_queue_priority_manager != NULL; -#endif // ( USE_D3D12_PREVIEW_HEADERS && ( D3D12_PREVIEW_SDK_VERSION >= 717 ) ) } diff --git a/src/gallium/frontends/mediafoundation/hmft_entrypoints.h b/src/gallium/frontends/mediafoundation/hmft_entrypoints.h index 19e29f11e3f..eaa64e9e2d9 100644 --- a/src/gallium/frontends/mediafoundation/hmft_entrypoints.h +++ b/src/gallium/frontends/mediafoundation/hmft_entrypoints.h @@ -742,12 +742,10 @@ class __declspec( uuid( HMFT_GUID ) ) CDX12EncHMFT : CMFD3DManager, BOOL m_bRateControlFramePreAnalysis = FALSE; BOOL m_bRateControlFramePreAnalysisExternalReconDownscale = FALSE; -#if ( USE_D3D12_PREVIEW_HEADERS && ( D3D12_PREVIEW_SDK_VERSION >= 717 ) ) D3D12_COMMAND_QUEUE_PROCESS_PRIORITY m_WorkProcessPriority = {}; BOOL m_bWorkProcessPrioritySet = FALSE; D3D12_COMMAND_QUEUE_GLOBAL_PRIORITY m_WorkGlobalPriority = {}; BOOL m_bWorkGlobalPrioritySet = FALSE; -#endif // ( USE_D3D12_PREVIEW_HEADERS && ( D3D12_PREVIEW_SDK_VERSION >= 717 ) ) UINT m_uiMaxOutputBitstreamSize = 0u; struct pipe_video_codec *m_pPipeVideoCodec = nullptr; diff --git a/src/gallium/frontends/mediafoundation/mfd3dmanager.cpp b/src/gallium/frontends/mediafoundation/mfd3dmanager.cpp index 16542b09a6b..acbc351f943 100644 --- a/src/gallium/frontends/mediafoundation/mfd3dmanager.cpp +++ b/src/gallium/frontends/mediafoundation/mfd3dmanager.cpp @@ -116,13 +116,11 @@ CMFD3DManager::Shutdown( bool bReleaseDeviceManager ) m_pWinsys->destroy( this->m_pWinsys ); m_pWinsys = nullptr; } -#if ( USE_D3D12_PREVIEW_HEADERS && ( D3D12_PREVIEW_SDK_VERSION >= 717 ) ) if(m_ContextPriorityMgr.base.register_work_queue) { mtx_destroy(&m_ContextPriorityMgr.m_lock); m_ContextPriorityMgr.base.register_work_queue = nullptr; } -#endif // ( USE_D3D12_PREVIEW_HEADERS && ( D3D12_PREVIEW_SDK_VERSION >= 717 ) ) return hr; } @@ -267,8 +265,6 @@ CMFD3DManager::UpdateGPUFeatureFlags() */ } -#if ( USE_D3D12_PREVIEW_HEADERS && ( D3D12_PREVIEW_SDK_VERSION >= 717 ) ) - int MFTRegisterWorkQueue(struct d3d12_context_queue_priority_manager* manager, ID3D12CommandQueue* queue) { mft_context_queue_priority_manager* mft_mgr = (mft_context_queue_priority_manager*) manager; @@ -320,17 +316,13 @@ int MFTUnregisterWorkQueue(struct d3d12_context_queue_priority_manager* manager, return 0; } -#endif // ( USE_D3D12_PREVIEW_HEADERS && ( D3D12_PREVIEW_SDK_VERSION >= 717 ) ) - HRESULT CMFD3DManager::xOnSetD3DManager( ULONG_PTR ulParam ) { HRESULT hr = S_OK; Shutdown(); -#if ( USE_D3D12_PREVIEW_HEADERS && ( D3D12_PREVIEW_SDK_VERSION >= 717 ) ) d3d12_interop_device_info1 screen_interop_info = {}; -#endif // ( USE_D3D12_PREVIEW_HEADERS && ( D3D12_PREVIEW_SDK_VERSION >= 717 ) ) if( ulParam == 0 ) { @@ -352,7 +344,6 @@ CMFD3DManager::xOnSetD3DManager( ULONG_PTR ulParam ) MF_E_DXGI_DEVICE_NOT_INITIALIZED, done ); -#if ( USE_D3D12_PREVIEW_HEADERS && ( D3D12_PREVIEW_SDK_VERSION >= 717 ) ) if ((m_pVlScreen->pscreen->interop_query_device_info(m_pVlScreen->pscreen, sizeof(d3d12_interop_device_info1), &screen_interop_info) != 0) && (screen_interop_info.set_context_queue_priority_manager != NULL)) { @@ -380,7 +371,7 @@ CMFD3DManager::xOnSetD3DManager( ULONG_PTR ulParam ) MF_E_DXGI_DEVICE_NOT_INITIALIZED, done ); } -#endif // ( USE_D3D12_PREVIEW_HEADERS && ( D3D12_PREVIEW_SDK_VERSION >= 717 ) ) + CHECKHR_GOTO( MFCreateVideoSampleAllocatorEx( IID_PPV_ARGS( &m_spVideoSampleAllocator ) ), done ); CHECKHR_GOTO( MFCreateVideoSampleAllocatorEx( IID_PPV_ARGS( &m_spSATDMapAllocator ) ), done ); CHECKHR_GOTO( MFCreateVideoSampleAllocatorEx( IID_PPV_ARGS( &m_spBitsusedMapAllocator ) ), done ); diff --git a/src/gallium/frontends/mediafoundation/mfd3dmanager.h b/src/gallium/frontends/mediafoundation/mfd3dmanager.h index 819acc1b555..0892f3c5847 100644 --- a/src/gallium/frontends/mediafoundation/mfd3dmanager.h +++ b/src/gallium/frontends/mediafoundation/mfd3dmanager.h @@ -68,14 +68,12 @@ typedef union uint64_t version; // bits field } MFAdapterDriverVersion; -#if ( USE_D3D12_PREVIEW_HEADERS && ( D3D12_PREVIEW_SDK_VERSION >= 717 ) ) struct mft_context_queue_priority_manager { struct d3d12_context_queue_priority_manager base; std::vector m_registeredQueues; mtx_t m_lock; }; -#endif // ( USE_D3D12_PREVIEW_HEADERS && ( D3D12_PREVIEW_SDK_VERSION >= 717 ) ) class CMFD3DManager { @@ -110,9 +108,7 @@ class CMFD3DManager struct sw_winsys *m_pWinsys = nullptr; struct pipe_context *m_pPipeContext = nullptr; -#if ( USE_D3D12_PREVIEW_HEADERS && ( D3D12_PREVIEW_SDK_VERSION >= 717 ) ) struct mft_context_queue_priority_manager m_ContextPriorityMgr = {}; -#endif // ( USE_D3D12_PREVIEW_HEADERS && ( D3D12_PREVIEW_SDK_VERSION >= 717 ) ) uint32_t m_deviceVendorId {}; uint32_t m_deviceDeviceId {}; diff --git a/src/gallium/frontends/mediafoundation/mftransform.cpp b/src/gallium/frontends/mediafoundation/mftransform.cpp index 2259fecda6e..7c6cae95c17 100644 --- a/src/gallium/frontends/mediafoundation/mftransform.cpp +++ b/src/gallium/frontends/mediafoundation/mftransform.cpp @@ -943,14 +943,12 @@ 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, @@ -1184,7 +1182,6 @@ CDX12EncHMFT::xThreadProc( void *pCtx ) metadata.encode_result = PIPE_VIDEO_FEEDBACK_METADATA_ENCODE_FLAG_FAILED; // default to failure -#if ( USE_D3D12_PREVIEW_HEADERS && ( D3D12_PREVIEW_SDK_VERSION >= 717 ) ) // If sliced fences supported, we asynchronously copy here every slice as it is ready // Otherwise, let's copy all the sliced together here after full frame completion (see below) if( pDX12EncodeContext->sliceNotificationMode == D3D12_VIDEO_ENCODER_COMPRESSED_BITSTREAM_NOTIFICATION_MODE_SUBREGIONS ) @@ -1269,7 +1266,6 @@ CDX12EncHMFT::xThreadProc( void *pCtx ) spMemoryBuffer->SetCurrentLength( static_cast( output_buffer_offset ) ); spOutputSample->AddBuffer( spMemoryBuffer.Get() ); } -#endif // (USE_D3D12_PREVIEW_HEADERS && (D3D12_PREVIEW_SDK_VERSION >= 717)) // Still wait for pAsyncFence (full frame fence) before calling get_feedback for full frame stats // First wait on the D3D12 encoder_fence @@ -1506,10 +1502,8 @@ CDX12EncHMFT::xThreadProc( void *pCtx ) // If sliced fences supported, we asynchronously copied every slice as it was ready (see above) // into spMemoryBuffer. Otherwise, let's copy all the sliced together here after full frame completion -#if ( USE_D3D12_PREVIEW_HEADERS && ( D3D12_PREVIEW_SDK_VERSION >= 717 ) ) if( pDX12EncodeContext->sliceNotificationMode == D3D12_VIDEO_ENCODER_COMPRESSED_BITSTREAM_NOTIFICATION_MODE_FULL_FRAME ) -#endif // (USE_D3D12_PREVIEW_HEADERS && (D3D12_PREVIEW_SDK_VERSION >= 717)) { // Readback full encoded frame bitstream from GPU memory onto CPU buffer struct pipe_box box = { 0 }; @@ -2200,7 +2194,6 @@ CDX12EncHMFT::ProcessInput( DWORD dwInputStreamIndex, IMFSample *pSample, DWORD pDX12EncodeContext->pPipeVideoBuffer, &pDX12EncodeContext->encoderPicInfo.base ); -#if ( USE_D3D12_PREVIEW_HEADERS && ( D3D12_PREVIEW_SDK_VERSION >= 717 ) ) if( pDX12EncodeContext->sliceNotificationMode == D3D12_VIDEO_ENCODER_COMPRESSED_BITSTREAM_NOTIFICATION_MODE_SUBREGIONS ) { m_pPipeVideoCodec->encode_bitstream_sliced( m_pPipeVideoCodec, @@ -2211,7 +2204,6 @@ CDX12EncHMFT::ProcessInput( DWORD dwInputStreamIndex, IMFSample *pSample, DWORD &pDX12EncodeContext->pAsyncCookie ); } else -#endif // (USE_D3D12_PREVIEW_HEADERS && (D3D12_PREVIEW_SDK_VERSION >= 717)) { m_pPipeVideoCodec->encode_bitstream( m_pPipeVideoCodec, pDX12EncodeContext->pPipeVideoBuffer,