]> git.karo-electronics.de Git - karo-tx-linux.git/blob - drivers/mxc/gpu-viv/hal/kernel/inc/gc_hal_compiler.h
f8413700031a6f14aea0efee0c87530601c3be95
[karo-tx-linux.git] / drivers / mxc / gpu-viv / hal / kernel / inc / gc_hal_compiler.h
1 /****************************************************************************
2 *
3 *    Copyright (C) 2005 - 2013 by Vivante Corp.
4 *
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.
9 *
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.
14 *
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.
18 *
19 *****************************************************************************/
20
21 /*
22 **      Include file the defines the front- and back-end compilers, as well as the
23 **      objects they use.
24 */
25
26 #ifndef __gc_hal_compiler_h_
27 #define __gc_hal_compiler_h_
28
29 #ifndef VIVANTE_NO_3D
30 #include "gc_hal_types.h"
31 #include "gc_hal_engine.h"
32
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36
37 #ifndef GC_ENABLE_LOADTIME_OPT
38 #define GC_ENABLE_LOADTIME_OPT           1
39 #endif
40
41 #define TEMP_OPT_CONSTANT_TEXLD_COORD    0
42
43 #define TEMP_SHADER_PATCH                1
44
45 #define TEMP_INLINE_ALL_EXPANSION            1
46 /******************************* IR VERSION ******************/
47 #define gcdSL_IR_VERSION gcmCC('\0','\0','\0','\1')
48
49 /******************************************************************************\
50 |******************************* SHADER LANGUAGE ******************************|
51 \******************************************************************************/
52
53     /* allocator/deallocator function pointer */
54 typedef gceSTATUS (*gctAllocatorFunc)(
55     IN gctSIZE_T Bytes,
56     OUT gctPOINTER * Memory
57     );
58
59 typedef gceSTATUS (*gctDeallocatorFunc)(
60     IN gctPOINTER Memory
61     );
62
63 typedef gctBOOL (*compareFunc) (
64      IN void *    data,
65      IN void *    key
66      );
67
68 typedef struct _gcsListNode gcsListNode;
69 struct _gcsListNode
70 {
71     gcsListNode *       next;
72     void *              data;
73 };
74
75 typedef struct _gcsAllocator
76 {
77     gctAllocatorFunc    allocate;
78     gctDeallocatorFunc  deallocate;
79 } gcsAllocator;
80
81 /* simple map structure */
82 typedef struct _SimpleMap SimpleMap;
83 struct _SimpleMap
84 {
85     gctUINT32     key;
86     gctUINT32     val;
87     SimpleMap    *next;
88     gcsAllocator *allocator;
89
90 };
91
92 /* SimpleMap Operations */
93 /* return -1 if not found, otherwise return the mapped value */
94 gctUINT32
95 gcSimpleMap_Find(
96      IN SimpleMap *Map,
97      IN gctUINT32    Key
98      );
99
100 gceSTATUS
101 gcSimpleMap_Destory(
102      IN SimpleMap *    Map,
103      IN gcsAllocator * Allocator
104      );
105
106 /* Add a pair <Key, Val> to the Map head, the user should be aware that the
107  * map pointer is always changed when adding a new node :
108  *
109  *   gcSimpleMap_AddNode(&theMap, key, val, allocator);
110  *
111  */
112 gceSTATUS
113 gcSimpleMap_AddNode(
114      IN SimpleMap **   Map,
115      IN gctUINT32      Key,
116      IN gctUINT32      Val,
117      IN gcsAllocator * Allocator
118      );
119
120 /* gcsList data structure and related operations */
121 typedef struct _gcsList
122 {
123     gcsListNode  *head;
124     gcsListNode  *tail;
125     gctINT        count;
126     gcsAllocator *allocator;
127 } gcsList;
128
129 /* List operations */
130 void
131 gcList_Init(
132     IN gcsList *list,
133     IN gcsAllocator *allocator
134     );
135
136 gceSTATUS
137 gcList_CreateNode(
138     IN void *             Data,
139     IN gctAllocatorFunc   Allocator,
140     OUT gcsListNode **    ListNode
141     );
142
143 gceSTATUS
144 gcList_Clean(
145     IN gcsList *          List,
146     IN gctBOOL            FreeData
147     );
148
149 gcsListNode *
150 gcList_FindNode(
151     IN gcsList *      List,
152     IN void *         Key,
153     IN compareFunc    compare
154     );
155
156 gceSTATUS
157 gcList_AddNode(
158     IN gcsList *          List,
159     IN void *             Data
160     );
161
162 gceSTATUS
163 gcList_RemoveNode(
164     IN gcsList *          List,
165     IN gcsListNode *      Node
166     );
167
168 /*  link list structure for code list */
169 typedef gcsList gcsCodeList;
170 typedef gcsCodeList * gctCodeList;
171 typedef gcsListNode gcsCodeListNode;
172
173 /* Possible shader language opcodes. */
174 typedef enum _gcSL_OPCODE
175 {
176         gcSL_NOP,                                                       /* 0x00 */
177         gcSL_MOV,                                                       /* 0x01 */
178         gcSL_SAT,                                                       /* 0x02 */
179         gcSL_DP3,                                                       /* 0x03 */
180         gcSL_DP4,                                                       /* 0x04 */
181         gcSL_ABS,                                                       /* 0x05 */
182         gcSL_JMP,                                                       /* 0x06 */
183         gcSL_ADD,                                                       /* 0x07 */
184         gcSL_MUL,                                                       /* 0x08 */
185         gcSL_RCP,                                                       /* 0x09 */
186         gcSL_SUB,                                                       /* 0x0A */
187         gcSL_KILL,                                                      /* 0x0B */
188         gcSL_TEXLD,                                                     /* 0x0C */
189         gcSL_CALL,                                                      /* 0x0D */
190         gcSL_RET,                                                       /* 0x0E */
191         gcSL_NORM,                                                      /* 0x0F */
192         gcSL_MAX,                                                       /* 0x10 */
193         gcSL_MIN,                                                       /* 0x11 */
194         gcSL_POW,                                                       /* 0x12 */
195         gcSL_RSQ,                                                       /* 0x13 */
196         gcSL_LOG,                                                       /* 0x14 */
197         gcSL_FRAC,                                                      /* 0x15 */
198         gcSL_FLOOR,                                                     /* 0x16 */
199         gcSL_CEIL,                                                      /* 0x17 */
200         gcSL_CROSS,                                                     /* 0x18 */
201         gcSL_TEXLDP,                                            /* 0x19 */
202         gcSL_TEXBIAS,                                           /* 0x1A */
203         gcSL_TEXGRAD,                                           /* 0x1B */
204         gcSL_TEXLOD,                                            /* 0x1C */
205         gcSL_SIN,                                                       /* 0x1D */
206         gcSL_COS,                                                       /* 0x1E */
207         gcSL_TAN,                                                       /* 0x1F */
208         gcSL_EXP,                                                       /* 0x20 */
209         gcSL_SIGN,                                                      /* 0x21 */
210         gcSL_STEP,                                                      /* 0x22 */
211         gcSL_SQRT,                                                      /* 0x23 */
212         gcSL_ACOS,                                                      /* 0x24 */
213         gcSL_ASIN,                                                      /* 0x25 */
214         gcSL_ATAN,                                                      /* 0x26 */
215         gcSL_SET,                                                       /* 0x27 */
216         gcSL_DSX,                                                       /* 0x28 */
217         gcSL_DSY,                                                       /* 0x29 */
218         gcSL_FWIDTH,                                            /* 0x2A */
219         gcSL_DIV,                                               /* 0x2B */
220         gcSL_MOD,                                               /* 0x2C */
221         gcSL_AND_BITWISE,                                       /* 0x2D */
222         gcSL_OR_BITWISE,                                        /* 0x2E */
223         gcSL_XOR_BITWISE,                                       /* 0x2F */
224         gcSL_NOT_BITWISE,                                       /* 0x30 */
225         gcSL_LSHIFT,                                            /* 0x31 */
226         gcSL_RSHIFT,                                            /* 0x32 */
227         gcSL_ROTATE,                                            /* 0x33 */
228         gcSL_BITSEL,                                            /* 0x34 */
229         gcSL_LEADZERO,                                          /* 0x35 */
230         gcSL_LOAD,                                                      /* 0x36 */
231         gcSL_STORE,                                                     /* 0x37 */
232         gcSL_BARRIER,                                           /* 0x38 */
233         gcSL_STORE1,                                            /* 0x39 */
234         gcSL_ATOMADD,                                           /* 0x3A */
235         gcSL_ATOMSUB,                                           /* 0x3B */
236         gcSL_ATOMXCHG,                                          /* 0x3C */
237         gcSL_ATOMCMPXCHG,                                       /* 0x3D */
238         gcSL_ATOMMIN,                                           /* 0x3E */
239         gcSL_ATOMMAX,                                           /* 0x3F */
240         gcSL_ATOMOR,                                            /* 0x40 */
241         gcSL_ATOMAND,                                           /* 0x41 */
242         gcSL_ATOMXOR,                                           /* 0x42 */
243         /*gcSL_UNUSED,                                           0x43 */
244         /*gcSL_UNUSED,                                           0x44 */
245         /*gcSL_UNUSED,                                           0x45 */
246         /*gcSL_UNUSED,                                           0x46 */
247         /*gcSL_UNUSED,                                           0x47 */
248         /*gcSL_UNUSED,                                           0x48 */
249         /*gcSL_UNUSED,                                           0x49 */
250         /*gcSL_UNUSED,                                           0x4A */
251         /*gcSL_UNUSED,                                           0x4B */
252         /*gcSL_UNUSED,                                           0x4C */
253         /*gcSL_UNUSED,                                           0x4D */
254         /*gcSL_UNUSED,                                           0x4E */
255         /*gcSL_UNUSED,                                           0x4F */
256         /*gcSL_UNUSED,                                           0x50 */
257         /*gcSL_UNUSED,                                           0x51 */
258         /*gcSL_UNUSED,                                           0x52 */
259         gcSL_ADDLO = 0x53,                                      /* 0x53 */  /* Float only. */
260         gcSL_MULLO,                                                     /* 0x54 */  /* Float only. */
261         gcSL_CONV,                                                      /* 0x55 */
262         gcSL_GETEXP,                                            /* 0x56 */
263         gcSL_GETMANT,                                           /* 0x57 */
264         gcSL_MULHI,                                                     /* 0x58 */  /* Integer only. */
265         gcSL_CMP,                                                       /* 0x59 */
266         gcSL_I2F,                                                       /* 0x5A */
267         gcSL_F2I,                                                       /* 0x5B */
268         gcSL_ADDSAT,                                            /* 0x5C */  /* Integer only. */
269         gcSL_SUBSAT,                                            /* 0x5D */  /* Integer only. */
270         gcSL_MULSAT,                                            /* 0x5E */  /* Integer only. */
271         gcSL_DP2,                                                       /* 0x5F */
272         gcSL_MAXOPCODE
273 }
274 gcSL_OPCODE;
275
276 typedef enum _gcSL_FORMAT
277 {
278         gcSL_FLOAT = 0,                                         /* 0 */
279         gcSL_INTEGER = 1,                                   /* 1 */
280         gcSL_INT32 = 1,                                     /* 1 */
281         gcSL_BOOLEAN = 2,                                       /* 2 */
282         gcSL_UINT32 = 3,                                        /* 3 */
283         gcSL_INT8,                                                  /* 4 */
284         gcSL_UINT8,                                                 /* 5 */
285         gcSL_INT16,                                                 /* 6 */
286         gcSL_UINT16,                                            /* 7 */
287         gcSL_INT64,                                                 /* 8 */     /* Reserved for future enhancement. */
288         gcSL_UINT64,                                            /* 9 */     /* Reserved for future enhancement. */
289         gcSL_INT128,                                        /* 10 */    /* Reserved for future enhancement. */
290         gcSL_UINT128,                                           /* 11 */    /* Reserved for future enhancement. */
291         gcSL_FLOAT16,                                       /* 12 */
292         gcSL_FLOAT64,                                           /* 13 */    /* Reserved for future enhancement. */
293         gcSL_FLOAT128,                                          /* 14 */    /* Reserved for future enhancement. */
294 }
295 gcSL_FORMAT;
296
297 /* Destination write enable bits. */
298 typedef enum _gcSL_ENABLE
299 {
300     gcSL_ENABLE_NONE                    = 0x0,     /* none is enabled, error/uninitialized state */
301         gcSL_ENABLE_X                                           = 0x1,
302         gcSL_ENABLE_Y                                           = 0x2,
303         gcSL_ENABLE_Z                                           = 0x4,
304         gcSL_ENABLE_W                                           = 0x8,
305         /* Combinations. */
306         gcSL_ENABLE_XY                                          = gcSL_ENABLE_X | gcSL_ENABLE_Y,
307         gcSL_ENABLE_XYZ                                         = gcSL_ENABLE_X | gcSL_ENABLE_Y | gcSL_ENABLE_Z,
308         gcSL_ENABLE_XYZW                                        = gcSL_ENABLE_X | gcSL_ENABLE_Y | gcSL_ENABLE_Z | gcSL_ENABLE_W,
309         gcSL_ENABLE_XYW                                         = gcSL_ENABLE_X | gcSL_ENABLE_Y | gcSL_ENABLE_W,
310         gcSL_ENABLE_XZ                                          = gcSL_ENABLE_X | gcSL_ENABLE_Z,
311         gcSL_ENABLE_XZW                                         = gcSL_ENABLE_X | gcSL_ENABLE_Z | gcSL_ENABLE_W,
312         gcSL_ENABLE_XW                                          = gcSL_ENABLE_X | gcSL_ENABLE_W,
313         gcSL_ENABLE_YZ                                          = gcSL_ENABLE_Y | gcSL_ENABLE_Z,
314         gcSL_ENABLE_YZW                                         = gcSL_ENABLE_Y | gcSL_ENABLE_Z | gcSL_ENABLE_W,
315         gcSL_ENABLE_YW                                          = gcSL_ENABLE_Y | gcSL_ENABLE_W,
316         gcSL_ENABLE_ZW                                          = gcSL_ENABLE_Z | gcSL_ENABLE_W,
317 }
318 gcSL_ENABLE;
319
320 /* Possible indices. */
321 typedef enum _gcSL_INDEXED
322 {
323         gcSL_NOT_INDEXED,                                       /* 0 */
324         gcSL_INDEXED_X,                                         /* 1 */
325         gcSL_INDEXED_Y,                                         /* 2 */
326         gcSL_INDEXED_Z,                                         /* 3 */
327         gcSL_INDEXED_W,                                         /* 4 */
328 }
329 gcSL_INDEXED;
330
331 /* Opcode conditions. */
332 typedef enum _gcSL_CONDITION
333 {
334         gcSL_ALWAYS,                                            /* 0x0 */
335         gcSL_NOT_EQUAL,                                         /* 0x1 */
336         gcSL_LESS_OR_EQUAL,                                     /* 0x2 */
337         gcSL_LESS,                                                      /* 0x3 */
338         gcSL_EQUAL,                                                     /* 0x4 */
339         gcSL_GREATER,                                           /* 0x5 */
340         gcSL_GREATER_OR_EQUAL,                          /* 0x6 */
341         gcSL_AND,                                                       /* 0x7 */
342         gcSL_OR,                                                        /* 0x8 */
343         gcSL_XOR,                                                       /* 0x9 */
344     gcSL_NOT_ZERO,                      /* 0xA */
345 }
346 gcSL_CONDITION;
347
348 /* Possible source operand types. */
349 typedef enum _gcSL_TYPE
350 {
351         gcSL_NONE,                                                      /* 0x0 */
352         gcSL_TEMP,                                                      /* 0x1 */
353         gcSL_ATTRIBUTE,                                         /* 0x2 */
354         gcSL_UNIFORM,                                           /* 0x3 */
355         gcSL_SAMPLER,                                           /* 0x4 */
356         gcSL_CONSTANT,                                          /* 0x5 */
357         gcSL_OUTPUT,                                            /* 0x6 */
358         gcSL_PHYSICAL,                                          /* 0x7 */
359 }
360 gcSL_TYPE;
361
362 /* Swizzle generator macro. */
363 #define gcmSWIZZLE(Component1, Component2, Component3, Component4) \
364 ( \
365         (gcSL_SWIZZLE_ ## Component1 << 0) | \
366         (gcSL_SWIZZLE_ ## Component2 << 2) | \
367         (gcSL_SWIZZLE_ ## Component3 << 4) | \
368         (gcSL_SWIZZLE_ ## Component4 << 6)   \
369 )
370
371 #define gcmExtractSwizzle(Swizzle, Index) \
372     ((gcSL_SWIZZLE) ((((Swizzle) >> (Index * 2)) & 0x3)))
373
374 #define gcmComposeSwizzle(SwizzleX, SwizzleY, SwizzleZ, SwizzleW) \
375 ( \
376         ((SwizzleX) << 0) | \
377         ((SwizzleY) << 2) | \
378         ((SwizzleZ) << 4) | \
379         ((SwizzleW) << 6)   \
380 )
381
382 /* Possible swizzle values. */
383 typedef enum _gcSL_SWIZZLE
384 {
385         gcSL_SWIZZLE_X,                                         /* 0x0 */
386         gcSL_SWIZZLE_Y,                                         /* 0x1 */
387         gcSL_SWIZZLE_Z,                                         /* 0x2 */
388         gcSL_SWIZZLE_W,                                         /* 0x3 */
389         /* Combinations. */
390         gcSL_SWIZZLE_XXXX = gcmSWIZZLE(X, X, X, X),
391         gcSL_SWIZZLE_YYYY = gcmSWIZZLE(Y, Y, Y, Y),
392         gcSL_SWIZZLE_ZZZZ = gcmSWIZZLE(Z, Z, Z, Z),
393         gcSL_SWIZZLE_WWWW = gcmSWIZZLE(W, W, W, W),
394         gcSL_SWIZZLE_XYYY = gcmSWIZZLE(X, Y, Y, Y),
395         gcSL_SWIZZLE_XZZZ = gcmSWIZZLE(X, Z, Z, Z),
396         gcSL_SWIZZLE_XWWW = gcmSWIZZLE(X, W, W, W),
397         gcSL_SWIZZLE_YZZZ = gcmSWIZZLE(Y, Z, Z, Z),
398         gcSL_SWIZZLE_YWWW = gcmSWIZZLE(Y, W, W, W),
399         gcSL_SWIZZLE_ZWWW = gcmSWIZZLE(Z, W, W, W),
400         gcSL_SWIZZLE_XYZZ = gcmSWIZZLE(X, Y, Z, Z),
401         gcSL_SWIZZLE_XYWW = gcmSWIZZLE(X, Y, W, W),
402         gcSL_SWIZZLE_XZWW = gcmSWIZZLE(X, Z, W, W),
403         gcSL_SWIZZLE_YZWW = gcmSWIZZLE(Y, Z, W, W),
404         gcSL_SWIZZLE_XXYZ = gcmSWIZZLE(X, X, Y, Z),
405         gcSL_SWIZZLE_XYZW = gcmSWIZZLE(X, Y, Z, W),
406         gcSL_SWIZZLE_XYXY = gcmSWIZZLE(X, Y, X, Y),
407         gcSL_SWIZZLE_YYZZ = gcmSWIZZLE(Y, Y, Z, Z),
408         gcSL_SWIZZLE_YYWW = gcmSWIZZLE(Y, Y, W, W),
409         gcSL_SWIZZLE_ZZZW = gcmSWIZZLE(Z, Z, Z, W),
410         gcSL_SWIZZLE_XZZW = gcmSWIZZLE(X, Z, Z, W),
411         gcSL_SWIZZLE_YYZW = gcmSWIZZLE(Y, Y, Z, W),
412
413     gcSL_SWIZZLE_INVALID = 0x7FFFFFFF
414 }
415 gcSL_SWIZZLE;
416
417 typedef enum _gcSL_COMPONENT
418 {
419         gcSL_COMPONENT_X,               /* 0x0 */
420         gcSL_COMPONENT_Y,               /* 0x1 */
421         gcSL_COMPONENT_Z,               /* 0x2 */
422         gcSL_COMPONENT_W,               /* 0x3 */
423     gcSL_COMPONENT_COUNT            /* 0x4 */
424 } gcSL_COMPONENT;
425
426 #define gcmIsComponentEnabled(Enable, Component) (((Enable) & (1 << (Component))) != 0)
427
428 /******************************************************************************\
429 |*********************************** SHADERS **********************************|
430 \******************************************************************************/
431
432 /* Shader types. */
433 typedef enum _gcSHADER_KIND {
434     gcSHADER_TYPE_UNKNOWN = 0,
435     gcSHADER_TYPE_VERTEX,
436     gcSHADER_TYPE_FRAGMENT,
437     gcSHADER_TYPE_CL,
438     gcSHADER_TYPE_PRECOMPILED,
439     gcSHADER_KIND_COUNT
440 } gcSHADER_KIND;
441
442 typedef enum _gcGL_DRIVER_VERSION {
443     gcGL_DRIVER_ES11,    /* OpenGL ES 1.1 */
444     gcGL_DRIVER_ES20,    /* OpenGL ES 2.0 */
445     gcGL_DRIVER_ES30     /* OpenGL ES 3.0 */
446 } gcGL_DRIVER_VERSION;
447
448 /* gcSHADER objects. */
449 typedef struct _gcSHADER *              gcSHADER;
450 typedef struct _gcATTRIBUTE *                   gcATTRIBUTE;
451 typedef struct _gcUNIFORM *             gcUNIFORM;
452 typedef struct _gcOUTPUT *              gcOUTPUT;
453 typedef struct _gcsFUNCTION *                   gcFUNCTION;
454 typedef struct _gcsKERNEL_FUNCTION *    gcKERNEL_FUNCTION;
455 typedef struct _gcsHINT *               gcsHINT_PTR;
456 typedef struct _gcSHADER_PROFILER *     gcSHADER_PROFILER;
457 typedef struct _gcVARIABLE *                    gcVARIABLE;
458
459 struct _gcsHINT
460 {
461     /* Numbr of data transfers for Vertex Shader output. */
462     gctUINT32   vsOutputCount;
463
464     /* Flag whether the VS has point size or not. */
465     gctBOOL     vsHasPointSize;
466
467 #if gcdUSE_WCLIP_PATCH
468     /* Flag whether the VS gl_position.z depends on gl_position.w
469        it's a hint for wclipping */
470     gctBOOL     vsPositionZDependsOnW;
471 #endif
472
473     gctBOOL     clipW;
474
475     /* Flag whether or not the shader has a KILL instruction. */
476     gctBOOL     hasKill;
477
478     /* Element count. */
479     gctUINT32   elementCount;
480
481     /* Component count. */
482     gctUINT32   componentCount;
483
484     /* Number of data transfers for Fragment Shader input. */
485     gctUINT32   fsInputCount;
486
487     /* Maximum number of temporary registers used in FS. */
488     gctUINT32   fsMaxTemp;
489
490         /* Maximum number of temporary registers used in VS. */
491         gctUINT32   vsMaxTemp;
492
493     /* Balance minimum. */
494     gctUINT32   balanceMin;
495
496     /* Balance maximum. */
497     gctUINT32   balanceMax;
498
499     /* Auto-shift balancing. */
500     gctBOOL     autoShift;
501
502     /* Flag whether the PS outputs the depth value or not. */
503     gctBOOL     psHasFragDepthOut;
504
505         /* Flag whether the ThreadWalker is in PS. */
506         gctBOOL         threadWalkerInPS;
507
508     /* HW reg number for position of VS */
509     gctUINT32   hwRegNoOfSIVPos;
510
511 #if gcdALPHA_KILL_IN_SHADER
512     /* States to set when alpha kill is enabled. */
513     gctUINT32   killStateAddress;
514     gctUINT32   alphaKillStateValue;
515     gctUINT32   colorKillStateValue;
516
517     /* Shader instructiuon. */
518     gctUINT32   killInstructionAddress;
519     gctUINT32   alphaKillInstruction[3];
520     gctUINT32   colorKillInstruction[3];
521 #endif
522
523 #if TEMP_SHADER_PATCH
524         gctUINT32       pachedShaderIdentifier;
525 #endif
526 };
527
528 #if TEMP_SHADER_PATCH
529 #define INVALID_SHADER_IDENTIFIER 0xFFFFFFFF
530 #endif
531
532 /* gcSHADER_TYPE enumeration. */
533 typedef enum _gcSHADER_TYPE
534 {
535     gcSHADER_FLOAT_X1   = 0,        /* 0x00 */
536     gcSHADER_FLOAT_X2,                          /* 0x01 */
537         gcSHADER_FLOAT_X3,                              /* 0x02 */
538         gcSHADER_FLOAT_X4,                              /* 0x03 */
539         gcSHADER_FLOAT_2X2,                             /* 0x04 */
540         gcSHADER_FLOAT_3X3,                             /* 0x05 */
541         gcSHADER_FLOAT_4X4,                             /* 0x06 */
542         gcSHADER_BOOLEAN_X1,                    /* 0x07 */
543         gcSHADER_BOOLEAN_X2,                    /* 0x08 */
544         gcSHADER_BOOLEAN_X3,                    /* 0x09 */
545         gcSHADER_BOOLEAN_X4,                    /* 0x0A */
546         gcSHADER_INTEGER_X1,                    /* 0x0B */
547         gcSHADER_INTEGER_X2,                    /* 0x0C */
548         gcSHADER_INTEGER_X3,                    /* 0x0D */
549         gcSHADER_INTEGER_X4,                    /* 0x0E */
550         gcSHADER_SAMPLER_1D,                    /* 0x0F */
551         gcSHADER_SAMPLER_2D,                    /* 0x10 */
552         gcSHADER_SAMPLER_3D,                    /* 0x11 */
553         gcSHADER_SAMPLER_CUBIC,                 /* 0x12 */
554         gcSHADER_FIXED_X1,                              /* 0x13 */
555         gcSHADER_FIXED_X2,                              /* 0x14 */
556         gcSHADER_FIXED_X3,                              /* 0x15 */
557         gcSHADER_FIXED_X4,                              /* 0x16 */
558         gcSHADER_IMAGE_2D,                              /* 0x17 */  /* For OCL. */
559         gcSHADER_IMAGE_3D,                              /* 0x18 */  /* For OCL. */
560         gcSHADER_SAMPLER,                               /* 0x19 */  /* For OCL. */
561         gcSHADER_FLOAT_2X3,                             /* 0x1A */
562         gcSHADER_FLOAT_2X4,                             /* 0x1B */
563         gcSHADER_FLOAT_3X2,                             /* 0x1C */
564         gcSHADER_FLOAT_3X4,                             /* 0x1D */
565         gcSHADER_FLOAT_4X2,                             /* 0x1E */
566         gcSHADER_FLOAT_4X3,                             /* 0x1F */
567         gcSHADER_ISAMPLER_2D,                   /* 0x20 */
568         gcSHADER_ISAMPLER_3D,                   /* 0x21 */
569         gcSHADER_ISAMPLER_CUBIC,                /* 0x22 */
570         gcSHADER_USAMPLER_2D,                   /* 0x23 */
571         gcSHADER_USAMPLER_3D,                   /* 0x24 */
572         gcSHADER_USAMPLER_CUBIC,                /* 0x25 */
573         gcSHADER_SAMPLER_EXTERNAL_OES,          /* 0x26 */
574
575         gcSHADER_UINT_X1,                       /* 0x27 */
576         gcSHADER_UINT_X2,                       /* 0x28 */
577         gcSHADER_UINT_X3,                       /* 0x29 */
578         gcSHADER_UINT_X4,                       /* 0x2A */
579
580     gcSHADER_UNKONWN_TYPE,      /* do not add type after this */
581     gcSHADER_TYPE_COUNT         /* must to change gcvShaderTypeInfo at the
582                                  * same time if you add any new type! */}
583 gcSHADER_TYPE;
584
585 typedef enum _gcSHADER_TYPE_KIND
586 {
587     gceTK_UNKOWN,
588     gceTK_FLOAT,
589     gceTK_INT,
590     gceTK_UINT,
591     gceTK_BOOL,
592     gceTK_FIXED,
593     gceTK_SAMPLER,
594     gceTK_IMAGE,
595     gceTK_OTHER
596 } gcSHADER_TYPE_KIND;
597
598 typedef struct _gcSHADER_TYPEINFO
599 {
600     gcSHADER_TYPE      type;              /* e.g. gcSHADER_FLOAT_2X4 */
601     gctINT             components;        /* e.g. 4 components       */
602     gctINT             rows;              /* e.g. 2 rows             */
603     gcSHADER_TYPE      componentType;     /* e.g. gcSHADER_FLOAT_X4  */
604     gcSHADER_TYPE_KIND kind;              /* e.g. gceTK_FLOAT */
605     gctCONST_STRING    name;              /* e.g. "FLOAT_2X4" */
606 } gcSHADER_TYPEINFO;
607
608 extern gcSHADER_TYPEINFO gcvShaderTypeInfo[];
609
610 #define gcmType_Comonents(Type)    (gcvShaderTypeInfo[Type].components)
611 #define gcmType_Rows(Type)         (gcvShaderTypeInfo[Type].rows)
612 #define gcmType_ComonentType(Type) (gcvShaderTypeInfo[Type].componentType)
613 #define gcmType_Kind(Type)         (gcvShaderTypeInfo[Type].kind)
614 #define gcmType_Name(Type)         (gcvShaderTypeInfo[Type].name)
615
616 #define gcmType_isMatrix(type) (gcmType_Rows(type) > 1)
617
618 typedef enum _gcSHADER_VAR_CATEGORY
619 {
620     gcSHADER_VAR_CATEGORY_NORMAL  =  0, /* primitive type and its array */
621     gcSHADER_VAR_CATEGORY_STRUCT  =  1  /* structure */
622 }
623 gcSHADER_VAR_CATEGORY;
624
625 typedef enum _gceTYPE_QUALIFIER
626 {
627     gcvTYPE_QUALIFIER_NONE         = 0x0, /* unqualified */
628     gcvTYPE_QUALIFIER_VOLATILE     = 0x1, /* volatile */
629 }gceTYPE_QUALIFIER;
630
631 typedef gctUINT16  gctTYPE_QUALIFIER;
632
633 #if GC_ENABLE_LOADTIME_OPT
634 typedef struct _gcSHADER_TYPE_INFO
635 {
636     gcSHADER_TYPE    type;        /* eg. gcSHADER_FLOAT_2X3 is the type */
637     gctCONST_STRING  name;        /* the name of the type: "gcSHADER_FLOAT_2X3" */
638     gcSHADER_TYPE    baseType;    /* its base type is gcSHADER_FLOAT_2 */
639     gctINT           components;  /* it has 2 components */
640     gctINT           rows;        /* and 3 rows */
641     gctINT           size;        /* the size in byte */
642 } gcSHADER_TYPE_INFO;
643
644 extern gcSHADER_TYPE_INFO shader_type_info[];
645
646 enum gceLTCDumpOption {
647     gceLTC_DUMP_UNIFORM      = 0x0001,
648     gceLTC_DUMP_EVALUATION   = 0x0002,
649     gceLTC_DUMP_EXPESSION    = 0x0004,
650     gceLTC_DUMP_COLLECTING   = 0x0008,
651 };
652
653 gctBOOL gcDumpOption(gctINT Opt);
654
655 #endif /* GC_ENABLE_LOADTIME_OPT */
656
657 #define IS_MATRIX_TYPE(type) \
658     (((type >= gcSHADER_FLOAT_2X2) && (type <= gcSHADER_FLOAT_4X4)) || \
659      ((type >= gcSHADER_FLOAT_2X3) && (type <= gcSHADER_FLOAT_4X3)))
660
661 /* gcSHADER_PRECISION enumeration. */
662 typedef enum _gcSHADER_PRECISION
663 {
664         gcSHADER_PRECISION_DEFAULT,                             /* 0x00 */
665         gcSHADER_PRECISION_HIGH,                                /* 0x01 */
666         gcSHADER_PRECISION_MEDIUM,                              /* 0x02 */
667         gcSHADER_PRECISION_LOW,                             /* 0x03 */
668 }
669 gcSHADER_PRECISION;
670
671 /* Shader flags. */
672 typedef enum _gceSHADER_FLAGS
673 {
674     gcvSHADER_NO_OPTIMIZATION           = 0x00,
675         gcvSHADER_DEAD_CODE                                     = 0x01,
676         gcvSHADER_RESOURCE_USAGE                        = 0x02,
677         gcvSHADER_OPTIMIZER                                     = 0x04,
678         gcvSHADER_USE_GL_Z                                      = 0x08,
679     /*
680         The GC family of GPU cores model GC860 and under require the Z
681         to be from 0 <= z <= w.
682         However, OpenGL specifies the Z to be from -w <= z <= w.  So we
683         have to a conversion here:
684
685             z = (z + w) / 2.
686
687         So here we append two instructions to the vertex shader.
688     */
689         gcvSHADER_USE_GL_POSITION                       = 0x10,
690         gcvSHADER_USE_GL_FACE                           = 0x20,
691         gcvSHADER_USE_GL_POINT_COORD            = 0x40,
692         gcvSHADER_LOADTIME_OPTIMIZER            = 0x80,
693 #if gcdALPHA_KILL_IN_SHADER
694     gcvSHADER_USE_ALPHA_KILL            = 0x100,
695 #endif
696
697 #if gcdPRE_ROTATION && (ANDROID_SDK_VERSION >= 14)
698     gcvSHADER_VS_PRE_ROTATION           = 0x200,
699 #endif
700
701 #if TEMP_INLINE_ALL_EXPANSION
702     gcvSHADER_INLINE_ALL_EXPANSION      = 0x400,
703 #endif
704 }
705 gceSHADER_FLAGS;
706
707 gceSTATUS
708 gcSHADER_CheckClipW(
709     IN gctCONST_STRING VertexSource,
710     IN gctCONST_STRING FragmentSource,
711     OUT gctBOOL * clipW);
712
713 /*******************************************************************************
714 **  gcSHADER_GetUniformVectorCount
715 **
716 **  Get the number of vectors used by uniforms for this shader.
717 **
718 **  INPUT:
719 **
720 **      gcSHADER Shader
721 **          Pointer to a gcSHADER object.
722 **
723 **  OUTPUT:
724 **
725 **      gctSIZE_T * Count
726 **          Pointer to a variable receiving the number of vectors.
727 */
728 gceSTATUS
729 gcSHADER_GetUniformVectorCount(
730     IN gcSHADER Shader,
731     OUT gctSIZE_T * Count
732     );
733
734 /*******************************************************************************
735 **                                                      gcOptimizer Data Structures
736 *******************************************************************************/
737 typedef enum _gceSHADER_OPTIMIZATION
738 {
739     /*  No optimization. */
740         gcvOPTIMIZATION_NONE,
741
742     /*  Flow graph construction. */
743         gcvOPTIMIZATION_CONSTRUCTION                = 1 << 0,
744
745     /*  Dead code elimination. */
746         gcvOPTIMIZATION_DEAD_CODE                   = 1 << 1,
747
748     /*  Redundant move instruction elimination. */
749         gcvOPTIMIZATION_REDUNDANT_MOVE              = 1 << 2,
750
751     /*  Inline expansion. */
752         gcvOPTIMIZATION_INLINE_EXPANSION            = 1 << 3,
753
754     /*  Constant propagation. */
755         gcvOPTIMIZATION_CONSTANT_PROPAGATION        = 1 << 4,
756
757     /*  Redundant bounds/checking elimination. */
758         gcvOPTIMIZATION_REDUNDANT_CHECKING          = 1 << 5,
759
760     /*  Loop invariant movement. */
761         gcvOPTIMIZATION_LOOP_INVARIANT              = 1 << 6,
762
763     /*  Induction variable removal. */
764         gcvOPTIMIZATION_INDUCTION_VARIABLE          = 1 << 7,
765
766     /*  Common subexpression elimination. */
767         gcvOPTIMIZATION_COMMON_SUBEXPRESSION        = 1 << 8,
768
769     /*  Control flow/banch optimization. */
770         gcvOPTIMIZATION_CONTROL_FLOW                = 1 << 9,
771
772     /*  Vector component operation merge. */
773         gcvOPTIMIZATION_VECTOR_INSTRUCTION_MERGE    = 1 << 10,
774
775     /*  Algebra simplificaton. */
776         gcvOPTIMIZATION_ALGEBRAIC_SIMPLIFICATION    = 1 << 11,
777
778     /*  Pattern matching and replacing. */
779         gcvOPTIMIZATION_PATTERN_MATCHING            = 1 << 12,
780
781     /*  Interprocedural constant propagation. */
782         gcvOPTIMIZATION_IP_CONSTANT_PROPAGATION     = 1 << 13,
783
784     /*  Interprecedural register optimization. */
785         gcvOPTIMIZATION_IP_REGISTRATION             = 1 << 14,
786
787     /*  Optimization option number. */
788         gcvOPTIMIZATION_OPTION_NUMBER               = 1 << 15,
789
790         /*  Loadtime constant. */
791     gcvOPTIMIZATION_LOADTIME_CONSTANT           = 1 << 16,
792
793     /*  MAD instruction optimization. */
794         gcvOPTIMIZATION_MAD_INSTRUCTION             = 1 << 17,
795
796     /*  Special optimization for LOAD SW workaround. */
797         gcvOPTIMIZATION_LOAD_SW_WORKAROUND          = 1 << 18,
798
799     /* move code into conditional block if possile */
800         gcvOPTIMIZATION_CONDITIONALIZE              = 1 << 19,
801
802     /* expriemental: power optimization mode
803         1. add extra dummy texld to tune performance
804         2. insert NOP after high power instrucitons
805         3. split high power vec3/vec4 instruciton to vec2/vec1 operation
806         4. ...
807      */
808         gcvOPTIMIZATION_POWER_OPTIMIZATION           = 1 << 20,
809
810     /* optimize varying packing */
811     gcvOPTIMIZATION_VARYINGPACKING              = 1 << 22,
812
813 #if TEMP_INLINE_ALL_EXPANSION
814         gcvOPTIMIZATION_INLINE_ALL_EXPANSION        = 1 << 23,
815 #endif
816
817     /*  Full optimization. */
818     /*  Note that gcvOPTIMIZATION_LOAD_SW_WORKAROUND is off. */
819         gcvOPTIMIZATION_FULL                        = 0x7FFFFFFF &
820                                                   ~gcvOPTIMIZATION_LOAD_SW_WORKAROUND &
821                                                   ~gcvOPTIMIZATION_INLINE_ALL_EXPANSION &
822                                                   ~gcvOPTIMIZATION_POWER_OPTIMIZATION,
823
824         /* Optimization Unit Test flag. */
825     gcvOPTIMIZATION_UNIT_TEST                   = 1 << 31
826 }
827 gceSHADER_OPTIMIZATION;
828
829 typedef enum _gceOPTIMIZATION_VaryingPaking
830 {
831     gcvOPTIMIZATION_VARYINGPACKING_NONE = 0,
832     gcvOPTIMIZATION_VARYINGPACKING_NOSPLIT,
833     gcvOPTIMIZATION_VARYINGPACKING_SPLIT
834 } gceOPTIMIZATION_VaryingPaking;
835
836 typedef struct _gcOPTIMIZER_OPTION
837 {
838     gceSHADER_OPTIMIZATION     optFlags;
839
840     /* debug & dump options:
841
842          VC_OPTION=-DUMP:SRC:OPT|:OPTV|:CG|:CGV:|ALL|ALLV
843
844          SRC:  dump shader source code
845          OPT:  dump incoming and final IR
846          OPTV: dump result IR in each optimization phase
847          CG:   dump generated machine code
848          CGV:  dump BE tree and optimization detail
849
850          ALL = SRC|OPT|CG
851          ALLV = SRC|OPT|OPTV|CG|CGV
852      */
853     gctBOOL     dumpShaderSource;      /* dump shader source code */
854     gctBOOL     dumpOptimizer;         /* dump incoming and final IR */
855     gctBOOL     dumpOptimizerVerbose;  /* dump result IR in each optimization phase */
856     gctBOOL     dumpBEGenertedCode;    /* dump generated machine code */
857     gctBOOL     dumpBEVerbose;         /* dump BE tree and optimization detail */
858     gctBOOL     dumpBEFinalIR;         /* dump BE final IR */
859
860     /* Code generation */
861
862     /* Varying Packing:
863
864           VC_OPTION=-PACKVARYING:[0-2]|:T[-]m[,n]|:LshaderIdx,min,max
865
866           0: turn off varying packing
867           1: pack varyings, donot split any varying
868           2: pack varyings, may split to make fully packed output
869
870           Tm:    only packing shader pair which vertex shader id is m
871           Tm,n:  only packing shader pair which vertex shader id
872                    is in range of [m, n]
873           T-m:   do not packing shader pair which vertex shader id is m
874           T-m,n: do not packing shader pair which vertex shader id
875                    is in range of [m, n]
876
877           LshaderIdx,min,max : set  load balance (min, max) for shaderIdx
878                                if shaderIdx is -1, all shaders are impacted
879                                newMin = origMin * (min/100.);
880                                newMax = origMax * (max/100.);
881      */
882     gceOPTIMIZATION_VaryingPaking    packVarying;
883     gctINT                           _triageStart;
884     gctINT                           _triageEnd;
885     gctINT                           _loadBalanceShaderIdx;
886     gctINT                           _loadBalanceMin;
887     gctINT                           _loadBalanceMax;
888
889     /* Do not generate immdeiate
890
891           VC_OPTION=-NOIMM
892
893        Force generate immediate even the machine model don't support it,
894        for testing purpose only
895
896           VC_OPTION=-FORCEIMM
897      */
898     gctBOOL     noImmediate;
899     gctBOOL     forceImmediate;
900
901     /* Power reduction mode options */
902     gctBOOL   needPowerOptimization;
903
904     /* Patch TEXLD instruction by adding dummy texld
905        (can be used to tune GPU power usage):
906          for every TEXLD we seen, add n dummy TEXLD
907
908         it can be enabled by environment variable:
909
910           VC_OPTION=-PATCH_TEXLD:M:N
911
912         (for each M texld, add N dummy texld)
913      */
914     gctINT      patchEveryTEXLDs;
915     gctINT      patchDummyTEXLDs;
916
917     /* Insert NOP after high power consumption instructions
918
919          VC_OPTION="-INSERTNOP:MUL:MULLO:DP3:DP4:SEENTEXLD"
920      */
921     gctBOOL     insertNOP;
922     gctBOOL     insertNOPAfterMUL;
923     gctBOOL     insertNOPAfterMULLO;
924     gctBOOL     insertNOPAfterDP3;
925     gctBOOL     insertNOPAfterDP4;
926     gctBOOL     insertNOPOnlyWhenTexldSeen;
927
928     /* split MAD to MUL and ADD:
929
930          VC_OPTION=-SPLITMAD
931      */
932     gctBOOL     splitMAD;
933
934     /* Convert vect3/vec4 operations to multiple vec2/vec1 operations
935
936          VC_OPTION=-SPLITVEC:MUL:MULLO:DP3:DP4
937      */
938     gctBOOL     splitVec;
939     gctBOOL     splitVec4MUL;
940     gctBOOL     splitVec4MULLO;
941     gctBOOL     splitVec4DP3;
942     gctBOOL     splitVec4DP4;
943
944     /* turn/off features:
945
946           VC_OPTION=-F:n,[0|1]
947           Note: n must be decimal number
948      */
949     gctUINT     featureBits;
950
951     /* inline level (default 2 at O1):
952
953           VC_OPTION=-INLINELEVEL:[0-3]
954              0:  no inline
955              1:  only inline the function only called once or small function
956              2:  inline functions be called less than 5 times or medium size function
957              3:  inline everything possible
958      */
959     gctUINT     inlineLevel;
960 } gcOPTIMIZER_OPTION;
961
962 extern gcOPTIMIZER_OPTION theOptimizerOption;
963 #define gcmGetOptimizerOption() gcGetOptimizerOption()
964
965 #define gcmOPT_DUMP_SHADER_SRC()         \
966              (gcmGetOptimizerOption()->dumpShaderSource != 0)
967 #define gcmOPT_DUMP_OPTIMIZER()          \
968              (gcmGetOptimizerOption()->dumpOptimizer != 0 || \
969               gcmOPT_DUMP_OPTIMIZER_VERBOSE() )
970 #define gcmOPT_DUMP_OPTIMIZER_VERBOSE()  \
971              (gcmGetOptimizerOption()->dumpOptimizerVerbose != 0)
972 #define gcmOPT_DUMP_CODEGEN()            \
973              (gcmGetOptimizerOption()->dumpBEGenertedCode != 0 || \
974               gcmOPT_DUMP_CODEGEN_VERBOSE() )
975 #define gcmOPT_DUMP_CODEGEN_VERBOSE()    \
976              (gcmGetOptimizerOption()->dumpBEVerbose != 0)
977 #define gcmOPT_DUMP_FINAL_IR()    \
978              (gcmGetOptimizerOption()->dumpBEFinalIR != 0)
979
980 #define gcmOPT_SET_DUMP_SHADER_SRC(v)   \
981              gcmGetOptimizerOption()->dumpShaderSource = (v)
982
983 #define gcmOPT_PATCH_TEXLD()  (gcmGetOptimizerOption()->patchDummyTEXLDs != 0)
984 #define gcmOPT_INSERT_NOP()   (gcmGetOptimizerOption()->insertNOP == gcvTRUE)
985 #define gcmOPT_SPLITMAD()     (gcmGetOptimizerOption()->splitMAD == gcvTRUE)
986 #define gcmOPT_SPLITVEC()     (gcmGetOptimizerOption()->splitVec == gcvTRUE)
987
988 #define gcmOPT_NOIMMEDIATE()  (gcmGetOptimizerOption()->noImmediate == gcvTRUE)
989 #define gcmOPT_FORCEIMMEDIATE()  (gcmGetOptimizerOption()->forceImmediate == gcvTRUE)
990
991 #define gcmOPT_PACKVARYING()     (gcmGetOptimizerOption()->packVarying)
992 #define gcmOPT_PACKVARYING_triageStart()   (gcmGetOptimizerOption()->_triageStart)
993 #define gcmOPT_PACKVARYING_triageEnd()     (gcmGetOptimizerOption()->_triageEnd)
994
995 #define gcmOPT_INLINELEVEL()     (gcmGetOptimizerOption()->inlineLevel)
996
997 /* Setters */
998 #define gcmOPT_SetPatchTexld(m,n) (gcmGetOptimizerOption()->patchEveryTEXLDs = (m),\
999                                    gcmGetOptimizerOption()->patchDummyTEXLDs = (n))
1000 #define gcmOPT_SetSplitVecMUL() (gcmGetOptimizerOption()->splitVec = gcvTRUE, \
1001                                  gcmGetOptimizerOption()->splitVec4MUL = gcvTRUE)
1002 #define gcmOPT_SetSplitVecMULLO() (gcmGetOptimizerOption()->splitVec = gcvTRUE, \
1003                                   gcmGetOptimizerOption()->splitVec4MULLO = gcvTRUE)
1004 #define gcmOPT_SetSplitVecDP3() (gcmGetOptimizerOption()->splitVec = gcvTRUE, \
1005                                  gcmGetOptimizerOption()->splitVec4DP3 = gcvTRUE)
1006 #define gcmOPT_SetSplitVecDP4() (gcmGetOptimizerOption()->splitVec = gcvTRUE, \
1007                                  gcmGetOptimizerOption()->splitVec4DP4 = gcvTRUE)
1008
1009 #define gcmOPT_SetPackVarying(v)     (gcmGetOptimizerOption()->packVarying = v)
1010
1011 #define FB_LIVERANGE_FIX1     0x0001
1012
1013
1014 #define PredefinedDummySamplerId       8
1015
1016 /* Function argument qualifier */
1017 typedef enum _gceINPUT_OUTPUT
1018 {
1019         gcvFUNCTION_INPUT,
1020         gcvFUNCTION_OUTPUT,
1021         gcvFUNCTION_INOUT
1022 }
1023 gceINPUT_OUTPUT;
1024
1025 /* Kernel function property flags. */
1026 typedef enum _gcePROPERTY_FLAGS
1027 {
1028         gcvPROPERTY_REQD_WORK_GRP_SIZE  = 0x01
1029 }
1030 gceKERNEL_FUNCTION_PROPERTY_FLAGS;
1031
1032 /* Uniform flags. */
1033 typedef enum _gceUNIFORM_FLAGS
1034 {
1035         gcvUNIFORM_KERNEL_ARG                   = 0x01,
1036         gcvUNIFORM_KERNEL_ARG_LOCAL             = 0x02,
1037         gcvUNIFORM_KERNEL_ARG_SAMPLER           = 0x04,
1038         gcvUNIFORM_LOCAL_ADDRESS_SPACE          = 0x08,
1039         gcvUNIFORM_PRIVATE_ADDRESS_SPACE        = 0x10,
1040         gcvUNIFORM_CONSTANT_ADDRESS_SPACE       = 0x20,
1041         gcvUNIFORM_GLOBAL_SIZE                  = 0x40,
1042         gcvUNIFORM_LOCAL_SIZE                   = 0x80,
1043         gcvUNIFORM_NUM_GROUPS                   = 0x100,
1044         gcvUNIFORM_GLOBAL_OFFSET                = 0x200,
1045         gcvUNIFORM_WORK_DIM                     = 0x400,
1046         gcvUNIFORM_KERNEL_ARG_CONSTANT          = 0x800,
1047         gcvUNIFORM_KERNEL_ARG_LOCAL_MEM_SIZE    = 0x1000,
1048         gcvUNIFORM_KERNEL_ARG_PRIVATE           = 0x2000,
1049         gcvUNIFORM_LOADTIME_CONSTANT            = 0x4000,
1050     gcvUNIFORM_IS_ARRAY                 = 0x8000,
1051 }
1052 gceUNIFORM_FLAGS;
1053
1054 #define gcdUNIFORM_KERNEL_ARG_MASK  (gcvUNIFORM_KERNEL_ARG         | \
1055                                      gcvUNIFORM_KERNEL_ARG_LOCAL   | \
1056                                                                          gcvUNIFORM_KERNEL_ARG_SAMPLER | \
1057                                                                          gcvUNIFORM_KERNEL_ARG_PRIVATE | \
1058                                                                          gcvUNIFORM_KERNEL_ARG_CONSTANT)
1059
1060 typedef enum _gceVARIABLE_UPDATE_FLAGS
1061 {
1062     gcvVARIABLE_UPDATE_NOUPDATE = 0,
1063     gcvVARIABLE_UPDATE_TEMPREG,
1064     gcvVARIABLE_UPDATE_TYPE_QUALIFIER,
1065 }gceVARIABLE_UPDATE_FLAGS;
1066
1067 typedef struct _gcMACHINE_INST
1068 {
1069     gctUINT        state0;
1070     gctUINT        state1;
1071     gctUINT        state2;
1072     gctUINT        state3;
1073 }gcMACHINE_INST, *gcMACHINE_INST_PTR;
1074
1075 typedef struct _gcMACHINECODE
1076 {
1077     gcMACHINE_INST_PTR   pCode;          /* machine code  */
1078     gctUINT              instCount;      /* 128-bit count */
1079     gctUINT              maxConstRegNo;
1080     gctUINT              maxTempRegNo;
1081     gctUINT              endPCOfMainRoutine;
1082 }gcMACHINECODE, *gcMACHINECODE_PTR;
1083
1084 typedef enum NP2_ADDRESS_MODE
1085 {
1086     NP2_ADDRESS_MODE_CLAMP  = 0,
1087     NP2_ADDRESS_MODE_REPEAT = 1,
1088     NP2_ADDRESS_MODE_MIRROR = 2
1089 }NP2_ADDRESS_MODE;
1090
1091 typedef struct _gcNPOT_PATCH_PARAM
1092 {
1093     gctINT               samplerSlot;
1094     NP2_ADDRESS_MODE     addressMode[3];
1095     gctINT               texDimension;    /* 2 or 3 */
1096 }gcNPOT_PATCH_PARAM, *gcNPOT_PATCH_PARAM_PTR;
1097
1098 typedef struct _gcZBIAS_PATCH_PARAM
1099 {
1100     /* Driver uses this to program uniform that designating zbias */
1101     gctINT               uniformAddr;
1102     gctINT               channel;
1103 }gcZBIAS_PATCH_PARAM, *gcZBIAS_PATCH_PARAM_PTR;
1104
1105 void
1106 gcGetOptionFromEnv(
1107     IN OUT gcOPTIMIZER_OPTION * Option
1108     );
1109
1110 void
1111 gcSetOptimizerOption(
1112     IN gceSHADER_FLAGS Flags
1113     );
1114
1115 gcOPTIMIZER_OPTION *
1116 gcGetOptimizerOption();
1117
1118 /*******************************************************************************
1119 **  gcSHADER_SetCompilerVersion
1120 **
1121 **  Set the compiler version of a gcSHADER object.
1122 **
1123 **  INPUT:
1124 **
1125 **      gcSHADER Shader
1126 **          Pointer to gcSHADER object
1127 **
1128 **      gctINT *Version
1129 **          Pointer to a two word version
1130 */
1131 gceSTATUS
1132 gcSHADER_SetCompilerVersion(
1133     IN gcSHADER Shader,
1134     IN gctUINT32 *Version
1135     );
1136
1137 /*******************************************************************************
1138 **  gcSHADER_GetCompilerVersion
1139 **
1140 **  Get the compiler version of a gcSHADER object.
1141 **
1142 **  INPUT:
1143 **
1144 **      gcSHADER Shader
1145 **          Pointer to a gcSHADER object.
1146 **
1147 **  OUTPUT:
1148 **
1149 **      gctUINT32_PTR *CompilerVersion.
1150 **          Pointer to holder of returned compilerVersion pointer
1151 */
1152 gceSTATUS
1153 gcSHADER_GetCompilerVersion(
1154     IN gcSHADER Shader,
1155     OUT gctUINT32_PTR *CompilerVersion
1156     );
1157
1158 /*******************************************************************************
1159 **  gcSHADER_GetType
1160 **
1161 **  Get the gcSHADER object's type.
1162 **
1163 **  INPUT:
1164 **
1165 **      gcSHADER Shader
1166 **          Pointer to a gcSHADER object.
1167 **
1168 **  OUTPUT:
1169 **
1170 **      gctINT *Type.
1171 **          Pointer to return shader type.
1172 */
1173 gceSTATUS
1174 gcSHADER_GetType(
1175     IN gcSHADER Shader,
1176     OUT gctINT *Type
1177     );
1178
1179 gctUINT
1180 gcSHADER_NextId();
1181 /*******************************************************************************
1182 **                             gcSHADER_Construct
1183 ********************************************************************************
1184 **
1185 **      Construct a new gcSHADER object.
1186 **
1187 **      INPUT:
1188 **
1189 **              gcoOS Hal
1190 **                      Pointer to an gcoHAL object.
1191 **
1192 **              gctINT ShaderType
1193 **                      Type of gcSHADER object to cerate.  'ShaderType' can be one of the
1194 **                      following:
1195 **
1196 **                              gcSHADER_TYPE_VERTEX    Vertex shader.
1197 **                              gcSHADER_TYPE_FRAGMENT  Fragment shader.
1198 **
1199 **      OUTPUT:
1200 **
1201 **              gcSHADER * Shader
1202 **                      Pointer to a variable receiving the gcSHADER object pointer.
1203 */
1204 gceSTATUS
1205 gcSHADER_Construct(
1206         IN gcoHAL Hal,
1207         IN gctINT ShaderType,
1208         OUT gcSHADER * Shader
1209         );
1210
1211 /*******************************************************************************
1212 **                              gcSHADER_Destroy
1213 ********************************************************************************
1214 **
1215 **      Destroy a gcSHADER object.
1216 **
1217 **      INPUT:
1218 **
1219 **              gcSHADER Shader
1220 **                      Pointer to a gcSHADER object.
1221 **
1222 **      OUTPUT:
1223 **
1224 **              Nothing.
1225 */
1226 gceSTATUS
1227 gcSHADER_Destroy(
1228         IN gcSHADER Shader
1229         );
1230
1231 /*******************************************************************************
1232 **                              gcSHADER_Copy
1233 ********************************************************************************
1234 **
1235 **      Copy a gcSHADER object.
1236 **
1237 **      INPUT:
1238 **
1239 **              gcSHADER Shader
1240 **                      Pointer to a gcSHADER object.
1241 **
1242 **      gcSHADER Source
1243 **          Pointer to a gcSHADER object that will be copied.
1244 **
1245 **      OUTPUT:
1246 **
1247 **              Nothing.
1248 */
1249 gceSTATUS
1250 gcSHADER_Copy(
1251         IN gcSHADER Shader,
1252         IN gcSHADER Source
1253         );
1254
1255 /*******************************************************************************
1256 **  gcSHADER_LoadHeader
1257 **
1258 **  Load a gcSHADER object from a binary buffer.  The binary buffer is layed out
1259 **  as follows:
1260 **      // Six word header
1261 **      // Signature, must be 'S','H','D','R'.
1262 **      gctINT8             signature[4];
1263 **      gctUINT32           binFileVersion;
1264 **      gctUINT32           compilerVersion[2];
1265 **      gctUINT32           gcSLVersion;
1266 **      gctUINT32           binarySize;
1267 **
1268 **  INPUT:
1269 **
1270 **      gcSHADER Shader
1271 **          Pointer to a gcSHADER object.
1272 **          Shader type will be returned if type in shader object is not gcSHADER_TYPE_PRECOMPILED
1273 **
1274 **      gctPOINTER Buffer
1275 **          Pointer to a binary buffer containing the shader data to load.
1276 **
1277 **      gctSIZE_T BufferSize
1278 **          Number of bytes inside the binary buffer pointed to by 'Buffer'.
1279 **
1280 **  OUTPUT:
1281 **      nothing
1282 **
1283 */
1284 gceSTATUS
1285 gcSHADER_LoadHeader(
1286     IN gcSHADER Shader,
1287     IN gctPOINTER Buffer,
1288     IN gctSIZE_T BufferSize,
1289     OUT gctUINT32 * ShaderVersion
1290     );
1291
1292 /*******************************************************************************
1293 **  gcSHADER_LoadKernel
1294 **
1295 **  Load a kernel function given by name into gcSHADER object
1296 **
1297 **  INPUT:
1298 **
1299 **      gcSHADER Shader
1300 **          Pointer to a gcSHADER object.
1301 **
1302 **      gctSTRING KernelName
1303 **          Pointer to a kernel function name
1304 **
1305 **  OUTPUT:
1306 **      nothing
1307 **
1308 */
1309 gceSTATUS
1310 gcSHADER_LoadKernel(
1311     IN gcSHADER Shader,
1312     IN gctSTRING KernelName
1313     );
1314
1315 /*******************************************************************************
1316 **                                gcSHADER_Load
1317 ********************************************************************************
1318 **
1319 **      Load a gcSHADER object from a binary buffer.
1320 **
1321 **      INPUT:
1322 **
1323 **              gcSHADER Shader
1324 **                      Pointer to a gcSHADER object.
1325 **
1326 **              gctPOINTER Buffer
1327 **                      Pointer to a binary buffer containg the shader data to load.
1328 **
1329 **              gctSIZE_T BufferSize
1330 **                      Number of bytes inside the binary buffer pointed to by 'Buffer'.
1331 **
1332 **      OUTPUT:
1333 **
1334 **              Nothing.
1335 */
1336 gceSTATUS
1337 gcSHADER_Load(
1338         IN gcSHADER Shader,
1339         IN gctPOINTER Buffer,
1340         IN gctSIZE_T BufferSize
1341         );
1342
1343 /*******************************************************************************
1344 **                                gcSHADER_Save
1345 ********************************************************************************
1346 **
1347 **      Save a gcSHADER object to a binary buffer.
1348 **
1349 **      INPUT:
1350 **
1351 **              gcSHADER Shader
1352 **                      Pointer to a gcSHADER object.
1353 **
1354 **              gctPOINTER Buffer
1355 **                      Pointer to a binary buffer to be used as storage for the gcSHADER
1356 **                      object.  If 'Buffer' is gcvNULL, the gcSHADER object will not be saved,
1357 **                      but the number of bytes required to hold the binary output for the
1358 **                      gcSHADER object will be returned.
1359 **
1360 **              gctSIZE_T * BufferSize
1361 **                      Pointer to a variable holding the number of bytes allocated in
1362 **                      'Buffer'.  Only valid if 'Buffer' is not gcvNULL.
1363 **
1364 **      OUTPUT:
1365 **
1366 **              gctSIZE_T * BufferSize
1367 **                      Pointer to a variable receiving the number of bytes required to hold
1368 **                      the binary form of the gcSHADER object.
1369 */
1370 gceSTATUS
1371 gcSHADER_Save(
1372         IN gcSHADER Shader,
1373         IN gctPOINTER Buffer,
1374         IN OUT gctSIZE_T * BufferSize
1375         );
1376
1377 /*******************************************************************************
1378 **                                gcSHADER_LoadEx
1379 ********************************************************************************
1380 **
1381 **      Load a gcSHADER object from a binary buffer.
1382 **
1383 **      INPUT:
1384 **
1385 **              gcSHADER Shader
1386 **                      Pointer to a gcSHADER object.
1387 **
1388 **              gctPOINTER Buffer
1389 **                      Pointer to a binary buffer containg the shader data to load.
1390 **
1391 **              gctSIZE_T BufferSize
1392 **                      Number of bytes inside the binary buffer pointed to by 'Buffer'.
1393 **
1394 **      OUTPUT:
1395 **
1396 **              Nothing.
1397 */
1398 gceSTATUS
1399 gcSHADER_LoadEx(
1400         IN gcSHADER Shader,
1401         IN gctPOINTER Buffer,
1402         IN gctSIZE_T BufferSize
1403         );
1404
1405 /*******************************************************************************
1406 **                                gcSHADER_SaveEx
1407 ********************************************************************************
1408 **
1409 **      Save a gcSHADER object to a binary buffer.
1410 **
1411 **      INPUT:
1412 **
1413 **              gcSHADER Shader
1414 **                      Pointer to a gcSHADER object.
1415 **
1416 **              gctPOINTER Buffer
1417 **                      Pointer to a binary buffer to be used as storage for the gcSHADER
1418 **                      object.  If 'Buffer' is gcvNULL, the gcSHADER object will not be saved,
1419 **                      but the number of bytes required to hold the binary output for the
1420 **                      gcSHADER object will be returned.
1421 **
1422 **              gctSIZE_T * BufferSize
1423 **                      Pointer to a variable holding the number of bytes allocated in
1424 **                      'Buffer'.  Only valid if 'Buffer' is not gcvNULL.
1425 **
1426 **      OUTPUT:
1427 **
1428 **              gctSIZE_T * BufferSize
1429 **                      Pointer to a variable receiving the number of bytes required to hold
1430 **                      the binary form of the gcSHADER object.
1431 */
1432 gceSTATUS
1433 gcSHADER_SaveEx(
1434         IN gcSHADER Shader,
1435         IN gctPOINTER Buffer,
1436         IN OUT gctSIZE_T * BufferSize
1437         );
1438
1439 /*******************************************************************************
1440 **  gcSHADER_ReallocateAttributes
1441 **
1442 **  Reallocate an array of pointers to gcATTRIBUTE objects.
1443 **
1444 **  INPUT:
1445 **
1446 **      gcSHADER Shader
1447 **          Pointer to a gcSHADER object.
1448 **
1449 **      gctSIZE_T Count
1450 **          Array count to reallocate.  'Count' must be at least 1.
1451 */
1452 gceSTATUS
1453 gcSHADER_ReallocateAttributes(
1454     IN gcSHADER Shader,
1455     IN gctSIZE_T Count
1456     );
1457
1458 /*******************************************************************************
1459 **                                                        gcSHADER_AddAttribute
1460 ********************************************************************************
1461 **
1462 **      Add an attribute to a gcSHADER object.
1463 **
1464 **      INPUT:
1465 **
1466 **              gcSHADER Shader
1467 **                      Pointer to a gcSHADER object.
1468 **
1469 **              gctCONST_STRING Name
1470 **                      Name of the attribute to add.
1471 **
1472 **              gcSHADER_TYPE Type
1473 **                      Type of the attribute to add.
1474 **
1475 **              gctSIZE_T Length
1476 **                      Array length of the attribute to add.  'Length' must be at least 1.
1477 **
1478 **              gctBOOL IsTexture
1479 **                      gcvTRUE if the attribute is used as a texture coordinate, gcvFALSE if not.
1480 **
1481 **      OUTPUT:
1482 **
1483 **              gcATTRIBUTE * Attribute
1484 **                      Pointer to a variable receiving the gcATTRIBUTE object pointer.
1485 */
1486 gceSTATUS
1487 gcSHADER_AddAttribute(
1488         IN gcSHADER Shader,
1489         IN gctCONST_STRING Name,
1490         IN gcSHADER_TYPE Type,
1491         IN gctSIZE_T Length,
1492         IN gctBOOL IsTexture,
1493         OUT gcATTRIBUTE * Attribute
1494         );
1495
1496 /*******************************************************************************
1497 **                         gcSHADER_GetAttributeCount
1498 ********************************************************************************
1499 **
1500 **      Get the number of attributes for this shader.
1501 **
1502 **      INPUT:
1503 **
1504 **              gcSHADER Shader
1505 **                      Pointer to a gcSHADER object.
1506 **
1507 **      OUTPUT:
1508 **
1509 **              gctSIZE_T * Count
1510 **                      Pointer to a variable receiving the number of attributes.
1511 */
1512 gceSTATUS
1513 gcSHADER_GetAttributeCount(
1514         IN gcSHADER Shader,
1515         OUT gctSIZE_T * Count
1516         );
1517
1518 /*******************************************************************************
1519 **                            gcSHADER_GetAttribute
1520 ********************************************************************************
1521 **
1522 **      Get the gcATTRIBUTE object poniter for an indexed attribute for this shader.
1523 **
1524 **      INPUT:
1525 **
1526 **              gcSHADER Shader
1527 **                      Pointer to a gcSHADER object.
1528 **
1529 **              gctUINT Index
1530 **                      Index of the attribute to retrieve.
1531 **
1532 **      OUTPUT:
1533 **
1534 **              gcATTRIBUTE * Attribute
1535 **                      Pointer to a variable receiving the gcATTRIBUTE object pointer.
1536 */
1537 gceSTATUS
1538 gcSHADER_GetAttribute(
1539         IN gcSHADER Shader,
1540         IN gctUINT Index,
1541         OUT gcATTRIBUTE * Attribute
1542         );
1543
1544 /*******************************************************************************
1545 **  gcSHADER_ReallocateUniforms
1546 **
1547 **  Reallocate an array of pointers to gcUNIFORM objects.
1548 **
1549 **  INPUT:
1550 **
1551 **      gcSHADER Shader
1552 **          Pointer to a gcSHADER object.
1553 **
1554 **      gctSIZE_T Count
1555 **          Array count to reallocate.  'Count' must be at least 1.
1556 */
1557 gceSTATUS
1558 gcSHADER_ReallocateUniforms(
1559     IN gcSHADER Shader,
1560     IN gctSIZE_T Count
1561     );
1562
1563 /*******************************************************************************
1564 **                                                         gcSHADER_AddUniform
1565 ********************************************************************************
1566 **
1567 **      Add an uniform to a gcSHADER object.
1568 **
1569 **      INPUT:
1570 **
1571 **              gcSHADER Shader
1572 **                      Pointer to a gcSHADER object.
1573 **
1574 **              gctCONST_STRING Name
1575 **                      Name of the uniform to add.
1576 **
1577 **              gcSHADER_TYPE Type
1578 **                      Type of the uniform to add.
1579 **
1580 **              gctSIZE_T Length
1581 **                      Array length of the uniform to add.  'Length' must be at least 1.
1582 **
1583 **      OUTPUT:
1584 **
1585 **              gcUNIFORM * Uniform
1586 **                      Pointer to a variable receiving the gcUNIFORM object pointer.
1587 */
1588 gceSTATUS
1589 gcSHADER_AddUniform(
1590         IN gcSHADER Shader,
1591         IN gctCONST_STRING Name,
1592         IN gcSHADER_TYPE Type,
1593         IN gctSIZE_T Length,
1594         OUT gcUNIFORM * Uniform
1595         );
1596
1597 /*******************************************************************************
1598 **                                                         gcSHADER_AddPreRotationUniform
1599 ********************************************************************************
1600 **
1601 **      Add an uniform to a gcSHADER object.
1602 **
1603 **      INPUT:
1604 **
1605 **              gcSHADER Shader
1606 **                      Pointer to a gcSHADER object.
1607 **
1608 **              gctCONST_STRING Name
1609 **                      Name of the uniform to add.
1610 **
1611 **              gcSHADER_TYPE Type
1612 **                      Type of the uniform to add.
1613 **
1614 **              gctSIZE_T Length
1615 **                      Array length of the uniform to add.  'Length' must be at least 1.
1616 **
1617 **              gctINT col
1618 **                      Which uniform.
1619 **
1620 **      OUTPUT:
1621 **
1622 **              gcUNIFORM * Uniform
1623 **                      Pointer to a variable receiving the gcUNIFORM object pointer.
1624 */
1625 gceSTATUS
1626 gcSHADER_AddPreRotationUniform(
1627         IN gcSHADER Shader,
1628         IN gctCONST_STRING Name,
1629         IN gcSHADER_TYPE Type,
1630         IN gctSIZE_T Length,
1631     IN gctINT col,
1632         OUT gcUNIFORM * Uniform
1633         );
1634
1635 /*******************************************************************************
1636 **                                                         gcSHADER_AddUniformEx
1637 ********************************************************************************
1638 **
1639 **      Add an uniform to a gcSHADER object.
1640 **
1641 **      INPUT:
1642 **
1643 **              gcSHADER Shader
1644 **                      Pointer to a gcSHADER object.
1645 **
1646 **              gctCONST_STRING Name
1647 **                      Name of the uniform to add.
1648 **
1649 **              gcSHADER_TYPE Type
1650 **                      Type of the uniform to add.
1651 **
1652 **      gcSHADER_PRECISION precision
1653 **          Precision of the uniform to add.
1654 **
1655 **              gctSIZE_T Length
1656 **                      Array length of the uniform to add.  'Length' must be at least 1.
1657 **
1658 **      OUTPUT:
1659 **
1660 **              gcUNIFORM * Uniform
1661 **                      Pointer to a variable receiving the gcUNIFORM object pointer.
1662 */
1663 gceSTATUS
1664 gcSHADER_AddUniformEx(
1665         IN gcSHADER Shader,
1666         IN gctCONST_STRING Name,
1667         IN gcSHADER_TYPE Type,
1668     IN gcSHADER_PRECISION precision,
1669         IN gctSIZE_T Length,
1670         OUT gcUNIFORM * Uniform
1671         );
1672
1673 /*******************************************************************************
1674 **                                                         gcSHADER_AddUniformEx1
1675 ********************************************************************************
1676 **
1677 **      Add an uniform to a gcSHADER object.
1678 **
1679 **      INPUT:
1680 **
1681 **              gcSHADER Shader
1682 **                      Pointer to a gcSHADER object.
1683 **
1684 **              gctCONST_STRING Name
1685 **                      Name of the uniform to add.
1686 **
1687 **              gcSHADER_TYPE Type
1688 **                      Type of the uniform to add.
1689 **
1690 **      gcSHADER_PRECISION precision
1691 **          Precision of the uniform to add.
1692 **
1693 **              gctSIZE_T Length
1694 **                      Array length of the uniform to add.  'Length' must be at least 1.
1695 **
1696 **      gcSHADER_VAR_CATEGORY varCategory
1697 **          Variable category, normal or struct.
1698 **
1699 **      gctUINT16 numStructureElement
1700 **          If struct, its element number.
1701 **
1702 **      gctINT16 parent
1703 **          If struct, parent index in gcSHADER.variables.
1704 **
1705 **      gctINT16 prevSibling
1706 **          If struct, previous sibling index in gcSHADER.variables.
1707 **
1708 **      OUTPUT:
1709 **
1710 **              gcUNIFORM * Uniform
1711 **                      Pointer to a variable receiving the gcUNIFORM object pointer.
1712 **
1713 **      gctINT16* ThisUniformIndex
1714 **          Returned value about uniform index in gcSHADER.
1715 */
1716 gceSTATUS
1717 gcSHADER_AddUniformEx1(
1718         IN gcSHADER Shader,
1719         IN gctCONST_STRING Name,
1720         IN gcSHADER_TYPE Type,
1721     IN gcSHADER_PRECISION precision,
1722         IN gctSIZE_T Length,
1723     IN gctINT    IsArray,
1724     IN gcSHADER_VAR_CATEGORY varCategory,
1725     IN gctUINT16 numStructureElement,
1726     IN gctINT16 parent,
1727     IN gctINT16 prevSibling,
1728     OUT gctINT16* ThisUniformIndex,
1729         OUT gcUNIFORM * Uniform
1730         );
1731
1732 /*******************************************************************************
1733 **                          gcSHADER_GetUniformCount
1734 ********************************************************************************
1735 **
1736 **      Get the number of uniforms for this shader.
1737 **
1738 **      INPUT:
1739 **
1740 **              gcSHADER Shader
1741 **                      Pointer to a gcSHADER object.
1742 **
1743 **      OUTPUT:
1744 **
1745 **              gctSIZE_T * Count
1746 **                      Pointer to a variable receiving the number of uniforms.
1747 */
1748 gceSTATUS
1749 gcSHADER_GetUniformCount(
1750         IN gcSHADER Shader,
1751         OUT gctSIZE_T * Count
1752         );
1753
1754 /*******************************************************************************
1755 **                         gcSHADER_GetPreRotationUniform
1756 ********************************************************************************
1757 **
1758 **      Get the preRotate Uniform.
1759 **
1760 **      INPUT:
1761 **
1762 **              gcSHADER Shader
1763 **                      Pointer to a gcSHADER object.
1764 **
1765 **      OUTPUT:
1766 **
1767 **              gcUNIFORM ** pUniform
1768 **                      Pointer to a preRotation uniforms array.
1769 */
1770 gceSTATUS
1771 gcSHADER_GetPreRotationUniform(
1772         IN gcSHADER Shader,
1773         OUT gcUNIFORM ** pUniform
1774         );
1775
1776 /*******************************************************************************
1777 **                             gcSHADER_GetUniform
1778 ********************************************************************************
1779 **
1780 **      Get the gcUNIFORM object pointer for an indexed uniform for this shader.
1781 **
1782 **      INPUT:
1783 **
1784 **              gcSHADER Shader
1785 **                      Pointer to a gcSHADER object.
1786 **
1787 **              gctUINT Index
1788 **                      Index of the uniform to retrieve.
1789 **
1790 **      OUTPUT:
1791 **
1792 **              gcUNIFORM * Uniform
1793 **                      Pointer to a variable receiving the gcUNIFORM object pointer.
1794 */
1795 gceSTATUS
1796 gcSHADER_GetUniform(
1797         IN gcSHADER Shader,
1798         IN gctUINT Index,
1799         OUT gcUNIFORM * Uniform
1800         );
1801
1802
1803 /*******************************************************************************
1804 **                             gcSHADER_GetUniformIndexingRange
1805 ********************************************************************************
1806 **
1807 **      Get the gcUNIFORM object pointer for an indexed uniform for this shader.
1808 **
1809 **      INPUT:
1810 **
1811 **              gcSHADER Shader
1812 **                      Pointer to a gcSHADER object.
1813 **
1814 **              gctINT uniformIndex
1815 **                      Index of the start uniform.
1816 **
1817 **              gctINT offset
1818 **                      Offset to indexing.
1819 **
1820 **      OUTPUT:
1821 **
1822 **              gctINT * LastUniformIndex
1823 **                      Pointer to index of last uniform in indexing range.
1824 **
1825 **              gctINT * OffsetUniformIndex
1826 **                      Pointer to index of uniform that indexing at offset.
1827 **
1828 **              gctINT * DeviationInOffsetUniform
1829 **                      Pointer to offset in uniform picked up.
1830 */
1831 gceSTATUS
1832 gcSHADER_GetUniformIndexingRange(
1833         IN gcSHADER Shader,
1834         IN gctINT uniformIndex,
1835     IN gctINT offset,
1836         OUT gctINT * LastUniformIndex,
1837     OUT gctINT * OffsetUniformIndex,
1838     OUT gctINT * DeviationInOffsetUniform
1839         );
1840
1841 /*******************************************************************************
1842 **  gcSHADER_GetKernelFucntion
1843 **
1844 **  Get the gcKERNEL_FUNCTION object pointer for an indexed kernel function for this shader.
1845 **
1846 **  INPUT:
1847 **
1848 **      gcSHADER Shader
1849 **          Pointer to a gcSHADER object.
1850 **
1851 **      gctUINT Index
1852 **          Index of kernel function to retreive the name for.
1853 **
1854 **  OUTPUT:
1855 **
1856 **      gcKERNEL_FUNCTION * KernelFunction
1857 **          Pointer to a variable receiving the gcKERNEL_FUNCTION object pointer.
1858 */
1859 gceSTATUS
1860 gcSHADER_GetKernelFunction(
1861     IN gcSHADER Shader,
1862     IN gctUINT Index,
1863     OUT gcKERNEL_FUNCTION * KernelFunction
1864     );
1865
1866 gceSTATUS
1867 gcSHADER_GetKernelFunctionByName(
1868         IN gcSHADER Shader,
1869     IN gctSTRING KernelName,
1870     OUT gcKERNEL_FUNCTION * KernelFunction
1871     );
1872 /*******************************************************************************
1873 **  gcSHADER_GetKernelFunctionCount
1874 **
1875 **  Get the number of kernel functions for this shader.
1876 **
1877 **  INPUT:
1878 **
1879 **      gcSHADER Shader
1880 **          Pointer to a gcSHADER object.
1881 **
1882 **  OUTPUT:
1883 **
1884 **      gctSIZE_T * Count
1885 **          Pointer to a variable receiving the number of kernel functions.
1886 */
1887 gceSTATUS
1888 gcSHADER_GetKernelFunctionCount(
1889     IN gcSHADER Shader,
1890     OUT gctSIZE_T * Count
1891     );
1892
1893 /*******************************************************************************
1894 **  gcSHADER_ReallocateOutputs
1895 **
1896 **  Reallocate an array of pointers to gcOUTPUT objects.
1897 **
1898 **  INPUT:
1899 **
1900 **      gcSHADER Shader
1901 **          Pointer to a gcSHADER object.
1902 **
1903 **      gctSIZE_T Count
1904 **          Array count to reallocate.  'Count' must be at least 1.
1905 */
1906 gceSTATUS
1907 gcSHADER_ReallocateOutputs(
1908     IN gcSHADER Shader,
1909     IN gctSIZE_T Count
1910     );
1911
1912 /*******************************************************************************
1913 **                                                         gcSHADER_AddOutput
1914 ********************************************************************************
1915 **
1916 **      Add an output to a gcSHADER object.
1917 **
1918 **      INPUT:
1919 **
1920 **              gcSHADER Shader
1921 **                      Pointer to a gcSHADER object.
1922 **
1923 **              gctCONST_STRING Name
1924 **                      Name of the output to add.
1925 **
1926 **              gcSHADER_TYPE Type
1927 **                      Type of the output to add.
1928 **
1929 **              gctSIZE_T Length
1930 **                      Array length of the output to add.  'Length' must be at least 1.
1931 **
1932 **              gctUINT16 TempRegister
1933 **                      Temporary register index that holds the output value.
1934 **
1935 **      OUTPUT:
1936 **
1937 **              Nothing.
1938 */
1939 gceSTATUS
1940 gcSHADER_AddOutput(
1941         IN gcSHADER Shader,
1942         IN gctCONST_STRING Name,
1943         IN gcSHADER_TYPE Type,
1944         IN gctSIZE_T Length,
1945         IN gctUINT16 TempRegister
1946         );
1947
1948 gceSTATUS
1949 gcSHADER_AddOutputIndexed(
1950         IN gcSHADER Shader,
1951         IN gctCONST_STRING Name,
1952         IN gctSIZE_T Index,
1953         IN gctUINT16 TempIndex
1954         );
1955
1956 /*******************************************************************************
1957 **                                                       gcSHADER_GetOutputCount
1958 ********************************************************************************
1959 **
1960 **      Get the number of outputs for this shader.
1961 **
1962 **      INPUT:
1963 **
1964 **              gcSHADER Shader
1965 **                      Pointer to a gcSHADER object.
1966 **
1967 **      OUTPUT:
1968 **
1969 **              gctSIZE_T * Count
1970 **                      Pointer to a variable receiving the number of outputs.
1971 */
1972 gceSTATUS
1973 gcSHADER_GetOutputCount(
1974         IN gcSHADER Shader,
1975         OUT gctSIZE_T * Count
1976         );
1977
1978 /*******************************************************************************
1979 **                                                         gcSHADER_GetOutput
1980 ********************************************************************************
1981 **
1982 **      Get the gcOUTPUT object pointer for an indexed output for this shader.
1983 **
1984 **      INPUT:
1985 **
1986 **              gcSHADER Shader
1987 **                      Pointer to a gcSHADER object.
1988 **
1989 **              gctUINT Index
1990 **                      Index of output to retrieve.
1991 **
1992 **      OUTPUT:
1993 **
1994 **              gcOUTPUT * Output
1995 **                      Pointer to a variable receiving the gcOUTPUT object pointer.
1996 */
1997 gceSTATUS
1998 gcSHADER_GetOutput(
1999         IN gcSHADER Shader,
2000         IN gctUINT Index,
2001         OUT gcOUTPUT * Output
2002         );
2003
2004
2005 /*******************************************************************************
2006 **                                                         gcSHADER_GetOutputByName
2007 ********************************************************************************
2008 **
2009 **      Get the gcOUTPUT object pointer for this shader by output name.
2010 **
2011 **      INPUT:
2012 **
2013 **              gcSHADER Shader
2014 **                      Pointer to a gcSHADER object.
2015 **
2016 **              gctSTRING name
2017 **                      Name of output to retrieve.
2018 **
2019 **      gctSIZE_T nameLength
2020 **          Length of name to retrieve
2021 **
2022 **      OUTPUT:
2023 **
2024 **              gcOUTPUT * Output
2025 **                      Pointer to a variable receiving the gcOUTPUT object pointer.
2026 */
2027 gceSTATUS
2028 gcSHADER_GetOutputByName(
2029         IN gcSHADER Shader,
2030         IN gctSTRING name,
2031     IN gctSIZE_T nameLength,
2032         OUT gcOUTPUT * Output
2033         );
2034
2035 /*******************************************************************************
2036 **  gcSHADER_ReallocateVariables
2037 **
2038 **  Reallocate an array of pointers to gcVARIABLE objects.
2039 **
2040 **  INPUT:
2041 **
2042 **      gcSHADER Shader
2043 **          Pointer to a gcSHADER object.
2044 **
2045 **      gctSIZE_T Count
2046 **          Array count to reallocate.  'Count' must be at least 1.
2047 */
2048 gceSTATUS
2049 gcSHADER_ReallocateVariables(
2050     IN gcSHADER Shader,
2051     IN gctSIZE_T Count
2052     );
2053
2054 /*******************************************************************************
2055 **                                                         gcSHADER_AddVariable
2056 ********************************************************************************
2057 **
2058 **      Add a variable to a gcSHADER object.
2059 **
2060 **      INPUT:
2061 **
2062 **              gcSHADER Shader
2063 **                      Pointer to a gcSHADER object.
2064 **
2065 **              gctCONST_STRING Name
2066 **                      Name of the variable to add.
2067 **
2068 **              gcSHADER_TYPE Type
2069 **                      Type of the variable to add.
2070 **
2071 **              gctSIZE_T Length
2072 **                      Array length of the variable to add.  'Length' must be at least 1.
2073 **
2074 **              gctUINT16 TempRegister
2075 **                      Temporary register index that holds the variable value.
2076 **
2077 **      OUTPUT:
2078 **
2079 **              Nothing.
2080 */
2081 gceSTATUS
2082 gcSHADER_AddVariable(
2083         IN gcSHADER Shader,
2084         IN gctCONST_STRING Name,
2085         IN gcSHADER_TYPE Type,
2086         IN gctSIZE_T Length,
2087         IN gctUINT16 TempRegister
2088         );
2089
2090
2091 /*******************************************************************************
2092 **  gcSHADER_AddVariableEx
2093 ********************************************************************************
2094 **
2095 **  Add a variable to a gcSHADER object.
2096 **
2097 **  INPUT:
2098 **
2099 **      gcSHADER Shader
2100 **          Pointer to a gcSHADER object.
2101 **
2102 **      gctCONST_STRING Name
2103 **          Name of the variable to add.
2104 **
2105 **      gcSHADER_TYPE Type
2106 **          Type of the variable to add.
2107 **
2108 **      gctSIZE_T Length
2109 **          Array length of the variable to add.  'Length' must be at least 1.
2110 **
2111 **      gctUINT16 TempRegister
2112 **          Temporary register index that holds the variable value.
2113 **
2114 **      gcSHADER_VAR_CATEGORY varCategory
2115 **          Variable category, normal or struct.
2116 **
2117 **      gctUINT16 numStructureElement
2118 **          If struct, its element number.
2119 **
2120 **      gctINT16 parent
2121 **          If struct, parent index in gcSHADER.variables.
2122 **
2123 **      gctINT16 prevSibling
2124 **          If struct, previous sibling index in gcSHADER.variables.
2125 **
2126 **  OUTPUT:
2127 **
2128 **      gctINT16* ThisVarIndex
2129 **          Returned value about variable index in gcSHADER.
2130 */
2131 gceSTATUS
2132 gcSHADER_AddVariableEx(
2133     IN gcSHADER Shader,
2134     IN gctCONST_STRING Name,
2135     IN gcSHADER_TYPE Type,
2136     IN gctSIZE_T Length,
2137     IN gctUINT16 TempRegister,
2138     IN gcSHADER_VAR_CATEGORY varCategory,
2139     IN gctUINT16 numStructureElement,
2140     IN gctINT16 parent,
2141     IN gctINT16 prevSibling,
2142     OUT gctINT16* ThisVarIndex
2143     );
2144
2145 /*******************************************************************************
2146 **  gcSHADER_UpdateVariable
2147 ********************************************************************************
2148 **
2149 **  Update a variable to a gcSHADER object.
2150 **
2151 **  INPUT:
2152 **
2153 **              gcSHADER Shader
2154 **                      Pointer to a gcSHADER object.
2155 **
2156 **              gctUINT Index
2157 **                      Index of variable to retrieve.
2158 **
2159 **              gceVARIABLE_UPDATE_FLAGS flag
2160 **                      Flag which property of variable will be updated.
2161 **
2162 **      gctUINT newValue
2163 **          New value to update.
2164 **
2165 **  OUTPUT:
2166 **
2167 **      Nothing.
2168 */
2169 gceSTATUS
2170 gcSHADER_UpdateVariable(
2171     IN gcSHADER Shader,
2172     IN gctUINT Index,
2173     IN gceVARIABLE_UPDATE_FLAGS flag,
2174     IN gctUINT newValue
2175     );
2176
2177 /*******************************************************************************
2178 **                                                       gcSHADER_GetVariableCount
2179 ********************************************************************************
2180 **
2181 **      Get the number of variables for this shader.
2182 **
2183 **      INPUT:
2184 **
2185 **              gcSHADER Shader
2186 **                      Pointer to a gcSHADER object.
2187 **
2188 **      OUTPUT:
2189 **
2190 **              gctSIZE_T * Count
2191 **                      Pointer to a variable receiving the number of variables.
2192 */
2193 gceSTATUS
2194 gcSHADER_GetVariableCount(
2195         IN gcSHADER Shader,
2196         OUT gctSIZE_T * Count
2197         );
2198
2199 /*******************************************************************************
2200 **                                                         gcSHADER_GetVariable
2201 ********************************************************************************
2202 **
2203 **      Get the gcVARIABLE object pointer for an indexed variable for this shader.
2204 **
2205 **      INPUT:
2206 **
2207 **              gcSHADER Shader
2208 **                      Pointer to a gcSHADER object.
2209 **
2210 **              gctUINT Index
2211 **                      Index of variable to retrieve.
2212 **
2213 **      OUTPUT:
2214 **
2215 **              gcVARIABLE * Variable
2216 **                      Pointer to a variable receiving the gcVARIABLE object pointer.
2217 */
2218 gceSTATUS
2219 gcSHADER_GetVariable(
2220         IN gcSHADER Shader,
2221         IN gctUINT Index,
2222         OUT gcVARIABLE * Variable
2223         );
2224
2225 /*******************************************************************************
2226 **                                                         gcSHADER_GetVariableIndexingRange
2227 ********************************************************************************
2228 **
2229 **      Get the gcVARIABLE indexing range.
2230 **
2231 **      INPUT:
2232 **
2233 **              gcSHADER Shader
2234 **                      Pointer to a gcSHADER object.
2235 **
2236 **              gcVARIABLE variable
2237 **                      Start variable.
2238 **
2239 **              gctBOOL whole
2240 **                      Indicate whether maximum indexing range is queried
2241 **
2242 **      OUTPUT:
2243 **
2244 **              gctUINT *Start
2245 **                      Pointer to range start (temp register index).
2246 **
2247 **              gctUINT *End
2248 **                      Pointer to range end (temp register index).
2249 */
2250 gceSTATUS
2251 gcSHADER_GetVariableIndexingRange(
2252         IN gcSHADER Shader,
2253     IN gcVARIABLE variable,
2254     IN gctBOOL whole,
2255     OUT gctUINT *Start,
2256     OUT gctUINT *End
2257         );
2258
2259 /*******************************************************************************
2260 **                                                         gcSHADER_AddOpcode
2261 ********************************************************************************
2262 **
2263 **      Add an opcode to a gcSHADER object.
2264 **
2265 **      INPUT:
2266 **
2267 **              gcSHADER Shader
2268 **                      Pointer to a gcSHADER object.
2269 **
2270 **              gcSL_OPCODE Opcode
2271 **                      Opcode to add.
2272 **
2273 **              gctUINT16 TempRegister
2274 **                      Temporary register index that acts as the target of the opcode.
2275 **
2276 **              gctUINT8 Enable
2277 **                      Write enable bits for the temporary register that acts as the target
2278 **                      of the opcode.
2279 **
2280 **              gcSL_FORMAT Format
2281 **                      Format of the temporary register.
2282 **
2283 **      OUTPUT:
2284 **
2285 **              Nothing.
2286 */
2287 gceSTATUS
2288 gcSHADER_AddOpcode(
2289         IN gcSHADER Shader,
2290         IN gcSL_OPCODE Opcode,
2291         IN gctUINT16 TempRegister,
2292         IN gctUINT8 Enable,
2293         IN gcSL_FORMAT Format
2294         );
2295
2296 gceSTATUS
2297 gcSHADER_AddOpcode2(
2298         IN gcSHADER Shader,
2299         IN gcSL_OPCODE Opcode,
2300         IN gcSL_CONDITION Condition,
2301         IN gctUINT16 TempRegister,
2302         IN gctUINT8 Enable,
2303         IN gcSL_FORMAT Format
2304         );
2305
2306 /*******************************************************************************
2307 **                                                      gcSHADER_AddOpcodeIndexed
2308 ********************************************************************************
2309 **
2310 **      Add an opcode to a gcSHADER object that writes to an dynamically indexed
2311 **      target.
2312 **
2313 **      INPUT:
2314 **
2315 **              gcSHADER Shader
2316 **                      Pointer to a gcSHADER object.
2317 **
2318 **              gcSL_OPCODE Opcode
2319 **                      Opcode to add.
2320 **
2321 **              gctUINT16 TempRegister
2322 **                      Temporary register index that acts as the target of the opcode.
2323 **
2324 **              gctUINT8 Enable
2325 **                      Write enable bits  for the temporary register that acts as the
2326 **                      target of the opcode.
2327 **
2328 **              gcSL_INDEXED Mode
2329 **                      Location of the dynamic index inside the temporary register.  Valid
2330 **                      values can be:
2331 **
2332 **                              gcSL_INDEXED_X - Use x component of the temporary register.
2333 **                              gcSL_INDEXED_Y - Use y component of the temporary register.
2334 **                              gcSL_INDEXED_Z - Use z component of the temporary register.
2335 **                              gcSL_INDEXED_W - Use w component of the temporary register.
2336 **
2337 **              gctUINT16 IndexRegister
2338 **                      Temporary register index that holds the dynamic index.
2339 **
2340 **              gcSL_FORMAT Format
2341 **                      Format of the temporary register.
2342 **
2343 **      OUTPUT:
2344 **
2345 **              Nothing.
2346 */
2347 gceSTATUS
2348 gcSHADER_AddOpcodeIndexed(
2349         IN gcSHADER Shader,
2350         IN gcSL_OPCODE Opcode,
2351         IN gctUINT16 TempRegister,
2352         IN gctUINT8 Enable,
2353         IN gcSL_INDEXED Mode,
2354         IN gctUINT16 IndexRegister,
2355         IN gcSL_FORMAT Format
2356         );
2357
2358 /*******************************************************************************
2359 **  gcSHADER_AddOpcodeConditionIndexed
2360 **
2361 **  Add an opcode to a gcSHADER object that writes to an dynamically indexed
2362 **  target.
2363 **
2364 **  INPUT:
2365 **
2366 **      gcSHADER Shader
2367 **          Pointer to a gcSHADER object.
2368 **
2369 **      gcSL_OPCODE Opcode
2370 **          Opcode to add.
2371 **
2372 **      gcSL_CONDITION Condition
2373 **          Condition to check.
2374 **
2375 **      gctUINT16 TempRegister
2376 **          Temporary register index that acts as the target of the opcode.
2377 **
2378 **      gctUINT8 Enable
2379 **          Write enable bits  for the temporary register that acts as the
2380 **          target of the opcode.
2381 **
2382 **      gcSL_INDEXED Indexed
2383 **          Location of the dynamic index inside the temporary register.  Valid
2384 **          values can be:
2385 **
2386 **              gcSL_INDEXED_X - Use x component of the temporary register.
2387 **              gcSL_INDEXED_Y - Use y component of the temporary register.
2388 **              gcSL_INDEXED_Z - Use z component of the temporary register.
2389 **              gcSL_INDEXED_W - Use w component of the temporary register.
2390 **
2391 **      gctUINT16 IndexRegister
2392 **          Temporary register index that holds the dynamic index.
2393 **
2394 **  OUTPUT:
2395 **
2396 **      Nothing.
2397 */
2398 gceSTATUS
2399 gcSHADER_AddOpcodeConditionIndexed(
2400     IN gcSHADER Shader,
2401     IN gcSL_OPCODE Opcode,
2402     IN gcSL_CONDITION Condition,
2403     IN gctUINT16 TempRegister,
2404     IN gctUINT8 Enable,
2405     IN gcSL_INDEXED Indexed,
2406     IN gctUINT16 IndexRegister,
2407     IN gcSL_FORMAT Format
2408     );
2409
2410 /*******************************************************************************
2411 **                                                gcSHADER_AddOpcodeConditional
2412 ********************************************************************************
2413 **
2414 **      Add an conditional opcode to a gcSHADER object.
2415 **
2416 **      INPUT:
2417 **
2418 **              gcSHADER Shader
2419 **                      Pointer to a gcSHADER object.
2420 **
2421 **              gcSL_OPCODE Opcode
2422 **                      Opcode to add.
2423 **
2424 **              gcSL_CONDITION Condition
2425 **                      Condition that needs to evaluate to gcvTRUE in order for the opcode to
2426 **                      execute.
2427 **
2428 **              gctUINT Label
2429 **                      Target label if 'Condition' evaluates to gcvTRUE.
2430 **
2431 **      OUTPUT:
2432 **
2433 **              Nothing.
2434 */
2435 gceSTATUS
2436 gcSHADER_AddOpcodeConditional(
2437         IN gcSHADER Shader,
2438         IN gcSL_OPCODE Opcode,
2439         IN gcSL_CONDITION Condition,
2440         IN gctUINT Label
2441         );
2442
2443 /*******************************************************************************
2444 **  gcSHADER_AddOpcodeConditionalFormatted
2445 **
2446 **  Add an conditional jump or call opcode to a gcSHADER object.
2447 **
2448 **  INPUT:
2449 **
2450 **      gcSHADER Shader
2451 **          Pointer to a gcSHADER object.
2452 **
2453 **      gcSL_OPCODE Opcode
2454 **          Opcode to add.
2455 **
2456 **      gcSL_CONDITION Condition
2457 **          Condition that needs to evaluate to gcvTRUE in order for the opcode to
2458 **          execute.
2459 **
2460 **      gcSL_FORMAT Format
2461 **          Format of conditional operands
2462 **
2463 **      gctUINT Label
2464 **          Target label if 'Condition' evaluates to gcvTRUE.
2465 **
2466 **  OUTPUT:
2467 **
2468 **      Nothing.
2469 */
2470 gceSTATUS
2471 gcSHADER_AddOpcodeConditionalFormatted(
2472     IN gcSHADER Shader,
2473     IN gcSL_OPCODE Opcode,
2474     IN gcSL_CONDITION Condition,
2475     IN gcSL_FORMAT Format,
2476     IN gctUINT Label
2477     );
2478
2479 /*******************************************************************************
2480 **  gcSHADER_AddOpcodeConditionalFormattedEnable
2481 **
2482 **  Add an conditional jump or call opcode to a gcSHADER object.
2483 **
2484 **  INPUT:
2485 **
2486 **      gcSHADER Shader
2487 **          Pointer to a gcSHADER object.
2488 **
2489 **      gcSL_OPCODE Opcode
2490 **          Opcode to add.
2491 **
2492 **      gcSL_CONDITION Condition
2493 **          Condition that needs to evaluate to gcvTRUE in order for the opcode to
2494 **          execute.
2495 **
2496 **      gcSL_FORMAT Format
2497 **          Format of conditional operands
2498 **
2499 **      gctUINT8 Enable
2500 **          Write enable value for the target of the opcode.
2501 **
2502 **      gctUINT Label
2503 **          Target label if 'Condition' evaluates to gcvTRUE.
2504 **
2505 **  OUTPUT:
2506 **
2507 **      Nothing.
2508 */
2509 gceSTATUS
2510 gcSHADER_AddOpcodeConditionalFormattedEnable(
2511     IN gcSHADER Shader,
2512     IN gcSL_OPCODE Opcode,
2513     IN gcSL_CONDITION Condition,
2514     IN gcSL_FORMAT Format,
2515     IN gctUINT8 Enable,
2516     IN gctUINT Label
2517     );
2518
2519 /*******************************************************************************
2520 **                                                              gcSHADER_AddLabel
2521 ********************************************************************************
2522 **
2523 **      Define a label at the current instruction of a gcSHADER object.
2524 **
2525 **      INPUT:
2526 **
2527 **              gcSHADER Shader
2528 **                      Pointer to a gcSHADER object.
2529 **
2530 **              gctUINT Label
2531 **                      Label to define.
2532 **
2533 **      OUTPUT:
2534 **
2535 **              Nothing.
2536 */
2537 gceSTATUS
2538 gcSHADER_AddLabel(
2539         IN gcSHADER Shader,
2540         IN gctUINT Label
2541         );
2542
2543 /*******************************************************************************
2544 **                                                         gcSHADER_AddSource
2545 ********************************************************************************
2546 **
2547 **      Add a source operand to a gcSHADER object.
2548 **
2549 **      INPUT:
2550 **
2551 **              gcSHADER Shader
2552 **                      Pointer to a gcSHADER object.
2553 **
2554 **              gcSL_TYPE Type
2555 **                      Type of the source operand.
2556 **
2557 **              gctUINT16 SourceIndex
2558 **                      Index of the source operand.
2559 **
2560 **              gctUINT8 Swizzle
2561 **                      x, y, z, and w swizzle values packed into one 8-bit value.
2562 **
2563 **              gcSL_FORMAT Format
2564 **                      Format of the source operand.
2565 **
2566 **      OUTPUT:
2567 **
2568 **              Nothing.
2569 */
2570 gceSTATUS
2571 gcSHADER_AddSource(
2572         IN gcSHADER Shader,
2573         IN gcSL_TYPE Type,
2574         IN gctUINT16 SourceIndex,
2575         IN gctUINT8 Swizzle,
2576         IN gcSL_FORMAT Format
2577         );
2578
2579 /*******************************************************************************
2580 **                                                      gcSHADER_AddSourceIndexed
2581 ********************************************************************************
2582 **
2583 **      Add a dynamically indexed source operand to a gcSHADER object.
2584 **
2585 **      INPUT:
2586 **
2587 **              gcSHADER Shader
2588 **                      Pointer to a gcSHADER object.
2589 **
2590 **              gcSL_TYPE Type
2591 **                      Type of the source operand.
2592 **
2593 **              gctUINT16 SourceIndex
2594 **                      Index of the source operand.
2595 **
2596 **              gctUINT8 Swizzle
2597 **                      x, y, z, and w swizzle values packed into one 8-bit value.
2598 **
2599 **              gcSL_INDEXED Mode
2600 **                      Addressing mode for the index.
2601 **
2602 **              gctUINT16 IndexRegister
2603 **                      Temporary register index that holds the dynamic index.
2604 **
2605 **              gcSL_FORMAT Format
2606 **                      Format of the source operand.
2607 **
2608 **      OUTPUT:
2609 **
2610 **              Nothing.
2611 */
2612 gceSTATUS
2613 gcSHADER_AddSourceIndexed(
2614         IN gcSHADER Shader,
2615         IN gcSL_TYPE Type,
2616         IN gctUINT16 SourceIndex,
2617         IN gctUINT8 Swizzle,
2618         IN gcSL_INDEXED Mode,
2619         IN gctUINT16 IndexRegister,
2620         IN gcSL_FORMAT Format
2621         );
2622
2623 /*******************************************************************************
2624 **                                                 gcSHADER_AddSourceAttribute
2625 ********************************************************************************
2626 **
2627 **      Add an attribute as a source operand to a gcSHADER object.
2628 **
2629 **      INPUT:
2630 **
2631 **              gcSHADER Shader
2632 **                      Pointer to a gcSHADER object.
2633 **
2634 **              gcATTRIBUTE Attribute
2635 **                      Pointer to a gcATTRIBUTE object.
2636 **
2637 **              gctUINT8 Swizzle
2638 **                      x, y, z, and w swizzle values packed into one 8-bit value.
2639 **
2640 **              gctINT Index
2641 **                      Static index into the attribute in case the attribute is a matrix
2642 **                      or array.
2643 **
2644 **      OUTPUT:
2645 **
2646 **              Nothing.
2647 */
2648 gceSTATUS
2649 gcSHADER_AddSourceAttribute(
2650         IN gcSHADER Shader,
2651         IN gcATTRIBUTE Attribute,
2652         IN gctUINT8 Swizzle,
2653         IN gctINT Index
2654         );
2655
2656 /*******************************************************************************
2657 **                                                 gcSHADER_AddSourceAttributeIndexed
2658 ********************************************************************************
2659 **
2660 **      Add an indexed attribute as a source operand to a gcSHADER object.
2661 **
2662 **      INPUT:
2663 **
2664 **              gcSHADER Shader
2665 **                      Pointer to a gcSHADER object.
2666 **
2667 **              gcATTRIBUTE Attribute
2668 **                      Pointer to a gcATTRIBUTE object.
2669 **
2670 **              gctUINT8 Swizzle
2671 **                      x, y, z, and w swizzle values packed into one 8-bit value.
2672 **
2673 **              gctINT Index
2674 **                      Static index into the attribute in case the attribute is a matrix
2675 **                      or array.
2676 **
2677 **              gcSL_INDEXED Mode
2678 **                      Addressing mode of the dynamic index.
2679 **
2680 **              gctUINT16 IndexRegister
2681 **                      Temporary register index that holds the dynamic index.
2682 **
2683 **      OUTPUT:
2684 **
2685 **              Nothing.
2686 */
2687 gceSTATUS
2688 gcSHADER_AddSourceAttributeIndexed(
2689         IN gcSHADER Shader,
2690         IN gcATTRIBUTE Attribute,
2691         IN gctUINT8 Swizzle,
2692         IN gctINT Index,
2693         IN gcSL_INDEXED Mode,
2694         IN gctUINT16 IndexRegister
2695         );
2696
2697 /*******************************************************************************
2698 **                                                      gcSHADER_AddSourceUniform
2699 ********************************************************************************
2700 **
2701 **      Add a uniform as a source operand to a gcSHADER object.
2702 **
2703 **      INPUT:
2704 **
2705 **              gcSHADER Shader
2706 **                      Pointer to a gcSHADER object.
2707 **
2708 **              gcUNIFORM Uniform
2709 **                      Pointer to a gcUNIFORM object.
2710 **
2711 **              gctUINT8 Swizzle
2712 **                      x, y, z, and w swizzle values packed into one 8-bit value.
2713 **
2714 **              gctINT Index
2715 **                      Static index into the uniform in case the uniform is a matrix or
2716 **                      array.
2717 **
2718 **      OUTPUT:
2719 **
2720 **              Nothing.
2721 */
2722 gceSTATUS
2723 gcSHADER_AddSourceUniform(
2724         IN gcSHADER Shader,
2725         IN gcUNIFORM Uniform,
2726         IN gctUINT8 Swizzle,
2727         IN gctINT Index
2728         );
2729
2730 /*******************************************************************************
2731 **                                              gcSHADER_AddSourceUniformIndexed
2732 ********************************************************************************
2733 **
2734 **      Add an indexed uniform as a source operand to a gcSHADER object.
2735 **
2736 **      INPUT:
2737 **
2738 **              gcSHADER Shader
2739 **                      Pointer to a gcSHADER object.
2740 **
2741 **              gcUNIFORM Uniform
2742 **                      Pointer to a gcUNIFORM object.
2743 **
2744 **              gctUINT8 Swizzle
2745 **                      x, y, z, and w swizzle values packed into one 8-bit value.
2746 **
2747 **              gctINT Index
2748 **                      Static index into the uniform in case the uniform is a matrix or
2749 **                      array.
2750 **
2751 **              gcSL_INDEXED Mode
2752 **                      Addressing mode of the dynamic index.
2753 **
2754 **              gctUINT16 IndexRegister
2755 **                      Temporary register index that holds the dynamic index.
2756 **
2757 **      OUTPUT:
2758 **
2759 **              Nothing.
2760 */
2761 gceSTATUS
2762 gcSHADER_AddSourceUniformIndexed(
2763         IN gcSHADER Shader,
2764         IN gcUNIFORM Uniform,
2765         IN gctUINT8 Swizzle,
2766         IN gctINT Index,
2767         IN gcSL_INDEXED Mode,
2768         IN gctUINT16 IndexRegister
2769         );
2770
2771 gceSTATUS
2772 gcSHADER_AddSourceSamplerIndexed(
2773         IN gcSHADER Shader,
2774         IN gctUINT8 Swizzle,
2775         IN gcSL_INDEXED Mode,
2776         IN gctUINT16 IndexRegister
2777         );
2778
2779 gceSTATUS
2780 gcSHADER_AddSourceAttributeFormatted(
2781     IN gcSHADER Shader,
2782     IN gcATTRIBUTE Attribute,
2783     IN gctUINT8 Swizzle,
2784     IN gctINT Index,
2785     IN gcSL_FORMAT Format
2786     );
2787
2788 gceSTATUS
2789 gcSHADER_AddSourceAttributeIndexedFormatted(
2790     IN gcSHADER Shader,
2791     IN gcATTRIBUTE Attribute,
2792     IN gctUINT8 Swizzle,
2793     IN gctINT Index,
2794     IN gcSL_INDEXED Mode,
2795     IN gctUINT16 IndexRegister,
2796     IN gcSL_FORMAT Format
2797     );
2798
2799 gceSTATUS
2800 gcSHADER_AddSourceUniformFormatted(
2801     IN gcSHADER Shader,
2802     IN gcUNIFORM Uniform,
2803     IN gctUINT8 Swizzle,
2804     IN gctINT Index,
2805     IN gcSL_FORMAT Format
2806     );
2807
2808 gceSTATUS
2809 gcSHADER_AddSourceUniformIndexedFormatted(
2810     IN gcSHADER Shader,
2811     IN gcUNIFORM Uniform,
2812     IN gctUINT8 Swizzle,
2813     IN gctINT Index,
2814     IN gcSL_INDEXED Mode,
2815     IN gctUINT16 IndexRegister,
2816     IN gcSL_FORMAT Format
2817     );
2818
2819 gceSTATUS
2820 gcSHADER_AddSourceSamplerIndexedFormatted(
2821     IN gcSHADER Shader,
2822     IN gctUINT8 Swizzle,
2823     IN gcSL_INDEXED Mode,
2824     IN gctUINT16 IndexRegister,
2825     IN gcSL_FORMAT Format
2826     );
2827
2828 /*******************************************************************************
2829 **                                                 gcSHADER_AddSourceConstant
2830 ********************************************************************************
2831 **
2832 **      Add a constant floating point value as a source operand to a gcSHADER
2833 **      object.
2834 **
2835 **      INPUT:
2836 **
2837 **              gcSHADER Shader
2838 **                      Pointer to a gcSHADER object.
2839 **
2840 **              gctFLOAT Constant
2841 **                      Floating point constant.
2842 **
2843 **      OUTPUT:
2844 **
2845 **              Nothing.
2846 */
2847 gceSTATUS
2848 gcSHADER_AddSourceConstant(
2849         IN gcSHADER Shader,
2850         IN gctFLOAT Constant
2851         );
2852
2853 /*******************************************************************************
2854 **                                         gcSHADER_AddSourceConstantFormatted
2855 ********************************************************************************
2856 **
2857 **      Add a constant value as a source operand to a gcSHADER
2858 **      object.
2859 **
2860 **      INPUT:
2861 **
2862 **              gcSHADER Shader
2863 **                      Pointer to a gcSHADER object.
2864 **
2865 **              void * Constant
2866 **                      Pointer to constant.
2867 **
2868 **              gcSL_FORMAT Format
2869 **
2870 **      OUTPUT:
2871 **
2872 **              Nothing.
2873 */
2874 gceSTATUS
2875 gcSHADER_AddSourceConstantFormatted(
2876         IN gcSHADER Shader,
2877         IN void *Constant,
2878         IN gcSL_FORMAT Format
2879         );
2880
2881 /*******************************************************************************
2882 **                                                                gcSHADER_Pack
2883 ********************************************************************************
2884 **
2885 **      Pack a dynamically created gcSHADER object by trimming the allocated arrays
2886 **      and resolving all the labeling.
2887 **
2888 **      INPUT:
2889 **
2890 **              gcSHADER Shader
2891 **                      Pointer to a gcSHADER object.
2892 **
2893 **      OUTPUT:
2894 **
2895 **              Nothing.
2896 */
2897 gceSTATUS
2898 gcSHADER_Pack(
2899         IN gcSHADER Shader
2900         );
2901
2902 /*******************************************************************************
2903 **                                                              gcSHADER_SetOptimizationOption
2904 ********************************************************************************
2905 **
2906 **      Set optimization option of a gcSHADER object.
2907 **
2908 **      INPUT:
2909 **
2910 **              gcSHADER Shader
2911 **                      Pointer to a gcSHADER object.
2912 **
2913 **              gctUINT OptimizationOption
2914 **                      Optimization option.  Can be one of the following:
2915 **
2916 **                              0                                               - No optimization.
2917 **                              1                                               - Full optimization.
2918 **                              Other value                             - For optimizer testing.
2919 **
2920 **      OUTPUT:
2921 **
2922 **              Nothing.
2923 */
2924 gceSTATUS
2925 gcSHADER_SetOptimizationOption(
2926         IN gcSHADER Shader,
2927         IN gctUINT OptimizationOption
2928         );
2929
2930 /*******************************************************************************
2931 **  gcSHADER_ReallocateFunctions
2932 **
2933 **  Reallocate an array of pointers to gcFUNCTION objects.
2934 **
2935 **  INPUT:
2936 **
2937 **      gcSHADER Shader
2938 **          Pointer to a gcSHADER object.
2939 **
2940 **      gctSIZE_T Count
2941 **          Array count to reallocate.  'Count' must be at least 1.
2942 */
2943 gceSTATUS
2944 gcSHADER_ReallocateFunctions(
2945     IN gcSHADER Shader,
2946     IN gctSIZE_T Count
2947     );
2948
2949 gceSTATUS
2950 gcSHADER_AddFunction(
2951         IN gcSHADER Shader,
2952         IN gctCONST_STRING Name,
2953         OUT gcFUNCTION * Function
2954         );
2955
2956 gceSTATUS
2957 gcSHADER_ReallocateKernelFunctions(
2958     IN gcSHADER Shader,
2959     IN gctSIZE_T Count
2960     );
2961
2962 gceSTATUS
2963 gcSHADER_AddKernelFunction(
2964         IN gcSHADER Shader,
2965         IN gctCONST_STRING Name,
2966         OUT gcKERNEL_FUNCTION * KernelFunction
2967         );
2968
2969 gceSTATUS
2970 gcSHADER_BeginFunction(
2971         IN gcSHADER Shader,
2972         IN gcFUNCTION Function
2973         );
2974
2975 gceSTATUS
2976 gcSHADER_EndFunction(
2977         IN gcSHADER Shader,
2978         IN gcFUNCTION Function
2979         );
2980
2981 gceSTATUS
2982 gcSHADER_BeginKernelFunction(
2983         IN gcSHADER Shader,
2984         IN gcKERNEL_FUNCTION KernelFunction
2985         );
2986
2987 gceSTATUS
2988 gcSHADER_EndKernelFunction(
2989         IN gcSHADER Shader,
2990         IN gcKERNEL_FUNCTION KernelFunction,
2991         IN gctSIZE_T LocalMemorySize
2992         );
2993
2994 gceSTATUS
2995 gcSHADER_SetMaxKernelFunctionArgs(
2996     IN gcSHADER Shader,
2997     IN gctUINT32 MaxKernelFunctionArgs
2998     );
2999
3000 /*******************************************************************************
3001 **  gcSHADER_SetConstantMemorySize
3002 **
3003 **  Set the constant memory address space size of a gcSHADER object.
3004 **
3005 **  INPUT:
3006 **
3007 **      gcSHADER Shader
3008 **          Pointer to a gcSHADER object.
3009 **
3010 **      gctSIZE_T ConstantMemorySize
3011 **          Constant memory size in bytes
3012 **
3013 **      gctCHAR *ConstantMemoryBuffer
3014 **          Constant memory buffer
3015 */
3016 gceSTATUS
3017 gcSHADER_SetConstantMemorySize(
3018     IN gcSHADER Shader,
3019     IN gctSIZE_T ConstantMemorySize,
3020     IN gctCHAR * ConstantMemoryBuffer
3021     );
3022
3023 /*******************************************************************************
3024 **  gcSHADER_GetConstantMemorySize
3025 **
3026 **  Set the constant memory address space size of a gcSHADER object.
3027 **
3028 **  INPUT:
3029 **
3030 **      gcSHADER Shader
3031 **          Pointer to a gcSHADER object.
3032 **
3033 **  OUTPUT:
3034 **
3035 **      gctSIZE_T * ConstantMemorySize
3036 **          Pointer to a variable receiving constant memory size in bytes
3037 **
3038 **      gctCHAR **ConstantMemoryBuffer.
3039 **          Pointer to a variable for returned shader constant memory buffer.
3040 */
3041 gceSTATUS
3042 gcSHADER_GetConstantMemorySize(
3043     IN gcSHADER Shader,
3044     OUT gctSIZE_T * ConstantMemorySize,
3045     OUT gctCHAR ** ConstantMemoryBuffer
3046     );
3047
3048 /*******************************************************************************
3049 **  gcSHADER_SetPrivateMemorySize
3050 **
3051 **  Set the private memory address space size of a gcSHADER object.
3052 **
3053 **  INPUT:
3054 **
3055 **      gcSHADER Shader
3056 **          Pointer to a gcSHADER object.
3057 **
3058 **      gctSIZE_T PrivateMemorySize
3059 **          Private memory size in bytes
3060 */
3061 gceSTATUS
3062 gcSHADER_SetPrivateMemorySize(
3063     IN gcSHADER Shader,
3064     IN gctSIZE_T PrivateMemorySize
3065     );
3066
3067 /*******************************************************************************
3068 **  gcSHADER_GetPrivateMemorySize
3069 **
3070 **  Set the private memory address space size of a gcSHADER object.
3071 **
3072 **  INPUT:
3073 **
3074 **      gcSHADER Shader
3075 **          Pointer to a gcSHADER object.
3076 **
3077 **  OUTPUT:
3078 **
3079 **      gctSIZE_T * PrivateMemorySize
3080 **          Pointer to a variable receiving private memory size in bytes
3081 */
3082 gceSTATUS
3083 gcSHADER_GetPrivateMemorySize(
3084     IN gcSHADER Shader,
3085     OUT gctSIZE_T * PrivateMemorySize
3086     );
3087
3088 /*******************************************************************************
3089 **  gcSHADER_SetLocalMemorySize
3090 **
3091 **  Set the local memory address space size of a gcSHADER object.
3092 **
3093 **  INPUT:
3094 **
3095 **      gcSHADER Shader
3096 **          Pointer to a gcSHADER object.
3097 **
3098 **      gctSIZE_T LocalMemorySize
3099 **          Local memory size in bytes
3100 */
3101 gceSTATUS
3102 gcSHADER_SetLocalMemorySize(
3103     IN gcSHADER Shader,
3104     IN gctSIZE_T LocalMemorySize
3105     );
3106
3107 /*******************************************************************************
3108 **  gcSHADER_GetLocalMemorySize
3109 **
3110 **  Set the local memory address space size of a gcSHADER object.
3111 **
3112 **  INPUT:
3113 **
3114 **      gcSHADER Shader
3115 **          Pointer to a gcSHADER object.
3116 **
3117 **  OUTPUT:
3118 **
3119 **      gctSIZE_T * LocalMemorySize
3120 **          Pointer to a variable receiving lcoal memory size in bytes
3121 */
3122 gceSTATUS
3123 gcSHADER_GetLocalMemorySize(
3124     IN gcSHADER Shader,
3125     OUT gctSIZE_T * LocalMemorySize
3126     );
3127
3128
3129 /*******************************************************************************
3130 **  gcSHADER_CheckValidity
3131 **
3132 **  Check validity for a gcSHADER object.
3133 **
3134 **  INPUT:
3135 **
3136 **      gcSHADER Shader
3137 **          Pointer to a gcSHADER object.
3138 **
3139 */
3140 gceSTATUS
3141 gcSHADER_CheckValidity(
3142     IN gcSHADER Shader
3143     );
3144
3145 #if gcdUSE_WCLIP_PATCH
3146 gceSTATUS
3147 gcATTRIBUTE_IsPosition(
3148         IN gcATTRIBUTE Attribute,
3149         OUT gctBOOL * IsPosition
3150         );
3151 #endif
3152
3153 /*******************************************************************************
3154 **                             gcATTRIBUTE_GetType
3155 ********************************************************************************
3156 **
3157 **      Get the type and array length of a gcATTRIBUTE object.
3158 **
3159 **      INPUT:
3160 **
3161 **              gcATTRIBUTE Attribute
3162 **                      Pointer to a gcATTRIBUTE object.
3163 **
3164 **      OUTPUT:
3165 **
3166 **              gcSHADER_TYPE * Type
3167 **                      Pointer to a variable receiving the type of the attribute.  'Type'
3168 **                      can be gcvNULL, in which case no type will be returned.
3169 **
3170 **              gctSIZE_T * ArrayLength
3171 **                      Pointer to a variable receiving the length of the array if the
3172 **                      attribute was declared as an array.  If the attribute was not
3173 **                      declared as an array, the array length will be 1.  'ArrayLength' can
3174 **                      be gcvNULL, in which case no array length will be returned.
3175 */
3176 gceSTATUS
3177 gcATTRIBUTE_GetType(
3178         IN gcATTRIBUTE Attribute,
3179         OUT gcSHADER_TYPE * Type,
3180         OUT gctSIZE_T * ArrayLength
3181         );
3182
3183 /*******************************************************************************
3184 **                            gcATTRIBUTE_GetName
3185 ********************************************************************************
3186 **
3187 **      Get the name of a gcATTRIBUTE object.
3188 **
3189 **      INPUT:
3190 **
3191 **              gcATTRIBUTE Attribute
3192 **                      Pointer to a gcATTRIBUTE object.
3193 **
3194 **      OUTPUT:
3195 **
3196 **              gctSIZE_T * Length
3197 **                      Pointer to a variable receiving the length of the attribute name.
3198 **                      'Length' can be gcvNULL, in which case no length will be returned.
3199 **
3200 **              gctCONST_STRING * Name
3201 **                      Pointer to a variable receiving the pointer to the attribute name.
3202 **                      'Name' can be gcvNULL, in which case no name will be returned.
3203 */
3204 gceSTATUS
3205 gcATTRIBUTE_GetName(
3206         IN gcATTRIBUTE Attribute,
3207         OUT gctSIZE_T * Length,
3208         OUT gctCONST_STRING * Name
3209         );
3210
3211 /*******************************************************************************
3212 **                            gcATTRIBUTE_IsEnabled
3213 ********************************************************************************
3214 **
3215 **      Query the enabled state of a gcATTRIBUTE object.
3216 **
3217 **      INPUT:
3218 **
3219 **              gcATTRIBUTE Attribute
3220 **                      Pointer to a gcATTRIBUTE object.
3221 **
3222 **      OUTPUT:
3223 **
3224 **              gctBOOL * Enabled
3225 **                      Pointer to a variable receiving the enabled state of the attribute.
3226 */
3227 gceSTATUS
3228 gcATTRIBUTE_IsEnabled(
3229         IN gcATTRIBUTE Attribute,
3230         OUT gctBOOL * Enabled
3231         );
3232
3233 /*******************************************************************************
3234 **                              gcUNIFORM_GetType
3235 ********************************************************************************
3236 **
3237 **      Get the type and array length of a gcUNIFORM object.
3238 **
3239 **      INPUT:
3240 **
3241 **              gcUNIFORM Uniform
3242 **                      Pointer to a gcUNIFORM object.
3243 **
3244 **      OUTPUT:
3245 **
3246 **              gcSHADER_TYPE * Type
3247 **                      Pointer to a variable receiving the type of the uniform.  'Type' can
3248 **                      be gcvNULL, in which case no type will be returned.
3249 **
3250 **              gctSIZE_T * ArrayLength
3251 **                      Pointer to a variable receiving the length of the array if the
3252 **                      uniform was declared as an array.  If the uniform was not declared
3253 **                      as an array, the array length will be 1.  'ArrayLength' can be gcvNULL,
3254 **                      in which case no array length will be returned.
3255 */
3256 gceSTATUS
3257 gcUNIFORM_GetType(
3258         IN gcUNIFORM Uniform,
3259         OUT gcSHADER_TYPE * Type,
3260         OUT gctSIZE_T * ArrayLength
3261         );
3262
3263 /*******************************************************************************
3264 **                              gcUNIFORM_GetTypeEx
3265 ********************************************************************************
3266 **
3267 **      Get the type and array length of a gcUNIFORM object.
3268 **
3269 **      INPUT:
3270 **
3271 **              gcUNIFORM Uniform
3272 **                      Pointer to a gcUNIFORM object.
3273 **
3274 **      OUTPUT:
3275 **
3276 **              gcSHADER_TYPE * Type
3277 **                      Pointer to a variable receiving the type of the uniform.  'Type' can
3278 **                      be gcvNULL, in which case no type will be returned.
3279 **
3280 **              gcSHADER_PRECISION * Precision
3281 **                      Pointer to a variable receiving the precision of the uniform.  'Precision' can
3282 **                      be gcvNULL, in which case no type will be returned.
3283 **
3284 **              gctSIZE_T * ArrayLength
3285 **                      Pointer to a variable receiving the length of the array if the
3286 **                      uniform was declared as an array.  If the uniform was not declared
3287 **                      as an array, the array length will be 1.  'ArrayLength' can be gcvNULL,
3288 **                      in which case no array length will be returned.
3289 */
3290 gceSTATUS
3291 gcUNIFORM_GetTypeEx(
3292         IN gcUNIFORM Uniform,
3293         OUT gcSHADER_TYPE * Type,
3294     OUT gcSHADER_PRECISION * Precision,
3295         OUT gctSIZE_T * ArrayLength
3296         );
3297
3298 /*******************************************************************************
3299 **                              gcUNIFORM_GetFlags
3300 ********************************************************************************
3301 **
3302 **      Get the flags of a gcUNIFORM object.
3303 **
3304 **      INPUT:
3305 **
3306 **              gcUNIFORM Uniform
3307 **                      Pointer to a gcUNIFORM object.
3308 **
3309 **      OUTPUT:
3310 **
3311 **              gceUNIFORM_FLAGS * Flags
3312 **                      Pointer to a variable receiving the flags of the uniform.
3313 **
3314 */
3315 gceSTATUS
3316 gcUNIFORM_GetFlags(
3317         IN gcUNIFORM Uniform,
3318         OUT gceUNIFORM_FLAGS * Flags
3319         );
3320
3321 /*******************************************************************************
3322 **                              gcUNIFORM_SetFlags
3323 ********************************************************************************
3324 **
3325 **      Set the flags of a gcUNIFORM object.
3326 **
3327 **      INPUT:
3328 **
3329 **              gcUNIFORM Uniform
3330 **                      Pointer to a gcUNIFORM object.
3331 **
3332 **              gceUNIFORM_FLAGS Flags
3333 **                      Flags of the uniform to be set.
3334 **
3335 **      OUTPUT:
3336 **                      Nothing.
3337 **
3338 */
3339 gceSTATUS
3340 gcUNIFORM_SetFlags(
3341         IN gcUNIFORM Uniform,
3342         IN gceUNIFORM_FLAGS Flags
3343         );
3344
3345 /*******************************************************************************
3346 **                              gcUNIFORM_GetName
3347 ********************************************************************************
3348 **
3349 **      Get the name of a gcUNIFORM object.
3350 **
3351 **      INPUT:
3352 **
3353 **              gcUNIFORM Uniform
3354 **                      Pointer to a gcUNIFORM object.
3355 **
3356 **      OUTPUT:
3357 **
3358 **              gctSIZE_T * Length
3359 **                      Pointer to a variable receiving the length of the uniform name.
3360 **                      'Length' can be gcvNULL, in which case no length will be returned.
3361 **
3362 **              gctCONST_STRING * Name
3363 **                      Pointer to a variable receiving the pointer to the uniform name.
3364 **                      'Name' can be gcvNULL, in which case no name will be returned.
3365 */
3366 gceSTATUS
3367 gcUNIFORM_GetName(
3368         IN gcUNIFORM Uniform,
3369         OUT gctSIZE_T * Length,
3370         OUT gctCONST_STRING * Name
3371         );
3372
3373 /*******************************************************************************
3374 **                              gcUNIFORM_GetSampler
3375 ********************************************************************************
3376 **
3377 **      Get the physical sampler number for a sampler gcUNIFORM object.
3378 **
3379 **      INPUT:
3380 **
3381 **              gcUNIFORM Uniform
3382 **                      Pointer to a gcUNIFORM object.
3383 **
3384 **      OUTPUT:
3385 **
3386 **              gctUINT32 * Sampler
3387 **                      Pointer to a variable receiving the physical sampler.
3388 */
3389 gceSTATUS
3390 gcUNIFORM_GetSampler(
3391         IN gcUNIFORM Uniform,
3392         OUT gctUINT32 * Sampler
3393         );
3394
3395 /*******************************************************************************
3396 **  gcUNIFORM_GetFormat
3397 **
3398 **  Get the type and array length of a gcUNIFORM object.
3399 **
3400 **  INPUT:
3401 **
3402 **      gcUNIFORM Uniform
3403 **          Pointer to a gcUNIFORM object.
3404 **
3405 **  OUTPUT:
3406 **
3407 **      gcSL_FORMAT * Format
3408 **          Pointer to a variable receiving the format of element of the uniform.
3409 **          'Type' can be gcvNULL, in which case no type will be returned.
3410 **
3411 **      gctBOOL * IsPointer
3412 **          Pointer to a variable receiving the state wheter the uniform is a pointer.
3413 **          'IsPointer' can be gcvNULL, in which case no array length will be returned.
3414 */
3415 gceSTATUS
3416 gcUNIFORM_GetFormat(
3417     IN gcUNIFORM Uniform,
3418     OUT gcSL_FORMAT * Format,
3419     OUT gctBOOL * IsPointer
3420     );
3421
3422 /*******************************************************************************
3423 **  gcUNIFORM_SetFormat
3424 **
3425 **  Set the format and isPointer of a uniform.
3426 **
3427 **  INPUT:
3428 **
3429 **      gcUNIFORM Uniform
3430 **          Pointer to a gcUNIFORM object.
3431 **
3432 **      gcSL_FORMAT Format
3433 **          Format of element of the uniform shaderType.
3434 **
3435 **      gctBOOL IsPointer
3436 **          Wheter the uniform is a pointer.
3437 **
3438 **  OUTPUT:
3439 **
3440 **      Nothing.
3441 */
3442 gceSTATUS
3443 gcUNIFORM_SetFormat(
3444     IN gcUNIFORM Uniform,
3445     IN gcSL_FORMAT Format,
3446     IN gctBOOL IsPointer
3447     );
3448
3449 /*******************************************************************************
3450 **                                                         gcUNIFORM_SetValue
3451 ********************************************************************************
3452 **
3453 **      Set the value of a uniform in integer.
3454 **
3455 **      INPUT:
3456 **
3457 **              gcUNIFORM Uniform
3458 **                      Pointer to a gcUNIFORM object.
3459 **
3460 **              gctSIZE_T Count
3461 **                      Number of entries to program if the uniform has been declared as an
3462 **                      array.
3463 **
3464 **              const gctINT * Value
3465 **                      Pointer to a buffer holding the integer values for the uniform.
3466 **
3467 **      OUTPUT:
3468 **
3469 **              Nothing.
3470 */
3471 gceSTATUS
3472 gcUNIFORM_SetValue(
3473         IN gcUNIFORM Uniform,
3474         IN gctSIZE_T Count,
3475         IN const gctINT * Value
3476         );
3477
3478 /*******************************************************************************
3479 **                                                         gcUNIFORM_SetValueX
3480 ********************************************************************************
3481 **
3482 **      Set the value of a uniform in fixed point.
3483 **
3484 **      INPUT:
3485 **
3486 **              gcUNIFORM Uniform
3487 **                      Pointer to a gcUNIFORM object.
3488 **
3489 **              gctSIZE_T Count
3490 **                      Number of entries to program if the uniform has been declared as an
3491 **                      array.
3492 **
3493 **              const gctFIXED_POINT * Value
3494 **                      Pointer to a buffer holding the fixed point values for the uniform.
3495 **
3496 **      OUTPUT:
3497 **
3498 **              Nothing.
3499 */
3500 gceSTATUS
3501 gcUNIFORM_SetValueX(
3502         IN gcUNIFORM Uniform,
3503         IN gctSIZE_T Count,
3504         IN gctFIXED_POINT * Value
3505         );
3506
3507 /*******************************************************************************
3508 **                                                         gcUNIFORM_SetValueF
3509 ********************************************************************************
3510 **
3511 **      Set the value of a uniform in floating point.
3512 **
3513 **      INPUT:
3514 **
3515 **              gcUNIFORM Uniform
3516 **                      Pointer to a gcUNIFORM object.
3517 **
3518 **              gctSIZE_T Count
3519 **                      Number of entries to program if the uniform has been declared as an
3520 **                      array.
3521 **
3522 **              const gctFLOAT * Value
3523 **                      Pointer to a buffer holding the floating point values for the
3524 **                      uniform.
3525 **
3526 **      OUTPUT:
3527 **
3528 **              Nothing.
3529 */
3530 gceSTATUS
3531 gcUNIFORM_SetValueF(
3532         IN gcUNIFORM Uniform,
3533         IN gctSIZE_T Count,
3534         IN const gctFLOAT * Value
3535         );
3536
3537 /*******************************************************************************
3538 **  gcUNIFORM_ProgramF
3539 **
3540 **  Set the value of a uniform in floating point.
3541 **
3542 **  INPUT:
3543 **
3544 **      gctUINT32 Address
3545 **          Address of Uniform.
3546 **
3547 **      gctSIZE_T Row/Col
3548 **
3549 **      const gctFLOAT * Value
3550 **          Pointer to a buffer holding the floating point values for the
3551 **          uniform.
3552 **
3553 **  OUTPUT:
3554 **
3555 **      Nothing.
3556 */
3557 gceSTATUS
3558 gcUNIFORM_ProgramF(
3559     IN gctUINT32 Address,
3560     IN gctSIZE_T Row,
3561     IN gctSIZE_T Col,
3562     IN const gctFLOAT * Value
3563     );
3564
3565 /*******************************************************************************
3566 **                                               gcUNIFORM_GetModelViewProjMatrix
3567 ********************************************************************************
3568 **
3569 **      Get the value of uniform modelViewProjMatrix ID if present.
3570 **
3571 **      INPUT:
3572 **
3573 **              gcUNIFORM Uniform
3574 **                      Pointer to a gcUNIFORM object.
3575 **
3576 **      OUTPUT:
3577 **
3578 **              Nothing.
3579 */
3580 gctUINT
3581 gcUNIFORM_GetModelViewProjMatrix(
3582     IN gcUNIFORM Uniform
3583     );
3584
3585 /*******************************************************************************
3586 **                                                              gcOUTPUT_GetType
3587 ********************************************************************************
3588 **
3589 **      Get the type and array length of a gcOUTPUT object.
3590 **
3591 **      INPUT:
3592 **
3593 **              gcOUTPUT Output
3594 **                      Pointer to a gcOUTPUT object.
3595 **
3596 **      OUTPUT:
3597 **
3598 **              gcSHADER_TYPE * Type
3599 **                      Pointer to a variable receiving the type of the output.  'Type' can
3600 **                      be gcvNULL, in which case no type will be returned.
3601 **
3602 **              gctSIZE_T * ArrayLength
3603 **                      Pointer to a variable receiving the length of the array if the
3604 **                      output was declared as an array.  If the output was not declared
3605 **                      as an array, the array length will be 1.  'ArrayLength' can be gcvNULL,
3606 **                      in which case no array length will be returned.
3607 */
3608 gceSTATUS
3609 gcOUTPUT_GetType(
3610         IN gcOUTPUT Output,
3611         OUT gcSHADER_TYPE * Type,
3612         OUT gctSIZE_T * ArrayLength
3613         );
3614
3615 /*******************************************************************************
3616 **                                                         gcOUTPUT_GetIndex
3617 ********************************************************************************
3618 **
3619 **      Get the index of a gcOUTPUT object.
3620 **
3621 **      INPUT:
3622 **
3623 **              gcOUTPUT Output
3624 **                      Pointer to a gcOUTPUT object.
3625 **
3626 **      OUTPUT:
3627 **
3628 **              gctUINT * Index
3629 **                      Pointer to a variable receiving the temporary register index of the
3630 **                      output.  'Index' can be gcvNULL,. in which case no index will be
3631 **                      returned.
3632 */
3633 gceSTATUS
3634 gcOUTPUT_GetIndex(
3635         IN gcOUTPUT Output,
3636         OUT gctUINT * Index
3637         );
3638
3639 /*******************************************************************************
3640 **                                                              gcOUTPUT_GetName
3641 ********************************************************************************
3642 **
3643 **      Get the name of a gcOUTPUT object.
3644 **
3645 **      INPUT:
3646 **
3647 **              gcOUTPUT Output
3648 **                      Pointer to a gcOUTPUT object.
3649 **
3650 **      OUTPUT:
3651 **
3652 **              gctSIZE_T * Length
3653 **                      Pointer to a variable receiving the length of the output name.
3654 **                      'Length' can be gcvNULL, in which case no length will be returned.
3655 **
3656 **              gctCONST_STRING * Name
3657 **                      Pointer to a variable receiving the pointer to the output name.
3658 **                      'Name' can be gcvNULL, in which case no name will be returned.
3659 */
3660 gceSTATUS
3661 gcOUTPUT_GetName(
3662         IN gcOUTPUT Output,
3663         OUT gctSIZE_T * Length,
3664         OUT gctCONST_STRING * Name
3665         );
3666
3667 /*******************************************************************************
3668 *********************************************************** F U N C T I O N S **
3669 *******************************************************************************/
3670
3671 /*******************************************************************************
3672 **  gcFUNCTION_ReallocateArguments
3673 **
3674 **  Reallocate an array of gcsFUNCTION_ARGUMENT objects.
3675 **
3676 **  INPUT:
3677 **
3678 **      gcFUNCTION Function
3679 **          Pointer to a gcFUNCTION object.
3680 **
3681 **      gctSIZE_T Count
3682 **          Array count to reallocate.  'Count' must be at least 1.
3683 */
3684 gceSTATUS
3685 gcFUNCTION_ReallocateArguments(
3686     IN gcFUNCTION Function,
3687     IN gctSIZE_T Count
3688     );
3689
3690 gceSTATUS
3691 gcFUNCTION_AddArgument(
3692         IN gcFUNCTION Function,
3693         IN gctUINT16 TempIndex,
3694         IN gctUINT8 Enable,
3695         IN gctUINT8 Qualifier
3696         );
3697
3698 gceSTATUS
3699 gcFUNCTION_GetArgument(
3700         IN gcFUNCTION Function,
3701         IN gctUINT16 Index,
3702         OUT gctUINT16_PTR Temp,
3703         OUT gctUINT8_PTR Enable,
3704         OUT gctUINT8_PTR Swizzle
3705         );
3706
3707 gceSTATUS
3708 gcFUNCTION_GetLabel(
3709         IN gcFUNCTION Function,
3710         OUT gctUINT_PTR Label
3711         );
3712
3713 /*******************************************************************************
3714 ************************* K E R N E L    P R O P E R T Y    F U N C T I O N S **
3715 *******************************************************************************/
3716 /*******************************************************************************/
3717 gceSTATUS
3718 gcKERNEL_FUNCTION_AddKernelFunctionProperties(
3719             IN gcKERNEL_FUNCTION KernelFunction,
3720                 IN gctINT propertyType,
3721                 IN gctSIZE_T propertySize,
3722                 IN gctINT * values
3723                 );
3724
3725 gceSTATUS
3726 gcKERNEL_FUNCTION_GetPropertyCount(
3727     IN gcKERNEL_FUNCTION KernelFunction,
3728     OUT gctSIZE_T * Count
3729     );
3730
3731 gceSTATUS
3732 gcKERNEL_FUNCTION_GetProperty(
3733     IN gcKERNEL_FUNCTION KernelFunction,
3734     IN gctUINT Index,
3735         OUT gctSIZE_T * propertySize,
3736         OUT gctINT * propertyType,
3737         OUT gctINT * propertyValues
3738     );
3739
3740
3741 /*******************************************************************************
3742 *******************************I M A G E   S A M P L E R    F U N C T I O N S **
3743 *******************************************************************************/
3744 /*******************************************************************************
3745 **  gcKERNEL_FUNCTION_ReallocateImageSamplers
3746 **
3747 **  Reallocate an array of pointers to image sampler pair.
3748 **
3749 **  INPUT:
3750 **
3751 **      gcKERNEL_FUNCTION KernelFunction
3752 **          Pointer to a gcKERNEL_FUNCTION object.
3753 **
3754 **      gctSIZE_T Count
3755 **          Array count to reallocate.  'Count' must be at least 1.
3756 */
3757 gceSTATUS
3758 gcKERNEL_FUNCTION_ReallocateImageSamplers(
3759     IN gcKERNEL_FUNCTION KernelFunction,
3760     IN gctSIZE_T Count
3761     );
3762
3763 gceSTATUS
3764 gcKERNEL_FUNCTION_AddImageSampler(
3765     IN gcKERNEL_FUNCTION KernelFunction,
3766     IN gctUINT8 ImageNum,
3767     IN gctBOOL IsConstantSamplerType,
3768     IN gctUINT32 SamplerType
3769     );
3770
3771 gceSTATUS
3772 gcKERNEL_FUNCTION_GetImageSamplerCount(
3773     IN gcKERNEL_FUNCTION KernelFunction,
3774     OUT gctSIZE_T * Count
3775     );
3776
3777 gceSTATUS
3778 gcKERNEL_FUNCTION_GetImageSampler(
3779     IN gcKERNEL_FUNCTION KernelFunction,
3780     IN gctUINT Index,
3781     OUT gctUINT8 *ImageNum,
3782     OUT gctBOOL *IsConstantSamplerType,
3783     OUT gctUINT32 *SamplerType
3784     );
3785
3786 /*******************************************************************************
3787 *********************************************K E R N E L    F U N C T I O N S **
3788 *******************************************************************************/
3789
3790 /*******************************************************************************
3791 **  gcKERNEL_FUNCTION_ReallocateArguments
3792 **
3793 **  Reallocate an array of gcsFUNCTION_ARGUMENT objects.
3794 **
3795 **  INPUT:
3796 **
3797 **      gcKERNEL_FUNCTION Function
3798 **          Pointer to a gcKERNEL_FUNCTION object.
3799 **
3800 **      gctSIZE_T Count
3801 **          Array count to reallocate.  'Count' must be at least 1.
3802 */
3803 gceSTATUS
3804 gcKERNEL_FUNCTION_ReallocateArguments(
3805     IN gcKERNEL_FUNCTION Function,
3806     IN gctSIZE_T Count
3807     );
3808
3809 gceSTATUS
3810 gcKERNEL_FUNCTION_AddArgument(
3811         IN gcKERNEL_FUNCTION Function,
3812         IN gctUINT16 TempIndex,
3813         IN gctUINT8 Enable,
3814         IN gctUINT8 Qualifier
3815         );
3816
3817 gceSTATUS
3818 gcKERNEL_FUNCTION_GetArgument(
3819         IN gcKERNEL_FUNCTION Function,
3820         IN gctUINT16 Index,
3821         OUT gctUINT16_PTR Temp,
3822         OUT gctUINT8_PTR Enable,
3823         OUT gctUINT8_PTR Swizzle
3824         );
3825
3826 gceSTATUS
3827 gcKERNEL_FUNCTION_GetLabel(
3828         IN gcKERNEL_FUNCTION Function,
3829         OUT gctUINT_PTR Label
3830         );
3831
3832 gceSTATUS
3833 gcKERNEL_FUNCTION_GetName(
3834     IN gcKERNEL_FUNCTION KernelFunction,
3835     OUT gctSIZE_T * Length,
3836     OUT gctCONST_STRING * Name
3837     );
3838
3839 gceSTATUS
3840 gcKERNEL_FUNCTION_ReallocateUniformArguments(
3841     IN gcKERNEL_FUNCTION KernelFunction,
3842     IN gctSIZE_T Count
3843     );
3844
3845 gceSTATUS
3846 gcKERNEL_FUNCTION_AddUniformArgument(
3847     IN gcKERNEL_FUNCTION KernelFunction,
3848     IN gctCONST_STRING Name,
3849     IN gcSHADER_TYPE Type,
3850     IN gctSIZE_T Length,
3851     OUT gcUNIFORM * UniformArgument
3852     );
3853
3854 gceSTATUS
3855 gcKERNEL_FUNCTION_GetUniformArgumentCount(
3856     IN gcKERNEL_FUNCTION KernelFunction,
3857     OUT gctSIZE_T * Count
3858     );
3859
3860 gceSTATUS
3861 gcKERNEL_FUNCTION_GetUniformArgument(
3862     IN gcKERNEL_FUNCTION KernelFunction,
3863     IN gctUINT Index,
3864     OUT gcUNIFORM * UniformArgument
3865     );
3866
3867 gceSTATUS
3868 gcKERNEL_FUNCTION_SetCodeEnd(
3869     IN gcKERNEL_FUNCTION KernelFunction
3870     );
3871
3872 /*******************************************************************************
3873 **                              gcCompileShader
3874 ********************************************************************************
3875 **
3876 **      Compile a shader.
3877 **
3878 **      INPUT:
3879 **
3880 **              gcoOS Hal
3881 **                      Pointer to an gcoHAL object.
3882 **
3883 **              gctINT ShaderType
3884 **                      Shader type to compile.  Can be one of the following values:
3885 **
3886 **                              gcSHADER_TYPE_VERTEX
3887 **                                      Compile a vertex shader.
3888 **
3889 **                              gcSHADER_TYPE_FRAGMENT
3890 **                                      Compile a fragment shader.
3891 **
3892 **              gctSIZE_T SourceSize
3893 **                      Size of the source buffer in bytes.
3894 **
3895 **              gctCONST_STRING Source
3896 **                      Pointer to the buffer containing the shader source code.
3897 **
3898 **      OUTPUT:
3899 **
3900 **              gcSHADER * Binary
3901 **                      Pointer to a variable receiving the pointer to a gcSHADER object
3902 **                      containg the compiled shader code.
3903 **
3904 **              gctSTRING * Log
3905 **                      Pointer to a variable receiving a string pointer containging the
3906 **                      compile log.
3907 */
3908 gceSTATUS
3909 gcCompileShader(
3910         IN gcoHAL Hal,
3911         IN gctINT ShaderType,
3912         IN gctSIZE_T SourceSize,
3913         IN gctCONST_STRING Source,
3914         OUT gcSHADER * Binary,
3915         OUT gctSTRING * Log
3916         );
3917
3918 /*******************************************************************************
3919 **                              gcOptimizeShader
3920 ********************************************************************************
3921 **
3922 **      Optimize a shader.
3923 **
3924 **      INPUT:
3925 **
3926 **              gcSHADER Shader
3927 **                      Pointer to a gcSHADER object holding information about the compiled
3928 **                      shader.
3929 **
3930 **              gctFILE LogFile
3931 **                      Pointer to an open FILE object.
3932 */
3933 gceSTATUS
3934 gcOptimizeShader(
3935         IN gcSHADER Shader,
3936         IN gctFILE LogFile
3937         );
3938
3939 /*******************************************************************************
3940 **                                gcLinkShaders
3941 ********************************************************************************
3942 **
3943 **      Link two shaders and generate a harwdare specific state buffer by compiling
3944 **      the compiler generated code through the resource allocator and code
3945 **      generator.
3946 **
3947 **      INPUT:
3948 **
3949 **              gcSHADER VertexShader
3950 **                      Pointer to a gcSHADER object holding information about the compiled
3951 **                      vertex shader.
3952 **
3953 **              gcSHADER FragmentShader
3954 **                      Pointer to a gcSHADER object holding information about the compiled
3955 **                      fragment shader.
3956 **
3957 **              gceSHADER_FLAGS Flags
3958 **                      Compiler flags.  Can be any of the following:
3959 **
3960 **                              gcvSHADER_DEAD_CODE       - Dead code elimination.
3961 **                              gcvSHADER_RESOURCE_USAGE  - Resource usage optimizaion.
3962 **                              gcvSHADER_OPTIMIZER       - Full optimization.
3963 **                              gcvSHADER_USE_GL_Z        - Use OpenGL ES Z coordinate.
3964 **                              gcvSHADER_USE_GL_POSITION - Use OpenGL ES gl_Position.
3965 **                              gcvSHADER_USE_GL_FACE     - Use OpenGL ES gl_FaceForward.
3966 **
3967 **      OUTPUT:
3968 **
3969 **              gctSIZE_T * StateBufferSize
3970 **                      Pointer to a variable receicing the number of bytes in the buffer
3971 **                      returned in 'StateBuffer'.
3972 **
3973 **              gctPOINTER * StateBuffer
3974 **                      Pointer to a variable receiving a buffer pointer that contains the
3975 **                      states required to download the shaders into the hardware.
3976 **
3977 **              gcsHINT_PTR * Hints
3978 **                      Pointer to a variable receiving a gcsHINT structure pointer that
3979 **                      contains information required when loading the shader states.
3980 */
3981 gceSTATUS
3982 gcLinkShaders(
3983         IN gcSHADER VertexShader,
3984         IN gcSHADER FragmentShader,
3985         IN gceSHADER_FLAGS Flags,
3986         OUT gctSIZE_T * StateBufferSize,
3987         OUT gctPOINTER * StateBuffer,
3988         OUT gcsHINT_PTR * Hints,
3989     OUT gcMACHINECODE_PTR *ppVsMachineCode,
3990     OUT gcMACHINECODE_PTR *ppFsMachineCode
3991         );
3992
3993 /*******************************************************************************
3994 **                                gcLoadShaders
3995 ********************************************************************************
3996 **
3997 **      Load a pre-compiled and pre-linked shader program into the hardware.
3998 **
3999 **      INPUT:
4000 **
4001 **              gcoHAL Hal
4002 **                      Pointer to a gcoHAL object.
4003 **
4004 **              gctSIZE_T StateBufferSize
4005 **                      The number of bytes in the 'StateBuffer'.
4006 **
4007 **              gctPOINTER StateBuffer
4008 **                      Pointer to the states that make up the shader program.
4009 **
4010 **              gcsHINT_PTR Hints
4011 **                      Pointer to a gcsHINT structure that contains information required
4012 **                      when loading the shader states.
4013 */
4014 gceSTATUS
4015 gcLoadShaders(
4016         IN gcoHAL Hal,
4017         IN gctSIZE_T StateBufferSize,
4018         IN gctPOINTER StateBuffer,
4019         IN gcsHINT_PTR Hints
4020         );
4021
4022 gceSTATUS
4023 gcRecompileShaders(
4024     IN gcoHAL Hal,
4025     IN gcMACHINECODE_PTR pVsMachineCode,
4026     IN gcMACHINECODE_PTR pPsMachineCode,
4027     /*Recompile variables*/
4028     IN OUT gctPOINTER *ppRecompileStateBuffer,
4029     IN OUT gctSIZE_T *pRecompileStateBufferSize,
4030     IN OUT gcsHINT_PTR *ppRecompileHints,
4031     /* natvie state*/
4032     IN gctPOINTER pNativeStateBuffer,
4033     IN gctSIZE_T nativeStateBufferSize,
4034     IN gcsHINT_PTR pNativeHints,
4035     /* npt info */
4036     IN gctUINT32 Samplers,
4037     IN gctUINT32 *SamplerWrapS,
4038     IN gctUINT32 *SamplerWrapT
4039     );
4040
4041 gceSTATUS
4042 gcRecompileDepthBias(
4043     IN gcoHAL Hal,
4044     IN gcMACHINECODE_PTR pVsMachineCode,
4045     /*Recompile variables*/
4046     IN OUT gctPOINTER *ppRecompileStateBuffer,
4047     IN OUT gctSIZE_T *pRecompileStateBufferSize,
4048     IN OUT gcsHINT_PTR *ppRecompileHints,
4049     /* natvie state*/
4050     IN gctPOINTER pNativeStateBuffer,
4051     IN gctSIZE_T nativeStateBufferSize,
4052     IN gcsHINT_PTR pNativeHints,
4053         OUT gctINT * uniformAddr,
4054         OUT gctINT * uniformChannel
4055     );
4056
4057 /*******************************************************************************
4058 **                                gcSaveProgram
4059 ********************************************************************************
4060 **
4061 **      Save pre-compiled shaders and pre-linked programs to a binary file.
4062 **
4063 **      INPUT:
4064 **
4065 **              gcSHADER VertexShader
4066 **                      Pointer to vertex shader object.
4067 **
4068 **              gcSHADER FragmentShader
4069 **                      Pointer to fragment shader object.
4070 **
4071 **              gctSIZE_T ProgramBufferSize
4072 **                      Number of bytes in 'ProgramBuffer'.
4073 **
4074 **              gctPOINTER ProgramBuffer
4075 **                      Pointer to buffer containing the program states.
4076 **
4077 **              gcsHINT_PTR Hints
4078 **                      Pointer to HINTS structure for program states.
4079 **
4080 **      OUTPUT:
4081 **
4082 **              gctPOINTER * Binary
4083 **                      Pointer to a variable receiving the binary data to be saved.
4084 **
4085 **              gctSIZE_T * BinarySize
4086 **                      Pointer to a variable receiving the number of bytes inside 'Binary'.
4087 */
4088 gceSTATUS
4089 gcSaveProgram(
4090         IN gcSHADER VertexShader,
4091         IN gcSHADER FragmentShader,
4092         IN gctSIZE_T ProgramBufferSize,
4093         IN gctPOINTER ProgramBuffer,
4094         IN gcsHINT_PTR Hints,
4095         OUT gctPOINTER * Binary,
4096         OUT gctSIZE_T * BinarySize
4097         );
4098
4099 /*******************************************************************************
4100 **                                gcLoadProgram
4101 ********************************************************************************
4102 **
4103 **      Load pre-compiled shaders and pre-linked programs from a binary file.
4104 **
4105 **      INPUT:
4106 **
4107 **              gctPOINTER Binary
4108 **                      Pointer to the binary data loaded.
4109 **
4110 **              gctSIZE_T BinarySize
4111 **                      Number of bytes in 'Binary'.
4112 **
4113 **      OUTPUT:
4114 **
4115 **              gcSHADER VertexShader
4116 **                      Pointer to a vertex shader object.
4117 **
4118 **              gcSHADER FragmentShader
4119 **                      Pointer to a fragment shader object.
4120 **
4121 **              gctSIZE_T * ProgramBufferSize
4122 **                      Pointer to a variable receicing the number of bytes in the buffer
4123 **                      returned in 'ProgramBuffer'.
4124 **
4125 **              gctPOINTER * ProgramBuffer
4126 **                      Pointer to a variable receiving a buffer pointer that contains the
4127 **                      states required to download the shaders into the hardware.
4128 **
4129 **              gcsHINT_PTR * Hints
4130 **                      Pointer to a variable receiving a gcsHINT structure pointer that
4131 **                      contains information required when loading the shader states.
4132 */
4133 gceSTATUS
4134 gcLoadProgram(
4135         IN gctPOINTER Binary,
4136         IN gctSIZE_T BinarySize,
4137         OUT gcSHADER VertexShader,
4138         OUT gcSHADER FragmentShader,
4139         OUT gctSIZE_T * ProgramBufferSize,
4140         OUT gctPOINTER * ProgramBuffer,
4141         OUT gcsHINT_PTR * Hints
4142         );
4143
4144 /*******************************************************************************
4145 **                              gcCompileKernel
4146 ********************************************************************************
4147 **
4148 **      Compile a OpenCL kernel shader.
4149 **
4150 **      INPUT:
4151 **
4152 **              gcoOS Hal
4153 **                      Pointer to an gcoHAL object.
4154 **
4155 **              gctSIZE_T SourceSize
4156 **                      Size of the source buffer in bytes.
4157 **
4158 **              gctCONST_STRING Source
4159 **                      Pointer to the buffer containing the shader source code.
4160 **
4161 **      OUTPUT:
4162 **
4163 **              gcSHADER * Binary
4164 **                      Pointer to a variable receiving the pointer to a gcSHADER object
4165 **                      containg the compiled shader code.
4166 **
4167 **              gctSTRING * Log
4168 **                      Pointer to a variable receiving a string pointer containging the
4169 **                      compile log.
4170 */
4171 gceSTATUS
4172 gcCompileKernel(
4173         IN gcoHAL Hal,
4174         IN gctSIZE_T SourceSize,
4175         IN gctCONST_STRING Source,
4176         IN gctCONST_STRING Options,
4177         OUT gcSHADER * Binary,
4178         OUT gctSTRING * Log
4179         );
4180
4181 /*******************************************************************************
4182 **                                gcLinkKernel
4183 ********************************************************************************
4184 **
4185 **      Link OpenCL kernel and generate a harwdare specific state buffer by compiling
4186 **      the compiler generated code through the resource allocator and code
4187 **      generator.
4188 **
4189 **      INPUT:
4190 **
4191 **              gcSHADER Kernel
4192 **                      Pointer to a gcSHADER object holding information about the compiled
4193 **                      OpenCL kernel.
4194 **
4195 **              gceSHADER_FLAGS Flags
4196 **                      Compiler flags.  Can be any of the following:
4197 **
4198 **                              gcvSHADER_DEAD_CODE       - Dead code elimination.
4199 **                              gcvSHADER_RESOURCE_USAGE  - Resource usage optimizaion.
4200 **                              gcvSHADER_OPTIMIZER       - Full optimization.
4201 **                              gcvSHADER_USE_GL_Z        - Use OpenGL ES Z coordinate.
4202 **                              gcvSHADER_USE_GL_POSITION - Use OpenGL ES gl_Position.
4203 **                              gcvSHADER_USE_GL_FACE     - Use OpenGL ES gl_FaceForward.
4204 **
4205 **      OUTPUT:
4206 **
4207 **              gctSIZE_T * StateBufferSize
4208 **                      Pointer to a variable receiving the number of bytes in the buffer
4209 **                      returned in 'StateBuffer'.
4210 **
4211 **              gctPOINTER * StateBuffer
4212 **                      Pointer to a variable receiving a buffer pointer that contains the
4213 **                      states required to download the shaders into the hardware.
4214 **
4215 **              gcsHINT_PTR * Hints
4216 **                      Pointer to a variable receiving a gcsHINT structure pointer that
4217 **                      contains information required when loading the shader states.
4218 */
4219 gceSTATUS
4220 gcLinkKernel(
4221         IN gcSHADER Kernel,
4222         IN gceSHADER_FLAGS Flags,
4223         OUT gctSIZE_T * StateBufferSize,
4224         OUT gctPOINTER * StateBuffer,
4225         OUT gcsHINT_PTR * Hints
4226         );
4227
4228 /*******************************************************************************
4229 **                                gcLoadKernel
4230 ********************************************************************************
4231 **
4232 **  Load a pre-compiled and pre-linked kernel program into the hardware.
4233 **
4234 **  INPUT:
4235 **
4236 **      gctSIZE_T StateBufferSize
4237 **          The number of bytes in the 'StateBuffer'.
4238 **
4239 **      gctPOINTER StateBuffer
4240 **          Pointer to the states that make up the shader program.
4241 **
4242 **      gcsHINT_PTR Hints
4243 **          Pointer to a gcsHINT structure that contains information required
4244 **          when loading the shader states.
4245 */
4246 gceSTATUS
4247 gcLoadKernel(
4248     IN gctSIZE_T StateBufferSize,
4249     IN gctPOINTER StateBuffer,
4250     IN gcsHINT_PTR Hints
4251     );
4252
4253 gceSTATUS
4254 gcInvokeThreadWalker(
4255     IN gcsTHREAD_WALKER_INFO_PTR Info
4256     );
4257
4258 void
4259 gcTYPE_GetTypeInfo(
4260     IN gcSHADER_TYPE      Type,
4261     OUT gctINT *          Components,
4262     OUT gctINT *          Rows,
4263     OUT gctCONST_STRING * Name
4264     );
4265
4266 gctBOOL
4267 gcOPT_doVaryingPackingForShader(
4268         IN gcSHADER Shader
4269     );
4270
4271 gceSTATUS
4272 gcSHADER_PatchNPOTForMachineCode(
4273     IN     gcSHADER_KIND          shaderType,
4274     IN     gcMACHINECODE_PTR      pMachineCode,
4275     IN     gcNPOT_PATCH_PARAM_PTR pPatchParam,
4276     IN     gctUINT                countOfPatchParam,
4277     IN     gctUINT                hwSupportedInstCount,
4278     OUT    gctPOINTER*            ppCmdBuffer,
4279     OUT    gctUINT32*             pByteSizeOfCmdBuffer,
4280     IN OUT gcsHINT_PTR            pHints /* User needs copy original hints to this one, then passed this one in */
4281     );
4282
4283 gceSTATUS
4284 gcSHADER_PatchZBiasForMachineCodeVS(
4285     IN     gcMACHINECODE_PTR       pMachineCode,
4286     IN OUT gcZBIAS_PATCH_PARAM_PTR pPatchParam,
4287     IN     gctUINT                 hwSupportedInstCount,
4288     OUT    gctPOINTER*             ppCmdBuffer,
4289     OUT    gctUINT32*              pByteSizeOfCmdBuffer,
4290     IN OUT gcsHINT_PTR             pHints /* User needs copy original hints to this one, then passed this one in */
4291     );
4292
4293 #ifdef __cplusplus
4294 }
4295 #endif
4296
4297 #endif /* VIVANTE_NO_3D */
4298 #endif /* __gc_hal_compiler_h_ */