1 /****************************************************************************
3 * Copyright (C) 2005 - 2013 by Vivante Corp.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the license, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 *****************************************************************************/
22 #ifndef __gc_hal_types_h_
23 #define __gc_hal_types_h_
25 #include "gc_hal_version.h"
26 #include "gc_hal_options.h"
29 #pragma warning(disable:4127) /* Conditional expression is constant (do { }
31 #pragma warning(disable:4100) /* Unreferenced formal parameter. */
32 #pragma warning(disable:4204) /* Non-constant aggregate initializer (C99). */
33 #pragma warning(disable:4131) /* Uses old-style declarator (for Bison and
34 ** Flex generated files). */
35 #pragma warning(disable:4206) /* Translation unit is empty. */
42 /******************************************************************************\
47 # define gcdHAS_ELLIPSES 1 /* GCC always has it. */
48 #elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
49 # define gcdHAS_ELLIPSES 1 /* C99 has it. */
50 #elif defined(_MSC_VER) && (_MSC_VER >= 1500)
51 # define gcdHAS_ELLIPSES 1 /* MSVC 2007+ has it. */
52 #elif defined(UNDER_CE)
54 # define gcdHAS_ELLIPSES 1
56 # define gcdHAS_ELLIPSES 0
59 # error "gcdHAS_ELLIPSES: Platform could not be determined"
62 /******************************************************************************\
63 ************************************ Keyword ***********************************
64 \******************************************************************************/
66 #if (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L))
67 # define gcmINLINE inline /* C99 keyword. */
68 #elif defined(__GNUC__)
69 # define gcmINLINE __inline__ /* GNU keyword. */
70 #elif defined(_MSC_VER) || defined(UNDER_CE)
71 # define gcmINLINE __inline /* Internal keyword. */
73 # error "gcmINLINE: Platform could not be determined"
76 /* Possible debug flags. */
77 #define gcdDEBUG_NONE 0
78 #define gcdDEBUG_ALL (1 << 0)
79 #define gcdDEBUG_FATAL (1 << 1)
80 #define gcdDEBUG_TRACE (1 << 2)
81 #define gcdDEBUG_BREAK (1 << 3)
82 #define gcdDEBUG_ASSERT (1 << 4)
83 #define gcdDEBUG_CODE (1 << 5)
84 #define gcdDEBUG_STACK (1 << 6)
86 #define gcmIS_DEBUG(flag) ( gcdDEBUG & (flag | gcdDEBUG_ALL) )
89 #if (defined(DBG) && DBG) || defined(DEBUG) || defined(_DEBUG)
90 # define gcdDEBUG gcdDEBUG_ALL
92 # define gcdDEBUG gcdDEBUG_NONE
99 # define HALAPI __declspec(dllexport)
101 # define HALAPI __declspec(dllimport)
103 # define HALDECL __cdecl
108 # define HALAPI extern
116 /******************************************************************************\
117 ********************************** Common Types ********************************
118 \******************************************************************************/
123 #define gcvINFINITE ((gctUINT32) ~0U)
125 #define gcvINVALID_HANDLE ((gctHANDLE) ~0U)
128 typedef gctBOOL * gctBOOL_PTR;
131 typedef signed char gctINT8;
132 typedef signed short gctINT16;
133 typedef signed int gctINT32;
134 typedef signed long long gctINT64;
136 typedef gctINT * gctINT_PTR;
137 typedef gctINT8 * gctINT8_PTR;
138 typedef gctINT16 * gctINT16_PTR;
139 typedef gctINT32 * gctINT32_PTR;
140 typedef gctINT64 * gctINT64_PTR;
142 typedef unsigned int gctUINT;
143 typedef unsigned char gctUINT8;
144 typedef unsigned short gctUINT16;
145 typedef unsigned int gctUINT32;
146 typedef unsigned long long gctUINT64;
147 typedef unsigned long gctUINTPTR_T;
149 typedef gctUINT * gctUINT_PTR;
150 typedef gctUINT8 * gctUINT8_PTR;
151 typedef gctUINT16 * gctUINT16_PTR;
152 typedef gctUINT32 * gctUINT32_PTR;
153 typedef gctUINT64 * gctUINT64_PTR;
155 typedef unsigned long gctSIZE_T;
156 typedef gctSIZE_T * gctSIZE_T_PTR;
161 # define gcvNULL ((void *) 0)
164 typedef float gctFLOAT;
165 typedef signed int gctFIXED_POINT;
166 typedef float * gctFLOAT_PTR;
168 typedef void * gctPHYS_ADDR;
169 typedef void * gctHANDLE;
170 typedef void * gctFILE;
171 typedef void * gctSIGNAL;
172 typedef void * gctWINDOW;
173 typedef void * gctIMAGE;
175 typedef void * gctSEMAPHORE;
177 typedef void * gctPOINTER;
178 typedef const void * gctCONST_POINTER;
180 typedef char gctCHAR;
181 typedef char * gctSTRING;
182 typedef const char * gctCONST_STRING;
184 typedef struct _gcsCOUNT_STRING
187 gctCONST_STRING String;
191 typedef union _gcuFLOAT_UINT32
198 /* Fixed point constants. */
199 #define gcvZERO_X ((gctFIXED_POINT) 0x00000000)
200 #define gcvHALF_X ((gctFIXED_POINT) 0x00008000)
201 #define gcvONE_X ((gctFIXED_POINT) 0x00010000)
202 #define gcvNEGONE_X ((gctFIXED_POINT) 0xFFFF0000)
203 #define gcvTWO_X ((gctFIXED_POINT) 0x00020000)
205 /* Stringizing macro. */
206 #define gcmSTRING(Value) #Value
208 /******************************************************************************\
209 ******************************* Fixed Point Math *******************************
210 \******************************************************************************/
212 #define gcmXMultiply(x1, x2) gcoMATH_MultiplyFixed(x1, x2)
213 #define gcmXDivide(x1, x2) gcoMATH_DivideFixed(x1, x2)
214 #define gcmXMultiplyDivide(x1, x2, x3) gcoMATH_MultiplyDivideFixed(x1, x2, x3)
216 /* 2D Engine profile. */
217 typedef struct _gcs2D_PROFILE
220 32bit counter incremented every 2D clock cycle.
221 Wraps back to 0 when the counter overflows.
223 gctUINT32 cycleCount;
225 /* Pixels rendered by the 2D engine.
226 Resets to 0 every time it is read. */
227 gctUINT32 pixelsRendered;
231 /* Macro to combine four characters into a Charcater Code. */
232 #define gcmCC(c1, c2, c3, c4) \
238 ((char) (c3) << 16) \
240 ((char) (c4) << 24) \
243 #define gcmPRINTABLE(c) ((((c) >= ' ') && ((c) <= '}')) ? ((c) != '%' ? (c) : ' ') : ' ')
245 #define gcmCC_PRINT(cc) \
246 gcmPRINTABLE((char) ( (cc) & 0xFF)), \
247 gcmPRINTABLE((char) (((cc) >> 8) & 0xFF)), \
248 gcmPRINTABLE((char) (((cc) >> 16) & 0xFF)), \
249 gcmPRINTABLE((char) (((cc) >> 24) & 0xFF))
251 /******************************************************************************\
252 ****************************** Function Parameters *****************************
253 \******************************************************************************/
259 /******************************************************************************\
260 ********************************* Status Codes *********************************
261 \******************************************************************************/
263 typedef enum _gceSTATUS
268 gcvSTATUS_NO_MORE_DATA = 2,
269 gcvSTATUS_CACHED = 3,
270 gcvSTATUS_MIPMAP_TOO_LARGE = 4,
271 gcvSTATUS_NAME_NOT_FOUND = 5,
272 gcvSTATUS_NOT_OUR_INTERRUPT = 6,
273 gcvSTATUS_MISMATCH = 7,
274 gcvSTATUS_MIPMAP_TOO_SMALL = 8,
275 gcvSTATUS_LARGER = 9,
276 gcvSTATUS_SMALLER = 10,
277 gcvSTATUS_CHIP_NOT_READY = 11,
278 gcvSTATUS_NEED_CONVERSION = 12,
280 gcvSTATUS_DATA_TOO_LARGE = 14,
281 gcvSTATUS_INVALID_CONFIG = 15,
282 gcvSTATUS_CHANGED = 16,
283 gcvSTATUS_NOT_SUPPORT_DITHER = 17,
284 gcvSTATUS_EXECUTED = 18,
285 gcvSTATUS_TERMINATE = 19,
287 gcvSTATUS_CONVERT_TO_SINGLE_STREAM = 20,
289 gcvSTATUS_INVALID_ARGUMENT = -1,
290 gcvSTATUS_INVALID_OBJECT = -2,
291 gcvSTATUS_OUT_OF_MEMORY = -3,
292 gcvSTATUS_MEMORY_LOCKED = -4,
293 gcvSTATUS_MEMORY_UNLOCKED = -5,
294 gcvSTATUS_HEAP_CORRUPTED = -6,
295 gcvSTATUS_GENERIC_IO = -7,
296 gcvSTATUS_INVALID_ADDRESS = -8,
297 gcvSTATUS_CONTEXT_LOSSED = -9,
298 gcvSTATUS_TOO_COMPLEX = -10,
299 gcvSTATUS_BUFFER_TOO_SMALL = -11,
300 gcvSTATUS_INTERFACE_ERROR = -12,
301 gcvSTATUS_NOT_SUPPORTED = -13,
302 gcvSTATUS_MORE_DATA = -14,
303 gcvSTATUS_TIMEOUT = -15,
304 gcvSTATUS_OUT_OF_RESOURCES = -16,
305 gcvSTATUS_INVALID_DATA = -17,
306 gcvSTATUS_INVALID_MIPMAP = -18,
307 gcvSTATUS_NOT_FOUND = -19,
308 gcvSTATUS_NOT_ALIGNED = -20,
309 gcvSTATUS_INVALID_REQUEST = -21,
310 gcvSTATUS_GPU_NOT_RESPONDING = -22,
311 gcvSTATUS_TIMER_OVERFLOW = -23,
312 gcvSTATUS_VERSION_MISMATCH = -24,
313 gcvSTATUS_LOCKED = -25,
314 gcvSTATUS_INTERRUPTED = -26,
315 gcvSTATUS_DEVICE = -27,
316 gcvSTATUS_NOT_MULTI_PIPE_ALIGNED = -28,
319 gcvSTATUS_GLOBAL_TYPE_MISMATCH = -1000,
320 gcvSTATUS_TOO_MANY_ATTRIBUTES = -1001,
321 gcvSTATUS_TOO_MANY_UNIFORMS = -1002,
322 gcvSTATUS_TOO_MANY_VARYINGS = -1003,
323 gcvSTATUS_UNDECLARED_VARYING = -1004,
324 gcvSTATUS_VARYING_TYPE_MISMATCH = -1005,
325 gcvSTATUS_MISSING_MAIN = -1006,
326 gcvSTATUS_NAME_MISMATCH = -1007,
327 gcvSTATUS_INVALID_INDEX = -1008,
328 gcvSTATUS_UNIFORM_TYPE_MISMATCH = -1009,
330 /* Compiler errors. */
331 gcvSTATUS_COMPILER_FE_PREPROCESSOR_ERROR = -2000,
332 gcvSTATUS_COMPILER_FE_PARSER_ERROR = -2001,
336 /******************************************************************************\
337 ********************************* Status Macros ********************************
338 \******************************************************************************/
340 #define gcmIS_ERROR(status) (status < 0)
341 #define gcmNO_ERROR(status) (status >= 0)
342 #define gcmIS_SUCCESS(status) (status == gcvSTATUS_OK)
344 /******************************************************************************\
345 ********************************* Field Macros *********************************
346 \******************************************************************************/
348 #define __gcmSTART(reg_field) \
351 #define __gcmEND(reg_field) \
354 #define __gcmGETSIZE(reg_field) \
355 (__gcmEND(reg_field) - __gcmSTART(reg_field) + 1)
357 #define __gcmALIGN(data, reg_field) \
358 (((gctUINT32) (data)) << __gcmSTART(reg_field))
360 #define __gcmMASK(reg_field) \
361 ((gctUINT32) ((__gcmGETSIZE(reg_field) == 32) \
363 : (~(~0 << __gcmGETSIZE(reg_field)))))
365 /*******************************************************************************
369 ** Get aligned field mask.
373 ** reg Name of register.
374 ** field Name of field within register.
376 #define gcmFIELDMASK(reg, field) \
378 __gcmALIGN(__gcmMASK(reg##_##field), reg##_##field) \
381 /*******************************************************************************
385 ** Extract the value of a field from specified data.
390 ** reg Name of register.
391 ** field Name of field within register.
393 #define gcmGETFIELD(data, reg, field) \
395 ((((gctUINT32) (data)) >> __gcmSTART(reg##_##field)) \
396 & __gcmMASK(reg##_##field)) \
399 /*******************************************************************************
403 ** Set the value of a field within specified data.
408 ** reg Name of register.
409 ** field Name of field within register.
410 ** value Value for field.
412 #define gcmSETFIELD(data, reg, field, value) \
414 (((gctUINT32) (data)) \
415 & ~__gcmALIGN(__gcmMASK(reg##_##field), reg##_##field)) \
416 | __gcmALIGN((gctUINT32) (value) \
417 & __gcmMASK(reg##_##field), reg##_##field) \
420 /*******************************************************************************
424 ** Set the value of a field within specified data with a
430 ** reg Name of register.
431 ** field Name of field within register.
432 ** value Name of the value within the field.
434 #define gcmSETFIELDVALUE(data, reg, field, value) \
436 (((gctUINT32) (data)) \
437 & ~__gcmALIGN(__gcmMASK(reg##_##field), reg##_##field)) \
438 | __gcmALIGN(reg##_##field##_##value \
439 & __gcmMASK(reg##_##field), reg##_##field) \
442 /*******************************************************************************
444 ** gcmGETMASKEDFIELDMASK
446 ** Determine field mask of a masked field.
450 ** reg Name of register.
451 ** field Name of field within register.
453 #define gcmGETMASKEDFIELDMASK(reg, field) \
455 gcmSETFIELD(0, reg, field, ~0) | \
456 gcmSETFIELD(0, reg, MASK_ ## field, ~0) \
459 /*******************************************************************************
463 ** Set the value of a masked field with specified data.
467 ** reg Name of register.
468 ** field Name of field within register.
469 ** value Value for field.
471 #define gcmSETMASKEDFIELD(reg, field, value) \
473 gcmSETFIELD (~0, reg, field, value) & \
474 gcmSETFIELDVALUE(~0, reg, MASK_ ## field, ENABLED) \
477 /*******************************************************************************
479 ** gcmSETMASKEDFIELDVALUE
481 ** Set the value of a masked field with specified data.
485 ** reg Name of register.
486 ** field Name of field within register.
487 ** value Value for field.
489 #define gcmSETMASKEDFIELDVALUE(reg, field, value) \
491 gcmSETFIELDVALUE(~0, reg, field, value) & \
492 gcmSETFIELDVALUE(~0, reg, MASK_ ## field, ENABLED) \
495 /*******************************************************************************
497 ** gcmVERIFYFIELDVALUE
499 ** Verify if the value of a field within specified data equals a
505 ** reg Name of register.
506 ** field Name of field within register.
507 ** value Name of the value within the field.
509 #define gcmVERIFYFIELDVALUE(data, reg, field, value) \
511 (((gctUINT32) (data)) >> __gcmSTART(reg##_##field) & \
512 __gcmMASK(reg##_##field)) \
514 (reg##_##field##_##value & __gcmMASK(reg##_##field)) \
517 /*******************************************************************************
521 #define __gcmSTARTBIT(Field) \
524 #define __gcmBITSIZE(Field) \
527 #define __gcmBITMASK(Field) \
529 (1 << __gcmBITSIZE(Field)) - 1 \
532 #define gcmGETBITS(Value, Type, Field) \
534 ( ((Type) (Value)) >> __gcmSTARTBIT(Field) ) \
536 __gcmBITMASK(Field) \
539 #define gcmSETBITS(Value, Type, Field, NewValue) \
542 & ~(__gcmBITMASK(Field) << __gcmSTARTBIT(Field)) \
545 ( ( ((Type) (NewValue)) \
546 & __gcmBITMASK(Field) \
547 ) << __gcmSTARTBIT(Field) \
551 /*******************************************************************************
555 ** Verify whether the specified address is in the register range.
559 ** Address Address to be verified.
560 ** Name Name of a register.
563 #define gcmISINREGRANGE(Address, Name) \
565 ((Address & (~0U << Name ## _LSB)) == (Name ## _Address >> 2)) \
568 /*******************************************************************************
570 ** A set of macros to aid state loading.
574 ** CommandBuffer Pointer to a gcoCMDBUF object.
575 ** StateDelta Pointer to a gcsSTATE_DELTA state delta structure.
576 ** Memory Destination memory pointer of gctUINT32_PTR type.
577 ** PartOfContext Whether or not the state is a part of the context.
578 ** FixedPoint Whether or not the state is of the fixed point format.
579 ** Count Number of consecutive states to be loaded.
580 ** Address State address.
581 ** Data Data to be set to the state.
584 /*----------------------------------------------------------------------------*/
586 #if gcmIS_DEBUG(gcdDEBUG_CODE)
588 # define gcmSTORELOADSTATE(CommandBuffer, Memory, Address, Count) \
589 CommandBuffer->lastLoadStatePtr = gcmPTR_TO_UINT64(Memory); \
590 CommandBuffer->lastLoadStateAddress = Address; \
591 CommandBuffer->lastLoadStateCount = Count
593 # define gcmVERIFYLOADSTATE(CommandBuffer, Memory, Address) \
595 (gctUINT) (Memory - gcmUINT64_TO_TYPE(CommandBuffer->lastLoadStatePtr, gctUINT32_PTR) - 1) \
597 (gctUINT) (Address - CommandBuffer->lastLoadStateAddress) \
600 gcmASSERT(CommandBuffer->lastLoadStateCount > 0); \
602 CommandBuffer->lastLoadStateCount -= 1
604 # define gcmVERIFYLOADSTATEDONE(CommandBuffer) \
605 gcmASSERT(CommandBuffer->lastLoadStateCount == 0)
609 # define gcmSTORELOADSTATE(CommandBuffer, Memory, Address, Count)
610 # define gcmVERIFYLOADSTATE(CommandBuffer, Memory, Address)
611 # define gcmVERIFYLOADSTATEDONE(CommandBuffer)
617 # define gcmDEFINESECUREUSER() \
618 gctUINT __secure_user_offset__; \
619 gctUINT32_PTR __secure_user_hintArray__;
621 # define gcmBEGINSECUREUSER() \
622 __secure_user_offset__ = reserve->lastOffset; \
624 __secure_user_hintArray__ = gcmUINT64_TO_PTR(reserve->hintArrayTail)
626 # define gcmENDSECUREUSER() \
627 reserve->hintArrayTail = gcmPTR_TO_UINT64(__secure_user_hintArray__)
629 # define gcmSKIPSECUREUSER() \
630 __secure_user_offset__ += gcmSIZEOF(gctUINT32)
632 # define gcmUPDATESECUREUSER() \
633 *__secure_user_hintArray__ = __secure_user_offset__; \
635 __secure_user_offset__ += gcmSIZEOF(gctUINT32); \
636 __secure_user_hintArray__ += 1
640 # define gcmDEFINESECUREUSER()
641 # define gcmBEGINSECUREUSER()
642 # define gcmENDSECUREUSER()
643 # define gcmSKIPSECUREUSER()
644 # define gcmUPDATESECUREUSER()
648 /*----------------------------------------------------------------------------*/
651 # define gcmDUMPSTATEDATA(StateDelta, FixedPoint, Address, Data) \
654 gcmDUMP(gcvNULL, "@[state.x 0x%04X 0x%08X]", \
660 gcmDUMP(gcvNULL, "@[state 0x%04X 0x%08X]", \
665 # define gcmDUMPSTATEDATA(StateDelta, FixedPoint, Address, Data)
668 /*----------------------------------------------------------------------------*/
670 #define gcmDEFINESTATEBUFFER(CommandBuffer, StateDelta, Memory, ReserveSize) \
671 gcmDEFINESECUREUSER() \
672 gctSIZE_T ReserveSize; \
673 gcoCMDBUF CommandBuffer; \
674 gctUINT32_PTR Memory; \
675 gcsSTATE_DELTA_PTR StateDelta
677 #define gcmBEGINSTATEBUFFER(Hardware, CommandBuffer, StateDelta, Memory, ReserveSize) \
679 gcmONERROR(gcoBUFFER_Reserve( \
680 Hardware->buffer, ReserveSize, gcvTRUE, &CommandBuffer \
683 Memory = gcmUINT64_TO_PTR(CommandBuffer->lastReserve); \
685 StateDelta = Hardware->delta; \
687 gcmBEGINSECUREUSER(); \
690 #define gcmENDSTATEBUFFER(CommandBuffer, Memory, ReserveSize) \
692 gcmENDSECUREUSER(); \
695 gcmUINT64_TO_TYPE(CommandBuffer->lastReserve, gctUINT8_PTR) + ReserveSize \
697 (gctUINT8_PTR) Memory \
701 /*----------------------------------------------------------------------------*/
703 #define gcmBEGINSTATEBATCH(CommandBuffer, Memory, FixedPoint, Address, Count) \
705 gcmASSERT(((Memory - gcmUINT64_TO_TYPE(CommandBuffer->lastReserve, gctUINT32_PTR)) & 1) == 0); \
706 gcmASSERT((gctUINT32)Count <= 1024); \
708 gcmVERIFYLOADSTATEDONE(CommandBuffer); \
710 gcmSTORELOADSTATE(CommandBuffer, Memory, Address, Count); \
713 = gcmSETFIELDVALUE(0, AQ_COMMAND_LOAD_STATE_COMMAND, OPCODE, LOAD_STATE) \
714 | gcmSETFIELD (0, AQ_COMMAND_LOAD_STATE_COMMAND, FLOAT, FixedPoint) \
715 | gcmSETFIELD (0, AQ_COMMAND_LOAD_STATE_COMMAND, COUNT, Count) \
716 | gcmSETFIELD (0, AQ_COMMAND_LOAD_STATE_COMMAND, ADDRESS, Address); \
718 gcmSKIPSECUREUSER(); \
721 #define gcmENDSTATEBATCH(CommandBuffer, Memory) \
723 gcmVERIFYLOADSTATEDONE(CommandBuffer); \
725 gcmASSERT(((Memory - gcmUINT64_TO_TYPE(CommandBuffer->lastReserve, gctUINT32_PTR)) & 1) == 0); \
728 /*----------------------------------------------------------------------------*/
730 #define gcmSETSTATEDATA(StateDelta, CommandBuffer, Memory, FixedPoint, \
733 gctUINT32 __temp_data32__; \
735 gcmVERIFYLOADSTATE(CommandBuffer, Memory, Address); \
737 __temp_data32__ = Data; \
739 *Memory++ = __temp_data32__; \
741 gcoHARDWARE_UpdateDelta( \
742 StateDelta, FixedPoint, Address, 0, __temp_data32__ \
745 gcmDUMPSTATEDATA(StateDelta, FixedPoint, Address, __temp_data32__); \
747 gcmUPDATESECUREUSER(); \
750 #define gcmSETCTRLSTATE(StateDelta, CommandBuffer, Memory, Address, Data) \
752 gctUINT32 __temp_data32__; \
754 gcmVERIFYLOADSTATE(CommandBuffer, Memory, Address); \
756 __temp_data32__ = Data; \
758 *Memory++ = __temp_data32__; \
760 gcmDUMPSTATEDATA(StateDelta, gcvFALSE, Address, __temp_data32__); \
762 gcmSKIPSECUREUSER(); \
765 #define gcmSETFILLER(CommandBuffer, Memory) \
767 gcmVERIFYLOADSTATEDONE(CommandBuffer); \
771 gcmSKIPSECUREUSER(); \
774 /*----------------------------------------------------------------------------*/
776 #define gcmSETSINGLESTATE(StateDelta, CommandBuffer, Memory, FixedPoint, \
779 gcmBEGINSTATEBATCH(CommandBuffer, Memory, FixedPoint, Address, 1); \
780 gcmSETSTATEDATA(StateDelta, CommandBuffer, Memory, FixedPoint, \
782 gcmENDSTATEBATCH(CommandBuffer, Memory); \
785 #define gcmSETSINGLECTRLSTATE(StateDelta, CommandBuffer, Memory, FixedPoint, \
788 gcmBEGINSTATEBATCH(CommandBuffer, Memory, FixedPoint, Address, 1); \
789 gcmSETCTRLSTATE(StateDelta, CommandBuffer, Memory, Address, Data); \
790 gcmENDSTATEBATCH(CommandBuffer, Memory); \
794 /*******************************************************************************
796 ** gcmSETSTARTDECOMMAND
798 ** Form a START_DE command.
802 ** Memory Destination memory pointer of gctUINT32_PTR type.
803 ** Count Number of the rectangles.
806 #define gcmSETSTARTDECOMMAND(Memory, Count) \
809 = gcmSETFIELDVALUE(0, AQ_COMMAND_START_DE_COMMAND, OPCODE, START_DE) \
810 | gcmSETFIELD (0, AQ_COMMAND_START_DE_COMMAND, COUNT, Count) \
811 | gcmSETFIELD (0, AQ_COMMAND_START_DE_COMMAND, DATA_COUNT, 0); \
813 *Memory++ = 0xDEADDEED; \
816 /******************************************************************************\
817 ******************************** Ceiling Macro ********************************
818 \******************************************************************************/
819 #define gcmCEIL(x) ((x - (gctUINT32)x) == 0 ? (gctUINT32)x : (gctUINT32)x + 1)
821 /******************************************************************************\
822 ******************************** Min/Max Macros ********************************
823 \******************************************************************************/
825 #define gcmMIN(x, y) (((x) <= (y)) ? (x) : (y))
826 #define gcmMAX(x, y) (((x) >= (y)) ? (x) : (y))
827 #define gcmCLAMP(x, min, max) (((x) < (min)) ? (min) : \
828 ((x) > (max)) ? (max) : (x))
829 #define gcmABS(x) (((x) < 0) ? -(x) : (x))
830 #define gcmNEG(x) (((x) < 0) ? (x) : -(x))
832 /*******************************************************************************
836 ** Convert a pointer to an integer value.
842 #if defined(_WIN32) || (defined(__LP64__) && __LP64__)
843 # define gcmPTR2INT(p) \
845 (gctUINT32) (gctUINT64) (p) \
848 # define gcmPTR2INT(p) \
854 /*******************************************************************************
858 ** Convert an integer value into a pointer.
865 # define gcmINT2PTR(i) \
867 (gctPOINTER) (gctINT64) (i) \
870 # define gcmINT2PTR(i) \
876 /*******************************************************************************
880 ** Compute the byte offset of a field inside a structure.
887 #define gcmOFFSETOF(s, field) \
889 gcmPTR2INT(& (((struct s *) 0)->field)) \
892 #define gcmSWAB32(x) ((gctUINT32)( \
893 (((gctUINT32)(x) & (gctUINT32)0x000000FFUL) << 24) | \
894 (((gctUINT32)(x) & (gctUINT32)0x0000FF00UL) << 8) | \
895 (((gctUINT32)(x) & (gctUINT32)0x00FF0000UL) >> 8) | \
896 (((gctUINT32)(x) & (gctUINT32)0xFF000000UL) >> 24)))
898 /*******************************************************************************
899 ***** Database ****************************************************************/
901 typedef struct _gcsDATABASE_COUNTERS
903 /* Number of currently allocated bytes. */
906 /* Maximum number of bytes allocated (memory footprint). */
909 /* Total number of bytes allocated. */
910 gctUINT64 totalBytes;
912 gcsDATABASE_COUNTERS;
914 typedef struct _gcuDATABASE_INFO
917 gcsDATABASE_COUNTERS counters;
924 /*******************************************************************************
925 ***** Frame database **********************************************************/
927 /* gcsHAL_FRAME_INFO */
928 typedef struct _gcsHAL_FRAME_INFO
930 /* Current timer tick. */
933 /* Bandwidth counters. */
934 OUT gctUINT readBytes8[8];
935 OUT gctUINT writeBytes8[8];
938 OUT gctUINT cycles[8];
939 OUT gctUINT idleCycles[8];
940 OUT gctUINT mcCycles[8];
941 OUT gctUINT readRequests[8];
942 OUT gctUINT writeRequests[8];
945 OUT gctUINT vertexCount;
946 OUT gctUINT primitiveCount;
947 OUT gctUINT rejectedPrimitives;
948 OUT gctUINT culledPrimitives;
949 OUT gctUINT clippedPrimitives;
950 OUT gctUINT outPrimitives;
951 OUT gctUINT inPrimitives;
952 OUT gctUINT culledQuadCount;
953 OUT gctUINT totalQuadCount;
954 OUT gctUINT quadCount;
955 OUT gctUINT totalPixelCount;
958 OUT gctUINT colorKilled[8];
959 OUT gctUINT colorDrawn[8];
960 OUT gctUINT depthKilled[8];
961 OUT gctUINT depthDrawn[8];
963 /* Shader counters. */
964 OUT gctUINT shaderCycles;
965 OUT gctUINT vsInstructionCount;
966 OUT gctUINT vsTextureCount;
967 OUT gctUINT psInstructionCount;
968 OUT gctUINT psTextureCount;
970 /* Texture counters. */
971 OUT gctUINT bilinearRequests;
972 OUT gctUINT trilinearRequests;
973 OUT gctUINT txBytes8;
974 OUT gctUINT txHitCount;
975 OUT gctUINT txMissCount;
979 #if gcdLINK_QUEUE_SIZE
980 typedef struct _gckLINKDATA * gckLINKDATA;
988 typedef struct _gckLINKQUEUE * gckLINKQUEUE;
991 struct _gckLINKDATA data[gcdLINK_QUEUE_SIZE];
1002 #endif /* __gc_hal_types_h_ */