2 * Copyright 2015 Intel Corporation
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:
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
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
26 * @brief Intel Surface Layout
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
44 #include "c99_compat.h"
45 #include "util/macros.h"
51 struct brw_device_info
;
52 struct brw_image_param
;
56 * @brief Get the hardware generation of isl_device.
58 * You can define this as a compile-time constant in the CFLAGS. For example,
59 * `gcc -DISL_DEV_GEN(dev)=9 ...`.
61 #define ISL_DEV_GEN(__dev) ((__dev)->info->gen)
64 #ifndef ISL_DEV_IS_HASWELL
66 * @brief Get the hardware generation of isl_device.
68 * You can define this as a compile-time constant in the CFLAGS. For example,
69 * `gcc -DISL_DEV_GEN(dev)=9 ...`.
71 #define ISL_DEV_IS_HASWELL(__dev) ((__dev)->info->is_haswell)
74 #ifndef ISL_DEV_USE_SEPARATE_STENCIL
76 * You can define this as a compile-time constant in the CFLAGS. For example,
77 * `gcc -DISL_DEV_USE_SEPARATE_STENCIL(dev)=1 ...`.
79 #define ISL_DEV_USE_SEPARATE_STENCIL(__dev) ((__dev)->use_separate_stencil)
83 * Hardware enumeration SURFACE_FORMAT.
85 * For the official list, see Broadwell PRM: Volume 2b: Command Reference:
86 * Enumerations: SURFACE_FORMAT.
89 ISL_FORMAT_R32G32B32A32_FLOAT
= 0,
90 ISL_FORMAT_R32G32B32A32_SINT
= 1,
91 ISL_FORMAT_R32G32B32A32_UINT
= 2,
92 ISL_FORMAT_R32G32B32A32_UNORM
= 3,
93 ISL_FORMAT_R32G32B32A32_SNORM
= 4,
94 ISL_FORMAT_R64G64_FLOAT
= 5,
95 ISL_FORMAT_R32G32B32X32_FLOAT
= 6,
96 ISL_FORMAT_R32G32B32A32_SSCALED
= 7,
97 ISL_FORMAT_R32G32B32A32_USCALED
= 8,
98 ISL_FORMAT_R32G32B32A32_SFIXED
= 32,
99 ISL_FORMAT_R64G64_PASSTHRU
= 33,
100 ISL_FORMAT_R32G32B32_FLOAT
= 64,
101 ISL_FORMAT_R32G32B32_SINT
= 65,
102 ISL_FORMAT_R32G32B32_UINT
= 66,
103 ISL_FORMAT_R32G32B32_UNORM
= 67,
104 ISL_FORMAT_R32G32B32_SNORM
= 68,
105 ISL_FORMAT_R32G32B32_SSCALED
= 69,
106 ISL_FORMAT_R32G32B32_USCALED
= 70,
107 ISL_FORMAT_R32G32B32_SFIXED
= 80,
108 ISL_FORMAT_R16G16B16A16_UNORM
= 128,
109 ISL_FORMAT_R16G16B16A16_SNORM
= 129,
110 ISL_FORMAT_R16G16B16A16_SINT
= 130,
111 ISL_FORMAT_R16G16B16A16_UINT
= 131,
112 ISL_FORMAT_R16G16B16A16_FLOAT
= 132,
113 ISL_FORMAT_R32G32_FLOAT
= 133,
114 ISL_FORMAT_R32G32_SINT
= 134,
115 ISL_FORMAT_R32G32_UINT
= 135,
116 ISL_FORMAT_R32_FLOAT_X8X24_TYPELESS
= 136,
117 ISL_FORMAT_X32_TYPELESS_G8X24_UINT
= 137,
118 ISL_FORMAT_L32A32_FLOAT
= 138,
119 ISL_FORMAT_R32G32_UNORM
= 139,
120 ISL_FORMAT_R32G32_SNORM
= 140,
121 ISL_FORMAT_R64_FLOAT
= 141,
122 ISL_FORMAT_R16G16B16X16_UNORM
= 142,
123 ISL_FORMAT_R16G16B16X16_FLOAT
= 143,
124 ISL_FORMAT_A32X32_FLOAT
= 144,
125 ISL_FORMAT_L32X32_FLOAT
= 145,
126 ISL_FORMAT_I32X32_FLOAT
= 146,
127 ISL_FORMAT_R16G16B16A16_SSCALED
= 147,
128 ISL_FORMAT_R16G16B16A16_USCALED
= 148,
129 ISL_FORMAT_R32G32_SSCALED
= 149,
130 ISL_FORMAT_R32G32_USCALED
= 150,
131 ISL_FORMAT_R32G32_FLOAT_LD
= 151,
132 ISL_FORMAT_R32G32_SFIXED
= 160,
133 ISL_FORMAT_R64_PASSTHRU
= 161,
134 ISL_FORMAT_B8G8R8A8_UNORM
= 192,
135 ISL_FORMAT_B8G8R8A8_UNORM_SRGB
= 193,
136 ISL_FORMAT_R10G10B10A2_UNORM
= 194,
137 ISL_FORMAT_R10G10B10A2_UNORM_SRGB
= 195,
138 ISL_FORMAT_R10G10B10A2_UINT
= 196,
139 ISL_FORMAT_R10G10B10_SNORM_A2_UNORM
= 197,
140 ISL_FORMAT_R8G8B8A8_UNORM
= 199,
141 ISL_FORMAT_R8G8B8A8_UNORM_SRGB
= 200,
142 ISL_FORMAT_R8G8B8A8_SNORM
= 201,
143 ISL_FORMAT_R8G8B8A8_SINT
= 202,
144 ISL_FORMAT_R8G8B8A8_UINT
= 203,
145 ISL_FORMAT_R16G16_UNORM
= 204,
146 ISL_FORMAT_R16G16_SNORM
= 205,
147 ISL_FORMAT_R16G16_SINT
= 206,
148 ISL_FORMAT_R16G16_UINT
= 207,
149 ISL_FORMAT_R16G16_FLOAT
= 208,
150 ISL_FORMAT_B10G10R10A2_UNORM
= 209,
151 ISL_FORMAT_B10G10R10A2_UNORM_SRGB
= 210,
152 ISL_FORMAT_R11G11B10_FLOAT
= 211,
153 ISL_FORMAT_R32_SINT
= 214,
154 ISL_FORMAT_R32_UINT
= 215,
155 ISL_FORMAT_R32_FLOAT
= 216,
156 ISL_FORMAT_R24_UNORM_X8_TYPELESS
= 217,
157 ISL_FORMAT_X24_TYPELESS_G8_UINT
= 218,
158 ISL_FORMAT_L32_UNORM
= 221,
159 ISL_FORMAT_A32_UNORM
= 222,
160 ISL_FORMAT_L16A16_UNORM
= 223,
161 ISL_FORMAT_I24X8_UNORM
= 224,
162 ISL_FORMAT_L24X8_UNORM
= 225,
163 ISL_FORMAT_A24X8_UNORM
= 226,
164 ISL_FORMAT_I32_FLOAT
= 227,
165 ISL_FORMAT_L32_FLOAT
= 228,
166 ISL_FORMAT_A32_FLOAT
= 229,
167 ISL_FORMAT_X8B8_UNORM_G8R8_SNORM
= 230,
168 ISL_FORMAT_A8X8_UNORM_G8R8_SNORM
= 231,
169 ISL_FORMAT_B8X8_UNORM_G8R8_SNORM
= 232,
170 ISL_FORMAT_B8G8R8X8_UNORM
= 233,
171 ISL_FORMAT_B8G8R8X8_UNORM_SRGB
= 234,
172 ISL_FORMAT_R8G8B8X8_UNORM
= 235,
173 ISL_FORMAT_R8G8B8X8_UNORM_SRGB
= 236,
174 ISL_FORMAT_R9G9B9E5_SHAREDEXP
= 237,
175 ISL_FORMAT_B10G10R10X2_UNORM
= 238,
176 ISL_FORMAT_L16A16_FLOAT
= 240,
177 ISL_FORMAT_R32_UNORM
= 241,
178 ISL_FORMAT_R32_SNORM
= 242,
179 ISL_FORMAT_R10G10B10X2_USCALED
= 243,
180 ISL_FORMAT_R8G8B8A8_SSCALED
= 244,
181 ISL_FORMAT_R8G8B8A8_USCALED
= 245,
182 ISL_FORMAT_R16G16_SSCALED
= 246,
183 ISL_FORMAT_R16G16_USCALED
= 247,
184 ISL_FORMAT_R32_SSCALED
= 248,
185 ISL_FORMAT_R32_USCALED
= 249,
186 ISL_FORMAT_B5G6R5_UNORM
= 256,
187 ISL_FORMAT_B5G6R5_UNORM_SRGB
= 257,
188 ISL_FORMAT_B5G5R5A1_UNORM
= 258,
189 ISL_FORMAT_B5G5R5A1_UNORM_SRGB
= 259,
190 ISL_FORMAT_B4G4R4A4_UNORM
= 260,
191 ISL_FORMAT_B4G4R4A4_UNORM_SRGB
= 261,
192 ISL_FORMAT_R8G8_UNORM
= 262,
193 ISL_FORMAT_R8G8_SNORM
= 263,
194 ISL_FORMAT_R8G8_SINT
= 264,
195 ISL_FORMAT_R8G8_UINT
= 265,
196 ISL_FORMAT_R16_UNORM
= 266,
197 ISL_FORMAT_R16_SNORM
= 267,
198 ISL_FORMAT_R16_SINT
= 268,
199 ISL_FORMAT_R16_UINT
= 269,
200 ISL_FORMAT_R16_FLOAT
= 270,
201 ISL_FORMAT_A8P8_UNORM_PALETTE0
= 271,
202 ISL_FORMAT_A8P8_UNORM_PALETTE1
= 272,
203 ISL_FORMAT_I16_UNORM
= 273,
204 ISL_FORMAT_L16_UNORM
= 274,
205 ISL_FORMAT_A16_UNORM
= 275,
206 ISL_FORMAT_L8A8_UNORM
= 276,
207 ISL_FORMAT_I16_FLOAT
= 277,
208 ISL_FORMAT_L16_FLOAT
= 278,
209 ISL_FORMAT_A16_FLOAT
= 279,
210 ISL_FORMAT_L8A8_UNORM_SRGB
= 280,
211 ISL_FORMAT_R5G5_SNORM_B6_UNORM
= 281,
212 ISL_FORMAT_B5G5R5X1_UNORM
= 282,
213 ISL_FORMAT_B5G5R5X1_UNORM_SRGB
= 283,
214 ISL_FORMAT_R8G8_SSCALED
= 284,
215 ISL_FORMAT_R8G8_USCALED
= 285,
216 ISL_FORMAT_R16_SSCALED
= 286,
217 ISL_FORMAT_R16_USCALED
= 287,
218 ISL_FORMAT_P8A8_UNORM_PALETTE0
= 290,
219 ISL_FORMAT_P8A8_UNORM_PALETTE1
= 291,
220 ISL_FORMAT_A1B5G5R5_UNORM
= 292,
221 ISL_FORMAT_A4B4G4R4_UNORM
= 293,
222 ISL_FORMAT_L8A8_UINT
= 294,
223 ISL_FORMAT_L8A8_SINT
= 295,
224 ISL_FORMAT_R8_UNORM
= 320,
225 ISL_FORMAT_R8_SNORM
= 321,
226 ISL_FORMAT_R8_SINT
= 322,
227 ISL_FORMAT_R8_UINT
= 323,
228 ISL_FORMAT_A8_UNORM
= 324,
229 ISL_FORMAT_I8_UNORM
= 325,
230 ISL_FORMAT_L8_UNORM
= 326,
231 ISL_FORMAT_P4A4_UNORM_PALETTE0
= 327,
232 ISL_FORMAT_A4P4_UNORM_PALETTE0
= 328,
233 ISL_FORMAT_R8_SSCALED
= 329,
234 ISL_FORMAT_R8_USCALED
= 330,
235 ISL_FORMAT_P8_UNORM_PALETTE0
= 331,
236 ISL_FORMAT_L8_UNORM_SRGB
= 332,
237 ISL_FORMAT_P8_UNORM_PALETTE1
= 333,
238 ISL_FORMAT_P4A4_UNORM_PALETTE1
= 334,
239 ISL_FORMAT_A4P4_UNORM_PALETTE1
= 335,
240 ISL_FORMAT_Y8_UNORM
= 336,
241 ISL_FORMAT_L8_UINT
= 338,
242 ISL_FORMAT_L8_SINT
= 339,
243 ISL_FORMAT_I8_UINT
= 340,
244 ISL_FORMAT_I8_SINT
= 341,
245 ISL_FORMAT_DXT1_RGB_SRGB
= 384,
246 ISL_FORMAT_R1_UNORM
= 385,
247 ISL_FORMAT_YCRCB_NORMAL
= 386,
248 ISL_FORMAT_YCRCB_SWAPUVY
= 387,
249 ISL_FORMAT_P2_UNORM_PALETTE0
= 388,
250 ISL_FORMAT_P2_UNORM_PALETTE1
= 389,
251 ISL_FORMAT_BC1_UNORM
= 390,
252 ISL_FORMAT_BC2_UNORM
= 391,
253 ISL_FORMAT_BC3_UNORM
= 392,
254 ISL_FORMAT_BC4_UNORM
= 393,
255 ISL_FORMAT_BC5_UNORM
= 394,
256 ISL_FORMAT_BC1_UNORM_SRGB
= 395,
257 ISL_FORMAT_BC2_UNORM_SRGB
= 396,
258 ISL_FORMAT_BC3_UNORM_SRGB
= 397,
259 ISL_FORMAT_MONO8
= 398,
260 ISL_FORMAT_YCRCB_SWAPUV
= 399,
261 ISL_FORMAT_YCRCB_SWAPY
= 400,
262 ISL_FORMAT_DXT1_RGB
= 401,
263 ISL_FORMAT_FXT1
= 402,
264 ISL_FORMAT_R8G8B8_UNORM
= 403,
265 ISL_FORMAT_R8G8B8_SNORM
= 404,
266 ISL_FORMAT_R8G8B8_SSCALED
= 405,
267 ISL_FORMAT_R8G8B8_USCALED
= 406,
268 ISL_FORMAT_R64G64B64A64_FLOAT
= 407,
269 ISL_FORMAT_R64G64B64_FLOAT
= 408,
270 ISL_FORMAT_BC4_SNORM
= 409,
271 ISL_FORMAT_BC5_SNORM
= 410,
272 ISL_FORMAT_R16G16B16_FLOAT
= 411,
273 ISL_FORMAT_R16G16B16_UNORM
= 412,
274 ISL_FORMAT_R16G16B16_SNORM
= 413,
275 ISL_FORMAT_R16G16B16_SSCALED
= 414,
276 ISL_FORMAT_R16G16B16_USCALED
= 415,
277 ISL_FORMAT_BC6H_SF16
= 417,
278 ISL_FORMAT_BC7_UNORM
= 418,
279 ISL_FORMAT_BC7_UNORM_SRGB
= 419,
280 ISL_FORMAT_BC6H_UF16
= 420,
281 ISL_FORMAT_PLANAR_420_8
= 421,
282 ISL_FORMAT_R8G8B8_UNORM_SRGB
= 424,
283 ISL_FORMAT_ETC1_RGB8
= 425,
284 ISL_FORMAT_ETC2_RGB8
= 426,
285 ISL_FORMAT_EAC_R11
= 427,
286 ISL_FORMAT_EAC_RG11
= 428,
287 ISL_FORMAT_EAC_SIGNED_R11
= 429,
288 ISL_FORMAT_EAC_SIGNED_RG11
= 430,
289 ISL_FORMAT_ETC2_SRGB8
= 431,
290 ISL_FORMAT_R16G16B16_UINT
= 432,
291 ISL_FORMAT_R16G16B16_SINT
= 433,
292 ISL_FORMAT_R32_SFIXED
= 434,
293 ISL_FORMAT_R10G10B10A2_SNORM
= 435,
294 ISL_FORMAT_R10G10B10A2_USCALED
= 436,
295 ISL_FORMAT_R10G10B10A2_SSCALED
= 437,
296 ISL_FORMAT_R10G10B10A2_SINT
= 438,
297 ISL_FORMAT_B10G10R10A2_SNORM
= 439,
298 ISL_FORMAT_B10G10R10A2_USCALED
= 440,
299 ISL_FORMAT_B10G10R10A2_SSCALED
= 441,
300 ISL_FORMAT_B10G10R10A2_UINT
= 442,
301 ISL_FORMAT_B10G10R10A2_SINT
= 443,
302 ISL_FORMAT_R64G64B64A64_PASSTHRU
= 444,
303 ISL_FORMAT_R64G64B64_PASSTHRU
= 445,
304 ISL_FORMAT_ETC2_RGB8_PTA
= 448,
305 ISL_FORMAT_ETC2_SRGB8_PTA
= 449,
306 ISL_FORMAT_ETC2_EAC_RGBA8
= 450,
307 ISL_FORMAT_ETC2_EAC_SRGB8_A8
= 451,
308 ISL_FORMAT_R8G8B8_UINT
= 456,
309 ISL_FORMAT_R8G8B8_SINT
= 457,
310 ISL_FORMAT_RAW
= 511,
311 ISL_FORMAT_ASTC_LDR_2D_4X4_U8SRGB
= 512,
312 ISL_FORMAT_ASTC_LDR_2D_5X4_U8SRGB
= 520,
313 ISL_FORMAT_ASTC_LDR_2D_5X5_U8SRGB
= 521,
314 ISL_FORMAT_ASTC_LDR_2D_6X5_U8SRGB
= 529,
315 ISL_FORMAT_ASTC_LDR_2D_6X6_U8SRGB
= 530,
316 ISL_FORMAT_ASTC_LDR_2D_8X5_U8SRGB
= 545,
317 ISL_FORMAT_ASTC_LDR_2D_8X6_U8SRGB
= 546,
318 ISL_FORMAT_ASTC_LDR_2D_8X8_U8SRGB
= 548,
319 ISL_FORMAT_ASTC_LDR_2D_10X5_U8SRGB
= 561,
320 ISL_FORMAT_ASTC_LDR_2D_10X6_U8SRGB
= 562,
321 ISL_FORMAT_ASTC_LDR_2D_10X8_U8SRGB
= 564,
322 ISL_FORMAT_ASTC_LDR_2D_10X10_U8SRGB
= 566,
323 ISL_FORMAT_ASTC_LDR_2D_12X10_U8SRGB
= 574,
324 ISL_FORMAT_ASTC_LDR_2D_12X12_U8SRGB
= 575,
325 ISL_FORMAT_ASTC_LDR_2D_4X4_FLT16
= 576,
326 ISL_FORMAT_ASTC_LDR_2D_5X4_FLT16
= 584,
327 ISL_FORMAT_ASTC_LDR_2D_5X5_FLT16
= 585,
328 ISL_FORMAT_ASTC_LDR_2D_6X5_FLT16
= 593,
329 ISL_FORMAT_ASTC_LDR_2D_6X6_FLT16
= 594,
330 ISL_FORMAT_ASTC_LDR_2D_8X5_FLT16
= 609,
331 ISL_FORMAT_ASTC_LDR_2D_8X6_FLT16
= 610,
332 ISL_FORMAT_ASTC_LDR_2D_8X8_FLT16
= 612,
333 ISL_FORMAT_ASTC_LDR_2D_10X5_FLT16
= 625,
334 ISL_FORMAT_ASTC_LDR_2D_10X6_FLT16
= 626,
335 ISL_FORMAT_ASTC_LDR_2D_10X8_FLT16
= 628,
336 ISL_FORMAT_ASTC_LDR_2D_10X10_FLT16
= 630,
337 ISL_FORMAT_ASTC_LDR_2D_12X10_FLT16
= 638,
338 ISL_FORMAT_ASTC_LDR_2D_12X12_FLT16
= 639,
340 /* Hardware doesn't understand this out-of-band value */
341 ISL_FORMAT_UNSUPPORTED
= UINT16_MAX
,
345 * Numerical base type for channels of isl_format.
363 * Colorspace of isl_format.
365 enum isl_colorspace
{
366 ISL_COLORSPACE_NONE
= 0,
367 ISL_COLORSPACE_LINEAR
,
373 * Texture compression mode of isl_format.
390 * @brief Hardware tile mode
392 * WARNING: These values differ from the hardware enum values, which are
393 * unstable across hardware generations.
395 * Note that legacy Y tiling is ISL_TILING_Y0 instead of ISL_TILING_Y, to
396 * clearly distinguish it from Yf and Ys.
399 ISL_TILING_LINEAR
= 0,
402 ISL_TILING_Y0
, /**< Legacy Y tiling */
403 ISL_TILING_Yf
, /**< Standard 4K tiling. The 'f' means "four". */
404 ISL_TILING_Ys
, /**< Standard 64K tiling. The 's' means "sixty-four". */
408 * @defgroup Tiling Flags
411 typedef uint32_t isl_tiling_flags_t
;
412 #define ISL_TILING_LINEAR_BIT (1u << ISL_TILING_LINEAR)
413 #define ISL_TILING_W_BIT (1u << ISL_TILING_W)
414 #define ISL_TILING_X_BIT (1u << ISL_TILING_X)
415 #define ISL_TILING_Y0_BIT (1u << ISL_TILING_Y0)
416 #define ISL_TILING_Yf_BIT (1u << ISL_TILING_Yf)
417 #define ISL_TILING_Ys_BIT (1u << ISL_TILING_Ys)
418 #define ISL_TILING_ANY_MASK (~0u)
419 #define ISL_TILING_NON_LINEAR_MASK (~ISL_TILING_LINEAR_BIT)
421 /** Any Y tiling, including legacy Y tiling. */
422 #define ISL_TILING_ANY_Y_MASK (ISL_TILING_Y0_BIT | \
423 ISL_TILING_Yf_BIT | \
426 /** The Skylake BSpec refers to Yf and Ys as "standard tiling formats". */
427 #define ISL_TILING_STD_Y_MASK (ISL_TILING_Yf_BIT | \
432 * @brief Logical dimension of surface.
434 * Note: There is no dimension for cube map surfaces. ISL interprets cube maps
435 * as 2D array surfaces.
444 * @brief Physical layout of the surface's dimensions.
446 enum isl_dim_layout
{
448 * For details, see the G35 PRM >> Volume 1: Graphics Core >> Section
449 * 6.17.3: 2D Surfaces.
451 * On many gens, 1D surfaces share the same layout as 2D surfaces. From
452 * the G35 PRM >> Volume 1: Graphics Core >> Section 6.17.2: 1D Surfaces:
454 * One-dimensional surfaces are identical to 2D surfaces with height of
457 * @invariant isl_surf::phys_level0_sa::depth == 1
459 ISL_DIM_LAYOUT_GEN4_2D
,
462 * For details, see the G35 PRM >> Volume 1: Graphics Core >> Section
463 * 6.17.5: 3D Surfaces.
465 * @invariant isl_surf::phys_level0_sa::array_len == 1
467 ISL_DIM_LAYOUT_GEN4_3D
,
470 * For details, see the Skylake BSpec >> Memory Views >> Common Surface
471 * Formats >> Surface Layout and Tiling >> » 1D Surfaces.
473 ISL_DIM_LAYOUT_GEN9_1D
,
476 /* TODO(chadv): Explain */
477 enum isl_array_pitch_span
{
478 ISL_ARRAY_PITCH_SPAN_FULL
,
479 ISL_ARRAY_PITCH_SPAN_COMPACT
,
483 * @defgroup Surface Usage
486 typedef uint64_t isl_surf_usage_flags_t
;
487 #define ISL_SURF_USAGE_RENDER_TARGET_BIT (1u << 0)
488 #define ISL_SURF_USAGE_DEPTH_BIT (1u << 1)
489 #define ISL_SURF_USAGE_STENCIL_BIT (1u << 2)
490 #define ISL_SURF_USAGE_TEXTURE_BIT (1u << 3)
491 #define ISL_SURF_USAGE_CUBE_BIT (1u << 4)
492 #define ISL_SURF_USAGE_DISABLE_AUX_BIT (1u << 5)
493 #define ISL_SURF_USAGE_DISPLAY_BIT (1u << 6)
494 #define ISL_SURF_USAGE_DISPLAY_ROTATE_90_BIT (1u << 7)
495 #define ISL_SURF_USAGE_DISPLAY_ROTATE_180_BIT (1u << 8)
496 #define ISL_SURF_USAGE_DISPLAY_ROTATE_270_BIT (1u << 9)
497 #define ISL_SURF_USAGE_DISPLAY_FLIP_X_BIT (1u << 10)
498 #define ISL_SURF_USAGE_DISPLAY_FLIP_Y_BIT (1u << 11)
499 #define ISL_SURF_USAGE_STORAGE_BIT (1u << 12)
503 * @brief A channel select (also known as texture swizzle) value
505 enum isl_channel_select
{
506 ISL_CHANNEL_SELECT_ZERO
= 0,
507 ISL_CHANNEL_SELECT_ONE
= 1,
508 ISL_CHANNEL_SELECT_RED
= 4,
509 ISL_CHANNEL_SELECT_GREEN
= 5,
510 ISL_CHANNEL_SELECT_BLUE
= 6,
511 ISL_CHANNEL_SELECT_ALPHA
= 7,
515 * Identical to VkSampleCountFlagBits.
517 enum isl_sample_count
{
518 ISL_SAMPLE_COUNT_1_BIT
= 1u,
519 ISL_SAMPLE_COUNT_2_BIT
= 2u,
520 ISL_SAMPLE_COUNT_4_BIT
= 4u,
521 ISL_SAMPLE_COUNT_8_BIT
= 8u,
522 ISL_SAMPLE_COUNT_16_BIT
= 16u,
524 typedef uint32_t isl_sample_count_mask_t
;
527 * @brief Multisample Format
529 enum isl_msaa_layout
{
531 * @brief Suface is single-sampled.
533 ISL_MSAA_LAYOUT_NONE
,
536 * @brief [SNB+] Interleaved Multisample Format
538 * In this format, multiple samples are interleaved into each cacheline.
539 * In other words, the sample index is swizzled into the low 6 bits of the
540 * surface's virtual address space.
542 * For example, suppose the surface is legacy Y tiled, is 4x multisampled,
543 * and its pixel format is 32bpp. Then the first cacheline is arranged
546 * (0,0,0) (0,1,0) (0,0,1) (1,0,1)
547 * (1,0,0) (1,1,0) (0,1,1) (1,1,1)
549 * (0,0,2) (1,0,2) (0,0,3) (1,0,3)
550 * (0,1,2) (1,1,2) (0,1,3) (1,1,3)
552 * The hardware docs refer to this format with multiple terms. In
553 * Sandybridge, this is the only multisample format; so no term is used.
554 * The Ivybridge docs refer to surfaces in this format as IMS (Interleaved
555 * Multisample Surface). Later hardware docs additionally refer to this
556 * format as MSFMT_DEPTH_STENCIL (because the format is deprecated for
559 * See the Sandybridge PRM, Volume 4, Part 1, Section 2.7 "Multisampled
562 * See the Ivybridge PRM, Volume 1, Part 1, Section 6.18.4.1 "Interleaved
563 * Multisampled Surfaces".
565 ISL_MSAA_LAYOUT_INTERLEAVED
,
568 * @brief [IVB+] Array Multisample Format
570 * In this format, the surface's physical layout resembles that of a
573 * Suppose the multisample surface's logical extent is (w, h) and its
574 * sample count is N. Then surface's physical extent is the same as
575 * a singlesample 2D surface whose logical extent is (w, h) and array
576 * length is N. Array slice `i` contains the pixel values for sample
579 * The Ivybridge docs refer to surfaces in this format as UMS
580 * (Uncompressed Multsample Layout) and CMS (Compressed Multisample
581 * Surface). The Broadwell docs additionally refer to this format as
582 * MSFMT_MSS (MSS=Multisample Surface Storage).
584 * See the Broadwell PRM, Volume 5 "Memory Views", Section "Uncompressed
585 * Multisample Surfaces".
587 * See the Broadwell PRM, Volume 5 "Memory Views", Section "Compressed
588 * Multisample Surfaces".
590 ISL_MSAA_LAYOUT_ARRAY
,
595 const struct brw_device_info
*info
;
596 bool use_separate_stencil
;
597 bool has_bit6_swizzling
;
600 struct isl_extent2d
{
601 union { uint32_t w
, width
; };
602 union { uint32_t h
, height
; };
605 struct isl_extent3d
{
606 union { uint32_t w
, width
; };
607 union { uint32_t h
, height
; };
608 union { uint32_t d
, depth
; };
611 struct isl_extent4d
{
612 union { uint32_t w
, width
; };
613 union { uint32_t h
, height
; };
614 union { uint32_t d
, depth
; };
615 union { uint32_t a
, array_len
; };
618 struct isl_channel_layout
{
619 enum isl_base_type type
;
620 uint8_t bits
; /**< Size in bits */
624 * Each format has 3D block extent (width, height, depth). The block extent of
625 * compressed formats is that of the format's compression block. For example,
626 * the block extent of ISL_FORMAT_ETC2_RGB8 is (w=4, h=4, d=1). The block
627 * extent of uncompressed pixel formats, such as ISL_FORMAT_R8G8B8A8_UNORM, is
628 * is (w=1, h=1, d=1).
630 struct isl_format_layout
{
631 enum isl_format format
;
634 uint8_t bs
; /**< Block size, in bytes, rounded towards 0 */
635 uint8_t bw
; /**< Block width, in pixels */
636 uint8_t bh
; /**< Block height, in pixels */
637 uint8_t bd
; /**< Block depth, in pixels */
640 struct isl_channel_layout r
; /**< Red channel */
641 struct isl_channel_layout g
; /**< Green channel */
642 struct isl_channel_layout b
; /**< Blue channel */
643 struct isl_channel_layout a
; /**< Alpha channel */
644 struct isl_channel_layout l
; /**< Luminance channel */
645 struct isl_channel_layout i
; /**< Intensity channel */
646 struct isl_channel_layout p
; /**< Palette channel */
649 enum isl_colorspace colorspace
;
653 struct isl_tile_info
{
654 enum isl_tiling tiling
;
655 uint32_t width
; /**< in bytes */
656 uint32_t height
; /**< in rows of memory */
657 uint32_t size
; /**< in bytes */
661 * @brief Input to surface initialization
663 * @invariant width >= 1
664 * @invariant height >= 1
665 * @invariant depth >= 1
666 * @invariant levels >= 1
667 * @invariant samples >= 1
668 * @invariant array_len >= 1
670 * @invariant if 1D then height == 1 and depth == 1 and samples == 1
671 * @invariant if 2D then depth == 1
672 * @invariant if 3D then array_len == 1 and samples == 1
674 struct isl_surf_init_info
{
675 enum isl_surf_dim dim
;
676 enum isl_format format
;
685 /** Lower bound for isl_surf::alignment, in bytes. */
686 uint32_t min_alignment
;
688 /** Lower bound for isl_surf::pitch, in bytes. */
691 isl_surf_usage_flags_t usage
;
693 /** Flags that alter how ISL selects isl_surf::tiling. */
694 isl_tiling_flags_t tiling_flags
;
698 enum isl_surf_dim dim
;
699 enum isl_dim_layout dim_layout
;
700 enum isl_msaa_layout msaa_layout
;
701 enum isl_tiling tiling
;
702 enum isl_format format
;
705 * Alignment of the upper-left sample of each subimage, in units of surface
708 struct isl_extent3d image_alignment_el
;
711 * Logical extent of the surface's base level, in units of pixels. This is
712 * identical to the extent defined in isl_surf_init_info.
714 struct isl_extent4d logical_level0_px
;
717 * Physical extent of the surface's base level, in units of physical
718 * surface samples and aligned to the format's compression block.
720 * Consider isl_dim_layout as an operator that transforms a logical surface
721 * layout to a physical surface layout. Then
723 * logical_layout := (isl_surf::dim, isl_surf::logical_level0_px)
724 * isl_surf::phys_level0_sa := isl_surf::dim_layout * logical_layout
726 struct isl_extent4d phys_level0_sa
;
731 /** Total size of the surface, in bytes. */
734 /** Required alignment for the surface's base address. */
738 * Pitch between vertically adjacent surface elements, in bytes.
743 * Pitch between physical array slices, in rows of surface elements.
745 uint32_t array_pitch_el_rows
;
747 enum isl_array_pitch_span array_pitch_span
;
749 /** Copy of isl_surf_init_info::usage. */
750 isl_surf_usage_flags_t usage
;
755 * Indicates the usage of the particular view
757 * Normally, this is one bit. However, for a cube map texture, it
758 * should be ISL_SURF_USAGE_TEXTURE_BIT | ISL_SURF_USAGE_CUBE_BIT.
760 isl_surf_usage_flags_t usage
;
763 * The format to use in the view
765 * This may differ from the format of the actual isl_surf but must have
766 * the same block size.
768 enum isl_format format
;
776 * For cube maps, both base_array_layer and array_len should be
777 * specified in terms of 2-D layers and must be a multiple of 6.
779 uint32_t base_array_layer
;
782 enum isl_channel_select channel_select
[4];
785 union isl_color_value
{
791 struct isl_surf_fill_state_info
{
792 const struct isl_surf
*surf
;
793 const struct isl_view
*view
;
796 * The address of the surface in GPU memory.
801 * The Memory Object Control state for the filled surface state.
803 * The exact format of this value depends on hardware generation.
808 * The clear color for this surface
810 * Valid values depend on hardware generation.
812 union isl_color_value clear_color
;
815 struct isl_buffer_fill_state_info
{
817 * The address of the surface in GPU memory.
822 * The size of the buffer
827 * The Memory Object Control state for the filled surface state.
829 * The exact format of this value depends on hardware generation.
834 * The format to use in the surface state
836 * This may differ from the format of the actual isl_surf but have the
839 enum isl_format format
;
844 extern const struct isl_format_layout isl_format_layouts
[];
847 isl_device_init(struct isl_device
*dev
,
848 const struct brw_device_info
*info
,
849 bool has_bit6_swizzling
);
851 isl_sample_count_mask_t ATTRIBUTE_CONST
852 isl_device_get_sample_counts(struct isl_device
*dev
);
854 static inline const struct isl_format_layout
* ATTRIBUTE_CONST
855 isl_format_get_layout(enum isl_format fmt
)
857 return &isl_format_layouts
[fmt
];
860 static inline const char * ATTRIBUTE_CONST
861 isl_format_get_name(enum isl_format fmt
)
863 return isl_format_layouts
[fmt
].name
;
866 bool isl_format_supports_rendering(const struct brw_device_info
*devinfo
,
867 enum isl_format format
);
868 bool isl_format_supports_alpha_blending(const struct brw_device_info
*devinfo
,
869 enum isl_format format
);
870 bool isl_format_supports_sampling(const struct brw_device_info
*devinfo
,
871 enum isl_format format
);
872 bool isl_format_supports_filtering(const struct brw_device_info
*devinfo
,
873 enum isl_format format
);
874 bool isl_format_supports_vertex_fetch(const struct brw_device_info
*devinfo
,
875 enum isl_format format
);
876 bool isl_format_supports_lossless_compression(const struct brw_device_info
*devinfo
,
877 enum isl_format format
);
879 bool isl_format_has_unorm_channel(enum isl_format fmt
) ATTRIBUTE_CONST
;
880 bool isl_format_has_snorm_channel(enum isl_format fmt
) ATTRIBUTE_CONST
;
881 bool isl_format_has_ufloat_channel(enum isl_format fmt
) ATTRIBUTE_CONST
;
882 bool isl_format_has_sfloat_channel(enum isl_format fmt
) ATTRIBUTE_CONST
;
883 bool isl_format_has_uint_channel(enum isl_format fmt
) ATTRIBUTE_CONST
;
884 bool isl_format_has_sint_channel(enum isl_format fmt
) ATTRIBUTE_CONST
;
887 isl_format_has_normalized_channel(enum isl_format fmt
)
889 return isl_format_has_unorm_channel(fmt
) ||
890 isl_format_has_snorm_channel(fmt
);
894 isl_format_has_float_channel(enum isl_format fmt
)
896 return isl_format_has_ufloat_channel(fmt
) ||
897 isl_format_has_sfloat_channel(fmt
);
901 isl_format_has_int_channel(enum isl_format fmt
)
903 return isl_format_has_uint_channel(fmt
) ||
904 isl_format_has_sint_channel(fmt
);
907 unsigned isl_format_get_num_channels(enum isl_format fmt
);
910 isl_format_is_compressed(enum isl_format fmt
)
912 const struct isl_format_layout
*fmtl
= isl_format_get_layout(fmt
);
914 return fmtl
->txc
!= ISL_TXC_NONE
;
918 isl_format_has_bc_compression(enum isl_format fmt
)
920 switch (isl_format_get_layout(fmt
)->txc
) {
936 unreachable("bad texture compression mode");
941 isl_format_is_yuv(enum isl_format fmt
)
943 const struct isl_format_layout
*fmtl
= isl_format_get_layout(fmt
);
945 return fmtl
->colorspace
== ISL_COLORSPACE_YUV
;
949 isl_format_block_is_1x1x1(enum isl_format fmt
)
951 const struct isl_format_layout
*fmtl
= isl_format_get_layout(fmt
);
953 return fmtl
->bw
== 1 && fmtl
->bh
== 1 && fmtl
->bd
== 1;
957 isl_format_is_rgb(enum isl_format fmt
)
959 return isl_format_layouts
[fmt
].channels
.r
.bits
> 0 &&
960 isl_format_layouts
[fmt
].channels
.g
.bits
> 0 &&
961 isl_format_layouts
[fmt
].channels
.b
.bits
> 0 &&
962 isl_format_layouts
[fmt
].channels
.a
.bits
== 0;
965 enum isl_format
isl_format_rgb_to_rgba(enum isl_format rgb
) ATTRIBUTE_CONST
;
966 enum isl_format
isl_format_rgb_to_rgbx(enum isl_format rgb
) ATTRIBUTE_CONST
;
968 bool isl_is_storage_image_format(enum isl_format fmt
);
971 isl_lower_storage_image_format(const struct brw_device_info
*devinfo
,
972 enum isl_format fmt
);
974 /* Returns true if this hardware supports typed load/store on a format with
975 * the same size as the given format.
978 isl_has_matching_typed_storage_image_format(const struct brw_device_info
*devinfo
,
979 enum isl_format fmt
);
982 isl_tiling_is_any_y(enum isl_tiling tiling
)
984 return (1u << tiling
) & ISL_TILING_ANY_MASK
;
988 isl_tiling_is_std_y(enum isl_tiling tiling
)
990 return (1u << tiling
) & ISL_TILING_STD_Y_MASK
;
994 isl_tiling_get_info(const struct isl_device
*dev
,
995 enum isl_tiling tiling
,
996 uint32_t format_block_size
,
997 struct isl_tile_info
*info
);
1000 isl_tiling_get_extent(const struct isl_device
*dev
,
1001 enum isl_tiling tiling
,
1002 uint32_t format_block_size
,
1003 struct isl_extent2d
*e
);
1005 isl_surf_choose_tiling(const struct isl_device
*dev
,
1006 const struct isl_surf_init_info
*restrict info
,
1007 enum isl_tiling
*tiling
);
1010 isl_surf_usage_is_display(isl_surf_usage_flags_t usage
)
1012 return usage
& ISL_SURF_USAGE_DISPLAY_BIT
;
1016 isl_surf_usage_is_depth(isl_surf_usage_flags_t usage
)
1018 return usage
& ISL_SURF_USAGE_DEPTH_BIT
;
1022 isl_surf_usage_is_stencil(isl_surf_usage_flags_t usage
)
1024 return usage
& ISL_SURF_USAGE_STENCIL_BIT
;
1028 isl_surf_usage_is_depth_and_stencil(isl_surf_usage_flags_t usage
)
1030 return (usage
& ISL_SURF_USAGE_DEPTH_BIT
) &&
1031 (usage
& ISL_SURF_USAGE_STENCIL_BIT
);
1035 isl_surf_usage_is_depth_or_stencil(isl_surf_usage_flags_t usage
)
1037 return usage
& (ISL_SURF_USAGE_DEPTH_BIT
| ISL_SURF_USAGE_STENCIL_BIT
);
1041 isl_surf_info_is_z16(const struct isl_surf_init_info
*info
)
1043 return (info
->usage
& ISL_SURF_USAGE_DEPTH_BIT
) &&
1044 (info
->format
== ISL_FORMAT_R16_UNORM
);
1048 isl_surf_info_is_z32_float(const struct isl_surf_init_info
*info
)
1050 return (info
->usage
& ISL_SURF_USAGE_DEPTH_BIT
) &&
1051 (info
->format
== ISL_FORMAT_R32_FLOAT
);
1054 static inline struct isl_extent2d
1055 isl_extent2d(uint32_t width
, uint32_t height
)
1057 struct isl_extent2d e
= { { 0 } };
1065 static inline struct isl_extent3d
1066 isl_extent3d(uint32_t width
, uint32_t height
, uint32_t depth
)
1068 struct isl_extent3d e
= { { 0 } };
1077 static inline struct isl_extent4d
1078 isl_extent4d(uint32_t width
, uint32_t height
, uint32_t depth
,
1081 struct isl_extent4d e
= { { 0 } };
1086 e
.array_len
= array_len
;
1091 #define isl_surf_init(dev, surf, ...) \
1092 isl_surf_init_s((dev), (surf), \
1093 &(struct isl_surf_init_info) { __VA_ARGS__ });
1096 isl_surf_init_s(const struct isl_device
*dev
,
1097 struct isl_surf
*surf
,
1098 const struct isl_surf_init_info
*restrict info
);
1101 isl_surf_get_tile_info(const struct isl_device
*dev
,
1102 const struct isl_surf
*surf
,
1103 struct isl_tile_info
*tile_info
);
1105 #define isl_surf_fill_state(dev, state, ...) \
1106 isl_surf_fill_state_s((dev), (state), \
1107 &(struct isl_surf_fill_state_info) { __VA_ARGS__ });
1110 isl_surf_fill_state_s(const struct isl_device
*dev
, void *state
,
1111 const struct isl_surf_fill_state_info
*restrict info
);
1113 #define isl_buffer_fill_state(dev, state, ...) \
1114 isl_buffer_fill_state_s((dev), (state), \
1115 &(struct isl_buffer_fill_state_info) { __VA_ARGS__ });
1118 isl_buffer_fill_state_s(const struct isl_device
*dev
, void *state
,
1119 const struct isl_buffer_fill_state_info
*restrict info
);
1122 isl_surf_fill_image_param(const struct isl_device
*dev
,
1123 struct brw_image_param
*param
,
1124 const struct isl_surf
*surf
,
1125 const struct isl_view
*view
);
1128 isl_buffer_fill_image_param(const struct isl_device
*dev
,
1129 struct brw_image_param
*param
,
1130 enum isl_format format
,
1134 * Alignment of the upper-left sample of each subimage, in units of surface
1137 static inline struct isl_extent3d
1138 isl_surf_get_image_alignment_el(const struct isl_surf
*surf
)
1140 return surf
->image_alignment_el
;
1144 * Alignment of the upper-left sample of each subimage, in units of surface
1147 static inline struct isl_extent3d
1148 isl_surf_get_image_alignment_sa(const struct isl_surf
*surf
)
1150 const struct isl_format_layout
*fmtl
= isl_format_get_layout(surf
->format
);
1152 return isl_extent3d(fmtl
->bw
* surf
->image_alignment_el
.w
,
1153 fmtl
->bh
* surf
->image_alignment_el
.h
,
1154 fmtl
->bd
* surf
->image_alignment_el
.d
);
1158 * Pitch between vertically adjacent surface elements, in bytes.
1160 static inline uint32_t
1161 isl_surf_get_row_pitch(const struct isl_surf
*surf
)
1163 return surf
->row_pitch
;
1167 * Pitch between vertically adjacent surface elements, in units of surface elements.
1169 static inline uint32_t
1170 isl_surf_get_row_pitch_el(const struct isl_surf
*surf
)
1172 const struct isl_format_layout
*fmtl
= isl_format_get_layout(surf
->format
);
1174 assert(surf
->row_pitch
% fmtl
->bs
== 0);
1175 return surf
->row_pitch
/ fmtl
->bs
;
1179 * Pitch between physical array slices, in rows of surface elements.
1181 static inline uint32_t
1182 isl_surf_get_array_pitch_el_rows(const struct isl_surf
*surf
)
1184 return surf
->array_pitch_el_rows
;
1188 * Pitch between physical array slices, in units of surface elements.
1190 static inline uint32_t
1191 isl_surf_get_array_pitch_el(const struct isl_surf
*surf
)
1193 return isl_surf_get_array_pitch_el_rows(surf
) *
1194 isl_surf_get_row_pitch_el(surf
);
1198 * Pitch between physical array slices, in rows of surface samples.
1200 static inline uint32_t
1201 isl_surf_get_array_pitch_sa_rows(const struct isl_surf
*surf
)
1203 const struct isl_format_layout
*fmtl
= isl_format_get_layout(surf
->format
);
1204 return fmtl
->bh
* isl_surf_get_array_pitch_el_rows(surf
);
1208 * Pitch between physical array slices, in bytes.
1210 static inline uint32_t
1211 isl_surf_get_array_pitch(const struct isl_surf
*surf
)
1213 return isl_surf_get_array_pitch_sa_rows(surf
) * surf
->row_pitch
;
1217 * Calculate the offset, in units of surface elements, to a subimage in the
1220 * @invariant level < surface levels
1221 * @invariant logical_array_layer < logical array length of surface
1222 * @invariant logical_z_offset_px < logical depth of surface at level
1225 isl_surf_get_image_offset_el(const struct isl_surf
*surf
,
1227 uint32_t logical_array_layer
,
1228 uint32_t logical_z_offset_px
,
1229 uint32_t *x_offset_el
,
1230 uint32_t *y_offset_el
);
1233 * @brief Calculate the intratile offsets to a surface.
1235 * In @a base_address_offset return the offset from the base of the surface to
1236 * the base address of the first tile of the subimage. In @a x_offset_B and
1237 * @a y_offset_rows, return the offset, in units of bytes and rows, from the
1238 * tile's base to the subimage's first surface element. The x and y offsets
1239 * are intratile offsets; that is, they do not exceed the boundary of the
1240 * surface's tiling format.
1243 isl_tiling_get_intratile_offset_el(const struct isl_device
*dev
,
1244 enum isl_tiling tiling
,
1247 uint32_t total_x_offset_B
,
1248 uint32_t total_y_offset_rows
,
1249 uint32_t *base_address_offset
,
1250 uint32_t *x_offset_B
,
1251 uint32_t *y_offset_rows
);
1254 * @brief Get value of 3DSTATE_DEPTH_BUFFER.SurfaceFormat
1256 * @pre surf->usage has ISL_SURF_USAGE_DEPTH_BIT
1257 * @pre surf->format must be a valid format for depth surfaces
1260 isl_surf_get_depth_format(const struct isl_device
*dev
,
1261 const struct isl_surf
*surf
);