Skip to content

Commit

Permalink
[Media Common] [Trinity9] Enable YV12 media part.
Browse files Browse the repository at this point in the history
* [Media Common] [Trinity9] Enable YV12 trinity9 part.

Enable YV12 trinity9 part

1. Add interface to get gmm infos and offsets of 3 planes.
2. Fix 3 planes 420 copy issue.
  • Loading branch information
jianxiah-intel authored and intel-mediadev committed Oct 25, 2023
1 parent edb0499 commit f362fb5
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 27 deletions.
3 changes: 3 additions & 0 deletions media_common/agnostic/common/vp/hal/vp_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ struct VPHAL_SURFACE
uint32_t dwWidth = 0; //!< Surface width
uint32_t dwHeight = 0; //!< Surface height
uint32_t dwPitch = 0; //!< Surface pitch
uint32_t dwYPitch = 0; //!< Surface Y plane pitch
uint32_t dwUPitch = 0; //!< Surface U plane pitch
uint32_t dwVPitch = 0; //!< Surface V plane pitch
MOS_TILE_TYPE TileType = MOS_TILE_X; //!< Tile Type
MOS_TILE_MODE_GMM TileModeGMM = MOS_TILE_LINEAR_GMM; //!< Tile Mode from GMM Definition
bool bGMMTileEnabled = false; //!< GMM Tile Mode Flag
Expand Down
5 changes: 4 additions & 1 deletion media_common/linux/common/os/mos_os_specific.h
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,10 @@ struct MOS_SURFACE
uint32_t dwOffset; // Surface Offset (Y/Base)
MOS_PLANE_OFFSET YPlaneOffset; // Y surface plane offset
MOS_PLANE_OFFSET UPlaneOffset; // U surface plane offset
MOS_PLANE_OFFSET VPlaneOffset; // V surface plane
MOS_PLANE_OFFSET VPlaneOffset; // V surface plane offset
uint32_t dwYPitch; // Y surface plane pitch
uint32_t dwUPitch; // U surface plane pitch
uint32_t dwVPitch; // V surface plane pitch

