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