anv: support fd==-1 in ImportSemaphoreFdKHR
[mesa.git] / src / intel / isl / isl.h
1 /*
2 * Copyright 2015 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 (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 * IN THE SOFTWARE.
22 */
23
24 /**
25 * @file
26 * @brief Intel Surface Layout
27 *
28 * Header Layout
29 * -------------
30 * The header is ordered as:
31 * - forward declarations
32 * - macros that may be overridden at compile-time for specific gens
33 * - enums and constants
34 * - structs and unions
35 * - functions
36 */
37
38 #ifndef ISL_H
39 #define ISL_H
40
41 #include <assert.h>
42 #include <stdbool.h>
43 #include <stdint.h>
44
45 #include "c99_compat.h"
46 #include "util/macros.h"
47 #include "util/format/u_format.h"
48
49 #ifdef __cplusplus
50 extern "C" {
51 #endif
52
53 struct gen_device_info;
54 struct brw_image_param;
55
56 #ifndef ISL_DEV_GEN
57 /**
58 * @brief Get the hardware generation of isl_device.
59 *
60 * You can define this as a compile-time constant in the CFLAGS. For example,
61 * `gcc -DISL_DEV_GEN(dev)=9 ...`.
62 */
63 #define ISL_DEV_GEN(__dev) ((__dev)->info->gen)
64 #define ISL_DEV_GEN_SANITIZE(__dev)
65 #else
66 #define ISL_DEV_GEN_SANITIZE(__dev) \
67 (assert(ISL_DEV_GEN(__dev) == (__dev)->info->gen))
68 #endif
69
70 #ifndef ISL_DEV_IS_G4X
71 #define ISL_DEV_IS_G4X(__dev) ((__dev)->info->is_g4x)
72 #endif
73
74 #ifndef ISL_DEV_IS_HASWELL
75 /**
76 * @brief Get the hardware generation of isl_device.
77 *
78 * You can define this as a compile-time constant in the CFLAGS. For example,
79 * `gcc -DISL_DEV_GEN(dev)=9 ...`.
80 */
81 #define ISL_DEV_IS_HASWELL(__dev) ((__dev)->info->is_haswell)
82 #endif
83
84 #ifndef ISL_DEV_IS_BAYTRAIL
85 #define ISL_DEV_IS_BAYTRAIL(__dev) ((__dev)->info->is_baytrail)
86 #endif
87
88 #ifndef ISL_DEV_USE_SEPARATE_STENCIL
89 /**
90 * You can define this as a compile-time constant in the CFLAGS. For example,
91 * `gcc -DISL_DEV_USE_SEPARATE_STENCIL(dev)=1 ...`.
92 */
93 #define ISL_DEV_USE_SEPARATE_STENCIL(__dev) ((__dev)->use_separate_stencil)
94 #define ISL_DEV_USE_SEPARATE_STENCIL_SANITIZE(__dev)
95 #else
96 #define ISL_DEV_USE_SEPARATE_STENCIL_SANITIZE(__dev) \
97 (assert(ISL_DEV_USE_SEPARATE_STENCIL(__dev) == (__dev)->use_separate_stencil))
98 #endif
99
100 /**
101 * Hardware enumeration SURFACE_FORMAT.
102 *
103 * For the official list, see Broadwell PRM: Volume 2b: Command Reference:
104 * Enumerations: SURFACE_FORMAT.
105 */
106 enum isl_format {
107 ISL_FORMAT_R32G32B32A32_FLOAT = 0,
108 ISL_FORMAT_R32G32B32A32_SINT = 1,
109 ISL_FORMAT_R32G32B32A32_UINT = 2,
110 ISL_FORMAT_R32G32B32A32_UNORM = 3,
111 ISL_FORMAT_R32G32B32A32_SNORM = 4,
112 ISL_FORMAT_R64G64_FLOAT = 5,
113 ISL_FORMAT_R32G32B32X32_FLOAT = 6,
114 ISL_FORMAT_R32G32B32A32_SSCALED = 7,
115 ISL_FORMAT_R32G32B32A32_USCALED = 8,
116 ISL_FORMAT_R32G32B32A32_SFIXED = 32,
117 ISL_FORMAT_R64G64_PASSTHRU = 33,
118 ISL_FORMAT_R32G32B32_FLOAT = 64,
119 ISL_FORMAT_R32G32B32_SINT = 65,
120 ISL_FORMAT_R32G32B32_UINT = 66,
121 ISL_FORMAT_R32G32B32_UNORM = 67,
122 ISL_FORMAT_R32G32B32_SNORM = 68,
123 ISL_FORMAT_R32G32B32_SSCALED = 69,
124 ISL_FORMAT_R32G32B32_USCALED = 70,
125 ISL_FORMAT_R32G32B32_SFIXED = 80,
126 ISL_FORMAT_R16G16B16A16_UNORM = 128,
127 ISL_FORMAT_R16G16B16A16_SNORM = 129,
128 ISL_FORMAT_R16G16B16A16_SINT = 130,
129 ISL_FORMAT_R16G16B16A16_UINT = 131,
130 ISL_FORMAT_R16G16B16A16_FLOAT = 132,
131 ISL_FORMAT_R32G32_FLOAT = 133,
132 ISL_FORMAT_R32G32_SINT = 134,
133 ISL_FORMAT_R32G32_UINT = 135,
134 ISL_FORMAT_R32_FLOAT_X8X24_TYPELESS = 136,
135 ISL_FORMAT_X32_TYPELESS_G8X24_UINT = 137,
136 ISL_FORMAT_L32A32_FLOAT = 138,
137 ISL_FORMAT_R32G32_UNORM = 139,
138 ISL_FORMAT_R32G32_SNORM = 140,
139 ISL_FORMAT_R64_FLOAT = 141,
140 ISL_FORMAT_R16G16B16X16_UNORM = 142,
141 ISL_FORMAT_R16G16B16X16_FLOAT = 143,
142 ISL_FORMAT_A32X32_FLOAT = 144,
143 ISL_FORMAT_L32X32_FLOAT = 145,
144 ISL_FORMAT_I32X32_FLOAT = 146,
145 ISL_FORMAT_R16G16B16A16_SSCALED = 147,
146 ISL_FORMAT_R16G16B16A16_USCALED = 148,
147 ISL_FORMAT_R32G32_SSCALED = 149,
148 ISL_FORMAT_R32G32_USCALED = 150,
149 ISL_FORMAT_R32G32_FLOAT_LD = 151,
150 ISL_FORMAT_R32G32_SFIXED = 160,
151 ISL_FORMAT_R64_PASSTHRU = 161,
152 ISL_FORMAT_B8G8R8A8_UNORM = 192,
153 ISL_FORMAT_B8G8R8A8_UNORM_SRGB = 193,
154 ISL_FORMAT_R10G10B10A2_UNORM = 194,
155 ISL_FORMAT_R10G10B10A2_UNORM_SRGB = 195,
156 ISL_FORMAT_R10G10B10A2_UINT = 196,
157 ISL_FORMAT_R10G10B10_SNORM_A2_UNORM = 197,
158 ISL_FORMAT_R8G8B8A8_UNORM = 199,
159 ISL_FORMAT_R8G8B8A8_UNORM_SRGB = 200,
160 ISL_FORMAT_R8G8B8A8_SNORM = 201,
161 ISL_FORMAT_R8G8B8A8_SINT = 202,
162 ISL_FORMAT_R8G8B8A8_UINT = 203,
163 ISL_FORMAT_R16G16_UNORM = 204,
164 ISL_FORMAT_R16G16_SNORM = 205,
165 ISL_FORMAT_R16G16_SINT = 206,
166 ISL_FORMAT_R16G16_UINT = 207,
167 ISL_FORMAT_R16G16_FLOAT = 208,
168 ISL_FORMAT_B10G10R10A2_UNORM = 209,
169 ISL_FORMAT_B10G10R10A2_UNORM_SRGB = 210,
170 ISL_FORMAT_R11G11B10_FLOAT = 211,
171 ISL_FORMAT_R10G10B10_FLOAT_A2_UNORM = 213,
172 ISL_FORMAT_R32_SINT = 214,
173 ISL_FORMAT_R32_UINT = 215,
174 ISL_FORMAT_R32_FLOAT = 216,
175 ISL_FORMAT_R24_UNORM_X8_TYPELESS = 217,
176 ISL_FORMAT_X24_TYPELESS_G8_UINT = 218,
177 ISL_FORMAT_L32_UNORM = 221,
178 ISL_FORMAT_A32_UNORM = 222,
179 ISL_FORMAT_L16A16_UNORM = 223,
180 ISL_FORMAT_I24X8_UNORM = 224,
181 ISL_FORMAT_L24X8_UNORM = 225,
182 ISL_FORMAT_A24X8_UNORM = 226,
183 ISL_FORMAT_I32_FLOAT = 227,
184 ISL_FORMAT_L32_FLOAT = 228,
185 ISL_FORMAT_A32_FLOAT = 229,
186 ISL_FORMAT_X8B8_UNORM_G8R8_SNORM = 230,
187 ISL_FORMAT_A8X8_UNORM_G8R8_SNORM = 231,
188 ISL_FORMAT_B8X8_UNORM_G8R8_SNORM = 232,
189 ISL_FORMAT_B8G8R8X8_UNORM = 233,
190 ISL_FORMAT_B8G8R8X8_UNORM_SRGB = 234,
191 ISL_FORMAT_R8G8B8X8_UNORM = 235,
192 ISL_FORMAT_R8G8B8X8_UNORM_SRGB = 236,
193 ISL_FORMAT_R9G9B9E5_SHAREDEXP = 237,
194 ISL_FORMAT_B10G10R10X2_UNORM = 238,
195 ISL_FORMAT_L16A16_FLOAT = 240,
196 ISL_FORMAT_R32_UNORM = 241,
197 ISL_FORMAT_R32_SNORM = 242,
198 ISL_FORMAT_R10G10B10X2_USCALED = 243,
199 ISL_FORMAT_R8G8B8A8_SSCALED = 244,
200 ISL_FORMAT_R8G8B8A8_USCALED = 245,
201 ISL_FORMAT_R16G16_SSCALED = 246,
202 ISL_FORMAT_R16G16_USCALED = 247,
203 ISL_FORMAT_R32_SSCALED = 248,
204 ISL_FORMAT_R32_USCALED = 249,
205 ISL_FORMAT_B5G6R5_UNORM = 256,
206 ISL_FORMAT_B5G6R5_UNORM_SRGB = 257,
207 ISL_FORMAT_B5G5R5A1_UNORM = 258,
208 ISL_FORMAT_B5G5R5A1_UNORM_SRGB = 259,
209 ISL_FORMAT_B4G4R4A4_UNORM = 260,
210 ISL_FORMAT_B4G4R4A4_UNORM_SRGB = 261,
211 ISL_FORMAT_R8G8_UNORM = 262,
212 ISL_FORMAT_R8G8_SNORM = 263,
213 ISL_FORMAT_R8G8_SINT = 264,
214 ISL_FORMAT_R8G8_UINT = 265,
215 ISL_FORMAT_R16_UNORM = 266,
216 ISL_FORMAT_R16_SNORM = 267,
217 ISL_FORMAT_R16_SINT = 268,
218 ISL_FORMAT_R16_UINT = 269,
219 ISL_FORMAT_R16_FLOAT = 270,
220 ISL_FORMAT_A8P8_UNORM_PALETTE0 = 271,
221 ISL_FORMAT_A8P8_UNORM_PALETTE1 = 272,
222 ISL_FORMAT_I16_UNORM = 273,
223 ISL_FORMAT_L16_UNORM = 274,
224 ISL_FORMAT_A16_UNORM = 275,
225 ISL_FORMAT_L8A8_UNORM = 276,
226 ISL_FORMAT_I16_FLOAT = 277,
227 ISL_FORMAT_L16_FLOAT = 278,
228 ISL_FORMAT_A16_FLOAT = 279,
229 ISL_FORMAT_L8A8_UNORM_SRGB = 280,
230 ISL_FORMAT_R5G5_SNORM_B6_UNORM = 281,
231 ISL_FORMAT_B5G5R5X1_UNORM = 282,
232 ISL_FORMAT_B5G5R5X1_UNORM_SRGB = 283,
233 ISL_FORMAT_R8G8_SSCALED = 284,
234 ISL_FORMAT_R8G8_USCALED = 285,
235 ISL_FORMAT_R16_SSCALED = 286,
236 ISL_FORMAT_R16_USCALED = 287,
237 ISL_FORMAT_P8A8_UNORM_PALETTE0 = 290,
238 ISL_FORMAT_P8A8_UNORM_PALETTE1 = 291,
239 ISL_FORMAT_A1B5G5R5_UNORM = 292,
240 ISL_FORMAT_A4B4G4R4_UNORM = 293,
241 ISL_FORMAT_L8A8_UINT = 294,
242 ISL_FORMAT_L8A8_SINT = 295,
243 ISL_FORMAT_R8_UNORM = 320,
244 ISL_FORMAT_R8_SNORM = 321,
245 ISL_FORMAT_R8_SINT = 322,
246 ISL_FORMAT_R8_UINT = 323,
247 ISL_FORMAT_A8_UNORM = 324,
248 ISL_FORMAT_I8_UNORM = 325,
249 ISL_FORMAT_L8_UNORM = 326,
250 ISL_FORMAT_P4A4_UNORM_PALETTE0 = 327,
251 ISL_FORMAT_A4P4_UNORM_PALETTE0 = 328,
252 ISL_FORMAT_R8_SSCALED = 329,
253 ISL_FORMAT_R8_USCALED = 330,
254 ISL_FORMAT_P8_UNORM_PALETTE0 = 331,
255 ISL_FORMAT_L8_UNORM_SRGB = 332,
256 ISL_FORMAT_P8_UNORM_PALETTE1 = 333,
257 ISL_FORMAT_P4A4_UNORM_PALETTE1 = 334,
258 ISL_FORMAT_A4P4_UNORM_PALETTE1 = 335,
259 ISL_FORMAT_Y8_UNORM = 336,
260 ISL_FORMAT_L8_UINT = 338,
261 ISL_FORMAT_L8_SINT = 339,
262 ISL_FORMAT_I8_UINT = 340,
263 ISL_FORMAT_I8_SINT = 341,
264 ISL_FORMAT_DXT1_RGB_SRGB = 384,
265 ISL_FORMAT_R1_UNORM = 385,
266 ISL_FORMAT_YCRCB_NORMAL = 386,
267 ISL_FORMAT_YCRCB_SWAPUVY = 387,
268 ISL_FORMAT_P2_UNORM_PALETTE0 = 388,
269 ISL_FORMAT_P2_UNORM_PALETTE1 = 389,
270 ISL_FORMAT_BC1_UNORM = 390,
271 ISL_FORMAT_BC2_UNORM = 391,
272 ISL_FORMAT_BC3_UNORM = 392,
273 ISL_FORMAT_BC4_UNORM = 393,
274 ISL_FORMAT_BC5_UNORM = 394,
275 ISL_FORMAT_BC1_UNORM_SRGB = 395,
276 ISL_FORMAT_BC2_UNORM_SRGB = 396,
277 ISL_FORMAT_BC3_UNORM_SRGB = 397,
278 ISL_FORMAT_MONO8 = 398,
279 ISL_FORMAT_YCRCB_SWAPUV = 399,
280 ISL_FORMAT_YCRCB_SWAPY = 400,
281 ISL_FORMAT_DXT1_RGB = 401,
282 ISL_FORMAT_FXT1 = 402,
283 ISL_FORMAT_R8G8B8_UNORM = 403,
284 ISL_FORMAT_R8G8B8_SNORM = 404,
285 ISL_FORMAT_R8G8B8_SSCALED = 405,
286 ISL_FORMAT_R8G8B8_USCALED = 406,
287 ISL_FORMAT_R64G64B64A64_FLOAT = 407,
288 ISL_FORMAT_R64G64B64_FLOAT = 408,
289 ISL_FORMAT_BC4_SNORM = 409,
290 ISL_FORMAT_BC5_SNORM = 410,
291 ISL_FORMAT_R16G16B16_FLOAT = 411,
292 ISL_FORMAT_R16G16B16_UNORM = 412,
293 ISL_FORMAT_R16G16B16_SNORM = 413,
294 ISL_FORMAT_R16G16B16_SSCALED = 414,
295 ISL_FORMAT_R16G16B16_USCALED = 415,
296 ISL_FORMAT_BC6H_SF16 = 417,
297 ISL_FORMAT_BC7_UNORM = 418,
298 ISL_FORMAT_BC7_UNORM_SRGB = 419,
299 ISL_FORMAT_BC6H_UF16 = 420,
300 ISL_FORMAT_PLANAR_420_8 = 421,
301 ISL_FORMAT_R8G8B8_UNORM_SRGB = 424,
302 ISL_FORMAT_ETC1_RGB8 = 425,
303 ISL_FORMAT_ETC2_RGB8 = 426,
304 ISL_FORMAT_EAC_R11 = 427,
305 ISL_FORMAT_EAC_RG11 = 428,
306 ISL_FORMAT_EAC_SIGNED_R11 = 429,
307 ISL_FORMAT_EAC_SIGNED_RG11 = 430,
308 ISL_FORMAT_ETC2_SRGB8 = 431,
309 ISL_FORMAT_R16G16B16_UINT = 432,
310 ISL_FORMAT_R16G16B16_SINT = 433,
311 ISL_FORMAT_R32_SFIXED = 434,
312 ISL_FORMAT_R10G10B10A2_SNORM = 435,
313 ISL_FORMAT_R10G10B10A2_USCALED = 436,
314 ISL_FORMAT_R10G10B10A2_SSCALED = 437,
315 ISL_FORMAT_R10G10B10A2_SINT = 438,
316 ISL_FORMAT_B10G10R10A2_SNORM = 439,
317 ISL_FORMAT_B10G10R10A2_USCALED = 440,
318 ISL_FORMAT_B10G10R10A2_SSCALED = 441,
319 ISL_FORMAT_B10G10R10A2_UINT = 442,
320 ISL_FORMAT_B10G10R10A2_SINT = 443,
321 ISL_FORMAT_R64G64B64A64_PASSTHRU = 444,
322 ISL_FORMAT_R64G64B64_PASSTHRU = 445,
323 ISL_FORMAT_ETC2_RGB8_PTA = 448,
324 ISL_FORMAT_ETC2_SRGB8_PTA = 449,
325 ISL_FORMAT_ETC2_EAC_RGBA8 = 450,
326 ISL_FORMAT_ETC2_EAC_SRGB8_A8 = 451,
327 ISL_FORMAT_R8G8B8_UINT = 456,
328 ISL_FORMAT_R8G8B8_SINT = 457,
329 ISL_FORMAT_RAW = 511,
330 ISL_FORMAT_ASTC_LDR_2D_4X4_U8SRGB = 512,
331 ISL_FORMAT_ASTC_LDR_2D_5X4_U8SRGB = 520,
332 ISL_FORMAT_ASTC_LDR_2D_5X5_U8SRGB = 521,
333 ISL_FORMAT_ASTC_LDR_2D_6X5_U8SRGB = 529,
334 ISL_FORMAT_ASTC_LDR_2D_6X6_U8SRGB = 530,
335 ISL_FORMAT_ASTC_LDR_2D_8X5_U8SRGB = 545,
336 ISL_FORMAT_ASTC_LDR_2D_8X6_U8SRGB = 546,
337 ISL_FORMAT_ASTC_LDR_2D_8X8_U8SRGB = 548,
338 ISL_FORMAT_ASTC_LDR_2D_10X5_U8SRGB = 561,
339 ISL_FORMAT_ASTC_LDR_2D_10X6_U8SRGB = 562,
340 ISL_FORMAT_ASTC_LDR_2D_10X8_U8SRGB = 564,
341 ISL_FORMAT_ASTC_LDR_2D_10X10_U8SRGB = 566,
342 ISL_FORMAT_ASTC_LDR_2D_12X10_U8SRGB = 574,
343 ISL_FORMAT_ASTC_LDR_2D_12X12_U8SRGB = 575,
344 ISL_FORMAT_ASTC_LDR_2D_4X4_FLT16 = 576,
345 ISL_FORMAT_ASTC_LDR_2D_5X4_FLT16 = 584,
346 ISL_FORMAT_ASTC_LDR_2D_5X5_FLT16 = 585,
347 ISL_FORMAT_ASTC_LDR_2D_6X5_FLT16 = 593,
348 ISL_FORMAT_ASTC_LDR_2D_6X6_FLT16 = 594,
349 ISL_FORMAT_ASTC_LDR_2D_8X5_FLT16 = 609,
350 ISL_FORMAT_ASTC_LDR_2D_8X6_FLT16 = 610,
351 ISL_FORMAT_ASTC_LDR_2D_8X8_FLT16 = 612,
352 ISL_FORMAT_ASTC_LDR_2D_10X5_FLT16 = 625,
353 ISL_FORMAT_ASTC_LDR_2D_10X6_FLT16 = 626,
354 ISL_FORMAT_ASTC_LDR_2D_10X8_FLT16 = 628,
355 ISL_FORMAT_ASTC_LDR_2D_10X10_FLT16 = 630,
356 ISL_FORMAT_ASTC_LDR_2D_12X10_FLT16 = 638,
357 ISL_FORMAT_ASTC_LDR_2D_12X12_FLT16 = 639,
358 ISL_FORMAT_ASTC_HDR_2D_4X4_FLT16 = 832,
359 ISL_FORMAT_ASTC_HDR_2D_5X4_FLT16 = 840,
360 ISL_FORMAT_ASTC_HDR_2D_5X5_FLT16 = 841,
361 ISL_FORMAT_ASTC_HDR_2D_6X5_FLT16 = 849,
362 ISL_FORMAT_ASTC_HDR_2D_6X6_FLT16 = 850,
363 ISL_FORMAT_ASTC_HDR_2D_8X5_FLT16 = 865,
364 ISL_FORMAT_ASTC_HDR_2D_8X6_FLT16 = 866,
365 ISL_FORMAT_ASTC_HDR_2D_8X8_FLT16 = 868,
366 ISL_FORMAT_ASTC_HDR_2D_10X5_FLT16 = 881,
367 ISL_FORMAT_ASTC_HDR_2D_10X6_FLT16 = 882,
368 ISL_FORMAT_ASTC_HDR_2D_10X8_FLT16 = 884,
369 ISL_FORMAT_ASTC_HDR_2D_10X10_FLT16 = 886,
370 ISL_FORMAT_ASTC_HDR_2D_12X10_FLT16 = 894,
371 ISL_FORMAT_ASTC_HDR_2D_12X12_FLT16 = 895,
372
373 /* The formats that follow are internal to ISL and as such don't have an
374 * explicit number. We'll just let the C compiler assign it for us. Any
375 * actual hardware formats *must* come before these in the list.
376 */
377
378 /* Formats for auxiliary surfaces */
379 ISL_FORMAT_HIZ,
380 ISL_FORMAT_MCS_2X,
381 ISL_FORMAT_MCS_4X,
382 ISL_FORMAT_MCS_8X,
383 ISL_FORMAT_MCS_16X,
384 ISL_FORMAT_GEN7_CCS_32BPP_X,
385 ISL_FORMAT_GEN7_CCS_64BPP_X,
386 ISL_FORMAT_GEN7_CCS_128BPP_X,
387 ISL_FORMAT_GEN7_CCS_32BPP_Y,
388 ISL_FORMAT_GEN7_CCS_64BPP_Y,
389 ISL_FORMAT_GEN7_CCS_128BPP_Y,
390 ISL_FORMAT_GEN9_CCS_32BPP,
391 ISL_FORMAT_GEN9_CCS_64BPP,
392 ISL_FORMAT_GEN9_CCS_128BPP,
393 ISL_FORMAT_GEN12_CCS_8BPP_Y0,
394 ISL_FORMAT_GEN12_CCS_16BPP_Y0,
395 ISL_FORMAT_GEN12_CCS_32BPP_Y0,
396 ISL_FORMAT_GEN12_CCS_64BPP_Y0,
397 ISL_FORMAT_GEN12_CCS_128BPP_Y0,
398
399 /* An upper bound on the supported format enumerations */
400 ISL_NUM_FORMATS,
401
402 /* Hardware doesn't understand this out-of-band value */
403 ISL_FORMAT_UNSUPPORTED = UINT16_MAX,
404 };
405
406 /**
407 * Numerical base type for channels of isl_format.
408 */
409 enum isl_base_type {
410 ISL_VOID,
411 ISL_RAW,
412 ISL_UNORM,
413 ISL_SNORM,
414 ISL_UFLOAT,
415 ISL_SFLOAT,
416 ISL_UFIXED,
417 ISL_SFIXED,
418 ISL_UINT,
419 ISL_SINT,
420 ISL_USCALED,
421 ISL_SSCALED,
422 };
423
424 /**
425 * Colorspace of isl_format.
426 */
427 enum isl_colorspace {
428 ISL_COLORSPACE_NONE = 0,
429 ISL_COLORSPACE_LINEAR,
430 ISL_COLORSPACE_SRGB,
431 ISL_COLORSPACE_YUV,
432 };
433
434 /**
435 * Texture compression mode of isl_format.
436 */
437 enum isl_txc {
438 ISL_TXC_NONE = 0,
439 ISL_TXC_DXT1,
440 ISL_TXC_DXT3,
441 ISL_TXC_DXT5,
442 ISL_TXC_FXT1,
443 ISL_TXC_RGTC1,
444 ISL_TXC_RGTC2,
445 ISL_TXC_BPTC,
446 ISL_TXC_ETC1,
447 ISL_TXC_ETC2,
448 ISL_TXC_ASTC,
449
450 /* Used for auxiliary surface formats */
451 ISL_TXC_HIZ,
452 ISL_TXC_MCS,
453 ISL_TXC_CCS,
454 };
455
456 /**
457 * @brief Hardware tile mode
458 *
459 * WARNING: These values differ from the hardware enum values, which are
460 * unstable across hardware generations.
461 *
462 * Note that legacy Y tiling is ISL_TILING_Y0 instead of ISL_TILING_Y, to
463 * clearly distinguish it from Yf and Ys.
464 */
465 enum isl_tiling {
466 ISL_TILING_LINEAR = 0,
467 ISL_TILING_W,
468 ISL_TILING_X,
469 ISL_TILING_Y0, /**< Legacy Y tiling */
470 ISL_TILING_Yf, /**< Standard 4K tiling. The 'f' means "four". */
471 ISL_TILING_Ys, /**< Standard 64K tiling. The 's' means "sixty-four". */
472 ISL_TILING_HIZ, /**< Tiling format for HiZ surfaces */
473 ISL_TILING_CCS, /**< Tiling format for CCS surfaces */
474 ISL_TILING_GEN12_CCS, /**< Tiling format for Gen12 CCS surfaces */
475 };
476
477 /**
478 * @defgroup Tiling Flags
479 * @{
480 */
481 typedef uint32_t isl_tiling_flags_t;
482 #define ISL_TILING_LINEAR_BIT (1u << ISL_TILING_LINEAR)
483 #define ISL_TILING_W_BIT (1u << ISL_TILING_W)
484 #define ISL_TILING_X_BIT (1u << ISL_TILING_X)
485 #define ISL_TILING_Y0_BIT (1u << ISL_TILING_Y0)
486 #define ISL_TILING_Yf_BIT (1u << ISL_TILING_Yf)
487 #define ISL_TILING_Ys_BIT (1u << ISL_TILING_Ys)
488 #define ISL_TILING_HIZ_BIT (1u << ISL_TILING_HIZ)
489 #define ISL_TILING_CCS_BIT (1u << ISL_TILING_CCS)
490 #define ISL_TILING_GEN12_CCS_BIT (1u << ISL_TILING_GEN12_CCS)
491 #define ISL_TILING_ANY_MASK (~0u)
492 #define ISL_TILING_NON_LINEAR_MASK (~ISL_TILING_LINEAR_BIT)
493
494 /** Any Y tiling, including legacy Y tiling. */
495 #define ISL_TILING_ANY_Y_MASK (ISL_TILING_Y0_BIT | \
496 ISL_TILING_Yf_BIT | \
497 ISL_TILING_Ys_BIT)
498
499 /** The Skylake BSpec refers to Yf and Ys as "standard tiling formats". */
500 #define ISL_TILING_STD_Y_MASK (ISL_TILING_Yf_BIT | \
501 ISL_TILING_Ys_BIT)
502 /** @} */
503
504 /**
505 * @brief Logical dimension of surface.
506 *
507 * Note: There is no dimension for cube map surfaces. ISL interprets cube maps
508 * as 2D array surfaces.
509 */
510 enum isl_surf_dim {
511 ISL_SURF_DIM_1D,
512 ISL_SURF_DIM_2D,
513 ISL_SURF_DIM_3D,
514 };
515
516 /**
517 * @brief Physical layout of the surface's dimensions.
518 */
519 enum isl_dim_layout {
520 /**
521 * For details, see the G35 PRM >> Volume 1: Graphics Core >> Section
522 * 6.17.3: 2D Surfaces.
523 *
524 * On many gens, 1D surfaces share the same layout as 2D surfaces. From
525 * the G35 PRM >> Volume 1: Graphics Core >> Section 6.17.2: 1D Surfaces:
526 *
527 * One-dimensional surfaces are identical to 2D surfaces with height of
528 * one.
529 *
530 * @invariant isl_surf::phys_level0_sa::depth == 1
531 */
532 ISL_DIM_LAYOUT_GEN4_2D,
533
534 /**
535 * For details, see the G35 PRM >> Volume 1: Graphics Core >> Section
536 * 6.17.5: 3D Surfaces.
537 *
538 * @invariant isl_surf::phys_level0_sa::array_len == 1
539 */
540 ISL_DIM_LAYOUT_GEN4_3D,
541
542 /**
543 * Special layout used for HiZ and stencil on Sandy Bridge to work around
544 * the hardware's lack of mipmap support. On gen6, HiZ and stencil buffers
545 * work the same as on gen7+ except that they don't technically support
546 * mipmapping. That does not, however, stop us from doing it. As far as
547 * Sandy Bridge hardware is concerned, HiZ and stencil always operates on a
548 * single miplevel 2D (possibly array) image. The dimensions of that image
549 * are NOT minified.
550 *
551 * In order to implement HiZ and stencil on Sandy Bridge, we create one
552 * full-sized 2D (possibly array) image for every LOD with every image
553 * aligned to a page boundary. When the surface is used with the stencil
554 * or HiZ hardware, we manually offset to the image for the given LOD.
555 *
556 * As a memory saving measure, we pretend that the width of each miplevel
557 * is minified and we place LOD1 and above below LOD0 but horizontally
558 * adjacent to each other. When considered as full-sized images, LOD1 and
559 * above technically overlap. However, since we only write to part of that
560 * image, the hardware will never notice the overlap.
561 *
562 * This layout looks something like this:
563 *
564 * +---------+
565 * | |
566 * | |
567 * +---------+
568 * | |
569 * | |
570 * +---------+
571 *
572 * +----+ +-+ .
573 * | | +-+
574 * +----+
575 *
576 * +----+ +-+ .
577 * | | +-+
578 * +----+
579 */
580 ISL_DIM_LAYOUT_GEN6_STENCIL_HIZ,
581
582 /**
583 * For details, see the Skylake BSpec >> Memory Views >> Common Surface
584 * Formats >> Surface Layout and Tiling >> » 1D Surfaces.
585 */
586 ISL_DIM_LAYOUT_GEN9_1D,
587 };
588
589 enum isl_aux_usage {
590 /** No Auxiliary surface is used */
591 ISL_AUX_USAGE_NONE,
592
593 /** The primary surface is a depth surface and the auxiliary surface is HiZ */
594 ISL_AUX_USAGE_HIZ,
595
596 /** The auxiliary surface is an MCS
597 *
598 * @invariant isl_surf::samples > 1
599 */
600 ISL_AUX_USAGE_MCS,
601
602 /** The auxiliary surface is a fast-clear-only compression surface
603 *
604 * @invariant isl_surf::samples == 1
605 */
606 ISL_AUX_USAGE_CCS_D,
607
608 /** The auxiliary surface provides full lossless color compression
609 *
610 * @invariant isl_surf::samples == 1
611 */
612 ISL_AUX_USAGE_CCS_E,
613
614 /** The auxiliary surface provides full lossless color compression on
615 * Gen12.
616 *
617 * @invariant isl_surf::samples == 1
618 */
619 ISL_AUX_USAGE_GEN12_CCS_E,
620
621 /** The auxiliary surface provides full lossless media color compression
622 *
623 * @invariant isl_surf::samples == 1
624 */
625 ISL_AUX_USAGE_MC,
626
627 /** The auxiliary surface is a HiZ surface operating in write-through mode
628 * and CCS is also enabled
629 *
630 * In this mode, the HiZ and CCS surfaces act as a single fused compression
631 * surface where resolves and ambiguates operate on both surfaces at the
632 * same time. In this mode, the HiZ surface operates in write-through
633 * mode where it is only used for accelerating depth testing and not for
634 * actual compression. The CCS-compressed surface contains valid data at
635 * all times.
636 *
637 * @invariant isl_surf::samples == 1
638 */
639 ISL_AUX_USAGE_HIZ_CCS_WT,
640
641 /** The auxiliary surface is a HiZ surface with and CCS is also enabled
642 *
643 * In this mode, the HiZ and CCS surfaces act as a single fused compression
644 * surface where resolves and ambiguates operate on both surfaces at the
645 * same time. In this mode, full HiZ compression is enabled and the
646 * CCS-compressed main surface may not contain valid data. The only way to
647 * read the surface outside of the depth hardware is to do a full resolve
648 * which resolves both HiZ and CCS so the surface is in the pass-through
649 * state.
650 */
651 ISL_AUX_USAGE_HIZ_CCS,
652
653 /** The auxiliary surface is an MCS and CCS is also enabled
654 *
655 * In this mode, we have fused MCS+CCS compression where the MCS is used
656 * for fast-clears and "identical samples" compression just like on Gen7-11
657 * but each plane is then CCS compressed.
658 *
659 * @invariant isl_surf::samples > 1
660 */
661 ISL_AUX_USAGE_MCS_CCS,
662
663 /** CCS auxiliary data is used to compress a stencil buffer
664 *
665 * @invariant isl_surf::samples == 1
666 */
667 ISL_AUX_USAGE_STC_CCS,
668 };
669
670 /**
671 * Enum for keeping track of the state an auxiliary compressed surface.
672 *
673 * For any given auxiliary surface compression format (HiZ, CCS, or MCS), any
674 * given slice (lod + array layer) can be in one of the six states described
675 * by this enum. Draw and resolve operations may cause the slice to change
676 * from one state to another. The six valid states are:
677 *
678 * 1) Clear: In this state, each block in the auxiliary surface contains a
679 * magic value that indicates that the block is in the clear state. If
680 * a block is in the clear state, it's values in the primary surface are
681 * ignored and the color of the samples in the block is taken either the
682 * RENDER_SURFACE_STATE packet for color or 3DSTATE_CLEAR_PARAMS for
683 * depth. Since neither the primary surface nor the auxiliary surface
684 * contains the clear value, the surface can be cleared to a different
685 * color by simply changing the clear color without modifying either
686 * surface.
687 *
688 * 2) Partial Clear: In this state, each block in the auxiliary surface
689 * contains either the magic clear or pass-through value. See Clear and
690 * Pass-through for more details.
691 *
692 * 3) Compressed w/ Clear: In this state, neither the auxiliary surface
693 * nor the primary surface has a complete representation of the data.
694 * Instead, both surfaces must be used together or else rendering
695 * corruption may occur. Depending on the auxiliary compression format
696 * and the data, any given block in the primary surface may contain all,
697 * some, or none of the data required to reconstruct the actual sample
698 * values. Blocks may also be in the clear state (see Clear) and have
699 * their value taken from outside the surface.
700 *
701 * 4) Compressed w/o Clear: This state is identical to the state above
702 * except that no blocks are in the clear state. In this state, all of
703 * the data required to reconstruct the final sample values is contained
704 * in the auxiliary and primary surface and the clear value is not
705 * considered.
706 *
707 * 5) Resolved: In this state, the primary surface contains 100% of the
708 * data. The auxiliary surface is also valid so the surface can be
709 * validly used with or without aux enabled. The auxiliary surface may,
710 * however, contain non-trivial data and any update to the primary
711 * surface with aux disabled will cause the two to get out of sync.
712 *
713 * 6) Pass-through: In this state, the primary surface contains 100% of the
714 * data and every block in the auxiliary surface contains a magic value
715 * which indicates that the auxiliary surface should be ignored and the
716 * only the primary surface should be considered. Updating the primary
717 * surface without aux works fine and can be done repeatedly in this
718 * mode. Writing to a surface in pass-through mode with aux enabled may
719 * cause the auxiliary buffer to contain non-trivial data and no longer
720 * be in the pass-through state.
721 *
722 * 7) Aux Invalid: In this state, the primary surface contains 100% of the
723 * data and the auxiliary surface is completely bogus. Any attempt to
724 * use the auxiliary surface is liable to result in rendering
725 * corruption. The only thing that one can do to re-enable aux once
726 * this state is reached is to use an ambiguate pass to transition into
727 * the pass-through state.
728 *
729 * Drawing with or without aux enabled may implicitly cause the surface to
730 * transition between these states. There are also four types of auxiliary
731 * compression operations which cause an explicit transition which are
732 * described by the isl_aux_op enum below.
733 *
734 * Not all operations are valid or useful in all states. The diagram below
735 * contains a complete description of the states and all valid and useful
736 * transitions except clear.
737 *
738 * Draw w/ Aux
739 * +----------+
740 * | |
741 * | +-------------+ Draw w/ Aux +-------------+
742 * +------>| Compressed |<-------------------| Clear |
743 * | w/ Clear |----->----+ | |
744 * +-------------+ | +-------------+
745 * | /|\ | | |
746 * | | | | |
747 * | | +------<-----+ | Draw w/
748 * | | | | Clear Only
749 * | | Full | | +----------+
750 * Partial | | Resolve | \|/ | |
751 * Resolve | | | +-------------+ |
752 * | | | | Partial |<------+
753 * | | | | Clear |<----------+
754 * | | | +-------------+ |
755 * | | | | |
756 * | | +------>---------+ Full |
757 * | | | Resolve |
758 * Draw w/ aux | | Partial Fast Clear | |
759 * +----------+ | +--------------------------+ | |
760 * | | \|/ | \|/ |
761 * | +-------------+ Full Resolve +-------------+ |
762 * +------>| Compressed |------------------->| Resolved | |
763 * | w/o Clear |<-------------------| | |
764 * +-------------+ Draw w/ Aux +-------------+ |
765 * /|\ | | |
766 * | Draw | | Draw |
767 * | w/ Aux | | w/o Aux |
768 * | Ambiguate | | |
769 * | +--------------------------+ | |
770 * Draw w/o Aux | | | Draw w/o Aux |
771 * +----------+ | | | +----------+ |
772 * | | | \|/ \|/ | | |
773 * | +-------------+ Ambiguate +-------------+ | |
774 * +------>| Pass- |<-------------------| Aux |<------+ |
775 * +------>| through | | Invalid | |
776 * | +-------------+ +-------------+ |
777 * | | | |
778 * +----------+ +-----------------------------------------------------+
779 * Draw w/ Partial Fast Clear
780 * Clear Only
781 *
782 *
783 * While the above general theory applies to all forms of auxiliary
784 * compression on Intel hardware, not all states and operations are available
785 * on all compression types. However, each of the auxiliary states and
786 * operations can be fairly easily mapped onto the above diagram:
787 *
788 * HiZ: Hierarchical depth compression is capable of being in any of the
789 * states above. Hardware provides three HiZ operations: "Depth
790 * Clear", "Depth Resolve", and "HiZ Resolve" which map to "Fast
791 * Clear", "Full Resolve", and "Ambiguate" respectively. The
792 * hardware provides no HiZ partial resolve operation so the only way
793 * to get into the "Compressed w/o Clear" state is to render with HiZ
794 * when the surface is in the resolved or pass-through states.
795 *
796 * MCS: Multisample compression is technically capable of being in any of
797 * the states above except that most of them aren't useful. Both the
798 * render engine and the sampler support MCS compression and, apart
799 * from clear color, MCS is format-unaware so we leave the surface
800 * compressed 100% of the time. The hardware provides no MCS
801 * operations.
802 *
803 * CCS_D: Single-sample fast-clears (also called CCS_D in ISL) are one of
804 * the simplest forms of compression since they don't do anything
805 * beyond clear color tracking. They really only support three of
806 * the six states: Clear, Partial Clear, and Pass-through. The
807 * only CCS_D operation is "Resolve" which maps to a full resolve
808 * followed by an ambiguate.
809 *
810 * CCS_E: Single-sample render target compression (also called CCS_E in ISL)
811 * is capable of being in almost all of the above states. THe only
812 * exception is that it does not have separate resolved and pass-
813 * through states. Instead, the CCS_E full resolve operation does
814 * both a resolve and an ambiguate so it goes directly into the
815 * pass-through state. CCS_E also provides fast clear and partial
816 * resolve operations which work as described above.
817 *
818 * While it is technically possible to perform a CCS_E ambiguate, it
819 * is not provided by Sky Lake hardware so we choose to avoid the aux
820 * invalid state. If the aux invalid state were determined to be
821 * useful, a CCS ambiguate could be done by carefully rendering to
822 * the CCS and filling it with zeros.
823 */
824 enum isl_aux_state {
825 #ifdef IN_UNIT_TEST
826 ISL_AUX_STATE_ASSERT,
827 #endif
828 ISL_AUX_STATE_CLEAR,
829 ISL_AUX_STATE_PARTIAL_CLEAR,
830 ISL_AUX_STATE_COMPRESSED_CLEAR,
831 ISL_AUX_STATE_COMPRESSED_NO_CLEAR,
832 ISL_AUX_STATE_RESOLVED,
833 ISL_AUX_STATE_PASS_THROUGH,
834 ISL_AUX_STATE_AUX_INVALID,
835 };
836
837 /**
838 * Enum which describes explicit aux transition operations.
839 */
840 enum isl_aux_op {
841 #ifdef IN_UNIT_TEST
842 ISL_AUX_OP_ASSERT,
843 #endif
844
845 ISL_AUX_OP_NONE,
846
847 /** Fast Clear
848 *
849 * This operation writes the magic "clear" value to the auxiliary surface.
850 * This operation will safely transition any slice of a surface from any
851 * state to the clear state so long as the entire slice is fast cleared at
852 * once. A fast clear that only covers part of a slice of a surface is
853 * called a partial fast clear.
854 */
855 ISL_AUX_OP_FAST_CLEAR,
856
857 /** Full Resolve
858 *
859 * This operation combines the auxiliary surface data with the primary
860 * surface data and writes the result to the primary. For HiZ, the docs
861 * call this a depth resolve. For CCS, the hardware full resolve operation
862 * does both a full resolve and an ambiguate so it actually takes you all
863 * the way to the pass-through state.
864 */
865 ISL_AUX_OP_FULL_RESOLVE,
866
867 /** Partial Resolve
868 *
869 * This operation considers blocks which are in the "clear" state and
870 * writes the clear value directly into the primary or auxiliary surface.
871 * Once this operation completes, the surface is still compressed but no
872 * longer references the clear color. This operation is only available
873 * for CCS_E.
874 */
875 ISL_AUX_OP_PARTIAL_RESOLVE,
876
877 /** Ambiguate
878 *
879 * This operation throws away the current auxiliary data and replaces it
880 * with the magic pass-through value. If an ambiguate operation is
881 * performed when the primary surface does not contain 100% of the data,
882 * data will be lost. This operation is only implemented in hardware for
883 * depth where it is called a HiZ resolve.
884 */
885 ISL_AUX_OP_AMBIGUATE,
886 };
887
888 /* TODO(chadv): Explain */
889 enum isl_array_pitch_span {
890 ISL_ARRAY_PITCH_SPAN_FULL,
891 ISL_ARRAY_PITCH_SPAN_COMPACT,
892 };
893
894 /**
895 * @defgroup Surface Usage
896 * @{
897 */
898 typedef uint64_t isl_surf_usage_flags_t;
899 #define ISL_SURF_USAGE_RENDER_TARGET_BIT (1u << 0)
900 #define ISL_SURF_USAGE_DEPTH_BIT (1u << 1)
901 #define ISL_SURF_USAGE_STENCIL_BIT (1u << 2)
902 #define ISL_SURF_USAGE_TEXTURE_BIT (1u << 3)
903 #define ISL_SURF_USAGE_CUBE_BIT (1u << 4)
904 #define ISL_SURF_USAGE_DISABLE_AUX_BIT (1u << 5)
905 #define ISL_SURF_USAGE_DISPLAY_BIT (1u << 6)
906 #define ISL_SURF_USAGE_DISPLAY_ROTATE_90_BIT (1u << 7)
907 #define ISL_SURF_USAGE_DISPLAY_ROTATE_180_BIT (1u << 8)
908 #define ISL_SURF_USAGE_DISPLAY_ROTATE_270_BIT (1u << 9)
909 #define ISL_SURF_USAGE_DISPLAY_FLIP_X_BIT (1u << 10)
910 #define ISL_SURF_USAGE_DISPLAY_FLIP_Y_BIT (1u << 11)
911 #define ISL_SURF_USAGE_STORAGE_BIT (1u << 12)
912 #define ISL_SURF_USAGE_HIZ_BIT (1u << 13)
913 #define ISL_SURF_USAGE_MCS_BIT (1u << 14)
914 #define ISL_SURF_USAGE_CCS_BIT (1u << 15)
915 /** @} */
916
917 /**
918 * @defgroup Channel Mask
919 *
920 * These #define values are chosen to match the values of
921 * RENDER_SURFACE_STATE::Color Buffer Component Write Disables
922 *
923 * @{
924 */
925 typedef uint8_t isl_channel_mask_t;
926 #define ISL_CHANNEL_BLUE_BIT (1 << 0)
927 #define ISL_CHANNEL_GREEN_BIT (1 << 1)
928 #define ISL_CHANNEL_RED_BIT (1 << 2)
929 #define ISL_CHANNEL_ALPHA_BIT (1 << 3)
930 /** @} */
931
932 /**
933 * @brief A channel select (also known as texture swizzle) value
934 */
935 enum PACKED isl_channel_select {
936 ISL_CHANNEL_SELECT_ZERO = 0,
937 ISL_CHANNEL_SELECT_ONE = 1,
938 ISL_CHANNEL_SELECT_RED = 4,
939 ISL_CHANNEL_SELECT_GREEN = 5,
940 ISL_CHANNEL_SELECT_BLUE = 6,
941 ISL_CHANNEL_SELECT_ALPHA = 7,
942 };
943
944 /**
945 * Identical to VkSampleCountFlagBits.
946 */
947 enum isl_sample_count {
948 ISL_SAMPLE_COUNT_1_BIT = 1u,
949 ISL_SAMPLE_COUNT_2_BIT = 2u,
950 ISL_SAMPLE_COUNT_4_BIT = 4u,
951 ISL_SAMPLE_COUNT_8_BIT = 8u,
952 ISL_SAMPLE_COUNT_16_BIT = 16u,
953 };
954 typedef uint32_t isl_sample_count_mask_t;
955
956 /**
957 * @brief Multisample Format
958 */
959 enum isl_msaa_layout {
960 /**
961 * @brief Suface is single-sampled.
962 */
963 ISL_MSAA_LAYOUT_NONE,
964
965 /**
966 * @brief [SNB+] Interleaved Multisample Format
967 *
968 * In this format, multiple samples are interleaved into each cacheline.
969 * In other words, the sample index is swizzled into the low 6 bits of the
970 * surface's virtual address space.
971 *
972 * For example, suppose the surface is legacy Y tiled, is 4x multisampled,
973 * and its pixel format is 32bpp. Then the first cacheline is arranged
974 * thus:
975 *
976 * (0,0,0) (0,1,0) (0,0,1) (1,0,1)
977 * (1,0,0) (1,1,0) (0,1,1) (1,1,1)
978 *
979 * (0,0,2) (1,0,2) (0,0,3) (1,0,3)
980 * (0,1,2) (1,1,2) (0,1,3) (1,1,3)
981 *
982 * The hardware docs refer to this format with multiple terms. In
983 * Sandybridge, this is the only multisample format; so no term is used.
984 * The Ivybridge docs refer to surfaces in this format as IMS (Interleaved
985 * Multisample Surface). Later hardware docs additionally refer to this
986 * format as MSFMT_DEPTH_STENCIL (because the format is deprecated for
987 * color surfaces).
988 *
989 * See the Sandybridge PRM, Volume 4, Part 1, Section 2.7 "Multisampled
990 * Surface Behavior".
991 *
992 * See the Ivybridge PRM, Volume 1, Part 1, Section 6.18.4.1 "Interleaved
993 * Multisampled Surfaces".
994 */
995 ISL_MSAA_LAYOUT_INTERLEAVED,
996
997 /**
998 * @brief [IVB+] Array Multisample Format
999 *
1000 * In this format, the surface's physical layout resembles that of a
1001 * 2D array surface.
1002 *
1003 * Suppose the multisample surface's logical extent is (w, h) and its
1004 * sample count is N. Then surface's physical extent is the same as
1005 * a singlesample 2D surface whose logical extent is (w, h) and array
1006 * length is N. Array slice `i` contains the pixel values for sample
1007 * index `i`.
1008 *
1009 * The Ivybridge docs refer to surfaces in this format as UMS
1010 * (Uncompressed Multsample Layout) and CMS (Compressed Multisample
1011 * Surface). The Broadwell docs additionally refer to this format as
1012 * MSFMT_MSS (MSS=Multisample Surface Storage).
1013 *
1014 * See the Broadwell PRM, Volume 5 "Memory Views", Section "Uncompressed
1015 * Multisample Surfaces".
1016 *
1017 * See the Broadwell PRM, Volume 5 "Memory Views", Section "Compressed
1018 * Multisample Surfaces".
1019 */
1020 ISL_MSAA_LAYOUT_ARRAY,
1021 };
1022
1023 typedef enum {
1024 ISL_MEMCPY = 0,
1025 ISL_MEMCPY_BGRA8,
1026 ISL_MEMCPY_STREAMING_LOAD,
1027 ISL_MEMCPY_INVALID,
1028 } isl_memcpy_type;
1029
1030 struct isl_device {
1031 const struct gen_device_info *info;
1032 bool use_separate_stencil;
1033 bool has_bit6_swizzling;
1034
1035 /**
1036 * Describes the layout of a RENDER_SURFACE_STATE structure for the
1037 * current gen.
1038 */
1039 struct {
1040 uint8_t size;
1041 uint8_t align;
1042 uint8_t addr_offset;
1043 uint8_t aux_addr_offset;
1044
1045 /* Rounded up to the nearest dword to simplify GPU memcpy operations. */
1046
1047 /* size of the state buffer used to store the clear color + extra
1048 * additional space used by the hardware */
1049 uint8_t clear_color_state_size;
1050 uint8_t clear_color_state_offset;
1051 /* size of the clear color itself - used to copy it to/from a BO */
1052 uint8_t clear_value_size;
1053 uint8_t clear_value_offset;
1054 } ss;
1055
1056 /**
1057 * Describes the layout of the depth/stencil/hiz commands as emitted by
1058 * isl_emit_depth_stencil_hiz.
1059 */
1060 struct {
1061 uint8_t size;
1062 uint8_t depth_offset;
1063 uint8_t stencil_offset;
1064 uint8_t hiz_offset;
1065 } ds;
1066
1067 struct {
1068 uint32_t internal;
1069 uint32_t external;
1070 } mocs;
1071 };
1072
1073 struct isl_extent2d {
1074 union { uint32_t w, width; };
1075 union { uint32_t h, height; };
1076 };
1077
1078 struct isl_extent3d {
1079 union { uint32_t w, width; };
1080 union { uint32_t h, height; };
1081 union { uint32_t d, depth; };
1082 };
1083
1084 struct isl_extent4d {
1085 union { uint32_t w, width; };
1086 union { uint32_t h, height; };
1087 union { uint32_t d, depth; };
1088 union { uint32_t a, array_len; };
1089 };
1090
1091 struct isl_channel_layout {
1092 enum isl_base_type type;
1093 uint8_t start_bit; /**< Bit at which this channel starts */
1094 uint8_t bits; /**< Size in bits */
1095 };
1096
1097 /**
1098 * Each format has 3D block extent (width, height, depth). The block extent of
1099 * compressed formats is that of the format's compression block. For example,
1100 * the block extent of ISL_FORMAT_ETC2_RGB8 is (w=4, h=4, d=1). The block
1101 * extent of uncompressed pixel formats, such as ISL_FORMAT_R8G8B8A8_UNORM, is
1102 * is (w=1, h=1, d=1).
1103 */
1104 struct isl_format_layout {
1105 enum isl_format format;
1106 const char *name;
1107
1108 uint16_t bpb; /**< Bits per block */
1109 uint8_t bw; /**< Block width, in pixels */
1110 uint8_t bh; /**< Block height, in pixels */
1111 uint8_t bd; /**< Block depth, in pixels */
1112
1113 union {
1114 struct {
1115 struct isl_channel_layout r; /**< Red channel */
1116 struct isl_channel_layout g; /**< Green channel */
1117 struct isl_channel_layout b; /**< Blue channel */
1118 struct isl_channel_layout a; /**< Alpha channel */
1119 struct isl_channel_layout l; /**< Luminance channel */
1120 struct isl_channel_layout i; /**< Intensity channel */
1121 struct isl_channel_layout p; /**< Palette channel */
1122 } channels;
1123 struct isl_channel_layout channels_array[7];
1124 };
1125
1126 enum isl_colorspace colorspace;
1127 enum isl_txc txc;
1128 };
1129
1130 struct isl_tile_info {
1131 enum isl_tiling tiling;
1132
1133 /* The size (in bits per block) of a single surface element
1134 *
1135 * For surfaces with power-of-two formats, this is the same as
1136 * isl_format_layout::bpb. For non-power-of-two formats it may be smaller.
1137 * The logical_extent_el field is in terms of elements of this size.
1138 *
1139 * For example, consider ISL_FORMAT_R32G32B32_FLOAT for which
1140 * isl_format_layout::bpb is 96 (a non-power-of-two). In this case, none
1141 * of the tiling formats can actually hold an integer number of 96-bit
1142 * surface elements so isl_tiling_get_info returns an isl_tile_info for a
1143 * 32-bit element size. It is the responsibility of the caller to
1144 * recognize that 32 != 96 ad adjust accordingly. For instance, to compute
1145 * the width of a surface in tiles, you would do:
1146 *
1147 * width_tl = DIV_ROUND_UP(width_el * (format_bpb / tile_info.format_bpb),
1148 * tile_info.logical_extent_el.width);
1149 */
1150 uint32_t format_bpb;
1151
1152 /** The logical size of the tile in units of format_bpb size elements
1153 *
1154 * This field determines how a given surface is cut up into tiles. It is
1155 * used to compute the size of a surface in tiles and can be used to
1156 * determine the location of the tile containing any given surface element.
1157 * The exact value of this field depends heavily on the bits-per-block of
1158 * the format being used.
1159 */
1160 struct isl_extent2d logical_extent_el;
1161
1162 /** The physical size of the tile in bytes and rows of bytes
1163 *
1164 * This field determines how the tiles of a surface are physically layed
1165 * out in memory. The logical and physical tile extent are frequently the
1166 * same but this is not always the case. For instance, a W-tile (which is
1167 * always used with ISL_FORMAT_R8) has a logical size of 64el x 64el but
1168 * its physical size is 128B x 32rows, the same as a Y-tile.
1169 *
1170 * @see isl_surf::row_pitch_B
1171 */
1172 struct isl_extent2d phys_extent_B;
1173 };
1174
1175 /**
1176 * Metadata about a DRM format modifier.
1177 */
1178 struct isl_drm_modifier_info {
1179 uint64_t modifier;
1180
1181 /** Text name of the modifier */
1182 const char *name;
1183
1184 /** ISL tiling implied by this modifier */
1185 enum isl_tiling tiling;
1186
1187 /** ISL aux usage implied by this modifier */
1188 enum isl_aux_usage aux_usage;
1189
1190 /** Whether or not this modifier supports clear color */
1191 bool supports_clear_color;
1192 };
1193
1194 /**
1195 * @brief Input to surface initialization
1196 *
1197 * @invariant width >= 1
1198 * @invariant height >= 1
1199 * @invariant depth >= 1
1200 * @invariant levels >= 1
1201 * @invariant samples >= 1
1202 * @invariant array_len >= 1
1203 *
1204 * @invariant if 1D then height == 1 and depth == 1 and samples == 1
1205 * @invariant if 2D then depth == 1
1206 * @invariant if 3D then array_len == 1 and samples == 1
1207 */
1208 struct isl_surf_init_info {
1209 enum isl_surf_dim dim;
1210 enum isl_format format;
1211
1212 uint32_t width;
1213 uint32_t height;
1214 uint32_t depth;
1215 uint32_t levels;
1216 uint32_t array_len;
1217 uint32_t samples;
1218
1219 /** Lower bound for isl_surf::alignment, in bytes. */
1220 uint32_t min_alignment_B;
1221
1222 /**
1223 * Exact value for isl_surf::row_pitch. Ignored if zero. isl_surf_init()
1224 * will fail if this is misaligned or out of bounds.
1225 */
1226 uint32_t row_pitch_B;
1227
1228 isl_surf_usage_flags_t usage;
1229
1230 /** Flags that alter how ISL selects isl_surf::tiling. */
1231 isl_tiling_flags_t tiling_flags;
1232 };
1233
1234 struct isl_surf {
1235 enum isl_surf_dim dim;
1236 enum isl_dim_layout dim_layout;
1237 enum isl_msaa_layout msaa_layout;
1238 enum isl_tiling tiling;
1239 enum isl_format format;
1240
1241 /**
1242 * Alignment of the upper-left sample of each subimage, in units of surface
1243 * elements.
1244 */
1245 struct isl_extent3d image_alignment_el;
1246
1247 /**
1248 * Logical extent of the surface's base level, in units of pixels. This is
1249 * identical to the extent defined in isl_surf_init_info.
1250 */
1251 struct isl_extent4d logical_level0_px;
1252
1253 /**
1254 * Physical extent of the surface's base level, in units of physical
1255 * surface samples.
1256 *
1257 * Consider isl_dim_layout as an operator that transforms a logical surface
1258 * layout to a physical surface layout. Then
1259 *
1260 * logical_layout := (isl_surf::dim, isl_surf::logical_level0_px)
1261 * isl_surf::phys_level0_sa := isl_surf::dim_layout * logical_layout
1262 */
1263 struct isl_extent4d phys_level0_sa;
1264
1265 uint32_t levels;
1266 uint32_t samples;
1267
1268 /** Total size of the surface, in bytes. */
1269 uint64_t size_B;
1270
1271 /** Required alignment for the surface's base address. */
1272 uint32_t alignment_B;
1273
1274 /**
1275 * The interpretation of this field depends on the value of
1276 * isl_tile_info::physical_extent_B. In particular, the width of the
1277 * surface in tiles is row_pitch_B / isl_tile_info::physical_extent_B.width
1278 * and the distance in bytes between vertically adjacent tiles in the image
1279 * is given by row_pitch_B * isl_tile_info::physical_extent_B.height.
1280 *
1281 * For linear images where isl_tile_info::physical_extent_B.height == 1,
1282 * this cleanly reduces to being the distance, in bytes, between vertically
1283 * adjacent surface elements.
1284 *
1285 * @see isl_tile_info::phys_extent_B;
1286 */
1287 uint32_t row_pitch_B;
1288
1289 /**
1290 * Pitch between physical array slices, in rows of surface elements.
1291 */
1292 uint32_t array_pitch_el_rows;
1293
1294 enum isl_array_pitch_span array_pitch_span;
1295
1296 /** Copy of isl_surf_init_info::usage. */
1297 isl_surf_usage_flags_t usage;
1298 };
1299
1300 struct isl_swizzle {
1301 enum isl_channel_select r:4;
1302 enum isl_channel_select g:4;
1303 enum isl_channel_select b:4;
1304 enum isl_channel_select a:4;
1305 };
1306
1307 #define ISL_SWIZZLE(R, G, B, A) ((struct isl_swizzle) { \
1308 .r = ISL_CHANNEL_SELECT_##R, \
1309 .g = ISL_CHANNEL_SELECT_##G, \
1310 .b = ISL_CHANNEL_SELECT_##B, \
1311 .a = ISL_CHANNEL_SELECT_##A, \
1312 })
1313
1314 #define ISL_SWIZZLE_IDENTITY ISL_SWIZZLE(RED, GREEN, BLUE, ALPHA)
1315
1316 struct isl_view {
1317 /**
1318 * Indicates the usage of the particular view
1319 *
1320 * Normally, this is one bit. However, for a cube map texture, it
1321 * should be ISL_SURF_USAGE_TEXTURE_BIT | ISL_SURF_USAGE_CUBE_BIT.
1322 */
1323 isl_surf_usage_flags_t usage;
1324
1325 /**
1326 * The format to use in the view
1327 *
1328 * This may differ from the format of the actual isl_surf but must have
1329 * the same block size.
1330 */
1331 enum isl_format format;
1332
1333 uint32_t base_level;
1334 uint32_t levels;
1335
1336 /**
1337 * Base array layer
1338 *
1339 * For cube maps, both base_array_layer and array_len should be
1340 * specified in terms of 2-D layers and must be a multiple of 6.
1341 *
1342 * 3-D textures are effectively treated as 2-D arrays when used as a
1343 * storage image or render target. If `usage` contains
1344 * ISL_SURF_USAGE_RENDER_TARGET_BIT or ISL_SURF_USAGE_STORAGE_BIT then
1345 * base_array_layer and array_len are applied. If the surface is only used
1346 * for texturing, they are ignored.
1347 */
1348 uint32_t base_array_layer;
1349
1350 /**
1351 * Array Length
1352 *
1353 * Indicates the number of array elements starting at Base Array Layer.
1354 */
1355 uint32_t array_len;
1356
1357 struct isl_swizzle swizzle;
1358 };
1359
1360 union isl_color_value {
1361 float f32[4];
1362 uint32_t u32[4];
1363 int32_t i32[4];
1364 };
1365
1366 struct isl_surf_fill_state_info {
1367 const struct isl_surf *surf;
1368 const struct isl_view *view;
1369
1370 /**
1371 * The address of the surface in GPU memory.
1372 */
1373 uint64_t address;
1374
1375 /**
1376 * The Memory Object Control state for the filled surface state.
1377 *
1378 * The exact format of this value depends on hardware generation.
1379 */
1380 uint32_t mocs;
1381
1382 /**
1383 * The auxilary surface or NULL if no auxilary surface is to be used.
1384 */
1385 const struct isl_surf *aux_surf;
1386 enum isl_aux_usage aux_usage;
1387 uint64_t aux_address;
1388
1389 /**
1390 * The clear color for this surface
1391 *
1392 * Valid values depend on hardware generation.
1393 */
1394 union isl_color_value clear_color;
1395
1396 /**
1397 * Send only the clear value address
1398 *
1399 * If set, we only pass the clear address to the GPU and it will fetch it
1400 * from wherever it is.
1401 */
1402 bool use_clear_address;
1403 uint64_t clear_address;
1404
1405 /**
1406 * Surface write disables for gen4-5
1407 */
1408 isl_channel_mask_t write_disables;
1409
1410 /* Intra-tile offset */
1411 uint16_t x_offset_sa, y_offset_sa;
1412 };
1413
1414 struct isl_buffer_fill_state_info {
1415 /**
1416 * The address of the surface in GPU memory.
1417 */
1418 uint64_t address;
1419
1420 /**
1421 * The size of the buffer
1422 */
1423 uint64_t size_B;
1424
1425 /**
1426 * The Memory Object Control state for the filled surface state.
1427 *
1428 * The exact format of this value depends on hardware generation.
1429 */
1430 uint32_t mocs;
1431
1432 /**
1433 * The format to use in the surface state
1434 *
1435 * This may differ from the format of the actual isl_surf but have the
1436 * same block size.
1437 */
1438 enum isl_format format;
1439
1440 /**
1441 * The swizzle to use in the surface state
1442 */
1443 struct isl_swizzle swizzle;
1444
1445 uint32_t stride_B;
1446 };
1447
1448 struct isl_depth_stencil_hiz_emit_info {
1449 /**
1450 * The depth surface
1451 */
1452 const struct isl_surf *depth_surf;
1453
1454 /**
1455 * The stencil surface
1456 *
1457 * If separate stencil is not available, this must point to the same
1458 * isl_surf as depth_surf.
1459 */
1460 const struct isl_surf *stencil_surf;
1461
1462 /**
1463 * The view into the depth and stencil surfaces.
1464 *
1465 * This view applies to both surfaces simultaneously.
1466 */
1467 const struct isl_view *view;
1468
1469 /**
1470 * The address of the depth surface in GPU memory
1471 */
1472 uint64_t depth_address;
1473
1474 /**
1475 * The address of the stencil surface in GPU memory
1476 *
1477 * If separate stencil is not available, this must have the same value as
1478 * depth_address.
1479 */
1480 uint64_t stencil_address;
1481
1482 /**
1483 * The Memory Object Control state for depth and stencil buffers
1484 *
1485 * Both depth and stencil will get the same MOCS value. The exact format
1486 * of this value depends on hardware generation.
1487 */
1488 uint32_t mocs;
1489
1490 /**
1491 * The HiZ surface or NULL if HiZ is disabled.
1492 */
1493 const struct isl_surf *hiz_surf;
1494 enum isl_aux_usage hiz_usage;
1495 uint64_t hiz_address;
1496
1497 /**
1498 * The depth clear value
1499 */
1500 float depth_clear_value;
1501
1502 /**
1503 * Track stencil aux usage for Gen >= 12
1504 */
1505 enum isl_aux_usage stencil_aux_usage;
1506 };
1507
1508 extern const struct isl_format_layout isl_format_layouts[];
1509
1510 void
1511 isl_device_init(struct isl_device *dev,
1512 const struct gen_device_info *info,
1513 bool has_bit6_swizzling);
1514
1515 isl_sample_count_mask_t ATTRIBUTE_CONST
1516 isl_device_get_sample_counts(struct isl_device *dev);
1517
1518 static inline const struct isl_format_layout * ATTRIBUTE_CONST
1519 isl_format_get_layout(enum isl_format fmt)
1520 {
1521 assert(fmt != ISL_FORMAT_UNSUPPORTED);
1522 assert(fmt < ISL_NUM_FORMATS);
1523 return &isl_format_layouts[fmt];
1524 }
1525
1526 bool isl_format_is_valid(enum isl_format);
1527
1528 static inline const char * ATTRIBUTE_CONST
1529 isl_format_get_name(enum isl_format fmt)
1530 {
1531 return isl_format_get_layout(fmt)->name;
1532 }
1533
1534 enum isl_format isl_format_for_pipe_format(enum pipe_format pf);
1535
1536 bool isl_format_supports_rendering(const struct gen_device_info *devinfo,
1537 enum isl_format format);
1538 bool isl_format_supports_alpha_blending(const struct gen_device_info *devinfo,
1539 enum isl_format format);
1540 bool isl_format_supports_sampling(const struct gen_device_info *devinfo,
1541 enum isl_format format);
1542 bool isl_format_supports_filtering(const struct gen_device_info *devinfo,
1543 enum isl_format format);
1544 bool isl_format_supports_vertex_fetch(const struct gen_device_info *devinfo,
1545 enum isl_format format);
1546 bool isl_format_supports_typed_writes(const struct gen_device_info *devinfo,
1547 enum isl_format format);
1548 bool isl_format_supports_typed_reads(const struct gen_device_info *devinfo,
1549 enum isl_format format);
1550 bool isl_format_supports_ccs_d(const struct gen_device_info *devinfo,
1551 enum isl_format format);
1552 bool isl_format_supports_ccs_e(const struct gen_device_info *devinfo,
1553 enum isl_format format);
1554 bool isl_format_supports_multisampling(const struct gen_device_info *devinfo,
1555 enum isl_format format);
1556
1557 bool isl_formats_are_ccs_e_compatible(const struct gen_device_info *devinfo,
1558 enum isl_format format1,
1559 enum isl_format format2);
1560 uint8_t isl_format_get_aux_map_encoding(enum isl_format format);
1561
1562 bool isl_format_has_unorm_channel(enum isl_format fmt) ATTRIBUTE_CONST;
1563 bool isl_format_has_snorm_channel(enum isl_format fmt) ATTRIBUTE_CONST;
1564 bool isl_format_has_ufloat_channel(enum isl_format fmt) ATTRIBUTE_CONST;
1565 bool isl_format_has_sfloat_channel(enum isl_format fmt) ATTRIBUTE_CONST;
1566 bool isl_format_has_uint_channel(enum isl_format fmt) ATTRIBUTE_CONST;
1567 bool isl_format_has_sint_channel(enum isl_format fmt) ATTRIBUTE_CONST;
1568
1569 static inline bool
1570 isl_format_has_normalized_channel(enum isl_format fmt)
1571 {
1572 return isl_format_has_unorm_channel(fmt) ||
1573 isl_format_has_snorm_channel(fmt);
1574 }
1575
1576 static inline bool
1577 isl_format_has_float_channel(enum isl_format fmt)
1578 {
1579 return isl_format_has_ufloat_channel(fmt) ||
1580 isl_format_has_sfloat_channel(fmt);
1581 }
1582
1583 static inline bool
1584 isl_format_has_int_channel(enum isl_format fmt)
1585 {
1586 return isl_format_has_uint_channel(fmt) ||
1587 isl_format_has_sint_channel(fmt);
1588 }
1589
1590 bool isl_format_has_color_component(enum isl_format fmt,
1591 int component) ATTRIBUTE_CONST;
1592
1593 unsigned isl_format_get_num_channels(enum isl_format fmt);
1594
1595 uint32_t isl_format_get_depth_format(enum isl_format fmt, bool has_stencil);
1596
1597 static inline bool
1598 isl_format_is_compressed(enum isl_format fmt)
1599 {
1600 const struct isl_format_layout *fmtl = isl_format_get_layout(fmt);
1601
1602 return fmtl->txc != ISL_TXC_NONE;
1603 }
1604
1605 static inline bool
1606 isl_format_has_bc_compression(enum isl_format fmt)
1607 {
1608 switch (isl_format_get_layout(fmt)->txc) {
1609 case ISL_TXC_DXT1:
1610 case ISL_TXC_DXT3:
1611 case ISL_TXC_DXT5:
1612 return true;
1613 case ISL_TXC_NONE:
1614 case ISL_TXC_FXT1:
1615 case ISL_TXC_RGTC1:
1616 case ISL_TXC_RGTC2:
1617 case ISL_TXC_BPTC:
1618 case ISL_TXC_ETC1:
1619 case ISL_TXC_ETC2:
1620 case ISL_TXC_ASTC:
1621 return false;
1622
1623 case ISL_TXC_HIZ:
1624 case ISL_TXC_MCS:
1625 case ISL_TXC_CCS:
1626 unreachable("Should not be called on an aux surface");
1627 }
1628
1629 unreachable("bad texture compression mode");
1630 return false;
1631 }
1632
1633 static inline bool
1634 isl_format_is_planar(enum isl_format fmt)
1635 {
1636 return fmt == ISL_FORMAT_PLANAR_420_8;
1637 }
1638
1639 static inline bool
1640 isl_format_is_yuv(enum isl_format fmt)
1641 {
1642 const struct isl_format_layout *fmtl = isl_format_get_layout(fmt);
1643
1644 return fmtl->colorspace == ISL_COLORSPACE_YUV;
1645 }
1646
1647 static inline bool
1648 isl_format_block_is_1x1x1(enum isl_format fmt)
1649 {
1650 const struct isl_format_layout *fmtl = isl_format_get_layout(fmt);
1651
1652 return fmtl->bw == 1 && fmtl->bh == 1 && fmtl->bd == 1;
1653 }
1654
1655 static inline bool
1656 isl_format_is_srgb(enum isl_format fmt)
1657 {
1658 return isl_format_get_layout(fmt)->colorspace == ISL_COLORSPACE_SRGB;
1659 }
1660
1661 enum isl_format isl_format_srgb_to_linear(enum isl_format fmt);
1662
1663 static inline bool
1664 isl_format_is_rgb(enum isl_format fmt)
1665 {
1666 if (isl_format_is_yuv(fmt))
1667 return false;
1668
1669 const struct isl_format_layout *fmtl = isl_format_get_layout(fmt);
1670
1671 return fmtl->channels.r.bits > 0 &&
1672 fmtl->channels.g.bits > 0 &&
1673 fmtl->channels.b.bits > 0 &&
1674 fmtl->channels.a.bits == 0;
1675 }
1676
1677 static inline bool
1678 isl_format_is_rgbx(enum isl_format fmt)
1679 {
1680 const struct isl_format_layout *fmtl = isl_format_get_layout(fmt);
1681
1682 return fmtl->channels.r.bits > 0 &&
1683 fmtl->channels.g.bits > 0 &&
1684 fmtl->channels.b.bits > 0 &&
1685 fmtl->channels.a.bits > 0 &&
1686 fmtl->channels.a.type == ISL_VOID;
1687 }
1688
1689 enum isl_format isl_format_rgb_to_rgba(enum isl_format rgb) ATTRIBUTE_CONST;
1690 enum isl_format isl_format_rgb_to_rgbx(enum isl_format rgb) ATTRIBUTE_CONST;
1691 enum isl_format isl_format_rgbx_to_rgba(enum isl_format rgb) ATTRIBUTE_CONST;
1692
1693 union isl_color_value
1694 isl_color_value_swizzle_inv(union isl_color_value src,
1695 struct isl_swizzle swizzle);
1696
1697 void isl_color_value_pack(const union isl_color_value *value,
1698 enum isl_format format,
1699 uint32_t *data_out);
1700 void isl_color_value_unpack(union isl_color_value *value,
1701 enum isl_format format,
1702 const uint32_t *data_in);
1703
1704 bool isl_is_storage_image_format(enum isl_format fmt);
1705
1706 enum isl_format
1707 isl_lower_storage_image_format(const struct gen_device_info *devinfo,
1708 enum isl_format fmt);
1709
1710 /* Returns true if this hardware supports typed load/store on a format with
1711 * the same size as the given format.
1712 */
1713 bool
1714 isl_has_matching_typed_storage_image_format(const struct gen_device_info *devinfo,
1715 enum isl_format fmt);
1716
1717 static inline enum isl_tiling
1718 isl_tiling_flag_to_enum(isl_tiling_flags_t flag)
1719 {
1720 assert(__builtin_popcount(flag) == 1);
1721 return (enum isl_tiling) (__builtin_ffs(flag) - 1);
1722 }
1723
1724 static inline bool
1725 isl_tiling_is_any_y(enum isl_tiling tiling)
1726 {
1727 return (1u << tiling) & ISL_TILING_ANY_Y_MASK;
1728 }
1729
1730 static inline bool
1731 isl_tiling_is_std_y(enum isl_tiling tiling)
1732 {
1733 return (1u << tiling) & ISL_TILING_STD_Y_MASK;
1734 }
1735
1736 uint32_t
1737 isl_tiling_to_i915_tiling(enum isl_tiling tiling);
1738
1739 enum isl_tiling
1740 isl_tiling_from_i915_tiling(uint32_t tiling);
1741
1742 /**
1743 * Return an isl_aux_op needed to enable an access to occur in an
1744 * isl_aux_state suitable for the isl_aux_usage.
1745 *
1746 * NOTE: If the access will invalidate the main surface, this function should
1747 * not be called and the isl_aux_op of NONE should be used instead.
1748 * Otherwise, an extra (but still lossless) ambiguate may occur.
1749 *
1750 * @invariant initial_state is possible with an isl_aux_usage compatible with
1751 * the given usage. Two usages are compatible if it's possible to
1752 * switch between them (e.g. CCS_E <-> CCS_D).
1753 * @invariant fast_clear is false if the aux doesn't support fast clears.
1754 */
1755 enum isl_aux_op
1756 isl_aux_prepare_access(enum isl_aux_state initial_state,
1757 enum isl_aux_usage usage,
1758 bool fast_clear_supported);
1759
1760 /**
1761 * Return the isl_aux_state entered after performing an isl_aux_op.
1762 *
1763 * @invariant initial_state is possible with the given usage.
1764 * @invariant op is possible with the given usage.
1765 * @invariant op must not cause HW to read from an invalid aux.
1766 */
1767 enum isl_aux_state
1768 isl_aux_state_transition_aux_op(enum isl_aux_state initial_state,
1769 enum isl_aux_usage usage,
1770 enum isl_aux_op op);
1771
1772 /**
1773 * Return the isl_aux_state entered after performing a write.
1774 *
1775 * NOTE: full_surface should be true if the write covers the entire
1776 * slice. Setting it to false in this case will still result in a
1777 * correct (but imprecise) aux state.
1778 *
1779 * @invariant if usage is not ISL_AUX_USAGE_NONE, then initial_state is
1780 * possible with the given usage.
1781 * @invariant usage can be ISL_AUX_USAGE_NONE iff:
1782 * * the main surface is valid, or
1783 * * the main surface is being invalidated/replaced.
1784 */
1785 enum isl_aux_state
1786 isl_aux_state_transition_write(enum isl_aux_state initial_state,
1787 enum isl_aux_usage usage,
1788 bool full_surface);
1789
1790 bool
1791 isl_aux_usage_has_fast_clears(enum isl_aux_usage usage);
1792
1793 static inline bool
1794 isl_aux_usage_has_hiz(enum isl_aux_usage usage)
1795 {
1796 return usage == ISL_AUX_USAGE_HIZ ||
1797 usage == ISL_AUX_USAGE_HIZ_CCS_WT ||
1798 usage == ISL_AUX_USAGE_HIZ_CCS;
1799 }
1800
1801 static inline bool
1802 isl_aux_usage_has_mcs(enum isl_aux_usage usage)
1803 {
1804 return usage == ISL_AUX_USAGE_MCS ||
1805 usage == ISL_AUX_USAGE_MCS_CCS;
1806 }
1807
1808 static inline bool
1809 isl_aux_usage_has_ccs(enum isl_aux_usage usage)
1810 {
1811 return usage == ISL_AUX_USAGE_CCS_D ||
1812 usage == ISL_AUX_USAGE_CCS_E ||
1813 usage == ISL_AUX_USAGE_GEN12_CCS_E ||
1814 usage == ISL_AUX_USAGE_MC ||
1815 usage == ISL_AUX_USAGE_HIZ_CCS_WT ||
1816 usage == ISL_AUX_USAGE_HIZ_CCS ||
1817 usage == ISL_AUX_USAGE_MCS_CCS ||
1818 usage == ISL_AUX_USAGE_STC_CCS;
1819 }
1820
1821 static inline bool
1822 isl_aux_state_has_valid_primary(enum isl_aux_state state)
1823 {
1824 return state == ISL_AUX_STATE_RESOLVED ||
1825 state == ISL_AUX_STATE_PASS_THROUGH ||
1826 state == ISL_AUX_STATE_AUX_INVALID;
1827 }
1828
1829 static inline bool
1830 isl_aux_state_has_valid_aux(enum isl_aux_state state)
1831 {
1832 return state != ISL_AUX_STATE_AUX_INVALID;
1833 }
1834
1835 const struct isl_drm_modifier_info * ATTRIBUTE_CONST
1836 isl_drm_modifier_get_info(uint64_t modifier);
1837
1838 static inline bool
1839 isl_drm_modifier_has_aux(uint64_t modifier)
1840 {
1841 return isl_drm_modifier_get_info(modifier)->aux_usage != ISL_AUX_USAGE_NONE;
1842 }
1843
1844 /** Returns the default isl_aux_state for the given modifier.
1845 *
1846 * If we have a modifier which supports compression, then the auxiliary data
1847 * could be in state other than ISL_AUX_STATE_AUX_INVALID. In particular, it
1848 * can be in any of the following:
1849 *
1850 * - ISL_AUX_STATE_CLEAR
1851 * - ISL_AUX_STATE_PARTIAL_CLEAR
1852 * - ISL_AUX_STATE_COMPRESSED_CLEAR
1853 * - ISL_AUX_STATE_COMPRESSED_NO_CLEAR
1854 * - ISL_AUX_STATE_RESOLVED
1855 * - ISL_AUX_STATE_PASS_THROUGH
1856 *
1857 * If the modifier does not support fast-clears, then we are guaranteed
1858 * that the surface is at least partially resolved and the first three not
1859 * possible. We return ISL_AUX_STATE_COMPRESSED_CLEAR if the modifier
1860 * supports fast clears and ISL_AUX_STATE_COMPRESSED_NO_CLEAR if it does not
1861 * because they are the least common denominator of the set of possible aux
1862 * states and will yield a valid interpretation of the aux data.
1863 *
1864 * For modifiers with no aux support, ISL_AUX_STATE_AUX_INVALID is returned.
1865 */
1866 static inline enum isl_aux_state
1867 isl_drm_modifier_get_default_aux_state(uint64_t modifier)
1868 {
1869 const struct isl_drm_modifier_info *mod_info =
1870 isl_drm_modifier_get_info(modifier);
1871
1872 if (!mod_info || mod_info->aux_usage == ISL_AUX_USAGE_NONE)
1873 return ISL_AUX_STATE_AUX_INVALID;
1874
1875 assert(mod_info->aux_usage == ISL_AUX_USAGE_CCS_E ||
1876 mod_info->aux_usage == ISL_AUX_USAGE_GEN12_CCS_E);
1877 return mod_info->supports_clear_color ? ISL_AUX_STATE_COMPRESSED_CLEAR :
1878 ISL_AUX_STATE_COMPRESSED_NO_CLEAR;
1879 }
1880
1881 struct isl_extent2d ATTRIBUTE_CONST
1882 isl_get_interleaved_msaa_px_size_sa(uint32_t samples);
1883
1884 static inline bool
1885 isl_surf_usage_is_display(isl_surf_usage_flags_t usage)
1886 {
1887 return usage & ISL_SURF_USAGE_DISPLAY_BIT;
1888 }
1889
1890 static inline bool
1891 isl_surf_usage_is_depth(isl_surf_usage_flags_t usage)
1892 {
1893 return usage & ISL_SURF_USAGE_DEPTH_BIT;
1894 }
1895
1896 static inline bool
1897 isl_surf_usage_is_stencil(isl_surf_usage_flags_t usage)
1898 {
1899 return usage & ISL_SURF_USAGE_STENCIL_BIT;
1900 }
1901
1902 static inline bool
1903 isl_surf_usage_is_depth_and_stencil(isl_surf_usage_flags_t usage)
1904 {
1905 return (usage & ISL_SURF_USAGE_DEPTH_BIT) &&
1906 (usage & ISL_SURF_USAGE_STENCIL_BIT);
1907 }
1908
1909 static inline bool
1910 isl_surf_usage_is_depth_or_stencil(isl_surf_usage_flags_t usage)
1911 {
1912 return usage & (ISL_SURF_USAGE_DEPTH_BIT | ISL_SURF_USAGE_STENCIL_BIT);
1913 }
1914
1915 static inline bool
1916 isl_surf_info_is_z16(const struct isl_surf_init_info *info)
1917 {
1918 return (info->usage & ISL_SURF_USAGE_DEPTH_BIT) &&
1919 (info->format == ISL_FORMAT_R16_UNORM);
1920 }
1921
1922 static inline bool
1923 isl_surf_info_is_z32_float(const struct isl_surf_init_info *info)
1924 {
1925 return (info->usage & ISL_SURF_USAGE_DEPTH_BIT) &&
1926 (info->format == ISL_FORMAT_R32_FLOAT);
1927 }
1928
1929 static inline struct isl_extent2d
1930 isl_extent2d(uint32_t width, uint32_t height)
1931 {
1932 struct isl_extent2d e = { { 0 } };
1933
1934 e.width = width;
1935 e.height = height;
1936
1937 return e;
1938 }
1939
1940 static inline struct isl_extent3d
1941 isl_extent3d(uint32_t width, uint32_t height, uint32_t depth)
1942 {
1943 struct isl_extent3d e = { { 0 } };
1944
1945 e.width = width;
1946 e.height = height;
1947 e.depth = depth;
1948
1949 return e;
1950 }
1951
1952 static inline struct isl_extent4d
1953 isl_extent4d(uint32_t width, uint32_t height, uint32_t depth,
1954 uint32_t array_len)
1955 {
1956 struct isl_extent4d e = { { 0 } };
1957
1958 e.width = width;
1959 e.height = height;
1960 e.depth = depth;
1961 e.array_len = array_len;
1962
1963 return e;
1964 }
1965
1966 bool isl_color_value_is_zero(union isl_color_value value,
1967 enum isl_format format);
1968
1969 bool isl_color_value_is_zero_one(union isl_color_value value,
1970 enum isl_format format);
1971
1972 static inline bool
1973 isl_swizzle_is_identity(struct isl_swizzle swizzle)
1974 {
1975 return swizzle.r == ISL_CHANNEL_SELECT_RED &&
1976 swizzle.g == ISL_CHANNEL_SELECT_GREEN &&
1977 swizzle.b == ISL_CHANNEL_SELECT_BLUE &&
1978 swizzle.a == ISL_CHANNEL_SELECT_ALPHA;
1979 }
1980
1981 bool
1982 isl_swizzle_supports_rendering(const struct gen_device_info *devinfo,
1983 struct isl_swizzle swizzle);
1984
1985 struct isl_swizzle
1986 isl_swizzle_compose(struct isl_swizzle first, struct isl_swizzle second);
1987 struct isl_swizzle
1988 isl_swizzle_invert(struct isl_swizzle swizzle);
1989
1990 #define isl_surf_init(dev, surf, ...) \
1991 isl_surf_init_s((dev), (surf), \
1992 &(struct isl_surf_init_info) { __VA_ARGS__ });
1993
1994 bool
1995 isl_surf_init_s(const struct isl_device *dev,
1996 struct isl_surf *surf,
1997 const struct isl_surf_init_info *restrict info);
1998
1999 void
2000 isl_surf_get_tile_info(const struct isl_surf *surf,
2001 struct isl_tile_info *tile_info);
2002
2003 bool
2004 isl_surf_supports_ccs(const struct isl_device *dev,
2005 const struct isl_surf *surf);
2006
2007 bool
2008 isl_surf_get_hiz_surf(const struct isl_device *dev,
2009 const struct isl_surf *surf,
2010 struct isl_surf *hiz_surf);
2011
2012 bool
2013 isl_surf_get_mcs_surf(const struct isl_device *dev,
2014 const struct isl_surf *surf,
2015 struct isl_surf *mcs_surf);
2016
2017 bool
2018 isl_surf_get_ccs_surf(const struct isl_device *dev,
2019 const struct isl_surf *surf,
2020 struct isl_surf *aux_surf,
2021 struct isl_surf *extra_aux_surf,
2022 uint32_t row_pitch_B /**< Ignored if 0 */);
2023
2024 #define isl_surf_fill_state(dev, state, ...) \
2025 isl_surf_fill_state_s((dev), (state), \
2026 &(struct isl_surf_fill_state_info) { __VA_ARGS__ });
2027
2028 void
2029 isl_surf_fill_state_s(const struct isl_device *dev, void *state,
2030 const struct isl_surf_fill_state_info *restrict info);
2031
2032 #define isl_buffer_fill_state(dev, state, ...) \
2033 isl_buffer_fill_state_s((dev), (state), \
2034 &(struct isl_buffer_fill_state_info) { __VA_ARGS__ });
2035
2036 void
2037 isl_buffer_fill_state_s(const struct isl_device *dev, void *state,
2038 const struct isl_buffer_fill_state_info *restrict info);
2039
2040 void
2041 isl_null_fill_state(const struct isl_device *dev, void *state,
2042 struct isl_extent3d size);
2043
2044 #define isl_emit_depth_stencil_hiz(dev, batch, ...) \
2045 isl_emit_depth_stencil_hiz_s((dev), (batch), \
2046 &(struct isl_depth_stencil_hiz_emit_info) { __VA_ARGS__ })
2047
2048 void
2049 isl_emit_depth_stencil_hiz_s(const struct isl_device *dev, void *batch,
2050 const struct isl_depth_stencil_hiz_emit_info *restrict info);
2051
2052 void
2053 isl_surf_fill_image_param(const struct isl_device *dev,
2054 struct brw_image_param *param,
2055 const struct isl_surf *surf,
2056 const struct isl_view *view);
2057
2058 void
2059 isl_buffer_fill_image_param(const struct isl_device *dev,
2060 struct brw_image_param *param,
2061 enum isl_format format,
2062 uint64_t size);
2063
2064 /**
2065 * Alignment of the upper-left sample of each subimage, in units of surface
2066 * elements.
2067 */
2068 static inline struct isl_extent3d
2069 isl_surf_get_image_alignment_el(const struct isl_surf *surf)
2070 {
2071 return surf->image_alignment_el;
2072 }
2073
2074 /**
2075 * Alignment of the upper-left sample of each subimage, in units of surface
2076 * samples.
2077 */
2078 static inline struct isl_extent3d
2079 isl_surf_get_image_alignment_sa(const struct isl_surf *surf)
2080 {
2081 const struct isl_format_layout *fmtl = isl_format_get_layout(surf->format);
2082
2083 return isl_extent3d(fmtl->bw * surf->image_alignment_el.w,
2084 fmtl->bh * surf->image_alignment_el.h,
2085 fmtl->bd * surf->image_alignment_el.d);
2086 }
2087
2088 /**
2089 * Logical extent of level 0 in units of surface elements.
2090 */
2091 static inline struct isl_extent4d
2092 isl_surf_get_logical_level0_el(const struct isl_surf *surf)
2093 {
2094 const struct isl_format_layout *fmtl = isl_format_get_layout(surf->format);
2095
2096 return isl_extent4d(DIV_ROUND_UP(surf->logical_level0_px.w, fmtl->bw),
2097 DIV_ROUND_UP(surf->logical_level0_px.h, fmtl->bh),
2098 DIV_ROUND_UP(surf->logical_level0_px.d, fmtl->bd),
2099 surf->logical_level0_px.a);
2100 }
2101
2102 /**
2103 * Physical extent of level 0 in units of surface elements.
2104 */
2105 static inline struct isl_extent4d
2106 isl_surf_get_phys_level0_el(const struct isl_surf *surf)
2107 {
2108 const struct isl_format_layout *fmtl = isl_format_get_layout(surf->format);
2109
2110 return isl_extent4d(DIV_ROUND_UP(surf->phys_level0_sa.w, fmtl->bw),
2111 DIV_ROUND_UP(surf->phys_level0_sa.h, fmtl->bh),
2112 DIV_ROUND_UP(surf->phys_level0_sa.d, fmtl->bd),
2113 surf->phys_level0_sa.a);
2114 }
2115
2116 /**
2117 * Pitch between vertically adjacent surface elements, in bytes.
2118 */
2119 static inline uint32_t
2120 isl_surf_get_row_pitch_B(const struct isl_surf *surf)
2121 {
2122 return surf->row_pitch_B;
2123 }
2124
2125 /**
2126 * Pitch between vertically adjacent surface elements, in units of surface elements.
2127 */
2128 static inline uint32_t
2129 isl_surf_get_row_pitch_el(const struct isl_surf *surf)
2130 {
2131 const struct isl_format_layout *fmtl = isl_format_get_layout(surf->format);
2132
2133 assert(surf->row_pitch_B % (fmtl->bpb / 8) == 0);
2134 return surf->row_pitch_B / (fmtl->bpb / 8);
2135 }
2136
2137 /**
2138 * Pitch between physical array slices, in rows of surface elements.
2139 */
2140 static inline uint32_t
2141 isl_surf_get_array_pitch_el_rows(const struct isl_surf *surf)
2142 {
2143 return surf->array_pitch_el_rows;
2144 }
2145
2146 /**
2147 * Pitch between physical array slices, in units of surface elements.
2148 */
2149 static inline uint32_t
2150 isl_surf_get_array_pitch_el(const struct isl_surf *surf)
2151 {
2152 return isl_surf_get_array_pitch_el_rows(surf) *
2153 isl_surf_get_row_pitch_el(surf);
2154 }
2155
2156 /**
2157 * Pitch between physical array slices, in rows of surface samples.
2158 */
2159 static inline uint32_t
2160 isl_surf_get_array_pitch_sa_rows(const struct isl_surf *surf)
2161 {
2162 const struct isl_format_layout *fmtl = isl_format_get_layout(surf->format);
2163 return fmtl->bh * isl_surf_get_array_pitch_el_rows(surf);
2164 }
2165
2166 /**
2167 * Pitch between physical array slices, in bytes.
2168 */
2169 static inline uint32_t
2170 isl_surf_get_array_pitch(const struct isl_surf *surf)
2171 {
2172 return isl_surf_get_array_pitch_sa_rows(surf) * surf->row_pitch_B;
2173 }
2174
2175 /**
2176 * Calculate the offset, in units of surface samples, to a subimage in the
2177 * surface.
2178 *
2179 * @invariant level < surface levels
2180 * @invariant logical_array_layer < logical array length of surface
2181 * @invariant logical_z_offset_px < logical depth of surface at level
2182 */
2183 void
2184 isl_surf_get_image_offset_sa(const struct isl_surf *surf,
2185 uint32_t level,
2186 uint32_t logical_array_layer,
2187 uint32_t logical_z_offset_px,
2188 uint32_t *x_offset_sa,
2189 uint32_t *y_offset_sa);
2190
2191 /**
2192 * Calculate the offset, in units of surface elements, to a subimage in the
2193 * surface.
2194 *
2195 * @invariant level < surface levels
2196 * @invariant logical_array_layer < logical array length of surface
2197 * @invariant logical_z_offset_px < logical depth of surface at level
2198 */
2199 void
2200 isl_surf_get_image_offset_el(const struct isl_surf *surf,
2201 uint32_t level,
2202 uint32_t logical_array_layer,
2203 uint32_t logical_z_offset_px,
2204 uint32_t *x_offset_el,
2205 uint32_t *y_offset_el);
2206
2207 /**
2208 * Calculate the offset, in bytes and intratile surface samples, to a
2209 * subimage in the surface.
2210 *
2211 * This is equivalent to calling isl_surf_get_image_offset_el, passing the
2212 * result to isl_tiling_get_intratile_offset_el, and converting the tile
2213 * offsets to samples.
2214 *
2215 * @invariant level < surface levels
2216 * @invariant logical_array_layer < logical array length of surface
2217 * @invariant logical_z_offset_px < logical depth of surface at level
2218 */
2219 void
2220 isl_surf_get_image_offset_B_tile_sa(const struct isl_surf *surf,
2221 uint32_t level,
2222 uint32_t logical_array_layer,
2223 uint32_t logical_z_offset_px,
2224 uint32_t *offset_B,
2225 uint32_t *x_offset_sa,
2226 uint32_t *y_offset_sa);
2227
2228 /**
2229 * Calculate the range in bytes occupied by a subimage, to the nearest tile.
2230 *
2231 * The range returned will be the smallest memory range in which the give
2232 * subimage fits, rounded to even tiles. Intel images do not usually have a
2233 * direct subimage -> range mapping so the range returned may contain data
2234 * from other sub-images. The returned range is a half-open interval where
2235 * all of the addresses within the subimage are < end_tile_B.
2236 *
2237 * @invariant level < surface levels
2238 * @invariant logical_array_layer < logical array length of surface
2239 * @invariant logical_z_offset_px < logical depth of surface at level
2240 */
2241 void
2242 isl_surf_get_image_range_B_tile(const struct isl_surf *surf,
2243 uint32_t level,
2244 uint32_t logical_array_layer,
2245 uint32_t logical_z_offset_px,
2246 uint32_t *start_tile_B,
2247 uint32_t *end_tile_B);
2248
2249 /**
2250 * Create an isl_surf that represents a particular subimage in the surface.
2251 *
2252 * The newly created surface will have a single miplevel and array slice. The
2253 * surface lives at the returned byte and intratile offsets, in samples.
2254 *
2255 * It is safe to call this function with surf == image_surf.
2256 *
2257 * @invariant level < surface levels
2258 * @invariant logical_array_layer < logical array length of surface
2259 * @invariant logical_z_offset_px < logical depth of surface at level
2260 */
2261 void
2262 isl_surf_get_image_surf(const struct isl_device *dev,
2263 const struct isl_surf *surf,
2264 uint32_t level,
2265 uint32_t logical_array_layer,
2266 uint32_t logical_z_offset_px,
2267 struct isl_surf *image_surf,
2268 uint32_t *offset_B,
2269 uint32_t *x_offset_sa,
2270 uint32_t *y_offset_sa);
2271
2272 /**
2273 * @brief Calculate the intratile offsets to a surface.
2274 *
2275 * In @a base_address_offset return the offset from the base of the surface to
2276 * the base address of the first tile of the subimage. In @a x_offset_B and
2277 * @a y_offset_rows, return the offset, in units of bytes and rows, from the
2278 * tile's base to the subimage's first surface element. The x and y offsets
2279 * are intratile offsets; that is, they do not exceed the boundary of the
2280 * surface's tiling format.
2281 */
2282 void
2283 isl_tiling_get_intratile_offset_el(enum isl_tiling tiling,
2284 uint32_t bpb,
2285 uint32_t row_pitch_B,
2286 uint32_t total_x_offset_el,
2287 uint32_t total_y_offset_el,
2288 uint32_t *base_address_offset,
2289 uint32_t *x_offset_el,
2290 uint32_t *y_offset_el);
2291
2292 static inline void
2293 isl_tiling_get_intratile_offset_sa(enum isl_tiling tiling,
2294 enum isl_format format,
2295 uint32_t row_pitch_B,
2296 uint32_t total_x_offset_sa,
2297 uint32_t total_y_offset_sa,
2298 uint32_t *base_address_offset,
2299 uint32_t *x_offset_sa,
2300 uint32_t *y_offset_sa)
2301 {
2302 const struct isl_format_layout *fmtl = isl_format_get_layout(format);
2303
2304 /* For computing the intratile offsets, we actually want a strange unit
2305 * which is samples for multisampled surfaces but elements for compressed
2306 * surfaces.
2307 */
2308 assert(total_x_offset_sa % fmtl->bw == 0);
2309 assert(total_y_offset_sa % fmtl->bh == 0);
2310 const uint32_t total_x_offset = total_x_offset_sa / fmtl->bw;
2311 const uint32_t total_y_offset = total_y_offset_sa / fmtl->bh;
2312
2313 isl_tiling_get_intratile_offset_el(tiling, fmtl->bpb, row_pitch_B,
2314 total_x_offset, total_y_offset,
2315 base_address_offset,
2316 x_offset_sa, y_offset_sa);
2317 *x_offset_sa *= fmtl->bw;
2318 *y_offset_sa *= fmtl->bh;
2319 }
2320
2321 /**
2322 * @brief Get value of 3DSTATE_DEPTH_BUFFER.SurfaceFormat
2323 *
2324 * @pre surf->usage has ISL_SURF_USAGE_DEPTH_BIT
2325 * @pre surf->format must be a valid format for depth surfaces
2326 */
2327 uint32_t
2328 isl_surf_get_depth_format(const struct isl_device *dev,
2329 const struct isl_surf *surf);
2330
2331 /**
2332 * @brief performs a copy from linear to tiled surface
2333 *
2334 */
2335 void
2336 isl_memcpy_linear_to_tiled(uint32_t xt1, uint32_t xt2,
2337 uint32_t yt1, uint32_t yt2,
2338 char *dst, const char *src,
2339 uint32_t dst_pitch, int32_t src_pitch,
2340 bool has_swizzling,
2341 enum isl_tiling tiling,
2342 isl_memcpy_type copy_type);
2343
2344 /**
2345 * @brief performs a copy from tiled to linear surface
2346 *
2347 */
2348 void
2349 isl_memcpy_tiled_to_linear(uint32_t xt1, uint32_t xt2,
2350 uint32_t yt1, uint32_t yt2,
2351 char *dst, const char *src,
2352 int32_t dst_pitch, uint32_t src_pitch,
2353 bool has_swizzling,
2354 enum isl_tiling tiling,
2355 isl_memcpy_type copy_type);
2356
2357 #ifdef __cplusplus
2358 }
2359 #endif
2360
2361 #endif /* ISL_H */