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 #pragma once
23 
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif /*__cplusplus*/
28 
29 // Set packing alignment
30 #pragma pack(push, 8)
31 
32 #define GMM_MAX_MIPMAP      15
33 #define GMM_MAX_MMC_INDEX   64
34 
35 //===========================================================================
36 // typedef:
37 //        GMM_PLANAR_OFFSET_INFO
38 //
39 // Description:
40 //     This structure stores the offset address of each level
41 //---------------------------------------------------------------------------
42 typedef struct GMM_PLANAR_OFFSET_INFO_REC
43 {
44     GMM_GFX_SIZE_T     ArrayQPitch;
45     GMM_GFX_SIZE_T     X[GMM_MAX_PLANE];
46     GMM_GFX_SIZE_T     Y[GMM_MAX_PLANE];
47     struct
48     {
49         GMM_GFX_SIZE_T     Height[GMM_MAX_PLANE];
50     } UnAligned, Aligned;
51     uint32_t            NoOfPlanes;
52     bool                IsTileAlignedPlanes;
53 }GMM_PLANAR_OFFSET_INFO;
54 
55 //===========================================================================
56 // typedef:
57 //        GMM_2D_TEXTURE_OFFSET_INFO
58 //
59 // Description:
60 //     This structure stores the offset address of each level
61 //---------------------------------------------------------------------------
62 typedef struct GMM_2D_TEXTURE_OFFSET_INFO_REC
63 {
64     GMM_GFX_SIZE_T              ArrayQPitchLock;
65     GMM_GFX_SIZE_T              ArrayQPitchRender;
66     GMM_GFX_SIZE_T              Offset[GMM_MAX_MIPMAP];
67 }GMM_2D_TEXTURE_OFFSET_INFO_T;
68 
69 //===========================================================================
70 // typedef:
71 //        GMM_3D_TEXTURE_OFFSET_INFO
72 //
73 // Description:
74 //     This structure stores the offset address of each level
75 //---------------------------------------------------------------------------
76 typedef struct GMM_3D_TEXTURE_OFFSET_INFO_REC
77 {
78     GMM_GFX_SIZE_T     Mip0SlicePitch;
79     GMM_GFX_SIZE_T     Offset[GMM_MAX_MIPMAP];
80 }GMM_3D_TEXTURE_OFFSET_INFO_T;
81 
82 //===========================================================================
83 // typedef:
84 //        GMM_OFFSET_INFO
85 //
86 // Description:
87 //     This structure stores the offset address of each level
88 //---------------------------------------------------------------------------
89 typedef struct GMM_OFFSET_INFO_REC
90 {
91     union
92     {
93         GMM_3D_TEXTURE_OFFSET_INFO_T    Texture3DOffsetInfo;
94         GMM_2D_TEXTURE_OFFSET_INFO_T    Texture2DOffsetInfo;
95         GMM_PLANAR_OFFSET_INFO          Plane;
96     };
97 }GMM_OFFSET_INFO, GMM_OFFSET_INFO_T;
98 
99 //===========================================================================
100 // typedef:
101 //        GMM_TEXTURE_CALC
102 //
103 // Description:
104 //     This struct is used to texture calculator.
105 //     Forward Declaration: Defined in GmmGenXXTextureCalc*.h
106 //---------------------------------------------------------------------------
107 #ifdef __cplusplus
108 namespace GmmLib
109 {
110     class GmmTextureCalc;
111 }
112 
113 typedef GmmLib::GmmTextureCalc GMM_TEXTURE_CALC;
114 #else
115 struct GmmTextureCalc;
116 typedef struct GmmTextureCalc GMM_TEXTURE_CALC;
117 #endif
118 
119 //===========================================================================
120 // typedef:
121 //      GMM_TEXTURE_INFO_REC
122 //
123 // Description:
124 //      This structure used to request mipmap offset information
125 //---------------------------------------------------------------------------
126 typedef struct GMM_TEXTURE_INFO_REC
127 {
128      // Input ----------------------------------
129     GMM_RESOURCE_TYPE       Type;
130     GMM_RESOURCE_FORMAT     Format;
131     uint32_t                BitsPerPixel;
132     GMM_RESOURCE_FLAG       Flags;
133 
134     uint64_t                BaseWidth;
135     uint32_t                BaseHeight;
136     uint32_t                Depth;
137     uint32_t                MaxLod;
138     uint32_t                ArraySize;
139     uint32_t                CpTag;
140 
141     struct{
142         GMM_RESOURCE_USAGE_TYPE Usage;
143     }                       CachePolicy;
144 
145     GMM_RESOURCE_MSAA_INFO  MSAA;
146 
147     // Output ---------------------------------
148     GMM_RESOURCE_ALIGNMENT  Alignment;
149 
150     uint8_t                 MmcMode[GMM_MAX_MMC_INDEX];
151     uint8_t                 MmcHint[GMM_MAX_MMC_INDEX];
152 
153     GMM_GFX_SIZE_T          Pitch;
154     GMM_GFX_SIZE_T          OverridePitch;   // VirtualPadding
155 
156     GMM_GFX_SIZE_T          Size;            // For AuxSurf Size = CCS + CC + Padding
157     GMM_GFX_SIZE_T          CCSize;          // 4kb => 128 bit Float + 32bit Native RT + Padding. Usage : Gpu.IndirectClearColor
158     GMM_GFX_SIZE_T          UnpaddedSize;    // Unpadded CCS Size for Flags.Gpu.UnifiedAuxSurface only
159     GMM_GFX_SIZE_T          SizeReportToOS;  // For Non-aligned ESM
160 
161     GMM_OFFSET_INFO         OffsetInfo;      // (X,Y) offsets to each mipmap/plane
162     GMM_TILE_MODE           TileMode;
163     uint32_t                CCSModeAlign;    // For AUX_CCS, TexAlign.CCSEx index derived from main surface tiling
164     uint32_t                LegacyFlags;
165 
166     GMM_S3D_INFO            S3d;
167 
168     #if(LHDM)
169         D3DDDIFORMAT        MsFormat;
170 
171     #endif
172 
173     struct{
174         uint32_t               Seg1    : 8;
175         uint32_t               Evict   : 8;
176     }                   SegmentOverride; // Used for tuning the Vista driver
177 
178     uint32_t               MaximumRenamingListLength;
179 
180     #if(_DEBUG || _RELEASE_INTERNAL)
181         PLATFORM        Platform;
182     #else
183         PLATFORM        __Platform; // Do not use--For size preservation only.
184     #endif
185 
186     struct{
187         uint8_t          IsGmmAllocated;
188         uint8_t          IsPageAligned;
189     }                   ExistingSysMem;
190 }GMM_TEXTURE_INFO;
191 
192 //***************************************************************************
193 //
194 //                      GMM_TEXTURE API
195 //
196 //***************************************************************************
197 #if(defined(__GMM_KMD__))
198 GMM_STATUS GmmTexAlloc(GMM_LIB_CONTEXT *pGmmLibContext, GMM_TEXTURE_INFO* pTexInfo);
199 GMM_STATUS GmmTexLinearCCS(GMM_LIB_CONTEXT *pGmmLibContext, GMM_TEXTURE_INFO* pTexInfo, GMM_TEXTURE_INFO *pAuxTexInfo);
200 #endif
201 GMM_STATUS GmmTexGetMipMapOffset(GMM_TEXTURE_INFO* pTexInfo, GMM_REQ_OFFSET_INFO* pReqInfo , GMM_LIB_CONTEXT* pGmmLibContext);
202 
203 #define GMM_ISNOT_TILED(TileInfo) ((TileInfo).LogicalSize == 0)
204 #define GMM_IS_TILED(TileInfo)    ((TileInfo).LogicalSize > 0)
205 #define GMM_CLEAR_TILEINFO(TileInfo)            \
206 {                                               \
207         (TileInfo).LogicalSize = 0;             \
208         (TileInfo).LogicalTileHeight = 0;       \
209         (TileInfo).LogicalTileWidth = 0;        \
210         (TileInfo).MaxPitch = 0;                \
211 }
212 
213 #define GMM_IS_4KB_TILE(Flags)  ((Flags).Info.TiledY || (Flags).Info.Tile4)
214 #define GMM_IS_64KB_TILE(Flags) (Flags.Info.TiledYs || Flags.Info.Tile64)
215 #define GMM_IS_SUPPORTED_BPP_ON_TILE_64_YF_YS(bpp) ((bpp == 8) || (bpp == 16) || (bpp == 32) || (bpp == 64) || (bpp == 128))
216 
217 #define GMM_SET_4KB_TILE(Flags, Value,pGmmLibContext) if (pGmmLibContext->GetSkuTable().FtrTileY) ((Flags).Info.TiledY = (Value)); else ((Flags).Info.Tile4 = (Value))
218 #define GMM_SET_64KB_TILE(Flags, Value,pGmmLibContext) if (pGmmLibContext->GetSkuTable().FtrTileY) ((Flags).Info.TiledYs = (Value)); else ((Flags).Info.Tile64 = (Value))
219 #define GMM_SET_4KB_TILE_MODE(TileMode,pGmmLibContext) if (pGmmLibContext->GetSkuTable().FtrTileY) (TileMode = LEGACY_TILE_Y); else (TileMode = TILE4)
220 #define GMM_IS_TILEY(pGmmLibContext) (((GmmClientContext*)pClientContext)->GetSkuTable().FtrTileY)
221 
222 // Reset packing alignment to project default
223 #pragma pack(pop)
224 
225 #ifdef __cplusplus
226 }
227 #endif /*__cplusplus*/
228