Skip to content

Commit 6210342

Browse files
vipuldasdrprajap
vipuldas
authored andcommitted
Page aligned YUV Planar surface
Change-Id: I1e80cacb28e6271c99d6fbd352a7b196dae94a2a
1 parent b1451bb commit 6210342

File tree

5 files changed

+105
-7
lines changed

5 files changed

+105
-7
lines changed

Source/GmmLib/Platform/GmmPlatforms.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ namespace GmmLib {
3737

3838
public:
3939
PlatformInfo(PLATFORM &Platform);
40-
virtual ~PlatformInfo()
40+
virtual ~PlatformInfo()
4141
{
4242
}
4343

Source/GmmLib/Resource/GmmResourceInfoCommon.cpp

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -873,6 +873,98 @@ uint8_t GMM_STDCALL GmmLib::GmmResourceInfoCommon::CpuBlt(GMM_RES_COPY_BLT *pBlt
873873

874874
pTexInfo = &(Surf);
875875

876+
// YUV Planar surface
877+
if (pTexInfo->OffsetInfo.Plane.IsTileAlignedPlanes && GmmIsPlanar(Surf.Format))
878+
{
879+
uint32_t PlaneId = GMM_NO_PLANE;
880+
uint32_t TotalHeight = 0;
881+
882+
if (pTexInfo->OffsetInfo.Plane.NoOfPlanes == 2)
883+
{
884+
TotalHeight = GFX_ULONG_CAST(pTexInfo->OffsetInfo.Plane.UnAligned.Height[GMM_PLANE_Y] +
885+
pTexInfo->OffsetInfo.Plane.UnAligned.Height[GMM_PLANE_U]);
886+
}
887+
else if (pTexInfo->OffsetInfo.Plane.NoOfPlanes == 3)
888+
{
889+
TotalHeight = GFX_ULONG_CAST(pTexInfo->OffsetInfo.Plane.UnAligned.Height[GMM_PLANE_Y] +
890+
pTexInfo->OffsetInfo.Plane.UnAligned.Height[GMM_PLANE_U] +
891+
pTexInfo->OffsetInfo.Plane.UnAligned.Height[GMM_PLANE_V]);
892+
}
893+
else
894+
{
895+
TotalHeight = GFX_ULONG_CAST(pTexInfo->OffsetInfo.Plane.UnAligned.Height[GMM_PLANE_Y]); //YV12 exception
896+
}
897+
898+
// Determine if BLT rectange is for monolithic surface or contained in specific Y/UV plane
899+
if (((pBlt->Gpu.OffsetY + pBlt->Blt.Height <= Surf.OffsetInfo.Plane.Y[GMM_PLANE_U]) || pTexInfo->OffsetInfo.Plane.NoOfPlanes == 1) &&
900+
(pBlt->Gpu.OffsetX + pBlt->Blt.Width <= Surf.BaseWidth))
901+
{
902+
PlaneId = GMM_PLANE_Y;
903+
}
904+
else if (pBlt->Gpu.OffsetY >= Surf.OffsetInfo.Plane.Y[GMM_PLANE_U] &&
905+
(pBlt->Gpu.OffsetY + pBlt->Blt.Height <= (Surf.OffsetInfo.Plane.Y[GMM_PLANE_U] + pTexInfo->OffsetInfo.Plane.UnAligned.Height[GMM_PLANE_U])) &&
906+
(pBlt->Gpu.OffsetX + pBlt->Blt.Width <= Surf.BaseWidth))
907+
{
908+
PlaneId = GMM_PLANE_U;
909+
}
910+
else if (pBlt->Gpu.OffsetY >= Surf.OffsetInfo.Plane.Y[GMM_PLANE_V] &&
911+
(pBlt->Gpu.OffsetY + pBlt->Blt.Height <= (Surf.OffsetInfo.Plane.Y[GMM_PLANE_V] + pTexInfo->OffsetInfo.Plane.UnAligned.Height[GMM_PLANE_U])) &&
912+
(pBlt->Gpu.OffsetX + pBlt->Blt.Width <= Surf.BaseWidth))
913+
{
914+
PlaneId = GMM_PLANE_V;
915+
}
916+
917+
// For smaller surface, BLT rect may fall in Y Plane due to tile alignment but user may have requested monolithic BLT
918+
if (pBlt->Gpu.OffsetX == 0 &&
919+
pBlt->Gpu.OffsetY == 0 &&
920+
pBlt->Blt.Height >= TotalHeight)
921+
{
922+
PlaneId = GMM_MAX_PLANE;
923+
}
924+
925+
if (PlaneId == GMM_MAX_PLANE)
926+
{
927+
// TODO BLT rect should not overlap between planes.
928+
{
929+
// __GMM_ASSERT(0); // decide later, for now blt it
930+
//return FALSE;
931+
}
932+
933+
// BLT monolithic surface per plane and remove padding due to tiling.
934+
for (PlaneId = GMM_PLANE_Y; PlaneId <= pTexInfo->OffsetInfo.Plane.NoOfPlanes; PlaneId++)
935+
{
936+
if (PlaneId == GMM_PLANE_Y)
937+
{
938+
pBlt->Gpu.OffsetX = GFX_ULONG_CAST(Surf.OffsetInfo.Plane.X[GMM_PLANE_Y]);
939+
pBlt->Gpu.OffsetY = GFX_ULONG_CAST(Surf.OffsetInfo.Plane.Y[GMM_PLANE_Y]);
940+
pBlt->Blt.Height = GFX_ULONG_CAST(Surf.OffsetInfo.Plane.UnAligned.Height[GMM_PLANE_Y]);
941+
}
942+
else if (PlaneId == GMM_PLANE_U)
943+
{
944+
pBlt->Gpu.OffsetX = GFX_ULONG_CAST(Surf.OffsetInfo.Plane.X[GMM_PLANE_U]);
945+
pBlt->Gpu.OffsetY = GFX_ULONG_CAST(Surf.OffsetInfo.Plane.Y[GMM_PLANE_U]);
946+
947+
pBlt->Sys.pData = (char *)pBlt->Sys.pData + uint32_t(pBlt->Blt.Height * pBlt->Sys.RowPitch);
948+
pBlt->Blt.Height = GFX_ULONG_CAST(Surf.OffsetInfo.Plane.UnAligned.Height[GMM_PLANE_U]);
949+
if (Surf.Flags.Info.RedecribedPlanes)
950+
{
951+
__GMM_ASSERT(0);
952+
}
953+
}
954+
else
955+
{
956+
pBlt->Gpu.OffsetX = GFX_ULONG_CAST(Surf.OffsetInfo.Plane.X[GMM_PLANE_V]);
957+
pBlt->Gpu.OffsetY = GFX_ULONG_CAST(Surf.OffsetInfo.Plane.Y[GMM_PLANE_V]);
958+
pBlt->Blt.Height = GFX_ULONG_CAST(Surf.OffsetInfo.Plane.UnAligned.Height[GMM_PLANE_U]);
959+
pBlt->Sys.pData = (char *)pBlt->Sys.pData + uint32_t(pBlt->Blt.Height * pBlt->Sys.RowPitch);
960+
}
961+
962+
CpuBlt(pBlt);
963+
}
964+
}
965+
// else continue below
966+
}
967+
876968
// UV packed planar surfaces will have different tiling geometries for the
877969
// Y and UV planes. Blts cannot span across the tiling boundaries and we
878970
// must select the proper mode for each plane. Non-UV packed formats will

Source/GmmLib/Texture/GmmTextureAlloc.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -956,7 +956,7 @@ GMM_STATUS GMM_STDCALL GmmLib::GmmTextureCalc::FillTexPlanar(GMM_TEXTURE_INFO *
956956
__GMM_ASSERT(!pTexInfo->Flags.Info.TiledW);
957957
// Client should always give us linear-fallback option for planar surfaces,
958958
// except for MMC surfaces, which are TileY.
959-
__GMM_ASSERT(pTexInfo->Flags.Info.Linear || pTexInfo->Flags.Gpu.MMC);
959+
//__GMM_ASSERT(pTexInfo->Flags.Info.Linear || pTexInfo->Flags.Gpu.MMC);
960960
pTexInfo->Flags.Info.Linear = 1;
961961
pTexInfo->TileMode = TILE_NONE;
962962

Source/GmmLib/Utility/GmmUtility.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ namespace GmmLib {
3333

3434
#if __cplusplus
3535
uint32_t GMM_STDCALL GmmGetNumPlanes(GMM_RESOURCE_FORMAT Format);
36-
GMM_RESOURCE_FORMAT GMM_STDCALL GmmGetFormatForASTC(uint8_t HDR,
37-
uint8_t Float,
38-
uint32_t BlockWidth,
39-
uint32_t BlockHeight,
36+
GMM_RESOURCE_FORMAT GMM_STDCALL GmmGetFormatForASTC(uint8_t HDR,
37+
uint8_t Float,
38+
uint32_t BlockWidth,
39+
uint32_t BlockHeight,
4040
uint32_t BlockDepth);
4141
#endif
4242
#if __cplusplus
@@ -67,7 +67,7 @@ extern NTSTATUS __GmmWriteDwordKeyValue(char *pCStringPath, WCHAR *pValueName, U
6767
#define REGISTRY_OVERRIDE_WRITE(Usage,CacheParam,Value) \
6868
__GmmWriteDwordKeyValue(GMM_CACHE_POLICY_OVERRIDE_REGISTY_PATH_REGISTRY_KMD #Usage , \
6969
L#CacheParam, \
70-
Value);
70+
Value);
7171

7272
#define GMM_REGISTRY_READ(Path, RegkeyName,RegkeyValue) \
7373
(__GmmReadDwordKeyValue(Path, \

Source/GmmLib/inc/External/Common/GmmTextureExt.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ typedef struct GMM_PLANAR_OFFSET_INFO_REC
4444
GMM_GFX_SIZE_T ArrayQPitch;
4545
GMM_GFX_SIZE_T X[GMM_MAX_PLANE];
4646
GMM_GFX_SIZE_T Y[GMM_MAX_PLANE];
47+
struct
48+
{
49+
GMM_GFX_SIZE_T Height[GMM_MAX_PLANE];
50+
} UnAligned;
51+
uint32_t NoOfPlanes;
52+
bool IsTileAlignedPlanes;
4753
}GMM_PLANAR_OFFSET_INFO;
4854

4955
//===========================================================================

0 commit comments

Comments
 (0)