Skip to content

Commit 8057a63

Browse files
authored
Planar Surface Redescription: GMM existing path removal + pitch adjustment (#6)
1 parent 78ccfbb commit 8057a63

File tree

9 files changed

+272
-231
lines changed

9 files changed

+272
-231
lines changed

Source/GmmLib/Resource/GmmResourceInfoCommon.cpp

Lines changed: 30 additions & 225 deletions
Original file line numberDiff line numberDiff line change
@@ -307,16 +307,6 @@ 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-
320310
if(Surf.Flags.Gpu.UnifiedAuxSurface)
321311
{
322312
GMM_GFX_SIZE_T TotalSize;
@@ -701,139 +691,6 @@ void GmmLib::GmmResourceInfoCommon::UpdateUnAlignedParams()
701691

702692
__GMM_ASSERTPTR(((Surf.OffsetInfo.Plane.Y[GMM_PLANE_U] == YHeight) && (UmdUHeight == VHeight)), VOIDRETURN);
703693
}
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-
}
837694

838695
/////////////////////////////////////////////////////////////////////////////////////
839696
/// Returns downscaled width for fast clear of given subresource
@@ -896,74 +753,6 @@ uint32_t GmmLib::GmmResourceInfoCommon::GetFastClearHeight(uint32_t MipLevel)
896753
return height;
897754
}
898755

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-
967756
/////////////////////////////////////////////////////////////////////////////////////
968757
/// Returns the Platform info. If Platform has been overriden by the clients, then
969758
/// it returns the overriden Platform Info struct.
@@ -1221,6 +1010,13 @@ uint32_t GMM_STDCALL GmmLib::GmmResourceInfoCommon::GetQPitch()
12211010
/////////////////////////////////////////////////////////////////////////////////////
12221011
GMM_STATUS GMM_STDCALL GmmLib::GmmResourceInfoCommon::GetOffset(GMM_REQ_OFFSET_INFO &ReqInfo)
12231012
{
1013+
1014+
GMM_TEXTURE_CALC *pTextureCalc;
1015+
1016+
pTextureCalc = GMM_OVERRIDE_TEXTURE_CALC(&Surf);
1017+
1018+
__GMM_ASSERT((pTextureCalc != NULL));
1019+
12241020
if(Surf.Flags.Info.RedecribedPlanes)
12251021
{
12261022
uint8_t RestoreReqStdLayout = ReqInfo.ReqStdLayout ? 1 : 0;
@@ -1236,6 +1032,7 @@ GMM_STATUS GMM_STDCALL GmmLib::GmmResourceInfoCommon::GetOffset(GMM_REQ_OFFSET_I
12361032
if(ReqInfo.ReqStdLayout)
12371033
{
12381034
GMM_REQ_OFFSET_INFO TempReqInfo[GMM_MAX_PLANE] = {0};
1035+
GMM_TEXTURE_INFO TexInfo[GMM_MAX_PLANE];
12391036
uint32_t Plane, TotalPlanes = GmmLib::Utility::GmmGetNumPlanes(Surf.Format);
12401037

12411038
// Caller must specify which plane they need the offset into if not
@@ -1253,9 +1050,13 @@ GMM_STATUS GMM_STDCALL GmmLib::GmmResourceInfoCommon::GetOffset(GMM_REQ_OFFSET_I
12531050

12541051
TempReqInfo[GMM_PLANE_V] = TempReqInfo[GMM_PLANE_U] = TempReqInfo[GMM_PLANE_Y];
12551052

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]))
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]))
12591060
{
12601061
__GMM_ASSERT(0);
12611062
return GMM_ERROR;
@@ -1285,9 +1086,9 @@ GMM_STATUS GMM_STDCALL GmmLib::GmmResourceInfoCommon::GetOffset(GMM_REQ_OFFSET_I
12851086
{
12861087
// Find the size of the previous planes and add it to the offset
12871088
TempReqInfo[Plane].StdLayout.Offset = -1;
1288-
1289-
if(GMM_SUCCESS != GmmTexGetMipMapOffset(&PlaneSurf[Plane], &TempReqInfo[Plane]))
1290-
{
1089+
1090+
if(GMM_SUCCESS != GmmTexGetMipMapOffset(&TexInfo[Plane], &TempReqInfo[Plane]))
1091+
{
12911092
__GMM_ASSERT(0);
12921093
return GMM_ERROR;
12931094
}
@@ -1326,6 +1127,7 @@ uint8_t GMM_STDCALL GmmLib::GmmResourceInfoCommon::CpuBlt(GMM_RES_COPY_BLT *pBlt
13261127
uint8_t Success = 1;
13271128
GMM_TEXTURE_INFO * pTexInfo;
13281129
GMM_TEXTURE_CALC * pTextureCalc;
1130+
GMM_TEXTURE_INFO RedescribedPlaneInfo;
13291131

13301132
__GMM_ASSERTPTR(pBlt, 0);
13311133

@@ -1458,16 +1260,17 @@ uint8_t GMM_STDCALL GmmLib::GmmResourceInfoCommon::CpuBlt(GMM_RES_COPY_BLT *pBlt
14581260

14591261
if(pBlt->Gpu.OffsetY < pTexInfo->OffsetInfo.Plane.Y[GMM_PLANE_U])
14601262
{
1263+
pTextureCalc->GetRedescribedPlaneParams(pTexInfo, GMM_PLANE_Y, &RedescribedPlaneInfo);
14611264
// Y Plane
1462-
pTexInfo = &(PlaneSurf[GMM_PLANE_Y]);
1265+
pTexInfo = &RedescribedPlaneInfo;
14631266
}
14641267
else
14651268
{
14661269
// UV Plane
1467-
pTexInfo = &(PlaneSurf[GMM_PLANE_U]);
1468-
}
1270+
pTextureCalc->GetRedescribedPlaneParams(pTexInfo, GMM_PLANE_U, &RedescribedPlaneInfo);
1271+
pTexInfo = &RedescribedPlaneInfo;
1272+
}
14691273
}
1470-
14711274
if(pBlt->Blt.Slices > 1)
14721275
{
14731276
GMM_RES_COPY_BLT SliceBlt = *pBlt;
@@ -1863,12 +1666,14 @@ uint8_t GMM_STDCALL GmmLib::GmmResourceInfoCommon::GetMappingSpanDesc(GMM_GET_MA
18631666
uint8_t WasFinalSpan = 0;
18641667
GMM_TEXTURE_INFO * pTexInfo;
18651668
GMM_TEXTURE_CALC * pTextureCalc;
1669+
GMM_TEXTURE_INFO RedescribedPlaneInfo;
18661670

18671671
__GMM_ASSERT(Surf.Flags.Info.StdSwizzle);
18681672

18691673
pPlatform = GMM_OVERRIDE_PLATFORM_INFO(&Surf);
18701674
pTextureCalc = GMM_OVERRIDE_TEXTURE_CALC(&Surf);
1871-
1675+
1676+
__GMM_ASSERT(pTextureCalc != NULL);
18721677
pTexInfo = &Surf;
18731678

18741679
if(pMapping->Type == GMM_MAPPING_GEN9_YS_TO_STDSWIZZLE)
@@ -1927,8 +1732,9 @@ uint8_t GMM_STDCALL GmmLib::GmmResourceInfoCommon::GetMappingSpanDesc(GMM_GET_MA
19271732
pMapping->__NextSpan.VirtualOffset = ReqInfo.Render.Offset64;
19281733
}
19291734

1930-
pTexInfo = &PlaneSurf[pMapping->Scratch.Plane];
1931-
}
1735+
pTextureCalc->GetRedescribedPlaneParams(pTexInfo, GMM_PLANE_Y, &RedescribedPlaneInfo);
1736+
pTexInfo = &RedescribedPlaneInfo;
1737+
}
19321738

19331739
// Initialization of Mapping Params...
19341740
if(pMapping->Scratch.Element.Width == 0) // i.e. initially zero'ed struct.
@@ -2199,7 +2005,6 @@ void GMM_STDCALL GmmLib::GmmResourceInfoCommon::GetTiledResourceMipPacking(uint3
21992005
// Lod of first packed Mip
22002006
//-----------------------------------------------------------------------------
22012007
uint32_t GMM_STDCALL GmmLib::GmmResourceInfoCommon::GetPackedMipTailStartLod()
2202-
22032008
{
22042009
uint32_t NumPackedMips = 0, NumTilesForPackedMips = 0;
22052010

Source/GmmLib/Texture/GmmGen10Texture.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -894,6 +894,14 @@ GMM_STATUS GMM_STDCALL GmmLib::GmmGen10TextureCalc::FillTexPlanar(GMM_TEXTURE_IN
894894
}
895895
}
896896

897+
if(pTexInfo->Flags.Info.RedecribedPlanes)
898+
{
899+
if(false == RedescribeTexturePlanes(pTexInfo, &WidthBytesPhysical))
900+
{
901+
__GMM_ASSERT(FALSE);
902+
}
903+
}
904+
897905
if((Status = // <-- Note assignment.
898906
FillTexPitchAndSize(
899907
pTexInfo, WidthBytesPhysical, Height, pRestrictions)) == GMM_SUCCESS)

Source/GmmLib/Texture/GmmGen11Texture.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,6 +1085,14 @@ GMM_STATUS GMM_STDCALL GmmLib::GmmGen11TextureCalc::FillTexPlanar(GMM_TEXTURE_IN
10851085
pTexInfo->Flags.Gpu.MMC = 0;
10861086
}
10871087
}
1088+
1089+
if(pTexInfo->Flags.Info.RedecribedPlanes)
1090+
{
1091+
if(false == RedescribeTexturePlanes(pTexInfo, &WidthBytesPhysical))
1092+
{
1093+
__GMM_ASSERT(FALSE);
1094+
}
1095+
}
10881096

10891097
if((Status = // <-- Note assignment.
10901098
FillTexPitchAndSize(

Source/GmmLib/Texture/GmmGen12Texture.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -923,6 +923,14 @@ GMM_STATUS GMM_STDCALL GmmLib::GmmGen12TextureCalc::FillTexPlanar(GMM_TEXTURE_IN
923923

924924
Height = YHeight + VHeight;
925925
}
926+
927+
if(pTexInfo->Flags.Info.RedecribedPlanes)
928+
{
929+
if(false == RedescribeTexturePlanes(pTexInfo, &WidthBytesPhysical))
930+
{
931+
__GMM_ASSERT(FALSE);
932+
}
933+
}
926934

927935
if((Status = // <-- Note assignment.
928936
FillTexPitchAndSize(

0 commit comments

Comments
 (0)