@@ -307,6 +307,16 @@ GMM_STATUS GMM_STDCALL GmmLib::GmmResourceInfoCommon::Create(Context &GmmLibCont
307
307
goto ERROR_CASE;
308
308
}
309
309
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
+
310
320
if (Surf.Flags .Gpu .UnifiedAuxSurface )
311
321
{
312
322
GMM_GFX_SIZE_T TotalSize;
@@ -691,6 +701,139 @@ void GmmLib::GmmResourceInfoCommon::UpdateUnAlignedParams()
691
701
692
702
__GMM_ASSERTPTR (((Surf.OffsetInfo .Plane .Y [GMM_PLANE_U] == YHeight) && (UmdUHeight == VHeight)), VOIDRETURN);
693
703
}
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
+ }
694
837
695
838
// ///////////////////////////////////////////////////////////////////////////////////
696
839
// / Returns downscaled width for fast clear of given subresource
@@ -753,6 +896,74 @@ uint32_t GmmLib::GmmResourceInfoCommon::GetFastClearHeight(uint32_t MipLevel)
753
896
return height;
754
897
}
755
898
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
+
756
967
// ///////////////////////////////////////////////////////////////////////////////////
757
968
// / Returns the Platform info. If Platform has been overriden by the clients, then
758
969
// / it returns the overriden Platform Info struct.
@@ -1010,13 +1221,6 @@ uint32_t GMM_STDCALL GmmLib::GmmResourceInfoCommon::GetQPitch()
1010
1221
// ///////////////////////////////////////////////////////////////////////////////////
1011
1222
GMM_STATUS GMM_STDCALL GmmLib::GmmResourceInfoCommon::GetOffset (GMM_REQ_OFFSET_INFO &ReqInfo)
1012
1223
{
1013
-
1014
- GMM_TEXTURE_CALC *pTextureCalc;
1015
-
1016
- pTextureCalc = GMM_OVERRIDE_TEXTURE_CALC (&Surf);
1017
-
1018
- __GMM_ASSERT ((pTextureCalc != NULL ));
1019
-
1020
1224
if (Surf.Flags .Info .RedecribedPlanes )
1021
1225
{
1022
1226
uint8_t RestoreReqStdLayout = ReqInfo.ReqStdLayout ? 1 : 0 ;
@@ -1032,7 +1236,6 @@ GMM_STATUS GMM_STDCALL GmmLib::GmmResourceInfoCommon::GetOffset(GMM_REQ_OFFSET_I
1032
1236
if (ReqInfo.ReqStdLayout )
1033
1237
{
1034
1238
GMM_REQ_OFFSET_INFO TempReqInfo[GMM_MAX_PLANE] = {0 };
1035
- GMM_TEXTURE_INFO TexInfo[GMM_MAX_PLANE];
1036
1239
uint32_t Plane, TotalPlanes = GmmLib::Utility::GmmGetNumPlanes (Surf.Format );
1037
1240
1038
1241
// 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
1050
1253
1051
1254
TempReqInfo[GMM_PLANE_V] = TempReqInfo[GMM_PLANE_U] = TempReqInfo[GMM_PLANE_Y];
1052
1255
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]))
1060
1259
{
1061
1260
__GMM_ASSERT (0 );
1062
1261
return GMM_ERROR;
@@ -1086,9 +1285,9 @@ GMM_STATUS GMM_STDCALL GmmLib::GmmResourceInfoCommon::GetOffset(GMM_REQ_OFFSET_I
1086
1285
{
1087
1286
// Find the size of the previous planes and add it to the offset
1088
1287
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
+ {
1092
1291
__GMM_ASSERT (0 );
1093
1292
return GMM_ERROR;
1094
1293
}
@@ -1127,7 +1326,6 @@ uint8_t GMM_STDCALL GmmLib::GmmResourceInfoCommon::CpuBlt(GMM_RES_COPY_BLT *pBlt
1127
1326
uint8_t Success = 1 ;
1128
1327
GMM_TEXTURE_INFO * pTexInfo;
1129
1328
GMM_TEXTURE_CALC * pTextureCalc;
1130
- GMM_TEXTURE_INFO RedescribedPlaneInfo;
1131
1329
1132
1330
__GMM_ASSERTPTR (pBlt, 0 );
1133
1331
@@ -1260,17 +1458,16 @@ uint8_t GMM_STDCALL GmmLib::GmmResourceInfoCommon::CpuBlt(GMM_RES_COPY_BLT *pBlt
1260
1458
1261
1459
if (pBlt->Gpu .OffsetY < pTexInfo->OffsetInfo .Plane .Y [GMM_PLANE_U])
1262
1460
{
1263
- pTextureCalc->GetRedescribedPlaneParams (pTexInfo, GMM_PLANE_Y, &RedescribedPlaneInfo);
1264
1461
// Y Plane
1265
- pTexInfo = &RedescribedPlaneInfo ;
1462
+ pTexInfo = &(PlaneSurf[GMM_PLANE_Y]) ;
1266
1463
}
1267
1464
else
1268
1465
{
1269
1466
// UV Plane
1270
- pTextureCalc->GetRedescribedPlaneParams (pTexInfo, GMM_PLANE_U, &RedescribedPlaneInfo);
1271
- pTexInfo = &RedescribedPlaneInfo;
1272
- }
1467
+ pTexInfo = &(PlaneSurf[GMM_PLANE_U]);
1468
+ }
1273
1469
}
1470
+
1274
1471
if (pBlt->Blt .Slices > 1 )
1275
1472
{
1276
1473
GMM_RES_COPY_BLT SliceBlt = *pBlt;
@@ -1666,14 +1863,12 @@ uint8_t GMM_STDCALL GmmLib::GmmResourceInfoCommon::GetMappingSpanDesc(GMM_GET_MA
1666
1863
uint8_t WasFinalSpan = 0 ;
1667
1864
GMM_TEXTURE_INFO * pTexInfo;
1668
1865
GMM_TEXTURE_CALC * pTextureCalc;
1669
- GMM_TEXTURE_INFO RedescribedPlaneInfo;
1670
1866
1671
1867
__GMM_ASSERT (Surf.Flags .Info .StdSwizzle );
1672
1868
1673
1869
pPlatform = GMM_OVERRIDE_PLATFORM_INFO (&Surf);
1674
1870
pTextureCalc = GMM_OVERRIDE_TEXTURE_CALC (&Surf);
1675
-
1676
- __GMM_ASSERT (pTextureCalc != NULL );
1871
+
1677
1872
pTexInfo = &Surf;
1678
1873
1679
1874
if (pMapping->Type == GMM_MAPPING_GEN9_YS_TO_STDSWIZZLE)
@@ -1732,9 +1927,8 @@ uint8_t GMM_STDCALL GmmLib::GmmResourceInfoCommon::GetMappingSpanDesc(GMM_GET_MA
1732
1927
pMapping->__NextSpan .VirtualOffset = ReqInfo.Render .Offset64 ;
1733
1928
}
1734
1929
1735
- pTextureCalc->GetRedescribedPlaneParams (pTexInfo, GMM_PLANE_Y, &RedescribedPlaneInfo);
1736
- pTexInfo = &RedescribedPlaneInfo;
1737
- }
1930
+ pTexInfo = &PlaneSurf[pMapping->Scratch .Plane ];
1931
+ }
1738
1932
1739
1933
// Initialization of Mapping Params...
1740
1934
if (pMapping->Scratch .Element .Width == 0 ) // i.e. initially zero'ed struct.
@@ -2005,6 +2199,7 @@ void GMM_STDCALL GmmLib::GmmResourceInfoCommon::GetTiledResourceMipPacking(uint3
2005
2199
// Lod of first packed Mip
2006
2200
// -----------------------------------------------------------------------------
2007
2201
uint32_t GMM_STDCALL GmmLib::GmmResourceInfoCommon::GetPackedMipTailStartLod ()
2202
+
2008
2203
{
2009
2204
uint32_t NumPackedMips = 0 , NumTilesForPackedMips = 0 ;
2010
2205
0 commit comments