Debian Codegraph @

media_common/agnostic/common/os/mos_resource_defs.h

raw
1 /*
2 * Copyright (c) 2009-2020, Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included
12 * in all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
21 */
22 //!
23 //! \file mos_resource_defs.h
24 //! \brief
25 //!
26 //!
27 //! \file mos_resource_defs.h
28 //! \brief Defines and enums used by os resource
29 //! \details Defines and enums used by os resource
30 //!
31
32 #ifndef __MOS_RESOURCE_DEFS_H__
33 #define __MOS_RESOURCE_DEFS_H__
34
35 //!
36 //! \brief Enum for Surface Format (for sampling)
37 //!
38 typedef enum _MOS_FORMAT
39 {
40 Format_Invalid = -14, //!< Invalid format
41 Format_Source = -13, //!< Current source format
42
43 // Generic Formats
44 Format_420O = -12, //!< Generic Render Target Format (NV12, IMC3, 422H, 422V, 411P, 444P, RGBP, BGRP, 400P)
45 Format_RGB_Swap = -11, //!< RGB Formats need HW Channel swap (A8R8G8B8, X8R8G8B8)
46 Format_RGB_No_Swap = -10, //!< RGB Formats don't need HW Channel swap (A8B8G8R8)
47 Format_RGB = -9, //!< Generic RGB input (A8R8G8B, X8R8G8B8, R5G6B5)
48 Format_RGB32 = -8, //!< Generic RGB32 input (A8R8G8B, X8R8G8B8)
49 Format_PA = -7, //!< Generic packed YUV input (YUY2, YUYV, YVYU, UYVY, VYUY)
50 Format_PL2 = -6, //!< Hybrid YUV input (NV12, NV11, P208)
51 Format_PL2_UnAligned = -5, //!< Width or Height is not a multiple of 4
52 Format_PL3 = -4, //!< Planar YUV input (IMC1, IMC2, IMC3, IMC4)
53 Format_PL3_RGB = -3, //!< Planar RGB input (RGBP, BGRP)
54 Format_PAL = -2, //!< Generic Palletized input (AI44, IA44, P8)
55
56 // Auxiliary Formats
57 Format_None = -1, //!< No format (colorfill)
58 Format_Any = 0, //!< Any format
59
60 // RGB formats
61 Format_A8R8G8B8 , //!< ARGB 32bpp (A = 255)
62 Format_X8R8G8B8 , //!< XRGB 32bpp (X = 0)
63 Format_A8B8G8R8 , //!< ABGR 32bpp
64 Format_X8B8G8R8 , //!< XBGR 32bpp
65 Format_A16B16G16R16, //!< ABGR 64bpp
66 Format_A16R16G16B16, //!< ARGB 64bpp
67 Format_R5G6B5 , //!< RGB 16bpp
68 Format_R32U , //!< R32U 32bpp
69 Format_R32F , //!< R32F 32bpp
70 Format_R8G8B8 , //!< RGB 24bpp
71
72 // Planar RGB formats
73 Format_RGBP , //!< R Plane, G Plane, B Plane
74 Format_BGRP , //!< B Plane, G Plane, R Plane
75
76 // YUV packed 4:2:2 formats
77 Format_YUY2 ,
78 Format_YUYV ,
79 Format_YVYU ,
80 Format_UYVY ,
81 Format_VYUY ,
82 Format_Y216 , //422 16bit
83 Format_Y210 , //422 10bit
84 // YUV packed 4:4:4 formats
85 Format_Y416 ,
86 Format_AYUV ,
87 Format_AUYV ,
88 Format_Y410 , //444 10bit
89
90 // Gray scale image with only Y plane
91 Format_400P ,
92
93 // YUV PL2 formats
94 Format_NV12 ,
95 Format_NV12_UnAligned ,
96 Format_NV21 ,
97 Format_NV11 ,
98 Format_NV11_UnAligned ,
99 Format_P208 ,
100 Format_P208_UnAligned ,
101
102 // YUV PL3 formats
103 Format_IMC1 ,
104 Format_IMC2 ,
105 Format_IMC3 ,
106 Format_IMC4 ,
107 Format_422H ,
108 Format_422V ,
109 Format_444P ,
110 Format_411P ,
111 Format_411R ,
112 Format_I420 ,
113 Format_IYUV ,
114 Format_YV12 ,
115 Format_YVU9 ,
116
117 // Palletized formats (RGB/YUV)
118 Format_AI44 ,
119 Format_IA44 ,
120 Format_P8 ,
121 Format_A8P8 ,
122
123 // Alpha + Intensity
124 Format_A8 ,
125 Format_L8 ,
126 Format_A4L4 ,
127 Format_A8L8 ,
128
129 // Bayer
130 Format_IRW0 , //!< BGGR 10/12 bit depth [16bit aligned]
131 Format_IRW1 , //!< RGGB 10/12 bit depth [16bit aligned]
132 Format_IRW2 , //!< GRBG 10/12 bit depth [16bit aligned]
133 Format_IRW3 , //!< GBRG 10/12 bit depth [16bit aligned]
134 Format_IRW4 , //!< BGGR 8 bit depth
135 Format_IRW5 , //!< RGGB 8 bit depth
136 Format_IRW6 , //!< GRBG 8 bit depth
137 Format_IRW7 , //!< GBRG 8 bit depth
138
139 Format_STMM,
140
141 Format_Buffer , //!< Used for creating buffer resource (linear)
142 Format_Buffer_2D , //!< Encoder 2D linear buffer.
143
144 Format_V8U8 ,
145
146 Format_R32S , //!< R32S 32bpp
147 Format_R8U , //!< R8 Uint
148 Format_R8G8UN , //!< R8G8 UNorm
149 Format_R8G8SN , //!< R8G8 SNorm
150 Format_G8R8_G8B8 ,
151 Format_R16U ,
152 Format_R16S ,
153 Format_R16UN , //!< R16_UNorm
154 Format_RAW , //!< HW RAW format
155
156 Format_Y8 , // R16F 16bpp
157 Format_Y1 , // R16F 16bpp
158 Format_Y16U , // R16F 16bpp
159 Format_Y16S , // R16F 16bpp
160
161 Format_L16 ,
162 Format_D16 ,
163 Format_R10G10B10A2 , //Memory layout: [A(2) | B(10) | G(10) | R(10)], where A is the highest order bits
164 Format_B10G10R10A2 , //Memory layout: [A(2) | R(10) | G(10) | B(10)], where A is the highest order bits
165
166 Format_P016 ,
167 Format_P010 ,
168 Format_YV12_Planar ,
169 Format_A16B16G16R16F, //!< ABGR 64bpp
170 Format_R16G16UN ,
171 Format_R16F ,
172 Format_P210 ,
173 Format_P216 ,
174 Format_A16R16G16B16F, //!< ARGB 64bpp
175 Format_YUY2V ,
176 Format_Y216V ,
177 Format_D32F ,
178 Format_D24S8UN ,
179 Format_D32S8X24_FLOAT ,
180
181 Format_R16 ,
182 Format_R16G16S ,
183 Format_R24G8 ,
184 Format_R32 ,
185 Format_R32G8X24 ,
186 Format_R8UN , //!< R8 UNORM
187 Format_R32G32B32A32F, //ARGB 128bpp
188 Format_G32R32F , // G32R32 64 bpp
189 Format_R16G16F ,
190 // Last Format
191 Format_Count
192 } MOS_FORMAT, *PMOS_FORMAT;
193 C_ASSERT(Format_Count == 105); //!< When adding, update assert & vphal_solo_scenario.cpp::VpFromXml_GetFormat() & hal_kerneldll.c::g_cIsFormatYUV.
194
195 //!
196 //! \brief Macros for format checking
197 //!
198 #define IS_PAL_FORMAT(format) \
199 ( (format == Format_AI44) || \
200 (format == Format_IA44) || \
201 (format == Format_P8) || \
202 (format == Format_A8P8))
203
204 #define CASE_PAL_FORMAT \
205 case Format_AI44: \
206 case Format_IA44: \
207 case Format_P8: \
208 case Format_A8P8
209
210 #define IS_ALPHA4_FORMAT(format) \
211 ( (format == Format_AI44) || \
212 (format == Format_IA44) )
213
214 #define IS_ALPHA_FORMAT_RGB8(format) \
215 ( (format == Format_A8R8G8B8) || \
216 (format == Format_A8B8G8R8) )
217
218 #define IS_ALPHA_FORMAT_RGB10(format) \
219 ( (format == Format_R10G10B10A2) || \
220 (format == Format_B10G10R10A2) )
221
222 #define IS_ALPHA_FORMAT_RGB16(format) \
223 ( (format == Format_A16B16G16R16) || \
224 (format == Format_A16R16G16B16) || \
225 (format == Format_A16B16G16R16F) || \
226 (format == Format_A16R16G16B16F) )
227
228 #define IS_ALPHA_FORMAT_YUV(format) \
229 ( (format == Format_Y410) || \
230 (format == Format_Y416) || \
231 (format == Format_AYUV) )
232
233 #define IS_ALPHA_FORMAT(format) \
234 ( IS_ALPHA_FORMAT_RGB8(format) || \
235 IS_ALPHA_FORMAT_RGB10(format) || \
236 IS_ALPHA_FORMAT_RGB16(format) || \
237 IS_ALPHA_FORMAT_YUV(format) )
238
239 #define IS_PL2_FORMAT(format) \
240 ( (format == Format_PL2) || \
241 (format == Format_NV12) || \
242 (format == Format_NV21) || \
243 (format == Format_NV11) || \
244 (format == Format_P208) || \
245 (format == Format_P010) || \
246 (format == Format_P016) )
247
248 #define IS_PL2_FORMAT_UnAligned(format) \
249 ( (format == Format_PL2_UnAligned) || \
250 (format == Format_NV12_UnAligned) || \
251 (format == Format_NV11_UnAligned) || \
252 (format == Format_P208_UnAligned) )
253
254 #define CASE_PL2_FORMAT \
255 case Format_PL2: \
256 case Format_NV12: \
257 case Format_NV21: \
258 case Format_NV11: \
259 case Format_P208: \
260 case Format_P010: \
261 case Format_P016
262
263 #define IS_PL3_FORMAT(format) \
264 ( (format == Format_PL3) || \
265 (format == Format_IMC1) || \
266 (format == Format_IMC2) || \
267 (format == Format_IMC3) || \
268 (format == Format_IMC4) || \
269 (format == Format_I420) || \
270 (format == Format_IYUV) || \
271 (format == Format_YV12) || \
272 (format == Format_YVU9) || \
273 (format == Format_422H) || \
274 (format == Format_422V) || \
275 (format == Format_411P) || \
276 (format == Format_411R) || \
277 (format == Format_444P) )
278
279 #define IS_PL3_RGB_FORMAT(format) \
280 ( (format == Format_RGBP) || \
281 (format == Format_BGRP) )
282
283 #define CASE_PL3_FORMAT \
284 case Format_PL3: \
285 case Format_IMC1: \
286 case Format_IMC2: \
287 case Format_IMC3: \
288 case Format_IMC4: \
289 case Format_I420: \
290 case Format_IYUV: \
291 case Format_YV12: \
292 case Format_YVU9: \
293 case Format_422H: \
294 case Format_422V: \
295 case Format_411P: \
296 case Format_411R: \
297 case Format_444P
298
299 #define CASE_PL3_RGB_FORMAT \
300 case Format_RGBP: \
301 case Format_BGRP
302
303 #define IS_PA_FORMAT(format) \
304 ( (format == Format_PA) || \
305 (format == Format_YUY2) || \
306 (format == Format_YUYV) || \
307 (format == Format_YVYU) || \
308 (format == Format_UYVY) || \
309 (format == Format_VYUY) || \
310 (format == Format_Y210) || \
311 (format == Format_Y216) || \
312 (format == Format_Y410) || \
313 (format == Format_Y416) )
314
315 #define CASE_PA_FORMAT \
316 case Format_PA: \
317 case Format_YUY2: \
318 case Format_YUYV: \
319 case Format_YVYU: \
320 case Format_UYVY: \
321 case Format_VYUY
322
323 #define IS_YUV_FORMAT(format) \
324 ( IS_PL2_FORMAT(format) || \
325 IS_PL3_FORMAT(format) || \
326 IS_PA_FORMAT(format) || \
327 (format == Format_400P) )
328
329 #define IS_ALPHA_YUV_FORMAT(format) \
330 ( (format == Format_AYUV) || \
331 (format == Format_AUYV) )
332
333 #define CASE_YUV_FORMAT \
334 CASE_PL2_FORMAT: \
335 CASE_PL3_FORMAT: \
336 CASE_PA_FORMAT: \
337 case Format_400P
338
339 #define IS_RGB64_FLOAT_FORMAT(format) \
340 ( (format == Format_A16B16G16R16F) || \
341 (format == Format_A16R16G16B16F) )
342
343 #define IS_RGB64_FORMAT(format) \
344 ( (format == Format_A16B16G16R16) || \
345 (format == Format_A16R16G16B16))
346
347 #define IS_RGB32_FORMAT(format) \
348 ( (format == Format_A8R8G8B8) || \
349 (format == Format_X8R8G8B8) || \
350 (format == Format_A8B8G8R8) || \
351 (format == Format_X8B8G8R8) || \
352 (format == Format_R10G10B10A2) || \
353 (format == Format_B10G10R10A2) || \
354 (format == Format_RGB32) )
355
356 #define IS_RGB16_FORMAT(format) \
357 (format == Format_R5G6B5)
358
359 #define IS_RGB24_FORMAT(format) \
360 (format == Format_R8G8B8)
361
362 #define IS_RGB_FORMAT(format) \
363 ( IS_RGB64_FORMAT(format) || \
364 IS_RGB32_FORMAT(format) || \
365 IS_RGB16_FORMAT(format) || \
366 IS_RGB24_FORMAT(format) || \
367 IS_PL3_RGB_FORMAT(format) || \
368 (format == Format_RGB) || \
369 IS_RGB64_FLOAT_FORMAT(format) )
370
371 #define IS_RGB_NO_SWAP(format) \
372 ( (format == Format_A8B8G8R8) || \
373 (format == Format_X8B8G8R8) || \
374 (format == Format_A16B16G16R16) || \
375 (format == Format_A16B16G16R16F) || \
376 (format == Format_R32G32B32A32F) || \
377 (format == Format_R10G10B10A2) )
378
379 #define IS_RGB_SWAP(format) \
380 ( IS_RGB_FORMAT(format) && \
381 !(IS_RGB_NO_SWAP(format)) )
382
383 #define IS_RGB128_FORMAT(format) \
384 (format == Format_R32G32B32A32F)
385
386 #define CASE_RGB32_FORMAT \
387 case Format_A8R8G8B8: \
388 case Format_X8R8G8B8: \
389 case Format_A8B8G8R8: \
390 case Format_X8B8G8R8: \
391 case Format_R10G10B10A2: \
392 case Format_B10G10R10A2: \
393 case Format_RGB32
394
395 #define CASE_RGB24_FORMAT \
396 case Format_R8G8B8
397
398 #define CASE_RGB16_FORMAT \
399 case Format_R5G6B5
400
401 #define CASE_RGB_FORMAT \
402 CASE_RGB32_FORMAT: \
403 CASE_RGB24_FORMAT: \
404 CASE_RGB16_FORMAT: \
405 CASE_PL3_RGB_FORMAT: \
406 case Format_RGB
407
408 #define IS_BT601_CSPACE(format) \
409 ( (format == CSpace_BT601) || \
410 (format == CSpace_xvYCC601) || \
411 (format == CSpace_BT601Gray) || \
412 (format == CSpace_BT601_FullRange) || \
413 (format == CSpace_BT601Gray_FullRange) )
414
415 #define IS_BT709_CSPACE(format) \
416 ( (format == CSpace_BT709) || \
417 (format == CSpace_xvYCC709) || \
418 (format == CSpace_BT709_FullRange) )
419
420 #define IS_YUV_CSPACE_FULLRANGE(format) \
421 ( (format == CSpace_BT601_FullRange) || \
422 (format == CSpace_BT601Gray_FullRange) || \
423 (format == CSpace_BT709_FullRange) )
424
425 #define CASE_YUV_CSPACE_FULLRANGE \
426 case CSpace_BT601_FullRange: \
427 case CSpace_BT601Gray_FullRange: \
428 case CSpace_BT709_FullRange
429
430 #define CASE_YUV_CSPACE_LIMITEDRANGE \
431 case CSpace_BT601: \
432 case CSpace_BT601Gray: \
433 case CSpace_xvYCC601: \
434 case CSpace_BT709: \
435 case CSpace_xvYCC709
436
437 #define IS_RGB_CSPACE_FULLRANGE(format) \
438 ( (format == CSpace_sRGB) )
439
440 #define IS_YUV_CSPACE(format) \
441 ( IS_BT601_CSPACE(format) || \
442 IS_BT709_CSPACE(format) )
443
444 #define IS_RGB_CSPACE(format) \
445 ( (format == CSpace_sRGB) || \
446 (format == CSpace_stRGB) )
447
448 #define IS_BAYER16_FORMAT(format) \
449 ( (format == Format_IRW0) || \
450 (format == Format_IRW1) || \
451 (format == Format_IRW2) || \
452 (format == Format_IRW3) )
453
454 #define CASE_BAYER16_FORMAT \
455 case Format_IRW0: \
456 case Format_IRW1: \
457 case Format_IRW2: \
458 case Format_IRW3
459
460 #define IS_BAYER8_FORMAT(format) \
461 ( (format == Format_IRW4) || \
462 (format == Format_IRW5) || \
463 (format == Format_IRW6) || \
464 (format == Format_IRW7) )
465
466 #define CASE_BAYER8_FORMAT \
467 case Format_IRW4: \
468 case Format_IRW5: \
469 case Format_IRW6: \
470 case Format_IRW7
471
472 #define IS_BAYER_FORMAT(format) \
473 ( IS_BAYER16_FORMAT(format) || \
474 IS_BAYER8_FORMAT(format) )
475
476 #define IS_BAYER_GRBG_FORMAT(format) \
477 ( (format == Format_IRW2) || \
478 (format == Format_IRW6) )
479
480 #define IS_BAYER_GBRG_FORMAT(format) \
481 ( (format == Format_IRW3) || \
482 (format == Format_IRW7) )
483
484 //!
485 //! \brief Tiling Enumeration, match GFX3DSTATE_TILEWALK
486 //!
487 #define MOS_YTILE_H_ALIGNMENT 32 // For Tile-Y and Tile-Yf
488 #define MOS_YTILE_W_ALIGNMENT 128
489 #define MOS_XTILE_H_ALIGNMENT 8
490 #define MOS_XTILE_W_ALIGNMENT 512
491 #define MOS_YSTILE_H_ALIGNMENT 256 // For Tile-Ys
492 #define MOS_YSTILE_W_ALIGNMENT 256
493
494 //!
495 //! \brief Enum for tile type
496 //!
497 typedef enum _MOS_TILE_TYPE
498 {
499 MOS_TILE_X,
500 MOS_TILE_Y,
501 MOS_TILE_YF, // 4KB tile
502 MOS_TILE_YS, // 64KB tile
503 MOS_TILE_LINEAR,
504 MOS_TILE_INVALID
505 } MOS_TILE_TYPE;
506 C_ASSERT(MOS_TILE_LINEAR == 4); //!< When adding, update assert
507
508 //!
509 //! \brief Enum for tile mode from GMM
510 //!
511 typedef enum _MOS_TILE_MODE_GMM : uint8_t
512 {
513 MOS_TILE_LINEAR_GMM = 0,
514 MOS_TILE_64_GMM,
515 MOS_TILE_X_GMM,
516 MOS_TILE_4_GMM,
517 MOS_TILE_UNSET_GMM
518 } MOS_TILE_MODE_GMM;
519 C_ASSERT(MOS_TILE_4_GMM == 3);
520
521 #define IS_TILE_FORMAT(TileType) \
522 ( (MOS_TILE_X == TileType) || \
523 (MOS_TILE_Y == TileType) || \
524 (MOS_TILE_YF == TileType) || \
525 (MOS_TILE_YS == TileType) )
526
527 #define IS_Y_MAJOR_TILE_FORMAT(TileType) \
528 ( (MOS_TILE_Y == TileType) || \
529 (MOS_TILE_YF == TileType) || \
530 (MOS_TILE_YS == TileType) )
531
532 //!
533 //! \brief Structure to resource type
534 //!
535 typedef enum _MOS_GFXRES_TYPE
536 {
537 MOS_GFXRES_INVALID = -1,
538 MOS_GFXRES_BUFFER, //!< Think malloc. This resource is a series of bytes. Is not 2 dimensional.
539 MOS_GFXRES_1D,
540 MOS_GFXRES_2D, //!< 2 dimensional resource w/ width and height. 1D is a subset of 2D.
541 MOS_GFXRES_VOLUME, //!< 3 dimensional resource w/ depth.
542 MOS_GFXRES_SCRATCH, //!< scratch space buffer.
543 } MOS_GFXRES_TYPE;
544
545 //!
546 //! \brief Enum for Memory Compression Mode
547 //!
548 typedef enum _MOS_RESOURCE_MMC_MODE
549 {
550 MOS_MMC_DISABLED,
551 MOS_MMC_HORIZONTAL,
552 MOS_MMC_VERTICAL,
553 MOS_MMC_MC,
554 MOS_MMC_RC
555 } MOS_RESOURCE_MMC_MODE;
556
557 enum Mos_MemPool
558 {
559 MOS_MEMPOOL_VIDEOMEMORY, //Default setting, Resource will be in video memory
560 MOS_MEMPOOL_DEVICEMEMORY, //Resource will be in device video memory
561 MOS_MEMPOOL_SYSTEMMEMORY //Resource will be in system video memory
562 };
563
564 #endif //__MOS_RESOURCE_DEFS_H__