xref: /aosp_15_r20/external/gmmlib/Source/GmmLib/inc/Internal/Common/Texture/GmmGen9TextureCalc.h (revision 35ffd701415c9e32e53136d61a677a8d0a8fc4a5)
1 /*==============================================================================
2 Copyright(c) 2017 Intel Corporation
3 
4 Permission is hereby granted, free of charge, to any person obtaining a
5 copy of this software and associated documentation files(the "Software"),
6 to deal in the Software without restriction, including without limitation
7 the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 and / or sell copies of the Software, and to permit persons to whom the
9 Software is furnished to do so, subject to the following conditions:
10 
11 The above copyright notice and this permission notice shall be included
12 in all copies or substantial portions of the Software.
13 
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 OTHER DEALINGS IN THE SOFTWARE.
21 ============================================================================*/
22 
23 #pragma once
24 #ifdef __cplusplus
25 #include "GmmTextureCalc.h"
26 /////////////////////////////////////////////////////////////////////////////////////
27 /// @file GmmGen9TextureCalc.h
28 /// @brief This file contains the functions and members definations for texture alloc-
29 ///        ation on all Gen9 platforms.
30 /////////////////////////////////////////////////////////////////////////////////////
31 namespace GmmLib
32 {
33     /////////////////////////////////////////////////////////////////////////
34     /// Contains texture calc functions and members for Gen9 platforms.
35     /// This class is derived from the base GmmTextureCalc class  so clients
36     /// shouldn't have to ever interact  with this class directly.
37     /////////////////////////////////////////////////////////////////////////
38     class NON_PAGED_SECTION GmmGen9TextureCalc :
39                                 public GmmTextureCalc
40     {
41         private:
42             void                    Fill1DTexOffsetAddress(
43                                         GMM_TEXTURE_INFO *pTexInfo);
44 
45             GMM_GFX_SIZE_T          Get1DTexOffsetAddressPerMip(
46                                         GMM_TEXTURE_INFO *pTexInfo,
47                                         uint32_t            MipLevel);
48         protected:
49             /* Function prototypes */
50 
51             virtual void            Fill2DTexOffsetAddress(
52                                         GMM_TEXTURE_INFO *pTexInfo);
53 
54             virtual GMM_GFX_SIZE_T  Get2DTexOffsetAddressPerMip(
55                                         GMM_TEXTURE_INFO   *pTexInfo,
56                                         uint32_t               MipLevel);
57 
58             virtual uint32_t           Get2DMipMapHeight(
59                                         GMM_TEXTURE_INFO   *pTexInfo);
60 
61             uint32_t                   Get2DMipMapTotalHeight(
62                                         GMM_TEXTURE_INFO *pTexInfo);
63 
64             virtual uint32_t           GetMipTailByteOffset(
65                                         GMM_TEXTURE_INFO *pTexInfo,
66                                         uint32_t            MipLevel);
67 
68             virtual void            GetMipTailGeometryOffset(
69                                         GMM_TEXTURE_INFO *pTexInfo,
70                                         uint32_t            MipLevel,
71                                         uint32_t*           OffsetX,
72                                         uint32_t*           OffsetY,
73                                         uint32_t*           OffsetZ);
74 
75             virtual uint32_t           GetAligned3DBlockHeight(
76                                         GMM_TEXTURE_INFO*    pTexInfo,
77                                         uint32_t BlockHeight,
78                                         uint32_t ExpandedArraySize);
79 
80         public:
81             /* Constructors */
82 
GmmGen9TextureCalc(Context * pGmmLibContext)83             GmmGen9TextureCalc(Context *pGmmLibContext)
84                 : GmmTextureCalc(pGmmLibContext)
85 	    {
86 
87             }
88 
~GmmGen9TextureCalc()89             ~GmmGen9TextureCalc()
90             {
91 
92             }
93 
94             /* Function prototypes */
95 
96             virtual GMM_STATUS GMM_STDCALL  FillTex1D(GMM_TEXTURE_INFO   *pTexInfo,
97                                                       __GMM_BUFFER_TYPE  *pRestrictions);
98 
99             virtual GMM_STATUS GMM_STDCALL  FillTex2D(GMM_TEXTURE_INFO   *pTexInfo,
100                                                       __GMM_BUFFER_TYPE  *pRestrictions);
101 
102             virtual GMM_STATUS GMM_STDCALL  FillTex3D(GMM_TEXTURE_INFO   *pTexInfo,
103                                                       __GMM_BUFFER_TYPE  *pRestrictions);
104 
105             virtual GMM_STATUS GMM_STDCALL  FillTexCube(GMM_TEXTURE_INFO   *pTexInfo,
106                                                         __GMM_BUFFER_TYPE  *pRestrictions);
107             virtual GMM_STATUS GMM_STDCALL MSAACCSUsage(GMM_TEXTURE_INFO *pTexInfo);
108 
ScaleFCRectHeight(GMM_TEXTURE_INFO * pTexInfo,uint32_t Height)109             virtual uint32_t GMM_STDCALL ScaleFCRectHeight(GMM_TEXTURE_INFO * pTexInfo, uint32_t Height)
110             {
111                 __GMM_ASSERTPTR(pTexInfo, 0);
112                 uint32_t ScaledHeight = Height;
113 
114                 if (pTexInfo->TileMode == LEGACY_TILE_Y)
115                 {
116                     const uint16_t FastClearRccTileYAlignHeight = 64; // lines - RCC ( Render Color Cache ) Alignment Sizes
117                     const uint16_t TileYClearHeightScale = 32;        // lines - Clear & Resolve Rect Scaling Sizes
118 
119                     ScaledHeight = GFX_ALIGN(ScaledHeight, FastClearRccTileYAlignHeight);
120                     ScaledHeight /= TileYClearHeightScale;
121                 }
122                 return ScaledHeight;
123             }
124 
125             /* inline functions */
126     };
127 }
128 #endif // #ifdef __cplusplus
129