diff --git a/media_driver/agnostic/common/os/mos_os_virtualengine.h b/media_driver/agnostic/common/os/mos_os_virtualengine.h index 4487207e158..5916878d72e 100644 --- a/media_driver/agnostic/common/os/mos_os_virtualengine.h +++ b/media_driver/agnostic/common/os/mos_os_virtualengine.h @@ -30,175 +30,6 @@ #include "mos_os_virtualengine_specific.h" #include "mos_os_virtualengine_next.h" -class MosVeInterface; -typedef struct _MOS_VIRTUALENGINE_INTERFACE -{ - MosVeInterface *veInterface; - - bool bScalabilitySupported; - PMOS_INTERFACE pOsInterface; -#if (_DEBUG || _RELEASE_INTERNAL) - uint8_t EngineLogicId[MOS_MAX_ENGINE_INSTANCE_PER_CLASS]; - uint8_t ucEngineCount; -#endif - uint8_t ucMaxNumPipesInUse; - uint8_t ucNumOfSdryCmdBufInCurFrm; //!< number of secondary cmd buffers for current frame - uint32_t dwSdryCmdBufSize; //!< secondary cmd buffer size for current frame - uint8_t ucMaxNumOfSdryCmdBufInOneFrame; - uint32_t dwTotalNumOfSdryCmdBufs; - uint8_t ucNumOfSdryCmdBufSets; - uint8_t ucSdryCmdbufPoolIndx; - bool *pbSdryCmdBufPrepared; - PMOS_COMMAND_BUFFER pSecondryCmdBufPool; - MOS_VIRTUALENGINE_HINT_PARAMS ScalabilityHintParams; - MOS_VIRTUALENGINE_HINT_PARAMS SinglePipeHintParams; - - //! - //! \brief check if scalability is supported - //! \param [in] pVEInterface - //! virtual engine interface - //! \param [out] pbScalabilitySupported - //! pointer to a bool value - //! \return MOS_STATUS - //! MOS_STATUS_SUCCESS if success, else fail reason - //! - MOS_STATUS (*pfnVEIsScalabilitySupported)( - PMOS_VIRTUALENGINE_INTERFACE pVEInterface, - bool *pbScalabilitySupported); - - //! - //! \brief Reset secondary cmd buffer state - //! \details Reset secondary cmd buffer state in scalability virtual engine interface - //! \param [in] pVEInterface - //! virtual engine interface - //! \return void - //! - void (*pfnVEResetSecdryCmdBufStates)( - PMOS_VIRTUALENGINE_INTERFACE pVEInterface); - - //! - //! \brief Verify secondary cmd buffer size - //! \param [in] pVEInterface - //! virtual engine interface - //! \param [in] dwNewRequestSize - //! new request cmd buffer size - //! \return MOS_STATUS - //! MOS_STATUS_SUCCESS if success, else fail reason - //! - MOS_STATUS (*pfnVEVerifySecdryCmdBufSize)( - PMOS_VIRTUALENGINE_INTERFACE pVEInterface, - uint32_t dwNewRequestSize); - - //! - //! \brief resize secondary cmd buffer - //! \param [in] pVEInterface - //! virtual engine interface - //! \param [in] dwNewRequestSize - //! new request cmd buffer size - //! \return MOS_STATUS - //! MOS_STATUS_SUCCESS if success, else fail reason - //! - MOS_STATUS (*pfnVEResizeSecdryCmdBuf)( - PMOS_VIRTUALENGINE_INTERFACE pVEInterface, - uint32_t dwNewRequestSize); - - //! - //! \brief get secondary cmd buffer - //! \param [in] pVEInterface - //! virtual engine interface - //! \param [in] pScdryCmdBuf - //! pointer to secondry cmd buffer - //! \param [in] dwBufIdxPlus1 - //! secondary cmd buffer index plus 1 - //! \return MOS_STATUS - //! MOS_STATUS_SUCCESS if success, else fail reason - //! - MOS_STATUS (*pfnVEGetSecdryCmdBuf)( - PMOS_VIRTUALENGINE_INTERFACE pVEInterface, - PMOS_COMMAND_BUFFER pScdryCmdBuf, - uint32_t dwBufIdxPlus1); - - //! - //! \brief return secondary cmd buffer - //! \param [in] pVEInterface - //! virtual engine interface - //! \param [in] pScdryCmdBuf - //! pointer to secondry cmd buffer address - //! \param [in] dwBufIdxPlus1 - //! secondary cmd buffer index plus 1 - //! \return MOS_STATUS - //! MOS_STATUS_SUCCESS if success, else fail reason - //! - MOS_STATUS (*pfnVEReturnSecdryCmdBuf)( - PMOS_VIRTUALENGINE_INTERFACE pVEInterface, - PMOS_COMMAND_BUFFER pScdryCmdBuf, - uint32_t dwBufIdxPlus1); - - //! - //! \brief done virtual engine secondary command buffers - //! \details UnLock virtual engine secondary command buffers - //! \param [in] pVEInterface - //! virtual engine interface - //! \return MOS_STATUS - //! MOS_STATUS_SUCCESS if success, else fail reason - //! - MOS_STATUS (*pfnVEDoneSecdryCmdBuf)( - PMOS_VIRTUALENGINE_INTERFACE pVEInterface); - - //! - //! \brief set hint parameters - //! \details set hint parameters for virtual engine scalability or single pipe mode - //! \param [in] pVEInterface - //! virtual engine interface - //! \param [in] pVEParams - //! pointer to VE parameter data structure - //! \return MOS_STATUS - //! MOS_STATUS_SUCCESS if success, else fail reason - //! - MOS_STATUS (*pfnVESetHintParams) ( - PMOS_VIRTUALENGINE_INTERFACE pVEInterface, - PMOS_VIRTUALENGINE_SET_PARAMS pVEParams); - - //! - //! \brief get hint parameters - //! \details get hint parameters for virtual engine scalability or single pipe mode - //! \param [in] pVEInterface - //! virtual engine interface - //! \param [in] bScalableMode - //! flag to indicate if scalability mode - //! \param [in] ppHintParams - //! pointer to VE hint parameter address - //! \return MOS_STATUS - //! MOS_STATUS_SUCCESS if success, else fail reason - //! - MOS_STATUS (*pfnVEGetHintParams)( - PMOS_VIRTUALENGINE_INTERFACE pVEInterface, - bool bScalableMode, - PMOS_VIRTUALENGINE_HINT_PARAMS *ppHintParams); - - //! - //! \brief check hint parameters - //! \details check hint parameters for virtual engine scalability or single pipe mode - //! \param [in] pVEInterface - //! virtual engine interface - //! \param [in] ppHintParams - //! pointer to VE hint parameter address - //! \return MOS_STATUS - //! MOS_STATUS_SUCCESS if success, else fail reason - //! - MOS_STATUS (*pfnVECheckHintParamsValidity) ( - PMOS_VIRTUALENGINE_INTERFACE pVEInterface); - - //! - //! \brief Destroy resources for virtual engine scalability - //! \param [in] pVEInterface - //! virtual engine interface - //! \return void - //! - void (* pfnVEDestroy)( - PMOS_VIRTUALENGINE_INTERFACE pVEInterface); -}MOS_VIRTUALENGINE_INTERFACE, *PMOS_VIRTUALENGINE_INTERFACE; - //! //! \brief initialize virtual engine interface //! \details initialize virtual engine interface diff --git a/media_driver/media_softlet/agnostic/common/vp/hal/shared/scalability/vp_scalability_multipipe.cpp b/media_driver/media_softlet/agnostic/common/vp/hal/shared/scalability/vp_scalability_multipipe.cpp index 534a34dd469..9cfe4993b96 100644 --- a/media_driver/media_softlet/agnostic/common/vp/hal/shared/scalability/vp_scalability_multipipe.cpp +++ b/media_driver/media_softlet/agnostic/common/vp/hal/shared/scalability/vp_scalability_multipipe.cpp @@ -52,27 +52,6 @@ MOS_STATUS VpScalabilityMultiPipe::Destroy() SCALABILITY_CHK_STATUS_RETURN(VpScalabilityMultiPipeNext::Destroy()); - if (m_veInterface) - { - if (m_veInterface->pfnVEDestroy) - { - m_veInterface->pfnVEDestroy(m_veInterface); - } - MOS_FreeMemAndSetNull(m_veInterface); - } - else - { - if (!m_osInterface->apoMosEnabled) - { - // For VE not enabled/supported case, such as vp vebox on some platform, m_veInterface is nullptr. - // MOS_STATUS_SUCCESS should be returned for such case. - if (MOS_VE_SUPPORTED(m_osInterface)) - { - SCALABILITY_CHK_NULL_RETURN(m_veInterface); - } - } - } - return MOS_STATUS_SUCCESS; } diff --git a/media_softlet/agnostic/common/os/mos_os_virtualengine_next.h b/media_softlet/agnostic/common/os/mos_os_virtualengine_next.h index 9e4abbfe548..9011f7a2082 100644 --- a/media_softlet/agnostic/common/os/mos_os_virtualengine_next.h +++ b/media_softlet/agnostic/common/os/mos_os_virtualengine_next.h @@ -251,5 +251,182 @@ class MosVeInterface MEDIA_CLASS_DEFINE_END(MosVeInterface) }; +typedef struct _MOS_VIRTUALENGINE_INTERFACE +{ + MosVeInterface *veInterface; + + bool bScalabilitySupported; + PMOS_INTERFACE pOsInterface; +#if (_DEBUG || _RELEASE_INTERNAL) + uint8_t EngineLogicId[MOS_MAX_ENGINE_INSTANCE_PER_CLASS]; + uint8_t ucEngineCount; +#endif + uint8_t ucMaxNumPipesInUse; + uint8_t ucNumOfSdryCmdBufInCurFrm; //!< number of secondary cmd buffers for current frame + uint32_t dwSdryCmdBufSize; //!< secondary cmd buffer size for current frame + uint8_t ucMaxNumOfSdryCmdBufInOneFrame; + uint32_t dwTotalNumOfSdryCmdBufs; + uint8_t ucNumOfSdryCmdBufSets; + uint8_t ucSdryCmdbufPoolIndx; + bool *pbSdryCmdBufPrepared; + PMOS_COMMAND_BUFFER pSecondryCmdBufPool; + MOS_VIRTUALENGINE_HINT_PARAMS ScalabilityHintParams; + MOS_VIRTUALENGINE_HINT_PARAMS SinglePipeHintParams; + + //! + //! \brief check if scalability is supported + //! \param [in] pVEInterface + //! virtual engine interface + //! \param [out] pbScalabilitySupported + //! pointer to a bool value + //! \return MOS_STATUS + //! MOS_STATUS_SUCCESS if success, else fail reason + //! + MOS_STATUS (*pfnVEIsScalabilitySupported) + ( + PMOS_VIRTUALENGINE_INTERFACE pVEInterface, + bool *pbScalabilitySupported); + + //! + //! \brief Reset secondary cmd buffer state + //! \details Reset secondary cmd buffer state in scalability virtual engine interface + //! \param [in] pVEInterface + //! virtual engine interface + //! \return void + //! + void (*pfnVEResetSecdryCmdBufStates)( + PMOS_VIRTUALENGINE_INTERFACE pVEInterface); + + //! + //! \brief Verify secondary cmd buffer size + //! \param [in] pVEInterface + //! virtual engine interface + //! \param [in] dwNewRequestSize + //! new request cmd buffer size + //! \return MOS_STATUS + //! MOS_STATUS_SUCCESS if success, else fail reason + //! + MOS_STATUS (*pfnVEVerifySecdryCmdBufSize) + ( + PMOS_VIRTUALENGINE_INTERFACE pVEInterface, + uint32_t dwNewRequestSize); + + //! + //! \brief resize secondary cmd buffer + //! \param [in] pVEInterface + //! virtual engine interface + //! \param [in] dwNewRequestSize + //! new request cmd buffer size + //! \return MOS_STATUS + //! MOS_STATUS_SUCCESS if success, else fail reason + //! + MOS_STATUS (*pfnVEResizeSecdryCmdBuf) + ( + PMOS_VIRTUALENGINE_INTERFACE pVEInterface, + uint32_t dwNewRequestSize); + + //! + //! \brief get secondary cmd buffer + //! \param [in] pVEInterface + //! virtual engine interface + //! \param [in] pScdryCmdBuf + //! pointer to secondry cmd buffer + //! \param [in] dwBufIdxPlus1 + //! secondary cmd buffer index plus 1 + //! \return MOS_STATUS + //! MOS_STATUS_SUCCESS if success, else fail reason + //! + MOS_STATUS (*pfnVEGetSecdryCmdBuf) + ( + PMOS_VIRTUALENGINE_INTERFACE pVEInterface, + PMOS_COMMAND_BUFFER pScdryCmdBuf, + uint32_t dwBufIdxPlus1); + + //! + //! \brief return secondary cmd buffer + //! \param [in] pVEInterface + //! virtual engine interface + //! \param [in] pScdryCmdBuf + //! pointer to secondry cmd buffer address + //! \param [in] dwBufIdxPlus1 + //! secondary cmd buffer index plus 1 + //! \return MOS_STATUS + //! MOS_STATUS_SUCCESS if success, else fail reason + //! + MOS_STATUS (*pfnVEReturnSecdryCmdBuf) + ( + PMOS_VIRTUALENGINE_INTERFACE pVEInterface, + PMOS_COMMAND_BUFFER pScdryCmdBuf, + uint32_t dwBufIdxPlus1); + + //! + //! \brief done virtual engine secondary command buffers + //! \details UnLock virtual engine secondary command buffers + //! \param [in] pVEInterface + //! virtual engine interface + //! \return MOS_STATUS + //! MOS_STATUS_SUCCESS if success, else fail reason + //! + MOS_STATUS (*pfnVEDoneSecdryCmdBuf) + ( + PMOS_VIRTUALENGINE_INTERFACE pVEInterface); + + //! + //! \brief set hint parameters + //! \details set hint parameters for virtual engine scalability or single pipe mode + //! \param [in] pVEInterface + //! virtual engine interface + //! \param [in] pVEParams + //! pointer to VE parameter data structure + //! \return MOS_STATUS + //! MOS_STATUS_SUCCESS if success, else fail reason + //! + MOS_STATUS (*pfnVESetHintParams) + ( + PMOS_VIRTUALENGINE_INTERFACE pVEInterface, + PMOS_VIRTUALENGINE_SET_PARAMS pVEParams); + + //! + //! \brief get hint parameters + //! \details get hint parameters for virtual engine scalability or single pipe mode + //! \param [in] pVEInterface + //! virtual engine interface + //! \param [in] bScalableMode + //! flag to indicate if scalability mode + //! \param [in] ppHintParams + //! pointer to VE hint parameter address + //! \return MOS_STATUS + //! MOS_STATUS_SUCCESS if success, else fail reason + //! + MOS_STATUS (*pfnVEGetHintParams) + ( + PMOS_VIRTUALENGINE_INTERFACE pVEInterface, + bool bScalableMode, + PMOS_VIRTUALENGINE_HINT_PARAMS *ppHintParams); + + //! + //! \brief check hint parameters + //! \details check hint parameters for virtual engine scalability or single pipe mode + //! \param [in] pVEInterface + //! virtual engine interface + //! \param [in] ppHintParams + //! pointer to VE hint parameter address + //! \return MOS_STATUS + //! MOS_STATUS_SUCCESS if success, else fail reason + //! + MOS_STATUS (*pfnVECheckHintParamsValidity) + ( + PMOS_VIRTUALENGINE_INTERFACE pVEInterface); + + //! + //! \brief Destroy resources for virtual engine scalability + //! \param [in] pVEInterface + //! virtual engine interface + //! \return void + //! + void (*pfnVEDestroy)( + PMOS_VIRTUALENGINE_INTERFACE pVEInterface); +} MOS_VIRTUALENGINE_INTERFACE, *PMOS_VIRTUALENGINE_INTERFACE; + #endif //__MOS_OS_VIRTUALENGINE_SCALABILITY_NEXT_H__ diff --git a/media_softlet/agnostic/common/vp/hal/shared/scalability/vp_scalability_multipipe_next.cpp b/media_softlet/agnostic/common/vp/hal/shared/scalability/vp_scalability_multipipe_next.cpp index 7846a71f7da..191418e0a83 100644 --- a/media_softlet/agnostic/common/vp/hal/shared/scalability/vp_scalability_multipipe_next.cpp +++ b/media_softlet/agnostic/common/vp/hal/shared/scalability/vp_scalability_multipipe_next.cpp @@ -126,7 +126,6 @@ MOS_STATUS VpScalabilityMultiPipeNext::Initialize(const MediaScalabilityOption & VpScalabilityOption *vpScalabilityOption = MOS_New(VpScalabilityOption, (const VpScalabilityOption &)option); SCALABILITY_CHK_NULL_RETURN(vpScalabilityOption); m_scalabilityOption = vpScalabilityOption; - if (m_hwInterface->m_bIsMediaSfcInterfaceInUse) { m_frameTrackingEnabled = false; @@ -145,7 +144,6 @@ MOS_STATUS VpScalabilityMultiPipeNext::Initialize(const MediaScalabilityOption & veInitParms.ucNumOfSdryCmdBufSets = m_maxCmdBufferSetsNum; veInitParms.ucMaxNumPipesInUse = vpScalabilityOption->GetMaxMultiPipeNum(); veInitParms.ucMaxNumOfSdryCmdBufInOneFrame = veInitParms.ucMaxNumPipesInUse; - if (m_osInterface->apoMosEnabled) { SCALABILITY_CHK_NULL_RETURN(m_osInterface->osStreamState); @@ -155,7 +153,17 @@ MOS_STATUS VpScalabilityMultiPipeNext::Initialize(const MediaScalabilityOption & SCALABILITY_CHK_NULL_RETURN(m_veState); SCALABILITY_CHK_NULL_RETURN(m_veHitParams); } - + else + { + SCALABILITY_CHK_STATUS_RETURN(m_osInterface->pfnVirtualEngineInit(m_osInterface, &m_veHitParams, veInitParms)); + m_veInterface = m_osInterface->pVEInterf; + SCALABILITY_CHK_NULL_RETURN(m_veInterface); + if (m_veInterface->pfnVEGetHintParams != nullptr) + { + SCALABILITY_CHK_NULL_RETURN(m_veHitParams); + } + } + m_pipeNum = m_scalabilityOption->GetNumPipe(); m_pipeIndexForSubmit = m_pipeNum; @@ -168,12 +176,23 @@ MOS_STATUS VpScalabilityMultiPipeNext::Initialize(const MediaScalabilityOption & #if (_DEBUG || _RELEASE_INTERNAL) if (m_osInterface->bEnableDbgOvrdInVE) - { - for (uint32_t i = 0; i < m_osInterface->pfnGetVeEngineCount(m_osInterface->osStreamState); i++) + { + if (m_osInterface->apoMosEnabled) + { + for (uint32_t i = 0; i < m_osInterface->pfnGetVeEngineCount(m_osInterface->osStreamState); i++) + { + gpuCtxCreateOption->EngineInstance[i] = + m_osInterface->pfnGetEngineLogicIdByIdx(m_osInterface->osStreamState, i); + } + } + else { - gpuCtxCreateOption->EngineInstance[i] = - m_osInterface->pfnGetEngineLogicIdByIdx(m_osInterface->osStreamState, i); + for (uint32_t i = 0; i < m_veInterface->ucEngineCount; i++) + { + gpuCtxCreateOption->EngineInstance[i] = m_veInterface->EngineLogicId[i]; + } } + } #endif m_gpuCtxCreateOption = (PMOS_GPUCTX_CREATOPTIONS)(gpuCtxCreateOption); @@ -204,11 +223,8 @@ MOS_STATUS VpScalabilityMultiPipeNext::GetGpuCtxCreationOption(MOS_GPUCTX_CREATO MOS_STATUS VpScalabilityMultiPipeNext::Destroy() { VP_FUNC_CALL(); - SCALABILITY_FUNCTION_ENTER; - SCALABILITY_CHK_STATUS_RETURN(MediaScalability::Destroy()); - if (m_gpuCtxCreateOption) { MOS_Delete(m_gpuCtxCreateOption); @@ -217,7 +233,26 @@ MOS_STATUS VpScalabilityMultiPipeNext::Destroy() { MOS_Delete(m_scalabilityOption); } - + + if (m_veInterface) + { + if (m_veInterface->pfnVEDestroy) + { + m_veInterface->pfnVEDestroy(m_veInterface); + } + MOS_FreeMemAndSetNull(m_veInterface); + } + else + { + if (!m_osInterface->apoMosEnabled) + { + if (MOS_VE_SUPPORTED(m_osInterface)) + { + SCALABILITY_CHK_NULL_RETURN(m_veInterface); + } + } + } + m_osInterface->pfnFreeResource(m_osInterface, &m_resSemaphoreAllPipes[0]); m_osInterface->pfnFreeResource(m_osInterface, &m_resSemaphoreAllPipes[1]); m_osInterface->pfnFreeResource(m_osInterface, &m_resSemaphoreOnePipeWait); @@ -348,16 +383,27 @@ MOS_STATUS VpScalabilityMultiPipeNext::GetCmdBuffer(PMOS_COMMAND_BUFFER cmdBuffe { m_osInterface->pfnGetCommandBuffer(m_osInterface, &m_secondaryCmdBuffers[bufIdx], bufIdxPlus1); } - - int32_t submissionType = IsFirstPipe() ? SUBMISSION_TYPE_MULTI_PIPE_MASTER : SUBMISSION_TYPE_MULTI_PIPE_SLAVE; - if (IsLastPipe()) + + if (m_osInterface->apoMosEnabled) { - submissionType |= SUBMISSION_TYPE_MULTI_PIPE_FLAGS_LAST_PIPE; + int32_t submissionType = IsFirstPipe() ? SUBMISSION_TYPE_MULTI_PIPE_MASTER : SUBMISSION_TYPE_MULTI_PIPE_SLAVE; + if (IsLastPipe()) + { + submissionType |= SUBMISSION_TYPE_MULTI_PIPE_FLAGS_LAST_PIPE; + } + SCALABILITY_CHK_NULL_RETURN(m_osInterface->osStreamState); + SCALABILITY_CHK_NULL_RETURN(m_osInterface->osStreamState->virtualEngineInterface); + SCALABILITY_CHK_STATUS_RETURN(m_osInterface->osStreamState->virtualEngineInterface->SetSubmissionType(&(m_secondaryCmdBuffers[bufIdx]), submissionType)); + } + else + { + m_secondaryCmdBuffers[bufIdx].iSubmissionType = + IsFirstPipe() ? SUBMISSION_TYPE_MULTI_PIPE_MASTER : SUBMISSION_TYPE_MULTI_PIPE_SLAVE; + if (IsLastPipe()) + { + m_secondaryCmdBuffers[bufIdx].iSubmissionType |= SUBMISSION_TYPE_MULTI_PIPE_FLAGS_LAST_PIPE; + } } - SCALABILITY_CHK_NULL_RETURN(m_osInterface->osStreamState); - SCALABILITY_CHK_NULL_RETURN(m_osInterface->osStreamState->virtualEngineInterface); - SCALABILITY_CHK_STATUS_RETURN(m_osInterface->osStreamState->virtualEngineInterface->SetSubmissionType(&(m_secondaryCmdBuffers[bufIdx]), submissionType)); - *cmdBuffer = m_secondaryCmdBuffers[bufIdx]; m_secondaryCmdBuffersReturned[bufIdx] = false; @@ -409,7 +455,7 @@ MOS_STATUS VpScalabilityMultiPipeNext::SetHintParams() SCALABILITY_FUNCTION_ENTER; SCALABILITY_CHK_NULL_RETURN(m_osInterface); - + VpScalabilityOption *vpScalabilityOption = dynamic_cast(m_scalabilityOption); SCALABILITY_CHK_NULL_RETURN(vpScalabilityOption); @@ -452,9 +498,12 @@ MOS_STATUS VpScalabilityMultiPipeNext::SubmitCmdBuffer(PMOS_COMMAND_BUFFER cmdBu SCALABILITY_CHK_NULL_RETURN(m_osInterface); m_attrReady = false; - - SCALABILITY_CHK_STATUS_RETURN(SetHintParams()); - SCALABILITY_CHK_STATUS_RETURN(PopulateHintParams(&m_primaryCmdBuffer)); + + if (m_osInterface->apoMosEnabled || (m_veInterface && m_veInterface->pfnVESetHintParams != nullptr)) + { + SCALABILITY_CHK_STATUS_RETURN(SetHintParams()); + SCALABILITY_CHK_STATUS_RETURN(PopulateHintParams(&m_primaryCmdBuffer)); + } #if MOS_COMMAND_BUFFER_DUMP_SUPPORTED if (m_osInterface->bDumpCommandBuffer)