Skip to content

Commit

Permalink
[VP] CPU latency optimize
Browse files Browse the repository at this point in the history
reuse the allocated buffer if the allocated size was larger than request size when OptimizeCpuTiming is enabled
  • Loading branch information
pengwan1 authored and intel-mediadev committed Jun 21, 2024
1 parent de1a43e commit 2a60d2d
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
20 changes: 20 additions & 0 deletions media_softlet/agnostic/common/vp/hal/bufferMgr/vp_allocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,17 @@ MOS_STATUS VpAllocator::ReAllocateSurface(
return eStatus;
}

// reuse the allocated buffer if the allocated size was larger than request size when OptimizeCpuTiming is enabled
if (m_osInterface->bOptimizeCpuTiming &&
surface &&
surface->osSurface &&
(!Mos_ResourceIsNull(&surface->osSurface->OsResource)) &&
(Format_Buffer == format) &&
(surface->bufferWidth * surface->bufferHeight >= width * height))
{
return eStatus;
}

if (surface && nullptr == surface->osSurface)
{
// VP_SURFACE should always be allocated by interface in VpAllocator,
Expand Down Expand Up @@ -988,6 +999,15 @@ MOS_STATUS VpAllocator::ReAllocateSurface(
return eStatus;
}

// reuse the allocated buffer if the allocated size was larger than request size when OptimizeCpuTiming is enabled
if (m_osInterface->bOptimizeCpuTiming &&
(!Mos_ResourceIsNull(&surface->OsResource)) &&
(Format_Buffer == format) &&
(surface->dwWidth * surface->dwHeight >= width * height))
{
return eStatus;
}

MOS_ZeroMemory(&allocParams, sizeof(MOS_ALLOC_GFXRES_PARAMS));

VpHal_AllocParamsInitType(&allocParams, surface, defaultResType, defaultTileType);
Expand Down
2 changes: 2 additions & 0 deletions media_softlet/agnostic/common/vp/hal/pipeline/vp_pipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,8 @@ MOS_STATUS VpPipeline::ExecuteVpPipeline()
{
params = m_pvpParams.renderParams;
VP_PUBLIC_CHK_NULL_RETURN(params);
// Get the OptimizeCpuTiming flag from params
m_osInterface->bOptimizeCpuTiming = params->bOptimizeCpuTiming;
// Set Pipeline status Table
m_statusReport->SetPipeStatusReportParams(params, m_vpMhwInterface.m_statusTable);

Expand Down
8 changes: 5 additions & 3 deletions media_softlet/agnostic/common/vp/hal/utils/vp_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,11 @@ MOS_STATUS VpUtils::ReAllocateSurface(
goto finish;
}

if (osInterface->bOptimizeCpuTiming &&
(defaultResType == MOS_GFXRES_BUFFER) &&
(surface->dwWidth >= dwWidth))
// reuse the allocated buffer if the allocated size was larger than request size when OptimizeCpuTiming is enabled
if (osInterface->bOptimizeCpuTiming &&
!Mos_ResourceIsNull(&surface->OsResource) &&
(Format_Buffer == format) &&
(surface->dwWidth * surface->dwHeight >= dwWidth * dwHeight))
{
goto finish;
}
Expand Down

0 comments on commit 2a60d2d

Please sign in to comment.