2 * Copyright © 2014 Advanced Micro Devices, Inc.
5 * Permission is hereby granted, free of charge, to any person obtaining
6 * a copy of this software and associated documentation files (the
7 * "Software"), to deal in the Software without restriction, including
8 * without limitation the rights to use, copy, modify, merge, publish,
9 * distribute, sub license, and/or sell copies of the Software, and to
10 * permit persons to whom the Software is furnished to do so, subject to
11 * the following conditions:
13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
14 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
15 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
16 * NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS, AUTHORS
17 * AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20 * USE OR OTHER DEALINGS IN THE SOFTWARE.
22 * The above copyright notice and this permission notice (including the
23 * next paragraph) shall be included in all copies or substantial portions
28 ***************************************************************************************************
30 * @brief Contains the helper function and constants
31 ***************************************************************************************************
33 #ifndef __ADDR_TYPES_H__
34 #define __ADDR_TYPES_H__
36 #if defined(__APPLE__) && !defined(HAVE_TSERVER)
37 // External definitions header maintained by Apple driver team, but not for diag team under Mac.
38 // Helps address compilation issues & reduces code covered by NDA
39 #include "addrExtDef.h"
43 // Windows and/or Linux
60 #include <stdarg.h> // va_list...etc need this header
62 #endif // defined (__APPLE__) && !defined(HAVE_TSERVER)
65 ***************************************************************************************************
67 ***************************************************************************************************
71 #define ADDR_CDECL __attribute__((cdecl))
73 #define ADDR_CDECL __cdecl
79 #if defined(__AMD64__)
82 #define ADDR_STDCALL __attribute__((stdcall))
85 #define ADDR_STDCALL __stdcall
92 #define ADDR_FASTCALL __attribute__((regparm(0)))
97 #define ADDR_FASTCALL __fastcall
102 #define GC_CDECL ADDR_CDECL
106 #define GC_STDCALL ADDR_STDCALL
110 #define GC_FASTCALL ADDR_FASTCALL
114 #if defined(__GNUC__)
115 #define ADDR_INLINE static inline // inline needs to be static to link
117 // win32, win64, other platforms
118 #define ADDR_INLINE __inline
119 #endif // #if defined(__GNUC__)
121 #define ADDR_API ADDR_FASTCALL //default call convention is fast call
124 ***************************************************************************************************
125 * Global defines used by other modules
126 ***************************************************************************************************
128 #if !defined(TILEINDEX_INVALID)
129 #define TILEINDEX_INVALID -1
132 #if !defined(TILEINDEX_LINEAR_GENERAL)
133 #define TILEINDEX_LINEAR_GENERAL -2
136 #if !defined(TILEINDEX_LINEAR_ALIGNED)
137 #define TILEINDEX_LINEAR_ALIGNED 8
141 ***************************************************************************************************
143 ***************************************************************************************************
145 typedef enum _ADDR_E_RETURNCODE
156 ADDR_PARAMSIZEMISMATCH
,
157 ADDR_INVALIDGBREGVALUES
,
162 ***************************************************************************************************
164 * Neutral enums that define tile modes for all H/W
166 * R600/R800 tiling mode can be cast to hw enums directly but never cast into HW enum from
167 * ADDR_TM_2D_TILED_XTHICK
169 ***************************************************************************************************
171 typedef enum _AddrTileMode
173 ADDR_TM_LINEAR_GENERAL
= 0, ///< Least restrictions, pitch: multiple of 8 if not buffer
174 ADDR_TM_LINEAR_ALIGNED
= 1, ///< Requests pitch or slice to be multiple of 64 pixels
175 ADDR_TM_1D_TILED_THIN1
= 2, ///< Linear array of 8x8 tiles
176 ADDR_TM_1D_TILED_THICK
= 3, ///< Linear array of 8x8x4 tiles
177 ADDR_TM_2D_TILED_THIN1
= 4, ///< A set of macro tiles consist of 8x8 tiles
178 ADDR_TM_2D_TILED_THIN2
= 5, ///< 600 HWL only, macro tile ratio is 1:4
179 ADDR_TM_2D_TILED_THIN4
= 6, ///< 600 HWL only, macro tile ratio is 1:16
180 ADDR_TM_2D_TILED_THICK
= 7, ///< A set of macro tiles consist of 8x8x4 tiles
181 ADDR_TM_2B_TILED_THIN1
= 8, ///< 600 HWL only, with bank swap
182 ADDR_TM_2B_TILED_THIN2
= 9, ///< 600 HWL only, with bank swap and ratio is 1:4
183 ADDR_TM_2B_TILED_THIN4
= 10, ///< 600 HWL only, with bank swap and ratio is 1:16
184 ADDR_TM_2B_TILED_THICK
= 11, ///< 600 HWL only, with bank swap, consists of 8x8x4 tiles
185 ADDR_TM_3D_TILED_THIN1
= 12, ///< Macro tiling w/ pipe rotation between slices
186 ADDR_TM_3D_TILED_THICK
= 13, ///< Macro tiling w/ pipe rotation bwtween slices, thick
187 ADDR_TM_3B_TILED_THIN1
= 14, ///< 600 HWL only, with bank swap
188 ADDR_TM_3B_TILED_THICK
= 15, ///< 600 HWL only, with bank swap, thick
189 ADDR_TM_2D_TILED_XTHICK
= 16, ///< Tile is 8x8x8, valid from NI
190 ADDR_TM_3D_TILED_XTHICK
= 17, ///< Tile is 8x8x8, valid from NI
191 ADDR_TM_POWER_SAVE
= 18, ///< Power save mode, only used by KMD on NI
192 ADDR_TM_PRT_TILED_THIN1
= 19, ///< No bank/pipe rotation or hashing beyond macrotile size
193 ADDR_TM_PRT_2D_TILED_THIN1
= 20, ///< Same as 2D_TILED_THIN1, PRT only
194 ADDR_TM_PRT_3D_TILED_THIN1
= 21, ///< Same as 3D_TILED_THIN1, PRT only
195 ADDR_TM_PRT_TILED_THICK
= 22, ///< No bank/pipe rotation or hashing beyond macrotile size
196 ADDR_TM_PRT_2D_TILED_THICK
= 23, ///< Same as 2D_TILED_THICK, PRT only
197 ADDR_TM_PRT_3D_TILED_THICK
= 24, ///< Same as 3D_TILED_THICK, PRT only
198 ADDR_TM_COUNT
= 25, ///< Must be the value of the last tile mode
202 ***************************************************************************************************
206 * Neutral enum for SurfaceFormat
208 ***************************************************************************************************
210 typedef enum _AddrFormat
{
211 ADDR_FMT_INVALID
= 0x00000000,
212 ADDR_FMT_8
= 0x00000001,
213 ADDR_FMT_4_4
= 0x00000002,
214 ADDR_FMT_3_3_2
= 0x00000003,
215 ADDR_FMT_RESERVED_4
= 0x00000004,
216 ADDR_FMT_16
= 0x00000005,
217 ADDR_FMT_16_FLOAT
= 0x00000006,
218 ADDR_FMT_8_8
= 0x00000007,
219 ADDR_FMT_5_6_5
= 0x00000008,
220 ADDR_FMT_6_5_5
= 0x00000009,
221 ADDR_FMT_1_5_5_5
= 0x0000000a,
222 ADDR_FMT_4_4_4_4
= 0x0000000b,
223 ADDR_FMT_5_5_5_1
= 0x0000000c,
224 ADDR_FMT_32
= 0x0000000d,
225 ADDR_FMT_32_FLOAT
= 0x0000000e,
226 ADDR_FMT_16_16
= 0x0000000f,
227 ADDR_FMT_16_16_FLOAT
= 0x00000010,
228 ADDR_FMT_8_24
= 0x00000011,
229 ADDR_FMT_8_24_FLOAT
= 0x00000012,
230 ADDR_FMT_24_8
= 0x00000013,
231 ADDR_FMT_24_8_FLOAT
= 0x00000014,
232 ADDR_FMT_10_11_11
= 0x00000015,
233 ADDR_FMT_10_11_11_FLOAT
= 0x00000016,
234 ADDR_FMT_11_11_10
= 0x00000017,
235 ADDR_FMT_11_11_10_FLOAT
= 0x00000018,
236 ADDR_FMT_2_10_10_10
= 0x00000019,
237 ADDR_FMT_8_8_8_8
= 0x0000001a,
238 ADDR_FMT_10_10_10_2
= 0x0000001b,
239 ADDR_FMT_X24_8_32_FLOAT
= 0x0000001c,
240 ADDR_FMT_32_32
= 0x0000001d,
241 ADDR_FMT_32_32_FLOAT
= 0x0000001e,
242 ADDR_FMT_16_16_16_16
= 0x0000001f,
243 ADDR_FMT_16_16_16_16_FLOAT
= 0x00000020,
244 ADDR_FMT_RESERVED_33
= 0x00000021,
245 ADDR_FMT_32_32_32_32
= 0x00000022,
246 ADDR_FMT_32_32_32_32_FLOAT
= 0x00000023,
247 ADDR_FMT_RESERVED_36
= 0x00000024,
248 ADDR_FMT_1
= 0x00000025,
249 ADDR_FMT_1_REVERSED
= 0x00000026,
250 ADDR_FMT_GB_GR
= 0x00000027,
251 ADDR_FMT_BG_RG
= 0x00000028,
252 ADDR_FMT_32_AS_8
= 0x00000029,
253 ADDR_FMT_32_AS_8_8
= 0x0000002a,
254 ADDR_FMT_5_9_9_9_SHAREDEXP
= 0x0000002b,
255 ADDR_FMT_8_8_8
= 0x0000002c,
256 ADDR_FMT_16_16_16
= 0x0000002d,
257 ADDR_FMT_16_16_16_FLOAT
= 0x0000002e,
258 ADDR_FMT_32_32_32
= 0x0000002f,
259 ADDR_FMT_32_32_32_FLOAT
= 0x00000030,
260 ADDR_FMT_BC1
= 0x00000031,
261 ADDR_FMT_BC2
= 0x00000032,
262 ADDR_FMT_BC3
= 0x00000033,
263 ADDR_FMT_BC4
= 0x00000034,
264 ADDR_FMT_BC5
= 0x00000035,
265 ADDR_FMT_BC6
= 0x00000036,
266 ADDR_FMT_BC7
= 0x00000037,
267 ADDR_FMT_32_AS_32_32_32_32
= 0x00000038,
268 ADDR_FMT_APC3
= 0x00000039,
269 ADDR_FMT_APC4
= 0x0000003a,
270 ADDR_FMT_APC5
= 0x0000003b,
271 ADDR_FMT_APC6
= 0x0000003c,
272 ADDR_FMT_APC7
= 0x0000003d,
273 ADDR_FMT_CTX1
= 0x0000003e,
274 ADDR_FMT_RESERVED_63
= 0x0000003f,
278 ***************************************************************************************************
282 * Neutral enum for addrFlt32ToDepthPixel
284 ***************************************************************************************************
286 typedef enum _AddrDepthFormat
288 ADDR_DEPTH_INVALID
= 0x00000000,
289 ADDR_DEPTH_16
= 0x00000001,
290 ADDR_DEPTH_X8_24
= 0x00000002,
291 ADDR_DEPTH_8_24
= 0x00000003,
292 ADDR_DEPTH_X8_24_FLOAT
= 0x00000004,
293 ADDR_DEPTH_8_24_FLOAT
= 0x00000005,
294 ADDR_DEPTH_32_FLOAT
= 0x00000006,
295 ADDR_DEPTH_X24_8_32_FLOAT
= 0x00000007,
300 ***************************************************************************************************
304 * Neutral enum for ColorFormat
306 ***************************************************************************************************
308 typedef enum _AddrColorFormat
310 ADDR_COLOR_INVALID
= 0x00000000,
311 ADDR_COLOR_8
= 0x00000001,
312 ADDR_COLOR_4_4
= 0x00000002,
313 ADDR_COLOR_3_3_2
= 0x00000003,
314 ADDR_COLOR_RESERVED_4
= 0x00000004,
315 ADDR_COLOR_16
= 0x00000005,
316 ADDR_COLOR_16_FLOAT
= 0x00000006,
317 ADDR_COLOR_8_8
= 0x00000007,
318 ADDR_COLOR_5_6_5
= 0x00000008,
319 ADDR_COLOR_6_5_5
= 0x00000009,
320 ADDR_COLOR_1_5_5_5
= 0x0000000a,
321 ADDR_COLOR_4_4_4_4
= 0x0000000b,
322 ADDR_COLOR_5_5_5_1
= 0x0000000c,
323 ADDR_COLOR_32
= 0x0000000d,
324 ADDR_COLOR_32_FLOAT
= 0x0000000e,
325 ADDR_COLOR_16_16
= 0x0000000f,
326 ADDR_COLOR_16_16_FLOAT
= 0x00000010,
327 ADDR_COLOR_8_24
= 0x00000011,
328 ADDR_COLOR_8_24_FLOAT
= 0x00000012,
329 ADDR_COLOR_24_8
= 0x00000013,
330 ADDR_COLOR_24_8_FLOAT
= 0x00000014,
331 ADDR_COLOR_10_11_11
= 0x00000015,
332 ADDR_COLOR_10_11_11_FLOAT
= 0x00000016,
333 ADDR_COLOR_11_11_10
= 0x00000017,
334 ADDR_COLOR_11_11_10_FLOAT
= 0x00000018,
335 ADDR_COLOR_2_10_10_10
= 0x00000019,
336 ADDR_COLOR_8_8_8_8
= 0x0000001a,
337 ADDR_COLOR_10_10_10_2
= 0x0000001b,
338 ADDR_COLOR_X24_8_32_FLOAT
= 0x0000001c,
339 ADDR_COLOR_32_32
= 0x0000001d,
340 ADDR_COLOR_32_32_FLOAT
= 0x0000001e,
341 ADDR_COLOR_16_16_16_16
= 0x0000001f,
342 ADDR_COLOR_16_16_16_16_FLOAT
= 0x00000020,
343 ADDR_COLOR_RESERVED_33
= 0x00000021,
344 ADDR_COLOR_32_32_32_32
= 0x00000022,
345 ADDR_COLOR_32_32_32_32_FLOAT
= 0x00000023,
349 ***************************************************************************************************
353 * Neutral enum for SurfaceNumber
355 ***************************************************************************************************
357 typedef enum _AddrSurfaceNumber
{
358 ADDR_NUMBER_UNORM
= 0x00000000,
359 ADDR_NUMBER_SNORM
= 0x00000001,
360 ADDR_NUMBER_USCALED
= 0x00000002,
361 ADDR_NUMBER_SSCALED
= 0x00000003,
362 ADDR_NUMBER_UINT
= 0x00000004,
363 ADDR_NUMBER_SINT
= 0x00000005,
364 ADDR_NUMBER_SRGB
= 0x00000006,
365 ADDR_NUMBER_FLOAT
= 0x00000007,
369 ***************************************************************************************************
373 * Neutral enum for SurfaceSwap
375 ***************************************************************************************************
377 typedef enum _AddrSurfaceSwap
{
378 ADDR_SWAP_STD
= 0x00000000,
379 ADDR_SWAP_ALT
= 0x00000001,
380 ADDR_SWAP_STD_REV
= 0x00000002,
381 ADDR_SWAP_ALT_REV
= 0x00000003,
385 ***************************************************************************************************
389 * Size of HTILE blocks, valid values are 4 or 8 for now
390 ***************************************************************************************************
392 typedef enum _AddrHtileBlockSize
394 ADDR_HTILE_BLOCKSIZE_4
= 4,
395 ADDR_HTILE_BLOCKSIZE_8
= 8,
396 } AddrHtileBlockSize
;
400 ***************************************************************************************************
404 * The pipe configuration field specifies both the number of pipes and
405 * how pipes are interleaved on the surface.
406 * The expression of number of pipes, the shader engine tile size, and packer tile size
407 * is encoded in a PIPE_CONFIG register field.
408 * In general the number of pipes usually matches the number of memory channels of the
409 * hardware configuration.
410 * For hw configurations w/ non-pow2 memory number of memory channels, it usually matches
411 * the number of ROP units(? TODO: which registers??)
412 * The enum value = hw enum + 1 which is to reserve 0 for requesting default.
413 ***************************************************************************************************
415 typedef enum _AddrPipeCfg
417 ADDR_PIPECFG_INVALID
= 0,
418 ADDR_PIPECFG_P2
= 1, /// 2 pipes,
419 ADDR_PIPECFG_P4_8x16
= 5, /// 4 pipes,
420 ADDR_PIPECFG_P4_16x16
= 6,
421 ADDR_PIPECFG_P4_16x32
= 7,
422 ADDR_PIPECFG_P4_32x32
= 8,
423 ADDR_PIPECFG_P8_16x16_8x16
= 9, /// 8 pipes
424 ADDR_PIPECFG_P8_16x32_8x16
= 10,
425 ADDR_PIPECFG_P8_32x32_8x16
= 11,
426 ADDR_PIPECFG_P8_16x32_16x16
= 12,
427 ADDR_PIPECFG_P8_32x32_16x16
= 13,
428 ADDR_PIPECFG_P8_32x32_16x32
= 14,
429 ADDR_PIPECFG_P8_32x64_32x32
= 15,
430 ADDR_PIPECFG_P16_32x32_8x16
= 17, /// 16 pipes
431 ADDR_PIPECFG_P16_32x32_16x16
= 18,
432 ADDR_PIPECFG_MAX
= 19,
436 ***************************************************************************************************
440 * Neutral enums that specifies micro tile type (MICRO_TILE_MODE)
441 ***************************************************************************************************
443 typedef enum _AddrTileType
445 ADDR_DISPLAYABLE
= 0, ///< Displayable tiling
446 ADDR_NON_DISPLAYABLE
= 1, ///< Non-displayable tiling, a.k.a thin micro tiling
447 ADDR_DEPTH_SAMPLE_ORDER
= 2, ///< Same as non-displayable plus depth-sample-order
448 ADDR_ROTATED
= 3, ///< Rotated displayable tiling
449 ADDR_THICK
= 4, ///< Thick micro-tiling, only valid for THICK and XTHICK
452 ///////////////////////////////////////////////////////////////////////////////////////////////////
454 // Type definitions: short system-independent names for address library types
456 ///////////////////////////////////////////////////////////////////////////////////////////////////
458 #if !defined(__APPLE__) || defined(HAVE_TSERVER)
460 #ifndef BOOL_32 // no bool type in C
461 /// @brief Boolean type, since none is defined in C
471 #define UINT_32 unsigned int
479 #define UINT_16 unsigned short
487 #define UINT_8 unsigned char
503 // 64-bit integer types depend on the compiler
505 #if defined( __GNUC__ ) || defined( __WATCOMC__ )
506 #define INT_64 long long
507 #define UINT_64 unsigned long long
509 #elif defined( _WIN32 )
510 #define INT_64 __int64
511 #define UINT_64 unsigned __int64
514 #error Unsupported compiler and/or operating system for 64-bit integers
516 /// @brief 64-bit signed integer type (compiler dependent)
519 /// The addrlib defines a 64-bit signed integer type for either
520 /// Gnu/Watcom compilers (which use the first syntax) or for
521 /// the Windows VCC compiler (which uses the second syntax).
522 #define INT_64 long long OR __int64
524 /// @brief 64-bit unsigned integer type (compiler dependent)
527 /// The addrlib defines a 64-bit unsigned integer type for either
528 /// Gnu/Watcom compilers (which use the first syntax) or for
529 /// the Windows VCC compiler (which uses the second syntax).
531 #define UINT_64 unsigned long long OR unsigned __int64
534 #endif // #if !defined(__APPLE__) || defined(HAVE_TSERVER)
536 // ADDR64X is used to print addresses in hex form on both Windows and Linux
538 #if defined( __GNUC__ ) || defined( __WATCOMC__ )
539 #define ADDR64X "llx"
540 #define ADDR64D "lld"
542 #elif defined( _WIN32 )
543 #define ADDR64X "I64x"
544 #define ADDR64D "I64d"
547 #error Unsupported compiler and/or operating system for 64-bit integers
549 /// @brief Addrlib device address 64-bit printf tag (compiler dependent)
552 /// This allows printf to display an ADDR_64 for either the Windows VCC compiler
553 /// (which used this value) or the Gnu/Watcom compilers (which use "llx".
554 /// An example of use is printf("addr 0x%"ADDR64X"\n", address);
556 #define ADDR64X "llx" OR "I64x"
557 #define ADDR64D "lld" OR "I64d"
561 /// @brief Union for storing a 32-bit float or 32-bit integer
564 /// This union provides a simple way to convert between a 32-bit float
565 /// and a 32-bit integer. It also prevents the compiler from producing
566 /// code that alters NaN values when assiging or coying floats.
567 /// Therefore, all address library routines that pass or return 32-bit
568 /// floating point data do so by passing or returning a FLT_32.
577 ///////////////////////////////////////////////////////////////////////////////////////////////////
579 // Macros for controlling linking and building on multiple systems
581 ///////////////////////////////////////////////////////////////////////////////////////////////////
582 #if defined(_MSC_VER)
584 #undef va_copy //redefine va_copy to support VC2013
588 #if !defined(va_copy)
589 #define va_copy(dst, src) \
590 ((void) memcpy(&(dst), &(src), sizeof(va_list)))
593 #endif // __ADDR_TYPES_H__