1 /****************************************************************************
3 * Copyright (C) 2005 - 2011 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 *****************************************************************************/
24 #ifndef __gc_hal_types_h_
25 #define __gc_hal_types_h_
27 #include "gc_hal_version.h"
28 #include "gc_hal_options.h"
31 #pragma warning(disable:4127) /* Conditional expression is constant (do { }
33 #pragma warning(disable:4100) /* Unreferenced formal parameter. */
34 #pragma warning(disable:4204) /* Non-constant aggregate initializer (C99). */
35 #pragma warning(disable:4131) /* Uses old-style declarator (for Bison and
36 ** Flex generated files). */
37 #pragma warning(disable:4206) /* Translation unit is empty. */
44 /******************************************************************************\
49 # define gcdHAS_ELLIPSES 1 /* GCC always has it. */
50 #elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
51 # define gcdHAS_ELLIPSES 1 /* C99 has it. */
52 #elif defined(_MSC_VER) && (_MSC_VER >= 1500)
53 # define gcdHAS_ELLIPSES 1 /* MSVC 2007+ has it. */
54 #elif defined(UNDER_CE)
56 # define gcdHAS_ELLIPSES 1
58 # define gcdHAS_ELLIPSES 0
61 # error "gcdHAS_ELLIPSES: Platform could not be determined"
64 /******************************************************************************\
65 ************************************ Keyword ***********************************
66 \******************************************************************************/
68 #if (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L))
69 # define gcmINLINE inline /* C99 keyword. */
70 #elif defined(__GNUC__)
71 # define gcmINLINE __inline__ /* GNU keyword. */
72 #elif defined(_MSC_VER) || defined(UNDER_CE)
73 # define gcmINLINE __inline /* Internal keyword. */
75 # error "gcmINLINE: Platform could not be determined"
78 /* Possible debug flags. */
79 #define gcdDEBUG_NONE 0
80 #define gcdDEBUG_ALL (1 << 0)
81 #define gcdDEBUG_FATAL (1 << 1)
82 #define gcdDEBUG_TRACE (1 << 2)
83 #define gcdDEBUG_BREAK (1 << 3)
84 #define gcdDEBUG_ASSERT (1 << 4)
85 #define gcdDEBUG_CODE (1 << 5)
86 #define gcdDEBUG_STACK (1 << 6)
88 #define gcmIS_DEBUG(flag) ( gcdDEBUG & (flag | gcdDEBUG_ALL) )
91 #if (defined(DBG) && DBG) || defined(DEBUG) || defined(_DEBUG)
92 # define gcdDEBUG gcdDEBUG_ALL
94 # define gcdDEBUG gcdDEBUG_NONE
101 # define HALAPI __declspec(dllexport)
103 # define HALAPI __declspec(dllimport)
105 # define HALDECL __cdecl
110 # define HALAPI extern
118 /******************************************************************************\
119 ********************************** Common Types ********************************
120 \******************************************************************************/
125 #define gcvINFINITE ((gctUINT32) ~0U)
127 #define gcvINVALID_HANDLE ((gctHANDLE) ~0U)
130 typedef gctBOOL
* gctBOOL_PTR
;
133 typedef signed char gctINT8
;
134 typedef signed short gctINT16
;
135 typedef signed int gctINT32
;
136 typedef signed long long gctINT64
;
138 typedef gctINT
* gctINT_PTR
;
139 typedef gctINT8
* gctINT8_PTR
;
140 typedef gctINT16
* gctINT16_PTR
;
141 typedef gctINT32
* gctINT32_PTR
;
142 typedef gctINT64
* gctINT64_PTR
;
144 typedef unsigned int gctUINT
;
145 typedef unsigned char gctUINT8
;
146 typedef unsigned short gctUINT16
;
147 typedef unsigned int gctUINT32
;
148 typedef unsigned long long gctUINT64
;
150 typedef gctUINT
* gctUINT_PTR
;
151 typedef gctUINT8
* gctUINT8_PTR
;
152 typedef gctUINT16
* gctUINT16_PTR
;
153 typedef gctUINT32
* gctUINT32_PTR
;
154 typedef gctUINT64
* gctUINT64_PTR
;
156 typedef unsigned long gctSIZE_T
;
157 typedef gctSIZE_T
* gctSIZE_T_PTR
;
162 # define gcvNULL ((void *) 0)
165 typedef float gctFLOAT
;
166 typedef signed int gctFIXED_POINT
;
167 typedef float * gctFLOAT_PTR
;
169 typedef void * gctPHYS_ADDR
;
170 typedef void * gctHANDLE
;
171 typedef void * gctFILE
;
172 typedef void * gctSIGNAL
;
173 typedef void * gctWINDOW
;
174 typedef void * gctIMAGE
;
176 typedef void * gctSEMAPHORE
;
178 typedef void * gctPOINTER
;
179 typedef const void * gctCONST_POINTER
;
181 typedef char gctCHAR
;
182 typedef char * gctSTRING
;
183 typedef const char * gctCONST_STRING
;
185 typedef struct _gcsCOUNT_STRING
188 gctCONST_STRING String
;
192 typedef union _gcuFLOAT_UINT32
199 /* Fixed point constants. */
200 #define gcvZERO_X ((gctFIXED_POINT) 0x00000000)
201 #define gcvHALF_X ((gctFIXED_POINT) 0x00008000)
202 #define gcvONE_X ((gctFIXED_POINT) 0x00010000)
203 #define gcvNEGONE_X ((gctFIXED_POINT) 0xFFFF0000)
204 #define gcvTWO_X ((gctFIXED_POINT) 0x00020000)
206 /* Stringizing macro. */
207 #define gcmSTRING(Value) #Value
209 /******************************************************************************\
210 ******************************* Fixed Point Math *******************************
211 \******************************************************************************/
213 #define gcmXMultiply(x1, x2) gcoMATH_MultiplyFixed(x1, x2)
214 #define gcmXDivide(x1, x2) gcoMATH_DivideFixed(x1, x2)
215 #define gcmXMultiplyDivide(x1, x2, x3) gcoMATH_MultiplyDivideFixed(x1, x2, x3)
217 /* 2D Engine profile. */
218 typedef struct _gcs2D_PROFILE
221 32bit counter incremented every 2D clock cycle.
222 Wraps back to 0 when the counter overflows.
224 gctUINT32 cycleCount
;
226 /* Pixels rendered by the 2D engine.
227 Resets to 0 every time it is read. */
228 gctUINT32 pixelsRendered
;
232 /* Macro to combine four characters into a Charcater Code. */
233 #define gcmCC(c1, c2, c3, c4) \
239 ((char) (c3) << 16) \
241 ((char) (c4) << 24) \
244 #define gcmPRINTABLE(c) ((((c) >= ' ') && ((c) <= '}')) ? ((c) != '%' ? (c) : ' ') : ' ')
246 #define gcmCC_PRINT(cc) \
247 gcmPRINTABLE((char) ( (cc) & 0xFF)), \
248 gcmPRINTABLE((char) (((cc) >> 8) & 0xFF)), \
249 gcmPRINTABLE((char) (((cc) >> 16) & 0xFF)), \
250 gcmPRINTABLE((char) (((cc) >> 24) & 0xFF))
252 /******************************************************************************\
253 ****************************** Function Parameters *****************************
254 \******************************************************************************/
260 /******************************************************************************\
261 ********************************* Status Codes *********************************
262 \******************************************************************************/
264 typedef enum _gceSTATUS
269 gcvSTATUS_NO_MORE_DATA
= 2,
270 gcvSTATUS_CACHED
= 3,
271 gcvSTATUS_MIPMAP_TOO_LARGE
= 4,
272 gcvSTATUS_NAME_NOT_FOUND
= 5,
273 gcvSTATUS_NOT_OUR_INTERRUPT
= 6,
274 gcvSTATUS_MISMATCH
= 7,
275 gcvSTATUS_MIPMAP_TOO_SMALL
= 8,
276 gcvSTATUS_LARGER
= 9,
277 gcvSTATUS_SMALLER
= 10,
278 gcvSTATUS_CHIP_NOT_READY
= 11,
279 gcvSTATUS_NEED_CONVERSION
= 12,
281 gcvSTATUS_DATA_TOO_LARGE
= 14,
282 gcvSTATUS_INVALID_CONFIG
= 15,
283 gcvSTATUS_CHANGED
= 16,
284 gcvSTATUS_NOT_SUPPORT_DITHER
= 17,
285 gcvSTATUS_EXECUTED
= 18,
286 gcvSTATUS_TERMINATE
= 19,
288 gcvSTATUS_INVALID_ARGUMENT
= -1,
289 gcvSTATUS_INVALID_OBJECT
= -2,
290 gcvSTATUS_OUT_OF_MEMORY
= -3,
291 gcvSTATUS_MEMORY_LOCKED
= -4,
292 gcvSTATUS_MEMORY_UNLOCKED
= -5,
293 gcvSTATUS_HEAP_CORRUPTED
= -6,
294 gcvSTATUS_GENERIC_IO
= -7,
295 gcvSTATUS_INVALID_ADDRESS
= -8,
296 gcvSTATUS_CONTEXT_LOSSED
= -9,
297 gcvSTATUS_TOO_COMPLEX
= -10,
298 gcvSTATUS_BUFFER_TOO_SMALL
= -11,
299 gcvSTATUS_INTERFACE_ERROR
= -12,
300 gcvSTATUS_NOT_SUPPORTED
= -13,
301 gcvSTATUS_MORE_DATA
= -14,
302 gcvSTATUS_TIMEOUT
= -15,
303 gcvSTATUS_OUT_OF_RESOURCES
= -16,
304 gcvSTATUS_INVALID_DATA
= -17,
305 gcvSTATUS_INVALID_MIPMAP
= -18,
306 gcvSTATUS_NOT_FOUND
= -19,
307 gcvSTATUS_NOT_ALIGNED
= -20,
308 gcvSTATUS_INVALID_REQUEST
= -21,
309 gcvSTATUS_GPU_NOT_RESPONDING
= -22,
310 gcvSTATUS_TIMER_OVERFLOW
= -23,
311 gcvSTATUS_VERSION_MISMATCH
= -24,
312 gcvSTATUS_LOCKED
= -25,
313 gcvSTATUS_INTERRUPTED
= -26,
314 gcvSTATUS_DEVICE
= -27,
317 gcvSTATUS_GLOBAL_TYPE_MISMATCH
= -1000,
318 gcvSTATUS_TOO_MANY_ATTRIBUTES
= -1001,
319 gcvSTATUS_TOO_MANY_UNIFORMS
= -1002,
320 gcvSTATUS_TOO_MANY_VARYINGS
= -1003,
321 gcvSTATUS_UNDECLARED_VARYING
= -1004,
322 gcvSTATUS_VARYING_TYPE_MISMATCH
= -1005,
323 gcvSTATUS_MISSING_MAIN
= -1006,
324 gcvSTATUS_NAME_MISMATCH
= -1007,
325 gcvSTATUS_INVALID_INDEX
= -1008,
329 /******************************************************************************\
330 ********************************* Status Macros ********************************
331 \******************************************************************************/
333 #define gcmIS_ERROR(status) (status < 0)
334 #define gcmNO_ERROR(status) (status >= 0)
335 #define gcmIS_SUCCESS(status) (status == gcvSTATUS_OK)
337 /******************************************************************************\
338 ********************************* Field Macros *********************************
339 \******************************************************************************/
341 #define __gcmSTART(reg_field) \
344 #define __gcmEND(reg_field) \
347 #define __gcmGETSIZE(reg_field) \
348 (__gcmEND(reg_field) - __gcmSTART(reg_field) + 1)
350 #define __gcmALIGN(data, reg_field) \
351 (((gctUINT32) (data)) << __gcmSTART(reg_field))
353 #define __gcmMASK(reg_field) \
354 ((gctUINT32) ((__gcmGETSIZE(reg_field) == 32) \
356 : (~(~0 << __gcmGETSIZE(reg_field)))))
358 /*******************************************************************************
362 ** Get aligned field mask.
366 ** reg Name of register.
367 ** field Name of field within register.
369 #define gcmFIELDMASK(reg, field) \
371 __gcmALIGN(__gcmMASK(reg##_##field), reg##_##field) \
374 /*******************************************************************************
378 ** Extract the value of a field from specified data.
383 ** reg Name of register.
384 ** field Name of field within register.
386 #define gcmGETFIELD(data, reg, field) \
388 ((((gctUINT32) (data)) >> __gcmSTART(reg##_##field)) \
389 & __gcmMASK(reg##_##field)) \
392 /*******************************************************************************
396 ** Set the value of a field within specified data.
401 ** reg Name of register.
402 ** field Name of field within register.
403 ** value Value for field.
405 #define gcmSETFIELD(data, reg, field, value) \
407 (((gctUINT32) (data)) \
408 & ~__gcmALIGN(__gcmMASK(reg##_##field), reg##_##field)) \
409 | __gcmALIGN((gctUINT32) (value) \
410 & __gcmMASK(reg##_##field), reg##_##field) \
413 /*******************************************************************************
417 ** Set the value of a field within specified data with a
423 ** reg Name of register.
424 ** field Name of field within register.
425 ** value Name of the value within the field.
427 #define gcmSETFIELDVALUE(data, reg, field, value) \
429 (((gctUINT32) (data)) \
430 & ~__gcmALIGN(__gcmMASK(reg##_##field), reg##_##field)) \
431 | __gcmALIGN(reg##_##field##_##value \
432 & __gcmMASK(reg##_##field), reg##_##field) \
435 /*******************************************************************************
437 ** gcmGETMASKEDFIELDMASK
439 ** Determine field mask of a masked field.
443 ** reg Name of register.
444 ** field Name of field within register.
446 #define gcmGETMASKEDFIELDMASK(reg, field) \
448 gcmSETFIELD(0, reg, field, ~0) | \
449 gcmSETFIELD(0, reg, MASK_ ## field, ~0) \
452 /*******************************************************************************
456 ** Set the value of a masked field with specified data.
460 ** reg Name of register.
461 ** field Name of field within register.
462 ** value Value for field.
464 #define gcmSETMASKEDFIELD(reg, field, value) \
466 gcmSETFIELD (~0, reg, field, value) & \
467 gcmSETFIELDVALUE(~0, reg, MASK_ ## field, ENABLED) \
470 /*******************************************************************************
472 ** gcmSETMASKEDFIELDVALUE
474 ** Set the value of a masked field with specified data.
478 ** reg Name of register.
479 ** field Name of field within register.
480 ** value Value for field.
482 #define gcmSETMASKEDFIELDVALUE(reg, field, value) \
484 gcmSETFIELDVALUE(~0, reg, field, value) & \
485 gcmSETFIELDVALUE(~0, reg, MASK_ ## field, ENABLED) \
488 /*******************************************************************************
490 ** gcmVERIFYFIELDVALUE
492 ** Verify if the value of a field within specified data equals a
498 ** reg Name of register.
499 ** field Name of field within register.
500 ** value Name of the value within the field.
502 #define gcmVERIFYFIELDVALUE(data, reg, field, value) \
504 (((gctUINT32) (data)) >> __gcmSTART(reg##_##field) & \
505 __gcmMASK(reg##_##field)) \
507 (reg##_##field##_##value & __gcmMASK(reg##_##field)) \
510 /*******************************************************************************
514 #define __gcmSTARTBIT(Field) \
517 #define __gcmBITSIZE(Field) \
520 #define __gcmBITMASK(Field) \
522 (1 << __gcmBITSIZE(Field)) - 1 \
525 #define gcmGETBITS(Value, Type, Field) \
527 ( ((Type) (Value)) >> __gcmSTARTBIT(Field) ) \
529 __gcmBITMASK(Field) \
532 #define gcmSETBITS(Value, Type, Field, NewValue) \
535 & ~(__gcmBITMASK(Field) << __gcmSTARTBIT(Field)) \
538 ( ( ((Type) (NewValue)) \
539 & __gcmBITMASK(Field) \
540 ) << __gcmSTARTBIT(Field) \
544 /*******************************************************************************
548 ** Verify whether the specified address is in the register range.
552 ** Address Address to be verified.
553 ** Name Name of a register.
556 #define gcmISINREGRANGE(Address, Name) \
558 ((Address & (~0U << Name ## _LSB)) == (Name ## _Address >> 2)) \
561 /*******************************************************************************
563 ** A set of macros to aid state loading.
567 ** CommandBuffer Pointer to a gcoCMDBUF object.
568 ** StateDelta Pointer to a gcsSTATE_DELTA state delta structure.
569 ** Memory Destination memory pointer of gctUINT32_PTR type.
570 ** PartOfContext Whether or not the state is a part of the context.
571 ** FixedPoint Whether or not the state is of the fixed point format.
572 ** Count Number of consecutive states to be loaded.
573 ** Address State address.
574 ** Data Data to be set to the state.
577 /*----------------------------------------------------------------------------*/
579 #if gcmIS_DEBUG(gcdDEBUG_CODE)
581 # define gcmSTORELOADSTATE(CommandBuffer, Memory, Address, Count) \
582 CommandBuffer->lastLoadStatePtr = Memory; \
583 CommandBuffer->lastLoadStateAddress = Address; \
584 CommandBuffer->lastLoadStateCount = Count
586 # define gcmVERIFYLOADSTATE(CommandBuffer, Memory, Address) \
588 (gctUINT) (Memory - CommandBuffer->lastLoadStatePtr - 1) \
590 (gctUINT) (Address - CommandBuffer->lastLoadStateAddress) \
593 gcmASSERT(CommandBuffer->lastLoadStateCount > 0); \
595 CommandBuffer->lastLoadStateCount -= 1
597 # define gcmVERIFYLOADSTATEDONE(CommandBuffer) \
598 gcmASSERT(CommandBuffer->lastLoadStateCount == 0)
602 # define gcmSTORELOADSTATE(CommandBuffer, Memory, Address, Count)
603 # define gcmVERIFYLOADSTATE(CommandBuffer, Memory, Address)
604 # define gcmVERIFYLOADSTATEDONE(CommandBuffer)
610 # define gcmDEFINESECUREUSER() \
611 gctUINT __secure_user_offset__; \
612 gctUINT32_PTR __secure_user_hintArray__;
614 # define gcmBEGINSECUREUSER() \
615 __secure_user_offset__ = reserve->lastOffset; \
617 __secure_user_hintArray__ = reserve->hintArrayTail
619 # define gcmENDSECUREUSER() \
620 reserve->hintArrayTail = __secure_user_hintArray__
622 # define gcmSKIPSECUREUSER() \
623 __secure_user_offset__ += gcmSIZEOF(gctUINT32)
625 # define gcmUPDATESECUREUSER() \
626 *__secure_user_hintArray__ = __secure_user_offset__; \
628 __secure_user_offset__ += gcmSIZEOF(gctUINT32); \
629 __secure_user_hintArray__ += 1
633 # define gcmDEFINESECUREUSER()
634 # define gcmBEGINSECUREUSER()
635 # define gcmENDSECUREUSER()
636 # define gcmSKIPSECUREUSER()
637 # define gcmUPDATESECUREUSER()
641 /*----------------------------------------------------------------------------*/
644 # define gcmDUMPSTATEDATA(StateDelta, FixedPoint, Address, Data) \
647 gcmDUMP(StateDelta->os, "@[state.x 0x%04X 0x%08X]", \
653 gcmDUMP(StateDelta->os, "@[state 0x%04X 0x%08X]", \
658 # define gcmDUMPSTATEDATA(StateDelta, FixedPoint, Address, Data)
661 /*----------------------------------------------------------------------------*/
663 #define gcmDEFINESTATEBUFFER(CommandBuffer, StateDelta, Memory, ReserveSize) \
664 gcmDEFINESECUREUSER() \
665 gctSIZE_T ReserveSize; \
666 gcoCMDBUF CommandBuffer; \
667 gctUINT32_PTR Memory; \
668 gcsSTATE_DELTA_PTR StateDelta
670 #define gcmBEGINSTATEBUFFER(Hardware, CommandBuffer, StateDelta, Memory, ReserveSize) \
672 gcmONERROR(gcoBUFFER_Reserve( \
673 Hardware->buffer, ReserveSize, gcvTRUE, &CommandBuffer \
676 Memory = (gctUINT32_PTR) CommandBuffer->lastReserve; \
678 StateDelta = Hardware->delta; \
680 gcmBEGINSECUREUSER(); \
683 #define gcmENDSTATEBUFFER(CommandBuffer, Memory, ReserveSize) \
685 gcmENDSECUREUSER(); \
688 ((gctUINT8_PTR) CommandBuffer->lastReserve) + ReserveSize \
690 (gctUINT8_PTR) Memory \
694 /*----------------------------------------------------------------------------*/
696 #define gcmBEGINSTATEBATCH(CommandBuffer, Memory, FixedPoint, Address, Count) \
698 gcmASSERT(((Memory - (gctUINT32_PTR) CommandBuffer->lastReserve) & 1) == 0); \
700 gcmVERIFYLOADSTATEDONE(CommandBuffer); \
702 gcmSTORELOADSTATE(CommandBuffer, Memory, Address, Count); \
705 = gcmSETFIELDVALUE(0, AQ_COMMAND_LOAD_STATE_COMMAND, OPCODE, LOAD_STATE) \
706 | gcmSETFIELD (0, AQ_COMMAND_LOAD_STATE_COMMAND, FLOAT, FixedPoint) \
707 | gcmSETFIELD (0, AQ_COMMAND_LOAD_STATE_COMMAND, COUNT, Count) \
708 | gcmSETFIELD (0, AQ_COMMAND_LOAD_STATE_COMMAND, ADDRESS, Address); \
710 gcmSKIPSECUREUSER(); \
713 #define gcmENDSTATEBATCH(CommandBuffer, Memory) \
715 gcmVERIFYLOADSTATEDONE(CommandBuffer); \
717 gcmASSERT(((Memory - (gctUINT32_PTR) CommandBuffer->lastReserve) & 1) == 0); \
720 /*----------------------------------------------------------------------------*/
722 #define gcmSETSTATEDATA(StateDelta, CommandBuffer, Memory, FixedPoint, \
725 gctUINT32 __temp_data32__; \
727 gcmVERIFYLOADSTATE(CommandBuffer, Memory, Address); \
729 __temp_data32__ = Data; \
731 *Memory++ = __temp_data32__; \
733 gcoHARDWARE_UpdateDelta( \
734 StateDelta, FixedPoint, Address, 0, __temp_data32__ \
737 gcmDUMPSTATEDATA(StateDelta, FixedPoint, Address, __temp_data32__); \
739 gcmUPDATESECUREUSER(); \
742 #define gcmSETCTRLSTATE(StateDelta, CommandBuffer, Memory, Address, Data) \
744 gctUINT32 __temp_data32__; \
746 gcmVERIFYLOADSTATE(CommandBuffer, Memory, Address); \
748 __temp_data32__ = Data; \
750 *Memory++ = __temp_data32__; \
752 gcmDUMPSTATEDATA(StateDelta, gcvFALSE, Address, __temp_data32__); \
754 gcmSKIPSECUREUSER(); \
757 #define gcmSETFILLER(CommandBuffer, Memory) \
759 gcmVERIFYLOADSTATEDONE(CommandBuffer); \
763 gcmSKIPSECUREUSER(); \
766 /*----------------------------------------------------------------------------*/
768 #define gcmSETSINGLESTATE(StateDelta, CommandBuffer, Memory, FixedPoint, \
771 gcmBEGINSTATEBATCH(CommandBuffer, Memory, FixedPoint, Address, 1); \
772 gcmSETSTATEDATA(StateDelta, CommandBuffer, Memory, FixedPoint, \
774 gcmENDSTATEBATCH(CommandBuffer, Memory); \
777 #define gcmSETSINGLECTRLSTATE(StateDelta, CommandBuffer, Memory, FixedPoint, \
780 gcmBEGINSTATEBATCH(CommandBuffer, Memory, FixedPoint, Address, 1); \
781 gcmSETCTRLSTATE(StateDelta, CommandBuffer, Memory, Address, Data); \
782 gcmENDSTATEBATCH(CommandBuffer, Memory); \
786 /*******************************************************************************
788 ** gcmSETSTARTDECOMMAND
790 ** Form a START_DE command.
794 ** Memory Destination memory pointer of gctUINT32_PTR type.
795 ** Count Number of the rectangles.
798 #define gcmSETSTARTDECOMMAND(Memory, Count) \
801 = gcmSETFIELDVALUE(0, AQ_COMMAND_START_DE_COMMAND, OPCODE, START_DE) \
802 | gcmSETFIELD (0, AQ_COMMAND_START_DE_COMMAND, COUNT, Count) \
803 | gcmSETFIELD (0, AQ_COMMAND_START_DE_COMMAND, DATA_COUNT, 0); \
805 *Memory++ = 0xDEADDEED; \
808 /******************************************************************************\
809 ******************************** Ceiling Macro ********************************
810 \******************************************************************************/
811 #define gcmCEIL(x) ((x - (gctUINT32)x) == 0 ? (gctUINT32)x : (gctUINT32)x + 1)
813 /******************************************************************************\
814 ******************************** Min/Max Macros ********************************
815 \******************************************************************************/
817 #define gcmMIN(x, y) (((x) <= (y)) ? (x) : (y))
818 #define gcmMAX(x, y) (((x) >= (y)) ? (x) : (y))
819 #define gcmCLAMP(x, min, max) (((x) < (min)) ? (min) : \
820 ((x) > (max)) ? (max) : (x))
821 #define gcmABS(x) (((x) < 0) ? -(x) : (x))
822 #define gcmNEG(x) (((x) < 0) ? (x) : -(x))
824 /*******************************************************************************
828 ** Convert a pointer to an integer value.
834 #if defined(_WIN32) || (defined(__LP64__) && __LP64__)
835 # define gcmPTR2INT(p) \
837 (gctUINT32) (gctUINT64) (p) \
840 # define gcmPTR2INT(p) \
846 /*******************************************************************************
850 ** Convert an integer value into a pointer.
857 # define gcmINT2PTR(i) \
859 (gctPOINTER) (gctINT64) (i) \
862 # define gcmINT2PTR(i) \
868 /*******************************************************************************
872 ** Compute the byte offset of a field inside a structure.
879 #define gcmOFFSETOF(s, field) \
881 gcmPTR2INT(& (((struct s *) 0)->field)) \
884 /*******************************************************************************
885 ***** Database ****************************************************************/
887 typedef struct _gcsDATABASE_COUNTERS
889 /* Number of currently allocated bytes. */
892 /* Maximum number of bytes allocated (memory footprint). */
895 /* Total number of bytes allocated. */
896 gctSIZE_T totalBytes
;
898 gcsDATABASE_COUNTERS
;
900 typedef struct _gcuDATABASE_INFO
903 gcsDATABASE_COUNTERS counters
;
910 /*******************************************************************************
911 ***** Frame database **********************************************************/
913 /* gcsHAL_FRAME_INFO */
914 typedef struct _gcsHAL_FRAME_INFO
916 /* Current timer tick. */
919 /* Bandwidth counters. */
920 OUT gctUINT readBytes8
[8];
921 OUT gctUINT writeBytes8
[8];
924 OUT gctUINT cycles
[8];
925 OUT gctUINT idleCycles
[8];
926 OUT gctUINT mcCycles
[8];
927 OUT gctUINT readRequests
[8];
928 OUT gctUINT writeRequests
[8];
931 OUT gctUINT vertexCount
;
932 OUT gctUINT primitiveCount
;
933 OUT gctUINT rejectedPrimitives
;
934 OUT gctUINT culledPrimitives
;
935 OUT gctUINT clippedPrimitives
;
936 OUT gctUINT outPrimitives
;
937 OUT gctUINT inPrimitives
;
938 OUT gctUINT culledQuadCount
;
939 OUT gctUINT totalQuadCount
;
940 OUT gctUINT quadCount
;
941 OUT gctUINT totalPixelCount
;
944 OUT gctUINT colorKilled
[8];
945 OUT gctUINT colorDrawn
[8];
946 OUT gctUINT depthKilled
[8];
947 OUT gctUINT depthDrawn
[8];
949 /* Shader counters. */
950 OUT gctUINT shaderCycles
;
951 OUT gctUINT vsInstructionCount
;
952 OUT gctUINT vsTextureCount
;
953 OUT gctUINT psInstructionCount
;
954 OUT gctUINT psTextureCount
;
956 /* Texture counters. */
957 OUT gctUINT bilinearRequests
;
958 OUT gctUINT trilinearRequests
;
959 OUT gctUINT txBytes8
;
960 OUT gctUINT txHitCount
;
961 OUT gctUINT txMissCount
;
969 #endif /* __gc_hal_types_h_ */