@@ -629,3 +629,200 @@ bool GmmLib::GmmTextureCalc::GmmGetD3DToHwTileConversion(GMM_TEXTURE_INFO *pTexI
629
629
*pRowFactor = 0 ;
630
630
return false ;
631
631
}
632
+
633
+ // ///////////////////////////////////////////////////////////////////////////////////
634
+ // / This function redescribes WidthBytesPhysical of main surface as per UV plane bpp and tilemode
635
+ // /
636
+ // / @return ::bool
637
+ // ///////////////////////////////////////////////////////////////////////////////////
638
+ bool GmmLib::GmmTextureCalc::RedescribeTexturePlanes (GMM_TEXTURE_INFO *pTexInfo, uint32_t *pWidthBytesPhysical)
639
+ {
640
+ GMM_STATUS Status = GMM_SUCCESS;
641
+ GMM_TEXTURE_INFO TexInfoUVPlane;
642
+ const GMM_PLATFORM_INFO *pPlatform = GMM_OVERRIDE_PLATFORM_INFO (pTexInfo);
643
+
644
+ __GMM_ASSERT (pTexInfo);
645
+ __GMM_ASSERT (pTexInfo->Flags .Info .RedecribedPlanes );
646
+ __GMM_ASSERT (pWidthBytesPhysical);
647
+
648
+ TexInfoUVPlane = *pTexInfo;
649
+ #ifdef _WIN32
650
+ memcpy_s (&TexInfoUVPlane, sizeof (GMM_TEXTURE_INFO), pTexInfo, sizeof (GMM_TEXTURE_INFO));
651
+ #else
652
+ memcpy (&TexInfoUVPlane, pTexInfo, sizeof (GMM_TEXTURE_INFO));
653
+ #endif // _WIN32
654
+
655
+
656
+ if (GmmIsUVPacked (pTexInfo->Format ))
657
+ {
658
+ // UV packed resources must have two seperate
659
+ // tiling modes per plane, due to the packed
660
+ // UV plane having twice the bits per pixel
661
+ // as the Y plane.
662
+ switch (pTexInfo->Format )
663
+ {
664
+ case GMM_FORMAT_NV12:
665
+ case GMM_FORMAT_NV21:
666
+ case GMM_FORMAT_P208:
667
+ TexInfoUVPlane.BitsPerPixel = 16 ; // Redescribe bpp to 16 from 8
668
+ break ;
669
+ case GMM_FORMAT_P010:
670
+ case GMM_FORMAT_P012:
671
+ case GMM_FORMAT_P016:
672
+ case GMM_FORMAT_P216:
673
+ TexInfoUVPlane.BitsPerPixel = 32 ;
674
+ break ;
675
+ default :
676
+ GMM_ASSERTDPF (0 , " Unsupported format/pixel size combo!" );
677
+ Status = GMM_INVALIDPARAM;
678
+ goto ERROR_CASE;
679
+ break ;
680
+ }
681
+ }
682
+ else
683
+ {
684
+ // Non-UV packed surfaces, TileMode and bpp of each plane is same as that of pTexInfo
685
+ }
686
+
687
+ SetTileMode (&TexInfoUVPlane);
688
+ *pWidthBytesPhysical = GFX_ALIGN (*pWidthBytesPhysical, pPlatform->TileInfo [TexInfoUVPlane.TileMode ].LogicalTileWidth );
689
+
690
+ ERROR_CASE:
691
+ return (Status == GMM_SUCCESS) ? true : false ;
692
+ }
693
+
694
+ // ///////////////////////////////////////////////////////////////////////////////////
695
+ // / This function returns per plane redescribed parameters (pRedescribedTexInfo: fmt, tilemode,bpp, width, height, size) when main surface pTexInfo is passed
696
+ // /
697
+ // / @return ::bool
698
+ // ///////////////////////////////////////////////////////////////////////////////////
699
+ bool GmmLib::GmmTextureCalc::GetRedescribedPlaneParams (GMM_TEXTURE_INFO *pTexInfo, GMM_YUV_PLANE PlaneType, GMM_TEXTURE_INFO *pRedescribedTexInfo)
700
+ {
701
+ GMM_STATUS Status = GMM_SUCCESS;
702
+ GMM_TEXTURE_INFO TexInfoUVPlane;
703
+ const GMM_PLATFORM_INFO *pPlatform = GMM_OVERRIDE_PLATFORM_INFO (pTexInfo);
704
+
705
+ __GMM_ASSERT (pTexInfo);
706
+ __GMM_ASSERT (pTexInfo->Flags .Info .RedecribedPlanes );
707
+ __GMM_ASSERT (pRedescribedTexInfo);
708
+
709
+ *pRedescribedTexInfo = *pTexInfo;
710
+ pRedescribedTexInfo->Flags .Info .RedecribedPlanes = 0 ;
711
+ #ifdef _WIN32
712
+ memcpy_s (&TexInfoUVPlane, sizeof (GMM_TEXTURE_INFO), pTexInfo, sizeof (GMM_TEXTURE_INFO));
713
+ #else
714
+ memcpy (&TexInfoUVPlane, pTexInfo, sizeof (GMM_TEXTURE_INFO));
715
+ #endif // _WIN32
716
+
717
+ if (GmmIsUVPacked (pTexInfo->Format ))
718
+ {
719
+ // UV packed resources must have two seperate
720
+ // tiling modes per plane, due to the packed
721
+ // UV plane having twice the bits per pixel
722
+ // as the Y plane.
723
+ if ((PlaneType == GMM_PLANE_U) || (PlaneType == GMM_PLANE_V))
724
+ {
725
+ switch (pTexInfo->Format )
726
+ {
727
+ // GMM_FORMAT_NV11 : linear format, no tiling supported, hence no redescription supported
728
+ case GMM_FORMAT_NV12:
729
+ case GMM_FORMAT_NV21:
730
+ pRedescribedTexInfo->BitsPerPixel = 16 ;
731
+ pRedescribedTexInfo->BaseWidth = GFX_CEIL_DIV (pTexInfo->BaseWidth , 2 );
732
+ pRedescribedTexInfo->BaseHeight = GFX_CEIL_DIV (pTexInfo->BaseHeight , 2 );
733
+ break ;
734
+ case GMM_FORMAT_P208:
735
+ pRedescribedTexInfo->BitsPerPixel = 16 ;
736
+ pRedescribedTexInfo->BaseWidth = GFX_CEIL_DIV (pTexInfo->BaseWidth , 2 );
737
+ // same base height as main surface
738
+ break ;
739
+ case GMM_FORMAT_P010:
740
+ case GMM_FORMAT_P012:
741
+ case GMM_FORMAT_P016:
742
+ pRedescribedTexInfo->BitsPerPixel = 32 ;
743
+ pRedescribedTexInfo->BaseWidth = GFX_CEIL_DIV (pTexInfo->BaseWidth , 2 );
744
+ pRedescribedTexInfo->BaseHeight = GFX_CEIL_DIV (pTexInfo->BaseHeight , 2 );
745
+ break ;
746
+ case GMM_FORMAT_P216:
747
+ pRedescribedTexInfo->BitsPerPixel = 32 ;
748
+ pRedescribedTexInfo->BaseWidth = GFX_CEIL_DIV (pTexInfo->BaseWidth , 2 );
749
+ // same base height as main surface
750
+ break ;
751
+ default :
752
+ GMM_ASSERTDPF (0 , " Unsupported format/pixel size combo!" );
753
+ Status = GMM_INVALIDPARAM;
754
+ goto ERROR_CASE;
755
+ break ;
756
+ }
757
+ }
758
+ }
759
+ else
760
+ {
761
+ // Non-UV packed surfaces TileMode of each plane is same as that of pTexInfo
762
+ if ((PlaneType == GMM_PLANE_U) || (PlaneType == GMM_PLANE_V))
763
+ { // Non-UV packed surfaces only require the plane descriptors have proper height and width for each plane
764
+ switch (pTexInfo->Format )
765
+ {
766
+ case GMM_FORMAT_IMC1:
767
+ case GMM_FORMAT_IMC2:
768
+ case GMM_FORMAT_IMC3:
769
+ case GMM_FORMAT_IMC4:
770
+ case GMM_FORMAT_MFX_JPEG_YUV420:
771
+ pRedescribedTexInfo->BaseWidth = GFX_CEIL_DIV (pTexInfo->BaseWidth , 2 );
772
+ pRedescribedTexInfo->BaseHeight = GFX_CEIL_DIV (pTexInfo->BaseHeight , 2 );
773
+ break ;
774
+ case GMM_FORMAT_MFX_JPEG_YUV422V:
775
+ pRedescribedTexInfo->BaseHeight = GFX_CEIL_DIV (pTexInfo->BaseHeight , 2 );
776
+ break ;
777
+ case GMM_FORMAT_MFX_JPEG_YUV411R_TYPE:
778
+ pRedescribedTexInfo->BaseHeight = GFX_CEIL_DIV (pTexInfo->BaseHeight , 4 );
779
+ break ;
780
+ case GMM_FORMAT_MFX_JPEG_YUV411:
781
+ pRedescribedTexInfo->BaseWidth = GFX_CEIL_DIV (pTexInfo->BaseWidth , 4 );
782
+ break ;
783
+ case GMM_FORMAT_MFX_JPEG_YUV422H:
784
+ pRedescribedTexInfo->BaseWidth = GFX_CEIL_DIV (pTexInfo->BaseWidth , 2 );
785
+ break ;
786
+ default :
787
+ GMM_ASSERTDPF (0 , " Unsupported format/pixel size combo!" );
788
+ Status = GMM_INVALIDPARAM;
789
+ goto ERROR_CASE;
790
+ break ;
791
+ }
792
+ }
793
+ }
794
+
795
+ SetTileMode (pRedescribedTexInfo);
796
+ switch (pRedescribedTexInfo->BitsPerPixel )
797
+ {
798
+ case 8 :
799
+ pRedescribedTexInfo->Format = GMM_FORMAT_R8_UINT;
800
+ break ;
801
+ case 16 :
802
+ pRedescribedTexInfo->Format = GMM_FORMAT_R16_UINT;
803
+ break ;
804
+ case 32 :
805
+ pRedescribedTexInfo->Format = GMM_FORMAT_R32_UINT;
806
+ break ;
807
+ default :
808
+ GMM_ASSERTDPF (0 , " Unsupported format/pixel size combo!" );
809
+ Status = GMM_INVALIDPARAM;
810
+ goto ERROR_CASE;
811
+ break ;
812
+ }
813
+ if (pTexInfo->ArraySize > 1 )
814
+ {
815
+ pRedescribedTexInfo->OffsetInfo .Plane .ArrayQPitch = 0 ; // no longer a planar format on redescription
816
+ pRedescribedTexInfo->Alignment .QPitch = GFX_ALIGN (pRedescribedTexInfo->BaseHeight , pTexInfo->Alignment .VAlign );
817
+ pRedescribedTexInfo->OffsetInfo .Texture2DOffsetInfo .ArrayQPitchRender =
818
+ pRedescribedTexInfo->OffsetInfo .Texture2DOffsetInfo .ArrayQPitchLock = pRedescribedTexInfo->Alignment .QPitch * pTexInfo->Pitch ;
819
+ pRedescribedTexInfo->Size = pRedescribedTexInfo->Alignment .QPitch * pTexInfo->Pitch * pTexInfo->ArraySize ;
820
+ }
821
+ else
822
+ {
823
+ pRedescribedTexInfo->Size = (GFX_ALIGN (pRedescribedTexInfo->BaseHeight , pTexInfo->Alignment .VAlign )) * pTexInfo->Pitch ;
824
+ }
825
+
826
+ ERROR_CASE:
827
+ return (Status == GMM_SUCCESS) ? true : false ;
828
+ }
0 commit comments