1 /****************************************************************************
3 * Copyright (C) 2005 - 2013 by Vivante Corp.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the license, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 *****************************************************************************/
22 ** Include file the defines the front- and back-end compilers, as well as the
26 #ifndef __gc_hal_compiler_h_
27 #define __gc_hal_compiler_h_
30 #include "gc_hal_types.h"
31 #include "gc_hal_engine.h"
37 #ifndef GC_ENABLE_LOADTIME_OPT
38 #define GC_ENABLE_LOADTIME_OPT 1
41 #define TEMP_OPT_CONSTANT_TEXLD_COORD 0
43 #define TEMP_SHADER_PATCH 1
45 #define TEMP_INLINE_ALL_EXPANSION 1
46 /******************************* IR VERSION ******************/
47 #define gcdSL_IR_VERSION gcmCC('\0','\0','\0','\1')
49 /******************************************************************************\
50 |******************************* SHADER LANGUAGE ******************************|
51 \******************************************************************************/
53 /* allocator/deallocator function pointer */
54 typedef gceSTATUS (*gctAllocatorFunc)(
56 OUT gctPOINTER * Memory
59 typedef gceSTATUS (*gctDeallocatorFunc)(
63 typedef gctBOOL (*compareFunc) (
68 typedef struct _gcsListNode gcsListNode;
75 typedef struct _gcsAllocator
77 gctAllocatorFunc allocate;
78 gctDeallocatorFunc deallocate;
81 /* simple map structure */
82 typedef struct _SimpleMap SimpleMap;
88 gcsAllocator *allocator;
92 /* SimpleMap Operations */
93 /* return -1 if not found, otherwise return the mapped value */
103 IN gcsAllocator * Allocator
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 :
109 * gcSimpleMap_AddNode(&theMap, key, val, allocator);
117 IN gcsAllocator * Allocator
120 /* gcsList data structure and related operations */
121 typedef struct _gcsList
126 gcsAllocator *allocator;
129 /* List operations */
133 IN gcsAllocator *allocator
139 IN gctAllocatorFunc Allocator,
140 OUT gcsListNode ** ListNode
153 IN compareFunc compare
165 IN gcsListNode * Node
168 /* link list structure for code list */
169 typedef gcsList gcsCodeList;
170 typedef gcsCodeList * gctCodeList;
171 typedef gcsListNode gcsCodeListNode;
173 /* Possible shader language opcodes. */
174 typedef enum _gcSL_OPCODE
187 gcSL_KILL, /* 0x0B */
188 gcSL_TEXLD, /* 0x0C */
189 gcSL_CALL, /* 0x0D */
191 gcSL_NORM, /* 0x0F */
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 */
209 gcSL_SIGN, /* 0x21 */
210 gcSL_STEP, /* 0x22 */
211 gcSL_SQRT, /* 0x23 */
212 gcSL_ACOS, /* 0x24 */
213 gcSL_ASIN, /* 0x25 */
214 gcSL_ATAN, /* 0x26 */
218 gcSL_FWIDTH, /* 0x2A */
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. */
268 gcSL_ADDSAT, /* 0x5C */ /* Integer only. */
269 gcSL_SUBSAT, /* 0x5D */ /* Integer only. */
270 gcSL_MULSAT, /* 0x5E */ /* Integer only. */
276 typedef enum _gcSL_FORMAT
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 */
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. */
297 /* Destination write enable bits. */
298 typedef enum _gcSL_ENABLE
300 gcSL_ENABLE_NONE = 0x0, /* none is enabled, error/uninitialized state */
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,
320 /* Possible indices. */
321 typedef enum _gcSL_INDEXED
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 */
331 /* Opcode conditions. */
332 typedef enum _gcSL_CONDITION
334 gcSL_ALWAYS, /* 0x0 */
335 gcSL_NOT_EQUAL, /* 0x1 */
336 gcSL_LESS_OR_EQUAL, /* 0x2 */
338 gcSL_EQUAL, /* 0x4 */
339 gcSL_GREATER, /* 0x5 */
340 gcSL_GREATER_OR_EQUAL, /* 0x6 */
344 gcSL_NOT_ZERO, /* 0xA */
348 /* Possible source operand types. */
349 typedef enum _gcSL_TYPE
353 gcSL_ATTRIBUTE, /* 0x2 */
354 gcSL_UNIFORM, /* 0x3 */
355 gcSL_SAMPLER, /* 0x4 */
356 gcSL_CONSTANT, /* 0x5 */
357 gcSL_OUTPUT, /* 0x6 */
358 gcSL_PHYSICAL, /* 0x7 */
362 /* Swizzle generator macro. */
363 #define gcmSWIZZLE(Component1, Component2, Component3, Component4) \
365 (gcSL_SWIZZLE_ ## Component1 << 0) | \
366 (gcSL_SWIZZLE_ ## Component2 << 2) | \
367 (gcSL_SWIZZLE_ ## Component3 << 4) | \
368 (gcSL_SWIZZLE_ ## Component4 << 6) \
371 #define gcmExtractSwizzle(Swizzle, Index) \
372 ((gcSL_SWIZZLE) ((((Swizzle) >> (Index * 2)) & 0x3)))
374 #define gcmComposeSwizzle(SwizzleX, SwizzleY, SwizzleZ, SwizzleW) \
376 ((SwizzleX) << 0) | \
377 ((SwizzleY) << 2) | \
378 ((SwizzleZ) << 4) | \
382 /* Possible swizzle values. */
383 typedef enum _gcSL_SWIZZLE
385 gcSL_SWIZZLE_X, /* 0x0 */
386 gcSL_SWIZZLE_Y, /* 0x1 */
387 gcSL_SWIZZLE_Z, /* 0x2 */
388 gcSL_SWIZZLE_W, /* 0x3 */
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),
413 gcSL_SWIZZLE_INVALID = 0x7FFFFFFF
417 typedef enum _gcSL_COMPONENT
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 */
426 #define gcmIsComponentEnabled(Enable, Component) (((Enable) & (1 << (Component))) != 0)
428 /******************************************************************************\
429 |*********************************** SHADERS **********************************|
430 \******************************************************************************/
433 typedef enum _gcSHADER_KIND {
434 gcSHADER_TYPE_UNKNOWN = 0,
435 gcSHADER_TYPE_VERTEX,
436 gcSHADER_TYPE_FRAGMENT,
438 gcSHADER_TYPE_PRECOMPILED,
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;
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;
461 /* Numbr of data transfers for Vertex Shader output. */
462 gctUINT32 vsOutputCount;
464 /* Flag whether the VS has point size or not. */
465 gctBOOL vsHasPointSize;
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;
475 /* Flag whether or not the shader has a KILL instruction. */
479 gctUINT32 elementCount;
481 /* Component count. */
482 gctUINT32 componentCount;
484 /* Number of data transfers for Fragment Shader input. */
485 gctUINT32 fsInputCount;
487 /* Maximum number of temporary registers used in FS. */
490 /* Maximum number of temporary registers used in VS. */
493 /* Balance minimum. */
494 gctUINT32 balanceMin;
496 /* Balance maximum. */
497 gctUINT32 balanceMax;
499 /* Auto-shift balancing. */
502 /* Flag whether the PS outputs the depth value or not. */
503 gctBOOL psHasFragDepthOut;
505 /* Flag whether the ThreadWalker is in PS. */
506 gctBOOL threadWalkerInPS;
508 /* HW reg number for position of VS */
509 gctUINT32 hwRegNoOfSIVPos;
511 #if gcdALPHA_KILL_IN_SHADER
512 /* States to set when alpha kill is enabled. */
513 gctUINT32 killStateAddress;
514 gctUINT32 alphaKillStateValue;
515 gctUINT32 colorKillStateValue;
517 /* Shader instructiuon. */
518 gctUINT32 killInstructionAddress;
519 gctUINT32 alphaKillInstruction[3];
520 gctUINT32 colorKillInstruction[3];
523 #if TEMP_SHADER_PATCH
524 gctUINT32 pachedShaderIdentifier;
528 #if TEMP_SHADER_PATCH
529 #define INVALID_SHADER_IDENTIFIER 0xFFFFFFFF
532 /* gcSHADER_TYPE enumeration. */
533 typedef enum _gcSHADER_TYPE
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 */
575 gcSHADER_UINT_X1, /* 0x27 */
576 gcSHADER_UINT_X2, /* 0x28 */
577 gcSHADER_UINT_X3, /* 0x29 */
578 gcSHADER_UINT_X4, /* 0x2A */
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! */}
585 typedef enum _gcSHADER_TYPE_KIND
596 } gcSHADER_TYPE_KIND;
598 typedef struct _gcSHADER_TYPEINFO
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" */
608 extern gcSHADER_TYPEINFO gcvShaderTypeInfo[];
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)
616 #define gcmType_isMatrix(type) (gcmType_Rows(type) > 1)
618 typedef enum _gcSHADER_VAR_CATEGORY
620 gcSHADER_VAR_CATEGORY_NORMAL = 0, /* primitive type and its array */
621 gcSHADER_VAR_CATEGORY_STRUCT = 1 /* structure */
623 gcSHADER_VAR_CATEGORY;
625 typedef enum _gceTYPE_QUALIFIER
627 gcvTYPE_QUALIFIER_NONE = 0x0, /* unqualified */
628 gcvTYPE_QUALIFIER_VOLATILE = 0x1, /* volatile */
631 typedef gctUINT16 gctTYPE_QUALIFIER;
633 #if GC_ENABLE_LOADTIME_OPT
634 typedef struct _gcSHADER_TYPE_INFO
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;
644 extern gcSHADER_TYPE_INFO shader_type_info[];
646 enum gceLTCDumpOption {
647 gceLTC_DUMP_UNIFORM = 0x0001,
648 gceLTC_DUMP_EVALUATION = 0x0002,
649 gceLTC_DUMP_EXPESSION = 0x0004,
650 gceLTC_DUMP_COLLECTING = 0x0008,
653 gctBOOL gcDumpOption(gctINT Opt);
655 #endif /* GC_ENABLE_LOADTIME_OPT */
657 #define IS_MATRIX_TYPE(type) \
658 (((type >= gcSHADER_FLOAT_2X2) && (type <= gcSHADER_FLOAT_4X4)) || \
659 ((type >= gcSHADER_FLOAT_2X3) && (type <= gcSHADER_FLOAT_4X3)))
661 /* gcSHADER_PRECISION enumeration. */
662 typedef enum _gcSHADER_PRECISION
664 gcSHADER_PRECISION_DEFAULT, /* 0x00 */
665 gcSHADER_PRECISION_HIGH, /* 0x01 */
666 gcSHADER_PRECISION_MEDIUM, /* 0x02 */
667 gcSHADER_PRECISION_LOW, /* 0x03 */
672 typedef enum _gceSHADER_FLAGS
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,
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:
687 So here we append two instructions to the vertex shader.
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,
697 #if gcdPRE_ROTATION && (ANDROID_SDK_VERSION >= 14)
698 gcvSHADER_VS_PRE_ROTATION = 0x200,
701 #if TEMP_INLINE_ALL_EXPANSION
702 gcvSHADER_INLINE_ALL_EXPANSION = 0x400,
709 IN gctCONST_STRING VertexSource,
710 IN gctCONST_STRING FragmentSource,
711 OUT gctBOOL * clipW);
713 /*******************************************************************************
714 ** gcSHADER_GetUniformVectorCount
716 ** Get the number of vectors used by uniforms for this shader.
721 ** Pointer to a gcSHADER object.
726 ** Pointer to a variable receiving the number of vectors.
729 gcSHADER_GetUniformVectorCount(
731 OUT gctSIZE_T * Count
734 /*******************************************************************************
735 ** gcOptimizer Data Structures
736 *******************************************************************************/
737 typedef enum _gceSHADER_OPTIMIZATION
739 /* No optimization. */
740 gcvOPTIMIZATION_NONE,
742 /* Flow graph construction. */
743 gcvOPTIMIZATION_CONSTRUCTION = 1 << 0,
745 /* Dead code elimination. */
746 gcvOPTIMIZATION_DEAD_CODE = 1 << 1,
748 /* Redundant move instruction elimination. */
749 gcvOPTIMIZATION_REDUNDANT_MOVE = 1 << 2,
751 /* Inline expansion. */
752 gcvOPTIMIZATION_INLINE_EXPANSION = 1 << 3,
754 /* Constant propagation. */
755 gcvOPTIMIZATION_CONSTANT_PROPAGATION = 1 << 4,
757 /* Redundant bounds/checking elimination. */
758 gcvOPTIMIZATION_REDUNDANT_CHECKING = 1 << 5,
760 /* Loop invariant movement. */
761 gcvOPTIMIZATION_LOOP_INVARIANT = 1 << 6,
763 /* Induction variable removal. */
764 gcvOPTIMIZATION_INDUCTION_VARIABLE = 1 << 7,
766 /* Common subexpression elimination. */
767 gcvOPTIMIZATION_COMMON_SUBEXPRESSION = 1 << 8,
769 /* Control flow/banch optimization. */
770 gcvOPTIMIZATION_CONTROL_FLOW = 1 << 9,
772 /* Vector component operation merge. */
773 gcvOPTIMIZATION_VECTOR_INSTRUCTION_MERGE = 1 << 10,
775 /* Algebra simplificaton. */
776 gcvOPTIMIZATION_ALGEBRAIC_SIMPLIFICATION = 1 << 11,
778 /* Pattern matching and replacing. */
779 gcvOPTIMIZATION_PATTERN_MATCHING = 1 << 12,
781 /* Interprocedural constant propagation. */
782 gcvOPTIMIZATION_IP_CONSTANT_PROPAGATION = 1 << 13,
784 /* Interprecedural register optimization. */
785 gcvOPTIMIZATION_IP_REGISTRATION = 1 << 14,
787 /* Optimization option number. */
788 gcvOPTIMIZATION_OPTION_NUMBER = 1 << 15,
790 /* Loadtime constant. */
791 gcvOPTIMIZATION_LOADTIME_CONSTANT = 1 << 16,
793 /* MAD instruction optimization. */
794 gcvOPTIMIZATION_MAD_INSTRUCTION = 1 << 17,
796 /* Special optimization for LOAD SW workaround. */
797 gcvOPTIMIZATION_LOAD_SW_WORKAROUND = 1 << 18,
799 /* move code into conditional block if possile */
800 gcvOPTIMIZATION_CONDITIONALIZE = 1 << 19,
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
808 gcvOPTIMIZATION_POWER_OPTIMIZATION = 1 << 20,
810 /* optimize varying packing */
811 gcvOPTIMIZATION_VARYINGPACKING = 1 << 22,
813 #if TEMP_INLINE_ALL_EXPANSION
814 gcvOPTIMIZATION_INLINE_ALL_EXPANSION = 1 << 23,
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,
824 /* Optimization Unit Test flag. */
825 gcvOPTIMIZATION_UNIT_TEST = 1 << 31
827 gceSHADER_OPTIMIZATION;
829 typedef enum _gceOPTIMIZATION_VaryingPaking
831 gcvOPTIMIZATION_VARYINGPACKING_NONE = 0,
832 gcvOPTIMIZATION_VARYINGPACKING_NOSPLIT,
833 gcvOPTIMIZATION_VARYINGPACKING_SPLIT
834 } gceOPTIMIZATION_VaryingPaking;
836 typedef struct _gcOPTIMIZER_OPTION
838 gceSHADER_OPTIMIZATION optFlags;
840 /* debug & dump options:
842 VC_OPTION=-DUMP:SRC:OPT|:OPTV|:CG|:CGV:|ALL|ALLV
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
851 ALLV = SRC|OPT|OPTV|CG|CGV
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 */
860 /* Code generation */
864 VC_OPTION=-PACKVARYING:[0-2]|:T[-]m[,n]|:LshaderIdx,min,max
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
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]
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.);
882 gceOPTIMIZATION_VaryingPaking packVarying;
885 gctINT _loadBalanceShaderIdx;
886 gctINT _loadBalanceMin;
887 gctINT _loadBalanceMax;
889 /* Do not generate immdeiate
893 Force generate immediate even the machine model don't support it,
894 for testing purpose only
899 gctBOOL forceImmediate;
901 /* Power reduction mode options */
902 gctBOOL needPowerOptimization;
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
908 it can be enabled by environment variable:
910 VC_OPTION=-PATCH_TEXLD:M:N
912 (for each M texld, add N dummy texld)
914 gctINT patchEveryTEXLDs;
915 gctINT patchDummyTEXLDs;
917 /* Insert NOP after high power consumption instructions
919 VC_OPTION="-INSERTNOP:MUL:MULLO:DP3:DP4:SEENTEXLD"
922 gctBOOL insertNOPAfterMUL;
923 gctBOOL insertNOPAfterMULLO;
924 gctBOOL insertNOPAfterDP3;
925 gctBOOL insertNOPAfterDP4;
926 gctBOOL insertNOPOnlyWhenTexldSeen;
928 /* split MAD to MUL and ADD:
934 /* Convert vect3/vec4 operations to multiple vec2/vec1 operations
936 VC_OPTION=-SPLITVEC:MUL:MULLO:DP3:DP4
939 gctBOOL splitVec4MUL;
940 gctBOOL splitVec4MULLO;
941 gctBOOL splitVec4DP3;
942 gctBOOL splitVec4DP4;
944 /* turn/off features:
947 Note: n must be decimal number
951 /* inline level (default 2 at O1):
953 VC_OPTION=-INLINELEVEL:[0-3]
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
960 } gcOPTIMIZER_OPTION;
962 extern gcOPTIMIZER_OPTION theOptimizerOption;
963 #define gcmGetOptimizerOption() gcGetOptimizerOption()
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)
980 #define gcmOPT_SET_DUMP_SHADER_SRC(v) \
981 gcmGetOptimizerOption()->dumpShaderSource = (v)
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)
988 #define gcmOPT_NOIMMEDIATE() (gcmGetOptimizerOption()->noImmediate == gcvTRUE)
989 #define gcmOPT_FORCEIMMEDIATE() (gcmGetOptimizerOption()->forceImmediate == gcvTRUE)
991 #define gcmOPT_PACKVARYING() (gcmGetOptimizerOption()->packVarying)
992 #define gcmOPT_PACKVARYING_triageStart() (gcmGetOptimizerOption()->_triageStart)
993 #define gcmOPT_PACKVARYING_triageEnd() (gcmGetOptimizerOption()->_triageEnd)
995 #define gcmOPT_INLINELEVEL() (gcmGetOptimizerOption()->inlineLevel)
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)
1009 #define gcmOPT_SetPackVarying(v) (gcmGetOptimizerOption()->packVarying = v)
1011 #define FB_LIVERANGE_FIX1 0x0001
1014 #define PredefinedDummySamplerId 8
1016 /* Function argument qualifier */
1017 typedef enum _gceINPUT_OUTPUT
1025 /* Kernel function property flags. */
1026 typedef enum _gcePROPERTY_FLAGS
1028 gcvPROPERTY_REQD_WORK_GRP_SIZE = 0x01
1030 gceKERNEL_FUNCTION_PROPERTY_FLAGS;
1032 /* Uniform flags. */
1033 typedef enum _gceUNIFORM_FLAGS
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,
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)
1060 typedef enum _gceVARIABLE_UPDATE_FLAGS
1062 gcvVARIABLE_UPDATE_NOUPDATE = 0,
1063 gcvVARIABLE_UPDATE_TEMPREG,
1064 gcvVARIABLE_UPDATE_TYPE_QUALIFIER,
1065 }gceVARIABLE_UPDATE_FLAGS;
1067 typedef struct _gcMACHINE_INST
1073 }gcMACHINE_INST, *gcMACHINE_INST_PTR;
1075 typedef struct _gcMACHINECODE
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;
1084 typedef enum NP2_ADDRESS_MODE
1086 NP2_ADDRESS_MODE_CLAMP = 0,
1087 NP2_ADDRESS_MODE_REPEAT = 1,
1088 NP2_ADDRESS_MODE_MIRROR = 2
1091 typedef struct _gcNPOT_PATCH_PARAM
1094 NP2_ADDRESS_MODE addressMode[3];
1095 gctINT texDimension; /* 2 or 3 */
1096 }gcNPOT_PATCH_PARAM, *gcNPOT_PATCH_PARAM_PTR;
1098 typedef struct _gcZBIAS_PATCH_PARAM
1100 /* Driver uses this to program uniform that designating zbias */
1103 }gcZBIAS_PATCH_PARAM, *gcZBIAS_PATCH_PARAM_PTR;
1107 IN OUT gcOPTIMIZER_OPTION * Option
1111 gcSetOptimizerOption(
1112 IN gceSHADER_FLAGS Flags
1115 gcOPTIMIZER_OPTION *
1116 gcGetOptimizerOption();
1118 /*******************************************************************************
1119 ** gcSHADER_SetCompilerVersion
1121 ** Set the compiler version of a gcSHADER object.
1126 ** Pointer to gcSHADER object
1129 ** Pointer to a two word version
1132 gcSHADER_SetCompilerVersion(
1134 IN gctUINT32 *Version
1137 /*******************************************************************************
1138 ** gcSHADER_GetCompilerVersion
1140 ** Get the compiler version of a gcSHADER object.
1145 ** Pointer to a gcSHADER object.
1149 ** gctUINT32_PTR *CompilerVersion.
1150 ** Pointer to holder of returned compilerVersion pointer
1153 gcSHADER_GetCompilerVersion(
1155 OUT gctUINT32_PTR *CompilerVersion
1158 /*******************************************************************************
1161 ** Get the gcSHADER object's type.
1166 ** Pointer to a gcSHADER object.
1171 ** Pointer to return shader type.
1181 /*******************************************************************************
1182 ** gcSHADER_Construct
1183 ********************************************************************************
1185 ** Construct a new gcSHADER object.
1190 ** Pointer to an gcoHAL object.
1192 ** gctINT ShaderType
1193 ** Type of gcSHADER object to cerate. 'ShaderType' can be one of the
1196 ** gcSHADER_TYPE_VERTEX Vertex shader.
1197 ** gcSHADER_TYPE_FRAGMENT Fragment shader.
1201 ** gcSHADER * Shader
1202 ** Pointer to a variable receiving the gcSHADER object pointer.
1207 IN gctINT ShaderType,
1208 OUT gcSHADER * Shader
1211 /*******************************************************************************
1213 ********************************************************************************
1215 ** Destroy a gcSHADER object.
1220 ** Pointer to a gcSHADER object.
1231 /*******************************************************************************
1233 ********************************************************************************
1235 ** Copy a gcSHADER object.
1240 ** Pointer to a gcSHADER object.
1243 ** Pointer to a gcSHADER object that will be copied.
1255 /*******************************************************************************
1256 ** gcSHADER_LoadHeader
1258 ** Load a gcSHADER object from a binary buffer. The binary buffer is layed out
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;
1271 ** Pointer to a gcSHADER object.
1272 ** Shader type will be returned if type in shader object is not gcSHADER_TYPE_PRECOMPILED
1274 ** gctPOINTER Buffer
1275 ** Pointer to a binary buffer containing the shader data to load.
1277 ** gctSIZE_T BufferSize
1278 ** Number of bytes inside the binary buffer pointed to by 'Buffer'.
1285 gcSHADER_LoadHeader(
1287 IN gctPOINTER Buffer,
1288 IN gctSIZE_T BufferSize,
1289 OUT gctUINT32 * ShaderVersion
1292 /*******************************************************************************
1293 ** gcSHADER_LoadKernel
1295 ** Load a kernel function given by name into gcSHADER object
1300 ** Pointer to a gcSHADER object.
1302 ** gctSTRING KernelName
1303 ** Pointer to a kernel function name
1310 gcSHADER_LoadKernel(
1312 IN gctSTRING KernelName
1315 /*******************************************************************************
1317 ********************************************************************************
1319 ** Load a gcSHADER object from a binary buffer.
1324 ** Pointer to a gcSHADER object.
1326 ** gctPOINTER Buffer
1327 ** Pointer to a binary buffer containg the shader data to load.
1329 ** gctSIZE_T BufferSize
1330 ** Number of bytes inside the binary buffer pointed to by 'Buffer'.
1339 IN gctPOINTER Buffer,
1340 IN gctSIZE_T BufferSize
1343 /*******************************************************************************
1345 ********************************************************************************
1347 ** Save a gcSHADER object to a binary buffer.
1352 ** Pointer to a gcSHADER object.
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.
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.
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.
1373 IN gctPOINTER Buffer,
1374 IN OUT gctSIZE_T * BufferSize
1377 /*******************************************************************************
1379 ********************************************************************************
1381 ** Load a gcSHADER object from a binary buffer.
1386 ** Pointer to a gcSHADER object.
1388 ** gctPOINTER Buffer
1389 ** Pointer to a binary buffer containg the shader data to load.
1391 ** gctSIZE_T BufferSize
1392 ** Number of bytes inside the binary buffer pointed to by 'Buffer'.
1401 IN gctPOINTER Buffer,
1402 IN gctSIZE_T BufferSize
1405 /*******************************************************************************
1407 ********************************************************************************
1409 ** Save a gcSHADER object to a binary buffer.
1414 ** Pointer to a gcSHADER object.
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.
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.
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.
1435 IN gctPOINTER Buffer,
1436 IN OUT gctSIZE_T * BufferSize
1439 /*******************************************************************************
1440 ** gcSHADER_ReallocateAttributes
1442 ** Reallocate an array of pointers to gcATTRIBUTE objects.
1447 ** Pointer to a gcSHADER object.
1450 ** Array count to reallocate. 'Count' must be at least 1.
1453 gcSHADER_ReallocateAttributes(
1458 /*******************************************************************************
1459 ** gcSHADER_AddAttribute
1460 ********************************************************************************
1462 ** Add an attribute to a gcSHADER object.
1467 ** Pointer to a gcSHADER object.
1469 ** gctCONST_STRING Name
1470 ** Name of the attribute to add.
1472 ** gcSHADER_TYPE Type
1473 ** Type of the attribute to add.
1476 ** Array length of the attribute to add. 'Length' must be at least 1.
1478 ** gctBOOL IsTexture
1479 ** gcvTRUE if the attribute is used as a texture coordinate, gcvFALSE if not.
1483 ** gcATTRIBUTE * Attribute
1484 ** Pointer to a variable receiving the gcATTRIBUTE object pointer.
1487 gcSHADER_AddAttribute(
1489 IN gctCONST_STRING Name,
1490 IN gcSHADER_TYPE Type,
1491 IN gctSIZE_T Length,
1492 IN gctBOOL IsTexture,
1493 OUT gcATTRIBUTE * Attribute
1496 /*******************************************************************************
1497 ** gcSHADER_GetAttributeCount
1498 ********************************************************************************
1500 ** Get the number of attributes for this shader.
1505 ** Pointer to a gcSHADER object.
1509 ** gctSIZE_T * Count
1510 ** Pointer to a variable receiving the number of attributes.
1513 gcSHADER_GetAttributeCount(
1515 OUT gctSIZE_T * Count
1518 /*******************************************************************************
1519 ** gcSHADER_GetAttribute
1520 ********************************************************************************
1522 ** Get the gcATTRIBUTE object poniter for an indexed attribute for this shader.
1527 ** Pointer to a gcSHADER object.
1530 ** Index of the attribute to retrieve.
1534 ** gcATTRIBUTE * Attribute
1535 ** Pointer to a variable receiving the gcATTRIBUTE object pointer.
1538 gcSHADER_GetAttribute(
1541 OUT gcATTRIBUTE * Attribute
1544 /*******************************************************************************
1545 ** gcSHADER_ReallocateUniforms
1547 ** Reallocate an array of pointers to gcUNIFORM objects.
1552 ** Pointer to a gcSHADER object.
1555 ** Array count to reallocate. 'Count' must be at least 1.
1558 gcSHADER_ReallocateUniforms(
1563 /*******************************************************************************
1564 ** gcSHADER_AddUniform
1565 ********************************************************************************
1567 ** Add an uniform to a gcSHADER object.
1572 ** Pointer to a gcSHADER object.
1574 ** gctCONST_STRING Name
1575 ** Name of the uniform to add.
1577 ** gcSHADER_TYPE Type
1578 ** Type of the uniform to add.
1581 ** Array length of the uniform to add. 'Length' must be at least 1.
1585 ** gcUNIFORM * Uniform
1586 ** Pointer to a variable receiving the gcUNIFORM object pointer.
1589 gcSHADER_AddUniform(
1591 IN gctCONST_STRING Name,
1592 IN gcSHADER_TYPE Type,
1593 IN gctSIZE_T Length,
1594 OUT gcUNIFORM * Uniform
1597 /*******************************************************************************
1598 ** gcSHADER_AddPreRotationUniform
1599 ********************************************************************************
1601 ** Add an uniform to a gcSHADER object.
1606 ** Pointer to a gcSHADER object.
1608 ** gctCONST_STRING Name
1609 ** Name of the uniform to add.
1611 ** gcSHADER_TYPE Type
1612 ** Type of the uniform to add.
1615 ** Array length of the uniform to add. 'Length' must be at least 1.
1622 ** gcUNIFORM * Uniform
1623 ** Pointer to a variable receiving the gcUNIFORM object pointer.
1626 gcSHADER_AddPreRotationUniform(
1628 IN gctCONST_STRING Name,
1629 IN gcSHADER_TYPE Type,
1630 IN gctSIZE_T Length,
1632 OUT gcUNIFORM * Uniform
1635 /*******************************************************************************
1636 ** gcSHADER_AddUniformEx
1637 ********************************************************************************
1639 ** Add an uniform to a gcSHADER object.
1644 ** Pointer to a gcSHADER object.
1646 ** gctCONST_STRING Name
1647 ** Name of the uniform to add.
1649 ** gcSHADER_TYPE Type
1650 ** Type of the uniform to add.
1652 ** gcSHADER_PRECISION precision
1653 ** Precision of the uniform to add.
1656 ** Array length of the uniform to add. 'Length' must be at least 1.
1660 ** gcUNIFORM * Uniform
1661 ** Pointer to a variable receiving the gcUNIFORM object pointer.
1664 gcSHADER_AddUniformEx(
1666 IN gctCONST_STRING Name,
1667 IN gcSHADER_TYPE Type,
1668 IN gcSHADER_PRECISION precision,
1669 IN gctSIZE_T Length,
1670 OUT gcUNIFORM * Uniform
1673 /*******************************************************************************
1674 ** gcSHADER_AddUniformEx1
1675 ********************************************************************************
1677 ** Add an uniform to a gcSHADER object.
1682 ** Pointer to a gcSHADER object.
1684 ** gctCONST_STRING Name
1685 ** Name of the uniform to add.
1687 ** gcSHADER_TYPE Type
1688 ** Type of the uniform to add.
1690 ** gcSHADER_PRECISION precision
1691 ** Precision of the uniform to add.
1694 ** Array length of the uniform to add. 'Length' must be at least 1.
1696 ** gcSHADER_VAR_CATEGORY varCategory
1697 ** Variable category, normal or struct.
1699 ** gctUINT16 numStructureElement
1700 ** If struct, its element number.
1703 ** If struct, parent index in gcSHADER.variables.
1705 ** gctINT16 prevSibling
1706 ** If struct, previous sibling index in gcSHADER.variables.
1710 ** gcUNIFORM * Uniform
1711 ** Pointer to a variable receiving the gcUNIFORM object pointer.
1713 ** gctINT16* ThisUniformIndex
1714 ** Returned value about uniform index in gcSHADER.
1717 gcSHADER_AddUniformEx1(
1719 IN gctCONST_STRING Name,
1720 IN gcSHADER_TYPE Type,
1721 IN gcSHADER_PRECISION precision,
1722 IN gctSIZE_T Length,
1724 IN gcSHADER_VAR_CATEGORY varCategory,
1725 IN gctUINT16 numStructureElement,
1727 IN gctINT16 prevSibling,
1728 OUT gctINT16* ThisUniformIndex,
1729 OUT gcUNIFORM * Uniform
1732 /*******************************************************************************
1733 ** gcSHADER_GetUniformCount
1734 ********************************************************************************
1736 ** Get the number of uniforms for this shader.
1741 ** Pointer to a gcSHADER object.
1745 ** gctSIZE_T * Count
1746 ** Pointer to a variable receiving the number of uniforms.
1749 gcSHADER_GetUniformCount(
1751 OUT gctSIZE_T * Count
1754 /*******************************************************************************
1755 ** gcSHADER_GetPreRotationUniform
1756 ********************************************************************************
1758 ** Get the preRotate Uniform.
1763 ** Pointer to a gcSHADER object.
1767 ** gcUNIFORM ** pUniform
1768 ** Pointer to a preRotation uniforms array.
1771 gcSHADER_GetPreRotationUniform(
1773 OUT gcUNIFORM ** pUniform
1776 /*******************************************************************************
1777 ** gcSHADER_GetUniform
1778 ********************************************************************************
1780 ** Get the gcUNIFORM object pointer for an indexed uniform for this shader.
1785 ** Pointer to a gcSHADER object.
1788 ** Index of the uniform to retrieve.
1792 ** gcUNIFORM * Uniform
1793 ** Pointer to a variable receiving the gcUNIFORM object pointer.
1796 gcSHADER_GetUniform(
1799 OUT gcUNIFORM * Uniform
1803 /*******************************************************************************
1804 ** gcSHADER_GetUniformIndexingRange
1805 ********************************************************************************
1807 ** Get the gcUNIFORM object pointer for an indexed uniform for this shader.
1812 ** Pointer to a gcSHADER object.
1814 ** gctINT uniformIndex
1815 ** Index of the start uniform.
1818 ** Offset to indexing.
1822 ** gctINT * LastUniformIndex
1823 ** Pointer to index of last uniform in indexing range.
1825 ** gctINT * OffsetUniformIndex
1826 ** Pointer to index of uniform that indexing at offset.
1828 ** gctINT * DeviationInOffsetUniform
1829 ** Pointer to offset in uniform picked up.
1832 gcSHADER_GetUniformIndexingRange(
1834 IN gctINT uniformIndex,
1836 OUT gctINT * LastUniformIndex,
1837 OUT gctINT * OffsetUniformIndex,
1838 OUT gctINT * DeviationInOffsetUniform
1841 /*******************************************************************************
1842 ** gcSHADER_GetKernelFucntion
1844 ** Get the gcKERNEL_FUNCTION object pointer for an indexed kernel function for this shader.
1849 ** Pointer to a gcSHADER object.
1852 ** Index of kernel function to retreive the name for.
1856 ** gcKERNEL_FUNCTION * KernelFunction
1857 ** Pointer to a variable receiving the gcKERNEL_FUNCTION object pointer.
1860 gcSHADER_GetKernelFunction(
1863 OUT gcKERNEL_FUNCTION * KernelFunction
1867 gcSHADER_GetKernelFunctionByName(
1869 IN gctSTRING KernelName,
1870 OUT gcKERNEL_FUNCTION * KernelFunction
1872 /*******************************************************************************
1873 ** gcSHADER_GetKernelFunctionCount
1875 ** Get the number of kernel functions for this shader.
1880 ** Pointer to a gcSHADER object.
1884 ** gctSIZE_T * Count
1885 ** Pointer to a variable receiving the number of kernel functions.
1888 gcSHADER_GetKernelFunctionCount(
1890 OUT gctSIZE_T * Count
1893 /*******************************************************************************
1894 ** gcSHADER_ReallocateOutputs
1896 ** Reallocate an array of pointers to gcOUTPUT objects.
1901 ** Pointer to a gcSHADER object.
1904 ** Array count to reallocate. 'Count' must be at least 1.
1907 gcSHADER_ReallocateOutputs(
1912 /*******************************************************************************
1913 ** gcSHADER_AddOutput
1914 ********************************************************************************
1916 ** Add an output to a gcSHADER object.
1921 ** Pointer to a gcSHADER object.
1923 ** gctCONST_STRING Name
1924 ** Name of the output to add.
1926 ** gcSHADER_TYPE Type
1927 ** Type of the output to add.
1930 ** Array length of the output to add. 'Length' must be at least 1.
1932 ** gctUINT16 TempRegister
1933 ** Temporary register index that holds the output value.
1942 IN gctCONST_STRING Name,
1943 IN gcSHADER_TYPE Type,
1944 IN gctSIZE_T Length,
1945 IN gctUINT16 TempRegister
1949 gcSHADER_AddOutputIndexed(
1951 IN gctCONST_STRING Name,
1953 IN gctUINT16 TempIndex
1956 /*******************************************************************************
1957 ** gcSHADER_GetOutputCount
1958 ********************************************************************************
1960 ** Get the number of outputs for this shader.
1965 ** Pointer to a gcSHADER object.
1969 ** gctSIZE_T * Count
1970 ** Pointer to a variable receiving the number of outputs.
1973 gcSHADER_GetOutputCount(
1975 OUT gctSIZE_T * Count
1978 /*******************************************************************************
1979 ** gcSHADER_GetOutput
1980 ********************************************************************************
1982 ** Get the gcOUTPUT object pointer for an indexed output for this shader.
1987 ** Pointer to a gcSHADER object.
1990 ** Index of output to retrieve.
1994 ** gcOUTPUT * Output
1995 ** Pointer to a variable receiving the gcOUTPUT object pointer.
2001 OUT gcOUTPUT * Output
2005 /*******************************************************************************
2006 ** gcSHADER_GetOutputByName
2007 ********************************************************************************
2009 ** Get the gcOUTPUT object pointer for this shader by output name.
2014 ** Pointer to a gcSHADER object.
2017 ** Name of output to retrieve.
2019 ** gctSIZE_T nameLength
2020 ** Length of name to retrieve
2024 ** gcOUTPUT * Output
2025 ** Pointer to a variable receiving the gcOUTPUT object pointer.
2028 gcSHADER_GetOutputByName(
2031 IN gctSIZE_T nameLength,
2032 OUT gcOUTPUT * Output
2035 /*******************************************************************************
2036 ** gcSHADER_ReallocateVariables
2038 ** Reallocate an array of pointers to gcVARIABLE objects.
2043 ** Pointer to a gcSHADER object.
2046 ** Array count to reallocate. 'Count' must be at least 1.
2049 gcSHADER_ReallocateVariables(
2054 /*******************************************************************************
2055 ** gcSHADER_AddVariable
2056 ********************************************************************************
2058 ** Add a variable to a gcSHADER object.
2063 ** Pointer to a gcSHADER object.
2065 ** gctCONST_STRING Name
2066 ** Name of the variable to add.
2068 ** gcSHADER_TYPE Type
2069 ** Type of the variable to add.
2072 ** Array length of the variable to add. 'Length' must be at least 1.
2074 ** gctUINT16 TempRegister
2075 ** Temporary register index that holds the variable value.
2082 gcSHADER_AddVariable(
2084 IN gctCONST_STRING Name,
2085 IN gcSHADER_TYPE Type,
2086 IN gctSIZE_T Length,
2087 IN gctUINT16 TempRegister
2091 /*******************************************************************************
2092 ** gcSHADER_AddVariableEx
2093 ********************************************************************************
2095 ** Add a variable to a gcSHADER object.
2100 ** Pointer to a gcSHADER object.
2102 ** gctCONST_STRING Name
2103 ** Name of the variable to add.
2105 ** gcSHADER_TYPE Type
2106 ** Type of the variable to add.
2109 ** Array length of the variable to add. 'Length' must be at least 1.
2111 ** gctUINT16 TempRegister
2112 ** Temporary register index that holds the variable value.
2114 ** gcSHADER_VAR_CATEGORY varCategory
2115 ** Variable category, normal or struct.
2117 ** gctUINT16 numStructureElement
2118 ** If struct, its element number.
2121 ** If struct, parent index in gcSHADER.variables.
2123 ** gctINT16 prevSibling
2124 ** If struct, previous sibling index in gcSHADER.variables.
2128 ** gctINT16* ThisVarIndex
2129 ** Returned value about variable index in gcSHADER.
2132 gcSHADER_AddVariableEx(
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,
2141 IN gctINT16 prevSibling,
2142 OUT gctINT16* ThisVarIndex
2145 /*******************************************************************************
2146 ** gcSHADER_UpdateVariable
2147 ********************************************************************************
2149 ** Update a variable to a gcSHADER object.
2154 ** Pointer to a gcSHADER object.
2157 ** Index of variable to retrieve.
2159 ** gceVARIABLE_UPDATE_FLAGS flag
2160 ** Flag which property of variable will be updated.
2163 ** New value to update.
2170 gcSHADER_UpdateVariable(
2173 IN gceVARIABLE_UPDATE_FLAGS flag,
2177 /*******************************************************************************
2178 ** gcSHADER_GetVariableCount
2179 ********************************************************************************
2181 ** Get the number of variables for this shader.
2186 ** Pointer to a gcSHADER object.
2190 ** gctSIZE_T * Count
2191 ** Pointer to a variable receiving the number of variables.
2194 gcSHADER_GetVariableCount(
2196 OUT gctSIZE_T * Count
2199 /*******************************************************************************
2200 ** gcSHADER_GetVariable
2201 ********************************************************************************
2203 ** Get the gcVARIABLE object pointer for an indexed variable for this shader.
2208 ** Pointer to a gcSHADER object.
2211 ** Index of variable to retrieve.
2215 ** gcVARIABLE * Variable
2216 ** Pointer to a variable receiving the gcVARIABLE object pointer.
2219 gcSHADER_GetVariable(
2222 OUT gcVARIABLE * Variable
2225 /*******************************************************************************
2226 ** gcSHADER_GetVariableIndexingRange
2227 ********************************************************************************
2229 ** Get the gcVARIABLE indexing range.
2234 ** Pointer to a gcSHADER object.
2236 ** gcVARIABLE variable
2240 ** Indicate whether maximum indexing range is queried
2245 ** Pointer to range start (temp register index).
2248 ** Pointer to range end (temp register index).
2251 gcSHADER_GetVariableIndexingRange(
2253 IN gcVARIABLE variable,
2259 /*******************************************************************************
2260 ** gcSHADER_AddOpcode
2261 ********************************************************************************
2263 ** Add an opcode to a gcSHADER object.
2268 ** Pointer to a gcSHADER object.
2270 ** gcSL_OPCODE Opcode
2273 ** gctUINT16 TempRegister
2274 ** Temporary register index that acts as the target of the opcode.
2277 ** Write enable bits for the temporary register that acts as the target
2280 ** gcSL_FORMAT Format
2281 ** Format of the temporary register.
2290 IN gcSL_OPCODE Opcode,
2291 IN gctUINT16 TempRegister,
2293 IN gcSL_FORMAT Format
2297 gcSHADER_AddOpcode2(
2299 IN gcSL_OPCODE Opcode,
2300 IN gcSL_CONDITION Condition,
2301 IN gctUINT16 TempRegister,
2303 IN gcSL_FORMAT Format
2306 /*******************************************************************************
2307 ** gcSHADER_AddOpcodeIndexed
2308 ********************************************************************************
2310 ** Add an opcode to a gcSHADER object that writes to an dynamically indexed
2316 ** Pointer to a gcSHADER object.
2318 ** gcSL_OPCODE Opcode
2321 ** gctUINT16 TempRegister
2322 ** Temporary register index that acts as the target of the opcode.
2325 ** Write enable bits for the temporary register that acts as the
2326 ** target of the opcode.
2328 ** gcSL_INDEXED Mode
2329 ** Location of the dynamic index inside the temporary register. Valid
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.
2337 ** gctUINT16 IndexRegister
2338 ** Temporary register index that holds the dynamic index.
2340 ** gcSL_FORMAT Format
2341 ** Format of the temporary register.
2348 gcSHADER_AddOpcodeIndexed(
2350 IN gcSL_OPCODE Opcode,
2351 IN gctUINT16 TempRegister,
2353 IN gcSL_INDEXED Mode,
2354 IN gctUINT16 IndexRegister,
2355 IN gcSL_FORMAT Format
2358 /*******************************************************************************
2359 ** gcSHADER_AddOpcodeConditionIndexed
2361 ** Add an opcode to a gcSHADER object that writes to an dynamically indexed
2367 ** Pointer to a gcSHADER object.
2369 ** gcSL_OPCODE Opcode
2372 ** gcSL_CONDITION Condition
2373 ** Condition to check.
2375 ** gctUINT16 TempRegister
2376 ** Temporary register index that acts as the target of the opcode.
2379 ** Write enable bits for the temporary register that acts as the
2380 ** target of the opcode.
2382 ** gcSL_INDEXED Indexed
2383 ** Location of the dynamic index inside the temporary register. Valid
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.
2391 ** gctUINT16 IndexRegister
2392 ** Temporary register index that holds the dynamic index.
2399 gcSHADER_AddOpcodeConditionIndexed(
2401 IN gcSL_OPCODE Opcode,
2402 IN gcSL_CONDITION Condition,
2403 IN gctUINT16 TempRegister,
2405 IN gcSL_INDEXED Indexed,
2406 IN gctUINT16 IndexRegister,
2407 IN gcSL_FORMAT Format
2410 /*******************************************************************************
2411 ** gcSHADER_AddOpcodeConditional
2412 ********************************************************************************
2414 ** Add an conditional opcode to a gcSHADER object.
2419 ** Pointer to a gcSHADER object.
2421 ** gcSL_OPCODE Opcode
2424 ** gcSL_CONDITION Condition
2425 ** Condition that needs to evaluate to gcvTRUE in order for the opcode to
2429 ** Target label if 'Condition' evaluates to gcvTRUE.
2436 gcSHADER_AddOpcodeConditional(
2438 IN gcSL_OPCODE Opcode,
2439 IN gcSL_CONDITION Condition,
2443 /*******************************************************************************
2444 ** gcSHADER_AddOpcodeConditionalFormatted
2446 ** Add an conditional jump or call opcode to a gcSHADER object.
2451 ** Pointer to a gcSHADER object.
2453 ** gcSL_OPCODE Opcode
2456 ** gcSL_CONDITION Condition
2457 ** Condition that needs to evaluate to gcvTRUE in order for the opcode to
2460 ** gcSL_FORMAT Format
2461 ** Format of conditional operands
2464 ** Target label if 'Condition' evaluates to gcvTRUE.
2471 gcSHADER_AddOpcodeConditionalFormatted(
2473 IN gcSL_OPCODE Opcode,
2474 IN gcSL_CONDITION Condition,
2475 IN gcSL_FORMAT Format,
2479 /*******************************************************************************
2480 ** gcSHADER_AddOpcodeConditionalFormattedEnable
2482 ** Add an conditional jump or call opcode to a gcSHADER object.
2487 ** Pointer to a gcSHADER object.
2489 ** gcSL_OPCODE Opcode
2492 ** gcSL_CONDITION Condition
2493 ** Condition that needs to evaluate to gcvTRUE in order for the opcode to
2496 ** gcSL_FORMAT Format
2497 ** Format of conditional operands
2500 ** Write enable value for the target of the opcode.
2503 ** Target label if 'Condition' evaluates to gcvTRUE.
2510 gcSHADER_AddOpcodeConditionalFormattedEnable(
2512 IN gcSL_OPCODE Opcode,
2513 IN gcSL_CONDITION Condition,
2514 IN gcSL_FORMAT Format,
2519 /*******************************************************************************
2520 ** gcSHADER_AddLabel
2521 ********************************************************************************
2523 ** Define a label at the current instruction of a gcSHADER object.
2528 ** Pointer to a gcSHADER object.
2543 /*******************************************************************************
2544 ** gcSHADER_AddSource
2545 ********************************************************************************
2547 ** Add a source operand to a gcSHADER object.
2552 ** Pointer to a gcSHADER object.
2555 ** Type of the source operand.
2557 ** gctUINT16 SourceIndex
2558 ** Index of the source operand.
2561 ** x, y, z, and w swizzle values packed into one 8-bit value.
2563 ** gcSL_FORMAT Format
2564 ** Format of the source operand.
2574 IN gctUINT16 SourceIndex,
2575 IN gctUINT8 Swizzle,
2576 IN gcSL_FORMAT Format
2579 /*******************************************************************************
2580 ** gcSHADER_AddSourceIndexed
2581 ********************************************************************************
2583 ** Add a dynamically indexed source operand to a gcSHADER object.
2588 ** Pointer to a gcSHADER object.
2591 ** Type of the source operand.
2593 ** gctUINT16 SourceIndex
2594 ** Index of the source operand.
2597 ** x, y, z, and w swizzle values packed into one 8-bit value.
2599 ** gcSL_INDEXED Mode
2600 ** Addressing mode for the index.
2602 ** gctUINT16 IndexRegister
2603 ** Temporary register index that holds the dynamic index.
2605 ** gcSL_FORMAT Format
2606 ** Format of the source operand.
2613 gcSHADER_AddSourceIndexed(
2616 IN gctUINT16 SourceIndex,
2617 IN gctUINT8 Swizzle,
2618 IN gcSL_INDEXED Mode,
2619 IN gctUINT16 IndexRegister,
2620 IN gcSL_FORMAT Format
2623 /*******************************************************************************
2624 ** gcSHADER_AddSourceAttribute
2625 ********************************************************************************
2627 ** Add an attribute as a source operand to a gcSHADER object.
2632 ** Pointer to a gcSHADER object.
2634 ** gcATTRIBUTE Attribute
2635 ** Pointer to a gcATTRIBUTE object.
2638 ** x, y, z, and w swizzle values packed into one 8-bit value.
2641 ** Static index into the attribute in case the attribute is a matrix
2649 gcSHADER_AddSourceAttribute(
2651 IN gcATTRIBUTE Attribute,
2652 IN gctUINT8 Swizzle,
2656 /*******************************************************************************
2657 ** gcSHADER_AddSourceAttributeIndexed
2658 ********************************************************************************
2660 ** Add an indexed attribute as a source operand to a gcSHADER object.
2665 ** Pointer to a gcSHADER object.
2667 ** gcATTRIBUTE Attribute
2668 ** Pointer to a gcATTRIBUTE object.
2671 ** x, y, z, and w swizzle values packed into one 8-bit value.
2674 ** Static index into the attribute in case the attribute is a matrix
2677 ** gcSL_INDEXED Mode
2678 ** Addressing mode of the dynamic index.
2680 ** gctUINT16 IndexRegister
2681 ** Temporary register index that holds the dynamic index.
2688 gcSHADER_AddSourceAttributeIndexed(
2690 IN gcATTRIBUTE Attribute,
2691 IN gctUINT8 Swizzle,
2693 IN gcSL_INDEXED Mode,
2694 IN gctUINT16 IndexRegister
2697 /*******************************************************************************
2698 ** gcSHADER_AddSourceUniform
2699 ********************************************************************************
2701 ** Add a uniform as a source operand to a gcSHADER object.
2706 ** Pointer to a gcSHADER object.
2708 ** gcUNIFORM Uniform
2709 ** Pointer to a gcUNIFORM object.
2712 ** x, y, z, and w swizzle values packed into one 8-bit value.
2715 ** Static index into the uniform in case the uniform is a matrix or
2723 gcSHADER_AddSourceUniform(
2725 IN gcUNIFORM Uniform,
2726 IN gctUINT8 Swizzle,
2730 /*******************************************************************************
2731 ** gcSHADER_AddSourceUniformIndexed
2732 ********************************************************************************
2734 ** Add an indexed uniform as a source operand to a gcSHADER object.
2739 ** Pointer to a gcSHADER object.
2741 ** gcUNIFORM Uniform
2742 ** Pointer to a gcUNIFORM object.
2745 ** x, y, z, and w swizzle values packed into one 8-bit value.
2748 ** Static index into the uniform in case the uniform is a matrix or
2751 ** gcSL_INDEXED Mode
2752 ** Addressing mode of the dynamic index.
2754 ** gctUINT16 IndexRegister
2755 ** Temporary register index that holds the dynamic index.
2762 gcSHADER_AddSourceUniformIndexed(
2764 IN gcUNIFORM Uniform,
2765 IN gctUINT8 Swizzle,
2767 IN gcSL_INDEXED Mode,
2768 IN gctUINT16 IndexRegister
2772 gcSHADER_AddSourceSamplerIndexed(
2774 IN gctUINT8 Swizzle,
2775 IN gcSL_INDEXED Mode,
2776 IN gctUINT16 IndexRegister
2780 gcSHADER_AddSourceAttributeFormatted(
2782 IN gcATTRIBUTE Attribute,
2783 IN gctUINT8 Swizzle,
2785 IN gcSL_FORMAT Format
2789 gcSHADER_AddSourceAttributeIndexedFormatted(
2791 IN gcATTRIBUTE Attribute,
2792 IN gctUINT8 Swizzle,
2794 IN gcSL_INDEXED Mode,
2795 IN gctUINT16 IndexRegister,
2796 IN gcSL_FORMAT Format
2800 gcSHADER_AddSourceUniformFormatted(
2802 IN gcUNIFORM Uniform,
2803 IN gctUINT8 Swizzle,
2805 IN gcSL_FORMAT Format
2809 gcSHADER_AddSourceUniformIndexedFormatted(
2811 IN gcUNIFORM Uniform,
2812 IN gctUINT8 Swizzle,
2814 IN gcSL_INDEXED Mode,
2815 IN gctUINT16 IndexRegister,
2816 IN gcSL_FORMAT Format
2820 gcSHADER_AddSourceSamplerIndexedFormatted(
2822 IN gctUINT8 Swizzle,
2823 IN gcSL_INDEXED Mode,
2824 IN gctUINT16 IndexRegister,
2825 IN gcSL_FORMAT Format
2828 /*******************************************************************************
2829 ** gcSHADER_AddSourceConstant
2830 ********************************************************************************
2832 ** Add a constant floating point value as a source operand to a gcSHADER
2838 ** Pointer to a gcSHADER object.
2840 ** gctFLOAT Constant
2841 ** Floating point constant.
2848 gcSHADER_AddSourceConstant(
2850 IN gctFLOAT Constant
2853 /*******************************************************************************
2854 ** gcSHADER_AddSourceConstantFormatted
2855 ********************************************************************************
2857 ** Add a constant value as a source operand to a gcSHADER
2863 ** Pointer to a gcSHADER object.
2866 ** Pointer to constant.
2868 ** gcSL_FORMAT Format
2875 gcSHADER_AddSourceConstantFormatted(
2878 IN gcSL_FORMAT Format
2881 /*******************************************************************************
2883 ********************************************************************************
2885 ** Pack a dynamically created gcSHADER object by trimming the allocated arrays
2886 ** and resolving all the labeling.
2891 ** Pointer to a gcSHADER object.
2902 /*******************************************************************************
2903 ** gcSHADER_SetOptimizationOption
2904 ********************************************************************************
2906 ** Set optimization option of a gcSHADER object.
2911 ** Pointer to a gcSHADER object.
2913 ** gctUINT OptimizationOption
2914 ** Optimization option. Can be one of the following:
2916 ** 0 - No optimization.
2917 ** 1 - Full optimization.
2918 ** Other value - For optimizer testing.
2925 gcSHADER_SetOptimizationOption(
2927 IN gctUINT OptimizationOption
2930 /*******************************************************************************
2931 ** gcSHADER_ReallocateFunctions
2933 ** Reallocate an array of pointers to gcFUNCTION objects.
2938 ** Pointer to a gcSHADER object.
2941 ** Array count to reallocate. 'Count' must be at least 1.
2944 gcSHADER_ReallocateFunctions(
2950 gcSHADER_AddFunction(
2952 IN gctCONST_STRING Name,
2953 OUT gcFUNCTION * Function
2957 gcSHADER_ReallocateKernelFunctions(
2963 gcSHADER_AddKernelFunction(
2965 IN gctCONST_STRING Name,
2966 OUT gcKERNEL_FUNCTION * KernelFunction
2970 gcSHADER_BeginFunction(
2972 IN gcFUNCTION Function
2976 gcSHADER_EndFunction(
2978 IN gcFUNCTION Function
2982 gcSHADER_BeginKernelFunction(
2984 IN gcKERNEL_FUNCTION KernelFunction
2988 gcSHADER_EndKernelFunction(
2990 IN gcKERNEL_FUNCTION KernelFunction,
2991 IN gctSIZE_T LocalMemorySize
2995 gcSHADER_SetMaxKernelFunctionArgs(
2997 IN gctUINT32 MaxKernelFunctionArgs
3000 /*******************************************************************************
3001 ** gcSHADER_SetConstantMemorySize
3003 ** Set the constant memory address space size of a gcSHADER object.
3008 ** Pointer to a gcSHADER object.
3010 ** gctSIZE_T ConstantMemorySize
3011 ** Constant memory size in bytes
3013 ** gctCHAR *ConstantMemoryBuffer
3014 ** Constant memory buffer
3017 gcSHADER_SetConstantMemorySize(
3019 IN gctSIZE_T ConstantMemorySize,
3020 IN gctCHAR * ConstantMemoryBuffer
3023 /*******************************************************************************
3024 ** gcSHADER_GetConstantMemorySize
3026 ** Set the constant memory address space size of a gcSHADER object.
3031 ** Pointer to a gcSHADER object.
3035 ** gctSIZE_T * ConstantMemorySize
3036 ** Pointer to a variable receiving constant memory size in bytes
3038 ** gctCHAR **ConstantMemoryBuffer.
3039 ** Pointer to a variable for returned shader constant memory buffer.
3042 gcSHADER_GetConstantMemorySize(
3044 OUT gctSIZE_T * ConstantMemorySize,
3045 OUT gctCHAR ** ConstantMemoryBuffer
3048 /*******************************************************************************
3049 ** gcSHADER_SetPrivateMemorySize
3051 ** Set the private memory address space size of a gcSHADER object.
3056 ** Pointer to a gcSHADER object.
3058 ** gctSIZE_T PrivateMemorySize
3059 ** Private memory size in bytes
3062 gcSHADER_SetPrivateMemorySize(
3064 IN gctSIZE_T PrivateMemorySize
3067 /*******************************************************************************
3068 ** gcSHADER_GetPrivateMemorySize
3070 ** Set the private memory address space size of a gcSHADER object.
3075 ** Pointer to a gcSHADER object.
3079 ** gctSIZE_T * PrivateMemorySize
3080 ** Pointer to a variable receiving private memory size in bytes
3083 gcSHADER_GetPrivateMemorySize(
3085 OUT gctSIZE_T * PrivateMemorySize
3088 /*******************************************************************************
3089 ** gcSHADER_SetLocalMemorySize
3091 ** Set the local memory address space size of a gcSHADER object.
3096 ** Pointer to a gcSHADER object.
3098 ** gctSIZE_T LocalMemorySize
3099 ** Local memory size in bytes
3102 gcSHADER_SetLocalMemorySize(
3104 IN gctSIZE_T LocalMemorySize
3107 /*******************************************************************************
3108 ** gcSHADER_GetLocalMemorySize
3110 ** Set the local memory address space size of a gcSHADER object.
3115 ** Pointer to a gcSHADER object.
3119 ** gctSIZE_T * LocalMemorySize
3120 ** Pointer to a variable receiving lcoal memory size in bytes
3123 gcSHADER_GetLocalMemorySize(
3125 OUT gctSIZE_T * LocalMemorySize
3129 /*******************************************************************************
3130 ** gcSHADER_CheckValidity
3132 ** Check validity for a gcSHADER object.
3137 ** Pointer to a gcSHADER object.
3141 gcSHADER_CheckValidity(
3145 #if gcdUSE_WCLIP_PATCH
3147 gcATTRIBUTE_IsPosition(
3148 IN gcATTRIBUTE Attribute,
3149 OUT gctBOOL * IsPosition
3153 /*******************************************************************************
3154 ** gcATTRIBUTE_GetType
3155 ********************************************************************************
3157 ** Get the type and array length of a gcATTRIBUTE object.
3161 ** gcATTRIBUTE Attribute
3162 ** Pointer to a gcATTRIBUTE object.
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.
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.
3177 gcATTRIBUTE_GetType(
3178 IN gcATTRIBUTE Attribute,
3179 OUT gcSHADER_TYPE * Type,
3180 OUT gctSIZE_T * ArrayLength
3183 /*******************************************************************************
3184 ** gcATTRIBUTE_GetName
3185 ********************************************************************************
3187 ** Get the name of a gcATTRIBUTE object.
3191 ** gcATTRIBUTE Attribute
3192 ** Pointer to a gcATTRIBUTE object.
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.
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.
3205 gcATTRIBUTE_GetName(
3206 IN gcATTRIBUTE Attribute,
3207 OUT gctSIZE_T * Length,
3208 OUT gctCONST_STRING * Name
3211 /*******************************************************************************
3212 ** gcATTRIBUTE_IsEnabled
3213 ********************************************************************************
3215 ** Query the enabled state of a gcATTRIBUTE object.
3219 ** gcATTRIBUTE Attribute
3220 ** Pointer to a gcATTRIBUTE object.
3224 ** gctBOOL * Enabled
3225 ** Pointer to a variable receiving the enabled state of the attribute.
3228 gcATTRIBUTE_IsEnabled(
3229 IN gcATTRIBUTE Attribute,
3230 OUT gctBOOL * Enabled
3233 /*******************************************************************************
3234 ** gcUNIFORM_GetType
3235 ********************************************************************************
3237 ** Get the type and array length of a gcUNIFORM object.
3241 ** gcUNIFORM Uniform
3242 ** Pointer to a gcUNIFORM object.
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.
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.
3258 IN gcUNIFORM Uniform,
3259 OUT gcSHADER_TYPE * Type,
3260 OUT gctSIZE_T * ArrayLength
3263 /*******************************************************************************
3264 ** gcUNIFORM_GetTypeEx
3265 ********************************************************************************
3267 ** Get the type and array length of a gcUNIFORM object.
3271 ** gcUNIFORM Uniform
3272 ** Pointer to a gcUNIFORM object.
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.
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.
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.
3291 gcUNIFORM_GetTypeEx(
3292 IN gcUNIFORM Uniform,
3293 OUT gcSHADER_TYPE * Type,
3294 OUT gcSHADER_PRECISION * Precision,
3295 OUT gctSIZE_T * ArrayLength
3298 /*******************************************************************************
3299 ** gcUNIFORM_GetFlags
3300 ********************************************************************************
3302 ** Get the flags of a gcUNIFORM object.
3306 ** gcUNIFORM Uniform
3307 ** Pointer to a gcUNIFORM object.
3311 ** gceUNIFORM_FLAGS * Flags
3312 ** Pointer to a variable receiving the flags of the uniform.
3317 IN gcUNIFORM Uniform,
3318 OUT gceUNIFORM_FLAGS * Flags
3321 /*******************************************************************************
3322 ** gcUNIFORM_SetFlags
3323 ********************************************************************************
3325 ** Set the flags of a gcUNIFORM object.
3329 ** gcUNIFORM Uniform
3330 ** Pointer to a gcUNIFORM object.
3332 ** gceUNIFORM_FLAGS Flags
3333 ** Flags of the uniform to be set.
3341 IN gcUNIFORM Uniform,
3342 IN gceUNIFORM_FLAGS Flags
3345 /*******************************************************************************
3346 ** gcUNIFORM_GetName
3347 ********************************************************************************
3349 ** Get the name of a gcUNIFORM object.
3353 ** gcUNIFORM Uniform
3354 ** Pointer to a gcUNIFORM object.
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.
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.
3368 IN gcUNIFORM Uniform,
3369 OUT gctSIZE_T * Length,
3370 OUT gctCONST_STRING * Name
3373 /*******************************************************************************
3374 ** gcUNIFORM_GetSampler
3375 ********************************************************************************
3377 ** Get the physical sampler number for a sampler gcUNIFORM object.
3381 ** gcUNIFORM Uniform
3382 ** Pointer to a gcUNIFORM object.
3386 ** gctUINT32 * Sampler
3387 ** Pointer to a variable receiving the physical sampler.
3390 gcUNIFORM_GetSampler(
3391 IN gcUNIFORM Uniform,
3392 OUT gctUINT32 * Sampler
3395 /*******************************************************************************
3396 ** gcUNIFORM_GetFormat
3398 ** Get the type and array length of a gcUNIFORM object.
3402 ** gcUNIFORM Uniform
3403 ** Pointer to a gcUNIFORM object.
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.
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.
3416 gcUNIFORM_GetFormat(
3417 IN gcUNIFORM Uniform,
3418 OUT gcSL_FORMAT * Format,
3419 OUT gctBOOL * IsPointer
3422 /*******************************************************************************
3423 ** gcUNIFORM_SetFormat
3425 ** Set the format and isPointer of a uniform.
3429 ** gcUNIFORM Uniform
3430 ** Pointer to a gcUNIFORM object.
3432 ** gcSL_FORMAT Format
3433 ** Format of element of the uniform shaderType.
3435 ** gctBOOL IsPointer
3436 ** Wheter the uniform is a pointer.
3443 gcUNIFORM_SetFormat(
3444 IN gcUNIFORM Uniform,
3445 IN gcSL_FORMAT Format,
3446 IN gctBOOL IsPointer
3449 /*******************************************************************************
3450 ** gcUNIFORM_SetValue
3451 ********************************************************************************
3453 ** Set the value of a uniform in integer.
3457 ** gcUNIFORM Uniform
3458 ** Pointer to a gcUNIFORM object.
3461 ** Number of entries to program if the uniform has been declared as an
3464 ** const gctINT * Value
3465 ** Pointer to a buffer holding the integer values for the uniform.
3473 IN gcUNIFORM Uniform,
3475 IN const gctINT * Value
3478 /*******************************************************************************
3479 ** gcUNIFORM_SetValueX
3480 ********************************************************************************
3482 ** Set the value of a uniform in fixed point.
3486 ** gcUNIFORM Uniform
3487 ** Pointer to a gcUNIFORM object.
3490 ** Number of entries to program if the uniform has been declared as an
3493 ** const gctFIXED_POINT * Value
3494 ** Pointer to a buffer holding the fixed point values for the uniform.
3501 gcUNIFORM_SetValueX(
3502 IN gcUNIFORM Uniform,
3504 IN gctFIXED_POINT * Value
3507 /*******************************************************************************
3508 ** gcUNIFORM_SetValueF
3509 ********************************************************************************
3511 ** Set the value of a uniform in floating point.
3515 ** gcUNIFORM Uniform
3516 ** Pointer to a gcUNIFORM object.
3519 ** Number of entries to program if the uniform has been declared as an
3522 ** const gctFLOAT * Value
3523 ** Pointer to a buffer holding the floating point values for the
3531 gcUNIFORM_SetValueF(
3532 IN gcUNIFORM Uniform,
3534 IN const gctFLOAT * Value
3537 /*******************************************************************************
3538 ** gcUNIFORM_ProgramF
3540 ** Set the value of a uniform in floating point.
3544 ** gctUINT32 Address
3545 ** Address of Uniform.
3547 ** gctSIZE_T Row/Col
3549 ** const gctFLOAT * Value
3550 ** Pointer to a buffer holding the floating point values for the
3559 IN gctUINT32 Address,
3562 IN const gctFLOAT * Value
3565 /*******************************************************************************
3566 ** gcUNIFORM_GetModelViewProjMatrix
3567 ********************************************************************************
3569 ** Get the value of uniform modelViewProjMatrix ID if present.
3573 ** gcUNIFORM Uniform
3574 ** Pointer to a gcUNIFORM object.
3581 gcUNIFORM_GetModelViewProjMatrix(
3582 IN gcUNIFORM Uniform
3585 /*******************************************************************************
3587 ********************************************************************************
3589 ** Get the type and array length of a gcOUTPUT object.
3594 ** Pointer to a gcOUTPUT object.
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.
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.
3611 OUT gcSHADER_TYPE * Type,
3612 OUT gctSIZE_T * ArrayLength
3615 /*******************************************************************************
3616 ** gcOUTPUT_GetIndex
3617 ********************************************************************************
3619 ** Get the index of a gcOUTPUT object.
3624 ** Pointer to a gcOUTPUT object.
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
3639 /*******************************************************************************
3641 ********************************************************************************
3643 ** Get the name of a gcOUTPUT object.
3648 ** Pointer to a gcOUTPUT object.
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.
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.
3663 OUT gctSIZE_T * Length,
3664 OUT gctCONST_STRING * Name
3667 /*******************************************************************************
3668 *********************************************************** F U N C T I O N S **
3669 *******************************************************************************/
3671 /*******************************************************************************
3672 ** gcFUNCTION_ReallocateArguments
3674 ** Reallocate an array of gcsFUNCTION_ARGUMENT objects.
3678 ** gcFUNCTION Function
3679 ** Pointer to a gcFUNCTION object.
3682 ** Array count to reallocate. 'Count' must be at least 1.
3685 gcFUNCTION_ReallocateArguments(
3686 IN gcFUNCTION Function,
3691 gcFUNCTION_AddArgument(
3692 IN gcFUNCTION Function,
3693 IN gctUINT16 TempIndex,
3695 IN gctUINT8 Qualifier
3699 gcFUNCTION_GetArgument(
3700 IN gcFUNCTION Function,
3702 OUT gctUINT16_PTR Temp,
3703 OUT gctUINT8_PTR Enable,
3704 OUT gctUINT8_PTR Swizzle
3708 gcFUNCTION_GetLabel(
3709 IN gcFUNCTION Function,
3710 OUT gctUINT_PTR Label
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 /*******************************************************************************/
3718 gcKERNEL_FUNCTION_AddKernelFunctionProperties(
3719 IN gcKERNEL_FUNCTION KernelFunction,
3720 IN gctINT propertyType,
3721 IN gctSIZE_T propertySize,
3726 gcKERNEL_FUNCTION_GetPropertyCount(
3727 IN gcKERNEL_FUNCTION KernelFunction,
3728 OUT gctSIZE_T * Count
3732 gcKERNEL_FUNCTION_GetProperty(
3733 IN gcKERNEL_FUNCTION KernelFunction,
3735 OUT gctSIZE_T * propertySize,
3736 OUT gctINT * propertyType,
3737 OUT gctINT * propertyValues
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
3747 ** Reallocate an array of pointers to image sampler pair.
3751 ** gcKERNEL_FUNCTION KernelFunction
3752 ** Pointer to a gcKERNEL_FUNCTION object.
3755 ** Array count to reallocate. 'Count' must be at least 1.
3758 gcKERNEL_FUNCTION_ReallocateImageSamplers(
3759 IN gcKERNEL_FUNCTION KernelFunction,
3764 gcKERNEL_FUNCTION_AddImageSampler(
3765 IN gcKERNEL_FUNCTION KernelFunction,
3766 IN gctUINT8 ImageNum,
3767 IN gctBOOL IsConstantSamplerType,
3768 IN gctUINT32 SamplerType
3772 gcKERNEL_FUNCTION_GetImageSamplerCount(
3773 IN gcKERNEL_FUNCTION KernelFunction,
3774 OUT gctSIZE_T * Count
3778 gcKERNEL_FUNCTION_GetImageSampler(
3779 IN gcKERNEL_FUNCTION KernelFunction,
3781 OUT gctUINT8 *ImageNum,
3782 OUT gctBOOL *IsConstantSamplerType,
3783 OUT gctUINT32 *SamplerType
3786 /*******************************************************************************
3787 *********************************************K E R N E L F U N C T I O N S **
3788 *******************************************************************************/
3790 /*******************************************************************************
3791 ** gcKERNEL_FUNCTION_ReallocateArguments
3793 ** Reallocate an array of gcsFUNCTION_ARGUMENT objects.
3797 ** gcKERNEL_FUNCTION Function
3798 ** Pointer to a gcKERNEL_FUNCTION object.
3801 ** Array count to reallocate. 'Count' must be at least 1.
3804 gcKERNEL_FUNCTION_ReallocateArguments(
3805 IN gcKERNEL_FUNCTION Function,
3810 gcKERNEL_FUNCTION_AddArgument(
3811 IN gcKERNEL_FUNCTION Function,
3812 IN gctUINT16 TempIndex,
3814 IN gctUINT8 Qualifier
3818 gcKERNEL_FUNCTION_GetArgument(
3819 IN gcKERNEL_FUNCTION Function,
3821 OUT gctUINT16_PTR Temp,
3822 OUT gctUINT8_PTR Enable,
3823 OUT gctUINT8_PTR Swizzle
3827 gcKERNEL_FUNCTION_GetLabel(
3828 IN gcKERNEL_FUNCTION Function,
3829 OUT gctUINT_PTR Label
3833 gcKERNEL_FUNCTION_GetName(
3834 IN gcKERNEL_FUNCTION KernelFunction,
3835 OUT gctSIZE_T * Length,
3836 OUT gctCONST_STRING * Name
3840 gcKERNEL_FUNCTION_ReallocateUniformArguments(
3841 IN gcKERNEL_FUNCTION KernelFunction,
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
3855 gcKERNEL_FUNCTION_GetUniformArgumentCount(
3856 IN gcKERNEL_FUNCTION KernelFunction,
3857 OUT gctSIZE_T * Count
3861 gcKERNEL_FUNCTION_GetUniformArgument(
3862 IN gcKERNEL_FUNCTION KernelFunction,
3864 OUT gcUNIFORM * UniformArgument
3868 gcKERNEL_FUNCTION_SetCodeEnd(
3869 IN gcKERNEL_FUNCTION KernelFunction
3872 /*******************************************************************************
3874 ********************************************************************************
3876 ** Compile a shader.
3881 ** Pointer to an gcoHAL object.
3883 ** gctINT ShaderType
3884 ** Shader type to compile. Can be one of the following values:
3886 ** gcSHADER_TYPE_VERTEX
3887 ** Compile a vertex shader.
3889 ** gcSHADER_TYPE_FRAGMENT
3890 ** Compile a fragment shader.
3892 ** gctSIZE_T SourceSize
3893 ** Size of the source buffer in bytes.
3895 ** gctCONST_STRING Source
3896 ** Pointer to the buffer containing the shader source code.
3900 ** gcSHADER * Binary
3901 ** Pointer to a variable receiving the pointer to a gcSHADER object
3902 ** containg the compiled shader code.
3905 ** Pointer to a variable receiving a string pointer containging the
3911 IN gctINT ShaderType,
3912 IN gctSIZE_T SourceSize,
3913 IN gctCONST_STRING Source,
3914 OUT gcSHADER * Binary,
3918 /*******************************************************************************
3920 ********************************************************************************
3922 ** Optimize a shader.
3927 ** Pointer to a gcSHADER object holding information about the compiled
3931 ** Pointer to an open FILE object.
3939 /*******************************************************************************
3941 ********************************************************************************
3943 ** Link two shaders and generate a harwdare specific state buffer by compiling
3944 ** the compiler generated code through the resource allocator and code
3949 ** gcSHADER VertexShader
3950 ** Pointer to a gcSHADER object holding information about the compiled
3953 ** gcSHADER FragmentShader
3954 ** Pointer to a gcSHADER object holding information about the compiled
3957 ** gceSHADER_FLAGS Flags
3958 ** Compiler flags. Can be any of the following:
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.
3969 ** gctSIZE_T * StateBufferSize
3970 ** Pointer to a variable receicing the number of bytes in the buffer
3971 ** returned in 'StateBuffer'.
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.
3977 ** gcsHINT_PTR * Hints
3978 ** Pointer to a variable receiving a gcsHINT structure pointer that
3979 ** contains information required when loading the shader states.
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
3993 /*******************************************************************************
3995 ********************************************************************************
3997 ** Load a pre-compiled and pre-linked shader program into the hardware.
4002 ** Pointer to a gcoHAL object.
4004 ** gctSIZE_T StateBufferSize
4005 ** The number of bytes in the 'StateBuffer'.
4007 ** gctPOINTER StateBuffer
4008 ** Pointer to the states that make up the shader program.
4010 ** gcsHINT_PTR Hints
4011 ** Pointer to a gcsHINT structure that contains information required
4012 ** when loading the shader states.
4017 IN gctSIZE_T StateBufferSize,
4018 IN gctPOINTER StateBuffer,
4019 IN gcsHINT_PTR Hints
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,
4032 IN gctPOINTER pNativeStateBuffer,
4033 IN gctSIZE_T nativeStateBufferSize,
4034 IN gcsHINT_PTR pNativeHints,
4036 IN gctUINT32 Samplers,
4037 IN gctUINT32 *SamplerWrapS,
4038 IN gctUINT32 *SamplerWrapT
4042 gcRecompileDepthBias(
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,
4050 IN gctPOINTER pNativeStateBuffer,
4051 IN gctSIZE_T nativeStateBufferSize,
4052 IN gcsHINT_PTR pNativeHints,
4053 OUT gctINT * uniformAddr,
4054 OUT gctINT * uniformChannel
4057 /*******************************************************************************
4059 ********************************************************************************
4061 ** Save pre-compiled shaders and pre-linked programs to a binary file.
4065 ** gcSHADER VertexShader
4066 ** Pointer to vertex shader object.
4068 ** gcSHADER FragmentShader
4069 ** Pointer to fragment shader object.
4071 ** gctSIZE_T ProgramBufferSize
4072 ** Number of bytes in 'ProgramBuffer'.
4074 ** gctPOINTER ProgramBuffer
4075 ** Pointer to buffer containing the program states.
4077 ** gcsHINT_PTR Hints
4078 ** Pointer to HINTS structure for program states.
4082 ** gctPOINTER * Binary
4083 ** Pointer to a variable receiving the binary data to be saved.
4085 ** gctSIZE_T * BinarySize
4086 ** Pointer to a variable receiving the number of bytes inside 'Binary'.
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
4099 /*******************************************************************************
4101 ********************************************************************************
4103 ** Load pre-compiled shaders and pre-linked programs from a binary file.
4107 ** gctPOINTER Binary
4108 ** Pointer to the binary data loaded.
4110 ** gctSIZE_T BinarySize
4111 ** Number of bytes in 'Binary'.
4115 ** gcSHADER VertexShader
4116 ** Pointer to a vertex shader object.
4118 ** gcSHADER FragmentShader
4119 ** Pointer to a fragment shader object.
4121 ** gctSIZE_T * ProgramBufferSize
4122 ** Pointer to a variable receicing the number of bytes in the buffer
4123 ** returned in 'ProgramBuffer'.
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.
4129 ** gcsHINT_PTR * Hints
4130 ** Pointer to a variable receiving a gcsHINT structure pointer that
4131 ** contains information required when loading the shader states.
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
4144 /*******************************************************************************
4146 ********************************************************************************
4148 ** Compile a OpenCL kernel shader.
4153 ** Pointer to an gcoHAL object.
4155 ** gctSIZE_T SourceSize
4156 ** Size of the source buffer in bytes.
4158 ** gctCONST_STRING Source
4159 ** Pointer to the buffer containing the shader source code.
4163 ** gcSHADER * Binary
4164 ** Pointer to a variable receiving the pointer to a gcSHADER object
4165 ** containg the compiled shader code.
4168 ** Pointer to a variable receiving a string pointer containging the
4174 IN gctSIZE_T SourceSize,
4175 IN gctCONST_STRING Source,
4176 IN gctCONST_STRING Options,
4177 OUT gcSHADER * Binary,
4181 /*******************************************************************************
4183 ********************************************************************************
4185 ** Link OpenCL kernel and generate a harwdare specific state buffer by compiling
4186 ** the compiler generated code through the resource allocator and code
4192 ** Pointer to a gcSHADER object holding information about the compiled
4195 ** gceSHADER_FLAGS Flags
4196 ** Compiler flags. Can be any of the following:
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.
4207 ** gctSIZE_T * StateBufferSize
4208 ** Pointer to a variable receiving the number of bytes in the buffer
4209 ** returned in 'StateBuffer'.
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.
4215 ** gcsHINT_PTR * Hints
4216 ** Pointer to a variable receiving a gcsHINT structure pointer that
4217 ** contains information required when loading the shader states.
4222 IN gceSHADER_FLAGS Flags,
4223 OUT gctSIZE_T * StateBufferSize,
4224 OUT gctPOINTER * StateBuffer,
4225 OUT gcsHINT_PTR * Hints
4228 /*******************************************************************************
4230 ********************************************************************************
4232 ** Load a pre-compiled and pre-linked kernel program into the hardware.
4236 ** gctSIZE_T StateBufferSize
4237 ** The number of bytes in the 'StateBuffer'.
4239 ** gctPOINTER StateBuffer
4240 ** Pointer to the states that make up the shader program.
4242 ** gcsHINT_PTR Hints
4243 ** Pointer to a gcsHINT structure that contains information required
4244 ** when loading the shader states.
4248 IN gctSIZE_T StateBufferSize,
4249 IN gctPOINTER StateBuffer,
4250 IN gcsHINT_PTR Hints
4254 gcInvokeThreadWalker(
4255 IN gcsTHREAD_WALKER_INFO_PTR Info
4260 IN gcSHADER_TYPE Type,
4261 OUT gctINT * Components,
4263 OUT gctCONST_STRING * Name
4267 gcOPT_doVaryingPackingForShader(
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 */
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 */
4297 #endif /* VIVANTE_NO_3D */
4298 #endif /* __gc_hal_compiler_h_ */