1 /*==============================================================================
2 Copyright(c) 2019 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 #include "Internal/Common/GmmLibInc.h"
24 #include "Internal/Common/Platform/GmmGen12Platform.h"
25
26 /************************ RT->CCS Sizing definitions ************************
27 H/V/D Align and Downscale factor to obtain CCS from given RT dimensions
28 Restrictions:
29 CCS's RT (2D/3D YF) alignment to 4x1 (2D/3D YF) pages sharing 1x1 Aux$line
30 (2D YS) 2x2 ( 2D YF) pages "
31 (3D YS) 2x1x2 ( 3D YF) pages " ie Slices share Aux$line
32 (Color MSAA'd YF) 4x1 (MSAA'dYF) pages " ie all samples share Aux$line (Samples are array'd ie YF 4KB = YF-MSAA x MSAA-Samples)
33 (Color MSAA 2x/4x YS) 2x2x1 ( 2D YF) pages " ie Single sample per Aux$line
34 (Color MSAA 8x YS) 1x2x2 ( 2D YF) pages " ie 2 samples share Aux$line
35 (Color MSAA 16x YS) 1x1x4 ( 2D YF) pages " ie 4 samples share Aux$line
36 (Depth MSAA YF) 4x1 ( 2D YF) pages " ie all samples share Aux$line
37 (Depth MSAA 2x/4x YS) 2x2x1 ( 2D YF) pages " ie Single sample per Aux$line
38 (Depth MSAA 8x YS) 1x2x2 ( 2D YF) pages " ie 2 samples share Aux$line
39 (Depth MSAA 16x YS) 1x1x4 ( 2D YF) pages " ie 4 samples share Aux$line
40 ie Depth/Color MSAA have common alignment, but due to different pixel packing (Depth MSS is interleaved, Color MSS is arrayed)
41 SamplePerAux$line samples are X-major (for Depth), while Y-major (for Color) packed ie For Depth MSAA, Hdownscale *=SamplePerAux$line;
42 for color MSAA, Vdownscale = Vdownscale; for both, MSAA-samples/SamplePerAux$line times sample shared CCS-size
43
44 HAlign: Horizontal Align in pixels
45 VAlign: Vertical Align in pixels
46 DAlign: Depth Align in pixels
47 HAlignxVAlignxDAlign [RT size] occupies one Aux$line
48 SamplesPerAux$line: Samples sharing CCS; NSamples divisor on MSAA-samples giving multiple (on shared CCS) to cover all samples
49 HDownscale: width divisor on CCSRTAlign`d width
50 VDownscale: height divisor on CCSRTAlign`d height
51 Convention:
52 (+ve) HDownscale/VDownscale are downscale factors, and used as divisors
53 (-ve) HDownscale/VDownscale are upscale factors, their absolute value used as multipliers
54 ie if HDownscale etc is smaller than 1, its reciprocal is stored with -ve sign
55 <---- CCSRTALIGN -----> <-- RT->CCS downscale-->
56 ( TileMode, HAlign , VAlign, DAlign, HDownscale, VDownscale)
57 or
58 SamplesPerAux$line,
59 eg:
60 CCSRTALIGN(TILE_YF_2D_8bpe, 256, 64, 1, 16, 16 )
61 **********************************************************************************************************/
62
63 /////////////////////////////////////////////////////////////////////////////////////
64 /// Allocates This function will initialize the necessary info based on platform.
65 /// - Buffer type restrictions (Eg: Z, Color, Display)
66 /// - X/Y tile dimensions
67 ///
68 /// @param[in] Platform: Contains information about platform to initialize an object
69 /////////////////////////////////////////////////////////////////////////////////////
PlatformInfoGen12(PLATFORM & Platform,Context * pGmmLibContext)70 GmmLib::PlatformInfoGen12::PlatformInfoGen12(PLATFORM &Platform, Context *pGmmLibContext)
71 : PlatformInfoGen11(Platform, pGmmLibContext)
72 {
73 __GMM_ASSERTPTR(pGmmLibContext, VOIDRETURN);
74
75 //Compression format update
76 GMM_RESOURCE_FORMAT GmmFormat;
77 #define GMM_FORMAT_SKU(FtrXxx) (pGmmLibContext->GetSkuTable().FtrXxx != 0)
78 #define GMM_FORMAT(Name, bpe, _Width, _Height, _Depth, IsRT, IsASTC, RcsSurfaceFormat, SSCompressionFmt, Availability) \
79 \
80 { \
81 GmmFormat = GMM_FORMAT_##Name; \
82 Data.FormatTable[GmmFormat].CompressionFormat.CompressionFormat = static_cast<uint8_t>(SSCompressionFmt); \
83 }
84
85 #include "External/Common/GmmFormatTable.h"
86
87
88 // --------------------------
89 // Surface Alignment Units
90 // --------------------------
91
92 // 3DSTATE_DEPTH_BUFFER
93 //======================================================================
94 // Surf Format | MSAA | HAlign | VAlign |
95 //======================================================================
96 // D16_UNORM | 1x, 4x, 16x | 8 | 8 |
97 // D16_UNORM | 2x, 8x | 16 | 4 |
98 // Not D16_UNORM | 1x,2x,4x,8x,16x | 8 | 4 |
99 //======================================================================
100
101
102 // 3DSTATE_STENCIL_BUFFER
103 //======================================================================
104 // Surf Format | MSAA | HAlign | VAlign |
105 //======================================================================
106 // N/A | N/A | 16 | 8 |
107 //======================================================================
108
109 Data.SurfaceMaxSize = GMM_GBYTE(16384);
110 Data.MaxGpuVirtualAddressBitsPerResource = 44;
111
112 //Override the Height VP9 VdEnc requirement for Gen12 16k resolution.
113 Data.ReconMaxHeight = GMM_KBYTE(48);
114 Data.ReconMaxWidth = GMM_KBYTE(32);
115
116 if((GFX_GET_CURRENT_PRODUCT(Data.Platform) >= IGFX_DG1))
117 {
118 Data.HiZPixelsPerByte = 4;
119 }
120
121 Data.TexAlign.Depth.Width = 8; // Not D16_UNORM
122 Data.TexAlign.Depth.Height = 4;
123 Data.TexAlign.Depth_D16_UNORM_1x_4x_16x.Width = 8;
124 Data.TexAlign.Depth_D16_UNORM_1x_4x_16x.Height = 8;
125 Data.TexAlign.Depth_D16_UNORM_2x_8x.Width = 16;
126 Data.TexAlign.Depth_D16_UNORM_2x_8x.Height = 4;
127 Data.TexAlign.SeparateStencil.Width = 16;
128 Data.TexAlign.SeparateStencil.Height = 8;
129
130 //CCS unit size ie cacheline
131 Data.TexAlign.CCS.Align.Width = 16;
132 Data.TexAlign.CCS.Align.Height = 4;
133 Data.TexAlign.CCS.Align.Depth = 1;
134 Data.TexAlign.CCS.MaxPitchinTiles = 1024;
135
136 // clang-format off
137 SET_TILE_MODE_INFO(TILE4, 128, 32, 1, 0, 0, 0)
138
139 // TILE__64 1D
140 SET_TILE_MODE_INFO(TILE__64_1D_128bpe, 4096, 1, 1, 1024, 1, 1)
141 SET_TILE_MODE_INFO(TILE__64_1D_64bpe, 8192, 1, 1, 2048, 1, 1)
142 SET_TILE_MODE_INFO(TILE__64_1D_32bpe, 16384, 1, 1, 4096, 1, 1)
143 SET_TILE_MODE_INFO(TILE__64_1D_16bpe, 32768, 1, 1, 8192, 1, 1)
144 SET_TILE_MODE_INFO(TILE__64_1D_8bpe, 65536, 1, 1, 16384, 1, 1)
145
146 // TILE__64 2D
147 SET_TILE_MODE_INFO(TILE__64_2D_128bpe, 1024, 64, 1, 32, 64, 1)
148 SET_TILE_MODE_INFO(TILE__64_2D_64bpe, 1024, 64, 1, 64, 64, 1)
149 SET_TILE_MODE_INFO(TILE__64_2D_32bpe, 512, 128, 1, 64, 128, 1)
150 SET_TILE_MODE_INFO(TILE__64_2D_16bpe, 512, 128, 1, 128, 128, 1)
151 SET_TILE_MODE_INFO(TILE__64_2D_8bpe, 256, 256, 1, 128, 256, 1)
152
153 // TILE__64 2D 2X
154 if(pGmmLibContext->GetSkuTable().FtrXe2PlusTiling)
155 {
156 SET_TILE_MODE_INFO(TILE__64_2D_2X_128bpe, 1024, 32, 1, 32, 32, 1)
157 }
158 else
159 {
160 SET_TILE_MODE_INFO(TILE__64_2D_2X_128bpe, 512, 64, 1, 32, 32, 1)
161 }
162
163 SET_TILE_MODE_INFO(TILE__64_2D_2X_64bpe, 512, 64, 1, 64, 32, 1)
164 SET_TILE_MODE_INFO(TILE__64_2D_2X_32bpe, 256, 128, 1, 64, 64, 1)
165 SET_TILE_MODE_INFO(TILE__64_2D_2X_16bpe, 256, 128, 1, 128, 64, 1)
166 SET_TILE_MODE_INFO(TILE__64_2D_2X_8bpe, 128, 256, 1, 128, 128, 1)
167
168 // TILE__64 2D 4X
169 SET_TILE_MODE_INFO(TILE__64_2D_4X_128bpe, 512, 32, 1, 16, 32, 1)
170 SET_TILE_MODE_INFO(TILE__64_2D_4X_64bpe, 512, 32, 1, 32, 32, 1)
171 SET_TILE_MODE_INFO(TILE__64_2D_4X_32bpe, 256, 64, 1, 32, 64, 1)
172 SET_TILE_MODE_INFO(TILE__64_2D_4X_16bpe, 256, 64, 1, 64, 64, 1)
173 SET_TILE_MODE_INFO(TILE__64_2D_4X_8bpe, 128, 128, 1, 64, 128, 1)
174
175 // TILE__64 2D 8X
176 SET_TILE_MODE_INFO(TILE__64_2D_8X_128bpe, 256, 32, 1, 8, 32, 1)
177 SET_TILE_MODE_INFO(TILE__64_2D_8X_64bpe, 256, 32, 1, 16, 32, 1)
178 SET_TILE_MODE_INFO(TILE__64_2D_8X_32bpe, 256, 32, 1, 16, 64, 1)
179 SET_TILE_MODE_INFO(TILE__64_2D_8X_16bpe, 128, 64, 1, 32, 64, 1)
180 SET_TILE_MODE_INFO(TILE__64_2D_8X_8bpe, 128, 64, 1, 32, 128, 1)
181
182 // TILE__64 2D 16X
183 SET_TILE_MODE_INFO(TILE__64_2D_16X_128bpe, 256, 16, 1, 8, 16, 1)
184 SET_TILE_MODE_INFO(TILE__64_2D_16X_64bpe, 128, 32, 1, 16, 16, 1)
185 SET_TILE_MODE_INFO(TILE__64_2D_16X_32bpe, 128, 32, 1, 16, 32, 1)
186 SET_TILE_MODE_INFO(TILE__64_2D_16X_16bpe, 128, 32, 1, 32, 32, 1)
187 SET_TILE_MODE_INFO(TILE__64_2D_16X_8bpe, 64, 64, 1, 32, 64, 1)
188
189 // TILE__64 3D
190 SET_TILE_MODE_INFO(TILE__64_3D_128bpe, 256, 16, 16, 8, 16, 16)
191 SET_TILE_MODE_INFO(TILE__64_3D_64bpe, 256, 16, 16, 16, 16, 16)
192 SET_TILE_MODE_INFO(TILE__64_3D_32bpe, 128, 32, 16, 16, 32, 16)
193 SET_TILE_MODE_INFO(TILE__64_3D_16bpe, 64, 32, 32, 16, 32, 32)
194 SET_TILE_MODE_INFO(TILE__64_3D_8bpe, 64, 32, 32, 32, 32, 32)
195 // clang-format off
196
197 //Extended CCS alignment for per bpp/Tiling CCS alignment
198 #define CCSRTALIGN(TileMode, HAlign, VAlign, DAlign, HDownscale, VDownscale) \
199 { \
200 TexAlignEx.CCSEx[CCS_MODE(TileMode)].Align.Width = HAlign; \
201 TexAlignEx.CCSEx[CCS_MODE(TileMode)].Align.Height = VAlign; \
202 TexAlignEx.CCSEx[CCS_MODE(TileMode)].Align.Depth = DAlign; \
203 TexAlignEx.CCSEx[CCS_MODE(TileMode)].Downscale.Width = HDownscale; \
204 TexAlignEx.CCSEx[CCS_MODE(TileMode)].Downscale.Height = VDownscale; \
205 TexAlignEx.CCSEx[CCS_MODE(TileMode)].Downscale.Depth = DAlign; \
206 }
207
208 // clang-format off
209 //See "RT->CCS Sizing definitions" comments above for explanation on fields
210 /********* TileMode HAlign, VAlign, DAlign, HDownscale, VDownscale ***/
211 CCSRTALIGN(TILE_YF_2D_8bpe, 256, 64, 1, 16, 16 );
212 CCSRTALIGN(TILE_YF_2D_16bpe, 256, 32, 1, 16, 8 );
213 CCSRTALIGN(TILE_YF_2D_32bpe, 128, 32, 1, 8, 8 );
214 CCSRTALIGN(TILE_YF_2D_64bpe, 128, 16, 1, 8, 4 );
215 CCSRTALIGN(TILE_YF_2D_128bpe, 64, 16, 1, 4, 4 );
216
217 CCSRTALIGN(TILE_YF_3D_8bpe, 64, 16, 16, 4, 4 );
218 CCSRTALIGN(TILE_YF_3D_16bpe, 32, 16, 16, 2, 4 );
219 CCSRTALIGN(TILE_YF_3D_32bpe, 32, 16, 8, 2, 4 );
220 CCSRTALIGN(TILE_YF_3D_64bpe, 32, 8, 8, 2, 2 );
221 CCSRTALIGN(TILE_YF_3D_128bpe, 16, 8, 8, 1, 2 );
222
223 CCSRTALIGN(TILE_YF_2D_2X_8bpe, 128, 64, 2, 8, 16 );
224 CCSRTALIGN(TILE_YF_2D_2X_16bpe, 128, 32, 2, 8, 8 );
225 CCSRTALIGN(TILE_YF_2D_2X_32bpe, 64, 32, 2, 4, 8 );
226 CCSRTALIGN(TILE_YF_2D_2X_64bpe, 64, 16, 2, 4, 4 );
227 CCSRTALIGN(TILE_YF_2D_2X_128bpe, 32, 16, 2, 2, 4 );
228
229 CCSRTALIGN(TILE_YF_2D_4X_8bpe, 128, 32, 4, 8, 8 );
230 CCSRTALIGN(TILE_YF_2D_4X_16bpe, 128, 16, 4, 8, 4 );
231 CCSRTALIGN(TILE_YF_2D_4X_32bpe, 64, 16, 4, 4, 4 );
232 CCSRTALIGN(TILE_YF_2D_4X_64bpe, 64, 8, 4, 4, 2 );
233 CCSRTALIGN(TILE_YF_2D_4X_128bpe, 32, 8, 4, 2, 2 );
234
235 CCSRTALIGN(TILE_YF_2D_8X_8bpe, 64, 32, 8, 4, 8 );
236 CCSRTALIGN(TILE_YF_2D_8X_16bpe, 64, 16, 8, 4, 4 );
237 CCSRTALIGN(TILE_YF_2D_8X_32bpe, 32, 16, 8, 2, 4 );
238 CCSRTALIGN(TILE_YF_2D_8X_64bpe, 32, 8, 8, 2, 2 );
239 CCSRTALIGN(TILE_YF_2D_8X_128bpe, 16, 8, 8, 1, 2 );
240
241 CCSRTALIGN(TILE_YF_2D_16X_8bpe, 64, 16, 16, 4, 4 );
242 CCSRTALIGN(TILE_YF_2D_16X_16bpe, 64, 8, 16, 4, 2 );
243 CCSRTALIGN(TILE_YF_2D_16X_32bpe, 32, 8, 16, 2, 2 );
244 CCSRTALIGN(TILE_YF_2D_16X_64bpe, 32, 4, 16, 2, 1 );
245 CCSRTALIGN(TILE_YF_2D_16X_128bpe, 16, 4, 16, 1, 1 );
246
247 CCSRTALIGN(TILE_YS_2D_8bpe, 128, 128, 1, 8, 32 );
248 CCSRTALIGN(TILE_YS_2D_16bpe, 128, 64, 1, 8, 16 );
249 CCSRTALIGN(TILE_YS_2D_32bpe, 64, 64, 1, 4, 16 );
250 CCSRTALIGN(TILE_YS_2D_64bpe, 64, 32, 1, 4, 8 );
251 CCSRTALIGN(TILE_YS_2D_128bpe, 32, 32, 1, 2, 8 );
252
253 CCSRTALIGN(TILE_YS_3D_8bpe, 32, 16, 32, 2, 4 );
254 CCSRTALIGN(TILE_YS_3D_16bpe, 16, 16, 32, 1, 4 );
255 CCSRTALIGN(TILE_YS_3D_32bpe, 16, 16, 16, 1, 4 );
256 CCSRTALIGN(TILE_YS_3D_64bpe, 16, 8, 16, 1, 2 );
257 CCSRTALIGN(TILE_YS_3D_128bpe, 8, 8, 16, -2, 2 );
258
259 CCSRTALIGN(TILE_YS_2D_2X_8bpe, 128, 128, 1, 8, 32 );
260 CCSRTALIGN(TILE_YS_2D_2X_16bpe, 128, 64, 1, 8, 16 );
261 CCSRTALIGN(TILE_YS_2D_2X_32bpe, 64, 64, 1, 4, 16 );
262 CCSRTALIGN(TILE_YS_2D_2X_64bpe, 64, 32, 1, 4, 8 );
263 CCSRTALIGN(TILE_YS_2D_2X_128bpe, 32, 32, 1, 2, 8 );
264
265 CCSRTALIGN(TILE_YS_2D_4X_8bpe, 128, 128, 1, 8, 32 );
266 CCSRTALIGN(TILE_YS_2D_4X_16bpe, 128, 64, 1, 8, 16 );
267 CCSRTALIGN(TILE_YS_2D_4X_32bpe, 64, 64, 1, 4, 16 );
268 CCSRTALIGN(TILE_YS_2D_4X_64bpe, 64, 32, 1, 4, 8 );
269 CCSRTALIGN(TILE_YS_2D_4X_128bpe, 32, 32, 1, 2, 8 );
270
271 CCSRTALIGN(TILE_YS_2D_8X_8bpe, 64, 128, 2, 4, 32 );
272 CCSRTALIGN(TILE_YS_2D_8X_16bpe, 64, 64, 2, 4, 16 );
273 CCSRTALIGN(TILE_YS_2D_8X_32bpe, 32, 64, 2, 2, 16 );
274 CCSRTALIGN(TILE_YS_2D_8X_64bpe, 32, 32, 2, 2, 8 );
275 CCSRTALIGN(TILE_YS_2D_8X_128bpe, 16, 32, 2, 1, 8 );
276
277 CCSRTALIGN(TILE_YS_2D_16X_8bpe, 64, 64, 4, 4, 16 );
278 CCSRTALIGN(TILE_YS_2D_16X_16bpe, 64, 32, 4, 4, 8 );
279 CCSRTALIGN(TILE_YS_2D_16X_32bpe, 32, 32, 4, 2, 8 );
280 CCSRTALIGN(TILE_YS_2D_16X_64bpe, 32, 16, 4, 2, 4 );
281 CCSRTALIGN(TILE_YS_2D_16X_128bpe, 16, 16, 4, 1, 4 );
282 #undef CCSRTALIGN
283 // clang-format on
284
285 #define FCRECTALIGN(TileMode, bpp, HAlign, VAlign, DAlign, HDownscale, VDownscale) \
286 { \
287 FCTileMode[FCMode(TileMode, bpp)].Align.Width = HAlign; \
288 FCTileMode[FCMode(TileMode, bpp)].Align.Height = VAlign; \
289 FCTileMode[FCMode(TileMode, bpp)].Align.Depth = DAlign; \
290 FCTileMode[FCMode(TileMode, bpp)].Downscale.Width = HDownscale; \
291 FCTileMode[FCMode(TileMode, bpp)].Downscale.Height = VDownscale; \
292 FCTileMode[FCMode(TileMode, bpp)].Downscale.Depth = 1; \
293 }
294
295 // clang-format off
296 FCRECTALIGN(LEGACY_TILE_Y , 8, 512, 32, 1, 256, 16);
297 FCRECTALIGN(LEGACY_TILE_Y , 16, 256, 32, 1, 128, 16);
298 FCRECTALIGN(LEGACY_TILE_Y , 32, 128, 32, 1, 64, 16);
299 FCRECTALIGN(LEGACY_TILE_Y , 64, 64, 32, 1, 32, 16);
300 FCRECTALIGN(LEGACY_TILE_Y , 128, 32, 32, 1, 16, 16);
301
302 FCRECTALIGN(TILE_YF_2D_8bpe , 8, 256, 64, 1, 128, 32);
303 FCRECTALIGN(TILE_YF_2D_16bpe , 16, 256, 32, 1, 128, 16);
304 FCRECTALIGN(TILE_YF_2D_32bpe , 32, 128, 32, 1, 64, 16);
305 FCRECTALIGN(TILE_YF_2D_64bpe , 64, 128, 16, 1, 64, 8);
306 FCRECTALIGN(TILE_YF_2D_128bpe, 128, 64, 16, 1, 32, 8);
307
308 FCRECTALIGN(TILE_YS_2D_8bpe , 8, 128, 128, 1, 64, 64);
309 FCRECTALIGN(TILE_YS_2D_16bpe , 16, 128, 64, 1, 64, 32);
310 FCRECTALIGN(TILE_YS_2D_32bpe , 32, 64, 64, 1, 32, 32);
311 FCRECTALIGN(TILE_YS_2D_64bpe , 64, 64, 32, 1, 32, 16);
312 FCRECTALIGN(TILE_YS_2D_128bpe, 128, 32, 32, 1, 16, 16);
313
314 if(pGmmLibContext->GetSkuTable().FtrXe2Compression)
315 {
316
317 FCRECTALIGN(TILE4 , 8, 64, 4, 1, 64, 4);
318 FCRECTALIGN(TILE4 , 16, 32, 4, 1, 32, 4);
319 FCRECTALIGN(TILE4 , 32, 16, 4, 1, 16, 4);
320 FCRECTALIGN(TILE4 , 64, 8, 4, 1, 8, 4);
321 FCRECTALIGN(TILE4 , 128, 4, 4, 1, 4, 4);
322
323 FCRECTALIGN(TILE__64_2D_8bpe , 8, 64, 4, 1, 64, 4);
324 FCRECTALIGN(TILE__64_2D_16bpe , 16, 32, 4, 1, 32, 4);
325 FCRECTALIGN(TILE__64_2D_32bpe , 32, 16, 4, 1, 16, 4);
326 FCRECTALIGN(TILE__64_2D_64bpe , 64, 8, 4, 1, 8, 4);
327 FCRECTALIGN(TILE__64_2D_128bpe, 128, 4, 4, 1, 4, 4);
328
329 FCRECTALIGN(TILE__64_3D_8bpe , 8, 64, 32, 32, 4, 8);
330 FCRECTALIGN(TILE__64_3D_16bpe , 16, 32, 32, 32, 8, 4);
331 FCRECTALIGN(TILE__64_3D_32bpe , 32, 32, 32, 16, 4, 4);
332 FCRECTALIGN(TILE__64_3D_64bpe , 64, 32, 16, 16, 4, 4);
333 FCRECTALIGN(TILE__64_3D_128bpe, 128, 16, 16, 16, 4, 4);
334 }
335 else
336 {
337 FCRECTALIGN(TILE4 , 8, 1024, 16, 1, 1024, 16);
338 FCRECTALIGN(TILE4 , 16, 512, 16, 1, 512, 16);
339 FCRECTALIGN(TILE4 , 32, 256, 16, 1, 256, 16);
340 FCRECTALIGN(TILE4 , 64, 128, 16, 1, 128, 16);
341 FCRECTALIGN(TILE4 , 128, 64, 16, 1, 64, 16);
342
343 FCRECTALIGN(TILE__64_2D_8bpe , 8, 128, 128, 1, 128, 128);
344 FCRECTALIGN(TILE__64_2D_16bpe , 16, 128, 64, 1, 128, 64);
345 FCRECTALIGN(TILE__64_2D_32bpe , 32, 64, 64, 1, 64, 64);
346 FCRECTALIGN(TILE__64_2D_64bpe , 64, 64, 32, 1, 64, 32);
347 FCRECTALIGN(TILE__64_2D_128bpe, 128, 32, 32, 1, 32, 32);
348
349 FCRECTALIGN(TILE__64_3D_8bpe , 8, 1, 1, 1, 1, 1);
350 FCRECTALIGN(TILE__64_3D_16bpe , 16, 1, 1, 1, 1, 1);
351 FCRECTALIGN(TILE__64_3D_32bpe , 32, 1, 1, 1, 1, 1);
352 FCRECTALIGN(TILE__64_3D_64bpe , 64, 1, 1, 1, 1, 1);
353 FCRECTALIGN(TILE__64_3D_128bpe, 128, 1, 1, 1, 1, 1);
354
355
356 }
357 #undef FCRECTALIGN
358
359 // clang-format on
360 Data.NoOfBitsSupported = 39;
361 Data.HighestAcceptablePhysicalAddress = GFX_MASK_LARGE(0, 38);
362
363 if (GFX_GET_CURRENT_PRODUCT(Data.Platform) >= IGFX_BMG)
364 {
365 Data.NoOfBitsSupported = 52;
366 Data.HighestAcceptablePhysicalAddress = GFX_MASK_LARGE(0, 51);
367 }
368 if(GFX_GET_CURRENT_PRODUCT(Data.Platform) == IGFX_PVC)
369 {
370 Data.NoOfBitsSupported = 52;
371 Data.HighestAcceptablePhysicalAddress = GFX_MASK_LARGE(0, 51);
372 }
373 else if(GFX_GET_CURRENT_PRODUCT(Data.Platform) == IGFX_ALDERLAKE_S ||
374 (GFX_GET_CURRENT_PRODUCT(Data.Platform) == IGFX_ALDERLAKE_P) ||
375 (GFX_GET_CURRENT_PRODUCT(Data.Platform) == IGFX_ALDERLAKE_N) ||
376 (GFX_GET_CURRENT_PRODUCT(Data.Platform) >= IGFX_XE_HP_SDV))
377 {
378 Data.NoOfBitsSupported = 46;
379 Data.HighestAcceptablePhysicalAddress = GFX_MASK_LARGE(0, 45);
380 }
381 }
382
ApplyExtendedTexAlign(uint32_t CCSMode,ALIGNMENT & UnitAlign)383 void GmmLib::PlatformInfoGen12::ApplyExtendedTexAlign(uint32_t CCSMode, ALIGNMENT &UnitAlign)
384 {
385 if(CCSMode < CCS_MODES)
386 {
387 UnitAlign.Width = TexAlignEx.CCSEx[CCSMode].Align.Width;
388 UnitAlign.Height = TexAlignEx.CCSEx[CCSMode].Align.Height;
389 UnitAlign.Depth = TexAlignEx.CCSEx[CCSMode].Align.Depth;
390 }
391 }
392
393 /////////////////////////////////////////////////////////////////////////////////////
394 /// Copies parameters or sets flags based on info sent by the client.
395 ///
396 /// @param[in] CreateParams: Flags which specify what sort of resource to create
397 /////////////////////////////////////////////////////////////////////////////////////
SetCCSFlag(GMM_RESOURCE_FLAG & Flags)398 void GmmLib::PlatformInfoGen12::SetCCSFlag(GMM_RESOURCE_FLAG &Flags)
399 {
400 if(Flags.Gpu.MMC)
401 {
402 Flags.Gpu.CCS = Flags.Gpu.MMC;
403 }
404 }
405
406 /////////////////////////////////////////////////////////////////////////////////////
407 /// Validates the MMC parameters passed in by clients to make sure they do not
408 /// conflict or ask for unsupporting combinations/features.
409 ///
410 /// @param[in] GMM_TEXTURE_INFO which specify what sort of resource to create
411 /// @return 1 is validation passed. 0 otherwise.
412 /////////////////////////////////////////////////////////////////////////////////////
ValidateMMC(GMM_TEXTURE_INFO & Surf)413 uint8_t GmmLib::PlatformInfoGen12::ValidateMMC(GMM_TEXTURE_INFO &Surf)
414 {
415 if(Surf.Flags.Gpu.MMC && //For Media Memory Compression --
416 (!(GMM_IS_4KB_TILE(Surf.Flags) || GMM_IS_64KB_TILE(Surf.Flags)) &&
417 (!Surf.Flags.Gpu.__NonMsaaLinearCCS)))
418 {
419 return 0;
420 }
421 return 1;
422 }
423
424 /////////////////////////////////////////////////////////////////////////////////////
425 /// Validates the parameters passed in by clients to make sure they do not
426 /// conflict or ask for unsupporting combinations/features.
427 ///
428 /// @param[in] GMM_TEXTURE_INFO which specify what sort of resource to create
429 /// @return 1 is validation passed. 0 otherwise.
430 /////////////////////////////////////////////////////////////////////////////////////
ValidateCCS(GMM_TEXTURE_INFO & Surf)431 uint8_t GmmLib::PlatformInfoGen12::ValidateCCS(GMM_TEXTURE_INFO &Surf)
432 {
433
434 if (!( //--- Legitimate CCS Case ----------------------------------------
435 ((Surf.Flags.Gpu.ProceduralTexture || //procedural texture, or compressed surface (no more separate Aux-CCS)
436 Surf.Flags.Info.RenderCompressed || Surf.Flags.Info.MediaCompressed) ||
437 pGmmLibContext->GetSkuTable().FtrXe2Compression && !Surf.Flags.Info.NotCompressed) &&
438 (((Surf.Type >= RESOURCE_2D && Surf.Type <= RESOURCE_CUBE) && //Not supported: 1D (until Flat CCS); Others Supported: Buffer, 2D, 3D, cube, Arrays, mip-maps, MSAA, Depth/Stencil
439 (GMM_IS_4KB_TILE(Surf.Flags) || GMM_IS_64KB_TILE(Surf.Flags))) || //Only on 2D + Y/Ys or Lienar buffer (until Flat CCS)
440 (Surf.Flags.Info.Linear && Surf.Type == RESOURCE_BUFFER) ||
441 ((pGmmLibContext->GetSkuTable().FtrFlatPhysCCS) && !Surf.Flags.Info.TiledX))))
442 {
443 GMM_ASSERTDPF(0, "Invalid CCS usage!");
444 return 0;
445 }
446
447 if (!pGmmLibContext->GetSkuTable().FtrFlatPhysCCS &&
448 Surf.Flags.Info.Linear && Surf.Type == RESOURCE_BUFFER && !Surf.Flags.Info.RenderCompressed)
449 {
450 GMM_ASSERTDPF(0, "Invalid CCS usage - MLC only supported as RC!");
451 return 0;
452 }
453
454 //Compressed resource (main surf) must pre-define MC/RC type
455 if(!(Surf.Flags.Gpu.__NonMsaaTileYCcs || Surf.Flags.Gpu.__NonMsaaLinearCCS) &&
456 !Surf.Flags.Gpu.ProceduralTexture &&
457 !(Surf.Flags.Info.RenderCompressed || Surf.Flags.Info.MediaCompressed || !Surf.Flags.Info.NotCompressed))
458 {
459 GMM_ASSERTDPF(0, "Invalid CCS usage - RC/MC type unspecified!");
460 return 0;
461 }
462
463 if(Surf.Flags.Info.RenderCompressed && Surf.Flags.Info.MediaCompressed)
464 {
465 GMM_ASSERTDPF(0, "Invalid CCS usage - can't be both RC and MC!");
466 return 0;
467 }
468
469 if(!pGmmLibContext->GetSkuTable().FtrLinearCCS &&
470 (Surf.Type == RESOURCE_3D || Surf.MaxLod > 0 || Surf.MSAA.NumSamples > 1 ||
471 !(Surf.Flags.Info.TiledYf || GMM_IS_64KB_TILE(Surf.Flags))))
472 {
473 GMM_ASSERTDPF(0, "CCS support for (volumetric, mip'd, MSAA'd, TileY) resources only enabled with Linear CCS!");
474 return 0;
475 }
476
477 GMM_ASSERTDPF((Surf.Flags.Wa.PreGen12FastClearOnly == 0), "FastClear Only unsupported on Gen12+!");
478 Surf.Flags.Wa.PreGen12FastClearOnly = 0;
479
480 return 1;
481 }
482
483 /////////////////////////////////////////////////////////////////////////////////////
484 /// Validates the UnifiedAuxSurface parameters passed in by clients to make sure they do not
485 /// conflict or ask for unsupporting combinations/features.
486 ///
487 /// @param[in] GMM_TEXTURE_INFO which specify what sort of resource to create
488 /// @return 1 is validation passed. 0 otherwise.
489 /////////////////////////////////////////////////////////////////////////////////////
ValidateUnifiedAuxSurface(GMM_TEXTURE_INFO & Surf)490 uint8_t GmmLib::PlatformInfoGen12::ValidateUnifiedAuxSurface(GMM_TEXTURE_INFO &Surf)
491 {
492
493 if ((Surf.Flags.Gpu.UnifiedAuxSurface) &&
494 !( //--- Legitimate UnifiedAuxSurface Case ------------------------------------------
495 (Surf.Flags.Gpu.CCS &&
496 (Surf.MSAA.NumSamples <= 1 && (Surf.Flags.Gpu.RenderTarget || Surf.Flags.Gpu.Texture))) ||
497 (Surf.Flags.Gpu.Depth || Surf.Flags.Gpu.SeparateStencil || Surf.MSAA.NumSamples > 1)))
498 {
499 GMM_ASSERTDPF(0, "Invalid UnifiedAuxSurface usage!");
500 return 0;
501 }
502
503 return 1;
504 }
505 //=============================================================================
506 //
507 // Function: CheckFmtDisplayDecompressible
508 //
509 // Desc: Returns true if display hw supports lossless render/media decompression
510 // else returns false. Restrictions are from
511 // Umds can call it to decide if full resolve is required
512 //
513 // Parameters:
514 // See function arguments.
515 //
516 // Returns:
517 // uint8_t
518 //-----------------------------------------------------------------------------
CheckFmtDisplayDecompressible(GMM_TEXTURE_INFO & Surf,bool IsSupportedRGB64_16_16_16_16,bool IsSupportedRGB32_8_8_8_8,bool IsSupportedRGB32_2_10_10_10,bool IsSupportedMediaFormats)519 uint8_t GmmLib::PlatformInfoGen12::CheckFmtDisplayDecompressible(GMM_TEXTURE_INFO &Surf,
520 bool IsSupportedRGB64_16_16_16_16,
521 bool IsSupportedRGB32_8_8_8_8,
522 bool IsSupportedRGB32_2_10_10_10,
523 bool IsSupportedMediaFormats)
524 {
525
526 //Check fmt is display decompressible
527 if (((Surf.Flags.Info.RenderCompressed || Surf.Flags.Info.MediaCompressed || !Surf.Flags.Info.NotCompressed) &&
528 (IsSupportedRGB64_16_16_16_16 || //RGB64 16:16 : 16 : 16 FP16
529 IsSupportedRGB32_8_8_8_8 || //RGB32 8 : 8 : 8 : 8
530 IsSupportedRGB32_2_10_10_10)) || //RGB32 2 : 10 : 10 : 10) ||
531 (Surf.Flags.Info.MediaCompressed && IsSupportedMediaFormats)) //YUV444 - Y412, Y416
532 {
533 //Display supports compression on TileY, but not Yf/Ys (deprecated for display support)
534 if(GMM_IS_4KB_TILE(Surf.Flags) &&
535 !(Surf.Flags.Info.TiledYf || GMM_IS_64KB_TILE(Surf.Flags)))
536 {
537 return true;
538 }
539 }
540 return false;
541 }
542
543 //=============================================================================
544 //
545 // Function: OverrideCompressionFormat
546 //
547 // Desc: SurfaceState compression format encoding differ for MC vs RC on few formats. This function
548 // overrides default RC encoding for MC requests
549 //
550 // Parameters:
551 // See function arguments.
552 //
553 // Returns:
554 // uint8_t
555 //-----------------------------------------------------------------------------
OverrideCompressionFormat(GMM_RESOURCE_FORMAT Format,uint8_t IsMC)556 uint8_t GmmLib::PlatformInfoGen12::OverrideCompressionFormat(GMM_RESOURCE_FORMAT Format, uint8_t IsMC)
557 {
558
559 uint8_t CompressionFormat = Data.FormatTable[Format].CompressionFormat.CompressionFormat;
560 if (pGmmLibContext->GetSkuTable().FtrXe2Compression)
561 {
562 if ((CompressionFormat < GMM_XE2_UNIFIED_COMP_MIN_FORMAT) ||
563 (CompressionFormat > GMM_XE2_UNIFIED_COMP_MAX_FORMAT))
564 {
565 CompressionFormat = GMM_XE2_UNIFIED_COMP_FORMAT_INVALID;
566 }
567 __GMM_ASSERT(CompressionFormat != GMM_XE2_UNIFIED_COMP_FORMAT_INVALID);
568 }
569 else if (pGmmLibContext->GetSkuTable().FtrFlatPhysCCS || pGmmLibContext->GetSkuTable().FtrUnified3DMediaCompressionFormats)
570 {
571 if(!IsMC &&
572 !pGmmLibContext->GetSkuTable().FtrUnified3DMediaCompressionFormats &&
573 (CompressionFormat < GMM_FLATCCS_MIN_RC_FORMAT ||
574 CompressionFormat > GMM_FLATCCS_MAX_RC_FORMAT))
575 {
576 CompressionFormat = GMM_FLATCCS_FORMAT_INVALID;
577 }
578
579 if(!IsMC &&
580 pGmmLibContext->GetSkuTable().FtrUnified3DMediaCompressionFormats &&
581 (CompressionFormat < GMM_UNIFIED_COMP_MIN_RC_FORMAT ||
582 CompressionFormat > GMM_UNIFIED_COMP_MAX_RC_FORMAT))
583 {
584 CompressionFormat = GMM_UNIFIED_COMP_FORMAT_INVALID;
585 }
586 else if(IsMC)
587 {
588 if(!pGmmLibContext->GetSkuTable().FtrUnified3DMediaCompressionFormats)
589 {
590 if(CompressionFormat >= GMM_FLATCCS_MIN_MC_FORMAT && CompressionFormat <= GMM_FLATCCS_MAX_MC_FORMAT)
591 {
592 //True MC format encodings, drop MC-identify bit (ie bit5)
593 CompressionFormat -= (GMM_FLATCCS_MIN_MC_FORMAT - 1);
594 }
595 else
596 {
597 // RC format encoding, needs MC format encoding for MC usage
598 switch(CompressionFormat)
599 {
600 case GMM_FLATCCS_FORMAT_RGB10A2:
601 CompressionFormat = GMM_FLATCCS_FORMAT_RGB10b;
602 break;
603 case GMM_FLATCCS_FORMAT_RGBA16U:
604 CompressionFormat = GMM_FLATCCS_FORMAT_RGBA16_MEDIA;
605 break;
606 case GMM_FLATCCS_FORMAT_RGBA8U:
607 CompressionFormat = GMM_FLATCCS_FORMAT_ARGB8b;
608 break;
609 default:
610 if(CompressionFormat < GMM_FLATCCS_MIN_MC_FORMAT || CompressionFormat > GMM_FLATCCS_MAX_MC_FORMAT)
611 {
612 CompressionFormat = GMM_FLATCCS_FORMAT_INVALID;
613 }
614 break;
615 }
616
617 if(CompressionFormat != GMM_FLATCCS_FORMAT_INVALID)
618 {
619 //drop MC-identify bit (ie bit 5)
620 CompressionFormat -= (GMM_FLATCCS_MIN_MC_FORMAT - 1);
621 }
622 }
623 }
624 else
625 {
626 if(CompressionFormat >= GMM_UNIFIED_COMP_MIN_MC_FORMAT && CompressionFormat <= GMM_UNIFIED_COMP_MAX_MC_FORMAT)
627 {
628 //True MC format encodings, drop MC-identify bit (ie bit5)
629 CompressionFormat -= (GMM_UNIFIED_COMP_MIN_MC_FORMAT - 1);
630 }
631 else
632 {
633 // RC format encoding, needs MC format encoding for MC usage
634 switch(CompressionFormat)
635 {
636 case GMM_UNIFIED_COMP_FORMAT_RGB10A2:
637 CompressionFormat = GMM_UNIFIED_COMP_FORMAT_RGB10b;
638 break;
639 case GMM_UNIFIED_COMP_FORMAT_RGBA16U:
640 case GMM_UNIFIED_COMP_FORMAT_RGBA16F:
641 CompressionFormat = GMM_UNIFIED_COMP_FORMAT_RGBA16_MEDIA;
642 break;
643 case GMM_UNIFIED_COMP_FORMAT_RGBA8U:
644 case GMM_UNIFIED_COMP_FORMAT_RGBA8S:
645 CompressionFormat = GMM_UNIFIED_COMP_FORMAT_ARGB8b;
646 break;
647 default:
648 if(CompressionFormat < GMM_UNIFIED_COMP_MIN_MC_FORMAT || CompressionFormat > GMM_UNIFIED_COMP_MAX_MC_FORMAT)
649 {
650 CompressionFormat = GMM_UNIFIED_COMP_FORMAT_INVALID;
651 }
652 break;
653 }
654
655 if(CompressionFormat != GMM_UNIFIED_COMP_FORMAT_INVALID)
656 {
657 //drop MC-identify bit (ie bit 5)
658 CompressionFormat -= (GMM_UNIFIED_COMP_MIN_MC_FORMAT - 1);
659 }
660 }
661 }
662 }
663
664 //Assert if out of MC/RC encoding range -ie format-table must be corrected for Compression code
665 __GMM_ASSERT(!pGmmLibContext->GetSkuTable().FtrUnified3DMediaCompressionFormats && CompressionFormat != GMM_FLATCCS_FORMAT_INVALID ||
666 pGmmLibContext->GetSkuTable().FtrUnified3DMediaCompressionFormats && CompressionFormat != GMM_UNIFIED_COMP_FORMAT_INVALID);
667 }
668
669 return CompressionFormat;
670 }
671