union
{
Expand Down
3 changes: 3 additions & 0 deletions media_driver/agnostic/common/vp/hal/vphal_render_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -973,6 +973,9 @@ MOS_STATUS VpHal_RndrCommonInitRenderHalSurface(
pRenderHalSurface->OsSurface.dwWidth = pVpSurface->dwWidth;
pRenderHalSurface->OsSurface.dwHeight = pVpSurface->dwHeight;
pRenderHalSurface->OsSurface.dwPitch = pVpSurface->dwPitch;
pRenderHalSurface->OsSurface.dwYPitch = pVpSurface->dwYPitch;
pRenderHalSurface->OsSurface.dwUPitch = pVpSurface->dwUPitch;
pRenderHalSurface->OsSurface.dwVPitch = pVpSurface->dwVPitch;
pRenderHalSurface->OsSurface.Format = pVpSurface->Format;
pRenderHalSurface->OsSurface.TileType = pVpSurface->TileType;
pRenderHalSurface->OsSurface.TileModeGMM = pVpSurface->TileModeGMM;
Expand Down
28 changes: 17 additions & 11 deletions media_driver/agnostic/common/vp/hal/vphal_render_composite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6829,17 +6829,23 @@ bool CompositeState::BuildFilter(
// Y_Uoffset(Height*2 + Height/2) of RENDERHAL_PLANES_YV12 define Bitfield_Range(0, 13) on gen9+.
// The max value is 16383. So use PL3 kernel to avoid out of range when Y_Uoffset is larger than 16383.
// Use PL3 plane to avoid YV12 blending issue with DI enabled and U channel shift issue with not 4-aligned height
if ((pFilter->format == Format_YV12) &&
(pSrc->ScalingMode != VPHAL_SCALING_AVS) &&
(pSrc->bIEF != true) &&
(pSrc->SurfType != SURF_OUT_RENDERTARGET) &&
m_pRenderHal->bEnableYV12SinglePass &&
!pSrc->pDeinterlaceParams &&
!pSrc->bInterlacedScaling &&
MOS_IS_ALIGNED(pSrc->dwHeight, 4) &&
((pSrc->dwHeight * 2 + pSrc->dwHeight / 2) < RENDERHAL_MAX_YV12_PLANE_Y_U_OFFSET_G9))
{
pFilter->format = Format_YV12_Planar;
if (pFilter->format == Format_YV12)
{
if (m_pOsInterface->trinityPath == TRINITY9_ENABLED)
{
pFilter->format = Format_PL3;
}
else if ((pSrc->ScalingMode != VPHAL_SCALING_AVS) &&
(pSrc->bIEF != true) &&
(pSrc->SurfType != SURF_OUT_RENDERTARGET) &&
m_pRenderHal->bEnableYV12SinglePass &&
!pSrc->pDeinterlaceParams &&
!pSrc->bInterlacedScaling &&
MOS_IS_ALIGNED(pSrc->dwHeight, 4) &&
((pSrc->dwHeight * 2 + pSrc->dwHeight / 2) < RENDERHAL_MAX_YV12_PLANE_Y_U_OFFSET_G9))
{
pFilter->format = Format_YV12_Planar;
}
}

if (pFilter->format == Format_A8R8G8B8 ||
Expand Down
21 changes: 17 additions & 4 deletions media_softlet/agnostic/common/renderhal/renderhal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3224,6 +3224,7 @@ MOS_STATUS RenderHal_GetSurfaceStateEntries(
uint16_t wVXOffset;
uint16_t wVYOffset;
bool bIsChromaSitEnabled;
bool bIsTri9YV12;

//------------------------------------------------
MHW_RENDERHAL_CHK_NULL_RETURN(pRenderHal);
Expand All @@ -3247,6 +3248,11 @@ MOS_STATUS RenderHal_GetSurfaceStateEntries(
PlaneDefinition = RENDERHAL_PLANES_DEFINITION_COUNT;
bIsChromaSitEnabled = 0;

// In trinity9, YV12 format will use 3 Planes
bIsTri9YV12 = pSurface->Format == Format_YV12 &&
pRenderHal->pOsInterface != nullptr &&
pRenderHal->pOsInterface->trinityPath == TRINITY9_ENABLED;

pRenderHal->bIsAVS = pParams->bAVS;

// Check palette allocations
Expand Down Expand Up @@ -3639,6 +3645,7 @@ MOS_STATUS RenderHal_GetSurfaceStateEntries(
PlaneDefinition = (pRenderHal->bEnableYV12SinglePass &&
!pRenderHalSurface->pDeinterlaceParams &&
!pRenderHalSurface->bInterlacedScaling &&
pRenderHal->pOsInterface->trinityPath != TRINITY9_ENABLED &&
MOS_IS_ALIGNED(pSurface->dwHeight, 4) &&
pRenderHalSurface->SurfType != RENDERHAL_SURF_OUT_RENDERTARGET &&
(pSurface->dwHeight * 2 + pSurface->dwHeight / 2) < RENDERHAL_MAX_YV12_PLANE_Y_U_OFFSET_G9)?
Expand Down Expand Up @@ -4087,14 +4094,20 @@ MOS_STATUS RenderHal_GetSurfaceStateEntries(
pSurfaceEntry->dwHeight = MOS_MAX(1, dwSurfaceHeight);
pSurfaceEntry->bWidthInDword = bWidthInDword;

if (pPlane->ui8PlaneID == MHW_U_PLANE ||
pPlane->ui8PlaneID == MHW_V_PLANE)
if (pPlane->ui8PlaneID == MHW_U_PLANE || pPlane->ui8PlaneID == MHW_V_PLANE)
{
pSurfaceEntry->dwPitch = dwUVPitch;
if (bIsTri9YV12)
{
pSurfaceEntry->dwPitch = (pPlane->ui8PlaneID == MHW_U_PLANE) ? pSurface->dwUPitch : pSurface->dwVPitch;
}
else
{
pSurfaceEntry->dwPitch = dwUVPitch;
}
}
else
{
pSurfaceEntry->dwPitch = pSurface->dwPitch;
pSurfaceEntry->dwPitch = bIsTri9YV12 ? pSurface->dwYPitch : pSurface->dwPitch;
}

pSurfaceEntry->dwQPitch = pSurface->dwQPitch;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,9 @@ MOS_STATUS VpAllocator::GetSurfaceInfo(VPHAL_SURFACE *surface, VPHAL_GET_SURFACE
surface->dwWidth = resDetails.dwWidth;
surface->dwHeight = resDetails.dwHeight;
surface->dwPitch = resDetails.dwPitch;
surface->dwYPitch = resDetails.dwYPitch;
surface->dwUPitch = resDetails.dwUPitch;
surface->dwVPitch = resDetails.dwVPitch;
surface->dwSlicePitch = resDetails.dwSlicePitch;
surface->dwDepth = resDetails.dwDepth;
surface->TileType = resDetails.TileType;
Expand Down
30 changes: 19 additions & 11 deletions media_softlet/agnostic/common/vp/hal/packet/vp_render_fc_kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -844,17 +844,25 @@ MOS_STATUS VpRenderFcKernel::BuildFilter(
// Y_Uoffset(Height*2 + Height/2) of RENDERHAL_PLANES_YV12 define Bitfield_Range(0, 13) on gen9+.
// The max value is 16383. So use PL3 kernel to avoid out of range when Y_Uoffset is larger than 16383.
// Use PL3 plane to avoid YV12 blending issue with DI enabled and U channel shift issue with not 4-aligned height
if ((pFilter->format == Format_YV12) &&
(src->scalingMode != VPHAL_SCALING_AVS) &&
(src->iefEnabled != true) &&
(src->surf->SurfType != SURF_OUT_RENDERTARGET) &&
m_renderHal->bEnableYV12SinglePass &&
!src->diParams &&
!src->iscalingEnabled &&
MOS_IS_ALIGNED(src->surf->osSurface->dwHeight, 4) &&
((src->surf->osSurface->dwHeight * 2 + src->surf->osSurface->dwHeight / 2) < RENDERHAL_MAX_YV12_PLANE_Y_U_OFFSET_G9))
{
pFilter->format = Format_YV12_Planar;
if (pFilter->format == Format_YV12)
{
if (m_renderHal->pOsInterface != nullptr &&
m_renderHal->pOsInterface->trinityPath == TRINITY9_ENABLED)
{
pFilter->format = Format_PL3;
}
else if (
(src->scalingMode != VPHAL_SCALING_AVS) &&
(src->iefEnabled != true) &&
(src->surf->SurfType != SURF_OUT_RENDERTARGET) &&
m_renderHal->bEnableYV12SinglePass &&
!src->diParams &&
!src->iscalingEnabled &&
MOS_IS_ALIGNED(src->surf->osSurface->dwHeight, 4) &&
((src->surf->osSurface->dwHeight * 2 + src->surf->osSurface->dwHeight / 2) < RENDERHAL_MAX_YV12_PLANE_Y_U_OFFSET_G9))
{
pFilter->format = Format_YV12_Planar;
}
}

if (pFilter->format == Format_A8R8G8B8 ||
Expand Down

0 comments on commit f362fb5

Please sign in to comment.