Skip to content

Commit

Permalink
[vpp] Enable copy pass thru for VAAPI
Browse files Browse the repository at this point in the history
Issue: MDP-53850
Fixes: Intel-Media-SDK#1027
  • Loading branch information
AlexandrX Konovalov committed Mar 19, 2019
1 parent dad7abb commit 039ecba
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 14 deletions.
4 changes: 1 addition & 3 deletions _studio/mfx_lib/shared/src/mfx_session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -920,9 +920,7 @@ mfxStatus _mfxSession_1_10::InitEx(mfxInitParam& par)
if (pCmCore)
{
mfxRes = pCmCore->SetCmCopyStatus(false);
}
if (MFX_ERR_NONE != mfxRes) {
return mfxRes;
MFX_CHECK_STS(mfxRes);
}
}

Expand Down
2 changes: 2 additions & 0 deletions _studio/mfx_lib/vpp/include/mfx_vpp_hw.h
Original file line number Diff line number Diff line change
Expand Up @@ -908,6 +908,8 @@ namespace MfxHwVideoProcessing
mfxFrameSurface1 *pInputSurface,
mfxFrameSurface1 *pOutputSurface);

bool UseCopyPassThrough(const DdiTask *pTask) const;

mfxStatus PreWorkOutSurface(ExtSurface & output);
mfxStatus PreWorkInputSurface(std::vector<ExtSurface> & surfQueue);

Expand Down
31 changes: 26 additions & 5 deletions _studio/mfx_lib/vpp/src/mfx_vpp_hw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2962,6 +2962,28 @@ mfxStatus VideoVPPHW::Close()
} // mfxStatus VideoVPPHW::Close()


bool VideoVPPHW::UseCopyPassThrough(const DdiTask *pTask) const
{
if (!m_config.m_bCopyPassThroughEnable
|| IsRoiDifferent(pTask->input.pSurf, pTask->output.pSurf))
{
return false;
}

if (m_pCore->GetVAType() != MFX_HW_VAAPI || m_ioMode != D3D_TO_D3D)
{
return true;
}

// Under VAAPI for D3D_TO_D3D either CM copy or VPP pipeline are preferred by
// performance reasons. So, before enabling CopyPassThrough for a task we check
// for CM availability to do fallback to VPP if there is no CM.
// This can't be done in ConfigureExecuteParams() because CmCopy status is set later.
const VAAPIVideoCORE *vaapiCore = dynamic_cast<VAAPIVideoCORE*>(m_pCore);
assert(vaapiCore);
return vaapiCore? vaapiCore->CmCopy() : false;
}

mfxStatus VideoVPPHW::VppFrameCheck(
mfxFrameSurface1 *input,
mfxFrameSurface1 *output,
Expand Down Expand Up @@ -3115,9 +3137,11 @@ mfxStatus VideoVPPHW::VppFrameCheck(
#endif
MFX_CHECK_STS(sts);

bool useCopyPassThrough = UseCopyPassThrough(pTask);

if (VPP_SYNC_WORKLOAD == m_workloadMode)
{
pTask->bRunTimeCopyPassThrough = (true == m_config.m_bCopyPassThroughEnable && false == IsRoiDifferent(pTask->input.pSurf, pTask->output.pSurf));
pTask->bRunTimeCopyPassThrough = useCopyPassThrough;

// submit task
SyncTaskSubmission(pTask);
Expand All @@ -3136,8 +3160,7 @@ mfxStatus VideoVPPHW::VppFrameCheck(
}
else
{
if (false == m_config.m_bCopyPassThroughEnable ||
(true == m_config.m_bCopyPassThroughEnable && true == IsRoiDifferent(pTask->input.pSurf, pTask->output.pSurf)))
if (!useCopyPassThrough)
{
pTask->bRunTimeCopyPassThrough = false;

Expand Down Expand Up @@ -6104,7 +6127,6 @@ mfxStatus ConfigureExecuteParams(
executeParams.bSceneDetectionEnable = false;
}

#if defined(WIN64) || defined (WIN32)
if ( (0 == memcmp(&videoParam.vpp.In, &videoParam.vpp.Out, sizeof(mfxFrameInfo))) &&
executeParams.IsDoNothing() )
{
Expand All @@ -6115,7 +6137,6 @@ mfxStatus ConfigureExecuteParams(
config.m_bCopyPassThroughEnable = false;// after Reset() parameters may be changed,
// flag should be disabled
}
#endif//m_bCopyPassThroughEnable == false for another OS

if (inDNRatio == outDNRatio && !executeParams.bVarianceEnable && !executeParams.bComposite &&
!(config.m_extConfig.mode == IS_REFERENCES) )
Expand Down
9 changes: 6 additions & 3 deletions _studio/shared/include/libmfx_core_vaapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,10 @@ class VAAPIVideoCORE : public CommonCORE
CMEnabledCoreAdapter(VAAPIVideoCORE *pVAAPICore): m_pVAAPICore(pVAAPICore)
{
};
virtual mfxStatus SetCmCopyStatus(bool enable)
virtual mfxStatus SetCmCopyStatus(bool enable) override
{
return m_pVAAPICore->SetCmCopyStatus(enable);
m_pVAAPICore->SetCmCopy(enable);
return MFX_ERR_NONE;
};
protected:
VAAPIVideoCORE *m_pVAAPICore;
Expand Down Expand Up @@ -175,7 +176,9 @@ class VAAPIVideoCORE : public CommonCORE
mfxStatus GetVAService(VADisplay *pVADisplay);

// this function should not be virtual
mfxStatus SetCmCopyStatus(bool enable);
void SetCmCopy(bool enable);

bool CmCopy() const { return m_bCmCopy; }

protected:
VAAPIVideoCORE(const mfxU32 adapterNum, const mfxU32 numThreadsAvailable, const mfxSession session = NULL);
Expand Down
5 changes: 2 additions & 3 deletions _studio/shared/src/libmfx_core_vaapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -812,8 +812,8 @@ VAAPIVideoCORE::GetVAService(

} // mfxStatus VAAPIVideoCORE::GetVAService(...)

mfxStatus
VAAPIVideoCORE::SetCmCopyStatus(bool enable)
void
VAAPIVideoCORE::SetCmCopy(bool enable)
{
m_bCmCopyAllowed = enable;
if (!enable)
Expand All @@ -824,7 +824,6 @@ VAAPIVideoCORE::SetCmCopyStatus(bool enable)
}
m_bCmCopy = false;
}
return MFX_ERR_NONE;
} // mfxStatus VAAPIVideoCORE::SetCmCopyStatus(...)

mfxStatus
Expand Down

0 comments on commit 039ecba

Please sign in to comment.