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
31 * The header is ordered as:
32 * - forward declarations
33 * - macros that may be overridden at compile-time for specific gens
34 * - enums and constants
35 * - structs and unions
42 * Some symbol names have a unit suffix.
44 * - px: logical pixels
45 * - sa: physical surface samples
46 * - el: physical surface elements
47 * - sa_rows: rows of physical surface samples
48 * - el_rows: rows of physical surface elements
50 * The Broadwell PRM [1] defines a surface element as follows:
52 * An element is defined as a pixel in uncompresed surface formats, and as
53 * a compression block in compressed surface formats. For
54 * MSFMT_DEPTH_STENCIL type multisampled surfaces, an element is a sample.
56 * [1]: Broadwell PRM >> Volume 2d: Command Reference: Structures >>
57 * RENDER_SURFACE_STATE Surface Vertical Alignment (p325)
66 #include "util/macros.h"
72 struct brw_device_info
;
76 * @brief Get the hardware generation of isl_device.
78 * You can define this as a compile-time constant in the CFLAGS. For example,
79 * `gcc -DISL_DEV_GEN(dev)=9 ...`.
81 #define ISL_DEV_GEN(__dev) ((__dev)->info->gen)
84 #ifndef ISL_DEV_USE_SEPARATE_STENCIL
86 * You can define this as a compile-time constant in the CFLAGS. For example,
87 * `gcc -DISL_DEV_USE_SEPARATE_STENCIL(dev)=1 ...`.
89 #define ISL_DEV_USE_SEPARATE_STENCIL(__dev) ((__dev)->use_separate_stencil)
93 * Hardware enumeration SURFACE_FORMAT.
95 * For the official list, see Broadwell PRM: Volume 2b: Command Reference:
96 * Enumerations: SURFACE_FORMAT.
99 ISL_FORMAT_R32G32B32A32_FLOAT
= 0,
100 ISL_FORMAT_R32G32B32A32_SINT
= 1,
101 ISL_FORMAT_R32G32B32A32_UINT
= 2,
102 ISL_FORMAT_R32G32B32A32_UNORM
= 3,
103 ISL_FORMAT_R32G32B32A32_SNORM
= 4,
104 ISL_FORMAT_R64G64_FLOAT
= 5,
105 ISL_FORMAT_R32G32B32X32_FLOAT
= 6,
106 ISL_FORMAT_R32G32B32A32_SSCALED
= 7,
107 ISL_FORMAT_R32G32B32A32_USCALED
= 8,
108 ISL_FORMAT_R32G32B32A32_SFIXED
= 32,
109 ISL_FORMAT_R64G64_PASSTHRU
= 33,
110 ISL_FORMAT_R32G32B32_FLOAT
= 64,
111 ISL_FORMAT_R32G32B32_SINT
= 65,
112 ISL_FORMAT_R32G32B32_UINT
= 66,
113 ISL_FORMAT_R32G32B32_UNORM
= 67,
114 ISL_FORMAT_R32G32B32_SNORM
= 68,
115 ISL_FORMAT_R32G32B32_SSCALED
= 69,
116 ISL_FORMAT_R32G32B32_USCALED
= 70,
117 ISL_FORMAT_R32G32B32_SFIXED
= 80,
118 ISL_FORMAT_R16G16B16A16_UNORM
= 128,
119 ISL_FORMAT_R16G16B16A16_SNORM
= 129,
120 ISL_FORMAT_R16G16B16A16_SINT
= 130,
121 ISL_FORMAT_R16G16B16A16_UINT
= 131,
122 ISL_FORMAT_R16G16B16A16_FLOAT
= 132,
123 ISL_FORMAT_R32G32_FLOAT
= 133,
124 ISL_FORMAT_R32G32_SINT
= 134,
125 ISL_FORMAT_R32G32_UINT
= 135,
126 ISL_FORMAT_R32_FLOAT_X8X24_TYPELESS
= 136,
127 ISL_FORMAT_X32_TYPELESS_G8X24_UINT
= 137,
128 ISL_FORMAT_L32A32_FLOAT
= 138,
129 ISL_FORMAT_R32G32_UNORM
= 139,
130 ISL_FORMAT_R32G32_SNORM
= 140,
131 ISL_FORMAT_R64_FLOAT
= 141,
132 ISL_FORMAT_R16G16B16X16_UNORM
= 142,
133 ISL_FORMAT_R16G16B16X16_FLOAT
= 143,
134 ISL_FORMAT_A32X32_FLOAT
= 144,
135 ISL_FORMAT_L32X32_FLOAT
= 145,
136 ISL_FORMAT_I32X32_FLOAT
= 146,
137 ISL_FORMAT_R16G16B16A16_SSCALED
= 147,
138 ISL_FORMAT_R16G16B16A16_USCALED
= 148,
139 ISL_FORMAT_R32G32_SSCALED
= 149,
140 ISL_FORMAT_R32G32_USCALED
= 150,
141 ISL_FORMAT_R32G32_SFIXED
= 160,
142 ISL_FORMAT_R64_PASSTHRU
= 161,
143 ISL_FORMAT_B8G8R8A8_UNORM
= 192,
144 ISL_FORMAT_B8G8R8A8_UNORM_SRGB
= 193,
145 ISL_FORMAT_R10G10B10A2_UNORM
= 194,
146 ISL_FORMAT_R10G10B10A2_UNORM_SRGB
= 195,
147 ISL_FORMAT_R10G10B10A2_UINT
= 196,
148 ISL_FORMAT_R10G10B10_SNORM_A2_UNORM
= 197,
149 ISL_FORMAT_R8G8B8A8_UNORM
= 199,
150 ISL_FORMAT_R8G8B8A8_UNORM_SRGB
= 200,
151 ISL_FORMAT_R8G8B8A8_SNORM
= 201,
152 ISL_FORMAT_R8G8B8A8_SINT
= 202,
153 ISL_FORMAT_R8G8B8A8_UINT
= 203,
154 ISL_FORMAT_R16G16_UNORM
= 204,
155 ISL_FORMAT_R16G16_SNORM
= 205,
156 ISL_FORMAT_R16G16_SINT
= 206,
157 ISL_FORMAT_R16G16_UINT
= 207,
158 ISL_FORMAT_R16G16_FLOAT
= 208,
159 ISL_FORMAT_B10G10R10A2_UNORM
= 209,
160 ISL_FORMAT_B10G10R10A2_UNORM_SRGB
= 210,
161 ISL_FORMAT_R11G11B10_FLOAT
= 211,
162 ISL_FORMAT_R32_SINT
= 214,
163 ISL_FORMAT_R32_UINT
= 215,
164 ISL_FORMAT_R32_FLOAT
= 216,
165 ISL_FORMAT_R24_UNORM_X8_TYPELESS
= 217,
166 ISL_FORMAT_X24_TYPELESS_G8_UINT
= 218,
167 ISL_FORMAT_L32_UNORM
= 221,
168 ISL_FORMAT_A32_UNORM
= 222,
169 ISL_FORMAT_L16A16_UNORM
= 223,
170 ISL_FORMAT_I24X8_UNORM
= 224,
171 ISL_FORMAT_L24X8_UNORM
= 225,
172 ISL_FORMAT_A24X8_UNORM
= 226,
173 ISL_FORMAT_I32_FLOAT
= 227,
174 ISL_FORMAT_L32_FLOAT
= 228,
175 ISL_FORMAT_A32_FLOAT
= 229,
176 ISL_FORMAT_X8B8_UNORM_G8R8_SNORM
= 230,
177 ISL_FORMAT_A8X8_UNORM_G8R8_SNORM
= 231,
178 ISL_FORMAT_B8X8_UNORM_G8R8_SNORM
= 232,
179 ISL_FORMAT_B8G8R8X8_UNORM
= 233,
180 ISL_FORMAT_B8G8R8X8_UNORM_SRGB
= 234,
181 ISL_FORMAT_R8G8B8X8_UNORM
= 235,
182 ISL_FORMAT_R8G8B8X8_UNORM_SRGB
= 236,
183 ISL_FORMAT_R9G9B9E5_SHAREDEXP
= 237,
184 ISL_FORMAT_B10G10R10X2_UNORM
= 238,
185 ISL_FORMAT_L16A16_FLOAT
= 240,
186 ISL_FORMAT_R32_UNORM
= 241,
187 ISL_FORMAT_R32_SNORM
= 242,
188 ISL_FORMAT_R10G10B10X2_USCALED
= 243,
189 ISL_FORMAT_R8G8B8A8_SSCALED
= 244,
190 ISL_FORMAT_R8G8B8A8_USCALED
= 245,
191 ISL_FORMAT_R16G16_SSCALED
= 246,
192 ISL_FORMAT_R16G16_USCALED
= 247,
193 ISL_FORMAT_R32_SSCALED
= 248,
194 ISL_FORMAT_R32_USCALED
= 249,
195 ISL_FORMAT_B5G6R5_UNORM
= 256,
196 ISL_FORMAT_B5G6R5_UNORM_SRGB
= 257,
197 ISL_FORMAT_B5G5R5A1_UNORM
= 258,
198 ISL_FORMAT_B5G5R5A1_UNORM_SRGB
= 259,
199 ISL_FORMAT_B4G4R4A4_UNORM
= 260,
200 ISL_FORMAT_B4G4R4A4_UNORM_SRGB
= 261,
201 ISL_FORMAT_R8G8_UNORM
= 262,
202 ISL_FORMAT_R8G8_SNORM
= 263,
203 ISL_FORMAT_R8G8_SINT
= 264,
204 ISL_FORMAT_R8G8_UINT
= 265,
205 ISL_FORMAT_R16_UNORM
= 266,
206 ISL_FORMAT_R16_SNORM
= 267,
207 ISL_FORMAT_R16_SINT
= 268,
208 ISL_FORMAT_R16_UINT
= 269,
209 ISL_FORMAT_R16_FLOAT
= 270,
210 ISL_FORMAT_A8P8_UNORM_PALETTE0
= 271,
211 ISL_FORMAT_A8P8_UNORM_PALETTE1
= 272,
212 ISL_FORMAT_I16_UNORM
= 273,
213 ISL_FORMAT_L16_UNORM
= 274,
214 ISL_FORMAT_A16_UNORM
= 275,
215 ISL_FORMAT_L8A8_UNORM
= 276,
216 ISL_FORMAT_I16_FLOAT
= 277,
217 ISL_FORMAT_L16_FLOAT
= 278,
218 ISL_FORMAT_A16_FLOAT
= 279,
219 ISL_FORMAT_L8A8_UNORM_SRGB
= 280,
220 ISL_FORMAT_R5G5_SNORM_B6_UNORM
= 281,
221 ISL_FORMAT_B5G5R5X1_UNORM
= 282,
222 ISL_FORMAT_B5G5R5X1_UNORM_SRGB
= 283,
223 ISL_FORMAT_R8G8_SSCALED
= 284,
224 ISL_FORMAT_R8G8_USCALED
= 285,
225 ISL_FORMAT_R16_SSCALED
= 286,
226 ISL_FORMAT_R16_USCALED
= 287,
227 ISL_FORMAT_P8A8_UNORM_PALETTE0
= 290,
228 ISL_FORMAT_P8A8_UNORM_PALETTE1
= 291,
229 ISL_FORMAT_A1B5G5R5_UNORM
= 292,
230 ISL_FORMAT_A4B4G4R4_UNORM
= 293,
231 ISL_FORMAT_L8A8_UINT
= 294,
232 ISL_FORMAT_L8A8_SINT
= 295,
233 ISL_FORMAT_R8_UNORM
= 320,
234 ISL_FORMAT_R8_SNORM
= 321,
235 ISL_FORMAT_R8_SINT
= 322,
236 ISL_FORMAT_R8_UINT
= 323,
237 ISL_FORMAT_A8_UNORM
= 324,
238 ISL_FORMAT_I8_UNORM
= 325,
239 ISL_FORMAT_L8_UNORM
= 326,
240 ISL_FORMAT_P4A4_UNORM_PALETTE0
= 327,
241 ISL_FORMAT_A4P4_UNORM_PALETTE0
= 328,
242 ISL_FORMAT_R8_SSCALED
= 329,
243 ISL_FORMAT_R8_USCALED
= 330,
244 ISL_FORMAT_P8_UNORM_PALETTE0
= 331,
245 ISL_FORMAT_L8_UNORM_SRGB
= 332,
246 ISL_FORMAT_P8_UNORM_PALETTE1
= 333,
247 ISL_FORMAT_P4A4_UNORM_PALETTE1
= 334,
248 ISL_FORMAT_A4P4_UNORM_PALETTE1
= 335,
249 ISL_FORMAT_Y8_UNORM
= 336,
250 ISL_FORMAT_L8_UINT
= 338,
251 ISL_FORMAT_L8_SINT
= 339,
252 ISL_FORMAT_I8_UINT
= 340,
253 ISL_FORMAT_I8_SINT
= 341,
254 ISL_FORMAT_DXT1_RGB_SRGB
= 384,
255 ISL_FORMAT_R1_UNORM
= 385,
256 ISL_FORMAT_YCRCB_NORMAL
= 386,
257 ISL_FORMAT_YCRCB_SWAPUVY
= 387,
258 ISL_FORMAT_P2_UNORM_PALETTE0
= 388,
259 ISL_FORMAT_P2_UNORM_PALETTE1
= 389,
260 ISL_FORMAT_BC1_UNORM
= 390,
261 ISL_FORMAT_BC2_UNORM
= 391,
262 ISL_FORMAT_BC3_UNORM
= 392,
263 ISL_FORMAT_BC4_UNORM
= 393,
264 ISL_FORMAT_BC5_UNORM
= 394,
265 ISL_FORMAT_BC1_UNORM_SRGB
= 395,
266 ISL_FORMAT_BC2_UNORM_SRGB
= 396,
267 ISL_FORMAT_BC3_UNORM_SRGB
= 397,
268 ISL_FORMAT_MONO8
= 398,
269 ISL_FORMAT_YCRCB_SWAPUV
= 399,
270 ISL_FORMAT_YCRCB_SWAPY
= 400,
271 ISL_FORMAT_DXT1_RGB
= 401,
272 ISL_FORMAT_FXT1
= 402,
273 ISL_FORMAT_R8G8B8_UNORM
= 403,
274 ISL_FORMAT_R8G8B8_SNORM
= 404,
275 ISL_FORMAT_R8G8B8_SSCALED
= 405,
276 ISL_FORMAT_R8G8B8_USCALED
= 406,
277 ISL_FORMAT_R64G64B64A64_FLOAT
= 407,
278 ISL_FORMAT_R64G64B64_FLOAT
= 408,
279 ISL_FORMAT_BC4_SNORM
= 409,
280 ISL_FORMAT_BC5_SNORM
= 410,
281 ISL_FORMAT_R16G16B16_FLOAT
= 411,
282 ISL_FORMAT_R16G16B16_UNORM
= 412,
283 ISL_FORMAT_R16G16B16_SNORM
= 413,
284 ISL_FORMAT_R16G16B16_SSCALED
= 414,
285 ISL_FORMAT_R16G16B16_USCALED
= 415,
286 ISL_FORMAT_BC6H_SF16
= 417,
287 ISL_FORMAT_BC7_UNORM
= 418,
288 ISL_FORMAT_BC7_UNORM_SRGB
= 419,
289 ISL_FORMAT_BC6H_UF16
= 420,
290 ISL_FORMAT_PLANAR_420_8
= 421,
291 ISL_FORMAT_R8G8B8_UNORM_SRGB
= 424,
292 ISL_FORMAT_ETC1_RGB8
= 425,
293 ISL_FORMAT_ETC2_RGB8
= 426,
294 ISL_FORMAT_EAC_R11
= 427,
295 ISL_FORMAT_EAC_RG11
= 428,
296 ISL_FORMAT_EAC_SIGNED_R11
= 429,
297 ISL_FORMAT_EAC_SIGNED_RG11
= 430,
298 ISL_FORMAT_ETC2_SRGB8
= 431,
299 ISL_FORMAT_R16G16B16_UINT
= 432,
300 ISL_FORMAT_R16G16B16_SINT
= 433,
301 ISL_FORMAT_R32_SFIXED
= 434,
302 ISL_FORMAT_R10G10B10A2_SNORM
= 435,
303 ISL_FORMAT_R10G10B10A2_USCALED
= 436,
304 ISL_FORMAT_R10G10B10A2_SSCALED
= 437,
305 ISL_FORMAT_R10G10B10A2_SINT
= 438,
306 ISL_FORMAT_B10G10R10A2_SNORM
= 439,
307 ISL_FORMAT_B10G10R10A2_USCALED
= 440,
308 ISL_FORMAT_B10G10R10A2_SSCALED
= 441,
309 ISL_FORMAT_B10G10R10A2_UINT
= 442,
310 ISL_FORMAT_B10G10R10A2_SINT
= 443,
311 ISL_FORMAT_R64G64B64A64_PASSTHRU
= 444,
312 ISL_FORMAT_R64G64B64_PASSTHRU
= 445,
313 ISL_FORMAT_ETC2_RGB8_PTA
= 448,
314 ISL_FORMAT_ETC2_SRGB8_PTA
= 449,
315 ISL_FORMAT_ETC2_EAC_RGBA8
= 450,
316 ISL_FORMAT_ETC2_EAC_SRGB8_A8
= 451,
317 ISL_FORMAT_R8G8B8_UINT
= 456,
318 ISL_FORMAT_R8G8B8_SINT
= 457,
319 ISL_FORMAT_RAW
= 511,
321 /* Hardware doesn't understand this out-of-band value */
322 ISL_FORMAT_UNSUPPORTED
= UINT16_MAX
,
326 * Numerical base type for channels of isl_format.
344 * Colorspace of isl_format.
346 enum isl_colorspace
{
347 ISL_COLORSPACE_NONE
= 0,
348 ISL_COLORSPACE_LINEAR
,
354 * Texture compression mode of isl_format.
370 * @brief Hardware tile mode
372 * WARNING: These values differ from the hardware enum values, which are
373 * unstable across hardware generations.
375 * Note that legacy Y tiling is ISL_TILING_Y0 instead of ISL_TILING_Y, to
376 * clearly distinguish it from Yf and Ys.
379 ISL_TILING_LINEAR
= 0,
382 ISL_TILING_Y0
, /**< Legacy Y tiling */
388 * @defgroup Tiling Flags
391 typedef uint32_t isl_tiling_flags_t
;
392 #define ISL_TILING_LINEAR_BIT (1u << ISL_TILING_LINEAR)
393 #define ISL_TILING_W_BIT (1u << ISL_TILING_W)
394 #define ISL_TILING_X_BIT (1u << ISL_TILING_X)
395 #define ISL_TILING_Y0_BIT (1u << ISL_TILING_Y0)
396 #define ISL_TILING_Yf_BIT (1u << ISL_TILING_Yf)
397 #define ISL_TILING_Ys_BIT (1u << ISL_TILING_Ys)
398 #define ISL_TILING_ANY_MASK (~0u)
399 #define ISL_TILING_NON_LINEAR_MASK (~ISL_TILING_LINEAR_BIT)
401 /** Any Y tiling, including legacy Y tiling. */
402 #define ISL_TILING_ANY_Y_MASK (ISL_TILING_Y0_BIT | \
403 ISL_TILING_Yf_BIT | \
406 /** The Skylake BSpec refers to Yf and Ys as "standard tiling formats". */
407 #define ISL_TILING_STD_Y_MASK (ISL_TILING_Yf_BIT | \
412 * @brief Logical dimension of surface.
414 * Note: There is no dimension for cube map surfaces. ISL interprets cube maps
415 * as 2D array surfaces.
424 * @brief Physical layout of the surface's dimensions.
426 enum isl_dim_layout
{
428 * For details, see the G35 PRM >> Volume 1: Graphics Core >> Section
429 * 6.17.3: 2D Surfaces.
431 * On many gens, 1D surfaces share the same layout as 2D surfaces. From
432 * the G35 PRM >> Volume 1: Graphics Core >> Section 6.17.2: 1D Surfaces:
434 * One-dimensional surfaces are identical to 2D surfaces with height of
437 ISL_DIM_LAYOUT_GEN4_2D
,
440 * For details, see the G35 PRM >> Volume 1: Graphics Core >> Section
441 * 6.17.5: 3D Surfaces.
443 ISL_DIM_LAYOUT_GEN4_3D
,
446 * For details, see the Skylake BSpec >> Memory Views >> Common Surface
447 * Formats >> Surface Layout and Tiling >> » 1D Surfaces.
449 ISL_DIM_LAYOUT_GEN9_1D
,
452 /* TODO(chadv): Explain */
453 enum isl_array_pitch_span
{
454 ISL_ARRAY_PITCH_SPAN_FULL
,
455 ISL_ARRAY_PITCH_SPAN_COMPACT
,
459 * @defgroup Surface Usage
462 typedef uint64_t isl_surf_usage_flags_t
;
463 #define ISL_SURF_USAGE_RENDER_TARGET_BIT (1u << 0)
464 #define ISL_SURF_USAGE_DEPTH_BIT (1u << 1)
465 #define ISL_SURF_USAGE_STENCIL_BIT (1u << 2)
466 #define ISL_SURF_USAGE_TEXTURE_BIT (1u << 3)
467 #define ISL_SURF_USAGE_CUBE_BIT (1u << 4)
468 #define ISL_SURF_USAGE_DISABLE_AUX_BIT (1u << 5)
469 #define ISL_SURF_USAGE_DISPLAY_BIT (1u << 6)
470 #define ISL_SURF_USAGE_DISPLAY_ROTATE_90_BIT (1u << 7)
471 #define ISL_SURF_USAGE_DISPLAY_ROTATE_180_BIT (1u << 8)
472 #define ISL_SURF_USAGE_DISPLAY_ROTATE_270_BIT (1u << 9)
473 #define ISL_SURF_USAGE_DISPLAY_FLIP_X_BIT (1u << 10)
474 #define ISL_SURF_USAGE_DISPLAY_FLIP_Y_BIT (1u << 11)
478 * @brief Multisample Format
480 enum isl_msaa_layout
{
482 * @brief Suface is single-sampled.
484 ISL_MSAA_LAYOUT_NONE
,
487 * @brief [SNB+] Interleaved Multisample Format
489 * In this format, multiple samples are interleaved into each cacheline.
490 * In other words, the sample index is swizzled into the low 6 bits of the
491 * surface's virtual address space.
493 * For example, suppose the surface is legacy Y tiled, is 4x multisampled,
494 * and its pixel format is 32bpp. Then the first cacheline is arranged
497 * (0,0,0) (0,1,0) (0,0,1) (1,0,1)
498 * (1,0,0) (1,1,0) (0,1,1) (1,1,1)
500 * (0,0,2) (1,0,2) (0,0,3) (1,0,3)
501 * (0,1,2) (1,1,2) (0,1,3) (1,1,3)
503 * The hardware docs refer to this format with multiple terms. In
504 * Sandybridge, this is the only multisample format; so no term is used.
505 * The Ivybridge docs refer to surfaces in this format as IMS (Interleaved
506 * Multisample Surface). Later hardware docs additionally refer to this
507 * format as MSFMT_DEPTH_STENCIL (because the format is deprecated for
510 * See the Sandybridge PRM, Volume 4, Part 1, Section 2.7 "Multisampled
513 * See the Ivybridge PRM, Volume 1, Part 1, Section 6.18.4.1 "Interleaved
514 * Multisampled Surfaces".
516 ISL_MSAA_LAYOUT_INTERLEAVED
,
519 * @brief [IVB+] Array Multisample Format
521 * In this format, the surface's physical layout resembles that of a
524 * Suppose the multisample surface's logical extent is (w, h) and its
525 * sample count is N. Then surface's physical extent is the same as
526 * a singlesample 2D surface whose logical extent is (w, h) and array
527 * length is N. Array slice `i` contains the pixel values for sample
530 * The Ivybridge docs refer to surfaces in this format as UMS
531 * (Uncompressed Multsample Layout) and CMS (Compressed Multisample
532 * Surface). The Broadwell docs additionally refer to this format as
533 * MSFMT_MSS (MSS=Multisample Surface Storage).
535 * See the Broadwell PRM, Volume 5 "Memory Views", Section "Uncompressed
536 * Multisample Surfaces".
538 * See the Broadwell PRM, Volume 5 "Memory Views", Section "Compressed
539 * Multisample Surfaces".
541 ISL_MSAA_LAYOUT_ARRAY
,
546 const struct brw_device_info
*info
;
547 bool use_separate_stencil
;
550 struct isl_extent2d
{
551 union { uint32_t w
, width
; };
552 union { uint32_t h
, height
; };
555 struct isl_extent3d
{
556 union { uint32_t w
, width
; };
557 union { uint32_t h
, height
; };
558 union { uint32_t d
, depth
; };
561 struct isl_extent4d
{
562 union { uint32_t w
, width
; };
563 union { uint32_t h
, height
; };
564 union { uint32_t d
, depth
; };
565 union { uint32_t a
, array_len
; };
568 struct isl_channel_layout
{
569 enum isl_base_type type
;
570 uint8_t bits
; /**< Size in bits */
573 struct isl_format_layout
{
574 enum isl_format format
;
576 uint16_t bpb
; /**< Bits per block */
577 uint8_t bs
; /**< Block size, in bytes, rounded towards 0 */
578 uint8_t bw
; /**< Block width, in pixels */
579 uint8_t bh
; /**< Block height, in pixels */
580 uint8_t bd
; /**< Block depth, in pixels */
583 struct isl_channel_layout r
; /**< Red channel */
584 struct isl_channel_layout g
; /**< Green channel */
585 struct isl_channel_layout b
; /**< Blue channel */
586 struct isl_channel_layout a
; /**< Alpha channel */
587 struct isl_channel_layout l
; /**< Luminance channel */
588 struct isl_channel_layout i
; /**< Intensity channel */
589 struct isl_channel_layout p
; /**< Palette channel */
592 enum isl_colorspace colorspace
;
596 struct isl_tile_info
{
597 enum isl_tiling tiling
;
598 uint32_t width
; /**< in bytes */
599 uint32_t height
; /**< in rows of memory */
600 uint32_t size
; /**< in bytes */
604 * @brief Input to surface initialization
606 * @invariant width >= 1
607 * @invariant height >= 1
608 * @invariant depth >= 1
609 * @invariant levels >= 1
610 * @invariant samples >= 1
611 * @invariant array_len >= 1
613 * @invariant if 1D then height == 1 and depth == 1 and samples == 1
614 * @invariant if 2D then depth == 1
615 * @invariant if 3D then array_len == 1 and samples == 1
617 struct isl_surf_init_info
{
618 enum isl_surf_dim dim
;
619 enum isl_format format
;
628 /** Lower bound for isl_surf::alignment, in bytes. */
629 uint32_t min_alignment
;
631 /** Lower bound for isl_surf::pitch, in bytes. */
634 isl_surf_usage_flags_t usage
;
636 /** Flags that alter how ISL selects isl_surf::tiling. */
637 isl_tiling_flags_t tiling_flags
;
641 enum isl_surf_dim dim
;
642 enum isl_dim_layout dim_layout
;
643 enum isl_msaa_layout msaa_layout
;
644 enum isl_tiling tiling
;
645 enum isl_format format
;
648 * Alignment of the upper-left sample of each LOD, in units of surface
651 struct isl_extent3d lod_alignment_el
;
654 * Logical extent of the surface's base level, in units of pixels. This is
655 * identical to the extent defined in isl_surf_init_info.
657 struct isl_extent4d logical_level0_px
;
660 * Physical extent of the surface's base level, in units of pixels.
662 * Consider isl_dim_layout as an operator that transforms a logical surface
663 * layout to a physical surface layout. Then
665 * logical_layout := (isl_surf::dim, isl_surf::logical_level0_px)
666 * isl_surf::phys_level0_sa := isl_surf::dim_layout * logical_layout
668 struct isl_extent4d phys_level0_sa
;
673 /** Total size of the surface, in bytes. */
676 /** Required alignment for the surface's base address. */
680 * Pitch between vertically adjacent samples, in bytes.
685 * Pitch between physical array slices, in rows of surface elements.
687 uint32_t array_pitch_el_rows
;
689 enum isl_array_pitch_span array_pitch_span
;
691 /** Copy of isl_surf_init_info::usage. */
692 isl_surf_usage_flags_t usage
;
695 extern const struct isl_format_layout isl_format_layouts
[];
698 isl_device_init(struct isl_device
*dev
,
699 const struct brw_device_info
*info
);
701 static inline const struct isl_format_layout
* ATTRIBUTE_CONST
702 isl_format_get_layout(enum isl_format fmt
)
704 return &isl_format_layouts
[fmt
];
708 isl_format_has_sint_channel(enum isl_format fmt
) ATTRIBUTE_CONST
;
711 isl_format_is_compressed(enum isl_format fmt
)
713 const struct isl_format_layout
*fmtl
= isl_format_get_layout(fmt
);
715 return fmtl
->txc
!= ISL_TXC_NONE
;
719 isl_format_has_bc_compression(enum isl_format fmt
)
721 switch (isl_format_get_layout(fmt
)->txc
) {
736 unreachable("bad texture compression mode");
741 isl_format_is_yuv(enum isl_format fmt
)
743 const struct isl_format_layout
*fmtl
= isl_format_get_layout(fmt
);
745 return fmtl
->colorspace
== ISL_COLORSPACE_YUV
;
749 isl_format_block_is_1x1x1(enum isl_format fmt
)
751 const struct isl_format_layout
*fmtl
= isl_format_get_layout(fmt
);
753 return fmtl
->bw
== 1 && fmtl
->bh
== 1 && fmtl
->bd
== 1;
757 isl_tiling_is_std_y(enum isl_tiling tiling
)
759 return (1u << tiling
) & ISL_TILING_STD_Y_MASK
;
763 isl_tiling_get_info(const struct isl_device
*dev
,
764 enum isl_tiling tiling
,
765 uint32_t format_block_size
,
766 struct isl_tile_info
*info
);
769 isl_tiling_get_extent(const struct isl_device
*dev
,
770 enum isl_tiling tiling
,
771 uint32_t format_block_size
,
772 struct isl_extent2d
*e
);
774 isl_surf_choose_tiling(const struct isl_device
*dev
,
775 const struct isl_surf_init_info
*restrict info
,
776 enum isl_tiling
*tiling
);
779 isl_surf_usage_is_display(isl_surf_usage_flags_t usage
)
781 return usage
& ISL_SURF_USAGE_DISPLAY_BIT
;
785 isl_surf_usage_is_depth(isl_surf_usage_flags_t usage
)
787 return usage
& ISL_SURF_USAGE_DEPTH_BIT
;
791 isl_surf_usage_is_stencil(isl_surf_usage_flags_t usage
)
793 return usage
& ISL_SURF_USAGE_STENCIL_BIT
;
797 isl_surf_usage_is_depth_and_stencil(isl_surf_usage_flags_t usage
)
799 return (usage
& ISL_SURF_USAGE_DEPTH_BIT
) &&
800 (usage
& ISL_SURF_USAGE_STENCIL_BIT
);
804 isl_surf_usage_is_depth_or_stencil(isl_surf_usage_flags_t usage
)
806 return usage
& (ISL_SURF_USAGE_DEPTH_BIT
| ISL_SURF_USAGE_STENCIL_BIT
);
810 isl_surf_info_is_z16(const struct isl_surf_init_info
*info
)
812 return (info
->usage
& ISL_SURF_USAGE_DEPTH_BIT
) &&
813 (info
->format
== ISL_FORMAT_R16_UNORM
);
817 isl_surf_info_is_z32_float(const struct isl_surf_init_info
*info
)
819 return (info
->usage
& ISL_SURF_USAGE_DEPTH_BIT
) &&
820 (info
->format
== ISL_FORMAT_R32_FLOAT
);
823 static inline struct isl_extent2d
824 isl_extent2d(uint32_t width
, uint32_t height
)
826 return (struct isl_extent2d
) { .w
= width
, .h
= height
};
829 static inline struct isl_extent3d
830 isl_extent3d(uint32_t width
, uint32_t height
, uint32_t depth
)
832 return (struct isl_extent3d
) { .w
= width
, .h
= height
, .d
= depth
};
835 static inline struct isl_extent4d
836 isl_extent4d(uint32_t width
, uint32_t height
, uint32_t depth
,
839 return (struct isl_extent4d
) {
847 #define isl_surf_init(dev, surf, ...) \
848 isl_surf_init_s((dev), (surf), \
849 &(struct isl_surf_init_info) { __VA_ARGS__ });
852 isl_surf_init_s(const struct isl_device
*dev
,
853 struct isl_surf
*surf
,
854 const struct isl_surf_init_info
*restrict info
);
857 * Alignment of the upper-left sample of each LOD, in units of surface
860 static inline struct isl_extent3d
861 isl_surf_get_lod_alignment_el(const struct isl_surf
*surf
)
863 return surf
->lod_alignment_el
;
867 * Alignment of the upper-left sample of each LOD, in units of surface
870 static inline struct isl_extent3d
871 isl_surf_get_lod_alignment_sa(const struct isl_surf
*surf
)
873 const struct isl_format_layout
*fmtl
= isl_format_get_layout(surf
->format
);
875 return (struct isl_extent3d
) {
876 .w
= fmtl
->bw
* surf
->lod_alignment_el
.w
,
877 .h
= fmtl
->bh
* surf
->lod_alignment_el
.h
,
878 .d
= fmtl
->bd
* surf
->lod_alignment_el
.d
,
883 * Pitch between physical array slices, in rows of surface elements.
885 static inline uint32_t
886 isl_surf_get_array_pitch_el_rows(const struct isl_surf
*surf
)
888 return surf
->array_pitch_el_rows
;
892 * Pitch between physical array slices, in rows of surface samples.
894 static inline uint32_t
895 isl_surf_get_array_pitch_sa_rows(const struct isl_surf
*surf
)
897 const struct isl_format_layout
*fmtl
= isl_format_get_layout(surf
->format
);
898 return fmtl
->bh
* isl_surf_get_array_pitch_el_rows(surf
);
902 * Pitch between physical array slices, in bytes.
904 static inline uint32_t
905 isl_surf_get_array_pitch(const struct isl_surf
*surf
)
907 return isl_surf_get_array_pitch_sa_rows(surf
) * surf
->row_pitch
;