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 long gctLONG;
132 typedef signed char gctINT8;
133 typedef signed short gctINT16;
134 typedef signed int gctINT32;
135 typedef signed long long gctINT64;
137 typedef gctINT * gctINT_PTR;
138 typedef gctINT8 * gctINT8_PTR;
139 typedef gctINT16 * gctINT16_PTR;
140 typedef gctINT32 * gctINT32_PTR;
141 typedef gctINT64 * gctINT64_PTR;
143 typedef unsigned int gctUINT;
144 typedef unsigned char gctUINT8;
145 typedef unsigned short gctUINT16;
146 typedef unsigned int gctUINT32;
147 typedef unsigned long long gctUINT64;
148 typedef unsigned long gctUINTPTR_T;
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;
175 typedef void * gctSYNC_POINT;
177 typedef void * gctSEMAPHORE;
179 typedef void * gctPOINTER;
180 typedef const void * gctCONST_POINTER;
182 typedef char gctCHAR;
183 typedef char * gctSTRING;
184 typedef const char * gctCONST_STRING;
186 typedef struct _gcsCOUNT_STRING
189 gctCONST_STRING String;
193 typedef union _gcuFLOAT_UINT32
200 /* Fixed point constants. */
201 #define gcvZERO_X ((gctFIXED_POINT) 0x00000000)
202 #define gcvHALF_X ((gctFIXED_POINT) 0x00008000)
203 #define gcvONE_X ((gctFIXED_POINT) 0x00010000)
204 #define gcvNEGONE_X ((gctFIXED_POINT) 0xFFFF0000)
205 #define gcvTWO_X ((gctFIXED_POINT) 0x00020000)
207 /* Stringizing macro. */
208 #define gcmSTRING(Value) #Value
210 /******************************************************************************\
211 ******************************* Fixed Point Math *******************************
212 \******************************************************************************/
214 #define gcmXMultiply(x1, x2) gcoMATH_MultiplyFixed(x1, x2)
215 #define gcmXDivide(x1, x2) gcoMATH_DivideFixed(x1, x2)
216 #define gcmXMultiplyDivide(x1, x2, x3) gcoMATH_MultiplyDivideFixed(x1, x2, x3)
218 /* 2D Engine profile. */
219 typedef struct _gcs2D_PROFILE
222 32bit counter incremented every 2D clock cycle.
223 Wraps back to 0 when the counter overflows.
225 gctUINT32 cycleCount;
227 /* Pixels rendered by the 2D engine.
228 Resets to 0 every time it is read. */
229 gctUINT32 pixelsRendered;
233 /* Macro to combine four characters into a Charcater Code. */
234 #define gcmCC(c1, c2, c3, c4) \
240 ((char) (c3) << 16) \
242 ((char) (c4) << 24) \
245 #define gcmPRINTABLE(c) ((((c) >= ' ') && ((c) <= '}')) ? ((c) != '%' ? (c) : ' ') : ' ')
247 #define gcmCC_PRINT(cc) \
248 gcmPRINTABLE((char) ( (cc) & 0xFF)), \
249 gcmPRINTABLE((char) (((cc) >> 8) & 0xFF)), \
250 gcmPRINTABLE((char) (((cc) >> 16) & 0xFF)), \
251 gcmPRINTABLE((char) (((cc) >> 24) & 0xFF))
253 /******************************************************************************\
254 ****************************** Function Parameters *****************************
255 \******************************************************************************/
261 /******************************************************************************\
262 ********************************* Status Codes *********************************
263 \******************************************************************************/
265 typedef enum _gceSTATUS
270 gcvSTATUS_NO_MORE_DATA = 2,
271 gcvSTATUS_CACHED = 3,
272 gcvSTATUS_MIPMAP_TOO_LARGE = 4,
273 gcvSTATUS_NAME_NOT_FOUND = 5,
274 gcvSTATUS_NOT_OUR_INTERRUPT = 6,
275 gcvSTATUS_MISMATCH = 7,
276 gcvSTATUS_MIPMAP_TOO_SMALL = 8,
277 gcvSTATUS_LARGER = 9,
278 gcvSTATUS_SMALLER = 10,
279 gcvSTATUS_CHIP_NOT_READY = 11,
280 gcvSTATUS_NEED_CONVERSION = 12,
282 gcvSTATUS_DATA_TOO_LARGE = 14,
283 gcvSTATUS_INVALID_CONFIG = 15,
284 gcvSTATUS_CHANGED = 16,
285 gcvSTATUS_NOT_SUPPORT_DITHER = 17,
286 gcvSTATUS_EXECUTED = 18,
287 gcvSTATUS_TERMINATE = 19,
289 gcvSTATUS_CONVERT_TO_SINGLE_STREAM = 20,
291 gcvSTATUS_INVALID_ARGUMENT = -1,
292 gcvSTATUS_INVALID_OBJECT = -2,
293 gcvSTATUS_OUT_OF_MEMORY = -3,
294 gcvSTATUS_MEMORY_LOCKED = -4,
295 gcvSTATUS_MEMORY_UNLOCKED = -5,
296 gcvSTATUS_HEAP_CORRUPTED = -6,
297 gcvSTATUS_GENERIC_IO = -7,
298 gcvSTATUS_INVALID_ADDRESS = -8,
299 gcvSTATUS_CONTEXT_LOSSED = -9,
300 gcvSTATUS_TOO_COMPLEX = -10,
301 gcvSTATUS_BUFFER_TOO_SMALL = -11,
302 gcvSTATUS_INTERFACE_ERROR = -12,
303 gcvSTATUS_NOT_SUPPORTED = -13,
304 gcvSTATUS_MORE_DATA = -14,
305 gcvSTATUS_TIMEOUT = -15,
306 gcvSTATUS_OUT_OF_RESOURCES = -16,
307 gcvSTATUS_INVALID_DATA = -17,
308 gcvSTATUS_INVALID_MIPMAP = -18,
309 gcvSTATUS_NOT_FOUND = -19,
310 gcvSTATUS_NOT_ALIGNED = -20,
311 gcvSTATUS_INVALID_REQUEST = -21,
312 gcvSTATUS_GPU_NOT_RESPONDING = -22,
313 gcvSTATUS_TIMER_OVERFLOW = -23,
314 gcvSTATUS_VERSION_MISMATCH = -24,
315 gcvSTATUS_LOCKED = -25,
316 gcvSTATUS_INTERRUPTED = -26,
317 gcvSTATUS_DEVICE = -27,
318 gcvSTATUS_NOT_MULTI_PIPE_ALIGNED = -28,
321 gcvSTATUS_GLOBAL_TYPE_MISMATCH = -1000,
322 gcvSTATUS_TOO_MANY_ATTRIBUTES = -1001,
323 gcvSTATUS_TOO_MANY_UNIFORMS = -1002,
324 gcvSTATUS_TOO_MANY_VARYINGS = -1003,
325 gcvSTATUS_UNDECLARED_VARYING = -1004,
326 gcvSTATUS_VARYING_TYPE_MISMATCH = -1005,
327 gcvSTATUS_MISSING_MAIN = -1006,
328 gcvSTATUS_NAME_MISMATCH = -1007,
329 gcvSTATUS_INVALID_INDEX = -1008,
330 gcvSTATUS_UNIFORM_TYPE_MISMATCH = -1009,
332 /* Compiler errors. */
333 gcvSTATUS_COMPILER_FE_PREPROCESSOR_ERROR = -2000,
334 gcvSTATUS_COMPILER_FE_PARSER_ERROR = -2001,
338 /******************************************************************************\
339 ********************************* Status Macros ********************************
340 \******************************************************************************/
342 #define gcmIS_ERROR(status) (status < 0)
343 #define gcmNO_ERROR(status) (status >= 0)
344 #define gcmIS_SUCCESS(status) (status == gcvSTATUS_OK)
346 /******************************************************************************\
347 ********************************* Field Macros *********************************
348 \******************************************************************************/
350 #define __gcmSTART(reg_field) \
353 #define __gcmEND(reg_field) \
356 #define __gcmGETSIZE(reg_field) \
357 (__gcmEND(reg_field) - __gcmSTART(reg_field) + 1)
359 #define __gcmALIGN(data, reg_field) \
360 (((gctUINT32) (data)) << __gcmSTART(reg_field))
362 #define __gcmMASK(reg_field) \
363 ((gctUINT32) ((__gcmGETSIZE(reg_field) == 32) \
365 : (~(~0 << __gcmGETSIZE(reg_field)))))
367 /*******************************************************************************
371 ** Get aligned field mask.
375 ** reg Name of register.
376 ** field Name of field within register.
378 #define gcmFIELDMASK(reg, field) \
380 __gcmALIGN(__gcmMASK(reg##_##field), reg##_##field) \
383 /*******************************************************************************
387 ** Extract the value of a field from specified data.
392 ** reg Name of register.
393 ** field Name of field within register.
395 #define gcmGETFIELD(data, reg, field) \
397 ((((gctUINT32) (data)) >> __gcmSTART(reg##_##field)) \
398 & __gcmMASK(reg##_##field)) \
401 /*******************************************************************************
405 ** Set the value of a field within specified data.
410 ** reg Name of register.
411 ** field Name of field within register.
412 ** value Value for field.
414 #define gcmSETFIELD(data, reg, field, value) \
416 (((gctUINT32) (data)) \
417 & ~__gcmALIGN(__gcmMASK(reg##_##field), reg##_##field)) \
418 | __gcmALIGN((gctUINT32) (value) \
419 & __gcmMASK(reg##_##field), reg##_##field) \
422 /*******************************************************************************
426 ** Set the value of a field within specified data with a
432 ** reg Name of register.
433 ** field Name of field within register.
434 ** value Name of the value within the field.
436 #define gcmSETFIELDVALUE(data, reg, field, value) \
438 (((gctUINT32) (data)) \
439 & ~__gcmALIGN(__gcmMASK(reg##_##field), reg##_##field)) \
440 | __gcmALIGN(reg##_##field##_##value \
441 & __gcmMASK(reg##_##field), reg##_##field) \
444 /*******************************************************************************
446 ** gcmGETMASKEDFIELDMASK
448 ** Determine field mask of a masked field.
452 ** reg Name of register.
453 ** field Name of field within register.
455 #define gcmGETMASKEDFIELDMASK(reg, field) \
457 gcmSETFIELD(0, reg, field, ~0) | \
458 gcmSETFIELD(0, reg, MASK_ ## field, ~0) \
461 /*******************************************************************************
465 ** Set the value of a masked field with specified data.
469 ** reg Name of register.
470 ** field Name of field within register.
471 ** value Value for field.
473 #define gcmSETMASKEDFIELD(reg, field, value) \
475 gcmSETFIELD (~0, reg, field, value) & \
476 gcmSETFIELDVALUE(~0, reg, MASK_ ## field, ENABLED) \
479 /*******************************************************************************
481 ** gcmSETMASKEDFIELDVALUE
483 ** Set the value of a masked field with specified data.
487 ** reg Name of register.
488 ** field Name of field within register.
489 ** value Value for field.
491 #define gcmSETMASKEDFIELDVALUE(reg, field, value) \
493 gcmSETFIELDVALUE(~0, reg, field, value) & \
494 gcmSETFIELDVALUE(~0, reg, MASK_ ## field, ENABLED) \
497 /*******************************************************************************
499 ** gcmVERIFYFIELDVALUE
501 ** Verify if the value of a field within specified data equals a
507 ** reg Name of register.
508 ** field Name of field within register.
509 ** value Name of the value within the field.
511 #define gcmVERIFYFIELDVALUE(data, reg, field, value) \
513 (((gctUINT32) (data)) >> __gcmSTART(reg##_##field) & \
514 __gcmMASK(reg##_##field)) \
516 (reg##_##field##_##value & __gcmMASK(reg##_##field)) \
519 /*******************************************************************************
523 #define __gcmSTARTBIT(Field) \
526 #define __gcmBITSIZE(Field) \
529 #define __gcmBITMASK(Field) \
531 (1 << __gcmBITSIZE(Field)) - 1 \
534 #define gcmGETBITS(Value, Type, Field) \
536 ( ((Type) (Value)) >> __gcmSTARTBIT(Field) ) \
538 __gcmBITMASK(Field) \
541 #define gcmSETBITS(Value, Type, Field, NewValue) \
544 & ~(__gcmBITMASK(Field) << __gcmSTARTBIT(Field)) \
547 ( ( ((Type) (NewValue)) \
548 & __gcmBITMASK(Field) \
549 ) << __gcmSTARTBIT(Field) \
553 /*******************************************************************************
557 ** Verify whether the specified address is in the register range.
561 ** Address Address to be verified.
562 ** Name Name of a register.
565 #define gcmISINREGRANGE(Address, Name) \
567 ((Address & (~0U << Name ## _LSB)) == (Name ## _Address >> 2)) \
570 /*******************************************************************************
572 ** A set of macros to aid state loading.
576 ** CommandBuffer Pointer to a gcoCMDBUF object.
577 ** StateDelta Pointer to a gcsSTATE_DELTA state delta structure.
578 ** Memory Destination memory pointer of gctUINT32_PTR type.
579 ** PartOfContext Whether or not the state is a part of the context.
580 ** FixedPoint Whether or not the state is of the fixed point format.
581 ** Count Number of consecutive states to be loaded.
582 ** Address State address.
583 ** Data Data to be set to the state.
586 /*----------------------------------------------------------------------------*/
588 #if gcmIS_DEBUG(gcdDEBUG_CODE)
590 # define gcmSTORELOADSTATE(CommandBuffer, Memory, Address, Count) \
591 CommandBuffer->lastLoadStatePtr = gcmPTR_TO_UINT64(Memory); \
592 CommandBuffer->lastLoadStateAddress = Address; \
593 CommandBuffer->lastLoadStateCount = Count
595 # define gcmVERIFYLOADSTATE(CommandBuffer, Memory, Address) \
597 (gctUINT) (Memory - gcmUINT64_TO_TYPE(CommandBuffer->lastLoadStatePtr, gctUINT32_PTR) - 1) \
599 (gctUINT) (Address - CommandBuffer->lastLoadStateAddress) \
602 gcmASSERT(CommandBuffer->lastLoadStateCount > 0); \
604 CommandBuffer->lastLoadStateCount -= 1
606 # define gcmVERIFYLOADSTATEDONE(CommandBuffer) \
607 gcmASSERT(CommandBuffer->lastLoadStateCount == 0)
611 # define gcmSTORELOADSTATE(CommandBuffer, Memory, Address, Count)
612 # define gcmVERIFYLOADSTATE(CommandBuffer, Memory, Address)
613 # define gcmVERIFYLOADSTATEDONE(CommandBuffer)
619 # define gcmDEFINESECUREUSER() \
620 gctUINT __secure_user_offset__; \
621 gctUINT32_PTR __secure_user_hintArray__;
623 # define gcmBEGINSECUREUSER() \
624 __secure_user_offset__ = reserve->lastOffset; \
626 __secure_user_hintArray__ = gcmUINT64_TO_PTR(reserve->hintArrayTail)
628 # define gcmENDSECUREUSER() \
629 reserve->hintArrayTail = gcmPTR_TO_UINT64(__secure_user_hintArray__)
631 # define gcmSKIPSECUREUSER() \
632 __secure_user_offset__ += gcmSIZEOF(gctUINT32)
634 # define gcmUPDATESECUREUSER() \
635 *__secure_user_hintArray__ = __secure_user_offset__; \
637 __secure_user_offset__ += gcmSIZEOF(gctUINT32); \
638 __secure_user_hintArray__ += 1
642 # define gcmDEFINESECUREUSER()
643 # define gcmBEGINSECUREUSER()
644 # define gcmENDSECUREUSER()
645 # define gcmSKIPSECUREUSER()
646 # define gcmUPDATESECUREUSER()
650 /*----------------------------------------------------------------------------*/
653 # define gcmDUMPSTATEDATA(StateDelta, FixedPoint, Address, Data) \
656 gcmDUMP(gcvNULL, "@[state.x 0x%04X 0x%08X]", \
662 gcmDUMP(gcvNULL, "@[state 0x%04X 0x%08X]", \
667 # define gcmDUMPSTATEDATA(StateDelta, FixedPoint, Address, Data)
670 /*----------------------------------------------------------------------------*/
672 #define gcmDEFINESTATEBUFFER(CommandBuffer, StateDelta, Memory, ReserveSize) \
673 gcmDEFINESECUREUSER() \
674 gctSIZE_T ReserveSize; \
675 gcoCMDBUF CommandBuffer; \
676 gctUINT32_PTR Memory; \
677 gcsSTATE_DELTA_PTR StateDelta
679 #define gcmBEGINSTATEBUFFER(Hardware, CommandBuffer, StateDelta, Memory, ReserveSize) \
681 gcmONERROR(gcoBUFFER_Reserve( \
682 Hardware->buffer, ReserveSize, gcvTRUE, &CommandBuffer \
685 Memory = gcmUINT64_TO_PTR(CommandBuffer->lastReserve); \
687 StateDelta = Hardware->delta; \
689 gcmBEGINSECUREUSER(); \
692 #define gcmENDSTATEBUFFER(CommandBuffer, Memory, ReserveSize) \
694 gcmENDSECUREUSER(); \
697 gcmUINT64_TO_TYPE(CommandBuffer->lastReserve, gctUINT8_PTR) + ReserveSize \
699 (gctUINT8_PTR) Memory \
703 /*----------------------------------------------------------------------------*/
705 #define gcmBEGINSTATEBATCH(CommandBuffer, Memory, FixedPoint, Address, Count) \
707 gcmASSERT(((Memory - gcmUINT64_TO_TYPE(CommandBuffer->lastReserve, gctUINT32_PTR)) & 1) == 0); \
708 gcmASSERT((gctUINT32)Count <= 1024); \
710 gcmVERIFYLOADSTATEDONE(CommandBuffer); \
712 gcmSTORELOADSTATE(CommandBuffer, Memory, Address, Count); \
715 = gcmSETFIELDVALUE(0, AQ_COMMAND_LOAD_STATE_COMMAND, OPCODE, LOAD_STATE) \
716 | gcmSETFIELD (0, AQ_COMMAND_LOAD_STATE_COMMAND, FLOAT, FixedPoint) \
717 | gcmSETFIELD (0, AQ_COMMAND_LOAD_STATE_COMMAND, COUNT, Count) \
718 | gcmSETFIELD (0, AQ_COMMAND_LOAD_STATE_COMMAND, ADDRESS, Address); \
720 gcmSKIPSECUREUSER(); \
723 #define gcmENDSTATEBATCH(CommandBuffer, Memory) \
725 gcmVERIFYLOADSTATEDONE(CommandBuffer); \
727 gcmASSERT(((Memory - gcmUINT64_TO_TYPE(CommandBuffer->lastReserve, gctUINT32_PTR)) & 1) == 0); \
730 /*----------------------------------------------------------------------------*/
732 #define gcmSETSTATEDATA(StateDelta, CommandBuffer, Memory, FixedPoint, \
735 gctUINT32 __temp_data32__; \
737 gcmVERIFYLOADSTATE(CommandBuffer, Memory, Address); \
739 __temp_data32__ = Data; \
741 *Memory++ = __temp_data32__; \
743 gcoHARDWARE_UpdateDelta( \
744 StateDelta, FixedPoint, Address, 0, __temp_data32__ \
747 gcmDUMPSTATEDATA(StateDelta, FixedPoint, Address, __temp_data32__); \
749 gcmUPDATESECUREUSER(); \
752 #define gcmSETCTRLSTATE(StateDelta, CommandBuffer, Memory, Address, Data) \
754 gctUINT32 __temp_data32__; \
756 gcmVERIFYLOADSTATE(CommandBuffer, Memory, Address); \
758 __temp_data32__ = Data; \
760 *Memory++ = __temp_data32__; \
762 gcmDUMPSTATEDATA(StateDelta, gcvFALSE, Address, __temp_data32__); \
764 gcmSKIPSECUREUSER(); \
767 #define gcmSETFILLER(CommandBuffer, Memory) \
769 gcmVERIFYLOADSTATEDONE(CommandBuffer); \
773 gcmSKIPSECUREUSER(); \
776 /*----------------------------------------------------------------------------*/
778 #define gcmSETSINGLESTATE(StateDelta, CommandBuffer, Memory, FixedPoint, \
781 gcmBEGINSTATEBATCH(CommandBuffer, Memory, FixedPoint, Address, 1); \
782 gcmSETSTATEDATA(StateDelta, CommandBuffer, Memory, FixedPoint, \
784 gcmENDSTATEBATCH(CommandBuffer, Memory); \
787 #define gcmSETSINGLECTRLSTATE(StateDelta, CommandBuffer, Memory, FixedPoint, \
790 gcmBEGINSTATEBATCH(CommandBuffer, Memory, FixedPoint, Address, 1); \
791 gcmSETCTRLSTATE(StateDelta, CommandBuffer, Memory, Address, Data); \
792 gcmENDSTATEBATCH(CommandBuffer, Memory); \
796 /*******************************************************************************
798 ** gcmSETSTARTDECOMMAND
800 ** Form a START_DE command.
804 ** Memory Destination memory pointer of gctUINT32_PTR type.
805 ** Count Number of the rectangles.
808 #define gcmSETSTARTDECOMMAND(Memory, Count) \
811 = gcmSETFIELDVALUE(0, AQ_COMMAND_START_DE_COMMAND, OPCODE, START_DE) \
812 | gcmSETFIELD (0, AQ_COMMAND_START_DE_COMMAND, COUNT, Count) \
813 | gcmSETFIELD (0, AQ_COMMAND_START_DE_COMMAND, DATA_COUNT, 0); \
815 *Memory++ = 0xDEADDEED; \
818 /******************************************************************************\
819 ******************************** Ceiling Macro ********************************
820 \******************************************************************************/
821 #define gcmCEIL(x) ((x - (gctUINT32)x) == 0 ? (gctUINT32)x : (gctUINT32)x + 1)
823 /******************************************************************************\
824 ******************************** Min/Max Macros ********************************
825 \******************************************************************************/
827 #define gcmMIN(x, y) (((x) <= (y)) ? (x) : (y))
828 #define gcmMAX(x, y) (((x) >= (y)) ? (x) : (y))
829 #define gcmCLAMP(x, min, max) (((x) < (min)) ? (min) : \
830 ((x) > (max)) ? (max) : (x))
831 #define gcmABS(x) (((x) < 0) ? -(x) : (x))
832 #define gcmNEG(x) (((x) < 0) ? (x) : -(x))
834 /*******************************************************************************
838 ** Convert a pointer to an integer value.
844 #if defined(_WIN32) || (defined(__LP64__) && __LP64__)
845 # define gcmPTR2INT(p) \
847 (gctUINT32) (gctUINT64) (p) \
850 # define gcmPTR2INT(p) \
856 /*******************************************************************************
860 ** Convert an integer value into a pointer.
867 # define gcmINT2PTR(i) \
869 (gctPOINTER) (gctINT64) (i) \
872 # define gcmINT2PTR(i) \
878 /*******************************************************************************
882 ** Compute the byte offset of a field inside a structure.
889 #define gcmOFFSETOF(s, field) \
891 gcmPTR2INT(& (((struct s *) 0)->field)) \
894 #define gcmSWAB32(x) ((gctUINT32)( \
895 (((gctUINT32)(x) & (gctUINT32)0x000000FFUL) << 24) | \
896 (((gctUINT32)(x) & (gctUINT32)0x0000FF00UL) << 8) | \
897 (((gctUINT32)(x) & (gctUINT32)0x00FF0000UL) >> 8) | \
898 (((gctUINT32)(x) & (gctUINT32)0xFF000000UL) >> 24)))
900 /*******************************************************************************
901 ***** Database ****************************************************************/
903 typedef struct _gcsDATABASE_COUNTERS
905 /* Number of currently allocated bytes. */
908 /* Maximum number of bytes allocated (memory footprint). */
911 /* Total number of bytes allocated. */
912 gctUINT64 totalBytes;
914 gcsDATABASE_COUNTERS;
916 typedef struct _gcuDATABASE_INFO
919 gcsDATABASE_COUNTERS counters;
926 /*******************************************************************************
927 ***** Frame database **********************************************************/
929 /* gcsHAL_FRAME_INFO */
930 typedef struct _gcsHAL_FRAME_INFO
932 /* Current timer tick. */
935 /* Bandwidth counters. */
936 OUT gctUINT readBytes8[8];
937 OUT gctUINT writeBytes8[8];
940 OUT gctUINT cycles[8];
941 OUT gctUINT idleCycles[8];
942 OUT gctUINT mcCycles[8];
943 OUT gctUINT readRequests[8];
944 OUT gctUINT writeRequests[8];
947 OUT gctUINT drawCount;
948 OUT gctUINT vertexOutCount;
949 OUT gctUINT vertexMissCount;
952 OUT gctUINT vertexCount;
953 OUT gctUINT primitiveCount;
954 OUT gctUINT rejectedPrimitives;
955 OUT gctUINT culledPrimitives;
956 OUT gctUINT clippedPrimitives;
957 OUT gctUINT droppedPrimitives;
958 OUT gctUINT frustumClippedPrimitives;
959 OUT gctUINT outPrimitives;
960 OUT gctUINT inPrimitives;
961 OUT gctUINT culledQuadCount;
962 OUT gctUINT totalQuadCount;
963 OUT gctUINT quadCount;
964 OUT gctUINT totalPixelCount;
967 OUT gctUINT colorKilled[8];
968 OUT gctUINT colorDrawn[8];
969 OUT gctUINT depthKilled[8];
970 OUT gctUINT depthDrawn[8];
972 /* Shader counters. */
973 OUT gctUINT shaderCycles;
974 OUT gctUINT vsInstructionCount;
975 OUT gctUINT vsTextureCount;
976 OUT gctUINT vsBranchCount;
977 OUT gctUINT vsVertices;
978 OUT gctUINT psInstructionCount;
979 OUT gctUINT psTextureCount;
980 OUT gctUINT psBranchCount;
981 OUT gctUINT psPixels;
983 /* Texture counters. */
984 OUT gctUINT bilinearRequests;
985 OUT gctUINT trilinearRequests;
986 OUT gctUINT txBytes8[2];
987 OUT gctUINT txHitCount;
988 OUT gctUINT txMissCount;
992 typedef enum _gcePATCH_ID
994 gcePATCH_UNKNOWN = 0xFFFFFFFF,
997 gcePATCH_GLB11 = 0x0,
1008 gcePATCH_SMARTBENCH,
1022 gcePATCH_BUSPARKING3D,
1023 gcePATCH_FISHBOODLE,
1024 gcePATCH_SUBWAYSURFER,
1025 gcePATCH_HIGHWAYDRIVER,
1027 gcePATCH_RACEILLEGAL,
1030 gcePATCH_GALAXYONFIRE2,
1041 gcePATCH_SIEGECRAFT,
1042 gcePATCH_CARCHALLENGE,
1043 gcePATCH_HEROESCALL,
1056 #if gcdLINK_QUEUE_SIZE
1057 typedef struct _gckLINKDATA * gckLINKDATA;
1065 typedef struct _gckLINKQUEUE * gckLINKQUEUE;
1066 struct _gckLINKQUEUE
1068 struct _gckLINKDATA data[gcdLINK_QUEUE_SIZE];
1079 #endif /* __gc_hal_types_h_ */