Skip to content

Commit

Permalink
[VP] Force to render for >8x or <1/8 scaling + di
Browse files Browse the repository at this point in the history
Force to render for >8x or <1/8 scaling + di.
  • Loading branch information
Alex1Zhang authored and intel-mediadev committed Dec 14, 2023
1 parent 864c636 commit 23eb02c
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ MOS_STATUS VpResourceManager::OnNewFrameProcessStart(SwFilterPipe &pipe)

// Only set sameSamples flag DI enabled frames.
if (m_pastFrameIds.valid && m_currentFrameIds.pastFrameAvailable &&
m_pastFrameIds.diEnabled && m_currentFrameIds.diEnabled)
m_pastFrameIds.diEnabled && m_currentFrameIds.diEnabled && m_isPastFrameVeboxDiUsed)
{
m_sameSamples =
WITHIN_BOUNDS(
Expand All @@ -327,7 +327,7 @@ MOS_STATUS VpResourceManager::OnNewFrameProcessStart(SwFilterPipe &pipe)
}
// bSameSamples flag also needs to be set for no reference case
else if (m_pastFrameIds.valid && !m_currentFrameIds.pastFrameAvailable &&
m_pastFrameIds.diEnabled && m_currentFrameIds.diEnabled)
m_pastFrameIds.diEnabled && m_currentFrameIds.diEnabled && m_isPastFrameVeboxDiUsed)
{
m_sameSamples =
WITHIN_BOUNDS(
Expand Down Expand Up @@ -1139,6 +1139,15 @@ MOS_STATUS VpResourceManager::AssignExecuteResource(std::vector<FeatureType> &fe

RESOURCE_ASSIGNMENT_HINT resHint = {};

if (caps.bVebox && (caps.bDI || caps.bDiProcess2ndField))
{
m_isPastFrameVeboxDiUsed = true;
}
else
{
m_isPastFrameVeboxDiUsed = false;
}

VP_PUBLIC_CHK_STATUS_RETURN(GetResourceHint(featurePool, executedFilters, resHint));

if (nullptr == outputSurface && IsOutputSurfaceNeeded(caps))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,7 @@ class VpResourceManager
uint32_t m_imageWidthOfCurrentHistogram = 0;
uint32_t m_imageHeightOfCurrentHistogram = 0;
bool m_isFcIntermediateSurfacePrepared = false;
bool m_isPastFrameVeboxDiUsed = false;
VP_SURFACE *m_fcIntermediateSurface[VP_NUM_FC_INTERMEDIA_SURFACES] = {}; // Ping-pong surface for multi-layer composition.
std::vector<VP_SURFACE *> m_intermediaSurfaces;
std::map<uint64_t, VP_SURFACE *> m_tempSurface; // allocation handle and surface pointer pair.
Expand Down
59 changes: 48 additions & 11 deletions media_softlet/agnostic/common/vp/hal/feature_manager/policy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,23 @@ MOS_STATUS Policy::GetExecutionCapsForSingleFeature(FeatureType featureType, SwF
SwFilter* di = nullptr;
SwFilter* hdr = nullptr;
SwFilter* cgc = nullptr;
SwFilter* scaling = nullptr;
VPHAL_CSPACE cscInputColorSpaceCheck = CSpace_None;

auto getDeinterlaceExecutionCaps = [&](SwFilter *_di)
{
bool forceDIToRender = false;
VP_PUBLIC_CHK_NULL_RETURN(_di);
scaling = scaling ? scaling : dynamic_cast<SwFilterScaling*>(swFilterPipe.GetSwFilter(FeatureType(FeatureTypeScaling)));
if (scaling)
{
// No need check HDR for DI case.
VP_PUBLIC_CHK_STATUS_RETURN(GetScalingExecutionCaps(scaling, false, true));
forceDIToRender = scaling->GetFilterEngineCaps().RenderNeeded && scaling->GetFilterEngineCaps().sfcNotSupported;
}
return GetDeinterlaceExecutionCaps(_di, forceDIToRender);
};

if (!feature)
{
VP_PUBLIC_VERBOSEMESSAGE("Feature %d is not enabled in current pipe", featureType);
Expand Down Expand Up @@ -426,7 +441,7 @@ MOS_STATUS Policy::GetExecutionCapsForSingleFeature(FeatureType featureType, SwF
}
else if (di)
{
VP_PUBLIC_CHK_STATUS_RETURN(GetDeinterlaceExecutionCaps(di));
VP_PUBLIC_CHK_STATUS_RETURN(getDeinterlaceExecutionCaps(di));

VP_EngineEntry *diEngine = &di->GetFilterEngineCaps();
if (diEngine->bEnabled && diEngine->VeboxNeeded)
Expand All @@ -451,7 +466,8 @@ MOS_STATUS Policy::GetExecutionCapsForSingleFeature(FeatureType featureType, SwF
}
else
{
VP_PUBLIC_CHK_STATUS_RETURN(GetScalingExecutionCaps(feature));
di = swFilterPipe.GetSwFilter(FeatureTypeDi);
VP_PUBLIC_CHK_STATUS_RETURN(GetScalingExecutionCaps(feature, di != nullptr));
}
break;
case FeatureTypeRotMir:
Expand All @@ -473,7 +489,7 @@ MOS_STATUS Policy::GetExecutionCapsForSingleFeature(FeatureType featureType, SwF
VP_PUBLIC_CHK_STATUS_RETURN(GetHdrExecutionCaps(feature));
break;
case FeatureTypeDi:
VP_PUBLIC_CHK_STATUS_RETURN(GetDeinterlaceExecutionCaps(feature));
VP_PUBLIC_CHK_STATUS_RETURN(getDeinterlaceExecutionCaps(feature));
break;
case FeatureTypeLumakey:
VP_PUBLIC_CHK_STATUS_RETURN(GetLumakeyExecutionCaps(feature));
Expand Down Expand Up @@ -1099,18 +1115,18 @@ MOS_STATUS Policy::GetCSCExecutionCaps(SwFilter* feature)
MOS_STATUS Policy::GetScalingExecutionCapsHdr(SwFilter *feature)
{
VP_FUNC_CALL();
VP_PUBLIC_CHK_STATUS_RETURN(GetScalingExecutionCaps(feature, true));
VP_PUBLIC_CHK_STATUS_RETURN(GetScalingExecutionCaps(feature, true, false));
return MOS_STATUS_SUCCESS;
}

MOS_STATUS Policy::GetScalingExecutionCaps(SwFilter *feature)
MOS_STATUS Policy::GetScalingExecutionCaps(SwFilter *feature, bool isDIEnabled)
{
VP_FUNC_CALL();
VP_PUBLIC_CHK_STATUS_RETURN(GetScalingExecutionCaps(feature, false));
VP_PUBLIC_CHK_STATUS_RETURN(GetScalingExecutionCaps(feature, false, isDIEnabled));
return MOS_STATUS_SUCCESS;
}

MOS_STATUS Policy::GetScalingExecutionCaps(SwFilter *feature, bool isHdrEnabled)
MOS_STATUS Policy::GetScalingExecutionCaps(SwFilter *feature, bool isHdrEnabled, bool isDIEnabled)
{
VP_FUNC_CALL();

Expand Down Expand Up @@ -1396,15 +1412,25 @@ MOS_STATUS Policy::GetScalingExecutionCaps(SwFilter *feature, bool isHdrEnabled)
{
bool sfc2PassScalingNeededX = OUT_OF_BOUNDS(fScaleX, fScaleMin, fScaleMax);
bool sfc2PassScalingNeededY = OUT_OF_BOUNDS(fScaleY, fScaleMin, fScaleMax);
bool multiPassNeeded= sfc2PassScalingNeededX || sfc2PassScalingNeededY;

scalingEngine->bEnabled = 1;
if (!m_hwCaps.m_rules.isAvsSamplerSupported && scalingParams->isPrimary && isAlphaSettingSupportedBySfc)

if (multiPassNeeded && isDIEnabled)
{
scalingEngine->RenderNeeded = 1;
scalingEngine->fcSupported = 1;
// Set sfcNotSupported to 1 to avoid SFC being selected without scaling filter.
scalingEngine->sfcNotSupported = 1;
VP_PUBLIC_NORMALMESSAGE("2 pass scaling + DI switch to render path.");
}
else if (!m_hwCaps.m_rules.isAvsSamplerSupported && scalingParams->isPrimary && isAlphaSettingSupportedBySfc)
{
// For primary layer, force to use sfc for better quailty.
scalingEngine->SfcNeeded = 1;
scalingEngine->sfc2PassScalingNeededX = sfc2PassScalingNeededX ? 1 : 0;
scalingEngine->sfc2PassScalingNeededY = sfc2PassScalingNeededY ? 1 : 0;
scalingEngine->multiPassNeeded = sfc2PassScalingNeededX || sfc2PassScalingNeededY;
scalingEngine->multiPassNeeded = multiPassNeeded;

if (1 == fScaleX && 1 == fScaleY)
{
Expand Down Expand Up @@ -1638,12 +1664,12 @@ MOS_STATUS Policy::GetDenoiseExecutionCaps(SwFilter* feature)
return MOS_STATUS_SUCCESS;
}

MOS_STATUS Policy::GetDeinterlaceExecutionCaps(SwFilter* feature)
MOS_STATUS Policy::GetDeinterlaceExecutionCaps(SwFilter* feature, bool forceDIToRender)
{
VP_FUNC_CALL();
VP_PUBLIC_CHK_NULL_RETURN(feature);

SwFilterDeinterlace* swFilterDi = dynamic_cast<SwFilterDeinterlace*>(feature);
SwFilterDeinterlace *swFilterDi = dynamic_cast<SwFilterDeinterlace*>(feature);
VP_PUBLIC_CHK_NULL_RETURN(swFilterDi);
VP_PUBLIC_CHK_NULL_RETURN(m_vpInterface.GetHwInterface());
VP_PUBLIC_CHK_NULL_RETURN(m_vpInterface.GetHwInterface()->m_userFeatureControl);
Expand Down Expand Up @@ -1692,6 +1718,17 @@ MOS_STATUS Policy::GetDeinterlaceExecutionCaps(SwFilter* feature)
return MOS_STATUS_SUCCESS;
}

if (forceDIToRender && diParams.diParams)
{
diEngine.bEnabled = 1;
diEngine.RenderNeeded = 1;
diEngine.fcSupported = 1;
diEngine.VeboxNeeded = 0;
VP_PUBLIC_NORMALMESSAGE("force to render for 2 pass scaling + DI.");
PrintFeatureExecutionCaps(__FUNCTION__, diEngine);
return MOS_STATUS_SUCCESS;
}

if (m_vpInterface.GetResourceManager()->IsRefValid() &&
diParams.diParams && diParams.diParams->bEnableFMD)
{
Expand Down
6 changes: 3 additions & 3 deletions media_softlet/agnostic/common/vp/hal/feature_manager/policy.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ class Policy
MOS_STATUS GetCSCExecutionCapsBT2020ToRGB(SwFilter *cgc, SwFilter *csc);
MOS_STATUS GetCSCExecutionCaps(SwFilter* feature);
bool IsSfcSupported(MOS_FORMAT format);
MOS_STATUS GetScalingExecutionCaps(SwFilter* feature);
MOS_STATUS GetScalingExecutionCaps(SwFilter *feature, bool isHdrEnabled);
MOS_STATUS GetScalingExecutionCaps(SwFilter* feature, bool isDIEnabled);
MOS_STATUS GetScalingExecutionCaps(SwFilter *feature, bool isHdrEnabled, bool isDIEnabled);
MOS_STATUS GetScalingExecutionCapsHdr(SwFilter *feature);
bool IsSfcRotationSupported(FeatureParamRotMir *rotationParams);
MOS_STATUS GetRotationExecutionCaps(SwFilter* feature);
Expand All @@ -107,7 +107,7 @@ class Policy
MOS_STATUS GetProcampExecutionCaps(SwFilter* feature);
MOS_STATUS GetHdrExecutionCaps(SwFilter *feature);
MOS_STATUS GetExecutionCaps(SwFilter* feature);
MOS_STATUS GetDeinterlaceExecutionCaps(SwFilter* feature);
MOS_STATUS GetDeinterlaceExecutionCaps(SwFilter* feature, bool is2PassScalingNeeded);
MOS_STATUS GetColorFillExecutionCaps(SwFilter* feature);
MOS_STATUS GetAlphaExecutionCaps(SwFilter* feature);
MOS_STATUS GetLumakeyExecutionCaps(SwFilter* feature);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -920,6 +920,7 @@ MOS_STATUS SwFilterDeinterlace::Clean()
VP_FUNC_CALL();

VP_PUBLIC_CHK_STATUS_RETURN(SwFilter::Clean());
MOS_ZeroMemory(&m_Params, sizeof(m_Params));
return MOS_STATUS_SUCCESS;
}

Expand All @@ -931,6 +932,8 @@ MOS_STATUS SwFilterDeinterlace::Configure(VP_PIPELINE_PARAMS& params, bool isInp
VP_PUBLIC_CHK_NULL_RETURN(surfInput);
VP_PUBLIC_CHK_NULL_RETURN(surfInput->pDeinterlaceParams);

MOS_ZeroMemory(&m_Params, sizeof(m_Params));

m_Params.formatInput = surfInput->Format;
m_Params.formatOutput = surfInput->Format;
m_Params.sampleTypeInput = surfInput->SampleType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,6 @@ MOS_STATUS VpRenderCmdPacket::SetupSurfaceState()
{
KERNEL_SURFACE_STATE_PARAM *kernelSurfaceParam = &surface->second;
SurfaceType type = surface->first;
auto bindingMap = m_kernel->GetSurfaceBindingIndex(type);

RENDERHAL_SURFACE_NEXT renderHalSurface;
MOS_ZeroMemory(&renderHalSurface, sizeof(RENDERHAL_SURFACE_NEXT));
Expand Down Expand Up @@ -732,6 +731,7 @@ MOS_STATUS VpRenderCmdPacket::SetupSurfaceState()

if (kernelSurfaceParam->surfaceOverwriteParams.bindedKernel && !kernelSurfaceParam->surfaceOverwriteParams.bufferResource)
{
auto bindingMap = m_kernel->GetSurfaceBindingIndex(type);
if (bindingMap.empty())
{
VP_RENDER_CHK_STATUS_RETURN(MOS_STATUS_INVALID_PARAMETER);
Expand All @@ -757,6 +757,7 @@ MOS_STATUS VpRenderCmdPacket::SetupSurfaceState()
kernelSurfaceParam->surfaceOverwriteParams.bufferResource &&
kernelSurfaceParam->surfaceOverwriteParams.bindedKernel))
{
auto bindingMap = m_kernel->GetSurfaceBindingIndex(type);
if (bindingMap.empty())
{
VP_RENDER_CHK_STATUS_RETURN(MOS_STATUS_INVALID_PARAMETER);
Expand Down

0 comments on commit 23eb02c

Please sign in to comment.