@@ -307,6 +307,16 @@ GMM_STATUS GMM_STDCALL GmmLib::GmmResourceInfoCommon::Create(Context &GmmLibCont
307307 goto ERROR_CASE;
308308 }
309309
310+ // Fill out the texture info for each plane if they require rediscription
311+ if (Surf.Flags .Info .RedecribedPlanes )
312+ {
313+ if (false == RedescribePlanes ())
314+ {
315+ GMM_ASSERTDPF (0 , " Redescribe planes failed!" );
316+ goto ERROR_CASE;
317+ }
318+ }
319+
310320 if (Surf.Flags .Gpu .UnifiedAuxSurface )
311321 {
312322 GMM_GFX_SIZE_T TotalSize;
@@ -691,6 +701,139 @@ void GmmLib::GmmResourceInfoCommon::UpdateUnAlignedParams()
691701
692702 __GMM_ASSERTPTR (((Surf.OffsetInfo .Plane .Y [GMM_PLANE_U] == YHeight) && (UmdUHeight == VHeight)), VOIDRETURN);
693703}
704+ // ///////////////////////////////////////////////////////////////////////////////////
705+ // / This function calculates number of planes required for the given input format
706+ // / and allocates texture info for the respective planes.
707+ // /
708+ // / @return ::bool
709+ // ///////////////////////////////////////////////////////////////////////////////////
710+ bool GmmLib::GmmResourceInfoCommon::RedescribePlanes ()
711+ {
712+ const GMM_PLATFORM_INFO *pPlatform;
713+ GMM_TEXTURE_CALC * pTextureCalc = NULL ;
714+ GMM_STATUS Status = GMM_SUCCESS;
715+ int MaxPlanes = 1 ;
716+
717+ pPlatform = GMM_OVERRIDE_PLATFORM_INFO (&Surf);
718+ pTextureCalc = GMM_OVERRIDE_TEXTURE_CALC (&Surf);
719+
720+ __GMM_ASSERT (Surf.Flags .Info .RedecribedPlanes );
721+
722+ GMM_TEXTURE_INFO *pYPlane = &PlaneSurf[GMM_PLANE_Y];
723+ GMM_TEXTURE_INFO *pUPlane = &PlaneSurf[GMM_PLANE_U];
724+ GMM_TEXTURE_INFO *pVPlane = &PlaneSurf[GMM_PLANE_V];
725+
726+ pYPlane->Type = Surf.Type ;
727+ pYPlane->BaseWidth = Surf.BaseWidth ;
728+ pYPlane->BaseHeight = Surf.BaseHeight ;
729+ pYPlane->Depth = Surf.Depth ;
730+ pYPlane->ArraySize = Surf.ArraySize ;
731+ pYPlane->MSAA = Surf.MSAA ;
732+ pYPlane->Flags = Surf.Flags ;
733+ pYPlane->BitsPerPixel = Surf.BitsPerPixel ;
734+
735+ #if (_DEBUG || _RELEASE_INTERNAL)
736+ pYPlane->Platform = Surf.Platform ;
737+ #endif
738+
739+ pYPlane->Flags .Info .RedecribedPlanes = false ;
740+
741+ *pUPlane = *pVPlane = *pYPlane;
742+
743+ if (GmmIsUVPacked (Surf.Format ))
744+ {
745+ // UV packed resources must have two seperate
746+ // tiling modes per plane, due to the packed
747+ // UV plane having twice the bits per pixel
748+ // as the Y plane.
749+
750+ if (Surf.BitsPerPixel == 8 )
751+ {
752+ pYPlane->BitsPerPixel = 8 ;
753+ pYPlane->Format = GMM_FORMAT_R8_UINT;
754+
755+ pUPlane->BitsPerPixel = 16 ;
756+ pUPlane->Format = GMM_FORMAT_R16_UINT;
757+ }
758+ else if (Surf.BitsPerPixel == 16 )
759+ {
760+ pYPlane->BitsPerPixel = 16 ;
761+ pYPlane->Format = GMM_FORMAT_R16_UINT;
762+
763+ pUPlane->BitsPerPixel = 32 ;
764+ pUPlane->Format = GMM_FORMAT_R32_UINT;
765+ }
766+ else
767+ {
768+ GMM_ASSERTDPF (0 , " Unsupported format/pixel size combo!" );
769+ Status = GMM_INVALIDPARAM;
770+ goto ERROR_CASE;
771+ }
772+
773+ pUPlane->BaseHeight = GFX_CEIL_DIV (pYPlane->BaseHeight , 2 );
774+ pUPlane->BaseWidth = GFX_CEIL_DIV (pYPlane->BaseWidth , 2 );
775+ MaxPlanes = 2 ;
776+ }
777+ else
778+ {
779+ // Non-UV packed surfaces only require the plane descriptors
780+ // have proper height and width for each plane
781+ switch (Surf.Format )
782+ {
783+ case GMM_FORMAT_IMC1:
784+ case GMM_FORMAT_IMC2:
785+ case GMM_FORMAT_IMC3:
786+ case GMM_FORMAT_IMC4:
787+ case GMM_FORMAT_MFX_JPEG_YUV420:
788+ {
789+ pUPlane->BaseWidth = pVPlane->BaseWidth = GFX_CEIL_DIV (pYPlane->BaseWidth , 2 );
790+ }
791+ case GMM_FORMAT_MFX_JPEG_YUV422V:
792+ {
793+ pUPlane->BaseHeight = pVPlane->BaseHeight = GFX_CEIL_DIV (pYPlane->BaseHeight , 2 );
794+ break ;
795+ }
796+ case GMM_FORMAT_MFX_JPEG_YUV411R_TYPE:
797+ {
798+ pUPlane->BaseHeight = pVPlane->BaseHeight = GFX_CEIL_DIV (pYPlane->BaseHeight , 4 );
799+ break ;
800+ }
801+ case GMM_FORMAT_MFX_JPEG_YUV411:
802+ {
803+ pUPlane->BaseWidth = pVPlane->BaseWidth = GFX_CEIL_DIV (pYPlane->BaseWidth , 4 );
804+ break ;
805+ }
806+ case GMM_FORMAT_MFX_JPEG_YUV422H:
807+ {
808+ pUPlane->BaseWidth = pVPlane->BaseWidth = GFX_CEIL_DIV (pYPlane->BaseWidth , 2 );
809+ break ;
810+ }
811+ default :
812+ {
813+ break ;
814+ }
815+ }
816+
817+ pYPlane->Format = pUPlane->Format = pVPlane->Format =
818+ (pYPlane->BitsPerPixel == 8 ) ? GMM_FORMAT_R8_UINT : GMM_FORMAT_R16_UINT;
819+ MaxPlanes = 3 ;
820+ }
821+
822+ for (int i = GMM_PLANE_Y; i <= MaxPlanes; i++) // all 2 or 3 planes
823+ {
824+ if ((GMM_SUCCESS != pTextureCalc->AllocateTexture (&PlaneSurf[i])))
825+ {
826+ GMM_ASSERTDPF (false , " GmmTexAlloc failed!" );
827+ Status = GMM_ERROR;
828+ goto ERROR_CASE;
829+ }
830+ }
831+
832+ Status = static_cast <GMM_STATUS>(false == ReAdjustPlaneProperties (false ));
833+
834+ ERROR_CASE:
835+ return (Status == GMM_SUCCESS) ? true : false ;
836+ }
694837
695838// ///////////////////////////////////////////////////////////////////////////////////
696839// / Returns downscaled width for fast clear of given subresource
@@ -753,6 +896,74 @@ uint32_t GmmLib::GmmResourceInfoCommon::GetFastClearHeight(uint32_t MipLevel)
753896 return height;
754897}
755898
899+
900+ // ///////////////////////////////////////////////////////////////////////////////////
901+ // / This function readjustes Plane properties. Valid for MainSurf not for AuxSurf
902+ // /
903+ // / @param[in] bool: Whether Surf is Aux
904+ // /
905+ // / @return ::bool
906+ // ///////////////////////////////////////////////////////////////////////////////////
907+ bool GmmLib::GmmResourceInfoCommon::ReAdjustPlaneProperties (bool IsAuxSurf)
908+ {
909+ const GMM_PLATFORM_INFO *pPlatform = GMM_OVERRIDE_PLATFORM_INFO (&Surf);
910+ GMM_TEXTURE_INFO * pTexInfo = &Surf;
911+ GMM_TEXTURE_INFO * pPlaneTexInfo = PlaneSurf;
912+
913+ if (IsAuxSurf)
914+ {
915+ // AuxSurf isn't redescribed
916+ return false ;
917+ }
918+
919+ if (GmmIsUVPacked (pTexInfo->Format ))
920+ {
921+ pPlaneTexInfo[GMM_PLANE_V] = pPlaneTexInfo[GMM_PLANE_U];
922+
923+ // Need to adjust the returned surfaces and then copy
924+ // the relivent data into the parent descriptor.
925+ // UV plane is wider while Y plane is taller,
926+ // so adjust pitch and sizes to fit accordingly
927+ pTexInfo->Alignment = pPlaneTexInfo[GMM_PLANE_U].Alignment ;
928+ pTexInfo->Alignment .VAlign = pPlaneTexInfo[GMM_PLANE_Y].Alignment .VAlign ;
929+
930+ if (pPlaneTexInfo[GMM_PLANE_Y].Pitch != pPlaneTexInfo[GMM_PLANE_U].Pitch )
931+ {
932+ pPlaneTexInfo[GMM_PLANE_Y].Size = (pPlaneTexInfo[GMM_PLANE_Y].Size / pPlaneTexInfo[GMM_PLANE_Y].Pitch ) * pPlaneTexInfo[GMM_PLANE_U].Pitch ;
933+ __GMM_ASSERT (GFX_IS_ALIGNED (pPlaneTexInfo[GMM_PLANE_Y].Size , pPlatform->TileInfo [pPlaneTexInfo[GMM_PLANE_Y].TileMode ].LogicalSize ));
934+
935+ if (pPlaneTexInfo[GMM_PLANE_Y].ArraySize > 1 )
936+ {
937+ pPlaneTexInfo[GMM_PLANE_Y].OffsetInfo .Texture2DOffsetInfo .ArrayQPitchRender =
938+ pPlaneTexInfo[GMM_PLANE_Y].OffsetInfo .Texture2DOffsetInfo .ArrayQPitchLock =
939+ pPlaneTexInfo[GMM_PLANE_Y].Size / pPlaneTexInfo[GMM_PLANE_Y].ArraySize ;
940+ }
941+
942+ pTexInfo->Pitch = pPlaneTexInfo[GMM_PLANE_Y].Pitch = pPlaneTexInfo[GMM_PLANE_U].Pitch ;
943+ }
944+
945+ pTexInfo->OffsetInfo .Plane .ArrayQPitch =
946+ pPlaneTexInfo[GMM_PLANE_Y].OffsetInfo .Texture2DOffsetInfo .ArrayQPitchRender +
947+ pPlaneTexInfo[GMM_PLANE_U].OffsetInfo .Texture2DOffsetInfo .ArrayQPitchRender ;
948+
949+ pTexInfo->Size = pPlaneTexInfo[GMM_PLANE_Y].Size + pPlaneTexInfo[GMM_PLANE_U].Size ;
950+
951+ if (pTexInfo->Size > (GMM_GFX_SIZE_T)(pPlatform->SurfaceMaxSize ))
952+ {
953+ GMM_ASSERTDPF (0 , " Surface too large!" );
954+ return false ;
955+ }
956+ }
957+ else
958+ {
959+ // The parent resource should be the same size as all of the child planes
960+ __GMM_ASSERT (pTexInfo->Size == (pPlaneTexInfo[GMM_PLANE_Y].Size +
961+ pPlaneTexInfo[GMM_PLANE_U].Size + pPlaneTexInfo[GMM_PLANE_U].Size ));
962+ }
963+
964+ return true ;
965+ }
966+
756967// ///////////////////////////////////////////////////////////////////////////////////
757968// / Returns the Platform info. If Platform has been overriden by the clients, then
758969// / it returns the overriden Platform Info struct.
@@ -1010,13 +1221,6 @@ uint32_t GMM_STDCALL GmmLib::GmmResourceInfoCommon::GetQPitch()
10101221// ///////////////////////////////////////////////////////////////////////////////////
10111222GMM_STATUS GMM_STDCALL GmmLib::GmmResourceInfoCommon::GetOffset (GMM_REQ_OFFSET_INFO &ReqInfo)
10121223{
1013-
1014- GMM_TEXTURE_CALC *pTextureCalc;
1015-
1016- pTextureCalc = GMM_OVERRIDE_TEXTURE_CALC (&Surf);
1017-
1018- __GMM_ASSERT ((pTextureCalc != NULL ));
1019-
10201224 if (Surf.Flags .Info .RedecribedPlanes )
10211225 {
10221226 uint8_t RestoreReqStdLayout = ReqInfo.ReqStdLayout ? 1 : 0 ;
@@ -1032,7 +1236,6 @@ GMM_STATUS GMM_STDCALL GmmLib::GmmResourceInfoCommon::GetOffset(GMM_REQ_OFFSET_I
10321236 if (ReqInfo.ReqStdLayout )
10331237 {
10341238 GMM_REQ_OFFSET_INFO TempReqInfo[GMM_MAX_PLANE] = {0 };
1035- GMM_TEXTURE_INFO TexInfo[GMM_MAX_PLANE];
10361239 uint32_t Plane, TotalPlanes = GmmLib::Utility::GmmGetNumPlanes (Surf.Format );
10371240
10381241 // Caller must specify which plane they need the offset into if not
@@ -1050,13 +1253,9 @@ GMM_STATUS GMM_STDCALL GmmLib::GmmResourceInfoCommon::GetOffset(GMM_REQ_OFFSET_I
10501253
10511254 TempReqInfo[GMM_PLANE_V] = TempReqInfo[GMM_PLANE_U] = TempReqInfo[GMM_PLANE_Y];
10521255
1053- pTextureCalc->GetRedescribedPlaneParams (&Surf, GMM_PLANE_Y, &TexInfo[GMM_PLANE_Y]);
1054- pTextureCalc->GetRedescribedPlaneParams (&Surf, GMM_PLANE_U, &TexInfo[GMM_PLANE_U]);
1055- pTextureCalc->GetRedescribedPlaneParams (&Surf, GMM_PLANE_V, &TexInfo[GMM_PLANE_V]);
1056-
1057- if (GMM_SUCCESS != GmmTexGetMipMapOffset (&TexInfo[GMM_PLANE_Y], &TempReqInfo[GMM_PLANE_Y]) ||
1058- GMM_SUCCESS != GmmTexGetMipMapOffset (&TexInfo[GMM_PLANE_U], &TempReqInfo[GMM_PLANE_U]) ||
1059- GMM_SUCCESS != GmmTexGetMipMapOffset (&TexInfo[GMM_PLANE_V], &TempReqInfo[GMM_PLANE_V]))
1256+ if (GMM_SUCCESS != GmmTexGetMipMapOffset (&PlaneSurf[GMM_PLANE_Y], &TempReqInfo[GMM_PLANE_Y]) ||
1257+ GMM_SUCCESS != GmmTexGetMipMapOffset (&PlaneSurf[GMM_PLANE_U], &TempReqInfo[GMM_PLANE_U]) ||
1258+ GMM_SUCCESS != GmmTexGetMipMapOffset (&PlaneSurf[GMM_PLANE_V], &TempReqInfo[GMM_PLANE_V]))
10601259 {
10611260 __GMM_ASSERT (0 );
10621261 return GMM_ERROR;
@@ -1086,9 +1285,9 @@ GMM_STATUS GMM_STDCALL GmmLib::GmmResourceInfoCommon::GetOffset(GMM_REQ_OFFSET_I
10861285 {
10871286 // Find the size of the previous planes and add it to the offset
10881287 TempReqInfo[Plane].StdLayout .Offset = -1 ;
1089-
1090- if (GMM_SUCCESS != GmmTexGetMipMapOffset (&TexInfo [Plane], &TempReqInfo[Plane]))
1091- {
1288+
1289+ if (GMM_SUCCESS != GmmTexGetMipMapOffset (&PlaneSurf [Plane], &TempReqInfo[Plane]))
1290+ {
10921291 __GMM_ASSERT (0 );
10931292 return GMM_ERROR;
10941293 }
@@ -1127,7 +1326,6 @@ uint8_t GMM_STDCALL GmmLib::GmmResourceInfoCommon::CpuBlt(GMM_RES_COPY_BLT *pBlt
11271326 uint8_t Success = 1 ;
11281327 GMM_TEXTURE_INFO * pTexInfo;
11291328 GMM_TEXTURE_CALC * pTextureCalc;
1130- GMM_TEXTURE_INFO RedescribedPlaneInfo;
11311329
11321330 __GMM_ASSERTPTR (pBlt, 0 );
11331331
@@ -1260,17 +1458,16 @@ uint8_t GMM_STDCALL GmmLib::GmmResourceInfoCommon::CpuBlt(GMM_RES_COPY_BLT *pBlt
12601458
12611459 if (pBlt->Gpu .OffsetY < pTexInfo->OffsetInfo .Plane .Y [GMM_PLANE_U])
12621460 {
1263- pTextureCalc->GetRedescribedPlaneParams (pTexInfo, GMM_PLANE_Y, &RedescribedPlaneInfo);
12641461 // Y Plane
1265- pTexInfo = &RedescribedPlaneInfo ;
1462+ pTexInfo = &(PlaneSurf[GMM_PLANE_Y]) ;
12661463 }
12671464 else
12681465 {
12691466 // UV Plane
1270- pTextureCalc->GetRedescribedPlaneParams (pTexInfo, GMM_PLANE_U, &RedescribedPlaneInfo);
1271- pTexInfo = &RedescribedPlaneInfo;
1272- }
1467+ pTexInfo = &(PlaneSurf[GMM_PLANE_U]);
1468+ }
12731469 }
1470+
12741471 if (pBlt->Blt .Slices > 1 )
12751472 {
12761473 GMM_RES_COPY_BLT SliceBlt = *pBlt;
@@ -1666,14 +1863,12 @@ uint8_t GMM_STDCALL GmmLib::GmmResourceInfoCommon::GetMappingSpanDesc(GMM_GET_MA
16661863 uint8_t WasFinalSpan = 0 ;
16671864 GMM_TEXTURE_INFO * pTexInfo;
16681865 GMM_TEXTURE_CALC * pTextureCalc;
1669- GMM_TEXTURE_INFO RedescribedPlaneInfo;
16701866
16711867 __GMM_ASSERT (Surf.Flags .Info .StdSwizzle );
16721868
16731869 pPlatform = GMM_OVERRIDE_PLATFORM_INFO (&Surf);
16741870 pTextureCalc = GMM_OVERRIDE_TEXTURE_CALC (&Surf);
1675-
1676- __GMM_ASSERT (pTextureCalc != NULL );
1871+
16771872 pTexInfo = &Surf;
16781873
16791874 if (pMapping->Type == GMM_MAPPING_GEN9_YS_TO_STDSWIZZLE)
@@ -1732,9 +1927,8 @@ uint8_t GMM_STDCALL GmmLib::GmmResourceInfoCommon::GetMappingSpanDesc(GMM_GET_MA
17321927 pMapping->__NextSpan .VirtualOffset = ReqInfo.Render .Offset64 ;
17331928 }
17341929
1735- pTextureCalc->GetRedescribedPlaneParams (pTexInfo, GMM_PLANE_Y, &RedescribedPlaneInfo);
1736- pTexInfo = &RedescribedPlaneInfo;
1737- }
1930+ pTexInfo = &PlaneSurf[pMapping->Scratch .Plane ];
1931+ }
17381932
17391933 // Initialization of Mapping Params...
17401934 if (pMapping->Scratch .Element .Width == 0 ) // i.e. initially zero'ed struct.
@@ -2005,6 +2199,7 @@ void GMM_STDCALL GmmLib::GmmResourceInfoCommon::GetTiledResourceMipPacking(uint3
20052199// Lod of first packed Mip
20062200// -----------------------------------------------------------------------------
20072201uint32_t GMM_STDCALL GmmLib::GmmResourceInfoCommon::GetPackedMipTailStartLod ()
2202+
20082203{
20092204 uint32_t NumPackedMips = 0 , NumTilesForPackedMips = 0 ;
20102205
0 commit comments