diff options
| author | sschirm <[email protected]> | 2016-12-23 14:20:36 +0100 |
|---|---|---|
| committer | sschirm <[email protected]> | 2016-12-23 14:56:17 +0100 |
| commit | ef6937e69e8ee3f409cf9d460d5ad300a65d5924 (patch) | |
| tree | 710426e8daa605551ce3f34b581897011101c30f /Externals | |
| parent | Initial commit: (diff) | |
| download | physx-3.4-ef6937e69e8ee3f409cf9d460d5ad300a65d5924.tar.xz physx-3.4-ef6937e69e8ee3f409cf9d460d5ad300a65d5924.zip | |
PhysX 3.4 / APEX 1.4 release candidate @21506124
Diffstat (limited to 'Externals')
18 files changed, 0 insertions, 42221 deletions
diff --git a/Externals/mojoshader/1067/GL/gl.h b/Externals/mojoshader/1067/GL/gl.h deleted file mode 100644 index 914e645b..00000000 --- a/Externals/mojoshader/1067/GL/gl.h +++ /dev/null @@ -1,1637 +0,0 @@ -#ifndef __gl_h_ -#define __gl_h_ - -#ifdef __cplusplus -extern "C" { -#endif - -/* -** Copyright 1998-2002, NVIDIA Corporation. -** All Rights Reserved. -** -** THE INFORMATION CONTAINED HEREIN IS PROPRIETARY AND CONFIDENTIAL TO -** NVIDIA, CORPORATION. USE, REPRODUCTION OR DISCLOSURE TO ANY THIRD PARTY -** IS SUBJECT TO WRITTEN PRE-APPROVAL BY NVIDIA, CORPORATION. -** -** -** Copyright 1992-1999, Silicon Graphics, Inc. -** All Rights Reserved. -** -** Portions of this file are UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon -** Graphics, Inc.; the contents of this file may not be disclosed to third -** parties, copied or duplicated in any form, in whole or in part, without -** the prior written permission of Silicon Graphics, Inc. -** -** RESTRICTED RIGHTS LEGEND: -** Use, duplication or disclosure by the Government is subject to -** restrictions as set forth in subdivision (c)(1)(ii) of the Rights in -** Technical Data and Computer Software clause at DFARS 252.227-7013, -** and/or in similar or successor clauses in the FAR, DOD or NASA FAR -** Supplement. Unpublished - rights reserved under the Copyright Laws of -** the United States. -*/ - -#ifndef APIENTRY -#define APIENTRY -#endif - -#ifndef WIN32 -#define WINGDIAPI -#endif - -#ifndef GLAPI -# ifdef _WIN32 -# define GLAPI __stdcall -# else -# define GLAPI -# endif -# define __DEFINED_GLAPI -#endif - -/*************************************************************/ - -typedef unsigned int GLenum; -typedef unsigned char GLboolean; -typedef unsigned int GLbitfield; -typedef signed char GLbyte; -typedef short GLshort; -typedef int GLint; -typedef int GLsizei; -typedef unsigned char GLubyte; -typedef unsigned short GLushort; -typedef unsigned int GLuint; -typedef float GLfloat; -typedef float GLclampf; -typedef double GLdouble; -typedef double GLclampd; -typedef void GLvoid; - - -/*************************************************************/ - -/* Version */ -#define GL_VERSION_1_1 1 - -/* AttribMask */ -#define GL_CURRENT_BIT 0x00000001 -#define GL_POINT_BIT 0x00000002 -#define GL_LINE_BIT 0x00000004 -#define GL_POLYGON_BIT 0x00000008 -#define GL_POLYGON_STIPPLE_BIT 0x00000010 -#define GL_PIXEL_MODE_BIT 0x00000020 -#define GL_LIGHTING_BIT 0x00000040 -#define GL_FOG_BIT 0x00000080 -#define GL_DEPTH_BUFFER_BIT 0x00000100 -#define GL_ACCUM_BUFFER_BIT 0x00000200 -#define GL_STENCIL_BUFFER_BIT 0x00000400 -#define GL_VIEWPORT_BIT 0x00000800 -#define GL_TRANSFORM_BIT 0x00001000 -#define GL_ENABLE_BIT 0x00002000 -#define GL_COLOR_BUFFER_BIT 0x00004000 -#define GL_HINT_BIT 0x00008000 -#define GL_EVAL_BIT 0x00010000 -#define GL_LIST_BIT 0x00020000 -#define GL_TEXTURE_BIT 0x00040000 -#define GL_SCISSOR_BIT 0x00080000 -#define GL_ALL_ATTRIB_BITS 0xFFFFFFFF - -/* ClearBufferMask */ -/* GL_COLOR_BUFFER_BIT */ -/* GL_ACCUM_BUFFER_BIT */ -/* GL_STENCIL_BUFFER_BIT */ -/* GL_DEPTH_BUFFER_BIT */ - -/* ClientAttribMask */ -#define GL_CLIENT_PIXEL_STORE_BIT 0x00000001 -#define GL_CLIENT_VERTEX_ARRAY_BIT 0x00000002 -#define GL_CLIENT_ALL_ATTRIB_BITS 0xFFFFFFFF - -/* Boolean */ -#define GL_FALSE 0 -#define GL_TRUE 1 - -/* BeginMode */ -#define GL_POINTS 0x0000 -#define GL_LINES 0x0001 -#define GL_LINE_LOOP 0x0002 -#define GL_LINE_STRIP 0x0003 -#define GL_TRIANGLES 0x0004 -#define GL_TRIANGLE_STRIP 0x0005 -#define GL_TRIANGLE_FAN 0x0006 -#define GL_QUADS 0x0007 -#define GL_QUAD_STRIP 0x0008 -#define GL_POLYGON 0x0009 - -/* AccumOp */ -#define GL_ACCUM 0x0100 -#define GL_LOAD 0x0101 -#define GL_RETURN 0x0102 -#define GL_MULT 0x0103 -#define GL_ADD 0x0104 - -/* AlphaFunction */ -#define GL_NEVER 0x0200 -#define GL_LESS 0x0201 -#define GL_EQUAL 0x0202 -#define GL_LEQUAL 0x0203 -#define GL_GREATER 0x0204 -#define GL_NOTEQUAL 0x0205 -#define GL_GEQUAL 0x0206 -#define GL_ALWAYS 0x0207 - -/* BlendingFactorDest */ -#define GL_ZERO 0 -#define GL_ONE 1 -#define GL_SRC_COLOR 0x0300 -#define GL_ONE_MINUS_SRC_COLOR 0x0301 -#define GL_SRC_ALPHA 0x0302 -#define GL_ONE_MINUS_SRC_ALPHA 0x0303 -#define GL_DST_ALPHA 0x0304 -#define GL_ONE_MINUS_DST_ALPHA 0x0305 - -/* BlendingFactorSrc */ -/* GL_ZERO */ -/* GL_ONE */ -#define GL_DST_COLOR 0x0306 -#define GL_ONE_MINUS_DST_COLOR 0x0307 -#define GL_SRC_ALPHA_SATURATE 0x0308 -/* GL_SRC_ALPHA */ -/* GL_ONE_MINUS_SRC_ALPHA */ -/* GL_DST_ALPHA */ -/* GL_ONE_MINUS_DST_ALPHA */ - -/* ColorMaterialFace */ -/* GL_FRONT */ -/* GL_BACK */ -/* GL_FRONT_AND_BACK */ - -/* ColorMaterialParameter */ -/* GL_AMBIENT */ -/* GL_DIFFUSE */ -/* GL_SPECULAR */ -/* GL_EMISSION */ -/* GL_AMBIENT_AND_DIFFUSE */ - -/* ColorPointerType */ -/* GL_BYTE */ -/* GL_UNSIGNED_BYTE */ -/* GL_SHORT */ -/* GL_UNSIGNED_SHORT */ -/* GL_INT */ -/* GL_UNSIGNED_INT */ -/* GL_FLOAT */ -/* GL_DOUBLE */ - -/* CullFaceMode */ -/* GL_FRONT */ -/* GL_BACK */ -/* GL_FRONT_AND_BACK */ - -/* DepthFunction */ -/* GL_NEVER */ -/* GL_LESS */ -/* GL_EQUAL */ -/* GL_LEQUAL */ -/* GL_GREATER */ -/* GL_NOTEQUAL */ -/* GL_GEQUAL */ -/* GL_ALWAYS */ - -/* DrawBufferMode */ -#define GL_NONE 0 -#define GL_FRONT_LEFT 0x0400 -#define GL_FRONT_RIGHT 0x0401 -#define GL_BACK_LEFT 0x0402 -#define GL_BACK_RIGHT 0x0403 -#define GL_FRONT 0x0404 -#define GL_BACK 0x0405 -#define GL_LEFT 0x0406 -#define GL_RIGHT 0x0407 -#define GL_FRONT_AND_BACK 0x0408 -#define GL_AUX0 0x0409 -#define GL_AUX1 0x040A -#define GL_AUX2 0x040B -#define GL_AUX3 0x040C - -/* EnableCap */ -/* GL_FOG */ -/* GL_LIGHTING */ -/* GL_TEXTURE_1D */ -/* GL_TEXTURE_2D */ -/* GL_LINE_STIPPLE */ -/* GL_POLYGON_STIPPLE */ -/* GL_CULL_FACE */ -/* GL_ALPHA_TEST */ -/* GL_BLEND */ -/* GL_INDEX_LOGIC_OP */ -/* GL_COLOR_LOGIC_OP */ -/* GL_DITHER */ -/* GL_STENCIL_TEST */ -/* GL_DEPTH_TEST */ -/* GL_CLIP_PLANE0 */ -/* GL_CLIP_PLANE1 */ -/* GL_CLIP_PLANE2 */ -/* GL_CLIP_PLANE3 */ -/* GL_CLIP_PLANE4 */ -/* GL_CLIP_PLANE5 */ -/* GL_LIGHT0 */ -/* GL_LIGHT1 */ -/* GL_LIGHT2 */ -/* GL_LIGHT3 */ -/* GL_LIGHT4 */ -/* GL_LIGHT5 */ -/* GL_LIGHT6 */ -/* GL_LIGHT7 */ -/* GL_TEXTURE_GEN_S */ -/* GL_TEXTURE_GEN_T */ -/* GL_TEXTURE_GEN_R */ -/* GL_TEXTURE_GEN_Q */ -/* GL_MAP1_VERTEX_3 */ -/* GL_MAP1_VERTEX_4 */ -/* GL_MAP1_COLOR_4 */ -/* GL_MAP1_INDEX */ -/* GL_MAP1_NORMAL */ -/* GL_MAP1_TEXTURE_COORD_1 */ -/* GL_MAP1_TEXTURE_COORD_2 */ -/* GL_MAP1_TEXTURE_COORD_3 */ -/* GL_MAP1_TEXTURE_COORD_4 */ -/* GL_MAP2_VERTEX_3 */ -/* GL_MAP2_VERTEX_4 */ -/* GL_MAP2_COLOR_4 */ -/* GL_MAP2_INDEX */ -/* GL_MAP2_NORMAL */ -/* GL_MAP2_TEXTURE_COORD_1 */ -/* GL_MAP2_TEXTURE_COORD_2 */ -/* GL_MAP2_TEXTURE_COORD_3 */ -/* GL_MAP2_TEXTURE_COORD_4 */ -/* GL_POINT_SMOOTH */ -/* GL_LINE_SMOOTH */ -/* GL_POLYGON_SMOOTH */ -/* GL_SCISSOR_TEST */ -/* GL_COLOR_MATERIAL */ -/* GL_NORMALIZE */ -/* GL_AUTO_NORMAL */ -/* GL_POLYGON_OFFSET_POINT */ -/* GL_POLYGON_OFFSET_LINE */ -/* GL_POLYGON_OFFSET_FILL */ -/* GL_VERTEX_ARRAY */ -/* GL_NORMAL_ARRAY */ -/* GL_COLOR_ARRAY */ -/* GL_INDEX_ARRAY */ -/* GL_TEXTURE_COORD_ARRAY */ -/* GL_EDGE_FLAG_ARRAY */ - -/* ErrorCode */ -#define GL_NO_ERROR 0 -#define GL_INVALID_ENUM 0x0500 -#define GL_INVALID_VALUE 0x0501 -#define GL_INVALID_OPERATION 0x0502 -#define GL_STACK_OVERFLOW 0x0503 -#define GL_STACK_UNDERFLOW 0x0504 -#define GL_OUT_OF_MEMORY 0x0505 -#define GL_TABLE_TOO_LARGE 0x8031 - -/* FeedbackType */ -#define GL_2D 0x0600 -#define GL_3D 0x0601 -#define GL_3D_COLOR 0x0602 -#define GL_3D_COLOR_TEXTURE 0x0603 -#define GL_4D_COLOR_TEXTURE 0x0604 - -/* FeedBackToken */ -#define GL_PASS_THROUGH_TOKEN 0x0700 -#define GL_POINT_TOKEN 0x0701 -#define GL_LINE_TOKEN 0x0702 -#define GL_POLYGON_TOKEN 0x0703 -#define GL_BITMAP_TOKEN 0x0704 -#define GL_DRAW_PIXEL_TOKEN 0x0705 -#define GL_COPY_PIXEL_TOKEN 0x0706 -#define GL_LINE_RESET_TOKEN 0x0707 - -/* FogMode */ -/* GL_LINEAR */ -#define GL_EXP 0x0800 -#define GL_EXP2 0x0801 - -/* FogParameter */ -/* GL_FOG_COLOR */ -/* GL_FOG_DENSITY */ -/* GL_FOG_END */ -/* GL_FOG_INDEX */ -/* GL_FOG_MODE */ -/* GL_FOG_START */ - -/* FrontFaceDirection */ -#define GL_CW 0x0900 -#define GL_CCW 0x0901 - -/* GetMapQuery */ -#define GL_COEFF 0x0A00 -#define GL_ORDER 0x0A01 -#define GL_DOMAIN 0x0A02 - -/* GetPixelMap */ -#define GL_PIXEL_MAP_I_TO_I 0x0C70 -#define GL_PIXEL_MAP_S_TO_S 0x0C71 -#define GL_PIXEL_MAP_I_TO_R 0x0C72 -#define GL_PIXEL_MAP_I_TO_G 0x0C73 -#define GL_PIXEL_MAP_I_TO_B 0x0C74 -#define GL_PIXEL_MAP_I_TO_A 0x0C75 -#define GL_PIXEL_MAP_R_TO_R 0x0C76 -#define GL_PIXEL_MAP_G_TO_G 0x0C77 -#define GL_PIXEL_MAP_B_TO_B 0x0C78 -#define GL_PIXEL_MAP_A_TO_A 0x0C79 - -/* GetPointervPName */ -#define GL_VERTEX_ARRAY_POINTER 0x808E -#define GL_NORMAL_ARRAY_POINTER 0x808F -#define GL_COLOR_ARRAY_POINTER 0x8090 -#define GL_INDEX_ARRAY_POINTER 0x8091 -#define GL_TEXTURE_COORD_ARRAY_POINTER 0x8092 -#define GL_EDGE_FLAG_ARRAY_POINTER 0x8093 - -/* GetPName */ -#define GL_CURRENT_COLOR 0x0B00 -#define GL_CURRENT_INDEX 0x0B01 -#define GL_CURRENT_NORMAL 0x0B02 -#define GL_CURRENT_TEXTURE_COORDS 0x0B03 -#define GL_CURRENT_RASTER_COLOR 0x0B04 -#define GL_CURRENT_RASTER_INDEX 0x0B05 -#define GL_CURRENT_RASTER_TEXTURE_COORDS 0x0B06 -#define GL_CURRENT_RASTER_POSITION 0x0B07 -#define GL_CURRENT_RASTER_POSITION_VALID 0x0B08 -#define GL_CURRENT_RASTER_DISTANCE 0x0B09 -#define GL_POINT_SMOOTH 0x0B10 -#define GL_POINT_SIZE 0x0B11 -#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12 -#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13 -#define GL_POINT_SIZE_RANGE GL_SMOOTH_POINT_SIZE_RANGE -#define GL_POINT_SIZE_GRANULARITY GL_SMOOTH_POINT_SIZE_GRANULARITY -#define GL_LINE_SMOOTH 0x0B20 -#define GL_LINE_WIDTH 0x0B21 -#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22 -#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23 -#define GL_LINE_WIDTH_RANGE GL_SMOOTH_LINE_WIDTH_RANGE -#define GL_LINE_WIDTH_GRANULARITY GL_SMOOTH_LINE_WIDTH_GRANULARITY -#define GL_LINE_STIPPLE 0x0B24 -#define GL_LINE_STIPPLE_PATTERN 0x0B25 -#define GL_LINE_STIPPLE_REPEAT 0x0B26 -#define GL_LIST_MODE 0x0B30 -#define GL_MAX_LIST_NESTING 0x0B31 -#define GL_LIST_BASE 0x0B32 -#define GL_LIST_INDEX 0x0B33 -#define GL_POLYGON_MODE 0x0B40 -#define GL_POLYGON_SMOOTH 0x0B41 -#define GL_POLYGON_STIPPLE 0x0B42 -#define GL_EDGE_FLAG 0x0B43 -#define GL_CULL_FACE 0x0B44 -#define GL_CULL_FACE_MODE 0x0B45 -#define GL_FRONT_FACE 0x0B46 -#define GL_LIGHTING 0x0B50 -#define GL_LIGHT_MODEL_LOCAL_VIEWER 0x0B51 -#define GL_LIGHT_MODEL_TWO_SIDE 0x0B52 -#define GL_LIGHT_MODEL_AMBIENT 0x0B53 -#define GL_SHADE_MODEL 0x0B54 -#define GL_COLOR_MATERIAL_FACE 0x0B55 -#define GL_COLOR_MATERIAL_PARAMETER 0x0B56 -#define GL_COLOR_MATERIAL 0x0B57 -#define GL_FOG 0x0B60 -#define GL_FOG_INDEX 0x0B61 -#define GL_FOG_DENSITY 0x0B62 -#define GL_FOG_START 0x0B63 -#define GL_FOG_END 0x0B64 -#define GL_FOG_MODE 0x0B65 -#define GL_FOG_COLOR 0x0B66 -#define GL_DEPTH_RANGE 0x0B70 -#define GL_DEPTH_TEST 0x0B71 -#define GL_DEPTH_WRITEMASK 0x0B72 -#define GL_DEPTH_CLEAR_VALUE 0x0B73 -#define GL_DEPTH_FUNC 0x0B74 -#define GL_ACCUM_CLEAR_VALUE 0x0B80 -#define GL_STENCIL_TEST 0x0B90 -#define GL_STENCIL_CLEAR_VALUE 0x0B91 -#define GL_STENCIL_FUNC 0x0B92 -#define GL_STENCIL_VALUE_MASK 0x0B93 -#define GL_STENCIL_FAIL 0x0B94 -#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95 -#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96 -#define GL_STENCIL_REF 0x0B97 -#define GL_STENCIL_WRITEMASK 0x0B98 -#define GL_MATRIX_MODE 0x0BA0 -#define GL_NORMALIZE 0x0BA1 -#define GL_VIEWPORT 0x0BA2 -#define GL_MODELVIEW_STACK_DEPTH 0x0BA3 -#define GL_PROJECTION_STACK_DEPTH 0x0BA4 -#define GL_TEXTURE_STACK_DEPTH 0x0BA5 -#define GL_MODELVIEW_MATRIX 0x0BA6 -#define GL_PROJECTION_MATRIX 0x0BA7 -#define GL_TEXTURE_MATRIX 0x0BA8 -#define GL_ATTRIB_STACK_DEPTH 0x0BB0 -#define GL_CLIENT_ATTRIB_STACK_DEPTH 0x0BB1 -#define GL_ALPHA_TEST 0x0BC0 -#define GL_ALPHA_TEST_FUNC 0x0BC1 -#define GL_ALPHA_TEST_REF 0x0BC2 -#define GL_DITHER 0x0BD0 -#define GL_BLEND_DST 0x0BE0 -#define GL_BLEND_SRC 0x0BE1 -#define GL_BLEND 0x0BE2 -#define GL_LOGIC_OP_MODE 0x0BF0 -#define GL_INDEX_LOGIC_OP 0x0BF1 -#define GL_LOGIC_OP GL_INDEX_LOGIC_OP -#define GL_COLOR_LOGIC_OP 0x0BF2 -#define GL_AUX_BUFFERS 0x0C00 -#define GL_DRAW_BUFFER 0x0C01 -#define GL_READ_BUFFER 0x0C02 -#define GL_SCISSOR_BOX 0x0C10 -#define GL_SCISSOR_TEST 0x0C11 -#define GL_INDEX_CLEAR_VALUE 0x0C20 -#define GL_INDEX_WRITEMASK 0x0C21 -#define GL_COLOR_CLEAR_VALUE 0x0C22 -#define GL_COLOR_WRITEMASK 0x0C23 -#define GL_INDEX_MODE 0x0C30 -#define GL_RGBA_MODE 0x0C31 -#define GL_DOUBLEBUFFER 0x0C32 -#define GL_STEREO 0x0C33 -#define GL_RENDER_MODE 0x0C40 -#define GL_PERSPECTIVE_CORRECTION_HINT 0x0C50 -#define GL_POINT_SMOOTH_HINT 0x0C51 -#define GL_LINE_SMOOTH_HINT 0x0C52 -#define GL_POLYGON_SMOOTH_HINT 0x0C53 -#define GL_FOG_HINT 0x0C54 -#define GL_TEXTURE_GEN_S 0x0C60 -#define GL_TEXTURE_GEN_T 0x0C61 -#define GL_TEXTURE_GEN_R 0x0C62 -#define GL_TEXTURE_GEN_Q 0x0C63 -#define GL_PIXEL_MAP_I_TO_I_SIZE 0x0CB0 -#define GL_PIXEL_MAP_S_TO_S_SIZE 0x0CB1 -#define GL_PIXEL_MAP_I_TO_R_SIZE 0x0CB2 -#define GL_PIXEL_MAP_I_TO_G_SIZE 0x0CB3 -#define GL_PIXEL_MAP_I_TO_B_SIZE 0x0CB4 -#define GL_PIXEL_MAP_I_TO_A_SIZE 0x0CB5 -#define GL_PIXEL_MAP_R_TO_R_SIZE 0x0CB6 -#define GL_PIXEL_MAP_G_TO_G_SIZE 0x0CB7 -#define GL_PIXEL_MAP_B_TO_B_SIZE 0x0CB8 -#define GL_PIXEL_MAP_A_TO_A_SIZE 0x0CB9 -#define GL_UNPACK_SWAP_BYTES 0x0CF0 -#define GL_UNPACK_LSB_FIRST 0x0CF1 -#define GL_UNPACK_ROW_LENGTH 0x0CF2 -#define GL_UNPACK_SKIP_ROWS 0x0CF3 -#define GL_UNPACK_SKIP_PIXELS 0x0CF4 -#define GL_UNPACK_ALIGNMENT 0x0CF5 -#define GL_PACK_SWAP_BYTES 0x0D00 -#define GL_PACK_LSB_FIRST 0x0D01 -#define GL_PACK_ROW_LENGTH 0x0D02 -#define GL_PACK_SKIP_ROWS 0x0D03 -#define GL_PACK_SKIP_PIXELS 0x0D04 -#define GL_PACK_ALIGNMENT 0x0D05 -#define GL_MAP_COLOR 0x0D10 -#define GL_MAP_STENCIL 0x0D11 -#define GL_INDEX_SHIFT 0x0D12 -#define GL_INDEX_OFFSET 0x0D13 -#define GL_RED_SCALE 0x0D14 -#define GL_RED_BIAS 0x0D15 -#define GL_ZOOM_X 0x0D16 -#define GL_ZOOM_Y 0x0D17 -#define GL_GREEN_SCALE 0x0D18 -#define GL_GREEN_BIAS 0x0D19 -#define GL_BLUE_SCALE 0x0D1A -#define GL_BLUE_BIAS 0x0D1B -#define GL_ALPHA_SCALE 0x0D1C -#define GL_ALPHA_BIAS 0x0D1D -#define GL_DEPTH_SCALE 0x0D1E -#define GL_DEPTH_BIAS 0x0D1F -#define GL_MAX_EVAL_ORDER 0x0D30 -#define GL_MAX_LIGHTS 0x0D31 -#define GL_MAX_CLIP_PLANES 0x0D32 -#define GL_MAX_TEXTURE_SIZE 0x0D33 -#define GL_MAX_PIXEL_MAP_TABLE 0x0D34 -#define GL_MAX_ATTRIB_STACK_DEPTH 0x0D35 -#define GL_MAX_MODELVIEW_STACK_DEPTH 0x0D36 -#define GL_MAX_NAME_STACK_DEPTH 0x0D37 -#define GL_MAX_PROJECTION_STACK_DEPTH 0x0D38 -#define GL_MAX_TEXTURE_STACK_DEPTH 0x0D39 -#define GL_MAX_VIEWPORT_DIMS 0x0D3A -#define GL_MAX_CLIENT_ATTRIB_STACK_DEPTH 0x0D3B -#define GL_SUBPIXEL_BITS 0x0D50 -#define GL_INDEX_BITS 0x0D51 -#define GL_RED_BITS 0x0D52 -#define GL_GREEN_BITS 0x0D53 -#define GL_BLUE_BITS 0x0D54 -#define GL_ALPHA_BITS 0x0D55 -#define GL_DEPTH_BITS 0x0D56 -#define GL_STENCIL_BITS 0x0D57 -#define GL_ACCUM_RED_BITS 0x0D58 -#define GL_ACCUM_GREEN_BITS 0x0D59 -#define GL_ACCUM_BLUE_BITS 0x0D5A -#define GL_ACCUM_ALPHA_BITS 0x0D5B -#define GL_NAME_STACK_DEPTH 0x0D70 -#define GL_AUTO_NORMAL 0x0D80 -#define GL_MAP1_COLOR_4 0x0D90 -#define GL_MAP1_INDEX 0x0D91 -#define GL_MAP1_NORMAL 0x0D92 -#define GL_MAP1_TEXTURE_COORD_1 0x0D93 -#define GL_MAP1_TEXTURE_COORD_2 0x0D94 -#define GL_MAP1_TEXTURE_COORD_3 0x0D95 -#define GL_MAP1_TEXTURE_COORD_4 0x0D96 -#define GL_MAP1_VERTEX_3 0x0D97 -#define GL_MAP1_VERTEX_4 0x0D98 -#define GL_MAP2_COLOR_4 0x0DB0 -#define GL_MAP2_INDEX 0x0DB1 -#define GL_MAP2_NORMAL 0x0DB2 -#define GL_MAP2_TEXTURE_COORD_1 0x0DB3 -#define GL_MAP2_TEXTURE_COORD_2 0x0DB4 -#define GL_MAP2_TEXTURE_COORD_3 0x0DB5 -#define GL_MAP2_TEXTURE_COORD_4 0x0DB6 -#define GL_MAP2_VERTEX_3 0x0DB7 -#define GL_MAP2_VERTEX_4 0x0DB8 -#define GL_MAP1_GRID_DOMAIN 0x0DD0 -#define GL_MAP1_GRID_SEGMENTS 0x0DD1 -#define GL_MAP2_GRID_DOMAIN 0x0DD2 -#define GL_MAP2_GRID_SEGMENTS 0x0DD3 -#define GL_TEXTURE_1D 0x0DE0 -#define GL_TEXTURE_2D 0x0DE1 -#define GL_FEEDBACK_BUFFER_POINTER 0x0DF0 -#define GL_FEEDBACK_BUFFER_SIZE 0x0DF1 -#define GL_FEEDBACK_BUFFER_TYPE 0x0DF2 -#define GL_SELECTION_BUFFER_POINTER 0x0DF3 -#define GL_SELECTION_BUFFER_SIZE 0x0DF4 -#define GL_POLYGON_OFFSET_UNITS 0x2A00 -#define GL_POLYGON_OFFSET_POINT 0x2A01 -#define GL_POLYGON_OFFSET_LINE 0x2A02 -#define GL_POLYGON_OFFSET_FILL 0x8037 -#define GL_POLYGON_OFFSET_FACTOR 0x8038 -#define GL_TEXTURE_BINDING_1D 0x8068 -#define GL_TEXTURE_BINDING_2D 0x8069 -#define GL_TEXTURE_BINDING_3D 0x806A -#define GL_VERTEX_ARRAY 0x8074 -#define GL_NORMAL_ARRAY 0x8075 -#define GL_COLOR_ARRAY 0x8076 -#define GL_INDEX_ARRAY 0x8077 -#define GL_TEXTURE_COORD_ARRAY 0x8078 -#define GL_EDGE_FLAG_ARRAY 0x8079 -#define GL_VERTEX_ARRAY_SIZE 0x807A -#define GL_VERTEX_ARRAY_TYPE 0x807B -#define GL_VERTEX_ARRAY_STRIDE 0x807C -#define GL_NORMAL_ARRAY_TYPE 0x807E -#define GL_NORMAL_ARRAY_STRIDE 0x807F -#define GL_COLOR_ARRAY_SIZE 0x8081 -#define GL_COLOR_ARRAY_TYPE 0x8082 -#define GL_COLOR_ARRAY_STRIDE 0x8083 -#define GL_INDEX_ARRAY_TYPE 0x8085 -#define GL_INDEX_ARRAY_STRIDE 0x8086 -#define GL_TEXTURE_COORD_ARRAY_SIZE 0x8088 -#define GL_TEXTURE_COORD_ARRAY_TYPE 0x8089 -#define GL_TEXTURE_COORD_ARRAY_STRIDE 0x808A -#define GL_EDGE_FLAG_ARRAY_STRIDE 0x808C -/* GL_VERTEX_ARRAY_COUNT_EXT */ -/* GL_NORMAL_ARRAY_COUNT_EXT */ -/* GL_COLOR_ARRAY_COUNT_EXT */ -/* GL_INDEX_ARRAY_COUNT_EXT */ -/* GL_TEXTURE_COORD_ARRAY_COUNT_EXT */ -/* GL_EDGE_FLAG_ARRAY_COUNT_EXT */ - -/* GetTextureParameter */ -/* GL_TEXTURE_MAG_FILTER */ -/* GL_TEXTURE_MIN_FILTER */ -/* GL_TEXTURE_WRAP_S */ -/* GL_TEXTURE_WRAP_T */ -#define GL_TEXTURE_WIDTH 0x1000 -#define GL_TEXTURE_HEIGHT 0x1001 -#define GL_TEXTURE_INTERNAL_FORMAT 0x1003 -#define GL_TEXTURE_COMPONENTS GL_TEXTURE_INTERNAL_FORMAT -#define GL_TEXTURE_BORDER_COLOR 0x1004 -#define GL_TEXTURE_BORDER 0x1005 -#define GL_TEXTURE_RED_SIZE 0x805C -#define GL_TEXTURE_GREEN_SIZE 0x805D -#define GL_TEXTURE_BLUE_SIZE 0x805E -#define GL_TEXTURE_ALPHA_SIZE 0x805F -#define GL_TEXTURE_LUMINANCE_SIZE 0x8060 -#define GL_TEXTURE_INTENSITY_SIZE 0x8061 -#define GL_TEXTURE_PRIORITY 0x8066 -#define GL_TEXTURE_RESIDENT 0x8067 - -/* HintMode */ -#define GL_DONT_CARE 0x1100 -#define GL_FASTEST 0x1101 -#define GL_NICEST 0x1102 - -/* HintTarget */ -/* GL_PERSPECTIVE_CORRECTION_HINT */ -/* GL_POINT_SMOOTH_HINT */ -/* GL_LINE_SMOOTH_HINT */ -/* GL_POLYGON_SMOOTH_HINT */ -/* GL_FOG_HINT */ - -/* IndexMaterialParameterSGI */ -/* GL_INDEX_OFFSET */ - -/* IndexPointerType */ -/* GL_SHORT */ -/* GL_INT */ -/* GL_FLOAT */ -/* GL_DOUBLE */ - -/* IndexFunctionSGI */ -/* GL_NEVER */ -/* GL_LESS */ -/* GL_EQUAL */ -/* GL_LEQUAL */ -/* GL_GREATER */ -/* GL_NOTEQUAL */ -/* GL_GEQUAL */ -/* GL_ALWAYS */ - -/* LightModelParameter */ -/* GL_LIGHT_MODEL_AMBIENT */ -/* GL_LIGHT_MODEL_LOCAL_VIEWER */ -/* GL_LIGHT_MODEL_TWO_SIDE */ - -/* LightParameter */ -#define GL_AMBIENT 0x1200 -#define GL_DIFFUSE 0x1201 -#define GL_SPECULAR 0x1202 -#define GL_POSITION 0x1203 -#define GL_SPOT_DIRECTION 0x1204 -#define GL_SPOT_EXPONENT 0x1205 -#define GL_SPOT_CUTOFF 0x1206 -#define GL_CONSTANT_ATTENUATION 0x1207 -#define GL_LINEAR_ATTENUATION 0x1208 -#define GL_QUADRATIC_ATTENUATION 0x1209 - -/* ListMode */ -#define GL_COMPILE 0x1300 -#define GL_COMPILE_AND_EXECUTE 0x1301 - -/* DataType */ -#define GL_BYTE 0x1400 -#define GL_UNSIGNED_BYTE 0x1401 -#define GL_SHORT 0x1402 -#define GL_UNSIGNED_SHORT 0x1403 -#define GL_INT 0x1404 -#define GL_UNSIGNED_INT 0x1405 -#define GL_FLOAT 0x1406 -#define GL_2_BYTES 0x1407 -#define GL_3_BYTES 0x1408 -#define GL_4_BYTES 0x1409 -#define GL_DOUBLE 0x140A -#define GL_DOUBLE_EXT 0x140A - -/* ListNameType */ -/* GL_BYTE */ -/* GL_UNSIGNED_BYTE */ -/* GL_SHORT */ -/* GL_UNSIGNED_SHORT */ -/* GL_INT */ -/* GL_UNSIGNED_INT */ -/* GL_FLOAT */ -/* GL_2_BYTES */ -/* GL_3_BYTES */ -/* GL_4_BYTES */ - -/* LogicOp */ -#define GL_CLEAR 0x1500 -#define GL_AND 0x1501 -#define GL_AND_REVERSE 0x1502 -#define GL_COPY 0x1503 -#define GL_AND_INVERTED 0x1504 -#define GL_NOOP 0x1505 -#define GL_XOR 0x1506 -#define GL_OR 0x1507 -#define GL_NOR 0x1508 -#define GL_EQUIV 0x1509 -#define GL_INVERT 0x150A -#define GL_OR_REVERSE 0x150B -#define GL_COPY_INVERTED 0x150C -#define GL_OR_INVERTED 0x150D -#define GL_NAND 0x150E -#define GL_SET 0x150F - -/* MapTarget */ -/* GL_MAP1_COLOR_4 */ -/* GL_MAP1_INDEX */ -/* GL_MAP1_NORMAL */ -/* GL_MAP1_TEXTURE_COORD_1 */ -/* GL_MAP1_TEXTURE_COORD_2 */ -/* GL_MAP1_TEXTURE_COORD_3 */ -/* GL_MAP1_TEXTURE_COORD_4 */ -/* GL_MAP1_VERTEX_3 */ -/* GL_MAP1_VERTEX_4 */ -/* GL_MAP2_COLOR_4 */ -/* GL_MAP2_INDEX */ -/* GL_MAP2_NORMAL */ -/* GL_MAP2_TEXTURE_COORD_1 */ -/* GL_MAP2_TEXTURE_COORD_2 */ -/* GL_MAP2_TEXTURE_COORD_3 */ -/* GL_MAP2_TEXTURE_COORD_4 */ -/* GL_MAP2_VERTEX_3 */ -/* GL_MAP2_VERTEX_4 */ - -/* MaterialFace */ -/* GL_FRONT */ -/* GL_BACK */ -/* GL_FRONT_AND_BACK */ - -/* MaterialParameter */ -#define GL_EMISSION 0x1600 -#define GL_SHININESS 0x1601 -#define GL_AMBIENT_AND_DIFFUSE 0x1602 -#define GL_COLOR_INDEXES 0x1603 -/* GL_AMBIENT */ -/* GL_DIFFUSE */ -/* GL_SPECULAR */ - -/* MatrixMode */ -#define GL_MODELVIEW 0x1700 -#define GL_PROJECTION 0x1701 -#define GL_TEXTURE 0x1702 - -/* MeshMode1 */ -/* GL_POINT */ -/* GL_LINE */ - -/* MeshMode2 */ -/* GL_POINT */ -/* GL_LINE */ -/* GL_FILL */ - -/* NormalPointerType */ -/* GL_BYTE */ -/* GL_SHORT */ -/* GL_INT */ -/* GL_FLOAT */ -/* GL_DOUBLE */ - -/* PixelCopyType */ -#define GL_COLOR 0x1800 -#define GL_DEPTH 0x1801 -#define GL_STENCIL 0x1802 - -/* PixelFormat */ -#define GL_COLOR_INDEX 0x1900 -#define GL_STENCIL_INDEX 0x1901 -#define GL_DEPTH_COMPONENT 0x1902 -#define GL_RED 0x1903 -#define GL_GREEN 0x1904 -#define GL_BLUE 0x1905 -#define GL_ALPHA 0x1906 -#define GL_RGB 0x1907 -#define GL_RGBA 0x1908 -#define GL_LUMINANCE 0x1909 -#define GL_LUMINANCE_ALPHA 0x190A -/* GL_ABGR_EXT */ - -/* PixelMap */ -/* GL_PIXEL_MAP_I_TO_I */ -/* GL_PIXEL_MAP_S_TO_S */ -/* GL_PIXEL_MAP_I_TO_R */ -/* GL_PIXEL_MAP_I_TO_G */ -/* GL_PIXEL_MAP_I_TO_B */ -/* GL_PIXEL_MAP_I_TO_A */ -/* GL_PIXEL_MAP_R_TO_R */ -/* GL_PIXEL_MAP_G_TO_G */ -/* GL_PIXEL_MAP_B_TO_B */ -/* GL_PIXEL_MAP_A_TO_A */ - -/* PixelStoreParameter */ -/* GL_UNPACK_SWAP_BYTES */ -/* GL_UNPACK_LSB_FIRST */ -/* GL_UNPACK_ROW_LENGTH */ -/* GL_UNPACK_SKIP_ROWS */ -/* GL_UNPACK_SKIP_PIXELS */ -/* GL_UNPACK_ALIGNMENT */ -/* GL_PACK_SWAP_BYTES */ -/* GL_PACK_LSB_FIRST */ -/* GL_PACK_ROW_LENGTH */ -/* GL_PACK_SKIP_ROWS */ -/* GL_PACK_SKIP_PIXELS */ -/* GL_PACK_ALIGNMENT */ - -/* PixelTransferParameter */ -/* GL_MAP_COLOR */ -/* GL_MAP_STENCIL */ -/* GL_INDEX_SHIFT */ -/* GL_INDEX_OFFSET */ -/* GL_RED_SCALE */ -/* GL_RED_BIAS */ -/* GL_GREEN_SCALE */ -/* GL_GREEN_BIAS */ -/* GL_BLUE_SCALE */ -/* GL_BLUE_BIAS */ -/* GL_ALPHA_SCALE */ -/* GL_ALPHA_BIAS */ -/* GL_DEPTH_SCALE */ -/* GL_DEPTH_BIAS */ - -/* PixelType */ -#define GL_BITMAP 0x1A00 -/* GL_BYTE */ -/* GL_UNSIGNED_BYTE */ -/* GL_SHORT */ -/* GL_UNSIGNED_SHORT */ -/* GL_INT */ -/* GL_UNSIGNED_INT */ -/* GL_FLOAT */ -/* GL_UNSIGNED_BYTE_3_3_2_EXT */ -/* GL_UNSIGNED_SHORT_4_4_4_4_EXT */ -/* GL_UNSIGNED_SHORT_5_5_5_1_EXT */ -/* GL_UNSIGNED_INT_8_8_8_8_EXT */ -/* GL_UNSIGNED_INT_10_10_10_2_EXT */ - -/* PolygonMode */ -#define GL_POINT 0x1B00 -#define GL_LINE 0x1B01 -#define GL_FILL 0x1B02 - -/* ReadBufferMode */ -/* GL_FRONT_LEFT */ -/* GL_FRONT_RIGHT */ -/* GL_BACK_LEFT */ -/* GL_BACK_RIGHT */ -/* GL_FRONT */ -/* GL_BACK */ -/* GL_LEFT */ -/* GL_RIGHT */ -/* GL_AUX0 */ -/* GL_AUX1 */ -/* GL_AUX2 */ -/* GL_AUX3 */ - -/* RenderingMode */ -#define GL_RENDER 0x1C00 -#define GL_FEEDBACK 0x1C01 -#define GL_SELECT 0x1C02 - -/* ShadingModel */ -#define GL_FLAT 0x1D00 -#define GL_SMOOTH 0x1D01 - -/* StencilFunction */ -/* GL_NEVER */ -/* GL_LESS */ -/* GL_EQUAL */ -/* GL_LEQUAL */ -/* GL_GREATER */ -/* GL_NOTEQUAL */ -/* GL_GEQUAL */ -/* GL_ALWAYS */ - -/* StencilOp */ -/* GL_ZERO */ -#define GL_KEEP 0x1E00 -#define GL_REPLACE 0x1E01 -#define GL_INCR 0x1E02 -#define GL_DECR 0x1E03 -/* GL_INVERT */ - -/* StringName */ -#define GL_VENDOR 0x1F00 -#define GL_RENDERER 0x1F01 -#define GL_VERSION 0x1F02 -#define GL_EXTENSIONS 0x1F03 - -/* TexCoordPointerType */ -/* GL_SHORT */ -/* GL_INT */ -/* GL_FLOAT */ -/* GL_DOUBLE */ - -/* TextureCoordName */ -#define GL_S 0x2000 -#define GL_T 0x2001 -#define GL_R 0x2002 -#define GL_Q 0x2003 - -/* TextureEnvMode */ -#define GL_MODULATE 0x2100 -#define GL_DECAL 0x2101 -/* GL_BLEND */ -/* GL_REPLACE */ -/* GL_ADD */ - -/* TextureEnvParameter */ -#define GL_TEXTURE_ENV_MODE 0x2200 -#define GL_TEXTURE_ENV_COLOR 0x2201 - -/* TextureEnvTarget */ -#define GL_TEXTURE_ENV 0x2300 - -/* TextureGenMode */ -#define GL_EYE_LINEAR 0x2400 -#define GL_OBJECT_LINEAR 0x2401 -#define GL_SPHERE_MAP 0x2402 - -/* TextureGenParameter */ -#define GL_TEXTURE_GEN_MODE 0x2500 -#define GL_OBJECT_PLANE 0x2501 -#define GL_EYE_PLANE 0x2502 - -/* TextureMagFilter */ -#define GL_NEAREST 0x2600 -#define GL_LINEAR 0x2601 - -/* TextureMinFilter */ -/* GL_NEAREST */ -/* GL_LINEAR */ -#define GL_NEAREST_MIPMAP_NEAREST 0x2700 -#define GL_LINEAR_MIPMAP_NEAREST 0x2701 -#define GL_NEAREST_MIPMAP_LINEAR 0x2702 -#define GL_LINEAR_MIPMAP_LINEAR 0x2703 - -/* TextureParameterName */ -#define GL_TEXTURE_MAG_FILTER 0x2800 -#define GL_TEXTURE_MIN_FILTER 0x2801 -#define GL_TEXTURE_WRAP_S 0x2802 -#define GL_TEXTURE_WRAP_T 0x2803 -/* GL_TEXTURE_BORDER_COLOR */ -/* GL_TEXTURE_PRIORITY */ - -/* TextureTarget */ -/* GL_TEXTURE_1D */ -/* GL_TEXTURE_2D */ -#define GL_PROXY_TEXTURE_1D 0x8063 -#define GL_PROXY_TEXTURE_2D 0x8064 - -/* TextureWrapMode */ -#define GL_CLAMP 0x2900 -#define GL_REPEAT 0x2901 - -/* PixelInternalFormat */ -#define GL_R3_G3_B2 0x2A10 -#define GL_ALPHA4 0x803B -#define GL_ALPHA8 0x803C -#define GL_ALPHA12 0x803D -#define GL_ALPHA16 0x803E -#define GL_LUMINANCE4 0x803F -#define GL_LUMINANCE8 0x8040 -#define GL_LUMINANCE12 0x8041 -#define GL_LUMINANCE16 0x8042 -#define GL_LUMINANCE4_ALPHA4 0x8043 -#define GL_LUMINANCE6_ALPHA2 0x8044 -#define GL_LUMINANCE8_ALPHA8 0x8045 -#define GL_LUMINANCE12_ALPHA4 0x8046 -#define GL_LUMINANCE12_ALPHA12 0x8047 -#define GL_LUMINANCE16_ALPHA16 0x8048 -#define GL_INTENSITY 0x8049 -#define GL_INTENSITY4 0x804A -#define GL_INTENSITY8 0x804B -#define GL_INTENSITY12 0x804C -#define GL_INTENSITY16 0x804D -#define GL_RGB4 0x804F -#define GL_RGB5 0x8050 -#define GL_RGB8 0x8051 -#define GL_RGB10 0x8052 -#define GL_RGB12 0x8053 -#define GL_RGB16 0x8054 -#define GL_RGBA2 0x8055 -#define GL_RGBA4 0x8056 -#define GL_RGB5_A1 0x8057 -#define GL_RGBA8 0x8058 -#define GL_RGB10_A2 0x8059 -#define GL_RGBA12 0x805A -#define GL_RGBA16 0x805B - -/* InterleavedArrayFormat */ -#define GL_V2F 0x2A20 -#define GL_V3F 0x2A21 -#define GL_C4UB_V2F 0x2A22 -#define GL_C4UB_V3F 0x2A23 -#define GL_C3F_V3F 0x2A24 -#define GL_N3F_V3F 0x2A25 -#define GL_C4F_N3F_V3F 0x2A26 -#define GL_T2F_V3F 0x2A27 -#define GL_T4F_V4F 0x2A28 -#define GL_T2F_C4UB_V3F 0x2A29 -#define GL_T2F_C3F_V3F 0x2A2A -#define GL_T2F_N3F_V3F 0x2A2B -#define GL_T2F_C4F_N3F_V3F 0x2A2C -#define GL_T4F_C4F_N3F_V4F 0x2A2D - -/* VertexPointerType */ -/* GL_SHORT */ -/* GL_INT */ -/* GL_FLOAT */ -/* GL_DOUBLE */ - -/* ClipPlaneName */ -#define GL_CLIP_PLANE0 0x3000 -#define GL_CLIP_PLANE1 0x3001 -#define GL_CLIP_PLANE2 0x3002 -#define GL_CLIP_PLANE3 0x3003 -#define GL_CLIP_PLANE4 0x3004 -#define GL_CLIP_PLANE5 0x3005 - -/* LightName */ -#define GL_LIGHT0 0x4000 -#define GL_LIGHT1 0x4001 -#define GL_LIGHT2 0x4002 -#define GL_LIGHT3 0x4003 -#define GL_LIGHT4 0x4004 -#define GL_LIGHT5 0x4005 -#define GL_LIGHT6 0x4006 -#define GL_LIGHT7 0x4007 - -/* EXT_abgr */ -#define GL_ABGR_EXT 0x8000 - -/* EXT_blend_subtract */ -#define GL_FUNC_SUBTRACT_EXT 0x800A -#define GL_FUNC_REVERSE_SUBTRACT_EXT 0x800B - -/* EXT_packed_pixels */ -#define GL_UNSIGNED_BYTE_3_3_2_EXT 0x8032 -#define GL_UNSIGNED_SHORT_4_4_4_4_EXT 0x8033 -#define GL_UNSIGNED_SHORT_5_5_5_1_EXT 0x8034 -#define GL_UNSIGNED_INT_8_8_8_8_EXT 0x8035 -#define GL_UNSIGNED_INT_10_10_10_2_EXT 0x8036 - -/* OpenGL12 */ -#define GL_PACK_SKIP_IMAGES 0x806B -#define GL_PACK_IMAGE_HEIGHT 0x806C -#define GL_UNPACK_SKIP_IMAGES 0x806D -#define GL_UNPACK_IMAGE_HEIGHT 0x806E -#define GL_TEXTURE_3D 0x806F -#define GL_PROXY_TEXTURE_3D 0x8070 -#define GL_TEXTURE_DEPTH 0x8071 -#define GL_TEXTURE_WRAP_R 0x8072 -#define GL_MAX_3D_TEXTURE_SIZE 0x8073 -#define GL_BGR 0x80E0 -#define GL_BGRA 0x80E1 -#define GL_UNSIGNED_BYTE_3_3_2 0x8032 -#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362 -#define GL_UNSIGNED_SHORT_5_6_5 0x8363 -#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364 -#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 -#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365 -#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 -#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 -#define GL_UNSIGNED_INT_8_8_8_8 0x8035 -#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367 -#define GL_UNSIGNED_INT_10_10_10_2 0x8036 -#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 -#define GL_RESCALE_NORMAL 0x803A -#define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8 -#define GL_SINGLE_COLOR 0x81F9 -#define GL_SEPARATE_SPECULAR_COLOR 0x81FA -#define GL_CLAMP_TO_EDGE 0x812F -#define GL_TEXTURE_MIN_LOD 0x813A -#define GL_TEXTURE_MAX_LOD 0x813B -#define GL_TEXTURE_BASE_LEVEL 0x813C -#define GL_TEXTURE_MAX_LEVEL 0x813D -#define GL_MAX_ELEMENTS_VERTICES 0x80E8 -#define GL_MAX_ELEMENTS_INDICES 0x80E9 -#define GL_ALIASED_POINT_SIZE_RANGE 0x846D -#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E - -/* OpenGL13 */ -#define GL_ACTIVE_TEXTURE 0x84E0 -#define GL_CLIENT_ACTIVE_TEXTURE 0x84E1 -#define GL_MAX_TEXTURE_UNITS 0x84E2 -#define GL_TEXTURE0 0x84C0 -#define GL_TEXTURE1 0x84C1 -#define GL_TEXTURE2 0x84C2 -#define GL_TEXTURE3 0x84C3 -#define GL_TEXTURE4 0x84C4 -#define GL_TEXTURE5 0x84C5 -#define GL_TEXTURE6 0x84C6 -#define GL_TEXTURE7 0x84C7 -#define GL_TEXTURE8 0x84C8 -#define GL_TEXTURE9 0x84C9 -#define GL_TEXTURE10 0x84CA -#define GL_TEXTURE11 0x84CB -#define GL_TEXTURE12 0x84CC -#define GL_TEXTURE13 0x84CD -#define GL_TEXTURE14 0x84CE -#define GL_TEXTURE15 0x84CF -#define GL_TEXTURE16 0x84D0 -#define GL_TEXTURE17 0x84D1 -#define GL_TEXTURE18 0x84D2 -#define GL_TEXTURE19 0x84D3 -#define GL_TEXTURE20 0x84D4 -#define GL_TEXTURE21 0x84D5 -#define GL_TEXTURE22 0x84D6 -#define GL_TEXTURE23 0x84D7 -#define GL_TEXTURE24 0x84D8 -#define GL_TEXTURE25 0x84D9 -#define GL_TEXTURE26 0x84DA -#define GL_TEXTURE27 0x84DB -#define GL_TEXTURE28 0x84DC -#define GL_TEXTURE29 0x84DD -#define GL_TEXTURE30 0x84DE -#define GL_TEXTURE31 0x84DF -#define GL_NORMAL_MAP 0x8511 -#define GL_REFLECTION_MAP 0x8512 -#define GL_TEXTURE_CUBE_MAP 0x8513 -#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A -#define GL_PROXY_TEXTURE_CUBE_MAP 0x851B -#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C -#define GL_COMBINE 0x8570 -#define GL_COMBINE_RGB 0x8571 -#define GL_COMBINE_ALPHA 0x8572 -#define GL_RGB_SCALE 0x8573 -#define GL_ADD_SIGNED 0x8574 -#define GL_INTERPOLATE 0x8575 -#define GL_CONSTANT 0x8576 -#define GL_PRIMARY_COLOR 0x8577 -#define GL_PREVIOUS 0x8578 -#define GL_SOURCE0_RGB 0x8580 -#define GL_SOURCE1_RGB 0x8581 -#define GL_SOURCE2_RGB 0x8582 -#define GL_SOURCE0_ALPHA 0x8588 -#define GL_SOURCE1_ALPHA 0x8589 -#define GL_SOURCE2_ALPHA 0x858A -#define GL_OPERAND0_RGB 0x8590 -#define GL_OPERAND1_RGB 0x8591 -#define GL_OPERAND2_RGB 0x8592 -#define GL_OPERAND0_ALPHA 0x8598 -#define GL_OPERAND1_ALPHA 0x8599 -#define GL_OPERAND2_ALPHA 0x859A -#define GL_SUBTRACT 0x84E7 -#define GL_TRANSPOSE_MODELVIEW_MATRIX 0x84E3 -#define GL_TRANSPOSE_PROJECTION_MATRIX 0x84E4 -#define GL_TRANSPOSE_TEXTURE_MATRIX 0x84E5 -#define GL_TRANSPOSE_COLOR_MATRIX 0x84E6 -#define GL_COMPRESSED_ALPHA 0x84E9 -#define GL_COMPRESSED_LUMINANCE 0x84EA -#define GL_COMPRESSED_LUMINANCE_ALPHA 0x84EB -#define GL_COMPRESSED_INTENSITY 0x84EC -#define GL_COMPRESSED_RGB 0x84ED -#define GL_COMPRESSED_RGBA 0x84EE -#define GL_TEXTURE_COMPRESSION_HINT 0x84EF -#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0 -#define GL_TEXTURE_COMPRESSED 0x86A1 -#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 -#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 -#define GL_DOT3_RGB 0x86AE -#define GL_DOT3_RGBA 0x86AF -#define GL_CLAMP_TO_BORDER 0x812D -#define GL_MULTISAMPLE 0x809D -#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E -#define GL_SAMPLE_ALPHA_TO_ONE 0x809F -#define GL_SAMPLE_COVERAGE 0x80A0 -#define GL_SAMPLE_BUFFERS 0x80A8 -#define GL_SAMPLES 0x80A9 -#define GL_SAMPLE_COVERAGE_VALUE 0x80AA -#define GL_SAMPLE_COVERAGE_INVERT 0x80AB -#define GL_MULTISAMPLE_BIT 0x20000000 - -/* EXT_vertex_array */ -#define GL_VERTEX_ARRAY_EXT 0x8074 -#define GL_NORMAL_ARRAY_EXT 0x8075 -#define GL_COLOR_ARRAY_EXT 0x8076 -#define GL_INDEX_ARRAY_EXT 0x8077 -#define GL_TEXTURE_COORD_ARRAY_EXT 0x8078 -#define GL_EDGE_FLAG_ARRAY_EXT 0x8079 -#define GL_VERTEX_ARRAY_SIZE_EXT 0x807A -#define GL_VERTEX_ARRAY_TYPE_EXT 0x807B -#define GL_VERTEX_ARRAY_STRIDE_EXT 0x807C -#define GL_VERTEX_ARRAY_COUNT_EXT 0x807D -#define GL_NORMAL_ARRAY_TYPE_EXT 0x807E -#define GL_NORMAL_ARRAY_STRIDE_EXT 0x807F -#define GL_NORMAL_ARRAY_COUNT_EXT 0x8080 -#define GL_COLOR_ARRAY_SIZE_EXT 0x8081 -#define GL_COLOR_ARRAY_TYPE_EXT 0x8082 -#define GL_COLOR_ARRAY_STRIDE_EXT 0x8083 -#define GL_COLOR_ARRAY_COUNT_EXT 0x8084 -#define GL_INDEX_ARRAY_TYPE_EXT 0x8085 -#define GL_INDEX_ARRAY_STRIDE_EXT 0x8086 -#define GL_INDEX_ARRAY_COUNT_EXT 0x8087 -#define GL_TEXTURE_COORD_ARRAY_SIZE_EXT 0x8088 -#define GL_TEXTURE_COORD_ARRAY_TYPE_EXT 0x8089 -#define GL_TEXTURE_COORD_ARRAY_STRIDE_EXT 0x808A -#define GL_TEXTURE_COORD_ARRAY_COUNT_EXT 0x808B -#define GL_EDGE_FLAG_ARRAY_STRIDE_EXT 0x808C -#define GL_EDGE_FLAG_ARRAY_COUNT_EXT 0x808D -#define GL_VERTEX_ARRAY_POINTER_EXT 0x808E -#define GL_NORMAL_ARRAY_POINTER_EXT 0x808F -#define GL_COLOR_ARRAY_POINTER_EXT 0x8090 -#define GL_INDEX_ARRAY_POINTER_EXT 0x8091 -#define GL_TEXTURE_COORD_ARRAY_POINTER_EXT 0x8092 -#define GL_EDGE_FLAG_ARRAY_POINTER_EXT 0x8093 - -/* SGIS_texture_lod */ -#define GL_TEXTURE_MIN_LOD_SGIS 0x813A -#define GL_TEXTURE_MAX_LOD_SGIS 0x813B -#define GL_TEXTURE_BASE_LEVEL_SGIS 0x813C -#define GL_TEXTURE_MAX_LEVEL_SGIS 0x813D - -/* EXT_shared_texture_palette */ -#define GL_SHARED_TEXTURE_PALETTE_EXT 0x81FB - -/* EXT_rescale_normal */ -#define GL_RESCALE_NORMAL_EXT 0x803A - -/* SGIX_shadow */ -#define GL_TEXTURE_COMPARE_SGIX 0x819A -#define GL_TEXTURE_COMPARE_OPERATOR_SGIX 0x819B -#define GL_TEXTURE_LEQUAL_R_SGIX 0x819C -#define GL_TEXTURE_GEQUAL_R_SGIX 0x819D - -/* SGIX_depth_texture */ -#define GL_DEPTH_COMPONENT16_SGIX 0x81A5 -#define GL_DEPTH_COMPONENT24_SGIX 0x81A6 -#define GL_DEPTH_COMPONENT32_SGIX 0x81A7 - -/* SGIS_generate_mipmap */ -#define GL_GENERATE_MIPMAP_SGIS 0x8191 -#define GL_GENERATE_MIPMAP_HINT_SGIS 0x8192 - -/* OpenGL14 */ -#define GL_POINT_SIZE_MIN 0x8126 -#define GL_POINT_SIZE_MAX 0x8127 -#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128 -#define GL_POINT_DISTANCE_ATTENUATION 0x8129 -#define GL_FOG_COORDINATE_SOURCE 0x8450 -#define GL_FOG_COORDINATE 0x8451 -#define GL_FRAGMENT_DEPTH 0x8452 -#define GL_CURRENT_FOG_COORDINATE 0x8453 -#define GL_FOG_COORDINATE_ARRAY_TYPE 0x8454 -#define GL_FOG_COORDINATE_ARRAY_STRIDE 0x8455 -#define GL_FOG_COORDINATE_ARRAY_POINTER 0x8456 -#define GL_FOG_COORDINATE_ARRAY 0x8457 -#define GL_COLOR_SUM 0x8458 -#define GL_CURRENT_SECONDARY_COLOR 0x8459 -#define GL_SECONDARY_COLOR_ARRAY_SIZE 0x845A -#define GL_SECONDARY_COLOR_ARRAY_TYPE 0x845B -#define GL_SECONDARY_COLOR_ARRAY_STRIDE 0x845C -#define GL_SECONDARY_COLOR_ARRAY_POINTER 0x845D -#define GL_SECONDARY_COLOR_ARRAY 0x845E -#define GL_INCR_WRAP 0x8507 -#define GL_DECR_WRAP 0x8508 -#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD -#define GL_TEXTURE_FILTER_CONTROL 0x8500 -#define GL_TEXTURE_LOD_BIAS 0x8501 -#define GL_GENERATE_MIPMAP 0x8191 -#define GL_GENERATE_MIPMAP_HINT 0x8192 -#define GL_BLEND_DST_RGB 0x80C8 -#define GL_BLEND_SRC_RGB 0x80C9 -#define GL_BLEND_DST_ALPHA 0x80CA -#define GL_BLEND_SRC_ALPHA 0x80CB -#define GL_MIRRORED_REPEAT 0x8370 -#define GL_DEPTH_COMPONENT16 0x81A5 -#define GL_DEPTH_COMPONENT24 0x81A6 -#define GL_DEPTH_COMPONENT32 0x81A7 -#define GL_TEXTURE_DEPTH_SIZE 0x884A -#define GL_DEPTH_TEXTURE_MODE 0x884B -#define GL_TEXTURE_COMPARE_MODE 0x884C -#define GL_TEXTURE_COMPARE_FUNC 0x884D -#define GL_COMPARE_R_TO_TEXTURE 0x884E - -/*************************************************************/ - -WINGDIAPI void APIENTRY glAccum (GLenum op, GLfloat value); -WINGDIAPI void APIENTRY glAlphaFunc (GLenum func, GLclampf ref); -WINGDIAPI GLboolean APIENTRY glAreTexturesResident (GLsizei n, const GLuint *textures, GLboolean *residences); -WINGDIAPI void APIENTRY glArrayElement (GLint i); -WINGDIAPI void APIENTRY glBegin (GLenum mode); -WINGDIAPI void APIENTRY glBindTexture (GLenum target, GLuint texture); -WINGDIAPI void APIENTRY glBitmap (GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte *bitmap); -WINGDIAPI void APIENTRY glBlendFunc (GLenum sfactor, GLenum dfactor); -WINGDIAPI void APIENTRY glCallList (GLuint list); -WINGDIAPI void APIENTRY glCallLists (GLsizei n, GLenum type, const GLvoid *lists); -WINGDIAPI void APIENTRY glClear (GLbitfield mask); -WINGDIAPI void APIENTRY glClearAccum (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); -WINGDIAPI void APIENTRY glClearColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); -WINGDIAPI void APIENTRY glClearDepth (GLclampd depth); -WINGDIAPI void APIENTRY glClearIndex (GLfloat c); -WINGDIAPI void APIENTRY glClearStencil (GLint s); -WINGDIAPI void APIENTRY glClipPlane (GLenum plane, const GLdouble *equation); -WINGDIAPI void APIENTRY glColor3b (GLbyte red, GLbyte green, GLbyte blue); -WINGDIAPI void APIENTRY glColor3bv (const GLbyte *v); -WINGDIAPI void APIENTRY glColor3d (GLdouble red, GLdouble green, GLdouble blue); -WINGDIAPI void APIENTRY glColor3dv (const GLdouble *v); -WINGDIAPI void APIENTRY glColor3f (GLfloat red, GLfloat green, GLfloat blue); -WINGDIAPI void APIENTRY glColor3fv (const GLfloat *v); -WINGDIAPI void APIENTRY glColor3i (GLint red, GLint green, GLint blue); -WINGDIAPI void APIENTRY glColor3iv (const GLint *v); -WINGDIAPI void APIENTRY glColor3s (GLshort red, GLshort green, GLshort blue); -WINGDIAPI void APIENTRY glColor3sv (const GLshort *v); -WINGDIAPI void APIENTRY glColor3ub (GLubyte red, GLubyte green, GLubyte blue); -WINGDIAPI void APIENTRY glColor3ubv (const GLubyte *v); -WINGDIAPI void APIENTRY glColor3ui (GLuint red, GLuint green, GLuint blue); -WINGDIAPI void APIENTRY glColor3uiv (const GLuint *v); -WINGDIAPI void APIENTRY glColor3us (GLushort red, GLushort green, GLushort blue); -WINGDIAPI void APIENTRY glColor3usv (const GLushort *v); -WINGDIAPI void APIENTRY glColor4b (GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha); -WINGDIAPI void APIENTRY glColor4bv (const GLbyte *v); -WINGDIAPI void APIENTRY glColor4d (GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha); -WINGDIAPI void APIENTRY glColor4dv (const GLdouble *v); -WINGDIAPI void APIENTRY glColor4f (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); -WINGDIAPI void APIENTRY glColor4fv (const GLfloat *v); -WINGDIAPI void APIENTRY glColor4i (GLint red, GLint green, GLint blue, GLint alpha); -WINGDIAPI void APIENTRY glColor4iv (const GLint *v); -WINGDIAPI void APIENTRY glColor4s (GLshort red, GLshort green, GLshort blue, GLshort alpha); -WINGDIAPI void APIENTRY glColor4sv (const GLshort *v); -WINGDIAPI void APIENTRY glColor4ub (GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha); -WINGDIAPI void APIENTRY glColor4ubv (const GLubyte *v); -WINGDIAPI void APIENTRY glColor4ui (GLuint red, GLuint green, GLuint blue, GLuint alpha); -WINGDIAPI void APIENTRY glColor4uiv (const GLuint *v); -WINGDIAPI void APIENTRY glColor4us (GLushort red, GLushort green, GLushort blue, GLushort alpha); -WINGDIAPI void APIENTRY glColor4usv (const GLushort *v); -WINGDIAPI void APIENTRY glColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); -WINGDIAPI void APIENTRY glColorMaterial (GLenum face, GLenum mode); -WINGDIAPI void APIENTRY glColorPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -WINGDIAPI void APIENTRY glCopyPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum type); -WINGDIAPI void APIENTRY glCopyTexImage1D (GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLint border); -WINGDIAPI void APIENTRY glCopyTexImage2D (GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); -WINGDIAPI void APIENTRY glCopyTexSubImage1D (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); -WINGDIAPI void APIENTRY glCopyTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); -WINGDIAPI void APIENTRY glCullFace (GLenum mode); -WINGDIAPI void APIENTRY glDeleteLists (GLuint list, GLsizei range); -WINGDIAPI void APIENTRY glDeleteTextures (GLsizei n, const GLuint *textures); -WINGDIAPI void APIENTRY glDepthFunc (GLenum func); -WINGDIAPI void APIENTRY glDepthMask (GLboolean flag); -WINGDIAPI void APIENTRY glDepthRange (GLclampd zNear, GLclampd zFar); -WINGDIAPI void APIENTRY glDisable (GLenum cap); -WINGDIAPI void APIENTRY glDisableClientState (GLenum array); -WINGDIAPI void APIENTRY glDrawArrays (GLenum mode, GLint first, GLsizei count); -WINGDIAPI void APIENTRY glDrawBuffer (GLenum mode); -WINGDIAPI void APIENTRY glDrawElements (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices); -WINGDIAPI void APIENTRY glDrawPixels (GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); -WINGDIAPI void APIENTRY glEdgeFlag (GLboolean flag); -WINGDIAPI void APIENTRY glEdgeFlagPointer (GLsizei stride, const GLvoid *pointer); -WINGDIAPI void APIENTRY glEdgeFlagv (const GLboolean *flag); -WINGDIAPI void APIENTRY glEnable (GLenum cap); -WINGDIAPI void APIENTRY glEnableClientState (GLenum array); -WINGDIAPI void APIENTRY glEnd (void); -WINGDIAPI void APIENTRY glEndList (void); -WINGDIAPI void APIENTRY glEvalCoord1d (GLdouble u); -WINGDIAPI void APIENTRY glEvalCoord1dv (const GLdouble *u); -WINGDIAPI void APIENTRY glEvalCoord1f (GLfloat u); -WINGDIAPI void APIENTRY glEvalCoord1fv (const GLfloat *u); -WINGDIAPI void APIENTRY glEvalCoord2d (GLdouble u, GLdouble v); -WINGDIAPI void APIENTRY glEvalCoord2dv (const GLdouble *u); -WINGDIAPI void APIENTRY glEvalCoord2f (GLfloat u, GLfloat v); -WINGDIAPI void APIENTRY glEvalCoord2fv (const GLfloat *u); -WINGDIAPI void APIENTRY glEvalMesh1 (GLenum mode, GLint i1, GLint i2); -WINGDIAPI void APIENTRY glEvalMesh2 (GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2); -WINGDIAPI void APIENTRY glEvalPoint1 (GLint i); -WINGDIAPI void APIENTRY glEvalPoint2 (GLint i, GLint j); -WINGDIAPI void APIENTRY glFeedbackBuffer (GLsizei size, GLenum type, GLfloat *buffer); -WINGDIAPI void APIENTRY glFinish (void); -WINGDIAPI void APIENTRY glFlush (void); -WINGDIAPI void APIENTRY glFogf (GLenum pname, GLfloat param); -WINGDIAPI void APIENTRY glFogfv (GLenum pname, const GLfloat *params); -WINGDIAPI void APIENTRY glFogi (GLenum pname, GLint param); -WINGDIAPI void APIENTRY glFogiv (GLenum pname, const GLint *params); -WINGDIAPI void APIENTRY glFrontFace (GLenum mode); -WINGDIAPI void APIENTRY glFrustum (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); -WINGDIAPI GLuint APIENTRY glGenLists (GLsizei range); -WINGDIAPI void APIENTRY glGenTextures (GLsizei n, GLuint *textures); -WINGDIAPI void APIENTRY glGetBooleanv (GLenum pname, GLboolean *params); -WINGDIAPI void APIENTRY glGetClipPlane (GLenum plane, GLdouble *equation); -WINGDIAPI void APIENTRY glGetDoublev (GLenum pname, GLdouble *params); -WINGDIAPI GLenum APIENTRY glGetError (void); -WINGDIAPI void APIENTRY glGetFloatv (GLenum pname, GLfloat *params); -WINGDIAPI void APIENTRY glGetIntegerv (GLenum pname, GLint *params); -WINGDIAPI void APIENTRY glGetLightfv (GLenum light, GLenum pname, GLfloat *params); -WINGDIAPI void APIENTRY glGetLightiv (GLenum light, GLenum pname, GLint *params); -WINGDIAPI void APIENTRY glGetMapdv (GLenum target, GLenum query, GLdouble *v); -WINGDIAPI void APIENTRY glGetMapfv (GLenum target, GLenum query, GLfloat *v); -WINGDIAPI void APIENTRY glGetMapiv (GLenum target, GLenum query, GLint *v); -WINGDIAPI void APIENTRY glGetMaterialfv (GLenum face, GLenum pname, GLfloat *params); -WINGDIAPI void APIENTRY glGetMaterialiv (GLenum face, GLenum pname, GLint *params); -WINGDIAPI void APIENTRY glGetPixelMapfv (GLenum map, GLfloat *values); -WINGDIAPI void APIENTRY glGetPixelMapuiv (GLenum map, GLuint *values); -WINGDIAPI void APIENTRY glGetPixelMapusv (GLenum map, GLushort *values); -WINGDIAPI void APIENTRY glGetPointerv (GLenum pname, GLvoid* *params); -WINGDIAPI void APIENTRY glGetPolygonStipple (GLubyte *mask); -WINGDIAPI const GLubyte * APIENTRY glGetString (GLenum name); -WINGDIAPI void APIENTRY glGetTexEnvfv (GLenum target, GLenum pname, GLfloat *params); -WINGDIAPI void APIENTRY glGetTexEnviv (GLenum target, GLenum pname, GLint *params); -WINGDIAPI void APIENTRY glGetTexGendv (GLenum coord, GLenum pname, GLdouble *params); -WINGDIAPI void APIENTRY glGetTexGenfv (GLenum coord, GLenum pname, GLfloat *params); -WINGDIAPI void APIENTRY glGetTexGeniv (GLenum coord, GLenum pname, GLint *params); -WINGDIAPI void APIENTRY glGetTexImage (GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels); -WINGDIAPI void APIENTRY glGetTexLevelParameterfv (GLenum target, GLint level, GLenum pname, GLfloat *params); -WINGDIAPI void APIENTRY glGetTexLevelParameteriv (GLenum target, GLint level, GLenum pname, GLint *params); -WINGDIAPI void APIENTRY glGetTexParameterfv (GLenum target, GLenum pname, GLfloat *params); -WINGDIAPI void APIENTRY glGetTexParameteriv (GLenum target, GLenum pname, GLint *params); -WINGDIAPI void APIENTRY glHint (GLenum target, GLenum mode); -WINGDIAPI void APIENTRY glIndexMask (GLuint mask); -WINGDIAPI void APIENTRY glIndexPointer (GLenum type, GLsizei stride, const GLvoid *pointer); -WINGDIAPI void APIENTRY glIndexd (GLdouble c); -WINGDIAPI void APIENTRY glIndexdv (const GLdouble *c); -WINGDIAPI void APIENTRY glIndexf (GLfloat c); -WINGDIAPI void APIENTRY glIndexfv (const GLfloat *c); -WINGDIAPI void APIENTRY glIndexi (GLint c); -WINGDIAPI void APIENTRY glIndexiv (const GLint *c); -WINGDIAPI void APIENTRY glIndexs (GLshort c); -WINGDIAPI void APIENTRY glIndexsv (const GLshort *c); -WINGDIAPI void APIENTRY glIndexub (GLubyte c); -WINGDIAPI void APIENTRY glIndexubv (const GLubyte *c); -WINGDIAPI void APIENTRY glInitNames (void); -WINGDIAPI void APIENTRY glInterleavedArrays (GLenum format, GLsizei stride, const GLvoid *pointer); -WINGDIAPI GLboolean APIENTRY glIsEnabled (GLenum cap); -WINGDIAPI GLboolean APIENTRY glIsList (GLuint list); -WINGDIAPI GLboolean APIENTRY glIsTexture (GLuint texture); -WINGDIAPI void APIENTRY glLightModelf (GLenum pname, GLfloat param); -WINGDIAPI void APIENTRY glLightModelfv (GLenum pname, const GLfloat *params); -WINGDIAPI void APIENTRY glLightModeli (GLenum pname, GLint param); -WINGDIAPI void APIENTRY glLightModeliv (GLenum pname, const GLint *params); -WINGDIAPI void APIENTRY glLightf (GLenum light, GLenum pname, GLfloat param); -WINGDIAPI void APIENTRY glLightfv (GLenum light, GLenum pname, const GLfloat *params); -WINGDIAPI void APIENTRY glLighti (GLenum light, GLenum pname, GLint param); -WINGDIAPI void APIENTRY glLightiv (GLenum light, GLenum pname, const GLint *params); -WINGDIAPI void APIENTRY glLineStipple (GLint factor, GLushort pattern); -WINGDIAPI void APIENTRY glLineWidth (GLfloat width); -WINGDIAPI void APIENTRY glListBase (GLuint base); -WINGDIAPI void APIENTRY glLoadIdentity (void); -WINGDIAPI void APIENTRY glLoadMatrixd (const GLdouble *m); -WINGDIAPI void APIENTRY glLoadMatrixf (const GLfloat *m); -WINGDIAPI void APIENTRY glLoadName (GLuint name); -WINGDIAPI void APIENTRY glLogicOp (GLenum opcode); -WINGDIAPI void APIENTRY glMap1d (GLenum target, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points); -WINGDIAPI void APIENTRY glMap1f (GLenum target, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points); -WINGDIAPI void APIENTRY glMap2d (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points); -WINGDIAPI void APIENTRY glMap2f (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points); -WINGDIAPI void APIENTRY glMapGrid1d (GLint un, GLdouble u1, GLdouble u2); -WINGDIAPI void APIENTRY glMapGrid1f (GLint un, GLfloat u1, GLfloat u2); -WINGDIAPI void APIENTRY glMapGrid2d (GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2); -WINGDIAPI void APIENTRY glMapGrid2f (GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2); -WINGDIAPI void APIENTRY glMaterialf (GLenum face, GLenum pname, GLfloat param); -WINGDIAPI void APIENTRY glMaterialfv (GLenum face, GLenum pname, const GLfloat *params); -WINGDIAPI void APIENTRY glMateriali (GLenum face, GLenum pname, GLint param); -WINGDIAPI void APIENTRY glMaterialiv (GLenum face, GLenum pname, const GLint *params); -WINGDIAPI void APIENTRY glMatrixMode (GLenum mode); -WINGDIAPI void APIENTRY glMultMatrixd (const GLdouble *m); -WINGDIAPI void APIENTRY glMultMatrixf (const GLfloat *m); -WINGDIAPI void APIENTRY glNewList (GLuint list, GLenum mode); -WINGDIAPI void APIENTRY glNormal3b (GLbyte nx, GLbyte ny, GLbyte nz); -WINGDIAPI void APIENTRY glNormal3bv (const GLbyte *v); -WINGDIAPI void APIENTRY glNormal3d (GLdouble nx, GLdouble ny, GLdouble nz); -WINGDIAPI void APIENTRY glNormal3dv (const GLdouble *v); -WINGDIAPI void APIENTRY glNormal3f (GLfloat nx, GLfloat ny, GLfloat nz); -WINGDIAPI void APIENTRY glNormal3fv (const GLfloat *v); -WINGDIAPI void APIENTRY glNormal3i (GLint nx, GLint ny, GLint nz); -WINGDIAPI void APIENTRY glNormal3iv (const GLint *v); -WINGDIAPI void APIENTRY glNormal3s (GLshort nx, GLshort ny, GLshort nz); -WINGDIAPI void APIENTRY glNormal3sv (const GLshort *v); -WINGDIAPI void APIENTRY glNormalPointer (GLenum type, GLsizei stride, const GLvoid *pointer); -WINGDIAPI void APIENTRY glOrtho (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); -WINGDIAPI void APIENTRY glPassThrough (GLfloat token); -WINGDIAPI void APIENTRY glPixelMapfv (GLenum map, GLsizei mapsize, const GLfloat *values); -WINGDIAPI void APIENTRY glPixelMapuiv (GLenum map, GLsizei mapsize, const GLuint *values); -WINGDIAPI void APIENTRY glPixelMapusv (GLenum map, GLsizei mapsize, const GLushort *values); -WINGDIAPI void APIENTRY glPixelStoref (GLenum pname, GLfloat param); -WINGDIAPI void APIENTRY glPixelStorei (GLenum pname, GLint param); -WINGDIAPI void APIENTRY glPixelTransferf (GLenum pname, GLfloat param); -WINGDIAPI void APIENTRY glPixelTransferi (GLenum pname, GLint param); -WINGDIAPI void APIENTRY glPixelZoom (GLfloat xfactor, GLfloat yfactor); -WINGDIAPI void APIENTRY glPointSize (GLfloat size); -WINGDIAPI void APIENTRY glPolygonMode (GLenum face, GLenum mode); -WINGDIAPI void APIENTRY glPolygonOffset (GLfloat factor, GLfloat units); -WINGDIAPI void APIENTRY glPolygonStipple (const GLubyte *mask); -WINGDIAPI void APIENTRY glPopAttrib (void); -WINGDIAPI void APIENTRY glPopClientAttrib (void); -WINGDIAPI void APIENTRY glPopMatrix (void); -WINGDIAPI void APIENTRY glPopName (void); -WINGDIAPI void APIENTRY glPrioritizeTextures (GLsizei n, const GLuint *textures, const GLclampf *priorities); -WINGDIAPI void APIENTRY glPushAttrib (GLbitfield mask); -WINGDIAPI void APIENTRY glPushClientAttrib (GLbitfield mask); -WINGDIAPI void APIENTRY glPushMatrix (void); -WINGDIAPI void APIENTRY glPushName (GLuint name); -WINGDIAPI void APIENTRY glRasterPos2d (GLdouble x, GLdouble y); -WINGDIAPI void APIENTRY glRasterPos2dv (const GLdouble *v); -WINGDIAPI void APIENTRY glRasterPos2f (GLfloat x, GLfloat y); -WINGDIAPI void APIENTRY glRasterPos2fv (const GLfloat *v); -WINGDIAPI void APIENTRY glRasterPos2i (GLint x, GLint y); -WINGDIAPI void APIENTRY glRasterPos2iv (const GLint *v); -WINGDIAPI void APIENTRY glRasterPos2s (GLshort x, GLshort y); -WINGDIAPI void APIENTRY glRasterPos2sv (const GLshort *v); -WINGDIAPI void APIENTRY glRasterPos3d (GLdouble x, GLdouble y, GLdouble z); -WINGDIAPI void APIENTRY glRasterPos3dv (const GLdouble *v); -WINGDIAPI void APIENTRY glRasterPos3f (GLfloat x, GLfloat y, GLfloat z); -WINGDIAPI void APIENTRY glRasterPos3fv (const GLfloat *v); -WINGDIAPI void APIENTRY glRasterPos3i (GLint x, GLint y, GLint z); -WINGDIAPI void APIENTRY glRasterPos3iv (const GLint *v); -WINGDIAPI void APIENTRY glRasterPos3s (GLshort x, GLshort y, GLshort z); -WINGDIAPI void APIENTRY glRasterPos3sv (const GLshort *v); -WINGDIAPI void APIENTRY glRasterPos4d (GLdouble x, GLdouble y, GLdouble z, GLdouble w); -WINGDIAPI void APIENTRY glRasterPos4dv (const GLdouble *v); -WINGDIAPI void APIENTRY glRasterPos4f (GLfloat x, GLfloat y, GLfloat z, GLfloat w); -WINGDIAPI void APIENTRY glRasterPos4fv (const GLfloat *v); -WINGDIAPI void APIENTRY glRasterPos4i (GLint x, GLint y, GLint z, GLint w); -WINGDIAPI void APIENTRY glRasterPos4iv (const GLint *v); -WINGDIAPI void APIENTRY glRasterPos4s (GLshort x, GLshort y, GLshort z, GLshort w); -WINGDIAPI void APIENTRY glRasterPos4sv (const GLshort *v); -WINGDIAPI void APIENTRY glReadBuffer (GLenum mode); -WINGDIAPI void APIENTRY glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels); -WINGDIAPI void APIENTRY glRectd (GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2); -WINGDIAPI void APIENTRY glRectdv (const GLdouble *v1, const GLdouble *v2); -WINGDIAPI void APIENTRY glRectf (GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2); -WINGDIAPI void APIENTRY glRectfv (const GLfloat *v1, const GLfloat *v2); -WINGDIAPI void APIENTRY glRecti (GLint x1, GLint y1, GLint x2, GLint y2); -WINGDIAPI void APIENTRY glRectiv (const GLint *v1, const GLint *v2); -WINGDIAPI void APIENTRY glRects (GLshort x1, GLshort y1, GLshort x2, GLshort y2); -WINGDIAPI void APIENTRY glRectsv (const GLshort *v1, const GLshort *v2); -WINGDIAPI GLint APIENTRY glRenderMode (GLenum mode); -WINGDIAPI void APIENTRY glRotated (GLdouble angle, GLdouble x, GLdouble y, GLdouble z); -WINGDIAPI void APIENTRY glRotatef (GLfloat angle, GLfloat x, GLfloat y, GLfloat z); -WINGDIAPI void APIENTRY glScaled (GLdouble x, GLdouble y, GLdouble z); -WINGDIAPI void APIENTRY glScalef (GLfloat x, GLfloat y, GLfloat z); -WINGDIAPI void APIENTRY glScissor (GLint x, GLint y, GLsizei width, GLsizei height); -WINGDIAPI void APIENTRY glSelectBuffer (GLsizei size, GLuint *buffer); -WINGDIAPI void APIENTRY glShadeModel (GLenum mode); -WINGDIAPI void APIENTRY glStencilFunc (GLenum func, GLint ref, GLuint mask); -WINGDIAPI void APIENTRY glStencilMask (GLuint mask); -WINGDIAPI void APIENTRY glStencilOp (GLenum fail, GLenum zfail, GLenum zpass); -WINGDIAPI void APIENTRY glTexCoord1d (GLdouble s); -WINGDIAPI void APIENTRY glTexCoord1dv (const GLdouble *v); -WINGDIAPI void APIENTRY glTexCoord1f (GLfloat s); -WINGDIAPI void APIENTRY glTexCoord1fv (const GLfloat *v); -WINGDIAPI void APIENTRY glTexCoord1i (GLint s); -WINGDIAPI void APIENTRY glTexCoord1iv (const GLint *v); -WINGDIAPI void APIENTRY glTexCoord1s (GLshort s); -WINGDIAPI void APIENTRY glTexCoord1sv (const GLshort *v); -WINGDIAPI void APIENTRY glTexCoord2d (GLdouble s, GLdouble t); -WINGDIAPI void APIENTRY glTexCoord2dv (const GLdouble *v); -WINGDIAPI void APIENTRY glTexCoord2f (GLfloat s, GLfloat t); -WINGDIAPI void APIENTRY glTexCoord2fv (const GLfloat *v); -WINGDIAPI void APIENTRY glTexCoord2i (GLint s, GLint t); -WINGDIAPI void APIENTRY glTexCoord2iv (const GLint *v); -WINGDIAPI void APIENTRY glTexCoord2s (GLshort s, GLshort t); -WINGDIAPI void APIENTRY glTexCoord2sv (const GLshort *v); -WINGDIAPI void APIENTRY glTexCoord3d (GLdouble s, GLdouble t, GLdouble r); -WINGDIAPI void APIENTRY glTexCoord3dv (const GLdouble *v); -WINGDIAPI void APIENTRY glTexCoord3f (GLfloat s, GLfloat t, GLfloat r); -WINGDIAPI void APIENTRY glTexCoord3fv (const GLfloat *v); -WINGDIAPI void APIENTRY glTexCoord3i (GLint s, GLint t, GLint r); -WINGDIAPI void APIENTRY glTexCoord3iv (const GLint *v); -WINGDIAPI void APIENTRY glTexCoord3s (GLshort s, GLshort t, GLshort r); -WINGDIAPI void APIENTRY glTexCoord3sv (const GLshort *v); -WINGDIAPI void APIENTRY glTexCoord4d (GLdouble s, GLdouble t, GLdouble r, GLdouble q); -WINGDIAPI void APIENTRY glTexCoord4dv (const GLdouble *v); -WINGDIAPI void APIENTRY glTexCoord4f (GLfloat s, GLfloat t, GLfloat r, GLfloat q); -WINGDIAPI void APIENTRY glTexCoord4fv (const GLfloat *v); -WINGDIAPI void APIENTRY glTexCoord4i (GLint s, GLint t, GLint r, GLint q); -WINGDIAPI void APIENTRY glTexCoord4iv (const GLint *v); -WINGDIAPI void APIENTRY glTexCoord4s (GLshort s, GLshort t, GLshort r, GLshort q); -WINGDIAPI void APIENTRY glTexCoord4sv (const GLshort *v); -WINGDIAPI void APIENTRY glTexCoordPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -WINGDIAPI void APIENTRY glTexEnvf (GLenum target, GLenum pname, GLfloat param); -WINGDIAPI void APIENTRY glTexEnvfv (GLenum target, GLenum pname, const GLfloat *params); -WINGDIAPI void APIENTRY glTexEnvi (GLenum target, GLenum pname, GLint param); -WINGDIAPI void APIENTRY glTexEnviv (GLenum target, GLenum pname, const GLint *params); -WINGDIAPI void APIENTRY glTexGend (GLenum coord, GLenum pname, GLdouble param); -WINGDIAPI void APIENTRY glTexGendv (GLenum coord, GLenum pname, const GLdouble *params); -WINGDIAPI void APIENTRY glTexGenf (GLenum coord, GLenum pname, GLfloat param); -WINGDIAPI void APIENTRY glTexGenfv (GLenum coord, GLenum pname, const GLfloat *params); -WINGDIAPI void APIENTRY glTexGeni (GLenum coord, GLenum pname, GLint param); -WINGDIAPI void APIENTRY glTexGeniv (GLenum coord, GLenum pname, const GLint *params); -WINGDIAPI void APIENTRY glTexImage1D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -WINGDIAPI void APIENTRY glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -WINGDIAPI void APIENTRY glTexParameterf (GLenum target, GLenum pname, GLfloat param); -WINGDIAPI void APIENTRY glTexParameterfv (GLenum target, GLenum pname, const GLfloat *params); -WINGDIAPI void APIENTRY glTexParameteri (GLenum target, GLenum pname, GLint param); -WINGDIAPI void APIENTRY glTexParameteriv (GLenum target, GLenum pname, const GLint *params); -WINGDIAPI void APIENTRY glTexSubImage1D (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); -WINGDIAPI void APIENTRY glTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); -WINGDIAPI void APIENTRY glTranslated (GLdouble x, GLdouble y, GLdouble z); -WINGDIAPI void APIENTRY glTranslatef (GLfloat x, GLfloat y, GLfloat z); -WINGDIAPI void APIENTRY glVertex2d (GLdouble x, GLdouble y); -WINGDIAPI void APIENTRY glVertex2dv (const GLdouble *v); -WINGDIAPI void APIENTRY glVertex2f (GLfloat x, GLfloat y); -WINGDIAPI void APIENTRY glVertex2fv (const GLfloat *v); -WINGDIAPI void APIENTRY glVertex2i (GLint x, GLint y); -WINGDIAPI void APIENTRY glVertex2iv (const GLint *v); -WINGDIAPI void APIENTRY glVertex2s (GLshort x, GLshort y); -WINGDIAPI void APIENTRY glVertex2sv (const GLshort *v); -WINGDIAPI void APIENTRY glVertex3d (GLdouble x, GLdouble y, GLdouble z); -WINGDIAPI void APIENTRY glVertex3dv (const GLdouble *v); -WINGDIAPI void APIENTRY glVertex3f (GLfloat x, GLfloat y, GLfloat z); -WINGDIAPI void APIENTRY glVertex3fv (const GLfloat *v); -WINGDIAPI void APIENTRY glVertex3i (GLint x, GLint y, GLint z); -WINGDIAPI void APIENTRY glVertex3iv (const GLint *v); -WINGDIAPI void APIENTRY glVertex3s (GLshort x, GLshort y, GLshort z); -WINGDIAPI void APIENTRY glVertex3sv (const GLshort *v); -WINGDIAPI void APIENTRY glVertex4d (GLdouble x, GLdouble y, GLdouble z, GLdouble w); -WINGDIAPI void APIENTRY glVertex4dv (const GLdouble *v); -WINGDIAPI void APIENTRY glVertex4f (GLfloat x, GLfloat y, GLfloat z, GLfloat w); -WINGDIAPI void APIENTRY glVertex4fv (const GLfloat *v); -WINGDIAPI void APIENTRY glVertex4i (GLint x, GLint y, GLint z, GLint w); -WINGDIAPI void APIENTRY glVertex4iv (const GLint *v); -WINGDIAPI void APIENTRY glVertex4s (GLshort x, GLshort y, GLshort z, GLshort w); -WINGDIAPI void APIENTRY glVertex4sv (const GLshort *v); -WINGDIAPI void APIENTRY glVertexPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -WINGDIAPI void APIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei height); - -#ifdef __DEFINED_GLAPI -# undef GLAPI -# undef __DEFINED_GLAPI -#endif - -#ifndef GL_GLEXT_LEGACY -#include <GL/glext.h> -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* __gl_h_ */ diff --git a/Externals/mojoshader/1067/GL/glext.h b/Externals/mojoshader/1067/GL/glext.h deleted file mode 100644 index 4d4b3a38..00000000 --- a/Externals/mojoshader/1067/GL/glext.h +++ /dev/null @@ -1,7199 +0,0 @@ -#ifndef __glext_h_ -#define __glext_h_ - -#ifdef __cplusplus -extern "C" { -#endif - -/****************************************************************************** - - Copyright NVIDIA Corporation 2006 - - TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED - *AS IS* AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS - OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL - NVIDIA OR ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT, OR - CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR - LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, - OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR INABILITY TO USE - THIS SOFTWARE, EVEN IF NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH - DAMAGES. - -******************************************************************************/ - -/* -** License Applicability. Except to the extent portions of this file are -** made subject to an alternative license as permitted in the SGI Free -** Software License B, Version 1.1 (the "License"), the contents of this -** file are subject only to the provisions of the License. You may not use -** this file except in compliance with the License. You may obtain a copy -** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 -** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: -** -** http://oss.sgi.com/projects/FreeB -** -** Note that, as provided in the License, the Software is distributed on an -** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS -** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND -** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A -** PARTICULAR PURPOSE, AND NON-INFRINGEMENT. -** -** Original Code. The Original Code is: OpenGL Sample Implementation, -** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, -** Inc. The Original Code is Copyright (c) 1991-2004 Silicon Graphics, Inc. -** Copyright in any portions created by third parties is as indicated -** elsewhere herein. All Rights Reserved. -** -** Additional Notice Provisions: This software was created using the -** OpenGL(R) version 1.2.1 Sample Implementation published by SGI, but has -** not been independently verified as being compliant with the OpenGL(R) -** version 1.2.1 Specification. -*/ - -#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) -#define WIN32_LEAN_AND_MEAN 1 -#include <windows.h> -#endif - -#ifndef APIENTRY -#define APIENTRY -#endif -#ifndef APIENTRYP -#define APIENTRYP APIENTRY * -#endif -#ifndef extern -#define extern extern -#endif - -/*************************************************************/ - -/* Header file version number, required by OpenGL ABI for Linux */ -/* glext.h last updated 2005/06/06 */ -/* Current version at http://oss.sgi.com/projects/ogl-sample/registry/ */ -#define GL_GLEXT_VERSION 28 - -#ifndef GL_VERSION_1_2 -#define GL_UNSIGNED_BYTE_3_3_2 0x8032 -#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 -#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 -#define GL_UNSIGNED_INT_8_8_8_8 0x8035 -#define GL_UNSIGNED_INT_10_10_10_2 0x8036 -#define GL_RESCALE_NORMAL 0x803A -#define GL_TEXTURE_BINDING_3D 0x806A -#define GL_PACK_SKIP_IMAGES 0x806B -#define GL_PACK_IMAGE_HEIGHT 0x806C -#define GL_UNPACK_SKIP_IMAGES 0x806D -#define GL_UNPACK_IMAGE_HEIGHT 0x806E -#define GL_TEXTURE_3D 0x806F -#define GL_PROXY_TEXTURE_3D 0x8070 -#define GL_TEXTURE_DEPTH 0x8071 -#define GL_TEXTURE_WRAP_R 0x8072 -#define GL_MAX_3D_TEXTURE_SIZE 0x8073 -#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362 -#define GL_UNSIGNED_SHORT_5_6_5 0x8363 -#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364 -#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365 -#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 -#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367 -#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 -#define GL_BGR 0x80E0 -#define GL_BGRA 0x80E1 -#define GL_MAX_ELEMENTS_VERTICES 0x80E8 -#define GL_MAX_ELEMENTS_INDICES 0x80E9 -#define GL_CLAMP_TO_EDGE 0x812F -#define GL_TEXTURE_MIN_LOD 0x813A -#define GL_TEXTURE_MAX_LOD 0x813B -#define GL_TEXTURE_BASE_LEVEL 0x813C -#define GL_TEXTURE_MAX_LEVEL 0x813D -#define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8 -#define GL_SINGLE_COLOR 0x81F9 -#define GL_SEPARATE_SPECULAR_COLOR 0x81FA -#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12 -#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13 -#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22 -#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23 -#define GL_ALIASED_POINT_SIZE_RANGE 0x846D -#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E -#endif - -#ifndef GL_ARB_imaging -#define GL_CONSTANT_COLOR 0x8001 -#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 -#define GL_CONSTANT_ALPHA 0x8003 -#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 -#define GL_BLEND_COLOR 0x8005 -#define GL_FUNC_ADD 0x8006 -#define GL_MIN 0x8007 -#define GL_MAX 0x8008 -#define GL_BLEND_EQUATION 0x8009 -#define GL_FUNC_SUBTRACT 0x800A -#define GL_FUNC_REVERSE_SUBTRACT 0x800B -#define GL_CONVOLUTION_1D 0x8010 -#define GL_CONVOLUTION_2D 0x8011 -#define GL_SEPARABLE_2D 0x8012 -#define GL_CONVOLUTION_BORDER_MODE 0x8013 -#define GL_CONVOLUTION_FILTER_SCALE 0x8014 -#define GL_CONVOLUTION_FILTER_BIAS 0x8015 -#define GL_REDUCE 0x8016 -#define GL_CONVOLUTION_FORMAT 0x8017 -#define GL_CONVOLUTION_WIDTH 0x8018 -#define GL_CONVOLUTION_HEIGHT 0x8019 -#define GL_MAX_CONVOLUTION_WIDTH 0x801A -#define GL_MAX_CONVOLUTION_HEIGHT 0x801B -#define GL_POST_CONVOLUTION_RED_SCALE 0x801C -#define GL_POST_CONVOLUTION_GREEN_SCALE 0x801D -#define GL_POST_CONVOLUTION_BLUE_SCALE 0x801E -#define GL_POST_CONVOLUTION_ALPHA_SCALE 0x801F -#define GL_POST_CONVOLUTION_RED_BIAS 0x8020 -#define GL_POST_CONVOLUTION_GREEN_BIAS 0x8021 -#define GL_POST_CONVOLUTION_BLUE_BIAS 0x8022 -#define GL_POST_CONVOLUTION_ALPHA_BIAS 0x8023 -#define GL_HISTOGRAM 0x8024 -#define GL_PROXY_HISTOGRAM 0x8025 -#define GL_HISTOGRAM_WIDTH 0x8026 -#define GL_HISTOGRAM_FORMAT 0x8027 -#define GL_HISTOGRAM_RED_SIZE 0x8028 -#define GL_HISTOGRAM_GREEN_SIZE 0x8029 -#define GL_HISTOGRAM_BLUE_SIZE 0x802A -#define GL_HISTOGRAM_ALPHA_SIZE 0x802B -#define GL_HISTOGRAM_LUMINANCE_SIZE 0x802C -#define GL_HISTOGRAM_SINK 0x802D -#define GL_MINMAX 0x802E -#define GL_MINMAX_FORMAT 0x802F -#define GL_MINMAX_SINK 0x8030 -#define GL_TABLE_TOO_LARGE 0x8031 -#define GL_COLOR_MATRIX 0x80B1 -#define GL_COLOR_MATRIX_STACK_DEPTH 0x80B2 -#define GL_MAX_COLOR_MATRIX_STACK_DEPTH 0x80B3 -#define GL_POST_COLOR_MATRIX_RED_SCALE 0x80B4 -#define GL_POST_COLOR_MATRIX_GREEN_SCALE 0x80B5 -#define GL_POST_COLOR_MATRIX_BLUE_SCALE 0x80B6 -#define GL_POST_COLOR_MATRIX_ALPHA_SCALE 0x80B7 -#define GL_POST_COLOR_MATRIX_RED_BIAS 0x80B8 -#define GL_POST_COLOR_MATRIX_GREEN_BIAS 0x80B9 -#define GL_POST_COLOR_MATRIX_BLUE_BIAS 0x80BA -#define GL_POST_COLOR_MATRIX_ALPHA_BIAS 0x80BB -#define GL_COLOR_TABLE 0x80D0 -#define GL_POST_CONVOLUTION_COLOR_TABLE 0x80D1 -#define GL_POST_COLOR_MATRIX_COLOR_TABLE 0x80D2 -#define GL_PROXY_COLOR_TABLE 0x80D3 -#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE 0x80D4 -#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE 0x80D5 -#define GL_COLOR_TABLE_SCALE 0x80D6 -#define GL_COLOR_TABLE_BIAS 0x80D7 -#define GL_COLOR_TABLE_FORMAT 0x80D8 -#define GL_COLOR_TABLE_WIDTH 0x80D9 -#define GL_COLOR_TABLE_RED_SIZE 0x80DA -#define GL_COLOR_TABLE_GREEN_SIZE 0x80DB -#define GL_COLOR_TABLE_BLUE_SIZE 0x80DC -#define GL_COLOR_TABLE_ALPHA_SIZE 0x80DD -#define GL_COLOR_TABLE_LUMINANCE_SIZE 0x80DE -#define GL_COLOR_TABLE_INTENSITY_SIZE 0x80DF -#define GL_CONSTANT_BORDER 0x8151 -#define GL_REPLICATE_BORDER 0x8153 -#define GL_CONVOLUTION_BORDER_COLOR 0x8154 -#endif - -#ifndef GL_VERSION_1_3 -#define GL_TEXTURE0 0x84C0 -#define GL_TEXTURE1 0x84C1 -#define GL_TEXTURE2 0x84C2 -#define GL_TEXTURE3 0x84C3 -#define GL_TEXTURE4 0x84C4 -#define GL_TEXTURE5 0x84C5 -#define GL_TEXTURE6 0x84C6 -#define GL_TEXTURE7 0x84C7 -#define GL_TEXTURE8 0x84C8 -#define GL_TEXTURE9 0x84C9 -#define GL_TEXTURE10 0x84CA -#define GL_TEXTURE11 0x84CB -#define GL_TEXTURE12 0x84CC -#define GL_TEXTURE13 0x84CD -#define GL_TEXTURE14 0x84CE -#define GL_TEXTURE15 0x84CF -#define GL_TEXTURE16 0x84D0 -#define GL_TEXTURE17 0x84D1 -#define GL_TEXTURE18 0x84D2 -#define GL_TEXTURE19 0x84D3 -#define GL_TEXTURE20 0x84D4 -#define GL_TEXTURE21 0x84D5 -#define GL_TEXTURE22 0x84D6 -#define GL_TEXTURE23 0x84D7 -#define GL_TEXTURE24 0x84D8 -#define GL_TEXTURE25 0x84D9 -#define GL_TEXTURE26 0x84DA -#define GL_TEXTURE27 0x84DB -#define GL_TEXTURE28 0x84DC -#define GL_TEXTURE29 0x84DD -#define GL_TEXTURE30 0x84DE -#define GL_TEXTURE31 0x84DF -#define GL_ACTIVE_TEXTURE 0x84E0 -#define GL_CLIENT_ACTIVE_TEXTURE 0x84E1 -#define GL_MAX_TEXTURE_UNITS 0x84E2 -#define GL_TRANSPOSE_MODELVIEW_MATRIX 0x84E3 -#define GL_TRANSPOSE_PROJECTION_MATRIX 0x84E4 -#define GL_TRANSPOSE_TEXTURE_MATRIX 0x84E5 -#define GL_TRANSPOSE_COLOR_MATRIX 0x84E6 -#define GL_MULTISAMPLE 0x809D -#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E -#define GL_SAMPLE_ALPHA_TO_ONE 0x809F -#define GL_SAMPLE_COVERAGE 0x80A0 -#define GL_SAMPLE_BUFFERS 0x80A8 -#define GL_SAMPLES 0x80A9 -#define GL_SAMPLE_COVERAGE_VALUE 0x80AA -#define GL_SAMPLE_COVERAGE_INVERT 0x80AB -#define GL_MULTISAMPLE_BIT 0x20000000 -#define GL_NORMAL_MAP 0x8511 -#define GL_REFLECTION_MAP 0x8512 -#define GL_TEXTURE_CUBE_MAP 0x8513 -#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A -#define GL_PROXY_TEXTURE_CUBE_MAP 0x851B -#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C -#define GL_COMPRESSED_ALPHA 0x84E9 -#define GL_COMPRESSED_LUMINANCE 0x84EA -#define GL_COMPRESSED_LUMINANCE_ALPHA 0x84EB -#define GL_COMPRESSED_INTENSITY 0x84EC -#define GL_COMPRESSED_RGB 0x84ED -#define GL_COMPRESSED_RGBA 0x84EE -#define GL_TEXTURE_COMPRESSION_HINT 0x84EF -#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0 -#define GL_TEXTURE_COMPRESSED 0x86A1 -#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 -#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 -#define GL_CLAMP_TO_BORDER 0x812D -#define GL_COMBINE 0x8570 -#define GL_COMBINE_RGB 0x8571 -#define GL_COMBINE_ALPHA 0x8572 -#define GL_SOURCE0_RGB 0x8580 -#define GL_SOURCE1_RGB 0x8581 -#define GL_SOURCE2_RGB 0x8582 -#define GL_SOURCE0_ALPHA 0x8588 -#define GL_SOURCE1_ALPHA 0x8589 -#define GL_SOURCE2_ALPHA 0x858A -#define GL_OPERAND0_RGB 0x8590 -#define GL_OPERAND1_RGB 0x8591 -#define GL_OPERAND2_RGB 0x8592 -#define GL_OPERAND0_ALPHA 0x8598 -#define GL_OPERAND1_ALPHA 0x8599 -#define GL_OPERAND2_ALPHA 0x859A -#define GL_RGB_SCALE 0x8573 -#define GL_ADD_SIGNED 0x8574 -#define GL_INTERPOLATE 0x8575 -#define GL_SUBTRACT 0x84E7 -#define GL_CONSTANT 0x8576 -#define GL_PRIMARY_COLOR 0x8577 -#define GL_PREVIOUS 0x8578 -#define GL_DOT3_RGB 0x86AE -#define GL_DOT3_RGBA 0x86AF -#endif - -#ifndef GL_VERSION_1_4 -#define GL_BLEND_DST_RGB 0x80C8 -#define GL_BLEND_SRC_RGB 0x80C9 -#define GL_BLEND_DST_ALPHA 0x80CA -#define GL_BLEND_SRC_ALPHA 0x80CB -#define GL_POINT_SIZE_MIN 0x8126 -#define GL_POINT_SIZE_MAX 0x8127 -#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128 -#define GL_POINT_DISTANCE_ATTENUATION 0x8129 -#define GL_GENERATE_MIPMAP 0x8191 -#define GL_GENERATE_MIPMAP_HINT 0x8192 -#define GL_DEPTH_COMPONENT16 0x81A5 -#define GL_DEPTH_COMPONENT24 0x81A6 -#define GL_DEPTH_COMPONENT32 0x81A7 -#define GL_MIRRORED_REPEAT 0x8370 -#define GL_FOG_COORDINATE_SOURCE 0x8450 -#define GL_FOG_COORDINATE 0x8451 -#define GL_FRAGMENT_DEPTH 0x8452 -#define GL_CURRENT_FOG_COORDINATE 0x8453 -#define GL_FOG_COORDINATE_ARRAY_TYPE 0x8454 -#define GL_FOG_COORDINATE_ARRAY_STRIDE 0x8455 -#define GL_FOG_COORDINATE_ARRAY_POINTER 0x8456 -#define GL_FOG_COORDINATE_ARRAY 0x8457 -#define GL_COLOR_SUM 0x8458 -#define GL_CURRENT_SECONDARY_COLOR 0x8459 -#define GL_SECONDARY_COLOR_ARRAY_SIZE 0x845A -#define GL_SECONDARY_COLOR_ARRAY_TYPE 0x845B -#define GL_SECONDARY_COLOR_ARRAY_STRIDE 0x845C -#define GL_SECONDARY_COLOR_ARRAY_POINTER 0x845D -#define GL_SECONDARY_COLOR_ARRAY 0x845E -#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD -#define GL_TEXTURE_FILTER_CONTROL 0x8500 -#define GL_TEXTURE_LOD_BIAS 0x8501 -#define GL_INCR_WRAP 0x8507 -#define GL_DECR_WRAP 0x8508 -#define GL_TEXTURE_DEPTH_SIZE 0x884A -#define GL_DEPTH_TEXTURE_MODE 0x884B -#define GL_TEXTURE_COMPARE_MODE 0x884C -#define GL_TEXTURE_COMPARE_FUNC 0x884D -#define GL_COMPARE_R_TO_TEXTURE 0x884E -#endif - -#ifndef GL_VERSION_1_5 -#define GL_BUFFER_SIZE 0x8764 -#define GL_BUFFER_USAGE 0x8765 -#define GL_QUERY_COUNTER_BITS 0x8864 -#define GL_CURRENT_QUERY 0x8865 -#define GL_QUERY_RESULT 0x8866 -#define GL_QUERY_RESULT_AVAILABLE 0x8867 -#define GL_ARRAY_BUFFER 0x8892 -#define GL_ELEMENT_ARRAY_BUFFER 0x8893 -#define GL_ARRAY_BUFFER_BINDING 0x8894 -#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 -#define GL_VERTEX_ARRAY_BUFFER_BINDING 0x8896 -#define GL_NORMAL_ARRAY_BUFFER_BINDING 0x8897 -#define GL_COLOR_ARRAY_BUFFER_BINDING 0x8898 -#define GL_INDEX_ARRAY_BUFFER_BINDING 0x8899 -#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING 0x889A -#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING 0x889B -#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING 0x889C -#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING 0x889D -#define GL_WEIGHT_ARRAY_BUFFER_BINDING 0x889E -#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F -#define GL_READ_ONLY 0x88B8 -#define GL_WRITE_ONLY 0x88B9 -#define GL_READ_WRITE 0x88BA -#define GL_BUFFER_ACCESS 0x88BB -#define GL_BUFFER_MAPPED 0x88BC -#define GL_BUFFER_MAP_POINTER 0x88BD -#define GL_STREAM_DRAW 0x88E0 -#define GL_STREAM_READ 0x88E1 -#define GL_STREAM_COPY 0x88E2 -#define GL_STATIC_DRAW 0x88E4 -#define GL_STATIC_READ 0x88E5 -#define GL_STATIC_COPY 0x88E6 -#define GL_DYNAMIC_DRAW 0x88E8 -#define GL_DYNAMIC_READ 0x88E9 -#define GL_DYNAMIC_COPY 0x88EA -#define GL_SAMPLES_PASSED 0x8914 -#define GL_FOG_COORD_SRC GL_FOG_COORDINATE_SOURCE -#define GL_FOG_COORD GL_FOG_COORDINATE -#define GL_CURRENT_FOG_COORD GL_CURRENT_FOG_COORDINATE -#define GL_FOG_COORD_ARRAY_TYPE GL_FOG_COORDINATE_ARRAY_TYPE -#define GL_FOG_COORD_ARRAY_STRIDE GL_FOG_COORDINATE_ARRAY_STRIDE -#define GL_FOG_COORD_ARRAY_POINTER GL_FOG_COORDINATE_ARRAY_POINTER -#define GL_FOG_COORD_ARRAY GL_FOG_COORDINATE_ARRAY -#define GL_FOG_COORD_ARRAY_BUFFER_BINDING GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING -#define GL_SRC0_RGB GL_SOURCE0_RGB -#define GL_SRC1_RGB GL_SOURCE1_RGB -#define GL_SRC2_RGB GL_SOURCE2_RGB -#define GL_SRC0_ALPHA GL_SOURCE0_ALPHA -#define GL_SRC1_ALPHA GL_SOURCE1_ALPHA -#define GL_SRC2_ALPHA GL_SOURCE2_ALPHA -#endif - -#ifndef GL_VERSION_2_0 -#define GL_BLEND_EQUATION_RGB GL_BLEND_EQUATION -#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 -#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 -#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 -#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 -#define GL_CURRENT_VERTEX_ATTRIB 0x8626 -#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642 -#define GL_VERTEX_PROGRAM_TWO_SIDE 0x8643 -#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 -#define GL_STENCIL_BACK_FUNC 0x8800 -#define GL_STENCIL_BACK_FAIL 0x8801 -#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 -#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 -#define GL_MAX_DRAW_BUFFERS 0x8824 -#define GL_DRAW_BUFFER0 0x8825 -#define GL_DRAW_BUFFER1 0x8826 -#define GL_DRAW_BUFFER2 0x8827 -#define GL_DRAW_BUFFER3 0x8828 -#define GL_DRAW_BUFFER4 0x8829 -#define GL_DRAW_BUFFER5 0x882A -#define GL_DRAW_BUFFER6 0x882B -#define GL_DRAW_BUFFER7 0x882C -#define GL_DRAW_BUFFER8 0x882D -#define GL_DRAW_BUFFER9 0x882E -#define GL_DRAW_BUFFER10 0x882F -#define GL_DRAW_BUFFER11 0x8830 -#define GL_DRAW_BUFFER12 0x8831 -#define GL_DRAW_BUFFER13 0x8832 -#define GL_DRAW_BUFFER14 0x8833 -#define GL_DRAW_BUFFER15 0x8834 -#define GL_BLEND_EQUATION_ALPHA 0x883D -#define GL_POINT_SPRITE 0x8861 -#define GL_COORD_REPLACE 0x8862 -#define GL_MAX_VERTEX_ATTRIBS 0x8869 -#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A -#define GL_MAX_TEXTURE_COORDS 0x8871 -#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 -#define GL_FRAGMENT_SHADER 0x8B30 -#define GL_VERTEX_SHADER 0x8B31 -#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49 -#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A -#define GL_MAX_VARYING_FLOATS 0x8B4B -#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C -#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D -#define GL_SHADER_TYPE 0x8B4F -#define GL_FLOAT_VEC2 0x8B50 -#define GL_FLOAT_VEC3 0x8B51 -#define GL_FLOAT_VEC4 0x8B52 -#define GL_INT_VEC2 0x8B53 -#define GL_INT_VEC3 0x8B54 -#define GL_INT_VEC4 0x8B55 -#define GL_BOOL 0x8B56 -#define GL_BOOL_VEC2 0x8B57 -#define GL_BOOL_VEC3 0x8B58 -#define GL_BOOL_VEC4 0x8B59 -#define GL_FLOAT_MAT2 0x8B5A -#define GL_FLOAT_MAT3 0x8B5B -#define GL_FLOAT_MAT4 0x8B5C -#define GL_SAMPLER_1D 0x8B5D -#define GL_SAMPLER_2D 0x8B5E -#define GL_SAMPLER_3D 0x8B5F -#define GL_SAMPLER_CUBE 0x8B60 -#define GL_SAMPLER_1D_SHADOW 0x8B61 -#define GL_SAMPLER_2D_SHADOW 0x8B62 -#define GL_DELETE_STATUS 0x8B80 -#define GL_COMPILE_STATUS 0x8B81 -#define GL_LINK_STATUS 0x8B82 -#define GL_VALIDATE_STATUS 0x8B83 -#define GL_INFO_LOG_LENGTH 0x8B84 -#define GL_ATTACHED_SHADERS 0x8B85 -#define GL_ACTIVE_UNIFORMS 0x8B86 -#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 -#define GL_SHADER_SOURCE_LENGTH 0x8B88 -#define GL_ACTIVE_ATTRIBUTES 0x8B89 -#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A -#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B -#define GL_SHADING_LANGUAGE_VERSION 0x8B8C -#define GL_CURRENT_PROGRAM 0x8B8D -#define GL_POINT_SPRITE_COORD_ORIGIN 0x8CA0 -#define GL_LOWER_LEFT 0x8CA1 -#define GL_UPPER_LEFT 0x8CA2 -#define GL_STENCIL_BACK_REF 0x8CA3 -#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 -#define GL_STENCIL_BACK_WRITEMASK 0x8CA5 -#endif - -#ifndef GL_VERSION_2_1 -#define GL_PIXEL_PACK_BUFFER 0x88EB -#define GL_PIXEL_UNPACK_BUFFER 0x88EC -#define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED -#define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF -#define GL_SRGB 0x8C40 -#define GL_SRGB8 0x8C41 -#define GL_SRGB_ALPHA 0x8C42 -#define GL_SRGB8_ALPHA8 0x8C43 -#define GL_SLUMINANCE_ALPHA 0x8C44 -#define GL_SLUMINANCE8_ALPHA8 0x8C45 -#define GL_SLUMINANCE 0x8C46 -#define GL_SLUMINANCE8 0x8C47 -#define GL_COMPRESSED_SRGB 0x8C48 -#define GL_COMPRESSED_SRGB_ALPHA 0x8C49 -#define GL_COMPRESSED_SLUMINANCE 0x8C4A -#define GL_COMPRESSED_SLUMINANCE_ALPHA 0x8C4B -#define GL_FLOAT_MAT2x3 0x8B65 -#define GL_FLOAT_MAT2x4 0x8B66 -#define GL_FLOAT_MAT3x2 0x8B67 -#define GL_FLOAT_MAT3x4 0x8B68 -#define GL_FLOAT_MAT4x2 0x8B69 -#define GL_FLOAT_MAT4x3 0x8B6A -#define GL_CURRENT_RASTER_SECONDARY_COLOR 0x845F -#endif - -#ifndef GL_ARB_multitexture -#define GL_TEXTURE0_ARB 0x84C0 -#define GL_TEXTURE1_ARB 0x84C1 -#define GL_TEXTURE2_ARB 0x84C2 -#define GL_TEXTURE3_ARB 0x84C3 -#define GL_TEXTURE4_ARB 0x84C4 -#define GL_TEXTURE5_ARB 0x84C5 -#define GL_TEXTURE6_ARB 0x84C6 -#define GL_TEXTURE7_ARB 0x84C7 -#define GL_TEXTURE8_ARB 0x84C8 -#define GL_TEXTURE9_ARB 0x84C9 -#define GL_TEXTURE10_ARB 0x84CA -#define GL_TEXTURE11_ARB 0x84CB -#define GL_TEXTURE12_ARB 0x84CC -#define GL_TEXTURE13_ARB 0x84CD -#define GL_TEXTURE14_ARB 0x84CE -#define GL_TEXTURE15_ARB 0x84CF -#define GL_TEXTURE16_ARB 0x84D0 -#define GL_TEXTURE17_ARB 0x84D1 -#define GL_TEXTURE18_ARB 0x84D2 -#define GL_TEXTURE19_ARB 0x84D3 -#define GL_TEXTURE20_ARB 0x84D4 -#define GL_TEXTURE21_ARB 0x84D5 -#define GL_TEXTURE22_ARB 0x84D6 -#define GL_TEXTURE23_ARB 0x84D7 -#define GL_TEXTURE24_ARB 0x84D8 -#define GL_TEXTURE25_ARB 0x84D9 -#define GL_TEXTURE26_ARB 0x84DA -#define GL_TEXTURE27_ARB 0x84DB -#define GL_TEXTURE28_ARB 0x84DC -#define GL_TEXTURE29_ARB 0x84DD -#define GL_TEXTURE30_ARB 0x84DE -#define GL_TEXTURE31_ARB 0x84DF -#define GL_ACTIVE_TEXTURE_ARB 0x84E0 -#define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1 -#define GL_MAX_TEXTURE_UNITS_ARB 0x84E2 -#endif - -#ifndef GL_ARB_transpose_matrix -#define GL_TRANSPOSE_MODELVIEW_MATRIX_ARB 0x84E3 -#define GL_TRANSPOSE_PROJECTION_MATRIX_ARB 0x84E4 -#define GL_TRANSPOSE_TEXTURE_MATRIX_ARB 0x84E5 -#define GL_TRANSPOSE_COLOR_MATRIX_ARB 0x84E6 -#endif - -#ifndef GL_ARB_multisample -#define GL_MULTISAMPLE_ARB 0x809D -#define GL_SAMPLE_ALPHA_TO_COVERAGE_ARB 0x809E -#define GL_SAMPLE_ALPHA_TO_ONE_ARB 0x809F -#define GL_SAMPLE_COVERAGE_ARB 0x80A0 -#define GL_SAMPLE_BUFFERS_ARB 0x80A8 -#define GL_SAMPLES_ARB 0x80A9 -#define GL_SAMPLE_COVERAGE_VALUE_ARB 0x80AA -#define GL_SAMPLE_COVERAGE_INVERT_ARB 0x80AB -#define GL_MULTISAMPLE_BIT_ARB 0x20000000 -#endif - -#ifndef GL_ARB_texture_env_add -#endif - -#ifndef GL_ARB_texture_cube_map -#define GL_NORMAL_MAP_ARB 0x8511 -#define GL_REFLECTION_MAP_ARB 0x8512 -#define GL_TEXTURE_CUBE_MAP_ARB 0x8513 -#define GL_TEXTURE_BINDING_CUBE_MAP_ARB 0x8514 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x8515 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x8516 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x8517 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x8518 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x8519 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x851A -#define GL_PROXY_TEXTURE_CUBE_MAP_ARB 0x851B -#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB 0x851C -#endif - -#ifndef GL_ARB_texture_compression -#define GL_COMPRESSED_ALPHA_ARB 0x84E9 -#define GL_COMPRESSED_LUMINANCE_ARB 0x84EA -#define GL_COMPRESSED_LUMINANCE_ALPHA_ARB 0x84EB -#define GL_COMPRESSED_INTENSITY_ARB 0x84EC -#define GL_COMPRESSED_RGB_ARB 0x84ED -#define GL_COMPRESSED_RGBA_ARB 0x84EE -#define GL_TEXTURE_COMPRESSION_HINT_ARB 0x84EF -#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB 0x86A0 -#define GL_TEXTURE_COMPRESSED_ARB 0x86A1 -#define GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A2 -#define GL_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A3 -#endif - -#ifndef GL_ARB_texture_border_clamp -#define GL_CLAMP_TO_BORDER_ARB 0x812D -#endif - -#ifndef GL_ARB_point_parameters -#define GL_POINT_SIZE_MIN_ARB 0x8126 -#define GL_POINT_SIZE_MAX_ARB 0x8127 -#define GL_POINT_FADE_THRESHOLD_SIZE_ARB 0x8128 -#define GL_POINT_DISTANCE_ATTENUATION_ARB 0x8129 -#endif - -#ifndef GL_ARB_vertex_blend -#define GL_MAX_VERTEX_UNITS_ARB 0x86A4 -#define GL_ACTIVE_VERTEX_UNITS_ARB 0x86A5 -#define GL_WEIGHT_SUM_UNITY_ARB 0x86A6 -#define GL_VERTEX_BLEND_ARB 0x86A7 -#define GL_CURRENT_WEIGHT_ARB 0x86A8 -#define GL_WEIGHT_ARRAY_TYPE_ARB 0x86A9 -#define GL_WEIGHT_ARRAY_STRIDE_ARB 0x86AA -#define GL_WEIGHT_ARRAY_SIZE_ARB 0x86AB -#define GL_WEIGHT_ARRAY_POINTER_ARB 0x86AC -#define GL_WEIGHT_ARRAY_ARB 0x86AD -#define GL_MODELVIEW0_ARB 0x1700 -#define GL_MODELVIEW1_ARB 0x850A -#define GL_MODELVIEW2_ARB 0x8722 -#define GL_MODELVIEW3_ARB 0x8723 -#define GL_MODELVIEW4_ARB 0x8724 -#define GL_MODELVIEW5_ARB 0x8725 -#define GL_MODELVIEW6_ARB 0x8726 -#define GL_MODELVIEW7_ARB 0x8727 -#define GL_MODELVIEW8_ARB 0x8728 -#define GL_MODELVIEW9_ARB 0x8729 -#define GL_MODELVIEW10_ARB 0x872A -#define GL_MODELVIEW11_ARB 0x872B -#define GL_MODELVIEW12_ARB 0x872C -#define GL_MODELVIEW13_ARB 0x872D -#define GL_MODELVIEW14_ARB 0x872E -#define GL_MODELVIEW15_ARB 0x872F -#define GL_MODELVIEW16_ARB 0x8730 -#define GL_MODELVIEW17_ARB 0x8731 -#define GL_MODELVIEW18_ARB 0x8732 -#define GL_MODELVIEW19_ARB 0x8733 -#define GL_MODELVIEW20_ARB 0x8734 -#define GL_MODELVIEW21_ARB 0x8735 -#define GL_MODELVIEW22_ARB 0x8736 -#define GL_MODELVIEW23_ARB 0x8737 -#define GL_MODELVIEW24_ARB 0x8738 -#define GL_MODELVIEW25_ARB 0x8739 -#define GL_MODELVIEW26_ARB 0x873A -#define GL_MODELVIEW27_ARB 0x873B -#define GL_MODELVIEW28_ARB 0x873C -#define GL_MODELVIEW29_ARB 0x873D -#define GL_MODELVIEW30_ARB 0x873E -#define GL_MODELVIEW31_ARB 0x873F -#endif - -#ifndef GL_ARB_matrix_palette -#define GL_MATRIX_PALETTE_ARB 0x8840 -#define GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB 0x8841 -#define GL_MAX_PALETTE_MATRICES_ARB 0x8842 -#define GL_CURRENT_PALETTE_MATRIX_ARB 0x8843 -#define GL_MATRIX_INDEX_ARRAY_ARB 0x8844 -#define GL_CURRENT_MATRIX_INDEX_ARB 0x8845 -#define GL_MATRIX_INDEX_ARRAY_SIZE_ARB 0x8846 -#define GL_MATRIX_INDEX_ARRAY_TYPE_ARB 0x8847 -#define GL_MATRIX_INDEX_ARRAY_STRIDE_ARB 0x8848 -#define GL_MATRIX_INDEX_ARRAY_POINTER_ARB 0x8849 -#endif - -#ifndef GL_ARB_texture_env_combine -#define GL_COMBINE_ARB 0x8570 -#define GL_COMBINE_RGB_ARB 0x8571 -#define GL_COMBINE_ALPHA_ARB 0x8572 -#define GL_SOURCE0_RGB_ARB 0x8580 -#define GL_SOURCE1_RGB_ARB 0x8581 -#define GL_SOURCE2_RGB_ARB 0x8582 -#define GL_SOURCE0_ALPHA_ARB 0x8588 -#define GL_SOURCE1_ALPHA_ARB 0x8589 -#define GL_SOURCE2_ALPHA_ARB 0x858A -#define GL_OPERAND0_RGB_ARB 0x8590 -#define GL_OPERAND1_RGB_ARB 0x8591 -#define GL_OPERAND2_RGB_ARB 0x8592 -#define GL_OPERAND0_ALPHA_ARB 0x8598 -#define GL_OPERAND1_ALPHA_ARB 0x8599 -#define GL_OPERAND2_ALPHA_ARB 0x859A -#define GL_RGB_SCALE_ARB 0x8573 -#define GL_ADD_SIGNED_ARB 0x8574 -#define GL_INTERPOLATE_ARB 0x8575 -#define GL_SUBTRACT_ARB 0x84E7 -#define GL_CONSTANT_ARB 0x8576 -#define GL_PRIMARY_COLOR_ARB 0x8577 -#define GL_PREVIOUS_ARB 0x8578 -#endif - -#ifndef GL_ARB_texture_env_crossbar -#endif - -#ifndef GL_ARB_texture_env_dot3 -#define GL_DOT3_RGB_ARB 0x86AE -#define GL_DOT3_RGBA_ARB 0x86AF -#endif - -#ifndef GL_ARB_texture_mirrored_repeat -#define GL_MIRRORED_REPEAT_ARB 0x8370 -#endif - -#ifndef GL_ARB_depth_texture -#define GL_DEPTH_COMPONENT16_ARB 0x81A5 -#define GL_DEPTH_COMPONENT24_ARB 0x81A6 -#define GL_DEPTH_COMPONENT32_ARB 0x81A7 -#define GL_TEXTURE_DEPTH_SIZE_ARB 0x884A -#define GL_DEPTH_TEXTURE_MODE_ARB 0x884B -#endif - -#ifndef GL_ARB_shadow -#define GL_TEXTURE_COMPARE_MODE_ARB 0x884C -#define GL_TEXTURE_COMPARE_FUNC_ARB 0x884D -#define GL_COMPARE_R_TO_TEXTURE_ARB 0x884E -#endif - -#ifndef GL_ARB_shadow_ambient -#define GL_TEXTURE_COMPARE_FAIL_VALUE_ARB 0x80BF -#endif - -#ifndef GL_ARB_window_pos -#endif - -#ifndef GL_ARB_vertex_program -#define GL_COLOR_SUM_ARB 0x8458 -#define GL_VERTEX_PROGRAM_ARB 0x8620 -#define GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB 0x8622 -#define GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB 0x8623 -#define GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB 0x8624 -#define GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB 0x8625 -#define GL_CURRENT_VERTEX_ATTRIB_ARB 0x8626 -#define GL_PROGRAM_LENGTH_ARB 0x8627 -#define GL_PROGRAM_STRING_ARB 0x8628 -#define GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB 0x862E -#define GL_MAX_PROGRAM_MATRICES_ARB 0x862F -#define GL_CURRENT_MATRIX_STACK_DEPTH_ARB 0x8640 -#define GL_CURRENT_MATRIX_ARB 0x8641 -#define GL_VERTEX_PROGRAM_POINT_SIZE_ARB 0x8642 -#define GL_VERTEX_PROGRAM_TWO_SIDE_ARB 0x8643 -#define GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB 0x8645 -#define GL_PROGRAM_ERROR_POSITION_ARB 0x864B -#define GL_PROGRAM_BINDING_ARB 0x8677 -#define GL_MAX_VERTEX_ATTRIBS_ARB 0x8869 -#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB 0x886A -#define GL_PROGRAM_ERROR_STRING_ARB 0x8874 -#define GL_PROGRAM_FORMAT_ASCII_ARB 0x8875 -#define GL_PROGRAM_FORMAT_ARB 0x8876 -#define GL_PROGRAM_INSTRUCTIONS_ARB 0x88A0 -#define GL_MAX_PROGRAM_INSTRUCTIONS_ARB 0x88A1 -#define GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A2 -#define GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A3 -#define GL_PROGRAM_TEMPORARIES_ARB 0x88A4 -#define GL_MAX_PROGRAM_TEMPORARIES_ARB 0x88A5 -#define GL_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A6 -#define GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A7 -#define GL_PROGRAM_PARAMETERS_ARB 0x88A8 -#define GL_MAX_PROGRAM_PARAMETERS_ARB 0x88A9 -#define GL_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AA -#define GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AB -#define GL_PROGRAM_ATTRIBS_ARB 0x88AC -#define GL_MAX_PROGRAM_ATTRIBS_ARB 0x88AD -#define GL_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AE -#define GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AF -#define GL_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B0 -#define GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B1 -#define GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B2 -#define GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B3 -#define GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB 0x88B4 -#define GL_MAX_PROGRAM_ENV_PARAMETERS_ARB 0x88B5 -#define GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB 0x88B6 -#define GL_TRANSPOSE_CURRENT_MATRIX_ARB 0x88B7 -#define GL_MATRIX0_ARB 0x88C0 -#define GL_MATRIX1_ARB 0x88C1 -#define GL_MATRIX2_ARB 0x88C2 -#define GL_MATRIX3_ARB 0x88C3 -#define GL_MATRIX4_ARB 0x88C4 -#define GL_MATRIX5_ARB 0x88C5 -#define GL_MATRIX6_ARB 0x88C6 -#define GL_MATRIX7_ARB 0x88C7 -#define GL_MATRIX8_ARB 0x88C8 -#define GL_MATRIX9_ARB 0x88C9 -#define GL_MATRIX10_ARB 0x88CA -#define GL_MATRIX11_ARB 0x88CB -#define GL_MATRIX12_ARB 0x88CC -#define GL_MATRIX13_ARB 0x88CD -#define GL_MATRIX14_ARB 0x88CE -#define GL_MATRIX15_ARB 0x88CF -#define GL_MATRIX16_ARB 0x88D0 -#define GL_MATRIX17_ARB 0x88D1 -#define GL_MATRIX18_ARB 0x88D2 -#define GL_MATRIX19_ARB 0x88D3 -#define GL_MATRIX20_ARB 0x88D4 -#define GL_MATRIX21_ARB 0x88D5 -#define GL_MATRIX22_ARB 0x88D6 -#define GL_MATRIX23_ARB 0x88D7 -#define GL_MATRIX24_ARB 0x88D8 -#define GL_MATRIX25_ARB 0x88D9 -#define GL_MATRIX26_ARB 0x88DA -#define GL_MATRIX27_ARB 0x88DB -#define GL_MATRIX28_ARB 0x88DC -#define GL_MATRIX29_ARB 0x88DD -#define GL_MATRIX30_ARB 0x88DE -#define GL_MATRIX31_ARB 0x88DF -#endif - -#ifndef GL_ARB_fragment_program -#define GL_FRAGMENT_PROGRAM_ARB 0x8804 -#define GL_PROGRAM_ALU_INSTRUCTIONS_ARB 0x8805 -#define GL_PROGRAM_TEX_INSTRUCTIONS_ARB 0x8806 -#define GL_PROGRAM_TEX_INDIRECTIONS_ARB 0x8807 -#define GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x8808 -#define GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x8809 -#define GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x880A -#define GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB 0x880B -#define GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB 0x880C -#define GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB 0x880D -#define GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x880E -#define GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x880F -#define GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x8810 -#define GL_MAX_TEXTURE_COORDS_ARB 0x8871 -#define GL_MAX_TEXTURE_IMAGE_UNITS_ARB 0x8872 -#endif - -#ifndef GL_ARB_vertex_buffer_object -#define GL_BUFFER_SIZE_ARB 0x8764 -#define GL_BUFFER_USAGE_ARB 0x8765 -#define GL_ARRAY_BUFFER_ARB 0x8892 -#define GL_ELEMENT_ARRAY_BUFFER_ARB 0x8893 -#define GL_ARRAY_BUFFER_BINDING_ARB 0x8894 -#define GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB 0x8895 -#define GL_VERTEX_ARRAY_BUFFER_BINDING_ARB 0x8896 -#define GL_NORMAL_ARRAY_BUFFER_BINDING_ARB 0x8897 -#define GL_COLOR_ARRAY_BUFFER_BINDING_ARB 0x8898 -#define GL_INDEX_ARRAY_BUFFER_BINDING_ARB 0x8899 -#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB 0x889A -#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB 0x889B -#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB 0x889C -#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB 0x889D -#define GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB 0x889E -#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB 0x889F -#define GL_READ_ONLY_ARB 0x88B8 -#define GL_WRITE_ONLY_ARB 0x88B9 -#define GL_READ_WRITE_ARB 0x88BA -#define GL_BUFFER_ACCESS_ARB 0x88BB -#define GL_BUFFER_MAPPED_ARB 0x88BC -#define GL_BUFFER_MAP_POINTER_ARB 0x88BD -#define GL_STREAM_DRAW_ARB 0x88E0 -#define GL_STREAM_READ_ARB 0x88E1 -#define GL_STREAM_COPY_ARB 0x88E2 -#define GL_STATIC_DRAW_ARB 0x88E4 -#define GL_STATIC_READ_ARB 0x88E5 -#define GL_STATIC_COPY_ARB 0x88E6 -#define GL_DYNAMIC_DRAW_ARB 0x88E8 -#define GL_DYNAMIC_READ_ARB 0x88E9 -#define GL_DYNAMIC_COPY_ARB 0x88EA -#endif - -#ifndef GL_ARB_occlusion_query -#define GL_QUERY_COUNTER_BITS_ARB 0x8864 -#define GL_CURRENT_QUERY_ARB 0x8865 -#define GL_QUERY_RESULT_ARB 0x8866 -#define GL_QUERY_RESULT_AVAILABLE_ARB 0x8867 -#define GL_SAMPLES_PASSED_ARB 0x8914 -#endif - -#ifndef GL_ARB_shader_objects -#define GL_PROGRAM_OBJECT_ARB 0x8B40 -#define GL_SHADER_OBJECT_ARB 0x8B48 -#define GL_OBJECT_TYPE_ARB 0x8B4E -#define GL_OBJECT_SUBTYPE_ARB 0x8B4F -#define GL_FLOAT_VEC2_ARB 0x8B50 -#define GL_FLOAT_VEC3_ARB 0x8B51 -#define GL_FLOAT_VEC4_ARB 0x8B52 -#define GL_INT_VEC2_ARB 0x8B53 -#define GL_INT_VEC3_ARB 0x8B54 -#define GL_INT_VEC4_ARB 0x8B55 -#define GL_BOOL_ARB 0x8B56 -#define GL_BOOL_VEC2_ARB 0x8B57 -#define GL_BOOL_VEC3_ARB 0x8B58 -#define GL_BOOL_VEC4_ARB 0x8B59 -#define GL_FLOAT_MAT2_ARB 0x8B5A -#define GL_FLOAT_MAT3_ARB 0x8B5B -#define GL_FLOAT_MAT4_ARB 0x8B5C -#define GL_SAMPLER_1D_ARB 0x8B5D -#define GL_SAMPLER_2D_ARB 0x8B5E -#define GL_SAMPLER_3D_ARB 0x8B5F -#define GL_SAMPLER_CUBE_ARB 0x8B60 -#define GL_SAMPLER_1D_SHADOW_ARB 0x8B61 -#define GL_SAMPLER_2D_SHADOW_ARB 0x8B62 -#define GL_SAMPLER_2D_RECT_ARB 0x8B63 -#define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8B64 -#define GL_OBJECT_DELETE_STATUS_ARB 0x8B80 -#define GL_OBJECT_COMPILE_STATUS_ARB 0x8B81 -#define GL_OBJECT_LINK_STATUS_ARB 0x8B82 -#define GL_OBJECT_VALIDATE_STATUS_ARB 0x8B83 -#define GL_OBJECT_INFO_LOG_LENGTH_ARB 0x8B84 -#define GL_OBJECT_ATTACHED_OBJECTS_ARB 0x8B85 -#define GL_OBJECT_ACTIVE_UNIFORMS_ARB 0x8B86 -#define GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB 0x8B87 -#define GL_OBJECT_SHADER_SOURCE_LENGTH_ARB 0x8B88 -#endif - -#ifndef GL_ARB_vertex_shader -#define GL_VERTEX_SHADER_ARB 0x8B31 -#define GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB 0x8B4A -#define GL_MAX_VARYING_FLOATS_ARB 0x8B4B -#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB 0x8B4C -#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB 0x8B4D -#define GL_OBJECT_ACTIVE_ATTRIBUTES_ARB 0x8B89 -#define GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB 0x8B8A -#endif - -#ifndef GL_ARB_fragment_shader -#define GL_FRAGMENT_SHADER_ARB 0x8B30 -#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB 0x8B49 -#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB 0x8B8B -#endif - -#ifndef GL_ARB_shading_language_100 -#define GL_SHADING_LANGUAGE_VERSION_ARB 0x8B8C -#endif - -#ifndef GL_ARB_texture_non_power_of_two -#endif - -#ifndef GL_ARB_point_sprite -#define GL_POINT_SPRITE_ARB 0x8861 -#define GL_COORD_REPLACE_ARB 0x8862 -#endif - -#ifndef GL_ARB_fragment_program_shadow -#endif - -#ifndef GL_ARB_draw_buffers -#define GL_MAX_DRAW_BUFFERS_ARB 0x8824 -#define GL_DRAW_BUFFER0_ARB 0x8825 -#define GL_DRAW_BUFFER1_ARB 0x8826 -#define GL_DRAW_BUFFER2_ARB 0x8827 -#define GL_DRAW_BUFFER3_ARB 0x8828 -#define GL_DRAW_BUFFER4_ARB 0x8829 -#define GL_DRAW_BUFFER5_ARB 0x882A -#define GL_DRAW_BUFFER6_ARB 0x882B -#define GL_DRAW_BUFFER7_ARB 0x882C -#define GL_DRAW_BUFFER8_ARB 0x882D -#define GL_DRAW_BUFFER9_ARB 0x882E -#define GL_DRAW_BUFFER10_ARB 0x882F -#define GL_DRAW_BUFFER11_ARB 0x8830 -#define GL_DRAW_BUFFER12_ARB 0x8831 -#define GL_DRAW_BUFFER13_ARB 0x8832 -#define GL_DRAW_BUFFER14_ARB 0x8833 -#define GL_DRAW_BUFFER15_ARB 0x8834 -#endif - -#ifndef GL_ARB_texture_rectangle -#define GL_TEXTURE_RECTANGLE_ARB 0x84F5 -#define GL_TEXTURE_BINDING_RECTANGLE_ARB 0x84F6 -#define GL_PROXY_TEXTURE_RECTANGLE_ARB 0x84F7 -#define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8 -#endif - -#ifndef GL_ARB_color_buffer_float -#define GL_RGBA_FLOAT_MODE_ARB 0x8820 -#define GL_CLAMP_VERTEX_COLOR_ARB 0x891A -#define GL_CLAMP_FRAGMENT_COLOR_ARB 0x891B -#define GL_CLAMP_READ_COLOR_ARB 0x891C -#define GL_FIXED_ONLY_ARB 0x891D -#endif - -#ifndef GL_ARB_half_float_pixel -#define GL_HALF_FLOAT_ARB 0x140B -#endif - -#ifndef GL_ARB_texture_float -#define GL_TEXTURE_RED_TYPE_ARB 0x8C10 -#define GL_TEXTURE_GREEN_TYPE_ARB 0x8C11 -#define GL_TEXTURE_BLUE_TYPE_ARB 0x8C12 -#define GL_TEXTURE_ALPHA_TYPE_ARB 0x8C13 -#define GL_TEXTURE_LUMINANCE_TYPE_ARB 0x8C14 -#define GL_TEXTURE_INTENSITY_TYPE_ARB 0x8C15 -#define GL_TEXTURE_DEPTH_TYPE_ARB 0x8C16 -#define GL_UNSIGNED_NORMALIZED_ARB 0x8C17 -#define GL_RGBA32F_ARB 0x8814 -#define GL_RGB32F_ARB 0x8815 -#define GL_ALPHA32F_ARB 0x8816 -#define GL_INTENSITY32F_ARB 0x8817 -#define GL_LUMINANCE32F_ARB 0x8818 -#define GL_LUMINANCE_ALPHA32F_ARB 0x8819 -#define GL_RGBA16F_ARB 0x881A -#define GL_RGB16F_ARB 0x881B -#define GL_ALPHA16F_ARB 0x881C -#define GL_INTENSITY16F_ARB 0x881D -#define GL_LUMINANCE16F_ARB 0x881E -#define GL_LUMINANCE_ALPHA16F_ARB 0x881F -#endif - -#ifndef GL_ARB_pixel_buffer_object -#define GL_PIXEL_PACK_BUFFER_ARB 0x88EB -#define GL_PIXEL_UNPACK_BUFFER_ARB 0x88EC -#define GL_PIXEL_PACK_BUFFER_BINDING_ARB 0x88ED -#define GL_PIXEL_UNPACK_BUFFER_BINDING_ARB 0x88EF -#endif - -#ifndef GL_EXT_abgr -#define GL_ABGR_EXT 0x8000 -#endif - -#ifndef GL_EXT_blend_color -#define GL_CONSTANT_COLOR_EXT 0x8001 -#define GL_ONE_MINUS_CONSTANT_COLOR_EXT 0x8002 -#define GL_CONSTANT_ALPHA_EXT 0x8003 -#define GL_ONE_MINUS_CONSTANT_ALPHA_EXT 0x8004 -#define GL_BLEND_COLOR_EXT 0x8005 -#endif - -#ifndef GL_EXT_polygon_offset -#define GL_POLYGON_OFFSET_EXT 0x8037 -#define GL_POLYGON_OFFSET_FACTOR_EXT 0x8038 -#define GL_POLYGON_OFFSET_BIAS_EXT 0x8039 -#endif - -#ifndef GL_EXT_texture -#define GL_ALPHA4_EXT 0x803B -#define GL_ALPHA8_EXT 0x803C -#define GL_ALPHA12_EXT 0x803D -#define GL_ALPHA16_EXT 0x803E -#define GL_LUMINANCE4_EXT 0x803F -#define GL_LUMINANCE8_EXT 0x8040 -#define GL_LUMINANCE12_EXT 0x8041 -#define GL_LUMINANCE16_EXT 0x8042 -#define GL_LUMINANCE4_ALPHA4_EXT 0x8043 -#define GL_LUMINANCE6_ALPHA2_EXT 0x8044 -#define GL_LUMINANCE8_ALPHA8_EXT 0x8045 -#define GL_LUMINANCE12_ALPHA4_EXT 0x8046 -#define GL_LUMINANCE12_ALPHA12_EXT 0x8047 -#define GL_LUMINANCE16_ALPHA16_EXT 0x8048 -#define GL_INTENSITY_EXT 0x8049 -#define GL_INTENSITY4_EXT 0x804A -#define GL_INTENSITY8_EXT 0x804B -#define GL_INTENSITY12_EXT 0x804C -#define GL_INTENSITY16_EXT 0x804D -#define GL_RGB2_EXT 0x804E -#define GL_RGB4_EXT 0x804F -#define GL_RGB5_EXT 0x8050 -#define GL_RGB8_EXT 0x8051 -#define GL_RGB10_EXT 0x8052 -#define GL_RGB12_EXT 0x8053 -#define GL_RGB16_EXT 0x8054 -#define GL_RGBA2_EXT 0x8055 -#define GL_RGBA4_EXT 0x8056 -#define GL_RGB5_A1_EXT 0x8057 -#define GL_RGBA8_EXT 0x8058 -#define GL_RGB10_A2_EXT 0x8059 -#define GL_RGBA12_EXT 0x805A -#define GL_RGBA16_EXT 0x805B -#define GL_TEXTURE_RED_SIZE_EXT 0x805C -#define GL_TEXTURE_GREEN_SIZE_EXT 0x805D -#define GL_TEXTURE_BLUE_SIZE_EXT 0x805E -#define GL_TEXTURE_ALPHA_SIZE_EXT 0x805F -#define GL_TEXTURE_LUMINANCE_SIZE_EXT 0x8060 -#define GL_TEXTURE_INTENSITY_SIZE_EXT 0x8061 -#define GL_REPLACE_EXT 0x8062 -#define GL_PROXY_TEXTURE_1D_EXT 0x8063 -#define GL_PROXY_TEXTURE_2D_EXT 0x8064 -#define GL_TEXTURE_TOO_LARGE_EXT 0x8065 -#endif - -#ifndef GL_EXT_texture3D -#define GL_PACK_SKIP_IMAGES_EXT 0x806B -#define GL_PACK_IMAGE_HEIGHT_EXT 0x806C -#define GL_UNPACK_SKIP_IMAGES_EXT 0x806D -#define GL_UNPACK_IMAGE_HEIGHT_EXT 0x806E -#define GL_TEXTURE_3D_EXT 0x806F -#define GL_PROXY_TEXTURE_3D_EXT 0x8070 -#define GL_TEXTURE_DEPTH_EXT 0x8071 -#define GL_TEXTURE_WRAP_R_EXT 0x8072 -#define GL_MAX_3D_TEXTURE_SIZE_EXT 0x8073 -#endif - -#ifndef GL_SGIS_texture_filter4 -#define GL_FILTER4_SGIS 0x8146 -#define GL_TEXTURE_FILTER4_SIZE_SGIS 0x8147 -#endif - -#ifndef GL_EXT_subtexture -#endif - -#ifndef GL_EXT_copy_texture -#endif - -#ifndef GL_EXT_histogram -#define GL_HISTOGRAM_EXT 0x8024 -#define GL_PROXY_HISTOGRAM_EXT 0x8025 -#define GL_HISTOGRAM_WIDTH_EXT 0x8026 -#define GL_HISTOGRAM_FORMAT_EXT 0x8027 -#define GL_HISTOGRAM_RED_SIZE_EXT 0x8028 -#define GL_HISTOGRAM_GREEN_SIZE_EXT 0x8029 -#define GL_HISTOGRAM_BLUE_SIZE_EXT 0x802A -#define GL_HISTOGRAM_ALPHA_SIZE_EXT 0x802B -#define GL_HISTOGRAM_LUMINANCE_SIZE_EXT 0x802C -#define GL_HISTOGRAM_SINK_EXT 0x802D -#define GL_MINMAX_EXT 0x802E -#define GL_MINMAX_FORMAT_EXT 0x802F -#define GL_MINMAX_SINK_EXT 0x8030 -#define GL_TABLE_TOO_LARGE_EXT 0x8031 -#endif - -#ifndef GL_EXT_convolution -#define GL_CONVOLUTION_1D_EXT 0x8010 -#define GL_CONVOLUTION_2D_EXT 0x8011 -#define GL_SEPARABLE_2D_EXT 0x8012 -#define GL_CONVOLUTION_BORDER_MODE_EXT 0x8013 -#define GL_CONVOLUTION_FILTER_SCALE_EXT 0x8014 -#define GL_CONVOLUTION_FILTER_BIAS_EXT 0x8015 -#define GL_REDUCE_EXT 0x8016 -#define GL_CONVOLUTION_FORMAT_EXT 0x8017 -#define GL_CONVOLUTION_WIDTH_EXT 0x8018 -#define GL_CONVOLUTION_HEIGHT_EXT 0x8019 -#define GL_MAX_CONVOLUTION_WIDTH_EXT 0x801A -#define GL_MAX_CONVOLUTION_HEIGHT_EXT 0x801B -#define GL_POST_CONVOLUTION_RED_SCALE_EXT 0x801C -#define GL_POST_CONVOLUTION_GREEN_SCALE_EXT 0x801D -#define GL_POST_CONVOLUTION_BLUE_SCALE_EXT 0x801E -#define GL_POST_CONVOLUTION_ALPHA_SCALE_EXT 0x801F -#define GL_POST_CONVOLUTION_RED_BIAS_EXT 0x8020 -#define GL_POST_CONVOLUTION_GREEN_BIAS_EXT 0x8021 -#define GL_POST_CONVOLUTION_BLUE_BIAS_EXT 0x8022 -#define GL_POST_CONVOLUTION_ALPHA_BIAS_EXT 0x8023 -#endif - -#ifndef GL_SGI_color_matrix -#define GL_COLOR_MATRIX_SGI 0x80B1 -#define GL_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B2 -#define GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B3 -#define GL_POST_COLOR_MATRIX_RED_SCALE_SGI 0x80B4 -#define GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI 0x80B5 -#define GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI 0x80B6 -#define GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI 0x80B7 -#define GL_POST_COLOR_MATRIX_RED_BIAS_SGI 0x80B8 -#define GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI 0x80B9 -#define GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI 0x80BA -#define GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI 0x80BB -#endif - -#ifndef GL_SGI_color_table -#define GL_COLOR_TABLE_SGI 0x80D0 -#define GL_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D1 -#define GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D2 -#define GL_PROXY_COLOR_TABLE_SGI 0x80D3 -#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D4 -#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D5 -#define GL_COLOR_TABLE_SCALE_SGI 0x80D6 -#define GL_COLOR_TABLE_BIAS_SGI 0x80D7 -#define GL_COLOR_TABLE_FORMAT_SGI 0x80D8 -#define GL_COLOR_TABLE_WIDTH_SGI 0x80D9 -#define GL_COLOR_TABLE_RED_SIZE_SGI 0x80DA -#define GL_COLOR_TABLE_GREEN_SIZE_SGI 0x80DB -#define GL_COLOR_TABLE_BLUE_SIZE_SGI 0x80DC -#define GL_COLOR_TABLE_ALPHA_SIZE_SGI 0x80DD -#define GL_COLOR_TABLE_LUMINANCE_SIZE_SGI 0x80DE -#define GL_COLOR_TABLE_INTENSITY_SIZE_SGI 0x80DF -#endif - -#ifndef GL_SGIS_pixel_texture -#define GL_PIXEL_TEXTURE_SGIS 0x8353 -#define GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS 0x8354 -#define GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS 0x8355 -#define GL_PIXEL_GROUP_COLOR_SGIS 0x8356 -#endif - -#ifndef GL_SGIX_pixel_texture -#define GL_PIXEL_TEX_GEN_SGIX 0x8139 -#define GL_PIXEL_TEX_GEN_MODE_SGIX 0x832B -#endif - -#ifndef GL_SGIS_texture4D -#define GL_PACK_SKIP_VOLUMES_SGIS 0x8130 -#define GL_PACK_IMAGE_DEPTH_SGIS 0x8131 -#define GL_UNPACK_SKIP_VOLUMES_SGIS 0x8132 -#define GL_UNPACK_IMAGE_DEPTH_SGIS 0x8133 -#define GL_TEXTURE_4D_SGIS 0x8134 -#define GL_PROXY_TEXTURE_4D_SGIS 0x8135 -#define GL_TEXTURE_4DSIZE_SGIS 0x8136 -#define GL_TEXTURE_WRAP_Q_SGIS 0x8137 -#define GL_MAX_4D_TEXTURE_SIZE_SGIS 0x8138 -#define GL_TEXTURE_4D_BINDING_SGIS 0x814F -#endif - -#ifndef GL_SGI_texture_color_table -#define GL_TEXTURE_COLOR_TABLE_SGI 0x80BC -#define GL_PROXY_TEXTURE_COLOR_TABLE_SGI 0x80BD -#endif - -#ifndef GL_EXT_cmyka -#define GL_CMYK_EXT 0x800C -#define GL_CMYKA_EXT 0x800D -#define GL_PACK_CMYK_HINT_EXT 0x800E -#define GL_UNPACK_CMYK_HINT_EXT 0x800F -#endif - -#ifndef GL_EXT_texture_object -#define GL_TEXTURE_PRIORITY_EXT 0x8066 -#define GL_TEXTURE_RESIDENT_EXT 0x8067 -#define GL_TEXTURE_1D_BINDING_EXT 0x8068 -#define GL_TEXTURE_2D_BINDING_EXT 0x8069 -#define GL_TEXTURE_3D_BINDING_EXT 0x806A -#endif - -#ifndef GL_SGIS_detail_texture -#define GL_DETAIL_TEXTURE_2D_SGIS 0x8095 -#define GL_DETAIL_TEXTURE_2D_BINDING_SGIS 0x8096 -#define GL_LINEAR_DETAIL_SGIS 0x8097 -#define GL_LINEAR_DETAIL_ALPHA_SGIS 0x8098 -#define GL_LINEAR_DETAIL_COLOR_SGIS 0x8099 -#define GL_DETAIL_TEXTURE_LEVEL_SGIS 0x809A -#define GL_DETAIL_TEXTURE_MODE_SGIS 0x809B -#define GL_DETAIL_TEXTURE_FUNC_POINTS_SGIS 0x809C -#endif - -#ifndef GL_SGIS_sharpen_texture -#define GL_LINEAR_SHARPEN_SGIS 0x80AD -#define GL_LINEAR_SHARPEN_ALPHA_SGIS 0x80AE -#define GL_LINEAR_SHARPEN_COLOR_SGIS 0x80AF -#define GL_SHARPEN_TEXTURE_FUNC_POINTS_SGIS 0x80B0 -#endif - -#ifndef GL_EXT_packed_pixels -#define GL_UNSIGNED_BYTE_3_3_2_EXT 0x8032 -#define GL_UNSIGNED_SHORT_4_4_4_4_EXT 0x8033 -#define GL_UNSIGNED_SHORT_5_5_5_1_EXT 0x8034 -#define GL_UNSIGNED_INT_8_8_8_8_EXT 0x8035 -#define GL_UNSIGNED_INT_10_10_10_2_EXT 0x8036 -#endif - -#ifndef GL_SGIS_texture_lod -#define GL_TEXTURE_MIN_LOD_SGIS 0x813A -#define GL_TEXTURE_MAX_LOD_SGIS 0x813B -#define GL_TEXTURE_BASE_LEVEL_SGIS 0x813C -#define GL_TEXTURE_MAX_LEVEL_SGIS 0x813D -#endif - -#ifndef GL_SGIS_multisample -#define GL_MULTISAMPLE_SGIS 0x809D -#define GL_SAMPLE_ALPHA_TO_MASK_SGIS 0x809E -#define GL_SAMPLE_ALPHA_TO_ONE_SGIS 0x809F -#define GL_SAMPLE_MASK_SGIS 0x80A0 -#define GL_1PASS_SGIS 0x80A1 -#define GL_2PASS_0_SGIS 0x80A2 -#define GL_2PASS_1_SGIS 0x80A3 -#define GL_4PASS_0_SGIS 0x80A4 -#define GL_4PASS_1_SGIS 0x80A5 -#define GL_4PASS_2_SGIS 0x80A6 -#define GL_4PASS_3_SGIS 0x80A7 -#define GL_SAMPLE_BUFFERS_SGIS 0x80A8 -#define GL_SAMPLES_SGIS 0x80A9 -#define GL_SAMPLE_MASK_VALUE_SGIS 0x80AA -#define GL_SAMPLE_MASK_INVERT_SGIS 0x80AB -#define GL_SAMPLE_PATTERN_SGIS 0x80AC -#endif - -#ifndef GL_EXT_rescale_normal -#define GL_RESCALE_NORMAL_EXT 0x803A -#endif - -#ifndef GL_EXT_vertex_array -#define GL_VERTEX_ARRAY_EXT 0x8074 -#define GL_NORMAL_ARRAY_EXT 0x8075 -#define GL_COLOR_ARRAY_EXT 0x8076 -#define GL_INDEX_ARRAY_EXT 0x8077 -#define GL_TEXTURE_COORD_ARRAY_EXT 0x8078 -#define GL_EDGE_FLAG_ARRAY_EXT 0x8079 -#define GL_VERTEX_ARRAY_SIZE_EXT 0x807A -#define GL_VERTEX_ARRAY_TYPE_EXT 0x807B -#define GL_VERTEX_ARRAY_STRIDE_EXT 0x807C -#define GL_VERTEX_ARRAY_COUNT_EXT 0x807D -#define GL_NORMAL_ARRAY_TYPE_EXT 0x807E -#define GL_NORMAL_ARRAY_STRIDE_EXT 0x807F -#define GL_NORMAL_ARRAY_COUNT_EXT 0x8080 -#define GL_COLOR_ARRAY_SIZE_EXT 0x8081 -#define GL_COLOR_ARRAY_TYPE_EXT 0x8082 -#define GL_COLOR_ARRAY_STRIDE_EXT 0x8083 -#define GL_COLOR_ARRAY_COUNT_EXT 0x8084 -#define GL_INDEX_ARRAY_TYPE_EXT 0x8085 -#define GL_INDEX_ARRAY_STRIDE_EXT 0x8086 -#define GL_INDEX_ARRAY_COUNT_EXT 0x8087 -#define GL_TEXTURE_COORD_ARRAY_SIZE_EXT 0x8088 -#define GL_TEXTURE_COORD_ARRAY_TYPE_EXT 0x8089 -#define GL_TEXTURE_COORD_ARRAY_STRIDE_EXT 0x808A -#define GL_TEXTURE_COORD_ARRAY_COUNT_EXT 0x808B -#define GL_EDGE_FLAG_ARRAY_STRIDE_EXT 0x808C -#define GL_EDGE_FLAG_ARRAY_COUNT_EXT 0x808D -#define GL_VERTEX_ARRAY_POINTER_EXT 0x808E -#define GL_NORMAL_ARRAY_POINTER_EXT 0x808F -#define GL_COLOR_ARRAY_POINTER_EXT 0x8090 -#define GL_INDEX_ARRAY_POINTER_EXT 0x8091 -#define GL_TEXTURE_COORD_ARRAY_POINTER_EXT 0x8092 -#define GL_EDGE_FLAG_ARRAY_POINTER_EXT 0x8093 -#endif - -#ifndef GL_EXT_misc_attribute -#endif - -#ifndef GL_SGIS_generate_mipmap -#define GL_GENERATE_MIPMAP_SGIS 0x8191 -#define GL_GENERATE_MIPMAP_HINT_SGIS 0x8192 -#endif - -#ifndef GL_SGIX_clipmap -#define GL_LINEAR_CLIPMAP_LINEAR_SGIX 0x8170 -#define GL_TEXTURE_CLIPMAP_CENTER_SGIX 0x8171 -#define GL_TEXTURE_CLIPMAP_FRAME_SGIX 0x8172 -#define GL_TEXTURE_CLIPMAP_OFFSET_SGIX 0x8173 -#define GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8174 -#define GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX 0x8175 -#define GL_TEXTURE_CLIPMAP_DEPTH_SGIX 0x8176 -#define GL_MAX_CLIPMAP_DEPTH_SGIX 0x8177 -#define GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8178 -#define GL_NEAREST_CLIPMAP_NEAREST_SGIX 0x844D -#define GL_NEAREST_CLIPMAP_LINEAR_SGIX 0x844E -#define GL_LINEAR_CLIPMAP_NEAREST_SGIX 0x844F -#endif - -#ifndef GL_SGIX_shadow -#define GL_TEXTURE_COMPARE_SGIX 0x819A -#define GL_TEXTURE_COMPARE_OPERATOR_SGIX 0x819B -#define GL_TEXTURE_LEQUAL_R_SGIX 0x819C -#define GL_TEXTURE_GEQUAL_R_SGIX 0x819D -#endif - -#ifndef GL_SGIS_texture_edge_clamp -#define GL_CLAMP_TO_EDGE_SGIS 0x812F -#endif - -#ifndef GL_SGIS_texture_border_clamp -#define GL_CLAMP_TO_BORDER_SGIS 0x812D -#endif - -#ifndef GL_EXT_blend_minmax -#define GL_FUNC_ADD_EXT 0x8006 -#define GL_MIN_EXT 0x8007 -#define GL_MAX_EXT 0x8008 -#define GL_BLEND_EQUATION_EXT 0x8009 -#endif - -#ifndef GL_EXT_blend_subtract -#define GL_FUNC_SUBTRACT_EXT 0x800A -#define GL_FUNC_REVERSE_SUBTRACT_EXT 0x800B -#endif - -#ifndef GL_EXT_blend_logic_op -#endif - -#ifndef GL_SGIX_interlace -#define GL_INTERLACE_SGIX 0x8094 -#endif - -#ifndef GL_SGIX_pixel_tiles -#define GL_PIXEL_TILE_BEST_ALIGNMENT_SGIX 0x813E -#define GL_PIXEL_TILE_CACHE_INCREMENT_SGIX 0x813F -#define GL_PIXEL_TILE_WIDTH_SGIX 0x8140 -#define GL_PIXEL_TILE_HEIGHT_SGIX 0x8141 -#define GL_PIXEL_TILE_GRID_WIDTH_SGIX 0x8142 -#define GL_PIXEL_TILE_GRID_HEIGHT_SGIX 0x8143 -#define GL_PIXEL_TILE_GRID_DEPTH_SGIX 0x8144 -#define GL_PIXEL_TILE_CACHE_SIZE_SGIX 0x8145 -#endif - -#ifndef GL_SGIS_texture_select -#define GL_DUAL_ALPHA4_SGIS 0x8110 -#define GL_DUAL_ALPHA8_SGIS 0x8111 -#define GL_DUAL_ALPHA12_SGIS 0x8112 -#define GL_DUAL_ALPHA16_SGIS 0x8113 -#define GL_DUAL_LUMINANCE4_SGIS 0x8114 -#define GL_DUAL_LUMINANCE8_SGIS 0x8115 -#define GL_DUAL_LUMINANCE12_SGIS 0x8116 -#define GL_DUAL_LUMINANCE16_SGIS 0x8117 -#define GL_DUAL_INTENSITY4_SGIS 0x8118 -#define GL_DUAL_INTENSITY8_SGIS 0x8119 -#define GL_DUAL_INTENSITY12_SGIS 0x811A -#define GL_DUAL_INTENSITY16_SGIS 0x811B -#define GL_DUAL_LUMINANCE_ALPHA4_SGIS 0x811C -#define GL_DUAL_LUMINANCE_ALPHA8_SGIS 0x811D -#define GL_QUAD_ALPHA4_SGIS 0x811E -#define GL_QUAD_ALPHA8_SGIS 0x811F -#define GL_QUAD_LUMINANCE4_SGIS 0x8120 -#define GL_QUAD_LUMINANCE8_SGIS 0x8121 -#define GL_QUAD_INTENSITY4_SGIS 0x8122 -#define GL_QUAD_INTENSITY8_SGIS 0x8123 -#define GL_DUAL_TEXTURE_SELECT_SGIS 0x8124 -#define GL_QUAD_TEXTURE_SELECT_SGIS 0x8125 -#endif - -#ifndef GL_SGIX_sprite -#define GL_SPRITE_SGIX 0x8148 -#define GL_SPRITE_MODE_SGIX 0x8149 -#define GL_SPRITE_AXIS_SGIX 0x814A -#define GL_SPRITE_TRANSLATION_SGIX 0x814B -#define GL_SPRITE_AXIAL_SGIX 0x814C -#define GL_SPRITE_OBJECT_ALIGNED_SGIX 0x814D -#define GL_SPRITE_EYE_ALIGNED_SGIX 0x814E -#endif - -#ifndef GL_SGIX_texture_multi_buffer -#define GL_TEXTURE_MULTI_BUFFER_HINT_SGIX 0x812E -#endif - -#ifndef GL_EXT_point_parameters -#define GL_POINT_SIZE_MIN_EXT 0x8126 -#define GL_POINT_SIZE_MAX_EXT 0x8127 -#define GL_POINT_FADE_THRESHOLD_SIZE_EXT 0x8128 -#define GL_DISTANCE_ATTENUATION_EXT 0x8129 -#endif - -#ifndef GL_SGIS_point_parameters -#define GL_POINT_SIZE_MIN_SGIS 0x8126 -#define GL_POINT_SIZE_MAX_SGIS 0x8127 -#define GL_POINT_FADE_THRESHOLD_SIZE_SGIS 0x8128 -#define GL_DISTANCE_ATTENUATION_SGIS 0x8129 -#endif - -#ifndef GL_SGIX_instruments -#define GL_INSTRUMENT_BUFFER_POINTER_SGIX 0x8180 -#define GL_INSTRUMENT_MEASUREMENTS_SGIX 0x8181 -#endif - -#ifndef GL_SGIX_texture_scale_bias -#define GL_POST_TEXTURE_FILTER_BIAS_SGIX 0x8179 -#define GL_POST_TEXTURE_FILTER_SCALE_SGIX 0x817A -#define GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX 0x817B -#define GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX 0x817C -#endif - -#ifndef GL_SGIX_framezoom -#define GL_FRAMEZOOM_SGIX 0x818B -#define GL_FRAMEZOOM_FACTOR_SGIX 0x818C -#define GL_MAX_FRAMEZOOM_FACTOR_SGIX 0x818D -#endif - -#ifndef GL_SGIX_tag_sample_buffer -#endif - -#ifndef GL_FfdMaskSGIX -#define GL_TEXTURE_DEFORMATION_BIT_SGIX 0x00000001 -#define GL_GEOMETRY_DEFORMATION_BIT_SGIX 0x00000002 -#endif - -#ifndef GL_SGIX_polynomial_ffd -#define GL_GEOMETRY_DEFORMATION_SGIX 0x8194 -#define GL_TEXTURE_DEFORMATION_SGIX 0x8195 -#define GL_DEFORMATIONS_MASK_SGIX 0x8196 -#define GL_MAX_DEFORMATION_ORDER_SGIX 0x8197 -#endif - -#ifndef GL_SGIX_reference_plane -#define GL_REFERENCE_PLANE_SGIX 0x817D -#define GL_REFERENCE_PLANE_EQUATION_SGIX 0x817E -#endif - -#ifndef GL_SGIX_flush_raster -#endif - -#ifndef GL_SGIX_depth_texture -#define GL_DEPTH_COMPONENT16_SGIX 0x81A5 -#define GL_DEPTH_COMPONENT24_SGIX 0x81A6 -#define GL_DEPTH_COMPONENT32_SGIX 0x81A7 -#endif - -#ifndef GL_SGIS_fog_function -#define GL_FOG_FUNC_SGIS 0x812A -#define GL_FOG_FUNC_POINTS_SGIS 0x812B -#define GL_MAX_FOG_FUNC_POINTS_SGIS 0x812C -#endif - -#ifndef GL_SGIX_fog_offset -#define GL_FOG_OFFSET_SGIX 0x8198 -#define GL_FOG_OFFSET_VALUE_SGIX 0x8199 -#endif - -#ifndef GL_HP_image_transform -#define GL_IMAGE_SCALE_X_HP 0x8155 -#define GL_IMAGE_SCALE_Y_HP 0x8156 -#define GL_IMAGE_TRANSLATE_X_HP 0x8157 -#define GL_IMAGE_TRANSLATE_Y_HP 0x8158 -#define GL_IMAGE_ROTATE_ANGLE_HP 0x8159 -#define GL_IMAGE_ROTATE_ORIGIN_X_HP 0x815A -#define GL_IMAGE_ROTATE_ORIGIN_Y_HP 0x815B -#define GL_IMAGE_MAG_FILTER_HP 0x815C -#define GL_IMAGE_MIN_FILTER_HP 0x815D -#define GL_IMAGE_CUBIC_WEIGHT_HP 0x815E -#define GL_CUBIC_HP 0x815F -#define GL_AVERAGE_HP 0x8160 -#define GL_IMAGE_TRANSFORM_2D_HP 0x8161 -#define GL_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8162 -#define GL_PROXY_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8163 -#endif - -#ifndef GL_HP_convolution_border_modes -#define GL_IGNORE_BORDER_HP 0x8150 -#define GL_CONSTANT_BORDER_HP 0x8151 -#define GL_REPLICATE_BORDER_HP 0x8153 -#define GL_CONVOLUTION_BORDER_COLOR_HP 0x8154 -#endif - -#ifndef GL_INGR_palette_buffer -#endif - -#ifndef GL_SGIX_texture_add_env -#define GL_TEXTURE_ENV_BIAS_SGIX 0x80BE -#endif - -#ifndef GL_EXT_color_subtable -#endif - -#ifndef GL_PGI_vertex_hints -#define GL_VERTEX_DATA_HINT_PGI 0x1A22A -#define GL_VERTEX_CONSISTENT_HINT_PGI 0x1A22B -#define GL_MATERIAL_SIDE_HINT_PGI 0x1A22C -#define GL_MAX_VERTEX_HINT_PGI 0x1A22D -#define GL_COLOR3_BIT_PGI 0x00010000 -#define GL_COLOR4_BIT_PGI 0x00020000 -#define GL_EDGEFLAG_BIT_PGI 0x00040000 -#define GL_INDEX_BIT_PGI 0x00080000 -#define GL_MAT_AMBIENT_BIT_PGI 0x00100000 -#define GL_MAT_AMBIENT_AND_DIFFUSE_BIT_PGI 0x00200000 -#define GL_MAT_DIFFUSE_BIT_PGI 0x00400000 -#define GL_MAT_EMISSION_BIT_PGI 0x00800000 -#define GL_MAT_COLOR_INDEXES_BIT_PGI 0x01000000 -#define GL_MAT_SHININESS_BIT_PGI 0x02000000 -#define GL_MAT_SPECULAR_BIT_PGI 0x04000000 -#define GL_NORMAL_BIT_PGI 0x08000000 -#define GL_TEXCOORD1_BIT_PGI 0x10000000 -#define GL_TEXCOORD2_BIT_PGI 0x20000000 -#define GL_TEXCOORD3_BIT_PGI 0x40000000 -#define GL_TEXCOORD4_BIT_PGI 0x80000000 -#define GL_VERTEX23_BIT_PGI 0x00000004 -#define GL_VERTEX4_BIT_PGI 0x00000008 -#endif - -#ifndef GL_PGI_misc_hints -#define GL_PREFER_DOUBLEBUFFER_HINT_PGI 0x1A1F8 -#define GL_CONSERVE_MEMORY_HINT_PGI 0x1A1FD -#define GL_RECLAIM_MEMORY_HINT_PGI 0x1A1FE -#define GL_NATIVE_GRAPHICS_HANDLE_PGI 0x1A202 -#define GL_NATIVE_GRAPHICS_BEGIN_HINT_PGI 0x1A203 -#define GL_NATIVE_GRAPHICS_END_HINT_PGI 0x1A204 -#define GL_ALWAYS_FAST_HINT_PGI 0x1A20C -#define GL_ALWAYS_SOFT_HINT_PGI 0x1A20D -#define GL_ALLOW_DRAW_OBJ_HINT_PGI 0x1A20E -#define GL_ALLOW_DRAW_WIN_HINT_PGI 0x1A20F -#define GL_ALLOW_DRAW_FRG_HINT_PGI 0x1A210 -#define GL_ALLOW_DRAW_MEM_HINT_PGI 0x1A211 -#define GL_STRICT_DEPTHFUNC_HINT_PGI 0x1A216 -#define GL_STRICT_LIGHTING_HINT_PGI 0x1A217 -#define GL_STRICT_SCISSOR_HINT_PGI 0x1A218 -#define GL_FULL_STIPPLE_HINT_PGI 0x1A219 -#define GL_CLIP_NEAR_HINT_PGI 0x1A220 -#define GL_CLIP_FAR_HINT_PGI 0x1A221 -#define GL_WIDE_LINE_HINT_PGI 0x1A222 -#define GL_BACK_NORMALS_HINT_PGI 0x1A223 -#endif - -#ifndef GL_EXT_paletted_texture -#define GL_COLOR_INDEX1_EXT 0x80E2 -#define GL_COLOR_INDEX2_EXT 0x80E3 -#define GL_COLOR_INDEX4_EXT 0x80E4 -#define GL_COLOR_INDEX8_EXT 0x80E5 -#define GL_COLOR_INDEX12_EXT 0x80E6 -#define GL_COLOR_INDEX16_EXT 0x80E7 -#define GL_TEXTURE_INDEX_SIZE_EXT 0x80ED -#endif - -#ifndef GL_EXT_clip_volume_hint -#define GL_CLIP_VOLUME_CLIPPING_HINT_EXT 0x80F0 -#endif - -#ifndef GL_SGIX_list_priority -#define GL_LIST_PRIORITY_SGIX 0x8182 -#endif - -#ifndef GL_SGIX_ir_instrument1 -#define GL_IR_INSTRUMENT1_SGIX 0x817F -#endif - -#ifndef GL_SGIX_calligraphic_fragment -#define GL_CALLIGRAPHIC_FRAGMENT_SGIX 0x8183 -#endif - -#ifndef GL_SGIX_texture_lod_bias -#define GL_TEXTURE_LOD_BIAS_S_SGIX 0x818E -#define GL_TEXTURE_LOD_BIAS_T_SGIX 0x818F -#define GL_TEXTURE_LOD_BIAS_R_SGIX 0x8190 -#endif - -#ifndef GL_SGIX_shadow_ambient -#define GL_SHADOW_AMBIENT_SGIX 0x80BF -#endif - -#ifndef GL_EXT_index_texture -#endif - -#ifndef GL_EXT_index_material -#define GL_INDEX_MATERIAL_EXT 0x81B8 -#define GL_INDEX_MATERIAL_PARAMETER_EXT 0x81B9 -#define GL_INDEX_MATERIAL_FACE_EXT 0x81BA -#endif - -#ifndef GL_EXT_index_func -#define GL_INDEX_TEST_EXT 0x81B5 -#define GL_INDEX_TEST_FUNC_EXT 0x81B6 -#define GL_INDEX_TEST_REF_EXT 0x81B7 -#endif - -#ifndef GL_EXT_index_array_formats -#define GL_IUI_V2F_EXT 0x81AD -#define GL_IUI_V3F_EXT 0x81AE -#define GL_IUI_N3F_V2F_EXT 0x81AF -#define GL_IUI_N3F_V3F_EXT 0x81B0 -#define GL_T2F_IUI_V2F_EXT 0x81B1 -#define GL_T2F_IUI_V3F_EXT 0x81B2 -#define GL_T2F_IUI_N3F_V2F_EXT 0x81B3 -#define GL_T2F_IUI_N3F_V3F_EXT 0x81B4 -#endif - -#ifndef GL_EXT_compiled_vertex_array -#define GL_ARRAY_ELEMENT_LOCK_FIRST_EXT 0x81A8 -#define GL_ARRAY_ELEMENT_LOCK_COUNT_EXT 0x81A9 -#endif - -#ifndef GL_EXT_cull_vertex -#define GL_CULL_VERTEX_EXT 0x81AA -#define GL_CULL_VERTEX_EYE_POSITION_EXT 0x81AB -#define GL_CULL_VERTEX_OBJECT_POSITION_EXT 0x81AC -#endif - -#ifndef GL_SGIX_ycrcb -#define GL_YCRCB_422_SGIX 0x81BB -#define GL_YCRCB_444_SGIX 0x81BC -#endif - -#ifndef GL_SGIX_fragment_lighting -#define GL_FRAGMENT_LIGHTING_SGIX 0x8400 -#define GL_FRAGMENT_COLOR_MATERIAL_SGIX 0x8401 -#define GL_FRAGMENT_COLOR_MATERIAL_FACE_SGIX 0x8402 -#define GL_FRAGMENT_COLOR_MATERIAL_PARAMETER_SGIX 0x8403 -#define GL_MAX_FRAGMENT_LIGHTS_SGIX 0x8404 -#define GL_MAX_ACTIVE_LIGHTS_SGIX 0x8405 -#define GL_CURRENT_RASTER_NORMAL_SGIX 0x8406 -#define GL_LIGHT_ENV_MODE_SGIX 0x8407 -#define GL_FRAGMENT_LIGHT_MODEL_LOCAL_VIEWER_SGIX 0x8408 -#define GL_FRAGMENT_LIGHT_MODEL_TWO_SIDE_SGIX 0x8409 -#define GL_FRAGMENT_LIGHT_MODEL_AMBIENT_SGIX 0x840A -#define GL_FRAGMENT_LIGHT_MODEL_NORMAL_INTERPOLATION_SGIX 0x840B -#define GL_FRAGMENT_LIGHT0_SGIX 0x840C -#define GL_FRAGMENT_LIGHT1_SGIX 0x840D -#define GL_FRAGMENT_LIGHT2_SGIX 0x840E -#define GL_FRAGMENT_LIGHT3_SGIX 0x840F -#define GL_FRAGMENT_LIGHT4_SGIX 0x8410 -#define GL_FRAGMENT_LIGHT5_SGIX 0x8411 -#define GL_FRAGMENT_LIGHT6_SGIX 0x8412 -#define GL_FRAGMENT_LIGHT7_SGIX 0x8413 -#endif - -#ifndef GL_IBM_rasterpos_clip -#define GL_RASTER_POSITION_UNCLIPPED_IBM 0x19262 -#endif - -#ifndef GL_HP_texture_lighting -#define GL_TEXTURE_LIGHTING_MODE_HP 0x8167 -#define GL_TEXTURE_POST_SPECULAR_HP 0x8168 -#define GL_TEXTURE_PRE_SPECULAR_HP 0x8169 -#endif - -#ifndef GL_EXT_draw_range_elements -#define GL_MAX_ELEMENTS_VERTICES_EXT 0x80E8 -#define GL_MAX_ELEMENTS_INDICES_EXT 0x80E9 -#endif - -#ifndef GL_WIN_phong_shading -#define GL_PHONG_WIN 0x80EA -#define GL_PHONG_HINT_WIN 0x80EB -#endif - -#ifndef GL_WIN_specular_fog -#define GL_FOG_SPECULAR_TEXTURE_WIN 0x80EC -#endif - -#ifndef GL_EXT_light_texture -#define GL_FRAGMENT_MATERIAL_EXT 0x8349 -#define GL_FRAGMENT_NORMAL_EXT 0x834A -#define GL_FRAGMENT_COLOR_EXT 0x834C -#define GL_ATTENUATION_EXT 0x834D -#define GL_SHADOW_ATTENUATION_EXT 0x834E -#define GL_TEXTURE_APPLICATION_MODE_EXT 0x834F -#define GL_TEXTURE_LIGHT_EXT 0x8350 -#define GL_TEXTURE_MATERIAL_FACE_EXT 0x8351 -#define GL_TEXTURE_MATERIAL_PARAMETER_EXT 0x8352 -/* reuse GL_FRAGMENT_DEPTH_EXT */ -#endif - -#ifndef GL_SGIX_blend_alpha_minmax -#define GL_ALPHA_MIN_SGIX 0x8320 -#define GL_ALPHA_MAX_SGIX 0x8321 -#endif - -#ifndef GL_SGIX_impact_pixel_texture -#define GL_PIXEL_TEX_GEN_Q_CEILING_SGIX 0x8184 -#define GL_PIXEL_TEX_GEN_Q_ROUND_SGIX 0x8185 -#define GL_PIXEL_TEX_GEN_Q_FLOOR_SGIX 0x8186 -#define GL_PIXEL_TEX_GEN_ALPHA_REPLACE_SGIX 0x8187 -#define GL_PIXEL_TEX_GEN_ALPHA_NO_REPLACE_SGIX 0x8188 -#define GL_PIXEL_TEX_GEN_ALPHA_LS_SGIX 0x8189 -#define GL_PIXEL_TEX_GEN_ALPHA_MS_SGIX 0x818A -#endif - -#ifndef GL_EXT_bgra -#define GL_BGR_EXT 0x80E0 -#define GL_BGRA_EXT 0x80E1 -#endif - -#ifndef GL_SGIX_async -#define GL_ASYNC_MARKER_SGIX 0x8329 -#endif - -#ifndef GL_SGIX_async_pixel -#define GL_ASYNC_TEX_IMAGE_SGIX 0x835C -#define GL_ASYNC_DRAW_PIXELS_SGIX 0x835D -#define GL_ASYNC_READ_PIXELS_SGIX 0x835E -#define GL_MAX_ASYNC_TEX_IMAGE_SGIX 0x835F -#define GL_MAX_ASYNC_DRAW_PIXELS_SGIX 0x8360 -#define GL_MAX_ASYNC_READ_PIXELS_SGIX 0x8361 -#endif - -#ifndef GL_SGIX_async_histogram -#define GL_ASYNC_HISTOGRAM_SGIX 0x832C -#define GL_MAX_ASYNC_HISTOGRAM_SGIX 0x832D -#endif - -#ifndef GL_INTEL_texture_scissor -#endif - -#ifndef GL_INTEL_parallel_arrays -#define GL_PARALLEL_ARRAYS_INTEL 0x83F4 -#define GL_VERTEX_ARRAY_PARALLEL_POINTERS_INTEL 0x83F5 -#define GL_NORMAL_ARRAY_PARALLEL_POINTERS_INTEL 0x83F6 -#define GL_COLOR_ARRAY_PARALLEL_POINTERS_INTEL 0x83F7 -#define GL_TEXTURE_COORD_ARRAY_PARALLEL_POINTERS_INTEL 0x83F8 -#endif - -#ifndef GL_HP_occlusion_test -#define GL_OCCLUSION_TEST_HP 0x8165 -#define GL_OCCLUSION_TEST_RESULT_HP 0x8166 -#endif - -#ifndef GL_EXT_pixel_transform -#define GL_PIXEL_TRANSFORM_2D_EXT 0x8330 -#define GL_PIXEL_MAG_FILTER_EXT 0x8331 -#define GL_PIXEL_MIN_FILTER_EXT 0x8332 -#define GL_PIXEL_CUBIC_WEIGHT_EXT 0x8333 -#define GL_CUBIC_EXT 0x8334 -#define GL_AVERAGE_EXT 0x8335 -#define GL_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8336 -#define GL_MAX_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8337 -#define GL_PIXEL_TRANSFORM_2D_MATRIX_EXT 0x8338 -#endif - -#ifndef GL_EXT_pixel_transform_color_table -#endif - -#ifndef GL_EXT_shared_texture_palette -#define GL_SHARED_TEXTURE_PALETTE_EXT 0x81FB -#endif - -#ifndef GL_EXT_separate_specular_color -#define GL_LIGHT_MODEL_COLOR_CONTROL_EXT 0x81F8 -#define GL_SINGLE_COLOR_EXT 0x81F9 -#define GL_SEPARATE_SPECULAR_COLOR_EXT 0x81FA -#endif - -#ifndef GL_EXT_secondary_color -#define GL_COLOR_SUM_EXT 0x8458 -#define GL_CURRENT_SECONDARY_COLOR_EXT 0x8459 -#define GL_SECONDARY_COLOR_ARRAY_SIZE_EXT 0x845A -#define GL_SECONDARY_COLOR_ARRAY_TYPE_EXT 0x845B -#define GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT 0x845C -#define GL_SECONDARY_COLOR_ARRAY_POINTER_EXT 0x845D -#define GL_SECONDARY_COLOR_ARRAY_EXT 0x845E -#endif - -#ifndef GL_EXT_texture_perturb_normal -#define GL_PERTURB_EXT 0x85AE -#define GL_TEXTURE_NORMAL_EXT 0x85AF -#endif - -#ifndef GL_EXT_multi_draw_arrays -#endif - -#ifndef GL_EXT_fog_coord -#define GL_FOG_COORDINATE_SOURCE_EXT 0x8450 -#define GL_FOG_COORDINATE_EXT 0x8451 -#define GL_FRAGMENT_DEPTH_EXT 0x8452 -#define GL_CURRENT_FOG_COORDINATE_EXT 0x8453 -#define GL_FOG_COORDINATE_ARRAY_TYPE_EXT 0x8454 -#define GL_FOG_COORDINATE_ARRAY_STRIDE_EXT 0x8455 -#define GL_FOG_COORDINATE_ARRAY_POINTER_EXT 0x8456 -#define GL_FOG_COORDINATE_ARRAY_EXT 0x8457 -#endif - -#ifndef GL_REND_screen_coordinates -#define GL_SCREEN_COORDINATES_REND 0x8490 -#define GL_INVERTED_SCREEN_W_REND 0x8491 -#endif - -#ifndef GL_EXT_coordinate_frame -#define GL_TANGENT_ARRAY_EXT 0x8439 -#define GL_BINORMAL_ARRAY_EXT 0x843A -#define GL_CURRENT_TANGENT_EXT 0x843B -#define GL_CURRENT_BINORMAL_EXT 0x843C -#define GL_TANGENT_ARRAY_TYPE_EXT 0x843E -#define GL_TANGENT_ARRAY_STRIDE_EXT 0x843F -#define GL_BINORMAL_ARRAY_TYPE_EXT 0x8440 -#define GL_BINORMAL_ARRAY_STRIDE_EXT 0x8441 -#define GL_TANGENT_ARRAY_POINTER_EXT 0x8442 -#define GL_BINORMAL_ARRAY_POINTER_EXT 0x8443 -#define GL_MAP1_TANGENT_EXT 0x8444 -#define GL_MAP2_TANGENT_EXT 0x8445 -#define GL_MAP1_BINORMAL_EXT 0x8446 -#define GL_MAP2_BINORMAL_EXT 0x8447 -#endif - -#ifndef GL_EXT_texture_env_combine -#define GL_COMBINE_EXT 0x8570 -#define GL_COMBINE_RGB_EXT 0x8571 -#define GL_COMBINE_ALPHA_EXT 0x8572 -#define GL_RGB_SCALE_EXT 0x8573 -#define GL_ADD_SIGNED_EXT 0x8574 -#define GL_INTERPOLATE_EXT 0x8575 -#define GL_CONSTANT_EXT 0x8576 -#define GL_PRIMARY_COLOR_EXT 0x8577 -#define GL_PREVIOUS_EXT 0x8578 -#define GL_SOURCE0_RGB_EXT 0x8580 -#define GL_SOURCE1_RGB_EXT 0x8581 -#define GL_SOURCE2_RGB_EXT 0x8582 -#define GL_SOURCE0_ALPHA_EXT 0x8588 -#define GL_SOURCE1_ALPHA_EXT 0x8589 -#define GL_SOURCE2_ALPHA_EXT 0x858A -#define GL_OPERAND0_RGB_EXT 0x8590 -#define GL_OPERAND1_RGB_EXT 0x8591 -#define GL_OPERAND2_RGB_EXT 0x8592 -#define GL_OPERAND0_ALPHA_EXT 0x8598 -#define GL_OPERAND1_ALPHA_EXT 0x8599 -#define GL_OPERAND2_ALPHA_EXT 0x859A -#endif - -#ifndef GL_APPLE_specular_vector -#define GL_LIGHT_MODEL_SPECULAR_VECTOR_APPLE 0x85B0 -#endif - -#ifndef GL_APPLE_transform_hint -#define GL_TRANSFORM_HINT_APPLE 0x85B1 -#endif - -#ifndef GL_SGIX_fog_scale -#define GL_FOG_SCALE_SGIX 0x81FC -#define GL_FOG_SCALE_VALUE_SGIX 0x81FD -#endif - -#ifndef GL_SUNX_constant_data -#define GL_UNPACK_CONSTANT_DATA_SUNX 0x81D5 -#define GL_TEXTURE_CONSTANT_DATA_SUNX 0x81D6 -#endif - -#ifndef GL_SUN_global_alpha -#define GL_GLOBAL_ALPHA_SUN 0x81D9 -#define GL_GLOBAL_ALPHA_FACTOR_SUN 0x81DA -#endif - -#ifndef GL_SUN_triangle_list -#define GL_RESTART_SUN 0x0001 -#define GL_REPLACE_MIDDLE_SUN 0x0002 -#define GL_REPLACE_OLDEST_SUN 0x0003 -#define GL_TRIANGLE_LIST_SUN 0x81D7 -#define GL_REPLACEMENT_CODE_SUN 0x81D8 -#define GL_REPLACEMENT_CODE_ARRAY_SUN 0x85C0 -#define GL_REPLACEMENT_CODE_ARRAY_TYPE_SUN 0x85C1 -#define GL_REPLACEMENT_CODE_ARRAY_STRIDE_SUN 0x85C2 -#define GL_REPLACEMENT_CODE_ARRAY_POINTER_SUN 0x85C3 -#define GL_R1UI_V3F_SUN 0x85C4 -#define GL_R1UI_C4UB_V3F_SUN 0x85C5 -#define GL_R1UI_C3F_V3F_SUN 0x85C6 -#define GL_R1UI_N3F_V3F_SUN 0x85C7 -#define GL_R1UI_C4F_N3F_V3F_SUN 0x85C8 -#define GL_R1UI_T2F_V3F_SUN 0x85C9 -#define GL_R1UI_T2F_N3F_V3F_SUN 0x85CA -#define GL_R1UI_T2F_C4F_N3F_V3F_SUN 0x85CB -#endif - -#ifndef GL_SUN_vertex -#endif - -#ifndef GL_EXT_blend_func_separate -#define GL_BLEND_DST_RGB_EXT 0x80C8 -#define GL_BLEND_SRC_RGB_EXT 0x80C9 -#define GL_BLEND_DST_ALPHA_EXT 0x80CA -#define GL_BLEND_SRC_ALPHA_EXT 0x80CB -#endif - -#ifndef GL_INGR_color_clamp -#define GL_RED_MIN_CLAMP_INGR 0x8560 -#define GL_GREEN_MIN_CLAMP_INGR 0x8561 -#define GL_BLUE_MIN_CLAMP_INGR 0x8562 -#define GL_ALPHA_MIN_CLAMP_INGR 0x8563 -#define GL_RED_MAX_CLAMP_INGR 0x8564 -#define GL_GREEN_MAX_CLAMP_INGR 0x8565 -#define GL_BLUE_MAX_CLAMP_INGR 0x8566 -#define GL_ALPHA_MAX_CLAMP_INGR 0x8567 -#endif - -#ifndef GL_INGR_interlace_read -#define GL_INTERLACE_READ_INGR 0x8568 -#endif - -#ifndef GL_EXT_stencil_wrap -#define GL_INCR_WRAP_EXT 0x8507 -#define GL_DECR_WRAP_EXT 0x8508 -#endif - -#ifndef GL_EXT_422_pixels -#define GL_422_EXT 0x80CC -#define GL_422_REV_EXT 0x80CD -#define GL_422_AVERAGE_EXT 0x80CE -#define GL_422_REV_AVERAGE_EXT 0x80CF -#endif - -#ifndef GL_NV_texgen_reflection -#define GL_NORMAL_MAP_NV 0x8511 -#define GL_REFLECTION_MAP_NV 0x8512 -#endif - -#ifndef GL_EXT_texture_cube_map -#define GL_NORMAL_MAP_EXT 0x8511 -#define GL_REFLECTION_MAP_EXT 0x8512 -#define GL_TEXTURE_CUBE_MAP_EXT 0x8513 -#define GL_TEXTURE_BINDING_CUBE_MAP_EXT 0x8514 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT 0x8515 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_EXT 0x8516 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_EXT 0x8517 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_EXT 0x8518 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_EXT 0x8519 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT 0x851A -#define GL_PROXY_TEXTURE_CUBE_MAP_EXT 0x851B -#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_EXT 0x851C -#endif - -#ifndef GL_SUN_convolution_border_modes -#define GL_WRAP_BORDER_SUN 0x81D4 -#endif - -#ifndef GL_EXT_texture_env_add -#endif - -#ifndef GL_EXT_texture_lod_bias -#define GL_MAX_TEXTURE_LOD_BIAS_EXT 0x84FD -#define GL_TEXTURE_FILTER_CONTROL_EXT 0x8500 -#define GL_TEXTURE_LOD_BIAS_EXT 0x8501 -#endif - -#ifndef GL_EXT_texture_filter_anisotropic -#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE -#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF -#endif - -#ifndef GL_EXT_vertex_weighting -#define GL_MODELVIEW0_STACK_DEPTH_EXT GL_MODELVIEW_STACK_DEPTH -#define GL_MODELVIEW1_STACK_DEPTH_EXT 0x8502 -#define GL_MODELVIEW0_MATRIX_EXT GL_MODELVIEW_MATRIX -#define GL_MODELVIEW1_MATRIX_EXT 0x8506 -#define GL_VERTEX_WEIGHTING_EXT 0x8509 -#define GL_MODELVIEW0_EXT GL_MODELVIEW -#define GL_MODELVIEW1_EXT 0x850A -#define GL_CURRENT_VERTEX_WEIGHT_EXT 0x850B -#define GL_VERTEX_WEIGHT_ARRAY_EXT 0x850C -#define GL_VERTEX_WEIGHT_ARRAY_SIZE_EXT 0x850D -#define GL_VERTEX_WEIGHT_ARRAY_TYPE_EXT 0x850E -#define GL_VERTEX_WEIGHT_ARRAY_STRIDE_EXT 0x850F -#define GL_VERTEX_WEIGHT_ARRAY_POINTER_EXT 0x8510 -#endif - -#ifndef GL_NV_light_max_exponent -#define GL_MAX_SHININESS_NV 0x8504 -#define GL_MAX_SPOT_EXPONENT_NV 0x8505 -#endif - -#ifndef GL_NV_vertex_array_range -#define GL_VERTEX_ARRAY_RANGE_NV 0x851D -#define GL_VERTEX_ARRAY_RANGE_LENGTH_NV 0x851E -#define GL_VERTEX_ARRAY_RANGE_VALID_NV 0x851F -#define GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_NV 0x8520 -#define GL_VERTEX_ARRAY_RANGE_POINTER_NV 0x8521 -#endif - -#ifndef GL_NV_register_combiners -#define GL_REGISTER_COMBINERS_NV 0x8522 -#define GL_VARIABLE_A_NV 0x8523 -#define GL_VARIABLE_B_NV 0x8524 -#define GL_VARIABLE_C_NV 0x8525 -#define GL_VARIABLE_D_NV 0x8526 -#define GL_VARIABLE_E_NV 0x8527 -#define GL_VARIABLE_F_NV 0x8528 -#define GL_VARIABLE_G_NV 0x8529 -#define GL_CONSTANT_COLOR0_NV 0x852A -#define GL_CONSTANT_COLOR1_NV 0x852B -#define GL_PRIMARY_COLOR_NV 0x852C -#define GL_SECONDARY_COLOR_NV 0x852D -#define GL_SPARE0_NV 0x852E -#define GL_SPARE1_NV 0x852F -#define GL_DISCARD_NV 0x8530 -#define GL_E_TIMES_F_NV 0x8531 -#define GL_SPARE0_PLUS_SECONDARY_COLOR_NV 0x8532 -#define GL_UNSIGNED_IDENTITY_NV 0x8536 -#define GL_UNSIGNED_INVERT_NV 0x8537 -#define GL_EXPAND_NORMAL_NV 0x8538 -#define GL_EXPAND_NEGATE_NV 0x8539 -#define GL_HALF_BIAS_NORMAL_NV 0x853A -#define GL_HALF_BIAS_NEGATE_NV 0x853B -#define GL_SIGNED_IDENTITY_NV 0x853C -#define GL_SIGNED_NEGATE_NV 0x853D -#define GL_SCALE_BY_TWO_NV 0x853E -#define GL_SCALE_BY_FOUR_NV 0x853F -#define GL_SCALE_BY_ONE_HALF_NV 0x8540 -#define GL_BIAS_BY_NEGATIVE_ONE_HALF_NV 0x8541 -#define GL_COMBINER_INPUT_NV 0x8542 -#define GL_COMBINER_MAPPING_NV 0x8543 -#define GL_COMBINER_COMPONENT_USAGE_NV 0x8544 -#define GL_COMBINER_AB_DOT_PRODUCT_NV 0x8545 -#define GL_COMBINER_CD_DOT_PRODUCT_NV 0x8546 -#define GL_COMBINER_MUX_SUM_NV 0x8547 -#define GL_COMBINER_SCALE_NV 0x8548 -#define GL_COMBINER_BIAS_NV 0x8549 -#define GL_COMBINER_AB_OUTPUT_NV 0x854A -#define GL_COMBINER_CD_OUTPUT_NV 0x854B -#define GL_COMBINER_SUM_OUTPUT_NV 0x854C -#define GL_MAX_GENERAL_COMBINERS_NV 0x854D -#define GL_NUM_GENERAL_COMBINERS_NV 0x854E -#define GL_COLOR_SUM_CLAMP_NV 0x854F -#define GL_COMBINER0_NV 0x8550 -#define GL_COMBINER1_NV 0x8551 -#define GL_COMBINER2_NV 0x8552 -#define GL_COMBINER3_NV 0x8553 -#define GL_COMBINER4_NV 0x8554 -#define GL_COMBINER5_NV 0x8555 -#define GL_COMBINER6_NV 0x8556 -#define GL_COMBINER7_NV 0x8557 -/* reuse GL_TEXTURE0_ARB */ -/* reuse GL_TEXTURE1_ARB */ -/* reuse GL_ZERO */ -/* reuse GL_NONE */ -/* reuse GL_FOG */ -#endif - -#ifndef GL_NV_fog_distance -#define GL_FOG_DISTANCE_MODE_NV 0x855A -#define GL_EYE_RADIAL_NV 0x855B -#define GL_EYE_PLANE_ABSOLUTE_NV 0x855C -/* reuse GL_EYE_PLANE */ -#endif - -#ifndef GL_NV_texgen_emboss -#define GL_EMBOSS_LIGHT_NV 0x855D -#define GL_EMBOSS_CONSTANT_NV 0x855E -#define GL_EMBOSS_MAP_NV 0x855F -#endif - -#ifndef GL_NV_blend_square -#endif - -#ifndef GL_NV_texture_env_combine4 -#define GL_COMBINE4_NV 0x8503 -#define GL_SOURCE3_RGB_NV 0x8583 -#define GL_SOURCE3_ALPHA_NV 0x858B -#define GL_OPERAND3_RGB_NV 0x8593 -#define GL_OPERAND3_ALPHA_NV 0x859B -#endif - -#ifndef GL_MESA_resize_buffers -#endif - -#ifndef GL_MESA_window_pos -#endif - -#ifndef GL_EXT_texture_compression_s3tc -#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 -#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 -#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 -#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 -#endif - -#ifndef GL_IBM_cull_vertex -#define GL_CULL_VERTEX_IBM 103050 -#endif - -#ifndef GL_IBM_multimode_draw_arrays -#endif - -#ifndef GL_IBM_vertex_array_lists -#define GL_VERTEX_ARRAY_LIST_IBM 103070 -#define GL_NORMAL_ARRAY_LIST_IBM 103071 -#define GL_COLOR_ARRAY_LIST_IBM 103072 -#define GL_INDEX_ARRAY_LIST_IBM 103073 -#define GL_TEXTURE_COORD_ARRAY_LIST_IBM 103074 -#define GL_EDGE_FLAG_ARRAY_LIST_IBM 103075 -#define GL_FOG_COORDINATE_ARRAY_LIST_IBM 103076 -#define GL_SECONDARY_COLOR_ARRAY_LIST_IBM 103077 -#define GL_VERTEX_ARRAY_LIST_STRIDE_IBM 103080 -#define GL_NORMAL_ARRAY_LIST_STRIDE_IBM 103081 -#define GL_COLOR_ARRAY_LIST_STRIDE_IBM 103082 -#define GL_INDEX_ARRAY_LIST_STRIDE_IBM 103083 -#define GL_TEXTURE_COORD_ARRAY_LIST_STRIDE_IBM 103084 -#define GL_EDGE_FLAG_ARRAY_LIST_STRIDE_IBM 103085 -#define GL_FOG_COORDINATE_ARRAY_LIST_STRIDE_IBM 103086 -#define GL_SECONDARY_COLOR_ARRAY_LIST_STRIDE_IBM 103087 -#endif - -#ifndef GL_SGIX_subsample -#define GL_PACK_SUBSAMPLE_RATE_SGIX 0x85A0 -#define GL_UNPACK_SUBSAMPLE_RATE_SGIX 0x85A1 -#define GL_PIXEL_SUBSAMPLE_4444_SGIX 0x85A2 -#define GL_PIXEL_SUBSAMPLE_2424_SGIX 0x85A3 -#define GL_PIXEL_SUBSAMPLE_4242_SGIX 0x85A4 -#endif - -#ifndef GL_SGIX_ycrcb_subsample -#endif - -#ifndef GL_SGIX_ycrcba -#define GL_YCRCB_SGIX 0x8318 -#define GL_YCRCBA_SGIX 0x8319 -#endif - -#ifndef GL_SGI_depth_pass_instrument -#define GL_DEPTH_PASS_INSTRUMENT_SGIX 0x8310 -#define GL_DEPTH_PASS_INSTRUMENT_COUNTERS_SGIX 0x8311 -#define GL_DEPTH_PASS_INSTRUMENT_MAX_SGIX 0x8312 -#endif - -#ifndef GL_3DFX_texture_compression_FXT1 -#define GL_COMPRESSED_RGB_FXT1_3DFX 0x86B0 -#define GL_COMPRESSED_RGBA_FXT1_3DFX 0x86B1 -#endif - -#ifndef GL_3DFX_multisample -#define GL_MULTISAMPLE_3DFX 0x86B2 -#define GL_SAMPLE_BUFFERS_3DFX 0x86B3 -#define GL_SAMPLES_3DFX 0x86B4 -#define GL_MULTISAMPLE_BIT_3DFX 0x20000000 -#endif - -#ifndef GL_3DFX_tbuffer -#endif - -#ifndef GL_EXT_multisample -#define GL_MULTISAMPLE_EXT 0x809D -#define GL_SAMPLE_ALPHA_TO_MASK_EXT 0x809E -#define GL_SAMPLE_ALPHA_TO_ONE_EXT 0x809F -#define GL_SAMPLE_MASK_EXT 0x80A0 -#define GL_1PASS_EXT 0x80A1 -#define GL_2PASS_0_EXT 0x80A2 -#define GL_2PASS_1_EXT 0x80A3 -#define GL_4PASS_0_EXT 0x80A4 -#define GL_4PASS_1_EXT 0x80A5 -#define GL_4PASS_2_EXT 0x80A6 -#define GL_4PASS_3_EXT 0x80A7 -#define GL_SAMPLE_BUFFERS_EXT 0x80A8 -#define GL_SAMPLES_EXT 0x80A9 -#define GL_SAMPLE_MASK_VALUE_EXT 0x80AA -#define GL_SAMPLE_MASK_INVERT_EXT 0x80AB -#define GL_SAMPLE_PATTERN_EXT 0x80AC -#define GL_MULTISAMPLE_BIT_EXT 0x20000000 -#endif - -#ifndef GL_SGIX_vertex_preclip -#define GL_VERTEX_PRECLIP_SGIX 0x83EE -#define GL_VERTEX_PRECLIP_HINT_SGIX 0x83EF -#endif - -#ifndef GL_SGIX_convolution_accuracy -#define GL_CONVOLUTION_HINT_SGIX 0x8316 -#endif - -#ifndef GL_SGIX_resample -#define GL_PACK_RESAMPLE_SGIX 0x842C -#define GL_UNPACK_RESAMPLE_SGIX 0x842D -#define GL_RESAMPLE_REPLICATE_SGIX 0x842E -#define GL_RESAMPLE_ZERO_FILL_SGIX 0x842F -#define GL_RESAMPLE_DECIMATE_SGIX 0x8430 -#endif - -#ifndef GL_SGIS_point_line_texgen -#define GL_EYE_DISTANCE_TO_POINT_SGIS 0x81F0 -#define GL_OBJECT_DISTANCE_TO_POINT_SGIS 0x81F1 -#define GL_EYE_DISTANCE_TO_LINE_SGIS 0x81F2 -#define GL_OBJECT_DISTANCE_TO_LINE_SGIS 0x81F3 -#define GL_EYE_POINT_SGIS 0x81F4 -#define GL_OBJECT_POINT_SGIS 0x81F5 -#define GL_EYE_LINE_SGIS 0x81F6 -#define GL_OBJECT_LINE_SGIS 0x81F7 -#endif - -#ifndef GL_SGIS_texture_color_mask -#define GL_TEXTURE_COLOR_WRITEMASK_SGIS 0x81EF -#endif - -#ifndef GL_EXT_texture_env_dot3 -#define GL_DOT3_RGB_EXT 0x8740 -#define GL_DOT3_RGBA_EXT 0x8741 -#endif - -#ifndef GL_ATI_texture_mirror_once -#define GL_MIRROR_CLAMP_ATI 0x8742 -#define GL_MIRROR_CLAMP_TO_EDGE_ATI 0x8743 -#endif - -#ifndef GL_NV_fence -#define GL_ALL_COMPLETED_NV 0x84F2 -#define GL_FENCE_STATUS_NV 0x84F3 -#define GL_FENCE_CONDITION_NV 0x84F4 -#endif - -#ifndef GL_IBM_texture_mirrored_repeat -#define GL_MIRRORED_REPEAT_IBM 0x8370 -#endif - -#ifndef GL_NV_evaluators -#define GL_EVAL_2D_NV 0x86C0 -#define GL_EVAL_TRIANGULAR_2D_NV 0x86C1 -#define GL_MAP_TESSELLATION_NV 0x86C2 -#define GL_MAP_ATTRIB_U_ORDER_NV 0x86C3 -#define GL_MAP_ATTRIB_V_ORDER_NV 0x86C4 -#define GL_EVAL_FRACTIONAL_TESSELLATION_NV 0x86C5 -#define GL_EVAL_VERTEX_ATTRIB0_NV 0x86C6 -#define GL_EVAL_VERTEX_ATTRIB1_NV 0x86C7 -#define GL_EVAL_VERTEX_ATTRIB2_NV 0x86C8 -#define GL_EVAL_VERTEX_ATTRIB3_NV 0x86C9 -#define GL_EVAL_VERTEX_ATTRIB4_NV 0x86CA -#define GL_EVAL_VERTEX_ATTRIB5_NV 0x86CB -#define GL_EVAL_VERTEX_ATTRIB6_NV 0x86CC -#define GL_EVAL_VERTEX_ATTRIB7_NV 0x86CD -#define GL_EVAL_VERTEX_ATTRIB8_NV 0x86CE -#define GL_EVAL_VERTEX_ATTRIB9_NV 0x86CF -#define GL_EVAL_VERTEX_ATTRIB10_NV 0x86D0 -#define GL_EVAL_VERTEX_ATTRIB11_NV 0x86D1 -#define GL_EVAL_VERTEX_ATTRIB12_NV 0x86D2 -#define GL_EVAL_VERTEX_ATTRIB13_NV 0x86D3 -#define GL_EVAL_VERTEX_ATTRIB14_NV 0x86D4 -#define GL_EVAL_VERTEX_ATTRIB15_NV 0x86D5 -#define GL_MAX_MAP_TESSELLATION_NV 0x86D6 -#define GL_MAX_RATIONAL_EVAL_ORDER_NV 0x86D7 -#endif - -#ifndef GL_NV_packed_depth_stencil -#define GL_DEPTH_STENCIL_NV 0x84F9 -#define GL_UNSIGNED_INT_24_8_NV 0x84FA -#endif - -#ifndef GL_EXT_packed_depth_stencil -#define GL_DEPTH_STENCIL_EXT 0x84F9 -#define GL_DEPTH24_STENCIL8_EXT 0x88F0 -#define GL_TEXTURE_STENCIL_SIZE_EXT 0x88F1 -#define GL_UNSIGNED_INT_24_8_EXT 0x84FA -#endif - -#ifndef GL_NV_register_combiners2 -#define GL_PER_STAGE_CONSTANTS_NV 0x8535 -#endif - -#ifndef GL_NV_texture_compression_vtc -#endif - -#ifndef GL_NV_texture_rectangle -#define GL_TEXTURE_RECTANGLE_NV 0x84F5 -#define GL_TEXTURE_BINDING_RECTANGLE_NV 0x84F6 -#define GL_PROXY_TEXTURE_RECTANGLE_NV 0x84F7 -#define GL_MAX_RECTANGLE_TEXTURE_SIZE_NV 0x84F8 -#endif - -#ifndef GL_NV_texture_shader -#define GL_OFFSET_TEXTURE_RECTANGLE_NV 0x864C -#define GL_OFFSET_TEXTURE_RECTANGLE_SCALE_NV 0x864D -#define GL_DOT_PRODUCT_TEXTURE_RECTANGLE_NV 0x864E -#define GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV 0x86D9 -#define GL_UNSIGNED_INT_S8_S8_8_8_NV 0x86DA -#define GL_UNSIGNED_INT_8_8_S8_S8_REV_NV 0x86DB -#define GL_DSDT_MAG_INTENSITY_NV 0x86DC -#define GL_SHADER_CONSISTENT_NV 0x86DD -#define GL_TEXTURE_SHADER_NV 0x86DE -#define GL_SHADER_OPERATION_NV 0x86DF -#define GL_CULL_MODES_NV 0x86E0 -#define GL_OFFSET_TEXTURE_MATRIX_NV 0x86E1 -#define GL_OFFSET_TEXTURE_SCALE_NV 0x86E2 -#define GL_OFFSET_TEXTURE_BIAS_NV 0x86E3 -#define GL_OFFSET_TEXTURE_2D_MATRIX_NV GL_OFFSET_TEXTURE_MATRIX_NV -#define GL_OFFSET_TEXTURE_2D_SCALE_NV GL_OFFSET_TEXTURE_SCALE_NV -#define GL_OFFSET_TEXTURE_2D_BIAS_NV GL_OFFSET_TEXTURE_BIAS_NV -#define GL_PREVIOUS_TEXTURE_INPUT_NV 0x86E4 -#define GL_CONST_EYE_NV 0x86E5 -#define GL_PASS_THROUGH_NV 0x86E6 -#define GL_CULL_FRAGMENT_NV 0x86E7 -#define GL_OFFSET_TEXTURE_2D_NV 0x86E8 -#define GL_DEPENDENT_AR_TEXTURE_2D_NV 0x86E9 -#define GL_DEPENDENT_GB_TEXTURE_2D_NV 0x86EA -#define GL_DOT_PRODUCT_NV 0x86EC -#define GL_DOT_PRODUCT_DEPTH_REPLACE_NV 0x86ED -#define GL_DOT_PRODUCT_TEXTURE_2D_NV 0x86EE -#define GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV 0x86F0 -#define GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV 0x86F1 -#define GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV 0x86F2 -#define GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV 0x86F3 -#define GL_HILO_NV 0x86F4 -#define GL_DSDT_NV 0x86F5 -#define GL_DSDT_MAG_NV 0x86F6 -#define GL_DSDT_MAG_VIB_NV 0x86F7 -#define GL_HILO16_NV 0x86F8 -#define GL_SIGNED_HILO_NV 0x86F9 -#define GL_SIGNED_HILO16_NV 0x86FA -#define GL_SIGNED_RGBA_NV 0x86FB -#define GL_SIGNED_RGBA8_NV 0x86FC -#define GL_SIGNED_RGB_NV 0x86FE -#define GL_SIGNED_RGB8_NV 0x86FF -#define GL_SIGNED_LUMINANCE_NV 0x8701 -#define GL_SIGNED_LUMINANCE8_NV 0x8702 -#define GL_SIGNED_LUMINANCE_ALPHA_NV 0x8703 -#define GL_SIGNED_LUMINANCE8_ALPHA8_NV 0x8704 -#define GL_SIGNED_ALPHA_NV 0x8705 -#define GL_SIGNED_ALPHA8_NV 0x8706 -#define GL_SIGNED_INTENSITY_NV 0x8707 -#define GL_SIGNED_INTENSITY8_NV 0x8708 -#define GL_DSDT8_NV 0x8709 -#define GL_DSDT8_MAG8_NV 0x870A -#define GL_DSDT8_MAG8_INTENSITY8_NV 0x870B -#define GL_SIGNED_RGB_UNSIGNED_ALPHA_NV 0x870C -#define GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV 0x870D -#define GL_HI_SCALE_NV 0x870E -#define GL_LO_SCALE_NV 0x870F -#define GL_DS_SCALE_NV 0x8710 -#define GL_DT_SCALE_NV 0x8711 -#define GL_MAGNITUDE_SCALE_NV 0x8712 -#define GL_VIBRANCE_SCALE_NV 0x8713 -#define GL_HI_BIAS_NV 0x8714 -#define GL_LO_BIAS_NV 0x8715 -#define GL_DS_BIAS_NV 0x8716 -#define GL_DT_BIAS_NV 0x8717 -#define GL_MAGNITUDE_BIAS_NV 0x8718 -#define GL_VIBRANCE_BIAS_NV 0x8719 -#define GL_TEXTURE_BORDER_VALUES_NV 0x871A -#define GL_TEXTURE_HI_SIZE_NV 0x871B -#define GL_TEXTURE_LO_SIZE_NV 0x871C -#define GL_TEXTURE_DS_SIZE_NV 0x871D -#define GL_TEXTURE_DT_SIZE_NV 0x871E -#define GL_TEXTURE_MAG_SIZE_NV 0x871F -#endif - -#ifndef GL_NV_texture_shader2 -#define GL_DOT_PRODUCT_TEXTURE_3D_NV 0x86EF -#endif - -#ifndef GL_NV_vertex_array_range2 -#define GL_VERTEX_ARRAY_RANGE_WITHOUT_FLUSH_NV 0x8533 -#endif - -#ifndef GL_NV_vertex_program -#define GL_VERTEX_PROGRAM_NV 0x8620 -#define GL_VERTEX_STATE_PROGRAM_NV 0x8621 -#define GL_ATTRIB_ARRAY_SIZE_NV 0x8623 -#define GL_ATTRIB_ARRAY_STRIDE_NV 0x8624 -#define GL_ATTRIB_ARRAY_TYPE_NV 0x8625 -#define GL_CURRENT_ATTRIB_NV 0x8626 -#define GL_PROGRAM_LENGTH_NV 0x8627 -#define GL_PROGRAM_STRING_NV 0x8628 -#define GL_MODELVIEW_PROJECTION_NV 0x8629 -#define GL_IDENTITY_NV 0x862A -#define GL_INVERSE_NV 0x862B -#define GL_TRANSPOSE_NV 0x862C -#define GL_INVERSE_TRANSPOSE_NV 0x862D -#define GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV 0x862E -#define GL_MAX_TRACK_MATRICES_NV 0x862F -#define GL_MATRIX0_NV 0x8630 -#define GL_MATRIX1_NV 0x8631 -#define GL_MATRIX2_NV 0x8632 -#define GL_MATRIX3_NV 0x8633 -#define GL_MATRIX4_NV 0x8634 -#define GL_MATRIX5_NV 0x8635 -#define GL_MATRIX6_NV 0x8636 -#define GL_MATRIX7_NV 0x8637 -#define GL_CURRENT_MATRIX_STACK_DEPTH_NV 0x8640 -#define GL_CURRENT_MATRIX_NV 0x8641 -#define GL_VERTEX_PROGRAM_POINT_SIZE_NV 0x8642 -#define GL_VERTEX_PROGRAM_TWO_SIDE_NV 0x8643 -#define GL_PROGRAM_PARAMETER_NV 0x8644 -#define GL_ATTRIB_ARRAY_POINTER_NV 0x8645 -#define GL_PROGRAM_TARGET_NV 0x8646 -#define GL_PROGRAM_RESIDENT_NV 0x8647 -#define GL_TRACK_MATRIX_NV 0x8648 -#define GL_TRACK_MATRIX_TRANSFORM_NV 0x8649 -#define GL_VERTEX_PROGRAM_BINDING_NV 0x864A -#define GL_PROGRAM_ERROR_POSITION_NV 0x864B -#define GL_VERTEX_ATTRIB_ARRAY0_NV 0x8650 -#define GL_VERTEX_ATTRIB_ARRAY1_NV 0x8651 -#define GL_VERTEX_ATTRIB_ARRAY2_NV 0x8652 -#define GL_VERTEX_ATTRIB_ARRAY3_NV 0x8653 -#define GL_VERTEX_ATTRIB_ARRAY4_NV 0x8654 -#define GL_VERTEX_ATTRIB_ARRAY5_NV 0x8655 -#define GL_VERTEX_ATTRIB_ARRAY6_NV 0x8656 -#define GL_VERTEX_ATTRIB_ARRAY7_NV 0x8657 -#define GL_VERTEX_ATTRIB_ARRAY8_NV 0x8658 -#define GL_VERTEX_ATTRIB_ARRAY9_NV 0x8659 -#define GL_VERTEX_ATTRIB_ARRAY10_NV 0x865A -#define GL_VERTEX_ATTRIB_ARRAY11_NV 0x865B -#define GL_VERTEX_ATTRIB_ARRAY12_NV 0x865C -#define GL_VERTEX_ATTRIB_ARRAY13_NV 0x865D -#define GL_VERTEX_ATTRIB_ARRAY14_NV 0x865E -#define GL_VERTEX_ATTRIB_ARRAY15_NV 0x865F -#define GL_MAP1_VERTEX_ATTRIB0_4_NV 0x8660 -#define GL_MAP1_VERTEX_ATTRIB1_4_NV 0x8661 -#define GL_MAP1_VERTEX_ATTRIB2_4_NV 0x8662 -#define GL_MAP1_VERTEX_ATTRIB3_4_NV 0x8663 -#define GL_MAP1_VERTEX_ATTRIB4_4_NV 0x8664 -#define GL_MAP1_VERTEX_ATTRIB5_4_NV 0x8665 -#define GL_MAP1_VERTEX_ATTRIB6_4_NV 0x8666 -#define GL_MAP1_VERTEX_ATTRIB7_4_NV 0x8667 -#define GL_MAP1_VERTEX_ATTRIB8_4_NV 0x8668 -#define GL_MAP1_VERTEX_ATTRIB9_4_NV 0x8669 -#define GL_MAP1_VERTEX_ATTRIB10_4_NV 0x866A -#define GL_MAP1_VERTEX_ATTRIB11_4_NV 0x866B -#define GL_MAP1_VERTEX_ATTRIB12_4_NV 0x866C -#define GL_MAP1_VERTEX_ATTRIB13_4_NV 0x866D -#define GL_MAP1_VERTEX_ATTRIB14_4_NV 0x866E -#define GL_MAP1_VERTEX_ATTRIB15_4_NV 0x866F -#define GL_MAP2_VERTEX_ATTRIB0_4_NV 0x8670 -#define GL_MAP2_VERTEX_ATTRIB1_4_NV 0x8671 -#define GL_MAP2_VERTEX_ATTRIB2_4_NV 0x8672 -#define GL_MAP2_VERTEX_ATTRIB3_4_NV 0x8673 -#define GL_MAP2_VERTEX_ATTRIB4_4_NV 0x8674 -#define GL_MAP2_VERTEX_ATTRIB5_4_NV 0x8675 -#define GL_MAP2_VERTEX_ATTRIB6_4_NV 0x8676 -#define GL_MAP2_VERTEX_ATTRIB7_4_NV 0x8677 -#define GL_MAP2_VERTEX_ATTRIB8_4_NV 0x8678 -#define GL_MAP2_VERTEX_ATTRIB9_4_NV 0x8679 -#define GL_MAP2_VERTEX_ATTRIB10_4_NV 0x867A -#define GL_MAP2_VERTEX_ATTRIB11_4_NV 0x867B -#define GL_MAP2_VERTEX_ATTRIB12_4_NV 0x867C -#define GL_MAP2_VERTEX_ATTRIB13_4_NV 0x867D -#define GL_MAP2_VERTEX_ATTRIB14_4_NV 0x867E -#define GL_MAP2_VERTEX_ATTRIB15_4_NV 0x867F -#endif - -#ifndef GL_SGIX_texture_coordinate_clamp -#define GL_TEXTURE_MAX_CLAMP_S_SGIX 0x8369 -#define GL_TEXTURE_MAX_CLAMP_T_SGIX 0x836A -#define GL_TEXTURE_MAX_CLAMP_R_SGIX 0x836B -#endif - -#ifndef GL_SGIX_scalebias_hint -#define GL_SCALEBIAS_HINT_SGIX 0x8322 -#endif - -#ifndef GL_OML_interlace -#define GL_INTERLACE_OML 0x8980 -#define GL_INTERLACE_READ_OML 0x8981 -#endif - -#ifndef GL_OML_subsample -#define GL_FORMAT_SUBSAMPLE_24_24_OML 0x8982 -#define GL_FORMAT_SUBSAMPLE_244_244_OML 0x8983 -#endif - -#ifndef GL_OML_resample -#define GL_PACK_RESAMPLE_OML 0x8984 -#define GL_UNPACK_RESAMPLE_OML 0x8985 -#define GL_RESAMPLE_REPLICATE_OML 0x8986 -#define GL_RESAMPLE_ZERO_FILL_OML 0x8987 -#define GL_RESAMPLE_AVERAGE_OML 0x8988 -#define GL_RESAMPLE_DECIMATE_OML 0x8989 -#endif - -#ifndef GL_NV_copy_depth_to_color -#define GL_DEPTH_STENCIL_TO_RGBA_NV 0x886E -#define GL_DEPTH_STENCIL_TO_BGRA_NV 0x886F -#endif - -#ifndef GL_ATI_envmap_bumpmap -#define GL_BUMP_ROT_MATRIX_ATI 0x8775 -#define GL_BUMP_ROT_MATRIX_SIZE_ATI 0x8776 -#define GL_BUMP_NUM_TEX_UNITS_ATI 0x8777 -#define GL_BUMP_TEX_UNITS_ATI 0x8778 -#define GL_DUDV_ATI 0x8779 -#define GL_DU8DV8_ATI 0x877A -#define GL_BUMP_ENVMAP_ATI 0x877B -#define GL_BUMP_TARGET_ATI 0x877C -#endif - -#ifndef GL_ATI_fragment_shader -#define GL_FRAGMENT_SHADER_ATI 0x8920 -#define GL_REG_0_ATI 0x8921 -#define GL_REG_1_ATI 0x8922 -#define GL_REG_2_ATI 0x8923 -#define GL_REG_3_ATI 0x8924 -#define GL_REG_4_ATI 0x8925 -#define GL_REG_5_ATI 0x8926 -#define GL_REG_6_ATI 0x8927 -#define GL_REG_7_ATI 0x8928 -#define GL_REG_8_ATI 0x8929 -#define GL_REG_9_ATI 0x892A -#define GL_REG_10_ATI 0x892B -#define GL_REG_11_ATI 0x892C -#define GL_REG_12_ATI 0x892D -#define GL_REG_13_ATI 0x892E -#define GL_REG_14_ATI 0x892F -#define GL_REG_15_ATI 0x8930 -#define GL_REG_16_ATI 0x8931 -#define GL_REG_17_ATI 0x8932 -#define GL_REG_18_ATI 0x8933 -#define GL_REG_19_ATI 0x8934 -#define GL_REG_20_ATI 0x8935 -#define GL_REG_21_ATI 0x8936 -#define GL_REG_22_ATI 0x8937 -#define GL_REG_23_ATI 0x8938 -#define GL_REG_24_ATI 0x8939 -#define GL_REG_25_ATI 0x893A -#define GL_REG_26_ATI 0x893B -#define GL_REG_27_ATI 0x893C -#define GL_REG_28_ATI 0x893D -#define GL_REG_29_ATI 0x893E -#define GL_REG_30_ATI 0x893F -#define GL_REG_31_ATI 0x8940 -#define GL_CON_0_ATI 0x8941 -#define GL_CON_1_ATI 0x8942 -#define GL_CON_2_ATI 0x8943 -#define GL_CON_3_ATI 0x8944 -#define GL_CON_4_ATI 0x8945 -#define GL_CON_5_ATI 0x8946 -#define GL_CON_6_ATI 0x8947 -#define GL_CON_7_ATI 0x8948 -#define GL_CON_8_ATI 0x8949 -#define GL_CON_9_ATI 0x894A -#define GL_CON_10_ATI 0x894B -#define GL_CON_11_ATI 0x894C -#define GL_CON_12_ATI 0x894D -#define GL_CON_13_ATI 0x894E -#define GL_CON_14_ATI 0x894F -#define GL_CON_15_ATI 0x8950 -#define GL_CON_16_ATI 0x8951 -#define GL_CON_17_ATI 0x8952 -#define GL_CON_18_ATI 0x8953 -#define GL_CON_19_ATI 0x8954 -#define GL_CON_20_ATI 0x8955 -#define GL_CON_21_ATI 0x8956 -#define GL_CON_22_ATI 0x8957 -#define GL_CON_23_ATI 0x8958 -#define GL_CON_24_ATI 0x8959 -#define GL_CON_25_ATI 0x895A -#define GL_CON_26_ATI 0x895B -#define GL_CON_27_ATI 0x895C -#define GL_CON_28_ATI 0x895D -#define GL_CON_29_ATI 0x895E -#define GL_CON_30_ATI 0x895F -#define GL_CON_31_ATI 0x8960 -#define GL_MOV_ATI 0x8961 -#define GL_ADD_ATI 0x8963 -#define GL_MUL_ATI 0x8964 -#define GL_SUB_ATI 0x8965 -#define GL_DOT3_ATI 0x8966 -#define GL_DOT4_ATI 0x8967 -#define GL_MAD_ATI 0x8968 -#define GL_LERP_ATI 0x8969 -#define GL_CND_ATI 0x896A -#define GL_CND0_ATI 0x896B -#define GL_DOT2_ADD_ATI 0x896C -#define GL_SECONDARY_INTERPOLATOR_ATI 0x896D -#define GL_NUM_FRAGMENT_REGISTERS_ATI 0x896E -#define GL_NUM_FRAGMENT_CONSTANTS_ATI 0x896F -#define GL_NUM_PASSES_ATI 0x8970 -#define GL_NUM_INSTRUCTIONS_PER_PASS_ATI 0x8971 -#define GL_NUM_INSTRUCTIONS_TOTAL_ATI 0x8972 -#define GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI 0x8973 -#define GL_NUM_LOOPBACK_COMPONENTS_ATI 0x8974 -#define GL_COLOR_ALPHA_PAIRING_ATI 0x8975 -#define GL_SWIZZLE_STR_ATI 0x8976 -#define GL_SWIZZLE_STQ_ATI 0x8977 -#define GL_SWIZZLE_STR_DR_ATI 0x8978 -#define GL_SWIZZLE_STQ_DQ_ATI 0x8979 -#define GL_SWIZZLE_STRQ_ATI 0x897A -#define GL_SWIZZLE_STRQ_DQ_ATI 0x897B -#define GL_RED_BIT_ATI 0x00000001 -#define GL_GREEN_BIT_ATI 0x00000002 -#define GL_BLUE_BIT_ATI 0x00000004 -#define GL_2X_BIT_ATI 0x00000001 -#define GL_4X_BIT_ATI 0x00000002 -#define GL_8X_BIT_ATI 0x00000004 -#define GL_HALF_BIT_ATI 0x00000008 -#define GL_QUARTER_BIT_ATI 0x00000010 -#define GL_EIGHTH_BIT_ATI 0x00000020 -#define GL_SATURATE_BIT_ATI 0x00000040 -#define GL_COMP_BIT_ATI 0x00000002 -#define GL_NEGATE_BIT_ATI 0x00000004 -#define GL_BIAS_BIT_ATI 0x00000008 -#endif - -#ifndef GL_ATI_pn_triangles -#define GL_PN_TRIANGLES_ATI 0x87F0 -#define GL_MAX_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F1 -#define GL_PN_TRIANGLES_POINT_MODE_ATI 0x87F2 -#define GL_PN_TRIANGLES_NORMAL_MODE_ATI 0x87F3 -#define GL_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F4 -#define GL_PN_TRIANGLES_POINT_MODE_LINEAR_ATI 0x87F5 -#define GL_PN_TRIANGLES_POINT_MODE_CUBIC_ATI 0x87F6 -#define GL_PN_TRIANGLES_NORMAL_MODE_LINEAR_ATI 0x87F7 -#define GL_PN_TRIANGLES_NORMAL_MODE_QUADRATIC_ATI 0x87F8 -#endif - -#ifndef GL_ATI_vertex_array_object -#define GL_STATIC_ATI 0x8760 -#define GL_DYNAMIC_ATI 0x8761 -#define GL_PRESERVE_ATI 0x8762 -#define GL_DISCARD_ATI 0x8763 -#define GL_OBJECT_BUFFER_SIZE_ATI 0x8764 -#define GL_OBJECT_BUFFER_USAGE_ATI 0x8765 -#define GL_ARRAY_OBJECT_BUFFER_ATI 0x8766 -#define GL_ARRAY_OBJECT_OFFSET_ATI 0x8767 -#endif - -#ifndef GL_EXT_vertex_shader -#define GL_VERTEX_SHADER_EXT 0x8780 -#define GL_VERTEX_SHADER_BINDING_EXT 0x8781 -#define GL_OP_INDEX_EXT 0x8782 -#define GL_OP_NEGATE_EXT 0x8783 -#define GL_OP_DOT3_EXT 0x8784 -#define GL_OP_DOT4_EXT 0x8785 -#define GL_OP_MUL_EXT 0x8786 -#define GL_OP_ADD_EXT 0x8787 -#define GL_OP_MADD_EXT 0x8788 -#define GL_OP_FRAC_EXT 0x8789 -#define GL_OP_MAX_EXT 0x878A -#define GL_OP_MIN_EXT 0x878B -#define GL_OP_SET_GE_EXT 0x878C -#define GL_OP_SET_LT_EXT 0x878D -#define GL_OP_CLAMP_EXT 0x878E -#define GL_OP_FLOOR_EXT 0x878F -#define GL_OP_ROUND_EXT 0x8790 -#define GL_OP_EXP_BASE_2_EXT 0x8791 -#define GL_OP_LOG_BASE_2_EXT 0x8792 -#define GL_OP_POWER_EXT 0x8793 -#define GL_OP_RECIP_EXT 0x8794 -#define GL_OP_RECIP_SQRT_EXT 0x8795 -#define GL_OP_SUB_EXT 0x8796 -#define GL_OP_CROSS_PRODUCT_EXT 0x8797 -#define GL_OP_MULTIPLY_MATRIX_EXT 0x8798 -#define GL_OP_MOV_EXT 0x8799 -#define GL_OUTPUT_VERTEX_EXT 0x879A -#define GL_OUTPUT_COLOR0_EXT 0x879B -#define GL_OUTPUT_COLOR1_EXT 0x879C -#define GL_OUTPUT_TEXTURE_COORD0_EXT 0x879D -#define GL_OUTPUT_TEXTURE_COORD1_EXT 0x879E -#define GL_OUTPUT_TEXTURE_COORD2_EXT 0x879F -#define GL_OUTPUT_TEXTURE_COORD3_EXT 0x87A0 -#define GL_OUTPUT_TEXTURE_COORD4_EXT 0x87A1 -#define GL_OUTPUT_TEXTURE_COORD5_EXT 0x87A2 -#define GL_OUTPUT_TEXTURE_COORD6_EXT 0x87A3 -#define GL_OUTPUT_TEXTURE_COORD7_EXT 0x87A4 -#define GL_OUTPUT_TEXTURE_COORD8_EXT 0x87A5 -#define GL_OUTPUT_TEXTURE_COORD9_EXT 0x87A6 -#define GL_OUTPUT_TEXTURE_COORD10_EXT 0x87A7 -#define GL_OUTPUT_TEXTURE_COORD11_EXT 0x87A8 -#define GL_OUTPUT_TEXTURE_COORD12_EXT 0x87A9 -#define GL_OUTPUT_TEXTURE_COORD13_EXT 0x87AA -#define GL_OUTPUT_TEXTURE_COORD14_EXT 0x87AB -#define GL_OUTPUT_TEXTURE_COORD15_EXT 0x87AC -#define GL_OUTPUT_TEXTURE_COORD16_EXT 0x87AD -#define GL_OUTPUT_TEXTURE_COORD17_EXT 0x87AE -#define GL_OUTPUT_TEXTURE_COORD18_EXT 0x87AF -#define GL_OUTPUT_TEXTURE_COORD19_EXT 0x87B0 -#define GL_OUTPUT_TEXTURE_COORD20_EXT 0x87B1 -#define GL_OUTPUT_TEXTURE_COORD21_EXT 0x87B2 -#define GL_OUTPUT_TEXTURE_COORD22_EXT 0x87B3 -#define GL_OUTPUT_TEXTURE_COORD23_EXT 0x87B4 -#define GL_OUTPUT_TEXTURE_COORD24_EXT 0x87B5 -#define GL_OUTPUT_TEXTURE_COORD25_EXT 0x87B6 -#define GL_OUTPUT_TEXTURE_COORD26_EXT 0x87B7 -#define GL_OUTPUT_TEXTURE_COORD27_EXT 0x87B8 -#define GL_OUTPUT_TEXTURE_COORD28_EXT 0x87B9 -#define GL_OUTPUT_TEXTURE_COORD29_EXT 0x87BA -#define GL_OUTPUT_TEXTURE_COORD30_EXT 0x87BB -#define GL_OUTPUT_TEXTURE_COORD31_EXT 0x87BC -#define GL_OUTPUT_FOG_EXT 0x87BD -#define GL_SCALAR_EXT 0x87BE -#define GL_VECTOR_EXT 0x87BF -#define GL_MATRIX_EXT 0x87C0 -#define GL_VARIANT_EXT 0x87C1 -#define GL_INVARIANT_EXT 0x87C2 -#define GL_LOCAL_CONSTANT_EXT 0x87C3 -#define GL_LOCAL_EXT 0x87C4 -#define GL_MAX_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87C5 -#define GL_MAX_VERTEX_SHADER_VARIANTS_EXT 0x87C6 -#define GL_MAX_VERTEX_SHADER_INVARIANTS_EXT 0x87C7 -#define GL_MAX_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87C8 -#define GL_MAX_VERTEX_SHADER_LOCALS_EXT 0x87C9 -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CA -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_VARIANTS_EXT 0x87CB -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87CC -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INVARIANTS_EXT 0x87CD -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCALS_EXT 0x87CE -#define GL_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CF -#define GL_VERTEX_SHADER_VARIANTS_EXT 0x87D0 -#define GL_VERTEX_SHADER_INVARIANTS_EXT 0x87D1 -#define GL_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87D2 -#define GL_VERTEX_SHADER_LOCALS_EXT 0x87D3 -#define GL_VERTEX_SHADER_OPTIMIZED_EXT 0x87D4 -#define GL_X_EXT 0x87D5 -#define GL_Y_EXT 0x87D6 -#define GL_Z_EXT 0x87D7 -#define GL_W_EXT 0x87D8 -#define GL_NEGATIVE_X_EXT 0x87D9 -#define GL_NEGATIVE_Y_EXT 0x87DA -#define GL_NEGATIVE_Z_EXT 0x87DB -#define GL_NEGATIVE_W_EXT 0x87DC -#define GL_ZERO_EXT 0x87DD -#define GL_ONE_EXT 0x87DE -#define GL_NEGATIVE_ONE_EXT 0x87DF -#define GL_NORMALIZED_RANGE_EXT 0x87E0 -#define GL_FULL_RANGE_EXT 0x87E1 -#define GL_CURRENT_VERTEX_EXT 0x87E2 -#define GL_MVP_MATRIX_EXT 0x87E3 -#define GL_VARIANT_VALUE_EXT 0x87E4 -#define GL_VARIANT_DATATYPE_EXT 0x87E5 -#define GL_VARIANT_ARRAY_STRIDE_EXT 0x87E6 -#define GL_VARIANT_ARRAY_TYPE_EXT 0x87E7 -#define GL_VARIANT_ARRAY_EXT 0x87E8 -#define GL_VARIANT_ARRAY_POINTER_EXT 0x87E9 -#define GL_INVARIANT_VALUE_EXT 0x87EA -#define GL_INVARIANT_DATATYPE_EXT 0x87EB -#define GL_LOCAL_CONSTANT_VALUE_EXT 0x87EC -#define GL_LOCAL_CONSTANT_DATATYPE_EXT 0x87ED -#endif - -#ifndef GL_ATI_vertex_streams -#define GL_MAX_VERTEX_STREAMS_ATI 0x876B -#define GL_VERTEX_STREAM0_ATI 0x876C -#define GL_VERTEX_STREAM1_ATI 0x876D -#define GL_VERTEX_STREAM2_ATI 0x876E -#define GL_VERTEX_STREAM3_ATI 0x876F -#define GL_VERTEX_STREAM4_ATI 0x8770 -#define GL_VERTEX_STREAM5_ATI 0x8771 -#define GL_VERTEX_STREAM6_ATI 0x8772 -#define GL_VERTEX_STREAM7_ATI 0x8773 -#define GL_VERTEX_SOURCE_ATI 0x8774 -#endif - -#ifndef GL_ATI_element_array -#define GL_ELEMENT_ARRAY_ATI 0x8768 -#define GL_ELEMENT_ARRAY_TYPE_ATI 0x8769 -#define GL_ELEMENT_ARRAY_POINTER_ATI 0x876A -#endif - -#ifndef GL_SUN_mesh_array -#define GL_QUAD_MESH_SUN 0x8614 -#define GL_TRIANGLE_MESH_SUN 0x8615 -#endif - -#ifndef GL_SUN_slice_accum -#define GL_SLICE_ACCUM_SUN 0x85CC -#endif - -#ifndef GL_NV_multisample_filter_hint -#define GL_MULTISAMPLE_FILTER_HINT_NV 0x8534 -#endif - -#ifndef GL_NV_depth_clamp -#define GL_DEPTH_CLAMP_NV 0x864F -#endif - -#ifndef GL_NV_occlusion_query -#define GL_PIXEL_COUNTER_BITS_NV 0x8864 -#define GL_CURRENT_OCCLUSION_QUERY_ID_NV 0x8865 -#define GL_PIXEL_COUNT_NV 0x8866 -#define GL_PIXEL_COUNT_AVAILABLE_NV 0x8867 -#endif - -#ifndef GL_NV_point_sprite -#define GL_POINT_SPRITE_NV 0x8861 -#define GL_COORD_REPLACE_NV 0x8862 -#define GL_POINT_SPRITE_R_MODE_NV 0x8863 -#endif - -#ifndef GL_NV_texture_shader3 -#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_NV 0x8850 -#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_SCALE_NV 0x8851 -#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8852 -#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_SCALE_NV 0x8853 -#define GL_OFFSET_HILO_TEXTURE_2D_NV 0x8854 -#define GL_OFFSET_HILO_TEXTURE_RECTANGLE_NV 0x8855 -#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_2D_NV 0x8856 -#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8857 -#define GL_DEPENDENT_HILO_TEXTURE_2D_NV 0x8858 -#define GL_DEPENDENT_RGB_TEXTURE_3D_NV 0x8859 -#define GL_DEPENDENT_RGB_TEXTURE_CUBE_MAP_NV 0x885A -#define GL_DOT_PRODUCT_PASS_THROUGH_NV 0x885B -#define GL_DOT_PRODUCT_TEXTURE_1D_NV 0x885C -#define GL_DOT_PRODUCT_AFFINE_DEPTH_REPLACE_NV 0x885D -#define GL_HILO8_NV 0x885E -#define GL_SIGNED_HILO8_NV 0x885F -#define GL_FORCE_BLUE_TO_ONE_NV 0x8860 -#endif - -#ifndef GL_NV_vertex_program1_1 -#endif - -#ifndef GL_EXT_shadow_funcs -#endif - -#ifndef GL_EXT_stencil_two_side -#define GL_STENCIL_TEST_TWO_SIDE_EXT 0x8910 -#define GL_ACTIVE_STENCIL_FACE_EXT 0x8911 -#endif - -#ifndef GL_ATI_text_fragment_shader -#define GL_TEXT_FRAGMENT_SHADER_ATI 0x8200 -#endif - -#ifndef GL_APPLE_client_storage -#define GL_UNPACK_CLIENT_STORAGE_APPLE 0x85B2 -#endif - -#ifndef GL_APPLE_element_array -#define GL_ELEMENT_ARRAY_APPLE 0x8768 -#define GL_ELEMENT_ARRAY_TYPE_APPLE 0x8769 -#define GL_ELEMENT_ARRAY_POINTER_APPLE 0x876A -#endif - -#ifndef GL_APPLE_fence -#define GL_DRAW_PIXELS_APPLE 0x8A0A -#define GL_FENCE_APPLE 0x8A0B -#endif - -#ifndef GL_APPLE_vertex_array_object -#define GL_VERTEX_ARRAY_BINDING_APPLE 0x85B5 -#endif - -#ifndef GL_APPLE_vertex_array_range -#define GL_VERTEX_ARRAY_RANGE_APPLE 0x851D -#define GL_VERTEX_ARRAY_RANGE_LENGTH_APPLE 0x851E -#define GL_VERTEX_ARRAY_STORAGE_HINT_APPLE 0x851F -#define GL_VERTEX_ARRAY_RANGE_POINTER_APPLE 0x8521 -#define GL_STORAGE_CACHED_APPLE 0x85BE -#define GL_STORAGE_SHARED_APPLE 0x85BF -#endif - -#ifndef GL_APPLE_ycbcr_422 -#define GL_YCBCR_422_APPLE 0x85B9 -#define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA -#define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB -#endif - -#ifndef GL_S3_s3tc -#define GL_RGB_S3TC 0x83A0 -#define GL_RGB4_S3TC 0x83A1 -#define GL_RGBA_S3TC 0x83A2 -#define GL_RGBA4_S3TC 0x83A3 -#endif - -#ifndef GL_ATI_draw_buffers -#define GL_MAX_DRAW_BUFFERS_ATI 0x8824 -#define GL_DRAW_BUFFER0_ATI 0x8825 -#define GL_DRAW_BUFFER1_ATI 0x8826 -#define GL_DRAW_BUFFER2_ATI 0x8827 -#define GL_DRAW_BUFFER3_ATI 0x8828 -#define GL_DRAW_BUFFER4_ATI 0x8829 -#define GL_DRAW_BUFFER5_ATI 0x882A -#define GL_DRAW_BUFFER6_ATI 0x882B -#define GL_DRAW_BUFFER7_ATI 0x882C -#define GL_DRAW_BUFFER8_ATI 0x882D -#define GL_DRAW_BUFFER9_ATI 0x882E -#define GL_DRAW_BUFFER10_ATI 0x882F -#define GL_DRAW_BUFFER11_ATI 0x8830 -#define GL_DRAW_BUFFER12_ATI 0x8831 -#define GL_DRAW_BUFFER13_ATI 0x8832 -#define GL_DRAW_BUFFER14_ATI 0x8833 -#define GL_DRAW_BUFFER15_ATI 0x8834 -#endif - -#ifndef GL_ATI_pixel_format_float -#define GL_TYPE_RGBA_FLOAT_ATI 0x8820 -#define GL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI 0x8835 -#endif - -#ifndef GL_ATI_texture_env_combine3 -#define GL_MODULATE_ADD_ATI 0x8744 -#define GL_MODULATE_SIGNED_ADD_ATI 0x8745 -#define GL_MODULATE_SUBTRACT_ATI 0x8746 -#endif - -#ifndef GL_ATI_texture_float -#define GL_RGBA_FLOAT32_ATI 0x8814 -#define GL_RGB_FLOAT32_ATI 0x8815 -#define GL_ALPHA_FLOAT32_ATI 0x8816 -#define GL_INTENSITY_FLOAT32_ATI 0x8817 -#define GL_LUMINANCE_FLOAT32_ATI 0x8818 -#define GL_LUMINANCE_ALPHA_FLOAT32_ATI 0x8819 -#define GL_RGBA_FLOAT16_ATI 0x881A -#define GL_RGB_FLOAT16_ATI 0x881B -#define GL_ALPHA_FLOAT16_ATI 0x881C -#define GL_INTENSITY_FLOAT16_ATI 0x881D -#define GL_LUMINANCE_FLOAT16_ATI 0x881E -#define GL_LUMINANCE_ALPHA_FLOAT16_ATI 0x881F -#endif - -#ifndef GL_NV_float_buffer -#define GL_FLOAT_R_NV 0x8880 -#define GL_FLOAT_RG_NV 0x8881 -#define GL_FLOAT_RGB_NV 0x8882 -#define GL_FLOAT_RGBA_NV 0x8883 -#define GL_FLOAT_R16_NV 0x8884 -#define GL_FLOAT_R32_NV 0x8885 -#define GL_FLOAT_RG16_NV 0x8886 -#define GL_FLOAT_RG32_NV 0x8887 -#define GL_FLOAT_RGB16_NV 0x8888 -#define GL_FLOAT_RGB32_NV 0x8889 -#define GL_FLOAT_RGBA16_NV 0x888A -#define GL_FLOAT_RGBA32_NV 0x888B -#define GL_TEXTURE_FLOAT_COMPONENTS_NV 0x888C -#define GL_FLOAT_CLEAR_COLOR_VALUE_NV 0x888D -#define GL_FLOAT_RGBA_MODE_NV 0x888E -#endif - -#ifndef GL_NV_fragment_program -#define GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV 0x8868 -#define GL_FRAGMENT_PROGRAM_NV 0x8870 -#define GL_MAX_TEXTURE_COORDS_NV 0x8871 -#define GL_MAX_TEXTURE_IMAGE_UNITS_NV 0x8872 -#define GL_FRAGMENT_PROGRAM_BINDING_NV 0x8873 -#define GL_PROGRAM_ERROR_STRING_NV 0x8874 -#endif - -#ifndef GL_NV_half_float -#define GL_HALF_FLOAT_NV 0x140B -#endif - -#ifndef GL_NV_pixel_data_range -#define GL_WRITE_PIXEL_DATA_RANGE_NV 0x8878 -#define GL_READ_PIXEL_DATA_RANGE_NV 0x8879 -#define GL_WRITE_PIXEL_DATA_RANGE_LENGTH_NV 0x887A -#define GL_READ_PIXEL_DATA_RANGE_LENGTH_NV 0x887B -#define GL_WRITE_PIXEL_DATA_RANGE_POINTER_NV 0x887C -#define GL_READ_PIXEL_DATA_RANGE_POINTER_NV 0x887D -#endif - -#ifndef GL_NV_primitive_restart -#define GL_PRIMITIVE_RESTART_NV 0x8558 -#define GL_PRIMITIVE_RESTART_INDEX_NV 0x8559 -#endif - -#ifndef GL_NV_texture_expand_normal -#define GL_TEXTURE_UNSIGNED_REMAP_MODE_NV 0x888F -#endif - -#ifndef GL_NV_vertex_program2 -#endif - -#ifndef GL_ATI_map_object_buffer -#endif - -#ifndef GL_ATI_separate_stencil -#define GL_STENCIL_BACK_FUNC_ATI 0x8800 -#define GL_STENCIL_BACK_FAIL_ATI 0x8801 -#define GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI 0x8802 -#define GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI 0x8803 -#endif - -#ifndef GL_ATI_vertex_attrib_array_object -#endif - -#ifndef GL_OES_read_format -#define GL_IMPLEMENTATION_COLOR_READ_TYPE_OES 0x8B9A -#define GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES 0x8B9B -#endif - -#ifndef GL_EXT_depth_bounds_test -#define GL_DEPTH_BOUNDS_TEST_EXT 0x8890 -#define GL_DEPTH_BOUNDS_EXT 0x8891 -#endif - -#ifndef GL_EXT_texture_mirror_clamp -#define GL_MIRROR_CLAMP_EXT 0x8742 -#define GL_MIRROR_CLAMP_TO_EDGE_EXT 0x8743 -#define GL_MIRROR_CLAMP_TO_BORDER_EXT 0x8912 -#endif - -#ifndef GL_EXT_blend_equation_separate -#define GL_BLEND_EQUATION_RGB_EXT GL_BLEND_EQUATION -#define GL_BLEND_EQUATION_ALPHA_EXT 0x883D -#endif - -#ifndef GL_MESA_pack_invert -#define GL_PACK_INVERT_MESA 0x8758 -#endif - -#ifndef GL_MESA_ycbcr_texture -#define GL_UNSIGNED_SHORT_8_8_MESA 0x85BA -#define GL_UNSIGNED_SHORT_8_8_REV_MESA 0x85BB -#define GL_YCBCR_MESA 0x8757 -#endif - -#ifndef GL_EXT_pixel_buffer_object -#define GL_PIXEL_PACK_BUFFER_EXT 0x88EB -#define GL_PIXEL_UNPACK_BUFFER_EXT 0x88EC -#define GL_PIXEL_PACK_BUFFER_BINDING_EXT 0x88ED -#define GL_PIXEL_UNPACK_BUFFER_BINDING_EXT 0x88EF -#endif - -#ifndef GL_NV_fragment_program_option -#endif - -#ifndef GL_NV_fragment_program2 -#define GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV 0x88F4 -#define GL_MAX_PROGRAM_CALL_DEPTH_NV 0x88F5 -#define GL_MAX_PROGRAM_IF_DEPTH_NV 0x88F6 -#define GL_MAX_PROGRAM_LOOP_DEPTH_NV 0x88F7 -#define GL_MAX_PROGRAM_LOOP_COUNT_NV 0x88F8 -#endif - -#ifndef GL_NV_vertex_program2_option -/* reuse GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV */ -/* reuse GL_MAX_PROGRAM_CALL_DEPTH_NV */ -#endif - -#ifndef GL_NV_vertex_program3 -/* reuse GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB */ -#endif - -#ifndef GL_EXT_framebuffer_object -#define GL_INVALID_FRAMEBUFFER_OPERATION_EXT 0x0506 -#define GL_MAX_RENDERBUFFER_SIZE_EXT 0x84E8 -#define GL_FRAMEBUFFER_BINDING_EXT 0x8CA6 -#define GL_RENDERBUFFER_BINDING_EXT 0x8CA7 -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT 0x8CD0 -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT 0x8CD1 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT 0x8CD2 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT 0x8CD3 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT 0x8CD4 -#define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5 -#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT 0x8CD6 -#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT 0x8CD7 -#define GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT 0x8CD8 -#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT 0x8CD9 -#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT 0x8CDA -#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT 0x8CDB -#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT 0x8CDC -#define GL_FRAMEBUFFER_UNSUPPORTED_EXT 0x8CDD -#define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF -#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0 -#define GL_COLOR_ATTACHMENT1_EXT 0x8CE1 -#define GL_COLOR_ATTACHMENT2_EXT 0x8CE2 -#define GL_COLOR_ATTACHMENT3_EXT 0x8CE3 -#define GL_COLOR_ATTACHMENT4_EXT 0x8CE4 -#define GL_COLOR_ATTACHMENT5_EXT 0x8CE5 -#define GL_COLOR_ATTACHMENT6_EXT 0x8CE6 -#define GL_COLOR_ATTACHMENT7_EXT 0x8CE7 -#define GL_COLOR_ATTACHMENT8_EXT 0x8CE8 -#define GL_COLOR_ATTACHMENT9_EXT 0x8CE9 -#define GL_COLOR_ATTACHMENT10_EXT 0x8CEA -#define GL_COLOR_ATTACHMENT11_EXT 0x8CEB -#define GL_COLOR_ATTACHMENT12_EXT 0x8CEC -#define GL_COLOR_ATTACHMENT13_EXT 0x8CED -#define GL_COLOR_ATTACHMENT14_EXT 0x8CEE -#define GL_COLOR_ATTACHMENT15_EXT 0x8CEF -#define GL_DEPTH_ATTACHMENT_EXT 0x8D00 -#define GL_STENCIL_ATTACHMENT_EXT 0x8D20 -#define GL_FRAMEBUFFER_EXT 0x8D40 -#define GL_RENDERBUFFER_EXT 0x8D41 -#define GL_RENDERBUFFER_WIDTH_EXT 0x8D42 -#define GL_RENDERBUFFER_HEIGHT_EXT 0x8D43 -#define GL_RENDERBUFFER_INTERNAL_FORMAT_EXT 0x8D44 -#define GL_STENCIL_INDEX_EXT 0x8D45 -#define GL_STENCIL_INDEX1_EXT 0x8D46 -#define GL_STENCIL_INDEX4_EXT 0x8D47 -#define GL_STENCIL_INDEX8_EXT 0x8D48 -#define GL_STENCIL_INDEX16_EXT 0x8D49 -#define GL_RENDERBUFFER_RED_SIZE_EXT 0x8D50 -#define GL_RENDERBUFFER_GREEN_SIZE_EXT 0x8D51 -#define GL_RENDERBUFFER_BLUE_SIZE_EXT 0x8D52 -#define GL_RENDERBUFFER_ALPHA_SIZE_EXT 0x8D53 -#define GL_RENDERBUFFER_DEPTH_SIZE_EXT 0x8D54 -#define GL_RENDERBUFFER_STENCIL_SIZE_EXT 0x8D55 -#endif - -#ifndef GL_GREMEDY_string_marker -#endif - -#ifndef GL_EXT_Cg_shader -#define GL_CG_VERTEX_SHADER_EXT 0x890E -#define GL_CG_FRAGMENT_SHADER_EXT 0x890F -#endif - -#ifndef GL_EXT_timer_query -#define GL_TIME_ELAPSED_EXT 0x88BF -#endif - -#ifndef GL_EXT_texture_buffer_object -#define GL_TEXTURE_BUFFER_EXT 0x8C2A -#define GL_MAX_TEXTURE_BUFFER_SIZE_EXT 0x8C2B -#define GL_TEXTURE_BINDING_BUFFER_EXT 0x8C2C -#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_EXT 0x8C2D -#define GL_TEXTURE_BUFFER_FORMAT_EXT 0x8C2E -#endif - -#ifndef GL_EXT_gpu_shader4 -#define GL_SAMPLER_1D_ARRAY_EXT 0x8DC0 -#define GL_SAMPLER_2D_ARRAY_EXT 0x8DC1 -#define GL_SAMPLER_BUFFER_EXT 0x8DC2 -#define GL_SAMPLER_1D_ARRAY_SHADOW_EXT 0x8DC3 -#define GL_SAMPLER_2D_ARRAY_SHADOW_EXT 0x8DC4 -#define GL_SAMPLER_CUBE_SHADOW_EXT 0x8DC5 -#define GL_UNSIGNED_INT_VEC2_EXT 0x8DC6 -#define GL_UNSIGNED_INT_VEC3_EXT 0x8DC7 -#define GL_UNSIGNED_INT_VEC4_EXT 0x8DC8 -#define GL_INT_SAMPLER_1D_EXT 0x8DC9 -#define GL_INT_SAMPLER_2D_EXT 0x8DCA -#define GL_INT_SAMPLER_3D_EXT 0x8DCB -#define GL_INT_SAMPLER_CUBE_EXT 0x8DCC -#define GL_INT_SAMPLER_2D_RECT_EXT 0x8DCD -#define GL_INT_SAMPLER_1D_ARRAY_EXT 0x8DCE -#define GL_INT_SAMPLER_2D_ARRAY_EXT 0x8DCF -#define GL_INT_SAMPLER_BUFFER_EXT 0x8DD0 -#define GL_UNSIGNED_INT_SAMPLER_1D_EXT 0x8DD1 -#define GL_UNSIGNED_INT_SAMPLER_2D_EXT 0x8DD2 -#define GL_UNSIGNED_INT_SAMPLER_3D_EXT 0x8DD3 -#define GL_UNSIGNED_INT_SAMPLER_CUBE_EXT 0x8DD4 -#define GL_UNSIGNED_INT_SAMPLER_2D_RECT_EXT 0x8DD5 -#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY_EXT 0x8DD6 -#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY_EXT 0x8DD7 -#define GL_UNSIGNED_INT_SAMPLER_BUFFER_EXT 0x8DD8 -#define GL_VERTEX_ATTRIB_ARRAY_INTEGER_EXT 0x88FD -#endif - -#ifndef GL_EXT_geometry_shader4 -#define GL_GEOMETRY_SHADER_EXT 0x8DD9 -#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_EXT 0x8DDD -#define GL_MAX_VERTEX_VARYING_COMPONENTS_EXT 0x8DDE -#define GL_MAX_VARYING_COMPONENTS_EXT 0x8B4B -#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT 0x8DDF -#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT 0x8DE0 -#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT 0x8DE1 -#define GL_GEOMETRY_VERTICES_OUT_EXT 0x8DDA -#define GL_GEOMETRY_INPUT_TYPE_EXT 0x8DDB -#define GL_GEOMETRY_OUTPUT_TYPE_EXT 0x8DDC -#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT 0x8C29 -#define GL_LINES_ADJACENCY_EXT 0xA -#define GL_LINE_STRIP_ADJACENCY_EXT 0xB -#define GL_TRIANGLES_ADJACENCY_EXT 0xC -#define GL_TRIANGLE_STRIP_ADJACENCY_EXT 0xD -#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT 0x8DA7 -#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT 0x8DA8 -#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_EXT 0x8DA9 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT 0x8CD4 -#define GL_PROGRAM_POINT_SIZE_EXT 0x8642 -#endif - -#ifndef GL_EXT_bindable_uniform -#define GL_MAX_VERTEX_BINDABLE_UNIFORMS_EXT 0x8DE2 -#define GL_MAX_FRAGMENT_BINDABLE_UNIFORMS_EXT 0x8DE3 -#define GL_MAX_GEOMETRY_BINDABLE_UNIFORMS_EXT 0x8DE4 -#define GL_MAX_BINDABLE_UNIFORM_SIZE_EXT 0x8DED -#define GL_UNIFORM_BUFFER_EXT 0x8DEE -#define GL_UNIFORM_BUFFER_BINDING_EXT 0x8DEF -#endif - -#ifndef GL_EXT_framebuffer_sRGB -#define GL_FRAMEBUFFER_SRGB_EXT 0x8DB9 -#define GL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x8DBA -#endif - -#ifndef GL_EXT_texture_shared_exponent -#define GL_RGB9_E5_EXT 0x8C3D -#define GL_UNSIGNED_INT_5_9_9_9_REV_EXT 0x8C3E -#define GL_TEXTURE_SHARED_SIZE_EXT 0x8C3F -#endif - -#ifndef GL_EXT_packed_float -#define GL_R11F_G11F_B10F_EXT 0x8C3A -#define GL_UNSIGNED_INT_10F_11F_11F_REV_EXT 0x8C3B -#define GL_RGBA_SIGNED_COMPONENTS_EXT 0x8C3C -#endif - -#ifndef GL_EXT_texture_array -#define GL_TEXTURE_1D_ARRAY_EXT 0x8C18 -#define GL_PROXY_TEXTURE_1D_ARRAY_EXT 0x8C19 -#define GL_TEXTURE_2D_ARRAY_EXT 0x8C1A -#define GL_PROXY_TEXTURE_2D_ARRAY_EXT 0x8C1B -#define GL_TEXTURE_BINDING_1D_ARRAY_EXT 0x8C1C -#define GL_TEXTURE_BINDING_2D_ARRAY_EXT 0x8C1D -#define GL_MAX_ARRAY_TEXTURE_LAYERS_EXT 0x88FF -#define GL_COMPARE_REF_DEPTH_TO_TEXTURE_EXT 0x884E -/* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT */ -#endif - -#ifndef GL_EXT_texture_integer -#define GL_RGBA32UI_EXT 0x8D70 -#define GL_RGB32UI_EXT 0x8D71 -#define GL_ALPHA32UI_EXT 0x8D72 -#define GL_INTENSITY32UI_EXT 0x8D73 -#define GL_LUMINANCE32UI_EXT 0x8D74 -#define GL_LUMINANCE_ALPHA32UI_EXT 0x8D75 -#define GL_RGBA16UI_EXT 0x8D76 -#define GL_RGB16UI_EXT 0x8D77 -#define GL_ALPHA16UI_EXT 0x8D78 -#define GL_INTENSITY16UI_EXT 0x8D79 -#define GL_LUMINANCE16UI_EXT 0x8D7A -#define GL_LUMINANCE_ALPHA16UI_EXT 0x8D7B -#define GL_RGBA8UI_EXT 0x8D7C -#define GL_RGB8UI_EXT 0x8D7D -#define GL_ALPHA8UI_EXT 0x8D7E -#define GL_INTENSITY8UI_EXT 0x8D7F -#define GL_LUMINANCE8UI_EXT 0x8D80 -#define GL_LUMINANCE_ALPHA8UI_EXT 0x8D81 -#define GL_RGBA32I_EXT 0x8D82 -#define GL_RGB32I_EXT 0x8D83 -#define GL_ALPHA32I_EXT 0x8D84 -#define GL_INTENSITY32I_EXT 0x8D85 -#define GL_LUMINANCE32I_EXT 0x8D86 -#define GL_LUMINANCE_ALPHA32I_EXT 0x8D87 -#define GL_RGBA16I_EXT 0x8D88 -#define GL_RGB16I_EXT 0x8D89 -#define GL_ALPHA16I_EXT 0x8D8A -#define GL_INTENSITY16I_EXT 0x8D8B -#define GL_LUMINANCE16I_EXT 0x8D8C -#define GL_LUMINANCE_ALPHA16I_EXT 0x8D8D -#define GL_RGBA8I_EXT 0x8D8E -#define GL_RGB8I_EXT 0x8D8F -#define GL_ALPHA8I_EXT 0x8D90 -#define GL_INTENSITY8I_EXT 0x8D91 -#define GL_LUMINANCE8I_EXT 0x8D92 -#define GL_LUMINANCE_ALPHA8I_EXT 0x8D93 -#define GL_RED_INTEGER_EXT 0x8D94 -#define GL_GREEN_INTEGER_EXT 0x8D95 -#define GL_BLUE_INTEGER_EXT 0x8D96 -#define GL_ALPHA_INTEGER_EXT 0x8D97 -#define GL_RGB_INTEGER_EXT 0x8D98 -#define GL_RGBA_INTEGER_EXT 0x8D99 -#define GL_BGR_INTEGER_EXT 0x8D9A -#define GL_BGRA_INTEGER_EXT 0x8D9B -#define GL_LUMINANCE_INTEGER_EXT 0x8D9C -#define GL_LUMINANCE_ALPHA_INTEGER_EXT 0x8D9D -#define GL_RGBA_INTEGER_MODE_EXT 0x8D9E -#endif - -#ifndef GL_NV_depth_buffer_float -#define GL_DEPTH_COMPONENT32F_NV 0x8DAB -#define GL_DEPTH32F_STENCIL8_NV 0x8DAC -#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV_NV 0x8DAD -#define GL_DEPTH_BUFFER_FLOAT_MODE_NV 0x8DAF -#endif - -#ifndef GL_EXT_texture_compression_latc -#define GL_COMPRESSED_LUMINANCE_LATC1_EXT 0x8C70 -#define GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT 0x8C71 -#define GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT 0x8C72 -#define GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT 0x8C73 -#endif - -#ifndef GL_NV_transform_feedback -#define GL_BACK_PRIMARY_COLOR_NV 0x8C77 -#define GL_BACK_SECONDARY_COLOR_NV 0x8C78 -#define GL_TEXTURE_COORD_NV 0x8C79 -#define GL_CLIP_DISTANCE_NV 0x8C7A -#define GL_VERTEX_ID_NV 0x8C7B -#define GL_PRIMITIVE_ID_NV 0x8C7C -#define GL_GENERIC_ATTRIB_NV 0x8C7D -#define GL_TRANSFORM_FEEDBACK_ATTRIBS_NV 0x8C7E -#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_NV 0x8C7F -#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_NV 0x8C80 -#define GL_ACTIVE_VARYINGS_NV 0x8C81 -#define GL_ACTIVE_VARYING_MAX_LENGTH_NV 0x8C82 -#define GL_TRANSFORM_FEEDBACK_VARYINGS_NV 0x8C83 -#define GL_TRANSFORM_FEEDBACK_BUFFER_START_NV 0x8C84 -#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_NV 0x8C85 -#define GL_TRANSFORM_FEEDBACK_RECORD_NV 0x8C86 -#define GL_PRIMITIVES_GENERATED_NV 0x8C87 -#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_NV 0x8C88 -#define GL_RASTERIZER_DISCARD_NV 0x8C89 -#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_ATTRIBS_NV 0x8C8A -#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_NV 0x8C8B -#define GL_INTERLEAVED_ATTRIBS_NV 0x8C8C -#define GL_SEPARATE_ATTRIBS_NV 0x8C8D -#define GL_TRANSFORM_FEEDBACK_BUFFER_NV 0x8C8E -#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_NV 0x8C8F -#endif - -#ifndef GL_NV_geometry_program4 -#define GL_GEOMETRY_PROGRAM_NV 0x8C26 -#define GL_MAX_PROGRAM_OUTPUT_VERTICES_NV 0x8C27 -#define GL_MAX_PROGRAM_TOTAL_OUTPUT_COMPONENTS_NV 0x8C28 -#endif - -#ifndef GL_NV_gpu_program4 -#define GL_MIN_PROGRAM_TEXEL_OFFSET_NV 0x8904 -#define GL_MAX_PROGRAM_TEXEL_OFFSET_NV 0x8905 -#define GL_PROGRAM_ATTRIB_COMPONENTS_NV 0x8906 -#define GL_PROGRAM_RESULT_COMPONENTS_NV 0x8907 -#define GL_MAX_PROGRAM_ATTRIB_COMPONENTS_NV 0x8908 -#define GL_MAX_PROGRAM_RESULT_COMPONENTS_NV 0x8909 -#define GL_MAX_PROGRAM_GENERIC_ATTRIBS_NV 0x8DA5 -#define GL_MAX_PROGRAM_GENERIC_RESULTS_NV 0x8DA6 -#endif - -#ifndef NV_parameter_buffer_object -#define GL_MAX_PROGRAM_PARAMETER_BUFFER_BINDINGS_NV 0x8DA0 -#define GL_MAX_PROGRAM_PARAMETER_BUFFER_SIZE_NV 0x8DA1 -#define GL_VERTEX_PROGRAM_PARAMETER_BUFFER_NV 0x8DA2 -#define GL_GEOMETRY_PROGRAM_PARAMETER_BUFFER_NV 0x8DA3 -#define GL_FRAGMENT_PROGRAM_PARAMETER_BUFFER_NV 0x8DA4 -#endif - -#ifndef GL_NV_framebuffer_multisample_coverage -#define GL_RENDERBUFFER_COVERAGE_SAMPLES_NV 0x8CAB -#define GL_RENDERBUFFER_COLOR_SAMPLES_NV 0x8E10 -#define GL_MAX_RENDERBUFFER_COVERAGE_SAMPLES_NV 0x8D57 -#define GL_MAX_RENDERBUFFER_COLOR_SAMPLES_NV 0x8E11 -#define GL_MAX_MULTISAMPLE_COVERAGE_MODES_NV 0x8E12 -#define GL_MULTISAMPLE_COVERAGE_MODES_NV 0x8E13 -#endif - -#ifndef GL_EXT_framebuffer_multisample -#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56 -#define GL_MAX_SAMPLES_EXT 0x8D57 -#define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB -#endif - -#ifndef GL_EXT_framebuffer_blit -#define GL_READ_FRAMEBUFFER_EXT 0x8CA8 -#define GL_DRAW_FRAMEBUFFER_EXT 0x8CA9 -#define GL_DRAW_FRAMEBUFFER_BINDING_EXT 0x8CA6 -#define GL_READ_FRAMEBUFFER_BINDING_EXT 0x8CAA -#endif - -#ifndef GL_EXT_texture_compression_rgtc -#define GL_COMPRESSED_RED_RGTC1_EXT 0x8DBB -#define GL_COMPRESSED_SIGNED_RED_RGTC1_EXT 0x8DBC -#define GL_COMPRESSED_RED_GREEN_RGTC2_EXT 0x8DBD -#define GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT 0x8DBE -#endif - -#ifndef GL_NV_present_video -#define GL_FRAME_NV 0x8E26 -#define GL_FIELDS_NV 0x8E27 -#define GL_CURRENT_TIME_NV 0x8E28 -#define GL_NUM_FILL_STREAMS_NV 0x8E29 -#define GL_PRESENT_TIME_NV 0x8E2A -#define GL_PRESENT_DURATION_NV 0x8E2B -#endif - -/*************************************************************/ - -#include <stddef.h> -#ifndef GL_VERSION_2_0 -/* GL type for program/shader text */ -typedef char GLchar; /* native character */ -#endif - -#ifndef GL_VERSION_1_5 -/* GL types for handling large vertex buffer objects */ -typedef ptrdiff_t GLintptr; -typedef ptrdiff_t GLsizeiptr; -#endif - -#ifndef GL_ARB_vertex_buffer_object -/* GL types for handling large vertex buffer objects */ -typedef ptrdiff_t GLintptrARB; -typedef ptrdiff_t GLsizeiptrARB; -#endif - -#ifndef GL_ARB_shader_objects -/* GL types for handling shader object handles and program/shader text */ -typedef char GLcharARB; /* native character */ -typedef unsigned int GLhandleARB; /* shader object handle */ -#endif - -/* GL types for "half" precision (s10e5) float data in host memory */ -#ifndef GL_ARB_half_float_pixel -typedef unsigned short GLhalfARB; -#endif - -#ifndef GL_NV_half_float -typedef unsigned short GLhalfNV; -#endif - -#ifndef GL_EXT_timer_query -typedef signed long long GLint64EXT; -typedef unsigned long long GLuint64EXT; -#endif - -#ifndef GL_VERSION_1_2 -#define GL_VERSION_1_2 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glBlendColor (GLclampf, GLclampf, GLclampf, GLclampf); -extern void APIENTRY glBlendEquation (GLenum); -extern void APIENTRY glDrawRangeElements (GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *); -extern void APIENTRY glColorTable (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); -extern void APIENTRY glColorTableParameterfv (GLenum, GLenum, const GLfloat *); -extern void APIENTRY glColorTableParameteriv (GLenum, GLenum, const GLint *); -extern void APIENTRY glCopyColorTable (GLenum, GLenum, GLint, GLint, GLsizei); -extern void APIENTRY glGetColorTable (GLenum, GLenum, GLenum, GLvoid *); -extern void APIENTRY glGetColorTableParameterfv (GLenum, GLenum, GLfloat *); -extern void APIENTRY glGetColorTableParameteriv (GLenum, GLenum, GLint *); -extern void APIENTRY glColorSubTable (GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); -extern void APIENTRY glCopyColorSubTable (GLenum, GLsizei, GLint, GLint, GLsizei); -extern void APIENTRY glConvolutionFilter1D (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); -extern void APIENTRY glConvolutionFilter2D (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); -extern void APIENTRY glConvolutionParameterf (GLenum, GLenum, GLfloat); -extern void APIENTRY glConvolutionParameterfv (GLenum, GLenum, const GLfloat *); -extern void APIENTRY glConvolutionParameteri (GLenum, GLenum, GLint); -extern void APIENTRY glConvolutionParameteriv (GLenum, GLenum, const GLint *); -extern void APIENTRY glCopyConvolutionFilter1D (GLenum, GLenum, GLint, GLint, GLsizei); -extern void APIENTRY glCopyConvolutionFilter2D (GLenum, GLenum, GLint, GLint, GLsizei, GLsizei); -extern void APIENTRY glGetConvolutionFilter (GLenum, GLenum, GLenum, GLvoid *); -extern void APIENTRY glGetConvolutionParameterfv (GLenum, GLenum, GLfloat *); -extern void APIENTRY glGetConvolutionParameteriv (GLenum, GLenum, GLint *); -extern void APIENTRY glGetSeparableFilter (GLenum, GLenum, GLenum, GLvoid *, GLvoid *, GLvoid *); -extern void APIENTRY glSeparableFilter2D (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *, const GLvoid *); -extern void APIENTRY glGetHistogram (GLenum, GLboolean, GLenum, GLenum, GLvoid *); -extern void APIENTRY glGetHistogramParameterfv (GLenum, GLenum, GLfloat *); -extern void APIENTRY glGetHistogramParameteriv (GLenum, GLenum, GLint *); -extern void APIENTRY glGetMinmax (GLenum, GLboolean, GLenum, GLenum, GLvoid *); -extern void APIENTRY glGetMinmaxParameterfv (GLenum, GLenum, GLfloat *); -extern void APIENTRY glGetMinmaxParameteriv (GLenum, GLenum, GLint *); -extern void APIENTRY glHistogram (GLenum, GLsizei, GLenum, GLboolean); -extern void APIENTRY glMinmax (GLenum, GLenum, GLboolean); -extern void APIENTRY glResetHistogram (GLenum); -extern void APIENTRY glResetMinmax (GLenum); -extern void APIENTRY glTexImage3D (GLenum, GLint, GLint, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); -extern void APIENTRY glTexSubImage3D (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); -extern void APIENTRY glCopyTexSubImage3D (GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDCOLORPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); -typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode); -typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); -typedef void (APIENTRYP PFNGLCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); -typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLCOPYCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); -typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIPROC) (GLenum target, GLenum pname, GLint params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETSEPARABLEFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); -typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); -typedef void (APIENTRYP PFNGLGETHISTOGRAMPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); -typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMINMAXPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); -typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLHISTOGRAMPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); -typedef void (APIENTRYP PFNGLMINMAXPROC) (GLenum target, GLenum internalformat, GLboolean sink); -typedef void (APIENTRYP PFNGLRESETHISTOGRAMPROC) (GLenum target); -typedef void (APIENTRYP PFNGLRESETMINMAXPROC) (GLenum target); -typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -#endif - -#ifndef GL_VERSION_1_3 -#define GL_VERSION_1_3 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glActiveTexture (GLenum); -extern void APIENTRY glClientActiveTexture (GLenum); -extern void APIENTRY glMultiTexCoord1d (GLenum, GLdouble); -extern void APIENTRY glMultiTexCoord1dv (GLenum, const GLdouble *); -extern void APIENTRY glMultiTexCoord1f (GLenum, GLfloat); -extern void APIENTRY glMultiTexCoord1fv (GLenum, const GLfloat *); -extern void APIENTRY glMultiTexCoord1i (GLenum, GLint); -extern void APIENTRY glMultiTexCoord1iv (GLenum, const GLint *); -extern void APIENTRY glMultiTexCoord1s (GLenum, GLshort); -extern void APIENTRY glMultiTexCoord1sv (GLenum, const GLshort *); -extern void APIENTRY glMultiTexCoord2d (GLenum, GLdouble, GLdouble); -extern void APIENTRY glMultiTexCoord2dv (GLenum, const GLdouble *); -extern void APIENTRY glMultiTexCoord2f (GLenum, GLfloat, GLfloat); -extern void APIENTRY glMultiTexCoord2fv (GLenum, const GLfloat *); -extern void APIENTRY glMultiTexCoord2i (GLenum, GLint, GLint); -extern void APIENTRY glMultiTexCoord2iv (GLenum, const GLint *); -extern void APIENTRY glMultiTexCoord2s (GLenum, GLshort, GLshort); -extern void APIENTRY glMultiTexCoord2sv (GLenum, const GLshort *); -extern void APIENTRY glMultiTexCoord3d (GLenum, GLdouble, GLdouble, GLdouble); -extern void APIENTRY glMultiTexCoord3dv (GLenum, const GLdouble *); -extern void APIENTRY glMultiTexCoord3f (GLenum, GLfloat, GLfloat, GLfloat); -extern void APIENTRY glMultiTexCoord3fv (GLenum, const GLfloat *); -extern void APIENTRY glMultiTexCoord3i (GLenum, GLint, GLint, GLint); -extern void APIENTRY glMultiTexCoord3iv (GLenum, const GLint *); -extern void APIENTRY glMultiTexCoord3s (GLenum, GLshort, GLshort, GLshort); -extern void APIENTRY glMultiTexCoord3sv (GLenum, const GLshort *); -extern void APIENTRY glMultiTexCoord4d (GLenum, GLdouble, GLdouble, GLdouble, GLdouble); -extern void APIENTRY glMultiTexCoord4dv (GLenum, const GLdouble *); -extern void APIENTRY glMultiTexCoord4f (GLenum, GLfloat, GLfloat, GLfloat, GLfloat); -extern void APIENTRY glMultiTexCoord4fv (GLenum, const GLfloat *); -extern void APIENTRY glMultiTexCoord4i (GLenum, GLint, GLint, GLint, GLint); -extern void APIENTRY glMultiTexCoord4iv (GLenum, const GLint *); -extern void APIENTRY glMultiTexCoord4s (GLenum, GLshort, GLshort, GLshort, GLshort); -extern void APIENTRY glMultiTexCoord4sv (GLenum, const GLshort *); -extern void APIENTRY glLoadTransposeMatrixf (const GLfloat *); -extern void APIENTRY glLoadTransposeMatrixd (const GLdouble *); -extern void APIENTRY glMultTransposeMatrixf (const GLfloat *); -extern void APIENTRY glMultTransposeMatrixd (const GLdouble *); -extern void APIENTRY glSampleCoverage (GLclampf, GLboolean); -extern void APIENTRY glCompressedTexImage3D (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); -extern void APIENTRY glCompressedTexImage2D (GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); -extern void APIENTRY glCompressedTexImage1D (GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *); -extern void APIENTRY glCompressedTexSubImage3D (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); -extern void APIENTRY glCompressedTexSubImage2D (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); -extern void APIENTRY glCompressedTexSubImage1D (GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *); -extern void APIENTRY glGetCompressedTexImage (GLenum, GLint, GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture); -typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREPROC) (GLenum texture); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1DPROC) (GLenum target, GLdouble s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1FPROC) (GLenum target, GLfloat s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1IPROC) (GLenum target, GLint s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1SPROC) (GLenum target, GLshort s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2DPROC) (GLenum target, GLdouble s, GLdouble t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2FPROC) (GLenum target, GLfloat s, GLfloat t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2IPROC) (GLenum target, GLint s, GLint t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2SPROC) (GLenum target, GLshort s, GLshort t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3IPROC) (GLenum target, GLint s, GLint t, GLint r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3SPROC) (GLenum target, GLshort s, GLshort t, GLshort r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4IPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4SPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFPROC) (const GLfloat *m); -typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDPROC) (const GLdouble *m); -typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFPROC) (const GLfloat *m); -typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDPROC) (const GLdouble *m); -typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLclampf value, GLboolean invert); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, GLvoid *img); -#endif - -#ifndef GL_VERSION_1_4 -#define GL_VERSION_1_4 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glBlendFuncSeparate (GLenum, GLenum, GLenum, GLenum); -extern void APIENTRY glFogCoordf (GLfloat); -extern void APIENTRY glFogCoordfv (const GLfloat *); -extern void APIENTRY glFogCoordd (GLdouble); -extern void APIENTRY glFogCoorddv (const GLdouble *); -extern void APIENTRY glFogCoordPointer (GLenum, GLsizei, const GLvoid *); -extern void APIENTRY glMultiDrawArrays (GLenum, GLint *, GLsizei *, GLsizei); -extern void APIENTRY glMultiDrawElements (GLenum, const GLsizei *, GLenum, const GLvoid* *, GLsizei); -extern void APIENTRY glPointParameterf (GLenum, GLfloat); -extern void APIENTRY glPointParameterfv (GLenum, const GLfloat *); -extern void APIENTRY glPointParameteri (GLenum, GLint); -extern void APIENTRY glPointParameteriv (GLenum, const GLint *); -extern void APIENTRY glSecondaryColor3b (GLbyte, GLbyte, GLbyte); -extern void APIENTRY glSecondaryColor3bv (const GLbyte *); -extern void APIENTRY glSecondaryColor3d (GLdouble, GLdouble, GLdouble); -extern void APIENTRY glSecondaryColor3dv (const GLdouble *); -extern void APIENTRY glSecondaryColor3f (GLfloat, GLfloat, GLfloat); -extern void APIENTRY glSecondaryColor3fv (const GLfloat *); -extern void APIENTRY glSecondaryColor3i (GLint, GLint, GLint); -extern void APIENTRY glSecondaryColor3iv (const GLint *); -extern void APIENTRY glSecondaryColor3s (GLshort, GLshort, GLshort); -extern void APIENTRY glSecondaryColor3sv (const GLshort *); -extern void APIENTRY glSecondaryColor3ub (GLubyte, GLubyte, GLubyte); -extern void APIENTRY glSecondaryColor3ubv (const GLubyte *); -extern void APIENTRY glSecondaryColor3ui (GLuint, GLuint, GLuint); -extern void APIENTRY glSecondaryColor3uiv (const GLuint *); -extern void APIENTRY glSecondaryColor3us (GLushort, GLushort, GLushort); -extern void APIENTRY glSecondaryColor3usv (const GLushort *); -extern void APIENTRY glSecondaryColorPointer (GLint, GLenum, GLsizei, const GLvoid *); -extern void APIENTRY glWindowPos2d (GLdouble, GLdouble); -extern void APIENTRY glWindowPos2dv (const GLdouble *); -extern void APIENTRY glWindowPos2f (GLfloat, GLfloat); -extern void APIENTRY glWindowPos2fv (const GLfloat *); -extern void APIENTRY glWindowPos2i (GLint, GLint); -extern void APIENTRY glWindowPos2iv (const GLint *); -extern void APIENTRY glWindowPos2s (GLshort, GLshort); -extern void APIENTRY glWindowPos2sv (const GLshort *); -extern void APIENTRY glWindowPos3d (GLdouble, GLdouble, GLdouble); -extern void APIENTRY glWindowPos3dv (const GLdouble *); -extern void APIENTRY glWindowPos3f (GLfloat, GLfloat, GLfloat); -extern void APIENTRY glWindowPos3fv (const GLfloat *); -extern void APIENTRY glWindowPos3i (GLint, GLint, GLint); -extern void APIENTRY glWindowPos3iv (const GLint *); -extern void APIENTRY glWindowPos3s (GLshort, GLshort, GLshort); -extern void APIENTRY glWindowPos3sv (const GLshort *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); -typedef void (APIENTRYP PFNGLFOGCOORDFPROC) (GLfloat coord); -typedef void (APIENTRYP PFNGLFOGCOORDFVPROC) (const GLfloat *coord); -typedef void (APIENTRYP PFNGLFOGCOORDDPROC) (GLdouble coord); -typedef void (APIENTRYP PFNGLFOGCOORDDVPROC) (const GLdouble *coord); -typedef void (APIENTRYP PFNGLFOGCOORDPOINTERPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); -typedef void (APIENTRYP PFNGLPOINTPARAMETERFPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERFVPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLPOINTPARAMETERIPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERIVPROC) (GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BPROC) (GLbyte red, GLbyte green, GLbyte blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVPROC) (const GLbyte *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DPROC) (GLdouble red, GLdouble green, GLdouble blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FPROC) (GLfloat red, GLfloat green, GLfloat blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IPROC) (GLint red, GLint green, GLint blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SPROC) (GLshort red, GLshort green, GLshort blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBPROC) (GLubyte red, GLubyte green, GLubyte blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVPROC) (const GLubyte *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIPROC) (GLuint red, GLuint green, GLuint blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVPROC) (const GLuint *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USPROC) (GLushort red, GLushort green, GLushort blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVPROC) (const GLushort *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLWINDOWPOS2DPROC) (GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLWINDOWPOS2DVPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2FPROC) (GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLWINDOWPOS2FVPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2IPROC) (GLint x, GLint y); -typedef void (APIENTRYP PFNGLWINDOWPOS2IVPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2SPROC) (GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLWINDOWPOS2SVPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3DPROC) (GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLWINDOWPOS3DVPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3FPROC) (GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLWINDOWPOS3FVPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3IPROC) (GLint x, GLint y, GLint z); -typedef void (APIENTRYP PFNGLWINDOWPOS3IVPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3SPROC) (GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLWINDOWPOS3SVPROC) (const GLshort *v); -#endif - -#ifndef GL_VERSION_1_5 -#define GL_VERSION_1_5 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glGenQueries (GLsizei, GLuint *); -extern void APIENTRY glDeleteQueries (GLsizei, const GLuint *); -extern GLboolean APIENTRY glIsQuery (GLuint); -extern void APIENTRY glBeginQuery (GLenum, GLuint); -extern void APIENTRY glEndQuery (GLenum); -extern void APIENTRY glGetQueryiv (GLenum, GLenum, GLint *); -extern void APIENTRY glGetQueryObjectiv (GLuint, GLenum, GLint *); -extern void APIENTRY glGetQueryObjectuiv (GLuint, GLenum, GLuint *); -extern void APIENTRY glBindBuffer (GLenum, GLuint); -extern void APIENTRY glDeleteBuffers (GLsizei, const GLuint *); -extern void APIENTRY glGenBuffers (GLsizei, GLuint *); -extern GLboolean APIENTRY glIsBuffer (GLuint); -extern void APIENTRY glBufferData (GLenum, GLsizeiptr, const GLvoid *, GLenum); -extern void APIENTRY glBufferSubData (GLenum, GLintptr, GLsizeiptr, const GLvoid *); -extern void APIENTRY glGetBufferSubData (GLenum, GLintptr, GLsizeiptr, GLvoid *); -extern GLvoid* APIENTRY glMapBuffer (GLenum, GLenum); -extern GLboolean APIENTRY glUnmapBuffer (GLenum); -extern void APIENTRY glGetBufferParameteriv (GLenum, GLenum, GLint *); -extern void APIENTRY glGetBufferPointerv (GLenum, GLenum, GLvoid* *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGENQUERIESPROC) (GLsizei n, GLuint *ids); -typedef void (APIENTRYP PFNGLDELETEQUERIESPROC) (GLsizei n, const GLuint *ids); -typedef GLboolean (APIENTRYP PFNGLISQUERYPROC) (GLuint id); -typedef void (APIENTRYP PFNGLBEGINQUERYPROC) (GLenum target, GLuint id); -typedef void (APIENTRYP PFNGLENDQUERYPROC) (GLenum target); -typedef void (APIENTRYP PFNGLGETQUERYIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVPROC) (GLuint id, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVPROC) (GLuint id, GLenum pname, GLuint *params); -typedef void (APIENTRYP PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer); -typedef void (APIENTRYP PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint *buffers); -typedef void (APIENTRYP PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers); -typedef GLboolean (APIENTRYP PFNGLISBUFFERPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage); -typedef void (APIENTRYP PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data); -typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data); -typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERPROC) (GLenum target, GLenum access); -typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERPROC) (GLenum target); -typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVPROC) (GLenum target, GLenum pname, GLvoid* *params); -#endif - -#ifndef GL_VERSION_2_0 -#define GL_VERSION_2_0 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glBlendEquationSeparate (GLenum, GLenum); -extern void APIENTRY glDrawBuffers (GLsizei, const GLenum *); -extern void APIENTRY glStencilOpSeparate (GLenum, GLenum, GLenum, GLenum); -extern void APIENTRY glStencilFuncSeparate (GLenum, GLenum, GLint, GLuint); -extern void APIENTRY glStencilMaskSeparate (GLenum, GLuint); -extern void APIENTRY glAttachShader (GLuint, GLuint); -extern void APIENTRY glBindAttribLocation (GLuint, GLuint, const GLchar *); -extern void APIENTRY glCompileShader (GLuint); -extern GLuint APIENTRY glCreateProgram (void); -extern GLuint APIENTRY glCreateShader (GLenum); -extern void APIENTRY glDeleteProgram (GLuint); -extern void APIENTRY glDeleteShader (GLuint); -extern void APIENTRY glDetachShader (GLuint, GLuint); -extern void APIENTRY glDisableVertexAttribArray (GLuint); -extern void APIENTRY glEnableVertexAttribArray (GLuint); -extern void APIENTRY glGetActiveAttrib (GLuint, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLchar *); -extern void APIENTRY glGetActiveUniform (GLuint, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLchar *); -extern void APIENTRY glGetAttachedShaders (GLuint, GLsizei, GLsizei *, GLuint *); -extern GLint APIENTRY glGetAttribLocation (GLuint, const GLchar *); -extern void APIENTRY glGetProgramiv (GLuint, GLenum, GLint *); -extern void APIENTRY glGetProgramInfoLog (GLuint, GLsizei, GLsizei *, GLchar *); -extern void APIENTRY glGetShaderiv (GLuint, GLenum, GLint *); -extern void APIENTRY glGetShaderInfoLog (GLuint, GLsizei, GLsizei *, GLchar *); -extern void APIENTRY glGetShaderSource (GLuint, GLsizei, GLsizei *, GLchar *); -extern GLint APIENTRY glGetUniformLocation (GLuint, const GLchar *); -extern void APIENTRY glGetUniformfv (GLuint, GLint, GLfloat *); -extern void APIENTRY glGetUniformiv (GLuint, GLint, GLint *); -extern void APIENTRY glGetVertexAttribdv (GLuint, GLenum, GLdouble *); -extern void APIENTRY glGetVertexAttribfv (GLuint, GLenum, GLfloat *); -extern void APIENTRY glGetVertexAttribiv (GLuint, GLenum, GLint *); -extern void APIENTRY glGetVertexAttribPointerv (GLuint, GLenum, GLvoid* *); -extern GLboolean APIENTRY glIsProgram (GLuint); -extern GLboolean APIENTRY glIsShader (GLuint); -extern void APIENTRY glLinkProgram (GLuint); -extern void APIENTRY glShaderSource (GLuint, GLsizei, const GLchar* *, const GLint *); -extern void APIENTRY glUseProgram (GLuint); -extern void APIENTRY glUniform1f (GLint, GLfloat); -extern void APIENTRY glUniform2f (GLint, GLfloat, GLfloat); -extern void APIENTRY glUniform3f (GLint, GLfloat, GLfloat, GLfloat); -extern void APIENTRY glUniform4f (GLint, GLfloat, GLfloat, GLfloat, GLfloat); -extern void APIENTRY glUniform1i (GLint, GLint); -extern void APIENTRY glUniform2i (GLint, GLint, GLint); -extern void APIENTRY glUniform3i (GLint, GLint, GLint, GLint); -extern void APIENTRY glUniform4i (GLint, GLint, GLint, GLint, GLint); -extern void APIENTRY glUniform1fv (GLint, GLsizei, const GLfloat *); -extern void APIENTRY glUniform2fv (GLint, GLsizei, const GLfloat *); -extern void APIENTRY glUniform3fv (GLint, GLsizei, const GLfloat *); -extern void APIENTRY glUniform4fv (GLint, GLsizei, const GLfloat *); -extern void APIENTRY glUniform1iv (GLint, GLsizei, const GLint *); -extern void APIENTRY glUniform2iv (GLint, GLsizei, const GLint *); -extern void APIENTRY glUniform3iv (GLint, GLsizei, const GLint *); -extern void APIENTRY glUniform4iv (GLint, GLsizei, const GLint *); -extern void APIENTRY glUniformMatrix2fv (GLint, GLsizei, GLboolean, const GLfloat *); -extern void APIENTRY glUniformMatrix3fv (GLint, GLsizei, GLboolean, const GLfloat *); -extern void APIENTRY glUniformMatrix4fv (GLint, GLsizei, GLboolean, const GLfloat *); -extern void APIENTRY glValidateProgram (GLuint); -extern void APIENTRY glVertexAttrib1d (GLuint, GLdouble); -extern void APIENTRY glVertexAttrib1dv (GLuint, const GLdouble *); -extern void APIENTRY glVertexAttrib1f (GLuint, GLfloat); -extern void APIENTRY glVertexAttrib1fv (GLuint, const GLfloat *); -extern void APIENTRY glVertexAttrib1s (GLuint, GLshort); -extern void APIENTRY glVertexAttrib1sv (GLuint, const GLshort *); -extern void APIENTRY glVertexAttrib2d (GLuint, GLdouble, GLdouble); -extern void APIENTRY glVertexAttrib2dv (GLuint, const GLdouble *); -extern void APIENTRY glVertexAttrib2f (GLuint, GLfloat, GLfloat); -extern void APIENTRY glVertexAttrib2fv (GLuint, const GLfloat *); -extern void APIENTRY glVertexAttrib2s (GLuint, GLshort, GLshort); -extern void APIENTRY glVertexAttrib2sv (GLuint, const GLshort *); -extern void APIENTRY glVertexAttrib3d (GLuint, GLdouble, GLdouble, GLdouble); -extern void APIENTRY glVertexAttrib3dv (GLuint, const GLdouble *); -extern void APIENTRY glVertexAttrib3f (GLuint, GLfloat, GLfloat, GLfloat); -extern void APIENTRY glVertexAttrib3fv (GLuint, const GLfloat *); -extern void APIENTRY glVertexAttrib3s (GLuint, GLshort, GLshort, GLshort); -extern void APIENTRY glVertexAttrib3sv (GLuint, const GLshort *); -extern void APIENTRY glVertexAttrib4Nbv (GLuint, const GLbyte *); -extern void APIENTRY glVertexAttrib4Niv (GLuint, const GLint *); -extern void APIENTRY glVertexAttrib4Nsv (GLuint, const GLshort *); -extern void APIENTRY glVertexAttrib4Nub (GLuint, GLubyte, GLubyte, GLubyte, GLubyte); -extern void APIENTRY glVertexAttrib4Nubv (GLuint, const GLubyte *); -extern void APIENTRY glVertexAttrib4Nuiv (GLuint, const GLuint *); -extern void APIENTRY glVertexAttrib4Nusv (GLuint, const GLushort *); -extern void APIENTRY glVertexAttrib4bv (GLuint, const GLbyte *); -extern void APIENTRY glVertexAttrib4d (GLuint, GLdouble, GLdouble, GLdouble, GLdouble); -extern void APIENTRY glVertexAttrib4dv (GLuint, const GLdouble *); -extern void APIENTRY glVertexAttrib4f (GLuint, GLfloat, GLfloat, GLfloat, GLfloat); -extern void APIENTRY glVertexAttrib4fv (GLuint, const GLfloat *); -extern void APIENTRY glVertexAttrib4iv (GLuint, const GLint *); -extern void APIENTRY glVertexAttrib4s (GLuint, GLshort, GLshort, GLshort, GLshort); -extern void APIENTRY glVertexAttrib4sv (GLuint, const GLshort *); -extern void APIENTRY glVertexAttrib4ubv (GLuint, const GLubyte *); -extern void APIENTRY glVertexAttrib4uiv (GLuint, const GLuint *); -extern void APIENTRY glVertexAttrib4usv (GLuint, const GLushort *); -extern void APIENTRY glVertexAttribPointer (GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum modeRGB, GLenum modeAlpha); -typedef void (APIENTRYP PFNGLDRAWBUFFERSPROC) (GLsizei n, const GLenum *bufs); -typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); -typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); -typedef void (APIENTRYP PFNGLSTENCILMASKSEPARATEPROC) (GLenum face, GLuint mask); -typedef void (APIENTRYP PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader); -typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar *name); -typedef void (APIENTRYP PFNGLCOMPILESHADERPROC) (GLuint shader); -typedef GLuint (APIENTRYP PFNGLCREATEPROGRAMPROC) (void); -typedef GLuint (APIENTRYP PFNGLCREATESHADERPROC) (GLenum type); -typedef void (APIENTRYP PFNGLDELETEPROGRAMPROC) (GLuint program); -typedef void (APIENTRYP PFNGLDELETESHADERPROC) (GLuint shader); -typedef void (APIENTRYP PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader); -typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint index); -typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index); -typedef void (APIENTRYP PFNGLGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); -typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); -typedef void (APIENTRYP PFNGLGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *obj); -typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar *name); -typedef void (APIENTRYP PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); -typedef void (APIENTRYP PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); -typedef void (APIENTRYP PFNGLGETSHADERSOURCEPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); -typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar *name); -typedef void (APIENTRYP PFNGLGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat *params); -typedef void (APIENTRYP PFNGLGETUNIFORMIVPROC) (GLuint program, GLint location, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVPROC) (GLuint index, GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVPROC) (GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVPROC) (GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint index, GLenum pname, GLvoid* *pointer); -typedef GLboolean (APIENTRYP PFNGLISPROGRAMPROC) (GLuint program); -typedef GLboolean (APIENTRYP PFNGLISSHADERPROC) (GLuint shader); -typedef void (APIENTRYP PFNGLLINKPROGRAMPROC) (GLuint program); -typedef void (APIENTRYP PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar* *string, const GLint *length); -typedef void (APIENTRYP PFNGLUSEPROGRAMPROC) (GLuint program); -typedef void (APIENTRYP PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0); -typedef void (APIENTRYP PFNGLUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1); -typedef void (APIENTRYP PFNGLUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -typedef void (APIENTRYP PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -typedef void (APIENTRYP PFNGLUNIFORM1IPROC) (GLint location, GLint v0); -typedef void (APIENTRYP PFNGLUNIFORM2IPROC) (GLint location, GLint v0, GLint v1); -typedef void (APIENTRYP PFNGLUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2); -typedef void (APIENTRYP PFNGLUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -typedef void (APIENTRYP PFNGLUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPROC) (GLuint program); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DPROC) (GLuint index, GLdouble x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FPROC) (GLuint index, GLfloat x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SPROC) (GLuint index, GLshort x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DPROC) (GLuint index, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SPROC) (GLuint index, GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SPROC) (GLuint index, GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); -#endif - -#ifndef GL_VERSION_2_1 -#define GL_VERSION_2_1 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glUniformMatrix2x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -extern void APIENTRY glUniformMatrix3x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -extern void APIENTRY glUniformMatrix2x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -extern void APIENTRY glUniformMatrix4x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -extern void APIENTRY glUniformMatrix3x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -extern void APIENTRY glUniformMatrix4x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -#endif - -#ifndef GL_ARB_multitexture -#define GL_ARB_multitexture 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glActiveTextureARB (GLenum); -extern void APIENTRY glClientActiveTextureARB (GLenum); -extern void APIENTRY glMultiTexCoord1dARB (GLenum, GLdouble); -extern void APIENTRY glMultiTexCoord1dvARB (GLenum, const GLdouble *); -extern void APIENTRY glMultiTexCoord1fARB (GLenum, GLfloat); -extern void APIENTRY glMultiTexCoord1fvARB (GLenum, const GLfloat *); -extern void APIENTRY glMultiTexCoord1iARB (GLenum, GLint); -extern void APIENTRY glMultiTexCoord1ivARB (GLenum, const GLint *); -extern void APIENTRY glMultiTexCoord1sARB (GLenum, GLshort); -extern void APIENTRY glMultiTexCoord1svARB (GLenum, const GLshort *); -extern void APIENTRY glMultiTexCoord2dARB (GLenum, GLdouble, GLdouble); -extern void APIENTRY glMultiTexCoord2dvARB (GLenum, const GLdouble *); -extern void APIENTRY glMultiTexCoord2fARB (GLenum, GLfloat, GLfloat); -extern void APIENTRY glMultiTexCoord2fvARB (GLenum, const GLfloat *); -extern void APIENTRY glMultiTexCoord2iARB (GLenum, GLint, GLint); -extern void APIENTRY glMultiTexCoord2ivARB (GLenum, const GLint *); -extern void APIENTRY glMultiTexCoord2sARB (GLenum, GLshort, GLshort); -extern void APIENTRY glMultiTexCoord2svARB (GLenum, const GLshort *); -extern void APIENTRY glMultiTexCoord3dARB (GLenum, GLdouble, GLdouble, GLdouble); -extern void APIENTRY glMultiTexCoord3dvARB (GLenum, const GLdouble *); -extern void APIENTRY glMultiTexCoord3fARB (GLenum, GLfloat, GLfloat, GLfloat); -extern void APIENTRY glMultiTexCoord3fvARB (GLenum, const GLfloat *); -extern void APIENTRY glMultiTexCoord3iARB (GLenum, GLint, GLint, GLint); -extern void APIENTRY glMultiTexCoord3ivARB (GLenum, const GLint *); -extern void APIENTRY glMultiTexCoord3sARB (GLenum, GLshort, GLshort, GLshort); -extern void APIENTRY glMultiTexCoord3svARB (GLenum, const GLshort *); -extern void APIENTRY glMultiTexCoord4dARB (GLenum, GLdouble, GLdouble, GLdouble, GLdouble); -extern void APIENTRY glMultiTexCoord4dvARB (GLenum, const GLdouble *); -extern void APIENTRY glMultiTexCoord4fARB (GLenum, GLfloat, GLfloat, GLfloat, GLfloat); -extern void APIENTRY glMultiTexCoord4fvARB (GLenum, const GLfloat *); -extern void APIENTRY glMultiTexCoord4iARB (GLenum, GLint, GLint, GLint, GLint); -extern void APIENTRY glMultiTexCoord4ivARB (GLenum, const GLint *); -extern void APIENTRY glMultiTexCoord4sARB (GLenum, GLshort, GLshort, GLshort, GLshort); -extern void APIENTRY glMultiTexCoord4svARB (GLenum, const GLshort *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLACTIVETEXTUREARBPROC) (GLenum texture); -typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v); -#endif - -#ifndef GL_ARB_transpose_matrix -#define GL_ARB_transpose_matrix 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glLoadTransposeMatrixfARB (const GLfloat *); -extern void APIENTRY glLoadTransposeMatrixdARB (const GLdouble *); -extern void APIENTRY glMultTransposeMatrixfARB (const GLfloat *); -extern void APIENTRY glMultTransposeMatrixdARB (const GLdouble *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); -typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); -typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); -typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); -#endif - -#ifndef GL_ARB_multisample -#define GL_ARB_multisample 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glSampleCoverageARB (GLclampf, GLboolean); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSAMPLECOVERAGEARBPROC) (GLclampf value, GLboolean invert); -#endif - -#ifndef GL_ARB_texture_env_add -#define GL_ARB_texture_env_add 1 -#endif - -#ifndef GL_ARB_texture_cube_map -#define GL_ARB_texture_cube_map 1 -#endif - -#ifndef GL_ARB_texture_compression -#define GL_ARB_texture_compression 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glCompressedTexImage3DARB (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); -extern void APIENTRY glCompressedTexImage2DARB (GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); -extern void APIENTRY glCompressedTexImage1DARB (GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *); -extern void APIENTRY glCompressedTexSubImage3DARB (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); -extern void APIENTRY glCompressedTexSubImage2DARB (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); -extern void APIENTRY glCompressedTexSubImage1DARB (GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *); -extern void APIENTRY glGetCompressedTexImageARB (GLenum, GLint, GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint level, GLvoid *img); -#endif - -#ifndef GL_ARB_texture_border_clamp -#define GL_ARB_texture_border_clamp 1 -#endif - -#ifndef GL_ARB_point_parameters -#define GL_ARB_point_parameters 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glPointParameterfARB (GLenum, GLfloat); -extern void APIENTRY glPointParameterfvARB (GLenum, const GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPOINTPARAMETERFARBPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERFVARBPROC) (GLenum pname, const GLfloat *params); -#endif - -#ifndef GL_ARB_vertex_blend -#define GL_ARB_vertex_blend 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glWeightbvARB (GLint, const GLbyte *); -extern void APIENTRY glWeightsvARB (GLint, const GLshort *); -extern void APIENTRY glWeightivARB (GLint, const GLint *); -extern void APIENTRY glWeightfvARB (GLint, const GLfloat *); -extern void APIENTRY glWeightdvARB (GLint, const GLdouble *); -extern void APIENTRY glWeightubvARB (GLint, const GLubyte *); -extern void APIENTRY glWeightusvARB (GLint, const GLushort *); -extern void APIENTRY glWeightuivARB (GLint, const GLuint *); -extern void APIENTRY glWeightPointerARB (GLint, GLenum, GLsizei, const GLvoid *); -extern void APIENTRY glVertexBlendARB (GLint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLWEIGHTBVARBPROC) (GLint size, const GLbyte *weights); -typedef void (APIENTRYP PFNGLWEIGHTSVARBPROC) (GLint size, const GLshort *weights); -typedef void (APIENTRYP PFNGLWEIGHTIVARBPROC) (GLint size, const GLint *weights); -typedef void (APIENTRYP PFNGLWEIGHTFVARBPROC) (GLint size, const GLfloat *weights); -typedef void (APIENTRYP PFNGLWEIGHTDVARBPROC) (GLint size, const GLdouble *weights); -typedef void (APIENTRYP PFNGLWEIGHTUBVARBPROC) (GLint size, const GLubyte *weights); -typedef void (APIENTRYP PFNGLWEIGHTUSVARBPROC) (GLint size, const GLushort *weights); -typedef void (APIENTRYP PFNGLWEIGHTUIVARBPROC) (GLint size, const GLuint *weights); -typedef void (APIENTRYP PFNGLWEIGHTPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLVERTEXBLENDARBPROC) (GLint count); -#endif - -#ifndef GL_ARB_matrix_palette -#define GL_ARB_matrix_palette 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glCurrentPaletteMatrixARB (GLint); -extern void APIENTRY glMatrixIndexubvARB (GLint, const GLubyte *); -extern void APIENTRY glMatrixIndexusvARB (GLint, const GLushort *); -extern void APIENTRY glMatrixIndexuivARB (GLint, const GLuint *); -extern void APIENTRY glMatrixIndexPointerARB (GLint, GLenum, GLsizei, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCURRENTPALETTEMATRIXARBPROC) (GLint index); -typedef void (APIENTRYP PFNGLMATRIXINDEXUBVARBPROC) (GLint size, const GLubyte *indices); -typedef void (APIENTRYP PFNGLMATRIXINDEXUSVARBPROC) (GLint size, const GLushort *indices); -typedef void (APIENTRYP PFNGLMATRIXINDEXUIVARBPROC) (GLint size, const GLuint *indices); -typedef void (APIENTRYP PFNGLMATRIXINDEXPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -#endif - -#ifndef GL_ARB_texture_env_combine -#define GL_ARB_texture_env_combine 1 -#endif - -#ifndef GL_ARB_texture_env_crossbar -#define GL_ARB_texture_env_crossbar 1 -#endif - -#ifndef GL_ARB_texture_env_dot3 -#define GL_ARB_texture_env_dot3 1 -#endif - -#ifndef GL_ARB_texture_mirrored_repeat -#define GL_ARB_texture_mirrored_repeat 1 -#endif - -#ifndef GL_ARB_depth_texture -#define GL_ARB_depth_texture 1 -#endif - -#ifndef GL_ARB_shadow -#define GL_ARB_shadow 1 -#endif - -#ifndef GL_ARB_shadow_ambient -#define GL_ARB_shadow_ambient 1 -#endif - -#ifndef GL_ARB_window_pos -#define GL_ARB_window_pos 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glWindowPos2dARB (GLdouble, GLdouble); -extern void APIENTRY glWindowPos2dvARB (const GLdouble *); -extern void APIENTRY glWindowPos2fARB (GLfloat, GLfloat); -extern void APIENTRY glWindowPos2fvARB (const GLfloat *); -extern void APIENTRY glWindowPos2iARB (GLint, GLint); -extern void APIENTRY glWindowPos2ivARB (const GLint *); -extern void APIENTRY glWindowPos2sARB (GLshort, GLshort); -extern void APIENTRY glWindowPos2svARB (const GLshort *); -extern void APIENTRY glWindowPos3dARB (GLdouble, GLdouble, GLdouble); -extern void APIENTRY glWindowPos3dvARB (const GLdouble *); -extern void APIENTRY glWindowPos3fARB (GLfloat, GLfloat, GLfloat); -extern void APIENTRY glWindowPos3fvARB (const GLfloat *); -extern void APIENTRY glWindowPos3iARB (GLint, GLint, GLint); -extern void APIENTRY glWindowPos3ivARB (const GLint *); -extern void APIENTRY glWindowPos3sARB (GLshort, GLshort, GLshort); -extern void APIENTRY glWindowPos3svARB (const GLshort *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLWINDOWPOS2DARBPROC) (GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLWINDOWPOS2DVARBPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2FARBPROC) (GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLWINDOWPOS2FVARBPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2IARBPROC) (GLint x, GLint y); -typedef void (APIENTRYP PFNGLWINDOWPOS2IVARBPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2SARBPROC) (GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLWINDOWPOS2SVARBPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3DARBPROC) (GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLWINDOWPOS3DVARBPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3FARBPROC) (GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLWINDOWPOS3FVARBPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3IARBPROC) (GLint x, GLint y, GLint z); -typedef void (APIENTRYP PFNGLWINDOWPOS3IVARBPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3SARBPROC) (GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLWINDOWPOS3SVARBPROC) (const GLshort *v); -#endif - -#ifndef GL_ARB_vertex_program -#define GL_ARB_vertex_program 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glVertexAttrib1dARB (GLuint, GLdouble); -extern void APIENTRY glVertexAttrib1dvARB (GLuint, const GLdouble *); -extern void APIENTRY glVertexAttrib1fARB (GLuint, GLfloat); -extern void APIENTRY glVertexAttrib1fvARB (GLuint, const GLfloat *); -extern void APIENTRY glVertexAttrib1sARB (GLuint, GLshort); -extern void APIENTRY glVertexAttrib1svARB (GLuint, const GLshort *); -extern void APIENTRY glVertexAttrib2dARB (GLuint, GLdouble, GLdouble); -extern void APIENTRY glVertexAttrib2dvARB (GLuint, const GLdouble *); -extern void APIENTRY glVertexAttrib2fARB (GLuint, GLfloat, GLfloat); -extern void APIENTRY glVertexAttrib2fvARB (GLuint, const GLfloat *); -extern void APIENTRY glVertexAttrib2sARB (GLuint, GLshort, GLshort); -extern void APIENTRY glVertexAttrib2svARB (GLuint, const GLshort *); -extern void APIENTRY glVertexAttrib3dARB (GLuint, GLdouble, GLdouble, GLdouble); -extern void APIENTRY glVertexAttrib3dvARB (GLuint, const GLdouble *); -extern void APIENTRY glVertexAttrib3fARB (GLuint, GLfloat, GLfloat, GLfloat); -extern void APIENTRY glVertexAttrib3fvARB (GLuint, const GLfloat *); -extern void APIENTRY glVertexAttrib3sARB (GLuint, GLshort, GLshort, GLshort); -extern void APIENTRY glVertexAttrib3svARB (GLuint, const GLshort *); -extern void APIENTRY glVertexAttrib4NbvARB (GLuint, const GLbyte *); -extern void APIENTRY glVertexAttrib4NivARB (GLuint, const GLint *); -extern void APIENTRY glVertexAttrib4NsvARB (GLuint, const GLshort *); -extern void APIENTRY glVertexAttrib4NubARB (GLuint, GLubyte, GLubyte, GLubyte, GLubyte); -extern void APIENTRY glVertexAttrib4NubvARB (GLuint, const GLubyte *); -extern void APIENTRY glVertexAttrib4NuivARB (GLuint, const GLuint *); -extern void APIENTRY glVertexAttrib4NusvARB (GLuint, const GLushort *); -extern void APIENTRY glVertexAttrib4bvARB (GLuint, const GLbyte *); -extern void APIENTRY glVertexAttrib4dARB (GLuint, GLdouble, GLdouble, GLdouble, GLdouble); -extern void APIENTRY glVertexAttrib4dvARB (GLuint, const GLdouble *); -extern void APIENTRY glVertexAttrib4fARB (GLuint, GLfloat, GLfloat, GLfloat, GLfloat); -extern void APIENTRY glVertexAttrib4fvARB (GLuint, const GLfloat *); -extern void APIENTRY glVertexAttrib4ivARB (GLuint, const GLint *); -extern void APIENTRY glVertexAttrib4sARB (GLuint, GLshort, GLshort, GLshort, GLshort); -extern void APIENTRY glVertexAttrib4svARB (GLuint, const GLshort *); -extern void APIENTRY glVertexAttrib4ubvARB (GLuint, const GLubyte *); -extern void APIENTRY glVertexAttrib4uivARB (GLuint, const GLuint *); -extern void APIENTRY glVertexAttrib4usvARB (GLuint, const GLushort *); -extern void APIENTRY glVertexAttribPointerARB (GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid *); -extern void APIENTRY glEnableVertexAttribArrayARB (GLuint); -extern void APIENTRY glDisableVertexAttribArrayARB (GLuint); -extern void APIENTRY glProgramStringARB (GLenum, GLenum, GLsizei, const GLvoid *); -extern void APIENTRY glBindProgramARB (GLenum, GLuint); -extern void APIENTRY glDeleteProgramsARB (GLsizei, const GLuint *); -extern void APIENTRY glGenProgramsARB (GLsizei, GLuint *); -extern void APIENTRY glProgramEnvParameter4dARB (GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble); -extern void APIENTRY glProgramEnvParameter4dvARB (GLenum, GLuint, const GLdouble *); -extern void APIENTRY glProgramEnvParameter4fARB (GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat); -extern void APIENTRY glProgramEnvParameter4fvARB (GLenum, GLuint, const GLfloat *); -extern void APIENTRY glProgramLocalParameter4dARB (GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble); -extern void APIENTRY glProgramLocalParameter4dvARB (GLenum, GLuint, const GLdouble *); -extern void APIENTRY glProgramLocalParameter4fARB (GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat); -extern void APIENTRY glProgramLocalParameter4fvARB (GLenum, GLuint, const GLfloat *); -extern void APIENTRY glGetProgramEnvParameterdvARB (GLenum, GLuint, GLdouble *); -extern void APIENTRY glGetProgramEnvParameterfvARB (GLenum, GLuint, GLfloat *); -extern void APIENTRY glGetProgramLocalParameterdvARB (GLenum, GLuint, GLdouble *); -extern void APIENTRY glGetProgramLocalParameterfvARB (GLenum, GLuint, GLfloat *); -extern void APIENTRY glGetProgramivARB (GLenum, GLenum, GLint *); -extern void APIENTRY glGetProgramStringARB (GLenum, GLenum, GLvoid *); -extern void APIENTRY glGetVertexAttribdvARB (GLuint, GLenum, GLdouble *); -extern void APIENTRY glGetVertexAttribfvARB (GLuint, GLenum, GLfloat *); -extern void APIENTRY glGetVertexAttribivARB (GLuint, GLenum, GLint *); -extern void APIENTRY glGetVertexAttribPointervARB (GLuint, GLenum, GLvoid* *); -extern GLboolean APIENTRY glIsProgramARB (GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DARBPROC) (GLuint index, GLdouble x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVARBPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FARBPROC) (GLuint index, GLfloat x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVARBPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SARBPROC) (GLuint index, GLshort x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVARBPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DARBPROC) (GLuint index, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVARBPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FARBPROC) (GLuint index, GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVARBPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SARBPROC) (GLuint index, GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVARBPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVARBPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVARBPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVARBPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVARBPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVARBPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVARBPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBARBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVARBPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVARBPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVARBPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVARBPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVARBPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVARBPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVARBPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVARBPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVARBPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVARBPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVARBPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERARBPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); -typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); -typedef void (APIENTRYP PFNGLPROGRAMSTRINGARBPROC) (GLenum target, GLenum format, GLsizei len, const GLvoid *string); -typedef void (APIENTRYP PFNGLBINDPROGRAMARBPROC) (GLenum target, GLuint program); -typedef void (APIENTRYP PFNGLDELETEPROGRAMSARBPROC) (GLsizei n, const GLuint *programs); -typedef void (APIENTRYP PFNGLGENPROGRAMSARBPROC) (GLsizei n, GLuint *programs); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); -typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); -typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); -typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); -typedef void (APIENTRYP PFNGLGETPROGRAMIVARBPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGARBPROC) (GLenum target, GLenum pname, GLvoid *string); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVARBPROC) (GLuint index, GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVARBPROC) (GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVARBPROC) (GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVARBPROC) (GLuint index, GLenum pname, GLvoid* *pointer); -typedef GLboolean (APIENTRYP PFNGLISPROGRAMARBPROC) (GLuint program); -#endif - -#ifndef GL_ARB_fragment_program -#define GL_ARB_fragment_program 1 -/* All ARB_fragment_program entry points are shared with ARB_vertex_program. */ -#endif - -#ifndef GL_ARB_vertex_buffer_object -#define GL_ARB_vertex_buffer_object 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glBindBufferARB (GLenum, GLuint); -extern void APIENTRY glDeleteBuffersARB (GLsizei, const GLuint *); -extern void APIENTRY glGenBuffersARB (GLsizei, GLuint *); -extern GLboolean APIENTRY glIsBufferARB (GLuint); -extern void APIENTRY glBufferDataARB (GLenum, GLsizeiptrARB, const GLvoid *, GLenum); -extern void APIENTRY glBufferSubDataARB (GLenum, GLintptrARB, GLsizeiptrARB, const GLvoid *); -extern void APIENTRY glGetBufferSubDataARB (GLenum, GLintptrARB, GLsizeiptrARB, GLvoid *); -extern GLvoid* APIENTRY glMapBufferARB (GLenum, GLenum); -extern GLboolean APIENTRY glUnmapBufferARB (GLenum); -extern void APIENTRY glGetBufferParameterivARB (GLenum, GLenum, GLint *); -extern void APIENTRY glGetBufferPointervARB (GLenum, GLenum, GLvoid* *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBINDBUFFERARBPROC) (GLenum target, GLuint buffer); -typedef void (APIENTRYP PFNGLDELETEBUFFERSARBPROC) (GLsizei n, const GLuint *buffers); -typedef void (APIENTRYP PFNGLGENBUFFERSARBPROC) (GLsizei n, GLuint *buffers); -typedef GLboolean (APIENTRYP PFNGLISBUFFERARBPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLBUFFERDATAARBPROC) (GLenum target, GLsizeiptrARB size, const GLvoid *data, GLenum usage); -typedef void (APIENTRYP PFNGLBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid *data); -typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, GLvoid *data); -typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERARBPROC) (GLenum target, GLenum access); -typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERARBPROC) (GLenum target); -typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVARBPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVARBPROC) (GLenum target, GLenum pname, GLvoid* *params); -#endif - -#ifndef GL_ARB_occlusion_query -#define GL_ARB_occlusion_query 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glGenQueriesARB (GLsizei, GLuint *); -extern void APIENTRY glDeleteQueriesARB (GLsizei, const GLuint *); -extern GLboolean APIENTRY glIsQueryARB (GLuint); -extern void APIENTRY glBeginQueryARB (GLenum, GLuint); -extern void APIENTRY glEndQueryARB (GLenum); -extern void APIENTRY glGetQueryivARB (GLenum, GLenum, GLint *); -extern void APIENTRY glGetQueryObjectivARB (GLuint, GLenum, GLint *); -extern void APIENTRY glGetQueryObjectuivARB (GLuint, GLenum, GLuint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGENQUERIESARBPROC) (GLsizei n, GLuint *ids); -typedef void (APIENTRYP PFNGLDELETEQUERIESARBPROC) (GLsizei n, const GLuint *ids); -typedef GLboolean (APIENTRYP PFNGLISQUERYARBPROC) (GLuint id); -typedef void (APIENTRYP PFNGLBEGINQUERYARBPROC) (GLenum target, GLuint id); -typedef void (APIENTRYP PFNGLENDQUERYARBPROC) (GLenum target); -typedef void (APIENTRYP PFNGLGETQUERYIVARBPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVARBPROC) (GLuint id, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVARBPROC) (GLuint id, GLenum pname, GLuint *params); -#endif - -#ifndef GL_ARB_shader_objects -#define GL_ARB_shader_objects 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glDeleteObjectARB (GLhandleARB); -extern GLhandleARB APIENTRY glGetHandleARB (GLenum); -extern void APIENTRY glDetachObjectARB (GLhandleARB, GLhandleARB); -extern GLhandleARB APIENTRY glCreateShaderObjectARB (GLenum); -extern void APIENTRY glShaderSourceARB (GLhandleARB, GLsizei, const GLcharARB* *, const GLint *); -extern void APIENTRY glCompileShaderARB (GLhandleARB); -extern GLhandleARB APIENTRY glCreateProgramObjectARB (void); -extern void APIENTRY glAttachObjectARB (GLhandleARB, GLhandleARB); -extern void APIENTRY glLinkProgramARB (GLhandleARB); -extern void APIENTRY glUseProgramObjectARB (GLhandleARB); -extern void APIENTRY glValidateProgramARB (GLhandleARB); -extern void APIENTRY glUniform1fARB (GLint, GLfloat); -extern void APIENTRY glUniform2fARB (GLint, GLfloat, GLfloat); -extern void APIENTRY glUniform3fARB (GLint, GLfloat, GLfloat, GLfloat); -extern void APIENTRY glUniform4fARB (GLint, GLfloat, GLfloat, GLfloat, GLfloat); -extern void APIENTRY glUniform1iARB (GLint, GLint); -extern void APIENTRY glUniform2iARB (GLint, GLint, GLint); -extern void APIENTRY glUniform3iARB (GLint, GLint, GLint, GLint); -extern void APIENTRY glUniform4iARB (GLint, GLint, GLint, GLint, GLint); -extern void APIENTRY glUniform1fvARB (GLint, GLsizei, const GLfloat *); -extern void APIENTRY glUniform2fvARB (GLint, GLsizei, const GLfloat *); -extern void APIENTRY glUniform3fvARB (GLint, GLsizei, const GLfloat *); -extern void APIENTRY glUniform4fvARB (GLint, GLsizei, const GLfloat *); -extern void APIENTRY glUniform1ivARB (GLint, GLsizei, const GLint *); -extern void APIENTRY glUniform2ivARB (GLint, GLsizei, const GLint *); -extern void APIENTRY glUniform3ivARB (GLint, GLsizei, const GLint *); -extern void APIENTRY glUniform4ivARB (GLint, GLsizei, const GLint *); -extern void APIENTRY glUniformMatrix2fvARB (GLint, GLsizei, GLboolean, const GLfloat *); -extern void APIENTRY glUniformMatrix3fvARB (GLint, GLsizei, GLboolean, const GLfloat *); -extern void APIENTRY glUniformMatrix4fvARB (GLint, GLsizei, GLboolean, const GLfloat *); -extern void APIENTRY glGetObjectParameterfvARB (GLhandleARB, GLenum, GLfloat *); -extern void APIENTRY glGetObjectParameterivARB (GLhandleARB, GLenum, GLint *); -extern void APIENTRY glGetInfoLogARB (GLhandleARB, GLsizei, GLsizei *, GLcharARB *); -extern void APIENTRY glGetAttachedObjectsARB (GLhandleARB, GLsizei, GLsizei *, GLhandleARB *); -extern GLint APIENTRY glGetUniformLocationARB (GLhandleARB, const GLcharARB *); -extern void APIENTRY glGetActiveUniformARB (GLhandleARB, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLcharARB *); -extern void APIENTRY glGetUniformfvARB (GLhandleARB, GLint, GLfloat *); -extern void APIENTRY glGetUniformivARB (GLhandleARB, GLint, GLint *); -extern void APIENTRY glGetShaderSourceARB (GLhandleARB, GLsizei, GLsizei *, GLcharARB *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDELETEOBJECTARBPROC) (GLhandleARB obj); -typedef GLhandleARB (APIENTRYP PFNGLGETHANDLEARBPROC) (GLenum pname); -typedef void (APIENTRYP PFNGLDETACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB attachedObj); -typedef GLhandleARB (APIENTRYP PFNGLCREATESHADEROBJECTARBPROC) (GLenum shaderType); -typedef void (APIENTRYP PFNGLSHADERSOURCEARBPROC) (GLhandleARB shaderObj, GLsizei count, const GLcharARB* *string, const GLint *length); -typedef void (APIENTRYP PFNGLCOMPILESHADERARBPROC) (GLhandleARB shaderObj); -typedef GLhandleARB (APIENTRYP PFNGLCREATEPROGRAMOBJECTARBPROC) (void); -typedef void (APIENTRYP PFNGLATTACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB obj); -typedef void (APIENTRYP PFNGLLINKPROGRAMARBPROC) (GLhandleARB programObj); -typedef void (APIENTRYP PFNGLUSEPROGRAMOBJECTARBPROC) (GLhandleARB programObj); -typedef void (APIENTRYP PFNGLVALIDATEPROGRAMARBPROC) (GLhandleARB programObj); -typedef void (APIENTRYP PFNGLUNIFORM1FARBPROC) (GLint location, GLfloat v0); -typedef void (APIENTRYP PFNGLUNIFORM2FARBPROC) (GLint location, GLfloat v0, GLfloat v1); -typedef void (APIENTRYP PFNGLUNIFORM3FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -typedef void (APIENTRYP PFNGLUNIFORM4FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -typedef void (APIENTRYP PFNGLUNIFORM1IARBPROC) (GLint location, GLint v0); -typedef void (APIENTRYP PFNGLUNIFORM2IARBPROC) (GLint location, GLint v0, GLint v1); -typedef void (APIENTRYP PFNGLUNIFORM3IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2); -typedef void (APIENTRYP PFNGLUNIFORM4IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -typedef void (APIENTRYP PFNGLUNIFORM1FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM2FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM3FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM4FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM1IVARBPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM2IVARBPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM3IVARBPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM4IVARBPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERFVARBPROC) (GLhandleARB obj, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVARBPROC) (GLhandleARB obj, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETINFOLOGARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog); -typedef void (APIENTRYP PFNGLGETATTACHEDOBJECTSARBPROC) (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj); -typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); -typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); -typedef void (APIENTRYP PFNGLGETUNIFORMFVARBPROC) (GLhandleARB programObj, GLint location, GLfloat *params); -typedef void (APIENTRYP PFNGLGETUNIFORMIVARBPROC) (GLhandleARB programObj, GLint location, GLint *params); -typedef void (APIENTRYP PFNGLGETSHADERSOURCEARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source); -#endif - -#ifndef GL_ARB_vertex_shader -#define GL_ARB_vertex_shader 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glBindAttribLocationARB (GLhandleARB, GLuint, const GLcharARB *); -extern void APIENTRY glGetActiveAttribARB (GLhandleARB, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLcharARB *); -extern GLint APIENTRY glGetAttribLocationARB (GLhandleARB, const GLcharARB *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONARBPROC) (GLhandleARB programObj, GLuint index, const GLcharARB *name); -typedef void (APIENTRYP PFNGLGETACTIVEATTRIBARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); -typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); -#endif - -#ifndef GL_ARB_fragment_shader -#define GL_ARB_fragment_shader 1 -#endif - -#ifndef GL_ARB_shading_language_100 -#define GL_ARB_shading_language_100 1 -#endif - -#ifndef GL_ARB_texture_non_power_of_two -#define GL_ARB_texture_non_power_of_two 1 -#endif - -#ifndef GL_ARB_point_sprite -#define GL_ARB_point_sprite 1 -#endif - -#ifndef GL_ARB_fragment_program_shadow -#define GL_ARB_fragment_program_shadow 1 -#endif - -#ifndef GL_ARB_draw_buffers -#define GL_ARB_draw_buffers 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glDrawBuffersARB (GLsizei, const GLenum *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWBUFFERSARBPROC) (GLsizei n, const GLenum *bufs); -#endif - -#ifndef GL_ARB_texture_rectangle -#define GL_ARB_texture_rectangle 1 -#endif - -#ifndef GL_ARB_color_buffer_float -#define GL_ARB_color_buffer_float 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glClampColorARB (GLenum, GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCLAMPCOLORARBPROC) (GLenum target, GLenum clamp); -#endif - -#ifndef GL_ARB_half_float_pixel -#define GL_ARB_half_float_pixel 1 -#endif - -#ifndef GL_ARB_texture_float -#define GL_ARB_texture_float 1 -#endif - -#ifndef GL_ARB_pixel_buffer_object -#define GL_ARB_pixel_buffer_object 1 -#endif - -#ifndef GL_EXT_abgr -#define GL_EXT_abgr 1 -#endif - -#ifndef GL_EXT_blend_color -#define GL_EXT_blend_color 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glBlendColorEXT (GLclampf, GLclampf, GLclampf, GLclampf); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDCOLOREXTPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); -#endif - -#ifndef GL_EXT_polygon_offset -#define GL_EXT_polygon_offset 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glPolygonOffsetEXT (GLfloat, GLfloat); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPOLYGONOFFSETEXTPROC) (GLfloat factor, GLfloat bias); -#endif - -#ifndef GL_EXT_texture -#define GL_EXT_texture 1 -#endif - -#ifndef GL_EXT_texture3D -#define GL_EXT_texture3D 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glTexImage3DEXT (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); -extern void APIENTRY glTexSubImage3DEXT (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXIMAGE3DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); -#endif - -#ifndef GL_SGIS_texture_filter4 -#define GL_SGIS_texture_filter4 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glGetTexFilterFuncSGIS (GLenum, GLenum, GLfloat *); -extern void APIENTRY glTexFilterFuncSGIS (GLenum, GLenum, GLsizei, const GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLfloat *weights); -typedef void (APIENTRYP PFNGLTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLsizei n, const GLfloat *weights); -#endif - -#ifndef GL_EXT_subtexture -#define GL_EXT_subtexture 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glTexSubImage1DEXT (GLenum, GLint, GLint, GLsizei, GLenum, GLenum, const GLvoid *); -extern void APIENTRY glTexSubImage2DEXT (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); -#endif - -#ifndef GL_EXT_copy_texture -#define GL_EXT_copy_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glCopyTexImage1DEXT (GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLint); -extern void APIENTRY glCopyTexImage2DEXT (GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLsizei, GLint); -extern void APIENTRY glCopyTexSubImage1DEXT (GLenum, GLint, GLint, GLint, GLint, GLsizei); -extern void APIENTRY glCopyTexSubImage2DEXT (GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); -extern void APIENTRY glCopyTexSubImage3DEXT (GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOPYTEXIMAGE1DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); -typedef void (APIENTRYP PFNGLCOPYTEXIMAGE2DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); -typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -#endif - -#ifndef GL_EXT_histogram -#define GL_EXT_histogram 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glGetHistogramEXT (GLenum, GLboolean, GLenum, GLenum, GLvoid *); -extern void APIENTRY glGetHistogramParameterfvEXT (GLenum, GLenum, GLfloat *); -extern void APIENTRY glGetHistogramParameterivEXT (GLenum, GLenum, GLint *); -extern void APIENTRY glGetMinmaxEXT (GLenum, GLboolean, GLenum, GLenum, GLvoid *); -extern void APIENTRY glGetMinmaxParameterfvEXT (GLenum, GLenum, GLfloat *); -extern void APIENTRY glGetMinmaxParameterivEXT (GLenum, GLenum, GLint *); -extern void APIENTRY glHistogramEXT (GLenum, GLsizei, GLenum, GLboolean); -extern void APIENTRY glMinmaxEXT (GLenum, GLenum, GLboolean); -extern void APIENTRY glResetHistogramEXT (GLenum); -extern void APIENTRY glResetMinmaxEXT (GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETHISTOGRAMEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); -typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMINMAXEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); -typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLHISTOGRAMEXTPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); -typedef void (APIENTRYP PFNGLMINMAXEXTPROC) (GLenum target, GLenum internalformat, GLboolean sink); -typedef void (APIENTRYP PFNGLRESETHISTOGRAMEXTPROC) (GLenum target); -typedef void (APIENTRYP PFNGLRESETMINMAXEXTPROC) (GLenum target); -#endif - -#ifndef GL_EXT_convolution -#define GL_EXT_convolution 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glConvolutionFilter1DEXT (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); -extern void APIENTRY glConvolutionFilter2DEXT (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); -extern void APIENTRY glConvolutionParameterfEXT (GLenum, GLenum, GLfloat); -extern void APIENTRY glConvolutionParameterfvEXT (GLenum, GLenum, const GLfloat *); -extern void APIENTRY glConvolutionParameteriEXT (GLenum, GLenum, GLint); -extern void APIENTRY glConvolutionParameterivEXT (GLenum, GLenum, const GLint *); -extern void APIENTRY glCopyConvolutionFilter1DEXT (GLenum, GLenum, GLint, GLint, GLsizei); -extern void APIENTRY glCopyConvolutionFilter2DEXT (GLenum, GLenum, GLint, GLint, GLsizei, GLsizei); -extern void APIENTRY glGetConvolutionFilterEXT (GLenum, GLenum, GLenum, GLvoid *); -extern void APIENTRY glGetConvolutionParameterfvEXT (GLenum, GLenum, GLfloat *); -extern void APIENTRY glGetConvolutionParameterivEXT (GLenum, GLenum, GLint *); -extern void APIENTRY glGetSeparableFilterEXT (GLenum, GLenum, GLenum, GLvoid *, GLvoid *, GLvoid *); -extern void APIENTRY glSeparableFilter2DEXT (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); -typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETSEPARABLEFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); -typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); -#endif - -#ifndef GL_EXT_color_matrix -#define GL_EXT_color_matrix 1 -#endif - -#ifndef GL_SGI_color_table -#define GL_SGI_color_table 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glColorTableSGI (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); -extern void APIENTRY glColorTableParameterfvSGI (GLenum, GLenum, const GLfloat *); -extern void APIENTRY glColorTableParameterivSGI (GLenum, GLenum, const GLint *); -extern void APIENTRY glCopyColorTableSGI (GLenum, GLenum, GLint, GLint, GLsizei); -extern void APIENTRY glGetColorTableSGI (GLenum, GLenum, GLenum, GLvoid *); -extern void APIENTRY glGetColorTableParameterfvSGI (GLenum, GLenum, GLfloat *); -extern void APIENTRY glGetColorTableParameterivSGI (GLenum, GLenum, GLint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); -typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLCOPYCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLGETCOLORTABLESGIPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, GLint *params); -#endif - -#ifndef GL_SGIX_pixel_texture -#define GL_SGIX_pixel_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glPixelTexGenSGIX (GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPIXELTEXGENSGIXPROC) (GLenum mode); -#endif - -#ifndef GL_SGIS_pixel_texture -#define GL_SGIS_pixel_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glPixelTexGenParameteriSGIS (GLenum, GLint); -extern void APIENTRY glPixelTexGenParameterivSGIS (GLenum, const GLint *); -extern void APIENTRY glPixelTexGenParameterfSGIS (GLenum, GLfloat); -extern void APIENTRY glPixelTexGenParameterfvSGIS (GLenum, const GLfloat *); -extern void APIENTRY glGetPixelTexGenParameterivSGIS (GLenum, GLint *); -extern void APIENTRY glGetPixelTexGenParameterfvSGIS (GLenum, GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERISGISPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFSGISPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, GLfloat *params); -#endif - -#ifndef GL_SGIS_texture4D -#define GL_SGIS_texture4D 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glTexImage4DSGIS (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); -extern void APIENTRY glTexSubImage4DSGIS (GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXIMAGE4DSGISPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLTEXSUBIMAGE4DSGISPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const GLvoid *pixels); -#endif - -#ifndef GL_SGI_texture_color_table -#define GL_SGI_texture_color_table 1 -#endif - -#ifndef GL_EXT_cmyka -#define GL_EXT_cmyka 1 -#endif - -#ifndef GL_EXT_texture_object -#define GL_EXT_texture_object 1 -#ifdef GL_GLEXT_PROTOTYPES -extern GLboolean APIENTRY glAreTexturesResidentEXT (GLsizei, const GLuint *, GLboolean *); -extern void APIENTRY glBindTextureEXT (GLenum, GLuint); -extern void APIENTRY glDeleteTexturesEXT (GLsizei, const GLuint *); -extern void APIENTRY glGenTexturesEXT (GLsizei, GLuint *); -extern GLboolean APIENTRY glIsTextureEXT (GLuint); -extern void APIENTRY glPrioritizeTexturesEXT (GLsizei, const GLuint *, const GLclampf *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLboolean (APIENTRYP PFNGLARETEXTURESRESIDENTEXTPROC) (GLsizei n, const GLuint *textures, GLboolean *residences); -typedef void (APIENTRYP PFNGLBINDTEXTUREEXTPROC) (GLenum target, GLuint texture); -typedef void (APIENTRYP PFNGLDELETETEXTURESEXTPROC) (GLsizei n, const GLuint *textures); -typedef void (APIENTRYP PFNGLGENTEXTURESEXTPROC) (GLsizei n, GLuint *textures); -typedef GLboolean (APIENTRYP PFNGLISTEXTUREEXTPROC) (GLuint texture); -typedef void (APIENTRYP PFNGLPRIORITIZETEXTURESEXTPROC) (GLsizei n, const GLuint *textures, const GLclampf *priorities); -#endif - -#ifndef GL_SGIS_detail_texture -#define GL_SGIS_detail_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glDetailTexFuncSGIS (GLenum, GLsizei, const GLfloat *); -extern void APIENTRY glGetDetailTexFuncSGIS (GLenum, GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDETAILTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); -typedef void (APIENTRYP PFNGLGETDETAILTEXFUNCSGISPROC) (GLenum target, GLfloat *points); -#endif - -#ifndef GL_SGIS_sharpen_texture -#define GL_SGIS_sharpen_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glSharpenTexFuncSGIS (GLenum, GLsizei, const GLfloat *); -extern void APIENTRY glGetSharpenTexFuncSGIS (GLenum, GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSHARPENTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); -typedef void (APIENTRYP PFNGLGETSHARPENTEXFUNCSGISPROC) (GLenum target, GLfloat *points); -#endif - -#ifndef GL_EXT_packed_pixels -#define GL_EXT_packed_pixels 1 -#endif - -#ifndef GL_SGIS_texture_lod -#define GL_SGIS_texture_lod 1 -#endif - -#ifndef GL_SGIS_multisample -#define GL_SGIS_multisample 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glSampleMaskSGIS (GLclampf, GLboolean); -extern void APIENTRY glSamplePatternSGIS (GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSAMPLEMASKSGISPROC) (GLclampf value, GLboolean invert); -typedef void (APIENTRYP PFNGLSAMPLEPATTERNSGISPROC) (GLenum pattern); -#endif - -#ifndef GL_EXT_rescale_normal -#define GL_EXT_rescale_normal 1 -#endif - -#ifndef GL_EXT_vertex_array -#define GL_EXT_vertex_array 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glArrayElementEXT (GLint); -extern void APIENTRY glColorPointerEXT (GLint, GLenum, GLsizei, GLsizei, const GLvoid *); -extern void APIENTRY glDrawArraysEXT (GLenum, GLint, GLsizei); -extern void APIENTRY glEdgeFlagPointerEXT (GLsizei, GLsizei, const GLboolean *); -extern void APIENTRY glGetPointervEXT (GLenum, GLvoid* *); -extern void APIENTRY glIndexPointerEXT (GLenum, GLsizei, GLsizei, const GLvoid *); -extern void APIENTRY glNormalPointerEXT (GLenum, GLsizei, GLsizei, const GLvoid *); -extern void APIENTRY glTexCoordPointerEXT (GLint, GLenum, GLsizei, GLsizei, const GLvoid *); -extern void APIENTRY glVertexPointerEXT (GLint, GLenum, GLsizei, GLsizei, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLARRAYELEMENTEXTPROC) (GLint i); -typedef void (APIENTRYP PFNGLCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLDRAWARRAYSEXTPROC) (GLenum mode, GLint first, GLsizei count); -typedef void (APIENTRYP PFNGLEDGEFLAGPOINTEREXTPROC) (GLsizei stride, GLsizei count, const GLboolean *pointer); -typedef void (APIENTRYP PFNGLGETPOINTERVEXTPROC) (GLenum pname, GLvoid* *params); -typedef void (APIENTRYP PFNGLINDEXPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLNORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLTEXCOORDPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLVERTEXPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -#endif - -#ifndef GL_EXT_misc_attribute -#define GL_EXT_misc_attribute 1 -#endif - -#ifndef GL_SGIS_generate_mipmap -#define GL_SGIS_generate_mipmap 1 -#endif - -#ifndef GL_SGIX_clipmap -#define GL_SGIX_clipmap 1 -#endif - -#ifndef GL_SGIX_shadow -#define GL_SGIX_shadow 1 -#endif - -#ifndef GL_SGIS_texture_edge_clamp -#define GL_SGIS_texture_edge_clamp 1 -#endif - -#ifndef GL_SGIS_texture_border_clamp -#define GL_SGIS_texture_border_clamp 1 -#endif - -#ifndef GL_EXT_blend_minmax -#define GL_EXT_blend_minmax 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glBlendEquationEXT (GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDEQUATIONEXTPROC) (GLenum mode); -#endif - -#ifndef GL_EXT_blend_subtract -#define GL_EXT_blend_subtract 1 -#endif - -#ifndef GL_EXT_blend_logic_op -#define GL_EXT_blend_logic_op 1 -#endif - -#ifndef GL_SGIX_interlace -#define GL_SGIX_interlace 1 -#endif - -#ifndef GL_SGIX_pixel_tiles -#define GL_SGIX_pixel_tiles 1 -#endif - -#ifndef GL_SGIX_texture_select -#define GL_SGIX_texture_select 1 -#endif - -#ifndef GL_SGIX_sprite -#define GL_SGIX_sprite 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glSpriteParameterfSGIX (GLenum, GLfloat); -extern void APIENTRY glSpriteParameterfvSGIX (GLenum, const GLfloat *); -extern void APIENTRY glSpriteParameteriSGIX (GLenum, GLint); -extern void APIENTRY glSpriteParameterivSGIX (GLenum, const GLint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSPRITEPARAMETERFSGIXPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLSPRITEPARAMETERFVSGIXPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLSPRITEPARAMETERISGIXPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLSPRITEPARAMETERIVSGIXPROC) (GLenum pname, const GLint *params); -#endif - -#ifndef GL_SGIX_texture_multi_buffer -#define GL_SGIX_texture_multi_buffer 1 -#endif - -#ifndef GL_EXT_point_parameters -#define GL_EXT_point_parameters 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glPointParameterfEXT (GLenum, GLfloat); -extern void APIENTRY glPointParameterfvEXT (GLenum, const GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPOINTPARAMETERFEXTPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERFVEXTPROC) (GLenum pname, const GLfloat *params); -#endif - -#ifndef GL_SGIS_point_parameters -#define GL_SGIS_point_parameters 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glPointParameterfSGIS (GLenum, GLfloat); -extern void APIENTRY glPointParameterfvSGIS (GLenum, const GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPOINTPARAMETERFSGISPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); -#endif - -#ifndef GL_SGIX_instruments -#define GL_SGIX_instruments 1 -#ifdef GL_GLEXT_PROTOTYPES -extern GLint APIENTRY glGetInstrumentsSGIX (void); -extern void APIENTRY glInstrumentsBufferSGIX (GLsizei, GLint *); -extern GLint APIENTRY glPollInstrumentsSGIX (GLint *); -extern void APIENTRY glReadInstrumentsSGIX (GLint); -extern void APIENTRY glStartInstrumentsSGIX (void); -extern void APIENTRY glStopInstrumentsSGIX (GLint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLint (APIENTRYP PFNGLGETINSTRUMENTSSGIXPROC) (void); -typedef void (APIENTRYP PFNGLINSTRUMENTSBUFFERSGIXPROC) (GLsizei size, GLint *buffer); -typedef GLint (APIENTRYP PFNGLPOLLINSTRUMENTSSGIXPROC) (GLint *marker_p); -typedef void (APIENTRYP PFNGLREADINSTRUMENTSSGIXPROC) (GLint marker); -typedef void (APIENTRYP PFNGLSTARTINSTRUMENTSSGIXPROC) (void); -typedef void (APIENTRYP PFNGLSTOPINSTRUMENTSSGIXPROC) (GLint marker); -#endif - -#ifndef GL_SGIX_texture_scale_bias -#define GL_SGIX_texture_scale_bias 1 -#endif - -#ifndef GL_SGIX_framezoom -#define GL_SGIX_framezoom 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glFrameZoomSGIX (GLint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFRAMEZOOMSGIXPROC) (GLint factor); -#endif - -#ifndef GL_SGIX_tag_sample_buffer -#define GL_SGIX_tag_sample_buffer 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glTagSampleBufferSGIX (void); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTAGSAMPLEBUFFERSGIXPROC) (void); -#endif - -#ifndef GL_SGIX_polynomial_ffd -#define GL_SGIX_polynomial_ffd 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glDeformationMap3dSGIX (GLenum, GLdouble, GLdouble, GLint, GLint, GLdouble, GLdouble, GLint, GLint, GLdouble, GLdouble, GLint, GLint, const GLdouble *); -extern void APIENTRY glDeformationMap3fSGIX (GLenum, GLfloat, GLfloat, GLint, GLint, GLfloat, GLfloat, GLint, GLint, GLfloat, GLfloat, GLint, GLint, const GLfloat *); -extern void APIENTRY glDeformSGIX (GLbitfield); -extern void APIENTRY glLoadIdentityDeformationMapSGIX (GLbitfield); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDEFORMATIONMAP3DSGIXPROC) (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble w1, GLdouble w2, GLint wstride, GLint worder, const GLdouble *points); -typedef void (APIENTRYP PFNGLDEFORMATIONMAP3FSGIXPROC) (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat w1, GLfloat w2, GLint wstride, GLint worder, const GLfloat *points); -typedef void (APIENTRYP PFNGLDEFORMSGIXPROC) (GLbitfield mask); -typedef void (APIENTRYP PFNGLLOADIDENTITYDEFORMATIONMAPSGIXPROC) (GLbitfield mask); -#endif - -#ifndef GL_SGIX_reference_plane -#define GL_SGIX_reference_plane 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glReferencePlaneSGIX (const GLdouble *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLREFERENCEPLANESGIXPROC) (const GLdouble *equation); -#endif - -#ifndef GL_SGIX_flush_raster -#define GL_SGIX_flush_raster 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glFlushRasterSGIX (void); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFLUSHRASTERSGIXPROC) (void); -#endif - -#ifndef GL_SGIX_depth_texture -#define GL_SGIX_depth_texture 1 -#endif - -#ifndef GL_SGIS_fog_function -#define GL_SGIS_fog_function 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glFogFuncSGIS (GLsizei, const GLfloat *); -extern void APIENTRY glGetFogFuncSGIS (GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFOGFUNCSGISPROC) (GLsizei n, const GLfloat *points); -typedef void (APIENTRYP PFNGLGETFOGFUNCSGISPROC) (GLfloat *points); -#endif - -#ifndef GL_SGIX_fog_offset -#define GL_SGIX_fog_offset 1 -#endif - -#ifndef GL_HP_image_transform -#define GL_HP_image_transform 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glImageTransformParameteriHP (GLenum, GLenum, GLint); -extern void APIENTRY glImageTransformParameterfHP (GLenum, GLenum, GLfloat); -extern void APIENTRY glImageTransformParameterivHP (GLenum, GLenum, const GLint *); -extern void APIENTRY glImageTransformParameterfvHP (GLenum, GLenum, const GLfloat *); -extern void APIENTRY glGetImageTransformParameterivHP (GLenum, GLenum, GLint *); -extern void APIENTRY glGetImageTransformParameterfvHP (GLenum, GLenum, GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIHPPROC) (GLenum target, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFHPPROC) (GLenum target, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, GLfloat *params); -#endif - -#ifndef GL_HP_convolution_border_modes -#define GL_HP_convolution_border_modes 1 -#endif - -#ifndef GL_SGIX_texture_add_env -#define GL_SGIX_texture_add_env 1 -#endif - -#ifndef GL_EXT_color_subtable -#define GL_EXT_color_subtable 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glColorSubTableEXT (GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); -extern void APIENTRY glCopyColorSubTableEXT (GLenum, GLsizei, GLint, GLint, GLsizei); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); -#endif - -#ifndef GL_PGI_vertex_hints -#define GL_PGI_vertex_hints 1 -#endif - -#ifndef GL_PGI_misc_hints -#define GL_PGI_misc_hints 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glHintPGI (GLenum, GLint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLHINTPGIPROC) (GLenum target, GLint mode); -#endif - -#ifndef GL_EXT_paletted_texture -#define GL_EXT_paletted_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glColorTableEXT (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); -extern void APIENTRY glGetColorTableEXT (GLenum, GLenum, GLenum, GLvoid *); -extern void APIENTRY glGetColorTableParameterivEXT (GLenum, GLenum, GLint *); -extern void APIENTRY glGetColorTableParameterfvEXT (GLenum, GLenum, GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOLORTABLEEXTPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); -typedef void (APIENTRYP PFNGLGETCOLORTABLEEXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *data); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); -#endif - -#ifndef GL_EXT_clip_volume_hint -#define GL_EXT_clip_volume_hint 1 -#endif - -#ifndef GL_SGIX_list_priority -#define GL_SGIX_list_priority 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glGetListParameterfvSGIX (GLuint, GLenum, GLfloat *); -extern void APIENTRY glGetListParameterivSGIX (GLuint, GLenum, GLint *); -extern void APIENTRY glListParameterfSGIX (GLuint, GLenum, GLfloat); -extern void APIENTRY glListParameterfvSGIX (GLuint, GLenum, const GLfloat *); -extern void APIENTRY glListParameteriSGIX (GLuint, GLenum, GLint); -extern void APIENTRY glListParameterivSGIX (GLuint, GLenum, const GLint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLLISTPARAMETERFSGIXPROC) (GLuint list, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLLISTPARAMETERISGIXPROC) (GLuint list, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, const GLint *params); -#endif - -#ifndef GL_SGIX_ir_instrument1 -#define GL_SGIX_ir_instrument1 1 -#endif - -#ifndef GL_SGIX_calligraphic_fragment -#define GL_SGIX_calligraphic_fragment 1 -#endif - -#ifndef GL_SGIX_texture_lod_bias -#define GL_SGIX_texture_lod_bias 1 -#endif - -#ifndef GL_SGIX_shadow_ambient -#define GL_SGIX_shadow_ambient 1 -#endif - -#ifndef GL_EXT_index_texture -#define GL_EXT_index_texture 1 -#endif - -#ifndef GL_EXT_index_material -#define GL_EXT_index_material 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glIndexMaterialEXT (GLenum, GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLINDEXMATERIALEXTPROC) (GLenum face, GLenum mode); -#endif - -#ifndef GL_EXT_index_func -#define GL_EXT_index_func 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glIndexFuncEXT (GLenum, GLclampf); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLINDEXFUNCEXTPROC) (GLenum func, GLclampf ref); -#endif - -#ifndef GL_EXT_index_array_formats -#define GL_EXT_index_array_formats 1 -#endif - -#ifndef GL_EXT_compiled_vertex_array -#define GL_EXT_compiled_vertex_array 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glLockArraysEXT (GLint, GLsizei); -extern void APIENTRY glUnlockArraysEXT (void); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLLOCKARRAYSEXTPROC) (GLint first, GLsizei count); -typedef void (APIENTRYP PFNGLUNLOCKARRAYSEXTPROC) (void); -#endif - -#ifndef GL_EXT_cull_vertex -#define GL_EXT_cull_vertex 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glCullParameterdvEXT (GLenum, GLdouble *); -extern void APIENTRY glCullParameterfvEXT (GLenum, GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCULLPARAMETERDVEXTPROC) (GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLCULLPARAMETERFVEXTPROC) (GLenum pname, GLfloat *params); -#endif - -#ifndef GL_SGIX_ycrcb -#define GL_SGIX_ycrcb 1 -#endif - -#ifndef GL_SGIX_fragment_lighting -#define GL_SGIX_fragment_lighting 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glFragmentColorMaterialSGIX (GLenum, GLenum); -extern void APIENTRY glFragmentLightfSGIX (GLenum, GLenum, GLfloat); -extern void APIENTRY glFragmentLightfvSGIX (GLenum, GLenum, const GLfloat *); -extern void APIENTRY glFragmentLightiSGIX (GLenum, GLenum, GLint); -extern void APIENTRY glFragmentLightivSGIX (GLenum, GLenum, const GLint *); -extern void APIENTRY glFragmentLightModelfSGIX (GLenum, GLfloat); -extern void APIENTRY glFragmentLightModelfvSGIX (GLenum, const GLfloat *); -extern void APIENTRY glFragmentLightModeliSGIX (GLenum, GLint); -extern void APIENTRY glFragmentLightModelivSGIX (GLenum, const GLint *); -extern void APIENTRY glFragmentMaterialfSGIX (GLenum, GLenum, GLfloat); -extern void APIENTRY glFragmentMaterialfvSGIX (GLenum, GLenum, const GLfloat *); -extern void APIENTRY glFragmentMaterialiSGIX (GLenum, GLenum, GLint); -extern void APIENTRY glFragmentMaterialivSGIX (GLenum, GLenum, const GLint *); -extern void APIENTRY glGetFragmentLightfvSGIX (GLenum, GLenum, GLfloat *); -extern void APIENTRY glGetFragmentLightivSGIX (GLenum, GLenum, GLint *); -extern void APIENTRY glGetFragmentMaterialfvSGIX (GLenum, GLenum, GLfloat *); -extern void APIENTRY glGetFragmentMaterialivSGIX (GLenum, GLenum, GLint *); -extern void APIENTRY glLightEnviSGIX (GLenum, GLint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFRAGMENTCOLORMATERIALSGIXPROC) (GLenum face, GLenum mode); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFSGIXPROC) (GLenum light, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTISGIXPROC) (GLenum light, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFSGIXPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFVSGIXPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELISGIXPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELIVSGIXPROC) (GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFSGIXPROC) (GLenum face, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLFRAGMENTMATERIALISGIXPROC) (GLenum face, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLLIGHTENVISGIXPROC) (GLenum pname, GLint param); -#endif - -#ifndef GL_IBM_rasterpos_clip -#define GL_IBM_rasterpos_clip 1 -#endif - -#ifndef GL_HP_texture_lighting -#define GL_HP_texture_lighting 1 -#endif - -#ifndef GL_EXT_draw_range_elements -#define GL_EXT_draw_range_elements 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glDrawRangeElementsEXT (GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSEXTPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); -#endif - -#ifndef GL_WIN_phong_shading -#define GL_WIN_phong_shading 1 -#endif - -#ifndef GL_WIN_specular_fog -#define GL_WIN_specular_fog 1 -#endif - -#ifndef GL_EXT_light_texture -#define GL_EXT_light_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glApplyTextureEXT (GLenum); -extern void APIENTRY glTextureLightEXT (GLenum); -extern void APIENTRY glTextureMaterialEXT (GLenum, GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLAPPLYTEXTUREEXTPROC) (GLenum mode); -typedef void (APIENTRYP PFNGLTEXTURELIGHTEXTPROC) (GLenum pname); -typedef void (APIENTRYP PFNGLTEXTUREMATERIALEXTPROC) (GLenum face, GLenum mode); -#endif - -#ifndef GL_SGIX_blend_alpha_minmax -#define GL_SGIX_blend_alpha_minmax 1 -#endif - -#ifndef GL_EXT_bgra -#define GL_EXT_bgra 1 -#endif - -#ifndef GL_SGIX_async -#define GL_SGIX_async 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glAsyncMarkerSGIX (GLuint); -extern GLint APIENTRY glFinishAsyncSGIX (GLuint *); -extern GLint APIENTRY glPollAsyncSGIX (GLuint *); -extern GLuint APIENTRY glGenAsyncMarkersSGIX (GLsizei); -extern void APIENTRY glDeleteAsyncMarkersSGIX (GLuint, GLsizei); -extern GLboolean APIENTRY glIsAsyncMarkerSGIX (GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLASYNCMARKERSGIXPROC) (GLuint marker); -typedef GLint (APIENTRYP PFNGLFINISHASYNCSGIXPROC) (GLuint *markerp); -typedef GLint (APIENTRYP PFNGLPOLLASYNCSGIXPROC) (GLuint *markerp); -typedef GLuint (APIENTRYP PFNGLGENASYNCMARKERSSGIXPROC) (GLsizei range); -typedef void (APIENTRYP PFNGLDELETEASYNCMARKERSSGIXPROC) (GLuint marker, GLsizei range); -typedef GLboolean (APIENTRYP PFNGLISASYNCMARKERSGIXPROC) (GLuint marker); -#endif - -#ifndef GL_SGIX_async_pixel -#define GL_SGIX_async_pixel 1 -#endif - -#ifndef GL_SGIX_async_histogram -#define GL_SGIX_async_histogram 1 -#endif - -#ifndef GL_INTEL_parallel_arrays -#define GL_INTEL_parallel_arrays 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glVertexPointervINTEL (GLint, GLenum, const GLvoid* *); -extern void APIENTRY glNormalPointervINTEL (GLenum, const GLvoid* *); -extern void APIENTRY glColorPointervINTEL (GLint, GLenum, const GLvoid* *); -extern void APIENTRY glTexCoordPointervINTEL (GLint, GLenum, const GLvoid* *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); -typedef void (APIENTRYP PFNGLNORMALPOINTERVINTELPROC) (GLenum type, const GLvoid* *pointer); -typedef void (APIENTRYP PFNGLCOLORPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); -typedef void (APIENTRYP PFNGLTEXCOORDPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); -#endif - -#ifndef GL_HP_occlusion_test -#define GL_HP_occlusion_test 1 -#endif - -#ifndef GL_EXT_pixel_transform -#define GL_EXT_pixel_transform 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glPixelTransformParameteriEXT (GLenum, GLenum, GLint); -extern void APIENTRY glPixelTransformParameterfEXT (GLenum, GLenum, GLfloat); -extern void APIENTRY glPixelTransformParameterivEXT (GLenum, GLenum, const GLint *); -extern void APIENTRY glPixelTransformParameterfvEXT (GLenum, GLenum, const GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); -#endif - -#ifndef GL_EXT_pixel_transform_color_table -#define GL_EXT_pixel_transform_color_table 1 -#endif - -#ifndef GL_EXT_shared_texture_palette -#define GL_EXT_shared_texture_palette 1 -#endif - -#ifndef GL_EXT_separate_specular_color -#define GL_EXT_separate_specular_color 1 -#endif - -#ifndef GL_EXT_secondary_color -#define GL_EXT_secondary_color 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glSecondaryColor3bEXT (GLbyte, GLbyte, GLbyte); -extern void APIENTRY glSecondaryColor3bvEXT (const GLbyte *); -extern void APIENTRY glSecondaryColor3dEXT (GLdouble, GLdouble, GLdouble); -extern void APIENTRY glSecondaryColor3dvEXT (const GLdouble *); -extern void APIENTRY glSecondaryColor3fEXT (GLfloat, GLfloat, GLfloat); -extern void APIENTRY glSecondaryColor3fvEXT (const GLfloat *); -extern void APIENTRY glSecondaryColor3iEXT (GLint, GLint, GLint); -extern void APIENTRY glSecondaryColor3ivEXT (const GLint *); -extern void APIENTRY glSecondaryColor3sEXT (GLshort, GLshort, GLshort); -extern void APIENTRY glSecondaryColor3svEXT (const GLshort *); -extern void APIENTRY glSecondaryColor3ubEXT (GLubyte, GLubyte, GLubyte); -extern void APIENTRY glSecondaryColor3ubvEXT (const GLubyte *); -extern void APIENTRY glSecondaryColor3uiEXT (GLuint, GLuint, GLuint); -extern void APIENTRY glSecondaryColor3uivEXT (const GLuint *); -extern void APIENTRY glSecondaryColor3usEXT (GLushort, GLushort, GLushort); -extern void APIENTRY glSecondaryColor3usvEXT (const GLushort *); -extern void APIENTRY glSecondaryColorPointerEXT (GLint, GLenum, GLsizei, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BEXTPROC) (GLbyte red, GLbyte green, GLbyte blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVEXTPROC) (const GLbyte *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DEXTPROC) (GLdouble red, GLdouble green, GLdouble blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVEXTPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FEXTPROC) (GLfloat red, GLfloat green, GLfloat blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVEXTPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IEXTPROC) (GLint red, GLint green, GLint blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVEXTPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SEXTPROC) (GLshort red, GLshort green, GLshort blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVEXTPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBEXTPROC) (GLubyte red, GLubyte green, GLubyte blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVEXTPROC) (const GLubyte *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIEXTPROC) (GLuint red, GLuint green, GLuint blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVEXTPROC) (const GLuint *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USEXTPROC) (GLushort red, GLushort green, GLushort blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVEXTPROC) (const GLushort *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -#endif - -#ifndef GL_EXT_texture_perturb_normal -#define GL_EXT_texture_perturb_normal 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glTextureNormalEXT (GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXTURENORMALEXTPROC) (GLenum mode); -#endif - -#ifndef GL_EXT_multi_draw_arrays -#define GL_EXT_multi_draw_arrays 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glMultiDrawArraysEXT (GLenum, GLint *, GLsizei *, GLsizei); -extern void APIENTRY glMultiDrawElementsEXT (GLenum, const GLsizei *, GLenum, const GLvoid* *, GLsizei); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); -#endif - -#ifndef GL_EXT_fog_coord -#define GL_EXT_fog_coord 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glFogCoordfEXT (GLfloat); -extern void APIENTRY glFogCoordfvEXT (const GLfloat *); -extern void APIENTRY glFogCoorddEXT (GLdouble); -extern void APIENTRY glFogCoorddvEXT (const GLdouble *); -extern void APIENTRY glFogCoordPointerEXT (GLenum, GLsizei, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFOGCOORDFEXTPROC) (GLfloat coord); -typedef void (APIENTRYP PFNGLFOGCOORDFVEXTPROC) (const GLfloat *coord); -typedef void (APIENTRYP PFNGLFOGCOORDDEXTPROC) (GLdouble coord); -typedef void (APIENTRYP PFNGLFOGCOORDDVEXTPROC) (const GLdouble *coord); -typedef void (APIENTRYP PFNGLFOGCOORDPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); -#endif - -#ifndef GL_REND_screen_coordinates -#define GL_REND_screen_coordinates 1 -#endif - -#ifndef GL_EXT_coordinate_frame -#define GL_EXT_coordinate_frame 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glTangent3bEXT (GLbyte, GLbyte, GLbyte); -extern void APIENTRY glTangent3bvEXT (const GLbyte *); -extern void APIENTRY glTangent3dEXT (GLdouble, GLdouble, GLdouble); -extern void APIENTRY glTangent3dvEXT (const GLdouble *); -extern void APIENTRY glTangent3fEXT (GLfloat, GLfloat, GLfloat); -extern void APIENTRY glTangent3fvEXT (const GLfloat *); -extern void APIENTRY glTangent3iEXT (GLint, GLint, GLint); -extern void APIENTRY glTangent3ivEXT (const GLint *); -extern void APIENTRY glTangent3sEXT (GLshort, GLshort, GLshort); -extern void APIENTRY glTangent3svEXT (const GLshort *); -extern void APIENTRY glBinormal3bEXT (GLbyte, GLbyte, GLbyte); -extern void APIENTRY glBinormal3bvEXT (const GLbyte *); -extern void APIENTRY glBinormal3dEXT (GLdouble, GLdouble, GLdouble); -extern void APIENTRY glBinormal3dvEXT (const GLdouble *); -extern void APIENTRY glBinormal3fEXT (GLfloat, GLfloat, GLfloat); -extern void APIENTRY glBinormal3fvEXT (const GLfloat *); -extern void APIENTRY glBinormal3iEXT (GLint, GLint, GLint); -extern void APIENTRY glBinormal3ivEXT (const GLint *); -extern void APIENTRY glBinormal3sEXT (GLshort, GLshort, GLshort); -extern void APIENTRY glBinormal3svEXT (const GLshort *); -extern void APIENTRY glTangentPointerEXT (GLenum, GLsizei, const GLvoid *); -extern void APIENTRY glBinormalPointerEXT (GLenum, GLsizei, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTANGENT3BEXTPROC) (GLbyte tx, GLbyte ty, GLbyte tz); -typedef void (APIENTRYP PFNGLTANGENT3BVEXTPROC) (const GLbyte *v); -typedef void (APIENTRYP PFNGLTANGENT3DEXTPROC) (GLdouble tx, GLdouble ty, GLdouble tz); -typedef void (APIENTRYP PFNGLTANGENT3DVEXTPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLTANGENT3FEXTPROC) (GLfloat tx, GLfloat ty, GLfloat tz); -typedef void (APIENTRYP PFNGLTANGENT3FVEXTPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLTANGENT3IEXTPROC) (GLint tx, GLint ty, GLint tz); -typedef void (APIENTRYP PFNGLTANGENT3IVEXTPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLTANGENT3SEXTPROC) (GLshort tx, GLshort ty, GLshort tz); -typedef void (APIENTRYP PFNGLTANGENT3SVEXTPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLBINORMAL3BEXTPROC) (GLbyte bx, GLbyte by, GLbyte bz); -typedef void (APIENTRYP PFNGLBINORMAL3BVEXTPROC) (const GLbyte *v); -typedef void (APIENTRYP PFNGLBINORMAL3DEXTPROC) (GLdouble bx, GLdouble by, GLdouble bz); -typedef void (APIENTRYP PFNGLBINORMAL3DVEXTPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLBINORMAL3FEXTPROC) (GLfloat bx, GLfloat by, GLfloat bz); -typedef void (APIENTRYP PFNGLBINORMAL3FVEXTPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLBINORMAL3IEXTPROC) (GLint bx, GLint by, GLint bz); -typedef void (APIENTRYP PFNGLBINORMAL3IVEXTPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLBINORMAL3SEXTPROC) (GLshort bx, GLshort by, GLshort bz); -typedef void (APIENTRYP PFNGLBINORMAL3SVEXTPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLTANGENTPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLBINORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); -#endif - -#ifndef GL_EXT_texture_env_combine -#define GL_EXT_texture_env_combine 1 -#endif - -#ifndef GL_APPLE_specular_vector -#define GL_APPLE_specular_vector 1 -#endif - -#ifndef GL_APPLE_transform_hint -#define GL_APPLE_transform_hint 1 -#endif - -#ifndef GL_SGIX_fog_scale -#define GL_SGIX_fog_scale 1 -#endif - -#ifndef GL_SUNX_constant_data -#define GL_SUNX_constant_data 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glFinishTextureSUNX (void); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFINISHTEXTURESUNXPROC) (void); -#endif - -#ifndef GL_SUN_global_alpha -#define GL_SUN_global_alpha 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glGlobalAlphaFactorbSUN (GLbyte); -extern void APIENTRY glGlobalAlphaFactorsSUN (GLshort); -extern void APIENTRY glGlobalAlphaFactoriSUN (GLint); -extern void APIENTRY glGlobalAlphaFactorfSUN (GLfloat); -extern void APIENTRY glGlobalAlphaFactordSUN (GLdouble); -extern void APIENTRY glGlobalAlphaFactorubSUN (GLubyte); -extern void APIENTRY glGlobalAlphaFactorusSUN (GLushort); -extern void APIENTRY glGlobalAlphaFactoruiSUN (GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORBSUNPROC) (GLbyte factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORSSUNPROC) (GLshort factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORISUNPROC) (GLint factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORFSUNPROC) (GLfloat factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORDSUNPROC) (GLdouble factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUBSUNPROC) (GLubyte factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUSSUNPROC) (GLushort factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUISUNPROC) (GLuint factor); -#endif - -#ifndef GL_SUN_triangle_list -#define GL_SUN_triangle_list 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glReplacementCodeuiSUN (GLuint); -extern void APIENTRY glReplacementCodeusSUN (GLushort); -extern void APIENTRY glReplacementCodeubSUN (GLubyte); -extern void APIENTRY glReplacementCodeuivSUN (const GLuint *); -extern void APIENTRY glReplacementCodeusvSUN (const GLushort *); -extern void APIENTRY glReplacementCodeubvSUN (const GLubyte *); -extern void APIENTRY glReplacementCodePointerSUN (GLenum, GLsizei, const GLvoid* *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUISUNPROC) (GLuint code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSSUNPROC) (GLushort code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBSUNPROC) (GLubyte code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVSUNPROC) (const GLuint *code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSVSUNPROC) (const GLushort *code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBVSUNPROC) (const GLubyte *code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEPOINTERSUNPROC) (GLenum type, GLsizei stride, const GLvoid* *pointer); -#endif - -#ifndef GL_SUN_vertex -#define GL_SUN_vertex 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glColor4ubVertex2fSUN (GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat); -extern void APIENTRY glColor4ubVertex2fvSUN (const GLubyte *, const GLfloat *); -extern void APIENTRY glColor4ubVertex3fSUN (GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat, GLfloat); -extern void APIENTRY glColor4ubVertex3fvSUN (const GLubyte *, const GLfloat *); -extern void APIENTRY glColor3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -extern void APIENTRY glColor3fVertex3fvSUN (const GLfloat *, const GLfloat *); -extern void APIENTRY glNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -extern void APIENTRY glNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *); -extern void APIENTRY glColor4fNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -extern void APIENTRY glColor4fNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *); -extern void APIENTRY glTexCoord2fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -extern void APIENTRY glTexCoord2fVertex3fvSUN (const GLfloat *, const GLfloat *); -extern void APIENTRY glTexCoord4fVertex4fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -extern void APIENTRY glTexCoord4fVertex4fvSUN (const GLfloat *, const GLfloat *); -extern void APIENTRY glTexCoord2fColor4ubVertex3fSUN (GLfloat, GLfloat, GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat, GLfloat); -extern void APIENTRY glTexCoord2fColor4ubVertex3fvSUN (const GLfloat *, const GLubyte *, const GLfloat *); -extern void APIENTRY glTexCoord2fColor3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -extern void APIENTRY glTexCoord2fColor3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *); -extern void APIENTRY glTexCoord2fNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -extern void APIENTRY glTexCoord2fNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *); -extern void APIENTRY glTexCoord2fColor4fNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -extern void APIENTRY glTexCoord2fColor4fNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *, const GLfloat *); -extern void APIENTRY glTexCoord4fColor4fNormal3fVertex4fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -extern void APIENTRY glTexCoord4fColor4fNormal3fVertex4fvSUN (const GLfloat *, const GLfloat *, const GLfloat *, const GLfloat *); -extern void APIENTRY glReplacementCodeuiVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat); -extern void APIENTRY glReplacementCodeuiVertex3fvSUN (const GLuint *, const GLfloat *); -extern void APIENTRY glReplacementCodeuiColor4ubVertex3fSUN (GLuint, GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat, GLfloat); -extern void APIENTRY glReplacementCodeuiColor4ubVertex3fvSUN (const GLuint *, const GLubyte *, const GLfloat *); -extern void APIENTRY glReplacementCodeuiColor3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -extern void APIENTRY glReplacementCodeuiColor3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *); -extern void APIENTRY glReplacementCodeuiNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -extern void APIENTRY glReplacementCodeuiNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *); -extern void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -extern void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *, const GLfloat *); -extern void APIENTRY glReplacementCodeuiTexCoord2fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -extern void APIENTRY glReplacementCodeuiTexCoord2fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *); -extern void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -extern void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *, const GLfloat *); -extern void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -extern void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *, const GLfloat *, const GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FVSUNPROC) (const GLubyte *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FVSUNPROC) (const GLubyte *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FSUNPROC) (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FVSUNPROC) (const GLfloat *tc, const GLubyte *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FSUNPROC) (GLuint rc, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FSUNPROC) (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FVSUNPROC) (const GLuint *rc, const GLubyte *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -#endif - -#ifndef GL_EXT_blend_func_separate -#define GL_EXT_blend_func_separate 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glBlendFuncSeparateEXT (GLenum, GLenum, GLenum, GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEEXTPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); -#endif - -#ifndef GL_INGR_blend_func_separate -#define GL_INGR_blend_func_separate 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glBlendFuncSeparateINGR (GLenum, GLenum, GLenum, GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEINGRPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); -#endif - -#ifndef GL_INGR_color_clamp -#define GL_INGR_color_clamp 1 -#endif - -#ifndef GL_INGR_interlace_read -#define GL_INGR_interlace_read 1 -#endif - -#ifndef GL_EXT_stencil_wrap -#define GL_EXT_stencil_wrap 1 -#endif - -#ifndef GL_EXT_422_pixels -#define GL_EXT_422_pixels 1 -#endif - -#ifndef GL_NV_texgen_reflection -#define GL_NV_texgen_reflection 1 -#endif - -#ifndef GL_SUN_convolution_border_modes -#define GL_SUN_convolution_border_modes 1 -#endif - -#ifndef GL_EXT_texture_env_add -#define GL_EXT_texture_env_add 1 -#endif - -#ifndef GL_EXT_texture_lod_bias -#define GL_EXT_texture_lod_bias 1 -#endif - -#ifndef GL_EXT_texture_filter_anisotropic -#define GL_EXT_texture_filter_anisotropic 1 -#endif - -#ifndef GL_EXT_vertex_weighting -#define GL_EXT_vertex_weighting 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glVertexWeightfEXT (GLfloat); -extern void APIENTRY glVertexWeightfvEXT (const GLfloat *); -extern void APIENTRY glVertexWeightPointerEXT (GLsizei, GLenum, GLsizei, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXWEIGHTFEXTPROC) (GLfloat weight); -typedef void (APIENTRYP PFNGLVERTEXWEIGHTFVEXTPROC) (const GLfloat *weight); -typedef void (APIENTRYP PFNGLVERTEXWEIGHTPOINTEREXTPROC) (GLsizei size, GLenum type, GLsizei stride, const GLvoid *pointer); -#endif - -#ifndef GL_NV_light_max_exponent -#define GL_NV_light_max_exponent 1 -#endif - -#ifndef GL_NV_vertex_array_range -#define GL_NV_vertex_array_range 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glFlushVertexArrayRangeNV (void); -extern void APIENTRY glVertexArrayRangeNV (GLsizei, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGENVPROC) (void); -typedef void (APIENTRYP PFNGLVERTEXARRAYRANGENVPROC) (GLsizei length, const GLvoid *pointer); -#endif - -#ifndef GL_NV_register_combiners -#define GL_NV_register_combiners 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glCombinerParameterfvNV (GLenum, const GLfloat *); -extern void APIENTRY glCombinerParameterfNV (GLenum, GLfloat); -extern void APIENTRY glCombinerParameterivNV (GLenum, const GLint *); -extern void APIENTRY glCombinerParameteriNV (GLenum, GLint); -extern void APIENTRY glCombinerInputNV (GLenum, GLenum, GLenum, GLenum, GLenum, GLenum); -extern void APIENTRY glCombinerOutputNV (GLenum, GLenum, GLenum, GLenum, GLenum, GLenum, GLenum, GLboolean, GLboolean, GLboolean); -extern void APIENTRY glFinalCombinerInputNV (GLenum, GLenum, GLenum, GLenum); -extern void APIENTRY glGetCombinerInputParameterfvNV (GLenum, GLenum, GLenum, GLenum, GLfloat *); -extern void APIENTRY glGetCombinerInputParameterivNV (GLenum, GLenum, GLenum, GLenum, GLint *); -extern void APIENTRY glGetCombinerOutputParameterfvNV (GLenum, GLenum, GLenum, GLfloat *); -extern void APIENTRY glGetCombinerOutputParameterivNV (GLenum, GLenum, GLenum, GLint *); -extern void APIENTRY glGetFinalCombinerInputParameterfvNV (GLenum, GLenum, GLfloat *); -extern void APIENTRY glGetFinalCombinerInputParameterivNV (GLenum, GLenum, GLint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFVNVPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFNVPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLCOMBINERPARAMETERIVNVPROC) (GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLCOMBINERPARAMETERINVPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLCOMBINERINPUTNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); -typedef void (APIENTRYP PFNGLCOMBINEROUTPUTNVPROC) (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); -typedef void (APIENTRYP PFNGLFINALCOMBINERINPUTNVPROC) (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); -typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC) (GLenum variable, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC) (GLenum variable, GLenum pname, GLint *params); -#endif - -#ifndef GL_NV_fog_distance -#define GL_NV_fog_distance 1 -#endif - -#ifndef GL_NV_texgen_emboss -#define GL_NV_texgen_emboss 1 -#endif - -#ifndef GL_NV_blend_square -#define GL_NV_blend_square 1 -#endif - -#ifndef GL_NV_texture_env_combine4 -#define GL_NV_texture_env_combine4 1 -#endif - -#ifndef GL_MESA_resize_buffers -#define GL_MESA_resize_buffers 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glResizeBuffersMESA (void); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLRESIZEBUFFERSMESAPROC) (void); -#endif - -#ifndef GL_MESA_window_pos -#define GL_MESA_window_pos 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glWindowPos2dMESA (GLdouble, GLdouble); -extern void APIENTRY glWindowPos2dvMESA (const GLdouble *); -extern void APIENTRY glWindowPos2fMESA (GLfloat, GLfloat); -extern void APIENTRY glWindowPos2fvMESA (const GLfloat *); -extern void APIENTRY glWindowPos2iMESA (GLint, GLint); -extern void APIENTRY glWindowPos2ivMESA (const GLint *); -extern void APIENTRY glWindowPos2sMESA (GLshort, GLshort); -extern void APIENTRY glWindowPos2svMESA (const GLshort *); -extern void APIENTRY glWindowPos3dMESA (GLdouble, GLdouble, GLdouble); -extern void APIENTRY glWindowPos3dvMESA (const GLdouble *); -extern void APIENTRY glWindowPos3fMESA (GLfloat, GLfloat, GLfloat); -extern void APIENTRY glWindowPos3fvMESA (const GLfloat *); -extern void APIENTRY glWindowPos3iMESA (GLint, GLint, GLint); -extern void APIENTRY glWindowPos3ivMESA (const GLint *); -extern void APIENTRY glWindowPos3sMESA (GLshort, GLshort, GLshort); -extern void APIENTRY glWindowPos3svMESA (const GLshort *); -extern void APIENTRY glWindowPos4dMESA (GLdouble, GLdouble, GLdouble, GLdouble); -extern void APIENTRY glWindowPos4dvMESA (const GLdouble *); -extern void APIENTRY glWindowPos4fMESA (GLfloat, GLfloat, GLfloat, GLfloat); -extern void APIENTRY glWindowPos4fvMESA (const GLfloat *); -extern void APIENTRY glWindowPos4iMESA (GLint, GLint, GLint, GLint); -extern void APIENTRY glWindowPos4ivMESA (const GLint *); -extern void APIENTRY glWindowPos4sMESA (GLshort, GLshort, GLshort, GLshort); -extern void APIENTRY glWindowPos4svMESA (const GLshort *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLWINDOWPOS2DMESAPROC) (GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLWINDOWPOS2DVMESAPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2FMESAPROC) (GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLWINDOWPOS2FVMESAPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2IMESAPROC) (GLint x, GLint y); -typedef void (APIENTRYP PFNGLWINDOWPOS2IVMESAPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2SMESAPROC) (GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLWINDOWPOS2SVMESAPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3DMESAPROC) (GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLWINDOWPOS3DVMESAPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3FMESAPROC) (GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLWINDOWPOS3FVMESAPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3IMESAPROC) (GLint x, GLint y, GLint z); -typedef void (APIENTRYP PFNGLWINDOWPOS3IVMESAPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3SMESAPROC) (GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLWINDOWPOS3SVMESAPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLWINDOWPOS4DMESAPROC) (GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLWINDOWPOS4DVMESAPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS4FMESAPROC) (GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLWINDOWPOS4FVMESAPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS4IMESAPROC) (GLint x, GLint y, GLint z, GLint w); -typedef void (APIENTRYP PFNGLWINDOWPOS4IVMESAPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS4SMESAPROC) (GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (APIENTRYP PFNGLWINDOWPOS4SVMESAPROC) (const GLshort *v); -#endif - -#ifndef GL_EXT_texture_compression_s3tc -#define GL_EXT_texture_compression_s3tc 1 -#endif - -#ifndef GL_IBM_cull_vertex -#define GL_IBM_cull_vertex 1 -#endif - -#ifndef GL_IBM_multimode_draw_arrays -#define GL_IBM_multimode_draw_arrays 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glMultiModeDrawArraysIBM (const GLenum *, const GLint *, const GLsizei *, GLsizei, GLint); -extern void APIENTRY glMultiModeDrawElementsIBM (const GLenum *, const GLsizei *, GLenum, const GLvoid* const *, GLsizei, GLint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLMULTIMODEDRAWARRAYSIBMPROC) (const GLenum *mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride); -typedef void (APIENTRYP PFNGLMULTIMODEDRAWELEMENTSIBMPROC) (const GLenum *mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei primcount, GLint modestride); -#endif - -#ifndef GL_IBM_vertex_array_lists -#define GL_IBM_vertex_array_lists 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glColorPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint); -extern void APIENTRY glSecondaryColorPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint); -extern void APIENTRY glEdgeFlagPointerListIBM (GLint, const GLboolean* *, GLint); -extern void APIENTRY glFogCoordPointerListIBM (GLenum, GLint, const GLvoid* *, GLint); -extern void APIENTRY glIndexPointerListIBM (GLenum, GLint, const GLvoid* *, GLint); -extern void APIENTRY glNormalPointerListIBM (GLenum, GLint, const GLvoid* *, GLint); -extern void APIENTRY glTexCoordPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint); -extern void APIENTRY glVertexPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLEDGEFLAGPOINTERLISTIBMPROC) (GLint stride, const GLboolean* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLFOGCOORDPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLINDEXPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLNORMALPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLTEXCOORDPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLVERTEXPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -#endif - -#ifndef GL_SGIX_subsample -#define GL_SGIX_subsample 1 -#endif - -#ifndef GL_SGIX_ycrcba -#define GL_SGIX_ycrcba 1 -#endif - -#ifndef GL_SGIX_ycrcb_subsample -#define GL_SGIX_ycrcb_subsample 1 -#endif - -#ifndef GL_SGIX_depth_pass_instrument -#define GL_SGIX_depth_pass_instrument 1 -#endif - -#ifndef GL_3DFX_texture_compression_FXT1 -#define GL_3DFX_texture_compression_FXT1 1 -#endif - -#ifndef GL_3DFX_multisample -#define GL_3DFX_multisample 1 -#endif - -#ifndef GL_3DFX_tbuffer -#define GL_3DFX_tbuffer 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glTbufferMask3DFX (GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTBUFFERMASK3DFXPROC) (GLuint mask); -#endif - -#ifndef GL_EXT_multisample -#define GL_EXT_multisample 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glSampleMaskEXT (GLclampf, GLboolean); -extern void APIENTRY glSamplePatternEXT (GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSAMPLEMASKEXTPROC) (GLclampf value, GLboolean invert); -typedef void (APIENTRYP PFNGLSAMPLEPATTERNEXTPROC) (GLenum pattern); -#endif - -#ifndef GL_SGIX_vertex_preclip -#define GL_SGIX_vertex_preclip 1 -#endif - -#ifndef GL_SGIX_convolution_accuracy -#define GL_SGIX_convolution_accuracy 1 -#endif - -#ifndef GL_SGIX_resample -#define GL_SGIX_resample 1 -#endif - -#ifndef GL_SGIS_point_line_texgen -#define GL_SGIS_point_line_texgen 1 -#endif - -#ifndef GL_SGIS_texture_color_mask -#define GL_SGIS_texture_color_mask 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glTextureColorMaskSGIS (GLboolean, GLboolean, GLboolean, GLboolean); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXTURECOLORMASKSGISPROC) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); -#endif - -#ifndef GL_SGIX_igloo_interface -#define GL_SGIX_igloo_interface 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glIglooInterfaceSGIX (GLenum, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLIGLOOINTERFACESGIXPROC) (GLenum pname, const GLvoid *params); -#endif - -#ifndef GL_EXT_texture_env_dot3 -#define GL_EXT_texture_env_dot3 1 -#endif - -#ifndef GL_ATI_texture_mirror_once -#define GL_ATI_texture_mirror_once 1 -#endif - -#ifndef GL_NV_fence -#define GL_NV_fence 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glDeleteFencesNV (GLsizei, const GLuint *); -extern void APIENTRY glGenFencesNV (GLsizei, GLuint *); -extern GLboolean APIENTRY glIsFenceNV (GLuint); -extern GLboolean APIENTRY glTestFenceNV (GLuint); -extern void APIENTRY glGetFenceivNV (GLuint, GLenum, GLint *); -extern void APIENTRY glFinishFenceNV (GLuint); -extern void APIENTRY glSetFenceNV (GLuint, GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDELETEFENCESNVPROC) (GLsizei n, const GLuint *fences); -typedef void (APIENTRYP PFNGLGENFENCESNVPROC) (GLsizei n, GLuint *fences); -typedef GLboolean (APIENTRYP PFNGLISFENCENVPROC) (GLuint fence); -typedef GLboolean (APIENTRYP PFNGLTESTFENCENVPROC) (GLuint fence); -typedef void (APIENTRYP PFNGLGETFENCEIVNVPROC) (GLuint fence, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLFINISHFENCENVPROC) (GLuint fence); -typedef void (APIENTRYP PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition); -#endif - -#ifndef GL_NV_evaluators -#define GL_NV_evaluators 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glMapControlPointsNV (GLenum, GLuint, GLenum, GLsizei, GLsizei, GLint, GLint, GLboolean, const GLvoid *); -extern void APIENTRY glMapParameterivNV (GLenum, GLenum, const GLint *); -extern void APIENTRY glMapParameterfvNV (GLenum, GLenum, const GLfloat *); -extern void APIENTRY glGetMapControlPointsNV (GLenum, GLuint, GLenum, GLsizei, GLsizei, GLboolean, GLvoid *); -extern void APIENTRY glGetMapParameterivNV (GLenum, GLenum, GLint *); -extern void APIENTRY glGetMapParameterfvNV (GLenum, GLenum, GLfloat *); -extern void APIENTRY glGetMapAttribParameterivNV (GLenum, GLuint, GLenum, GLint *); -extern void APIENTRY glGetMapAttribParameterfvNV (GLenum, GLuint, GLenum, GLfloat *); -extern void APIENTRY glEvalMapsNV (GLenum, GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const GLvoid *points); -typedef void (APIENTRYP PFNGLMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, GLvoid *points); -typedef void (APIENTRYP PFNGLGETMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERIVNVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLEVALMAPSNVPROC) (GLenum target, GLenum mode); -#endif - -#ifndef GL_NV_packed_depth_stencil -#define GL_NV_packed_depth_stencil 1 -#endif - -#ifndef GL_EXT_packed_depth_stencil -#define GL_EXT_packed_depth_stencil 1 -#endif - -#ifndef GL_NV_register_combiners2 -#define GL_NV_register_combiners2 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glCombinerStageParameterfvNV (GLenum, GLenum, const GLfloat *); -extern void APIENTRY glGetCombinerStageParameterfvNV (GLenum, GLenum, GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, GLfloat *params); -#endif - -#ifndef GL_NV_texture_compression_vtc -#define GL_NV_texture_compression_vtc 1 -#endif - -#ifndef GL_NV_texture_rectangle -#define GL_NV_texture_rectangle 1 -#endif - -#ifndef GL_NV_texture_shader -#define GL_NV_texture_shader 1 -#endif - -#ifndef GL_NV_texture_shader2 -#define GL_NV_texture_shader2 1 -#endif - -#ifndef GL_NV_vertex_array_range2 -#define GL_NV_vertex_array_range2 1 -#endif - -#ifndef GL_NV_vertex_program -#define GL_NV_vertex_program 1 -#ifdef GL_GLEXT_PROTOTYPES -extern GLboolean APIENTRY glAreProgramsResidentNV (GLsizei, const GLuint *, GLboolean *); -extern void APIENTRY glBindProgramNV (GLenum, GLuint); -extern void APIENTRY glDeleteProgramsNV (GLsizei, const GLuint *); -extern void APIENTRY glExecuteProgramNV (GLenum, GLuint, const GLfloat *); -extern void APIENTRY glGenProgramsNV (GLsizei, GLuint *); -extern void APIENTRY glGetProgramParameterdvNV (GLenum, GLuint, GLenum, GLdouble *); -extern void APIENTRY glGetProgramParameterfvNV (GLenum, GLuint, GLenum, GLfloat *); -extern void APIENTRY glGetProgramivNV (GLuint, GLenum, GLint *); -extern void APIENTRY glGetProgramStringNV (GLuint, GLenum, GLubyte *); -extern void APIENTRY glGetTrackMatrixivNV (GLenum, GLuint, GLenum, GLint *); -extern void APIENTRY glGetVertexAttribdvNV (GLuint, GLenum, GLdouble *); -extern void APIENTRY glGetVertexAttribfvNV (GLuint, GLenum, GLfloat *); -extern void APIENTRY glGetVertexAttribivNV (GLuint, GLenum, GLint *); -extern void APIENTRY glGetVertexAttribPointervNV (GLuint, GLenum, GLvoid* *); -extern GLboolean APIENTRY glIsProgramNV (GLuint); -extern void APIENTRY glLoadProgramNV (GLenum, GLuint, GLsizei, const GLubyte *); -extern void APIENTRY glProgramParameter4dNV (GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble); -extern void APIENTRY glProgramParameter4dvNV (GLenum, GLuint, const GLdouble *); -extern void APIENTRY glProgramParameter4fNV (GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat); -extern void APIENTRY glProgramParameter4fvNV (GLenum, GLuint, const GLfloat *); -extern void APIENTRY glProgramParameters4dvNV (GLenum, GLuint, GLuint, const GLdouble *); -extern void APIENTRY glProgramParameters4fvNV (GLenum, GLuint, GLuint, const GLfloat *); -extern void APIENTRY glRequestResidentProgramsNV (GLsizei, const GLuint *); -extern void APIENTRY glTrackMatrixNV (GLenum, GLuint, GLenum, GLenum); -extern void APIENTRY glVertexAttribPointerNV (GLuint, GLint, GLenum, GLsizei, const GLvoid *); -extern void APIENTRY glVertexAttrib1dNV (GLuint, GLdouble); -extern void APIENTRY glVertexAttrib1dvNV (GLuint, const GLdouble *); -extern void APIENTRY glVertexAttrib1fNV (GLuint, GLfloat); -extern void APIENTRY glVertexAttrib1fvNV (GLuint, const GLfloat *); -extern void APIENTRY glVertexAttrib1sNV (GLuint, GLshort); -extern void APIENTRY glVertexAttrib1svNV (GLuint, const GLshort *); -extern void APIENTRY glVertexAttrib2dNV (GLuint, GLdouble, GLdouble); -extern void APIENTRY glVertexAttrib2dvNV (GLuint, const GLdouble *); -extern void APIENTRY glVertexAttrib2fNV (GLuint, GLfloat, GLfloat); -extern void APIENTRY glVertexAttrib2fvNV (GLuint, const GLfloat *); -extern void APIENTRY glVertexAttrib2sNV (GLuint, GLshort, GLshort); -extern void APIENTRY glVertexAttrib2svNV (GLuint, const GLshort *); -extern void APIENTRY glVertexAttrib3dNV (GLuint, GLdouble, GLdouble, GLdouble); -extern void APIENTRY glVertexAttrib3dvNV (GLuint, const GLdouble *); -extern void APIENTRY glVertexAttrib3fNV (GLuint, GLfloat, GLfloat, GLfloat); -extern void APIENTRY glVertexAttrib3fvNV (GLuint, const GLfloat *); -extern void APIENTRY glVertexAttrib3sNV (GLuint, GLshort, GLshort, GLshort); -extern void APIENTRY glVertexAttrib3svNV (GLuint, const GLshort *); -extern void APIENTRY glVertexAttrib4dNV (GLuint, GLdouble, GLdouble, GLdouble, GLdouble); -extern void APIENTRY glVertexAttrib4dvNV (GLuint, const GLdouble *); -extern void APIENTRY glVertexAttrib4fNV (GLuint, GLfloat, GLfloat, GLfloat, GLfloat); -extern void APIENTRY glVertexAttrib4fvNV (GLuint, const GLfloat *); -extern void APIENTRY glVertexAttrib4sNV (GLuint, GLshort, GLshort, GLshort, GLshort); -extern void APIENTRY glVertexAttrib4svNV (GLuint, const GLshort *); -extern void APIENTRY glVertexAttrib4ubNV (GLuint, GLubyte, GLubyte, GLubyte, GLubyte); -extern void APIENTRY glVertexAttrib4ubvNV (GLuint, const GLubyte *); -extern void APIENTRY glVertexAttribs1dvNV (GLuint, GLsizei, const GLdouble *); -extern void APIENTRY glVertexAttribs1fvNV (GLuint, GLsizei, const GLfloat *); -extern void APIENTRY glVertexAttribs1svNV (GLuint, GLsizei, const GLshort *); -extern void APIENTRY glVertexAttribs2dvNV (GLuint, GLsizei, const GLdouble *); -extern void APIENTRY glVertexAttribs2fvNV (GLuint, GLsizei, const GLfloat *); -extern void APIENTRY glVertexAttribs2svNV (GLuint, GLsizei, const GLshort *); -extern void APIENTRY glVertexAttribs3dvNV (GLuint, GLsizei, const GLdouble *); -extern void APIENTRY glVertexAttribs3fvNV (GLuint, GLsizei, const GLfloat *); -extern void APIENTRY glVertexAttribs3svNV (GLuint, GLsizei, const GLshort *); -extern void APIENTRY glVertexAttribs4dvNV (GLuint, GLsizei, const GLdouble *); -extern void APIENTRY glVertexAttribs4fvNV (GLuint, GLsizei, const GLfloat *); -extern void APIENTRY glVertexAttribs4svNV (GLuint, GLsizei, const GLshort *); -extern void APIENTRY glVertexAttribs4ubvNV (GLuint, GLsizei, const GLubyte *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLboolean (APIENTRYP PFNGLAREPROGRAMSRESIDENTNVPROC) (GLsizei n, const GLuint *programs, GLboolean *residences); -typedef void (APIENTRYP PFNGLBINDPROGRAMNVPROC) (GLenum target, GLuint id); -typedef void (APIENTRYP PFNGLDELETEPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); -typedef void (APIENTRYP PFNGLEXECUTEPROGRAMNVPROC) (GLenum target, GLuint id, const GLfloat *params); -typedef void (APIENTRYP PFNGLGENPROGRAMSNVPROC) (GLsizei n, GLuint *programs); -typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERDVNVPROC) (GLenum target, GLuint index, GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETPROGRAMIVNVPROC) (GLuint id, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGNVPROC) (GLuint id, GLenum pname, GLubyte *program); -typedef void (APIENTRYP PFNGLGETTRACKMATRIXIVNVPROC) (GLenum target, GLuint address, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVNVPROC) (GLuint index, GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVNVPROC) (GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVNVPROC) (GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVNVPROC) (GLuint index, GLenum pname, GLvoid* *pointer); -typedef GLboolean (APIENTRYP PFNGLISPROGRAMNVPROC) (GLuint id); -typedef void (APIENTRYP PFNGLLOADPROGRAMNVPROC) (GLenum target, GLuint id, GLsizei len, const GLubyte *program); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DNVPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DVNVPROC) (GLenum target, GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FNVPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FVNVPROC) (GLenum target, GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4DVNVPROC) (GLenum target, GLuint index, GLuint count, const GLdouble *v); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4FVNVPROC) (GLenum target, GLuint index, GLuint count, const GLfloat *v); -typedef void (APIENTRYP PFNGLREQUESTRESIDENTPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); -typedef void (APIENTRYP PFNGLTRACKMATRIXNVPROC) (GLenum target, GLuint address, GLenum matrix, GLenum transform); -typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERNVPROC) (GLuint index, GLint fsize, GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DNVPROC) (GLuint index, GLdouble x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVNVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FNVPROC) (GLuint index, GLfloat x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVNVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SNVPROC) (GLuint index, GLshort x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVNVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DNVPROC) (GLuint index, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVNVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FNVPROC) (GLuint index, GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVNVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SNVPROC) (GLuint index, GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVNVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVNVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVNVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVNVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVNVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVNVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVNVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBNVPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVNVPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS1DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS1FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS1SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS2DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS2FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS2SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS3DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS3FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS3SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS4DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS4FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS4SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS4UBVNVPROC) (GLuint index, GLsizei count, const GLubyte *v); -#endif - -#ifndef GL_SGIX_texture_coordinate_clamp -#define GL_SGIX_texture_coordinate_clamp 1 -#endif - -#ifndef GL_SGIX_scalebias_hint -#define GL_SGIX_scalebias_hint 1 -#endif - -#ifndef GL_OML_interlace -#define GL_OML_interlace 1 -#endif - -#ifndef GL_OML_subsample -#define GL_OML_subsample 1 -#endif - -#ifndef GL_OML_resample -#define GL_OML_resample 1 -#endif - -#ifndef GL_NV_copy_depth_to_color -#define GL_NV_copy_depth_to_color 1 -#endif - -#ifndef GL_ATI_envmap_bumpmap -#define GL_ATI_envmap_bumpmap 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glTexBumpParameterivATI (GLenum, const GLint *); -extern void APIENTRY glTexBumpParameterfvATI (GLenum, const GLfloat *); -extern void APIENTRY glGetTexBumpParameterivATI (GLenum, GLint *); -extern void APIENTRY glGetTexBumpParameterfvATI (GLenum, GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERIVATIPROC) (GLenum pname, const GLint *param); -typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERFVATIPROC) (GLenum pname, const GLfloat *param); -typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERIVATIPROC) (GLenum pname, GLint *param); -typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERFVATIPROC) (GLenum pname, GLfloat *param); -#endif - -#ifndef GL_ATI_fragment_shader -#define GL_ATI_fragment_shader 1 -#ifdef GL_GLEXT_PROTOTYPES -extern GLuint APIENTRY glGenFragmentShadersATI (GLuint); -extern void APIENTRY glBindFragmentShaderATI (GLuint); -extern void APIENTRY glDeleteFragmentShaderATI (GLuint); -extern void APIENTRY glBeginFragmentShaderATI (void); -extern void APIENTRY glEndFragmentShaderATI (void); -extern void APIENTRY glPassTexCoordATI (GLuint, GLuint, GLenum); -extern void APIENTRY glSampleMapATI (GLuint, GLuint, GLenum); -extern void APIENTRY glColorFragmentOp1ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); -extern void APIENTRY glColorFragmentOp2ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); -extern void APIENTRY glColorFragmentOp3ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); -extern void APIENTRY glAlphaFragmentOp1ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint); -extern void APIENTRY glAlphaFragmentOp2ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); -extern void APIENTRY glAlphaFragmentOp3ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); -extern void APIENTRY glSetFragmentShaderConstantATI (GLuint, const GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLuint (APIENTRYP PFNGLGENFRAGMENTSHADERSATIPROC) (GLuint range); -typedef void (APIENTRYP PFNGLBINDFRAGMENTSHADERATIPROC) (GLuint id); -typedef void (APIENTRYP PFNGLDELETEFRAGMENTSHADERATIPROC) (GLuint id); -typedef void (APIENTRYP PFNGLBEGINFRAGMENTSHADERATIPROC) (void); -typedef void (APIENTRYP PFNGLENDFRAGMENTSHADERATIPROC) (void); -typedef void (APIENTRYP PFNGLPASSTEXCOORDATIPROC) (GLuint dst, GLuint coord, GLenum swizzle); -typedef void (APIENTRYP PFNGLSAMPLEMAPATIPROC) (GLuint dst, GLuint interp, GLenum swizzle); -typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); -typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); -typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); -typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); -typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); -typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); -typedef void (APIENTRYP PFNGLSETFRAGMENTSHADERCONSTANTATIPROC) (GLuint dst, const GLfloat *value); -#endif - -#ifndef GL_ATI_pn_triangles -#define GL_ATI_pn_triangles 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glPNTrianglesiATI (GLenum, GLint); -extern void APIENTRY glPNTrianglesfATI (GLenum, GLfloat); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPNTRIANGLESIATIPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLPNTRIANGLESFATIPROC) (GLenum pname, GLfloat param); -#endif - -#ifndef GL_ATI_vertex_array_object -#define GL_ATI_vertex_array_object 1 -#ifdef GL_GLEXT_PROTOTYPES -extern GLuint APIENTRY glNewObjectBufferATI (GLsizei, const GLvoid *, GLenum); -extern GLboolean APIENTRY glIsObjectBufferATI (GLuint); -extern void APIENTRY glUpdateObjectBufferATI (GLuint, GLuint, GLsizei, const GLvoid *, GLenum); -extern void APIENTRY glGetObjectBufferfvATI (GLuint, GLenum, GLfloat *); -extern void APIENTRY glGetObjectBufferivATI (GLuint, GLenum, GLint *); -extern void APIENTRY glFreeObjectBufferATI (GLuint); -extern void APIENTRY glArrayObjectATI (GLenum, GLint, GLenum, GLsizei, GLuint, GLuint); -extern void APIENTRY glGetArrayObjectfvATI (GLenum, GLenum, GLfloat *); -extern void APIENTRY glGetArrayObjectivATI (GLenum, GLenum, GLint *); -extern void APIENTRY glVariantArrayObjectATI (GLuint, GLenum, GLsizei, GLuint, GLuint); -extern void APIENTRY glGetVariantArrayObjectfvATI (GLuint, GLenum, GLfloat *); -extern void APIENTRY glGetVariantArrayObjectivATI (GLuint, GLenum, GLint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLuint (APIENTRYP PFNGLNEWOBJECTBUFFERATIPROC) (GLsizei size, const GLvoid *pointer, GLenum usage); -typedef GLboolean (APIENTRYP PFNGLISOBJECTBUFFERATIPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLUPDATEOBJECTBUFFERATIPROC) (GLuint buffer, GLuint offset, GLsizei size, const GLvoid *pointer, GLenum preserve); -typedef void (APIENTRYP PFNGLGETOBJECTBUFFERFVATIPROC) (GLuint buffer, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETOBJECTBUFFERIVATIPROC) (GLuint buffer, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLFREEOBJECTBUFFERATIPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLARRAYOBJECTATIPROC) (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); -typedef void (APIENTRYP PFNGLGETARRAYOBJECTFVATIPROC) (GLenum array, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETARRAYOBJECTIVATIPROC) (GLenum array, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLVARIANTARRAYOBJECTATIPROC) (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); -typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTFVATIPROC) (GLuint id, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTIVATIPROC) (GLuint id, GLenum pname, GLint *params); -#endif - -#ifndef GL_EXT_vertex_shader -#define GL_EXT_vertex_shader 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glBeginVertexShaderEXT (void); -extern void APIENTRY glEndVertexShaderEXT (void); -extern void APIENTRY glBindVertexShaderEXT (GLuint); -extern GLuint APIENTRY glGenVertexShadersEXT (GLuint); -extern void APIENTRY glDeleteVertexShaderEXT (GLuint); -extern void APIENTRY glShaderOp1EXT (GLenum, GLuint, GLuint); -extern void APIENTRY glShaderOp2EXT (GLenum, GLuint, GLuint, GLuint); -extern void APIENTRY glShaderOp3EXT (GLenum, GLuint, GLuint, GLuint, GLuint); -extern void APIENTRY glSwizzleEXT (GLuint, GLuint, GLenum, GLenum, GLenum, GLenum); -extern void APIENTRY glWriteMaskEXT (GLuint, GLuint, GLenum, GLenum, GLenum, GLenum); -extern void APIENTRY glInsertComponentEXT (GLuint, GLuint, GLuint); -extern void APIENTRY glExtractComponentEXT (GLuint, GLuint, GLuint); -extern GLuint APIENTRY glGenSymbolsEXT (GLenum, GLenum, GLenum, GLuint); -extern void APIENTRY glSetInvariantEXT (GLuint, GLenum, const GLvoid *); -extern void APIENTRY glSetLocalConstantEXT (GLuint, GLenum, const GLvoid *); -extern void APIENTRY glVariantbvEXT (GLuint, const GLbyte *); -extern void APIENTRY glVariantsvEXT (GLuint, const GLshort *); -extern void APIENTRY glVariantivEXT (GLuint, const GLint *); -extern void APIENTRY glVariantfvEXT (GLuint, const GLfloat *); -extern void APIENTRY glVariantdvEXT (GLuint, const GLdouble *); -extern void APIENTRY glVariantubvEXT (GLuint, const GLubyte *); -extern void APIENTRY glVariantusvEXT (GLuint, const GLushort *); -extern void APIENTRY glVariantuivEXT (GLuint, const GLuint *); -extern void APIENTRY glVariantPointerEXT (GLuint, GLenum, GLuint, const GLvoid *); -extern void APIENTRY glEnableVariantClientStateEXT (GLuint); -extern void APIENTRY glDisableVariantClientStateEXT (GLuint); -extern GLuint APIENTRY glBindLightParameterEXT (GLenum, GLenum); -extern GLuint APIENTRY glBindMaterialParameterEXT (GLenum, GLenum); -extern GLuint APIENTRY glBindTexGenParameterEXT (GLenum, GLenum, GLenum); -extern GLuint APIENTRY glBindTextureUnitParameterEXT (GLenum, GLenum); -extern GLuint APIENTRY glBindParameterEXT (GLenum); -extern GLboolean APIENTRY glIsVariantEnabledEXT (GLuint, GLenum); -extern void APIENTRY glGetVariantBooleanvEXT (GLuint, GLenum, GLboolean *); -extern void APIENTRY glGetVariantIntegervEXT (GLuint, GLenum, GLint *); -extern void APIENTRY glGetVariantFloatvEXT (GLuint, GLenum, GLfloat *); -extern void APIENTRY glGetVariantPointervEXT (GLuint, GLenum, GLvoid* *); -extern void APIENTRY glGetInvariantBooleanvEXT (GLuint, GLenum, GLboolean *); -extern void APIENTRY glGetInvariantIntegervEXT (GLuint, GLenum, GLint *); -extern void APIENTRY glGetInvariantFloatvEXT (GLuint, GLenum, GLfloat *); -extern void APIENTRY glGetLocalConstantBooleanvEXT (GLuint, GLenum, GLboolean *); -extern void APIENTRY glGetLocalConstantIntegervEXT (GLuint, GLenum, GLint *); -extern void APIENTRY glGetLocalConstantFloatvEXT (GLuint, GLenum, GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBEGINVERTEXSHADEREXTPROC) (void); -typedef void (APIENTRYP PFNGLENDVERTEXSHADEREXTPROC) (void); -typedef void (APIENTRYP PFNGLBINDVERTEXSHADEREXTPROC) (GLuint id); -typedef GLuint (APIENTRYP PFNGLGENVERTEXSHADERSEXTPROC) (GLuint range); -typedef void (APIENTRYP PFNGLDELETEVERTEXSHADEREXTPROC) (GLuint id); -typedef void (APIENTRYP PFNGLSHADEROP1EXTPROC) (GLenum op, GLuint res, GLuint arg1); -typedef void (APIENTRYP PFNGLSHADEROP2EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2); -typedef void (APIENTRYP PFNGLSHADEROP3EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3); -typedef void (APIENTRYP PFNGLSWIZZLEEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); -typedef void (APIENTRYP PFNGLWRITEMASKEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); -typedef void (APIENTRYP PFNGLINSERTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); -typedef void (APIENTRYP PFNGLEXTRACTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); -typedef GLuint (APIENTRYP PFNGLGENSYMBOLSEXTPROC) (GLenum datatype, GLenum storagetype, GLenum range, GLuint components); -typedef void (APIENTRYP PFNGLSETINVARIANTEXTPROC) (GLuint id, GLenum type, const GLvoid *addr); -typedef void (APIENTRYP PFNGLSETLOCALCONSTANTEXTPROC) (GLuint id, GLenum type, const GLvoid *addr); -typedef void (APIENTRYP PFNGLVARIANTBVEXTPROC) (GLuint id, const GLbyte *addr); -typedef void (APIENTRYP PFNGLVARIANTSVEXTPROC) (GLuint id, const GLshort *addr); -typedef void (APIENTRYP PFNGLVARIANTIVEXTPROC) (GLuint id, const GLint *addr); -typedef void (APIENTRYP PFNGLVARIANTFVEXTPROC) (GLuint id, const GLfloat *addr); -typedef void (APIENTRYP PFNGLVARIANTDVEXTPROC) (GLuint id, const GLdouble *addr); -typedef void (APIENTRYP PFNGLVARIANTUBVEXTPROC) (GLuint id, const GLubyte *addr); -typedef void (APIENTRYP PFNGLVARIANTUSVEXTPROC) (GLuint id, const GLushort *addr); -typedef void (APIENTRYP PFNGLVARIANTUIVEXTPROC) (GLuint id, const GLuint *addr); -typedef void (APIENTRYP PFNGLVARIANTPOINTEREXTPROC) (GLuint id, GLenum type, GLuint stride, const GLvoid *addr); -typedef void (APIENTRYP PFNGLENABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); -typedef void (APIENTRYP PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); -typedef GLuint (APIENTRYP PFNGLBINDLIGHTPARAMETEREXTPROC) (GLenum light, GLenum value); -typedef GLuint (APIENTRYP PFNGLBINDMATERIALPARAMETEREXTPROC) (GLenum face, GLenum value); -typedef GLuint (APIENTRYP PFNGLBINDTEXGENPARAMETEREXTPROC) (GLenum unit, GLenum coord, GLenum value); -typedef GLuint (APIENTRYP PFNGLBINDTEXTUREUNITPARAMETEREXTPROC) (GLenum unit, GLenum value); -typedef GLuint (APIENTRYP PFNGLBINDPARAMETEREXTPROC) (GLenum value); -typedef GLboolean (APIENTRYP PFNGLISVARIANTENABLEDEXTPROC) (GLuint id, GLenum cap); -typedef void (APIENTRYP PFNGLGETVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); -typedef void (APIENTRYP PFNGLGETVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); -typedef void (APIENTRYP PFNGLGETVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); -typedef void (APIENTRYP PFNGLGETVARIANTPOINTERVEXTPROC) (GLuint id, GLenum value, GLvoid* *data); -typedef void (APIENTRYP PFNGLGETINVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); -typedef void (APIENTRYP PFNGLGETINVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); -typedef void (APIENTRYP PFNGLGETINVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); -typedef void (APIENTRYP PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); -typedef void (APIENTRYP PFNGLGETLOCALCONSTANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); -typedef void (APIENTRYP PFNGLGETLOCALCONSTANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); -#endif - -#ifndef GL_ATI_vertex_streams -#define GL_ATI_vertex_streams 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glVertexStream1sATI (GLenum, GLshort); -extern void APIENTRY glVertexStream1svATI (GLenum, const GLshort *); -extern void APIENTRY glVertexStream1iATI (GLenum, GLint); -extern void APIENTRY glVertexStream1ivATI (GLenum, const GLint *); -extern void APIENTRY glVertexStream1fATI (GLenum, GLfloat); -extern void APIENTRY glVertexStream1fvATI (GLenum, const GLfloat *); -extern void APIENTRY glVertexStream1dATI (GLenum, GLdouble); -extern void APIENTRY glVertexStream1dvATI (GLenum, const GLdouble *); -extern void APIENTRY glVertexStream2sATI (GLenum, GLshort, GLshort); -extern void APIENTRY glVertexStream2svATI (GLenum, const GLshort *); -extern void APIENTRY glVertexStream2iATI (GLenum, GLint, GLint); -extern void APIENTRY glVertexStream2ivATI (GLenum, const GLint *); -extern void APIENTRY glVertexStream2fATI (GLenum, GLfloat, GLfloat); -extern void APIENTRY glVertexStream2fvATI (GLenum, const GLfloat *); -extern void APIENTRY glVertexStream2dATI (GLenum, GLdouble, GLdouble); -extern void APIENTRY glVertexStream2dvATI (GLenum, const GLdouble *); -extern void APIENTRY glVertexStream3sATI (GLenum, GLshort, GLshort, GLshort); -extern void APIENTRY glVertexStream3svATI (GLenum, const GLshort *); -extern void APIENTRY glVertexStream3iATI (GLenum, GLint, GLint, GLint); -extern void APIENTRY glVertexStream3ivATI (GLenum, const GLint *); -extern void APIENTRY glVertexStream3fATI (GLenum, GLfloat, GLfloat, GLfloat); -extern void APIENTRY glVertexStream3fvATI (GLenum, const GLfloat *); -extern void APIENTRY glVertexStream3dATI (GLenum, GLdouble, GLdouble, GLdouble); -extern void APIENTRY glVertexStream3dvATI (GLenum, const GLdouble *); -extern void APIENTRY glVertexStream4sATI (GLenum, GLshort, GLshort, GLshort, GLshort); -extern void APIENTRY glVertexStream4svATI (GLenum, const GLshort *); -extern void APIENTRY glVertexStream4iATI (GLenum, GLint, GLint, GLint, GLint); -extern void APIENTRY glVertexStream4ivATI (GLenum, const GLint *); -extern void APIENTRY glVertexStream4fATI (GLenum, GLfloat, GLfloat, GLfloat, GLfloat); -extern void APIENTRY glVertexStream4fvATI (GLenum, const GLfloat *); -extern void APIENTRY glVertexStream4dATI (GLenum, GLdouble, GLdouble, GLdouble, GLdouble); -extern void APIENTRY glVertexStream4dvATI (GLenum, const GLdouble *); -extern void APIENTRY glNormalStream3bATI (GLenum, GLbyte, GLbyte, GLbyte); -extern void APIENTRY glNormalStream3bvATI (GLenum, const GLbyte *); -extern void APIENTRY glNormalStream3sATI (GLenum, GLshort, GLshort, GLshort); -extern void APIENTRY glNormalStream3svATI (GLenum, const GLshort *); -extern void APIENTRY glNormalStream3iATI (GLenum, GLint, GLint, GLint); -extern void APIENTRY glNormalStream3ivATI (GLenum, const GLint *); -extern void APIENTRY glNormalStream3fATI (GLenum, GLfloat, GLfloat, GLfloat); -extern void APIENTRY glNormalStream3fvATI (GLenum, const GLfloat *); -extern void APIENTRY glNormalStream3dATI (GLenum, GLdouble, GLdouble, GLdouble); -extern void APIENTRY glNormalStream3dvATI (GLenum, const GLdouble *); -extern void APIENTRY glClientActiveVertexStreamATI (GLenum); -extern void APIENTRY glVertexBlendEnviATI (GLenum, GLint); -extern void APIENTRY glVertexBlendEnvfATI (GLenum, GLfloat); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXSTREAM1SATIPROC) (GLenum stream, GLshort x); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1SVATIPROC) (GLenum stream, const GLshort *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1IATIPROC) (GLenum stream, GLint x); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1IVATIPROC) (GLenum stream, const GLint *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1FATIPROC) (GLenum stream, GLfloat x); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1FVATIPROC) (GLenum stream, const GLfloat *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1DATIPROC) (GLenum stream, GLdouble x); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1DVATIPROC) (GLenum stream, const GLdouble *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2SATIPROC) (GLenum stream, GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2SVATIPROC) (GLenum stream, const GLshort *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2IATIPROC) (GLenum stream, GLint x, GLint y); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2IVATIPROC) (GLenum stream, const GLint *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2FATIPROC) (GLenum stream, GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2FVATIPROC) (GLenum stream, const GLfloat *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2DATIPROC) (GLenum stream, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2DVATIPROC) (GLenum stream, const GLdouble *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3IATIPROC) (GLenum stream, GLint x, GLint y, GLint z); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4SVATIPROC) (GLenum stream, const GLshort *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4IATIPROC) (GLenum stream, GLint x, GLint y, GLint z, GLint w); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4IVATIPROC) (GLenum stream, const GLint *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4FVATIPROC) (GLenum stream, const GLfloat *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4DVATIPROC) (GLenum stream, const GLdouble *coords); -typedef void (APIENTRYP PFNGLNORMALSTREAM3BATIPROC) (GLenum stream, GLbyte nx, GLbyte ny, GLbyte nz); -typedef void (APIENTRYP PFNGLNORMALSTREAM3BVATIPROC) (GLenum stream, const GLbyte *coords); -typedef void (APIENTRYP PFNGLNORMALSTREAM3SATIPROC) (GLenum stream, GLshort nx, GLshort ny, GLshort nz); -typedef void (APIENTRYP PFNGLNORMALSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); -typedef void (APIENTRYP PFNGLNORMALSTREAM3IATIPROC) (GLenum stream, GLint nx, GLint ny, GLint nz); -typedef void (APIENTRYP PFNGLNORMALSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); -typedef void (APIENTRYP PFNGLNORMALSTREAM3FATIPROC) (GLenum stream, GLfloat nx, GLfloat ny, GLfloat nz); -typedef void (APIENTRYP PFNGLNORMALSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); -typedef void (APIENTRYP PFNGLNORMALSTREAM3DATIPROC) (GLenum stream, GLdouble nx, GLdouble ny, GLdouble nz); -typedef void (APIENTRYP PFNGLNORMALSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); -typedef void (APIENTRYP PFNGLCLIENTACTIVEVERTEXSTREAMATIPROC) (GLenum stream); -typedef void (APIENTRYP PFNGLVERTEXBLENDENVIATIPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLVERTEXBLENDENVFATIPROC) (GLenum pname, GLfloat param); -#endif - -#ifndef GL_ATI_element_array -#define GL_ATI_element_array 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glElementPointerATI (GLenum, const GLvoid *); -extern void APIENTRY glDrawElementArrayATI (GLenum, GLsizei); -extern void APIENTRY glDrawRangeElementArrayATI (GLenum, GLuint, GLuint, GLsizei); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLELEMENTPOINTERATIPROC) (GLenum type, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYATIPROC) (GLenum mode, GLsizei count); -typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYATIPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count); -#endif - -#ifndef GL_SUN_mesh_array -#define GL_SUN_mesh_array 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glDrawMeshArraysSUN (GLenum, GLint, GLsizei, GLsizei); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWMESHARRAYSSUNPROC) (GLenum mode, GLint first, GLsizei count, GLsizei width); -#endif - -#ifndef GL_SUN_slice_accum -#define GL_SUN_slice_accum 1 -#endif - -#ifndef GL_NV_multisample_filter_hint -#define GL_NV_multisample_filter_hint 1 -#endif - -#ifndef GL_NV_depth_clamp -#define GL_NV_depth_clamp 1 -#endif - -#ifndef GL_NV_occlusion_query -#define GL_NV_occlusion_query 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glGenOcclusionQueriesNV (GLsizei, GLuint *); -extern void APIENTRY glDeleteOcclusionQueriesNV (GLsizei, const GLuint *); -extern GLboolean APIENTRY glIsOcclusionQueryNV (GLuint); -extern void APIENTRY glBeginOcclusionQueryNV (GLuint); -extern void APIENTRY glEndOcclusionQueryNV (void); -extern void APIENTRY glGetOcclusionQueryivNV (GLuint, GLenum, GLint *); -extern void APIENTRY glGetOcclusionQueryuivNV (GLuint, GLenum, GLuint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGENOCCLUSIONQUERIESNVPROC) (GLsizei n, GLuint *ids); -typedef void (APIENTRYP PFNGLDELETEOCCLUSIONQUERIESNVPROC) (GLsizei n, const GLuint *ids); -typedef GLboolean (APIENTRYP PFNGLISOCCLUSIONQUERYNVPROC) (GLuint id); -typedef void (APIENTRYP PFNGLBEGINOCCLUSIONQUERYNVPROC) (GLuint id); -typedef void (APIENTRYP PFNGLENDOCCLUSIONQUERYNVPROC) (void); -typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYIVNVPROC) (GLuint id, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYUIVNVPROC) (GLuint id, GLenum pname, GLuint *params); -#endif - -#ifndef GL_NV_point_sprite -#define GL_NV_point_sprite 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glPointParameteriNV (GLenum, GLint); -extern void APIENTRY glPointParameterivNV (GLenum, const GLint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPOINTPARAMETERINVPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERIVNVPROC) (GLenum pname, const GLint *params); -#endif - -#ifndef GL_NV_texture_shader3 -#define GL_NV_texture_shader3 1 -#endif - -#ifndef GL_NV_vertex_program1_1 -#define GL_NV_vertex_program1_1 1 -#endif - -#ifndef GL_EXT_shadow_funcs -#define GL_EXT_shadow_funcs 1 -#endif - -#ifndef GL_EXT_stencil_two_side -#define GL_EXT_stencil_two_side 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glActiveStencilFaceEXT (GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLACTIVESTENCILFACEEXTPROC) (GLenum face); -#endif - -#ifndef GL_ATI_text_fragment_shader -#define GL_ATI_text_fragment_shader 1 -#endif - -#ifndef GL_APPLE_client_storage -#define GL_APPLE_client_storage 1 -#endif - -#ifndef GL_APPLE_element_array -#define GL_APPLE_element_array 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glElementPointerAPPLE (GLenum, const GLvoid *); -extern void APIENTRY glDrawElementArrayAPPLE (GLenum, GLint, GLsizei); -extern void APIENTRY glDrawRangeElementArrayAPPLE (GLenum, GLuint, GLuint, GLint, GLsizei); -extern void APIENTRY glMultiDrawElementArrayAPPLE (GLenum, const GLint *, const GLsizei *, GLsizei); -extern void APIENTRY glMultiDrawRangeElementArrayAPPLE (GLenum, GLuint, GLuint, const GLint *, const GLsizei *, GLsizei); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLELEMENTPOINTERAPPLEPROC) (GLenum type, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, GLint first, GLsizei count); -typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); -typedef void (APIENTRYP PFNGLMULTIDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount); -#endif - -#ifndef GL_APPLE_fence -#define GL_APPLE_fence 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glGenFencesAPPLE (GLsizei, GLuint *); -extern void APIENTRY glDeleteFencesAPPLE (GLsizei, const GLuint *); -extern void APIENTRY glSetFenceAPPLE (GLuint); -extern GLboolean APIENTRY glIsFenceAPPLE (GLuint); -extern GLboolean APIENTRY glTestFenceAPPLE (GLuint); -extern void APIENTRY glFinishFenceAPPLE (GLuint); -extern GLboolean APIENTRY glTestObjectAPPLE (GLenum, GLuint); -extern void APIENTRY glFinishObjectAPPLE (GLenum, GLint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGENFENCESAPPLEPROC) (GLsizei n, GLuint *fences); -typedef void (APIENTRYP PFNGLDELETEFENCESAPPLEPROC) (GLsizei n, const GLuint *fences); -typedef void (APIENTRYP PFNGLSETFENCEAPPLEPROC) (GLuint fence); -typedef GLboolean (APIENTRYP PFNGLISFENCEAPPLEPROC) (GLuint fence); -typedef GLboolean (APIENTRYP PFNGLTESTFENCEAPPLEPROC) (GLuint fence); -typedef void (APIENTRYP PFNGLFINISHFENCEAPPLEPROC) (GLuint fence); -typedef GLboolean (APIENTRYP PFNGLTESTOBJECTAPPLEPROC) (GLenum object, GLuint name); -typedef void (APIENTRYP PFNGLFINISHOBJECTAPPLEPROC) (GLenum object, GLint name); -#endif - -#ifndef GL_APPLE_vertex_array_object -#define GL_APPLE_vertex_array_object 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glBindVertexArrayAPPLE (GLuint); -extern void APIENTRY glDeleteVertexArraysAPPLE (GLsizei, const GLuint *); -extern void APIENTRY glGenVertexArraysAPPLE (GLsizei, const GLuint *); -extern GLboolean APIENTRY glIsVertexArrayAPPLE (GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBINDVERTEXARRAYAPPLEPROC) (GLuint array); -typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint *arrays); -typedef void (APIENTRYP PFNGLGENVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint *arrays); -typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYAPPLEPROC) (GLuint array); -#endif - -#ifndef GL_APPLE_vertex_array_range -#define GL_APPLE_vertex_array_range 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glVertexArrayRangeAPPLE (GLsizei, GLvoid *); -extern void APIENTRY glFlushVertexArrayRangeAPPLE (GLsizei, GLvoid *); -extern void APIENTRY glVertexArrayParameteriAPPLE (GLenum, GLint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, GLvoid *pointer); -typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, GLvoid *pointer); -typedef void (APIENTRYP PFNGLVERTEXARRAYPARAMETERIAPPLEPROC) (GLenum pname, GLint param); -#endif - -#ifndef GL_APPLE_ycbcr_422 -#define GL_APPLE_ycbcr_422 1 -#endif - -#ifndef GL_S3_s3tc -#define GL_S3_s3tc 1 -#endif - -#ifndef GL_ATI_draw_buffers -#define GL_ATI_draw_buffers 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glDrawBuffersATI (GLsizei, const GLenum *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWBUFFERSATIPROC) (GLsizei n, const GLenum *bufs); -#endif - -#ifndef GL_ATI_pixel_format_float -#define GL_ATI_pixel_format_float 1 -/* This is really a WGL extension, but defines some associated GL enums. - * ATI does not export "GL_ATI_pixel_format_float" in the GL_EXTENSIONS string. - */ -#endif - -#ifndef GL_ATI_texture_env_combine3 -#define GL_ATI_texture_env_combine3 1 -#endif - -#ifndef GL_ATI_texture_float -#define GL_ATI_texture_float 1 -#endif - -#ifndef GL_NV_float_buffer -#define GL_NV_float_buffer 1 -#endif - -#ifndef GL_NV_fragment_program -#define GL_NV_fragment_program 1 -/* Some NV_fragment_program entry points are shared with ARB_vertex_program. */ -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glProgramNamedParameter4fNV (GLuint, GLsizei, const GLubyte *, GLfloat, GLfloat, GLfloat, GLfloat); -extern void APIENTRY glProgramNamedParameter4dNV (GLuint, GLsizei, const GLubyte *, GLdouble, GLdouble, GLdouble, GLdouble); -extern void APIENTRY glProgramNamedParameter4fvNV (GLuint, GLsizei, const GLubyte *, const GLfloat *); -extern void APIENTRY glProgramNamedParameter4dvNV (GLuint, GLsizei, const GLubyte *, const GLdouble *); -extern void APIENTRY glGetProgramNamedParameterfvNV (GLuint, GLsizei, const GLubyte *, GLfloat *); -extern void APIENTRY glGetProgramNamedParameterdvNV (GLuint, GLsizei, const GLubyte *, GLdouble *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLfloat *v); -typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLdouble *v); -typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERFVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params); -typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERDVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params); -#endif - -#ifndef GL_NV_half_float -#define GL_NV_half_float 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glVertex2hNV (GLhalfNV, GLhalfNV); -extern void APIENTRY glVertex2hvNV (const GLhalfNV *); -extern void APIENTRY glVertex3hNV (GLhalfNV, GLhalfNV, GLhalfNV); -extern void APIENTRY glVertex3hvNV (const GLhalfNV *); -extern void APIENTRY glVertex4hNV (GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); -extern void APIENTRY glVertex4hvNV (const GLhalfNV *); -extern void APIENTRY glNormal3hNV (GLhalfNV, GLhalfNV, GLhalfNV); -extern void APIENTRY glNormal3hvNV (const GLhalfNV *); -extern void APIENTRY glColor3hNV (GLhalfNV, GLhalfNV, GLhalfNV); -extern void APIENTRY glColor3hvNV (const GLhalfNV *); -extern void APIENTRY glColor4hNV (GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); -extern void APIENTRY glColor4hvNV (const GLhalfNV *); -extern void APIENTRY glTexCoord1hNV (GLhalfNV); -extern void APIENTRY glTexCoord1hvNV (const GLhalfNV *); -extern void APIENTRY glTexCoord2hNV (GLhalfNV, GLhalfNV); -extern void APIENTRY glTexCoord2hvNV (const GLhalfNV *); -extern void APIENTRY glTexCoord3hNV (GLhalfNV, GLhalfNV, GLhalfNV); -extern void APIENTRY glTexCoord3hvNV (const GLhalfNV *); -extern void APIENTRY glTexCoord4hNV (GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); -extern void APIENTRY glTexCoord4hvNV (const GLhalfNV *); -extern void APIENTRY glMultiTexCoord1hNV (GLenum, GLhalfNV); -extern void APIENTRY glMultiTexCoord1hvNV (GLenum, const GLhalfNV *); -extern void APIENTRY glMultiTexCoord2hNV (GLenum, GLhalfNV, GLhalfNV); -extern void APIENTRY glMultiTexCoord2hvNV (GLenum, const GLhalfNV *); -extern void APIENTRY glMultiTexCoord3hNV (GLenum, GLhalfNV, GLhalfNV, GLhalfNV); -extern void APIENTRY glMultiTexCoord3hvNV (GLenum, const GLhalfNV *); -extern void APIENTRY glMultiTexCoord4hNV (GLenum, GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); -extern void APIENTRY glMultiTexCoord4hvNV (GLenum, const GLhalfNV *); -extern void APIENTRY glFogCoordhNV (GLhalfNV); -extern void APIENTRY glFogCoordhvNV (const GLhalfNV *); -extern void APIENTRY glSecondaryColor3hNV (GLhalfNV, GLhalfNV, GLhalfNV); -extern void APIENTRY glSecondaryColor3hvNV (const GLhalfNV *); -extern void APIENTRY glVertexWeighthNV (GLhalfNV); -extern void APIENTRY glVertexWeighthvNV (const GLhalfNV *); -extern void APIENTRY glVertexAttrib1hNV (GLuint, GLhalfNV); -extern void APIENTRY glVertexAttrib1hvNV (GLuint, const GLhalfNV *); -extern void APIENTRY glVertexAttrib2hNV (GLuint, GLhalfNV, GLhalfNV); -extern void APIENTRY glVertexAttrib2hvNV (GLuint, const GLhalfNV *); -extern void APIENTRY glVertexAttrib3hNV (GLuint, GLhalfNV, GLhalfNV, GLhalfNV); -extern void APIENTRY glVertexAttrib3hvNV (GLuint, const GLhalfNV *); -extern void APIENTRY glVertexAttrib4hNV (GLuint, GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); -extern void APIENTRY glVertexAttrib4hvNV (GLuint, const GLhalfNV *); -extern void APIENTRY glVertexAttribs1hvNV (GLuint, GLsizei, const GLhalfNV *); -extern void APIENTRY glVertexAttribs2hvNV (GLuint, GLsizei, const GLhalfNV *); -extern void APIENTRY glVertexAttribs3hvNV (GLuint, GLsizei, const GLhalfNV *); -extern void APIENTRY glVertexAttribs4hvNV (GLuint, GLsizei, const GLhalfNV *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEX2HNVPROC) (GLhalfNV x, GLhalfNV y); -typedef void (APIENTRYP PFNGLVERTEX2HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEX3HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z); -typedef void (APIENTRYP PFNGLVERTEX3HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEX4HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); -typedef void (APIENTRYP PFNGLVERTEX4HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLNORMAL3HNVPROC) (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz); -typedef void (APIENTRYP PFNGLNORMAL3HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); -typedef void (APIENTRYP PFNGLCOLOR3HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLCOLOR4HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha); -typedef void (APIENTRYP PFNGLCOLOR4HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLTEXCOORD1HNVPROC) (GLhalfNV s); -typedef void (APIENTRYP PFNGLTEXCOORD1HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLTEXCOORD2HNVPROC) (GLhalfNV s, GLhalfNV t); -typedef void (APIENTRYP PFNGLTEXCOORD2HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLTEXCOORD3HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r); -typedef void (APIENTRYP PFNGLTEXCOORD3HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLTEXCOORD4HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); -typedef void (APIENTRYP PFNGLTEXCOORD4HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1HNVPROC) (GLenum target, GLhalfNV s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1HVNVPROC) (GLenum target, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2HVNVPROC) (GLenum target, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3HVNVPROC) (GLenum target, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4HVNVPROC) (GLenum target, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLFOGCOORDHNVPROC) (GLhalfNV fog); -typedef void (APIENTRYP PFNGLFOGCOORDHVNVPROC) (const GLhalfNV *fog); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXWEIGHTHNVPROC) (GLhalfNV weight); -typedef void (APIENTRYP PFNGLVERTEXWEIGHTHVNVPROC) (const GLhalfNV *weight); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1HNVPROC) (GLuint index, GLhalfNV x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1HVNVPROC) (GLuint index, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2HVNVPROC) (GLuint index, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3HVNVPROC) (GLuint index, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4HVNVPROC) (GLuint index, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS1HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS2HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS3HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS4HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); -#endif - -#ifndef GL_NV_pixel_data_range -#define GL_NV_pixel_data_range 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glPixelDataRangeNV (GLenum, GLsizei, GLvoid *); -extern void APIENTRY glFlushPixelDataRangeNV (GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPIXELDATARANGENVPROC) (GLenum target, GLsizei length, GLvoid *pointer); -typedef void (APIENTRYP PFNGLFLUSHPIXELDATARANGENVPROC) (GLenum target); -#endif - -#ifndef GL_NV_primitive_restart -#define GL_NV_primitive_restart 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glPrimitiveRestartNV (void); -extern void APIENTRY glPrimitiveRestartIndexNV (GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPRIMITIVERESTARTNVPROC) (void); -typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXNVPROC) (GLuint index); -#endif - -#ifndef GL_NV_texture_expand_normal -#define GL_NV_texture_expand_normal 1 -#endif - -#ifndef GL_NV_vertex_program2 -#define GL_NV_vertex_program2 1 -#endif - -#ifndef GL_ATI_map_object_buffer -#define GL_ATI_map_object_buffer 1 -#ifdef GL_GLEXT_PROTOTYPES -extern GLvoid* APIENTRY glMapObjectBufferATI (GLuint); -extern void APIENTRY glUnmapObjectBufferATI (GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLvoid* (APIENTRYP PFNGLMAPOBJECTBUFFERATIPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLUNMAPOBJECTBUFFERATIPROC) (GLuint buffer); -#endif - -#ifndef GL_ATI_separate_stencil -#define GL_ATI_separate_stencil 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glStencilOpSeparateATI (GLenum, GLenum, GLenum, GLenum); -extern void APIENTRY glStencilFuncSeparateATI (GLenum, GLenum, GLint, GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEATIPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); -typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEATIPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); -#endif - -#ifndef GL_ATI_vertex_attrib_array_object -#define GL_ATI_vertex_attrib_array_object 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glVertexAttribArrayObjectATI (GLuint, GLint, GLenum, GLboolean, GLsizei, GLuint, GLuint); -extern void APIENTRY glGetVertexAttribArrayObjectfvATI (GLuint, GLenum, GLfloat *); -extern void APIENTRY glGetVertexAttribArrayObjectivATI (GLuint, GLenum, GLint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXATTRIBARRAYOBJECTATIPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTFVATIPROC) (GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTIVATIPROC) (GLuint index, GLenum pname, GLint *params); -#endif - -#ifndef GL_OES_read_format -#define GL_OES_read_format 1 -#endif - -#ifndef GL_EXT_depth_bounds_test -#define GL_EXT_depth_bounds_test 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glDepthBoundsEXT (GLclampd, GLclampd); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDEPTHBOUNDSEXTPROC) (GLclampd zmin, GLclampd zmax); -#endif - -#ifndef GL_EXT_texture_mirror_clamp -#define GL_EXT_texture_mirror_clamp 1 -#endif - -#ifndef GL_EXT_blend_equation_separate -#define GL_EXT_blend_equation_separate 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glBlendEquationSeparateEXT (GLenum, GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEEXTPROC) (GLenum modeRGB, GLenum modeAlpha); -#endif - -#ifndef GL_MESA_pack_invert -#define GL_MESA_pack_invert 1 -#endif - -#ifndef GL_MESA_ycbcr_texture -#define GL_MESA_ycbcr_texture 1 -#endif - -#ifndef GL_EXT_pixel_buffer_object -#define GL_EXT_pixel_buffer_object 1 -#endif - -#ifndef GL_NV_fragment_program_option -#define GL_NV_fragment_program_option 1 -#endif - -#ifndef GL_NV_fragment_program2 -#define GL_NV_fragment_program2 1 -#endif - -#ifndef GL_NV_vertex_program2_option -#define GL_NV_vertex_program2_option 1 -#endif - -#ifndef GL_NV_vertex_program3 -#define GL_NV_vertex_program3 1 -#endif - -#ifndef GL_EXT_framebuffer_object -#define GL_EXT_framebuffer_object 1 -#ifdef GL_GLEXT_PROTOTYPES -extern GLboolean APIENTRY glIsRenderbufferEXT (GLuint); -extern void APIENTRY glBindRenderbufferEXT (GLenum, GLuint); -extern void APIENTRY glDeleteRenderbuffersEXT (GLsizei, const GLuint *); -extern void APIENTRY glGenRenderbuffersEXT (GLsizei, GLuint *); -extern void APIENTRY glRenderbufferStorageEXT (GLenum, GLenum, GLsizei, GLsizei); -extern void APIENTRY glGetRenderbufferParameterivEXT (GLenum, GLenum, GLint *); -extern GLboolean APIENTRY glIsFramebufferEXT (GLuint); -extern void APIENTRY glBindFramebufferEXT (GLenum, GLuint); -extern void APIENTRY glDeleteFramebuffersEXT (GLsizei, const GLuint *); -extern void APIENTRY glGenFramebuffersEXT (GLsizei, GLuint *); -extern GLenum APIENTRY glCheckFramebufferStatusEXT (GLenum); -extern void APIENTRY glFramebufferTexture1DEXT (GLenum, GLenum, GLenum, GLuint, GLint); -extern void APIENTRY glFramebufferTexture2DEXT (GLenum, GLenum, GLenum, GLuint, GLint); -extern void APIENTRY glFramebufferTexture3DEXT (GLenum, GLenum, GLenum, GLuint, GLint, GLint); -extern void APIENTRY glFramebufferRenderbufferEXT (GLenum, GLenum, GLenum, GLuint); -extern void APIENTRY glGetFramebufferAttachmentParameterivEXT (GLenum, GLenum, GLenum, GLint *); -extern void APIENTRY glGenerateMipmapEXT (GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFEREXTPROC) (GLuint renderbuffer); -typedef void (APIENTRYP PFNGLBINDRENDERBUFFEREXTPROC) (GLenum target, GLuint renderbuffer); -typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSEXTPROC) (GLsizei n, const GLuint *renderbuffers); -typedef void (APIENTRYP PFNGLGENRENDERBUFFERSEXTPROC) (GLsizei n, GLuint *renderbuffers); -typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFEREXTPROC) (GLuint framebuffer); -typedef void (APIENTRYP PFNGLBINDFRAMEBUFFEREXTPROC) (GLenum target, GLuint framebuffer); -typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSEXTPROC) (GLsizei n, const GLuint *framebuffers); -typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSEXTPROC) (GLsizei n, GLuint *framebuffers); -typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) (GLenum target); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); -typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGENERATEMIPMAPEXTPROC) (GLenum target); -#endif - -#ifndef GL_GREMEDY_string_marker -#define GL_GREMEDY_string_marker 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glStringMarkerGREMEDY (GLsizei, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSTRINGMARKERGREMEDYPROC) (GLsizei len, const GLvoid *string); -#endif - -#ifndef GL_EXT_Cg_shader -#define GL_EXT_Cg_shader 1 -#endif - -#ifndef GL_EXT_timer_query -#define GL_EXT_timer_query 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glGetQueryObjecti64vEXT (GLuint id, GLenum pname, GLint64EXT *params); -extern void APIENTRY glGetQueryObjectui64vEXT (GLuint id, GLenum pname, GLuint64EXT *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETQUERYOBJECTI64VEXTPROC) (GLuint id, GLenum pname, GLint64EXT *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VEXTPROC) (GLuint id, GLenum pname, GLuint64EXT *params); -#endif - -#ifndef GL_EXT_texture_buffer_object -#define GL_EXT_texture_buffer_object 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glTexBufferEXT (GLenum target, GLenum internalformat, GLuint buffer); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXBUFFEREXTPROC) (GLenum target, GLenum internalformat, GLuint buffer); -#endif - -#ifndef GL_NV_transform_feedback -#define GL_NV_transform_feedback 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glBeginTransformFeedbackNV (GLenum primitiveMode); -extern void APIENTRY glEndTransformFeedbackNV (void); -extern void APIENTRY glTransformFeedbackAttribsNV (GLuint count, const GLint *attribs, GLenum bufferMode); -extern void APIENTRY glBindBufferRangeNV (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); -extern void APIENTRY glBindBufferOffsetNV (GLenum target, GLuint index, GLuint buffer, GLintptr offset); -extern void APIENTRY glBindBufferBaseNV (GLenum target, GLuint index, GLuint buffer); -extern void APIENTRY glTransformFeedbackVaryingsNV (GLuint program, GLsizei count, const GLint *locations, GLenum bufferMode); -extern void APIENTRY glActiveVaryingNV (GLuint program, const GLchar *name); -extern GLint APIENTRY glGetVaryingLocationNV (GLuint program, const GLchar *name); -extern void APIENTRY glGetActiveVaryingNV (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); -extern void APIENTRY glGetTransformFeedbackVaryingNV (GLuint program, GLuint index, GLint *location); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKNVPROC) (GLenum primitiveMode); -typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKNVPROC) (void); -typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKATTRIBSNVPROC) (GLuint count, const GLint *attribs, GLenum bufferMode); -typedef void (APIENTRYP PFNGLBINDBUFFERRANGENVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); -typedef void (APIENTRYP PFNGLBINDBUFFEROFFSETNVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset); -typedef void (APIENTRYP PFNGLBINDBUFFERBASENVPROC) (GLenum target, GLuint index, GLuint buffer); -typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSNVPROC) (GLuint program, GLsizei count, const GLint *locations, GLenum bufferMode); -typedef void (APIENTRYP PFNGLACTIVEVARYINGNVPROC) (GLuint program, const GLchar *name); -typedef GLint (APIENTRYP PFNGLGETVARYINGLOCATIONNVPROC) (GLuint program, const GLchar *name); -typedef void (APIENTRYP PFNGLGETACTIVEVARYINGNVPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); -typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGNVPROC) (GLuint program, GLuint index, GLint *location); -#endif - - -#ifndef GL_NV_depth_buffer_float -#define GL_NV_depth_buffer_float 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glDepthRangedNV (GLdouble zNear, GLdouble zFar); -extern void APIENTRY glClearDepthdNV (GLdouble depth); -extern void APIENTRY glDepthBoundsdNV (GLdouble zmin, GLdouble zmax); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDEPTHRANGEDNVPROC) (GLdouble zNear, GLdouble zFar); -typedef void (APIENTRYP PFNGLCLEARDEPTHDNVPROC) (GLdouble depth); -typedef void (APIENTRYP PFNGLDEPTHBOUNDSDNVPROC) (GLdouble zmin, GLdouble zmax); -#endif - -#ifndef GL_EXT_texture_compression_latc -#define GL_EXT_texture_compression_latc 1 -#endif - -#ifndef GL_EXT_framebuffer_sRGB -#define GL_EXT_framebuffer_sRGB 1 -#endif - -#ifndef GL_EXT_texture_shared_exponent -#define GL_EXT_texture_shared_exponent 1 -#endif - -#ifndef GL_EXT_packed_float -#define GL_EXT_packed_float 1 -#endif - -#ifndef GL_EXT_texture_array -#define GL_EXT_texture_array 1 -#endif - -#ifndef GL_EXT_draw_buffers2 -#define GL_EXT_draw_buffers2 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glColorMaskIndexedEXT (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); -extern void APIENTRY glGetBooleanIndexedvEXT (GLenum target, GLuint index, GLboolean *data); -extern void APIENTRY glGetIntegerIndexedvEXT (GLenum target, GLuint index, GLint *data); -extern void APIENTRY glEnableIndexedEXT (GLenum target, GLuint index); -extern void APIENTRY glDisableIndexedEXT (GLenum target, GLuint index); -extern GLboolean APIENTRY glIsEnabledIndexedEXT (GLenum target, GLuint index); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOLORMASKINDEXEDEXTPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); -typedef void (APIENTRYP PFNGLGETBOOLEANINDEXEDVEXTPROC) (GLenum target, GLuint index, GLboolean *data); -typedef void (APIENTRYP PFNGLGETINTEGERINDEXEDVEXTPROC) (GLenum target, GLuint index, GLint *data); -typedef void (APIENTRYP PFNGLENABLEINDEXEDEXTPROC) (GLenum target, GLuint index); -typedef void (APIENTRYP PFNGLDISABLEINDEXEDEXTPROC) (GLenum target, GLuint index); -typedef GLboolean (APIENTRYP PFNGLISENABLEDINDEXEDEXTPROC) (GLenum target, GLuint index); -#endif - -#ifndef GL_EXT_texture_integer -#define GL_EXT_texture_integer 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glTexParameterIivEXT (GLenum target, GLenum pname, const GLint *params); -extern void APIENTRY glTexParameterIuivEXT (GLenum target, GLenum pname, const GLuint *params); -extern void APIENTRY glGetTexParameterIivEXT (GLenum target, GLenum pname, GLint *params); -extern void APIENTRY glGetTexParameterIuivEXT (GLenum target, GLenum pname, GLuint *params); -extern void APIENTRY glClearColorIiEXT (GLint red, GLint green, GLint blue, GLint alpha); -extern void APIENTRY glClearColorIuiEXT (GLuint red, GLuint green, GLuint blue, GLuint alpha); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, const GLuint *params); -typedef void (APIENTRYP PFNGLGETTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, GLuint *params); -typedef void (APIENTRYP PFNGLCLEARCOLORIIEXTPROC) (GLint red, GLint green, GLint blue, GLint alpha); -typedef void (APIENTRYP PFNGLCLEARCOLORIUIEXTPROC) (GLuint red, GLuint green, GLuint blue, GLuint alpha); -#endif - -#ifndef GL_EXT_bindable_uniform -#define GL_EXT_bindable_uniform 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glUniformBufferEXT (GLuint program, GLint location, GLuint buffer); -extern GLint APIENTRY glGetUniformBufferSizeEXT (GLuint program, GLint location); -extern GLintptr APIENTRY glGetUniformOffsetEXT (GLuint program, GLint location); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLUNIFORMBUFFEREXTPROC) (GLuint program, GLint location, GLuint buffer); -typedef GLint (APIENTRYP PFNGLGETUNIFORMBUFFERSIZEEXTPROC) (GLuint program, GLint location); -typedef GLintptr (APIENTRYP PFNGLGETUNIFORMOFFSETEXTPROC) (GLuint program, GLint location); -#endif - -#ifndef GL_EXT_gpu_shader4 -#define GL_EXT_gpu_shader4 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glGetUniformuivEXT (GLuint program, GLint location, GLuint *params); -extern void APIENTRY glBindFragDataLocationEXT (GLuint program, GLuint color, const GLchar *name); -extern GLint APIENTRY glGetFragDataLocationEXT (GLuint program, const GLchar *name); -extern void APIENTRY glUniform1uiEXT (GLint location, GLuint v0); -extern void APIENTRY glUniform2uiEXT (GLint location, GLuint v0, GLuint v1); -extern void APIENTRY glUniform3uiEXT (GLint location, GLuint v0, GLuint v1, GLuint v2); -extern void APIENTRY glUniform4uiEXT (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -extern void APIENTRY glUniform1uivEXT (GLint location, GLsizei count, const GLuint *value); -extern void APIENTRY glUniform2uivEXT (GLint location, GLsizei count, const GLuint *value); -extern void APIENTRY glUniform3uivEXT (GLint location, GLsizei count, const GLuint *value); -extern void APIENTRY glUniform4uivEXT (GLint location, GLsizei count, const GLuint *value); -extern void APIENTRY glVertexAttribI1iEXT (GLuint index, GLint x); -extern void APIENTRY glVertexAttribI2iEXT (GLuint index, GLint x, GLint y); -extern void APIENTRY glVertexAttribI3iEXT (GLuint index, GLint x, GLint y, GLint z); -extern void APIENTRY glVertexAttribI4iEXT (GLuint index, GLint x, GLint y, GLint z, GLint w); -extern void APIENTRY glVertexAttribI1uiEXT (GLuint index, GLuint x); -extern void APIENTRY glVertexAttribI2uiEXT (GLuint index, GLuint x, GLuint y); -extern void APIENTRY glVertexAttribI3uiEXT (GLuint index, GLuint x, GLuint y, GLuint z); -extern void APIENTRY glVertexAttribI4uiEXT (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -extern void APIENTRY glVertexAttribI1ivEXT (GLuint index, const GLint *v); -extern void APIENTRY glVertexAttribI2ivEXT (GLuint index, const GLint *v); -extern void APIENTRY glVertexAttribI3ivEXT (GLuint index, const GLint *v); -extern void APIENTRY glVertexAttribI4ivEXT (GLuint index, const GLint *v); -extern void APIENTRY glVertexAttribI1uivEXT (GLuint index, const GLuint *v); -extern void APIENTRY glVertexAttribI2uivEXT (GLuint index, const GLuint *v); -extern void APIENTRY glVertexAttribI3uivEXT (GLuint index, const GLuint *v); -extern void APIENTRY glVertexAttribI4uivEXT (GLuint index, const GLuint *v); -extern void APIENTRY glVertexAttribI4bvEXT (GLuint index, const GLbyte *v); -extern void APIENTRY glVertexAttribI4svEXT (GLuint index, const GLshort *v); -extern void APIENTRY glVertexAttribI4ubvEXT (GLuint index, const GLubyte *v); -extern void APIENTRY glVertexAttribI4usvEXT (GLuint index, const GLushort *v); -extern void APIENTRY glVertexAttribIPointerEXT (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -extern void APIENTRY glGetVertexAttribIivEXT (GLuint index, GLenum pname, GLint *params); -extern void APIENTRY glGetVertexAttribIuivEXT (GLuint index, GLenum pname, GLuint *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETUNIFORMUIVEXTPROC) (GLuint program, GLint location, GLuint *params); -typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONEXTPROC) (GLuint program, GLuint color, const GLchar *name); -typedef GLint (APIENTRYP PFNGLGETFRAGDATALOCATIONEXTPROC) (GLuint program, const GLchar *name); -typedef void (APIENTRYP PFNGLUNIFORM1UIEXTPROC) (GLint location, GLuint v0); -typedef void (APIENTRYP PFNGLUNIFORM2UIEXTPROC) (GLint location, GLuint v0, GLuint v1); -typedef void (APIENTRYP PFNGLUNIFORM3UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2); -typedef void (APIENTRYP PFNGLUNIFORM4UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -typedef void (APIENTRYP PFNGLUNIFORM1UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLUNIFORM2UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLUNIFORM3UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLUNIFORM4UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IEXTPROC) (GLuint index, GLint x); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IEXTPROC) (GLuint index, GLint x, GLint y); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IEXTPROC) (GLuint index, GLint x, GLint y, GLint z); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IEXTPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIEXTPROC) (GLuint index, GLuint x); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIEXTPROC) (GLuint index, GLuint x, GLuint y); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVEXTPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVEXTPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVEXTPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVEXTPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVEXTPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVEXTPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVEXTPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVEXTPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVEXTPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVEXTPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVEXTPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVEXTPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTEREXTPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVEXTPROC) (GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVEXTPROC) (GLuint index, GLenum pname, GLuint *params); -#endif - - -#ifndef GL_EXT_geometry_shader4 -#define GL_EXT_geometry_shader4 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glProgramParameteriEXT (GLuint program, GLenum pname, GLint value); -extern void APIENTRY glFramebufferTextureEXT (GLenum target, GLenum attachment, GLuint texture, GLint level); -extern void APIENTRY glFramebufferTextureLayerEXT (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); -extern void APIENTRY glFramebufferTextureFaceEXT (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIEXTPROC) (GLuint program, GLenum pname, GLint value); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYEREXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREFACEEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); -#endif - -#ifndef GL_NV_geometry_program4 -#define GL_NV_geometry_program4 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glProgramVertexLimitNV (GLenum target, GLint limit); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPROGRAMVERTEXLIMITNVPROC) (GLenum target, GLint limit); -#endif - -#ifndef GL_NV_gpu_program4 -#define GL_NV_gpu_program4 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glProgramLocalParameterI4iNV (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); -extern void APIENTRY glProgramLocalParameterI4ivNV (GLenum target, GLuint index, const GLint *params); -extern void APIENTRY glProgramLocalParametersI4ivNV (GLenum target, GLuint index, GLsizei count, const GLint *params); -extern void APIENTRY glProgramLocalParameterI4uiNV (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -extern void APIENTRY glProgramLocalParameterI4uivNV (GLenum target, GLuint index, const GLuint *params); -extern void APIENTRY glProgramLocalParametersI4uivNV (GLenum target, GLuint index, GLsizei count, const GLuint *params); -extern void APIENTRY glProgramEnvParameterI4iNV (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); -extern void APIENTRY glProgramEnvParameterI4ivNV (GLenum target, GLuint index, const GLint *params); -extern void APIENTRY glProgramEnvParametersI4ivNV (GLenum target, GLuint index, GLsizei count, const GLint *params); -extern void APIENTRY glProgramEnvParameterI4uiNV (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -extern void APIENTRY glProgramEnvParameterI4uivNV (GLenum target, GLuint index, const GLuint *params); -extern void APIENTRY glProgramEnvParametersI4uivNV (GLenum target, GLuint index, GLsizei count, const GLuint *params); -extern void APIENTRY glGetProgramLocalParameterIivNV (GLenum target, GLuint index, GLint *params); -extern void APIENTRY glGetProgramLocalParameterIuivNV (GLenum target, GLuint index, GLuint *params); -extern void APIENTRY glGetProgramEnvParameterIivNV (GLenum target, GLuint index, GLint *params); -extern void APIENTRY glGetProgramEnvParameterIuivNV (GLenum target, GLuint index, GLuint *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERIIVNVPROC) (GLenum target, GLuint index, GLint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERIUIVNVPROC) (GLenum target, GLuint index, GLuint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERIIVNVPROC) (GLenum target, GLuint index, GLint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERIUIVNVPROC) (GLenum target, GLuint index, GLuint *params); -#endif - -#ifndef GL_NV_parameter_buffer_object -#define GL_NV_parameter_buffer_object 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glProgramBufferParametersfvNV (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLfloat *params); -extern void APIENTRY glProgramBufferParametersIivNV (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLint *params); -extern void APIENTRY glProgramBufferParametersIuivNV (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLuint *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSFVNVPROC) (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLfloat *params); -typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSIIVNVPROC) (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLint *params); -typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSIUIVNVPROC) (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLuint *params); -#endif - -#ifndef GL_EXT_framebuffer_multisample -#define GL_EXT_framebuffer_multisample 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glRenderbufferStorageMultisampleEXT (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -#endif - -#ifndef GL_NV_framebuffer_multisample_coverage -#define GL_NV_framebuffer_multisample_coverage 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glRenderbufferStorageMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); -#endif - -#ifndef GL_EXT_framebuffer_blit -#define GL_EXT_framebuffer_blit 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glBlitFramebufferEXT (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLITFRAMEBUFFEREXTPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); -#endif - -#ifndef GL_EXT_draw_instanced -#define GL_EXT_draw_instanced 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glDrawArraysInstancedEXT (GLenum mode, GLint start, GLsizei count, GLsizei primcount); -extern void APIENTRY glDrawElementsInstancedEXT (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDEXTPROC) (GLenum mode, GLint start, GLsizei count, GLsizei primcount); -typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDEXTPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); -#endif - -#ifndef GL_EXT_texture_compression_rgtc -#define GL_EXT_texture_compression_rgtc 1 -#endif - -#ifndef GL_NV_present_video -#define GL_NV_present_video 1 -#ifdef GL_GLEXT_PROTOTYPES -extern void APIENTRY glPresentFrameKeyedNV (GLuint video_slot, - GLuint64EXT minPresentTime, - GLuint beginPresentTimeId, - GLuint presentDurationId, - GLenum type, - GLenum target0, GLuint fill0, GLuint key0, - GLenum target1, GLuint fill1, GLuint key1); -extern void APIENTRY glPresentFrameDualFillNV (GLuint video_slot, - GLuint64EXT minPresentTime, - GLuint beginPresentTimeId, - GLuint presentDurationId, - GLenum type, - GLenum target0, GLuint fill0, - GLenum target1, GLuint fill1, - GLenum target2, GLuint fill2, - GLenum target3, GLuint fill3); -extern void APIENTRY glGetVideoivNV (GLuint video_slot, GLenum pname, GLint *params); -extern void APIENTRY glGetVideouivNV (GLuint video_slot, GLenum pname, GLuint *params); -extern void APIENTRY glGetVideoi64vNV (GLuint video_slot, GLenum pname, GLint64EXT *params); -extern void APIENTRY glGetVideoui64vNV (GLuint video_slot, GLenum pname, GLuint64EXT *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPRESENTFRAMEKEYEDNVPROC) (GLuint video_slot, - GLuint64EXT minPresentTime, - GLuint beginPresentTimeId, - GLuint presentDurationId, - GLenum type, - GLenum target0, GLuint fill0, GLuint key0, - GLenum target1, GLuint fill1, GLuint key1); -typedef void (APIENTRYP PFNGLPRESENTFRAMEDUALFILLNVPROC) (GLuint video_slot, - GLuint64EXT minPresentTime, - GLuint beginPresentTimeId, - GLuint presentDurationId, - GLenum type, - GLenum target0, GLuint fill0, - GLenum target1, GLuint fill1, - GLenum target2, GLuint fill2, - GLenum target3, GLuint fill3); -typedef void (APIENTRYP PFNGLGETVIDEOIVNVPROC) (GLuint video_slot, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVIDEOUIVNVPROC) (GLuint video_slot, GLenum pname, GLuint *params); -typedef void (APIENTRYP PFNGLGETVIDEOI64VNVPROC) (GLuint video_slot, GLenum pname, GLint64EXT *params); -typedef void (APIENTRYP PFNGLGETVIDEOUI64VNVPROC) (GLuint video_slot, GLenum pname, GLuint64EXT *params); -#endif - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/Externals/mojoshader/1067/README.txt b/Externals/mojoshader/1067/README.txt deleted file mode 100644 index cf270bf1..00000000 --- a/Externals/mojoshader/1067/README.txt +++ /dev/null @@ -1,12 +0,0 @@ -To use this in your project: - -- Add mojoshader*.c and mojoshader*.h to your project. -- Compile mojoshader*.c -- If you don't have a C99-compliant compiler, like Microsoft Visual Studio, - you'll need to compile the .c files as C++ to get them to build. -- If you don't have cmake to generate mojoshader_version.h, you can either - add a blank file with that name, or add MOJOSHADER_NO_VERSION_INCLUDE to - your preprocessor definitions. - -// end of README.txt ... - diff --git a/Externals/mojoshader/1067/mojoshader.c b/Externals/mojoshader/1067/mojoshader.c deleted file mode 100644 index 6ad2fcb2..00000000 --- a/Externals/mojoshader/1067/mojoshader.c +++ /dev/null @@ -1,8510 +0,0 @@ -/** - * MojoShader; generate shader programs from bytecode of compiled - * Direct3D shaders. - * - * Please see the file LICENSE.txt in the source's root directory. - * - * This file written by Ryan C. Gordon. - */ - -// !!! FIXME: this file really needs to be split up. -// !!! FIXME: I keep changing coding styles for symbols and typedefs. - -#define __MOJOSHADER_INTERNAL__ 1 -#include "mojoshader_internal.h" - -typedef struct ConstantsList -{ - MOJOSHADER_constant constant; - struct ConstantsList *next; -} ConstantsList; - -typedef struct VariableList -{ - MOJOSHADER_uniformType type; - int index; - int count; - ConstantsList *constant; - int used; - int emit_position; // used in some profiles. - struct VariableList *next; -} VariableList; - -typedef struct RegisterList -{ - RegisterType regtype; - int regnum; - MOJOSHADER_usage usage; - unsigned int index; - int writemask; - int misc; - const VariableList *array; - struct RegisterList *next; -} RegisterList; - -typedef struct -{ - const uint32 *token; // this is the unmolested token in the stream. - int regnum; - int swizzle; // xyzw (all four, not split out). - int swizzle_x; - int swizzle_y; - int swizzle_z; - int swizzle_w; - SourceMod src_mod; - RegisterType regtype; - int relative; - RegisterType relative_regtype; - int relative_regnum; - int relative_component; - const VariableList *relative_array; -} SourceArgInfo; - -struct Profile; // predeclare. - -typedef struct CtabData -{ - int have_ctab; - int symbol_count; - MOJOSHADER_symbol *symbols; -} CtabData; - -// Context...this is state that changes as we parse through a shader... -typedef struct Context -{ - int isfail; - int out_of_memory; - MOJOSHADER_malloc malloc; - MOJOSHADER_free free; - void *malloc_data; - int current_position; - const uint32 *orig_tokens; - const uint32 *tokens; - uint32 tokencount; - const MOJOSHADER_swizzle *swizzles; - unsigned int swizzles_count; - Buffer *output; - Buffer *preflight; - Buffer *globals; - Buffer *helpers; - Buffer *subroutines; - Buffer *mainline_intro; - Buffer *mainline; - Buffer *ignore; - Buffer *output_stack[2]; - int indent_stack[2]; - int output_stack_len; - int indent; - const char *shader_type_str; - const char *endline; - int endline_len; - int profileid; - const struct Profile *profile; - MOJOSHADER_shaderType shader_type; - uint8 major_ver; - uint8 minor_ver; - DestArgInfo dest_arg; - SourceArgInfo source_args[5]; - SourceArgInfo predicate_arg; // for predicated instructions. - uint32 dwords[4]; - uint32 version_token; - int instruction_count; - uint32 instruction_controls; - uint32 previous_opcode; - int loops; - int reps; - int max_reps; - int cmps; - int scratch_registers; - int max_scratch_registers; - int branch_labels_stack_index; - int branch_labels_stack[32]; - int assigned_branch_labels; - int assigned_vertex_attributes; - int last_address_reg_component; - RegisterList used_registers; - RegisterList defined_registers; - ErrorList *errors; - int constant_count; - ConstantsList *constants; - int uniform_count; - int uniform_float4_count; - int uniform_int4_count; - int uniform_bool_count; - RegisterList uniforms; - int attribute_count; - RegisterList attributes; - int sampler_count; - RegisterList samplers; - VariableList *variables; // variables to register mapping. - int centroid_allowed; - CtabData ctab; - int have_relative_input_registers; - int have_multi_color_outputs; - int determined_constants_arrays; - int predicated; - int uses_pointsize; - int glsl_generated_lit_opcode; - int glsl_generated_texldd_setup; - int arb1_wrote_position; - int have_preshader; - int ignores_ctab; - MOJOSHADER_preshader *preshader; - -#if SUPPORT_PROFILE_ARB1_NV - int profile_supports_nv2; - int profile_supports_nv3; - int profile_supports_nv4; -#endif -#if SUPPORT_PROFILE_GLSL120 - int profile_supports_glsl120; -#endif -} Context; - - -// Use these macros so we can remove all bits of these profiles from the build. -#if SUPPORT_PROFILE_ARB1_NV -#define support_nv2(ctx) ((ctx)->profile_supports_nv2) -#define support_nv3(ctx) ((ctx)->profile_supports_nv3) -#define support_nv4(ctx) ((ctx)->profile_supports_nv4) -#else -#define support_nv2(ctx) (0) -#define support_nv3(ctx) (0) -#define support_nv4(ctx) (0) -#endif - -#if SUPPORT_PROFILE_GLSL120 -#define support_glsl120(ctx) ((ctx)->profile_supports_glsl120) -#else -#define support_glsl120(ctx) (0) -#endif - - -// Profile entry points... - -// one emit function for each opcode in each profile. -typedef void (*emit_function)(Context *ctx); - -// one emit function for starting output in each profile. -typedef void (*emit_start)(Context *ctx, const char *profilestr); - -// one emit function for ending output in each profile. -typedef void (*emit_end)(Context *ctx); - -// one emit function for phase opcode output in each profile. -typedef void (*emit_phase)(Context *ctx); - -// one emit function for finalizing output in each profile. -typedef void (*emit_finalize)(Context *ctx); - -// one emit function for global definitions in each profile. -typedef void (*emit_global)(Context *ctx, RegisterType regtype, int regnum); - -// one emit function for relative uniform arrays in each profile. -typedef void (*emit_array)(Context *ctx, VariableList *var); - -// one emit function for relative constants arrays in each profile. -typedef void (*emit_const_array)(Context *ctx, - const struct ConstantsList *constslist, - int base, int size); - -// one emit function for uniforms in each profile. -typedef void (*emit_uniform)(Context *ctx, RegisterType regtype, int regnum, - const VariableList *var); - -// one emit function for samplers in each profile. -typedef void (*emit_sampler)(Context *ctx, int stage, TextureType ttype); - -// one emit function for attributes in each profile. -typedef void (*emit_attribute)(Context *ctx, RegisterType regtype, int regnum, - MOJOSHADER_usage usage, int index, int wmask, - int flags); - -// one args function for each possible sequence of opcode arguments. -typedef int (*args_function)(Context *ctx); - -// one state function for each opcode where we have state machine updates. -typedef void (*state_function)(Context *ctx); - -// one function for varnames in each profile. -typedef const char *(*varname_function)(Context *c, RegisterType t, int num); - -// one function for const var array in each profile. -typedef const char *(*const_array_varname_function)(Context *c, int base, int size); - -typedef struct Profile -{ - const char *name; - emit_start start_emitter; - emit_end end_emitter; - emit_phase phase_emitter; - emit_global global_emitter; - emit_array array_emitter; - emit_const_array const_array_emitter; - emit_uniform uniform_emitter; - emit_sampler sampler_emitter; - emit_attribute attribute_emitter; - emit_finalize finalize_emitter; - varname_function get_varname; - const_array_varname_function get_const_array_varname; -} Profile; - - -// Convenience functions for allocators... -#if !MOJOSHADER_FORCE_ALLOCATOR -void *MOJOSHADER_internal_malloc(int bytes, void *d) { return malloc(bytes); } -void MOJOSHADER_internal_free(void *ptr, void *d) { free(ptr); } -#endif - -MOJOSHADER_error MOJOSHADER_out_of_mem_error = { - "Out of memory", NULL, MOJOSHADER_POSITION_NONE -}; - -MOJOSHADER_parseData MOJOSHADER_out_of_mem_data = { - 1, &MOJOSHADER_out_of_mem_error, 0, 0, 0, 0, - MOJOSHADER_TYPE_UNKNOWN, 0, 0, 0, 0 -}; - - -// !!! FIXME: cut and paste between every damned source file follows... -// !!! FIXME: We need to make some sort of ContextBase that applies to all -// !!! FIXME: files and move this stuff to mojoshader_common.c ... - -static inline void out_of_memory(Context *ctx) -{ - ctx->isfail = ctx->out_of_memory = 1; -} // out_of_memory - -static inline void *Malloc(Context *ctx, const size_t len) -{ - void *retval = ctx->malloc((int) len, ctx->malloc_data); - if (retval == NULL) - out_of_memory(ctx); - return retval; -} // Malloc - -static inline char *StrDup(Context *ctx, const char *str) -{ - char *retval = (char *) Malloc(ctx, strlen(str) + 1); - if (retval != NULL) - strcpy(retval, str); - return retval; -} // StrDup - -static inline void Free(Context *ctx, void *ptr) -{ - ctx->free(ptr, ctx->malloc_data); -} // Free - -static void *MallocBridge(int bytes, void *data) -{ - return Malloc((Context *) data, (size_t) bytes); -} // MallocBridge - -static void FreeBridge(void *ptr, void *data) -{ - Free((Context *) data, ptr); -} // FreeBridge - - -// jump between output sections in the context... - -static int set_output(Context *ctx, Buffer **section) -{ - // only create output sections on first use. - if (*section == NULL) - { - *section = buffer_create(256, MallocBridge, FreeBridge, ctx); - if (*section == NULL) - return 0; - } // if - - ctx->output = *section; - return 1; -} // set_output - -static void push_output(Context *ctx, Buffer **section) -{ - assert(ctx->output_stack_len < (int) (STATICARRAYLEN(ctx->output_stack))); - ctx->output_stack[ctx->output_stack_len] = ctx->output; - ctx->indent_stack[ctx->output_stack_len] = ctx->indent; - ctx->output_stack_len++; - if (!set_output(ctx, section)) - return; - ctx->indent = 0; -} // push_output - -static inline void pop_output(Context *ctx) -{ - assert(ctx->output_stack_len > 0); - ctx->output_stack_len--; - ctx->output = ctx->output_stack[ctx->output_stack_len]; - ctx->indent = ctx->indent_stack[ctx->output_stack_len]; -} // pop_output - - - -// Shader model version magic... - -static inline uint32 ver_ui32(const uint8 major, const uint8 minor) -{ - return ( (((uint32) major) << 16) | (((minor) == 0xFF) ? 1 : (minor)) ); -} // version_ui32 - -static inline int shader_version_supported(const uint8 maj, const uint8 min) -{ - return (ver_ui32(maj,min) <= ver_ui32(MAX_SHADER_MAJOR, MAX_SHADER_MINOR)); -} // shader_version_supported - -static inline int shader_version_atleast(const Context *ctx, const uint8 maj, - const uint8 min) -{ - return (ver_ui32(ctx->major_ver, ctx->minor_ver) >= ver_ui32(maj, min)); -} // shader_version_atleast - -static inline int shader_version_exactly(const Context *ctx, const uint8 maj, - const uint8 min) -{ - return ((ctx->major_ver == maj) && (ctx->minor_ver == min)); -} // shader_version_exactly - -static inline int shader_is_pixel(const Context *ctx) -{ - return (ctx->shader_type == MOJOSHADER_TYPE_PIXEL); -} // shader_is_pixel - -static inline int shader_is_vertex(const Context *ctx) -{ - return (ctx->shader_type == MOJOSHADER_TYPE_VERTEX); -} // shader_is_vertex - - -static inline int isfail(const Context *ctx) -{ - return ctx->isfail; -} // isfail - - -static void failf(Context *ctx, const char *fmt, ...) ISPRINTF(2,3); -static void failf(Context *ctx, const char *fmt, ...) -{ - ctx->isfail = 1; - if (ctx->out_of_memory) - return; - - // no filename at this level (we pass a NULL to errorlist_add_va()...) - va_list ap; - va_start(ap, fmt); - errorlist_add_va(ctx->errors, NULL, ctx->current_position, fmt, ap); - va_end(ap); -} // failf - - -static inline void fail(Context *ctx, const char *reason) -{ - failf(ctx, "%s", reason); -} // fail - - -static void output_line(Context *ctx, const char *fmt, ...) ISPRINTF(2,3); -static void output_line(Context *ctx, const char *fmt, ...) -{ - assert(ctx->output != NULL); - if (isfail(ctx)) - return; // we failed previously, don't go on... - - const int indent = ctx->indent; - if (indent > 0) - { - char *indentbuf = (char *) alloca(indent); - memset(indentbuf, '\t', indent); - buffer_append(ctx->output, indentbuf, indent); - } // if - - va_list ap; - va_start(ap, fmt); - buffer_append_va(ctx->output, fmt, ap); - va_end(ap); - - buffer_append(ctx->output, ctx->endline, ctx->endline_len); -} // output_line - - -static inline void output_blank_line(Context *ctx) -{ - assert(ctx->output != NULL); - if (!isfail(ctx)) - buffer_append(ctx->output, ctx->endline, ctx->endline_len); -} // output_blank_line - - -// !!! FIXME: this is sort of nasty. -static void floatstr(Context *ctx, char *buf, size_t bufsize, float f, - int leavedecimal) -{ - const size_t len = snprintf(buf, bufsize, "%f", f); - if ((len+2) >= bufsize) - fail(ctx, "BUG: internal buffer is too small"); - else - { - char *end = buf + len; - char *ptr = strchr(buf, '.'); - if (ptr == NULL) - { - if (leavedecimal) - strcat(buf, ".0"); - return; // done. - } // if - - while (--end != ptr) - { - if (*end != '0') - { - end++; - break; - } // if - } // while - if ((leavedecimal) && (end == ptr)) - end += 2; - *end = '\0'; // chop extra '0' or all decimal places off. - } // else -} // floatstr - - -// Deal with register lists... !!! FIXME: I sort of hate this. - -static void free_reglist(MOJOSHADER_free f, void *d, RegisterList *item) -{ - while (item != NULL) - { - RegisterList *next = item->next; - f(item, d); - item = next; - } // while -} // free_reglist - -static inline uint32 reg_to_ui32(const RegisterType regtype, const int regnum) -{ - return ( ((uint32) regtype) | (((uint32) regnum) << 16) ); -} // reg_to_uint32 - -// !!! FIXME: ditch this for a hash table. -static RegisterList *reglist_insert(Context *ctx, RegisterList *prev, - const RegisterType regtype, - const int regnum) -{ - const uint32 newval = reg_to_ui32(regtype, regnum); - RegisterList *item = prev->next; - while (item != NULL) - { - const uint32 val = reg_to_ui32(item->regtype, item->regnum); - if (newval == val) - return item; // already set, so we're done. - else if (newval < val) // insert it here. - break; - else // if (newval > val) - { - // keep going, we're not to the insertion point yet. - prev = item; - item = item->next; - } // else - } // while - - // we need to insert an entry after (prev). - item = (RegisterList *) Malloc(ctx, sizeof (RegisterList)); - if (item != NULL) - { - item->regtype = regtype; - item->regnum = regnum; - item->usage = MOJOSHADER_USAGE_UNKNOWN; - item->index = 0; - item->writemask = 0; - item->misc = 0; - item->array = NULL; - item->next = prev->next; - prev->next = item; - } // if - - return item; -} // reglist_insert - -static RegisterList *reglist_find(const RegisterList *prev, - const RegisterType rtype, const int regnum) -{ - const uint32 newval = reg_to_ui32(rtype, regnum); - RegisterList *item = prev->next; - while (item != NULL) - { - const uint32 val = reg_to_ui32(item->regtype, item->regnum); - if (newval == val) - return item; // here it is. - else if (newval < val) // should have been here if it existed. - return NULL; - else // if (newval > val) - item = item->next; - } // while - - return NULL; // wasn't in the list. -} // reglist_find - -static inline const RegisterList *reglist_exists(RegisterList *prev, - const RegisterType regtype, - const int regnum) -{ - return (reglist_find(prev, regtype, regnum)); -} // reglist_exists - -static inline void set_used_register(Context *ctx, const RegisterType regtype, - const int regnum) -{ - if ((regtype == REG_TYPE_COLOROUT) && (regnum > 0)) - ctx->have_multi_color_outputs = 1; - reglist_insert(ctx, &ctx->used_registers, regtype, regnum); -} // set_used_register - -static inline int get_used_register(Context *ctx, const RegisterType regtype, - const int regnum) -{ - return (reglist_exists(&ctx->used_registers, regtype, regnum) != NULL); -} // get_used_register - -static inline void set_defined_register(Context *ctx, const RegisterType rtype, - const int regnum) -{ - reglist_insert(ctx, &ctx->defined_registers, rtype, regnum); -} // set_defined_register - -static inline int get_defined_register(Context *ctx, const RegisterType rtype, - const int regnum) -{ - return (reglist_exists(&ctx->defined_registers, rtype, regnum) != NULL); -} // get_defined_register - -static void add_attribute_register(Context *ctx, const RegisterType rtype, - const int regnum, const MOJOSHADER_usage usage, - const int index, const int writemask, int flags) -{ - RegisterList *item = reglist_insert(ctx, &ctx->attributes, rtype, regnum); - item->usage = usage; - item->index = index; - item->writemask = writemask; - item->misc = flags; - - if ((rtype == REG_TYPE_OUTPUT) && (usage == MOJOSHADER_USAGE_POINTSIZE)) - ctx->uses_pointsize = 1; // note that we have to check this later. -} // add_attribute_register - -static inline void add_sampler(Context *ctx, const RegisterType rtype, - const int regnum, const TextureType ttype) -{ - // !!! FIXME: make sure it doesn't exist? - RegisterList *item = reglist_insert(ctx, &ctx->samplers, rtype, regnum); - item->index = (int) ttype; -} // add_sampler - - -static inline int writemask_xyzw(const int writemask) -{ - return (writemask == 0xF); // 0xF == 1111. No explicit mask (full!). -} // writemask_xyzw - - -static inline int writemask_xyz(const int writemask) -{ - return (writemask == 0x7); // 0x7 == 0111. (that is: xyz) -} // writemask_xyz - - -static inline int writemask_xy(const int writemask) -{ - return (writemask == 0x3); // 0x3 == 0011. (that is: xy) -} // writemask_xy - - -static inline int writemask_x(const int writemask) -{ - return (writemask == 0x1); // 0x1 == 0001. (that is: x) -} // writemask_x - - -static inline int writemask_y(const int writemask) -{ - return (writemask == 0x2); // 0x1 == 0010. (that is: y) -} // writemask_y - - -static inline int replicate_swizzle(const int swizzle) -{ - return ( (((swizzle >> 0) & 0x3) == ((swizzle >> 2) & 0x3)) && - (((swizzle >> 2) & 0x3) == ((swizzle >> 4) & 0x3)) && - (((swizzle >> 4) & 0x3) == ((swizzle >> 6) & 0x3)) ); -} // replicate_swizzle - - -static inline int no_swizzle(const int swizzle) -{ - return (swizzle == 0xE4); // 0xE4 == 11100100 ... 0 1 2 3. No swizzle. -} // no_swizzle - - -static inline int vecsize_from_writemask(const int m) -{ - return (m & 1) + ((m >> 1) & 1) + ((m >> 2) & 1) + ((m >> 3) & 1); -} // vecsize_from_writemask - -static int allocate_scratch_register(Context *ctx) -{ - const int retval = ctx->scratch_registers++; - if (retval >= ctx->max_scratch_registers) - ctx->max_scratch_registers = retval + 1; - return retval; -} // allocate_scratch_register - -static int allocate_branch_label(Context *ctx) -{ - return ctx->assigned_branch_labels++; -} // allocate_branch_label - -static inline void adjust_token_position(Context *ctx, const int incr) -{ - ctx->tokens += incr; - ctx->tokencount -= incr; - ctx->current_position += incr * sizeof (uint32); -} // adjust_token_position - - -// D3D stuff that's used in more than just the d3d profile... - -static int isscalar(Context *ctx, const MOJOSHADER_shaderType shader_type, - const RegisterType rtype, const int rnum) -{ - if ((rtype == REG_TYPE_OUTPUT) && (ctx->uses_pointsize)) - { - const RegisterList *reg = reglist_find(&ctx->attributes, rtype, rnum); - if (reg != NULL) - return (reg->usage == MOJOSHADER_USAGE_POINTSIZE); - } // if - - return scalar_register(shader_type, rtype, rnum); -} // isscalar - -static const char swizzle_channels[] = { 'x', 'y', 'z', 'w' }; - - -static const char *usagestrs[] = { - "_position", "_blendweight", "_blendindices", "_normal", "_psize", - "_texcoord", "_tangent", "_binormal", "_tessfactor", "_positiont", - "_color", "_fog", "_depth", "_sample" -}; - -static const char *get_D3D_register_string(Context *ctx, - RegisterType regtype, - int regnum, char *regnum_str, - size_t regnum_size) -{ - const char *retval = NULL; - int has_number = 1; - - switch (regtype) - { - case REG_TYPE_TEMP: - retval = "r"; - break; - - case REG_TYPE_INPUT: - retval = "v"; - break; - - case REG_TYPE_CONST: - retval = "c"; - break; - - case REG_TYPE_ADDRESS: // (or REG_TYPE_TEXTURE, same value.) - retval = shader_is_vertex(ctx) ? "a" : "t"; - break; - - case REG_TYPE_RASTOUT: - switch ((RastOutType) regnum) - { - case RASTOUT_TYPE_POSITION: retval = "oPos"; break; - case RASTOUT_TYPE_FOG: retval = "oFog"; break; - case RASTOUT_TYPE_POINT_SIZE: retval = "oPts"; break; - } // switch - has_number = 0; - break; - - case REG_TYPE_ATTROUT: - retval = "oD"; - break; - - case REG_TYPE_OUTPUT: // (or REG_TYPE_TEXCRDOUT, same value.) - if (shader_is_vertex(ctx) && shader_version_atleast(ctx, 3, 0)) - retval = "o"; - else - retval = "oT"; - break; - - case REG_TYPE_CONSTINT: - retval = "i"; - break; - - case REG_TYPE_COLOROUT: - retval = "oC"; - break; - - case REG_TYPE_DEPTHOUT: - retval = "oDepth"; - has_number = 0; - break; - - case REG_TYPE_SAMPLER: - retval = "s"; - break; - - case REG_TYPE_CONSTBOOL: - retval = "b"; - break; - - case REG_TYPE_LOOP: - retval = "aL"; - has_number = 0; - break; - - case REG_TYPE_MISCTYPE: - switch ((const MiscTypeType) regnum) - { - case MISCTYPE_TYPE_POSITION: retval = "vPos"; break; - case MISCTYPE_TYPE_FACE: retval = "vFace"; break; - } // switch - has_number = 0; - break; - - case REG_TYPE_LABEL: - retval = "l"; - break; - - case REG_TYPE_PREDICATE: - retval = "p"; - break; - - //case REG_TYPE_TEMPFLOAT16: // !!! FIXME: don't know this asm string - default: - fail(ctx, "unknown register type"); - retval = "???"; - has_number = 0; - break; - } // switch - - if (has_number) - snprintf(regnum_str, regnum_size, "%u", (uint) regnum); - else - regnum_str[0] = '\0'; - - return retval; -} // get_D3D_register_string - - -// !!! FIXME: can we split the profile code out to separate source files? - -#define AT_LEAST_ONE_PROFILE 0 - -#if !SUPPORT_PROFILE_D3D -#define PROFILE_EMITTER_D3D(op) -#else -#undef AT_LEAST_ONE_PROFILE -#define AT_LEAST_ONE_PROFILE 1 -#define PROFILE_EMITTER_D3D(op) emit_D3D_##op, - -static const char *make_D3D_srcarg_string_in_buf(Context *ctx, - const SourceArgInfo *arg, - char *buf, size_t buflen) -{ - const char *premod_str = ""; - const char *postmod_str = ""; - switch (arg->src_mod) - { - case SRCMOD_NEGATE: - premod_str = "-"; - break; - - case SRCMOD_BIASNEGATE: - premod_str = "-"; - // fall through. - case SRCMOD_BIAS: - postmod_str = "_bias"; - break; - - case SRCMOD_SIGNNEGATE: - premod_str = "-"; - // fall through. - case SRCMOD_SIGN: - postmod_str = "_bx2"; - break; - - case SRCMOD_COMPLEMENT: - premod_str = "1-"; - break; - - case SRCMOD_X2NEGATE: - premod_str = "-"; - // fall through. - case SRCMOD_X2: - postmod_str = "_x2"; - break; - - case SRCMOD_DZ: - postmod_str = "_dz"; - break; - - case SRCMOD_DW: - postmod_str = "_dw"; - break; - - case SRCMOD_ABSNEGATE: - premod_str = "-"; - // fall through. - case SRCMOD_ABS: - postmod_str = "_abs"; - break; - - case SRCMOD_NOT: - premod_str = "!"; - break; - - case SRCMOD_NONE: - case SRCMOD_TOTAL: - break; // stop compiler whining. - } // switch - - - char regnum_str[16]; - const char *regtype_str = get_D3D_register_string(ctx, arg->regtype, - arg->regnum, regnum_str, - sizeof (regnum_str)); - - if (regtype_str == NULL) - { - fail(ctx, "Unknown source register type."); - *buf = '\0'; - return buf; - } // if - - const char *rel_lbracket = ""; - const char *rel_rbracket = ""; - char rel_swizzle[4] = { '\0' }; - char rel_regnum_str[16] = { '\0' }; - const char *rel_regtype_str = ""; - if (arg->relative) - { - rel_swizzle[0] = '.'; - rel_swizzle[1] = swizzle_channels[arg->relative_component]; - rel_swizzle[2] = '\0'; - rel_lbracket = "["; - rel_rbracket = "]"; - rel_regtype_str = get_D3D_register_string(ctx, arg->relative_regtype, - arg->relative_regnum, - rel_regnum_str, - sizeof (rel_regnum_str)); - - if (regtype_str == NULL) - { - fail(ctx, "Unknown relative source register type."); - *buf = '\0'; - return buf; - } // if - } // if - - char swizzle_str[6]; - size_t i = 0; - const int scalar = isscalar(ctx, ctx->shader_type, arg->regtype, arg->regnum); - if (!scalar && !no_swizzle(arg->swizzle)) - { - swizzle_str[i++] = '.'; - swizzle_str[i++] = swizzle_channels[arg->swizzle_x]; - swizzle_str[i++] = swizzle_channels[arg->swizzle_y]; - swizzle_str[i++] = swizzle_channels[arg->swizzle_z]; - swizzle_str[i++] = swizzle_channels[arg->swizzle_w]; - - // .xyzz is the same as .xyz, .z is the same as .zzzz, etc. - while (swizzle_str[i-1] == swizzle_str[i-2]) - i--; - } // if - swizzle_str[i] = '\0'; - assert(i < sizeof (swizzle_str)); - - // !!! FIXME: c12[a0.x] actually needs to be c[a0.x + 12] - snprintf(buf, buflen, "%s%s%s%s%s%s%s%s%s%s", - premod_str, regtype_str, regnum_str, postmod_str, - rel_lbracket, rel_regtype_str, rel_regnum_str, rel_swizzle, - rel_rbracket, swizzle_str); - // !!! FIXME: make sure the scratch buffer was large enough. - return buf; -} // make_D3D_srcarg_string_in_buf - - -static const char *make_D3D_destarg_string(Context *ctx, char *buf, - const size_t buflen) -{ - const DestArgInfo *arg = &ctx->dest_arg; - - const char *result_shift_str = ""; - switch (arg->result_shift) - { - case 0x1: result_shift_str = "_x2"; break; - case 0x2: result_shift_str = "_x4"; break; - case 0x3: result_shift_str = "_x8"; break; - case 0xD: result_shift_str = "_d8"; break; - case 0xE: result_shift_str = "_d4"; break; - case 0xF: result_shift_str = "_d2"; break; - } // switch - - const char *sat_str = (arg->result_mod & MOD_SATURATE) ? "_sat" : ""; - const char *pp_str = (arg->result_mod & MOD_PP) ? "_pp" : ""; - const char *cent_str = (arg->result_mod & MOD_CENTROID) ? "_centroid" : ""; - - char regnum_str[16]; - const char *regtype_str = get_D3D_register_string(ctx, arg->regtype, - arg->regnum, regnum_str, - sizeof (regnum_str)); - if (regtype_str == NULL) - { - fail(ctx, "Unknown destination register type."); - *buf = '\0'; - return buf; - } // if - - char writemask_str[6]; - size_t i = 0; - const int scalar = isscalar(ctx, ctx->shader_type, arg->regtype, arg->regnum); - if (!scalar && !writemask_xyzw(arg->writemask)) - { - writemask_str[i++] = '.'; - if (arg->writemask0) writemask_str[i++] = 'x'; - if (arg->writemask1) writemask_str[i++] = 'y'; - if (arg->writemask2) writemask_str[i++] = 'z'; - if (arg->writemask3) writemask_str[i++] = 'w'; - } // if - writemask_str[i] = '\0'; - assert(i < sizeof (writemask_str)); - - const char *pred_left = ""; - const char *pred_right = ""; - char pred[32] = { '\0' }; - if (ctx->predicated) - { - pred_left = "("; - pred_right = ") "; - make_D3D_srcarg_string_in_buf(ctx, &ctx->predicate_arg, - pred, sizeof (pred)); - } // if - - // may turn out something like "_x2_sat_pp_centroid (!p0.x) r0.xyzw" ... - snprintf(buf, buflen, "%s%s%s%s %s%s%s%s%s%s", - result_shift_str, sat_str, pp_str, cent_str, - pred_left, pred, pred_right, - regtype_str, regnum_str, writemask_str); - // !!! FIXME: make sure the scratch buffer was large enough. - return buf; -} // make_D3D_destarg_string - - -static const char *make_D3D_srcarg_string(Context *ctx, const size_t idx, - char *buf, size_t buflen) -{ - if (idx >= STATICARRAYLEN(ctx->source_args)) - { - fail(ctx, "Too many source args"); - *buf = '\0'; - return buf; - } // if - - const SourceArgInfo *arg = &ctx->source_args[idx]; - return make_D3D_srcarg_string_in_buf(ctx, arg, buf, buflen); -} // make_D3D_srcarg_string - -static const char *get_D3D_varname_in_buf(Context *ctx, RegisterType rt, - int regnum, char *buf, - const size_t len) -{ - char regnum_str[16]; - const char *regtype_str = get_D3D_register_string(ctx, rt, regnum, - regnum_str, sizeof (regnum_str)); - snprintf(buf,len,"%s%s", regtype_str, regnum_str); - return buf; -} // get_D3D_varname_in_buf - - -static const char *get_D3D_varname(Context *ctx, RegisterType rt, int regnum) -{ - char buf[64]; - get_D3D_varname_in_buf(ctx, rt, regnum, buf, sizeof (buf)); - return StrDup(ctx, buf); -} // get_D3D_varname - - -static const char *get_D3D_const_array_varname(Context *ctx, int base, int size) -{ - char buf[64]; - snprintf(buf, sizeof (buf), "c_array_%d_%d", base, size); - return StrDup(ctx, buf); -} // get_D3D_const_array_varname - - -static void emit_D3D_start(Context *ctx, const char *profilestr) -{ - const uint major = (uint) ctx->major_ver; - const uint minor = (uint) ctx->minor_ver; - char minor_str[16]; - - ctx->ignores_ctab = 1; - - if (minor == 0xFF) - strcpy(minor_str, "sw"); - else if ((major > 1) && (minor == 1)) - strcpy(minor_str, "x"); // for >= SM2, apparently this is "x". Weird. - else - snprintf(minor_str, sizeof (minor_str), "%u", (uint) minor); - - output_line(ctx, "%s_%u_%s", ctx->shader_type_str, major, minor_str); -} // emit_D3D_start - - -static void emit_D3D_end(Context *ctx) -{ - output_line(ctx, "end"); -} // emit_D3D_end - - -static void emit_D3D_phase(Context *ctx) -{ - output_line(ctx, "phase"); -} // emit_D3D_phase - - -static void emit_D3D_finalize(Context *ctx) -{ - // no-op. -} // emit_D3D_finalize - - -static void emit_D3D_global(Context *ctx, RegisterType regtype, int regnum) -{ - // no-op. -} // emit_D3D_global - - -static void emit_D3D_array(Context *ctx, VariableList *var) -{ - // no-op. -} // emit_D3D_array - - -static void emit_D3D_const_array(Context *ctx, const ConstantsList *clist, - int base, int size) -{ - // no-op. -} // emit_D3D_const_array - - -static void emit_D3D_uniform(Context *ctx, RegisterType regtype, int regnum, - const VariableList *var) -{ - // no-op. -} // emit_D3D_uniform - - -static void emit_D3D_sampler(Context *ctx, int stage, TextureType ttype) -{ - // no-op. -} // emit_D3D_sampler - - -static void emit_D3D_attribute(Context *ctx, RegisterType regtype, int regnum, - MOJOSHADER_usage usage, int index, int wmask, - int flags) -{ - // no-op. -} // emit_D3D_attribute - - -static void emit_D3D_RESERVED(Context *ctx) -{ - // do nothing; fails in the state machine. -} // emit_D3D_RESERVED - - -// Generic D3D opcode emitters. A list of macros generate all the entry points -// that call into these... - -static char *lowercase(char *dst, const char *src) -{ - int i = 0; - do - { - const char ch = src[i]; - dst[i] = (((ch >= 'A') && (ch <= 'Z')) ? (ch - ('A' - 'a')) : ch); - } while (src[i++]); - return dst; -} // lowercase - - -static void emit_D3D_opcode_d(Context *ctx, const char *opcode) -{ - char dst[64]; make_D3D_destarg_string(ctx, dst, sizeof (dst)); - opcode = lowercase((char *) alloca(strlen(opcode) + 1), opcode); - output_line(ctx, "%s%s", opcode, dst); -} // emit_D3D_opcode_d - - -static void emit_D3D_opcode_s(Context *ctx, const char *opcode) -{ - char src0[64]; make_D3D_srcarg_string(ctx, 0, src0, sizeof (src0)); - opcode = lowercase((char *) alloca(strlen(opcode) + 1), opcode); - output_line(ctx, "%s %s", opcode, src0); -} // emit_D3D_opcode_s - - -static void emit_D3D_opcode_ss(Context *ctx, const char *opcode) -{ - char src0[64]; make_D3D_srcarg_string(ctx, 0, src0, sizeof (src0)); - char src1[64]; make_D3D_srcarg_string(ctx, 1, src1, sizeof (src1)); - opcode = lowercase((char *) alloca(strlen(opcode) + 1), opcode); - output_line(ctx, "%s %s, %s", opcode, src0, src1); -} // emit_D3D_opcode_ss - - -static void emit_D3D_opcode_ds(Context *ctx, const char *opcode) -{ - char dst[64]; make_D3D_destarg_string(ctx, dst, sizeof (dst)); - char src0[64]; make_D3D_srcarg_string(ctx, 0, src0, sizeof (src0)); - opcode = lowercase((char *) alloca(strlen(opcode) + 1), opcode); - output_line(ctx, "%s%s, %s", opcode, dst, src0); -} // emit_D3D_opcode_ds - - -static void emit_D3D_opcode_dss(Context *ctx, const char *opcode) -{ - char dst[64]; make_D3D_destarg_string(ctx, dst, sizeof (dst)); - char src0[64]; make_D3D_srcarg_string(ctx, 0, src0, sizeof (src0)); - char src1[64]; make_D3D_srcarg_string(ctx, 1, src1, sizeof (src1)); - opcode = lowercase((char *) alloca(strlen(opcode) + 1), opcode); - output_line(ctx, "%s%s, %s, %s", opcode, dst, src0, src1); -} // emit_D3D_opcode_dss - - -static void emit_D3D_opcode_dsss(Context *ctx, const char *opcode) -{ - char dst[64]; make_D3D_destarg_string(ctx, dst, sizeof (dst)); - char src0[64]; make_D3D_srcarg_string(ctx, 0, src0, sizeof (src0)); - char src1[64]; make_D3D_srcarg_string(ctx, 1, src1, sizeof (src1)); - char src2[64]; make_D3D_srcarg_string(ctx, 2, src2, sizeof (src2)); - opcode = lowercase((char *) alloca(strlen(opcode) + 1), opcode); - output_line(ctx, "%s%s, %s, %s, %s", opcode, dst, src0, src1, src2); -} // emit_D3D_opcode_dsss - - -static void emit_D3D_opcode_dssss(Context *ctx, const char *opcode) -{ - char dst[64]; make_D3D_destarg_string(ctx, dst, sizeof (dst)); - char src0[64]; make_D3D_srcarg_string(ctx, 0, src0, sizeof (src0)); - char src1[64]; make_D3D_srcarg_string(ctx, 1, src1, sizeof (src1)); - char src2[64]; make_D3D_srcarg_string(ctx, 2, src2, sizeof (src2)); - char src3[64]; make_D3D_srcarg_string(ctx, 3, src3, sizeof (src3)); - opcode = lowercase((char *) alloca(strlen(opcode) + 1), opcode); - output_line(ctx,"%s%s, %s, %s, %s, %s",opcode,dst,src0,src1,src2,src3); -} // emit_D3D_opcode_dssss - - -static void emit_D3D_opcode(Context *ctx, const char *opcode) -{ - opcode = lowercase((char *) alloca(strlen(opcode) + 1), opcode); - output_line(ctx, "%s", opcode); -} // emit_D3D_opcode_dssss - - -#define EMIT_D3D_OPCODE_FUNC(op) \ - static void emit_D3D_##op(Context *ctx) { \ - emit_D3D_opcode(ctx, #op); \ - } -#define EMIT_D3D_OPCODE_D_FUNC(op) \ - static void emit_D3D_##op(Context *ctx) { \ - emit_D3D_opcode_d(ctx, #op); \ - } -#define EMIT_D3D_OPCODE_S_FUNC(op) \ - static void emit_D3D_##op(Context *ctx) { \ - emit_D3D_opcode_s(ctx, #op); \ - } -#define EMIT_D3D_OPCODE_SS_FUNC(op) \ - static void emit_D3D_##op(Context *ctx) { \ - emit_D3D_opcode_ss(ctx, #op); \ - } -#define EMIT_D3D_OPCODE_DS_FUNC(op) \ - static void emit_D3D_##op(Context *ctx) { \ - emit_D3D_opcode_ds(ctx, #op); \ - } -#define EMIT_D3D_OPCODE_DSS_FUNC(op) \ - static void emit_D3D_##op(Context *ctx) { \ - emit_D3D_opcode_dss(ctx, #op); \ - } -#define EMIT_D3D_OPCODE_DSSS_FUNC(op) \ - static void emit_D3D_##op(Context *ctx) { \ - emit_D3D_opcode_dsss(ctx, #op); \ - } -#define EMIT_D3D_OPCODE_DSSSS_FUNC(op) \ - static void emit_D3D_##op(Context *ctx) { \ - emit_D3D_opcode_dssss(ctx, #op); \ - } - -EMIT_D3D_OPCODE_FUNC(NOP) -EMIT_D3D_OPCODE_DS_FUNC(MOV) -EMIT_D3D_OPCODE_DSS_FUNC(ADD) -EMIT_D3D_OPCODE_DSS_FUNC(SUB) -EMIT_D3D_OPCODE_DSSS_FUNC(MAD) -EMIT_D3D_OPCODE_DSS_FUNC(MUL) -EMIT_D3D_OPCODE_DS_FUNC(RCP) -EMIT_D3D_OPCODE_DS_FUNC(RSQ) -EMIT_D3D_OPCODE_DSS_FUNC(DP3) -EMIT_D3D_OPCODE_DSS_FUNC(DP4) -EMIT_D3D_OPCODE_DSS_FUNC(MIN) -EMIT_D3D_OPCODE_DSS_FUNC(MAX) -EMIT_D3D_OPCODE_DSS_FUNC(SLT) -EMIT_D3D_OPCODE_DSS_FUNC(SGE) -EMIT_D3D_OPCODE_DS_FUNC(EXP) -EMIT_D3D_OPCODE_DS_FUNC(LOG) -EMIT_D3D_OPCODE_DS_FUNC(LIT) -EMIT_D3D_OPCODE_DSS_FUNC(DST) -EMIT_D3D_OPCODE_DSSS_FUNC(LRP) -EMIT_D3D_OPCODE_DS_FUNC(FRC) -EMIT_D3D_OPCODE_DSS_FUNC(M4X4) -EMIT_D3D_OPCODE_DSS_FUNC(M4X3) -EMIT_D3D_OPCODE_DSS_FUNC(M3X4) -EMIT_D3D_OPCODE_DSS_FUNC(M3X3) -EMIT_D3D_OPCODE_DSS_FUNC(M3X2) -EMIT_D3D_OPCODE_S_FUNC(CALL) -EMIT_D3D_OPCODE_SS_FUNC(CALLNZ) -EMIT_D3D_OPCODE_SS_FUNC(LOOP) -EMIT_D3D_OPCODE_FUNC(RET) -EMIT_D3D_OPCODE_FUNC(ENDLOOP) -EMIT_D3D_OPCODE_S_FUNC(LABEL) -EMIT_D3D_OPCODE_DSS_FUNC(POW) -EMIT_D3D_OPCODE_DSS_FUNC(CRS) -EMIT_D3D_OPCODE_DSSS_FUNC(SGN) -EMIT_D3D_OPCODE_DS_FUNC(ABS) -EMIT_D3D_OPCODE_DS_FUNC(NRM) -EMIT_D3D_OPCODE_S_FUNC(REP) -EMIT_D3D_OPCODE_FUNC(ENDREP) -EMIT_D3D_OPCODE_S_FUNC(IF) -EMIT_D3D_OPCODE_FUNC(ELSE) -EMIT_D3D_OPCODE_FUNC(ENDIF) -EMIT_D3D_OPCODE_FUNC(BREAK) -EMIT_D3D_OPCODE_DS_FUNC(MOVA) -EMIT_D3D_OPCODE_D_FUNC(TEXKILL) -EMIT_D3D_OPCODE_DS_FUNC(TEXBEM) -EMIT_D3D_OPCODE_DS_FUNC(TEXBEML) -EMIT_D3D_OPCODE_DS_FUNC(TEXREG2AR) -EMIT_D3D_OPCODE_DS_FUNC(TEXREG2GB) -EMIT_D3D_OPCODE_DS_FUNC(TEXM3X2PAD) -EMIT_D3D_OPCODE_DS_FUNC(TEXM3X2TEX) -EMIT_D3D_OPCODE_DS_FUNC(TEXM3X3PAD) -EMIT_D3D_OPCODE_DS_FUNC(TEXM3X3TEX) -EMIT_D3D_OPCODE_DSS_FUNC(TEXM3X3SPEC) -EMIT_D3D_OPCODE_DS_FUNC(TEXM3X3VSPEC) -EMIT_D3D_OPCODE_DS_FUNC(EXPP) -EMIT_D3D_OPCODE_DS_FUNC(LOGP) -EMIT_D3D_OPCODE_DSSS_FUNC(CND) -EMIT_D3D_OPCODE_DS_FUNC(TEXREG2RGB) -EMIT_D3D_OPCODE_DS_FUNC(TEXDP3TEX) -EMIT_D3D_OPCODE_DS_FUNC(TEXM3X2DEPTH) -EMIT_D3D_OPCODE_DS_FUNC(TEXDP3) -EMIT_D3D_OPCODE_DS_FUNC(TEXM3X3) -EMIT_D3D_OPCODE_D_FUNC(TEXDEPTH) -EMIT_D3D_OPCODE_DSSS_FUNC(CMP) -EMIT_D3D_OPCODE_DSS_FUNC(BEM) -EMIT_D3D_OPCODE_DSSS_FUNC(DP2ADD) -EMIT_D3D_OPCODE_DS_FUNC(DSX) -EMIT_D3D_OPCODE_DS_FUNC(DSY) -EMIT_D3D_OPCODE_DSSSS_FUNC(TEXLDD) -EMIT_D3D_OPCODE_DSS_FUNC(TEXLDL) -EMIT_D3D_OPCODE_S_FUNC(BREAKP) - -// special cases for comparison opcodes... -static const char *get_D3D_comparison_string(Context *ctx) -{ - static const char *comps[] = { - "", "_gt", "_eq", "_ge", "_lt", "_ne", "_le" - }; - - if (ctx->instruction_controls >= STATICARRAYLEN(comps)) - { - fail(ctx, "unknown comparison control"); - return ""; - } // if - - return comps[ctx->instruction_controls]; -} // get_D3D_comparison_string - -static void emit_D3D_BREAKC(Context *ctx) -{ - char op[16]; - snprintf(op, sizeof (op), "break%s", get_D3D_comparison_string(ctx)); - emit_D3D_opcode_ss(ctx, op); -} // emit_D3D_BREAKC - -static void emit_D3D_IFC(Context *ctx) -{ - char op[16]; - snprintf(op, sizeof (op), "if%s", get_D3D_comparison_string(ctx)); - emit_D3D_opcode_ss(ctx, op); -} // emit_D3D_IFC - -static void emit_D3D_SETP(Context *ctx) -{ - char op[16]; - snprintf(op, sizeof (op), "setp%s", get_D3D_comparison_string(ctx)); - emit_D3D_opcode_dss(ctx, op); -} // emit_D3D_SETP - -static void emit_D3D_DEF(Context *ctx) -{ - char dst[64]; - make_D3D_destarg_string(ctx, dst, sizeof (dst)); - const float *val = (const float *) ctx->dwords; // !!! FIXME: could be int? - char val0[32]; - char val1[32]; - char val2[32]; - char val3[32]; - floatstr(ctx, val0, sizeof (val0), val[0], 0); - floatstr(ctx, val1, sizeof (val1), val[1], 0); - floatstr(ctx, val2, sizeof (val2), val[2], 0); - floatstr(ctx, val3, sizeof (val3), val[3], 0); - output_line(ctx, "def%s, %s, %s, %s, %s", dst, val0, val1, val2, val3); -} // emit_D3D_DEF - -static void emit_D3D_DEFI(Context *ctx) -{ - char dst[64]; - make_D3D_destarg_string(ctx, dst, sizeof (dst)); - const int32 *x = (const int32 *) ctx->dwords; - output_line(ctx, "defi%s, %d, %d, %d, %d", dst, - (int) x[0], (int) x[1], (int) x[2], (int) x[3]); -} // emit_D3D_DEFI - -static void emit_D3D_DEFB(Context *ctx) -{ - char dst[64]; - make_D3D_destarg_string(ctx, dst, sizeof (dst)); - output_line(ctx, "defb%s, %s", dst, ctx->dwords[0] ? "true" : "false"); -} // emit_D3D_DEFB - - -static void emit_D3D_DCL(Context *ctx) -{ - char dst[64]; - make_D3D_destarg_string(ctx, dst, sizeof (dst)); - const DestArgInfo *arg = &ctx->dest_arg; - const char *usage_str = ""; - char index_str[16] = { '\0' }; - - if (arg->regtype == REG_TYPE_SAMPLER) - { - switch ((const TextureType) ctx->dwords[0]) - { - case TEXTURE_TYPE_2D: usage_str = "_2d"; break; - case TEXTURE_TYPE_CUBE: usage_str = "_cube"; break; - case TEXTURE_TYPE_VOLUME: usage_str = "_volume"; break; - default: fail(ctx, "unknown sampler texture type"); return; - } // switch - } // if - - else if (arg->regtype == REG_TYPE_MISCTYPE) - { - switch ((const MiscTypeType) arg->regnum) - { - case MISCTYPE_TYPE_POSITION: - case MISCTYPE_TYPE_FACE: - usage_str = ""; // just become "dcl vFace" or whatever. - break; - default: fail(ctx, "unknown misc register type"); return; - } // switch - } // else if - - else - { - const uint32 usage = ctx->dwords[0]; - const uint32 index = ctx->dwords[1]; - usage_str = usagestrs[usage]; - if (index != 0) - snprintf(index_str, sizeof (index_str), "%u", (uint) index); - } // else - - output_line(ctx, "dcl%s%s%s", usage_str, index_str, dst); -} // emit_D3D_DCL - - -static void emit_D3D_TEXCRD(Context *ctx) -{ - // this opcode looks and acts differently depending on the shader model. - if (shader_version_atleast(ctx, 1, 4)) - emit_D3D_opcode_ds(ctx, "texcrd"); - else - emit_D3D_opcode_d(ctx, "texcoord"); -} // emit_D3D_TEXCOORD - -static void emit_D3D_TEXLD(Context *ctx) -{ - // this opcode looks and acts differently depending on the shader model. - if (shader_version_atleast(ctx, 2, 0)) - { - if (ctx->instruction_controls == CONTROL_TEXLD) - emit_D3D_opcode_dss(ctx, "texld"); - else if (ctx->instruction_controls == CONTROL_TEXLDP) - emit_D3D_opcode_dss(ctx, "texldp"); - else if (ctx->instruction_controls == CONTROL_TEXLDB) - emit_D3D_opcode_dss(ctx, "texldb"); - } // if - - else if (shader_version_atleast(ctx, 1, 4)) - { - emit_D3D_opcode_ds(ctx, "texld"); - } // else if - - else - { - emit_D3D_opcode_d(ctx, "tex"); - } // else -} // emit_D3D_TEXLD - -static void emit_D3D_SINCOS(Context *ctx) -{ - // this opcode needs extra registers for sm2 and lower. - if (!shader_version_atleast(ctx, 3, 0)) - emit_D3D_opcode_dsss(ctx, "sincos"); - else - emit_D3D_opcode_ds(ctx, "sincos"); -} // emit_D3D_SINCOS - - -#undef EMIT_D3D_OPCODE_FUNC -#undef EMIT_D3D_OPCODE_D_FUNC -#undef EMIT_D3D_OPCODE_S_FUNC -#undef EMIT_D3D_OPCODE_SS_FUNC -#undef EMIT_D3D_OPCODE_DS_FUNC -#undef EMIT_D3D_OPCODE_DSS_FUNC -#undef EMIT_D3D_OPCODE_DSSS_FUNC -#undef EMIT_D3D_OPCODE_DSSSS_FUNC - -#endif // SUPPORT_PROFILE_D3D - - -#if !SUPPORT_PROFILE_BYTECODE -#define PROFILE_EMITTER_BYTECODE(op) -#else -#undef AT_LEAST_ONE_PROFILE -#define AT_LEAST_ONE_PROFILE 1 -#define PROFILE_EMITTER_BYTECODE(op) emit_BYTECODE_##op, - -static void emit_BYTECODE_start(Context *ctx, const char *profilestr) -{ - ctx->ignores_ctab = 1; - - // just copy the whole token stream and make all other emitters no-ops. - if (set_output(ctx, &ctx->mainline)) - { - const size_t len = ctx->tokencount * sizeof (uint32); - buffer_append(ctx->mainline, (const char *) ctx->tokens, len); - } // if -} // emit_BYTECODE_start - -static void emit_BYTECODE_end(Context *ctx) {} -static void emit_BYTECODE_phase(Context *ctx) {} -static void emit_BYTECODE_finalize(Context *ctx) {} -static void emit_BYTECODE_global(Context *ctx, RegisterType t, int n) {} -static void emit_BYTECODE_array(Context *ctx, VariableList *var) {} -static void emit_BYTECODE_sampler(Context *ctx, int s, TextureType ttype) {} -static void emit_BYTECODE_const_array(Context *ctx, const ConstantsList *c, - int base, int size) {} -static void emit_BYTECODE_uniform(Context *ctx, RegisterType t, int n, - const VariableList *var) {} -static void emit_BYTECODE_attribute(Context *ctx, RegisterType t, int n, - MOJOSHADER_usage u, int i, int w, - int f) {} - -static const char *get_BYTECODE_varname(Context *ctx, RegisterType rt, int regnum) -{ - char regnum_str[16]; - const char *regtype_str = get_D3D_register_string(ctx, rt, regnum, - regnum_str, sizeof (regnum_str)); - char buf[64]; - snprintf(buf, sizeof (buf), "%s%s", regtype_str, regnum_str); - return StrDup(ctx, buf); -} // get_BYTECODE_varname - -static const char *get_BYTECODE_const_array_varname(Context *ctx, int base, int size) -{ - char buf[64]; - snprintf(buf, sizeof (buf), "c_array_%d_%d", base, size); - return StrDup(ctx, buf); -} // get_BYTECODE_const_array_varname - -#define EMIT_BYTECODE_OPCODE_FUNC(op) \ - static void emit_BYTECODE_##op(Context *ctx) {} - -EMIT_BYTECODE_OPCODE_FUNC(RESERVED) -EMIT_BYTECODE_OPCODE_FUNC(NOP) -EMIT_BYTECODE_OPCODE_FUNC(MOV) -EMIT_BYTECODE_OPCODE_FUNC(ADD) -EMIT_BYTECODE_OPCODE_FUNC(SUB) -EMIT_BYTECODE_OPCODE_FUNC(MAD) -EMIT_BYTECODE_OPCODE_FUNC(MUL) -EMIT_BYTECODE_OPCODE_FUNC(RCP) -EMIT_BYTECODE_OPCODE_FUNC(RSQ) -EMIT_BYTECODE_OPCODE_FUNC(DP3) -EMIT_BYTECODE_OPCODE_FUNC(DP4) -EMIT_BYTECODE_OPCODE_FUNC(MIN) -EMIT_BYTECODE_OPCODE_FUNC(MAX) -EMIT_BYTECODE_OPCODE_FUNC(SLT) -EMIT_BYTECODE_OPCODE_FUNC(SGE) -EMIT_BYTECODE_OPCODE_FUNC(EXP) -EMIT_BYTECODE_OPCODE_FUNC(LOG) -EMIT_BYTECODE_OPCODE_FUNC(LIT) -EMIT_BYTECODE_OPCODE_FUNC(DST) -EMIT_BYTECODE_OPCODE_FUNC(LRP) -EMIT_BYTECODE_OPCODE_FUNC(FRC) -EMIT_BYTECODE_OPCODE_FUNC(M4X4) -EMIT_BYTECODE_OPCODE_FUNC(M4X3) -EMIT_BYTECODE_OPCODE_FUNC(M3X4) -EMIT_BYTECODE_OPCODE_FUNC(M3X3) -EMIT_BYTECODE_OPCODE_FUNC(M3X2) -EMIT_BYTECODE_OPCODE_FUNC(CALL) -EMIT_BYTECODE_OPCODE_FUNC(CALLNZ) -EMIT_BYTECODE_OPCODE_FUNC(LOOP) -EMIT_BYTECODE_OPCODE_FUNC(RET) -EMIT_BYTECODE_OPCODE_FUNC(ENDLOOP) -EMIT_BYTECODE_OPCODE_FUNC(LABEL) -EMIT_BYTECODE_OPCODE_FUNC(POW) -EMIT_BYTECODE_OPCODE_FUNC(CRS) -EMIT_BYTECODE_OPCODE_FUNC(SGN) -EMIT_BYTECODE_OPCODE_FUNC(ABS) -EMIT_BYTECODE_OPCODE_FUNC(NRM) -EMIT_BYTECODE_OPCODE_FUNC(SINCOS) -EMIT_BYTECODE_OPCODE_FUNC(REP) -EMIT_BYTECODE_OPCODE_FUNC(ENDREP) -EMIT_BYTECODE_OPCODE_FUNC(IF) -EMIT_BYTECODE_OPCODE_FUNC(ELSE) -EMIT_BYTECODE_OPCODE_FUNC(ENDIF) -EMIT_BYTECODE_OPCODE_FUNC(BREAK) -EMIT_BYTECODE_OPCODE_FUNC(MOVA) -EMIT_BYTECODE_OPCODE_FUNC(TEXKILL) -EMIT_BYTECODE_OPCODE_FUNC(TEXBEM) -EMIT_BYTECODE_OPCODE_FUNC(TEXBEML) -EMIT_BYTECODE_OPCODE_FUNC(TEXREG2AR) -EMIT_BYTECODE_OPCODE_FUNC(TEXREG2GB) -EMIT_BYTECODE_OPCODE_FUNC(TEXM3X2PAD) -EMIT_BYTECODE_OPCODE_FUNC(TEXM3X2TEX) -EMIT_BYTECODE_OPCODE_FUNC(TEXM3X3PAD) -EMIT_BYTECODE_OPCODE_FUNC(TEXM3X3TEX) -EMIT_BYTECODE_OPCODE_FUNC(TEXM3X3SPEC) -EMIT_BYTECODE_OPCODE_FUNC(TEXM3X3VSPEC) -EMIT_BYTECODE_OPCODE_FUNC(EXPP) -EMIT_BYTECODE_OPCODE_FUNC(LOGP) -EMIT_BYTECODE_OPCODE_FUNC(CND) -EMIT_BYTECODE_OPCODE_FUNC(TEXREG2RGB) -EMIT_BYTECODE_OPCODE_FUNC(TEXDP3TEX) -EMIT_BYTECODE_OPCODE_FUNC(TEXM3X2DEPTH) -EMIT_BYTECODE_OPCODE_FUNC(TEXDP3) -EMIT_BYTECODE_OPCODE_FUNC(TEXM3X3) -EMIT_BYTECODE_OPCODE_FUNC(TEXDEPTH) -EMIT_BYTECODE_OPCODE_FUNC(CMP) -EMIT_BYTECODE_OPCODE_FUNC(BEM) -EMIT_BYTECODE_OPCODE_FUNC(DP2ADD) -EMIT_BYTECODE_OPCODE_FUNC(DSX) -EMIT_BYTECODE_OPCODE_FUNC(DSY) -EMIT_BYTECODE_OPCODE_FUNC(TEXLDD) -EMIT_BYTECODE_OPCODE_FUNC(TEXLDL) -EMIT_BYTECODE_OPCODE_FUNC(BREAKP) -EMIT_BYTECODE_OPCODE_FUNC(BREAKC) -EMIT_BYTECODE_OPCODE_FUNC(IFC) -EMIT_BYTECODE_OPCODE_FUNC(SETP) -EMIT_BYTECODE_OPCODE_FUNC(DEF) -EMIT_BYTECODE_OPCODE_FUNC(DEFI) -EMIT_BYTECODE_OPCODE_FUNC(DEFB) -EMIT_BYTECODE_OPCODE_FUNC(DCL) -EMIT_BYTECODE_OPCODE_FUNC(TEXCRD) -EMIT_BYTECODE_OPCODE_FUNC(TEXLD) - -#undef EMIT_BYTECODE_OPCODE_FUNC - -#endif // SUPPORT_PROFILE_BYTECODE - - -#if !SUPPORT_PROFILE_GLSL -#define PROFILE_EMITTER_GLSL(op) -#else -#undef AT_LEAST_ONE_PROFILE -#define AT_LEAST_ONE_PROFILE 1 -#define PROFILE_EMITTER_GLSL(op) emit_GLSL_##op, - -#define EMIT_GLSL_OPCODE_UNIMPLEMENTED_FUNC(op) \ - static void emit_GLSL_##op(Context *ctx) { \ - fail(ctx, #op " unimplemented in glsl profile"); \ - } - -static inline const char *get_GLSL_register_string(Context *ctx, - const RegisterType regtype, const int regnum, - char *regnum_str, const size_t regnum_size) -{ - // turns out these are identical at the moment. - return get_D3D_register_string(ctx,regtype,regnum,regnum_str,regnum_size); -} // get_GLSL_register_string - -static const char *get_GLSL_uniform_type(Context *ctx, const RegisterType rtype) -{ - switch (rtype) - { - case REG_TYPE_CONST: return "vec4"; - case REG_TYPE_CONSTINT: return "ivec4"; - case REG_TYPE_CONSTBOOL: return "bool"; - default: fail(ctx, "BUG: used a uniform we don't know how to define."); - } // switch - - return NULL; -} // get_GLSL_uniform_type - -static const char *get_GLSL_varname_in_buf(Context *ctx, RegisterType rt, - int regnum, char *buf, - const size_t len) -{ - char regnum_str[16]; - const char *regtype_str = get_GLSL_register_string(ctx, rt, regnum, - regnum_str, sizeof (regnum_str)); - snprintf(buf,len,"%s_%s%s", ctx->shader_type_str, regtype_str, regnum_str); - return buf; -} // get_GLSL_varname_in_buf - - -static const char *get_GLSL_varname(Context *ctx, RegisterType rt, int regnum) -{ - char buf[64]; - get_GLSL_varname_in_buf(ctx, rt, regnum, buf, sizeof (buf)); - return StrDup(ctx, buf); -} // get_GLSL_varname - - -static inline const char *get_GLSL_const_array_varname_in_buf(Context *ctx, - const int base, const int size, - char *buf, const size_t buflen) -{ - const char *type = ctx->shader_type_str; - snprintf(buf, buflen, "%s_const_array_%d_%d", type, base, size); - return buf; -} // get_GLSL_const_array_varname_in_buf - -static const char *get_GLSL_const_array_varname(Context *ctx, int base, int size) -{ - char buf[64]; - get_GLSL_const_array_varname_in_buf(ctx, base, size, buf, sizeof (buf)); - return StrDup(ctx, buf); -} // get_GLSL_const_array_varname - - -static inline const char *get_GLSL_input_array_varname(Context *ctx, - char *buf, const size_t buflen) -{ - snprintf(buf, buflen, "%s", "vertex_input_array"); - return buf; -} // get_GLSL_input_array_varname - - -static const char *get_GLSL_uniform_array_varname(Context *ctx, - const RegisterType regtype, - char *buf, const size_t len) -{ - const char *shadertype = ctx->shader_type_str; - const char *type = get_GLSL_uniform_type(ctx, regtype); - snprintf(buf, len, "%s_uniforms_%s", shadertype, type); - return buf; -} // get_GLSL_uniform_array_varname - -static const char *get_GLSL_destarg_varname(Context *ctx, char *buf, size_t len) -{ - const DestArgInfo *arg = &ctx->dest_arg; - return get_GLSL_varname_in_buf(ctx, arg->regtype, arg->regnum, buf, len); -} // get_GLSL_destarg_varname - -static const char *get_GLSL_srcarg_varname(Context *ctx, const size_t idx, - char *buf, size_t len) -{ - if (idx >= STATICARRAYLEN(ctx->source_args)) - { - fail(ctx, "Too many source args"); - *buf = '\0'; - return buf; - } // if - - const SourceArgInfo *arg = &ctx->source_args[idx]; - return get_GLSL_varname_in_buf(ctx, arg->regtype, arg->regnum, buf, len); -} // get_GLSL_srcarg_varname - - -static const char *make_GLSL_destarg_assign(Context *, char *, const size_t, - const char *, ...) ISPRINTF(4,5); - -static const char *make_GLSL_destarg_assign(Context *ctx, char *buf, - const size_t buflen, - const char *fmt, ...) -{ - int need_parens = 0; - const DestArgInfo *arg = &ctx->dest_arg; - - if (arg->writemask == 0) - { - *buf = '\0'; - return buf; // no writemask? It's a no-op. - } // if - - char clampbuf[32] = { '\0' }; - const char *clampleft = ""; - const char *clampright = ""; - if (arg->result_mod & MOD_SATURATE) - { - const int vecsize = vecsize_from_writemask(arg->writemask); - clampleft = "clamp("; - if (vecsize == 1) - clampright = ", 0.0, 1.0)"; - else - { - snprintf(clampbuf, sizeof (clampbuf), - ", vec%d(0.0), vec%d(1.0))", vecsize, vecsize); - clampright = clampbuf; - } // else - } // if - - // MSDN says MOD_PP is a hint and many implementations ignore it. So do we. - - // CENTROID only allowed in DCL opcodes, which shouldn't come through here. - assert((arg->result_mod & MOD_CENTROID) == 0); - - if (ctx->predicated) - { - fail(ctx, "predicated destinations unsupported"); // !!! FIXME - *buf = '\0'; - return buf; - } // if - - char operation[128]; - va_list ap; - va_start(ap, fmt); - const int len = vsnprintf(operation, sizeof (operation), fmt, ap); - va_end(ap); - if (len >= sizeof (operation)) - { - fail(ctx, "operation string too large"); // I'm lazy. :P - *buf = '\0'; - return buf; - } // if - - const char *result_shift_str = ""; - switch (arg->result_shift) - { - case 0x1: result_shift_str = " * 2.0"; break; - case 0x2: result_shift_str = " * 4.0"; break; - case 0x3: result_shift_str = " * 8.0"; break; - case 0xD: result_shift_str = " / 8.0"; break; - case 0xE: result_shift_str = " / 4.0"; break; - case 0xF: result_shift_str = " / 2.0"; break; - } // switch - need_parens |= (result_shift_str[0] != '\0'); - - char regnum_str[16]; - const char *regtype_str = get_GLSL_register_string(ctx, arg->regtype, - arg->regnum, regnum_str, - sizeof (regnum_str)); - char writemask_str[6]; - size_t i = 0; - const int scalar = isscalar(ctx, ctx->shader_type, arg->regtype, arg->regnum); - if (!scalar && !writemask_xyzw(arg->writemask)) - { - writemask_str[i++] = '.'; - if (arg->writemask0) writemask_str[i++] = 'x'; - if (arg->writemask1) writemask_str[i++] = 'y'; - if (arg->writemask2) writemask_str[i++] = 'z'; - if (arg->writemask3) writemask_str[i++] = 'w'; - } // if - writemask_str[i] = '\0'; - assert(i < sizeof (writemask_str)); - - const char *leftparen = (need_parens) ? "(" : ""; - const char *rightparen = (need_parens) ? ")" : ""; - - snprintf(buf, buflen, "%s_%s%s%s = %s%s%s%s%s%s;", - ctx->shader_type_str, regtype_str, regnum_str, writemask_str, - clampleft, leftparen, operation, rightparen, result_shift_str, - clampright); - // !!! FIXME: make sure the scratch buffer was large enough. - return buf; -} // make_GLSL_destarg_assign - - -static char *make_GLSL_swizzle_string(char *swiz_str, const size_t strsize, - const int swizzle, const int writemask) -{ - size_t i = 0; - if ( (!no_swizzle(swizzle)) || (!writemask_xyzw(writemask)) ) - { - const int writemask0 = (writemask >> 0) & 0x1; - const int writemask1 = (writemask >> 1) & 0x1; - const int writemask2 = (writemask >> 2) & 0x1; - const int writemask3 = (writemask >> 3) & 0x1; - - const int swizzle_x = (swizzle >> 0) & 0x3; - const int swizzle_y = (swizzle >> 2) & 0x3; - const int swizzle_z = (swizzle >> 4) & 0x3; - const int swizzle_w = (swizzle >> 6) & 0x3; - - swiz_str[i++] = '.'; - if (writemask0) swiz_str[i++] = swizzle_channels[swizzle_x]; - if (writemask1) swiz_str[i++] = swizzle_channels[swizzle_y]; - if (writemask2) swiz_str[i++] = swizzle_channels[swizzle_z]; - if (writemask3) swiz_str[i++] = swizzle_channels[swizzle_w]; - } // if - assert(i < strsize); - swiz_str[i] = '\0'; - return swiz_str; -} // make_GLSL_swizzle_string - - -static const char *make_GLSL_srcarg_string(Context *ctx, const size_t idx, - const int writemask, char *buf, - const size_t buflen) -{ - *buf = '\0'; - - if (idx >= STATICARRAYLEN(ctx->source_args)) - { - fail(ctx, "Too many source args"); - return buf; - } // if - -// !!! FIXME: not right. - const SourceArgInfo *arg = &ctx->source_args[idx]; - - const char *premod_str = ""; - const char *postmod_str = ""; - switch (arg->src_mod) - { - case SRCMOD_NEGATE: - premod_str = "-"; - break; - - case SRCMOD_BIASNEGATE: - premod_str = "-"; - // fall through. - case SRCMOD_BIAS: - fail(ctx, "SRCMOD_BIAS unsupported"); return buf; // !!! FIXME - postmod_str = "_bias"; - break; - - case SRCMOD_SIGNNEGATE: - premod_str = "-"; - // fall through. - case SRCMOD_SIGN: - fail(ctx, "SRCMOD_SIGN unsupported"); return buf; // !!! FIXME - postmod_str = "_bx2"; - break; - - case SRCMOD_COMPLEMENT: - fail(ctx, "SRCMOD_COMPLEMENT unsupported"); return buf; // !!! FIXME (need to handle vecsize) - premod_str = "(1.0 - ("; - postmod_str = "))"; - break; - - case SRCMOD_X2NEGATE: - fail(ctx, "SRCMOD_X2NEGATE unsupported"); return buf; // !!! FIXME (need to handle vecsize) - premod_str = "-("; - postmod_str = " * 2.0)"; - break; - - case SRCMOD_X2: - fail(ctx, "SRCMOD_X2 unsupported"); return buf; // !!! FIXME (need to handle vecsize) - premod_str = "("; - postmod_str = " * 2.0)"; - break; - - case SRCMOD_DZ: - fail(ctx, "SRCMOD_DZ unsupported"); return buf; // !!! FIXME - postmod_str = "_dz"; - break; - - case SRCMOD_DW: - fail(ctx, "SRCMOD_DW unsupported"); return buf; // !!! FIXME - postmod_str = "_dw"; - break; - - case SRCMOD_ABSNEGATE: - premod_str = "-abs("; - postmod_str = ")"; - break; - - case SRCMOD_ABS: - premod_str = "abs("; - postmod_str = ")"; - break; - - case SRCMOD_NOT: - premod_str = "!"; - break; - - case SRCMOD_NONE: - case SRCMOD_TOTAL: - break; // stop compiler whining. - } // switch - - const char *regtype_str = NULL; - - if (!arg->relative) - { - regtype_str = get_GLSL_varname_in_buf(ctx, arg->regtype, arg->regnum, - (char *) alloca(64), 64); - } // if - - const char *rel_lbracket = ""; - char rel_offset[32] = { '\0' }; - const char *rel_rbracket = ""; - char rel_swizzle[4] = { '\0' }; - const char *rel_regtype_str = ""; - if (arg->relative) - { - if (arg->regtype == REG_TYPE_INPUT) - regtype_str=get_GLSL_input_array_varname(ctx,(char*)alloca(64),64); - else - { - assert(arg->regtype == REG_TYPE_CONST); - const int arrayidx = arg->relative_array->index; - const int offset = arg->regnum - arrayidx; - assert(offset >= 0); - if (arg->relative_array->constant) - { - const int arraysize = arg->relative_array->count; - regtype_str = get_GLSL_const_array_varname_in_buf(ctx, - arrayidx, arraysize, (char *) alloca(64), 64); - if (offset != 0) - snprintf(rel_offset, sizeof (rel_offset), "%d + ", offset); - } // if - else - { - regtype_str = get_GLSL_uniform_array_varname(ctx, arg->regtype, - (char *) alloca(64), 64); - if (offset == 0) - { - snprintf(rel_offset, sizeof (rel_offset), - "ARRAYBASE_%d + ", arrayidx); - } // if - else - { - snprintf(rel_offset, sizeof (rel_offset), - "(ARRAYBASE_%d + %d) + ", arrayidx, offset); - } // else - } // else - } // else - - rel_lbracket = "["; - - rel_regtype_str = get_GLSL_varname_in_buf(ctx, arg->relative_regtype, - arg->relative_regnum, - (char *) alloca(64), 64); - rel_swizzle[0] = '.'; - rel_swizzle[1] = swizzle_channels[arg->relative_component]; - rel_swizzle[2] = '\0'; - rel_rbracket = "]"; - } // if - - char swiz_str[6] = { '\0' }; - if (!isscalar(ctx, ctx->shader_type, arg->regtype, arg->regnum)) - { - make_GLSL_swizzle_string(swiz_str, sizeof (swiz_str), - arg->swizzle, writemask); - } // if - - if (regtype_str == NULL) - { - fail(ctx, "Unknown source register type."); - return buf; - } // if - - snprintf(buf, buflen, "%s%s%s%s%s%s%s%s%s", - premod_str, regtype_str, rel_lbracket, rel_offset, - rel_regtype_str, rel_swizzle, rel_rbracket, swiz_str, - postmod_str); - // !!! FIXME: make sure the scratch buffer was large enough. - return buf; -} // make_GLSL_srcarg_string - -// generate some convenience functions. -#define MAKE_GLSL_SRCARG_STRING_(mask, bitmask) \ - static inline const char *make_GLSL_srcarg_string_##mask(Context *ctx, \ - const size_t idx, char *buf, \ - const size_t buflen) { \ - return make_GLSL_srcarg_string(ctx, idx, bitmask, buf, buflen); \ - } -MAKE_GLSL_SRCARG_STRING_(x, (1 << 0)) -MAKE_GLSL_SRCARG_STRING_(y, (1 << 1)) -MAKE_GLSL_SRCARG_STRING_(z, (1 << 2)) -MAKE_GLSL_SRCARG_STRING_(w, (1 << 3)) -MAKE_GLSL_SRCARG_STRING_(scalar, (1 << 0)) -MAKE_GLSL_SRCARG_STRING_(full, 0xF) -MAKE_GLSL_SRCARG_STRING_(masked, ctx->dest_arg.writemask) -MAKE_GLSL_SRCARG_STRING_(vec3, 0x7) -MAKE_GLSL_SRCARG_STRING_(vec2, 0x3) -#undef MAKE_GLSL_SRCARG_STRING_ - -// special cases for comparison opcodes... - -static const char *get_GLSL_comparison_string_scalar(Context *ctx) -{ - static const char *comps[] = { "", ">", "==", ">=", "<", "!=", "<=" }; - if (ctx->instruction_controls >= STATICARRAYLEN(comps)) - { - fail(ctx, "unknown comparison control"); - return ""; - } // if - - return comps[ctx->instruction_controls]; -} // get_GLSL_comparison_string_scalar - -static const char *get_GLSL_comparison_string_vector(Context *ctx) -{ - static const char *comps[] = { - "", "greaterThan", "equal", "greaterThanEqual", "lessThan", - "notEqual", "lessThanEqual" - }; - - if (ctx->instruction_controls >= STATICARRAYLEN(comps)) - { - fail(ctx, "unknown comparison control"); - return ""; - } // if - - return comps[ctx->instruction_controls]; -} // get_GLSL_comparison_string_vector - - -static void emit_GLSL_start(Context *ctx, const char *profilestr) -{ - if (!shader_is_vertex(ctx) && !shader_is_pixel(ctx)) - { - failf(ctx, "Shader type %u unsupported in this profile.", - (uint) ctx->shader_type); - return; - } // if - - else if (strcmp(profilestr, MOJOSHADER_PROFILE_GLSL) == 0) - { - // No gl_FragData[] before GLSL 1.10, so we have to force the version. - push_output(ctx, &ctx->preflight); - output_line(ctx, "#version 110"); - pop_output(ctx); - } // else if - - #if SUPPORT_PROFILE_GLSL120 - else if (strcmp(profilestr, MOJOSHADER_PROFILE_GLSL120) == 0) - { - ctx->profile_supports_glsl120 = 1; - push_output(ctx, &ctx->preflight); - output_line(ctx, "#version 120"); - pop_output(ctx); - } // else if - #endif - - else - { - failf(ctx, "Profile '%s' unsupported or unknown.", profilestr); - return; - } // else - - push_output(ctx, &ctx->mainline_intro); - output_line(ctx, "void main()"); - output_line(ctx, "{"); - pop_output(ctx); - - set_output(ctx, &ctx->mainline); - ctx->indent++; -} // emit_GLSL_start - -static void emit_GLSL_RET(Context *ctx); -static void emit_GLSL_end(Context *ctx) -{ - // force a RET opcode if we're at the end of the stream without one. - if (ctx->previous_opcode != OPCODE_RET) - emit_GLSL_RET(ctx); -} // emit_GLSL_end - -static void emit_GLSL_phase(Context *ctx) -{ - // no-op in GLSL. -} // emit_GLSL_phase - -static void output_GLSL_uniform_array(Context *ctx, const RegisterType regtype, - const int size) -{ - if (size > 0) - { - char buf[64]; - get_GLSL_uniform_array_varname(ctx, regtype, buf, sizeof (buf)); - output_line(ctx, "uniform vec4 %s[%d];", buf, size); - } // if -} // output_GLSL_uniform_array - -static void emit_GLSL_finalize(Context *ctx) -{ - // throw some blank lines around to make source more readable. - push_output(ctx, &ctx->globals); - output_blank_line(ctx); - pop_output(ctx); - - // If we had a relative addressing of REG_TYPE_INPUT, we need to build - // an array for it at the start of main(). GLSL doesn't let you specify - // arrays of attributes. - //vec4 blah_array[BIGGEST_ARRAY]; - if (ctx->have_relative_input_registers) // !!! FIXME - fail(ctx, "Relative addressing of input registers not supported."); - - push_output(ctx, &ctx->preflight); - output_GLSL_uniform_array(ctx, REG_TYPE_CONST, ctx->uniform_float4_count); - output_GLSL_uniform_array(ctx, REG_TYPE_CONSTINT, ctx->uniform_int4_count); - output_GLSL_uniform_array(ctx, REG_TYPE_CONSTBOOL, ctx->uniform_bool_count); - pop_output(ctx); -} // emit_GLSL_finalize - -static void emit_GLSL_global(Context *ctx, RegisterType regtype, int regnum) -{ - char varname[64]; - get_GLSL_varname_in_buf(ctx, regtype, regnum, varname, sizeof (varname)); - - push_output(ctx, &ctx->globals); - switch (regtype) - { - case REG_TYPE_ADDRESS: - output_line(ctx, "ivec4 %s;", varname); - break; - case REG_TYPE_PREDICATE: - output_line(ctx, "bvec4 %s;", varname); - break; - case REG_TYPE_TEMP: - output_line(ctx, "vec4 %s;", varname); - break; - case REG_TYPE_LOOP: - break; // no-op. We declare these in for loops at the moment. - case REG_TYPE_LABEL: - break; // no-op. If we see it here, it means we optimized it out. - default: - fail(ctx, "BUG: we used a register we don't know how to define."); - break; - } // switch - pop_output(ctx); -} // emit_GLSL_global - -static void emit_GLSL_array(Context *ctx, VariableList *var) -{ - // All uniforms (except constant arrays, which only get pushed once at - // compile time) are now packed into a single array, so we can batch - // the uniform transfers. So this is doesn't actually define an array - // here; the one, big array is emitted during finalization instead. - // However, we need to #define the offset into the one, big array here, - // and let dereferences use that #define. - const int base = var->index; - const int glslbase = ctx->uniform_float4_count; - push_output(ctx, &ctx->globals); - output_line(ctx, "#define ARRAYBASE_%d %d", base, glslbase); - pop_output(ctx); - var->emit_position = glslbase; -} // emit_GLSL_array - -static void emit_GLSL_const_array(Context *ctx, const ConstantsList *clist, - int base, int size) -{ - char varname[64]; - get_GLSL_const_array_varname_in_buf(ctx,base,size,varname,sizeof(varname)); - -#if 0 - // !!! FIXME: fails on Nvidia's and Apple's GL, even with #version 120. - // !!! FIXME: (the 1.20 spec says it should work, though, I think...) - if (support_glsl120(ctx)) - { - // GLSL 1.20 can do constant arrays. - const char *cstr = NULL; - push_output(ctx, &ctx->globals); - output_line(ctx, "const vec4 %s[%d] = vec4[%d](", varname, size, size); - ctx->indent++; - - int i; - for (i = 0; i < size; i++) - { - while (clist->constant.type != MOJOSHADER_UNIFORM_FLOAT) - clist = clist->next; - assert(clist->constant.index == (base + i)); - - char val0[32]; - char val1[32]; - char val2[32]; - char val3[32]; - floatstr(ctx, val0, sizeof (val0), clist->constant.value.f[0], 1); - floatstr(ctx, val1, sizeof (val1), clist->constant.value.f[1], 1); - floatstr(ctx, val2, sizeof (val2), clist->constant.value.f[2], 1); - floatstr(ctx, val3, sizeof (val3), clist->constant.value.f[3], 1); - - output_line(ctx, "vec4(%s, %s, %s, %s)%s", val0, val1, val2, val3, - (i < (size-1)) ? "," : ""); - - clist = clist->next; - } // for - - ctx->indent--; - output_line(ctx, ");"); - pop_output(ctx); - } // if - - else -#endif - { - // stock GLSL 1.0 can't do constant arrays, so make a uniform array - // and have the OpenGL glue assign it at link time. Lame! - push_output(ctx, &ctx->globals); - output_line(ctx, "uniform vec4 %s[%d];", varname, size); - pop_output(ctx); - } // else -} // emit_GLSL_const_array - -static void emit_GLSL_uniform(Context *ctx, RegisterType regtype, int regnum, - const VariableList *var) -{ - // Now that we're pushing all the uniforms as one big array, pack these - // down, so if we only use register c439, it'll actually map to - // glsl_uniforms_vec4[0]. As we push one big array, this will prevent - // uploading unused data. - - char varname[64]; - char name[64]; - int index = 0; - - get_GLSL_varname_in_buf(ctx, regtype, regnum, varname, sizeof (varname)); - - push_output(ctx, &ctx->globals); - - if (var == NULL) - { - get_GLSL_uniform_array_varname(ctx, regtype, name, sizeof (name)); - - if (regtype == REG_TYPE_CONST) - index = ctx->uniform_float4_count; - else if (regtype == REG_TYPE_CONSTINT) - index = ctx->uniform_int4_count; - else if (regtype == REG_TYPE_CONSTBOOL) - index = ctx->uniform_bool_count; - else // get_GLSL_uniform_array_varname() would have called fail(). - assert(isfail(ctx)); - - output_line(ctx, "#define %s %s[%d]", varname, name, index); - } // if - - else - { - const int arraybase = var->index; - if (var->constant) - { - get_GLSL_const_array_varname_in_buf(ctx, arraybase, var->count, - name, sizeof (name)); - index = (regnum - arraybase); - } // if - else - { - assert(var->emit_position != -1); - get_GLSL_uniform_array_varname(ctx, regtype, name, sizeof (name)); - index = (regnum - arraybase) + var->emit_position; - } // else - - output_line(ctx, "#define %s %s[%d]", varname, name, index); - } // else - - pop_output(ctx); -} // emit_GLSL_uniform - -static void emit_GLSL_sampler(Context *ctx, int stage, TextureType ttype) -{ - const char *type = ""; - switch (ttype) - { - case TEXTURE_TYPE_2D: type = "sampler2D"; break; - case TEXTURE_TYPE_CUBE: type = "samplerCube"; break; - case TEXTURE_TYPE_VOLUME: type = "sampler3D"; break; - default: fail(ctx, "BUG: used a sampler we don't know how to define."); - } // switch - - char var[64]; - get_GLSL_varname_in_buf(ctx, REG_TYPE_SAMPLER, stage, var, sizeof (var)); - - push_output(ctx, &ctx->globals); - output_line(ctx, "uniform %s %s;", type, var); - pop_output(ctx); -} // emit_GLSL_sampler - -static void emit_GLSL_attribute(Context *ctx, RegisterType regtype, int regnum, - MOJOSHADER_usage usage, int index, int wmask, - int flags) -{ - // !!! FIXME: this function doesn't deal with write masks at all yet! - const char *usage_str = NULL; - const char *arrayleft = ""; - const char *arrayright = ""; - char index_str[16] = { '\0' }; - char var[64]; - - get_GLSL_varname_in_buf(ctx, regtype, regnum, var, sizeof (var)); - - //assert((flags & MOD_PP) == 0); // !!! FIXME: is PP allowed? - - if (index != 0) // !!! FIXME: a lot of these MUST be zero. - snprintf(index_str, sizeof (index_str), "%u", (uint) index); - - if (shader_is_vertex(ctx)) - { - // pre-vs3 output registers. - // these don't ever happen in DCL opcodes, I think. Map to vs_3_* - // output registers. - if (!shader_version_atleast(ctx, 3, 0)) - { - if (regtype == REG_TYPE_RASTOUT) - { - regtype = REG_TYPE_OUTPUT; - index = regnum; - switch ((const RastOutType) regnum) - { - case RASTOUT_TYPE_POSITION: - usage = MOJOSHADER_USAGE_POSITION; - break; - case RASTOUT_TYPE_FOG: - usage = MOJOSHADER_USAGE_FOG; - break; - case RASTOUT_TYPE_POINT_SIZE: - usage = MOJOSHADER_USAGE_POINTSIZE; - break; - } // switch - } // if - - else if (regtype == REG_TYPE_ATTROUT) - { - regtype = REG_TYPE_OUTPUT; - usage = MOJOSHADER_USAGE_COLOR; - index = regnum; - } // else if - - else if (regtype == REG_TYPE_TEXCRDOUT) - { - regtype = REG_TYPE_OUTPUT; - usage = MOJOSHADER_USAGE_TEXCOORD; - index = regnum; - } // else if - } // if - - // to avoid limitations of various GL entry points for input - // attributes (glSecondaryColorPointer() can only take 3 component - // items, glVertexPointer() can't do GL_UNSIGNED_BYTE, many other - // issues), we set up all inputs as generic vertex attributes, so we - // can pass data in just about any form, and ignore the built-in GLSL - // attributes like gl_SecondaryColor. Output needs to use the the - // built-ins, though, but we don't have to worry about the GL entry - // point limitations there. - - if (regtype == REG_TYPE_INPUT) - { - push_output(ctx, &ctx->globals); - output_line(ctx, "attribute vec4 %s;", var); - pop_output(ctx); - } // if - - else if (regtype == REG_TYPE_OUTPUT) - { - switch (usage) - { - case MOJOSHADER_USAGE_POSITION: - usage_str = "gl_Position"; - break; - case MOJOSHADER_USAGE_POINTSIZE: - usage_str = "gl_PointSize"; - break; - case MOJOSHADER_USAGE_COLOR: - index_str[0] = '\0'; // no explicit number. - if (index == 0) - usage_str = "gl_FrontColor"; - else if (index == 1) - usage_str = "gl_FrontSecondaryColor"; - break; - case MOJOSHADER_USAGE_FOG: - usage_str = "gl_FogFragCoord"; - break; - case MOJOSHADER_USAGE_TEXCOORD: - snprintf(index_str, sizeof (index_str), "%u", (uint) index); - usage_str = "gl_TexCoord"; - arrayleft = "["; - arrayright = "]"; - break; - default: - // !!! FIXME: we need to deal with some more built-in varyings here. - break; - } // switch - - // !!! FIXME: the #define is a little hacky, but it means we don't - // !!! FIXME: have to track these separately if this works. - push_output(ctx, &ctx->globals); - // no mapping to built-in var? Just make it a regular global, pray. - if (usage_str == NULL) - output_line(ctx, "vec4 %s;", var); - else - { - output_line(ctx, "#define %s %s%s%s%s", var, usage_str, - arrayleft, index_str, arrayright); - } // else - pop_output(ctx); - } // else if - - else - { - fail(ctx, "unknown vertex shader attribute register"); - } // else - } // if - - else if (shader_is_pixel(ctx)) - { - // samplers DCLs get handled in emit_GLSL_sampler(). - - if (flags & MOD_CENTROID) // !!! FIXME - { - failf(ctx, "centroid unsupported in %s profile", ctx->profile->name); - return; - } // if - - if (regtype == REG_TYPE_COLOROUT) - { - if (!ctx->have_multi_color_outputs) - usage_str = "gl_FragColor"; // maybe faster? - else - { - snprintf(index_str, sizeof (index_str), "%u", (uint) regnum); - usage_str = "gl_FragData"; - arrayleft = "["; - arrayright = "]"; - } // else - } // if - - else if (regtype == REG_TYPE_DEPTHOUT) - usage_str = "gl_FragDepth"; - - // !!! FIXME: can you actualy have a texture register with COLOR usage? - else if ((regtype == REG_TYPE_TEXTURE) || (regtype == REG_TYPE_INPUT)) - { - if (usage == MOJOSHADER_USAGE_TEXCOORD) - { - snprintf(index_str, sizeof (index_str), "%u", (uint) index); - usage_str = "gl_TexCoord"; - arrayleft = "["; - arrayright = "]"; - } // if - - else if (usage == MOJOSHADER_USAGE_COLOR) - { - index_str[0] = '\0'; // no explicit number. - if (index == 0) - usage_str = "gl_Color"; - else if (index == 1) - usage_str = "gl_SecondaryColor"; - else - fail(ctx, "unsupported color index"); - } // else if - } // else if - - else if (regtype == REG_TYPE_MISCTYPE) - { - const MiscTypeType mt = (MiscTypeType) regnum; - if (mt == MISCTYPE_TYPE_FACE) - { - push_output(ctx, &ctx->globals); - output_line(ctx, "float %s = gl_FrontFacing ? 1.0 : -1.0;", var); - pop_output(ctx); - } // if - else if (mt == MISCTYPE_TYPE_POSITION) - { - index_str[0] = '\0'; // no explicit number. - usage_str = "gl_FragCoord"; // !!! FIXME: is this the same coord space as D3D? - } // else if - else - { - fail(ctx, "BUG: unhandled misc register"); - } // else - } // else if - - else - { - fail(ctx, "unknown pixel shader attribute register"); - } // else - - if (usage_str != NULL) - { - push_output(ctx, &ctx->globals); - output_line(ctx, "#define %s %s%s%s%s", var, usage_str, - arrayleft, index_str, arrayright); - pop_output(ctx); - } // if - } // else if - - else - { - fail(ctx, "Unknown shader type"); // state machine should catch this. - } // else -} // emit_GLSL_attribute - -static void emit_GLSL_NOP(Context *ctx) -{ - // no-op is a no-op. :) -} // emit_GLSL_NOP - -static void emit_GLSL_MOV(Context *ctx) -{ - char src0[64]; make_GLSL_srcarg_string_masked(ctx, 0, src0, sizeof (src0)); - char code[128]; - make_GLSL_destarg_assign(ctx, code, sizeof (code), "%s", src0); - output_line(ctx, "%s", code); -} // emit_GLSL_MOV - -static void emit_GLSL_ADD(Context *ctx) -{ - char src0[64]; make_GLSL_srcarg_string_masked(ctx, 0, src0, sizeof (src0)); - char src1[64]; make_GLSL_srcarg_string_masked(ctx, 1, src1, sizeof (src1)); - char code[128]; - make_GLSL_destarg_assign(ctx, code, sizeof (code), "%s + %s", src0, src1); - output_line(ctx, "%s", code); -} // emit_GLSL_ADD - -static void emit_GLSL_SUB(Context *ctx) -{ - char src0[64]; make_GLSL_srcarg_string_masked(ctx, 0, src0, sizeof (src0)); - char src1[64]; make_GLSL_srcarg_string_masked(ctx, 1, src1, sizeof (src1)); - char code[128]; - make_GLSL_destarg_assign(ctx, code, sizeof (code), "%s - %s", src0, src1); - output_line(ctx, "%s", code); -} // emit_GLSL_SUB - -static void emit_GLSL_MAD(Context *ctx) -{ - char src0[64]; make_GLSL_srcarg_string_masked(ctx, 0, src0, sizeof (src0)); - char src1[64]; make_GLSL_srcarg_string_masked(ctx, 1, src1, sizeof (src1)); - char src2[64]; make_GLSL_srcarg_string_masked(ctx, 2, src2, sizeof (src2)); - char code[128]; - make_GLSL_destarg_assign(ctx, code, sizeof (code), "(%s * %s) + %s", src0, src1, src2); - output_line(ctx, "%s", code); -} // emit_GLSL_MAD - -static void emit_GLSL_MUL(Context *ctx) -{ - char src0[64]; make_GLSL_srcarg_string_masked(ctx, 0, src0, sizeof (src0)); - char src1[64]; make_GLSL_srcarg_string_masked(ctx, 1, src1, sizeof (src1)); - char code[128]; - make_GLSL_destarg_assign(ctx, code, sizeof (code), "%s * %s", src0, src1); - output_line(ctx, "%s", code); -} // emit_GLSL_MUL - -static void emit_GLSL_RCP(Context *ctx) -{ - char src0[64]; make_GLSL_srcarg_string_masked(ctx, 0, src0, sizeof (src0)); - char code[128]; - make_GLSL_destarg_assign(ctx, code, sizeof (code), "1.0 / %s", src0); - output_line(ctx, "%s", code); -} // emit_GLSL_RCP - -static void emit_GLSL_RSQ(Context *ctx) -{ - char src0[64]; make_GLSL_srcarg_string_masked(ctx, 0, src0, sizeof (src0)); - char code[128]; - make_GLSL_destarg_assign(ctx, code, sizeof (code), "inversesqrt(%s)", src0); - output_line(ctx, "%s", code); -} // emit_GLSL_RSQ - -static void emit_GLSL_dotprod(Context *ctx, const char *src0, const char *src1, - const char *extra) -{ - const int vecsize = vecsize_from_writemask(ctx->dest_arg.writemask); - char castleft[16] = { '\0' }; - const char *castright = ""; - if (vecsize != 1) - { - snprintf(castleft, sizeof (castleft), "vec%d(", vecsize); - castright = ")"; - } // if - - char code[128]; - make_GLSL_destarg_assign(ctx, code, sizeof (code), "%sdot(%s, %s)%s%s", - castleft, src0, src1, extra, castright); - output_line(ctx, "%s", code); -} // emit_GLSL_dotprod - -static void emit_GLSL_DP3(Context *ctx) -{ - char src0[64]; make_GLSL_srcarg_string_vec3(ctx, 0, src0, sizeof (src0)); - char src1[64]; make_GLSL_srcarg_string_vec3(ctx, 1, src1, sizeof (src1)); - emit_GLSL_dotprod(ctx, src0, src1, ""); -} // emit_GLSL_DP3 - -static void emit_GLSL_DP4(Context *ctx) -{ - char src0[64]; make_GLSL_srcarg_string_full(ctx, 0, src0, sizeof (src0)); - char src1[64]; make_GLSL_srcarg_string_full(ctx, 1, src1, sizeof (src1)); - emit_GLSL_dotprod(ctx, src0, src1, ""); -} // emit_GLSL_DP4 - -static void emit_GLSL_MIN(Context *ctx) -{ - char src0[64]; make_GLSL_srcarg_string_masked(ctx, 0, src0, sizeof (src0)); - char src1[64]; make_GLSL_srcarg_string_masked(ctx, 1, src1, sizeof (src1)); - char code[128]; - make_GLSL_destarg_assign(ctx, code, sizeof (code), "min(%s, %s)", src0, src1); - output_line(ctx, "%s", code); -} // emit_GLSL_MIN - -static void emit_GLSL_MAX(Context *ctx) -{ - char src0[64]; make_GLSL_srcarg_string_masked(ctx, 0, src0, sizeof (src0)); - char src1[64]; make_GLSL_srcarg_string_masked(ctx, 1, src1, sizeof (src1)); - char code[128]; - make_GLSL_destarg_assign(ctx, code, sizeof (code), "max(%s, %s)", src0, src1); - output_line(ctx, "%s", code); -} // emit_GLSL_MAX - -static void emit_GLSL_SLT(Context *ctx) -{ - const int vecsize = vecsize_from_writemask(ctx->dest_arg.writemask); - char src0[64]; make_GLSL_srcarg_string_masked(ctx, 0, src0, sizeof (src0)); - char src1[64]; make_GLSL_srcarg_string_masked(ctx, 1, src1, sizeof (src1)); - char code[128]; - - // float(bool) or vec(bvec) results in 0.0 or 1.0, like SLT wants. - if (vecsize == 1) - make_GLSL_destarg_assign(ctx, code, sizeof (code), "float(%s < %s)", src0, src1); - else - { - make_GLSL_destarg_assign(ctx, code, sizeof (code), - "vec%d(lessThan(%s, %s))", - vecsize, src0, src1); - } // else - output_line(ctx, "%s", code); -} // emit_GLSL_SLT - -static void emit_GLSL_SGE(Context *ctx) -{ - const int vecsize = vecsize_from_writemask(ctx->dest_arg.writemask); - char src0[64]; make_GLSL_srcarg_string_masked(ctx, 0, src0, sizeof (src0)); - char src1[64]; make_GLSL_srcarg_string_masked(ctx, 1, src1, sizeof (src1)); - char code[128]; - - // float(bool) or vec(bvec) results in 0.0 or 1.0, like SGE wants. - if (vecsize == 1) - { - make_GLSL_destarg_assign(ctx, code, sizeof (code), - "float(%s >= %s)", src0, src1); - } // if - else - { - make_GLSL_destarg_assign(ctx, code, sizeof (code), - "vec%d(greaterThanEqual(%s, %s))", - vecsize, src0, src1); - } // else - output_line(ctx, "%s", code); -} // emit_GLSL_SGE - -static void emit_GLSL_EXP(Context *ctx) -{ - char src0[64]; make_GLSL_srcarg_string_masked(ctx, 0, src0, sizeof (src0)); - char code[128]; - make_GLSL_destarg_assign(ctx, code, sizeof (code), "exp2(%s)", src0); - output_line(ctx, "%s", code); -} // emit_GLSL_EXP - -static void emit_GLSL_LOG(Context *ctx) -{ - char src0[64]; make_GLSL_srcarg_string_masked(ctx, 0, src0, sizeof (src0)); - char code[128]; - make_GLSL_destarg_assign(ctx, code, sizeof (code), "log2(%s)", src0); - output_line(ctx, "%s", code); -} // emit_GLSL_LOG - -static void emit_GLSL_LIT_helper(Context *ctx) -{ - const char *maxp = "127.9961f"; // value from the dx9 reference. - - if (ctx->glsl_generated_lit_opcode) - return; - - ctx->glsl_generated_lit_opcode = 1; - - push_output(ctx, &ctx->helpers); - output_line(ctx, "const vec4 LIT(const vec4 src)"); - output_line(ctx, "{"); ctx->indent++; - output_line(ctx, "const float power = clamp(src.w, -%s, %s);",maxp,maxp); - output_line(ctx, "vec4 retval(1.0, 0.0, 0.0, 1.0)"); - output_line(ctx, "if (src.x > 0.0) {"); ctx->indent++; - output_line(ctx, "retval.y = src.x;"); - output_line(ctx, "if (src.y > 0.0) {"); ctx->indent++; - output_line(ctx, "retval.z = pow(src.y, power);"); ctx->indent--; - output_line(ctx, "}"); ctx->indent--; - output_line(ctx, "}"); - output_line(ctx, "return retval;"); ctx->indent--; - output_line(ctx, "}"); - output_blank_line(ctx); - pop_output(ctx); -} // emit_GLSL_LIT_helper - -static void emit_GLSL_LIT(Context *ctx) -{ - char src0[64]; make_GLSL_srcarg_string_full(ctx, 0, src0, sizeof (src0)); - char code[128]; - make_GLSL_destarg_assign(ctx, code, sizeof (code), "LIT(%s)", src0); - output_line(ctx, "%s", code); - emit_GLSL_LIT_helper(ctx); -} // emit_GLSL_LIT - -static void emit_GLSL_DST(Context *ctx) -{ - // !!! FIXME: needs to take ctx->dst_arg.writemask into account. - char src0_y[64]; make_GLSL_srcarg_string_y(ctx, 0, src0_y, sizeof (src0_y)); - char src1_y[64]; make_GLSL_srcarg_string_y(ctx, 1, src1_y, sizeof (src1_y)); - char src0_z[64]; make_GLSL_srcarg_string_z(ctx, 0, src0_z, sizeof (src0_z)); - char src1_w[64]; make_GLSL_srcarg_string_w(ctx, 1, src1_w, sizeof (src1_w)); - - char code[128]; - make_GLSL_destarg_assign(ctx, code, sizeof (code), - "vec4(1.0, %s * %s, %s, %s)", - src0_y, src1_y, src0_z, src1_w); - output_line(ctx, "%s", code); -} // emit_GLSL_DST - -static void emit_GLSL_LRP(Context *ctx) -{ - char src0[64]; make_GLSL_srcarg_string_masked(ctx, 0, src0, sizeof (src0)); - char src1[64]; make_GLSL_srcarg_string_masked(ctx, 1, src1, sizeof (src1)); - char src2[64]; make_GLSL_srcarg_string_masked(ctx, 2, src2, sizeof (src2)); - char code[128]; - make_GLSL_destarg_assign(ctx, code, sizeof (code), "mix(%s, %s, %s)", - src2, src1, src0); - output_line(ctx, "%s", code); -} // emit_GLSL_LRP - -static void emit_GLSL_FRC(Context *ctx) -{ - char src0[64]; make_GLSL_srcarg_string_masked(ctx, 0, src0, sizeof (src0)); - char code[128]; - make_GLSL_destarg_assign(ctx, code, sizeof (code), "fract(%s)", src0); - output_line(ctx, "%s", code); -} // emit_GLSL_FRC - -static void emit_GLSL_M4X4(Context *ctx) -{ - // !!! FIXME: d3d is row-major, glsl is column-major, I think. - char src0[64]; make_GLSL_srcarg_string_full(ctx, 0, src0, sizeof (src0)); - char row0[64]; make_GLSL_srcarg_string_full(ctx, 1, row0, sizeof (row0)); - char row1[64]; make_GLSL_srcarg_string_full(ctx, 2, row1, sizeof (row1)); - char row2[64]; make_GLSL_srcarg_string_full(ctx, 3, row2, sizeof (row2)); - char row3[64]; make_GLSL_srcarg_string_full(ctx, 4, row3, sizeof (row3)); - char code[128]; - make_GLSL_destarg_assign(ctx, code, sizeof (code), - "vec4(dot(%s, %s), dot(%s, %s), dot(%s, %s), dot(%s, %s))", - src0, row0, src0, row1, src0, row2, src0, row3); - output_line(ctx, "%s", code); -} // emit_GLSL_M4X4 - -static void emit_GLSL_M4X3(Context *ctx) -{ - // !!! FIXME: d3d is row-major, glsl is column-major, I think. - char src0[64]; make_GLSL_srcarg_string_full(ctx, 0, src0, sizeof (src0)); - char row0[64]; make_GLSL_srcarg_string_full(ctx, 1, row0, sizeof (row0)); - char row1[64]; make_GLSL_srcarg_string_full(ctx, 2, row1, sizeof (row1)); - char row2[64]; make_GLSL_srcarg_string_full(ctx, 3, row2, sizeof (row2)); - char code[128]; - make_GLSL_destarg_assign(ctx, code, sizeof (code), - "vec3(dot(%s, %s), dot(%s, %s), dot(%s, %s))", - src0, row0, src0, row1, src0, row2); - output_line(ctx, "%s", code); -} // emit_GLSL_M4X3 - -static void emit_GLSL_M3X4(Context *ctx) -{ - // !!! FIXME: d3d is row-major, glsl is column-major, I think. - char src0[64]; make_GLSL_srcarg_string_vec3(ctx, 0, src0, sizeof (src0)); - char row0[64]; make_GLSL_srcarg_string_vec3(ctx, 1, row0, sizeof (row0)); - char row1[64]; make_GLSL_srcarg_string_vec3(ctx, 2, row1, sizeof (row1)); - char row2[64]; make_GLSL_srcarg_string_vec3(ctx, 3, row2, sizeof (row2)); - char row3[64]; make_GLSL_srcarg_string_vec3(ctx, 4, row3, sizeof (row3)); - - char code[128]; - make_GLSL_destarg_assign(ctx, code, sizeof (code), - "vec4(dot(%s, %s), dot(%s, %s), " - "dot(%s, %s), dot(%s, %s))", - src0, row0, src0, row1, - src0, row2, src0, row3); - output_line(ctx, "%s", code); -} // emit_GLSL_M3X4 - -static void emit_GLSL_M3X3(Context *ctx) -{ - // !!! FIXME: d3d is row-major, glsl is column-major, I think. - char src0[64]; make_GLSL_srcarg_string_vec3(ctx, 0, src0, sizeof (src0)); - char row0[64]; make_GLSL_srcarg_string_vec3(ctx, 1, row0, sizeof (row0)); - char row1[64]; make_GLSL_srcarg_string_vec3(ctx, 2, row1, sizeof (row1)); - char row2[64]; make_GLSL_srcarg_string_vec3(ctx, 3, row2, sizeof (row2)); - char code[128]; - make_GLSL_destarg_assign(ctx, code, sizeof (code), - "vec3(dot(%s, %s), dot(%s, %s), dot(%s, %s))", - src0, row0, src0, row1, src0, row2); - output_line(ctx, "%s", code); -} // emit_GLSL_M3X3 - -static void emit_GLSL_M3X2(Context *ctx) -{ - // !!! FIXME: d3d is row-major, glsl is column-major, I think. - char src0[64]; make_GLSL_srcarg_string_vec3(ctx, 0, src0, sizeof (src0)); - char row0[64]; make_GLSL_srcarg_string_vec3(ctx, 1, row0, sizeof (row0)); - char row1[64]; make_GLSL_srcarg_string_vec3(ctx, 2, row1, sizeof (row1)); - - char code[128]; - make_GLSL_destarg_assign(ctx, code, sizeof (code), - "vec2(dot(%s, %s), dot(%s, %s))", - src0, row0, src0, row1); - output_line(ctx, "%s", code); -} // emit_GLSL_M3X2 - -static void emit_GLSL_CALL(Context *ctx) -{ - char src0[64]; make_GLSL_srcarg_string_masked(ctx, 0, src0, sizeof (src0)); - if (ctx->loops > 0) - output_line(ctx, "%s(aL);", src0); - else - output_line(ctx, "%s();", src0); -} // emit_GLSL_CALL - -static void emit_GLSL_CALLNZ(Context *ctx) -{ - // !!! FIXME: if src1 is a constbool that's true, we can remove the - // !!! FIXME: if. If it's false, we can make this a no-op. - char src0[64]; make_GLSL_srcarg_string_masked(ctx, 0, src0, sizeof (src0)); - char src1[64]; make_GLSL_srcarg_string_masked(ctx, 1, src1, sizeof (src1)); - - if (ctx->loops > 0) - output_line(ctx, "if (%s) { %s(aL); }", src1, src0); - else - output_line(ctx, "if (%s) { %s(); }", src1, src0); -} // emit_GLSL_CALLNZ - -static void emit_GLSL_LOOP(Context *ctx) -{ - // !!! FIXME: swizzle? - char var[64]; get_GLSL_srcarg_varname(ctx, 1, var, sizeof (var)); - assert(ctx->source_args[0].regnum == 0); // in case they add aL1 someday. - output_line(ctx, "{"); - ctx->indent++; - output_line(ctx, "const int aLend = %s.x + %s.y;", var, var); - output_line(ctx, "for (int aL = %s.y; aL < aLend; aL += %s.z) {", var, var); - ctx->indent++; -} // emit_GLSL_LOOP - -static void emit_GLSL_RET(Context *ctx) -{ - // thankfully, the MSDN specs say a RET _has_ to end a function...no - // early returns. So if you hit one, you know you can safely close - // a high-level function. - ctx->indent--; - output_line(ctx, "}"); - output_blank_line(ctx); - set_output(ctx, &ctx->subroutines); -} // emit_GLSL_RET - -static void emit_GLSL_ENDLOOP(Context *ctx) -{ - ctx->indent--; - output_line(ctx, "}"); - ctx->indent--; - output_line(ctx, "}"); -} // emit_GLSL_ENDLOOP - -static void emit_GLSL_LABEL(Context *ctx) -{ - char src0[64]; make_GLSL_srcarg_string_masked(ctx, 0, src0, sizeof (src0)); - const int label = ctx->source_args[0].regnum; - RegisterList *reg = reglist_find(&ctx->used_registers, REG_TYPE_LABEL, label); - assert(ctx->output == ctx->subroutines); // not mainline, etc. - assert(ctx->indent == 0); // we shouldn't be in the middle of a function. - - // MSDN specs say CALL* has to come before the LABEL, so we know if we - // can ditch the entire function here as unused. - if (reg == NULL) - set_output(ctx, &ctx->ignore); // Func not used. Parse, but don't output. - - // !!! FIXME: it would be nice if we could determine if a function is - // !!! FIXME: only called once and, if so, forcibly inline it. - - const char *uses_loopreg = ((reg) && (reg->misc == 1)) ? "int aL" : ""; - output_line(ctx, "void %s(%s)", src0, uses_loopreg); - output_line(ctx, "{"); - ctx->indent++; -} // emit_GLSL_LABEL - -static void emit_GLSL_DCL(Context *ctx) -{ - // no-op. We do this in our emit_attribute() and emit_uniform(). -} // emit_GLSL_DCL - -static void emit_GLSL_POW(Context *ctx) -{ - char src0[64]; make_GLSL_srcarg_string_masked(ctx, 0, src0, sizeof (src0)); - char src1[64]; make_GLSL_srcarg_string_masked(ctx, 1, src1, sizeof (src1)); - char code[128]; - make_GLSL_destarg_assign(ctx, code, sizeof (code), - "pow(abs(%s), %s)", src0, src1); - output_line(ctx, "%s", code); -} // emit_GLSL_POW - -static void emit_GLSL_CRS(Context *ctx) -{ - // !!! FIXME: needs to take ctx->dst_arg.writemask into account. - char src0[64]; make_GLSL_srcarg_string_vec3(ctx, 0, src0, sizeof (src0)); - char src1[64]; make_GLSL_srcarg_string_vec3(ctx, 1, src1, sizeof (src1)); - char code[128]; - make_GLSL_destarg_assign(ctx, code, sizeof (code), - "cross(%s, %s)", src0, src1); - output_line(ctx, "%s", code); -} // emit_GLSL_CRS - -static void emit_GLSL_SGN(Context *ctx) -{ - // (we don't need the temporary registers specified for the D3D opcode.) - char src0[64]; make_GLSL_srcarg_string_masked(ctx, 0, src0, sizeof (src0)); - char code[128]; - make_GLSL_destarg_assign(ctx, code, sizeof (code), "sign(%s)", src0); - output_line(ctx, "%s", code); -} // emit_GLSL_SGN - -static void emit_GLSL_ABS(Context *ctx) -{ - char src0[64]; make_GLSL_srcarg_string_masked(ctx, 0, src0, sizeof (src0)); - char code[128]; - make_GLSL_destarg_assign(ctx, code, sizeof (code), "abs(%s)", src0); - output_line(ctx, "%s", code); -} // emit_GLSL_ABS - -static void emit_GLSL_NRM(Context *ctx) -{ - char src0[64]; make_GLSL_srcarg_string_masked(ctx, 0, src0, sizeof (src0)); - char code[128]; - make_GLSL_destarg_assign(ctx, code, sizeof (code), "normalize(%s)", src0); - output_line(ctx, "%s", code); -} // emit_GLSL_NRM - -static void emit_GLSL_SINCOS(Context *ctx) -{ - // we don't care about the temp registers that <= sm2 demands; ignore them. - // sm2 also talks about what components are left untouched vs. undefined, - // but we just leave those all untouched with GLSL write masks (which - // would fulfill the "undefined" requirement, too). - const int mask = ctx->dest_arg.writemask; - char src0[64]; make_GLSL_srcarg_string_scalar(ctx, 0, src0, sizeof (src0)); - char code[128] = { '\0' }; - - if (writemask_x(mask)) - make_GLSL_destarg_assign(ctx, code, sizeof (code), "cos(%s)", src0); - else if (writemask_y(mask)) - make_GLSL_destarg_assign(ctx, code, sizeof (code), "sin(%s)", src0); - else if (writemask_xy(mask)) - { - make_GLSL_destarg_assign(ctx, code, sizeof (code), - "vec2(cos(%s), sin(%s))", src0, src0); - } // else if - - output_line(ctx, "%s", code); -} // emit_GLSL_SINCOS - -static void emit_GLSL_REP(Context *ctx) -{ - // !!! FIXME: - // msdn docs say legal loop values are 0 to 255. We can check DEFI values - // at parse time, but if they are pulling a value from a uniform, do - // we clamp here? - // !!! FIXME: swizzle is legal here, right? - char src0[64]; make_GLSL_srcarg_string_x(ctx, 0, src0, sizeof (src0)); - const uint rep = (uint) ctx->reps; - output_line(ctx, "for (int rep%u = 0; rep%u < %s; rep%u++) {", - rep, rep, src0, rep); - ctx->indent++; -} // emit_GLSL_REP - -static void emit_GLSL_ENDREP(Context *ctx) -{ - ctx->indent--; - output_line(ctx, "}"); -} // emit_GLSL_ENDREP - -static void emit_GLSL_IF(Context *ctx) -{ - char src0[64]; make_GLSL_srcarg_string_scalar(ctx, 0, src0, sizeof (src0)); - output_line(ctx, "if (%s) {", src0); - ctx->indent++; -} // emit_GLSL_IF - -static void emit_GLSL_IFC(Context *ctx) -{ - const char *comp = get_GLSL_comparison_string_scalar(ctx); - char src0[64]; make_GLSL_srcarg_string_scalar(ctx, 0, src0, sizeof (src0)); - char src1[64]; make_GLSL_srcarg_string_scalar(ctx, 1, src1, sizeof (src1)); - output_line(ctx, "if (%s %s %s) {", src0, comp, src1); - ctx->indent++; -} // emit_GLSL_IFC - -static void emit_GLSL_ELSE(Context *ctx) -{ - ctx->indent--; - output_line(ctx, "} else {"); - ctx->indent++; -} // emit_GLSL_ELSE - -static void emit_GLSL_ENDIF(Context *ctx) -{ - ctx->indent--; - output_line(ctx, "}"); -} // emit_GLSL_ENDIF - -static void emit_GLSL_BREAK(Context *ctx) -{ - output_line(ctx, "break;"); -} // emit_GLSL_BREAK - -static void emit_GLSL_BREAKC(Context *ctx) -{ - const char *comp = get_GLSL_comparison_string_scalar(ctx); - char src0[64]; make_GLSL_srcarg_string_scalar(ctx, 0, src0, sizeof (src0)); - char src1[64]; make_GLSL_srcarg_string_scalar(ctx, 1, src1, sizeof (src1)); - output_line(ctx, "if (%s %s %s) { break; }", src0, comp, src1); -} // emit_GLSL_BREAKC - -static void emit_GLSL_MOVA(Context *ctx) -{ - const int vecsize = vecsize_from_writemask(ctx->dest_arg.writemask); - char src0[64]; make_GLSL_srcarg_string_masked(ctx, 0, src0, sizeof (src0)); - char code[128]; - - if (vecsize == 1) - { - make_GLSL_destarg_assign(ctx, code, sizeof (code), - "int(floor(abs(%s) + 0.5) * sign(%s))", - src0, src0); - } // if - - else - { - make_GLSL_destarg_assign(ctx, code, sizeof (code), - "ivec%d(floor(abs(%s) + vec%d(0.5)) * sign(%s))", - vecsize, src0, vecsize, src0); - } // else - - output_line(ctx, "%s", code); -} // emit_GLSL_MOVA - -static void emit_GLSL_DEFB(Context *ctx) -{ - char varname[64]; get_GLSL_destarg_varname(ctx, varname, sizeof (varname)); - push_output(ctx, &ctx->globals); - output_line(ctx, "const bool %s = %s;", - varname, ctx->dwords[0] ? "true" : "false"); - pop_output(ctx); -} // emit_GLSL_DEFB - -static void emit_GLSL_DEFI(Context *ctx) -{ - char varname[64]; get_GLSL_destarg_varname(ctx, varname, sizeof (varname)); - const int32 *x = (const int32 *) ctx->dwords; - push_output(ctx, &ctx->globals); - output_line(ctx, "const ivec4 %s = ivec4(%d, %d, %d, %d);", - varname, (int) x[0], (int) x[1], (int) x[2], (int) x[3]); - pop_output(ctx); -} // emit_GLSL_DEFI - -EMIT_GLSL_OPCODE_UNIMPLEMENTED_FUNC(TEXCRD) - -static void emit_GLSL_TEXKILL(Context *ctx) -{ - char dst[64]; get_GLSL_destarg_varname(ctx, dst, sizeof (dst)); - output_line(ctx, "if (any(lessThan(%s.xyz, vec3(0.0)))) discard;", dst); -} // emit_GLSL_TEXKILL - -static void glsl_texld(Context *ctx, const int texldd) -{ - // !!! FIXME: do non-RGBA textures map to same default values as D3D? - - if (!shader_version_atleast(ctx, 2, 0)) - { - // ps_1_0 and ps_1_4 are both different, too! - fail(ctx, "TEXLD <= Shader Model 2.0 unimplemented."); // !!! FIXME - return; - } // if - else - { - const SourceArgInfo *samp_arg = &ctx->source_args[1]; - RegisterList *sreg = reglist_find(&ctx->samplers, REG_TYPE_SAMPLER, - samp_arg->regnum); - const char *funcname = NULL; - char src0[64] = { '\0' }; - char src1[64]; get_GLSL_srcarg_varname(ctx, 1, src1, sizeof (src1)); // !!! FIXME: SRC_MOD? - char src2[64] = { '\0' }; - char src3[64] = { '\0' }; - - if (sreg == NULL) - { - fail(ctx, "TEXLD using undeclared sampler"); - return; - } // if - - if (texldd) - { - make_GLSL_srcarg_string_vec2(ctx, 2, src2, sizeof (src2)); - make_GLSL_srcarg_string_vec2(ctx, 3, src3, sizeof (src3)); - } // if - - // !!! FIXME: can TEXLDD set instruction_controls? - // !!! FIXME: does the d3d bias value map directly to GLSL? - const char *biassep = ""; - char bias[64] = { '\0' }; - if (ctx->instruction_controls == CONTROL_TEXLDB) - { - biassep = ", "; - make_GLSL_srcarg_string_w(ctx, 0, bias, sizeof (bias)); - } // if - - switch ((const TextureType) sreg->index) - { - case TEXTURE_TYPE_2D: - if (ctx->instruction_controls == CONTROL_TEXLDP) - { - funcname = "texture2DProj"; - make_GLSL_srcarg_string_full(ctx, 0, src0, sizeof (src0)); - } // if - else // texld/texldb - { - funcname = "texture2D"; - make_GLSL_srcarg_string_vec2(ctx, 0, src0, sizeof (src0)); - } // else - break; - case TEXTURE_TYPE_CUBE: - if (ctx->instruction_controls == CONTROL_TEXLDP) - fail(ctx, "TEXLDP on a cubemap"); // !!! FIXME: is this legal? - funcname = "textureCube"; - make_GLSL_srcarg_string_vec3(ctx, 0, src0, sizeof (src0)); - break; - case TEXTURE_TYPE_VOLUME: - if (ctx->instruction_controls == CONTROL_TEXLDP) - { - funcname = "texture3DProj"; - make_GLSL_srcarg_string_full(ctx, 0, src0, sizeof (src0)); - } // if - else // texld/texldb - { - funcname = "texture3D"; - make_GLSL_srcarg_string_vec3(ctx, 0, src0, sizeof (src0)); - } // else - break; - default: - fail(ctx, "unknown texture type"); - return; - } // switch - - assert(!isscalar(ctx, ctx->shader_type, samp_arg->regtype, samp_arg->regnum)); - char swiz_str[6] = { '\0' }; - make_GLSL_swizzle_string(swiz_str, sizeof (swiz_str), - samp_arg->swizzle, ctx->dest_arg.writemask); - - char code[128]; - if (texldd) - { - make_GLSL_destarg_assign(ctx, code, sizeof (code), - "%sGrad(%s, %s, %s, %s)%s", funcname, - src1, src0, src2, src3, swiz_str); - } // if - else - { - make_GLSL_destarg_assign(ctx, code, sizeof (code), - "%s(%s, %s%s%s)%s", funcname, - src1, src0, biassep, bias, swiz_str); - } // else - - output_line(ctx, "%s", code); - } // else -} // glsl_texld - -static void emit_GLSL_TEXLD(Context *ctx) -{ - glsl_texld(ctx, 0); -} // emit_GLSL_TEXLD - - -EMIT_GLSL_OPCODE_UNIMPLEMENTED_FUNC(TEXBEM) // !!! FIXME -EMIT_GLSL_OPCODE_UNIMPLEMENTED_FUNC(TEXBEML) // !!! FIXME -EMIT_GLSL_OPCODE_UNIMPLEMENTED_FUNC(TEXREG2AR) // !!! FIXME -EMIT_GLSL_OPCODE_UNIMPLEMENTED_FUNC(TEXREG2GB) // !!! FIXME -EMIT_GLSL_OPCODE_UNIMPLEMENTED_FUNC(TEXM3X2PAD) // !!! FIXME -EMIT_GLSL_OPCODE_UNIMPLEMENTED_FUNC(TEXM3X2TEX) // !!! FIXME -EMIT_GLSL_OPCODE_UNIMPLEMENTED_FUNC(TEXM3X3PAD) // !!! FIXME -EMIT_GLSL_OPCODE_UNIMPLEMENTED_FUNC(TEXM3X3TEX) // !!! FIXME -EMIT_GLSL_OPCODE_UNIMPLEMENTED_FUNC(TEXM3X3SPEC) // !!! FIXME -EMIT_GLSL_OPCODE_UNIMPLEMENTED_FUNC(TEXM3X3VSPEC) // !!! FIXME - -static void emit_GLSL_EXPP(Context *ctx) -{ - // !!! FIXME: msdn's asm docs don't list this opcode, I'll have to check the driver documentation. - emit_GLSL_EXP(ctx); // I guess this is just partial precision EXP? -} // emit_GLSL_EXPP - -static void emit_GLSL_LOGP(Context *ctx) -{ - // LOGP is just low-precision LOG, but we'll take the higher precision. - emit_GLSL_LOG(ctx); -} // emit_GLSL_LOGP - -// common code between CMP and CND. -static void emit_GLSL_comparison_operations(Context *ctx, const char *cmp) -{ - int i, j; - DestArgInfo *dst = &ctx->dest_arg; - const SourceArgInfo *srcarg0 = &ctx->source_args[0]; - const int origmask = dst->writemask; - int used_swiz[4] = { 0, 0, 0, 0 }; - const int writemask[4] = { dst->writemask0, dst->writemask1, - dst->writemask2, dst->writemask3 }; - const int src0swiz[4] = { srcarg0->swizzle_x, srcarg0->swizzle_y, - srcarg0->swizzle_z, srcarg0->swizzle_w }; - - for (i = 0; i < 4; i++) - { - int mask = (1 << i); - - if (!writemask[i]) continue; - if (used_swiz[i]) continue; - - // This is a swizzle we haven't checked yet. - used_swiz[i] = 1; - - // see if there are any other elements swizzled to match (.yyyy) - for (j = i + 1; j < 4; j++) - { - if (!writemask[j]) continue; - if (src0swiz[i] != src0swiz[j]) continue; - mask |= (1 << j); - used_swiz[j] = 1; - } // for - - // okay, (mask) should be the writemask of swizzles we like. - - //return make_GLSL_srcarg_string(ctx, idx, (1 << 0)); - - char src0[64]; - char src1[64]; - char src2[64]; - make_GLSL_srcarg_string(ctx, 0, (1 << i), src0, sizeof (src0)); - make_GLSL_srcarg_string(ctx, 1, mask, src1, sizeof (src1)); - make_GLSL_srcarg_string(ctx, 2, mask, src2, sizeof (src2)); - - dst->writemask = mask; - dst->writemask0 = ((mask >> 0) & 1); - dst->writemask1 = ((mask >> 1) & 1); - dst->writemask2 = ((mask >> 2) & 1); - dst->writemask3 = ((mask >> 3) & 1); - - char code[128]; - make_GLSL_destarg_assign(ctx, code, sizeof (code), - "((%s %s) ? %s : %s)", - src0, cmp, src1, src2); - dst->writemask = origmask; - dst->writemask0 = ((origmask >> 0) & 1); - dst->writemask1 = ((origmask >> 1) & 1); - dst->writemask2 = ((origmask >> 2) & 1); - dst->writemask3 = ((origmask >> 3) & 1); - output_line(ctx, "%s", code); - } // for -} // emit_GLSL_comparison_operations - -static void emit_GLSL_CND(Context *ctx) -{ - emit_GLSL_comparison_operations(ctx, "> 0.5"); -} // emit_GLSL_CND - -static void emit_GLSL_DEF(Context *ctx) -{ - const float *val = (const float *) ctx->dwords; // !!! FIXME: could be int? - char varname[64]; get_GLSL_destarg_varname(ctx, varname, sizeof (varname)); - char val0[32]; floatstr(ctx, val0, sizeof (val0), val[0], 1); - char val1[32]; floatstr(ctx, val1, sizeof (val1), val[1], 1); - char val2[32]; floatstr(ctx, val2, sizeof (val2), val[2], 1); - char val3[32]; floatstr(ctx, val3, sizeof (val3), val[3], 1); - - push_output(ctx, &ctx->globals); - output_line(ctx, "const vec4 %s = vec4(%s, %s, %s, %s);", - varname, val0, val1, val2, val3); - pop_output(ctx); -} // emit_GLSL_DEF - -EMIT_GLSL_OPCODE_UNIMPLEMENTED_FUNC(TEXREG2RGB) // !!! FIXME -EMIT_GLSL_OPCODE_UNIMPLEMENTED_FUNC(TEXDP3TEX) // !!! FIXME -EMIT_GLSL_OPCODE_UNIMPLEMENTED_FUNC(TEXM3X2DEPTH) // !!! FIXME -EMIT_GLSL_OPCODE_UNIMPLEMENTED_FUNC(TEXDP3) // !!! FIXME -EMIT_GLSL_OPCODE_UNIMPLEMENTED_FUNC(TEXM3X3) // !!! FIXME -EMIT_GLSL_OPCODE_UNIMPLEMENTED_FUNC(TEXDEPTH) // !!! FIXME - -static void emit_GLSL_CMP(Context *ctx) -{ - emit_GLSL_comparison_operations(ctx, ">= 0.0"); -} // emit_GLSL_CMP - -EMIT_GLSL_OPCODE_UNIMPLEMENTED_FUNC(BEM) // !!! FIXME - -static void emit_GLSL_DP2ADD(Context *ctx) -{ - char src0[64]; make_GLSL_srcarg_string_vec2(ctx, 0, src0, sizeof (src0)); - char src1[64]; make_GLSL_srcarg_string_vec2(ctx, 1, src1, sizeof (src1)); - char src2[64]; make_GLSL_srcarg_string_scalar(ctx, 2, src2, sizeof (src2)); - char extra[64]; snprintf(extra, sizeof (extra), " + %s", src2); - emit_GLSL_dotprod(ctx, src0, src1, extra); -} // emit_GLSL_DP2ADD - -static void emit_GLSL_DSX(Context *ctx) -{ - char src0[64]; make_GLSL_srcarg_string_masked(ctx, 0, src0, sizeof (src0)); - char code[128]; - make_GLSL_destarg_assign(ctx, code, sizeof (code), "dFdx(%s)", src0); - output_line(ctx, "%s", code); -} // emit_GLSL_DSX - -static void emit_GLSL_DSY(Context *ctx) -{ - char src0[64]; make_GLSL_srcarg_string_masked(ctx, 0, src0, sizeof (src0)); - char code[128]; - make_GLSL_destarg_assign(ctx, code, sizeof (code), "dFdy(%s)", src0); - output_line(ctx, "%s", code); -} // emit_GLSL_DSY - -static void emit_GLSL_TEXLDD(Context *ctx) -{ - // !!! FIXME: - // GLSL 1.30 introduced textureGrad() for this, but it looks like the - // functions are overloaded instead of texture2DGrad() (etc). - - // GL_shader_texture_lod and GL_EXT_gpu_shader4 added texture2DGrad*(), - // so we'll use them if available. Failing that, we'll just fallback - // to a regular texture2D call and hope the mipmap it chooses is close - // enough. - if (!ctx->glsl_generated_texldd_setup) - { - ctx->glsl_generated_texldd_setup = 1; - push_output(ctx, &ctx->preflight); - output_line(ctx, "#if GL_ARB_shader_texture_lod"); - output_line(ctx, "#extension GL_ARB_shader_texture_lod : enable"); - output_line(ctx, "#define texture2DGrad texture2DGradARB"); - output_line(ctx, "#define texture2DProjGrad texture2DProjARB"); - output_line(ctx, "#elif GL_EXT_gpu_shader4"); - output_line(ctx, "#extension GL_EXT_gpu_shader4 : enable"); - output_line(ctx, "#else"); - output_line(ctx, "#define texture2DGrad(a,b,c,d) texture2D(a,b)"); - output_line(ctx, "#define texture2DProjGrad(a,b,c,d) texture2DProj(a,b)"); - output_line(ctx, "#endif"); - output_blank_line(ctx); - pop_output(ctx); - } // if - - glsl_texld(ctx, 1); -} // emit_GLSL_TEXLDD - -static void emit_GLSL_SETP(Context *ctx) -{ - const int vecsize = vecsize_from_writemask(ctx->dest_arg.writemask); - char src0[64]; make_GLSL_srcarg_string_masked(ctx, 0, src0, sizeof (src0)); - char src1[64]; make_GLSL_srcarg_string_masked(ctx, 1, src1, sizeof (src1)); - char code[128]; - - // destination is always predicate register (which is type bvec4). - if (vecsize == 1) - { - const char *comp = get_GLSL_comparison_string_scalar(ctx); - make_GLSL_destarg_assign(ctx, code, sizeof (code), - "(%s %s %s)", src0, comp, src1); - } // if - else - { - const char *comp = get_GLSL_comparison_string_vector(ctx); - make_GLSL_destarg_assign(ctx, code, sizeof (code), - "%s(%s, %s)", comp, src0, src1); - } // else - - output_line(ctx, "%s", code); -} // emit_GLSL_SETP - -static void emit_GLSL_TEXLDL(Context *ctx) -{ - // !!! FIXME: The spec says we can't use GLSL's texture*Lod() built-ins - // !!! FIXME: from fragment shaders for some inexplicable reason. - // !!! FIXME: For now, you'll just have to suffer with the potentially - // !!! FIXME: wrong mipmap until I can figure something out. - emit_GLSL_TEXLD(ctx); -} // emit_GLSL_TEXLDL - -static void emit_GLSL_BREAKP(Context *ctx) -{ - char src0[64]; make_GLSL_srcarg_string_scalar(ctx, 0, src0, sizeof (src0)); - output_line(ctx, "if (%s) { break; }", src0); -} // emit_GLSL_BREAKP - -static void emit_GLSL_RESERVED(Context *ctx) -{ - // do nothing; fails in the state machine. -} // emit_GLSL_RESERVED - -#endif // SUPPORT_PROFILE_GLSL - - - -#if !SUPPORT_PROFILE_ARB1 -#define PROFILE_EMITTER_ARB1(op) -#else -#undef AT_LEAST_ONE_PROFILE -#define AT_LEAST_ONE_PROFILE 1 -#define PROFILE_EMITTER_ARB1(op) emit_ARB1_##op, - -static inline const char *get_ARB1_register_string(Context *ctx, - const RegisterType regtype, const int regnum, - char *regnum_str, const size_t regnum_size) -{ - // turns out these are identical at the moment. - return get_D3D_register_string(ctx,regtype,regnum,regnum_str,regnum_size); -} // get_ARB1_register_string - -static const char *allocate_ARB1_scratch_reg_name(Context *ctx, char *buf, - const size_t buflen) -{ - const int scratch = allocate_scratch_register(ctx); - snprintf(buf, buflen, "scratch%d", scratch); - return buf; -} // allocate_ARB1_scratch_reg_name - -static inline const char *get_ARB1_branch_label_name(Context *ctx, const int id, - char *buf, const size_t buflen) -{ - snprintf(buf, buflen, "branch_label%d", id); - return buf; -} // get_ARB1_branch_label_name - -static const char *get_ARB1_varname_in_buf(Context *ctx, const RegisterType rt, - const int regnum, char *buf, - const size_t buflen) -{ - // turns out these are identical at the moment. - return get_D3D_varname_in_buf(ctx, rt, regnum, buf, buflen); -} // get_ARB1_varname_in_buf - -static const char *get_ARB1_varname(Context *ctx, const RegisterType rt, - const int regnum) -{ - // turns out these are identical at the moment. - return get_D3D_varname(ctx, rt, regnum); -} // get_ARB1_varname - - -static inline const char *get_ARB1_const_array_varname_in_buf(Context *ctx, - const int base, const int size, - char *buf, const size_t buflen) -{ - snprintf(buf, buflen, "c_array_%d_%d", base, size); - return buf; -} // get_ARB1_const_array_varname_in_buf - - -static const char *get_ARB1_const_array_varname(Context *ctx, int base, int size) -{ - char buf[64]; - get_ARB1_const_array_varname_in_buf(ctx, base, size, buf, sizeof (buf)); - return StrDup(ctx, buf); -} // get_ARB1_const_array_varname - - -static const char *make_ARB1_srcarg_string_in_buf(Context *ctx, - const SourceArgInfo *arg, - char *buf, size_t buflen) -{ - char regnum_str[16] = { '\0' }; - - // !!! FIXME: use get_ARB1_varname_in_buf() instead? - const char *regtype_str = NULL; - if (!arg->relative) - { - regtype_str = get_ARB1_register_string(ctx, arg->regtype, - arg->regnum, regnum_str, - sizeof (regnum_str)); - } // if - - const char *rel_lbracket = ""; - char rel_offset[32] = { '\0' }; - const char *rel_rbracket = ""; - char rel_swizzle[4] = { '\0' }; - const char *rel_regtype_str = ""; - if (arg->relative) - { - rel_regtype_str = get_ARB1_varname_in_buf(ctx, arg->relative_regtype, - arg->relative_regnum, - (char *) alloca(64), 64); - - rel_swizzle[0] = '.'; - rel_swizzle[1] = swizzle_channels[arg->relative_component]; - rel_swizzle[2] = '\0'; - - if (!support_nv2(ctx)) - { - // The address register in ARB1 only allows the '.x' component, so - // we need to load the component we need from a temp vector - // register into .x as needed. - assert(arg->relative_regtype == REG_TYPE_ADDRESS); - assert(arg->relative_regnum == 0); - if (ctx->last_address_reg_component != arg->relative_component) - { - output_line(ctx, "ARL %s.x, addr%d.%c;", rel_regtype_str, - arg->relative_regnum, - swizzle_channels[arg->relative_component]); - ctx->last_address_reg_component = arg->relative_component; - } // if - - rel_swizzle[1] = 'x'; - } // if - - if (arg->regtype == REG_TYPE_INPUT) - regtype_str = "vertex.attrib"; - else - { - assert(arg->regtype == REG_TYPE_CONST); - const int arrayidx = arg->relative_array->index; - const int arraysize = arg->relative_array->count; - const int offset = arg->regnum - arrayidx; - assert(offset >= 0); - regtype_str = get_ARB1_const_array_varname_in_buf(ctx, arrayidx, - arraysize, (char *) alloca(64), 64); - if (offset != 0) - snprintf(rel_offset, sizeof (rel_offset), " + %d", offset); - } // else - - rel_lbracket = "["; - rel_rbracket = "]"; - } // if - - // This is the source register with everything but swizzle and source mods. - snprintf(buf, buflen, "%s%s%s%s%s%s%s", regtype_str, regnum_str, - rel_lbracket, rel_regtype_str, rel_swizzle, rel_offset, - rel_rbracket); - - // Some of the source mods need to generate instructions to a temp - // register, in which case we'll replace the register name. - - const char *premod_str = ""; - const char *postmod_str = ""; - switch (arg->src_mod) - { - case SRCMOD_NEGATE: - premod_str = "-"; - break; - - case SRCMOD_BIASNEGATE: - premod_str = "-"; - // fall through. - case SRCMOD_BIAS: - fail(ctx, "SRCMOD_BIAS currently unsupported in arb1"); - postmod_str = "_bias"; - break; - - case SRCMOD_SIGNNEGATE: - premod_str = "-"; - // fall through. - case SRCMOD_SIGN: - fail(ctx, "SRCMOD_SIGN currently unsupported in arb1"); - postmod_str = "_bx2"; - break; - - case SRCMOD_COMPLEMENT: - fail(ctx, "SRCMOD_COMPLEMENT currently unsupported in arb1"); - premod_str = "1-"; - break; - - case SRCMOD_X2NEGATE: - premod_str = "-"; - // fall through. - case SRCMOD_X2: - fail(ctx, "SRCMOD_X2 currently unsupported in arb1"); - postmod_str = "_x2"; - break; - - case SRCMOD_DZ: - fail(ctx, "SRCMOD_DZ currently unsupported in arb1"); - postmod_str = "_dz"; - break; - - case SRCMOD_DW: - fail(ctx, "SRCMOD_DW currently unsupported in arb1"); - postmod_str = "_dw"; - break; - - case SRCMOD_ABSNEGATE: - premod_str = "-"; - // fall through. - case SRCMOD_ABS: - if (support_nv2(ctx)) // GL_NV_vertex_program2_option adds this. - { - premod_str = (arg->src_mod == SRCMOD_ABSNEGATE) ? "-|" : "|"; - postmod_str = "|"; - } // if - else - { - regtype_str = allocate_ARB1_scratch_reg_name(ctx, - (char *) alloca(64), 64); - regnum_str[0] = '\0'; // move value to scratch register. - rel_lbracket = ""; // scratch register won't use array. - rel_rbracket = ""; - rel_offset[0] = '\0'; - rel_swizzle[0] = '\0'; - rel_regtype_str = ""; - output_line(ctx, "ABS %s, %s;", regtype_str, buf); - } // else - break; - - case SRCMOD_NOT: - fail(ctx, "SRCMOD_NOT currently unsupported in arb1"); - premod_str = "!"; - break; - - case SRCMOD_NONE: - case SRCMOD_TOTAL: - break; // stop compiler whining. - } // switch - - char swizzle_str[6]; - size_t i = 0; - - if (support_nv4(ctx)) // vFace must be output as "vFace.x" in nv4. - { - if (arg->regtype == REG_TYPE_MISCTYPE) - { - if ( ((const MiscTypeType) arg->regnum) == MISCTYPE_TYPE_FACE ) - { - swizzle_str[i++] = '.'; - swizzle_str[i++] = 'x'; - } // if - } // if - } // if - - const int scalar = isscalar(ctx, ctx->shader_type, arg->regtype, arg->regnum); - if (!scalar && !no_swizzle(arg->swizzle)) - { - swizzle_str[i++] = '.'; - - // .xxxx is the same as .x, but .xx is illegal...scalar or full! - if (replicate_swizzle(arg->swizzle)) - swizzle_str[i++] = swizzle_channels[arg->swizzle_x]; - else - { - swizzle_str[i++] = swizzle_channels[arg->swizzle_x]; - swizzle_str[i++] = swizzle_channels[arg->swizzle_y]; - swizzle_str[i++] = swizzle_channels[arg->swizzle_z]; - swizzle_str[i++] = swizzle_channels[arg->swizzle_w]; - } // else - } // if - swizzle_str[i] = '\0'; - assert(i < sizeof (swizzle_str)); - - snprintf(buf, buflen, "%s%s%s%s%s%s%s%s%s%s", premod_str, - regtype_str, regnum_str, rel_lbracket, - rel_regtype_str, rel_swizzle, rel_offset, rel_rbracket, - swizzle_str, postmod_str); - // !!! FIXME: make sure the scratch buffer was large enough. - return buf; -} // make_ARB1_srcarg_string_in_buf - -static const char *get_ARB1_destarg_varname(Context *ctx, char *buf, - const size_t buflen) -{ - const DestArgInfo *arg = &ctx->dest_arg; - return get_ARB1_varname_in_buf(ctx, arg->regtype, arg->regnum, buf, buflen); -} // get_ARB1_destarg_varname - -static const char *get_ARB1_srcarg_varname(Context *ctx, const size_t idx, - char *buf, const size_t buflen) -{ - if (idx >= STATICARRAYLEN(ctx->source_args)) - { - fail(ctx, "Too many source args"); - *buf = '\0'; - return buf; - } // if - - const SourceArgInfo *arg = &ctx->source_args[idx]; - return get_ARB1_varname_in_buf(ctx, arg->regtype, arg->regnum, buf, buflen); -} // get_ARB1_srcarg_varname - - -static const char *make_ARB1_destarg_string(Context *ctx, char *buf, - const size_t buflen) -{ - const DestArgInfo *arg = &ctx->dest_arg; - - *buf = '\0'; - - const char *sat_str = ""; - if (arg->result_mod & MOD_SATURATE) - { - // nv4 can use ".SAT" in all program types. - // For less than nv4, the "_SAT" modifier is only available in - // fragment shaders. Every thing else will fake it later in - // emit_ARB1_dest_modifiers() ... - if (support_nv4(ctx)) - sat_str = ".SAT"; - else if (shader_is_pixel(ctx)) - sat_str = "_SAT"; - } // if - - const char *pp_str = ""; - if (arg->result_mod & MOD_PP) - { - // Most ARB1 profiles can't do partial precision (MOD_PP), but that's - // okay. The spec says lots of Direct3D implementations ignore the - // flag anyhow. - if (support_nv4(ctx)) - pp_str = "H"; - } // if - - // CENTROID only allowed in DCL opcodes, which shouldn't come through here. - assert((arg->result_mod & MOD_CENTROID) == 0); - - char regnum_str[16]; - const char *regtype_str = get_ARB1_register_string(ctx, arg->regtype, - arg->regnum, regnum_str, - sizeof (regnum_str)); - if (regtype_str == NULL) - { - fail(ctx, "Unknown destination register type."); - return buf; - } // if - - char writemask_str[6]; - size_t i = 0; - const int scalar = isscalar(ctx, ctx->shader_type, arg->regtype, arg->regnum); - if (!scalar && !writemask_xyzw(arg->writemask)) - { - writemask_str[i++] = '.'; - if (arg->writemask0) writemask_str[i++] = 'x'; - if (arg->writemask1) writemask_str[i++] = 'y'; - if (arg->writemask2) writemask_str[i++] = 'z'; - if (arg->writemask3) writemask_str[i++] = 'w'; - } // if - writemask_str[i] = '\0'; - assert(i < sizeof (writemask_str)); - - const char *pred_left = ""; - const char *pred_right = ""; - char pred[32] = { '\0' }; - if (ctx->predicated) - { - fail(ctx, "dest register predication currently unsupported in arb1"); - return buf; - pred_left = "("; - pred_right = ") "; - make_ARB1_srcarg_string_in_buf(ctx, &ctx->predicate_arg, - pred, sizeof (pred)); - } // if - - snprintf(buf, buflen, "%s%s %s%s%s", pp_str, sat_str, - regtype_str, regnum_str, writemask_str); - // !!! FIXME: make sure the scratch buffer was large enough. - return buf; -} // make_ARB1_destarg_string - - -static void emit_ARB1_dest_modifiers(Context *ctx) -{ - const DestArgInfo *arg = &ctx->dest_arg; - - if (arg->result_shift != 0x0) - { - char dst[64]; make_ARB1_destarg_string(ctx, dst, sizeof (dst)); - const char *multiplier = NULL; - - switch (arg->result_shift) - { - case 0x1: multiplier = "2.0"; break; - case 0x2: multiplier = "4.0"; break; - case 0x3: multiplier = "8.0"; break; - case 0xD: multiplier = "0.125"; break; - case 0xE: multiplier = "0.25"; break; - case 0xF: multiplier = "0.5"; break; - } // switch - - if (multiplier != NULL) - { - char var[64]; get_ARB1_destarg_varname(ctx, var, sizeof (var)); - output_line(ctx, "MUL%s, %s, %s;", dst, var, multiplier); - } // if - } // if - - if (arg->result_mod & MOD_SATURATE) - { - // nv4 and/or pixel shaders just used the "SAT" modifier, instead. - if ( (!support_nv4(ctx)) && (!shader_is_pixel(ctx)) ) - { - char var[64]; get_ARB1_destarg_varname(ctx, var, sizeof (var)); - char dst[64]; make_ARB1_destarg_string(ctx, dst, sizeof (dst)); - output_line(ctx, "MIN%s, %s, 1.0;", dst, var); - output_line(ctx, "MAX%s, %s, 0.0;", dst, var); - } // if - } // if -} // emit_ARB1_dest_modifiers - - -static const char *make_ARB1_srcarg_string(Context *ctx, const size_t idx, - char *buf, const size_t buflen) -{ - if (idx >= STATICARRAYLEN(ctx->source_args)) - { - fail(ctx, "Too many source args"); - *buf = '\0'; - return buf; - } // if - - const SourceArgInfo *arg = &ctx->source_args[idx]; - return make_ARB1_srcarg_string_in_buf(ctx, arg, buf, buflen); -} // make_ARB1_srcarg_string - -static void emit_ARB1_opcode_ds(Context *ctx, const char *opcode) -{ - char dst[64]; make_ARB1_destarg_string(ctx, dst, sizeof (dst)); - char src0[64]; make_ARB1_srcarg_string(ctx, 0, src0, sizeof (src0)); - output_line(ctx, "%s%s, %s;", opcode, dst, src0); - emit_ARB1_dest_modifiers(ctx); -} // emit_ARB1_opcode_ds - -static void emit_ARB1_opcode_dss(Context *ctx, const char *opcode) -{ - char dst[64]; make_ARB1_destarg_string(ctx, dst, sizeof (dst)); - char src0[64]; make_ARB1_srcarg_string(ctx, 0, src0, sizeof (src0)); - char src1[64]; make_ARB1_srcarg_string(ctx, 1, src1, sizeof (src1)); - output_line(ctx, "%s%s, %s, %s;", opcode, dst, src0, src1); - emit_ARB1_dest_modifiers(ctx); -} // emit_ARB1_opcode_dss - -static void emit_ARB1_opcode_dsss(Context *ctx, const char *opcode) -{ - char dst[64]; make_ARB1_destarg_string(ctx, dst, sizeof (dst)); - char src0[64]; make_ARB1_srcarg_string(ctx, 0, src0, sizeof (src0)); - char src1[64]; make_ARB1_srcarg_string(ctx, 1, src1, sizeof (src1)); - char src2[64]; make_ARB1_srcarg_string(ctx, 2, src2, sizeof (src2)); - output_line(ctx, "%s%s, %s, %s, %s;", opcode, dst, src0, src1, src2); - emit_ARB1_dest_modifiers(ctx); -} // emit_ARB1_opcode_dsss - - -#define EMIT_ARB1_OPCODE_FUNC(op) \ - static void emit_ARB1_##op(Context *ctx) { \ - emit_ARB1_opcode(ctx, #op); \ - } -#define EMIT_ARB1_OPCODE_D_FUNC(op) \ - static void emit_ARB1_##op(Context *ctx) { \ - emit_ARB1_opcode_d(ctx, #op); \ - } -#define EMIT_ARB1_OPCODE_S_FUNC(op) \ - static void emit_ARB1_##op(Context *ctx) { \ - emit_ARB1_opcode_s(ctx, #op); \ - } -#define EMIT_ARB1_OPCODE_SS_FUNC(op) \ - static void emit_ARB1_##op(Context *ctx) { \ - emit_ARB1_opcode_ss(ctx, #op); \ - } -#define EMIT_ARB1_OPCODE_DS_FUNC(op) \ - static void emit_ARB1_##op(Context *ctx) { \ - emit_ARB1_opcode_ds(ctx, #op); \ - } -#define EMIT_ARB1_OPCODE_DSS_FUNC(op) \ - static void emit_ARB1_##op(Context *ctx) { \ - emit_ARB1_opcode_dss(ctx, #op); \ - } -#define EMIT_ARB1_OPCODE_DSSS_FUNC(op) \ - static void emit_ARB1_##op(Context *ctx) { \ - emit_ARB1_opcode_dsss(ctx, #op); \ - } -#define EMIT_ARB1_OPCODE_DSSSS_FUNC(op) \ - static void emit_ARB1_##op(Context *ctx) { \ - emit_ARB1_opcode_dssss(ctx, #op); \ - } -#define EMIT_ARB1_OPCODE_UNIMPLEMENTED_FUNC(op) \ - static void emit_ARB1_##op(Context *ctx) { \ - failf(ctx, #op " unimplemented in %s profile", ctx->profile->name); \ - } - - -static void emit_ARB1_start(Context *ctx, const char *profilestr) -{ - const char *shader_str = NULL; - const char *shader_full_str = NULL; - if (shader_is_vertex(ctx)) - { - shader_str = "vp"; - shader_full_str = "vertex"; - } // if - else if (shader_is_pixel(ctx)) - { - shader_str = "fp"; - shader_full_str = "fragment"; - } // else if - else - { - failf(ctx, "Shader type %u unsupported in this profile.", - (uint) ctx->shader_type); - return; - } // if - - set_output(ctx, &ctx->preflight); - - if (strcmp(profilestr, MOJOSHADER_PROFILE_ARB1) == 0) - output_line(ctx, "!!ARB%s1.0", shader_str); - - #if SUPPORT_PROFILE_ARB1_NV - else if (strcmp(profilestr, MOJOSHADER_PROFILE_NV2) == 0) - { - ctx->profile_supports_nv2 = 1; - output_line(ctx, "!!ARB%s1.0", shader_str); - output_line(ctx, "OPTION NV_%s_program2;", shader_full_str); - } // else if - - else if (strcmp(profilestr, MOJOSHADER_PROFILE_NV3) == 0) - { - // there's no NV_fragment_program3, so just use 2. - const int ver = shader_is_pixel(ctx) ? 2 : 3; - ctx->profile_supports_nv2 = 1; - ctx->profile_supports_nv3 = 1; - output_line(ctx, "!!ARB%s1.0", shader_str); - output_line(ctx, "OPTION NV_%s_program%d;", shader_full_str, ver); - } // else if - - else if (strcmp(profilestr, MOJOSHADER_PROFILE_NV4) == 0) - { - ctx->profile_supports_nv2 = 1; - ctx->profile_supports_nv3 = 1; - ctx->profile_supports_nv4 = 1; - output_line(ctx, "!!NV%s4.0", shader_str); - } // else if - #endif - - else - { - failf(ctx, "Profile '%s' unsupported or unknown.", profilestr); - } // else - - set_output(ctx, &ctx->mainline); -} // emit_ARB1_start - -static void emit_ARB1_end(Context *ctx) -{ - output_line(ctx, "END"); -} // emit_ARB1_end - -static void emit_ARB1_phase(Context *ctx) -{ - // no-op in arb1. -} // emit_ARB1_phase - -static inline const char *arb1_float_temp(const Context *ctx) -{ - // nv4 lets you specify data type. - return (support_nv4(ctx)) ? "FLOAT TEMP" : "TEMP"; -} // arb1_float_temp - -static void emit_ARB1_finalize(Context *ctx) -{ - push_output(ctx, &ctx->preflight); - - if (shader_is_vertex(ctx) && !ctx->arb1_wrote_position) - output_line(ctx, "OPTION ARB_position_invariant;"); - - if (shader_is_pixel(ctx) && ctx->have_multi_color_outputs) - output_line(ctx, "OPTION ARB_draw_buffers;"); - - pop_output(ctx); - - const char *tmpstr = arb1_float_temp(ctx); - int i; - push_output(ctx, &ctx->globals); - for (i = 0; i < ctx->max_scratch_registers; i++) - { - char buf[64]; - allocate_ARB1_scratch_reg_name(ctx, buf, sizeof (buf)); - output_line(ctx, "%s %s;", tmpstr, buf); - } // for - - // nv2 fragment programs (and anything nv4) have a real REP/ENDREP. - if ( (support_nv2(ctx)) && (!shader_is_pixel(ctx)) && (!support_nv4(ctx)) ) - { - // set up temps for nv2 REP/ENDREP emulation through branching. - for (i = 0; i < ctx->max_reps; i++) - output_line(ctx, "TEMP rep%d;", i); - } // if - - pop_output(ctx); - assert(ctx->scratch_registers == ctx->max_scratch_registers); -} // emit_ARB1_finalize - -static void emit_ARB1_global(Context *ctx, RegisterType regtype, int regnum) -{ - // !!! FIXME: dependency on ARB1 profile. // !!! FIXME about FIXME: huh? - char varname[64]; - get_ARB1_varname_in_buf(ctx, regtype, regnum, varname, sizeof (varname)); - - push_output(ctx, &ctx->globals); - switch (regtype) - { - case REG_TYPE_ADDRESS: - // nv4 replaced address registers with generic int registers. - if (support_nv4(ctx)) - output_line(ctx, "INT TEMP %s;", varname); - else - { - // nv2 has four-component address already, but stock arb1 has - // to emulate it in a temporary, and move components to the - // scalar ADDRESS register on demand. - output_line(ctx, "ADDRESS %s;", varname); - if (!support_nv2(ctx)) - output_line(ctx, "TEMP addr%d;", regnum); - } // else - break; - - //case REG_TYPE_PREDICATE: - // output_line(ctx, "bvec4 %s;", varname); - // break; - case REG_TYPE_TEMP: - output_line(ctx, "%s %s;", arb1_float_temp(ctx), varname); - break; - //case REG_TYPE_LOOP: - // break; // no-op. We declare these in for loops at the moment. - //case REG_TYPE_LABEL: - // break; // no-op. If we see it here, it means we optimized it out. - default: - fail(ctx, "BUG: we used a register we don't know how to define."); - break; - } // switch - pop_output(ctx); -} // emit_ARB1_global - -static void emit_ARB1_array(Context *ctx, VariableList *var) -{ - // All uniforms are now packed tightly into the program.local array, - // instead of trying to map them to the d3d registers. So this needs to - // map to the next piece of the array we haven't used yet. Thankfully, - // arb1 lets you make a PARAM array that maps to a subset of another - // array; we don't need to do offsets, since myarray[0] can map to - // program.local[5] without any extra math from us. - const int base = var->index; - const int size = var->count; - const int arb1base = ctx->uniform_float4_count + - ctx->uniform_int4_count + - ctx->uniform_bool_count; - char varname[64]; - get_ARB1_const_array_varname_in_buf(ctx, base, size, varname, sizeof (varname)); - push_output(ctx, &ctx->globals); - output_line(ctx, "PARAM %s[%d] = { program.local[%d..%d] };", varname, - size, arb1base, (arb1base + size) - 1); - pop_output(ctx); - var->emit_position = arb1base; -} // emit_ARB1_array - -static void emit_ARB1_const_array(Context *ctx, const ConstantsList *clist, - int base, int size) -{ - char varname[64]; - get_ARB1_const_array_varname_in_buf(ctx, base, size, varname, sizeof (varname)); - int i; - - push_output(ctx, &ctx->globals); - output_line(ctx, "PARAM %s[%d] = {", varname, size); - ctx->indent++; - - for (i = 0; i < size; i++) - { - while (clist->constant.type != MOJOSHADER_UNIFORM_FLOAT) - clist = clist->next; - assert(clist->constant.index == (base + i)); - - char val0[32]; - char val1[32]; - char val2[32]; - char val3[32]; - floatstr(ctx, val0, sizeof (val0), clist->constant.value.f[0], 1); - floatstr(ctx, val1, sizeof (val1), clist->constant.value.f[1], 1); - floatstr(ctx, val2, sizeof (val2), clist->constant.value.f[2], 1); - floatstr(ctx, val3, sizeof (val3), clist->constant.value.f[3], 1); - - output_line(ctx, "{ %s, %s, %s, %s }%s", val0, val1, val2, val3, - (i < (size-1)) ? "," : ""); - - clist = clist->next; - } // for - - ctx->indent--; - output_line(ctx, "};"); - pop_output(ctx); -} // emit_ARB1_const_array - -static void emit_ARB1_uniform(Context *ctx, RegisterType regtype, int regnum, - const VariableList *var) -{ - // We pack these down into the program.local array, so if we only use - // register c439, it'll actually map to program.local[0]. This will - // prevent overflows when we actually have enough resources to run. - - const char *arrayname = "program.local"; - int index = 0; - - char varname[64]; - get_ARB1_varname_in_buf(ctx, regtype, regnum, varname, sizeof (varname)); - - push_output(ctx, &ctx->globals); - - if (var == NULL) - { - // all types share one array (rather, all types convert to float4). - index = ctx->uniform_float4_count + ctx->uniform_int4_count + - ctx->uniform_bool_count; - } // if - - else - { - const int arraybase = var->index; - if (var->constant) - { - const int arraysize = var->count; - arrayname = get_ARB1_const_array_varname_in_buf(ctx, arraybase, - arraysize, (char *) alloca(64), 64); - index = (regnum - arraybase); - } // if - else - { - assert(var->emit_position != -1); - index = (regnum - arraybase) + var->emit_position; - } // else - } // else - - output_line(ctx, "PARAM %s = %s[%d];", varname, arrayname, index); - pop_output(ctx); -} // emit_ARB1_uniform - -static void emit_ARB1_sampler(Context *ctx, int stage, TextureType ttype) -{ - // this is a no-op...you don't predeclare samplers in arb1. -} // emit_ARB1_sampler - -// !!! FIXME: a lot of cut-and-paste here from emit_GLSL_attribute(). -static void emit_ARB1_attribute(Context *ctx, RegisterType regtype, int regnum, - MOJOSHADER_usage usage, int index, int wmask, - int flags) -{ - // !!! FIXME: this function doesn't deal with write masks at all yet! - const char *usage_str = NULL; - const char *arrayleft = ""; - const char *arrayright = ""; - char index_str[16] = { '\0' }; - - char varname[64]; - get_ARB1_varname_in_buf(ctx, regtype, regnum, varname, sizeof (varname)); - - //assert((flags & MOD_PP) == 0); // !!! FIXME: is PP allowed? - - if (index != 0) // !!! FIXME: a lot of these MUST be zero. - snprintf(index_str, sizeof (index_str), "%u", (uint) index); - - if (shader_is_vertex(ctx)) - { - // pre-vs3 output registers. - // these don't ever happen in DCL opcodes, I think. Map to vs_3_* - // output registers. - if (!shader_version_atleast(ctx, 3, 0)) - { - if (regtype == REG_TYPE_RASTOUT) - { - regtype = REG_TYPE_OUTPUT; - index = regnum; - switch ((const RastOutType) regnum) - { - case RASTOUT_TYPE_POSITION: - usage = MOJOSHADER_USAGE_POSITION; - break; - case RASTOUT_TYPE_FOG: - usage = MOJOSHADER_USAGE_FOG; - break; - case RASTOUT_TYPE_POINT_SIZE: - usage = MOJOSHADER_USAGE_POINTSIZE; - break; - } // switch - } // if - - else if (regtype == REG_TYPE_ATTROUT) - { - regtype = REG_TYPE_OUTPUT; - usage = MOJOSHADER_USAGE_COLOR; - index = regnum; - } // else if - - else if (regtype == REG_TYPE_TEXCRDOUT) - { - regtype = REG_TYPE_OUTPUT; - usage = MOJOSHADER_USAGE_TEXCOORD; - index = regnum; - } // else if - } // if - - // to avoid limitations of various GL entry points for input - // attributes (glSecondaryColorPointer() can only take 3 component - // items, glVertexPointer() can't do GL_UNSIGNED_BYTE, many other - // issues), we set up all inputs as generic vertex attributes, so we - // can pass data in just about any form, and ignore the built-in GLSL - // attributes like gl_SecondaryColor. Output needs to use the the - // built-ins, though, but we don't have to worry about the GL entry - // point limitations there. - - if (regtype == REG_TYPE_INPUT) - { - const int attr = ctx->assigned_vertex_attributes++; - push_output(ctx, &ctx->globals); - output_line(ctx, "ATTRIB %s = vertex.attrib[%d];", varname, attr); - pop_output(ctx); - } // if - - else if (regtype == REG_TYPE_OUTPUT) - { - switch (usage) - { - case MOJOSHADER_USAGE_POSITION: - ctx->arb1_wrote_position = 1; - usage_str = "result.position"; - break; - case MOJOSHADER_USAGE_POINTSIZE: - usage_str = "result.pointsize"; - break; - case MOJOSHADER_USAGE_COLOR: - index_str[0] = '\0'; // no explicit number. - if (index == 0) - usage_str = "result.color.primary"; - else if (index == 1) - usage_str = "result.color.secondary"; - break; - case MOJOSHADER_USAGE_FOG: - usage_str = "result.fogcoord"; - break; - case MOJOSHADER_USAGE_TEXCOORD: - snprintf(index_str, sizeof (index_str), "%u", (uint) index); - usage_str = "result.texcoord"; - arrayleft = "["; - arrayright = "]"; - break; - default: - // !!! FIXME: we need to deal with some more built-in varyings here. - break; - } // switch - - // !!! FIXME: the #define is a little hacky, but it means we don't - // !!! FIXME: have to track these separately if this works. - push_output(ctx, &ctx->globals); - // no mapping to built-in var? Just make it a regular global, pray. - if (usage_str == NULL) - output_line(ctx, "%s %s;", arb1_float_temp(ctx), varname); - else - { - output_line(ctx, "OUTPUT %s = %s%s%s%s;", varname, usage_str, - arrayleft, index_str, arrayright); - } // else - pop_output(ctx); - } // else if - - else - { - fail(ctx, "unknown vertex shader attribute register"); - } // else - } // if - - else if (shader_is_pixel(ctx)) - { - const char *paramtype_str = "ATTRIB"; - - // samplers DCLs get handled in emit_ARB1_sampler(). - - if (flags & MOD_CENTROID) - { - if (!support_nv4(ctx)) // GL_NV_fragment_program4 adds centroid. - { - // !!! FIXME: should we just wing it without centroid here? - failf(ctx, "centroid unsupported in %s profile", - ctx->profile->name); - return; - } // if - - paramtype_str = "CENTROID ATTRIB"; - } // if - - if (regtype == REG_TYPE_COLOROUT) - { - paramtype_str = "OUTPUT"; - usage_str = "result.color"; - if (ctx->have_multi_color_outputs) - { - // We have to gamble that you have GL_ARB_draw_buffers. - // You probably do at this point if you have a sane setup. - snprintf(index_str, sizeof (index_str), "%u", (uint) regnum); - arrayleft = "["; - arrayright = "]"; - } // if - } // if - - else if (regtype == REG_TYPE_DEPTHOUT) - { - paramtype_str = "OUTPUT"; - usage_str = "result.depth"; - } // else if - - // !!! FIXME: can you actualy have a texture register with COLOR usage? - else if ((regtype == REG_TYPE_TEXTURE) || (regtype == REG_TYPE_INPUT)) - { - if (usage == MOJOSHADER_USAGE_TEXCOORD) - { - snprintf(index_str, sizeof (index_str), "%u", (uint) index); - usage_str = "fragment.texcoord"; - arrayleft = "["; - arrayright = "]"; - } // if - - else if (usage == MOJOSHADER_USAGE_COLOR) - { - index_str[0] = '\0'; // no explicit number. - if (index == 0) - usage_str = "fragment.color.primary"; - else if (index == 1) - usage_str = "fragment.color.secondary"; - else - fail(ctx, "unsupported color index"); - } // else if - } // else if - - else if (regtype == REG_TYPE_MISCTYPE) - { - const MiscTypeType mt = (MiscTypeType) regnum; - if (mt == MISCTYPE_TYPE_FACE) - { - if (support_nv4(ctx)) // FINALLY, a vFace equivalent in nv4! - { - index_str[0] = '\0'; // no explicit number. - usage_str = "fragment.facing"; - } // if - else - { - failf(ctx, "vFace unsupported in %s profile", - ctx->profile->name); - } // else - } // if - else if (mt == MISCTYPE_TYPE_POSITION) - { - index_str[0] = '\0'; // no explicit number. - usage_str = "fragment.position"; // !!! FIXME: is this the same coord space as D3D? - } // else if - else - { - fail(ctx, "BUG: unhandled misc register"); - } // else - } // else if - - else - { - fail(ctx, "unknown pixel shader attribute register"); - } // else - - if (usage_str != NULL) - { - push_output(ctx, &ctx->globals); - output_line(ctx, "%s %s = %s%s%s%s;", paramtype_str, varname, - usage_str, arrayleft, index_str, arrayright); - pop_output(ctx); - } // if - } // else if - - else - { - fail(ctx, "Unknown shader type"); // state machine should catch this. - } // else -} // emit_ARB1_attribute - -static void emit_ARB1_RESERVED(Context *ctx) { /* no-op. */ } - -static void emit_ARB1_NOP(Context *ctx) -{ - // There is no NOP in arb1. Just don't output anything here. -} // emit_ARB1_NOP - -EMIT_ARB1_OPCODE_DS_FUNC(MOV) -EMIT_ARB1_OPCODE_DSS_FUNC(ADD) -EMIT_ARB1_OPCODE_DSS_FUNC(SUB) -EMIT_ARB1_OPCODE_DSSS_FUNC(MAD) -EMIT_ARB1_OPCODE_DSS_FUNC(MUL) -EMIT_ARB1_OPCODE_DS_FUNC(RCP) - -static void emit_ARB1_RSQ(Context *ctx) -{ - // nv4 doesn't force abs() on this, so negative values will generate NaN. - // The spec says you should force the abs() yourself. - if (!support_nv4(ctx)) - { - emit_ARB1_opcode_ds(ctx, "RSQ"); // pre-nv4 implies ABS. - return; - } // if - - // we can optimize this to use nv2's |abs| construct in some cases. - if ( (ctx->source_args[0].src_mod == SRCMOD_NONE) || - (ctx->source_args[0].src_mod == SRCMOD_NEGATE) || - (ctx->source_args[0].src_mod == SRCMOD_ABSNEGATE) ) - ctx->source_args[0].src_mod = SRCMOD_ABS; - - char dst[64]; make_ARB1_destarg_string(ctx, dst, sizeof (dst)); - char src0[64]; make_ARB1_srcarg_string(ctx, 0, src0, sizeof (src0)); - - if (ctx->source_args[0].src_mod == SRCMOD_ABS) - output_line(ctx, "RSQ%s, %s;", dst, src0); - else - { - char buf[64]; allocate_ARB1_scratch_reg_name(ctx, buf, sizeof (buf)); - output_line(ctx, "ABS %s, %s;", buf, src0); - output_line(ctx, "RSQ%s, %s.x;", dst, buf); - } // else - - emit_ARB1_dest_modifiers(ctx); -} // emit_ARB1_RSQ - -EMIT_ARB1_OPCODE_DSS_FUNC(DP3) -EMIT_ARB1_OPCODE_DSS_FUNC(DP4) -EMIT_ARB1_OPCODE_DSS_FUNC(MIN) -EMIT_ARB1_OPCODE_DSS_FUNC(MAX) -EMIT_ARB1_OPCODE_DSS_FUNC(SLT) -EMIT_ARB1_OPCODE_DSS_FUNC(SGE) - -static void emit_ARB1_EXP(Context *ctx) { emit_ARB1_opcode_ds(ctx, "EX2"); } - -static void arb1_log(Context *ctx, const char *opcode) -{ - // !!! FIXME: SRCMOD_NEGATE can be made into SRCMOD_ABS here, too - // we can optimize this to use nv2's |abs| construct in some cases. - if ( (ctx->source_args[0].src_mod == SRCMOD_NONE) || - (ctx->source_args[0].src_mod == SRCMOD_ABSNEGATE) ) - ctx->source_args[0].src_mod = SRCMOD_ABS; - - char dst[64]; make_ARB1_destarg_string(ctx, dst, sizeof (dst)); - char src0[64]; make_ARB1_srcarg_string(ctx, 0, src0, sizeof (src0)); - - if (ctx->source_args[0].src_mod == SRCMOD_ABS) - output_line(ctx, "%s%s, %s;", opcode, dst, src0); - else - { - char buf[64]; allocate_ARB1_scratch_reg_name(ctx, buf, sizeof (buf)); - output_line(ctx, "ABS %s, %s;", buf, src0); - output_line(ctx, "%s%s, %s.x;", opcode, dst, buf); - } // else - - emit_ARB1_dest_modifiers(ctx); -} // arb1_log - - -static void emit_ARB1_LOG(Context *ctx) -{ - arb1_log(ctx, "LG2"); -} // emit_ARB1_LOG - - -EMIT_ARB1_OPCODE_DS_FUNC(LIT) -EMIT_ARB1_OPCODE_DSS_FUNC(DST) - -static void emit_ARB1_LRP(Context *ctx) -{ - if (shader_is_pixel(ctx)) // fragment shaders have a matching LRP opcode. - emit_ARB1_opcode_dsss(ctx, "LRP"); - else - { - char dst[64]; make_ARB1_destarg_string(ctx, dst, sizeof (dst)); - char src0[64]; make_ARB1_srcarg_string(ctx, 0, src0, sizeof (src0)); - char src1[64]; make_ARB1_srcarg_string(ctx, 1, src1, sizeof (src1)); - char src2[64]; make_ARB1_srcarg_string(ctx, 2, src2, sizeof (src2)); - char buf[64]; allocate_ARB1_scratch_reg_name(ctx, buf, sizeof (buf)); - - // LRP is: dest = src2 + src0 * (src1 - src2) - output_line(ctx, "SUB %s, %s, %s;", buf, src1, src2); - output_line(ctx, "MAD%s, %s, %s, %s;", dst, buf, src0, src2); - emit_ARB1_dest_modifiers(ctx); - } // else -} // emit_ARB1_LRP - -EMIT_ARB1_OPCODE_DS_FUNC(FRC) - -// !!! FIXME: these could be implemented with vector opcodes, but it looks -// !!! FIXME: like the Microsoft HLSL compiler never generates matrix -// !!! FIXME: operations for some reason. -EMIT_ARB1_OPCODE_UNIMPLEMENTED_FUNC(M4X4) -EMIT_ARB1_OPCODE_UNIMPLEMENTED_FUNC(M4X3) -EMIT_ARB1_OPCODE_UNIMPLEMENTED_FUNC(M3X4) -EMIT_ARB1_OPCODE_UNIMPLEMENTED_FUNC(M3X3) -EMIT_ARB1_OPCODE_UNIMPLEMENTED_FUNC(M3X2) - -static void emit_ARB1_CALL(Context *ctx) -{ - if (!support_nv2(ctx)) // no branching in stock ARB1. - { - failf(ctx, "branching unsupported in %s profile", ctx->profile->name); - return; - } // if - - char labelstr[64]; - get_ARB1_srcarg_varname(ctx, 0, labelstr, sizeof (labelstr)); - output_line(ctx, "CAL %s;", labelstr); -} // emit_ARB1_CALL - -static void emit_ARB1_CALLNZ(Context *ctx) -{ - // !!! FIXME: if src1 is a constbool that's true, we can remove the - // !!! FIXME: if. If it's false, we can make this a no-op. - - if (!support_nv2(ctx)) // no branching in stock ARB1. - failf(ctx, "branching unsupported in %s profile", ctx->profile->name); - else - { - // !!! FIXME: double-check this. - char labelstr[64]; - char scratch[64]; - char src1[64]; - get_ARB1_srcarg_varname(ctx, 0, labelstr, sizeof (labelstr)); - get_ARB1_srcarg_varname(ctx, 1, src1, sizeof (src1)); - allocate_ARB1_scratch_reg_name(ctx, scratch, sizeof (scratch)); - output_line(ctx, "MOVC %s, %s;", scratch, src1); - output_line(ctx, "CAL %s (NE.x);", labelstr); - } // else -} // emit_ARB1_CALLNZ - -// !!! FIXME: needs BRA in nv2, LOOP in nv2 fragment progs, and REP in nv4. -EMIT_ARB1_OPCODE_UNIMPLEMENTED_FUNC(LOOP) - -static void emit_ARB1_RET(Context *ctx) -{ - // don't fail() if no nv2...maybe we're just ending the mainline? - // if we're ending a LABEL that had no CALL, this would all be written - // to ctx->ignore anyhow, so this should be "safe" ... arb1 profile will - // just end up throwing all this code out. - if (support_nv2(ctx)) // no branching in stock ARB1. - output_line(ctx, "RET;"); - set_output(ctx, &ctx->mainline); // in case we were ignoring this function. -} // emit_ARB1_RET - - -EMIT_ARB1_OPCODE_UNIMPLEMENTED_FUNC(ENDLOOP) - -static void emit_ARB1_LABEL(Context *ctx) -{ - if (!support_nv2(ctx)) // no branching in stock ARB1. - return; // don't fail()...maybe we never use it, but do fail in CALL. - - const int label = ctx->source_args[0].regnum; - RegisterList *reg = reglist_find(&ctx->used_registers, REG_TYPE_LABEL, label); - - // MSDN specs say CALL* has to come before the LABEL, so we know if we - // can ditch the entire function here as unused. - if (reg == NULL) - set_output(ctx, &ctx->ignore); // Func not used. Parse, but don't output. - - // !!! FIXME: it would be nice if we could determine if a function is - // !!! FIXME: only called once and, if so, forcibly inline it. - - //const char *uses_loopreg = ((reg) && (reg->misc == 1)) ? "int aL" : ""; - char labelstr[64]; - get_ARB1_srcarg_varname(ctx, 0, labelstr, sizeof (labelstr)); - output_line(ctx, "%s:", labelstr); -} // emit_ARB1_LABEL - - -static void emit_ARB1_POW(Context *ctx) -{ - // we can optimize this to use nv2's |abs| construct in some cases. - if ( (ctx->source_args[0].src_mod == SRCMOD_NONE) || - (ctx->source_args[0].src_mod == SRCMOD_ABSNEGATE) ) - ctx->source_args[0].src_mod = SRCMOD_ABS; - - char dst[64]; make_ARB1_destarg_string(ctx, dst, sizeof (dst)); - char src0[64]; make_ARB1_srcarg_string(ctx, 0, src0, sizeof (src0)); - char src1[64]; make_ARB1_srcarg_string(ctx, 1, src1, sizeof (src1)); - - if (ctx->source_args[0].src_mod == SRCMOD_ABS) - output_line(ctx, "POW%s, %s, %s;", dst, src0, src1); - else - { - char buf[64]; allocate_ARB1_scratch_reg_name(ctx, buf, sizeof (buf)); - output_line(ctx, "ABS %s, %s;", buf, src0); - output_line(ctx, "POW%s, %s.x, %s;", dst, buf, src1); - } // else - - emit_ARB1_dest_modifiers(ctx); -} // emit_ARB1_POW - -static void emit_ARB1_CRS(Context *ctx) { emit_ARB1_opcode_dss(ctx, "XPD"); } - -static void emit_ARB1_SGN(Context *ctx) -{ - if (support_nv2(ctx)) - emit_ARB1_opcode_ds(ctx, "SSG"); - else - { - char dst[64]; - char src0[64]; - char scratch1[64]; - char scratch2[64]; - make_ARB1_destarg_string(ctx, dst, sizeof (dst)); - make_ARB1_srcarg_string(ctx, 0, src0, sizeof (src0)); - allocate_ARB1_scratch_reg_name(ctx, scratch1, sizeof (scratch1)); - allocate_ARB1_scratch_reg_name(ctx, scratch2, sizeof (scratch2)); - output_line(ctx, "SLT %s, %s, 0.0;", scratch1, src0); - output_line(ctx, "SLT %s, -%s, 0.0;", scratch2, src0); - output_line(ctx, "ADD%s -%s, %s;", dst, scratch1, scratch2); - emit_ARB1_dest_modifiers(ctx); - } // else -} // emit_ARB1_SGN - -EMIT_ARB1_OPCODE_DS_FUNC(ABS) - -static void emit_ARB1_NRM(Context *ctx) -{ - // nv2 fragment programs (and anything nv4) have a real NRM. - if ( (support_nv4(ctx)) || ((support_nv2(ctx)) && (shader_is_pixel(ctx))) ) - emit_ARB1_opcode_ds(ctx, "NRM"); - else - { - char dst[64]; make_ARB1_destarg_string(ctx, dst, sizeof (dst)); - char src0[64]; make_ARB1_srcarg_string(ctx, 0, src0, sizeof (src0)); - char buf[64]; allocate_ARB1_scratch_reg_name(ctx, buf, sizeof (buf)); - output_line(ctx, "DP3 %s.w, %s, %s;", buf, src0, src0); - output_line(ctx, "RSQ %s.w, %s.w;", buf, buf); - output_line(ctx, "MUL%s, %s.w, %s;", dst, buf, src0); - emit_ARB1_dest_modifiers(ctx); - } // else -} // emit_ARB1_NRM - - -static void emit_ARB1_SINCOS(Context *ctx) -{ - // we don't care about the temp registers that <= sm2 demands; ignore them. - const int mask = ctx->dest_arg.writemask; - - // arb1 fragment programs and everything nv4 have sin/cos/sincos opcodes. - if ((shader_is_pixel(ctx)) || (support_nv4(ctx))) - { - char dst[64]; make_ARB1_destarg_string(ctx, dst, sizeof (dst)); - char src0[64]; make_ARB1_srcarg_string(ctx, 0, src0, sizeof (src0)); - if (writemask_x(mask)) - output_line(ctx, "COS%s, %s;", dst, src0); - else if (writemask_y(mask)) - output_line(ctx, "SIN%s, %s;", dst, src0); - else if (writemask_xy(mask)) - output_line(ctx, "SCS%s, %s;", dst, src0); - } // if - - // nv2+ profiles have sin and cos opcodes. - else if (support_nv2(ctx)) - { - char dst[64]; get_ARB1_destarg_varname(ctx, dst, sizeof (dst)); - char src0[64]; make_ARB1_srcarg_string(ctx, 0, src0, sizeof (src0)); - if (writemask_x(mask)) - output_line(ctx, "COS %s.x, %s;", dst, src0); - else if (writemask_y(mask)) - output_line(ctx, "SIN %s.y, %s;", dst, src0); - else if (writemask_xy(mask)) - { - output_line(ctx, "SIN %s.x, %s;", dst, src0); - output_line(ctx, "COS %s.y, %s;", dst, src0); - } // else if - } // if - - else // big nasty. - { - char dst[64]; get_ARB1_destarg_varname(ctx, dst, sizeof (dst)); - char src0[64]; get_ARB1_srcarg_varname(ctx, 0, src0, sizeof (src0)); - const int need_sin = (writemask_x(mask) || writemask_xy(mask)); - const int need_cos = (writemask_y(mask) || writemask_xy(mask)); - char scratch[64]; - - if (need_sin || need_cos) - allocate_ARB1_scratch_reg_name(ctx, scratch, sizeof (scratch)); - - // These sin() and cos() approximations originally found here: - // http://www.devmaster.net/forums/showthread.php?t=5784 - // - // const float B = 4.0f / M_PI; - // const float C = -4.0f / (M_PI * M_PI); - // float y = B * x + C * x * fabs(x); - // - // // optional better precision... - // const float P = 0.225f; - // y = P * (y * fabs(y) - y) + y; - // - // - // That first thing can be reduced to: - // const float y = ((1.2732395447351626861510701069801f * x) + - // ((-0.40528473456935108577551785283891f * x) * fabs(x))); - - if (need_sin) - { - // !!! FIXME: use SRCMOD_ABS here? - output_line(ctx, "ABS %s.x, %s.x;", dst, src0); - output_line(ctx, "MUL %s.x, %s.x, -0.40528473456935108577551785283891;", dst, dst); - output_line(ctx, "MUL %s.x, %s.x, 1.2732395447351626861510701069801;", scratch, src0); - output_line(ctx, "MAD %s.x, %s.x, %s.x, %s.x;", dst, dst, src0, scratch); - } // if - - // cosine is sin(x + M_PI/2), but you have to wrap x to pi: - // if (x+(M_PI/2) > M_PI) - // x -= 2 * M_PI; - // - // which is... - // if (x+(1.57079637050628662109375) > 3.1415927410125732421875) - // x += -6.283185482025146484375; - - if (need_cos) - { - output_line(ctx, "ADD %s.x, %s.x, 1.57079637050628662109375;", scratch, src0); - output_line(ctx, "SGE %s.y, %s.x, 3.1415927410125732421875;", scratch, scratch); - output_line(ctx, "MAD %s.x, %s.y, -6.283185482025146484375, %s.x;", scratch, scratch, scratch); - output_line(ctx, "ABS %s.x, %s.x;", dst, src0); - output_line(ctx, "MUL %s.x, %s.x, -0.40528473456935108577551785283891;", dst, dst); - output_line(ctx, "MUL %s.x, %s.x, 1.2732395447351626861510701069801;", scratch, src0); - output_line(ctx, "MAD %s.y, %s.x, %s.x, %s.x;", dst, dst, src0, scratch); - } // if - } // else - - // !!! FIXME: might not have done anything. Don't emit if we didn't. - if (!isfail(ctx)) - emit_ARB1_dest_modifiers(ctx); -} // emit_ARB1_SINCOS - - -static void emit_ARB1_REP(Context *ctx) -{ - char src0[64]; make_ARB1_srcarg_string(ctx, 0, src0, sizeof (src0)); - - // nv2 fragment programs (and everything nv4) have a real REP. - if ( (support_nv4(ctx)) || ((support_nv2(ctx)) && (shader_is_pixel(ctx))) ) - output_line(ctx, "REP %s;", src0); - - else if (support_nv2(ctx)) - { - // no REP, but we can use branches. - char failbranch[32]; - char topbranch[32]; - const int toplabel = allocate_branch_label(ctx); - const int faillabel = allocate_branch_label(ctx); - get_ARB1_branch_label_name(ctx,faillabel,failbranch,sizeof(failbranch)); - get_ARB1_branch_label_name(ctx,toplabel,topbranch,sizeof(topbranch)); - - assert(((size_t) ctx->branch_labels_stack_index) < - STATICARRAYLEN(ctx->branch_labels_stack)-1); - - ctx->branch_labels_stack[ctx->branch_labels_stack_index++] = toplabel; - ctx->branch_labels_stack[ctx->branch_labels_stack_index++] = faillabel; - - char scratch[32]; - snprintf(scratch, sizeof (scratch), "rep%d", ctx->reps); - output_line(ctx, "MOVC %s.x, %s;", scratch, src0); - output_line(ctx, "BRA %s (LE.x);", failbranch); - output_line(ctx, "%s:", topbranch); - } // else if - - else // stock ARB1 has no branching. - { - fail(ctx, "branching unsupported in this profile"); - } // else -} // emit_ARB1_REP - - -static void emit_ARB1_ENDREP(Context *ctx) -{ - // nv2 fragment programs (and everything nv4) have a real ENDREP. - if ( (support_nv4(ctx)) || ((support_nv2(ctx)) && (shader_is_pixel(ctx))) ) - output_line(ctx, "ENDREP;"); - - else if (support_nv2(ctx)) - { - // no ENDREP, but we can use branches. - assert(ctx->branch_labels_stack_index >= 2); - - char failbranch[32]; - char topbranch[32]; - const int faillabel = ctx->branch_labels_stack[--ctx->branch_labels_stack_index]; - const int toplabel = ctx->branch_labels_stack[--ctx->branch_labels_stack_index]; - get_ARB1_branch_label_name(ctx,faillabel,failbranch,sizeof(failbranch)); - get_ARB1_branch_label_name(ctx,toplabel,topbranch,sizeof(topbranch)); - - char scratch[32]; - snprintf(scratch, sizeof (scratch), "rep%d", ctx->reps); - output_line(ctx, "SUBC %s.x, %s.x, 1.0;", scratch, scratch); - output_line(ctx, "BRA %s (GT.x);", topbranch); - output_line(ctx, "%s:", failbranch); - } // else if - - else // stock ARB1 has no branching. - { - fail(ctx, "branching unsupported in this profile"); - } // else -} // emit_ARB1_ENDREP - - -static void nv2_if(Context *ctx) -{ - // The condition code register MUST be set up before this! - // nv2 fragment programs (and everything nv4) have a real IF. - if ( (support_nv4(ctx)) || (shader_is_pixel(ctx)) ) - output_line(ctx, "IF EQ.x;"); - else - { - // there's no IF construct, but we can use a branch to a label. - char failbranch[32]; - const int label = allocate_branch_label(ctx); - get_ARB1_branch_label_name(ctx, label, failbranch, sizeof (failbranch)); - - assert(((size_t) ctx->branch_labels_stack_index) - < STATICARRAYLEN(ctx->branch_labels_stack)); - - ctx->branch_labels_stack[ctx->branch_labels_stack_index++] = label; - - // !!! FIXME: should this be NE? (EQ would jump to the ELSE for the IF condition, right?). - output_line(ctx, "BRA %s (EQ.x);", failbranch); - } // else -} // nv2_if - - -static void emit_ARB1_IF(Context *ctx) -{ - if (support_nv2(ctx)) - { - char buf[64]; allocate_ARB1_scratch_reg_name(ctx, buf, sizeof (buf)); - char src0[64]; get_ARB1_srcarg_varname(ctx, 0, src0, sizeof (src0)); - output_line(ctx, "MOVC %s.x, %s;", buf, src0); - nv2_if(ctx); - } // if - - else // stock ARB1 has no branching. - { - failf(ctx, "branching unsupported in %s profile", ctx->profile->name); - } // else -} // emit_ARB1_IF - - -static void emit_ARB1_ELSE(Context *ctx) -{ - // nv2 fragment programs (and everything nv4) have a real ELSE. - if ( (support_nv4(ctx)) || ((support_nv2(ctx)) && (shader_is_pixel(ctx))) ) - output_line(ctx, "ELSE;"); - - else if (support_nv2(ctx)) - { - // there's no ELSE construct, but we can use a branch to a label. - assert(ctx->branch_labels_stack_index > 0); - - // At the end of the IF block, unconditionally jump to the ENDIF. - const int endlabel = allocate_branch_label(ctx); - char endbranch[32]; - get_ARB1_branch_label_name(ctx,endlabel,endbranch,sizeof (endbranch)); - output_line(ctx, "BRA %s;", endbranch); - - // Now mark the ELSE section with a lable. - const int elselabel = ctx->branch_labels_stack[ctx->branch_labels_stack_index-1]; - char elsebranch[32]; - get_ARB1_branch_label_name(ctx,elselabel,elsebranch,sizeof(elsebranch)); - output_line(ctx, "%s:", elsebranch); - - // Replace the ELSE label with the ENDIF on the label stack. - ctx->branch_labels_stack[ctx->branch_labels_stack_index-1] = endlabel; - } // else if - - else // stock ARB1 has no branching. - { - failf(ctx, "branching unsupported in %s profile", ctx->profile->name); - } // else -} // emit_ARB1_ELSE - - -static void emit_ARB1_ENDIF(Context *ctx) -{ - // nv2 fragment programs (and everything nv4) have a real ENDIF. - if ( (support_nv4(ctx)) || ((support_nv2(ctx)) && (shader_is_pixel(ctx))) ) - output_line(ctx, "ENDIF;"); - - else if (support_nv2(ctx)) - { - // there's no ENDIF construct, but we can use a branch to a label. - assert(ctx->branch_labels_stack_index > 0); - const int endlabel = ctx->branch_labels_stack[--ctx->branch_labels_stack_index]; - char endbranch[32]; - get_ARB1_branch_label_name(ctx,endlabel,endbranch,sizeof (endbranch)); - output_line(ctx, "%s:", endbranch); - } // if - - else // stock ARB1 has no branching. - { - failf(ctx, "branching unsupported in %s profile", ctx->profile->name); - } // else -} // emit_ARB1_ENDIF - - -static void emit_ARB1_BREAK(Context *ctx) -{ - // nv2 fragment programs (and everything nv4) have a real BREAK. - if ( (support_nv4(ctx)) || ((support_nv2(ctx)) && (shader_is_pixel(ctx))) ) - output_line(ctx, "BRK;"); - - else if (support_nv2(ctx)) - { - // no BREAK, but we can use branches. - assert(ctx->branch_labels_stack_index >= 2); - const int faillabel = ctx->branch_labels_stack[ctx->branch_labels_stack_index]; - char failbranch[32]; - get_ARB1_branch_label_name(ctx,faillabel,failbranch,sizeof(failbranch)); - output_line(ctx, "BRA %s;", failbranch); - } // else if - - else // stock ARB1 has no branching. - { - failf(ctx, "branching unsupported in %s profile", ctx->profile->name); - } // else -} // emit_ARB1_BREAK - - -static void emit_ARB1_MOVA(Context *ctx) -{ - // nv2 and nv3 can use the ARR opcode. - // But nv4 removed ARR (and ADDRESS registers!). Just ROUND to an INT. - if (support_nv4(ctx)) - emit_ARB1_opcode_ds(ctx, "ROUND.S"); // !!! FIXME: don't use a modifier here. - else if ((support_nv2(ctx)) || (support_nv3(ctx))) - emit_ARB1_opcode_ds(ctx, "ARR"); - else - { - char src0[64]; - char scratch[64]; - char addr[32]; - - make_ARB1_srcarg_string(ctx, 0, src0, sizeof (src0)); - allocate_ARB1_scratch_reg_name(ctx, scratch, sizeof (scratch)); - snprintf(addr, sizeof (addr), "addr%d", ctx->dest_arg.regnum); - - // !!! FIXME: we can optimize this if src_mod is ABS or ABSNEGATE. - - // ARL uses floor(), but D3D expects round-to-nearest. - // There is probably a more efficient way to do this. - if (shader_is_pixel(ctx)) // CMP only exists in fragment programs. :/ - output_line(ctx, "CMP %s, %s, -1.0, 1.0;", scratch, src0); - else - { - output_line(ctx, "SLT %s, %s, 0.0;", scratch, src0); - output_line(ctx, "MAD %s, %s, -2.0, 1.0;", scratch, scratch); - } // else - - output_line(ctx, "ABS %s, %s;", addr, src0); - output_line(ctx, "ADD %s, %s, 0.5;", addr, addr); - output_line(ctx, "FLR %s, %s;", addr, addr); - output_line(ctx, "MUL %s, %s, %s;", addr, addr, scratch); - - // we don't handle these right now, since emit_ARB1_dest_modifiers(ctx) - // wants to look at dest_arg, not our temp register. - assert(ctx->dest_arg.result_mod == 0); - assert(ctx->dest_arg.result_shift == 0); - - // we assign to the actual address register as needed. - ctx->last_address_reg_component = -1; - } // else -} // emit_ARB1_MOVA - - -static void emit_ARB1_TEXKILL(Context *ctx) -{ - // d3d kills on xyz, arb1 kills on xyzw. Fix the swizzle. - // We just map the x component to w. If it's negative, the fragment - // would discard anyhow, otherwise, it'll pass through okay. This saves - // us a temp register. - char dst[64]; - get_ARB1_destarg_varname(ctx, dst, sizeof (dst)); - output_line(ctx, "KIL %s.xyzx;", dst); -} // emit_ARB1_TEXKILL - -EMIT_ARB1_OPCODE_UNIMPLEMENTED_FUNC(TEXBEM) -EMIT_ARB1_OPCODE_UNIMPLEMENTED_FUNC(TEXBEML) -EMIT_ARB1_OPCODE_UNIMPLEMENTED_FUNC(TEXREG2AR) -EMIT_ARB1_OPCODE_UNIMPLEMENTED_FUNC(TEXREG2GB) -EMIT_ARB1_OPCODE_UNIMPLEMENTED_FUNC(TEXM3X2PAD) -EMIT_ARB1_OPCODE_UNIMPLEMENTED_FUNC(TEXM3X2TEX) -EMIT_ARB1_OPCODE_UNIMPLEMENTED_FUNC(TEXM3X3PAD) -EMIT_ARB1_OPCODE_UNIMPLEMENTED_FUNC(TEXM3X3TEX) -EMIT_ARB1_OPCODE_UNIMPLEMENTED_FUNC(TEXM3X3SPEC) -EMIT_ARB1_OPCODE_UNIMPLEMENTED_FUNC(TEXM3X3VSPEC) - -static void emit_ARB1_EXPP(Context *ctx) { emit_ARB1_opcode_ds(ctx, "EX2"); } -static void emit_ARB1_LOGP(Context *ctx) { arb1_log(ctx, "LG2"); } - -EMIT_ARB1_OPCODE_UNIMPLEMENTED_FUNC(CND) -EMIT_ARB1_OPCODE_UNIMPLEMENTED_FUNC(TEXREG2RGB) -EMIT_ARB1_OPCODE_UNIMPLEMENTED_FUNC(TEXDP3TEX) -EMIT_ARB1_OPCODE_UNIMPLEMENTED_FUNC(TEXM3X2DEPTH) -EMIT_ARB1_OPCODE_UNIMPLEMENTED_FUNC(TEXDP3) -EMIT_ARB1_OPCODE_UNIMPLEMENTED_FUNC(TEXM3X3) -EMIT_ARB1_OPCODE_UNIMPLEMENTED_FUNC(TEXDEPTH) - -static void emit_ARB1_CMP(Context *ctx) -{ - char dst[64]; make_ARB1_destarg_string(ctx, dst, sizeof (dst)); - char src0[64]; make_ARB1_srcarg_string(ctx, 0, src0, sizeof (src0)); - char src1[64]; make_ARB1_srcarg_string(ctx, 1, src1, sizeof (src1)); - char src2[64]; make_ARB1_srcarg_string(ctx, 2, src2, sizeof (src2)); - // D3D tests (src0 >= 0.0), but ARB1 tests (src0 < 0.0) ... so just - // switch src1 and src2 to get the same results. - output_line(ctx, "CMP%s, %s, %s, %s;", dst, src0, src2, src1); - emit_ARB1_dest_modifiers(ctx); -} // emit_ARB1_CMP - -EMIT_ARB1_OPCODE_UNIMPLEMENTED_FUNC(BEM) - - -static void emit_ARB1_DP2ADD(Context *ctx) -{ - if (support_nv4(ctx)) // nv4 has a built-in equivalent to DP2ADD. - emit_ARB1_opcode_dsss(ctx, "DP2A"); - else - { - char dst[64]; make_ARB1_destarg_string(ctx, dst, sizeof (dst)); - char src0[64]; make_ARB1_srcarg_string(ctx, 0, src0, sizeof (src0)); - char src1[64]; make_ARB1_srcarg_string(ctx, 1, src1, sizeof (src1)); - char src2[64]; make_ARB1_srcarg_string(ctx, 2, src2, sizeof (src2)); - char scratch[64]; - - // DP2ADD is: - // dst = (src0.r * src1.r) + (src0.g * src1.g) + src2.replicate_swiz - allocate_ARB1_scratch_reg_name(ctx, scratch, sizeof (scratch)); - output_line(ctx, "MUL %s, %s, %s;", scratch, src0, src1); - output_line(ctx, "ADD %s, %s.x, %s.y;", scratch, scratch, scratch); - output_line(ctx, "ADD%s, %s.x, %s;", dst, scratch, src2); - emit_ARB1_dest_modifiers(ctx); - } // else -} // emit_ARB1_DP2ADD - - -static void emit_ARB1_DSX(Context *ctx) -{ - if (support_nv2(ctx)) // nv2 has a built-in equivalent to DSX. - emit_ARB1_opcode_ds(ctx, "DDX"); - else - failf(ctx, "DSX unsupported in %s profile", ctx->profile->name); -} // emit_ARB1_DSX - - -static void emit_ARB1_DSY(Context *ctx) -{ - if (support_nv2(ctx)) // nv2 has a built-in equivalent to DSY. - emit_ARB1_opcode_ds(ctx, "DDY"); - else - failf(ctx, "DSY unsupported in %s profile", ctx->profile->name); -} // emit_ARB1_DSY - -static void arb1_texld(Context *ctx, const char *opcode, const int texldd) -{ - // !!! FIXME: Hack: "TEXH" is invalid in nv4. Fix this more cleanly. - if ((ctx->dest_arg.result_mod & MOD_PP) && (support_nv4(ctx))) - ctx->dest_arg.result_mod &= ~MOD_PP; - - // !!! FIXME: do non-RGBA textures map to same default values as D3D? - char dst[64]; make_ARB1_destarg_string(ctx, dst, sizeof (dst)); - const SourceArgInfo *samp_arg = &ctx->source_args[1]; - RegisterList *sreg = reglist_find(&ctx->samplers, REG_TYPE_SAMPLER, - samp_arg->regnum); - const char *ttype = NULL; - char src0[64]; get_ARB1_srcarg_varname(ctx, 0, src0, sizeof (src0)); - //char src1[64]; get_ARB1_srcarg_varname(ctx, 1, src1, sizeof (src1)); // !!! FIXME: SRC_MOD? - - char src2[64] = { 0 }; - char src3[64] = { 0 }; - - if (texldd) - { - make_ARB1_srcarg_string(ctx, 2, src2, sizeof (src2)); - make_ARB1_srcarg_string(ctx, 3, src3, sizeof (src3)); - } // if - - // !!! FIXME: this should be in state_TEXLD, not in the arb1/glsl emitters. - if (sreg == NULL) - { - fail(ctx, "TEXLD using undeclared sampler"); - return; - } // if - - if (!no_swizzle(samp_arg->swizzle)) - { - // !!! FIXME: does this ever actually happen? - fail(ctx, "BUG: can't handle TEXLD with sampler swizzle at the moment"); - } // if - - switch ((const TextureType) sreg->index) - { - case TEXTURE_TYPE_2D: ttype = "2D"; break; // !!! FIXME: "RECT"? - case TEXTURE_TYPE_CUBE: ttype = "CUBE"; break; - case TEXTURE_TYPE_VOLUME: ttype = "3D"; break; - default: fail(ctx, "unknown texture type"); return; - } // switch - - if (texldd) - { - output_line(ctx, "%s%s, %s, %s, %s, texture[%d], %s;", opcode, dst, - src0, src2, src3, samp_arg->regnum, ttype); - } // if - else - { - output_line(ctx, "%s%s, %s, texture[%d], %s;", opcode, dst, src0, - samp_arg->regnum, ttype); - } // else -} // arb1_texld - - -static void emit_ARB1_TEXLDD(Context *ctx) -{ - // With GL_NV_fragment_program2, we can use the TXD opcode. - // In stock arb1, we can settle for a standard texld, which isn't - // perfect, but oh well. - if (support_nv2(ctx)) - arb1_texld(ctx, "TXD", 1); - else - arb1_texld(ctx, "TEX", 0); -} // emit_ARB1_TEXLDD - - -static void emit_ARB1_TEXLDL(Context *ctx) -{ - if ((shader_is_vertex(ctx)) && (!support_nv3(ctx))) - { - failf(ctx, "Vertex shader TEXLDL unsupported in %s profile", - ctx->profile->name); - return; - } // if - - else if ((shader_is_pixel(ctx)) && (!support_nv2(ctx))) - { - failf(ctx, "Pixel shader TEXLDL unsupported in %s profile", - ctx->profile->name); - return; - } // if - - // !!! FIXME: this doesn't map exactly to TEXLDL. Review this. - arb1_texld(ctx, "TXL", 0); -} // emit_ARB1_TEXLDL - - -EMIT_ARB1_OPCODE_UNIMPLEMENTED_FUNC(BREAKP) -EMIT_ARB1_OPCODE_UNIMPLEMENTED_FUNC(BREAKC) - -static void emit_ARB1_IFC(Context *ctx) -{ - if (support_nv2(ctx)) - { - static const char *comps[] = { - "", "SGTC", "SEQC", "SGEC", "SGTC", "SNEC", "SLEC" - }; - - if (ctx->instruction_controls >= STATICARRAYLEN(comps)) - { - fail(ctx, "unknown comparison control"); - return; - } // if - - char src0[64]; - char src1[64]; - char scratch[64]; - - const char *comp = comps[ctx->instruction_controls]; - get_ARB1_srcarg_varname(ctx, 0, src0, sizeof (src0)); - get_ARB1_srcarg_varname(ctx, 1, src1, sizeof (src1)); - allocate_ARB1_scratch_reg_name(ctx, scratch, sizeof (scratch)); - output_line(ctx, "%s %s.x, %s, %s;", comp, scratch, src0, src1); - nv2_if(ctx); - } // if - - else // stock ARB1 has no branching. - { - failf(ctx, "branching unsupported in %s profile", ctx->profile->name); - } // else -} // emit_ARB1_IFC - - -EMIT_ARB1_OPCODE_UNIMPLEMENTED_FUNC(SETP) - -static void emit_ARB1_DEF(Context *ctx) -{ - const float *val = (const float *) ctx->dwords; // !!! FIXME: could be int? - char dst[64]; get_ARB1_destarg_varname(ctx, dst, sizeof (dst)); - char val0[32]; floatstr(ctx, val0, sizeof (val0), val[0], 1); - char val1[32]; floatstr(ctx, val1, sizeof (val1), val[1], 1); - char val2[32]; floatstr(ctx, val2, sizeof (val2), val[2], 1); - char val3[32]; floatstr(ctx, val3, sizeof (val3), val[3], 1); - - push_output(ctx, &ctx->globals); - output_line(ctx, "PARAM %s = { %s, %s, %s, %s };", - dst, val0, val1, val2, val3); - pop_output(ctx); -} // emit_ARB1_DEF - -static void emit_ARB1_DEFI(Context *ctx) -{ - char dst[64]; get_ARB1_destarg_varname(ctx, dst, sizeof (dst)); - const int32 *x = (const int32 *) ctx->dwords; - push_output(ctx, &ctx->globals); - output_line(ctx, "PARAM %s = { %d, %d, %d, %d };", - dst, (int) x[0], (int) x[1], (int) x[2], (int) x[3]); - pop_output(ctx); -} // emit_ARB1_DEFI - -static void emit_ARB1_DEFB(Context *ctx) -{ - char dst[64]; get_ARB1_destarg_varname(ctx, dst, sizeof (dst)); - push_output(ctx, &ctx->globals); - output_line(ctx, "PARAM %s = %d;", dst, ctx->dwords[0] ? 1 : 0); - pop_output(ctx); -} // emit_ARB1_DEFB - -static void emit_ARB1_DCL(Context *ctx) -{ - // no-op. We do this in our emit_attribute() and emit_uniform(). -} // emit_ARB1_DCL - -EMIT_ARB1_OPCODE_UNIMPLEMENTED_FUNC(TEXCRD) - -static void emit_ARB1_TEXLD(Context *ctx) -{ - if (!shader_version_atleast(ctx, 2, 0)) - { - // ps_1_0 and ps_1_4 are both different, too! - fail(ctx, "TEXLD <= Shader Model 2.0 unimplemented."); // !!! FIXME - return; - } // if - - // !!! FIXME: do texldb and texldp map between OpenGL and D3D correctly? - if (ctx->instruction_controls == CONTROL_TEXLD) - arb1_texld(ctx, "TEX", 0); - else if (ctx->instruction_controls == CONTROL_TEXLDP) - arb1_texld(ctx, "TXP", 0); - else if (ctx->instruction_controls == CONTROL_TEXLDB) - arb1_texld(ctx, "TXB", 0); -} // emit_ARB1_TEXLD - -#endif // SUPPORT_PROFILE_ARB1 - - -#if !AT_LEAST_ONE_PROFILE -#error No profiles are supported. Fix your build. -#endif - -#define DEFINE_PROFILE(prof) { \ - MOJOSHADER_PROFILE_##prof, \ - emit_##prof##_start, \ - emit_##prof##_end, \ - emit_##prof##_phase, \ - emit_##prof##_global, \ - emit_##prof##_array, \ - emit_##prof##_const_array, \ - emit_##prof##_uniform, \ - emit_##prof##_sampler, \ - emit_##prof##_attribute, \ - emit_##prof##_finalize, \ - get_##prof##_varname, \ - get_##prof##_const_array_varname, \ -}, - -static const Profile profiles[] = -{ -#if SUPPORT_PROFILE_D3D - DEFINE_PROFILE(D3D) -#endif -#if SUPPORT_PROFILE_BYTECODE - DEFINE_PROFILE(BYTECODE) -#endif -#if SUPPORT_PROFILE_GLSL - DEFINE_PROFILE(GLSL) -#endif -#if SUPPORT_PROFILE_ARB1 - DEFINE_PROFILE(ARB1) -#endif -}; - -#undef DEFINE_PROFILE - -// This is for profiles that extend other profiles... -static const struct { const char *from; const char *to; } profileMap[] = -{ - { MOJOSHADER_PROFILE_GLSL120, MOJOSHADER_PROFILE_GLSL }, - { MOJOSHADER_PROFILE_NV2, MOJOSHADER_PROFILE_ARB1 }, - { MOJOSHADER_PROFILE_NV3, MOJOSHADER_PROFILE_ARB1 }, - { MOJOSHADER_PROFILE_NV4, MOJOSHADER_PROFILE_ARB1 }, -}; - - -// The PROFILE_EMITTER_* items MUST be in the same order as profiles[]! -#define PROFILE_EMITTERS(op) { \ - PROFILE_EMITTER_D3D(op) \ - PROFILE_EMITTER_BYTECODE(op) \ - PROFILE_EMITTER_GLSL(op) \ - PROFILE_EMITTER_ARB1(op) \ -} - -static int parse_destination_token(Context *ctx, DestArgInfo *info) -{ - // !!! FIXME: recheck against the spec for ranges (like RASTOUT values, etc). - if (ctx->tokencount == 0) - { - fail(ctx, "Out of tokens in destination parameter"); - return 0; - } // if - - const uint32 token = SWAP32(*(ctx->tokens)); - const int reserved1 = (int) ((token >> 14) & 0x3); // bits 14 through 15 - const int reserved2 = (int) ((token >> 31) & 0x1); // bit 31 - - info->token = ctx->tokens; - info->regnum = (int) (token & 0x7ff); // bits 0 through 10 - info->relative = (int) ((token >> 13) & 0x1); // bit 13 - info->orig_writemask = (int) ((token >> 16) & 0xF); // bits 16 through 19 - info->result_mod = (int) ((token >> 20) & 0xF); // bits 20 through 23 - info->result_shift = (int) ((token >> 24) & 0xF); // bits 24 through 27 abc - info->regtype = (RegisterType) (((token >> 28) & 0x7) | ((token >> 8) & 0x18)); // bits 28-30, 11-12 - - int writemask; - if (isscalar(ctx, ctx->shader_type, info->regtype, info->regnum)) - writemask = 0x1; // just x. - else - writemask = info->orig_writemask; - - info->writemask = writemask; - info->writemask0 = (int) ((writemask >> 0) & 0x1); // bit 16 - info->writemask1 = (int) ((writemask >> 1) & 0x1); // bit 17 - info->writemask2 = (int) ((writemask >> 2) & 0x1); // bit 18 - info->writemask3 = (int) ((writemask >> 3) & 0x1); // bit 19 - - // all the REG_TYPE_CONSTx types are the same register type, it's just - // split up so its regnum can be > 2047 in the bytecode. Clean it up. - if (info->regtype == REG_TYPE_CONST2) - { - info->regtype = REG_TYPE_CONST; - info->regnum += 2048; - } // else if - else if (info->regtype == REG_TYPE_CONST3) - { - info->regtype = REG_TYPE_CONST; - info->regnum += 4096; - } // else if - else if (info->regtype == REG_TYPE_CONST4) - { - info->regtype = REG_TYPE_CONST; - info->regnum += 6144; - } // else if - - // swallow token for now, for multiple calls in a row. - adjust_token_position(ctx, 1); - - if (reserved1 != 0x0) - fail(ctx, "Reserved bit #1 in destination token must be zero"); - - if (reserved2 != 0x1) - fail(ctx, "Reserved bit #2 in destination token must be one"); - - if (info->relative) - { - if (!shader_is_vertex(ctx)) - fail(ctx, "Relative addressing in non-vertex shader"); - if (!shader_version_atleast(ctx, 3, 0)) - fail(ctx, "Relative addressing in vertex shader version < 3.0"); - if ((!ctx->ctab.have_ctab) && (!ctx->ignores_ctab)) - { - // it's hard to do this efficiently without! - fail(ctx, "relative addressing unsupported without a CTAB"); - } // if - - // !!! FIXME: I don't have a shader that has a relative dest currently. - fail(ctx, "Relative addressing of dest tokens is unsupported"); - return 2; - } // if - - const int s = info->result_shift; - if (s != 0) - { - if (!shader_is_pixel(ctx)) - fail(ctx, "Result shift scale in non-pixel shader"); - if (shader_version_atleast(ctx, 2, 0)) - fail(ctx, "Result shift scale in pixel shader version >= 2.0"); - if ( ! (((s >= 1) && (s <= 3)) || ((s >= 0xD) && (s <= 0xF))) ) - fail(ctx, "Result shift scale isn't 1 to 3, or 13 to 15."); - } // if - - if (info->result_mod & MOD_PP) // Partial precision (pixel shaders only) - { - if (!shader_is_pixel(ctx)) - fail(ctx, "Partial precision result mod in non-pixel shader"); - } // if - - if (info->result_mod & MOD_CENTROID) // Centroid (pixel shaders only) - { - if (!shader_is_pixel(ctx)) - fail(ctx, "Centroid result mod in non-pixel shader"); - else if (!ctx->centroid_allowed) // only on DCL opcodes! - fail(ctx, "Centroid modifier not allowed here"); - } // if - - if ((info->regtype < 0) || (info->regtype > REG_TYPE_MAX)) - fail(ctx, "Register type is out of range"); - - if (!isfail(ctx)) - set_used_register(ctx, info->regtype, info->regnum); - - return 1; -} // parse_destination_token - - -static void determine_constants_arrays(Context *ctx) -{ - // Only process this stuff once. This is called after all DEF* opcodes - // could have been parsed. - if (ctx->determined_constants_arrays) - return; - - ctx->determined_constants_arrays = 1; - - if (ctx->constant_count <= 1) - return; // nothing to sort or group. - - // Sort the linked list into an array for easier tapdancing... - ConstantsList **array = (ConstantsList **) alloca(sizeof (ConstantsList *) * (ctx->constant_count + 1)); - ConstantsList *item = ctx->constants; - int i; - - for (i = 0; i < ctx->constant_count; i++) - { - if (item == NULL) - { - fail(ctx, "BUG: mismatched constant list and count"); - return; - } // if - - array[i] = item; - item = item->next; - } // for - - array[ctx->constant_count] = NULL; - - // bubble sort ftw. - int sorted; - do - { - sorted = 1; - for (i = 0; i < ctx->constant_count-1; i++) - { - if (array[i]->constant.index > array[i+1]->constant.index) - { - ConstantsList *tmp = array[i]; - array[i] = array[i+1]; - array[i+1] = tmp; - sorted = 0; - } // if - } // for - } while (!sorted); - - // okay, sorted. While we're here, let's redo the linked list in order... - for (i = 0; i < ctx->constant_count; i++) - array[i]->next = array[i+1]; - ctx->constants = array[0]; - - // now figure out the groupings of constants and add to ctx->variables... - int start = -1; - int prev = -1; - int count = 0; - const int hi = ctx->constant_count; - for (i = 0; i <= hi; i++) - { - if (array[i] && (array[i]->constant.type != MOJOSHADER_UNIFORM_FLOAT)) - continue; // we only care about REG_TYPE_CONST for array groups. - - if (start == -1) - { - prev = start = i; // first REG_TYPE_CONST we've seen. Mark it! - continue; - } // if - - // not a match (or last item in the array)...see if we had a - // contiguous set before this point... - if ( (array[i]) && (array[i]->constant.index == (array[prev]->constant.index + 1)) ) - count++; - else - { - if (count > 0) // multiple constants in the set? - { - VariableList *var; - var = (VariableList *) Malloc(ctx, sizeof (VariableList)); - if (var == NULL) - break; - - var->type = MOJOSHADER_UNIFORM_FLOAT; - var->index = array[start]->constant.index; - var->count = (array[prev]->constant.index - var->index) + 1; - var->constant = array[start]; - var->used = 0; - var->emit_position = -1; - var->next = ctx->variables; - ctx->variables = var; - } // else - - start = i; // set this as new start of sequence. - } // if - - prev = i; - } // for -} // determine_constants_arrays - - -static int adjust_swizzle(const Context *ctx, const RegisterType regtype, - const int regnum, const int swizzle) -{ - if (regtype != REG_TYPE_INPUT) // !!! FIXME: maybe lift this later? - return swizzle; - else if (ctx->swizzles_count == 0) - return swizzle; - - const RegisterList *reg = reglist_find(&ctx->attributes, regtype, regnum); - if (reg == NULL) - return swizzle; - - size_t i; - for (i = 0; i < ctx->swizzles_count; i++) - { - const MOJOSHADER_swizzle *swiz = &ctx->swizzles[i]; - if ((swiz->usage == reg->usage) && (swiz->index == reg->index)) - { - return ( (((int)(swiz->swizzles[((swizzle >> 0) & 0x3)])) << 0) | - (((int)(swiz->swizzles[((swizzle >> 2) & 0x3)])) << 2) | - (((int)(swiz->swizzles[((swizzle >> 4) & 0x3)])) << 4) | - (((int)(swiz->swizzles[((swizzle >> 6) & 0x3)])) << 6) ); - } // if - } // for - - return swizzle; -} // adjust_swizzle - - -static int parse_source_token(Context *ctx, SourceArgInfo *info) -{ - int retval = 1; - - if (ctx->tokencount == 0) - { - fail(ctx, "Out of tokens in source parameter"); - return 0; - } // if - - const uint32 token = SWAP32(*(ctx->tokens)); - const int reserved1 = (int) ((token >> 14) & 0x3); // bits 14 through 15 - const int reserved2 = (int) ((token >> 31) & 0x1); // bit 31 - - info->token = ctx->tokens; - info->regnum = (int) (token & 0x7ff); // bits 0 through 10 - info->relative = (int) ((token >> 13) & 0x1); // bit 13 - const int swizzle = (int) ((token >> 16) & 0xFF); // bits 16 through 23 - info->src_mod = (SourceMod) ((token >> 24) & 0xF); // bits 24 through 27 - info->regtype = (RegisterType) (((token >> 28) & 0x7) | ((token >> 8) & 0x18)); // bits 28-30, 11-12 - - // all the REG_TYPE_CONSTx types are the same register type, it's just - // split up so its regnum can be > 2047 in the bytecode. Clean it up. - if (info->regtype == REG_TYPE_CONST2) - { - info->regtype = REG_TYPE_CONST; - info->regnum += 2048; - } // else if - else if (info->regtype == REG_TYPE_CONST3) - { - info->regtype = REG_TYPE_CONST; - info->regnum += 4096; - } // else if - else if (info->regtype == REG_TYPE_CONST4) - { - info->regtype = REG_TYPE_CONST; - info->regnum += 6144; - } // else if - - info->swizzle = adjust_swizzle(ctx, info->regtype, info->regnum, swizzle); - info->swizzle_x = ((info->swizzle >> 0) & 0x3); - info->swizzle_y = ((info->swizzle >> 2) & 0x3); - info->swizzle_z = ((info->swizzle >> 4) & 0x3); - info->swizzle_w = ((info->swizzle >> 6) & 0x3); - - // swallow token for now, for multiple calls in a row. - adjust_token_position(ctx, 1); - - if (reserved1 != 0x0) - fail(ctx, "Reserved bits #1 in source token must be zero"); - - if (reserved2 != 0x1) - fail(ctx, "Reserved bit #2 in source token must be one"); - - if ((info->relative) && (ctx->tokencount == 0)) - { - fail(ctx, "Out of tokens in relative source parameter"); - info->relative = 0; // don't try to process it. - } // if - - if (info->relative) - { - if ( (shader_is_pixel(ctx)) && (!shader_version_atleast(ctx, 3, 0)) ) - fail(ctx, "Relative addressing in pixel shader version < 3.0"); - - const uint32 reltoken = SWAP32(*(ctx->tokens)); - // swallow token for now, for multiple calls in a row. - adjust_token_position(ctx, 1); - - const int relswiz = (int) ((reltoken >> 16) & 0xFF); - info->relative_regnum = (int) (reltoken & 0x7ff); - info->relative_regtype = (RegisterType) - (((reltoken >> 28) & 0x7) | - ((reltoken >> 8) & 0x18)); - - if (((reltoken >> 31) & 0x1) == 0) - fail(ctx, "bit #31 in relative address must be set"); - - if ((reltoken & 0xF00E000) != 0) // usused bits. - fail(ctx, "relative address reserved bit must be zero"); - - switch (info->relative_regtype) - { - case REG_TYPE_LOOP: - case REG_TYPE_ADDRESS: - break; - default: - fail(ctx, "invalid register for relative address"); - break; - } // switch - - if (info->relative_regnum != 0) // true for now. - fail(ctx, "invalid register for relative address"); - - if (!replicate_swizzle(relswiz)) - fail(ctx, "relative address needs replicate swizzle"); - - info->relative_component = (relswiz & 0x3); - - if (info->regtype == REG_TYPE_INPUT) - { - if ( (shader_is_pixel(ctx)) || (!shader_version_atleast(ctx, 3, 0)) ) - fail(ctx, "relative addressing of input registers not supported in this shader model"); - ctx->have_relative_input_registers = 1; - } // if - else if (info->regtype == REG_TYPE_CONST) - { - // figure out what array we're in... - if (!ctx->ignores_ctab) - { - if (!ctx->ctab.have_ctab) // hard to do efficiently without! - fail(ctx, "relative addressing unsupported without a CTAB"); - else - { - determine_constants_arrays(ctx); - - VariableList *var; - const int reltarget = info->regnum; - for (var = ctx->variables; var != NULL; var = var->next) - { - const int lo = var->index; - if ( (reltarget >= lo) && (reltarget < (lo + var->count)) ) - break; // match! - } // for - - if (var == NULL) - fail(ctx, "relative addressing of indeterminate array"); - else - { - var->used = 1; - info->relative_array = var; - set_used_register(ctx, info->relative_regtype, info->relative_regnum); - } // else - } // else - } // if - } // else if - else - { - fail(ctx, "relative addressing of invalid register"); - } // else - - retval++; - } // if - - switch (info->src_mod) - { - case SRCMOD_NONE: - case SRCMOD_ABSNEGATE: - case SRCMOD_ABS: - case SRCMOD_NEGATE: - break; // okay in any shader model. - - // apparently these are only legal in Shader Model 1.x ... - case SRCMOD_BIASNEGATE: - case SRCMOD_BIAS: - case SRCMOD_SIGNNEGATE: - case SRCMOD_SIGN: - case SRCMOD_COMPLEMENT: - case SRCMOD_X2NEGATE: - case SRCMOD_X2: - case SRCMOD_DZ: - case SRCMOD_DW: - if (shader_version_atleast(ctx, 2, 0)) - fail(ctx, "illegal source mod for this Shader Model."); - break; - - case SRCMOD_NOT: // !!! FIXME: I _think_ this is right... - if (shader_version_atleast(ctx, 2, 0)) - { - if (info->regtype != REG_TYPE_PREDICATE) - fail(ctx, "NOT only allowed on predicate register."); - } // if - break; - - default: - fail(ctx, "Unknown source modifier"); - } // switch - - // !!! FIXME: docs say this for sm3 ... check these! - // "The negate modifier cannot be used on second source register of these - // instructions: m3x2 - ps, m3x3 - ps, m3x4 - ps, m4x3 - ps, and - // m4x4 - ps." - // "If any version 3 shader reads from one or more constant float - // registers (c#), one of the following must be true. - // All of the constant floating-point registers must use the abs modifier. - // None of the constant floating-point registers can use the abs modifier. - - if (!isfail(ctx)) - set_used_register(ctx, info->regtype, info->regnum); - - return retval; -} // parse_source_token - - -static int parse_predicated_token(Context *ctx) -{ - SourceArgInfo *arg = &ctx->predicate_arg; - parse_source_token(ctx, arg); - if (arg->regtype != REG_TYPE_PREDICATE) - fail(ctx, "Predicated instruction but not predicate register!"); - if ((arg->src_mod != SRCMOD_NONE) && (arg->src_mod != SRCMOD_NOT)) - fail(ctx, "Predicated instruction register is not NONE or NOT"); - if ( !no_swizzle(arg->swizzle) && !replicate_swizzle(arg->swizzle) ) - fail(ctx, "Predicated instruction register has wrong swizzle"); - if (arg->relative) // I'm pretty sure this is illegal...? - fail(ctx, "relative addressing in predicated token"); - - return 1; -} // parse_predicated_token - - -static int parse_args_NULL(Context *ctx) -{ - return 1; -} // parse_args_NULL - - -static int parse_args_DEF(Context *ctx) -{ - parse_destination_token(ctx, &ctx->dest_arg); - if (ctx->dest_arg.regtype != REG_TYPE_CONST) - fail(ctx, "DEF using non-CONST register"); - if (ctx->dest_arg.relative) // I'm pretty sure this is illegal...? - fail(ctx, "relative addressing in DEF"); - - ctx->dwords[0] = SWAP32(ctx->tokens[0]); - ctx->dwords[1] = SWAP32(ctx->tokens[1]); - ctx->dwords[2] = SWAP32(ctx->tokens[2]); - ctx->dwords[3] = SWAP32(ctx->tokens[3]); - - return 6; -} // parse_args_DEF - - -static int parse_args_DEFI(Context *ctx) -{ - parse_destination_token(ctx, &ctx->dest_arg); - if (ctx->dest_arg.regtype != REG_TYPE_CONSTINT) - fail(ctx, "DEFI using non-CONSTING register"); - if (ctx->dest_arg.relative) // I'm pretty sure this is illegal...? - fail(ctx, "relative addressing in DEFI"); - - ctx->dwords[0] = SWAP32(ctx->tokens[0]); - ctx->dwords[1] = SWAP32(ctx->tokens[1]); - ctx->dwords[2] = SWAP32(ctx->tokens[2]); - ctx->dwords[3] = SWAP32(ctx->tokens[3]); - - return 6; -} // parse_args_DEFI - - -static int parse_args_DEFB(Context *ctx) -{ - parse_destination_token(ctx, &ctx->dest_arg); - if (ctx->dest_arg.regtype != REG_TYPE_CONSTBOOL) - fail(ctx, "DEFB using non-CONSTBOOL register"); - if (ctx->dest_arg.relative) // I'm pretty sure this is illegal...? - fail(ctx, "relative addressing in DEFB"); - - ctx->dwords[0] = *(ctx->tokens) ? 1 : 0; - - return 3; -} // parse_args_DEFB - - -static int valid_texture_type(const uint32 ttype) -{ - switch ((const TextureType) ttype) - { - case TEXTURE_TYPE_2D: - case TEXTURE_TYPE_CUBE: - case TEXTURE_TYPE_VOLUME: - return 1; // it's okay. - } // switch - - return 0; -} // valid_texture_type - - -// !!! FIXME: this function is kind of a mess. -static int parse_args_DCL(Context *ctx) -{ - int unsupported = 0; - const uint32 token = SWAP32(*(ctx->tokens)); - const int reserved1 = (int) ((token >> 31) & 0x1); // bit 31 - uint32 reserved_mask = 0x00000000; - - if (reserved1 != 0x1) - fail(ctx, "Bit #31 in DCL token must be one"); - - ctx->centroid_allowed = 1; - adjust_token_position(ctx, 1); - parse_destination_token(ctx, &ctx->dest_arg); - ctx->centroid_allowed = 0; - - if (ctx->dest_arg.result_shift != 0) // I'm pretty sure this is illegal...? - fail(ctx, "shift scale in DCL"); - if (ctx->dest_arg.relative) // I'm pretty sure this is illegal...? - fail(ctx, "relative addressing in DCL"); - - const RegisterType regtype = ctx->dest_arg.regtype; - const int regnum = ctx->dest_arg.regnum; - if ( (shader_is_pixel(ctx)) && (shader_version_atleast(ctx, 3, 0)) ) - { - if (regtype == REG_TYPE_INPUT) - { - const uint32 usage = (token & 0xF); - const uint32 index = ((token >> 16) & 0xF); - reserved_mask = 0x7FF0FFE0; - ctx->dwords[0] = usage; - ctx->dwords[1] = index; - } // if - - else if (regtype == REG_TYPE_MISCTYPE) - { - const MiscTypeType mt = (MiscTypeType) regnum; - if (mt == MISCTYPE_TYPE_POSITION) - reserved_mask = 0x7FFFFFFF; - else if (mt == MISCTYPE_TYPE_FACE) - { - reserved_mask = 0x7FFFFFFF; - if (!writemask_xyzw(ctx->dest_arg.orig_writemask)) - fail(ctx, "DCL face writemask must be full"); - if (ctx->dest_arg.result_mod != 0) - fail(ctx, "DCL face result modifier must be zero"); - if (ctx->dest_arg.result_shift != 0) - fail(ctx, "DCL face shift scale must be zero"); - } // else if - else - { - unsupported = 1; - } // else - - ctx->dwords[0] = (uint32) MOJOSHADER_USAGE_UNKNOWN; - ctx->dwords[1] = 0; - } // else if - - else if (regtype == REG_TYPE_TEXTURE) - { - const uint32 usage = (token & 0xF); - const uint32 index = ((token >> 16) & 0xF); - if (usage == MOJOSHADER_USAGE_TEXCOORD) - { - if (index > 7) - fail(ctx, "DCL texcoord usage must have 0-7 index"); - } // if - else if (usage == MOJOSHADER_USAGE_COLOR) - { - if (index != 0) - fail(ctx, "DCL color usage must have 0 index"); - } // else if - else - { - fail(ctx, "Invalid DCL texture usage"); - } // else - - reserved_mask = 0x7FF0FFE0; - ctx->dwords[0] = usage; - ctx->dwords[1] = index; - } // else if - - else if (regtype == REG_TYPE_SAMPLER) - { - const uint32 ttype = ((token >> 27) & 0xF); - if (!valid_texture_type(ttype)) - fail(ctx, "unknown sampler texture type"); - reserved_mask = 0x7FFFFFF; - ctx->dwords[0] = ttype; - } // else if - - else - { - unsupported = 1; - } // else - } // if - - else if ( (shader_is_pixel(ctx)) && (shader_version_atleast(ctx, 2, 0)) ) - { - if (regtype == REG_TYPE_INPUT) - { - ctx->dwords[0] = (uint32) MOJOSHADER_USAGE_COLOR; - ctx->dwords[1] = regnum; - reserved_mask = 0x7FFFFFFF; - } // if - else if (regtype == REG_TYPE_TEXTURE) - { - ctx->dwords[0] = (uint32) MOJOSHADER_USAGE_TEXCOORD; - ctx->dwords[1] = regnum; - reserved_mask = 0x7FFFFFFF; - } // else if - else if (regtype == REG_TYPE_SAMPLER) - { - const uint32 ttype = ((token >> 27) & 0xF); - if (!valid_texture_type(ttype)) - fail(ctx, "unknown sampler texture type"); - reserved_mask = 0x7FFFFFF; - ctx->dwords[0] = ttype; - } // else if - else - { - unsupported = 1; - } // else - } // if - - else if ( (shader_is_vertex(ctx)) && (shader_version_atleast(ctx, 3, 0)) ) - { - if ((regtype == REG_TYPE_INPUT) || (regtype == REG_TYPE_OUTPUT)) - { - const uint32 usage = (token & 0xF); - const uint32 index = ((token >> 16) & 0xF); - reserved_mask = 0x7FF0FFE0; - ctx->dwords[0] = usage; - ctx->dwords[1] = index; - } // if - else - { - unsupported = 1; - } // else - } // else if - - else if ( (shader_is_vertex(ctx)) && (shader_version_atleast(ctx, 1, 1)) ) - { - if (regtype == REG_TYPE_INPUT) - { - const uint32 usage = (token & 0xF); - const uint32 index = ((token >> 16) & 0xF); - reserved_mask = 0x7FF0FFE0; - ctx->dwords[0] = usage; - ctx->dwords[1] = index; - } // if - else - { - unsupported = 1; - } // else - } // else if - - else - { - unsupported = 1; - } // else - - if (unsupported) - fail(ctx, "invalid DCL register type for this shader model"); - - if ((token & reserved_mask) != 0) - fail(ctx, "reserved bits in DCL dword aren't zero"); - - return 3; -} // parse_args_DCL - - -static int parse_args_D(Context *ctx) -{ - int retval = 1; - retval += parse_destination_token(ctx, &ctx->dest_arg); - return retval; -} // parse_args_D - - -static int parse_args_S(Context *ctx) -{ - int retval = 1; - retval += parse_source_token(ctx, &ctx->source_args[0]); - return retval; -} // parse_args_S - - -static int parse_args_SS(Context *ctx) -{ - int retval = 1; - retval += parse_source_token(ctx, &ctx->source_args[0]); - retval += parse_source_token(ctx, &ctx->source_args[1]); - return retval; -} // parse_args_SS - - -static int parse_args_DS(Context *ctx) -{ - int retval = 1; - retval += parse_destination_token(ctx, &ctx->dest_arg); - retval += parse_source_token(ctx, &ctx->source_args[0]); - return retval; -} // parse_args_DS - - -static int parse_args_DSS(Context *ctx) -{ - int retval = 1; - retval += parse_destination_token(ctx, &ctx->dest_arg); - retval += parse_source_token(ctx, &ctx->source_args[0]); - retval += parse_source_token(ctx, &ctx->source_args[1]); - return retval; -} // parse_args_DSS - - -static int parse_args_DSSS(Context *ctx) -{ - int retval = 1; - retval += parse_destination_token(ctx, &ctx->dest_arg); - retval += parse_source_token(ctx, &ctx->source_args[0]); - retval += parse_source_token(ctx, &ctx->source_args[1]); - retval += parse_source_token(ctx, &ctx->source_args[2]); - return retval; -} // parse_args_DSSS - - -static int parse_args_DSSSS(Context *ctx) -{ - int retval = 1; - retval += parse_destination_token(ctx, &ctx->dest_arg); - retval += parse_source_token(ctx, &ctx->source_args[0]); - retval += parse_source_token(ctx, &ctx->source_args[1]); - retval += parse_source_token(ctx, &ctx->source_args[2]); - retval += parse_source_token(ctx, &ctx->source_args[3]); - return retval; -} // parse_args_DSSSS - - -static int parse_args_SINCOS(Context *ctx) -{ - // this opcode needs extra registers for sm2 and lower. - if (!shader_version_atleast(ctx, 3, 0)) - return parse_args_DSSS(ctx); - return parse_args_DS(ctx); -} // parse_args_SINCOS - - -static int parse_args_TEXCRD(Context *ctx) -{ - // added extra register in ps_1_4. - if (shader_version_atleast(ctx, 1, 4)) - return parse_args_DS(ctx); - return parse_args_D(ctx); -} // parse_args_TEXCRD - - -static int parse_args_TEXLD(Context *ctx) -{ - // different registers in px_1_3, ps_1_4, and ps_2_0! - if (shader_version_atleast(ctx, 2, 0)) - return parse_args_DSS(ctx); - else if (shader_version_atleast(ctx, 1, 4)) - return parse_args_DS(ctx); - return parse_args_D(ctx); -} // parse_args_TEXLD - - -// State machine functions... - -static ConstantsList *alloc_constant_listitem(Context *ctx) -{ - ConstantsList *item = (ConstantsList *) Malloc(ctx, sizeof (ConstantsList)); - if (item == NULL) - return NULL; - - memset(&item->constant, '\0', sizeof (MOJOSHADER_constant)); - item->next = ctx->constants; - ctx->constants = item; - ctx->constant_count++; - - return item; -} // alloc_constant_listitem - - -static void state_DEF(Context *ctx) -{ - const RegisterType regtype = ctx->dest_arg.regtype; - const int regnum = ctx->dest_arg.regnum; - - // !!! FIXME: fail if same register is defined twice. - - if (ctx->instruction_count != 0) - fail(ctx, "DEF token must come before any instructions"); - else if (regtype != REG_TYPE_CONST) - fail(ctx, "DEF token using invalid register"); - else - { - ConstantsList *item = alloc_constant_listitem(ctx); - item->constant.index = regnum; - item->constant.type = MOJOSHADER_UNIFORM_FLOAT; - memcpy(item->constant.value.f, ctx->dwords, - sizeof (item->constant.value.f)); - set_defined_register(ctx, regtype, regnum); - } // else -} // state_DEF - -static void state_DEFI(Context *ctx) -{ - const RegisterType regtype = ctx->dest_arg.regtype; - const int regnum = ctx->dest_arg.regnum; - - // !!! FIXME: fail if same register is defined twice. - - if (ctx->instruction_count != 0) - fail(ctx, "DEFI token must come before any instructions"); - else if (regtype != REG_TYPE_CONSTINT) - fail(ctx, "DEFI token using invalid register"); - else - { - ConstantsList *item = alloc_constant_listitem(ctx); - item->constant.index = regnum; - item->constant.type = MOJOSHADER_UNIFORM_INT; - memcpy(item->constant.value.i, ctx->dwords, - sizeof (item->constant.value.i)); - - set_defined_register(ctx, regtype, regnum); - } // else -} // state_DEFI - -static void state_DEFB(Context *ctx) -{ - const RegisterType regtype = ctx->dest_arg.regtype; - const int regnum = ctx->dest_arg.regnum; - - // !!! FIXME: fail if same register is defined twice. - - if (ctx->instruction_count != 0) - fail(ctx, "DEFB token must come before any instructions"); - else if (regtype != REG_TYPE_CONSTBOOL) - fail(ctx, "DEFB token using invalid register"); - else - { - ConstantsList *item = alloc_constant_listitem(ctx); - item->constant.index = regnum; - item->constant.type = MOJOSHADER_UNIFORM_BOOL; - item->constant.value.b = ctx->dwords[0] ? 1 : 0; - set_defined_register(ctx, regtype, regnum); - } // else -} // state_DEFB - -static void state_DCL(Context *ctx) -{ - const DestArgInfo *arg = &ctx->dest_arg; - const RegisterType regtype = arg->regtype; - const int regnum = arg->regnum; - const int wmask = arg->writemask; - const int mods = arg->result_mod; - - // parse_args_DCL() does a lot of state checking before we get here. - - // !!! FIXME: apparently vs_3_0 can use sampler registers now. - // !!! FIXME: (but only s0 through s3, not all 16 of them.) - - if (ctx->instruction_count != 0) - fail(ctx, "DCL token must come before any instructions"); - - else if (shader_is_vertex(ctx)) - { - const MOJOSHADER_usage usage = (const MOJOSHADER_usage) ctx->dwords[0]; - const int index = ctx->dwords[1]; - if (usage >= MOJOSHADER_USAGE_TOTAL) - { - fail(ctx, "unknown DCL usage"); - return; - } // if - add_attribute_register(ctx, regtype, regnum, usage, index, wmask, mods); - } // if - - else if (shader_is_pixel(ctx)) - { - if (regtype == REG_TYPE_SAMPLER) - add_sampler(ctx, regtype, regnum, (TextureType) ctx->dwords[0]); - else - { - const MOJOSHADER_usage usage = (MOJOSHADER_usage) ctx->dwords[0]; - const int index = ctx->dwords[1]; - add_attribute_register(ctx, regtype, regnum, usage, index, wmask, mods); - } // else - } // else if - - else - { - fail(ctx, "unsupported shader type."); // should be caught elsewhere. - return; - } // else - - set_defined_register(ctx, regtype, regnum); -} // state_DCL - -static void state_TEXCRD(Context *ctx) -{ - if (shader_version_atleast(ctx, 2, 0)) - fail(ctx, "TEXCRD in Shader Model >= 2.0"); // apparently removed. -} // state_TEXCRD - -static void state_FRC(Context *ctx) -{ - const DestArgInfo *dst = &ctx->dest_arg; - - if (dst->result_mod & MOD_SATURATE) // according to msdn... - fail(ctx, "FRC destination can't use saturate modifier"); - - else if (!shader_version_atleast(ctx, 2, 0)) - { - if (!writemask_y(dst->writemask) && !writemask_xy(dst->writemask)) - fail(ctx, "FRC writemask must be .y or .xy for shader model 1.x"); - } // else if -} // state_FRC - - -// replicate the matrix registers to source args. The D3D profile will -// only use the one legitimate argument, but this saves other profiles -// from having to build this. -static void srcarg_matrix_replicate(Context *ctx, const int idx, - const int rows) -{ - int i; - SourceArgInfo *src = &ctx->source_args[idx]; - SourceArgInfo *dst = &ctx->source_args[idx+1]; - for (i = 0; i < (rows-1); i++, dst++) - { - memcpy(dst, src, sizeof (SourceArgInfo)); - dst->regnum += (i + 1); - set_used_register(ctx, dst->regtype, dst->regnum); - } // for -} // srcarg_matrix_replicate - -static void state_M4X4(Context *ctx) -{ - const DestArgInfo *info = &ctx->dest_arg; - if (!writemask_xyzw(info->writemask)) - fail(ctx, "M4X4 writemask must be full"); - -// !!! FIXME: MSDN: -//The xyzw (default) mask is required for the destination register. Negate and swizzle modifiers are allowed for src0, but not for src1. -//Swizzle and negate modifiers are invalid for the src0 register. The dest and src0 registers cannot be the same. - - srcarg_matrix_replicate(ctx, 1, 4); -} // state_M4X4 - -static void state_M4X3(Context *ctx) -{ - const DestArgInfo *info = &ctx->dest_arg; - if (!writemask_xyz(info->writemask)) - fail(ctx, "M4X3 writemask must be .xyz"); - -// !!! FIXME: MSDN stuff - - srcarg_matrix_replicate(ctx, 1, 3); -} // state_M4X3 - -static void state_M3X4(Context *ctx) -{ - const DestArgInfo *info = &ctx->dest_arg; - if (!writemask_xyzw(info->writemask)) - fail(ctx, "M3X4 writemask must be .xyzw"); - -// !!! FIXME: MSDN stuff - - srcarg_matrix_replicate(ctx, 1, 4); -} // state_M3X4 - -static void state_M3X3(Context *ctx) -{ - const DestArgInfo *info = &ctx->dest_arg; - if (!writemask_xyz(info->writemask)) - fail(ctx, "M3X3 writemask must be .xyz"); - -// !!! FIXME: MSDN stuff - - srcarg_matrix_replicate(ctx, 1, 3); -} // state_M3X3 - -static void state_M3X2(Context *ctx) -{ - const DestArgInfo *info = &ctx->dest_arg; - if (!writemask_xy(info->writemask)) - fail(ctx, "M3X2 writemask must be .xy"); - -// !!! FIXME: MSDN stuff - - srcarg_matrix_replicate(ctx, 1, 2); -} // state_M3X2 - -static void state_RET(Context *ctx) -{ - // MSDN all but says that assembly shaders are more or less serialized - // HLSL functions, and a RET means you're at the end of one, unlike how - // most CPUs would behave. This is actually really helpful, - // since we can use high-level constructs and not a mess of GOTOs, - // which is a godsend for GLSL...this also means we can consider things - // like a LOOP without a matching ENDLOOP within a label's section as - // an error. - if (ctx->loops > 0) - fail(ctx, "LOOP without ENDLOOP"); - if (ctx->reps > 0) - fail(ctx, "REP without ENDREP"); -} // state_RET - -static void check_label_register(Context *ctx, int arg, const char *opcode) -{ - const SourceArgInfo *info = &ctx->source_args[arg]; - const RegisterType regtype = info->regtype; - const int regnum = info->regnum; - - if (regtype != REG_TYPE_LABEL) - failf(ctx, "%s with a non-label register specified", opcode); - if (!shader_version_atleast(ctx, 2, 0)) - failf(ctx, "%s not supported in Shader Model 1", opcode); - if ((shader_version_atleast(ctx, 2, 255)) && (regnum > 2047)) - fail(ctx, "label register number must be <= 2047"); - if (regnum > 15) - fail(ctx, "label register number must be <= 15"); -} // check_label_register - -static void state_LABEL(Context *ctx) -{ - if (ctx->previous_opcode != OPCODE_RET) - fail(ctx, "LABEL not followed by a RET"); - check_label_register(ctx, 0, "LABEL"); - set_defined_register(ctx, REG_TYPE_LABEL, ctx->source_args[0].regnum); -} // state_LABEL - -static void check_call_loop_wrappage(Context *ctx, const int regnum) -{ - // msdn says subroutines inherit aL register if you're in a loop when - // you call, and further more _if you ever call this function in a loop, - // it must always be called in a loop_. So we'll just pass our loop - // variable as a function parameter in those cases. - - const int current_usage = (ctx->loops > 0) ? 1 : -1; - RegisterList *reg = reglist_find(&ctx->used_registers, REG_TYPE_LABEL, regnum); - assert(reg != NULL); - - if (reg->misc == 0) - reg->misc = current_usage; - else if (reg->misc != current_usage) - { - if (current_usage == 1) - fail(ctx, "CALL to this label must be wrapped in LOOP/ENDLOOP"); - else - fail(ctx, "CALL to this label must not be wrapped in LOOP/ENDLOOP"); - } // else if -} // check_call_loop_wrappage - -static void state_CALL(Context *ctx) -{ - check_label_register(ctx, 0, "CALL"); - check_call_loop_wrappage(ctx, ctx->source_args[0].regnum); -} // state_CALL - -static void state_CALLNZ(Context *ctx) -{ - const RegisterType regtype = ctx->source_args[1].regtype; - if ((regtype != REG_TYPE_CONSTBOOL) && (regtype != REG_TYPE_PREDICATE)) - fail(ctx, "CALLNZ argument isn't constbool or predicate register"); - check_label_register(ctx, 0, "CALLNZ"); - check_call_loop_wrappage(ctx, ctx->source_args[0].regnum); -} // state_CALLNZ - -static void state_MOVA(Context *ctx) -{ - if (ctx->dest_arg.regtype != REG_TYPE_ADDRESS) - fail(ctx, "MOVA argument isn't address register"); -} // state_MOVA - -static void state_RCP(Context *ctx) -{ - if (!replicate_swizzle(ctx->source_args[0].swizzle)) - fail(ctx, "RCP without replicate swizzzle"); -} // state_RCP - -static void state_LOOP(Context *ctx) -{ - if (ctx->source_args[0].regtype != REG_TYPE_LOOP) - fail(ctx, "LOOP argument isn't loop register"); - else if (ctx->source_args[1].regtype != REG_TYPE_CONSTINT) - fail(ctx, "LOOP argument isn't constint register"); - else - ctx->loops++; -} // state_LOOP - -static void state_ENDLOOP(Context *ctx) -{ - // !!! FIXME: check that we aren't straddling an IF block. - if (ctx->loops <= 0) - fail(ctx, "ENDLOOP without LOOP"); - ctx->loops--; -} // state_ENDLOOP - -static void state_BREAKP(Context *ctx) -{ - const RegisterType regtype = ctx->source_args[0].regtype; - if (regtype != REG_TYPE_PREDICATE) - fail(ctx, "BREAKP argument isn't predicate register"); - else if (!replicate_swizzle(ctx->source_args[0].swizzle)) - fail(ctx, "BREAKP without replicate swizzzle"); - else if ((ctx->loops == 0) && (ctx->reps == 0)) - fail(ctx, "BREAKP outside LOOP/ENDLOOP or REP/ENDREP"); -} // state_BREAKP - -static void state_BREAK(Context *ctx) -{ - if ((ctx->loops == 0) && (ctx->reps == 0)) - fail(ctx, "BREAK outside LOOP/ENDLOOP or REP/ENDREP"); -} // state_BREAK - -static void state_SETP(Context *ctx) -{ - const RegisterType regtype = ctx->dest_arg.regtype; - if (regtype != REG_TYPE_PREDICATE) - fail(ctx, "SETP argument isn't predicate register"); -} // state_SETP - -static void state_REP(Context *ctx) -{ - const RegisterType regtype = ctx->source_args[0].regtype; - if (regtype != REG_TYPE_CONSTINT) - fail(ctx, "REP argument isn't constint register"); - - ctx->reps++; - if (ctx->reps > ctx->max_reps) - ctx->max_reps = ctx->reps; -} // state_REP - -static void state_ENDREP(Context *ctx) -{ - // !!! FIXME: check that we aren't straddling an IF block. - if (ctx->reps <= 0) - fail(ctx, "ENDREP without REP"); - ctx->reps--; -} // state_ENDREP - -static void state_CMP(Context *ctx) -{ - ctx->cmps++; - - // extra limitations for ps <= 1.4 ... - if (!shader_version_atleast(ctx, 1, 4)) - { - int i; - const DestArgInfo *dst = &ctx->dest_arg; - const RegisterType dregtype = dst->regtype; - const int dregnum = dst->regnum; - - if (ctx->cmps > 3) - fail(ctx, "only 3 CMP instructions allowed in this shader model"); - - for (i = 0; i < 3; i++) - { - const SourceArgInfo *src = &ctx->source_args[i]; - const RegisterType sregtype = src->regtype; - const int sregnum = src->regnum; - if ((dregtype == sregtype) && (dregnum == sregnum)) - fail(ctx, "CMP dest can't match sources in this shader model"); - } // for - - ctx->instruction_count++; // takes an extra slot in ps_1_2 and _3. - } // if -} // state_CMP - -static void state_DP4(Context *ctx) -{ - // extra limitations for ps <= 1.4 ... - if (!shader_version_atleast(ctx, 1, 4)) - ctx->instruction_count++; // takes an extra slot in ps_1_2 and _3. -} // state_DP4 - -static void state_CND(Context *ctx) -{ - // apparently it was removed...it's not in the docs past ps_1_4 ... - if (shader_version_atleast(ctx, 2, 0)) - fail(ctx, "CND not allowed in this shader model"); - - // extra limitations for ps <= 1.4 ... - else if (!shader_version_atleast(ctx, 1, 4)) - { - const SourceArgInfo *src = &ctx->source_args[0]; - if ((src->regtype != REG_TYPE_TEMP) || (src->regnum != 0) || - (src->swizzle != 0x0000)) - { - fail(ctx, "CND src must be r0.a in this shader model"); - } // if - } // if -} // state_CND - -static void state_POW(Context *ctx) -{ - if (!replicate_swizzle(ctx->source_args[0].swizzle)) - fail(ctx, "POW src0 must have replicate swizzle"); - else if (!replicate_swizzle(ctx->source_args[1].swizzle)) - fail(ctx, "POW src1 must have replicate swizzle"); -} // state_POW - -static void state_LOG(Context *ctx) -{ - if (!replicate_swizzle(ctx->source_args[0].swizzle)) - fail(ctx, "LOG src0 must have replicate swizzle"); -} // state_LOG - -static void state_LOGP(Context *ctx) -{ - if (!replicate_swizzle(ctx->source_args[0].swizzle)) - fail(ctx, "LOGP src0 must have replicate swizzle"); -} // state_LOGP - -static void state_SINCOS(Context *ctx) -{ - const DestArgInfo *dst = &ctx->dest_arg; - const int mask = dst->writemask; - if (!writemask_x(mask) && !writemask_y(mask) && !writemask_xy(mask)) - fail(ctx, "SINCOS write mask must be .x or .y or .xy"); - - else if (!replicate_swizzle(ctx->source_args[0].swizzle)) - fail(ctx, "SINCOS src0 must have replicate swizzle"); - - else if (dst->result_mod & MOD_SATURATE) // according to msdn... - fail(ctx, "SINCOS destination can't use saturate modifier"); - - // this opcode needs extra registers, with extra limitations, for <= sm2. - else if (!shader_version_atleast(ctx, 3, 0)) - { - int i; - for (i = 1; i < 3; i++) - { - if (ctx->source_args[i].regtype != REG_TYPE_CONST) - { - failf(ctx, "SINCOS src%d must be constfloat", i); - return; - } // if - } // for - - if (ctx->source_args[1].regnum == ctx->source_args[2].regnum) - fail(ctx, "SINCOS src1 and src2 must be different registers"); - } // if -} // state_SINCOS - -static void state_IF(Context *ctx) -{ - const RegisterType regtype = ctx->source_args[0].regtype; - if ((regtype != REG_TYPE_PREDICATE) && (regtype != REG_TYPE_CONSTBOOL)) - fail(ctx, "IF src0 must be CONSTBOOL or PREDICATE"); - else if (!replicate_swizzle(ctx->source_args[0].swizzle)) - fail(ctx, "IF src0 must have replicate swizzle"); - // !!! FIXME: track if nesting depth. -} // state_IF - -static void state_IFC(Context *ctx) -{ - if (!replicate_swizzle(ctx->source_args[0].swizzle)) - fail(ctx, "IFC src0 must have replicate swizzle"); - else if (!replicate_swizzle(ctx->source_args[1].swizzle)) - fail(ctx, "IFC src1 must have replicate swizzle"); - // !!! FIXME: track if nesting depth. -} // state_IFC - -static void state_BREAKC(Context *ctx) -{ - if (!replicate_swizzle(ctx->source_args[0].swizzle)) - fail(ctx, "BREAKC src1 must have replicate swizzle"); - else if (!replicate_swizzle(ctx->source_args[1].swizzle)) - fail(ctx, "BREAKC src2 must have replicate swizzle"); - else if ((ctx->loops == 0) && (ctx->reps == 0)) - fail(ctx, "BREAKC outside LOOP/ENDLOOP or REP/ENDREP"); -} // state_BREAKC - -static void state_TEXKILL(Context *ctx) -{ - // The MSDN docs say this should be a source arg, but the driver docs - // say it's a dest arg. That's annoying. - const DestArgInfo *info = &ctx->dest_arg; - const RegisterType regtype = info->regtype; - if (!writemask_xyzw(info->writemask)) - fail(ctx, "TEXKILL writemask must be .xyzw"); - else if ((regtype != REG_TYPE_TEMP) && (regtype != REG_TYPE_TEXTURE)) - fail(ctx, "TEXKILL must use a temp or texture register"); - - // !!! FIXME: "If a temporary register is used, all components must have been previously written." - // !!! FIXME: "If a texture register is used, all components that are read must have been declared." - // !!! FIXME: there are further limitations in ps_1_3 and earlier. -} // state_TEXKILL - -static void state_TEXLD(Context *ctx) -{ - if (shader_version_atleast(ctx, 2, 0)) - { - const SourceArgInfo *src0 = &ctx->source_args[0]; - const SourceArgInfo *src1 = &ctx->source_args[1]; - - // !!! FIXME: verify texldp restrictions: - //http://msdn.microsoft.com/en-us/library/bb206221(VS.85).aspx - // !!! FIXME: ...and texldb, too. - //http://msdn.microsoft.com/en-us/library/bb206217(VS.85).aspx - - //const RegisterType rt0 = src0->regtype; - - // !!! FIXME: msdn says it has to be temp, but Microsoft's HLSL - // !!! FIXME: compiler is generating code that uses oC0 for a dest. - //if (ctx->dest_arg.regtype != REG_TYPE_TEMP) - // fail(ctx, "TEXLD dest must be a temp register"); - - // !!! FIXME: this can be an REG_TYPE_INPUT, DCL'd to TEXCOORD. - //else if ((rt0 != REG_TYPE_TEXTURE) && (rt0 != REG_TYPE_TEMP)) - // fail(ctx, "TEXLD src0 must be texture or temp register"); - //else - - if (src0->src_mod != SRCMOD_NONE) - fail(ctx, "TEXLD src0 must have no modifiers"); - else if (src1->regtype != REG_TYPE_SAMPLER) - fail(ctx, "TEXLD src1 must be sampler register"); - else if (src1->src_mod != SRCMOD_NONE) - fail(ctx, "TEXLD src0 must have no modifiers"); - else if ( (ctx->instruction_controls != CONTROL_TEXLD) && - (ctx->instruction_controls != CONTROL_TEXLDP) && - (ctx->instruction_controls != CONTROL_TEXLDB) ) - { - fail(ctx, "TEXLD has unknown control bits"); - } // else if - - // Shader Model 3 added swizzle support to this opcode. - if (!shader_version_atleast(ctx, 3, 0)) - { - if (!no_swizzle(src0->swizzle)) - fail(ctx, "TEXLD src0 must not swizzle"); - else if (!no_swizzle(src1->swizzle)) - fail(ctx, "TEXLD src1 must not swizzle"); - } // if - - if ( ((TextureType) ctx->source_args[1].regnum) == TEXTURE_TYPE_CUBE ) - ctx->instruction_count += 3; - } // if - - // !!! FIXME: checks for ps_1_4 and ps_1_0 versions here... -} // state_TEXLD - -static void state_TEXLDL(Context *ctx) -{ - if (!shader_version_atleast(ctx, 3, 0)) - fail(ctx, "TEXLDL in version < Shader Model 3.0"); - else if (ctx->source_args[1].regtype != REG_TYPE_SAMPLER) - fail(ctx, "TEXLDL src1 must be sampler register"); - else - { - if ( ((TextureType) ctx->source_args[1].regnum) == TEXTURE_TYPE_CUBE ) - ctx->instruction_count += 3; - } // else -} // state_TEXLDL - -static void state_DP2ADD(Context *ctx) -{ - if (!replicate_swizzle(ctx->source_args[2].swizzle)) - fail(ctx, "DP2ADD src2 must have replicate swizzle"); -} // state_DP2ADD - - -// Lookup table for instruction opcodes... -typedef struct -{ - const char *opcode_string; - int slots; // number of instruction slots this opcode eats. - MOJOSHADER_shaderType shader_types; // mask of types that can use opcode. - args_function parse_args; - state_function state; - emit_function emitter[STATICARRAYLEN(profiles)]; -} Instruction; - -// These have to be in the right order! This array is indexed by the value -// of the instruction token. -static const Instruction instructions[] = -{ - #define INSTRUCTION_STATE(op, opstr, slots, a, t) { \ - opstr, slots, t, parse_args_##a, state_##op, PROFILE_EMITTERS(op) \ - }, - - #define INSTRUCTION(op, opstr, slots, a, t) { \ - opstr, slots, t, parse_args_##a, 0, PROFILE_EMITTERS(op) \ - }, - - #define MOJOSHADER_DO_INSTRUCTION_TABLE 1 - #include "mojoshader_internal.h" - #undef MOJOSHADER_DO_INSTRUCTION_TABLE - - #undef INSTRUCTION - #undef INSTRUCTION_STATE -}; - - -// parse various token types... - -static int parse_instruction_token(Context *ctx) -{ - int retval = 0; - const int start_position = ctx->current_position; - const uint32 *start_tokens = ctx->tokens; - const uint32 start_tokencount = ctx->tokencount; - const uint32 token = SWAP32(*(ctx->tokens)); - const uint32 opcode = (token & 0xFFFF); - const uint32 controls = ((token >> 16) & 0xFF); - const uint32 insttoks = ((token >> 24) & 0x0F); - const int coissue = (token & 0x40000000) ? 1 : 0; - const int predicated = (token & 0x10000000) ? 1 : 0; - - if ( opcode >= (sizeof (instructions) / sizeof (instructions[0])) ) - return 0; // not an instruction token, or just not handled here. - - const Instruction *instruction = &instructions[opcode]; - const emit_function emitter = instruction->emitter[ctx->profileid]; - - if ((token & 0x80000000) != 0) - fail(ctx, "instruction token high bit must be zero."); // so says msdn. - - if (instruction->opcode_string == NULL) - { - fail(ctx, "Unknown opcode."); - return insttoks + 1; // pray that you resync later. - } // if - - if (coissue) - { - if (!shader_is_pixel(ctx)) - fail(ctx, "coissue instruction on non-pixel shader"); - if (shader_version_atleast(ctx, 2, 0)) - fail(ctx, "coissue instruction in Shader Model >= 2.0"); - // !!! FIXME: I'm not sure what this actually means, yet. - fail(ctx, "coissue instructions unsupported"); - } // if - - if ((ctx->shader_type & instruction->shader_types) == 0) - { - failf(ctx, "opcode '%s' not available in this shader type.", - instruction->opcode_string); - } // if - - memset(ctx->dwords, '\0', sizeof (ctx->dwords)); - ctx->instruction_controls = controls; - ctx->predicated = predicated; - - // Update the context with instruction's arguments. - adjust_token_position(ctx, 1); - retval = instruction->parse_args(ctx); - - if (predicated) - retval += parse_predicated_token(ctx); - - // parse_args() moves these forward for convenience...reset them. - ctx->tokens = start_tokens; - ctx->tokencount = start_tokencount; - ctx->current_position = start_position; - - if (instruction->state != NULL) - instruction->state(ctx); - - ctx->instruction_count += instruction->slots; - - if (!isfail(ctx)) - emitter(ctx); // call the profile's emitter. - - ctx->previous_opcode = opcode; - ctx->scratch_registers = 0; // reset after every instruction. - - if (!shader_version_atleast(ctx, 2, 0)) - { - if (insttoks != 0) // reserved field in shaders < 2.0 ... - fail(ctx, "instruction token count must be zero"); - } // if - else - { - if (((uint32)retval) != (insttoks+1)) - { - failf(ctx, "wrong token count (%u, not %u) for opcode '%s'.", - (uint) retval, (uint) (insttoks+1), - instruction->opcode_string); - retval = insttoks + 1; // try to keep sync. - } // if - } // else - - return retval; -} // parse_instruction_token - - -static int parse_version_token(Context *ctx, const char *profilestr) -{ - if (ctx->tokencount == 0) - { - fail(ctx, "Expected version token, got none at all."); - return 0; - } // if - - const uint32 token = SWAP32(*(ctx->tokens)); - const uint32 shadertype = ((token >> 16) & 0xFFFF); - const uint8 major = (uint8) ((token >> 8) & 0xFF); - const uint8 minor = (uint8) (token & 0xFF); - - ctx->version_token = token; - - // 0xFFFF == pixel shader, 0xFFFE == vertex shader - if (shadertype == 0xFFFF) - { - ctx->shader_type = MOJOSHADER_TYPE_PIXEL; - ctx->shader_type_str = "ps"; - } // if - else if (shadertype == 0xFFFE) - { - ctx->shader_type = MOJOSHADER_TYPE_VERTEX; - ctx->shader_type_str = "vs"; - } // else if - else // geometry shader? Bogus data? - { - fail(ctx, "Unsupported shader type or not a shader at all"); - return -1; - } // else - - ctx->major_ver = major; - ctx->minor_ver = minor; - - if (!shader_version_supported(major, minor)) - { - failf(ctx, "Shader Model %u.%u is currently unsupported.", - (uint) major, (uint) minor); - } // if - - if (!isfail(ctx)) - ctx->profile->start_emitter(ctx, profilestr); - - return 1; // ate one token. -} // parse_version_token - - -static int parse_ctab_string(const uint8 *start, const uint32 bytes, - const uint32 name) -{ - // Make sure strings don't overflow the CTAB buffer... - if (name < bytes) - { - int i; - const int slenmax = bytes - name; - const char *namestr = (const char *) (start + name); - for (i = 0; i < slenmax; i++) - { - if (namestr[i] == '\0') - return 1; // it's okay. - } // for - } // if - - return 0; // overflowed. -} // parse_ctab_string - - -static int parse_ctab_typeinfo(Context *ctx, const uint8 *start, - const uint32 bytes, const uint32 pos, - MOJOSHADER_symbolTypeInfo *info) -{ - if ((pos + 16) >= bytes) - return 0; // corrupt CTAB. - - const uint16 *typeptr = (const uint16 *) (start + pos); - - info->parameter_class = (MOJOSHADER_symbolClass) SWAP16(typeptr[0]); - info->parameter_type = (MOJOSHADER_symbolType) SWAP16(typeptr[1]); - info->rows = (unsigned int) SWAP16(typeptr[2]); - info->columns = (unsigned int) SWAP16(typeptr[3]); - info->elements = (unsigned int) SWAP16(typeptr[4]); - info->member_count = (unsigned int) SWAP16(typeptr[5]); - - if ((pos + 16 + (info->member_count * 8)) >= bytes) - return 0; // corrupt CTAB. - - if (info->member_count == 0) - info->members = NULL; - else - { - const size_t len = sizeof (MOJOSHADER_symbolStructMember) * - info->member_count; - info->members = (MOJOSHADER_symbolStructMember *) Malloc(ctx, len); - if (info->members == NULL) - return 1; // we'll check ctx->out_of_memory later. - memset(info->members, '\0', len); - } // else - - int i; - const uint32 *member = (const uint32 *)((const uint8 *) (&typeptr[6])); - for (i = 0; i < info->member_count; i++) - { - MOJOSHADER_symbolStructMember *mbr = &info->members[i]; - const uint32 name = SWAP32(member[0]); - const uint32 memberinfopos = SWAP32(member[1]); - member += 2; - - if (!parse_ctab_string(start, bytes, name)) - return 0; // info->members will be free()'d elsewhere. - - mbr->name = StrDup(ctx, (const char *) (start + name)); - if (mbr->name == NULL) - return 1; // we'll check ctx->out_of_memory later. - if (!parse_ctab_typeinfo(ctx, start, bytes, memberinfopos, &mbr->info)) - return 0; - if (ctx->out_of_memory) - return 1; // drop out now. - } // for - - return 1; -} // parse_ctab_typeinfo - - -// Microsoft's tools add a CTAB comment to all shaders. This is the -// "constant table," or specifically: D3DXSHADER_CONSTANTTABLE: -// http://msdn.microsoft.com/en-us/library/bb205440(VS.85).aspx -// This may tell us high-level truths about an otherwise generic low-level -// registers, for instance, how large an array actually is, etc. -static void parse_constant_table(Context *ctx, const uint32 *tokens, - const uint32 bytes, const uint32 okay_version, - const int setvariables, CtabData *ctab) -{ - const uint32 id = SWAP32(tokens[1]); - if (id != CTAB_ID) - return; // not the constant table. - - assert(ctab->have_ctab == 0); // !!! FIXME: can you have more than one? - ctab->have_ctab = 1; - - const uint8 *start = (uint8 *) &tokens[2]; - - if (bytes < 32) - { - fail(ctx, "Truncated CTAB data"); - return; - } // if - - const uint32 size = SWAP32(tokens[2]); - const uint32 creator = SWAP32(tokens[3]); - const uint32 version = SWAP32(tokens[4]); - const uint32 constants = SWAP32(tokens[5]); - const uint32 constantinfo = SWAP32(tokens[6]); - const uint32 target = SWAP32(tokens[8]); - - if (size != CTAB_SIZE) - goto corrupt_ctab; - - if (version != okay_version) goto corrupt_ctab; - if (creator >= bytes) goto corrupt_ctab; - if ((constantinfo + (constants * CINFO_SIZE)) >= bytes) goto corrupt_ctab; - if (target >= bytes) goto corrupt_ctab; - if (!parse_ctab_string(start, bytes, target)) goto corrupt_ctab; - // !!! FIXME: check that (start+target) points to "ps_3_0", etc. - - ctab->symbol_count = constants; - ctab->symbols = Malloc(ctx, sizeof (MOJOSHADER_symbol) * constants); - if (ctab->symbols == NULL) - return; - memset(ctab->symbols, '\0', sizeof (MOJOSHADER_symbol) * constants); - - uint32 i = 0; - for (i = 0; i < constants; i++) - { - const uint8 *ptr = start + constantinfo + (i * CINFO_SIZE); - const uint32 name = SWAP32(*((uint32 *) (ptr + 0))); - const uint16 regset = SWAP16(*((uint16 *) (ptr + 4))); - const uint16 regidx = SWAP16(*((uint16 *) (ptr + 6))); - const uint16 regcnt = SWAP16(*((uint16 *) (ptr + 8))); - const uint32 typeinf = SWAP32(*((uint32 *) (ptr + 12))); - const uint32 defval = SWAP32(*((uint32 *) (ptr + 16))); - MOJOSHADER_uniformType mojotype = MOJOSHADER_UNIFORM_UNKNOWN; - - if (!parse_ctab_string(start, bytes, name)) goto corrupt_ctab; - if (defval >= bytes) goto corrupt_ctab; - - switch (regset) - { - case 0: mojotype = MOJOSHADER_UNIFORM_BOOL; break; - case 1: mojotype = MOJOSHADER_UNIFORM_INT; break; - case 2: mojotype = MOJOSHADER_UNIFORM_FLOAT; break; - case 3: /* SAMPLER */ break; - default: goto corrupt_ctab; - } // switch - - if ((setvariables) && (mojotype != MOJOSHADER_UNIFORM_UNKNOWN)) - { - VariableList *item; - item = (VariableList *) Malloc(ctx, sizeof (VariableList)); - if (item != NULL) - { - item->type = mojotype; - item->index = regidx; - item->count = regcnt; - item->constant = NULL; - item->used = 0; - item->emit_position = -1; - item->next = ctx->variables; - ctx->variables = item; - } // if - } // if - - // Add the symbol. - const char *namecpy = StrDup(ctx, (const char *) (start + name)); - if (namecpy == NULL) - return; - - MOJOSHADER_symbol *sym = &ctab->symbols[i]; - sym->name = namecpy; - sym->register_set = (MOJOSHADER_symbolRegisterSet) regset; - sym->register_index = (unsigned int) regidx; - sym->register_count = (unsigned int) regcnt; - if (!parse_ctab_typeinfo(ctx, start, bytes, typeinf, &sym->info)) - goto corrupt_ctab; // sym->name will get free()'d later. - else if (ctx->out_of_memory) - return; // just bail now. - } // for - - return; - -corrupt_ctab: - fail(ctx, "Shader has corrupt CTAB data"); -} // parse_constant_table - - -static void free_symbols(MOJOSHADER_free f, void *d, MOJOSHADER_symbol *syms, - const int symcount); - - -static int is_comment_token(Context *ctx, const uint32 tok, uint32 *tokcount) -{ - const uint32 token = SWAP32(tok); - if ((token & 0xFFFF) == 0xFFFE) // actually a comment token? - { - if ((token & 0x80000000) != 0) - fail(ctx, "comment token high bit must be zero."); // so says msdn. - *tokcount = ((token >> 16) & 0xFFFF); - return 1; - } // if - - return 0; -} // is_comment_token - - -typedef struct PreshaderBlockInfo -{ - const uint32 *tokens; - uint32 tokcount; - int seen; -} PreshaderBlockInfo; - -// Preshaders only show up in compiled Effect files. The format is -// undocumented, and even the instructions aren't the same opcodes as you -// would find in a regular shader. These things show up because the HLSL -// compiler can detect work that sets up constant registers that could -// be moved out of the shader itself. Preshaders run once, then the shader -// itself runs many times, using the constant registers the preshader has set -// up. There are cases where the preshaders are 3+ times as many instructions -// as the shader itself, so this can be a big performance win. -// My presumption is that Microsoft's Effects framework runs the preshaders on -// the CPU, then loads the constant register file appropriately before handing -// off to the GPU. As such, we do the same. -static void parse_preshader(Context *ctx, uint32 tokcount) -{ - const uint32 *tokens = ctx->tokens; - if ((tokcount < 2) || (SWAP32(tokens[1]) != PRES_ID)) - return; // not a preshader. - -#if !SUPPORT_PRESHADERS - fail(ctx, "Preshader found, but preshader support is disabled!"); -#else - - assert(ctx->have_preshader == 0); // !!! FIXME: can you have more than one? - ctx->have_preshader = 1; - - // !!! FIXME: I don't know what specific versions signify, but we need to - // !!! FIXME: save this to test against the CTAB version field, if - // !!! FIXME: nothing else. - // !!! FIXME: 0x02 0x01 is probably the version (fx_2_1), - // !!! FIXME: and 0x4658 is the magic, like a real shader's version token. - const uint32 okay_version = 0x46580201; - if (SWAP32(tokens[2]) != okay_version) - { - fail(ctx, "Unsupported preshader version."); - return; // fail because the shader will malfunction w/o this. - } // if - - tokens += 3; - tokcount -= 3; - - // All sections of a preshader are packed into separate comment tokens, - // inside the containing comment token block. Find them all before - // we start, so we don't care about the order they appear in the file. - PreshaderBlockInfo ctab = { 0, 0, 0 }; - PreshaderBlockInfo prsi = { 0, 0, 0 }; - PreshaderBlockInfo fxlc = { 0, 0, 0 }; - PreshaderBlockInfo clit = { 0, 0, 0 }; - - while (tokcount > 0) - { - uint32 subtokcount = 0; - if ( (!is_comment_token(ctx, *tokens, &subtokcount)) || - (subtokcount > tokcount) ) - { - fail(ctx, "Bogus preshader data."); - return; - } // if - - tokens++; - tokcount--; - - const uint32 *nexttokens = tokens + subtokcount; - const uint32 nexttokcount = tokcount - subtokcount; - - if (subtokcount > 0) - { - switch (SWAP32(*tokens)) - { - #define PRESHADER_BLOCK_CASE(id, var) \ - case id##_ID: { \ - if (var.seen) { \ - fail(ctx, "Multiple " #id " preshader blocks."); \ - return; \ - } \ - var.tokens = tokens; \ - var.tokcount = subtokcount; \ - var.seen = 1; \ - break; \ - } - PRESHADER_BLOCK_CASE(CTAB, ctab); - PRESHADER_BLOCK_CASE(PRSI, prsi); - PRESHADER_BLOCK_CASE(FXLC, fxlc); - PRESHADER_BLOCK_CASE(CLIT, clit); - default: fail(ctx, "Bogus preshader section."); return; - #undef PRESHADER_BLOCK_CASE - } // switch - } // if - - tokens = nexttokens; - tokcount = nexttokcount; - } // while - - if (!ctab.seen) { fail(ctx, "No CTAB block in preshader."); return; } - if (!prsi.seen) { fail(ctx, "No PRSI block in preshader."); return; } - if (!fxlc.seen) { fail(ctx, "No FXLC block in preshader."); return; } - if (!clit.seen) { fail(ctx, "No CLIT block in preshader."); return; } - - MOJOSHADER_preshader *preshader = (MOJOSHADER_preshader *) - Malloc(ctx, sizeof (MOJOSHADER_preshader)); - if (preshader == NULL) - return; - memset(preshader, '\0', sizeof (MOJOSHADER_preshader)); - ctx->preshader = preshader; - - // Let's set up the constant literals first... - if (clit.tokcount == 0) - fail(ctx, "Bogus CLIT block in preshader."); - else - { - const uint32 lit_count = SWAP32(clit.tokens[1]); - if (lit_count > ((clit.tokcount - 2) / 2)) - { - fail(ctx, "Bogus CLIT block in preshader."); - return; - } // if - else if (lit_count > 0) - { - preshader->literal_count = (unsigned int) lit_count; - assert(sizeof (double) == 8); // just in case. - const size_t len = sizeof (double) * lit_count; - preshader->literals = (double *) Malloc(ctx, len); - if (preshader->literals == NULL) - return; // oh well. - const double *litptr = (const double *) (clit.tokens + 2); - int i; - for (i = 0; i < lit_count; i++) - preshader->literals[i] = SWAPDBL(litptr[i]); - } // else if - } // else - - // Parse out the PRSI block. This is used to map the output registers. - if (prsi.tokcount < 8) - { - fail(ctx, "Bogus preshader PRSI data"); - return; - } // if - - //const uint32 first_output_reg = SWAP32(prsi.tokens[1]); - // !!! FIXME: there are a lot of fields here I don't know about. - // !!! FIXME: maybe [2] and [3] are for int4 and bool registers? - //const uint32 output_reg_count = SWAP32(prsi.tokens[4]); - // !!! FIXME: maybe [5] and [6] are for int4 and bool registers? - const uint32 output_map_count = SWAP32(prsi.tokens[7]); - - prsi.tokcount -= 8; - prsi.tokens += 8; - - if (prsi.tokcount < ((output_map_count + 1) * 2)) - { - fail(ctx, "Bogus preshader PRSI data"); - return; - } // if - - const uint32 *output_map = prsi.tokens; - - // Now we'll figure out the CTAB... - CtabData ctabdata = { 0, 0, 0 }; - parse_constant_table(ctx, ctab.tokens - 1, ctab.tokcount * 4, - okay_version, 0, &ctabdata); - - // preshader owns this now. Don't free it in this function. - preshader->symbol_count = ctabdata.symbol_count; - preshader->symbols = ctabdata.symbols; - - if (!ctabdata.have_ctab) - { - fail(ctx, "Bogus preshader CTAB data"); - return; - } // if - - // The FXLC block has the actual instructions... - uint32 opcode_count = SWAP32(fxlc.tokens[1]); - - size_t len = sizeof (MOJOSHADER_preshaderInstruction) * opcode_count; - preshader->instruction_count = (unsigned int) opcode_count; - preshader->instructions = (MOJOSHADER_preshaderInstruction *) - Malloc(ctx, len); - if (preshader->instructions == NULL) - return; - memset(preshader->instructions, '\0', len); - - fxlc.tokens += 2; - fxlc.tokcount -= 2; - if (opcode_count > (fxlc.tokcount / 2)) - { - fail(ctx, "Bogus preshader FXLC block."); - return; - } // if - - MOJOSHADER_preshaderInstruction *inst = preshader->instructions; - while (opcode_count--) - { - const uint32 opcodetok = SWAP32(fxlc.tokens[0]); - MOJOSHADER_preshaderOpcode opcode = MOJOSHADER_PRESHADEROP_NOP; - switch ((opcodetok >> 16) & 0xFFFF) - { - case 0x1000: opcode = MOJOSHADER_PRESHADEROP_MOV; break; - case 0x1010: opcode = MOJOSHADER_PRESHADEROP_NEG; break; - case 0x1030: opcode = MOJOSHADER_PRESHADEROP_RCP; break; - case 0x1040: opcode = MOJOSHADER_PRESHADEROP_FRC; break; - case 0x1050: opcode = MOJOSHADER_PRESHADEROP_EXP; break; - case 0x1060: opcode = MOJOSHADER_PRESHADEROP_LOG; break; - case 0x1070: opcode = MOJOSHADER_PRESHADEROP_RSQ; break; - case 0x1080: opcode = MOJOSHADER_PRESHADEROP_SIN; break; - case 0x1090: opcode = MOJOSHADER_PRESHADEROP_COS; break; - case 0x10A0: opcode = MOJOSHADER_PRESHADEROP_ASIN; break; - case 0x10B0: opcode = MOJOSHADER_PRESHADEROP_ACOS; break; - case 0x10C0: opcode = MOJOSHADER_PRESHADEROP_ATAN; break; - case 0x2000: opcode = MOJOSHADER_PRESHADEROP_MIN; break; - case 0x2010: opcode = MOJOSHADER_PRESHADEROP_MAX; break; - case 0x2020: opcode = MOJOSHADER_PRESHADEROP_LT; break; - case 0x2030: opcode = MOJOSHADER_PRESHADEROP_GE; break; - case 0x2040: opcode = MOJOSHADER_PRESHADEROP_ADD; break; - case 0x2050: opcode = MOJOSHADER_PRESHADEROP_MUL; break; - case 0x2060: opcode = MOJOSHADER_PRESHADEROP_ATAN2; break; - case 0x2080: opcode = MOJOSHADER_PRESHADEROP_DIV; break; - case 0x3000: opcode = MOJOSHADER_PRESHADEROP_CMP; break; - case 0x3010: opcode = MOJOSHADER_PRESHADEROP_MOVC; break; - case 0x5000: opcode = MOJOSHADER_PRESHADEROP_DOT; break; - case 0x5020: opcode = MOJOSHADER_PRESHADEROP_NOISE; break; - case 0xA000: opcode = MOJOSHADER_PRESHADEROP_MIN_SCALAR; break; - case 0xA010: opcode = MOJOSHADER_PRESHADEROP_MAX_SCALAR; break; - case 0xA020: opcode = MOJOSHADER_PRESHADEROP_LT_SCALAR; break; - case 0xA030: opcode = MOJOSHADER_PRESHADEROP_GE_SCALAR; break; - case 0xA040: opcode = MOJOSHADER_PRESHADEROP_ADD_SCALAR; break; - case 0xA050: opcode = MOJOSHADER_PRESHADEROP_MUL_SCALAR; break; - case 0xA060: opcode = MOJOSHADER_PRESHADEROP_ATAN2_SCALAR; break; - case 0xA080: opcode = MOJOSHADER_PRESHADEROP_DIV_SCALAR; break; - case 0xD000: opcode = MOJOSHADER_PRESHADEROP_DOT_SCALAR; break; - case 0xD020: opcode = MOJOSHADER_PRESHADEROP_NOISE_SCALAR; break; - default: fail(ctx, "Unknown preshader opcode."); break; - } // switch - - uint32 operand_count = SWAP32(fxlc.tokens[1]) + 1; // +1 for dest. - - inst->opcode = opcode; - inst->element_count = (unsigned int) (opcodetok & 0xFF); - inst->operand_count = (unsigned int) operand_count; - - fxlc.tokens += 2; - fxlc.tokcount -= 2; - if ((operand_count * 3) > fxlc.tokcount) - { - fail(ctx, "Bogus preshader FXLC block."); - return; - } // if - - MOJOSHADER_preshaderOperand *operand = inst->operands; - while (operand_count--) - { - const unsigned int item = (unsigned int) SWAP32(fxlc.tokens[2]); - - // !!! FIXME: don't know what first token does. - switch (SWAP32(fxlc.tokens[1])) - { - case 1: // literal from CLIT block. - { - if (item >= preshader->literal_count) - { - fail(ctx, "Bogus preshader literal index."); - break; - } // if - operand->type = MOJOSHADER_PRESHADEROPERAND_LITERAL; - break; - } // case - - case 2: // item from ctabdata. - { - int i; - MOJOSHADER_symbol *sym = ctabdata.symbols; - for (i = 0; i < ctabdata.symbol_count; i++, sym++) - { - const uint32 base = sym->register_index * 4; - const uint32 count = sym->register_count * 4; - assert(sym->register_set==MOJOSHADER_SYMREGSET_FLOAT4); - if ( (base <= item) && ((base + count) > item) ) - break; - } // for - if (i == ctabdata.symbol_count) - { - fail(ctx, "Bogus preshader input index."); - break; - } // if - operand->type = MOJOSHADER_PRESHADEROPERAND_INPUT; - break; - } // case - - case 4: - { - int i; - for (i = 0; i < output_map_count; i++) - { - const uint32 base = output_map[(i*2)] * 4; - const uint32 count = output_map[(i*2)+1] * 4; - if ( (base <= item) && ((base + count) > item) ) - break; - } // for - if (i == output_map_count) - { - fail(ctx, "Bogus preshader output index."); - break; - } // if - - operand->type = MOJOSHADER_PRESHADEROPERAND_OUTPUT; - break; - } // case - - case 7: - { - operand->type = MOJOSHADER_PRESHADEROPERAND_TEMP; - if (item >= preshader->temp_count) - preshader->temp_count = item + 1; - break; - } // case - } // switch - - operand->index = item; - - fxlc.tokens += 3; - fxlc.tokcount -= 3; - operand++; - } // while - - inst++; - } // while -#endif -} // parse_preshader - - -static int parse_comment_token(Context *ctx) -{ - uint32 commenttoks = 0; - if (is_comment_token(ctx, *ctx->tokens, &commenttoks)) - { - if ((commenttoks >= 1) && (commenttoks < ctx->tokencount)) - { - const uint32 id = SWAP32(ctx->tokens[1]); - if (id == PRES_ID) - parse_preshader(ctx, commenttoks); - else if (id == CTAB_ID) - { - parse_constant_table(ctx, ctx->tokens, commenttoks * 4, - ctx->version_token, 1, &ctx->ctab); - } // else if - } // if - return commenttoks + 1; // comment data plus the initial token. - } // if - - return 0; // not a comment token. -} // parse_comment_token - - -static int parse_end_token(Context *ctx) -{ - if (SWAP32(*(ctx->tokens)) != 0x0000FFFF) // end token always 0x0000FFFF. - return 0; // not us, eat no tokens. - - if (ctx->tokencount != 1) // we _must_ be last. If not: fail. - fail(ctx, "end token before end of stream"); - - if (!isfail(ctx)) - ctx->profile->end_emitter(ctx); - - return 1; -} // parse_end_token - - -static int parse_phase_token(Context *ctx) -{ - // !!! FIXME: needs state; allow only one phase token per shader, I think? - if (SWAP32(*(ctx->tokens)) != 0x0000FFFD) // phase token always 0x0000FFFD. - return 0; // not us, eat no tokens. - - if ( (!shader_is_pixel(ctx)) || (!shader_version_exactly(ctx, 1, 4)) ) - fail(ctx, "phase token only available in 1.4 pixel shaders"); - - if (!isfail(ctx)) - ctx->profile->phase_emitter(ctx); - - return 1; -} // parse_phase_token - - -static int parse_token(Context *ctx) -{ - int rc = 0; - - assert(ctx->output_stack_len == 0); - - if (ctx->tokencount == 0) - fail(ctx, "unexpected end of shader."); - - else if ((rc = parse_comment_token(ctx)) != 0) - return rc; - - else if ((rc = parse_end_token(ctx)) != 0) - return rc; - - else if ((rc = parse_phase_token(ctx)) != 0) - return rc; - - else if ((rc = parse_instruction_token(ctx)) != 0) - return rc; - - failf(ctx, "unknown token (0x%x)", (uint) *ctx->tokens); - return 1; // good luck! -} // parse_token - - -static int find_profile_id(const char *profile) -{ - size_t i; - for (i = 0; i < STATICARRAYLEN(profileMap); i++) - { - const char *name = profileMap[i].from; - if (strcmp(name, profile) == 0) - { - profile = profileMap[i].to; - break; - } // if - } // for - - for (i = 0; i < STATICARRAYLEN(profiles); i++) - { - const char *name = profiles[i].name; - if (strcmp(name, profile) == 0) - return i; - } // for - - return -1; // no match. -} // find_profile_id - - -static Context *build_context(const char *profile, - const unsigned char *tokenbuf, - const unsigned int bufsize, - const MOJOSHADER_swizzle *swiz, - const unsigned int swizcount, - MOJOSHADER_malloc m, MOJOSHADER_free f, void *d) -{ - if (m == NULL) m = MOJOSHADER_internal_malloc; - if (f == NULL) f = MOJOSHADER_internal_free; - - Context *ctx = (Context *) m(sizeof (Context), d); - if (ctx == NULL) - return NULL; - - memset(ctx, '\0', sizeof (Context)); - ctx->malloc = m; - ctx->free = f; - ctx->malloc_data = d; - ctx->tokens = (const uint32 *) tokenbuf; - ctx->orig_tokens = (const uint32 *) tokenbuf; - ctx->tokencount = bufsize / sizeof (uint32); - ctx->swizzles = swiz; - ctx->swizzles_count = swizcount; - ctx->endline = ENDLINE_STR; - ctx->endline_len = strlen(ctx->endline); - ctx->last_address_reg_component = -1; - ctx->current_position = MOJOSHADER_POSITION_BEFORE; - - ctx->errors = errorlist_create(MallocBridge, FreeBridge, ctx); - if (ctx->errors == NULL) - { - f(ctx, d); - return NULL; - } // if - - if (!set_output(ctx, &ctx->mainline)) - { - errorlist_destroy(ctx->errors); - f(ctx, d); - return NULL; - } // if - - const int profileid = find_profile_id(profile); - ctx->profileid = profileid; - if (profileid >= 0) - ctx->profile = &profiles[profileid]; - else - failf(ctx, "Profile '%s' is unknown or unsupported", profile); - - return ctx; -} // build_context - - -static void free_constants_list(MOJOSHADER_free f, void *d, ConstantsList *item) -{ - while (item != NULL) - { - ConstantsList *next = item->next; - f(item, d); - item = next; - } // while -} // free_constants_list - - -static void free_variable_list(MOJOSHADER_free f, void *d, VariableList *item) -{ - while (item != NULL) - { - VariableList *next = item->next; - f(item, d); - item = next; - } // while -} // free_variable_list - - -static void free_sym_typeinfo(MOJOSHADER_free f, void *d, - MOJOSHADER_symbolTypeInfo *typeinfo) -{ - int i; - for (i = 0; i < typeinfo->member_count; i++) - { - f((void *) typeinfo->members[i].name, d); - free_sym_typeinfo(f, d, &typeinfo->members[i].info); - } // for - f((void *) typeinfo->members, d); -} // free_sym_members - - -static void free_symbols(MOJOSHADER_free f, void *d, MOJOSHADER_symbol *syms, - const int symcount) -{ - int i; - for (i = 0; i < symcount; i++) - { - f((void *) syms[i].name, d); - free_sym_typeinfo(f, d, &syms[i].info); - } // for - f((void *) syms, d); -} // free_symbols - - -static void free_preshader(MOJOSHADER_free f, void *d, - MOJOSHADER_preshader *preshader) -{ - if (preshader != NULL) - { - f((void *) preshader->literals, d); - f((void *) preshader->instructions, d); - free_symbols(f, d, preshader->symbols, preshader->symbol_count); - f((void *) preshader, d); - } // if -} // free_preshader - - -static void destroy_context(Context *ctx) -{ - if (ctx != NULL) - { - MOJOSHADER_free f = ((ctx->free != NULL) ? ctx->free : MOJOSHADER_internal_free); - void *d = ctx->malloc_data; - buffer_destroy(ctx->preflight); - buffer_destroy(ctx->globals); - buffer_destroy(ctx->helpers); - buffer_destroy(ctx->subroutines); - buffer_destroy(ctx->mainline_intro); - buffer_destroy(ctx->mainline); - buffer_destroy(ctx->ignore); - free_constants_list(f, d, ctx->constants); - free_reglist(f, d, ctx->used_registers.next); - free_reglist(f, d, ctx->defined_registers.next); - free_reglist(f, d, ctx->uniforms.next); - free_reglist(f, d, ctx->attributes.next); - free_reglist(f, d, ctx->samplers.next); - free_variable_list(f, d, ctx->variables); - errorlist_destroy(ctx->errors); - free_symbols(f, d, ctx->ctab.symbols, ctx->ctab.symbol_count); - free_preshader(f, d, ctx->preshader); - f(ctx, d); - } // if -} // destroy_context - - -static char *build_output(Context *ctx, size_t *len) -{ - // add a byte for a null terminator. - Buffer *buffers[] = { - ctx->preflight, ctx->globals, ctx->helpers, - ctx->subroutines, ctx->mainline_intro, ctx->mainline - // don't append ctx->ignore ... that's why it's called "ignore" - }; - char *retval = buffer_merge(buffers, STATICARRAYLEN(buffers), len); - return retval; -} // build_output - - -static inline const char *alloc_varname(Context *ctx, const RegisterList *reg) -{ - return ctx->profile->get_varname(ctx, reg->regtype, reg->regnum); -} // alloc_varname - - -// !!! FIXME: this code is sort of hard to follow: -// !!! FIXME: "var->used" only applies to arrays (at the moment, at least, -// !!! FIXME: but this might be buggy at a later time?), and this code -// !!! FIXME: relies on that. -// !!! FIXME: "variables" means "things we found in a CTAB" but it's not -// !!! FIXME: all registers, etc. -// !!! FIXME: "const_array" means an array for d3d "const" registers (c0, c1, -// !!! FIXME: etc), but not a constant array, although they _can_ be. -// !!! FIXME: It's just a mess. :/ -static MOJOSHADER_uniform *build_uniforms(Context *ctx) -{ - const size_t len = sizeof (MOJOSHADER_uniform) * ctx->uniform_count; - MOJOSHADER_uniform *retval = (MOJOSHADER_uniform *) Malloc(ctx, len); - - if (retval != NULL) - { - MOJOSHADER_uniform *wptr = retval; - memset(wptr, '\0', len); - - VariableList *var; - int written = 0; - for (var = ctx->variables; var != NULL; var = var->next) - { - if (var->used) - { - const char *name = ctx->profile->get_const_array_varname(ctx, - var->index, var->count); - if (name != NULL) - { - wptr->type = MOJOSHADER_UNIFORM_FLOAT; - wptr->index = var->index; - wptr->array_count = var->count; - wptr->constant = (var->constant != NULL) ? 1 : 0; - wptr->name = name; - wptr++; - written++; - } // if - } // if - } // for - - RegisterList *item = ctx->uniforms.next; - MOJOSHADER_uniformType type = MOJOSHADER_UNIFORM_FLOAT; - while (written < ctx->uniform_count) - { - int skip = 0; - - // !!! FIXME: does this fail if written > ctx->uniform_count? - if (item == NULL) - { - fail(ctx, "BUG: mismatched uniform list and count"); - break; - } // if - - int index = item->regnum; - switch (item->regtype) - { - case REG_TYPE_CONST: - skip = (item->array != NULL); - type = MOJOSHADER_UNIFORM_FLOAT; - break; - - case REG_TYPE_CONSTINT: - type = MOJOSHADER_UNIFORM_INT; - break; - - case REG_TYPE_CONSTBOOL: - type = MOJOSHADER_UNIFORM_BOOL; - break; - - default: - fail(ctx, "unknown uniform datatype"); - break; - } // switch - - if (!skip) - { - wptr->type = type; - wptr->index = index; - wptr->array_count = 0; - wptr->name = alloc_varname(ctx, item); - wptr++; - written++; - } // if - - item = item->next; - } // for - } // if - - return retval; -} // build_uniforms - - -static MOJOSHADER_constant *build_constants(Context *ctx) -{ - const size_t len = sizeof (MOJOSHADER_constant) * ctx->constant_count; - MOJOSHADER_constant *retval = (MOJOSHADER_constant *) Malloc(ctx, len); - - if (retval != NULL) - { - ConstantsList *item = ctx->constants; - int i; - - for (i = 0; i < ctx->constant_count; i++) - { - if (item == NULL) - { - fail(ctx, "BUG: mismatched constant list and count"); - break; - } // if - - memcpy(&retval[i], &item->constant, sizeof (MOJOSHADER_constant)); - item = item->next; - } // for - } // if - - return retval; -} // build_constants - - -static MOJOSHADER_sampler *build_samplers(Context *ctx) -{ - const size_t len = sizeof (MOJOSHADER_sampler) * ctx->sampler_count; - MOJOSHADER_sampler *retval = (MOJOSHADER_sampler *) Malloc(ctx, len); - - if (retval != NULL) - { - RegisterList *item = ctx->samplers.next; - MOJOSHADER_samplerType type = MOJOSHADER_SAMPLER_2D; - int i; - - memset(retval, '\0', len); - - for (i = 0; i < ctx->sampler_count; i++) - { - if (item == NULL) - { - fail(ctx, "BUG: mismatched sampler list and count"); - break; - } // if - - assert(item->regtype == REG_TYPE_SAMPLER); - switch ((const TextureType) item->index) - { - case TEXTURE_TYPE_2D: - type = MOJOSHADER_SAMPLER_2D; - break; - - case TEXTURE_TYPE_CUBE: - type = MOJOSHADER_SAMPLER_CUBE; - break; - - case TEXTURE_TYPE_VOLUME: - type = MOJOSHADER_SAMPLER_VOLUME; - break; - - default: - fail(ctx, "Unknown sampler type"); - break; - } // switch - - retval[i].type = type; - retval[i].index = item->regnum; - retval[i].name = alloc_varname(ctx, item); - item = item->next; - } // for - } // if - - return retval; -} // build_samplers - - -static MOJOSHADER_attribute *build_attributes(Context *ctx, int *_count) -{ - int count = 0; - - if (ctx->attribute_count == 0) - { - *_count = 0; - return NULL; // nothing to do. - } // if - - const size_t len = sizeof (MOJOSHADER_attribute) * ctx->attribute_count; - MOJOSHADER_attribute *retval = (MOJOSHADER_attribute *) Malloc(ctx, len); - - if (retval != NULL) - { - RegisterList *item = ctx->attributes.next; - MOJOSHADER_attribute *wptr = retval; - int ignore = 0; - int i; - - memset(retval, '\0', len); - - for (i = 0; i < ctx->attribute_count; i++) - { - if (item == NULL) - { - fail(ctx, "BUG: mismatched attribute list and count"); - break; - } // if - - switch (item->regtype) - { - case REG_TYPE_RASTOUT: - case REG_TYPE_ATTROUT: - case REG_TYPE_TEXCRDOUT: - case REG_TYPE_COLOROUT: - case REG_TYPE_DEPTHOUT: - ignore = 1; - break; - case REG_TYPE_TEXTURE: - case REG_TYPE_MISCTYPE: - case REG_TYPE_INPUT: - ignore = shader_is_pixel(ctx); - break; - default: - ignore = 0; - break; - } // switch - - if (!ignore) - { - if (shader_is_pixel(ctx)) - fail(ctx, "BUG: pixel shader with vertex attributes"); - else - { - wptr->usage = item->usage; - wptr->index = item->index; - wptr->name = alloc_varname(ctx, item); - wptr++; - count++; - } // else - } // if - - item = item->next; - } // for - } // if - - *_count = count; - return retval; -} // build_attributes - -static MOJOSHADER_attribute *build_outputs(Context *ctx, int *_count) -{ - int count = 0; - - if (ctx->attribute_count == 0) - { - *_count = 0; - return NULL; // nothing to do. - } // if - - const size_t len = sizeof (MOJOSHADER_attribute) * ctx->attribute_count; - MOJOSHADER_attribute *retval = (MOJOSHADER_attribute *) Malloc(ctx, len); - - if (retval != NULL) - { - RegisterList *item = ctx->attributes.next; - MOJOSHADER_attribute *wptr = retval; - int i; - - memset(retval, '\0', len); - - for (i = 0; i < ctx->attribute_count; i++) - { - if (item == NULL) - { - fail(ctx, "BUG: mismatched attribute list and count"); - break; - } // if - - switch (item->regtype) - { - case REG_TYPE_RASTOUT: - case REG_TYPE_ATTROUT: - case REG_TYPE_TEXCRDOUT: - case REG_TYPE_COLOROUT: - case REG_TYPE_DEPTHOUT: - wptr->usage = item->usage; - wptr->index = item->index; - wptr->name = alloc_varname(ctx, item); - wptr++; - count++; - break; - default: - break; - } // switch - - - item = item->next; - } // for - } // if - - *_count = count; - return retval; -} // build_outputs - - -static MOJOSHADER_parseData *build_parsedata(Context *ctx) -{ - char *output = NULL; - MOJOSHADER_constant *constants = NULL; - MOJOSHADER_uniform *uniforms = NULL; - MOJOSHADER_attribute *attributes = NULL; - MOJOSHADER_attribute *outputs = NULL; - MOJOSHADER_sampler *samplers = NULL; - MOJOSHADER_swizzle *swizzles = NULL; - MOJOSHADER_error *errors = NULL; - MOJOSHADER_parseData *retval = NULL; - size_t output_len = 0; - int attribute_count = 0; - int output_count = 0; - - if (ctx->out_of_memory) - return &MOJOSHADER_out_of_mem_data; - - retval = (MOJOSHADER_parseData*) Malloc(ctx, sizeof(MOJOSHADER_parseData)); - if (retval == NULL) - return &MOJOSHADER_out_of_mem_data; - - memset(retval, '\0', sizeof (MOJOSHADER_parseData)); - - if (!isfail(ctx)) - output = build_output(ctx, &output_len); - - if (!isfail(ctx)) - constants = build_constants(ctx); - - if (!isfail(ctx)) - uniforms = build_uniforms(ctx); - - if (!isfail(ctx)) - attributes = build_attributes(ctx, &attribute_count); - - if (!isfail(ctx)) - outputs = build_outputs(ctx, &output_count); - - if (!isfail(ctx)) - samplers = build_samplers(ctx); - - const int error_count = errorlist_count(ctx->errors); - errors = errorlist_flatten(ctx->errors); - - if (!isfail(ctx)) - { - if (ctx->swizzles_count > 0) - { - const int len = ctx->swizzles_count * sizeof (MOJOSHADER_swizzle); - swizzles = (MOJOSHADER_swizzle *) Malloc(ctx, len); - if (swizzles != NULL) - memcpy(swizzles, ctx->swizzles, len); - } // if - } // if - - // check again, in case build_output, etc, ran out of memory. - if (isfail(ctx)) - { - int i; - - Free(ctx, output); - Free(ctx, constants); - Free(ctx, swizzles); - - if (uniforms != NULL) - { - for (i = 0; i < ctx->uniform_count; i++) - Free(ctx, (void *) uniforms[i].name); - Free(ctx, uniforms); - } // if - - if (attributes != NULL) - { - for (i = 0; i < attribute_count; i++) - Free(ctx, (void *) attributes[i].name); - Free(ctx, attributes); - } // if - - if (outputs != NULL) - { - for (i = 0; i < output_count; i++) - Free(ctx, (void *) outputs[i].name); - Free(ctx, outputs); - } // if - - if (samplers != NULL) - { - for (i = 0; i < ctx->sampler_count; i++) - Free(ctx, (void *) samplers[i].name); - Free(ctx, samplers); - } // if - - if (ctx->out_of_memory) - { - for (i = 0; i < error_count; i++) - { - Free(ctx, (void *) errors[i].filename); - Free(ctx, (void *) errors[i].error); - } // for - Free(ctx, errors); - Free(ctx, retval); - return &MOJOSHADER_out_of_mem_data; - } // if - } // if - else - { - retval->profile = ctx->profile->name; - retval->output = output; - retval->output_len = (int) output_len; - retval->instruction_count = ctx->instruction_count; - retval->shader_type = ctx->shader_type; - retval->major_ver = (int) ctx->major_ver; - retval->minor_ver = (int) ctx->minor_ver; - retval->uniform_count = ctx->uniform_count; - retval->uniforms = uniforms; - retval->constant_count = ctx->constant_count; - retval->constants = constants; - retval->sampler_count = ctx->sampler_count; - retval->samplers = samplers; - retval->attribute_count = attribute_count; - retval->attributes = attributes; - retval->output_count = output_count; - retval->outputs = outputs; - retval->swizzle_count = ctx->swizzles_count; - retval->swizzles = swizzles; - retval->symbol_count = ctx->ctab.symbol_count; - retval->symbols = ctx->ctab.symbols; - retval->preshader = ctx->preshader; - - // we don't own these now, retval does. - ctx->ctab.symbols = NULL; - ctx->preshader = NULL; - ctx->ctab.symbol_count = 0; - } // else - - retval->error_count = error_count; - retval->errors = errors; - retval->malloc = (ctx->malloc == MOJOSHADER_internal_malloc) ? NULL : ctx->malloc; - retval->free = (ctx->free == MOJOSHADER_internal_free) ? NULL : ctx->free; - retval->malloc_data = ctx->malloc_data; - - return retval; -} // build_parsedata - - -static void process_definitions(Context *ctx) -{ - // !!! FIXME: apparently, pre ps_3_0, sampler registers don't need to be - // !!! FIXME: DCL'd before use (default to 2d?). We aren't checking - // !!! FIXME: this at the moment, though. - - determine_constants_arrays(ctx); // in case this hasn't been called yet. - - RegisterList *uitem = &ctx->uniforms; - RegisterList *prev = &ctx->used_registers; - RegisterList *item = prev->next; - - while (item != NULL) - { - RegisterList *next = item->next; - const RegisterType regtype = item->regtype; - const int regnum = item->regnum; - - if (!get_defined_register(ctx, regtype, regnum)) - { - // haven't already dealt with this one. - switch (regtype) - { - // !!! FIXME: I'm not entirely sure this is right... - case REG_TYPE_RASTOUT: - case REG_TYPE_ATTROUT: - case REG_TYPE_TEXCRDOUT: - case REG_TYPE_COLOROUT: - case REG_TYPE_DEPTHOUT: - if (shader_is_vertex(ctx)&&shader_version_atleast(ctx,3,0)) - { - fail(ctx, "vs_3 can't use output registers" - " without declaring them first."); - return; - } // if - - // Apparently this is an attribute that wasn't DCL'd. - // Add it to the attribute list; deal with it later. - add_attribute_register(ctx, item->regtype, item->regnum, - MOJOSHADER_USAGE_UNKNOWN, 0, 0xF, 0); - break; - - case REG_TYPE_ADDRESS: - case REG_TYPE_PREDICATE: - case REG_TYPE_TEMP: - case REG_TYPE_LOOP: - case REG_TYPE_LABEL: - ctx->profile->global_emitter(ctx, regtype, regnum); - break; - - case REG_TYPE_CONST: - case REG_TYPE_CONSTINT: - case REG_TYPE_CONSTBOOL: - // separate uniforms into a different list for now. - prev->next = next; - item->next = NULL; - uitem->next = item; - uitem = item; - item = prev; - break; - - default: - fail(ctx, "BUG: we used a register we don't know how to define."); - } // switch - } // if - - prev = item; - item = next; - } // while - - // okay, now deal with uniform/constant arrays... - VariableList *var; - for (var = ctx->variables; var != NULL; var = var->next) - { - if (var->used) - { - if (var->constant) - { - ctx->profile->const_array_emitter(ctx, var->constant, - var->index, var->count); - } // if - else - { - ctx->profile->array_emitter(ctx, var); - ctx->uniform_float4_count += var->count; - ctx->uniform_count++; - } // else - } // if - } // for - - // ...and uniforms... - for (item = ctx->uniforms.next; item != NULL; item = item->next) - { - int arraysize = -1; - - // check if this is a register contained in an array... - if (item->regtype == REG_TYPE_CONST) - { - for (var = ctx->variables; var != NULL; var = var->next) - { - if (!var->used) - continue; - - const int regnum = item->regnum; - const int lo = var->index; - if ( (regnum >= lo) && (regnum < (lo + var->count)) ) - { - assert(!var->constant); - item->array = var; // used when building parseData. - arraysize = var->count; - break; - } // if - } // for - } // if - - ctx->profile->uniform_emitter(ctx, item->regtype, item->regnum, var); - - if (arraysize < 0) // not part of an array? - { - ctx->uniform_count++; - switch (item->regtype) - { - case REG_TYPE_CONST: ctx->uniform_float4_count++; break; - case REG_TYPE_CONSTINT: ctx->uniform_int4_count++; break; - case REG_TYPE_CONSTBOOL: ctx->uniform_bool_count++; break; - default: break; - } // switch - } // if - } // for - - // ...and samplers... - for (item = ctx->samplers.next; item != NULL; item = item->next) - { - ctx->sampler_count++; - ctx->profile->sampler_emitter(ctx, item->regnum, - (TextureType) item->index); - } // for - - // ...and attributes... - for (item = ctx->attributes.next; item != NULL; item = item->next) - { - ctx->attribute_count++; - ctx->profile->attribute_emitter(ctx, item->regtype, item->regnum, - item->usage, item->index, - item->writemask, item->misc); - } // for -} // process_definitions - - -static void verify_swizzles(Context *ctx) -{ - size_t i; - const char *failmsg = "invalid swizzle"; - for (i = 0; i < ctx->swizzles_count; i++) - { - const MOJOSHADER_swizzle *swiz = &ctx->swizzles[i]; - if (swiz->swizzles[0] > 3) { fail(ctx, failmsg); return; } - if (swiz->swizzles[1] > 3) { fail(ctx, failmsg); return; } - if (swiz->swizzles[2] > 3) { fail(ctx, failmsg); return; } - if (swiz->swizzles[3] > 3) { fail(ctx, failmsg); return; } - } // for -} // verify_swizzles - - -// API entry point... - -const MOJOSHADER_parseData *MOJOSHADER_parse(const char *profile, - const unsigned char *tokenbuf, - const unsigned int bufsize, - const MOJOSHADER_swizzle *swiz, - const unsigned int swizcount, - MOJOSHADER_malloc m, - MOJOSHADER_free f, void *d) -{ - MOJOSHADER_parseData *retval = NULL; - Context *ctx = NULL; - int rc = 0; - int failed = 0; - - if ( ((m == NULL) && (f != NULL)) || ((m != NULL) && (f == NULL)) ) - return &MOJOSHADER_out_of_mem_data; // supply both or neither. - - ctx = build_context(profile, tokenbuf, bufsize, swiz, swizcount, m, f, d); - if (ctx == NULL) - return &MOJOSHADER_out_of_mem_data; - - if (isfail(ctx)) - { - retval = build_parsedata(ctx); - destroy_context(ctx); - return retval; - } // if - - verify_swizzles(ctx); - - // Version token always comes first. - ctx->current_position = 0; - rc = parse_version_token(ctx, profile); - - // drop out now if this definitely isn't bytecode. Saves lots of - // meaningless errors flooding through. - if (rc < 0) - { - retval = build_parsedata(ctx); - destroy_context(ctx); - return retval; - } // if - - if ( ((uint32) rc) > ctx->tokencount ) - { - fail(ctx, "Corrupted or truncated shader"); - ctx->tokencount = rc; - } // if - - adjust_token_position(ctx, rc); - - // parse out the rest of the tokens after the version token... - while (ctx->tokencount > 0) - { - // reset for each token. - if (isfail(ctx)) - { - failed = 1; - ctx->isfail = 0; - } // if - - rc = parse_token(ctx); - if ( ((uint32) rc) > ctx->tokencount ) - { - fail(ctx, "Corrupted or truncated shader"); - break; - } // if - - adjust_token_position(ctx, rc); - } // while - - ctx->current_position = MOJOSHADER_POSITION_AFTER; - - if (!failed) - { - process_definitions(ctx); - failed = isfail(ctx); - } // if - - if (!failed) - ctx->profile->finalize_emitter(ctx); - - ctx->isfail = failed; - retval = build_parsedata(ctx); - destroy_context(ctx); - return retval; -} // MOJOSHADER_parse - - -void MOJOSHADER_freeParseData(const MOJOSHADER_parseData *_data) -{ - MOJOSHADER_parseData *data = (MOJOSHADER_parseData *) _data; - if ((data == NULL) || (data == &MOJOSHADER_out_of_mem_data)) - return; // no-op. - - MOJOSHADER_free f = (data->free == NULL) ? MOJOSHADER_internal_free : data->free; - void *d = data->malloc_data; - int i; - - // we don't f(data->profile), because that's internal static data. - - f((void *) data->output, d); - f((void *) data->constants, d); - f((void *) data->swizzles, d); - - for (i = 0; i < data->error_count; i++) - { - f((void *) data->errors[i].error, d); - f((void *) data->errors[i].filename, d); - } // for - f((void *) data->errors, d); - - for (i = 0; i < data->uniform_count; i++) - f((void *) data->uniforms[i].name, d); - f((void *) data->uniforms, d); - - for (i = 0; i < data->attribute_count; i++) - f((void *) data->attributes[i].name, d); - f((void *) data->attributes, d); - - for (i = 0; i < data->output_count; i++) - f((void *) data->outputs[i].name, d); - f((void *) data->outputs, d); - - for (i = 0; i < data->sampler_count; i++) - f((void *) data->samplers[i].name, d); - f((void *) data->samplers, d); - - free_symbols(f, d, data->symbols, data->symbol_count); - free_preshader(f, d, data->preshader); - - f(data, d); -} // MOJOSHADER_freeParseData - - -int MOJOSHADER_version(void) -{ - return MOJOSHADER_VERSION; -} // MOJOSHADER_version - - -const char *MOJOSHADER_changeset(void) -{ - return MOJOSHADER_CHANGESET; -} // MOJOSHADER_changeset - - -int MOJOSHADER_maxShaderModel(const char *profile) -{ - #define PROFILE_SHADER_MODEL(p,v) if (strcmp(profile, p) == 0) return v; - PROFILE_SHADER_MODEL(MOJOSHADER_PROFILE_D3D, 3); - PROFILE_SHADER_MODEL(MOJOSHADER_PROFILE_BYTECODE, 3); - PROFILE_SHADER_MODEL(MOJOSHADER_PROFILE_GLSL, 3); - PROFILE_SHADER_MODEL(MOJOSHADER_PROFILE_GLSL120, 3); - PROFILE_SHADER_MODEL(MOJOSHADER_PROFILE_ARB1, 2); - PROFILE_SHADER_MODEL(MOJOSHADER_PROFILE_NV2, 2); - PROFILE_SHADER_MODEL(MOJOSHADER_PROFILE_NV3, 2); - PROFILE_SHADER_MODEL(MOJOSHADER_PROFILE_NV4, 3); - #undef PROFILE_SHADER_MODEL - return -1; // unknown profile? -} // MOJOSHADER_maxShaderModel - -// end of mojoshader.c ... - diff --git a/Externals/mojoshader/1067/mojoshader.h b/Externals/mojoshader/1067/mojoshader.h deleted file mode 100644 index ad43ae29..00000000 --- a/Externals/mojoshader/1067/mojoshader.h +++ /dev/null @@ -1,3123 +0,0 @@ -/** - * MojoShader; generate shader programs from bytecode of compiled - * Direct3D shaders. - * - * Please see the file LICENSE.txt in the source's root directory. - * - * This file written by Ryan C. Gordon. - */ - -#ifndef _INCL_MOJOSHADER_H_ -#define _INCL_MOJOSHADER_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -/* You can define this if you aren't generating mojoshader_version.h */ -#ifndef MOJOSHADER_NO_VERSION_INCLUDE -#include "mojoshader_version.h" -#endif - -#ifndef MOJOSHADER_VERSION -#define MOJOSHADER_VERSION -1 -#endif - -#ifndef MOJOSHADER_CHANGESET -#define MOJOSHADER_CHANGESET "???" -#endif - -/* - * For determining the version of MojoShader you are using: - * const int compiled_against = MOJOSHADER_VERSION; - * const int linked_against = MOJOSHADER_version(); - * - * The version is a single integer that increments, not a major/minor value. - */ -int MOJOSHADER_version(void); - -/* - * For determining the revision control changeset of MojoShader you are using: - * const char *compiled_against = MOJOSHADER_CHANGESET; - * const char *linked_against = MOJOSHADER_changeset(); - * - * The version is an arbitrary, null-terminated ASCII string. It is probably - * a hash that represents a revision control changeset, and can't be - * compared to any other string to determine chronology. - * - * Do not attempt to free this string; it's statically allocated. - */ -const char *MOJOSHADER_changeset(void); - -/* - * These allocators work just like the C runtime's malloc() and free() - * (in fact, they probably use malloc() and free() internally if you don't - * specify your own allocator, but don't rely on that behaviour). - * (data) is the pointer you supplied when specifying these allocator - * callbacks, in case you need instance-specific data...it is passed through - * to your allocator unmolested, and can be NULL if you like. - */ -typedef void *(*MOJOSHADER_malloc)(int bytes, void *data); -typedef void (*MOJOSHADER_free)(void *ptr, void *data); - - -/* - * These are enum values, but they also can be used in bitmasks, so we can - * test if an opcode is acceptable: if (op->shader_types & ourtype) {} ... - */ -typedef enum -{ - MOJOSHADER_TYPE_UNKNOWN = 0, - MOJOSHADER_TYPE_PIXEL = (1 << 0), - MOJOSHADER_TYPE_VERTEX = (1 << 1), - MOJOSHADER_TYPE_GEOMETRY = (1 << 2), /* (not supported yet.) */ - MOJOSHADER_TYPE_ANY = 0xFFFFFFFF /* used for bitmasks */ -} MOJOSHADER_shaderType; - -/* - * Data types for vertex attribute streams. - */ -typedef enum -{ - MOJOSHADER_ATTRIBUTE_UNKNOWN = -1, /* housekeeping; not returned. */ - MOJOSHADER_ATTRIBUTE_BYTE, - MOJOSHADER_ATTRIBUTE_UBYTE, - MOJOSHADER_ATTRIBUTE_SHORT, - MOJOSHADER_ATTRIBUTE_USHORT, - MOJOSHADER_ATTRIBUTE_INT, - MOJOSHADER_ATTRIBUTE_UINT, - MOJOSHADER_ATTRIBUTE_FLOAT, - MOJOSHADER_ATTRIBUTE_DOUBLE, - MOJOSHADER_ATTRIBUTE_HALF_FLOAT, /* MAYBE available in your OpenGL! */ -} MOJOSHADER_attributeType; - -/* - * Data types for uniforms. See MOJOSHADER_uniform for more information. - */ -typedef enum -{ - MOJOSHADER_UNIFORM_UNKNOWN = -1, /* housekeeping value; never returned. */ - MOJOSHADER_UNIFORM_FLOAT, - MOJOSHADER_UNIFORM_INT, - MOJOSHADER_UNIFORM_BOOL, -} MOJOSHADER_uniformType; - -/* - * These are the uniforms to be set for a shader. "Uniforms" are what Direct3D - * calls "Constants" ... IDirect3DDevice::SetVertexShaderConstantF() would - * need this data, for example. These integers are register indexes. So if - * index==6 and type==MOJOSHADER_UNIFORM_FLOAT, that means we'd expect a - * 4-float vector to be specified for what would be register "c6" in D3D - * assembly language, before drawing with the shader. - * (array_count) means this is an array of uniforms...this happens in some - * profiles when we see a relative address ("c0[a0.x]", not the usual "c0"). - * In those cases, the shader was built to set some range of constant - * registers as an array. You should set this array with (array_count) - * elements from the constant register file, starting at (index) instead of - * just a single uniform. To be extra difficult, you'll need to fill in the - * correct values from the MOJOSHADER_constant data into the appropriate - * parts of the array, overriding the constant register file. Fun! - * (constant) says whether this is a constant array; these need to be loaded - * once at creation time, from the constant list and not ever updated from - * the constant register file. This is a workaround for limitations in some - * profiles. - * (name) is a profile-specific variable name; it may be NULL if it isn't - * applicable to the requested profile. - */ -typedef struct MOJOSHADER_uniform -{ - MOJOSHADER_uniformType type; - int index; - int array_count; - int constant; - const char *name; -} MOJOSHADER_uniform; - -/* - * These are the constants defined in a shader. These are data values - * hardcoded in a shader (with the DEF, DEFI, DEFB instructions), which - * override your Uniforms. This data is largely for informational purposes, - * since they are compiled in and can't be changed, like Uniforms can be. - * These integers are register indexes. So if index==6 and - * type==MOJOSHADER_UNIFORM_FLOAT, that means we'd expect a 4-float vector - * to be specified for what would be register "c6" in D3D assembly language, - * before drawing with the shader. - * (value) is the value of the constant, unioned by type. - */ -typedef struct MOJOSHADER_constant -{ - MOJOSHADER_uniformType type; - int index; - union - { - float f[4]; /* if type==MOJOSHADER_UNIFORM_FLOAT */ - int i[4]; /* if type==MOJOSHADER_UNIFORM_INT */ - int b; /* if type==MOJOSHADER_UNIFORM_BOOL */ - } value; -} MOJOSHADER_constant; - -/* - * Data types for samplers. See MOJOSHADER_sampler for more information. - */ -typedef enum -{ - MOJOSHADER_SAMPLER_UNKNOWN = -1, /* housekeeping value; never returned. */ - MOJOSHADER_SAMPLER_2D, - MOJOSHADER_SAMPLER_CUBE, - MOJOSHADER_SAMPLER_VOLUME, -} MOJOSHADER_samplerType; - -/* - * These are the samplers to be set for a shader. ... - * IDirect3DDevice::SetTexture() would need this data, for example. - * These integers are the sampler "stage". So if index==6 and - * type==MOJOSHADER_SAMPLER_2D, that means we'd expect a regular 2D texture - * to be specified for what would be register "s6" in D3D assembly language, - * before drawing with the shader. - * (name) is a profile-specific variable name; it may be NULL if it isn't - * applicable to the requested profile. - */ -typedef struct MOJOSHADER_sampler -{ - MOJOSHADER_samplerType type; - int index; - const char *name; -} MOJOSHADER_sampler; - -/* - * Data types for attributes. See MOJOSHADER_attribute for more information. - */ -typedef enum -{ - MOJOSHADER_USAGE_UNKNOWN = -1, /* housekeeping value; never returned. */ - MOJOSHADER_USAGE_POSITION, - MOJOSHADER_USAGE_BLENDWEIGHT, - MOJOSHADER_USAGE_BLENDINDICES, - MOJOSHADER_USAGE_NORMAL, - MOJOSHADER_USAGE_POINTSIZE, - MOJOSHADER_USAGE_TEXCOORD, - MOJOSHADER_USAGE_TANGENT, - MOJOSHADER_USAGE_BINORMAL, - MOJOSHADER_USAGE_TESSFACTOR, - MOJOSHADER_USAGE_POSITIONT, - MOJOSHADER_USAGE_COLOR, - MOJOSHADER_USAGE_FOG, - MOJOSHADER_USAGE_DEPTH, - MOJOSHADER_USAGE_SAMPLE, - MOJOSHADER_USAGE_TOTAL, /* housekeeping value; never returned. */ -} MOJOSHADER_usage; - -/* - * These are the attributes to be set for a shader. "Attributes" are what - * Direct3D calls "Vertex Declarations Usages" ... - * IDirect3DDevice::CreateVertexDeclaration() would need this data, for - * example. Each attribute is associated with an array of data that uses one - * element per-vertex. So if usage==MOJOSHADER_USAGE_COLOR and index==1, that - * means we'd expect a secondary color array to be bound to this shader - * before drawing. - * (name) is a profile-specific variable name; it may be NULL if it isn't - * applicable to the requested profile. - */ -typedef struct MOJOSHADER_attribute -{ - MOJOSHADER_usage usage; - int index; - const char *name; -} MOJOSHADER_attribute; - -/* - * Use this if you want to specify newly-parsed code to swizzle incoming - * data. This can be useful if you know, at parse time, that a shader - * will be processing data on COLOR0 that should be RGBA, but you'll - * be passing it a vertex array full of ARGB instead. - */ -typedef struct MOJOSHADER_swizzle -{ - MOJOSHADER_usage usage; - unsigned int index; - unsigned char swizzles[4]; /* {0,1,2,3} == .xyzw, {2,2,2,2} == .zzzz */ -} MOJOSHADER_swizzle; - - -/* - * MOJOSHADER_symbol data. - * - * These are used to expose high-level information in shader bytecode. - * They associate HLSL variables with registers. This data is used for both - * debugging and optimization. - */ - -typedef enum -{ - MOJOSHADER_SYMREGSET_BOOL, - MOJOSHADER_SYMREGSET_INT4, - MOJOSHADER_SYMREGSET_FLOAT4, - MOJOSHADER_SYMREGSET_SAMPLER, -} MOJOSHADER_symbolRegisterSet; - -typedef enum -{ - MOJOSHADER_SYMCLASS_SCALAR, - MOJOSHADER_SYMCLASS_VECTOR, - MOJOSHADER_SYMCLASS_MATRIX_ROWS, - MOJOSHADER_SYMCLASS_MATRIX_COLUMNS, - MOJOSHADER_SYMCLASS_OBJECT, - MOJOSHADER_SYMCLASS_STRUCT, -} MOJOSHADER_symbolClass; - -typedef enum -{ - MOJOSHADER_SYMTYPE_VOID, - MOJOSHADER_SYMTYPE_BOOL, - MOJOSHADER_SYMTYPE_INT, - MOJOSHADER_SYMTYPE_FLOAT, - MOJOSHADER_SYMTYPE_STRING, - MOJOSHADER_SYMTYPE_TEXTURE, - MOJOSHADER_SYMTYPE_TEXTURE1D, - MOJOSHADER_SYMTYPE_TEXTURE2D, - MOJOSHADER_SYMTYPE_TEXTURE3D, - MOJOSHADER_SYMTYPE_TEXTURECUBE, - MOJOSHADER_SYMTYPE_SAMPLER, - MOJOSHADER_SYMTYPE_SAMPLER1D, - MOJOSHADER_SYMTYPE_SAMPLER2D, - MOJOSHADER_SYMTYPE_SAMPLER3D, - MOJOSHADER_SYMTYPE_SAMPLERCUBE, - MOJOSHADER_SYMTYPE_PIXELSHADER, - MOJOSHADER_SYMTYPE_VERTEXSHADER, - MOJOSHADER_SYMTYPE_PIXELFRAGMENT, - MOJOSHADER_SYMTYPE_VERTEXFRAGMENT, - MOJOSHADER_SYMTYPE_UNSUPPORTED, -} MOJOSHADER_symbolType; - -typedef struct MOJOSHADER_symbolStructMember MOJOSHADER_symbolStructMember; - -typedef struct MOJOSHADER_symbolTypeInfo -{ - MOJOSHADER_symbolClass parameter_class; - MOJOSHADER_symbolType parameter_type; - unsigned int rows; - unsigned int columns; - unsigned int elements; - unsigned int member_count; - MOJOSHADER_symbolStructMember *members; -} MOJOSHADER_symbolTypeInfo; - -struct MOJOSHADER_symbolStructMember -{ - const char *name; - MOJOSHADER_symbolTypeInfo info; -}; - -typedef struct MOJOSHADER_symbol -{ - const char *name; - MOJOSHADER_symbolRegisterSet register_set; - unsigned int register_index; - unsigned int register_count; - MOJOSHADER_symbolTypeInfo info; -} MOJOSHADER_symbol; - - -/* - * These are used with MOJOSHADER_error as special case positions. - */ -#define MOJOSHADER_POSITION_NONE (-3) -#define MOJOSHADER_POSITION_BEFORE (-2) -#define MOJOSHADER_POSITION_AFTER (-1) - -typedef struct MOJOSHADER_error -{ - /* - * Human-readable error, if there is one. Will be NULL if there was no - * error. The string will be UTF-8 encoded, and English only. Most of - * these shouldn't be shown to the end-user anyhow. - */ - const char *error; - - /* - * Filename where error happened. This can be NULL if the information - * isn't available. - */ - const char *filename; - - /* - * Position of error, if there is one. Will be MOJOSHADER_POSITION_NONE if - * there was no error, MOJOSHADER_POSITION_BEFORE if there was an error - * before processing started, and MOJOSHADER_POSITION_AFTER if there was - * an error during final processing. If >= 0, MOJOSHADER_parse() sets - * this to the byte offset (starting at zero) into the bytecode you - * supplied, and MOJOSHADER_assemble(), MOJOSHADER_parseAst(), and - * MOJOSHADER_compile() sets this to a a line number in the source code - * you supplied (starting at one). - */ - int error_position; -} MOJOSHADER_error; - - -/* !!! FIXME: document me. */ -typedef enum MOJOSHADER_preshaderOpcode -{ - MOJOSHADER_PRESHADEROP_NOP, - MOJOSHADER_PRESHADEROP_MOV, - MOJOSHADER_PRESHADEROP_NEG, - MOJOSHADER_PRESHADEROP_RCP, - MOJOSHADER_PRESHADEROP_FRC, - MOJOSHADER_PRESHADEROP_EXP, - MOJOSHADER_PRESHADEROP_LOG, - MOJOSHADER_PRESHADEROP_RSQ, - MOJOSHADER_PRESHADEROP_SIN, - MOJOSHADER_PRESHADEROP_COS, - MOJOSHADER_PRESHADEROP_ASIN, - MOJOSHADER_PRESHADEROP_ACOS, - MOJOSHADER_PRESHADEROP_ATAN, - MOJOSHADER_PRESHADEROP_MIN, - MOJOSHADER_PRESHADEROP_MAX, - MOJOSHADER_PRESHADEROP_LT, - MOJOSHADER_PRESHADEROP_GE, - MOJOSHADER_PRESHADEROP_ADD, - MOJOSHADER_PRESHADEROP_MUL, - MOJOSHADER_PRESHADEROP_ATAN2, - MOJOSHADER_PRESHADEROP_DIV, - MOJOSHADER_PRESHADEROP_CMP, - MOJOSHADER_PRESHADEROP_MOVC, - MOJOSHADER_PRESHADEROP_DOT, - MOJOSHADER_PRESHADEROP_NOISE, - MOJOSHADER_PRESHADEROP_SCALAR_OPS, - MOJOSHADER_PRESHADEROP_MIN_SCALAR = MOJOSHADER_PRESHADEROP_SCALAR_OPS, - MOJOSHADER_PRESHADEROP_MAX_SCALAR, - MOJOSHADER_PRESHADEROP_LT_SCALAR, - MOJOSHADER_PRESHADEROP_GE_SCALAR, - MOJOSHADER_PRESHADEROP_ADD_SCALAR, - MOJOSHADER_PRESHADEROP_MUL_SCALAR, - MOJOSHADER_PRESHADEROP_ATAN2_SCALAR, - MOJOSHADER_PRESHADEROP_DIV_SCALAR, - MOJOSHADER_PRESHADEROP_DOT_SCALAR, - MOJOSHADER_PRESHADEROP_NOISE_SCALAR, -} MOJOSHADER_preshaderOpcode; - -typedef enum MOJOSHADER_preshaderOperandType -{ - MOJOSHADER_PRESHADEROPERAND_INPUT, - MOJOSHADER_PRESHADEROPERAND_OUTPUT, - MOJOSHADER_PRESHADEROPERAND_LITERAL, - MOJOSHADER_PRESHADEROPERAND_TEMP, -} MOJOSHADER_preshaderOperandType; - -typedef struct MOJOSHADER_preshaderOperand -{ - MOJOSHADER_preshaderOperandType type; - unsigned int index; -} MOJOSHADER_preshaderOperand; - -typedef struct MOJOSHADER_preshaderInstruction -{ - MOJOSHADER_preshaderOpcode opcode; - unsigned int element_count; - unsigned int operand_count; - MOJOSHADER_preshaderOperand operands[3]; -} MOJOSHADER_preshaderInstruction; - -typedef struct MOJOSHADER_preshader -{ - unsigned int literal_count; - double *literals; - unsigned int temp_count; /* scalar, not vector! */ - unsigned int symbol_count; - MOJOSHADER_symbol *symbols; - unsigned int instruction_count; - MOJOSHADER_preshaderInstruction *instructions; -} MOJOSHADER_preshader; - -/* - * Structure used to return data from parsing of a shader... - */ -/* !!! FIXME: most of these ints should be unsigned. */ -typedef struct MOJOSHADER_parseData -{ - /* - * The number of elements pointed to by (errors). - */ - int error_count; - - /* - * (error_count) elements of data that specify errors that were generated - * by parsing this shader. - * This can be NULL if there were no errors or if (error_count) is zero. - */ - MOJOSHADER_error *errors; - - /* - * The name of the profile used to parse the shader. Will be NULL on error. - */ - const char *profile; - - /* - * Bytes of output from parsing. Most profiles produce a string of source - * code, but profiles that do binary output may not be text at all. - * Will be NULL on error. - */ - const char *output; - - /* - * Byte count for output, not counting any null terminator. Most profiles - * produce an ASCII string of source code (which will be null-terminated - * even though that null char isn't included in output_len), but profiles - * that do binary output may not be text at all. Will be 0 on error. - */ - int output_len; - - /* - * Count of Direct3D instruction slots used. This is meaningless in terms - * of the actual output, as the profile will probably grow or reduce - * the count (or for high-level languages, not have that information at - * all). Also, as with Microsoft's own assembler, this value is just a - * rough estimate, as unpredicable real-world factors make the actual - * value vary at least a little from this count. Still, it can give you - * a rough idea of the size of your shader. Will be zero on error. - */ - int instruction_count; - - /* - * The type of shader we parsed. Will be MOJOSHADER_TYPE_UNKNOWN on error. - */ - MOJOSHADER_shaderType shader_type; - - /* - * The shader's major version. If this was a "vs_3_0", this would be 3. - */ - int major_ver; - - /* - * The shader's minor version. If this was a "ps_1_4", this would be 4. - * Two notes: for "vs_2_x", this is 1, and for "vs_3_sw", this is 255. - */ - int minor_ver; - - /* - * The number of elements pointed to by (uniforms). - */ - int uniform_count; - - /* - * (uniform_count) elements of data that specify Uniforms to be set for - * this shader. See discussion on MOJOSHADER_uniform for details. - * This can be NULL on error or if (uniform_count) is zero. - */ - MOJOSHADER_uniform *uniforms; - - /* - * The number of elements pointed to by (constants). - */ - int constant_count; - - /* - * (constant_count) elements of data that specify constants used in - * this shader. See discussion on MOJOSHADER_constant for details. - * This can be NULL on error or if (constant_count) is zero. - * This is largely informational: constants are hardcoded into a shader. - * The constants that you can set like parameters are in the "uniforms" - * list. - */ - MOJOSHADER_constant *constants; - - /* - * The number of elements pointed to by (samplers). - */ - int sampler_count; - - /* - * (sampler_count) elements of data that specify Samplers to be set for - * this shader. See discussion on MOJOSHADER_sampler for details. - * This can be NULL on error or if (sampler_count) is zero. - */ - MOJOSHADER_sampler *samplers; - - /* !!! FIXME: this should probably be "input" and not "attribute" */ - /* - * The number of elements pointed to by (attributes). - */ - int attribute_count; - - /* !!! FIXME: this should probably be "input" and not "attribute" */ - /* - * (attribute_count) elements of data that specify Attributes to be set - * for this shader. See discussion on MOJOSHADER_attribute for details. - * This can be NULL on error or if (attribute_count) is zero. - */ - MOJOSHADER_attribute *attributes; - - /* - * The number of elements pointed to by (outputs). - */ - int output_count; - - /* - * (output_count) elements of data that specify outputs this shader - * writes to. See discussion on MOJOSHADER_attribute for details. - * This can be NULL on error or if (output_count) is zero. - */ - MOJOSHADER_attribute *outputs; - - /* - * The number of elements pointed to by (swizzles). - */ - int swizzle_count; - - /* !!! FIXME: this should probably be "input" and not "attribute" */ - /* - * (swizzle_count) elements of data that specify swizzles the shader will - * apply to incoming attributes. This is a copy of what was passed to - * MOJOSHADER_parseData(). - * This can be NULL on error or if (swizzle_count) is zero. - */ - MOJOSHADER_swizzle *swizzles; - - /* - * The number of elements pointed to by (symbols). - */ - int symbol_count; - - /* - * (symbol_count) elements of data that specify high-level symbol data - * for the shader. This will be parsed from the CTAB section - * in bytecode, and will be a copy of what you provide to - * MOJOSHADER_assemble(). This data is optional. - * This can be NULL on error or if (symbol_count) is zero. - */ - MOJOSHADER_symbol *symbols; - - /* - * !!! FIXME: document me. - * This can be NULL on error or if no preshader was available. - */ - MOJOSHADER_preshader *preshader; - - /* - * This is the malloc implementation you passed to MOJOSHADER_parse(). - */ - MOJOSHADER_malloc malloc; - - /* - * This is the free implementation you passed to MOJOSHADER_parse(). - */ - MOJOSHADER_free free; - - /* - * This is the pointer you passed as opaque data for your allocator. - */ - void *malloc_data; -} MOJOSHADER_parseData; - - -/* - * Profile string for Direct3D assembly language output. - */ -#define MOJOSHADER_PROFILE_D3D "d3d" - -/* - * Profile string for passthrough of the original bytecode, unchanged. - */ -#define MOJOSHADER_PROFILE_BYTECODE "bytecode" - -/* - * Profile string for GLSL: OpenGL high-level shader language output. - */ -#define MOJOSHADER_PROFILE_GLSL "glsl" - -/* - * Profile string for GLSL 1.20: minor improvements to base GLSL spec. - */ -#define MOJOSHADER_PROFILE_GLSL120 "glsl120" - -/* - * Profile string for OpenGL ARB 1.0 shaders: GL_ARB_(vertex|fragment)_program. - */ -#define MOJOSHADER_PROFILE_ARB1 "arb1" - -/* - * Profile string for OpenGL ARB 1.0 shaders with Nvidia 2.0 extensions: - * GL_NV_vertex_program2_option and GL_NV_fragment_program2 - */ -#define MOJOSHADER_PROFILE_NV2 "nv2" - -/* - * Profile string for OpenGL ARB 1.0 shaders with Nvidia 3.0 extensions: - * GL_NV_vertex_program3 and GL_NV_fragment_program2 - */ -#define MOJOSHADER_PROFILE_NV3 "nv3" - -/* - * Profile string for OpenGL ARB 1.0 shaders with Nvidia 4.0 extensions: - * GL_NV_gpu_program4 - */ -#define MOJOSHADER_PROFILE_NV4 "nv4" - -/* - * Determine the highest supported Shader Model for a profile. - */ -int MOJOSHADER_maxShaderModel(const char *profile); - - -/* - * Parse a compiled Direct3D shader's bytecode. - * - * This is your primary entry point into MojoShader. You need to pass it - * a compiled D3D shader and tell it which "profile" you want to use to - * convert it into useful data. - * - * The available profiles are the set of MOJOSHADER_PROFILE_* defines. - * Note that MojoShader may be built without support for all listed - * profiles (in which case using one here will return with an error). - * - * As parsing requires some memory to be allocated, you may provide a custom - * allocator to this function, which will be used to allocate/free memory. - * They function just like malloc() and free(). We do not use realloc(). - * If you don't care, pass NULL in for the allocator functions. If your - * allocator needs instance-specific data, you may supply it with the - * (d) parameter. This pointer is passed as-is to your (m) and (f) functions. - * - * This function returns a MOJOSHADER_parseData. - * - * This function will never return NULL, even if the system is completely - * out of memory upon entry (in which case, this function returns a static - * MOJOSHADER_parseData object, which is still safe to pass to - * MOJOSHADER_freeParseData()). - * - * You can tell the generated program to swizzle certain inputs. If you know - * that COLOR0 should be RGBA but you're passing in ARGB, you can specify - * a swizzle of { MOJOSHADER_USAGE_COLOR, 0, {1,2,3,0} } to (swiz). If the - * input register in the code would produce reg.ywzx, that swizzle would - * change it to reg.wzxy ... (swiz) can be NULL. - * - * This function is thread safe, so long as (m) and (f) are too, and that - * (tokenbuf) remains intact for the duration of the call. This allows you - * to parse several shaders on separate CPU cores at the same time. - */ -const MOJOSHADER_parseData *MOJOSHADER_parse(const char *profile, - const unsigned char *tokenbuf, - const unsigned int bufsize, - const MOJOSHADER_swizzle *swiz, - const unsigned int swizcount, - MOJOSHADER_malloc m, - MOJOSHADER_free f, - void *d); - -/* - * Call this to dispose of parsing results when you are done with them. - * This will call the MOJOSHADER_free function you provided to - * MOJOSHADER_parse multiple times, if you provided one. - * Passing a NULL here is a safe no-op. - * - * This function is thread safe, so long as any allocator you passed into - * MOJOSHADER_parse() is, too. - */ -void MOJOSHADER_freeParseData(const MOJOSHADER_parseData *data); - - -/* Effects interface... */ /* !!! FIXME: THIS API IS NOT STABLE YET! */ - -typedef struct MOJOSHADER_effectParam -{ - const char *name; - const char *semantic; -} MOJOSHADER_effectParam; - -typedef struct MOJOSHADER_effectState -{ - unsigned int type; -} MOJOSHADER_effectState; - -typedef struct MOJOSHADER_effectPass -{ - const char *name; - unsigned int state_count; - MOJOSHADER_effectState *states; -} MOJOSHADER_effectPass; - -typedef struct MOJOSHADER_effectTechnique -{ - const char *name; - unsigned int pass_count; - MOJOSHADER_effectPass *passes; -} MOJOSHADER_effectTechnique; - -typedef struct MOJOSHADER_effectTexture -{ - unsigned int param; - const char *name; -} MOJOSHADER_effectTexture; - -typedef struct MOJOSHADER_effectShader -{ - unsigned int technique; - unsigned int pass; - const MOJOSHADER_parseData *shader; -} MOJOSHADER_effectShader; - -/* - * Structure used to return data from parsing of an effect file... - */ -/* !!! FIXME: most of these ints should be unsigned. */ -typedef struct MOJOSHADER_effect -{ - /* - * The number of elements pointed to by (errors). - */ - int error_count; - - /* - * (error_count) elements of data that specify errors that were generated - * by parsing this shader. - * This can be NULL if there were no errors or if (error_count) is zero. - */ - MOJOSHADER_error *errors; - - /* - * The name of the profile used to parse the shader. Will be NULL on error. - */ - const char *profile; - - /* - * The number of params pointed to by (params). - */ - int param_count; - - /* - * (param_count) elements of data that specify parameter bind points for - * this effect. - * This can be NULL on error or if (param_count) is zero. - */ - MOJOSHADER_effectParam *params; - - /* - * The number of elements pointed to by (techniques). - */ - int technique_count; - - /* - * (technique_count) elements of data that specify techniques used in - * this effect. Each technique contains a series of passes, and each pass - * specifies state and shaders that affect rendering. - * This can be NULL on error or if (technique_count) is zero. - */ - MOJOSHADER_effectTechnique *techniques; - - /* - * The number of elements pointed to by (textures). - */ - int texture_count; - - /* - * (texture_count) elements of data that specify textures used in - * this effect. - * This can be NULL on error or if (texture_count) is zero. - */ - MOJOSHADER_effectTexture *textures; - - /* - * The number of elements pointed to by (shaders). - */ - int shader_count; - - /* - * (shader_count) elements of data that specify shaders used in - * this effect. - * This can be NULL on error or if (shader_count) is zero. - */ - MOJOSHADER_effectShader *shaders; - - /* - * This is the malloc implementation you passed to MOJOSHADER_parseEffect(). - */ - MOJOSHADER_malloc malloc; - - /* - * This is the free implementation you passed to MOJOSHADER_parseEffect(). - */ - MOJOSHADER_free free; - - /* - * This is the pointer you passed as opaque data for your allocator. - */ - void *malloc_data; -} MOJOSHADER_effect; - -/* !!! FIXME: document me. */ -const MOJOSHADER_effect *MOJOSHADER_parseEffect(const char *profile, - const unsigned char *buf, - const unsigned int _len, - const MOJOSHADER_swizzle *swiz, - const unsigned int swizcount, - MOJOSHADER_malloc m, - MOJOSHADER_free f, - void *d); - - -/* !!! FIXME: document me. */ -void MOJOSHADER_freeEffect(const MOJOSHADER_effect *effect); - - -/* Preprocessor interface... */ - -/* - * Structure used to pass predefined macros. Maps to D3DXMACRO. - * You can have macro arguments: set identifier to "a(b, c)" or whatever. - */ -typedef struct MOJOSHADER_preprocessorDefine -{ - const char *identifier; - const char *definition; -} MOJOSHADER_preprocessorDefine; - -/* - * Used with the MOJOSHADER_includeOpen callback. Maps to D3DXINCLUDE_TYPE. - */ -typedef enum -{ - MOJOSHADER_INCLUDETYPE_LOCAL, /* local header: #include "blah.h" */ - MOJOSHADER_INCLUDETYPE_SYSTEM /* system header: #include <blah.h> */ -} MOJOSHADER_includeType; - - -/* - * Structure used to return data from preprocessing of a shader... - */ -/* !!! FIXME: most of these ints should be unsigned. */ -typedef struct MOJOSHADER_preprocessData -{ - /* - * The number of elements pointed to by (errors). - */ - int error_count; - - /* - * (error_count) elements of data that specify errors that were generated - * by parsing this shader. - * This can be NULL if there were no errors or if (error_count) is zero. - */ - MOJOSHADER_error *errors; - - /* - * Bytes of output from preprocessing. This is a UTF-8 string. We - * guarantee it to be NULL-terminated. Will be NULL on error. - */ - const char *output; - - /* - * Byte count for output, not counting any null terminator. - * Will be 0 on error. - */ - int output_len; - - /* - * This is the malloc implementation you passed to MOJOSHADER_parse(). - */ - MOJOSHADER_malloc malloc; - - /* - * This is the free implementation you passed to MOJOSHADER_parse(). - */ - MOJOSHADER_free free; - - /* - * This is the pointer you passed as opaque data for your allocator. - */ - void *malloc_data; -} MOJOSHADER_preprocessData; - - -/* - * This callback allows an app to handle #include statements for the - * preprocessor. When the preprocessor sees an #include, it will call this - * function to obtain the contents of the requested file. This is optional; - * the preprocessor will open files directly if no callback is supplied, but - * this allows an app to retrieve data from something other than the - * traditional filesystem (for example, headers packed in a .zip file or - * headers generated on-the-fly). - * - * This function maps to ID3DXInclude::Open() - * - * (inctype) specifies the type of header we wish to include. - * (fname) specifies the name of the file specified on the #include line. - * (parent) is a string of the entire source file containing the include, in - * its original, not-yet-preprocessed state. Note that this is just the - * contents of the specific file, not all source code that the preprocessor - * has seen through other includes, etc. - * (outdata) will be set by the callback to a pointer to the included file's - * contents. The callback is responsible for allocating this however they - * see fit (we provide allocator functions, but you may ignore them). This - * pointer must remain valid until the includeClose callback runs. This - * string does not need to be NULL-terminated. - * (outbytes) will be set by the callback to the number of bytes pointed to - * by (outdata). - * (m),(f), and (d) are the allocator details that the application passed to - * MojoShader. If these were NULL, MojoShader may have replaced them with its - * own internal allocators. - * - * The callback returns zero on error, non-zero on success. - * - * If you supply an includeOpen callback, you must supply includeClose, too. - */ -typedef int (*MOJOSHADER_includeOpen)(MOJOSHADER_includeType inctype, - const char *fname, const char *parent, - const char **outdata, unsigned int *outbytes, - MOJOSHADER_malloc m, MOJOSHADER_free f, void *d); - -/* - * This callback allows an app to clean up the results of a previous - * includeOpen callback. - * - * This function maps to ID3DXInclude::Close() - * - * (data) is the data that was returned from a previous call to includeOpen. - * It is now safe to deallocate this data. - * (m),(f), and (d) are the same allocator details that were passed to your - * includeOpen callback. - * - * If you supply an includeClose callback, you must supply includeOpen, too. - */ -typedef void (*MOJOSHADER_includeClose)(const char *data, - MOJOSHADER_malloc m, MOJOSHADER_free f, void *d); - - -/* - * This function is optional. Even if you are dealing with shader source - * code, you don't need to explicitly use the preprocessor, as the compiler - * and assembler will use it behind the scenes. In fact, you probably never - * need this function unless you are debugging a custom tool (or debugging - * MojoShader itself). - * - * Preprocessing roughly follows the syntax of an ANSI C preprocessor, as - * Microsoft's Direct3D assembler and HLSL compiler use this syntax. Please - * note that we try to match the output you'd get from Direct3D's - * preprocessor, which has some quirks if you're expecting output that matches - * a generic C preprocessor. - * - * This function maps to D3DXPreprocessShader(). - * - * (filename) is a NULL-terminated UTF-8 filename. It can be NULL. We do not - * actually access this file, as we obtain our data from (source). This - * string is copied when we need to report errors while processing (source), - * as opposed to errors in a file referenced via the #include directive in - * (source). If this is NULL, then errors will report the filename as NULL, - * too. - * - * (source) is an string of UTF-8 text to preprocess. It does not need to be - * NULL-terminated. - * - * (sourcelen) is the length of the string pointed to by (source), in bytes. - * - * (defines) points to (define_count) preprocessor definitions, and can be - * NULL. These are treated by the preprocessor as if the source code started - * with one #define for each entry you pass in here. - * - * (include_open) and (include_close) let the app control the preprocessor's - * behaviour for #include statements. Both are optional and can be NULL, but - * both must be specified if either is specified. - * - * This will return a MOJOSHADER_preprocessorData. You should pass this - * return value to MOJOSHADER_freePreprocessData() when you are done with - * it. - * - * This function will never return NULL, even if the system is completely - * out of memory upon entry (in which case, this function returns a static - * MOJOSHADER_preprocessData object, which is still safe to pass to - * MOJOSHADER_freePreprocessData()). - * - * As preprocessing requires some memory to be allocated, you may provide a - * custom allocator to this function, which will be used to allocate/free - * memory. They function just like malloc() and free(). We do not use - * realloc(). If you don't care, pass NULL in for the allocator functions. - * If your allocator needs instance-specific data, you may supply it with the - * (d) parameter. This pointer is passed as-is to your (m) and (f) functions. - * - * This function is thread safe, so long as the various callback functions - * are, too, and that the parameters remains intact for the duration of the - * call. This allows you to preprocess several shaders on separate CPU cores - * at the same time. - */ -const MOJOSHADER_preprocessData *MOJOSHADER_preprocess(const char *filename, - const char *source, unsigned int sourcelen, - const MOJOSHADER_preprocessorDefine *defines, - unsigned int define_count, - MOJOSHADER_includeOpen include_open, - MOJOSHADER_includeClose include_close, - MOJOSHADER_malloc m, MOJOSHADER_free f, void *d); - - -/* - * Call this to dispose of preprocessing results when you are done with them. - * This will call the MOJOSHADER_free function you provided to - * MOJOSHADER_preprocess() multiple times, if you provided one. - * Passing a NULL here is a safe no-op. - * - * This function is thread safe, so long as any allocator you passed into - * MOJOSHADER_preprocess() is, too. - */ -void MOJOSHADER_freePreprocessData(const MOJOSHADER_preprocessData *data); - - -/* Assembler interface... */ - -/* - * This function is optional. Use this to convert Direct3D shader assembly - * language into bytecode, which can be handled by MOJOSHADER_parse(). - * - * (filename) is a NULL-terminated UTF-8 filename. It can be NULL. We do not - * actually access this file, as we obtain our data from (source). This - * string is copied when we need to report errors while processing (source), - * as opposed to errors in a file referenced via the #include directive in - * (source). If this is NULL, then errors will report the filename as NULL, - * too. - * - * (source) is an UTF-8 string of valid Direct3D shader assembly source code. - * It does not need to be NULL-terminated. - * - * (sourcelen) is the length of the string pointed to by (source), in bytes. - * - * (comments) points to (comment_count) NULL-terminated UTF-8 strings, and - * can be NULL. These strings are inserted as comments in the bytecode. - * - * (symbols) points to (symbol_count) symbol structs, and can be NULL. These - * become a CTAB field in the bytecode. This is optional, but - * MOJOSHADER_parse() needs CTAB data for all arrays used in a program, or - * relative addressing will not be permitted, so you'll want to at least - * provide symbol information for those. The symbol data is 100% trusted - * at this time; it will not be checked to see if it matches what was - * assembled in any way whatsoever. - * - * (defines) points to (define_count) preprocessor definitions, and can be - * NULL. These are treated by the preprocessor as if the source code started - * with one #define for each entry you pass in here. - * - * (include_open) and (include_close) let the app control the preprocessor's - * behaviour for #include statements. Both are optional and can be NULL, but - * both must be specified if either is specified. - * - * This will return a MOJOSHADER_parseData, like MOJOSHADER_parse() would, - * except the profile will be MOJOSHADER_PROFILE_BYTECODE and the output - * will be the assembled bytecode instead of some other language. This output - * can be pushed back through MOJOSHADER_parseData() with a different profile. - * - * This function will never return NULL, even if the system is completely - * out of memory upon entry (in which case, this function returns a static - * MOJOSHADER_parseData object, which is still safe to pass to - * MOJOSHADER_freeParseData()). - * - * As assembling requires some memory to be allocated, you may provide a - * custom allocator to this function, which will be used to allocate/free - * memory. They function just like malloc() and free(). We do not use - * realloc(). If you don't care, pass NULL in for the allocator functions. - * If your allocator needs instance-specific data, you may supply it with the - * (d) parameter. This pointer is passed as-is to your (m) and (f) functions. - * - * This function is thread safe, so long as the various callback functions - * are, too, and that the parameters remains intact for the duration of the - * call. This allows you to assemble several shaders on separate CPU cores - * at the same time. - */ -const MOJOSHADER_parseData *MOJOSHADER_assemble(const char *filename, - const char *source, unsigned int sourcelen, - const char **comments, unsigned int comment_count, - const MOJOSHADER_symbol *symbols, - unsigned int symbol_count, - const MOJOSHADER_preprocessorDefine *defines, - unsigned int define_count, - MOJOSHADER_includeOpen include_open, - MOJOSHADER_includeClose include_close, - MOJOSHADER_malloc m, MOJOSHADER_free f, void *d); - - -/* High level shading language support... */ - -/* - * Source profile strings for HLSL: Direct3D High Level Shading Language. - */ -#define MOJOSHADER_SRC_PROFILE_HLSL_VS_1_1 "hlsl_vs_1_1" -#define MOJOSHADER_SRC_PROFILE_HLSL_VS_2_0 "hlsl_vs_2_0" -#define MOJOSHADER_SRC_PROFILE_HLSL_VS_3_0 "hlsl_vs_3_0" -#define MOJOSHADER_SRC_PROFILE_HLSL_PS_1_1 "hlsl_ps_1_1" -#define MOJOSHADER_SRC_PROFILE_HLSL_PS_1_2 "hlsl_ps_1_2" -#define MOJOSHADER_SRC_PROFILE_HLSL_PS_1_3 "hlsl_ps_1_3" -#define MOJOSHADER_SRC_PROFILE_HLSL_PS_1_4 "hlsl_ps_1_4" -#define MOJOSHADER_SRC_PROFILE_HLSL_PS_2_0 "hlsl_ps_2_0" -#define MOJOSHADER_SRC_PROFILE_HLSL_PS_3_0 "hlsl_ps_3_0" - - -/* Abstract Syntax Tree interface... */ - -/* - * ATTENTION: This adds a lot of stuff to the API, but almost everyone can - * ignore this section. Seriously, go ahead and skip over anything that has - * "AST" in it, unless you know why you'd want to use it. - * - * ALSO: This API is still evolving! We make no promises at this time to keep - * source or binary compatibility for the AST pieces. - * - * Important notes: - * - ASTs are the result of parsing the source code: a program that fails to - * compile will often parse successfully. Undeclared variables, - * type incompatibilities, etc, aren't detected at this point. - * - Vector swizzles (the ".xyzw" part of "MyVec4.xyzw") will look like - * structure dereferences. We don't realize these are actually swizzles - * until semantic analysis. - * - MOJOSHADER_astDataType info is not reliable when returned from - * MOJOSHADER_parseAst()! Most of the datatype info will be missing or have - * inaccurate data types. We sort these out during semantic analysis, which - * happens after the AST parsing is complete. A few are filled in, or can - * be deduced fairly trivially by processing several pieces into one. - * It's enough that you can reproduce the original source code, more or - * less, from the AST. - */ - -/* High-level datatypes for AST nodes. */ -typedef enum MOJOSHADER_astDataTypeType -{ - MOJOSHADER_AST_DATATYPE_NONE, - MOJOSHADER_AST_DATATYPE_BOOL, - MOJOSHADER_AST_DATATYPE_INT, - MOJOSHADER_AST_DATATYPE_UINT, - MOJOSHADER_AST_DATATYPE_FLOAT, - MOJOSHADER_AST_DATATYPE_FLOAT_SNORM, - MOJOSHADER_AST_DATATYPE_FLOAT_UNORM, - MOJOSHADER_AST_DATATYPE_HALF, - MOJOSHADER_AST_DATATYPE_DOUBLE, - MOJOSHADER_AST_DATATYPE_STRING, - MOJOSHADER_AST_DATATYPE_SAMPLER_1D, - MOJOSHADER_AST_DATATYPE_SAMPLER_2D, - MOJOSHADER_AST_DATATYPE_SAMPLER_3D, - MOJOSHADER_AST_DATATYPE_SAMPLER_CUBE, - MOJOSHADER_AST_DATATYPE_SAMPLER_STATE, - MOJOSHADER_AST_DATATYPE_SAMPLER_COMPARISON_STATE, - MOJOSHADER_AST_DATATYPE_STRUCT, - MOJOSHADER_AST_DATATYPE_ARRAY, - MOJOSHADER_AST_DATATYPE_VECTOR, - MOJOSHADER_AST_DATATYPE_MATRIX, - MOJOSHADER_AST_DATATYPE_BUFFER, - MOJOSHADER_AST_DATATYPE_FUNCTION, - MOJOSHADER_AST_DATATYPE_USER, -} MOJOSHADER_astDataTypeType; -#define MOJOSHADER_AST_DATATYPE_CONST (1 << 31) - -typedef union MOJOSHADER_astDataType MOJOSHADER_astDataType; - -// This is just part of DataTypeStruct, never appears outside of it. -typedef struct MOJOSHADER_astDataTypeStructMember -{ - const MOJOSHADER_astDataType *datatype; - const char *identifier; -} MOJOSHADER_astDataTypeStructMember; - -typedef struct MOJOSHADER_astDataTypeStruct -{ - MOJOSHADER_astDataTypeType type; - const MOJOSHADER_astDataTypeStructMember *members; - int member_count; -} MOJOSHADER_astDataTypeStruct; - -typedef struct MOJOSHADER_astDataTypeArray -{ - MOJOSHADER_astDataTypeType type; - const MOJOSHADER_astDataType *base; - int elements; -} MOJOSHADER_astDataTypeArray; - -typedef MOJOSHADER_astDataTypeArray MOJOSHADER_astDataTypeVector; - -typedef struct MOJOSHADER_astDataTypeMatrix -{ - MOJOSHADER_astDataTypeType type; - const MOJOSHADER_astDataType *base; - int rows; - int columns; -} MOJOSHADER_astDataTypeMatrix; - -typedef struct MOJOSHADER_astDataTypeBuffer -{ - MOJOSHADER_astDataTypeType type; - const MOJOSHADER_astDataType *base; -} MOJOSHADER_astDataTypeBuffer; - -typedef struct MOJOSHADER_astDataTypeFunction -{ - MOJOSHADER_astDataTypeType type; - const MOJOSHADER_astDataType *retval; - const MOJOSHADER_astDataType **params; - int num_params; - int intrinsic; /* non-zero for built-in functions */ -} MOJOSHADER_astDataTypeFunction; - -typedef struct MOJOSHADER_astDataTypeUser -{ - MOJOSHADER_astDataTypeType type; - const MOJOSHADER_astDataType *details; - const char *name; -} MOJOSHADER_astDataTypeUser; - -union MOJOSHADER_astDataType -{ - MOJOSHADER_astDataTypeType type; - MOJOSHADER_astDataTypeArray array; - MOJOSHADER_astDataTypeStruct structure; - MOJOSHADER_astDataTypeVector vector; - MOJOSHADER_astDataTypeMatrix matrix; - MOJOSHADER_astDataTypeBuffer buffer; - MOJOSHADER_astDataTypeUser user; - MOJOSHADER_astDataTypeFunction function; -}; - -/* Structures that make up the parse tree... */ - -typedef enum MOJOSHADER_astNodeType -{ - MOJOSHADER_AST_OP_START_RANGE, /* expression operators. */ - - MOJOSHADER_AST_OP_START_RANGE_UNARY, /* unary operators. */ - MOJOSHADER_AST_OP_PREINCREMENT, - MOJOSHADER_AST_OP_PREDECREMENT, - MOJOSHADER_AST_OP_NEGATE, - MOJOSHADER_AST_OP_COMPLEMENT, - MOJOSHADER_AST_OP_NOT, - MOJOSHADER_AST_OP_POSTINCREMENT, - MOJOSHADER_AST_OP_POSTDECREMENT, - MOJOSHADER_AST_OP_CAST, - MOJOSHADER_AST_OP_END_RANGE_UNARY, - - MOJOSHADER_AST_OP_START_RANGE_BINARY, /* binary operators. */ - MOJOSHADER_AST_OP_COMMA, - MOJOSHADER_AST_OP_MULTIPLY, - MOJOSHADER_AST_OP_DIVIDE, - MOJOSHADER_AST_OP_MODULO, - MOJOSHADER_AST_OP_ADD, - MOJOSHADER_AST_OP_SUBTRACT, - MOJOSHADER_AST_OP_LSHIFT, - MOJOSHADER_AST_OP_RSHIFT, - MOJOSHADER_AST_OP_LESSTHAN, - MOJOSHADER_AST_OP_GREATERTHAN, - MOJOSHADER_AST_OP_LESSTHANOREQUAL, - MOJOSHADER_AST_OP_GREATERTHANOREQUAL, - MOJOSHADER_AST_OP_EQUAL, - MOJOSHADER_AST_OP_NOTEQUAL, - MOJOSHADER_AST_OP_BINARYAND, - MOJOSHADER_AST_OP_BINARYXOR, - MOJOSHADER_AST_OP_BINARYOR, - MOJOSHADER_AST_OP_LOGICALAND, - MOJOSHADER_AST_OP_LOGICALOR, - MOJOSHADER_AST_OP_ASSIGN, - MOJOSHADER_AST_OP_MULASSIGN, - MOJOSHADER_AST_OP_DIVASSIGN, - MOJOSHADER_AST_OP_MODASSIGN, - MOJOSHADER_AST_OP_ADDASSIGN, - MOJOSHADER_AST_OP_SUBASSIGN, - MOJOSHADER_AST_OP_LSHIFTASSIGN, - MOJOSHADER_AST_OP_RSHIFTASSIGN, - MOJOSHADER_AST_OP_ANDASSIGN, - MOJOSHADER_AST_OP_XORASSIGN, - MOJOSHADER_AST_OP_ORASSIGN, - MOJOSHADER_AST_OP_DEREF_ARRAY, - MOJOSHADER_AST_OP_END_RANGE_BINARY, - - MOJOSHADER_AST_OP_START_RANGE_TERNARY, /* ternary operators. */ - MOJOSHADER_AST_OP_CONDITIONAL, - MOJOSHADER_AST_OP_END_RANGE_TERNARY, - - MOJOSHADER_AST_OP_START_RANGE_DATA, /* expression operands. */ - MOJOSHADER_AST_OP_IDENTIFIER, - MOJOSHADER_AST_OP_INT_LITERAL, - MOJOSHADER_AST_OP_FLOAT_LITERAL, - MOJOSHADER_AST_OP_STRING_LITERAL, - MOJOSHADER_AST_OP_BOOLEAN_LITERAL, - MOJOSHADER_AST_OP_END_RANGE_DATA, - - MOJOSHADER_AST_OP_START_RANGE_MISC, /* other expression things. */ - MOJOSHADER_AST_OP_DEREF_STRUCT, - MOJOSHADER_AST_OP_CALLFUNC, - MOJOSHADER_AST_OP_CONSTRUCTOR, - MOJOSHADER_AST_OP_END_RANGE_MISC, - MOJOSHADER_AST_OP_END_RANGE, - - MOJOSHADER_AST_COMPUNIT_START_RANGE, /* things in global scope. */ - MOJOSHADER_AST_COMPUNIT_FUNCTION, - MOJOSHADER_AST_COMPUNIT_TYPEDEF, - MOJOSHADER_AST_COMPUNIT_STRUCT, - MOJOSHADER_AST_COMPUNIT_VARIABLE, - MOJOSHADER_AST_COMPUNIT_END_RANGE, - - MOJOSHADER_AST_STATEMENT_START_RANGE, /* statements in function scope. */ - MOJOSHADER_AST_STATEMENT_EMPTY, - MOJOSHADER_AST_STATEMENT_BREAK, - MOJOSHADER_AST_STATEMENT_CONTINUE, - MOJOSHADER_AST_STATEMENT_DISCARD, - MOJOSHADER_AST_STATEMENT_BLOCK, - MOJOSHADER_AST_STATEMENT_EXPRESSION, - MOJOSHADER_AST_STATEMENT_IF, - MOJOSHADER_AST_STATEMENT_SWITCH, - MOJOSHADER_AST_STATEMENT_FOR, - MOJOSHADER_AST_STATEMENT_DO, - MOJOSHADER_AST_STATEMENT_WHILE, - MOJOSHADER_AST_STATEMENT_RETURN, - MOJOSHADER_AST_STATEMENT_TYPEDEF, - MOJOSHADER_AST_STATEMENT_STRUCT, - MOJOSHADER_AST_STATEMENT_VARDECL, - MOJOSHADER_AST_STATEMENT_END_RANGE, - - MOJOSHADER_AST_MISC_START_RANGE, /* misc. syntactic glue. */ - MOJOSHADER_AST_FUNCTION_PARAMS, - MOJOSHADER_AST_FUNCTION_SIGNATURE, - MOJOSHADER_AST_SCALAR_OR_ARRAY, - MOJOSHADER_AST_TYPEDEF, - MOJOSHADER_AST_PACK_OFFSET, - MOJOSHADER_AST_VARIABLE_LOWLEVEL, - MOJOSHADER_AST_ANNOTATION, - MOJOSHADER_AST_VARIABLE_DECLARATION, - MOJOSHADER_AST_STRUCT_DECLARATION, - MOJOSHADER_AST_STRUCT_MEMBER, - MOJOSHADER_AST_SWITCH_CASE, - MOJOSHADER_AST_ARGUMENTS, - MOJOSHADER_AST_MISC_END_RANGE, - - MOJOSHADER_AST_END_RANGE -} MOJOSHADER_astNodeType; - -typedef struct MOJOSHADER_astNodeInfo -{ - MOJOSHADER_astNodeType type; - const char *filename; - unsigned int line; -} MOJOSHADER_astNodeInfo; - -typedef enum MOJOSHADER_astVariableAttributes -{ - MOJOSHADER_AST_VARATTR_EXTERN = (1 << 0), - MOJOSHADER_AST_VARATTR_NOINTERPOLATION = (1 << 1), - MOJOSHADER_AST_VARATTR_SHARED = (1 << 2), - MOJOSHADER_AST_VARATTR_STATIC = (1 << 3), - MOJOSHADER_AST_VARATTR_UNIFORM = (1 << 4), - MOJOSHADER_AST_VARATTR_VOLATILE = (1 << 5), - MOJOSHADER_AST_VARATTR_CONST = (1 << 6), - MOJOSHADER_AST_VARATTR_ROWMAJOR = (1 << 7), - MOJOSHADER_AST_VARATTR_COLUMNMAJOR = (1 << 8) -} MOJOSHADER_astVariableAttributes; - -typedef enum MOJOSHADER_astIfAttributes -{ - MOJOSHADER_AST_IFATTR_NONE, - MOJOSHADER_AST_IFATTR_BRANCH, - MOJOSHADER_AST_IFATTR_FLATTEN, - MOJOSHADER_AST_IFATTR_IFALL, - MOJOSHADER_AST_IFATTR_IFANY, - MOJOSHADER_AST_IFATTR_PREDICATE, - MOJOSHADER_AST_IFATTR_PREDICATEBLOCK, -} MOJOSHADER_astIfAttributes; - -typedef enum MOJOSHADER_astSwitchAttributes -{ - MOJOSHADER_AST_SWITCHATTR_NONE, - MOJOSHADER_AST_SWITCHATTR_FLATTEN, - MOJOSHADER_AST_SWITCHATTR_BRANCH, - MOJOSHADER_AST_SWITCHATTR_FORCECASE, - MOJOSHADER_AST_SWITCHATTR_CALL -} MOJOSHADER_astSwitchAttributes; - -/* You can cast any AST node pointer to this. */ -typedef struct MOJOSHADER_astGeneric -{ - MOJOSHADER_astNodeInfo ast; -} MOJOSHADER_astGeneric; - -typedef struct MOJOSHADER_astExpression -{ - MOJOSHADER_astNodeInfo ast; - const MOJOSHADER_astDataType *datatype; -} MOJOSHADER_astExpression; - -typedef struct MOJOSHADER_astArguments -{ - MOJOSHADER_astNodeInfo ast; /* Always MOJOSHADER_AST_ARGUMENTS */ - MOJOSHADER_astExpression *argument; - struct MOJOSHADER_astArguments *next; -} MOJOSHADER_astArguments; - -typedef struct MOJOSHADER_astExpressionUnary -{ - MOJOSHADER_astNodeInfo ast; - const MOJOSHADER_astDataType *datatype; - MOJOSHADER_astExpression *operand; -} MOJOSHADER_astExpressionUnary; - -typedef struct MOJOSHADER_astExpressionBinary -{ - MOJOSHADER_astNodeInfo ast; - const MOJOSHADER_astDataType *datatype; - MOJOSHADER_astExpression *left; - MOJOSHADER_astExpression *right; -} MOJOSHADER_astExpressionBinary; - -typedef struct MOJOSHADER_astExpressionTernary -{ - MOJOSHADER_astNodeInfo ast; - const MOJOSHADER_astDataType *datatype; - MOJOSHADER_astExpression *left; - MOJOSHADER_astExpression *center; - MOJOSHADER_astExpression *right; -} MOJOSHADER_astExpressionTernary; - -/* Identifier indexes aren't available until semantic analysis phase completes. - * It provides a unique id for this identifier's variable. - * It will be negative for global scope, positive for function scope - * (global values are globally unique, function values are only - * unique within the scope of the given function). There's a different - * set of indices if this identifier is a function (positive for - * user-defined functions, negative for intrinsics). - * May be zero for various reasons (unknown identifier, etc). - */ -typedef struct MOJOSHADER_astExpressionIdentifier -{ - MOJOSHADER_astNodeInfo ast; /* Always MOJOSHADER_AST_OP_IDENTIFIER */ - const MOJOSHADER_astDataType *datatype; - const char *identifier; - int index; -} MOJOSHADER_astExpressionIdentifier; - -typedef struct MOJOSHADER_astExpressionIntLiteral -{ - MOJOSHADER_astNodeInfo ast; /* Always MOJOSHADER_AST_OP_INT_LITERAL */ - const MOJOSHADER_astDataType *datatype; /* always AST_DATATYPE_INT */ - int value; -} MOJOSHADER_astExpressionIntLiteral; - -typedef struct MOJOSHADER_astExpressionFloatLiteral -{ - MOJOSHADER_astNodeInfo ast; /* Always MOJOSHADER_AST_OP_FLOAT_LITERAL */ - const MOJOSHADER_astDataType *datatype; /* always AST_DATATYPE_FLOAT */ - double value; -} MOJOSHADER_astExpressionFloatLiteral; - -typedef struct MOJOSHADER_astExpressionStringLiteral -{ - MOJOSHADER_astNodeInfo ast; /* Always MOJOSHADER_AST_OP_STRING_LITERAL */ - const MOJOSHADER_astDataType *datatype; /* always AST_DATATYPE_STRING */ - const char *string; -} MOJOSHADER_astExpressionStringLiteral; - -typedef struct MOJOSHADER_astExpressionBooleanLiteral -{ - MOJOSHADER_astNodeInfo ast; /* Always MOJOSHADER_AST_OP_BOOLEAN_LITERAL */ - const MOJOSHADER_astDataType *datatype; /* always AST_DATATYPE_BOOL */ - int value; /* Always 1 or 0. */ -} MOJOSHADER_astExpressionBooleanLiteral; - -typedef struct MOJOSHADER_astExpressionConstructor -{ - MOJOSHADER_astNodeInfo ast; /* Always MOJOSHADER_AST_OP_CONSTRUCTOR */ - const MOJOSHADER_astDataType *datatype; - MOJOSHADER_astArguments *args; -} MOJOSHADER_astExpressionConstructor; - -typedef struct MOJOSHADER_astExpressionDerefStruct -{ - MOJOSHADER_astNodeInfo ast; /* Always MOJOSHADER_AST_OP_DEREF_STRUCT */ - const MOJOSHADER_astDataType *datatype; - /* !!! FIXME: - * "identifier" is misnamed; this might not be an identifier at all: - * x = FunctionThatReturnsAStruct().SomeMember; - */ - MOJOSHADER_astExpression *identifier; - const char *member; - int isswizzle; /* Always 1 or 0. Never set by parseAst()! */ - int member_index; /* Never set by parseAst()! */ -} MOJOSHADER_astExpressionDerefStruct; - -typedef struct MOJOSHADER_astExpressionCallFunction -{ - MOJOSHADER_astNodeInfo ast; /* Always MOJOSHADER_AST_OP_CALLFUNC */ - const MOJOSHADER_astDataType *datatype; - MOJOSHADER_astExpressionIdentifier *identifier; - MOJOSHADER_astArguments *args; -} MOJOSHADER_astExpressionCallFunction; - -typedef struct MOJOSHADER_astExpressionCast -{ - MOJOSHADER_astNodeInfo ast; /* Always MOJOSHADER_AST_OP_CAST */ - const MOJOSHADER_astDataType *datatype; - MOJOSHADER_astExpression *operand; -} MOJOSHADER_astExpressionCast; - -typedef struct MOJOSHADER_astCompilationUnit -{ - MOJOSHADER_astNodeInfo ast; - struct MOJOSHADER_astCompilationUnit *next; -} MOJOSHADER_astCompilationUnit; - -typedef enum MOJOSHADER_astFunctionStorageClass -{ - MOJOSHADER_AST_FNSTORECLS_NONE, - MOJOSHADER_AST_FNSTORECLS_INLINE -} MOJOSHADER_astFunctionStorageClass; - -typedef enum MOJOSHADER_astInputModifier -{ - MOJOSHADER_AST_INPUTMOD_NONE, - MOJOSHADER_AST_INPUTMOD_IN, - MOJOSHADER_AST_INPUTMOD_OUT, - MOJOSHADER_AST_INPUTMOD_INOUT, - MOJOSHADER_AST_INPUTMOD_UNIFORM -} MOJOSHADER_astInputModifier; - -typedef enum MOJOSHADER_astInterpolationModifier -{ - MOJOSHADER_AST_INTERPMOD_NONE, - MOJOSHADER_AST_INTERPMOD_LINEAR, - MOJOSHADER_AST_INTERPMOD_CENTROID, - MOJOSHADER_AST_INTERPMOD_NOINTERPOLATION, - MOJOSHADER_AST_INTERPMOD_NOPERSPECTIVE, - MOJOSHADER_AST_INTERPMOD_SAMPLE -} MOJOSHADER_astInterpolationModifier; - -typedef struct MOJOSHADER_astFunctionParameters -{ - MOJOSHADER_astNodeInfo ast; - const MOJOSHADER_astDataType *datatype; - MOJOSHADER_astInputModifier input_modifier; - const char *identifier; - const char *semantic; - MOJOSHADER_astInterpolationModifier interpolation_modifier; - MOJOSHADER_astExpression *initializer; - struct MOJOSHADER_astFunctionParameters *next; -} MOJOSHADER_astFunctionParameters; - -typedef struct MOJOSHADER_astFunctionSignature -{ - MOJOSHADER_astNodeInfo ast; - const MOJOSHADER_astDataType *datatype; - const char *identifier; - MOJOSHADER_astFunctionParameters *params; - MOJOSHADER_astFunctionStorageClass storage_class; - const char *semantic; -} MOJOSHADER_astFunctionSignature; - -typedef struct MOJOSHADER_astScalarOrArray -{ - MOJOSHADER_astNodeInfo ast; - const char *identifier; - int isarray; /* boolean: 1 or 0 */ - MOJOSHADER_astExpression *dimension; -} MOJOSHADER_astScalarOrArray; - -typedef struct MOJOSHADER_astAnnotations -{ - MOJOSHADER_astNodeInfo ast; - const MOJOSHADER_astDataType *datatype; - MOJOSHADER_astExpression *initializer; - struct MOJOSHADER_astAnnotations *next; -} MOJOSHADER_astAnnotations; - -typedef struct MOJOSHADER_astPackOffset -{ - MOJOSHADER_astNodeInfo ast; - const char *ident1; /* !!! FIXME: rename this. */ - const char *ident2; -} MOJOSHADER_astPackOffset; - -typedef struct MOJOSHADER_astVariableLowLevel -{ - MOJOSHADER_astNodeInfo ast; - MOJOSHADER_astPackOffset *packoffset; - const char *register_name; -} MOJOSHADER_astVariableLowLevel; - -typedef struct MOJOSHADER_astStructMembers -{ - MOJOSHADER_astNodeInfo ast; - const MOJOSHADER_astDataType *datatype; - const char *semantic; - MOJOSHADER_astScalarOrArray *details; - MOJOSHADER_astInterpolationModifier interpolation_mod; - struct MOJOSHADER_astStructMembers *next; -} MOJOSHADER_astStructMembers; - -typedef struct MOJOSHADER_astStructDeclaration -{ - MOJOSHADER_astNodeInfo ast; - const MOJOSHADER_astDataType *datatype; - const char *name; - MOJOSHADER_astStructMembers *members; -} MOJOSHADER_astStructDeclaration; - -typedef struct MOJOSHADER_astVariableDeclaration -{ - MOJOSHADER_astNodeInfo ast; - int attributes; - const MOJOSHADER_astDataType *datatype; - MOJOSHADER_astStructDeclaration *anonymous_datatype; - MOJOSHADER_astScalarOrArray *details; - const char *semantic; - MOJOSHADER_astAnnotations *annotations; - MOJOSHADER_astExpression *initializer; - MOJOSHADER_astVariableLowLevel *lowlevel; - struct MOJOSHADER_astVariableDeclaration *next; -} MOJOSHADER_astVariableDeclaration; - -typedef struct MOJOSHADER_astStatement -{ - MOJOSHADER_astNodeInfo ast; - struct MOJOSHADER_astStatement *next; -} MOJOSHADER_astStatement; - -typedef MOJOSHADER_astStatement MOJOSHADER_astEmptyStatement; -typedef MOJOSHADER_astStatement MOJOSHADER_astBreakStatement; -typedef MOJOSHADER_astStatement MOJOSHADER_astContinueStatement; -typedef MOJOSHADER_astStatement MOJOSHADER_astDiscardStatement; - -/* something enclosed in "{}" braces. */ -typedef struct MOJOSHADER_astBlockStatement -{ - MOJOSHADER_astNodeInfo ast; - MOJOSHADER_astStatement *next; - MOJOSHADER_astStatement *statements; /* list of child statements. */ -} MOJOSHADER_astBlockStatement; - -typedef struct MOJOSHADER_astReturnStatement -{ - MOJOSHADER_astNodeInfo ast; - MOJOSHADER_astStatement *next; - MOJOSHADER_astExpression *expr; -} MOJOSHADER_astReturnStatement; - -typedef struct MOJOSHADER_astExpressionStatement -{ - MOJOSHADER_astNodeInfo ast; - MOJOSHADER_astStatement *next; - MOJOSHADER_astExpression *expr; -} MOJOSHADER_astExpressionStatement; - -typedef struct MOJOSHADER_astIfStatement -{ - MOJOSHADER_astNodeInfo ast; - MOJOSHADER_astStatement *next; - int attributes; - MOJOSHADER_astExpression *expr; - MOJOSHADER_astStatement *statement; - MOJOSHADER_astStatement *else_statement; -} MOJOSHADER_astIfStatement; - -typedef struct MOJOSHADER_astSwitchCases -{ - MOJOSHADER_astNodeInfo ast; - MOJOSHADER_astExpression *expr; - MOJOSHADER_astStatement *statement; - struct MOJOSHADER_astSwitchCases *next; -} MOJOSHADER_astSwitchCases; - -typedef struct MOJOSHADER_astSwitchStatement -{ - MOJOSHADER_astNodeInfo ast; - MOJOSHADER_astStatement *next; - int attributes; - MOJOSHADER_astExpression *expr; - MOJOSHADER_astSwitchCases *cases; -} MOJOSHADER_astSwitchStatement; - -typedef struct MOJOSHADER_astWhileStatement -{ - MOJOSHADER_astNodeInfo ast; - MOJOSHADER_astStatement *next; - int unroll; /* # times to unroll, 0 to loop, < 0 == compiler's choice. */ - MOJOSHADER_astExpression *expr; - MOJOSHADER_astStatement *statement; -} MOJOSHADER_astWhileStatement; - -typedef MOJOSHADER_astWhileStatement MOJOSHADER_astDoStatement; - -typedef struct MOJOSHADER_astForStatement -{ - MOJOSHADER_astNodeInfo ast; - MOJOSHADER_astStatement *next; - int unroll; /* # times to unroll, 0 to loop, < 0 == compiler's choice. */ - MOJOSHADER_astVariableDeclaration *var_decl; /* either this ... */ - MOJOSHADER_astExpression *initializer; /* ... or this will used. */ - MOJOSHADER_astExpression *looptest; - MOJOSHADER_astExpression *counter; - MOJOSHADER_astStatement *statement; -} MOJOSHADER_astForStatement; - -typedef struct MOJOSHADER_astTypedef -{ - MOJOSHADER_astNodeInfo ast; - const MOJOSHADER_astDataType *datatype; - int isconst; /* boolean: 1 or 0 */ - MOJOSHADER_astScalarOrArray *details; -} MOJOSHADER_astTypedef; - -typedef struct MOJOSHADER_astTypedefStatement -{ - MOJOSHADER_astNodeInfo ast; - MOJOSHADER_astStatement *next; - MOJOSHADER_astTypedef *type_info; -} MOJOSHADER_astTypedefStatement; - -typedef struct MOJOSHADER_astVarDeclStatement -{ - MOJOSHADER_astNodeInfo ast; - MOJOSHADER_astStatement *next; - MOJOSHADER_astVariableDeclaration *declaration; -} MOJOSHADER_astVarDeclStatement; - -typedef struct MOJOSHADER_astStructStatement -{ - MOJOSHADER_astNodeInfo ast; - MOJOSHADER_astStatement *next; - MOJOSHADER_astStructDeclaration *struct_info; -} MOJOSHADER_astStructStatement; - -typedef struct MOJOSHADER_astCompilationUnitFunction -{ - MOJOSHADER_astNodeInfo ast; - MOJOSHADER_astCompilationUnit *next; - MOJOSHADER_astFunctionSignature *declaration; - MOJOSHADER_astStatement *definition; - int index; /* unique id. Will be 0 until semantic analysis runs. */ -} MOJOSHADER_astCompilationUnitFunction; - -typedef struct MOJOSHADER_astCompilationUnitTypedef -{ - MOJOSHADER_astNodeInfo ast; - MOJOSHADER_astCompilationUnit *next; - MOJOSHADER_astTypedef *type_info; -} MOJOSHADER_astCompilationUnitTypedef; - -typedef struct MOJOSHADER_astCompilationUnitStruct -{ - MOJOSHADER_astNodeInfo ast; - MOJOSHADER_astCompilationUnit *next; - MOJOSHADER_astStructDeclaration *struct_info; -} MOJOSHADER_astCompilationUnitStruct; - -typedef struct MOJOSHADER_astCompilationUnitVariable -{ - MOJOSHADER_astNodeInfo ast; - MOJOSHADER_astCompilationUnit *next; - MOJOSHADER_astVariableDeclaration *declaration; -} MOJOSHADER_astCompilationUnitVariable; - - -/* this is way cleaner than all the nasty typecasting. */ -typedef union MOJOSHADER_astNode -{ - MOJOSHADER_astNodeInfo ast; - MOJOSHADER_astGeneric generic; - MOJOSHADER_astExpression expression; - MOJOSHADER_astArguments arguments; - MOJOSHADER_astExpressionUnary unary; - MOJOSHADER_astExpressionBinary binary; - MOJOSHADER_astExpressionTernary ternary; - MOJOSHADER_astExpressionIdentifier identifier; - MOJOSHADER_astExpressionIntLiteral intliteral; - MOJOSHADER_astExpressionFloatLiteral floatliteral; - MOJOSHADER_astExpressionStringLiteral stringliteral; - MOJOSHADER_astExpressionBooleanLiteral boolliteral; - MOJOSHADER_astExpressionConstructor constructor; - MOJOSHADER_astExpressionDerefStruct derefstruct; - MOJOSHADER_astExpressionCallFunction callfunc; - MOJOSHADER_astExpressionCast cast; - MOJOSHADER_astCompilationUnit compunit; - MOJOSHADER_astFunctionParameters params; - MOJOSHADER_astFunctionSignature funcsig; - MOJOSHADER_astScalarOrArray soa; - MOJOSHADER_astAnnotations annotations; - MOJOSHADER_astPackOffset packoffset; - MOJOSHADER_astVariableLowLevel varlowlevel; - MOJOSHADER_astStructMembers structmembers; - MOJOSHADER_astStructDeclaration structdecl; - MOJOSHADER_astVariableDeclaration vardecl; - MOJOSHADER_astStatement stmt; - MOJOSHADER_astEmptyStatement emptystmt; - MOJOSHADER_astBreakStatement breakstmt; - MOJOSHADER_astContinueStatement contstmt; - MOJOSHADER_astDiscardStatement discardstmt; - MOJOSHADER_astBlockStatement blockstmt; - MOJOSHADER_astReturnStatement returnstmt; - MOJOSHADER_astExpressionStatement exprstmt; - MOJOSHADER_astIfStatement ifstmt; - MOJOSHADER_astSwitchCases cases; - MOJOSHADER_astSwitchStatement switchstmt; - MOJOSHADER_astWhileStatement whilestmt; - MOJOSHADER_astDoStatement dostmt; - MOJOSHADER_astForStatement forstmt; - MOJOSHADER_astTypedef typdef; - MOJOSHADER_astTypedefStatement typedefstmt; - MOJOSHADER_astVarDeclStatement vardeclstmt; - MOJOSHADER_astStructStatement structstmt; - MOJOSHADER_astCompilationUnitFunction funcunit; - MOJOSHADER_astCompilationUnitTypedef typedefunit; - MOJOSHADER_astCompilationUnitStruct structunit; - MOJOSHADER_astCompilationUnitVariable varunit; -} MOJOSHADER_astNode; - - -/* - * Structure used to return data from parsing of a shader into an AST... - */ -/* !!! FIXME: most of these ints should be unsigned. */ -typedef struct MOJOSHADER_astData -{ - /* - * The number of elements pointed to by (errors). - */ - int error_count; - - /* - * (error_count) elements of data that specify errors that were generated - * by parsing this shader. - * This can be NULL if there were no errors or if (error_count) is zero. - * Note that this will only produce errors for syntax problems. Most of - * the things we expect a compiler to produce errors for--incompatible - * types, unknown identifiers, etc--are not checked at all during - * initial generation of the syntax tree...bogus programs that would - * fail to compile will pass here without error, if they are syntactically - * correct! - */ - MOJOSHADER_error *errors; - - /* - * The name of the source profile used to parse the shader. Will be NULL - * on error. - */ - const char *source_profile; - - /* - * The actual syntax tree. You are responsible for walking it yourself. - * CompilationUnits are always the top of the tree (functions, typedefs, - * global variables, etc). Will be NULL on error. - */ - const MOJOSHADER_astNode *ast; - - /* - * This is the malloc implementation you passed to MOJOSHADER_parse(). - */ - MOJOSHADER_malloc malloc; - - /* - * This is the free implementation you passed to MOJOSHADER_parse(). - */ - MOJOSHADER_free free; - - /* - * This is the pointer you passed as opaque data for your allocator. - */ - void *malloc_data; - - /* - * This is internal data, and not for the application to touch. - */ - void *opaque; -} MOJOSHADER_astData; - - -/* - * You almost certainly don't need this function, unless you absolutely know - * why you need it without hesitation. This is almost certainly only good for - * building code analysis tools on top of. - * - * This is intended to parse HLSL source code, turning it into an abstract - * syntax tree. - * - * (srcprofile) specifies the source language of the shader. You can specify - * a shader model with this, too. See MOJOSHADER_SRC_PROFILE_* constants. - * - * (filename) is a NULL-terminated UTF-8 filename. It can be NULL. We do not - * actually access this file, as we obtain our data from (source). This - * string is copied when we need to report errors while processing (source), - * as opposed to errors in a file referenced via the #include directive in - * (source). If this is NULL, then errors will report the filename as NULL, - * too. - * - * (source) is an UTF-8 string of valid high-level shader source code. - * It does not need to be NULL-terminated. - * - * (sourcelen) is the length of the string pointed to by (source), in bytes. - * - * (defines) points to (define_count) preprocessor definitions, and can be - * NULL. These are treated by the preprocessor as if the source code started - * with one #define for each entry you pass in here. - * - * (include_open) and (include_close) let the app control the preprocessor's - * behaviour for #include statements. Both are optional and can be NULL, but - * both must be specified if either is specified. - * - * This will return a MOJOSHADER_astData. The data supplied here gives the - * application a tree-like structure they can walk to see the layout of - * a given program. When you are done with this data, pass it to - * MOJOSHADER_freeCompileData() to deallocate resources. - * - * This function will never return NULL, even if the system is completely - * out of memory upon entry (in which case, this function returns a static - * MOJOSHADER_astData object, which is still safe to pass to - * MOJOSHADER_freeAstData()). - * - * As parsing requires some memory to be allocated, you may provide a - * custom allocator to this function, which will be used to allocate/free - * memory. They function just like malloc() and free(). We do not use - * realloc(). If you don't care, pass NULL in for the allocator functions. - * If your allocator needs instance-specific data, you may supply it with the - * (d) parameter. This pointer is passed as-is to your (m) and (f) functions. - * - * This function is thread safe, so long as the various callback functions - * are, too, and that the parameters remains intact for the duration of the - * call. This allows you to parse several shaders on separate CPU cores - * at the same time. - */ -const MOJOSHADER_astData *MOJOSHADER_parseAst(const char *srcprofile, - const char *filename, const char *source, - unsigned int sourcelen, - const MOJOSHADER_preprocessorDefine *defs, - unsigned int define_count, - MOJOSHADER_includeOpen include_open, - MOJOSHADER_includeClose include_close, - MOJOSHADER_malloc m, MOJOSHADER_free f, - void *d); - - -/* !!! FIXME: expose semantic analysis to the public API? */ - - -/* - * Call this to dispose of AST parsing results when you are done with them. - * This will call the MOJOSHADER_free function you provided to - * MOJOSHADER_parseAst() multiple times, if you provided one. - * Passing a NULL here is a safe no-op. - * - * This function is thread safe, so long as any allocator you passed into - * MOJOSHADER_parseAst() is, too. - */ -void MOJOSHADER_freeAstData(const MOJOSHADER_astData *data); - - -/* Intermediate Representation interface... */ -/* !!! FIXME: there is currently no way to access the IR via the public API. */ -typedef enum MOJOSHADER_irNodeType -{ - MOJOSHADER_IR_START_RANGE_EXPR, - MOJOSHADER_IR_CONSTANT, - MOJOSHADER_IR_TEMP, - MOJOSHADER_IR_BINOP, - MOJOSHADER_IR_MEMORY, - MOJOSHADER_IR_CALL, - MOJOSHADER_IR_ESEQ, - MOJOSHADER_IR_ARRAY, - MOJOSHADER_IR_CONVERT, - MOJOSHADER_IR_SWIZZLE, - MOJOSHADER_IR_CONSTRUCT, - MOJOSHADER_IR_END_RANGE_EXPR, - - MOJOSHADER_IR_START_RANGE_STMT, - MOJOSHADER_IR_MOVE, - MOJOSHADER_IR_EXPR_STMT, - MOJOSHADER_IR_JUMP, - MOJOSHADER_IR_CJUMP, - MOJOSHADER_IR_SEQ, - MOJOSHADER_IR_LABEL, - MOJOSHADER_IR_DISCARD, - MOJOSHADER_IR_END_RANGE_STMT, - - MOJOSHADER_IR_START_RANGE_MISC, - MOJOSHADER_IR_EXPRLIST, - MOJOSHADER_IR_END_RANGE_MISC, - - MOJOSHADER_IR_END_RANGE -} MOJOSHADER_irNodeType; - -typedef struct MOJOSHADER_irNodeInfo -{ - MOJOSHADER_irNodeType type; - const char *filename; - unsigned int line; -} MOJOSHADER_irNodeInfo; - -typedef struct MOJOSHADER_irExprList MOJOSHADER_irExprList; - -/* - * IR nodes are categorized into Expressions, Statements, and Everything Else. - * You can cast any of them to MOJOSHADER_irGeneric, but this split is - * useful for slightly better type-checking (you can't cleanly assign - * something that doesn't return a value to something that wants one, etc). - * These broader categories are just unions of the simpler types, so the - * real definitions are below all the things they contain (but these - * predeclarations are because the simpler types refer to the broader - * categories). - */ -typedef union MOJOSHADER_irExpression MOJOSHADER_irExpression; /* returns a value. */ -typedef union MOJOSHADER_irStatement MOJOSHADER_irStatement; /* no returned value. */ -typedef union MOJOSHADER_irMisc MOJOSHADER_irMisc; /* Everything Else. */ -typedef union MOJOSHADER_irNode MOJOSHADER_irNode; /* Generic uber-wrapper. */ - -/* You can cast any IR node pointer to this. */ -typedef struct MOJOSHADER_irGeneric -{ - MOJOSHADER_irNodeInfo ir; -} MOJOSHADER_irGeneric; - - -/* These are used for MOJOSHADER_irBinOp */ -typedef enum MOJOSHADER_irBinOpType -{ - MOJOSHADER_IR_BINOP_ADD, - MOJOSHADER_IR_BINOP_SUBTRACT, - MOJOSHADER_IR_BINOP_MULTIPLY, - MOJOSHADER_IR_BINOP_DIVIDE, - MOJOSHADER_IR_BINOP_MODULO, - MOJOSHADER_IR_BINOP_AND, - MOJOSHADER_IR_BINOP_OR, - MOJOSHADER_IR_BINOP_XOR, - MOJOSHADER_IR_BINOP_LSHIFT, - MOJOSHADER_IR_BINOP_RSHIFT, - MOJOSHADER_IR_BINOP_UNKNOWN -} MOJOSHADER_irBinOpType; - -typedef enum MOJOSHADER_irConditionType -{ - MOJOSHADER_IR_COND_EQL, - MOJOSHADER_IR_COND_NEQ, - MOJOSHADER_IR_COND_LT, - MOJOSHADER_IR_COND_GT, - MOJOSHADER_IR_COND_LEQ, - MOJOSHADER_IR_COND_GEQ, - MOJOSHADER_IR_COND_UNKNOWN -} MOJOSHADER_irConditionType; - - -/* MOJOSHADER_irExpression types... */ - -typedef struct MOJOSHADER_irExprInfo -{ - MOJOSHADER_irNodeInfo ir; - MOJOSHADER_astDataTypeType type; - int elements; -} MOJOSHADER_irExprInfo; - -typedef struct MOJOSHADER_irConstant /* Constant value */ -{ - MOJOSHADER_irExprInfo info; /* Always MOJOSHADER_IR_CONSTANT */ - union - { - int ival[16]; - float fval[16]; - } value; -} MOJOSHADER_irConstant; - -typedef struct MOJOSHADER_irTemp /* temp value (not necessarily a register). */ -{ - MOJOSHADER_irExprInfo info; /* Always MOJOSHADER_IR_TEMP */ - int index; -} MOJOSHADER_irTemp; - -typedef struct MOJOSHADER_irBinOp /* binary operator (+, -, etc) */ -{ - MOJOSHADER_irExprInfo info; /* Always MOJOSHADER_IR_BINOP */ - MOJOSHADER_irBinOpType op; - MOJOSHADER_irExpression *left; - MOJOSHADER_irExpression *right; -} MOJOSHADER_irBinOp; - -typedef struct MOJOSHADER_irMemory -{ - MOJOSHADER_irExprInfo info; /* Always MOJOSHADER_IR_MEMORY */ - int index; /* not final addresses, just a unique identifier. */ -} MOJOSHADER_irMemory; - -typedef struct MOJOSHADER_irCall -{ - MOJOSHADER_irExprInfo info; /* Always MOJOSHADER_IR_CALL */ - int index; - MOJOSHADER_irExprList *args; -} MOJOSHADER_irCall; - -typedef struct MOJOSHADER_irESeq /* statement with result */ -{ - MOJOSHADER_irExprInfo info; /* Always MOJOSHADER_IR_ESEQ */ - MOJOSHADER_irStatement *stmt; /* execute this for side-effects, then... */ - MOJOSHADER_irExpression *expr; /* ...use this for the result. */ -} MOJOSHADER_irESeq; - -typedef struct MOJOSHADER_irArray /* Array dereference. */ -{ - MOJOSHADER_irExprInfo info; /* Always MOJOSHADER_IR_ARRAY */ - MOJOSHADER_irExpression *array; - MOJOSHADER_irExpression *element; -} MOJOSHADER_irArray; - -typedef struct MOJOSHADER_irConvert /* casting between datatypes */ -{ - MOJOSHADER_irExprInfo info; /* Always MOJOSHADER_IR_CONVERT */ - MOJOSHADER_irExpression *expr; -} MOJOSHADER_irConvert; - -typedef struct MOJOSHADER_irSwizzle /* vector swizzle */ -{ - MOJOSHADER_irExprInfo info; /* Always MOJOSHADER_IR_SWIZZLE */ - MOJOSHADER_irExpression *expr; - char channels[4]; -} MOJOSHADER_irSwizzle; - -typedef struct MOJOSHADER_irConstruct /* vector construct from discrete items */ -{ - MOJOSHADER_irExprInfo info; /* Always MOJOSHADER_IR_CONTSTRUCT */ - MOJOSHADER_irExprList *args; -} MOJOSHADER_irConstruct; - -/* Wrap the whole category in a union for type "safety." */ -union MOJOSHADER_irExpression -{ - MOJOSHADER_irNodeInfo ir; - MOJOSHADER_irExprInfo info; - MOJOSHADER_irConstant constant; - MOJOSHADER_irTemp temp; - MOJOSHADER_irBinOp binop; - MOJOSHADER_irMemory memory; - MOJOSHADER_irCall call; - MOJOSHADER_irESeq eseq; - MOJOSHADER_irArray array; - MOJOSHADER_irConvert convert; - MOJOSHADER_irSwizzle swizzle; - MOJOSHADER_irConstruct construct; -}; - -/* MOJOSHADER_irStatement types. */ - -typedef struct MOJOSHADER_irMove /* load/store. */ -{ - MOJOSHADER_irNodeInfo ir; /* Always MOJOSHADER_IR_MOVE */ - MOJOSHADER_irExpression *dst; /* must result in a temp or mem! */ - MOJOSHADER_irExpression *src; - int writemask; // for write-masking vector channels. -} MOJOSHADER_irMove; - -typedef struct MOJOSHADER_irExprStmt /* evaluate expression, throw it away. */ -{ - MOJOSHADER_irNodeInfo ir; /* Always MOJOSHADER_IR_EXPR_STMT */ - MOJOSHADER_irExpression *expr; -} MOJOSHADER_irExprStmt; - -typedef struct MOJOSHADER_irJump /* unconditional jump */ -{ - MOJOSHADER_irNodeInfo ir; /* Always MOJOSHADER_IR_JUMP */ - int label; - // !!! FIXME: possible label list, for further optimization passes. -} MOJOSHADER_irJump; - -typedef struct MOJOSHADER_irCJump /* conditional jump */ -{ - MOJOSHADER_irNodeInfo ir; /* Always MOJOSHADER_IR_CJUMP */ - MOJOSHADER_irConditionType cond; - MOJOSHADER_irExpression *left; /* if (left cond right) */ - MOJOSHADER_irExpression *right; - int iftrue; /* label id for true case. */ - int iffalse; /* label id for false case. */ -} MOJOSHADER_irCJump; - -typedef struct MOJOSHADER_irSeq /* statement without side effects */ -{ - MOJOSHADER_irNodeInfo ir; /* Always MOJOSHADER_IR_SEQ */ - MOJOSHADER_irStatement *first; - MOJOSHADER_irStatement *next; -} MOJOSHADER_irSeq; - -typedef struct MOJOSHADER_irLabel /* like a label in assembly language. */ -{ - MOJOSHADER_irNodeInfo ir; /* Always MOJOSHADER_IR_LABEL */ - int index; -} MOJOSHADER_irLabel; - -typedef MOJOSHADER_irGeneric MOJOSHADER_irDiscard; /* discard statement. */ - - -/* Wrap the whole category in a union for type "safety." */ -union MOJOSHADER_irStatement -{ - MOJOSHADER_irNodeInfo ir; - MOJOSHADER_irGeneric generic; - MOJOSHADER_irMove move; - MOJOSHADER_irExprStmt expr; - MOJOSHADER_irJump jump; - MOJOSHADER_irCJump cjump; - MOJOSHADER_irSeq seq; - MOJOSHADER_irLabel label; - MOJOSHADER_irDiscard discard; -}; - -/* MOJOSHADER_irMisc types. */ - -struct MOJOSHADER_irExprList -{ - MOJOSHADER_irNodeInfo ir; /* Always MOJOSHADER_IR_EXPRLIST */ - MOJOSHADER_irExpression *expr; - MOJOSHADER_irExprList *next; -}; - -/* Wrap the whole category in a union for type "safety." */ -union MOJOSHADER_irMisc -{ - MOJOSHADER_irNodeInfo ir; - MOJOSHADER_irGeneric generic; - MOJOSHADER_irExprList exprlist; -}; - -/* This is a catchall for all your needs. :) */ -union MOJOSHADER_irNode -{ - MOJOSHADER_irNodeInfo ir; - MOJOSHADER_irGeneric generic; - MOJOSHADER_irExpression expr; - MOJOSHADER_irStatement stmt; - MOJOSHADER_irMisc misc; -}; - - -/* Compiler interface... */ - -/* - * Structure used to return data from parsing of a shader... - */ -/* !!! FIXME: most of these ints should be unsigned. */ -typedef struct MOJOSHADER_compileData -{ - /* - * The number of elements pointed to by (errors). - */ - int error_count; - - /* - * (error_count) elements of data that specify errors that were generated - * by compiling this shader. - * This can be NULL if there were no errors or if (error_count) is zero. - */ - MOJOSHADER_error *errors; - - /* - * The number of elements pointed to by (warnings). - */ - int warning_count; - - /* - * (warning_count) elements of data that specify errors that were - * generated by compiling this shader. - * This can be NULL if there were no errors or if (warning_count) is zero. - */ - MOJOSHADER_error *warnings; - - /* - * The name of the source profile used to compile the shader. Will be NULL - * on error. - */ - const char *source_profile; - - /* - * Bytes of output from compiling. This will be a null-terminated ASCII - * string of D3D assembly source code. - */ - const char *output; - - /* - * Byte count for output, not counting any null terminator. - * Will be 0 on error. - */ - int output_len; - - /* - * The number of elements pointed to by (symbols). - */ - int symbol_count; - - /* - * (symbol_count) elements of data that specify high-level symbol data - * for the shader. This can be used by MOJOSHADER_assemble() to - * generate a CTAB section in bytecode, which is needed by - * MOJOSHADER_parseData() to handle some shaders. This can be NULL on - * error or if (symbol_count) is zero. - */ - MOJOSHADER_symbol *symbols; - - /* - * This is the malloc implementation you passed to MOJOSHADER_parse(). - */ - MOJOSHADER_malloc malloc; - - /* - * This is the free implementation you passed to MOJOSHADER_parse(). - */ - MOJOSHADER_free free; - - /* - * This is the pointer you passed as opaque data for your allocator. - */ - void *malloc_data; -} MOJOSHADER_compileData; - - -/* - * This function is optional. Use this to compile high-level shader programs. - * - * This is intended to turn HLSL source code into D3D assembly code, which - * can then be passed to MOJOSHADER_assemble() to convert it to D3D bytecode - * (which can then be used with MOJOSHADER_parseData() to support other - * shading targets). - * - * (srcprofile) specifies the source language of the shader. You can specify - * a shader model with this, too. See MOJOSHADER_SRC_PROFILE_* constants. - * - * (filename) is a NULL-terminated UTF-8 filename. It can be NULL. We do not - * actually access this file, as we obtain our data from (source). This - * string is copied when we need to report errors while processing (source), - * as opposed to errors in a file referenced via the #include directive in - * (source). If this is NULL, then errors will report the filename as NULL, - * too. - * - * (source) is an UTF-8 string of valid high-level shader source code. - * It does not need to be NULL-terminated. - * - * (sourcelen) is the length of the string pointed to by (source), in bytes. - * - * (defines) points to (define_count) preprocessor definitions, and can be - * NULL. These are treated by the preprocessor as if the source code started - * with one #define for each entry you pass in here. - * - * (include_open) and (include_close) let the app control the preprocessor's - * behaviour for #include statements. Both are optional and can be NULL, but - * both must be specified if either is specified. - * - * This will return a MOJOSHADER_compileData. The data supplied here is - * sufficient to supply to MOJOSHADER_assemble() for further processing. - * When you are done with this data, pass it to MOJOSHADER_freeCompileData() - * to deallocate resources. - * - * This function will never return NULL, even if the system is completely - * out of memory upon entry (in which case, this function returns a static - * MOJOSHADER_compileData object, which is still safe to pass to - * MOJOSHADER_freeCompileData()). - * - * As compiling requires some memory to be allocated, you may provide a - * custom allocator to this function, which will be used to allocate/free - * memory. They function just like malloc() and free(). We do not use - * realloc(). If you don't care, pass NULL in for the allocator functions. - * If your allocator needs instance-specific data, you may supply it with the - * (d) parameter. This pointer is passed as-is to your (m) and (f) functions. - * - * This function is thread safe, so long as the various callback functions - * are, too, and that the parameters remains intact for the duration of the - * call. This allows you to compile several shaders on separate CPU cores - * at the same time. - */ -const MOJOSHADER_compileData *MOJOSHADER_compile(const char *srcprofile, - const char *filename, const char *source, - unsigned int sourcelen, - const MOJOSHADER_preprocessorDefine *defs, - unsigned int define_count, - MOJOSHADER_includeOpen include_open, - MOJOSHADER_includeClose include_close, - MOJOSHADER_malloc m, MOJOSHADER_free f, - void *d); - - -/* - * Call this to dispose of compile results when you are done with them. - * This will call the MOJOSHADER_free function you provided to - * MOJOSHADER_compile() multiple times, if you provided one. - * Passing a NULL here is a safe no-op. - * - * This function is thread safe, so long as any allocator you passed into - * MOJOSHADER_compile() is, too. - */ -void MOJOSHADER_freeCompileData(const MOJOSHADER_compileData *data); - - -/* OpenGL interface... */ - -/* - * Signature for function lookup callbacks. MojoShader will call a function - * you provide to get OpenGL entry points (both standard functions and - * extensions). Through this, MojoShader never links directly to OpenGL, - * but relies on you to provide the implementation. This means you can - * swap in different drivers, or hook functions (log every GL call MojoShader - * makes, etc). - * - * (fnname) is the function name we want the address for ("glBegin" or - * whatever. (data) is a void pointer you provide, if this callback needs - * extra information. If you don't need it, you may specify NULL. - * - * Return the entry point on success, NULL if it couldn't be found. - * Note that this could ask for standard entry points like glEnable(), or - * extensions like glProgramLocalParameterI4ivNV(), so you might need - * to check two places to find the desired entry point, depending on your - * platform (Windows might need to look in OpenGL32.dll and use WGL, etc). - */ -typedef void *(*MOJOSHADER_glGetProcAddress)(const char *fnname, void *data); - - -/* - * "Contexts" map to OpenGL contexts...you need one per window, or whatever, - * and need to inform MojoShader when you make a new one current. - * - * "Shaders" refer to individual vertex or pixel programs, and are created - * by "compiling" Direct3D shader bytecode. A vertex and pixel shader are - * "linked" into a "Program" before you can use them to render. - * - * To the calling application, these are all opaque handles. - */ -typedef struct MOJOSHADER_glContext MOJOSHADER_glContext; -typedef struct MOJOSHADER_glShader MOJOSHADER_glShader; -typedef struct MOJOSHADER_glProgram MOJOSHADER_glProgram; - - -/* - * Get a list of available profiles. This will fill in the array (profs) - * with up to (size) pointers of profiles that the current system can handle; - * that is, the profiles are built into MojoShader and the OpenGL extensions - * required for them exist at runtime. This function returns the number of - * available profiles, which may be more, less, or equal to (size). - * - * If there are more than (size) profiles, the (profs) buffer will not - * overflow. You can check the return value for the total number of - * available profiles, allocate more space, and try again if necessary. - * Calling this function with (size) == 0 is legal. - * - * You can only call this AFTER you have successfully built your GL context - * and made it current. This function will lookup the GL functions it needs - * through the callback you supply, via (lookup) and (d). The lookup function - * is neither stored nor used by MojoShader after this function returns, nor - * are the functions it might look up. - * - * You should not free any strings returned from this function; they are - * pointers to internal, probably static, memory. - * - * This call is NOT thread safe! As most OpenGL implementations are not thread - * safe, you should probably only call this from the same thread that created - * the GL context. - */ -int MOJOSHADER_glAvailableProfiles(MOJOSHADER_glGetProcAddress lookup, void *d, - const char **profs, const int size); - - -/* - * Determine the best profile to use for the current system. - * - * You can only call this AFTER you have successfully built your GL context - * and made it current. This function will lookup the GL functions it needs - * through the callback you supply via (lookup) and (d). The lookup function - * is neither stored nor used by MojoShader after this function returns, nor - * are the functions it might look up. - * - * Returns the name of the "best" profile on success, NULL if none of the - * available profiles will work on this system. "Best" is a relative term, - * but it generally means the best trade off between feature set and - * performance. The selection algorithm may be arbitrary and complex. - * - * The returned value is an internal static string, and should not be free()'d - * by the caller. If you get a NULL, calling MOJOSHADER_glGetError() might - * shed some light on why. - * - * This call is NOT thread safe! As most OpenGL implementations are not thread - * safe, you should probably only call this from the same thread that created - * the GL context. - */ -const char *MOJOSHADER_glBestProfile(MOJOSHADER_glGetProcAddress lookup, void *d); - - -/* - * Prepare MojoShader to manage OpenGL shaders. - * - * You do not need to call this if all you want is MOJOSHADER_parse(). - * - * You must call this once AFTER you have successfully built your GL context - * and made it current. This function will lookup the GL functions it needs - * through the callback you supply via (lookup) and (lookup_d), after which - * it may call them at any time up until you call - * MOJOSHADER_glDestroyContext(). The lookup function is neither stored nor - * used by MojoShader after this function returns. - * - * (profile) is an OpenGL-specific MojoShader profile, which decides how - * Direct3D bytecode shaders get turned into OpenGL programs, and how they - * are fed to the GL. - * - * (lookup) is a callback that is used to load GL entry points. This callback - * has to look up base GL functions and extension entry points. The pointer - * you supply in (lookup_d) is passed as-is to the callback. - * - * As MojoShader requires some memory to be allocated, you may provide a - * custom allocator to this function, which will be used to allocate/free - * memory. They function just like malloc() and free(). We do not use - * realloc(). If you don't care, pass NULL in for the allocator functions. - * If your allocator needs instance-specific data, you may supply it with the - * (malloc_d) parameter. This pointer is passed as-is to your (m) and (f) - * functions. - * - * Returns a new context on success, NULL on error. If you get a new context, - * you need to make it current before using it with - * MOJOSHADER_glMakeContextCurrent(). - * - * This call is NOT thread safe! It must return success before you may call - * any other MOJOSHADER_gl* function. Also, as most OpenGL implementations - * are not thread safe, you should probably only call this from the same - * thread that created the GL context. - */ -MOJOSHADER_glContext *MOJOSHADER_glCreateContext(const char *profile, - MOJOSHADER_glGetProcAddress lookup, - void *lookup_d, - MOJOSHADER_malloc m, MOJOSHADER_free f, - void *malloc_d); - -/* - * You must call this before using the context that you got from - * MOJOSHADER_glCreateContext(), and must use it when you switch to a new GL - * context. - * - * You can only have one MOJOSHADER_glContext per actual GL context, or - * undefined behaviour will result. - * - * It is legal to call this with a NULL pointer to make no context current, - * but you need a valid context to be current to use most of MojoShader. - */ -void MOJOSHADER_glMakeContextCurrent(MOJOSHADER_glContext *ctx); - -/* - * Get any error state we might have picked up. MojoShader will NOT call - * glGetError() internally, but there are other errors we can pick up, - * such as failed shader compilation, etc. - * - * Returns a human-readable string. This string is for debugging purposes, and - * not guaranteed to be localized, coherent, or user-friendly in any way. - * It's for programmers! - * - * The latest error may remain between calls. New errors replace any existing - * error. Don't check this string for a sign that an error happened, check - * return codes instead and use this for explanation when debugging. - * - * Do not free the returned string: it's a pointer to a static internal - * buffer. Do not keep the pointer around, either, as it's likely to become - * invalid as soon as you call into MojoShader again. - * - * This call is NOT thread safe! As most OpenGL implementations are not thread - * safe, you should probably only call this from the same thread that created - * the GL context. - * - * This call does NOT require a valid MOJOSHADER_glContext to have been made - * current. The error buffer is shared between contexts, so you can get - * error results from a failed MOJOSHADER_glCreateContext(). - */ -const char *MOJOSHADER_glGetError(void); - -/* - * Get the maximum uniforms a shader can support for the current GL context, - * MojoShader profile, and shader type. You can use this to make decisions - * about what shaders you want to use (for example, a less complicated - * shader may be swapped in for lower-end systems). - * - * Returns the number, or -1 on error. - * - * This call is NOT thread safe! As most OpenGL implementations are not thread - * safe, you should probably only call this from the same thread that created - * the GL context. - * - * This call requires a valid MOJOSHADER_glContext to have been made current, - * or it will crash your program. See MOJOSHADER_glMakeContextCurrent(). - */ -int MOJOSHADER_glMaxUniforms(MOJOSHADER_shaderType shader_type); - -/* - * Compile a buffer of Direct3D shader bytecode into an OpenGL shader. - * You still need to link the shader before you may render with it. - * - * (tokenbuf) is a buffer of Direct3D shader bytecode. - * (bufsize) is the size, in bytes, of the bytecode buffer. - * (swiz) and (swizcount) are passed to MOJOSHADER_parse() unmolested. - * - * Returns NULL on error, or a shader handle on success. - * - * This call is NOT thread safe! As most OpenGL implementations are not thread - * safe, you should probably only call this from the same thread that created - * the GL context. - * - * This call requires a valid MOJOSHADER_glContext to have been made current, - * or it will crash your program. See MOJOSHADER_glMakeContextCurrent(). - * - * Compiled shaders from this function may not be shared between contexts. - */ -MOJOSHADER_glShader *MOJOSHADER_glCompileShader(const unsigned char *tokenbuf, - const unsigned int bufsize, - const MOJOSHADER_swizzle *swiz, - const unsigned int swizcount); - - -/* - * Get the MOJOSHADER_parseData structure that was produced from the - * call to MOJOSHADER_glCompileShader(). - * - * This data is read-only, and you should NOT attempt to free it. This - * pointer remains valid until the shader is deleted. - */ -const MOJOSHADER_parseData *MOJOSHADER_glGetShaderParseData( - MOJOSHADER_glShader *shader); -/* - * Link a vertex and pixel shader into an OpenGL program. - * (vshader) or (pshader) can be NULL, to specify that the GL should use the - * fixed-function pipeline instead of the programmable pipeline for that - * portion of the work. You can reuse shaders in various combinations across - * multiple programs, by relinking different pairs. - * - * It is illegal to give a vertex shader for (pshader) or a pixel shader - * for (vshader). - * - * Once you have successfully linked a program, you may render with it. - * - * Returns NULL on error, or a program handle on success. - * - * This call is NOT thread safe! As most OpenGL implementations are not thread - * safe, you should probably only call this from the same thread that created - * the GL context. - * - * This call requires a valid MOJOSHADER_glContext to have been made current, - * or it will crash your program. See MOJOSHADER_glMakeContextCurrent(). - * - * Linked programs from this function may not be shared between contexts. - */ -MOJOSHADER_glProgram *MOJOSHADER_glLinkProgram(MOJOSHADER_glShader *vshader, - MOJOSHADER_glShader *pshader); - -/* - * This binds the program (using, for example, glUseProgramObjectARB()), and - * disables all the client-side arrays so we can reset them with new values - * if appropriate. - * - * Call with NULL to disable the programmable pipeline and all enabled - * client-side arrays. - * - * After binding a program, you should update any uniforms you care about - * with MOJOSHADER_glSetVertexShaderUniformF() (etc), set any vertex arrays - * you want to use with MOJOSHADER_glSetVertexAttribute(), and finally call - * MOJOSHADER_glProgramReady() to commit everything to the GL. Then you may - * begin drawing through standard GL entry points. - * - * This call is NOT thread safe! As most OpenGL implementations are not thread - * safe, you should probably only call this from the same thread that created - * the GL context. - * - * This call requires a valid MOJOSHADER_glContext to have been made current, - * or it will crash your program. See MOJOSHADER_glMakeContextCurrent(). - */ -void MOJOSHADER_glBindProgram(MOJOSHADER_glProgram *program); - -// !!! FIXME: document this. -void MOJOSHADER_glBindShaders(MOJOSHADER_glShader *vshader, - MOJOSHADER_glShader *pshader); - -/* - * Set a floating-point uniform value (what Direct3D calls a "constant"). - * - * There is a single array of 4-float "registers" shared by all vertex shaders. - * This is the "c" register file in Direct3D (c0, c1, c2, etc...) - * MojoShader will take care of synchronizing this internal array with the - * appropriate variables in the GL shaders. - * - * (idx) is the index into the internal array: 0 is the first four floats, - * 1 is the next four, etc. - * (data) is a pointer to (vec4count*4) floats. - * - * This call is NOT thread safe! As most OpenGL implementations are not thread - * safe, you should probably only call this from the same thread that created - * the GL context. - * - * This call requires a valid MOJOSHADER_glContext to have been made current, - * or it will crash your program. See MOJOSHADER_glMakeContextCurrent(). - * - * Uniforms are not shared between contexts. - */ -void MOJOSHADER_glSetVertexShaderUniformF(unsigned int idx, const float *data, - unsigned int vec4count); - -/* - * Retrieve a floating-point uniform value (what Direct3D calls a "constant"). - * - * There is a single array of 4-float "registers" shared by all vertex shaders. - * This is the "c" register file in Direct3D (c0, c1, c2, etc...) - * MojoShader will take care of synchronizing this internal array with the - * appropriate variables in the GL shaders. - * - * (idx) is the index into the internal array: 0 is the first four floats, - * 1 is the next four, etc. - * (data) is a pointer to space for (vec4count*4) floats. - * (data) will be filled will current values in the register file. Results - * are undefined if you request data past the end of the register file or - * previously uninitialized registers. - * - * This is a "fast" call; we're just reading memory from internal memory. We - * do not query the GPU or the GL for this information. - * - * This call is NOT thread safe! As most OpenGL implementations are not thread - * safe, you should probably only call this from the same thread that created - * the GL context. - * - * This call requires a valid MOJOSHADER_glContext to have been made current, - * or it will crash your program. See MOJOSHADER_glMakeContextCurrent(). - * - * Uniforms are not shared between contexts. - */ -void MOJOSHADER_glGetVertexShaderUniformF(unsigned int idx, float *data, - unsigned int vec4count); - - -/* - * Set an integer uniform value (what Direct3D calls a "constant"). - * - * There is a single array of 4-int "registers" shared by all vertex shaders. - * This is the "i" register file in Direct3D (i0, i1, i2, etc...) - * MojoShader will take care of synchronizing this internal array with the - * appropriate variables in the GL shaders. - * - * (idx) is the index into the internal array: 0 is the first four ints, - * 1 is the next four, etc. - * (data) is a pointer to (ivec4count*4) ints. - * - * This call is NOT thread safe! As most OpenGL implementations are not thread - * safe, you should probably only call this from the same thread that created - * the GL context. - * - * This call requires a valid MOJOSHADER_glContext to have been made current, - * or it will crash your program. See MOJOSHADER_glMakeContextCurrent(). - * - * Uniforms are not shared between contexts. - */ -void MOJOSHADER_glSetVertexShaderUniformI(unsigned int idx, const int *data, - unsigned int ivec4count); - -/* - * Retrieve an integer uniform value (what Direct3D calls a "constant"). - * - * There is a single array of 4-int "registers" shared by all vertex shaders. - * This is the "i" register file in Direct3D (i0, i1, i2, etc...) - * MojoShader will take care of synchronizing this internal array with the - * appropriate variables in the GL shaders. - * - * (idx) is the index into the internal array: 0 is the first four ints, - * 1 is the next four, etc. - * (data) is a pointer to space for (ivec4count*4) ints. - * (data) will be filled will current values in the register file. Results - * are undefined if you request data past the end of the register file or - * previously uninitialized registers. - * - * This is a "fast" call; we're just reading memory from internal memory. We - * do not query the GPU or the GL for this information. - * - * This call is NOT thread safe! As most OpenGL implementations are not thread - * safe, you should probably only call this from the same thread that created - * the GL context. - * - * This call requires a valid MOJOSHADER_glContext to have been made current, - * or it will crash your program. See MOJOSHADER_glMakeContextCurrent(). - * - * Uniforms are not shared between contexts. - */ -void MOJOSHADER_glGetVertexShaderUniformI(unsigned int idx, int *data, - unsigned int ivec4count); - -/* - * Set a boolean uniform value (what Direct3D calls a "constant"). - * - * There is a single array of "registers" shared by all vertex shaders. - * This is the "b" register file in Direct3D (b0, b1, b2, etc...) - * MojoShader will take care of synchronizing this internal array with the - * appropriate variables in the GL shaders. - * - * Unlike the float and int counterparts, booleans are single values, not - * four-element vectors...so idx==1 is the second boolean in the internal - * array, not the fifth. - * - * Non-zero values are considered "true" and zero is considered "false". - * - * (idx) is the index into the internal array. - * (data) is a pointer to (bcount) ints. - * - * This call is NOT thread safe! As most OpenGL implementations are not thread - * safe, you should probably only call this from the same thread that created - * the GL context. - * - * This call requires a valid MOJOSHADER_glContext to have been made current, - * or it will crash your program. See MOJOSHADER_glMakeContextCurrent(). - * - * Uniforms are not shared between contexts. - */ -void MOJOSHADER_glSetVertexShaderUniformB(unsigned int idx, const int *data, - unsigned int bcount); - -/* - * Retrieve a boolean uniform value (what Direct3D calls a "constant"). - * - * There is a single array of "registers" shared by all vertex shaders. - * This is the "b" register file in Direct3D (b0, b1, b2, etc...) - * MojoShader will take care of synchronizing this internal array with the - * appropriate variables in the GL shaders. - * - * Unlike the float and int counterparts, booleans are single values, not - * four-element vectors...so idx==1 is the second boolean in the internal - * array, not the fifth. - * - * Non-zero values are considered "true" and zero is considered "false". - * This function will always return true values as 1, regardless of what - * non-zero integer you originally used to set the registers. - * - * (idx) is the index into the internal array. - * (data) is a pointer to space for (bcount) ints. - * (data) will be filled will current values in the register file. Results - * are undefined if you request data past the end of the register file or - * previously uninitialized registers. - * - * This is a "fast" call; we're just reading memory from internal memory. We - * do not query the GPU or the GL for this information. - * - * This call is NOT thread safe! As most OpenGL implementations are not thread - * safe, you should probably only call this from the same thread that created - * the GL context. - * - * This call requires a valid MOJOSHADER_glContext to have been made current, - * or it will crash your program. See MOJOSHADER_glMakeContextCurrent(). - * - * Uniforms are not shared between contexts. - */ -void MOJOSHADER_glGetVertexShaderUniformB(unsigned int idx, int *data, - unsigned int bcount); - -/* - * The equivalent of MOJOSHADER_glSetVertexShaderUniformF() for pixel - * shaders. Other than using a different internal array that is specific - * to pixel shaders, this functions just like its vertex array equivalent. - * - * This call is NOT thread safe! As most OpenGL implementations are not thread - * safe, you should probably only call this from the same thread that created - * the GL context. - * - * This call requires a valid MOJOSHADER_glContext to have been made current, - * or it will crash your program. See MOJOSHADER_glMakeContextCurrent(). - * - * Uniforms are not shared between contexts. - */ -void MOJOSHADER_glSetPixelShaderUniformF(unsigned int idx, const float *data, - unsigned int vec4count); - - -/* - * The equivalent of MOJOSHADER_glGetVertexShaderUniformF() for pixel - * shaders. Other than using a different internal array that is specific - * to pixel shaders, this functions just like its vertex array equivalent. - * - * This call is NOT thread safe! As most OpenGL implementations are not thread - * safe, you should probably only call this from the same thread that created - * the GL context. - * - * This call requires a valid MOJOSHADER_glContext to have been made current, - * or it will crash your program. See MOJOSHADER_glMakeContextCurrent(). - * - * Uniforms are not shared between contexts. - */ -void MOJOSHADER_glGetPixelShaderUniformF(unsigned int idx, float *data, - unsigned int vec4count); - - -/* - * The equivalent of MOJOSHADER_glSetVertexShaderUniformI() for pixel - * shaders. Other than using a different internal array that is specific - * to pixel shaders, this functions just like its vertex array equivalent. - * - * This call is NOT thread safe! As most OpenGL implementations are not thread - * safe, you should probably only call this from the same thread that created - * the GL context. - * - * This call requires a valid MOJOSHADER_glContext to have been made current, - * or it will crash your program. See MOJOSHADER_glMakeContextCurrent(). - * - * Uniforms are not shared between contexts. - */ -void MOJOSHADER_glSetPixelShaderUniformI(unsigned int idx, const int *data, - unsigned int ivec4count); - - -/* - * The equivalent of MOJOSHADER_glGetVertexShaderUniformI() for pixel - * shaders. Other than using a different internal array that is specific - * to pixel shaders, this functions just like its vertex array equivalent. - * - * This call is NOT thread safe! As most OpenGL implementations are not thread - * safe, you should probably only call this from the same thread that created - * the GL context. - * - * This call requires a valid MOJOSHADER_glContext to have been made current, - * or it will crash your program. See MOJOSHADER_glMakeContextCurrent(). - * - * Uniforms are not shared between contexts. - */ -void MOJOSHADER_glGetPixelShaderUniformI(unsigned int idx, int *data, - unsigned int ivec4count); - -/* - * The equivalent of MOJOSHADER_glSetVertexShaderUniformB() for pixel - * shaders. Other than using a different internal array that is specific - * to pixel shaders, this functions just like its vertex array equivalent. - * - * This call is NOT thread safe! As most OpenGL implementations are not thread - * safe, you should probably only call this from the same thread that created - * the GL context. - * - * This call requires a valid MOJOSHADER_glContext to have been made current, - * or it will crash your program. See MOJOSHADER_glMakeContextCurrent(). - * - * Uniforms are not shared between contexts. - */ -void MOJOSHADER_glSetPixelShaderUniformB(unsigned int idx, const int *data, - unsigned int bcount); - -/* - * The equivalent of MOJOSHADER_glGetVertexShaderUniformB() for pixel - * shaders. Other than using a different internal array that is specific - * to pixel shaders, this functions just like its vertex array equivalent. - * - * This call is NOT thread safe! As most OpenGL implementations are not thread - * safe, you should probably only call this from the same thread that created - * the GL context. - * - * This call requires a valid MOJOSHADER_glContext to have been made current, - * or it will crash your program. See MOJOSHADER_glMakeContextCurrent(). - * - * Uniforms are not shared between contexts. - */ -void MOJOSHADER_glGetPixelShaderUniformB(unsigned int idx, int *data, - unsigned int bcount); - -/* - * Connect a client-side array to the currently-bound program. - * - * (usage) and (index) map to Direct3D vertex declaration values: COLOR1 would - * be MOJOSHADER_USAGE_COLOR and 1. - * - * The caller should bind VBOs before this call and treat (ptr) as an offset, - * if appropriate. - * - * MojoShader will figure out where to plug this stream into the - * currently-bound program, and enable the appropriate client-side array. - * - * (size), (type), (normalized), (stride), and (ptr) correspond to - * glVertexAttribPointer()'s parameters (in most cases, these get passed - * unmolested to that very entry point during this function). - * - * This call is NOT thread safe! As most OpenGL implementations are not thread - * safe, you should probably only call this from the same thread that created - * the GL context. - * - * This call requires a valid MOJOSHADER_glContext to have been made current, - * or it will crash your program. See MOJOSHADER_glMakeContextCurrent(). - * - * Vertex attributes are not shared between contexts. - */ - /* !!! FIXME: this should probably be "input" and not "attribute" */ - /* !!! FIXME: or maybe "vertex array" or something. */ -void MOJOSHADER_glSetVertexAttribute(MOJOSHADER_usage usage, - int index, unsigned int size, - MOJOSHADER_attributeType type, - int normalized, unsigned int stride, - const void *ptr); - - - - -/* These below functions are temporary and will be removed from the API once - the real Effects API is written. Do not use! */ -void MOJOSHADER_glSetVertexPreshaderUniformF(unsigned int idx, const float *data, - unsigned int vec4n); -void MOJOSHADER_glGetVertexPreshaderUniformF(unsigned int idx, float *data, - unsigned int vec4n); -void MOJOSHADER_glSetPixelPreshaderUniformF(unsigned int idx, const float *data, - unsigned int vec4n); -void MOJOSHADER_glGetPixelPreshaderUniformF(unsigned int idx, float *data, - unsigned int vec4n); -/* These above functions are temporary and will be removed from the API once - the real Effects API is written. Do not use! */ - - - - -/* - * Inform MojoShader that it should commit any pending state to the GL. This - * must be called after you bind a program and update any inputs, right - * before you start drawing, so any outstanding changes made to the shared - * constants array (etc) can propagate to the shader during this call. - * - * This call is NOT thread safe! As most OpenGL implementations are not thread - * safe, you should probably only call this from the same thread that created - * the GL context. - * - * This call requires a valid MOJOSHADER_glContext to have been made current, - * or it will crash your program. See MOJOSHADER_glMakeContextCurrent(). - */ -void MOJOSHADER_glProgramReady(void); - -/* - * Free the resources of a linked program. This will delete the GL object - * and free memory. - * - * If the program is currently bound by MOJOSHADER_glBindProgram(), it will - * be deleted as soon as it becomes unbound. - * - * This call is NOT thread safe! As most OpenGL implementations are not thread - * safe, you should probably only call this from the same thread that created - * the GL context. - * - * This call requires a valid MOJOSHADER_glContext to have been made current, - * or it will crash your program. See MOJOSHADER_glMakeContextCurrent(). - */ -void MOJOSHADER_glDeleteProgram(MOJOSHADER_glProgram *program); - -/* - * Free the resources of a compiled shader. This will delete the GL object - * and free memory. - * - * If the shader is currently referenced by a linked program (or is currently - * bound with MOJOSHADER_glBindShaders()), it will be deleted as soon as all - * referencing programs are deleted and it is no longer bound, too. - * - * This call is NOT thread safe! As most OpenGL implementations are not thread - * safe, you should probably only call this from the same thread that created - * the GL context. - * - * This call requires a valid MOJOSHADER_glContext to have been made current, - * or it will crash your program. See MOJOSHADER_glMakeContextCurrent(). - */ -void MOJOSHADER_glDeleteShader(MOJOSHADER_glShader *shader); - -/* - * Deinitialize MojoShader's OpenGL shader management. - * - * You must call this once, while your GL context (not MojoShader context) is - * still current, if you previously had a successful call to - * MOJOSHADER_glCreateContext(). This should be the last MOJOSHADER_gl* - * function you call until you've prepared a context again. - * - * This will clean up resources previously allocated, and may call into the GL. - * - * This will not clean up shaders and programs you created! Please call - * MOJOSHADER_glDeleteShader() and MOJOSHADER_glDeleteProgram() to clean - * those up before calling this function! - * - * This function destroys the MOJOSHADER_glContext you pass it. If it's the - * current context, then no context will be current upon return. - * - * This call is NOT thread safe! There must not be any other MOJOSHADER_gl* - * functions running when this is called. Also, as most OpenGL implementations - * are not thread safe, you should probably only call this from the same - * thread that created the GL context. - */ -void MOJOSHADER_glDestroyContext(MOJOSHADER_glContext *ctx); - -#ifdef __cplusplus -} -#endif - -#endif /* include-once blocker. */ - -/* end of mojoshader.h ... */ - diff --git a/Externals/mojoshader/1067/mojoshader_assembler.c b/Externals/mojoshader/1067/mojoshader_assembler.c deleted file mode 100644 index 7885bd45..00000000 --- a/Externals/mojoshader/1067/mojoshader_assembler.c +++ /dev/null @@ -1,1766 +0,0 @@ -/** - * MojoShader; generate shader programs from bytecode of compiled - * Direct3D shaders. - * - * Please see the file LICENSE.txt in the source's root directory. - * - * This file written by Ryan C. Gordon. - */ - -// !!! FIXME: this should probably use a formal grammar and not a hand-written -// !!! FIXME: pile of C code. - -#define __MOJOSHADER_INTERNAL__ 1 -#include "mojoshader_internal.h" - -#if !SUPPORT_PROFILE_BYTECODE -#error Shader assembler needs bytecode profile. Fix your build. -#endif - -#if DEBUG_ASSEMBLER_PARSER - #define print_debug_token(token, len, val) \ - MOJOSHADER_print_debug_token("ASSEMBLER", token, len, val) -#else - #define print_debug_token(token, len, val) -#endif - - -typedef struct SourcePos -{ - const char *filename; - uint32 line; -} SourcePos; - - -// Context...this is state that changes as we assemble a shader... -typedef struct Context -{ - int isfail; - int out_of_memory; - MOJOSHADER_malloc malloc; - MOJOSHADER_free free; - void *malloc_data; - const char *current_file; - int current_position; - ErrorList *errors; - Preprocessor *preprocessor; - MOJOSHADER_shaderType shader_type; - uint8 major_ver; - uint8 minor_ver; - int pushedback; - const char *token; // assembler token! - unsigned int tokenlen; // assembler token! - Token tokenval; // assembler token! - uint32 version_token; // bytecode token! - uint32 tokenbuf[16]; // bytecode tokens! - int tokenbufpos; // bytecode tokens! - DestArgInfo dest_arg; - Buffer *output; - Buffer *token_to_source; - Buffer *ctab; -} Context; - - -// !!! FIXME: cut and paste between every damned source file follows... -// !!! FIXME: We need to make some sort of ContextBase that applies to all -// !!! FIXME: files and move this stuff to mojoshader_common.c ... - -// Convenience functions for allocators... - -static inline void out_of_memory(Context *ctx) -{ - ctx->isfail = ctx->out_of_memory = 1; -} // out_of_memory - -static inline void *Malloc(Context *ctx, const size_t len) -{ - void *retval = ctx->malloc((int) len, ctx->malloc_data); - if (retval == NULL) - out_of_memory(ctx); - return retval; -} // Malloc - -static inline char *StrDup(Context *ctx, const char *str) -{ - char *retval = (char *) Malloc(ctx, strlen(str) + 1); - if (retval != NULL) - strcpy(retval, str); - return retval; -} // StrDup - -static inline void Free(Context *ctx, void *ptr) -{ - ctx->free(ptr, ctx->malloc_data); -} // Free - -static void *MallocBridge(int bytes, void *data) -{ - return Malloc((Context *) data, (size_t) bytes); -} // MallocBridge - -static void FreeBridge(void *ptr, void *data) -{ - Free((Context *) data, ptr); -} // FreeBridge - - -static void failf(Context *ctx, const char *fmt, ...) ISPRINTF(2,3); -static void failf(Context *ctx, const char *fmt, ...) -{ - ctx->isfail = 1; - if (ctx->out_of_memory) - return; - - va_list ap; - va_start(ap, fmt); - errorlist_add_va(ctx->errors, ctx->current_file, ctx->current_position, fmt, ap); - va_end(ap); -} // failf - -static inline void fail(Context *ctx, const char *reason) -{ - failf(ctx, "%s", reason); -} // fail - -static inline int isfail(const Context *ctx) -{ - return ctx->isfail; -} // isfail - - -// Shader model version magic... - -static inline uint32 ver_ui32(const uint8 major, const uint8 minor) -{ - return ( (((uint32) major) << 16) | (((minor) == 0xFF) ? 0 : (minor)) ); -} // version_ui32 - -static inline int shader_version_atleast(const Context *ctx, const uint8 maj, - const uint8 min) -{ - return (ver_ui32(ctx->major_ver, ctx->minor_ver) >= ver_ui32(maj, min)); -} // shader_version_atleast - -static inline int shader_is_pixel(const Context *ctx) -{ - return (ctx->shader_type == MOJOSHADER_TYPE_PIXEL); -} // shader_is_pixel - -static inline int shader_is_vertex(const Context *ctx) -{ - return (ctx->shader_type == MOJOSHADER_TYPE_VERTEX); -} // shader_is_vertex - -static inline void pushback(Context *ctx) -{ - #if DEBUG_ASSEMBLER_PARSER - printf("ASSEMBLER PUSHBACK\n"); - #endif - assert(!ctx->pushedback); - ctx->pushedback = 1; -} // pushback - - -static Token nexttoken(Context *ctx) -{ - if (ctx->pushedback) - ctx->pushedback = 0; - else - { - while (1) - { - ctx->token = preprocessor_nexttoken(ctx->preprocessor, - &ctx->tokenlen, - &ctx->tokenval); - - if (preprocessor_outofmemory(ctx->preprocessor)) - { - ctx->tokenval = TOKEN_EOI; - ctx->token = NULL; - ctx->tokenlen = 0; - break; - } // if - - unsigned int line; - ctx->current_file = preprocessor_sourcepos(ctx->preprocessor,&line); - ctx->current_position = (int) line; - - if (ctx->tokenval == TOKEN_BAD_CHARS) - { - fail(ctx, "Bad characters in source file"); - continue; - } // else if - - else if (ctx->tokenval == TOKEN_PREPROCESSING_ERROR) - { - fail(ctx, ctx->token); - continue; - } // else if - - break; - } // while - } // else - - print_debug_token(ctx->token, ctx->tokenlen, ctx->tokenval); - return ctx->tokenval; -} // nexttoken - - -static void output_token_noswap(Context *ctx, const uint32 token) -{ - if (!isfail(ctx)) - { - buffer_append(ctx->output, &token, sizeof (token)); - - // We only need a list of these that grows throughout processing, and - // is flattened for reference at the end of the run, so we use a - // Buffer. It's sneaky! - unsigned int pos = 0; - const char *fname = preprocessor_sourcepos(ctx->preprocessor, &pos); - SourcePos srcpos; - memset(&srcpos, '\0', sizeof (SourcePos)); - srcpos.line = pos; - srcpos.filename = fname; // cached in preprocessor! - buffer_append(ctx->token_to_source, &srcpos, sizeof (SourcePos)); - } // if -} // output_token_noswap - - -static inline void output_token(Context *ctx, const uint32 token) -{ - output_token_noswap(ctx, SWAP32(token)); -} // output_token - - -static void output_comment_bytes(Context *ctx, const uint8 *buf, size_t len) -{ - if (len > (0xFFFF * 4)) // length is stored as token count, in 16 bits. - fail(ctx, "Comment field is too big"); - else if (!isfail(ctx)) - { - const uint32 tokencount = (len / 4) + ((len % 4) ? 1 : 0); - output_token(ctx, 0xFFFE | (tokencount << 16)); - while (len >= 4) - { - output_token_noswap(ctx, *((const uint32 *) buf)); - len -= 4; - buf += 4; - } // while - - if (len > 0) // handle spillover... - { - union { uint8 ui8[4]; uint32 ui32; } overflow; - overflow.ui32 = 0; - memcpy(overflow.ui8, buf, len); - output_token_noswap(ctx, overflow.ui32); - } // if - } // else if -} // output_comment_bytes - - -static inline void output_comment_string(Context *ctx, const char *str) -{ - output_comment_bytes(ctx, (const uint8 *) str, strlen(str)); -} // output_comment_string - - -static int require_comma(Context *ctx) -{ - const Token token = nexttoken(ctx); - if (token != ((Token) ',')) - { - fail(ctx, "Comma expected"); - return 0; - } // if - return 1; -} // require_comma - - -static int check_token_segment(Context *ctx, const char *str) -{ - // !!! FIXME: these are case-insensitive, right? - const size_t len = strlen(str); - if ( (ctx->tokenlen < len) || (strncasecmp(ctx->token, str, len) != 0) ) - return 0; - ctx->token += len; - ctx->tokenlen -= len; - return 1; -} // check_token_segment - - -static int check_token(Context *ctx, const char *str) -{ - const size_t len = strlen(str); - if ( (ctx->tokenlen != len) || (strncasecmp(ctx->token, str, len) != 0) ) - return 0; - ctx->token += len; - ctx->tokenlen = 0; - return 1; -} // check_token - - -static int ui32fromtoken(Context *ctx, uint32 *_val) -{ - unsigned int i; - for (i = 0; i < ctx->tokenlen; i++) - { - if ((ctx->token[i] < '0') || (ctx->token[i] > '9')) - break; - } // for - - if (i == 0) - { - *_val = 0; - return 0; - } // if - - const unsigned int len = i; - uint32 val = 0; - uint32 mult = 1; - while (i--) - { - val += ((uint32) (ctx->token[i] - '0')) * mult; - mult *= 10; - } // while - - ctx->token += len; - ctx->tokenlen -= len; - - *_val = val; - return 1; -} // ui32fromtoken - - -static int parse_register_name(Context *ctx, RegisterType *rtype, int *rnum) -{ - if (nexttoken(ctx) != TOKEN_IDENTIFIER) - { - fail(ctx, "Expected register"); - return 0; - } // if - - int neednum = 1; - int regnum = 0; - RegisterType regtype = REG_TYPE_TEMP; - - // Watch out for substrings! oDepth must be checked before oD, since - // the latter will match either case. - if (check_token_segment(ctx, "oDepth")) - { - regtype = REG_TYPE_DEPTHOUT; - neednum = 0; - } // else if - else if (check_token_segment(ctx, "vFace")) - { - regtype = REG_TYPE_MISCTYPE; - regnum = (int) MISCTYPE_TYPE_FACE; - neednum = 0; - } // else if - else if (check_token_segment(ctx, "vPos")) - { - regtype = REG_TYPE_MISCTYPE; - regnum = (int) MISCTYPE_TYPE_POSITION; - neednum = 0; - } // else if - else if (check_token_segment(ctx, "oPos")) - { - regtype = REG_TYPE_RASTOUT; - regnum = (int) RASTOUT_TYPE_POSITION; - neednum = 0; - } // else if - else if (check_token_segment(ctx, "oFog")) - { - regtype = REG_TYPE_RASTOUT; - regnum = (int) RASTOUT_TYPE_FOG; - neednum = 0; - } // else if - else if (check_token_segment(ctx, "oPts")) - { - regtype = REG_TYPE_RASTOUT; - regnum = (int) RASTOUT_TYPE_POINT_SIZE; - neednum = 0; - } // else if - else if (check_token_segment(ctx, "aL")) - { - regtype = REG_TYPE_LOOP; - neednum = 0; - } // else if - else if (check_token_segment(ctx, "oC")) - regtype = REG_TYPE_COLOROUT; - else if (check_token_segment(ctx, "oT")) - regtype = REG_TYPE_OUTPUT; - else if (check_token_segment(ctx, "oD")) - regtype = REG_TYPE_ATTROUT; - else if (check_token_segment(ctx, "r")) - regtype = REG_TYPE_TEMP; - else if (check_token_segment(ctx, "v")) - regtype = REG_TYPE_INPUT; - else if (check_token_segment(ctx, "c")) - regtype = REG_TYPE_CONST; - else if (check_token_segment(ctx, "i")) - regtype = REG_TYPE_CONSTINT; - else if (check_token_segment(ctx, "b")) - regtype = REG_TYPE_CONSTBOOL; - else if (check_token_segment(ctx, "s")) - regtype = REG_TYPE_SAMPLER; - else if (check_token_segment(ctx, "l")) - regtype = REG_TYPE_LABEL; - else if (check_token_segment(ctx, "p")) - regtype = REG_TYPE_PREDICATE; - else if (check_token_segment(ctx, "o")) - regtype = REG_TYPE_OUTPUT; - else if (check_token_segment(ctx, "a")) - regtype = REG_TYPE_ADDRESS; - else if (check_token_segment(ctx, "t")) - regtype = REG_TYPE_ADDRESS; - - //case REG_TYPE_TEMPFLOAT16: // !!! FIXME: don't know this asm string - - else - { - fail(ctx, "expected register type"); - regtype = REG_TYPE_CONST; - regnum = 0; - neednum = 0; - } // else - - // "c[5]" is the same as "c5", so if the token is done, see if next is '['. - if ((neednum) && (ctx->tokenlen == 0)) - { - const int tlen = ctx->tokenlen; // we need to protect this for later. - if (nexttoken(ctx) == ((Token) '[')) - neednum = 0; // don't need a number on register name itself. - pushback(ctx); - ctx->tokenlen = tlen; - } // if - - if (neednum) - { - uint32 ui32 = 0; - if (!ui32fromtoken(ctx, &ui32)) - fail(ctx, "Invalid register index"); - regnum = (int) ui32; - } // if - - // split up REG_TYPE_CONST - if (regtype == REG_TYPE_CONST) - { - if (regnum < 2048) - { - regtype = REG_TYPE_CONST; - regnum -= 0; - } // if - else if (regnum < 4096) - { - regtype = REG_TYPE_CONST2; - regnum -= 2048; - } // if - else if (regnum < 6144) - { - regtype = REG_TYPE_CONST3; - regnum -= 4096; - } // if - else if (regnum < 8192) - { - regtype = REG_TYPE_CONST4; - regnum -= 6144; - } // if - else - { - fail(ctx, "Invalid const register index"); - } // else - } // if - - *rtype = regtype; - *rnum = regnum; - - return 1; -} // parse_register_name - - -static void set_result_shift(Context *ctx, DestArgInfo *info, const int val) -{ - if (info->result_shift != 0) - fail(ctx, "Multiple result shift modifiers"); - info->result_shift = val; -} // set_result_shift - - -static inline int tokenbuf_overflow(Context *ctx) -{ - if ( ctx->tokenbufpos >= ((int) (STATICARRAYLEN(ctx->tokenbuf))) ) - { - fail(ctx, "Too many tokens"); - return 1; - } // if - - return 0; -} // tokenbuf_overflow - - -static int parse_destination_token(Context *ctx) -{ - DestArgInfo *info = &ctx->dest_arg; - memset(info, '\0', sizeof (DestArgInfo)); - - // parse_instruction_token() sets ctx->token to the end of the instruction - // so we can see if there are destination modifiers on the instruction - // itself... - - int invalid_modifier = 0; - - while ((ctx->tokenlen > 0) && (!invalid_modifier)) - { - if (check_token_segment(ctx, "_x2")) - set_result_shift(ctx, info, 0x1); - else if (check_token_segment(ctx, "_x4")) - set_result_shift(ctx, info, 0x2); - else if (check_token_segment(ctx, "_x8")) - set_result_shift(ctx, info, 0x3); - else if (check_token_segment(ctx, "_d8")) - set_result_shift(ctx, info, 0xD); - else if (check_token_segment(ctx, "_d4")) - set_result_shift(ctx, info, 0xE); - else if (check_token_segment(ctx, "_d2")) - set_result_shift(ctx, info, 0xF); - else if (check_token_segment(ctx, "_sat")) - info->result_mod |= MOD_SATURATE; - else if (check_token_segment(ctx, "_pp")) - info->result_mod |= MOD_PP; - else if (check_token_segment(ctx, "_centroid")) - info->result_mod |= MOD_CENTROID; - else - invalid_modifier = 1; - } // while - - if (invalid_modifier) - fail(ctx, "Invalid destination modifier"); - - // !!! FIXME: predicates. - if (nexttoken(ctx) == ((Token) '(')) - fail(ctx, "Predicates unsupported at this time"); // !!! FIXME: ... - - pushback(ctx); // parse_register_name calls nexttoken(). - - parse_register_name(ctx, &info->regtype, &info->regnum); - // parse_register_name() can't check this: dest regs might have modifiers. - if (ctx->tokenlen > 0) - fail(ctx, "invalid register name"); - - // !!! FIXME: can dest registers do relative addressing? - - int invalid_writemask = 0; - int implicit_writemask = 0; - if (nexttoken(ctx) != ((Token) '.')) - { - implicit_writemask = 1; - info->writemask = 0xF; - info->writemask0 = info->writemask1 = info->writemask2 = info->writemask3 = 1; - pushback(ctx); // no explicit writemask; do full mask. - } // if - - // !!! FIXME: Cg generates code with oDepth.z ... this is a bug, I think. - //else if (scalar_register(ctx->shader_type, info->regtype, info->regnum)) - else if ( (scalar_register(ctx->shader_type, info->regtype, info->regnum)) && (info->regtype != REG_TYPE_DEPTHOUT) ) - fail(ctx, "Writemask specified for scalar register"); - else if (nexttoken(ctx) != TOKEN_IDENTIFIER) - invalid_writemask = 1; - else - { - char tokenbytes[5] = { '\0', '\0', '\0', '\0', '\0' }; - const unsigned int tokenlen = ctx->tokenlen; - memcpy(tokenbytes, ctx->token, ((tokenlen < 4) ? tokenlen : 4)); - char *ptr = tokenbytes; - - if ((*ptr == 'r') || (*ptr == 'x')) { info->writemask0 = 1; ptr++; } - if ((*ptr == 'g') || (*ptr == 'y')) { info->writemask1 = 1; ptr++; } - if ((*ptr == 'b') || (*ptr == 'z')) { info->writemask2 = 1; ptr++; } - if ((*ptr == 'a') || (*ptr == 'w')) { info->writemask3 = 1; ptr++; } - - if (*ptr != '\0') - invalid_writemask = 1; - - info->writemask = ( ((info->writemask0 & 0x1) << 0) | - ((info->writemask1 & 0x1) << 1) | - ((info->writemask2 & 0x1) << 2) | - ((info->writemask3 & 0x1) << 3) ); - } // else - - if (invalid_writemask) - fail(ctx, "Invalid writemask"); - - // !!! FIXME: Cg generates code with oDepth.z ... this is a bug, I think. - if (info->regtype == REG_TYPE_DEPTHOUT) - { - if ( (!implicit_writemask) && ((info->writemask0 + info->writemask1 + - info->writemask2 + info->writemask3) > 1) ) - fail(ctx, "Writemask specified for scalar register"); - } // if - - info->orig_writemask = info->writemask; - - if (tokenbuf_overflow(ctx)) - return 1; - - ctx->tokenbuf[ctx->tokenbufpos++] = - ( ((((uint32) 1)) << 31) | - ((((uint32) info->regnum) & 0x7ff) << 0) | - ((((uint32) info->relative) & 0x1) << 13) | - ((((uint32) info->result_mod) & 0xF) << 20) | - ((((uint32) info->result_shift) & 0xF) << 24) | - ((((uint32) info->writemask) & 0xF) << 16) | - ((((uint32) info->regtype) & 0x7) << 28) | - ((((uint32) info->regtype) & 0x18) << 8) ); - - return 1; -} // parse_destination_token - - -static void set_source_mod(Context *ctx, const int negate, - const SourceMod norm, const SourceMod negated, - SourceMod *srcmod) -{ - if ( (*srcmod != SRCMOD_NONE) || (negate && (negated == SRCMOD_NONE)) ) - fail(ctx, "Incompatible source modifiers"); - else - *srcmod = ((negate) ? negated : norm); -} // set_source_mod - - -static int parse_source_token_maybe_relative(Context *ctx, const int relok) -{ - int retval = 1; - - if (tokenbuf_overflow(ctx)) - return 0; - - // mark this now, so optional relative addressing token is placed second. - uint32 *outtoken = &ctx->tokenbuf[ctx->tokenbufpos++]; - *outtoken = 0; - - SourceMod srcmod = SRCMOD_NONE; - int negate = 0; - Token token = nexttoken(ctx); - - if (token == ((Token) '!')) - srcmod = SRCMOD_NOT; - else if (token == ((Token) '-')) - negate = 1; - else if ( (token == TOKEN_INT_LITERAL) && (check_token(ctx, "1")) ) - { - if (nexttoken(ctx) != ((Token) '-')) - fail(ctx, "Unexpected token"); - else - srcmod = SRCMOD_COMPLEMENT; - } // else - else - { - pushback(ctx); - } // else - - RegisterType regtype; - int regnum; - parse_register_name(ctx, ®type, ®num); - - if (ctx->tokenlen == 0) - { - if (negate) - set_source_mod(ctx, negate, SRCMOD_NONE, SRCMOD_NEGATE, &srcmod); - } // if - else - { - assert(ctx->tokenlen > 0); - if (check_token_segment(ctx, "_bias")) - set_source_mod(ctx, negate, SRCMOD_BIAS, SRCMOD_BIASNEGATE, &srcmod); - else if (check_token_segment(ctx, "_bx2")) - set_source_mod(ctx, negate, SRCMOD_SIGN, SRCMOD_SIGNNEGATE, &srcmod); - else if (check_token_segment(ctx, "_x2")) - set_source_mod(ctx, negate, SRCMOD_X2, SRCMOD_X2NEGATE, &srcmod); - else if (check_token_segment(ctx, "_dz")) - set_source_mod(ctx, negate, SRCMOD_DZ, SRCMOD_NONE, &srcmod); - else if (check_token_segment(ctx, "_dw")) - set_source_mod(ctx, negate, SRCMOD_DW, SRCMOD_NONE, &srcmod); - else if (check_token_segment(ctx, "_abs")) - set_source_mod(ctx, negate, SRCMOD_ABS, SRCMOD_ABSNEGATE, &srcmod); - else - fail(ctx, "Invalid source modifier"); - } // else - - uint32 relative = 0; - if (nexttoken(ctx) != ((Token) '[')) - pushback(ctx); // not relative addressing? - else - { - if (!relok) - fail(ctx, "Relative addressing not permitted here."); - else - retval++; - - parse_source_token_maybe_relative(ctx, 0); - relative = 1; - - if (nexttoken(ctx) != ((Token) '+')) - pushback(ctx); - else - { - // !!! FIXME: maybe c3[a0.x + 5] is legal and becomes c[a0.x + 8] ? - if (regnum != 0) - fail(ctx, "Relative addressing with explicit register number."); - - uint32 ui32 = 0; - if ( (nexttoken(ctx) != TOKEN_INT_LITERAL) || - (!ui32fromtoken(ctx, &ui32)) || - (ctx->tokenlen != 0) ) - { - fail(ctx, "Invalid relative addressing offset"); - } // if - regnum += (int) ui32; - } // else - - if (nexttoken(ctx) != ((Token) ']')) - fail(ctx, "Expected ']'"); - } // else - - int invalid_swizzle = 0; - uint32 swizzle = 0; - if (nexttoken(ctx) != ((Token) '.')) - { - swizzle = 0xE4; // 0xE4 == 11100100 ... 0 1 2 3. No swizzle. - pushback(ctx); // no explicit writemask; do full mask. - } // if - else if (scalar_register(ctx->shader_type, regtype, regnum)) - fail(ctx, "Swizzle specified for scalar register"); - else if (nexttoken(ctx) != TOKEN_IDENTIFIER) - invalid_swizzle = 1; - else - { - char tokenbytes[5] = { '\0', '\0', '\0', '\0', '\0' }; - const unsigned int tokenlen = ctx->tokenlen; - memcpy(tokenbytes, ctx->token, ((tokenlen < 4) ? tokenlen : 4)); - - // deal with shortened form (.x = .xxxx, etc). - if (tokenlen == 1) - tokenbytes[1] = tokenbytes[2] = tokenbytes[3] = tokenbytes[0]; - else if (tokenlen == 2) - tokenbytes[2] = tokenbytes[3] = tokenbytes[1]; - else if (tokenlen == 3) - tokenbytes[3] = tokenbytes[2]; - else if (tokenlen != 4) - invalid_swizzle = 1; - tokenbytes[4] = '\0'; - - uint32 val = 0; - int i; - for (i = 0; i < 4; i++) - { - const int component = (int) tokenbytes[i]; - switch (component) - { - case 'r': case 'x': val = 0; break; - case 'g': case 'y': val = 1; break; - case 'b': case 'z': val = 2; break; - case 'a': case 'w': val = 3; break; - default: invalid_swizzle = 1; break; - } // switch - swizzle |= (val << (i * 2)); - } // for - } // else - - if (invalid_swizzle) - fail(ctx, "Invalid swizzle"); - - *outtoken = ( ((((uint32) 1)) << 31) | - ((((uint32) regnum) & 0x7ff) << 0) | - ((((uint32) relative) & 0x1) << 13) | - ((((uint32) swizzle) & 0xFF) << 16) | - ((((uint32) srcmod) & 0xF) << 24) | - ((((uint32) regtype) & 0x7) << 28) | - ((((uint32) regtype) & 0x18) << 8) ); - - return retval; -} // parse_source_token_maybe_relative - - -static inline int parse_source_token(Context *ctx) -{ - return parse_source_token_maybe_relative(ctx, 1); -} // parse_source_token - - -static int parse_args_NULL(Context *ctx) -{ - return 1; -} // parse_args_NULL - - -static int parse_num(Context *ctx, const int floatok, uint32 *value) -{ - union { float f; int32 si32; uint32 ui32; } cvt; - int negative = 0; - Token token = nexttoken(ctx); - - if (token == ((Token) '-')) - { - negative = 1; - token = nexttoken(ctx); - } // if - - if (token == TOKEN_INT_LITERAL) - { - int d = 0; - sscanf(ctx->token, "%d", &d); - if (floatok) - cvt.f = (float) ((negative) ? -d : d); - else - cvt.si32 = (int32) ((negative) ? -d : d); - } // if - else if (token == TOKEN_FLOAT_LITERAL) - { - if (!floatok) - { - fail(ctx, "Expected whole number"); - *value = 0; - return 0; - } // if - sscanf(ctx->token, "%f", &cvt.f); - if (negative) - cvt.f = -cvt.f; - } // if - else - { - fail(ctx, "Expected number"); - *value = 0; - return 0; - } // else - - *value = cvt.ui32; - return 1; -} // parse_num - - -static int parse_args_DEFx(Context *ctx, const int isflt) -{ - parse_destination_token(ctx); - require_comma(ctx); - parse_num(ctx, isflt, &ctx->tokenbuf[ctx->tokenbufpos++]); - require_comma(ctx); - parse_num(ctx, isflt, &ctx->tokenbuf[ctx->tokenbufpos++]); - require_comma(ctx); - parse_num(ctx, isflt, &ctx->tokenbuf[ctx->tokenbufpos++]); - require_comma(ctx); - parse_num(ctx, isflt, &ctx->tokenbuf[ctx->tokenbufpos++]); - return 6; -} // parse_args_DEFx - - -static int parse_args_DEF(Context *ctx) -{ - return parse_args_DEFx(ctx, 1); -} // parse_args_DEF - - -static int parse_args_DEFI(Context *ctx) -{ - return parse_args_DEFx(ctx, 0); -} // parse_args_DEFI - - -static int parse_args_DEFB(Context *ctx) -{ - parse_destination_token(ctx); - require_comma(ctx); - - // !!! FIXME: do a TOKEN_TRUE and TOKEN_FALSE? Is this case-sensitive? - const Token token = nexttoken(ctx); - - int bad = 0; - if (token != TOKEN_IDENTIFIER) - bad = 1; - else if (check_token_segment(ctx, "true")) - ctx->tokenbuf[ctx->tokenbufpos++] = 1; - else if (check_token_segment(ctx, "false")) - ctx->tokenbuf[ctx->tokenbufpos++] = 0; - else - bad = 1; - - if (ctx->tokenlen != 0) - bad = 1; - - if (bad) - fail(ctx, "Expected 'true' or 'false'"); - - return 3; -} // parse_args_DEFB - - -static int parse_dcl_usage(Context *ctx, uint32 *val, int *issampler) -{ - size_t i; - static const char *samplerusagestrs[] = { "_2d", "_cube", "_volume" }; - static const char *usagestrs[] = { - "_position", "_blendweight", "_blendindices", "_normal", "_psize", - "_texcoord", "_tangent", "_binormal", "_tessfactor", "_positiont", - "_color", "_fog", "_depth", "_sample" - }; - - for (i = 0; i < STATICARRAYLEN(usagestrs); i++) - { - if (check_token_segment(ctx, usagestrs[i])) - { - *issampler = 0; - *val = i; - return 1; - } // if - } // for - - for (i = 0; i < STATICARRAYLEN(samplerusagestrs); i++) - { - if (check_token_segment(ctx, samplerusagestrs[i])) - { - *issampler = 1; - *val = i + 2; - return 1; - } // if - } // for - - *issampler = 0; - *val = 0; - return 0; -} // parse_dcl_usage - - -static int parse_args_DCL(Context *ctx) -{ - int issampler = 0; - uint32 usage = 0; - uint32 index = 0; - - ctx->tokenbufpos++; // save a spot for the usage/index token. - ctx->tokenbuf[0] = 0; - - // parse_instruction_token() sets ctx->token to the end of the instruction - // so we can see if there are destination modifiers on the instruction - // itself... - - if (parse_dcl_usage(ctx, &usage, &issampler)) - { - if ((ctx->tokenlen > 0) && (*ctx->token != '_')) - { - if (!ui32fromtoken(ctx, &index)) - fail(ctx, "Expected usage index"); - } // if - } // if - - parse_destination_token(ctx); - - const int samplerreg = (ctx->dest_arg.regtype == REG_TYPE_SAMPLER); - if (issampler != samplerreg) - fail(ctx, "Invalid usage"); - else if (samplerreg) - ctx->tokenbuf[0] = (usage << 27) | 0x80000000; - else - ctx->tokenbuf[0] = usage | (index << 16) | 0x80000000; - - return 3; -} // parse_args_DCL - - -static int parse_args_D(Context *ctx) -{ - int retval = 1; - retval += parse_destination_token(ctx); - return retval; -} // parse_args_D - - -static int parse_args_S(Context *ctx) -{ - int retval = 1; - retval += parse_source_token(ctx); - return retval; -} // parse_args_S - - -static int parse_args_SS(Context *ctx) -{ - int retval = 1; - retval += parse_source_token(ctx); - require_comma(ctx); - retval += parse_source_token(ctx); - return retval; -} // parse_args_SS - - -static int parse_args_DS(Context *ctx) -{ - int retval = 1; - retval += parse_destination_token(ctx); - require_comma(ctx); - retval += parse_source_token(ctx); - return retval; -} // parse_args_DS - - -static int parse_args_DSS(Context *ctx) -{ - int retval = 1; - retval += parse_destination_token(ctx); - require_comma(ctx); - retval += parse_source_token(ctx); - require_comma(ctx); - retval += parse_source_token(ctx); - return retval; -} // parse_args_DSS - - -static int parse_args_DSSS(Context *ctx) -{ - int retval = 1; - retval += parse_destination_token(ctx); - require_comma(ctx); - retval += parse_source_token(ctx); - require_comma(ctx); - retval += parse_source_token(ctx); - require_comma(ctx); - retval += parse_source_token(ctx); - return retval; -} // parse_args_DSSS - - -static int parse_args_DSSSS(Context *ctx) -{ - int retval = 1; - retval += parse_destination_token(ctx); - require_comma(ctx); - retval += parse_source_token(ctx); - require_comma(ctx); - retval += parse_source_token(ctx); - require_comma(ctx); - retval += parse_source_token(ctx); - require_comma(ctx); - retval += parse_source_token(ctx); - return retval; -} // parse_args_DSSSS - - -static int parse_args_SINCOS(Context *ctx) -{ - // this opcode needs extra registers for sm2 and lower. - if (!shader_version_atleast(ctx, 3, 0)) - return parse_args_DSSS(ctx); - return parse_args_DS(ctx); -} // parse_args_SINCOS - - -static int parse_args_TEXCRD(Context *ctx) -{ - // added extra register in ps_1_4. - if (shader_version_atleast(ctx, 1, 4)) - return parse_args_DS(ctx); - return parse_args_D(ctx); -} // parse_args_TEXCRD - - -static int parse_args_TEXLD(Context *ctx) -{ - // different registers in px_1_3, ps_1_4, and ps_2_0! - if (shader_version_atleast(ctx, 2, 0)) - return parse_args_DSS(ctx); - else if (shader_version_atleast(ctx, 1, 4)) - return parse_args_DS(ctx); - return parse_args_D(ctx); -} // parse_args_TEXLD - - - -// one args function for each possible sequence of opcode arguments. -typedef int (*args_function)(Context *ctx); - -// Lookup table for instruction opcodes... -typedef struct -{ - const char *opcode_string; - args_function parse_args; -} Instruction; - - -static const Instruction instructions[] = -{ - #define INSTRUCTION_STATE(op, opstr, s, a, t) { opstr, parse_args_##a }, - #define INSTRUCTION(op, opstr, slots, a, t) { opstr, parse_args_##a }, - #define MOJOSHADER_DO_INSTRUCTION_TABLE 1 - #include "mojoshader_internal.h" - #undef MOJOSHADER_DO_INSTRUCTION_TABLE - #undef INSTRUCTION - #undef INSTRUCTION_STATE -}; - - -static int parse_condition(Context *ctx, uint32 *controls) -{ - static const char *comps[] = { "_gt", "_eq", "_ge", "_lt", "_ne", "_le" }; - size_t i; - - if (ctx->tokenlen >= 3) - { - for (i = 0; i < STATICARRAYLEN(comps); i++) - { - if (check_token_segment(ctx, comps[i])) - { - *controls = (uint32) (i + 1); - return 1; - } // if - } // for - } // if - - return 0; -} // parse_condition - - -static int parse_instruction_token(Context *ctx, Token token) -{ - int coissue = 0; - int predicated = 0; - - if (token == ((Token) '+')) - { - coissue = 1; - token = nexttoken(ctx); - } // if - - if (token != TOKEN_IDENTIFIER) - { - fail(ctx, "Expected instruction"); - return 0; - } // if - - uint32 controls = 0; - uint32 opcode = OPCODE_TEXLD; - const char *origtoken = ctx->token; - const unsigned int origtokenlen = ctx->tokenlen; - - // This might need to be TEXLD instead of TEXLDP. - if (check_token_segment(ctx, "TEXLDP")) - controls = CONTROL_TEXLDP; - - // This might need to be TEXLD instead of TEXLDB. - else if (check_token_segment(ctx, "TEXLDB")) - controls = CONTROL_TEXLDB; - - else // find the instruction. - { - size_t i; - for (i = 0; i < STATICARRAYLEN(instructions); i++) - { - const char *opcode_string = instructions[i].opcode_string; - if (opcode_string == NULL) - continue; // skip this. - else if (!check_token_segment(ctx, opcode_string)) - continue; // not us. - else if ((ctx->tokenlen > 0) && (*ctx->token != '_')) - { - ctx->token = origtoken; - ctx->tokenlen = origtokenlen; - continue; // not the match: TEXLD when we wanted TEXLDL, etc. - } // if - - break; // found it! - } // for - - opcode = (uint32) i; - - // This might need to be IFC instead of IF. - if (opcode == OPCODE_IF) - { - if (parse_condition(ctx, &controls)) - opcode = OPCODE_IFC; - } // if - - // This might need to be BREAKC instead of BREAK. - else if (opcode == OPCODE_BREAK) - { - if (parse_condition(ctx, &controls)) - opcode = OPCODE_BREAKC; - } // else if - - // SETP has a conditional code, always. - else if (opcode == OPCODE_SETP) - { - if (!parse_condition(ctx, &controls)) - fail(ctx, "SETP requires a condition"); - } // else if - } // else - - if ( (opcode == STATICARRAYLEN(instructions)) || - ((ctx->tokenlen > 0) && (ctx->token[0] != '_')) ) - { - char opstr[32]; - const int len = Min(sizeof (opstr) - 1, origtokenlen); - memcpy(opstr, origtoken, len); - opstr[len] = '\0'; - failf(ctx, "Unknown instruction '%s'", opstr); - return 0; - } // if - - const Instruction *instruction = &instructions[opcode]; - - // !!! FIXME: predicated instructions - - ctx->tokenbufpos = 0; - - const int tokcount = instruction->parse_args(ctx); - - // insttoks bits are reserved and should be zero if < SM2. - const uint32 insttoks = shader_version_atleast(ctx, 2, 0) ? tokcount-1 : 0; - - // write out the instruction token. - output_token(ctx, ((opcode & 0xFFFF) << 0) | - ((controls & 0xFF) << 16) | - ((insttoks & 0xF) << 24) | - ((coissue) ? 0x40000000 : 0x00000000) | - ((predicated) ? 0x10000000 : 0x00000000) ); - - // write out the argument tokens. - int i; - for (i = 0; i < (tokcount-1); i++) - output_token(ctx, ctx->tokenbuf[i]); - - return 1; -} // parse_instruction_token - - -static void parse_version_token(Context *ctx) -{ - int bad = 0; - int dot_form = 0; - uint32 shader_type = 0; - - if (nexttoken(ctx) != TOKEN_IDENTIFIER) - bad = 1; - else if (check_token_segment(ctx, "vs")) - { - ctx->shader_type = MOJOSHADER_TYPE_VERTEX; - shader_type = 0xFFFE; - } // if - else if (check_token_segment(ctx, "ps")) - { - ctx->shader_type = MOJOSHADER_TYPE_PIXEL; - shader_type = 0xFFFF; - } // if - else - { - // !!! FIXME: geometry shaders? - bad = 1; - } // else - - dot_form = ((!bad) && (ctx->tokenlen == 0)); // it's in xs.x.x form? - - uint32 major = 0; - uint32 minor = 0; - - if (dot_form) - { - Token t = TOKEN_UNKNOWN; - - if (!bad) - { - t = nexttoken(ctx); - // stupid lexer sees "vs.2.0" and makes the ".2" into a float. - if (t == ((Token) '.')) - t = nexttoken(ctx); - else - { - if ((t != TOKEN_FLOAT_LITERAL) || (ctx->token[0] != '.')) - bad = 1; - else - { - ctx->tokenval = t = TOKEN_INT_LITERAL; - ctx->token++; - ctx->tokenlen--; - } // else - } // else - } // if - - if (!bad) - { - if (t != TOKEN_INT_LITERAL) - bad = 1; - else if (!ui32fromtoken(ctx, &major)) - bad = 1; - } // if - - if (!bad) - { - t = nexttoken(ctx); - // stupid lexer sees "vs.2.0" and makes the ".2" into a float. - if (t == ((Token) '.')) - t = nexttoken(ctx); - else - { - if ((t != TOKEN_FLOAT_LITERAL) || (ctx->token[0] != '.')) - bad = 1; - else - { - ctx->tokenval = t = TOKEN_INT_LITERAL; - ctx->token++; - ctx->tokenlen--; - } // else - } // else - } // if - - if (!bad) - { - if ((t == TOKEN_INT_LITERAL) && (ui32fromtoken(ctx, &minor))) - ; // good to go. - else if ((t == TOKEN_IDENTIFIER) && (check_token_segment(ctx, "x"))) - minor = 1; - else if ((t == TOKEN_IDENTIFIER) && (check_token_segment(ctx, "sw"))) - minor = 255; - else - bad = 1; - } // if - } // if - else - { - if (!check_token_segment(ctx, "_")) - bad = 1; - else if (!ui32fromtoken(ctx, &major)) - bad = 1; - else if (!check_token_segment(ctx, "_")) - bad = 1; - else if (check_token_segment(ctx, "x")) - minor = 1; - else if (check_token_segment(ctx, "sw")) - minor = 255; - else if (!ui32fromtoken(ctx, &minor)) - bad = 1; - } // else - - if ((!bad) && (ctx->tokenlen != 0)) - bad = 1; - - if (bad) - fail(ctx, "Expected valid version string"); - - ctx->major_ver = major; - ctx->minor_ver = minor; - - ctx->version_token = (shader_type << 16) | (major << 8) | (minor << 0); - output_token(ctx, ctx->version_token); -} // parse_version_token - - -static void parse_phase_token(Context *ctx) -{ - output_token(ctx, 0x0000FFFD); // phase token always 0x0000FFFD. -} // parse_phase_token - - -static void parse_end_token(Context *ctx) -{ - // We don't emit the end token bits here, since it's valid for a shader - // to not specify an "end" string at all; it's implicit, in that case. - // Instead, we make sure if we see "end" that it's the last thing we see. - if (nexttoken(ctx) != TOKEN_EOI) - fail(ctx, "Content after END"); -} // parse_end_token - - -static void parse_token(Context *ctx, const Token token) -{ - if (token != TOKEN_IDENTIFIER) - parse_instruction_token(ctx, token); // might be a coissue '+', etc. - else - { - if (check_token(ctx, "end")) - parse_end_token(ctx); - else if (check_token(ctx, "phase")) - parse_phase_token(ctx); - else - parse_instruction_token(ctx, token); - } // if -} // parse_token - - -static void destroy_context(Context *ctx) -{ - if (ctx != NULL) - { - MOJOSHADER_free f = ((ctx->free != NULL) ? ctx->free : MOJOSHADER_internal_free); - void *d = ctx->malloc_data; - preprocessor_end(ctx->preprocessor); - errorlist_destroy(ctx->errors); - buffer_destroy(ctx->ctab); - buffer_destroy(ctx->token_to_source); - buffer_destroy(ctx->output); - f(ctx, d); - } // if -} // destroy_context - - -static Context *build_context(const char *filename, - const char *source, unsigned int sourcelen, - const MOJOSHADER_preprocessorDefine *defines, - unsigned int define_count, - MOJOSHADER_includeOpen include_open, - MOJOSHADER_includeClose include_close, - MOJOSHADER_malloc m, MOJOSHADER_free f, void *d) -{ - if (!m) m = MOJOSHADER_internal_malloc; - if (!f) f = MOJOSHADER_internal_free; - if (!include_open) include_open = MOJOSHADER_internal_include_open; - if (!include_close) include_close = MOJOSHADER_internal_include_close; - - Context *ctx = (Context *) m(sizeof (Context), d); - if (ctx == NULL) - return NULL; - - memset(ctx, '\0', sizeof (Context)); - ctx->malloc = m; - ctx->free = f; - ctx->malloc_data = d; - ctx->current_position = MOJOSHADER_POSITION_BEFORE; - - const size_t outblk = sizeof (uint32) * 4 * 64; // 64 4-token instrs. - ctx->output = buffer_create(outblk, MallocBridge, FreeBridge, ctx); - if (ctx->output == NULL) - goto build_context_failed; - - const size_t mapblk = sizeof (SourcePos) * 4 * 64; // 64 * 4-tokens. - ctx->token_to_source = buffer_create(mapblk, MallocBridge, FreeBridge, ctx); - if (ctx->token_to_source == NULL) - goto build_context_failed; - - ctx->errors = errorlist_create(MallocBridge, FreeBridge, ctx); - if (ctx->errors == NULL) - goto build_context_failed; - - ctx->preprocessor = preprocessor_start(filename, source, sourcelen, - include_open, include_close, - defines, define_count, 1, - MallocBridge, FreeBridge, ctx); - - if (ctx->preprocessor == NULL) - goto build_context_failed; - - return ctx; - -build_context_failed: // ctx is allocated and zeroed before this is called. - destroy_context(ctx); - return NULL; -} // build_context - - -static const MOJOSHADER_parseData *build_failed_assembly(Context *ctx) -{ - assert(isfail(ctx)); - - if (ctx->out_of_memory) - return &MOJOSHADER_out_of_mem_data; - - MOJOSHADER_parseData *retval = NULL; - retval = (MOJOSHADER_parseData*) Malloc(ctx, sizeof(MOJOSHADER_parseData)); - if (retval == NULL) - return &MOJOSHADER_out_of_mem_data; - - memset(retval, '\0', sizeof (MOJOSHADER_parseData)); - retval->malloc = (ctx->malloc == MOJOSHADER_internal_malloc) ? NULL : ctx->malloc; - retval->free = (ctx->free == MOJOSHADER_internal_free) ? NULL : ctx->free; - retval->malloc_data = ctx->malloc_data; - - retval->error_count = errorlist_count(ctx->errors); - retval->errors = errorlist_flatten(ctx->errors); - - if (ctx->out_of_memory) - { - Free(ctx, retval->errors); - Free(ctx, retval); - return &MOJOSHADER_out_of_mem_data; - } // if - - return retval; -} // build_failed_assembly - - -static uint32 add_ctab_bytes(Context *ctx, const uint8 *bytes, const size_t len) -{ - if (isfail(ctx)) - return 0; - - const size_t extra = CTAB_SIZE + sizeof (uint32); - const ssize_t pos = buffer_find(ctx->ctab, extra, bytes, len); - if (pos >= 0) // blob is already in here. - return ((uint32) pos) - sizeof (uint32); - - // add it to the byte pile... - const uint32 retval = ((uint32) buffer_size(ctx->ctab)) - sizeof (uint32); - buffer_append(ctx->ctab, bytes, len); - return retval; -} // add_ctab_bytes - - -static inline uint32 add_ctab_string(Context *ctx, const char *str) -{ - return add_ctab_bytes(ctx, (const uint8 *) str, strlen(str) + 1); -} // add_ctab_string - - -static uint32 add_ctab_typeinfo(Context *ctx, const MOJOSHADER_symbolTypeInfo *info); - -static uint32 add_ctab_members(Context *ctx, const MOJOSHADER_symbolTypeInfo *info) -{ - unsigned int i; - const size_t len = info->member_count * CMEMBERINFO_SIZE; - uint8 *bytes = (uint8 *) Malloc(ctx, len); - if (bytes == NULL) - return 0; - - union { uint8 *ui8; uint16 *ui16; uint32 *ui32; } ptr; - ptr.ui8 = bytes; - for (i = 0; i < info->member_count; i++) - { - const MOJOSHADER_symbolStructMember *member = &info->members[i]; - *(ptr.ui32++) = SWAP32(add_ctab_string(ctx, member->name)); - *(ptr.ui32++) = SWAP32(add_ctab_typeinfo(ctx, &member->info)); - } // for - - const uint32 retval = add_ctab_bytes(ctx, bytes, len); - Free(ctx, bytes); - return retval; -} // add_ctab_members - - -static uint32 add_ctab_typeinfo(Context *ctx, const MOJOSHADER_symbolTypeInfo *info) -{ - uint8 bytes[CTYPEINFO_SIZE]; - union { uint8 *ui8; uint16 *ui16; uint32 *ui32; } ptr; - ptr.ui8 = bytes; - - *(ptr.ui16++) = SWAP16((uint16) info->parameter_class); - *(ptr.ui16++) = SWAP16((uint16) info->parameter_type); - *(ptr.ui16++) = SWAP16((uint16) info->rows); - *(ptr.ui16++) = SWAP16((uint16) info->columns); - *(ptr.ui16++) = SWAP16((uint16) info->elements); - *(ptr.ui16++) = SWAP16((uint16) info->member_count); - *(ptr.ui32++) = SWAP32(add_ctab_members(ctx, info)); - - return add_ctab_bytes(ctx, bytes, sizeof (bytes)); -} // add_ctab_typeinfo - - -static uint32 add_ctab_info(Context *ctx, const MOJOSHADER_symbol *symbols, - const unsigned int symbol_count) -{ - unsigned int i; - const size_t len = symbol_count * CINFO_SIZE; - uint8 *bytes = (uint8 *) Malloc(ctx, len); - if (bytes == NULL) - return 0; - - union { uint8 *ui8; uint16 *ui16; uint32 *ui32; } ptr; - ptr.ui8 = bytes; - for (i = 0; i < symbol_count; i++) - { - const MOJOSHADER_symbol *sym = &symbols[i]; - *(ptr.ui32++) = SWAP32(add_ctab_string(ctx, sym->name)); - *(ptr.ui16++) = SWAP16((uint16) sym->register_set); - *(ptr.ui16++) = SWAP16((uint16) sym->register_index); - *(ptr.ui16++) = SWAP16((uint16) sym->register_count); - *(ptr.ui16++) = SWAP16(0); // reserved - *(ptr.ui32++) = SWAP32(add_ctab_typeinfo(ctx, &sym->info)); - *(ptr.ui32++) = SWAP32(0); // !!! FIXME: default value. - } // for - - const uint32 retval = add_ctab_bytes(ctx, bytes, len); - Free(ctx, bytes); - return retval; -} // add_ctab_info - - -static void output_ctab(Context *ctx, const MOJOSHADER_symbol *symbols, - unsigned int symbol_count, const char *creator) -{ - const size_t tablelen = CTAB_SIZE + sizeof (uint32); - - ctx->ctab = buffer_create(256, MallocBridge, FreeBridge, ctx); - if (ctx->ctab == NULL) - return; // out of memory. - - uint32 *table = (uint32 *) buffer_reserve(ctx->ctab, tablelen); - if (table == NULL) - { - buffer_destroy(ctx->ctab); - ctx->ctab = NULL; - return; // out of memory. - } // if - - *(table++) = SWAP32(CTAB_ID); - *(table++) = SWAP32(CTAB_SIZE); - *(table++) = SWAP32(add_ctab_string(ctx, creator)); - *(table++) = SWAP32(ctx->version_token); - *(table++) = SWAP32(((uint32) symbol_count)); - *(table++) = SWAP32(add_ctab_info(ctx, symbols, symbol_count)); - *(table++) = SWAP32(0); // build flags. - *(table++) = SWAP32(add_ctab_string(ctx, "")); // !!! FIXME: target? - - const size_t ctablen = buffer_size(ctx->ctab); - uint8 *buf = (uint8 *) buffer_flatten(ctx->ctab); - if (buf != NULL) - { - output_comment_bytes(ctx, buf, ctablen); - Free(ctx, buf); - } // if - - buffer_destroy(ctx->ctab); - ctx->ctab = NULL; -} // output_ctab - - -static void output_comments(Context *ctx, const char **comments, - unsigned int comment_count, - const MOJOSHADER_symbol *symbols, - unsigned int symbol_count) -{ - if (isfail(ctx)) - return; - - // make error messages sane if CTAB fails, etc. - const char *prev_fname = ctx->current_file; - const int prev_position = ctx->current_position; - ctx->current_file = NULL; - ctx->current_position = MOJOSHADER_POSITION_BEFORE; - - const char *creator = "MojoShader revision " MOJOSHADER_CHANGESET; - if (symbol_count > 0) - output_ctab(ctx, symbols, symbol_count, creator); - else - output_comment_string(ctx, creator); - - unsigned int i; - for (i = 0; i < comment_count; i++) - output_comment_string(ctx, comments[i]); - - ctx->current_file = prev_fname; - ctx->current_position = prev_position; -} // output_comments - - -static const MOJOSHADER_parseData *build_final_assembly(Context *ctx) -{ - if (isfail(ctx)) - return build_failed_assembly(ctx); - - // get the final bytecode! - const unsigned int output_len = (unsigned int) buffer_size(ctx->output); - unsigned char *bytecode = (unsigned char *) buffer_flatten(ctx->output); - buffer_destroy(ctx->output); - ctx->output = NULL; - - if (bytecode == NULL) - return build_failed_assembly(ctx); - - // This validates the shader; there are lots of things that are - // invalid, but will successfully parse in the assembler, - // generating bad bytecode; this will catch them without us - // having to duplicate most of the validation here. - // It also saves us the trouble of duplicating all the other work, - // like setting up the uniforms list, etc. - MOJOSHADER_parseData *retval = (MOJOSHADER_parseData *) - MOJOSHADER_parse(MOJOSHADER_PROFILE_BYTECODE, - bytecode, output_len, NULL, 0, - ctx->malloc, ctx->free, ctx->malloc_data); - Free(ctx, bytecode); - - SourcePos *token_to_src = NULL; - if (retval->error_count > 0) - token_to_src = (SourcePos *) buffer_flatten(ctx->token_to_source); - buffer_destroy(ctx->token_to_source); - ctx->token_to_source = NULL; - - if (retval->error_count > 0) - { - if (token_to_src == NULL) - { - assert(ctx->out_of_memory); - MOJOSHADER_freeParseData(retval); - return build_failed_assembly(ctx); - } // if - - // on error, map the bytecode back to a line number. - int i; - for (i = 0; i < retval->error_count; i++) - { - MOJOSHADER_error *error = &retval->errors[i]; - if (error->error_position >= 0) - { - assert(retval != &MOJOSHADER_out_of_mem_data); - assert((error->error_position % sizeof (uint32)) == 0); - - const size_t pos = error->error_position / sizeof(uint32); - if (pos >= output_len) - error->error_position = -1; // oh well. - else - { - const SourcePos *srcpos = &token_to_src[pos]; - Free(ctx, (void *) error->filename); - char *fname = NULL; - if (srcpos->filename != NULL) - fname = StrDup(ctx, srcpos->filename); - error->error_position = srcpos->line; - error->filename = fname; // may be NULL, that's okay. - } // else - } // if - } // for - - Free(ctx, token_to_src); - } // if - - return retval; -} // build_final_assembly - - -// API entry point... - -const MOJOSHADER_parseData *MOJOSHADER_assemble(const char *filename, - const char *source, unsigned int sourcelen, - const char **comments, unsigned int comment_count, - const MOJOSHADER_symbol *symbols, - unsigned int symbol_count, - const MOJOSHADER_preprocessorDefine *defines, - unsigned int define_count, - MOJOSHADER_includeOpen include_open, - MOJOSHADER_includeClose include_close, - MOJOSHADER_malloc m, MOJOSHADER_free f, void *d) -{ - const MOJOSHADER_parseData *retval = NULL; - Context *ctx = NULL; - - if ( ((m == NULL) && (f != NULL)) || ((m != NULL) && (f == NULL)) ) - return &MOJOSHADER_out_of_mem_data; // supply both or neither. - - ctx = build_context(filename, source, sourcelen, defines, define_count, - include_open, include_close, m, f, d); - if (ctx == NULL) - return &MOJOSHADER_out_of_mem_data; - - // Version token always comes first. - parse_version_token(ctx); - output_comments(ctx, comments, comment_count, symbols, symbol_count); - - // parse out the rest of the tokens after the version token... - Token token; - while ((token = nexttoken(ctx)) != TOKEN_EOI) - parse_token(ctx, token); - - ctx->current_file = NULL; - ctx->current_position = MOJOSHADER_POSITION_AFTER; - - output_token(ctx, 0x0000FFFF); // end token always 0x0000FFFF. - - retval = build_final_assembly(ctx); - destroy_context(ctx); - return retval; -} // MOJOSHADER_assemble - -// end of mojoshader_assembler.c ... - diff --git a/Externals/mojoshader/1067/mojoshader_common.c b/Externals/mojoshader/1067/mojoshader_common.c deleted file mode 100644 index 07505a99..00000000 --- a/Externals/mojoshader/1067/mojoshader_common.c +++ /dev/null @@ -1,986 +0,0 @@ -#define __MOJOSHADER_INTERNAL__ 1 -#include "mojoshader_internal.h" - -typedef struct HashItem -{ - const void *key; - const void *value; - struct HashItem *next; -} HashItem; - -struct HashTable -{ - HashItem **table; - uint32 table_len; - int stackable; - void *data; - HashTable_HashFn hash; - HashTable_KeyMatchFn keymatch; - HashTable_NukeFn nuke; - MOJOSHADER_malloc m; - MOJOSHADER_free f; - void *d; -}; - -static inline uint32 calc_hash(const HashTable *table, const void *key) -{ - return table->hash(key, table->data) & (table->table_len-1); -} // calc_hash - -int hash_find(const HashTable *table, const void *key, const void **_value) -{ - HashItem *i; - void *data = table->data; - const uint32 hash = calc_hash(table, key); - HashItem *prev = NULL; - for (i = table->table[hash]; i != NULL; i = i->next) - { - if (table->keymatch(key, i->key, data)) - { - if (_value != NULL) - *_value = i->value; - - // Matched! Move to the front of list for faster lookup next time. - // (stackable tables have to remain in the same order, though!) - if ((!table->stackable) && (prev != NULL)) - { - assert(prev->next == i); - prev->next = i->next; - i->next = table->table[hash]; - table->table[hash] = i; - } // if - - return 1; - } // if - - prev = i; - } // for - - return 0; -} // hash_find - -int hash_iter(const HashTable *table, const void *key, - const void **_value, void **iter) -{ - HashItem *item = *iter; - if (item == NULL) - item = table->table[calc_hash(table, key)]; - else - item = item->next; - - while (item != NULL) - { - if (table->keymatch(key, item->key, table->data)) - { - *_value = item->value; - *iter = item; - return 1; - } // if - item = item->next; - } // while - - // no more matches. - *_value = NULL; - *iter = NULL; - return 0; -} // hash_iter - -int hash_iter_keys(const HashTable *table, const void **_key, void **iter) -{ - HashItem *item = *iter; - int idx = 0; - - if (item != NULL) - { - const HashItem *orig = item; - item = item->next; - if (item == NULL) - idx = calc_hash(table, orig->key) + 1; - } // if - - while (!item && (idx < table->table_len)) - item = table->table[idx++]; // skip empty buckets... - - if (item == NULL) // no more matches? - { - *_key = NULL; - *iter = NULL; - return 0; - } // if - - *_key = item->key; - *iter = item; - return 1; -} // hash_iter_keys - -int hash_insert(HashTable *table, const void *key, const void *value) -{ - HashItem *item = NULL; - const uint32 hash = calc_hash(table, key); - if ( (!table->stackable) && (hash_find(table, key, NULL)) ) - return 0; - - // !!! FIXME: grow and rehash table if it gets too saturated. - item = (HashItem *) table->m(sizeof (HashItem), table->d); - if (item == NULL) - return -1; - - item->key = key; - item->value = value; - item->next = table->table[hash]; - table->table[hash] = item; - - return 1; -} // hash_insert - -HashTable *hash_create(void *data, const HashTable_HashFn hashfn, - const HashTable_KeyMatchFn keymatchfn, - const HashTable_NukeFn nukefn, - const int stackable, - MOJOSHADER_malloc m, MOJOSHADER_free f, void *d) -{ - const uint32 initial_table_size = 256; - const uint32 alloc_len = sizeof (HashItem *) * initial_table_size; - HashTable *table = (HashTable *) m(sizeof (HashTable), d); - if (table == NULL) - return NULL; - memset(table, '\0', sizeof (HashTable)); - - table->table = (HashItem **) m(alloc_len, d); - if (table->table == NULL) - { - f(table, d); - return NULL; - } // if - - memset(table->table, '\0', alloc_len); - table->table_len = initial_table_size; - table->stackable = stackable; - table->data = data; - table->hash = hashfn; - table->keymatch = keymatchfn; - table->nuke = nukefn; - table->m = m; - table->f = f; - table->d = d; - return table; -} // hash_create - -void hash_destroy(HashTable *table) -{ - uint32 i; - void *data = table->data; - MOJOSHADER_free f = table->f; - void *d = table->d; - for (i = 0; i < table->table_len; i++) - { - HashItem *item = table->table[i]; - while (item != NULL) - { - HashItem *next = item->next; - table->nuke(item->key, item->value, data); - f(item, d); - item = next; - } // while - } // for - - f(table->table, d); - f(table, d); -} // hash_destroy - -int hash_remove(HashTable *table, const void *key) -{ - HashItem *item = NULL; - HashItem *prev = NULL; - void *data = table->data; - const uint32 hash = calc_hash(table, key); - for (item = table->table[hash]; item != NULL; item = item->next) - { - if (table->keymatch(key, item->key, data)) - { - if (prev != NULL) - prev->next = item->next; - else - table->table[hash] = item->next; - - table->nuke(item->key, item->value, data); - table->f(item, table->d); - return 1; - } // if - - prev = item; - } // for - - return 0; -} // hash_remove - - -// this is djb's xor hashing function. -static inline uint32 hash_string_djbxor(const char *str, size_t len) -{ - register uint32 hash = 5381; - while (len--) - hash = ((hash << 5) + hash) ^ *(str++); - return hash; -} // hash_string_djbxor - -static inline uint32 hash_string(const char *str, size_t len) -{ - return hash_string_djbxor(str, len); -} // hash_string - -uint32 hash_hash_string(const void *sym, void *data) -{ - (void) data; - return hash_string((const char*) sym, strlen((const char *) sym)); -} // hash_hash_string - -int hash_keymatch_string(const void *a, const void *b, void *data) -{ - (void) data; - return (strcmp((const char *) a, (const char *) b) == 0); -} // hash_keymatch_string - - -// string -> string map... - -static void stringmap_nuke_noop(const void *key, const void *val, void *d) {} - -static void stringmap_nuke(const void *key, const void *val, void *d) -{ - StringMap *smap = (StringMap *) d; - smap->f((void *) key, smap->d); - smap->f((void *) val, smap->d); -} // stringmap_nuke - -StringMap *stringmap_create(const int copy, MOJOSHADER_malloc m, - MOJOSHADER_free f, void *d) -{ - HashTable_NukeFn nuke = copy ? stringmap_nuke : stringmap_nuke_noop; - StringMap *smap; - smap = hash_create(0,hash_hash_string,hash_keymatch_string,nuke,0,m,f,d); - smap->data = smap; - return smap; -} // stringmap_create - -void stringmap_destroy(StringMap *smap) -{ - hash_destroy(smap); -} // stringmap_destroy - -int stringmap_insert(StringMap *smap, const char *key, const char *value) -{ - assert(key != NULL); - if (smap->nuke == stringmap_nuke_noop) // no copy? - return hash_insert(smap, key, value); - - int rc = -1; - char *k = (char *) smap->m(strlen(key) + 1, smap->d); - char *v = (char *) (value ? smap->m(strlen(value) + 1, smap->d) : NULL); - int failed = ( (!k) || ((!v) && (value)) ); - - if (!failed) - { - strcpy(k, key); - if (value != NULL) - strcpy(v, value); - failed = ((rc = hash_insert(smap, k, v)) <= 0); - } // if - - if (failed) - { - smap->f(k, smap->d); - smap->f(v, smap->d); - } // if - - return rc; -} // stringmap_insert - -int stringmap_remove(StringMap *smap, const char *key) -{ - return hash_remove(smap, key); -} // stringmap_remove - -int stringmap_find(const StringMap *smap, const char *key, const char **_value) -{ - const void *value = NULL; - const int retval = hash_find(smap, key, &value); - *_value = (const char *) value; - return retval; -} // stringmap_find - - -// The string cache... !!! FIXME: use StringMap internally for this. - -typedef struct StringBucket -{ - char *string; - struct StringBucket *next; -} StringBucket; - -struct StringCache -{ - StringBucket **hashtable; - uint32 table_size; - MOJOSHADER_malloc m; - MOJOSHADER_free f; - void *d; -}; - -const char *stringcache(StringCache *cache, const char *str) -{ - return stringcache_len(cache, str, strlen(str)); -} // stringcache - -const char *stringcache_len(StringCache *cache, const char *str, - const unsigned int len) -{ - const uint8 hash = hash_string(str, len) & (cache->table_size-1); - StringBucket *bucket = cache->hashtable[hash]; - StringBucket *prev = NULL; - while (bucket) - { - const char *bstr = bucket->string; - if ((strncmp(bstr, str, len) == 0) && (bstr[len] == 0)) - { - // Matched! Move this to the front of the list. - if (prev != NULL) - { - assert(prev->next == bucket); - prev->next = bucket->next; - bucket->next = cache->hashtable[hash]; - cache->hashtable[hash] = bucket; - } // if - return bstr; // already cached - } // if - prev = bucket; - bucket = bucket->next; - } // while - - // no match, add to the table. - bucket = (StringBucket *) cache->m(sizeof (StringBucket), cache->d); - if (bucket == NULL) - return NULL; - bucket->string = (char *) cache->m(len + 1, cache->d); - if (bucket->string == NULL) - { - cache->f(bucket, cache->d); - return NULL; - } // if - memcpy(bucket->string, str, len); - bucket->string[len] = '\0'; - bucket->next = cache->hashtable[hash]; - cache->hashtable[hash] = bucket; - return bucket->string; -} // stringcache_len - -const char *stringcache_fmt(StringCache *cache, const char *fmt, ...) -{ - char buf[128]; // use the stack if reasonable. - char *ptr = NULL; - int len = 0; // number of chars, NOT counting null-terminator! - va_list ap; - - va_start(ap, fmt); - len = vsnprintf(buf, sizeof (buf), fmt, ap); - va_end(ap); - - if (len > sizeof (buf)) - { - ptr = (char *) cache->m(len, cache->d); - if (ptr == NULL) - return NULL; - - va_start(ap, fmt); - vsnprintf(ptr, len, fmt, ap); - va_end(ap); - } // if - - const char *retval = stringcache_len(cache, ptr ? ptr : buf, len); - if (ptr != NULL) - cache->f(ptr, cache->d); - - return retval; -} // stringcache_fmt - -StringCache *stringcache_create(MOJOSHADER_malloc m, MOJOSHADER_free f, void *d) -{ - const uint32 initial_table_size = 256; - const size_t tablelen = sizeof (StringBucket *) * initial_table_size; - StringCache *cache = (StringCache *) m(sizeof (StringCache), d); - if (!cache) - return NULL; - memset(cache, '\0', sizeof (StringCache)); - - cache->hashtable = (StringBucket **) m(tablelen, d); - if (!cache->hashtable) - { - f(cache, d); - return NULL; - } // if - memset(cache->hashtable, '\0', tablelen); - - cache->table_size = initial_table_size; - cache->m = m; - cache->f = f; - cache->d = d; - return cache; -} // stringcache_create - -void stringcache_destroy(StringCache *cache) -{ - if (cache == NULL) - return; - - MOJOSHADER_free f = cache->f; - void *d = cache->d; - size_t i; - - for (i = 0; i < cache->table_size; i++) - { - StringBucket *bucket = cache->hashtable[i]; - cache->hashtable[i] = NULL; - while (bucket) - { - StringBucket *next = bucket->next; - f(bucket->string, d); - f(bucket, d); - bucket = next; - } // while - } // for - - f(cache->hashtable, d); - f(cache, d); -} // stringcache_destroy - - -// We chain errors as a linked list with a head/tail for easy appending. -// These get flattened before passing to the application. -typedef struct ErrorItem -{ - MOJOSHADER_error error; - struct ErrorItem *next; -} ErrorItem; - -struct ErrorList -{ - ErrorItem head; - ErrorItem *tail; - int count; - MOJOSHADER_malloc m; - MOJOSHADER_free f; - void *d; -}; - -ErrorList *errorlist_create(MOJOSHADER_malloc m, MOJOSHADER_free f, void *d) -{ - ErrorList *retval = (ErrorList *) m(sizeof (ErrorList), d); - if (retval != NULL) - { - memset(retval, '\0', sizeof (ErrorList)); - retval->tail = &retval->head; - retval->m = m; - retval->f = f; - retval->d = d; - } // if - - return retval; -} // errorlist_create - - -int errorlist_add(ErrorList *list, const char *fname, - const int errpos, const char *str) -{ - return errorlist_add_fmt(list, fname, errpos, "%s", str); -} // errorlist_add - - -int errorlist_add_fmt(ErrorList *list, const char *fname, - const int errpos, const char *fmt, ...) -{ - va_list ap; - va_start(ap, fmt); - const int retval = errorlist_add_va(list, fname, errpos, fmt, ap); - va_end(ap); - return retval; -} // errorlist_add_fmt - - -int errorlist_add_va(ErrorList *list, const char *_fname, - const int errpos, const char *fmt, va_list va) -{ - ErrorItem *error = (ErrorItem *) list->m(sizeof (ErrorItem), list->d); - if (error == NULL) - return 0; - - char *fname = NULL; - if (_fname != NULL) - { - fname = (char *) list->m(strlen(_fname) + 1, list->d); - if (fname == NULL) - { - list->f(error, list->d); - return 0; - } // if - strcpy(fname, _fname); - } // if - - char scratch[128]; - va_list ap; - va_copy(ap, va); - const int len = vsnprintf(scratch, sizeof (scratch), fmt, ap); - va_end(ap); - - char *failstr = (char *) list->m(len + 1, list->d); - if (failstr == NULL) - { - list->f(error, list->d); - list->f(fname, list->d); - return 0; - } // if - - // If we overflowed our scratch buffer, that's okay. We were going to - // allocate anyhow...the scratch buffer just lets us avoid a second - // run of vsnprintf(). - if (len < sizeof (scratch)) - strcpy(failstr, scratch); // copy it over. - else - { - va_copy(ap, va); - vsnprintf(failstr, len + 1, fmt, ap); // rebuild it. - va_end(ap); - } // else - - error->error.error = failstr; - error->error.filename = fname; - error->error.error_position = errpos; - error->next = NULL; - - list->tail->next = error; - list->tail = error; - - list->count++; - return 1; -} // errorlist_add_va - - -int errorlist_count(ErrorList *list) -{ - return list->count; -} // errorlist_count - - -MOJOSHADER_error *errorlist_flatten(ErrorList *list) -{ - if (list->count == 0) - return NULL; - - int total = 0; - MOJOSHADER_error *retval = (MOJOSHADER_error *) - list->m(sizeof (MOJOSHADER_error) * list->count, list->d); - if (retval == NULL) - return NULL; - - ErrorItem *item = list->head.next; - while (item != NULL) - { - ErrorItem *next = item->next; - // reuse the string allocations - memcpy(&retval[total], &item->error, sizeof (MOJOSHADER_error)); - list->f(item, list->d); - item = next; - total++; - } // while - - assert(total == list->count); - list->count = 0; - list->head.next = NULL; - list->tail = &list->head; - return retval; -} // errorlist_flatten - - -void errorlist_destroy(ErrorList *list) -{ - if (list == NULL) - return; - - MOJOSHADER_free f = list->f; - void *d = list->d; - ErrorItem *item = list->head.next; - while (item != NULL) - { - ErrorItem *next = item->next; - f((void *) item->error.error, d); - f((void *) item->error.filename, d); - f(item, d); - item = next; - } // while - f(list, d); -} // errorlist_destroy - - -typedef struct BufferBlock -{ - uint8 *data; - size_t bytes; - struct BufferBlock *next; -} BufferBlock; - -struct Buffer -{ - size_t total_bytes; - BufferBlock *head; - BufferBlock *tail; - size_t block_size; - MOJOSHADER_malloc m; - MOJOSHADER_free f; - void *d; -}; - -Buffer *buffer_create(size_t blksz, MOJOSHADER_malloc m, - MOJOSHADER_free f, void *d) -{ - Buffer *buffer = (Buffer *) m(sizeof (Buffer), d); - if (buffer != NULL) - { - memset(buffer, '\0', sizeof (Buffer)); - buffer->block_size = blksz; - buffer->m = m; - buffer->f = f; - buffer->d = d; - } // if - return buffer; -} // buffer_create - -char *buffer_reserve(Buffer *buffer, const size_t len) -{ - // note that we make the blocks bigger than blocksize when we have enough - // data to overfill a fresh block, to reduce allocations. - const size_t blocksize = buffer->block_size; - - if (len == 0) - return NULL; - - if (buffer->tail != NULL) - { - const size_t tailbytes = buffer->tail->bytes; - const size_t avail = (tailbytes >= blocksize) ? 0 : blocksize - tailbytes; - if (len <= avail) - { - buffer->tail->bytes += len; - buffer->total_bytes += len; - assert(buffer->tail->bytes <= blocksize); - return (char *) buffer->tail->data + tailbytes; - } // if - } // if - - // need to allocate a new block (even if a previous block wasn't filled, - // so this buffer is contiguous). - const size_t bytecount = len > blocksize ? len : blocksize; - const size_t malloc_len = sizeof (BufferBlock) + bytecount; - BufferBlock *item = (BufferBlock *) buffer->m(malloc_len, buffer->d); - if (item == NULL) - return NULL; - - item->data = ((uint8 *) item) + sizeof (BufferBlock); - item->bytes = len; - item->next = NULL; - if (buffer->tail != NULL) - buffer->tail->next = item; - else - buffer->head = item; - buffer->tail = item; - - buffer->total_bytes += len; - - return (char *) item->data; -} // buffer_reserve - -int buffer_append(Buffer *buffer, const void *_data, size_t len) -{ - const uint8 *data = (const uint8 *) _data; - - // note that we make the blocks bigger than blocksize when we have enough - // data to overfill a fresh block, to reduce allocations. - const size_t blocksize = buffer->block_size; - - if (len == 0) - return 1; - - if (buffer->tail != NULL) - { - const size_t tailbytes = buffer->tail->bytes; - const size_t avail = (tailbytes >= blocksize) ? 0 : blocksize - tailbytes; - const size_t cpy = (avail > len) ? len : avail; - if (cpy > 0) - { - memcpy(buffer->tail->data + tailbytes, data, cpy); - len -= cpy; - data += cpy; - buffer->tail->bytes += cpy; - buffer->total_bytes += cpy; - assert(buffer->tail->bytes <= blocksize); - } // if - } // if - - if (len > 0) - { - assert((!buffer->tail) || (buffer->tail->bytes == blocksize)); - const size_t bytecount = len > blocksize ? len : blocksize; - const size_t malloc_len = sizeof (BufferBlock) + bytecount; - BufferBlock *item = (BufferBlock *) buffer->m(malloc_len, buffer->d); - if (item == NULL) - return 0; - - item->data = ((uint8 *) item) + sizeof (BufferBlock); - item->bytes = len; - item->next = NULL; - if (buffer->tail != NULL) - buffer->tail->next = item; - else - buffer->head = item; - buffer->tail = item; - - memcpy(item->data, data, len); - buffer->total_bytes += len; - } // if - - return 1; -} // buffer_append - -int buffer_append_fmt(Buffer *buffer, const char *fmt, ...) -{ - va_list ap; - va_start(ap, fmt); - const int retval = buffer_append_va(buffer, fmt, ap); - va_end(ap); - return retval; -} // buffer_append_fmt - -int buffer_append_va(Buffer *buffer, const char *fmt, va_list va) -{ - char scratch[128]; - - va_list ap; - va_copy(ap, va); - const int len = vsnprintf(scratch, sizeof (scratch), fmt, ap); - va_end(ap); - - // If we overflowed our scratch buffer, heap allocate and try again. - - if (len == 0) - return 1; // nothing to do. - else if (len < sizeof (scratch)) - return buffer_append(buffer, scratch, len); - - char *buf = (char *) buffer->m(len + 1, buffer->d); - if (buf == NULL) - return 0; - va_copy(ap, va); - vsnprintf(buf, len + 1, fmt, ap); // rebuild it. - va_end(ap); - const int retval = buffer_append(buffer, scratch, len); - buffer->f(buf, buffer->d); - return retval; -} // buffer_append_va - -size_t buffer_size(Buffer *buffer) -{ - return buffer->total_bytes; -} // buffer_size - -void buffer_empty(Buffer *buffer) -{ - BufferBlock *item = buffer->head; - while (item != NULL) - { - BufferBlock *next = item->next; - buffer->f(item, buffer->d); - item = next; - } // while - buffer->head = buffer->tail = NULL; - buffer->total_bytes = 0; -} // buffer_empty - -char *buffer_flatten(Buffer *buffer) -{ - char *retval = (char *) buffer->m(buffer->total_bytes + 1, buffer->d); - if (retval == NULL) - return NULL; - BufferBlock *item = buffer->head; - char *ptr = retval; - while (item != NULL) - { - BufferBlock *next = item->next; - memcpy(ptr, item->data, item->bytes); - ptr += item->bytes; - buffer->f(item, buffer->d); - item = next; - } // while - *ptr = '\0'; - - assert(ptr == (retval + buffer->total_bytes)); - - buffer->head = buffer->tail = NULL; - buffer->total_bytes = 0; - - return retval; -} // buffer_flatten - -char *buffer_merge(Buffer **buffers, const size_t n, size_t *_len) -{ - Buffer *first = NULL; - size_t len = 0; - size_t i; - for (i = 0; i < n; i++) - { - Buffer *buffer = buffers[i]; - if (buffer == NULL) - continue; - if (first == NULL) - first = buffer; - len += buffer->total_bytes; - } // for - - char *retval = (char *) (first ? first->m(len + 1, first->d) : NULL); - if (retval == NULL) - { - *_len = 0; - return NULL; - } // if - - *_len = len; - char *ptr = retval; - for (i = 0; i < n; i++) - { - Buffer *buffer = buffers[i]; - if (buffer == NULL) - continue; - BufferBlock *item = buffer->head; - while (item != NULL) - { - BufferBlock *next = item->next; - memcpy(ptr, item->data, item->bytes); - ptr += item->bytes; - buffer->f(item, buffer->d); - item = next; - } // while - - buffer->head = buffer->tail = NULL; - buffer->total_bytes = 0; - } // for - *ptr = '\0'; - - assert(ptr == (retval + len)); - - return retval; -} // buffer_merge - -void buffer_destroy(Buffer *buffer) -{ - if (buffer != NULL) - { - MOJOSHADER_free f = buffer->f; - void *d = buffer->d; - buffer_empty(buffer); - f(buffer, d); - } // if -} // buffer_destroy - -static int blockscmp(BufferBlock *item, const uint8 *data, size_t len) -{ - if (len == 0) - return 1; // "match" - - while (item != NULL) - { - const size_t itemremain = item->bytes; - const size_t avail = len < itemremain ? len : itemremain; - if (memcmp(item->data, data, avail) != 0) - return 0; // not a match. - - if (len == avail) - return 1; // complete match! - - len -= avail; - data += avail; - item = item->next; - } // while - - return 0; // not a complete match. -} // blockscmp - -ssize_t buffer_find(Buffer *buffer, const size_t start, - const void *_data, const size_t len) -{ - if (len == 0) - return 0; // I guess that's right. - - if (start >= buffer->total_bytes) - return -1; // definitely can't match. - - if (len > (buffer->total_bytes - start)) - return -1; // definitely can't match. - - // Find the start point somewhere in the center of a buffer. - BufferBlock *item = buffer->head; - const uint8 *ptr = item->data; - size_t pos = 0; - if (start > 0) - { - while (1) - { - assert(item != NULL); - if ((pos + item->bytes) > start) // start is in this block. - { - ptr = item->data + (start - pos); - break; - } // if - - pos += item->bytes; - item = item->next; - } // while - } // if - - // okay, we're at the origin of the search. - assert(item != NULL); - assert(ptr != NULL); - - const uint8 *data = (const uint8 *) _data; - const uint8 first = *data; - while (item != NULL) - { - const size_t itemremain = item->bytes - ((size_t)(ptr-item->data)); - ptr = (uint8 *) memchr(ptr, first, itemremain); - while (ptr != NULL) - { - const size_t retval = pos + ((size_t) (ptr - item->data)); - if (len == 1) - return retval; // we're done, here it is! - - const size_t itemremain = item->bytes - ((size_t)(ptr-item->data)); - const size_t avail = len < itemremain ? len : itemremain; - if ((avail == 0) || (memcmp(ptr, data, avail) == 0)) - { - // okay, we've got a (sub)string match! Move to the next block. - // check all blocks until we get a complete match or a failure. - if (blockscmp(item->next, data+avail, len-avail)) - return (ssize_t) retval; - } // if - - // try again, further in this block. - ptr = (uint8 *) memchr(ptr + 1, first, itemremain - 1); - } // while - - pos += item->bytes; - item = item->next; - if (item != NULL) - ptr = item->data; - } // while - - return -1; // no match found. -} // buffer_find - -// end of mojoshader_common.c ... - diff --git a/Externals/mojoshader/1067/mojoshader_compiler.c b/Externals/mojoshader/1067/mojoshader_compiler.c deleted file mode 100644 index 6f6e11c2..00000000 --- a/Externals/mojoshader/1067/mojoshader_compiler.c +++ /dev/null @@ -1,6288 +0,0 @@ -/** - * MojoShader; generate shader programs from bytecode of compiled - * Direct3D shaders. - * - * Please see the file LICENSE.txt in the source's root directory. - * - * This file written by Ryan C. Gordon. - */ - -// !!! FIXME: this needs to be split into separate source files: -// !!! FIXME: parse, AST, IR, etc. The problem is we need to deal with the -// !!! FIXME: "Context" struct being passed around everywhere. - -#define __MOJOSHADER_INTERNAL__ 1 -#include "mojoshader_internal.h" - -#if DEBUG_COMPILER_PARSER -#define LEMON_SUPPORT_TRACING 1 -#endif - -// !!! FIXME: I'd like to lose this. It's really inefficient. Just keep a -// !!! FIXME: (tail) on these list structures instead? -#define REVERSE_LINKED_LIST(typ, head) { \ - if ((head) && (head->next)) { \ - typ *tmp = NULL; \ - typ *tmp1 = NULL; \ - while (head != NULL) { \ - tmp = head; \ - head = head->next; \ - tmp->next = tmp1; \ - tmp1 = tmp; \ - } \ - head = tmp; \ - } \ -} - -static inline int operator_is_unary(const MOJOSHADER_astNodeType op) -{ - return ( (op > MOJOSHADER_AST_OP_START_RANGE_UNARY) && - (op < MOJOSHADER_AST_OP_END_RANGE_UNARY) ); -} // operator_is_unary - -static inline int operator_is_binary(const MOJOSHADER_astNodeType op) -{ - return ( (op > MOJOSHADER_AST_OP_START_RANGE_BINARY) && - (op < MOJOSHADER_AST_OP_END_RANGE_BINARY) ); -} // operator_is_binary - -static inline int operator_is_ternary(const MOJOSHADER_astNodeType op) -{ - return ( (op > MOJOSHADER_AST_OP_START_RANGE_TERNARY) && - (op < MOJOSHADER_AST_OP_END_RANGE_TERNARY) ); -} // operator_is_ternary - - -typedef union TokenData -{ - int64 i64; - double dbl; - const char *string; - const MOJOSHADER_astDataType *datatype; -} TokenData; - - -// This tracks data types and variables, and notes when they enter/leave scope. - -typedef struct SymbolScope -{ - const char *symbol; - const MOJOSHADER_astDataType *datatype; - int index; // unique positive value within a function, negative if global. - int referenced; // non-zero if something looked for this symbol (so we know it's used). - struct SymbolScope *next; -} SymbolScope; - -typedef struct SymbolMap -{ - HashTable *hash; - SymbolScope *scope; -} SymbolMap; - -typedef struct LoopLabels -{ - int start; // loop's start label during IR build. - int end; // loop's end label during IR build. - struct LoopLabels *prev; -} LoopLabels; - -// Compile state, passed around all over the place. - -typedef struct Context -{ - int isfail; - int out_of_memory; - MOJOSHADER_malloc malloc; - MOJOSHADER_free free; - void *malloc_data; - ErrorList *errors; - ErrorList *warnings; - StringCache *strcache; - const char *sourcefile; // current source file that we're parsing. - unsigned int sourceline; // current line in sourcefile that we're parsing. - SymbolMap usertypes; - SymbolMap variables; - MOJOSHADER_astNode *ast; // Abstract Syntax Tree - const char *source_profile; - int is_func_scope; // non-zero if semantic analysis is in function scope. - int loop_count; - int switch_count; - int var_index; // next variable index for current function. - int global_var_index; // next variable index for global scope. - int user_func_index; // next function index for user-defined functions. - int intrinsic_func_index; // next function index for intrinsic functions. - - MOJOSHADER_irStatement **ir; // intermediate representation. - int ir_label_count; // next unused IR label index. - int ir_temp_count; // next unused IR temporary value index. - int ir_end; // current function's end label during IR build. - int ir_ret; // temp that holds current function's retval during IR build. - LoopLabels *ir_loop; // nested loop boundary labels during IR build. - - // Cache intrinsic types for fast lookup and consistent pointer values. - MOJOSHADER_astDataType dt_none; - MOJOSHADER_astDataType dt_bool; - MOJOSHADER_astDataType dt_int; - MOJOSHADER_astDataType dt_uint; - MOJOSHADER_astDataType dt_float; - MOJOSHADER_astDataType dt_float_snorm; - MOJOSHADER_astDataType dt_float_unorm; - MOJOSHADER_astDataType dt_half; - MOJOSHADER_astDataType dt_double; - MOJOSHADER_astDataType dt_string; - MOJOSHADER_astDataType dt_sampler1d; - MOJOSHADER_astDataType dt_sampler2d; - MOJOSHADER_astDataType dt_sampler3d; - MOJOSHADER_astDataType dt_samplercube; - MOJOSHADER_astDataType dt_samplerstate; - MOJOSHADER_astDataType dt_samplercompstate; - MOJOSHADER_astDataType dt_buf_bool; - MOJOSHADER_astDataType dt_buf_int; - MOJOSHADER_astDataType dt_buf_uint; - MOJOSHADER_astDataType dt_buf_half; - MOJOSHADER_astDataType dt_buf_float; - MOJOSHADER_astDataType dt_buf_double; - MOJOSHADER_astDataType dt_buf_float_snorm; - MOJOSHADER_astDataType dt_buf_float_unorm; - - Buffer *garbage; // this is sort of hacky. -} Context; - - -// !!! FIXME: cut and paste between every damned source file follows... -// !!! FIXME: We need to make some sort of ContextBase that applies to all -// !!! FIXME: files and move this stuff to mojoshader_common.c ... - -// Convenience functions for allocators... - -static inline void out_of_memory(Context *ctx) -{ - ctx->isfail = ctx->out_of_memory = 1; -} // out_of_memory - -static inline void *Malloc(Context *ctx, const size_t len) -{ - void *retval = ctx->malloc((int) len, ctx->malloc_data); - if (retval == NULL) - out_of_memory(ctx); - return retval; -} // Malloc - -static inline char *StrDup(Context *ctx, const char *str) -{ - char *retval = (char *) Malloc(ctx, strlen(str) + 1); - if (retval != NULL) - strcpy(retval, str); - return retval; -} // StrDup - -static inline void Free(Context *ctx, void *ptr) -{ - ctx->free(ptr, ctx->malloc_data); -} // Free - -static void *MallocBridge(int bytes, void *data) -{ - return Malloc((Context *) data, (size_t) bytes); -} // MallocBridge - -static void FreeBridge(void *ptr, void *data) -{ - Free((Context *) data, ptr); -} // FreeBridge - -static void failf(Context *ctx, const char *fmt, ...) ISPRINTF(2,3); -static void failf(Context *ctx, const char *fmt, ...) -{ - ctx->isfail = 1; - if (ctx->out_of_memory) - return; - - va_list ap; - va_start(ap, fmt); - errorlist_add_va(ctx->errors, ctx->sourcefile, ctx->sourceline, fmt, ap); - va_end(ap); -} // failf - -static inline void fail(Context *ctx, const char *reason) -{ - failf(ctx, "%s", reason); -} // fail - -static void warnf(Context *ctx, const char *fmt, ...) ISPRINTF(2,3); -static void warnf(Context *ctx, const char *fmt, ...) -{ - if (ctx->out_of_memory) - return; - - va_list ap; - va_start(ap, fmt); - errorlist_add_va(ctx->warnings, ctx->sourcefile, ctx->sourceline, fmt, ap); - va_end(ap); -} // warnf - -static inline void warn(Context *ctx, const char *reason) -{ - warnf(ctx, "%s", reason); -} // warn - -static inline int isfail(const Context *ctx) -{ - return ctx->isfail; -} // isfail - - -static void symbolmap_nuke(const void *k, const void *v, void *d) {/*no-op*/} - -static int create_symbolmap(Context *ctx, SymbolMap *map) -{ - // !!! FIXME: should compare string pointer, with string in cache. - map->scope = NULL; - map->hash = hash_create(ctx, hash_hash_string, hash_keymatch_string, - symbolmap_nuke, 1, MallocBridge, FreeBridge, ctx); - return (map->hash != NULL); -} // create_symbolmap - -static int datatypes_match(const MOJOSHADER_astDataType *a, - const MOJOSHADER_astDataType *b) -{ - int i; - - if (a == b) - return 1; - else if (a->type != b->type) - return 0; - - switch (a->type) - { - case MOJOSHADER_AST_DATATYPE_STRUCT: - if (a->structure.member_count != b->structure.member_count) - return 0; - for (i = 0; i < a->structure.member_count; i++) - { - if (!datatypes_match(a->structure.members[i].datatype, - b->structure.members[i].datatype)) - return 0; - // stringcache'd, pointer compare is safe. - else if (a->structure.members[i].identifier != - b->structure.members[i].identifier) - return 0; - } // for - return 1; - - case MOJOSHADER_AST_DATATYPE_ARRAY: - if (a->array.elements != b->array.elements) - return 0; - else if (!datatypes_match(a->array.base, b->array.base)) - return 0; - return 1; - - case MOJOSHADER_AST_DATATYPE_VECTOR: - if (a->vector.elements != b->vector.elements) - return 0; - else if (!datatypes_match(a->vector.base, b->vector.base)) - return 0; - return 1; - - case MOJOSHADER_AST_DATATYPE_MATRIX: - if (a->matrix.rows != b->matrix.rows) - return 0; - else if (a->matrix.columns != b->matrix.columns) - return 0; - else if (!datatypes_match(a->matrix.base, b->matrix.base)) - return 0; - return 1; - - case MOJOSHADER_AST_DATATYPE_BUFFER: - return datatypes_match(a->buffer.base, b->buffer.base); - - case MOJOSHADER_AST_DATATYPE_FUNCTION: - if (a->function.num_params != b->function.num_params) - return 0; - else if (a->function.intrinsic != b->function.intrinsic) - return 0; - else if (!datatypes_match(a->function.retval, b->function.retval)) - return 0; - for (i = 0; i < a->function.num_params; i++) - { - if (!datatypes_match(a->function.params[i], b->function.params[i])) - return 0; - } // for - return 1; - - case MOJOSHADER_AST_DATATYPE_USER: - return 0; // pointers must match, this clearly didn't. - - default: - assert(0 && "unexpected case"); - return 0; - } // switch - - return 0; -} // datatypes_match - -static void push_symbol(Context *ctx, SymbolMap *map, const char *sym, - const MOJOSHADER_astDataType *dt, const int index, - const int check_dupes) -{ - if (ctx->out_of_memory) - return; - - // Decide if this symbol is defined, and if it's in the current scope. - SymbolScope *item = NULL; - const void *value = NULL; - if ((check_dupes) && (sym != NULL) && (hash_find(map->hash, sym, &value))) - { - // check the current scope for a dupe. - // !!! FIXME: note current scope's starting index, see if found - // !!! FIXME: item is < index (and thus, a previous scope). - item = map->scope; - while ((item) && (item->symbol)) - { - if ( ((const void *) item) == value ) - { - failf(ctx, "Symbol '%s' already defined", sym); - return; - } // if - item = item->next; - } // while - } // if - - // Add the symbol to our map and scope stack. - item = (SymbolScope *) Malloc(ctx, sizeof (SymbolScope)); - if (item == NULL) - return; - - if (sym != NULL) // sym can be NULL if we're pushing a new scope. - { - if (hash_insert(map->hash, sym, item) == -1) - { - Free(ctx, item); - return; - } // if - } // if - - item->symbol = sym; // cached strings, don't copy. - item->index = index; - item->datatype = dt; - item->referenced = 0; - item->next = map->scope; - map->scope = item; -} // push_symbol - -static void push_usertype(Context *ctx, const char *sym, const MOJOSHADER_astDataType *dt) -{ - if (sym != NULL) - { - MOJOSHADER_astDataType *userdt; - userdt = (MOJOSHADER_astDataType *) Malloc(ctx, sizeof (*userdt)); - if (userdt != NULL) - { - // !!! FIXME: this is hacky. - if (!buffer_append(ctx->garbage, &userdt, sizeof (userdt))) - { - Free(ctx, userdt); - return; - } // if - - userdt->type = MOJOSHADER_AST_DATATYPE_USER; - userdt->user.details = dt; - userdt->user.name = sym; - - dt = userdt; - } // if - } // if - - push_symbol(ctx, &ctx->usertypes, sym, dt, 0, 1); -} // push_usertype - -static inline void push_variable(Context *ctx, const char *sym, const MOJOSHADER_astDataType *dt) -{ - int idx = 0; - if (sym != NULL) - { - // leave space for individual member indexes. The IR will need this. - int additional = 0; - if (dt->type == MOJOSHADER_AST_DATATYPE_STRUCT) - additional = dt->structure.member_count; - if (ctx->is_func_scope) - { - idx = ++ctx->var_index; // these are positive. - ctx->var_index += additional; - } // if - else - { - idx = --ctx->global_var_index; // these are negative. - ctx->global_var_index -= additional; - } // else - } // if - - push_symbol(ctx, &ctx->variables, sym, dt, idx, 1); -} // push_variable - -static int push_function(Context *ctx, const char *sym, - const MOJOSHADER_astDataType *dt, - const int just_declare) -{ - // we don't have any reason to support nested functions at the moment, - // so this would be a bug. - assert(!ctx->is_func_scope); - assert(dt->type == MOJOSHADER_AST_DATATYPE_FUNCTION); - - // Functions are always global, so no need to search scopes. - // Functions overload, though, so we have to continue iterating to - // see if it matches anything. - const void *value = NULL; - void *iter = NULL; - while (hash_iter(ctx->variables.hash, sym, &value, &iter)) - { - // !!! FIXME: this breaks if you predeclare a function. - // !!! FIXME: (a declare AFTER defining works, though.) - // there's already something called this. - SymbolScope *item = (SymbolScope *) value; - if (datatypes_match(dt, item->datatype)) - { - if (!just_declare) - failf(ctx, "Function '%s' already defined.", sym); - return item->index; - } // if - } // while - - int idx = 0; - if ((sym != NULL) && (dt != NULL)) - { - if (!dt->function.intrinsic) - idx = ++ctx->user_func_index; // these are positive. - else - idx = --ctx->intrinsic_func_index; // these are negative. - } // if - - // push_symbol() doesn't check dupes, because we just did. - push_symbol(ctx, &ctx->variables, sym, dt, idx, 0); - - return idx; -} // push_function - -static inline void push_scope(Context *ctx) -{ - push_usertype(ctx, NULL, NULL); - push_variable(ctx, NULL, NULL); -} // push_scope - -static void pop_symbol(Context *ctx, SymbolMap *map) -{ - SymbolScope *item = map->scope; - if (!item) - return; - if (item->symbol) - hash_remove(map->hash, item->symbol); - map->scope = item->next; - Free(ctx, item); -} // pop_symbol - -static void pop_symbol_scope(Context *ctx, SymbolMap *map) -{ - while ((map->scope) && (map->scope->symbol)) - pop_symbol(ctx, map); - - assert(map->scope != NULL); - assert(map->scope->symbol == NULL); - pop_symbol(ctx, map); -} // pop_symbol_scope - -static inline void pop_scope(Context *ctx) -{ - pop_symbol_scope(ctx, &ctx->usertypes); - pop_symbol_scope(ctx, &ctx->variables); -} // push_scope - -static const MOJOSHADER_astDataType *find_symbol(Context *ctx, SymbolMap *map, const char *sym, int *_index) -{ - const void *_item = NULL; - hash_find(map->hash, sym, &_item); - SymbolScope *item = (SymbolScope *) _item; - if (item != NULL) - { - item->referenced++; - if (_index != NULL) - *_index = item->index; - } // if - return item ? item->datatype : NULL; -} // find_symbol - -static inline const MOJOSHADER_astDataType *find_usertype(Context *ctx, const char *sym) -{ - return find_symbol(ctx, &ctx->usertypes, sym, NULL); -} // find_usertype - -static inline const MOJOSHADER_astDataType *find_variable(Context *ctx, const char *sym, int *_index) -{ - return find_symbol(ctx, &ctx->variables, sym, _index); -} // find_variable - -static void destroy_symbolmap(Context *ctx, SymbolMap *map) -{ - while (map->scope) - pop_symbol(ctx, map); - hash_destroy(map->hash); -} // destroy_symbolmap - - -static const MOJOSHADER_astDataType *new_datatype_vector(Context *ctx, - const MOJOSHADER_astDataType *dt, - const int columns) -{ - MOJOSHADER_astDataType *retval; - retval = (MOJOSHADER_astDataType *) Malloc(ctx, sizeof (*retval)); - if (retval == NULL) - return NULL; - - // !!! FIXME: this is hacky. - // !!! FIXME: I'd like to cache these anyhow and reuse types. - if (!buffer_append(ctx->garbage, &retval, sizeof (retval))) - { - Free(ctx, retval); - return NULL; - } // if - - if ((columns < 1) || (columns > 4)) - fail(ctx, "Vector must have between 1 and 4 elements"); - - retval->type = MOJOSHADER_AST_DATATYPE_VECTOR; - retval->vector.base = dt; - retval->vector.elements = columns; - return retval; -} // new_datatype_vector - -static const MOJOSHADER_astDataType *new_datatype_matrix(Context *ctx, - const MOJOSHADER_astDataType *dt, - const int rows, const int columns) -{ - MOJOSHADER_astDataType *retval; - // !!! FIXME: allocate enough for a matrix, but we need to cleanup things that copy without checking for subsize. - retval = (MOJOSHADER_astDataType *) Malloc(ctx, sizeof (*retval)); - if (retval == NULL) - return NULL; - - // !!! FIXME: this is hacky. - // !!! FIXME: I'd like to cache these anyhow and reuse types. - if (!buffer_append(ctx->garbage, &retval, sizeof (retval))) - { - Free(ctx, retval); - return NULL; - } // if - - if ((rows < 1) || (rows > 4)) - fail(ctx, "Matrix must have between 1 and 4 rows"); - if ((columns < 1) || (columns > 4)) - fail(ctx, "Matrix must have between 1 and 4 columns"); - - retval->type = MOJOSHADER_AST_DATATYPE_MATRIX; - retval->matrix.base = dt; - retval->matrix.rows = rows; - retval->matrix.columns = columns; - return retval; -} // new_datatype_matrix - - -// !!! FIXME: move this to mojoshader_ast.c -// !!! FIXME: new_* and delete_* should take an allocator, not a context. - -// These functions are mostly for construction and cleanup of nodes in the -// parse tree. Mostly this is simple allocation and initialization, so we -// can do as little in the lemon code as possible, and then sort it all out -// afterwards. - -#define NEW_AST_NODE(retval, cls, typ) \ - cls *retval = (cls *) Malloc(ctx, sizeof (cls)); \ - do { \ - if (retval == NULL) { return NULL; } \ - retval->ast.type = typ; \ - retval->ast.filename = ctx->sourcefile; \ - retval->ast.line = ctx->sourceline; \ - } while (0) - -#define DELETE_AST_NODE(cls) do { \ - if (!cls) return; \ -} while (0) - - -static void delete_compilation_unit(Context*, MOJOSHADER_astCompilationUnit*); -static void delete_statement(Context *ctx, MOJOSHADER_astStatement *stmt); - -static MOJOSHADER_astExpression *new_identifier_expr(Context *ctx, - const char *string) -{ - NEW_AST_NODE(retval, MOJOSHADER_astExpressionIdentifier, - MOJOSHADER_AST_OP_IDENTIFIER); - retval->datatype = NULL; - retval->identifier = string; // cached; don't copy string. - retval->index = 0; - return (MOJOSHADER_astExpression *) retval; -} // new_identifier_expr - -static MOJOSHADER_astExpression *new_callfunc_expr(Context *ctx, - const char *identifier, - MOJOSHADER_astArguments *args) -{ - NEW_AST_NODE(retval, MOJOSHADER_astExpressionCallFunction, - MOJOSHADER_AST_OP_CALLFUNC); - MOJOSHADER_astExpression *expr = new_identifier_expr(ctx, identifier); - retval->datatype = NULL; - retval->identifier = (MOJOSHADER_astExpressionIdentifier *) expr; - retval->args = args; - return (MOJOSHADER_astExpression *) retval; -} // new_callfunc_expr - -static MOJOSHADER_astExpression *new_constructor_expr(Context *ctx, - const MOJOSHADER_astDataType *dt, - MOJOSHADER_astArguments *args) -{ - NEW_AST_NODE(retval, MOJOSHADER_astExpressionConstructor, - MOJOSHADER_AST_OP_CONSTRUCTOR); - retval->datatype = dt; - retval->args = args; - return (MOJOSHADER_astExpression *) retval; -} // new_constructor_expr - -static MOJOSHADER_astExpression *new_cast_expr(Context *ctx, - const MOJOSHADER_astDataType *dt, - MOJOSHADER_astExpression *operand) -{ - NEW_AST_NODE(retval, MOJOSHADER_astExpressionCast, MOJOSHADER_AST_OP_CAST); - retval->datatype = dt; - retval->operand = operand; - return (MOJOSHADER_astExpression *) retval; -} // new_cast_expr - -static MOJOSHADER_astExpression *new_unary_expr(Context *ctx, - const MOJOSHADER_astNodeType op, - MOJOSHADER_astExpression *operand) -{ - NEW_AST_NODE(retval, MOJOSHADER_astExpressionUnary, op); - assert(operator_is_unary(op)); - retval->datatype = NULL; - retval->operand = operand; - return (MOJOSHADER_astExpression *) retval; -} // new_unary_expr - -static MOJOSHADER_astExpression *new_binary_expr(Context *ctx, - const MOJOSHADER_astNodeType op, - MOJOSHADER_astExpression *left, - MOJOSHADER_astExpression *right) -{ - NEW_AST_NODE(retval, MOJOSHADER_astExpressionBinary, op); - assert(operator_is_binary(op)); - retval->datatype = NULL; - retval->left = left; - retval->right = right; - return (MOJOSHADER_astExpression *) retval; -} // new_binary_expr - -static MOJOSHADER_astExpression *new_ternary_expr(Context *ctx, - const MOJOSHADER_astNodeType op, - MOJOSHADER_astExpression *left, - MOJOSHADER_astExpression *center, - MOJOSHADER_astExpression *right) -{ - NEW_AST_NODE(retval, MOJOSHADER_astExpressionTernary, op); - assert(operator_is_ternary(op)); - assert(op == MOJOSHADER_AST_OP_CONDITIONAL); - retval->datatype = &ctx->dt_bool; - retval->left = left; - retval->center = center; - retval->right = right; - return (MOJOSHADER_astExpression *) retval; -} // new_ternary_expr - -static MOJOSHADER_astExpression *new_deref_struct_expr(Context *ctx, - MOJOSHADER_astExpression *identifier, - const char *member) -{ - NEW_AST_NODE(retval, MOJOSHADER_astExpressionDerefStruct, - MOJOSHADER_AST_OP_DEREF_STRUCT); - retval->datatype = NULL; - retval->identifier = identifier; - retval->member = member; // cached; don't copy string. - retval->isswizzle = 0; // may change during semantic analysis. - retval->member_index = 0; // set during semantic analysis. - return (MOJOSHADER_astExpression *) retval; -} // new_deref_struct_expr - -static MOJOSHADER_astExpression *new_literal_int_expr(Context *ctx, - const int value) -{ - NEW_AST_NODE(retval, MOJOSHADER_astExpressionIntLiteral, - MOJOSHADER_AST_OP_INT_LITERAL); - retval->datatype = &ctx->dt_int; - retval->value = value; - return (MOJOSHADER_astExpression *) retval; -} // new_literal_int_expr - -static MOJOSHADER_astExpression *new_literal_float_expr(Context *ctx, - const double dbl) -{ - NEW_AST_NODE(retval, MOJOSHADER_astExpressionFloatLiteral, - MOJOSHADER_AST_OP_FLOAT_LITERAL); - retval->datatype = &ctx->dt_float; - retval->value = dbl; - return (MOJOSHADER_astExpression *) retval; -} // new_literal_float_expr - -static MOJOSHADER_astExpression *new_literal_string_expr(Context *ctx, - const char *string) -{ - NEW_AST_NODE(retval, MOJOSHADER_astExpressionStringLiteral, - MOJOSHADER_AST_OP_STRING_LITERAL); - retval->datatype = &ctx->dt_string; - retval->string = string; // cached; don't copy string. - return (MOJOSHADER_astExpression *) retval; -} // new_literal_string_expr - -static MOJOSHADER_astExpression *new_literal_boolean_expr(Context *ctx, - const int value) -{ - NEW_AST_NODE(retval, MOJOSHADER_astExpressionBooleanLiteral, - MOJOSHADER_AST_OP_BOOLEAN_LITERAL); - retval->datatype = &ctx->dt_bool; - retval->value = value; - return (MOJOSHADER_astExpression *) retval; -} // new_literal_boolean_expr - -static void delete_arguments(Context *ctx, MOJOSHADER_astArguments *args); - -static void delete_expr(Context *ctx, MOJOSHADER_astExpression *_expr) -{ - MOJOSHADER_astNode *expr = (MOJOSHADER_astNode *) _expr; - - DELETE_AST_NODE(expr); - - if (expr->ast.type == MOJOSHADER_AST_OP_CAST) - delete_expr(ctx, expr->cast.operand); - - else if (expr->ast.type == MOJOSHADER_AST_OP_CONSTRUCTOR) - delete_arguments(ctx, expr->constructor.args); - - else if (expr->ast.type == MOJOSHADER_AST_OP_DEREF_STRUCT) - delete_expr(ctx, expr->derefstruct.identifier); - - else if (operator_is_unary(expr->ast.type)) - delete_expr(ctx, expr->unary.operand); - - else if (operator_is_binary(expr->ast.type)) - { - delete_expr(ctx, expr->binary.left); - delete_expr(ctx, expr->binary.right); - } // else if - - else if (operator_is_ternary(expr->ast.type)) - { - delete_expr(ctx, expr->ternary.left); - delete_expr(ctx, expr->ternary.center); - delete_expr(ctx, expr->ternary.right); - } // else if - - else if (expr->ast.type == MOJOSHADER_AST_OP_CALLFUNC) - { - delete_expr(ctx, (MOJOSHADER_astExpression*)expr->callfunc.identifier); - delete_arguments(ctx, expr->callfunc.args); - } // else if - - // rest of operators don't have extra data to free. - - Free(ctx, expr); -} // delete_expr - -static MOJOSHADER_astArguments *new_argument(Context *ctx, - MOJOSHADER_astExpression *arg) -{ - NEW_AST_NODE(retval, MOJOSHADER_astArguments, MOJOSHADER_AST_ARGUMENTS); - retval->argument = arg; - retval->next = NULL; - return retval; -} // new_argument - -static void delete_arguments(Context *ctx, MOJOSHADER_astArguments *args) -{ - DELETE_AST_NODE(args); - delete_arguments(ctx, args->next); - delete_expr(ctx, args->argument); - Free(ctx, args); -} // delete_arguments - -static MOJOSHADER_astFunctionParameters *new_function_param(Context *ctx, - const MOJOSHADER_astInputModifier inputmod, - const MOJOSHADER_astDataType *dt, - const char *identifier, const char *semantic, - const MOJOSHADER_astInterpolationModifier interpmod, - MOJOSHADER_astExpression *initializer) -{ - NEW_AST_NODE(retval, MOJOSHADER_astFunctionParameters, - MOJOSHADER_AST_FUNCTION_PARAMS); - retval->datatype = dt; - retval->input_modifier = inputmod; - retval->identifier = identifier; - retval->semantic = semantic; - retval->interpolation_modifier = interpmod; - retval->initializer = initializer; - retval->next = NULL; - return retval; -} // new_function_param - -static void delete_function_params(Context *ctx, - MOJOSHADER_astFunctionParameters *params) -{ - DELETE_AST_NODE(params); - delete_function_params(ctx, params->next); - delete_expr(ctx, params->initializer); - Free(ctx, params); -} // delete_function_params - -static MOJOSHADER_astFunctionSignature *new_function_signature(Context *ctx, - const MOJOSHADER_astDataType *dt, - const char *identifier, - MOJOSHADER_astFunctionParameters *params) -{ - NEW_AST_NODE(retval, MOJOSHADER_astFunctionSignature, - MOJOSHADER_AST_FUNCTION_SIGNATURE); - retval->datatype = dt; - retval->identifier = identifier; - retval->params = params; - retval->storage_class = MOJOSHADER_AST_FNSTORECLS_NONE; - retval->semantic = NULL; - return retval; -} // new_function_signature - -static void delete_function_signature(Context *ctx, - MOJOSHADER_astFunctionSignature *sig) -{ - DELETE_AST_NODE(sig); - delete_function_params(ctx, sig->params); - Free(ctx, sig); -} // delete_function_signature - -static MOJOSHADER_astCompilationUnit *new_function(Context *ctx, - MOJOSHADER_astFunctionSignature *declaration, - MOJOSHADER_astStatement *definition) -{ - NEW_AST_NODE(retval, MOJOSHADER_astCompilationUnitFunction, - MOJOSHADER_AST_COMPUNIT_FUNCTION); - retval->next = NULL; - retval->declaration = declaration; - retval->definition = definition; - retval->index = 0; - return (MOJOSHADER_astCompilationUnit *) retval; -} // new_function - -static void delete_function(Context *ctx, - MOJOSHADER_astCompilationUnitFunction *unitfn) -{ - DELETE_AST_NODE(unitfn); - delete_compilation_unit(ctx, unitfn->next); - delete_function_signature(ctx, unitfn->declaration); - delete_statement(ctx, unitfn->definition); - Free(ctx, unitfn); -} // delete_function - -static MOJOSHADER_astScalarOrArray *new_scalar_or_array(Context *ctx, - const char *ident, const int isvec, - MOJOSHADER_astExpression *dim) -{ - NEW_AST_NODE(retval, MOJOSHADER_astScalarOrArray, - MOJOSHADER_AST_SCALAR_OR_ARRAY); - retval->identifier = ident; - retval->isarray = isvec; - retval->dimension = dim; - return retval; -} // new_scalar_or_array - -static void delete_scalar_or_array(Context *ctx,MOJOSHADER_astScalarOrArray *s) -{ - DELETE_AST_NODE(s); - delete_expr(ctx, s->dimension); - Free(ctx, s); -} // delete_scalar_or_array - -static MOJOSHADER_astTypedef *new_typedef(Context *ctx, const int isconst, - const MOJOSHADER_astDataType *dt, - MOJOSHADER_astScalarOrArray *soa) -{ - // we correct this datatype to the final version during semantic analysis. - NEW_AST_NODE(retval, MOJOSHADER_astTypedef, MOJOSHADER_AST_TYPEDEF); - retval->datatype = dt; - retval->isconst = isconst; - retval->details = soa; - return retval; -} // new_typedef - -static void delete_typedef(Context *ctx, MOJOSHADER_astTypedef *td) -{ - DELETE_AST_NODE(td); - delete_scalar_or_array(ctx, td->details); - Free(ctx, td); -} // delete_typedef - -static MOJOSHADER_astPackOffset *new_pack_offset(Context *ctx, - const char *a, const char *b) -{ - NEW_AST_NODE(retval, MOJOSHADER_astPackOffset, MOJOSHADER_AST_PACK_OFFSET); - retval->ident1 = a; - retval->ident2 = b; - return retval; -} // new_pack_offset - -static void delete_pack_offset(Context *ctx, MOJOSHADER_astPackOffset *o) -{ - DELETE_AST_NODE(o); - Free(ctx, o); -} // delete_pack_offset - -static MOJOSHADER_astVariableLowLevel *new_variable_lowlevel(Context *ctx, - MOJOSHADER_astPackOffset *po, - const char *reg) -{ - NEW_AST_NODE(retval, MOJOSHADER_astVariableLowLevel, - MOJOSHADER_AST_VARIABLE_LOWLEVEL); - retval->packoffset = po; - retval->register_name = reg; - return retval; -} // new_variable_lowlevel - -static void delete_variable_lowlevel(Context *ctx, - MOJOSHADER_astVariableLowLevel *vll) -{ - DELETE_AST_NODE(vll); - delete_pack_offset(ctx, vll->packoffset); - Free(ctx, vll); -} // delete_variable_lowlevel - -static MOJOSHADER_astAnnotations *new_annotation(Context *ctx, - const MOJOSHADER_astDataType *dt, - MOJOSHADER_astExpression *initializer) -{ - NEW_AST_NODE(retval, MOJOSHADER_astAnnotations, MOJOSHADER_AST_ANNOTATION); - retval->datatype = dt; - retval->initializer = initializer; - retval->next = NULL; - return retval; -} // new_annotation - -static void delete_annotation(Context *ctx, MOJOSHADER_astAnnotations *annos) -{ - DELETE_AST_NODE(annos); - delete_annotation(ctx, annos->next); - delete_expr(ctx, annos->initializer); - Free(ctx, annos); -} // delete_annotation - -static MOJOSHADER_astVariableDeclaration *new_variable_declaration( - Context *ctx, MOJOSHADER_astScalarOrArray *soa, - const char *semantic, - MOJOSHADER_astAnnotations *annotations, - MOJOSHADER_astExpression *init, - MOJOSHADER_astVariableLowLevel *vll) -{ - NEW_AST_NODE(retval, MOJOSHADER_astVariableDeclaration, - MOJOSHADER_AST_VARIABLE_DECLARATION); - retval->datatype = NULL; - retval->attributes = 0; - retval->anonymous_datatype = NULL; - retval->details = soa; - retval->semantic = semantic; - retval->annotations = annotations; - retval->initializer = init; - retval->lowlevel = vll; - retval->next = NULL; - return retval; -} // new_variable_declaration - -static void delete_variable_declaration(Context *ctx, - MOJOSHADER_astVariableDeclaration *dcl) -{ - DELETE_AST_NODE(dcl); - delete_variable_declaration(ctx, dcl->next); - delete_scalar_or_array(ctx, dcl->details); - delete_annotation(ctx, dcl->annotations); - delete_expr(ctx, dcl->initializer); - delete_variable_lowlevel(ctx, dcl->lowlevel); - Free(ctx, dcl); -} // delete_variable_declaration - -static MOJOSHADER_astCompilationUnit *new_global_variable(Context *ctx, - MOJOSHADER_astVariableDeclaration *decl) -{ - NEW_AST_NODE(retval, MOJOSHADER_astCompilationUnitVariable, - MOJOSHADER_AST_COMPUNIT_VARIABLE); - retval->next = NULL; - retval->declaration = decl; - return (MOJOSHADER_astCompilationUnit *) retval; -} // new_global_variable - -static void delete_global_variable(Context *ctx, - MOJOSHADER_astCompilationUnitVariable *var) -{ - DELETE_AST_NODE(var); - delete_compilation_unit(ctx, var->next); - delete_variable_declaration(ctx, var->declaration); - Free(ctx, var); -} // delete_global_variable - -static MOJOSHADER_astCompilationUnit *new_global_typedef(Context *ctx, - MOJOSHADER_astTypedef *td) -{ - NEW_AST_NODE(retval, MOJOSHADER_astCompilationUnitTypedef, - MOJOSHADER_AST_COMPUNIT_TYPEDEF); - retval->next = NULL; - retval->type_info = td; - return (MOJOSHADER_astCompilationUnit *) retval; -} // new_global_typedef - -static void delete_global_typedef(Context *ctx, - MOJOSHADER_astCompilationUnitTypedef *unit) -{ - DELETE_AST_NODE(unit); - delete_compilation_unit(ctx, unit->next); - delete_typedef(ctx, unit->type_info); - Free(ctx, unit); -} // delete_global_typedef - -static MOJOSHADER_astStructMembers *new_struct_member(Context *ctx, - MOJOSHADER_astScalarOrArray *soa, - const char *semantic) -{ - NEW_AST_NODE(retval, MOJOSHADER_astStructMembers, - MOJOSHADER_AST_STRUCT_MEMBER); - retval->datatype = NULL; - retval->semantic = semantic; - retval->details = soa; - retval->interpolation_mod = MOJOSHADER_AST_INTERPMOD_NONE; - retval->next = NULL; - return retval; -} // new_struct_member - -static void delete_struct_member(Context *ctx, - MOJOSHADER_astStructMembers *member) -{ - DELETE_AST_NODE(member); - delete_struct_member(ctx, member->next); - delete_scalar_or_array(ctx, member->details); - Free(ctx, member); -} // delete_struct_member - -static MOJOSHADER_astStructDeclaration *new_struct_declaration(Context *ctx, - const char *name, - MOJOSHADER_astStructMembers *members) -{ - NEW_AST_NODE(retval, MOJOSHADER_astStructDeclaration, - MOJOSHADER_AST_STRUCT_DECLARATION); - retval->datatype = NULL; - retval->name = name; - retval->members = members; - return retval; -} // new_struct_declaration - -static void delete_struct_declaration(Context *ctx, - MOJOSHADER_astStructDeclaration *decl) -{ - DELETE_AST_NODE(decl); - delete_struct_member(ctx, decl->members); - Free(ctx, decl); -} // delete_struct_declaration - -static MOJOSHADER_astCompilationUnit *new_global_struct(Context *ctx, - MOJOSHADER_astStructDeclaration *sd) -{ - NEW_AST_NODE(retval, MOJOSHADER_astCompilationUnitStruct, - MOJOSHADER_AST_COMPUNIT_STRUCT); - retval->next = NULL; - retval->struct_info = sd; - return (MOJOSHADER_astCompilationUnit *) retval; -} // new_global_struct - -static void delete_global_struct(Context *ctx, - MOJOSHADER_astCompilationUnitStruct *unit) -{ - DELETE_AST_NODE(unit); - delete_compilation_unit(ctx, unit->next); - delete_struct_declaration(ctx, unit->struct_info); - Free(ctx, unit); -} // delete_global_struct - -static void delete_compilation_unit(Context *ctx, - MOJOSHADER_astCompilationUnit *unit) -{ - if (!unit) return; - - // it's important to not recurse too deeply here, since you may have - // thousands of items in this linked list (each line of a massive - // function, for example). To avoid this, we iterate the list here, - // deleting all children and making them think they have no reason - // to recurse in their own delete methods. - // Please note that everyone should _try_ to delete their "next" member, - // just in case, but hopefully this cleaned it out. - - MOJOSHADER_astCompilationUnit *i = unit->next; - unit->next = NULL; - while (i) - { - MOJOSHADER_astCompilationUnit *next = i->next; - i->next = NULL; - delete_compilation_unit(ctx, i); - i = next; - } // while - - switch (unit->ast.type) - { - #define DELETE_UNIT(typ, cls, fn) \ - case MOJOSHADER_AST_COMPUNIT_##typ: delete_##fn(ctx, (cls *) unit); break; - DELETE_UNIT(FUNCTION, MOJOSHADER_astCompilationUnitFunction, function); - DELETE_UNIT(TYPEDEF, MOJOSHADER_astCompilationUnitTypedef, global_typedef); - DELETE_UNIT(VARIABLE, MOJOSHADER_astCompilationUnitVariable, global_variable); - DELETE_UNIT(STRUCT, MOJOSHADER_astCompilationUnitStruct, global_struct); - #undef DELETE_UNIT - default: assert(0 && "missing cleanup code"); break; - } // switch - - // don't free (unit) here, the class-specific functions do it. -} // delete_compilation_unit - -static MOJOSHADER_astStatement *new_typedef_statement(Context *ctx, - MOJOSHADER_astTypedef *td) -{ - NEW_AST_NODE(retval, MOJOSHADER_astTypedefStatement, - MOJOSHADER_AST_STATEMENT_TYPEDEF); - retval->next = NULL; - retval->type_info = td; - return (MOJOSHADER_astStatement *) retval; -} // new_typedef_statement - -static void delete_typedef_statement(Context *ctx, - MOJOSHADER_astTypedefStatement *stmt) -{ - DELETE_AST_NODE(stmt); - delete_statement(ctx, stmt->next); - delete_typedef(ctx, stmt->type_info); - Free(ctx, stmt); -} // delete_typedef_statement - -static MOJOSHADER_astStatement *new_return_statement(Context *ctx, - MOJOSHADER_astExpression *expr) -{ - NEW_AST_NODE(retval, MOJOSHADER_astReturnStatement, - MOJOSHADER_AST_STATEMENT_RETURN); - retval->next = NULL; - retval->expr = expr; - return (MOJOSHADER_astStatement *) retval; -} // new_return_statement - -static void delete_return_statement(Context *ctx, - MOJOSHADER_astReturnStatement *stmt) -{ - DELETE_AST_NODE(stmt); - delete_statement(ctx, stmt->next); - delete_expr(ctx, stmt->expr); - Free(ctx, stmt); -} // delete_return_statement - -static MOJOSHADER_astStatement *new_block_statement(Context *ctx, - MOJOSHADER_astStatement *stmts) -{ - NEW_AST_NODE(retval, MOJOSHADER_astBlockStatement, - MOJOSHADER_AST_STATEMENT_BLOCK); - retval->next = NULL; - retval->statements = stmts; - return (MOJOSHADER_astStatement *) retval; -} // new_block_statement - -static void delete_block_statement(Context *ctx, - MOJOSHADER_astBlockStatement *stmt) -{ - DELETE_AST_NODE(stmt); - delete_statement(ctx, stmt->statements); - delete_statement(ctx, stmt->next); - Free(ctx, stmt); -} // delete_statement_block - -static MOJOSHADER_astStatement *new_for_statement(Context *ctx, - MOJOSHADER_astVariableDeclaration *decl, - MOJOSHADER_astExpression *initializer, - MOJOSHADER_astExpression *looptest, - MOJOSHADER_astExpression *counter, - MOJOSHADER_astStatement *statement) -{ - NEW_AST_NODE(retval, MOJOSHADER_astForStatement, - MOJOSHADER_AST_STATEMENT_FOR); - retval->next = NULL; - retval->unroll = -1; - retval->var_decl = decl; - retval->initializer = initializer; - retval->looptest = looptest; - retval->counter = counter; - retval->statement = statement; - return (MOJOSHADER_astStatement *) retval; -} // new_for_statement - -static void delete_for_statement(Context *ctx,MOJOSHADER_astForStatement *stmt) -{ - DELETE_AST_NODE(stmt); - delete_statement(ctx, stmt->next); - delete_variable_declaration(ctx, stmt->var_decl); - delete_expr(ctx, stmt->initializer); - delete_expr(ctx, stmt->looptest); - delete_expr(ctx, stmt->counter); - delete_statement(ctx, stmt->statement); - Free(ctx, stmt); -} // delete_for_statement - -static MOJOSHADER_astStatement *new_do_statement(Context *ctx, - const int unroll, - MOJOSHADER_astStatement *stmt, - MOJOSHADER_astExpression *expr) -{ - NEW_AST_NODE(retval,MOJOSHADER_astDoStatement,MOJOSHADER_AST_STATEMENT_DO); - retval->next = NULL; - retval->unroll = unroll; - retval->expr = expr; - retval->statement = stmt; - return (MOJOSHADER_astStatement *) retval; -} // new_do_statement - -static void delete_do_statement(Context *ctx, MOJOSHADER_astDoStatement *stmt) -{ - DELETE_AST_NODE(stmt); - delete_statement(ctx, stmt->next); - delete_statement(ctx, stmt->statement); - delete_expr(ctx, stmt->expr); - Free(ctx, stmt); -} // delete_do_statement - -static MOJOSHADER_astStatement *new_while_statement(Context *ctx, - const int unroll, - MOJOSHADER_astExpression *expr, - MOJOSHADER_astStatement *stmt) -{ - NEW_AST_NODE(retval, MOJOSHADER_astWhileStatement, - MOJOSHADER_AST_STATEMENT_WHILE); - retval->next = NULL; - retval->unroll = unroll; - retval->expr = expr; - retval->statement = stmt; - return (MOJOSHADER_astStatement *) retval; -} // new_while_statement - -static void delete_while_statement(Context *ctx, - MOJOSHADER_astWhileStatement *stmt) -{ - DELETE_AST_NODE(stmt); - delete_statement(ctx, stmt->next); - delete_statement(ctx, stmt->statement); - delete_expr(ctx, stmt->expr); - Free(ctx, stmt); -} // delete_while_statement - -static MOJOSHADER_astStatement *new_if_statement(Context *ctx, - const int attr, - MOJOSHADER_astExpression *expr, - MOJOSHADER_astStatement *stmt, - MOJOSHADER_astStatement *elsestmt) -{ - NEW_AST_NODE(retval,MOJOSHADER_astIfStatement,MOJOSHADER_AST_STATEMENT_IF); - retval->next = NULL; - retval->attributes = attr; - retval->expr = expr; - retval->statement = stmt; - retval->else_statement = elsestmt; - return (MOJOSHADER_astStatement *) retval; -} // new_if_statement - -static void delete_if_statement(Context *ctx, MOJOSHADER_astIfStatement *stmt) -{ - DELETE_AST_NODE(stmt); - delete_statement(ctx, stmt->next); - delete_expr(ctx, stmt->expr); - delete_statement(ctx, stmt->statement); - delete_statement(ctx, stmt->else_statement); - Free(ctx, stmt); -} // delete_if_statement - -static MOJOSHADER_astSwitchCases *new_switch_case(Context *ctx, - MOJOSHADER_astExpression *expr, - MOJOSHADER_astStatement *stmt) -{ - NEW_AST_NODE(retval, MOJOSHADER_astSwitchCases, MOJOSHADER_AST_SWITCH_CASE); - retval->expr = expr; - retval->statement = stmt; - retval->next = NULL; - return retval; -} // new_switch_case - -static void delete_switch_case(Context *ctx, MOJOSHADER_astSwitchCases *sc) -{ - DELETE_AST_NODE(sc); - delete_switch_case(ctx, sc->next); - delete_expr(ctx, sc->expr); - delete_statement(ctx, sc->statement); - Free(ctx, sc); -} // delete_switch_case - -static MOJOSHADER_astStatement *new_empty_statement(Context *ctx) -{ - NEW_AST_NODE(retval, MOJOSHADER_astEmptyStatement, - MOJOSHADER_AST_STATEMENT_EMPTY); - retval->next = NULL; - return (MOJOSHADER_astStatement *) retval; -} // new_empty_statement - -static void delete_empty_statement(Context *ctx, - MOJOSHADER_astEmptyStatement *stmt) -{ - DELETE_AST_NODE(stmt); - delete_statement(ctx, stmt->next); - Free(ctx, stmt); -} // delete_empty_statement - -static MOJOSHADER_astStatement *new_break_statement(Context *ctx) -{ - NEW_AST_NODE(retval, MOJOSHADER_astBreakStatement, - MOJOSHADER_AST_STATEMENT_BREAK); - retval->next = NULL; - return (MOJOSHADER_astStatement *) retval; -} // new_break_statement - -static void delete_break_statement(Context *ctx, - MOJOSHADER_astBreakStatement *stmt) -{ - DELETE_AST_NODE(stmt); - delete_statement(ctx, stmt->next); - Free(ctx, stmt); -} // delete_break_statement - -static MOJOSHADER_astStatement *new_continue_statement(Context *ctx) -{ - NEW_AST_NODE(retval, MOJOSHADER_astContinueStatement, - MOJOSHADER_AST_STATEMENT_CONTINUE); - retval->next = NULL; - return (MOJOSHADER_astStatement *) retval; -} // new_continue_statement - -static void delete_continue_statement(Context *ctx, - MOJOSHADER_astContinueStatement *stmt) -{ - DELETE_AST_NODE(stmt); - delete_statement(ctx, stmt->next); - Free(ctx, stmt); -} // delete_continue_statement - -static MOJOSHADER_astStatement *new_discard_statement(Context *ctx) -{ - NEW_AST_NODE(retval, MOJOSHADER_astDiscardStatement, - MOJOSHADER_AST_STATEMENT_DISCARD); - retval->next = NULL; - return (MOJOSHADER_astStatement *) retval; -} // new_discard_statement - -static void delete_discard_statement(Context *ctx, - MOJOSHADER_astDiscardStatement *stmt) -{ - DELETE_AST_NODE(stmt); - delete_statement(ctx, stmt->next); - Free(ctx, stmt); -} // delete_discard_statement - -static MOJOSHADER_astStatement *new_expr_statement(Context *ctx, - MOJOSHADER_astExpression *expr) -{ - NEW_AST_NODE(retval, MOJOSHADER_astExpressionStatement, - MOJOSHADER_AST_STATEMENT_EXPRESSION); - retval->next = NULL; - retval->expr = expr; - return (MOJOSHADER_astStatement *) retval; -} // new_expr_statement - -static void delete_expr_statement(Context *ctx, - MOJOSHADER_astExpressionStatement *stmt) -{ - DELETE_AST_NODE(stmt); - delete_statement(ctx, stmt->next); - delete_expr(ctx, stmt->expr); - Free(ctx, stmt); -} // delete_expr_statement - -static MOJOSHADER_astStatement *new_switch_statement(Context *ctx, - const int attr, - MOJOSHADER_astExpression *expr, - MOJOSHADER_astSwitchCases *cases) -{ - NEW_AST_NODE(retval, MOJOSHADER_astSwitchStatement, - MOJOSHADER_AST_STATEMENT_SWITCH); - retval->next = NULL; - retval->attributes = attr; - retval->expr = expr; - retval->cases = cases; - return (MOJOSHADER_astStatement *) retval; -} // new_switch_statement - -static void delete_switch_statement(Context *ctx, - MOJOSHADER_astSwitchStatement *stmt) -{ - DELETE_AST_NODE(stmt); - delete_expr(ctx, stmt->expr); - delete_switch_case(ctx, stmt->cases); - Free(ctx, stmt); -} // delete_switch_statement - -static MOJOSHADER_astStatement *new_struct_statement(Context *ctx, - MOJOSHADER_astStructDeclaration *sd) -{ - NEW_AST_NODE(retval, MOJOSHADER_astStructStatement, - MOJOSHADER_AST_STATEMENT_STRUCT); - retval->next = NULL; - retval->struct_info = sd; - return (MOJOSHADER_astStatement *) retval; -} // new_struct_statement - -static void delete_struct_statement(Context *ctx, - MOJOSHADER_astStructStatement *stmt) -{ - DELETE_AST_NODE(stmt); - delete_statement(ctx, stmt->next); - delete_struct_declaration(ctx, stmt->struct_info); - Free(ctx, stmt); -} // delete_struct_statement - -static MOJOSHADER_astStatement *new_vardecl_statement(Context *ctx, - MOJOSHADER_astVariableDeclaration *vd) -{ - NEW_AST_NODE(retval, MOJOSHADER_astVarDeclStatement, - MOJOSHADER_AST_STATEMENT_VARDECL); - retval->next = NULL; - retval->declaration = vd; - return (MOJOSHADER_astStatement *) retval; -} // new_vardecl_statement - -static void delete_vardecl_statement(Context *ctx, - MOJOSHADER_astVarDeclStatement *stmt) -{ - DELETE_AST_NODE(stmt); - delete_statement(ctx, stmt->next); - delete_variable_declaration(ctx, stmt->declaration); - Free(ctx, stmt); -} // delete_vardecl_statement - -static void delete_statement(Context *ctx, MOJOSHADER_astStatement *stmt) -{ - if (!stmt) return; - - // it's important to not recurse too deeply here, since you may have - // thousands of items in this linked list (each line of a massive - // function, for example). To avoid this, we iterate the list here, - // deleting all children and making them think they have no reason - // to recurse in their own delete methods. - // Please note that everyone should _try_ to delete their "next" member, - // just in case, but hopefully this cleaned it out. - - MOJOSHADER_astStatement *i = stmt->next; - stmt->next = NULL; - while (i) - { - MOJOSHADER_astStatement *next = i->next; - i->next = NULL; - delete_statement(ctx, i); - i = next; - } // while - - switch (stmt->ast.type) - { - #define DELETE_STATEMENT(typ, cls, fn) \ - case MOJOSHADER_AST_STATEMENT_##typ: \ - delete_##fn##_statement(ctx, (cls *) stmt); break; - DELETE_STATEMENT(BLOCK, MOJOSHADER_astBlockStatement, block); - DELETE_STATEMENT(EMPTY, MOJOSHADER_astEmptyStatement, empty); - DELETE_STATEMENT(IF, MOJOSHADER_astIfStatement, if); - DELETE_STATEMENT(SWITCH, MOJOSHADER_astSwitchStatement, switch); - DELETE_STATEMENT(EXPRESSION, MOJOSHADER_astExpressionStatement, expr); - DELETE_STATEMENT(FOR, MOJOSHADER_astForStatement, for); - DELETE_STATEMENT(DO, MOJOSHADER_astDoStatement, do); - DELETE_STATEMENT(WHILE, MOJOSHADER_astWhileStatement, while); - DELETE_STATEMENT(RETURN, MOJOSHADER_astReturnStatement, return); - DELETE_STATEMENT(BREAK, MOJOSHADER_astBreakStatement, break); - DELETE_STATEMENT(CONTINUE, MOJOSHADER_astContinueStatement, continue); - DELETE_STATEMENT(DISCARD, MOJOSHADER_astDiscardStatement, discard); - DELETE_STATEMENT(TYPEDEF, MOJOSHADER_astTypedefStatement, typedef); - DELETE_STATEMENT(STRUCT, MOJOSHADER_astStructStatement, struct); - DELETE_STATEMENT(VARDECL, MOJOSHADER_astVarDeclStatement, vardecl); - #undef DELETE_STATEMENT - default: assert(0 && "missing cleanup code"); break; - } // switch - // don't free (stmt) here, the class-specific functions do it. -} // delete_statement - - -static const MOJOSHADER_astDataType *get_usertype(const Context *ctx, - const char *token) -{ - const void *value; // search all scopes. - if (!hash_find(ctx->usertypes.hash, token, &value)) - return NULL; - return value ? ((SymbolScope *) value)->datatype : NULL; -} // get_usertype - - -// This is where the actual parsing happens. It's Lemon-generated! -#define __MOJOSHADER_HLSL_COMPILER__ 1 -#include "mojoshader_parser_hlsl.h" - - -#if 0 -static int expr_is_constant(MOJOSHADER_astExpression *expr) -{ - const MOJOSHADER_astNodeType op = expr->ast.type; - if (operator_is_unary(op)) - return expr_is_constant(expr->unary.operand); - else if (operator_is_binary(op)) - { - return ( expr_is_constant(expr->binary.left) && - expr_is_constant(expr->binary.right) ); - } // else if - else if (operator_is_ternary(op)) - { - return ( expr_is_constant(expr->ternary.left) && - expr_is_constant(expr->ternary.center) && - expr_is_constant(expr->ternary.right) ); - } // else if - - return ( (op == MOJOSHADER_AST_OP_INT_LITERAL) || - (op == MOJOSHADER_AST_OP_FLOAT_LITERAL) || - (op == MOJOSHADER_AST_OP_STRING_LITERAL) || - (op == MOJOSHADER_AST_OP_BOOLEAN_LITERAL) ); -} // expr_is_constant -#endif - -typedef struct AstCalcData -{ - int isflt; - union - { - double f; - int64 i; - } value; -} AstCalcData; - -// returns 0 if this expression is non-constant, 1 if it is. -// calculation results land in (data). -static int calc_ast_const_expr(Context *ctx, void *_expr, AstCalcData *data) -{ - const MOJOSHADER_astNode *expr = (MOJOSHADER_astNode *) _expr; - const MOJOSHADER_astNodeType op = expr->ast.type; - - ctx->sourcefile = expr->ast.filename; - ctx->sourceline = expr->ast.line; - - if (operator_is_unary(op)) - { - if (!calc_ast_const_expr(ctx, expr->unary.operand, data)) - return 0; - - if (data->isflt) - { - switch (op) - { - case MOJOSHADER_AST_OP_NEGATE: - data->value.f = -data->value.f; - return 1; - case MOJOSHADER_AST_OP_NOT: - data->value.f = !data->value.f; - return 1; - case MOJOSHADER_AST_OP_COMPLEMENT: - fail(ctx, "integer operation on floating point value"); - return 0; - case MOJOSHADER_AST_OP_CAST: - // !!! FIXME: this should work, but it's complicated. - assert(0 && "write me"); - return 0; - default: break; - } // switch - } // if - - else // integer version - { - switch (op) - { - case MOJOSHADER_AST_OP_NEGATE: - data->value.i = -data->value.i; - return 1; - case MOJOSHADER_AST_OP_NOT: - data->value.i = !data->value.i; - return 1; - case MOJOSHADER_AST_OP_COMPLEMENT: - data->value.i = ~data->value.i; - return 1; - case MOJOSHADER_AST_OP_CAST: - // !!! FIXME: this should work, but it's complicated. - assert(0 && "write me"); - return 0; - default: break; - } // switch - } // else - assert(0 && "unhandled operation?"); - return 0; - } // if - - else if (operator_is_binary(op)) - { - AstCalcData subdata2; - if ( (!calc_ast_const_expr(ctx, expr->binary.left, data)) || - (!calc_ast_const_expr(ctx, expr->binary.right, &subdata2)) ) - return 0; - - // upgrade to float if either operand is float. - if ((data->isflt) || (subdata2.isflt)) - { - if (!data->isflt) data->value.f = (double) data->value.i; - if (!subdata2.isflt) subdata2.value.f = (double) subdata2.value.i; - data->isflt = subdata2.isflt = 1; - } // if - - switch (op) - { - // gcc doesn't handle commas here, either (fails to parse!). - case MOJOSHADER_AST_OP_COMMA: - case MOJOSHADER_AST_OP_ASSIGN: - case MOJOSHADER_AST_OP_MULASSIGN: - case MOJOSHADER_AST_OP_DIVASSIGN: - case MOJOSHADER_AST_OP_MODASSIGN: - case MOJOSHADER_AST_OP_ADDASSIGN: - case MOJOSHADER_AST_OP_SUBASSIGN: - case MOJOSHADER_AST_OP_LSHIFTASSIGN: - case MOJOSHADER_AST_OP_RSHIFTASSIGN: - case MOJOSHADER_AST_OP_ANDASSIGN: - case MOJOSHADER_AST_OP_XORASSIGN: - case MOJOSHADER_AST_OP_ORASSIGN: - return 0; // assignment is non-constant. - default: break; - } // switch - - if (data->isflt) - { - switch (op) - { - case MOJOSHADER_AST_OP_MULTIPLY: - data->value.f *= subdata2.value.f; - return 1; - case MOJOSHADER_AST_OP_DIVIDE: - data->value.f /= subdata2.value.f; - return 1; - case MOJOSHADER_AST_OP_ADD: - data->value.f += subdata2.value.f; - return 1; - case MOJOSHADER_AST_OP_SUBTRACT: - data->value.f -= subdata2.value.f; - return 1; - case MOJOSHADER_AST_OP_LESSTHAN: - data->isflt = 0; - data->value.i = data->value.f < subdata2.value.f; - return 1; - case MOJOSHADER_AST_OP_GREATERTHAN: - data->isflt = 0; - data->value.i = data->value.f > subdata2.value.f; - return 1; - case MOJOSHADER_AST_OP_LESSTHANOREQUAL: - data->isflt = 0; - data->value.i = data->value.f <= subdata2.value.f; - return 1; - case MOJOSHADER_AST_OP_GREATERTHANOREQUAL: - data->isflt = 0; - data->value.i = data->value.f >= subdata2.value.f; - return 1; - case MOJOSHADER_AST_OP_EQUAL: - data->isflt = 0; - data->value.i = data->value.f == subdata2.value.f; - return 1; - case MOJOSHADER_AST_OP_NOTEQUAL: - data->isflt = 0; - data->value.i = data->value.f != subdata2.value.f; - return 1; - case MOJOSHADER_AST_OP_LOGICALAND: - data->isflt = 0; - data->value.i = data->value.f && subdata2.value.f; - return 1; - case MOJOSHADER_AST_OP_LOGICALOR: - data->isflt = 0; - data->value.i = data->value.f || subdata2.value.f; - return 1; - - case MOJOSHADER_AST_OP_LSHIFT: - case MOJOSHADER_AST_OP_RSHIFT: - case MOJOSHADER_AST_OP_MODULO: - case MOJOSHADER_AST_OP_BINARYAND: - case MOJOSHADER_AST_OP_BINARYXOR: - case MOJOSHADER_AST_OP_BINARYOR: - fail(ctx, "integer operation on floating point value"); - return 0; - default: break; - } // switch - } // if - - else // integer version. - { - switch (op) - { - case MOJOSHADER_AST_OP_MULTIPLY: - data->value.i *= subdata2.value.i; - return 1; - case MOJOSHADER_AST_OP_DIVIDE: - data->value.i /= subdata2.value.i; - return 1; - case MOJOSHADER_AST_OP_ADD: - data->value.i += subdata2.value.i; - return 1; - case MOJOSHADER_AST_OP_SUBTRACT: - data->value.i -= subdata2.value.i; - return 1; - case MOJOSHADER_AST_OP_LESSTHAN: - data->value.i = data->value.i < subdata2.value.i; - return 1; - case MOJOSHADER_AST_OP_GREATERTHAN: - data->value.i = data->value.i > subdata2.value.i; - return 1; - case MOJOSHADER_AST_OP_LESSTHANOREQUAL: - data->value.i = data->value.i <= subdata2.value.i; - return 1; - case MOJOSHADER_AST_OP_GREATERTHANOREQUAL: - data->value.i = data->value.i >= subdata2.value.i; - return 1; - case MOJOSHADER_AST_OP_EQUAL: - data->value.i = data->value.i == subdata2.value.i; - return 1; - case MOJOSHADER_AST_OP_NOTEQUAL: - data->value.i = data->value.i != subdata2.value.i; - return 1; - case MOJOSHADER_AST_OP_LOGICALAND: - data->value.i = data->value.i && subdata2.value.i; - return 1; - case MOJOSHADER_AST_OP_LOGICALOR: - data->value.i = data->value.i || subdata2.value.i; - return 1; - case MOJOSHADER_AST_OP_LSHIFT: - data->value.i = data->value.i << subdata2.value.i; - return 1; - case MOJOSHADER_AST_OP_RSHIFT: - data->value.i = data->value.i >> subdata2.value.i; - return 1; - case MOJOSHADER_AST_OP_MODULO: - data->value.i = data->value.i % subdata2.value.i; - return 1; - case MOJOSHADER_AST_OP_BINARYAND: - data->value.i = data->value.i & subdata2.value.i; - return 1; - case MOJOSHADER_AST_OP_BINARYXOR: - data->value.i = data->value.i ^ subdata2.value.i; - return 1; - case MOJOSHADER_AST_OP_BINARYOR: - data->value.i = data->value.i | subdata2.value.i; - return 1; - default: break; - } // switch - } // else - - assert(0 && "unhandled operation?"); - return 0; - } // else if - - else if (operator_is_ternary(op)) - { - AstCalcData subdata2; - AstCalcData subdata3; - - assert(op == MOJOSHADER_AST_OP_CONDITIONAL); // only one we have. - - if ( (!calc_ast_const_expr(ctx, expr->ternary.left, data)) || - (!calc_ast_const_expr(ctx, expr->ternary.center, &subdata2)) || - (!calc_ast_const_expr(ctx, expr->ternary.right, &subdata3)) ) - return 0; - - // first operand should be bool (for the one ternary operator we have). - if (data->isflt) - { - data->isflt = 0; - data->value.i = (int64) subdata3.value.f; - } // if - - // upgrade to float if either operand is float. - if ((subdata2.isflt) || (subdata3.isflt)) - { - if (!subdata2.isflt) subdata2.value.f = (double) subdata2.value.i; - if (!subdata3.isflt) subdata3.value.f = (double) subdata3.value.i; - subdata2.isflt = subdata3.isflt = 1; - } // if - - data->isflt = subdata2.isflt; - if (data->isflt) - data->value.f = data->value.i ? subdata2.value.f : subdata3.value.f; - else - data->value.i = data->value.i ? subdata2.value.i : subdata3.value.i; - return 1; - } // else if - - else // not an operator? See if this is a literal value. - { - switch (op) - { - case MOJOSHADER_AST_OP_INT_LITERAL: - data->isflt = 0; - data->value.i = expr->intliteral.value; - return 1; - - case MOJOSHADER_AST_OP_FLOAT_LITERAL: - data->isflt = 1; - data->value.f = expr->floatliteral.value; - return 1; - - case MOJOSHADER_AST_OP_BOOLEAN_LITERAL: - data->isflt = 0; - data->value.i = expr->boolliteral.value ? 1 : 0; - return 1; - - default: break; - } // switch - } // switch - - return 0; // not constant, or unhandled. -} // calc_ast_const_expr - - -static const MOJOSHADER_astDataType *reduce_datatype(Context *ctx, const MOJOSHADER_astDataType *dt) -{ - const MOJOSHADER_astDataType *retval = dt; - while (retval && retval->type == MOJOSHADER_AST_DATATYPE_USER) - { - // !!! FIXME: Ugh, const removal. - MOJOSHADER_astDataTypeUser *user = (MOJOSHADER_astDataTypeUser *) &retval->user; - if (user->details->type == MOJOSHADER_AST_DATATYPE_NONE) - { - // Take this opportunity to fix up some usertype stubs that were - // left over from the parse phase. You HAVE to catch these in the - // right scope, so be aggressive about calling reduce_datatype() - // as soon as things come into view! - user->details = get_usertype(ctx, user->name); - assert(user->details != NULL); - } // if - - retval = user->details; - } // while - - return retval; -} // reduce_datatype - - -static inline const MOJOSHADER_astDataType *sanitize_datatype(Context *ctx, const MOJOSHADER_astDataType *dt) -{ - reduce_datatype(ctx, dt); - return dt; -} // sanitize_datatype - - -static const MOJOSHADER_astDataType *build_function_datatype(Context *ctx, - const MOJOSHADER_astDataType *rettype, - const int paramcount, - const MOJOSHADER_astDataType **params, - const int intrinsic) -{ - if ( ((paramcount > 0) && (params == NULL)) || - ((paramcount == 0) && (params != NULL)) ) - return NULL; - - // !!! FIXME: this is hacky. - const MOJOSHADER_astDataType **dtparams; - void *ptr = Malloc(ctx, sizeof (*params) * paramcount); - if (ptr == NULL) - return NULL; - if (!buffer_append(ctx->garbage, &ptr, sizeof (ptr))) - { - Free(ctx, ptr); - return NULL; - } // if - dtparams = (const MOJOSHADER_astDataType **) ptr; - memcpy(dtparams, params, sizeof (*params) * paramcount); - - ptr = Malloc(ctx, sizeof (MOJOSHADER_astDataType)); - if (ptr == NULL) - return NULL; - if (!buffer_append(ctx->garbage, &ptr, sizeof (ptr))) - { - Free(ctx, ptr); - return NULL; - } // if - - MOJOSHADER_astDataType *dt = (MOJOSHADER_astDataType *) ptr; - dt->type = MOJOSHADER_AST_DATATYPE_FUNCTION; - dt->function.retval = rettype; - dt->function.params = dtparams; - dt->function.num_params = paramcount; - dt->function.intrinsic = intrinsic; - return dt; -} // build_function_datatype - - -static const MOJOSHADER_astDataType *build_datatype(Context *ctx, - const int isconst, - const MOJOSHADER_astDataType *dt, - MOJOSHADER_astScalarOrArray *soa) -{ - MOJOSHADER_astDataType *retval = NULL; - - assert( (soa->isarray && soa->dimension) || - (!soa->isarray && !soa->dimension) ); - - sanitize_datatype(ctx, dt); - - // see if we can just reuse the exist datatype. - if (!soa->isarray) - { - const int c1 = (dt->type & MOJOSHADER_AST_DATATYPE_CONST) != 0; - const int c2 = (isconst != 0); - if (c1 == c2) - return dt; // reuse existing datatype! - } // if - - retval = (MOJOSHADER_astDataType *) Malloc(ctx, sizeof (*retval)); - if (retval == NULL) - return NULL; - - // !!! FIXME: this is hacky. - if (!buffer_append(ctx->garbage, &retval, sizeof (retval))) - { - Free(ctx, retval); - return NULL; - } // if - - if (!soa->isarray) - { - assert(soa->dimension == NULL); - memcpy(retval, dt, sizeof (MOJOSHADER_astDataType)); - if (isconst) - retval->type |= MOJOSHADER_AST_DATATYPE_CONST; - else - retval->type &= ~MOJOSHADER_AST_DATATYPE_CONST; - return retval; - } // if - - retval->type = MOJOSHADER_AST_DATATYPE_ARRAY; - retval->array.base = dt; - if (soa->dimension == NULL) - { - retval->array.elements = -1; - return retval; - } // if - - // Run the expression to verify it's constant and produces a positive int. - AstCalcData data; - data.isflt = 0; - data.value.i = 0; - retval->array.elements = 16; // sane default for failure. - const int ok = calc_ast_const_expr(ctx, soa->dimension, &data); - - // reset error position. - ctx->sourcefile = soa->ast.filename; - ctx->sourceline = soa->ast.line; - - if (!ok) - fail(ctx, "array dimensions not constant"); - else if (data.isflt) - fail(ctx, "array dimensions not integer"); - else if (data.value.i < 0) - fail(ctx, "array dimensions negative"); - else - retval->array.elements = data.value.i; - - return retval; -} // build_datatype - - -static void require_numeric_datatype(Context *ctx, - const MOJOSHADER_astDataType *datatype) -{ - datatype = reduce_datatype(ctx, datatype); - if (datatype->type == MOJOSHADER_AST_DATATYPE_VECTOR) - datatype = reduce_datatype(ctx, datatype->vector.base); - else if (datatype->type == MOJOSHADER_AST_DATATYPE_MATRIX) - datatype = reduce_datatype(ctx, datatype->matrix.base); - - switch (datatype->type) - { - case MOJOSHADER_AST_DATATYPE_BOOL: - case MOJOSHADER_AST_DATATYPE_INT: - case MOJOSHADER_AST_DATATYPE_UINT: - case MOJOSHADER_AST_DATATYPE_HALF: - case MOJOSHADER_AST_DATATYPE_FLOAT: - case MOJOSHADER_AST_DATATYPE_DOUBLE: - return; - default: break; - } // switch - - fail(ctx, "Expected numeric type"); // !!! FIXME: fmt. - // !!! FIXME: replace AST node with an AST_OP_INT_LITERAL zero, keep going. -} // require_numeric_datatype - -static void require_integer_datatype(Context *ctx, - const MOJOSHADER_astDataType *datatype) -{ - datatype = reduce_datatype(ctx, datatype); - switch (datatype->type) - { - case MOJOSHADER_AST_DATATYPE_INT: - case MOJOSHADER_AST_DATATYPE_UINT: - return; - default: break; - } // switch - - fail(ctx, "Expected integer type"); // !!! FIXME: fmt. - // !!! FIXME: replace AST node with an AST_OP_INT_LITERAL zero, keep going. -} // require_integer_datatype - -static void require_boolean_datatype(Context *ctx, - const MOJOSHADER_astDataType *datatype) -{ - datatype = reduce_datatype(ctx, datatype); - switch (datatype->type) - { - case MOJOSHADER_AST_DATATYPE_BOOL: - case MOJOSHADER_AST_DATATYPE_INT: - case MOJOSHADER_AST_DATATYPE_UINT: - return; - default: break; - } // switch - - fail(ctx, "Expected boolean type"); // !!! FIXME: fmt. - // !!! FIXME: replace AST node with an AST_OP_BOOLEAN_LITERAL false, keep going. -} // require_numeric_datatype - - -static void require_array_datatype(Context *ctx, - const MOJOSHADER_astDataType *datatype) -{ - datatype = reduce_datatype(ctx, datatype); - if (datatype->type == MOJOSHADER_AST_DATATYPE_ARRAY) - return; - - fail(ctx, "expected array"); - // !!! FIXME: delete array dereference for further processing. -} // require_array_datatype - - -static void require_struct_datatype(Context *ctx, - const MOJOSHADER_astDataType *datatype) -{ - datatype = reduce_datatype(ctx, datatype); - if (datatype->type == MOJOSHADER_AST_DATATYPE_STRUCT) - return; - - fail(ctx, "expected struct"); - // !!! FIXME: delete struct dereference for further processing. -} // require_struct_datatype - - -static int require_function_datatype(Context *ctx, - const MOJOSHADER_astDataType *datatype) -{ - datatype = reduce_datatype(ctx, datatype); - if ((!datatype) || (datatype->type != MOJOSHADER_AST_DATATYPE_FUNCTION)) - { - fail(ctx, "expected function"); - return 0; - } // if - - return 1; -} // require_function_datatype - - -// Extract the individual element type from an array datatype. -static const MOJOSHADER_astDataType *array_element_datatype(Context *ctx, - const MOJOSHADER_astDataType *datatype) -{ - datatype = reduce_datatype(ctx, datatype); - assert(datatype->type == MOJOSHADER_AST_DATATYPE_ARRAY); - return datatype->array.base; -} // array_element_datatype - - -// This tests two datatypes to see if they are compatible, and adds cast -// operator nodes to the AST if the program was relying on implicit -// casts between then. Will fail() if the datatypes can't be coerced -// with a cast at all. (left) can be NULL to say that its datatype is -// set in stone (an lvalue, for example). No other NULLs are allowed. -// Returns final datatype used once implicit casting is complete. -// The datatypes must be pointers from the string cache. -static const MOJOSHADER_astDataType *add_type_coercion(Context *ctx, - MOJOSHADER_astExpression **left, - const MOJOSHADER_astDataType *_ldatatype, - MOJOSHADER_astExpression **right, - const MOJOSHADER_astDataType *_rdatatype) -{ - // !!! FIXME: this whole function is probably naive at best. - const MOJOSHADER_astDataType *ldatatype = reduce_datatype(ctx, _ldatatype); - const MOJOSHADER_astDataType *rdatatype = reduce_datatype(ctx, _rdatatype); - - if (ldatatype == rdatatype) - return ldatatype; // they already match, so we're done. - - struct { - const MOJOSHADER_astDataTypeType type; - const int bits; - const int is_unsigned; - const int floating; - } typeinf[] = { - { MOJOSHADER_AST_DATATYPE_BOOL, 1, 1, 0 }, - { MOJOSHADER_AST_DATATYPE_HALF, 16, 0, 1 }, - { MOJOSHADER_AST_DATATYPE_INT, 32, 0, 0 }, - { MOJOSHADER_AST_DATATYPE_UINT, 32, 1, 0 }, - { MOJOSHADER_AST_DATATYPE_FLOAT, 32, 0, 1 }, - { MOJOSHADER_AST_DATATYPE_DOUBLE, 64, 0, 1 }, - }; - - int lvector = 0; - int lmatrix = 0; - int l = STATICARRAYLEN(typeinf); - if (ldatatype != NULL) - { - MOJOSHADER_astDataTypeType type = ldatatype->type; - if (type == MOJOSHADER_AST_DATATYPE_VECTOR) - { - lvector = 1; - type = ldatatype->vector.base->type; - } // if - else if (type == MOJOSHADER_AST_DATATYPE_MATRIX) - { - lmatrix = 1; - type = ldatatype->matrix.base->type; - } // if - - for (l = 0; l < STATICARRAYLEN(typeinf); l++) - { - if (typeinf[l].type == type) - break; - } // for - } // if - - int rvector = 0; - int rmatrix = 0; - int r = STATICARRAYLEN(typeinf); - if (rdatatype != NULL) - { - MOJOSHADER_astDataTypeType type = rdatatype->type; - if (type == MOJOSHADER_AST_DATATYPE_VECTOR) - { - rvector = 1; - type = rdatatype->vector.base->type; - } // if - else if (type == MOJOSHADER_AST_DATATYPE_MATRIX) - { - rmatrix = 1; - type = rdatatype->matrix.base->type; - } // if - - for (r = 0; r < STATICARRAYLEN(typeinf); r++) - { - if (typeinf[r].type == type) - break; - } // for - } // if - - enum { CHOOSE_NEITHER, CHOOSE_LEFT, CHOOSE_RIGHT } choice = CHOOSE_NEITHER; - if ((l < STATICARRAYLEN(typeinf)) && (r < STATICARRAYLEN(typeinf))) - { - if (left == NULL) - choice = CHOOSE_LEFT; // we need to force to the lvalue. - else if (lmatrix && !rmatrix) - choice = CHOOSE_LEFT; - else if (!lmatrix && rmatrix) - choice = CHOOSE_RIGHT; - else if (lvector && !rvector) - choice = CHOOSE_LEFT; - else if (!lvector && rvector) - choice = CHOOSE_RIGHT; - else if (typeinf[l].bits > typeinf[r].bits) - choice = CHOOSE_LEFT; - else if (typeinf[l].bits < typeinf[r].bits) - choice = CHOOSE_RIGHT; - else if (typeinf[l].floating && !typeinf[r].floating) - choice = CHOOSE_LEFT; - else if (!typeinf[l].floating && typeinf[r].floating) - choice = CHOOSE_RIGHT; - else if (typeinf[l].is_unsigned && !typeinf[r].is_unsigned) - choice = CHOOSE_LEFT; - else if (!typeinf[l].is_unsigned && typeinf[r].is_unsigned) - choice = CHOOSE_RIGHT; - } // if - - if (choice == CHOOSE_LEFT) - { - *right = new_cast_expr(ctx, _ldatatype, *right); - return _ldatatype; - } // if - else if (choice == CHOOSE_RIGHT) - { - *left = new_cast_expr(ctx, _rdatatype, *left); - return _rdatatype; - } // else if - - assert(choice == CHOOSE_NEITHER); - fail(ctx, "incompatible data types"); - // Ditch original (*right), force a literal value that matches - // ldatatype, so further processing is normalized. - // !!! FIXME: force (right) to match (left). - delete_expr(ctx, *right); - *right = new_cast_expr(ctx, _ldatatype, new_literal_int_expr(ctx, 0)); - return ldatatype; -} // add_type_coercion - -static int is_swizzle_str(const char *str, const int veclen) -{ - int i; - int is_xyzw = 0; - int is_rgba = 0; - - assert(*str != '\0'); // can this actually happen? - - for (i = 0; i < veclen; i++, str++) - { - const char ch = *str; - if (ch == '\0') - break; - else if ((ch == 'x') || (ch == 'y') || (ch == 'z') || (ch == 'w')) - is_xyzw = 1; - else if ((ch == 'r') || (ch == 'g') || (ch == 'b') || (ch == 'a')) - is_rgba = 1; - } // for - - if (*str != '\0') // must be end of string here. - return 0; // not a swizzle. - return ((is_rgba + is_xyzw) == 1); // can only be one or the other. -} // is_swizzle_str - -static int datatype_size(const MOJOSHADER_astDataType *dt) -{ - switch (dt->type) - { - case MOJOSHADER_AST_DATATYPE_BOOL: return 1; - case MOJOSHADER_AST_DATATYPE_INT: return 4; - case MOJOSHADER_AST_DATATYPE_UINT: return 4; - case MOJOSHADER_AST_DATATYPE_FLOAT: return 4; - case MOJOSHADER_AST_DATATYPE_FLOAT_SNORM: return 4; - case MOJOSHADER_AST_DATATYPE_FLOAT_UNORM: return 4; - case MOJOSHADER_AST_DATATYPE_HALF: return 2; - case MOJOSHADER_AST_DATATYPE_DOUBLE: return 8; - return 1; - default: - assert(0 && "Maybe should have used reduce_datatype()?"); - return 0; - } // switch -} // datatype_size - -static inline int is_scalar_datatype(const MOJOSHADER_astDataType *dt) -{ - switch (dt->type) - { - case MOJOSHADER_AST_DATATYPE_BOOL: - case MOJOSHADER_AST_DATATYPE_INT: - case MOJOSHADER_AST_DATATYPE_UINT: - case MOJOSHADER_AST_DATATYPE_FLOAT: - case MOJOSHADER_AST_DATATYPE_FLOAT_SNORM: - case MOJOSHADER_AST_DATATYPE_FLOAT_UNORM: - case MOJOSHADER_AST_DATATYPE_HALF: - case MOJOSHADER_AST_DATATYPE_DOUBLE: - return 1; - default: - return 0; - } // switch -} // is_scalar_datatype - -static inline int is_float_datatype(const MOJOSHADER_astDataType *dt) -{ - switch (dt->type) - { - case MOJOSHADER_AST_DATATYPE_FLOAT: return 1; - case MOJOSHADER_AST_DATATYPE_FLOAT_SNORM: return 1; - case MOJOSHADER_AST_DATATYPE_FLOAT_UNORM: return 1; - default: return 0; - } // switch -} // is_float_datatype - -static int datatype_elems(Context *ctx, const MOJOSHADER_astDataType *dt) -{ - dt = reduce_datatype(ctx, dt); - switch (dt->type) - { - case MOJOSHADER_AST_DATATYPE_VECTOR: - return dt->vector.elements; - case MOJOSHADER_AST_DATATYPE_MATRIX: - return dt->matrix.rows * dt->matrix.columns; - default: - return 1; - } // switch -} // datatype_elems - -static const MOJOSHADER_astDataType *datatype_base(Context *ctx, const MOJOSHADER_astDataType *dt) -{ - dt = reduce_datatype(ctx, dt); - switch (dt->type) - { - case MOJOSHADER_AST_DATATYPE_VECTOR: - dt = dt->vector.base; - break; - case MOJOSHADER_AST_DATATYPE_MATRIX: - dt = dt->matrix.base; - break; - case MOJOSHADER_AST_DATATYPE_BUFFER: - dt = dt->buffer.base; - break; - case MOJOSHADER_AST_DATATYPE_ARRAY: - dt = dt->array.base; - break; - default: break; - } // switch - - return dt; -} // datatype_base - -typedef enum -{ - DT_MATCH_INCOMPATIBLE, // flatly incompatible - DT_MATCH_COMPATIBLE_DOWNCAST, // would have to lose precision - DT_MATCH_COMPATIBLE_UPCAST, // would have to gain precision - DT_MATCH_COMPATIBLE, // can cast to without serious change. - DT_MATCH_PERFECT // identical datatype. -} DatatypeMatch; - -static DatatypeMatch compatible_arg_datatype(Context *ctx, - const MOJOSHADER_astDataType *arg, - const MOJOSHADER_astDataType *param) -{ - // The matching rules for HLSL function overloading, as far as I can - // tell from experimenting with Microsoft's compiler, seem to be this: - // - // - All parameters of a function must match what the caller specified - // after possible type promotion via the following rules. - // - If the number of arguments and the number of parameters don't match, - // that overload is immediately rejected. - // - Each overloaded function is given a score that is the sum of the - // "worth" of each parameter vs the caller's arguments - // (see DatatypeMatch). The higher the score, the more favorable this - // function overload would be. - // - If there is a tie for highest score between two or more function - // overloads, we declare that function call to be ambiguous and fail(). - // - Scalars can be promoted to vectors to make a parameter match. - // - Scalars can promote to other scalars (short to int, etc). - // - Datatypes can downcast, but should generate a warning. - // (calling void fn(float x); as fn((double)1.0) should warn). - // - Vectors may NOT be extend (a float2 can't implicity extend to a - // float4). - // - Vectors with the same elements can promote (a half2 can become - // a float2). Downcasting between vectors with the same number of - // elements is allowed. - // - A perfect match of all params will be favored over any functions - // that only match if type promotion is applied (given a perfect match - // of all parameters, we'll stop looking for other matches). - - if (datatypes_match(arg, param)) - return DT_MATCH_PERFECT; // that was easy. - - arg = reduce_datatype(ctx, arg); - param = reduce_datatype(ctx, param); - - int do_base_test = 0; - - if (is_scalar_datatype(arg)) - do_base_test = 1; // we let these all go through for now. - - else if (arg->type == param->type) - { - if (arg->type == MOJOSHADER_AST_DATATYPE_VECTOR) - do_base_test = (arg->vector.elements == param->vector.elements); - else if (arg->type == MOJOSHADER_AST_DATATYPE_MATRIX) - { - do_base_test = - ((arg->matrix.rows == param->matrix.rows) && - (arg->matrix.columns == param->matrix.columns)); - } // if - } // if - - if (do_base_test) - { - arg = datatype_base(ctx, arg); - param = datatype_base(ctx, param); - - const int argsize = datatype_size(arg); - const int paramsize = datatype_size(param); - const int argfloat = is_float_datatype(arg); - const int paramfloat = is_float_datatype(param); - - if (argfloat && !paramfloat) - return DT_MATCH_COMPATIBLE_DOWNCAST; // always loss of precision. - else if (argfloat && !paramfloat) - { - if (argsize < paramsize) - return DT_MATCH_COMPATIBLE_UPCAST; - else - return DT_MATCH_COMPATIBLE_DOWNCAST; // loss of precision. - } // else if - else if (argsize == paramsize) - return DT_MATCH_COMPATIBLE; - else if (argsize < paramsize) - return DT_MATCH_COMPATIBLE_UPCAST; - else /* if (argsize > paramsize) */ - return DT_MATCH_COMPATIBLE_DOWNCAST; - } // if - - return DT_MATCH_INCOMPATIBLE; -} // compatible_arg_datatype - - -static const MOJOSHADER_astDataType *type_check_ast(Context *ctx, void *_ast); - -// !!! FIXME: this function sucks. -static const MOJOSHADER_astDataType *match_func_to_call(Context *ctx, - MOJOSHADER_astExpressionCallFunction *ast) -{ - SymbolScope *best = NULL; // best choice we find. - int best_score = 0; - MOJOSHADER_astExpressionIdentifier *ident = ast->identifier; - const char *sym = ident->identifier; - const void *value = NULL; - void *iter = NULL; - - int argcount = 0; - MOJOSHADER_astArguments *args = ast->args; - while (args != NULL) - { - argcount++; - type_check_ast(ctx, args->argument); - args = args->next; - } // while; - - // we do some tapdancing to handle function overloading here. - int match = 0; - while (hash_iter(ctx->variables.hash, sym, &value, &iter)) - { - SymbolScope *item = (SymbolScope *) value; - const MOJOSHADER_astDataType *dt = item->datatype; - dt = reduce_datatype(ctx, dt); - // there's a locally-scoped symbol with this name? It takes precedence. - if (dt->type != MOJOSHADER_AST_DATATYPE_FUNCTION) - return dt; - - const MOJOSHADER_astDataTypeFunction *dtfn = (MOJOSHADER_astDataTypeFunction *) dt; - const int perfect = argcount * ((int) DT_MATCH_PERFECT); - int score = 0; - - if (argcount == dtfn->num_params) // !!! FIXME: default args. - { - args = ast->args; - int i; - for (i = 0; i < argcount; i++) - { - assert(args != NULL); - dt = args->argument->datatype; - args = args->next; - const DatatypeMatch compatible = compatible_arg_datatype(ctx, dt, dtfn->params[i]); - if (compatible == DT_MATCH_INCOMPATIBLE) - { - args = NULL; - score = 0; - break; - } // if - - score += (int) compatible; - } // for - - if (args != NULL) - score = 0; // too many arguments supplied. No match. - } // else - - if (score == 0) // incompatible. - continue; - - else if (score == perfect) // perfection! stop looking! - { - match = 1; // ignore all other compatible matches. - best = item; - break; - } // if - - else if (score >= best_score) // compatible, but not perfect, match. - { - if (score == best_score) - { - match++; - // !!! FIXME: list each possible function in a fail(), - // !!! FIXME: but you can't actually fail() here, since - // !!! FIXME: this may cease to be ambiguous if we get - // !!! FIXME: a better match on a later overload. - } // if - - else if (score > best_score) - { - match = 1; // reset the ambiguousness count. - best = item; - best_score = score; - } // if - } // else if - } // while - - if (match > 1) - { - assert(best != NULL); - failf(ctx, "Ambiguous function call to '%s'", sym); - } // if - - if (best == NULL) - { - assert(match == 0); - assert(best_score == 0); - // !!! FIXME: ident->datatype = ? - failf(ctx, "No matching function named '%s'", sym); - } // if - else - { - ident->datatype = reduce_datatype(ctx, best->datatype); - ident->index = best->index; - } // else - - return ident->datatype; -} // match_func_to_call - - -static const MOJOSHADER_astDataType *vectype_from_base(Context *ctx, - const MOJOSHADER_astDataType *base, - const int len) -{ - assert(len > 0); - assert(len <= 4); - - if (len == 1) // return "float" and not "float1" - return base; - - const char *typestr = NULL; - switch (base->type) - { - case MOJOSHADER_AST_DATATYPE_BOOL: typestr = "bool"; break; - case MOJOSHADER_AST_DATATYPE_INT: typestr = "int"; break; - case MOJOSHADER_AST_DATATYPE_UINT: typestr = "uint"; break; - case MOJOSHADER_AST_DATATYPE_HALF: typestr = "half"; break; - case MOJOSHADER_AST_DATATYPE_FLOAT: typestr = "float"; break; - case MOJOSHADER_AST_DATATYPE_DOUBLE: typestr = "double"; break; - default: assert(0 && "This shouldn't happen"); break; - } // switch - - char buf[32]; - snprintf(buf, sizeof (buf), "%s%d", typestr, len); - const MOJOSHADER_astDataType *datatype = get_usertype(ctx, buf); - assert(datatype != NULL); - return datatype; -} // vectype_from_base - - -// Go through the AST and make sure all datatypes check out okay. For datatypes -// that are compatible but are relying on an implicit cast, we add explicit -// casts to the AST here, so further processing doesn't have to worry about -// type coercion. -// For things that are incompatible, we generate errors and -// then replace them with reasonable defaults so further processing can -// continue (but code generation will be skipped due to errors). -// This means further processing can assume the AST is sane and not have to -// spend effort verifying it again. -// This stage will also set every AST node's datatype field, if it is -// meaningful to do so. This will allow conversion to IR to know what -// type/size a given node is. -static const MOJOSHADER_astDataType *type_check_ast(Context *ctx, void *_ast) -{ - MOJOSHADER_astNode *ast = (MOJOSHADER_astNode *) _ast; - const MOJOSHADER_astDataType *datatype = NULL; - const MOJOSHADER_astDataType *datatype2 = NULL; - const MOJOSHADER_astDataType *datatype3 = NULL; - - if ((!ast) || (ctx->out_of_memory)) - return NULL; - - // upkeep so we report correct error locations... - ctx->sourcefile = ast->ast.filename; - ctx->sourceline = ast->ast.line; - - switch (ast->ast.type) - { - case MOJOSHADER_AST_OP_POSTINCREMENT: - case MOJOSHADER_AST_OP_POSTDECREMENT: - case MOJOSHADER_AST_OP_PREINCREMENT: - case MOJOSHADER_AST_OP_PREDECREMENT: - case MOJOSHADER_AST_OP_COMPLEMENT: - case MOJOSHADER_AST_OP_NEGATE: - // !!! FIXME: must be lvalue. - // !!! FIXME: bools must type-promote to ...int? - // !!! FIXME: complement must not be float (...right?) - datatype = type_check_ast(ctx, ast->unary.operand); - require_numeric_datatype(ctx, datatype); - ast->unary.datatype = datatype; - return datatype; - - case MOJOSHADER_AST_OP_NOT: - datatype = type_check_ast(ctx, ast->unary.operand); - require_boolean_datatype(ctx, datatype); - // !!! FIXME: coerce to bool here. - ast->unary.datatype = &ctx->dt_bool; - return datatype; - - case MOJOSHADER_AST_OP_DEREF_ARRAY: - datatype = type_check_ast(ctx, ast->binary.left); - datatype2 = type_check_ast(ctx, ast->binary.right); - require_integer_datatype(ctx, datatype2); - add_type_coercion(ctx, NULL, &ctx->dt_int, &ast->binary.right, datatype2); - - datatype = reduce_datatype(ctx, datatype); - if (datatype->type == MOJOSHADER_AST_DATATYPE_VECTOR) - { - // !!! FIXME: if constant int, fail if not 0 >= value <= vecsize. - ast->binary.datatype = datatype->vector.base; - } // if - else if (datatype->type == MOJOSHADER_AST_DATATYPE_MATRIX) - { - // !!! FIXME: if constant int, fail if not 0 >= value <= rowsize (colsize?). - ast->binary.datatype = vectype_from_base(ctx, datatype->matrix.base, datatype->matrix.columns); // !!! FIXME: rows? - } - else - { - require_array_datatype(ctx, datatype); - ast->binary.datatype = array_element_datatype(ctx, datatype); - } // else - - return ast->binary.datatype; - - case MOJOSHADER_AST_OP_DEREF_STRUCT: - { - const char *member = ast->derefstruct.member; - datatype = type_check_ast(ctx, ast->derefstruct.identifier); - const MOJOSHADER_astDataType *reduced = reduce_datatype(ctx, datatype); - - // Is this a swizzle and not a struct deref? - if (reduced->type == MOJOSHADER_AST_DATATYPE_VECTOR) - { - const int veclen = reduced->vector.elements; - ast->derefstruct.isswizzle = 1; - if (!is_swizzle_str(member, veclen)) - { - fail(ctx, "invalid swizzle on vector"); - // force this to be sane for further processing. - const char *sane_swiz = stringcache(ctx->strcache, "xyzw"); - member = ast->derefstruct.member = sane_swiz; - } // if - - const int swizlen = (int) strlen(member); - if (swizlen != veclen) - datatype = vectype_from_base(ctx, reduced->vector.base, swizlen); - - ast->derefstruct.datatype = datatype; - return ast->derefstruct.datatype; - } // if - - // maybe this is an actual struct? - // !!! FIXME: replace with an int or something if not. - require_struct_datatype(ctx, reduced); - - // map member to datatype - assert(ast->derefstruct.datatype == NULL); - const MOJOSHADER_astDataTypeStructMember *mbrs = reduced->structure.members; - int i; - for (i = 0; i < reduced->structure.member_count; i++) - { - if (strcmp(mbrs[i].identifier, member) == 0) - { - ast->derefstruct.datatype = mbrs[i].datatype; - ast->derefstruct.member_index = i; - break; - } // if - } // for - - if (ast->derefstruct.datatype == NULL) - { - // !!! FIXME: replace with an int or something. - failf(ctx, "Struct has no member named '%s'", member); - } // if - - return ast->derefstruct.datatype; - } // case - - case MOJOSHADER_AST_OP_COMMA: - // evaluate and throw away left, return right. - type_check_ast(ctx, ast->binary.left); - ast->binary.datatype = type_check_ast(ctx, ast->binary.right); - return ast->binary.datatype; - - case MOJOSHADER_AST_OP_MULTIPLY: - case MOJOSHADER_AST_OP_DIVIDE: - case MOJOSHADER_AST_OP_ADD: - case MOJOSHADER_AST_OP_SUBTRACT: - datatype = type_check_ast(ctx, ast->binary.left); - datatype2 = type_check_ast(ctx, ast->binary.right); - require_numeric_datatype(ctx, datatype); - require_numeric_datatype(ctx, datatype2); - ast->binary.datatype = add_type_coercion(ctx, &ast->binary.left, - datatype, &ast->binary.right, datatype2); - return ast->binary.datatype; - - case MOJOSHADER_AST_OP_LSHIFT: - case MOJOSHADER_AST_OP_RSHIFT: - case MOJOSHADER_AST_OP_MODULO: - datatype = type_check_ast(ctx, ast->binary.left); - datatype2 = type_check_ast(ctx, ast->binary.right); - require_integer_datatype(ctx, datatype); - require_integer_datatype(ctx, datatype2); - ast->binary.datatype = add_type_coercion(ctx, &ast->binary.left, - datatype, &ast->binary.right, datatype2); - return ast->binary.datatype; - - case MOJOSHADER_AST_OP_LESSTHAN: - case MOJOSHADER_AST_OP_GREATERTHAN: - case MOJOSHADER_AST_OP_LESSTHANOREQUAL: - case MOJOSHADER_AST_OP_GREATERTHANOREQUAL: - case MOJOSHADER_AST_OP_NOTEQUAL: - case MOJOSHADER_AST_OP_EQUAL: - datatype = type_check_ast(ctx, ast->binary.left); - datatype2 = type_check_ast(ctx, ast->binary.right); - add_type_coercion(ctx, &ast->binary.left, datatype, - &ast->binary.right, datatype2); - ast->binary.datatype = &ctx->dt_bool; - return ast->binary.datatype; - - case MOJOSHADER_AST_OP_BINARYAND: - case MOJOSHADER_AST_OP_BINARYXOR: - case MOJOSHADER_AST_OP_BINARYOR: - datatype = type_check_ast(ctx, ast->binary.left); - datatype2 = type_check_ast(ctx, ast->binary.right); - require_integer_datatype(ctx, datatype); - require_integer_datatype(ctx, datatype2); - ast->binary.datatype = add_type_coercion(ctx, &ast->binary.left, - datatype, &ast->binary.right, datatype2); - return ast->binary.datatype; - - case MOJOSHADER_AST_OP_LOGICALAND: - case MOJOSHADER_AST_OP_LOGICALOR: - datatype = type_check_ast(ctx, ast->binary.left); - datatype2 = type_check_ast(ctx, ast->binary.right); - require_boolean_datatype(ctx, datatype); - require_boolean_datatype(ctx, datatype2); - // !!! FIXME: coerce each to bool here, separately. - add_type_coercion(ctx, &ast->binary.left, datatype, - &ast->binary.right, datatype2); - ast->binary.datatype = &ctx->dt_bool; - - case MOJOSHADER_AST_OP_ASSIGN: - case MOJOSHADER_AST_OP_MULASSIGN: - case MOJOSHADER_AST_OP_DIVASSIGN: - case MOJOSHADER_AST_OP_MODASSIGN: - case MOJOSHADER_AST_OP_ADDASSIGN: - case MOJOSHADER_AST_OP_SUBASSIGN: - case MOJOSHADER_AST_OP_LSHIFTASSIGN: - case MOJOSHADER_AST_OP_RSHIFTASSIGN: - case MOJOSHADER_AST_OP_ANDASSIGN: - case MOJOSHADER_AST_OP_XORASSIGN: - case MOJOSHADER_AST_OP_ORASSIGN: - // !!! FIXME: verify binary.left is an lvalue, or fail()! - datatype = type_check_ast(ctx, ast->binary.left); - datatype2 = type_check_ast(ctx, ast->binary.right); - ast->binary.datatype = add_type_coercion(ctx, NULL, datatype, - &ast->binary.right, datatype2); - return ast->binary.datatype; - - case MOJOSHADER_AST_OP_CONDITIONAL: - datatype = type_check_ast(ctx, ast->ternary.left); - datatype2 = type_check_ast(ctx, ast->ternary.center); - datatype3 = type_check_ast(ctx, ast->ternary.right); - require_numeric_datatype(ctx, datatype); - ast->ternary.datatype = add_type_coercion(ctx, &ast->ternary.center, - datatype2, &ast->ternary.right, datatype3); - return ast->ternary.datatype; - - case MOJOSHADER_AST_OP_IDENTIFIER: - datatype = find_variable(ctx, ast->identifier.identifier, &ast->identifier.index); - if (datatype == NULL) - { - fail(ctx, "Unknown identifier"); - // !!! FIXME: replace with a sane default, move on. - datatype = &ctx->dt_int; - } // if - ast->identifier.datatype = datatype; - return ast->identifier.datatype; - - case MOJOSHADER_AST_OP_INT_LITERAL: - case MOJOSHADER_AST_OP_FLOAT_LITERAL: - case MOJOSHADER_AST_OP_STRING_LITERAL: - case MOJOSHADER_AST_OP_BOOLEAN_LITERAL: - assert(ast->expression.datatype != NULL); - return ast->expression.datatype; // already set up during parsing. - - case MOJOSHADER_AST_ARGUMENTS: - assert(0 && "Should be done by MOJOSHADER_AST_OP_CALLFUNC/CONSTRUCTOR"); - return NULL; - - case MOJOSHADER_AST_OP_CALLFUNC: - { - datatype = match_func_to_call(ctx, &ast->callfunc); - const MOJOSHADER_astDataType *reduced = reduce_datatype(ctx, datatype); - // !!! FIXME: replace AST node with an int if this isn't a func. - if (!require_function_datatype(ctx, reduced)) - { - ast->callfunc.datatype = &ctx->dt_int; - return ast->callfunc.datatype; - } // if - - MOJOSHADER_astArguments *arg = ast->callfunc.args; - int i; - for (i = 0; i < reduced->function.num_params; i++) - { - if (arg == NULL) // !!! FIXME: check for default parameters, fill them in. - { - fail(ctx, "Too few arguments"); - // !!! FIXME: replace AST here. - break; - } // if - datatype2 = arg->argument->datatype; // already type-checked. - add_type_coercion(ctx, NULL, reduced->function.params[i], - &arg->argument, datatype2); - arg = arg->next; - } // for - - assert(arg == NULL); // shouldn't have chosen func if too many args. - - ast->callfunc.datatype = reduced->function.retval; - return ast->callfunc.datatype; - } // case - - case MOJOSHADER_AST_OP_CONSTRUCTOR: - { - const MOJOSHADER_astDataType *reduced = reduce_datatype(ctx, ast->constructor.datatype); - const MOJOSHADER_astDataType *base_dt = reduced; - int num_params = 1; - - assert(reduced != NULL); - switch (reduced->type) - { - case MOJOSHADER_AST_DATATYPE_VECTOR: - num_params = reduced->vector.elements; - base_dt = reduced->vector.base; - break; - case MOJOSHADER_AST_DATATYPE_MATRIX: - num_params = reduced->matrix.rows * reduced->matrix.columns; - base_dt = reduced->matrix.base; - break; - - case MOJOSHADER_AST_DATATYPE_BOOL: - case MOJOSHADER_AST_DATATYPE_INT: - case MOJOSHADER_AST_DATATYPE_UINT: - case MOJOSHADER_AST_DATATYPE_FLOAT: - case MOJOSHADER_AST_DATATYPE_FLOAT_SNORM: - case MOJOSHADER_AST_DATATYPE_FLOAT_UNORM: - case MOJOSHADER_AST_DATATYPE_HALF: - case MOJOSHADER_AST_DATATYPE_DOUBLE: - case MOJOSHADER_AST_DATATYPE_STRING: - num_params = 1; - break; - - // !!! FIXME: can you construct a MOJOSHADER_AST_DATATYPE_STRUCT? - // !!! FIXME: can you construct a MOJOSHADER_AST_DATATYPE_ARRAY? - // !!! FIXME: can you construct a MOJOSHADER_AST_DATATYPE_BUFFER? - - default: - fail(ctx, "Invalid type for constructor"); - delete_arguments(ctx, ast->constructor.args); - ast->constructor.args = new_argument(ctx, new_literal_int_expr(ctx, 0)); - ast->constructor.datatype = &ctx->dt_int; - return ast->constructor.datatype; - } // switch - - assert(num_params > 0); - - MOJOSHADER_astArguments *arg = ast->constructor.args; - MOJOSHADER_astArguments *prev = NULL; - int i; - for (i = 0; i < num_params; i++) - { - if (arg == NULL) // !!! FIXME: check for default parameters. - { - fail(ctx, "Too few arguments"); - // !!! FIXME: replace AST here. - break; - } // if - datatype2 = type_check_ast(ctx, arg->argument); - - // "float4(float3(1,2,3),4)" is legal, so we need to see if - // we're a vector, and jump that number of parameters instead - // of doing type coercion. - reduced = reduce_datatype(ctx, datatype2); - if (reduced->type == MOJOSHADER_AST_DATATYPE_VECTOR) - { - // make sure things like float4(half3(1,2,3),1) convert that half3 to float3. - const int count = reduced->vector.elements; - datatype3 = vectype_from_base(ctx, base_dt, count); - add_type_coercion(ctx, NULL, datatype3, &arg->argument, datatype2); - i += count - 1; - } // else - else - { - add_type_coercion(ctx, NULL, base_dt, &arg->argument, datatype2); - } // else - prev = arg; - arg = arg->next; - } // for - - if (arg != NULL) - { - fail(ctx, "Too many arguments"); - // Process extra arguments then chop them out. - MOJOSHADER_astArguments *argi; - for (argi = arg; argi != NULL; argi = argi->next) - type_check_ast(ctx, argi->argument); - if (prev != NULL) - prev->next = NULL; - delete_arguments(ctx, arg); - } // if - - return ast->constructor.datatype; - } // case - - case MOJOSHADER_AST_OP_CAST: - datatype = sanitize_datatype(ctx, ast->cast.datatype); - datatype2 = type_check_ast(ctx, ast->cast.operand); - // you still need type coercion, since you could do a wrong cast, - // like "int x = (short) mychar;" - add_type_coercion(ctx, NULL, datatype, &ast->cast.operand, datatype2); - return datatype; - - case MOJOSHADER_AST_STATEMENT_BREAK: - if ((ctx->loop_count == 0) && (ctx->switch_count == 0)) - fail(ctx, "Break outside loop or switch"); - // !!! FIXME: warn if unreachable statements follow? - type_check_ast(ctx, ast->stmt.next); - return NULL; - - case MOJOSHADER_AST_STATEMENT_CONTINUE: - if (ctx->loop_count == 0) - fail(ctx, "Continue outside loop"); - // !!! FIXME: warn if unreachable statements follow? - type_check_ast(ctx, ast->stmt.next); - return NULL; - - case MOJOSHADER_AST_STATEMENT_DISCARD: - // !!! FIXME: warn if unreachable statements follow? - type_check_ast(ctx, ast->stmt.next); - return NULL; - - case MOJOSHADER_AST_STATEMENT_EMPTY: - type_check_ast(ctx, ast->stmt.next); - return NULL; - - case MOJOSHADER_AST_STATEMENT_EXPRESSION: - // !!! FIXME: warn about expressions without a side-effect here? - type_check_ast(ctx, ast->exprstmt.expr); // !!! FIXME: This is named badly... - type_check_ast(ctx, ast->exprstmt.next); - return NULL; - - case MOJOSHADER_AST_STATEMENT_IF: - push_scope(ctx); // new scope for "if ((int x = blah()) != 0)" - type_check_ast(ctx, ast->ifstmt.expr); - type_check_ast(ctx, ast->ifstmt.statement); - pop_scope(ctx); - type_check_ast(ctx, ast->ifstmt.next); - return NULL; - - case MOJOSHADER_AST_STATEMENT_TYPEDEF: - type_check_ast(ctx, ast->typedefstmt.type_info); - type_check_ast(ctx, ast->typedefstmt.next); - return NULL; - - case MOJOSHADER_AST_STATEMENT_SWITCH: - { - ctx->switch_count++; - MOJOSHADER_astSwitchCases *cases = ast->switchstmt.cases; - // !!! FIXME: expr must be POD (no structs, arrays, etc!). - datatype = type_check_ast(ctx, ast->switchstmt.expr); - while (cases) - { - // !!! FIXME: case must be POD (no structs, arrays, etc!). - datatype2 = type_check_ast(ctx, cases->expr); - add_type_coercion(ctx, NULL, datatype, - &cases->expr, datatype2); - type_check_ast(ctx, cases->statement); - cases = cases->next; - } // while - ctx->switch_count--; - type_check_ast(ctx, ast->switchstmt.next); - return NULL; - } // case - - case MOJOSHADER_AST_SWITCH_CASE: - assert(0 && "Should be done by MOJOSHADER_AST_STATEMENT_SWITCH."); - return NULL; - - case MOJOSHADER_AST_STATEMENT_STRUCT: - type_check_ast(ctx, ast->structstmt.struct_info); - type_check_ast(ctx, ast->structstmt.next); - return NULL; - - case MOJOSHADER_AST_STATEMENT_VARDECL: - type_check_ast(ctx, ast->vardeclstmt.declaration); - type_check_ast(ctx, ast->vardeclstmt.next); - return NULL; - - case MOJOSHADER_AST_STATEMENT_BLOCK: - push_scope(ctx); // new vars declared here live until '}'. - type_check_ast(ctx, ast->blockstmt.statements); - pop_scope(ctx); - type_check_ast(ctx, ast->blockstmt.next); - return NULL; - - case MOJOSHADER_AST_STATEMENT_FOR: - ctx->loop_count++; - push_scope(ctx); // new scope for "for (int x = 0; ...)" - type_check_ast(ctx, ast->forstmt.var_decl); - type_check_ast(ctx, ast->forstmt.initializer); - type_check_ast(ctx, ast->forstmt.looptest); - type_check_ast(ctx, ast->forstmt.counter); - type_check_ast(ctx, ast->forstmt.statement); - pop_scope(ctx); - ctx->loop_count--; - type_check_ast(ctx, ast->forstmt.next); - return NULL; - - case MOJOSHADER_AST_STATEMENT_DO: - ctx->loop_count++; - // !!! FIXME: should there be a push_scope() here? - type_check_ast(ctx, ast->dostmt.statement); - push_scope(ctx); // new scope for "while ((int x = blah()) != 0)" - type_check_ast(ctx, ast->dostmt.expr); - pop_scope(ctx); - ctx->loop_count--; - type_check_ast(ctx, ast->dostmt.next); - return NULL; - - case MOJOSHADER_AST_STATEMENT_WHILE: - ctx->loop_count++; - push_scope(ctx); // new scope for "while ((int x = blah()) != 0)" - type_check_ast(ctx, ast->whilestmt.expr); - type_check_ast(ctx, ast->whilestmt.statement); - pop_scope(ctx); - ctx->loop_count--; - type_check_ast(ctx, ast->whilestmt.next); - return NULL; - - case MOJOSHADER_AST_STATEMENT_RETURN: - // !!! FIXME: type coercion to outer function's return type. - // !!! FIXME: warn if unreachable statements follow? - type_check_ast(ctx, ast->returnstmt.expr); - type_check_ast(ctx, ast->returnstmt.next); - return NULL; - - case MOJOSHADER_AST_COMPUNIT_FUNCTION: - assert(!ctx->is_func_scope); - - // We have to tapdance here to make sure the function is in - // the global scope, but it's parameters are pushed as variables - // in the function's scope. - datatype = type_check_ast(ctx, ast->funcunit.declaration); - ast->funcunit.index = push_function(ctx, - ast->funcunit.declaration->identifier, - datatype, ast->funcunit.definition == NULL); - - // not just a declaration, but a full function definition? - if (ast->funcunit.definition != NULL) - { - assert(ctx->loop_count == 0); - assert(ctx->switch_count == 0); - ctx->is_func_scope = 1; - ctx->var_index = 0; // reset this every function. - push_scope(ctx); // so function params are in function scope. - // repush the parameters before checking the actual function. - MOJOSHADER_astFunctionParameters *param; - for (param = ast->funcunit.declaration->params; param; param = param->next) - push_variable(ctx, param->identifier, param->datatype); - type_check_ast(ctx, ast->funcunit.definition); - pop_scope(ctx); - ctx->is_func_scope = 0; - assert(ctx->loop_count == 0); - assert(ctx->switch_count == 0); - } // else - - type_check_ast(ctx, ast->funcunit.next); - return NULL; - - case MOJOSHADER_AST_COMPUNIT_TYPEDEF: - type_check_ast(ctx, ast->typedefunit.type_info); - type_check_ast(ctx, ast->typedefunit.next); - return NULL; - - case MOJOSHADER_AST_COMPUNIT_STRUCT: - type_check_ast(ctx, ast->structunit.struct_info); - type_check_ast(ctx, ast->structunit.next); - return NULL; - - case MOJOSHADER_AST_COMPUNIT_VARIABLE: - type_check_ast(ctx, ast->varunit.declaration); - type_check_ast(ctx, ast->varunit.next); - return NULL; - - case MOJOSHADER_AST_SCALAR_OR_ARRAY: - assert(0 && "Should be done by other AST nodes."); - return NULL; - - case MOJOSHADER_AST_TYPEDEF: - { - MOJOSHADER_astScalarOrArray *soa = ast->typdef.details; - datatype = get_usertype(ctx, soa->identifier); - if (datatype != NULL) - { - fail(ctx, "typedef already defined"); - ast->typdef.datatype = datatype; - return datatype; - } // if - - datatype = build_datatype(ctx, ast->typdef.isconst, - ast->typdef.datatype, soa); - if (datatype == NULL) - return NULL; // out of memory? - - push_usertype(ctx, soa->identifier, datatype); - ast->typdef.datatype = datatype; - return ast->typdef.datatype; - } // case - - case MOJOSHADER_AST_FUNCTION_PARAMS: - assert(0 && "Should be done by MOJOSHADER_AST_FUNCTION_SIGNATURE"); - - case MOJOSHADER_AST_FUNCTION_SIGNATURE: - { - MOJOSHADER_astFunctionParameters *param; - const MOJOSHADER_astDataType *dtparams[64]; - - int i = 0; - for (param = ast->funcsig.params; param; param = param->next) - { - assert(i <= STATICARRAYLEN(dtparams)); // laziness. - sanitize_datatype(ctx, param->datatype); - if (param->initializer != NULL) - { - datatype2 = type_check_ast(ctx, param->initializer); - add_type_coercion(ctx, NULL, param->datatype, - ¶m->initializer, datatype2); - } // if - dtparams[i] = param->datatype; - i++; - } // for - - ast->funcsig.datatype = build_function_datatype(ctx, - ast->funcsig.datatype, - i, dtparams, 0); - return ast->funcsig.datatype; - } // case - - case MOJOSHADER_AST_STRUCT_DECLARATION: - { - // !!! FIXME: We don't handle struct predeclaration at all right now - // !!! FIXME: (neither does the grammar)...not only does that mean - // !!! FIXME: you need to know the struct definition up front, but - // !!! FIXME: you can't do "struct XXX *next;" for a self-referencing - // !!! FIXME: linked list struct thing. This probably isn't a big - // !!! FIXME: deal, as there aren't (CURRENTLY!) pointers in HLSL, - // !!! FIXME: but you never know. - - const MOJOSHADER_astStructMembers *mbrs; - - // !!! FIXME: count this during parsing? - int count = 0; - mbrs = ast->structdecl.members; - while (mbrs != NULL) - { - count++; - mbrs = mbrs->next; - } // while - - // !!! FIXME: this is hacky. - MOJOSHADER_astDataTypeStructMember *dtmbrs; - void *ptr = Malloc(ctx, sizeof (*dtmbrs) * count); - if (ptr == NULL) - return NULL; - if (!buffer_append(ctx->garbage, &ptr, sizeof (ptr))) - { - Free(ctx, ptr); - return NULL; - } // if - dtmbrs = (MOJOSHADER_astDataTypeStructMember *) ptr; - - ptr = Malloc(ctx, sizeof (MOJOSHADER_astDataType)); - if (ptr == NULL) - return NULL; - if (!buffer_append(ctx->garbage, &ptr, sizeof (ptr))) - { - Free(ctx, ptr); - return NULL; - } // if - MOJOSHADER_astDataType *dt = (MOJOSHADER_astDataType *) ptr; - - mbrs = ast->structdecl.members; - int i; - for (i = 0; i < count; i++) - { - // !!! FIXME: current grammar forbids const keyword on struct members! - dtmbrs[i].datatype = build_datatype(ctx, 0, mbrs->datatype, mbrs->details); - dtmbrs[i].identifier = mbrs->details->identifier; // cached! - mbrs = mbrs->next; - } // for - - dt->structure.type = MOJOSHADER_AST_DATATYPE_STRUCT; - dt->structure.members = dtmbrs; - dt->structure.member_count = count; - ast->structdecl.datatype = dt; - - // !!! FIXME: this shouldn't push for anonymous structs: "struct { int x; } myvar;" - // !!! FIXME: but right now, the grammar is wrong and requires a name for the struct. - push_usertype(ctx, ast->structdecl.name, ast->structdecl.datatype); - return ast->structdecl.datatype; - } // case - - case MOJOSHADER_AST_STRUCT_MEMBER: - assert(0 && "Should be done by MOJOSHADER_AST_STRUCT_DECLARATION."); - return NULL; - - case MOJOSHADER_AST_VARIABLE_DECLARATION: - { - MOJOSHADER_astVariableDeclaration *decl = &ast->vardecl; - - // this is true now, but we'll fill in ->datatype no matter what. - assert((decl->datatype && !decl->anonymous_datatype) || - (!decl->datatype && decl->anonymous_datatype)); - - // An anonymous struct? That AST node does the heavy lifting. - if (decl->anonymous_datatype != NULL) - datatype = type_check_ast(ctx, decl->anonymous_datatype); - else - { - datatype = build_datatype(ctx, (decl->attributes & MOJOSHADER_AST_VARATTR_CONST) != 0, - decl->datatype, decl->details); - } // else - - while (decl != NULL) - { - decl->datatype = datatype; - push_variable(ctx, decl->details->identifier, datatype); - if (decl->initializer != NULL) - { - datatype2 = type_check_ast(ctx, decl->initializer); - add_type_coercion(ctx, NULL, datatype, &decl->initializer, datatype2); - } // if - - type_check_ast(ctx, decl->annotations); - type_check_ast(ctx, decl->lowlevel); - decl = decl->next; - } // while - - return datatype; - } // case - - case MOJOSHADER_AST_ANNOTATION: - { - MOJOSHADER_astAnnotations *anno = &ast->annotations; - while (anno) - { - type_check_ast(ctx, anno->initializer); - anno = anno->next; - } // while - return NULL; - } // case - - case MOJOSHADER_AST_PACK_OFFSET: - case MOJOSHADER_AST_VARIABLE_LOWLEVEL: - return NULL; // no-op (for now, at least). - - default: - assert(0 && "unexpected type"); - } // switch - - return NULL; -} // type_check_ast - - -static inline void semantic_analysis(Context *ctx) -{ - type_check_ast(ctx, ctx->ast); -} // semantic_analysis - -// !!! FIXME: isn't this a cut-and-paste of somewhere else? -static inline int64 strtoi64(const char *str, unsigned int len) -{ - int64 retval = 0; - int64 mult = 1; - int i = 0; - - while ((len) && (*str == ' ')) - { - str++; - len--; - } // while - - if ((len) && (*str == '-')) - { - mult = -1; - str++; - len--; - } // if - - while (i < len) - { - const char ch = str[i]; - if ((ch < '0') || (ch > '9')) - break; - i++; - } // while - - while (--i >= 0) - { - const char ch = str[i]; - retval += ((int64) (ch - '0')) * mult; - mult *= 10; - } // while - - return retval; -} // strtoi64 - -// !!! FIXME: isn't this a cut-and-paste of somewhere else? -static inline double strtodouble(const char *_str, unsigned int len) -{ - // !!! FIXME: laziness prevails. - char *str = (char *) alloca(len+1); - memcpy(str, _str, len); - str[len] = '\0'; - return strtod(str, NULL); -} // strtodouble - -#if 0 -// This does not check correctness (POSITIONT993842 passes, etc). -static int is_semantic(const Context *ctx, const char *token, - const unsigned int tokenlen) -{ - static const char *names[] = { - "BINORMAL", "BLENDINDICES", "BLENDWEIGHT", - "COLOR", "NORMAL", "POSITION", "POSITIONT", "PSIZE", "TANGENT", - "TEXCOORD", "FOG", "TESSFACTOR", "TEXCOORD", "VFACE", "VPOS", - "DEPTH", NULL - }; - - // !!! FIXME: DX10 has SV_* ("System Value Semantics"). - const char **i; - for (i = names; *i; i++) - { - const char *name = *i; - const size_t namelen = strlen(name); - if (tokenlen < namelen) - continue; - else if (memcmp(token, name, namelen) != 0) - continue; - - for (name += namelen; *name; name++) - { - if ((*name < '0') || (*name > '9')) - break; - } // for - - if (*name == '\0') - return 1; - } // for - - return 0; -} // is_semantic -#endif - -static int convert_to_lemon_token(Context *ctx, const char *token, - unsigned int tokenlen, const Token tokenval) -{ - switch (tokenval) - { - case ((Token) ','): return TOKEN_HLSL_COMMA; - case ((Token) '='): return TOKEN_HLSL_ASSIGN; - case ((Token) TOKEN_ADDASSIGN): return TOKEN_HLSL_ADDASSIGN; - case ((Token) TOKEN_SUBASSIGN): return TOKEN_HLSL_SUBASSIGN; - case ((Token) TOKEN_MULTASSIGN): return TOKEN_HLSL_MULASSIGN; - case ((Token) TOKEN_DIVASSIGN): return TOKEN_HLSL_DIVASSIGN; - case ((Token) TOKEN_MODASSIGN): return TOKEN_HLSL_MODASSIGN; - case ((Token) TOKEN_LSHIFTASSIGN): return TOKEN_HLSL_LSHIFTASSIGN; - case ((Token) TOKEN_RSHIFTASSIGN): return TOKEN_HLSL_RSHIFTASSIGN; - case ((Token) TOKEN_ANDASSIGN): return TOKEN_HLSL_ANDASSIGN; - case ((Token) TOKEN_ORASSIGN): return TOKEN_HLSL_ORASSIGN; - case ((Token) TOKEN_XORASSIGN): return TOKEN_HLSL_XORASSIGN; - case ((Token) '?'): return TOKEN_HLSL_QUESTION; - case ((Token) TOKEN_OROR): return TOKEN_HLSL_OROR; - case ((Token) TOKEN_ANDAND): return TOKEN_HLSL_ANDAND; - case ((Token) '|'): return TOKEN_HLSL_OR; - case ((Token) '^'): return TOKEN_HLSL_XOR; - case ((Token) '&'): return TOKEN_HLSL_AND; - case ((Token) TOKEN_EQL): return TOKEN_HLSL_EQL; - case ((Token) TOKEN_NEQ): return TOKEN_HLSL_NEQ; - case ((Token) '<'): return TOKEN_HLSL_LT; - case ((Token) TOKEN_LEQ): return TOKEN_HLSL_LEQ; - case ((Token) '>'): return TOKEN_HLSL_GT; - case ((Token) TOKEN_GEQ): return TOKEN_HLSL_GEQ; - case ((Token) TOKEN_LSHIFT): return TOKEN_HLSL_LSHIFT; - case ((Token) TOKEN_RSHIFT): return TOKEN_HLSL_RSHIFT; - case ((Token) '+'): return TOKEN_HLSL_PLUS; - case ((Token) '-'): return TOKEN_HLSL_MINUS; - case ((Token) '*'): return TOKEN_HLSL_STAR; - case ((Token) '/'): return TOKEN_HLSL_SLASH; - case ((Token) '%'): return TOKEN_HLSL_PERCENT; - case ((Token) '!'): return TOKEN_HLSL_EXCLAMATION; - case ((Token) '~'): return TOKEN_HLSL_COMPLEMENT; - case ((Token) TOKEN_DECREMENT): return TOKEN_HLSL_MINUSMINUS; - case ((Token) TOKEN_INCREMENT): return TOKEN_HLSL_PLUSPLUS; - case ((Token) '.'): return TOKEN_HLSL_DOT; - case ((Token) '['): return TOKEN_HLSL_LBRACKET; - case ((Token) ']'): return TOKEN_HLSL_RBRACKET; - case ((Token) '('): return TOKEN_HLSL_LPAREN; - case ((Token) ')'): return TOKEN_HLSL_RPAREN; - case ((Token) TOKEN_INT_LITERAL): return TOKEN_HLSL_INT_CONSTANT; - case ((Token) TOKEN_FLOAT_LITERAL): return TOKEN_HLSL_FLOAT_CONSTANT; - case ((Token) TOKEN_STRING_LITERAL): return TOKEN_HLSL_STRING_LITERAL; - case ((Token) ':'): return TOKEN_HLSL_COLON; - case ((Token) ';'): return TOKEN_HLSL_SEMICOLON; - case ((Token) '{'): return TOKEN_HLSL_LBRACE; - case ((Token) '}'): return TOKEN_HLSL_RBRACE; - //case ((Token) TOKEN_PP_PRAGMA): return TOKEN_HLSL_PRAGMA; - //case ((Token) '\n'): return TOKEN_HLSL_NEWLINE; - - case ((Token) TOKEN_IDENTIFIER): - #define tokencmp(t) ((tokenlen == strlen(t)) && (memcmp(token, t, tokenlen) == 0)) - //case ((Token) ''): return TOKEN_HLSL_TYPECAST - //if (tokencmp("")) return TOKEN_HLSL_TYPE_NAME - //if (tokencmp("...")) return TOKEN_HLSL_ELIPSIS - if (tokencmp("else")) return TOKEN_HLSL_ELSE; - if (tokencmp("inline")) return TOKEN_HLSL_INLINE; - if (tokencmp("void")) return TOKEN_HLSL_VOID; - if (tokencmp("in")) return TOKEN_HLSL_IN; - if (tokencmp("inout")) return TOKEN_HLSL_INOUT; - if (tokencmp("out")) return TOKEN_HLSL_OUT; - if (tokencmp("uniform")) return TOKEN_HLSL_UNIFORM; - if (tokencmp("linear")) return TOKEN_HLSL_LINEAR; - if (tokencmp("centroid")) return TOKEN_HLSL_CENTROID; - if (tokencmp("nointerpolation")) return TOKEN_HLSL_NOINTERPOLATION; - if (tokencmp("noperspective")) return TOKEN_HLSL_NOPERSPECTIVE; - if (tokencmp("sample")) return TOKEN_HLSL_SAMPLE; - if (tokencmp("struct")) return TOKEN_HLSL_STRUCT; - if (tokencmp("typedef")) return TOKEN_HLSL_TYPEDEF; - if (tokencmp("const")) return TOKEN_HLSL_CONST; - if (tokencmp("packoffset")) return TOKEN_HLSL_PACKOFFSET; - if (tokencmp("register")) return TOKEN_HLSL_REGISTER; - if (tokencmp("extern")) return TOKEN_HLSL_EXTERN; - if (tokencmp("shared")) return TOKEN_HLSL_SHARED; - if (tokencmp("static")) return TOKEN_HLSL_STATIC; - if (tokencmp("volatile")) return TOKEN_HLSL_VOLATILE; - if (tokencmp("row_major")) return TOKEN_HLSL_ROWMAJOR; - if (tokencmp("column_major")) return TOKEN_HLSL_COLUMNMAJOR; - if (tokencmp("bool")) return TOKEN_HLSL_BOOL; - if (tokencmp("int")) return TOKEN_HLSL_INT; - if (tokencmp("uint")) return TOKEN_HLSL_UINT; - if (tokencmp("half")) return TOKEN_HLSL_HALF; - if (tokencmp("float")) return TOKEN_HLSL_FLOAT; - if (tokencmp("double")) return TOKEN_HLSL_DOUBLE; - if (tokencmp("string")) return TOKEN_HLSL_STRING; - if (tokencmp("snorm")) return TOKEN_HLSL_SNORM; - if (tokencmp("unorm")) return TOKEN_HLSL_UNORM; - if (tokencmp("buffer")) return TOKEN_HLSL_BUFFER; - if (tokencmp("vector")) return TOKEN_HLSL_VECTOR; - if (tokencmp("matrix")) return TOKEN_HLSL_MATRIX; - if (tokencmp("break")) return TOKEN_HLSL_BREAK; - if (tokencmp("continue")) return TOKEN_HLSL_CONTINUE; - if (tokencmp("discard")) return TOKEN_HLSL_DISCARD; - if (tokencmp("return")) return TOKEN_HLSL_RETURN; - if (tokencmp("while")) return TOKEN_HLSL_WHILE; - if (tokencmp("for")) return TOKEN_HLSL_FOR; - if (tokencmp("unroll")) return TOKEN_HLSL_UNROLL; - if (tokencmp("loop")) return TOKEN_HLSL_LOOP; - if (tokencmp("do")) return TOKEN_HLSL_DO; - if (tokencmp("if")) return TOKEN_HLSL_IF; - if (tokencmp("branch")) return TOKEN_HLSL_BRANCH; - if (tokencmp("flatten")) return TOKEN_HLSL_FLATTEN; - if (tokencmp("switch")) return TOKEN_HLSL_SWITCH; - if (tokencmp("forcecase")) return TOKEN_HLSL_FORCECASE; - if (tokencmp("call")) return TOKEN_HLSL_CALL; - if (tokencmp("case")) return TOKEN_HLSL_CASE; - if (tokencmp("default")) return TOKEN_HLSL_DEFAULT; - if (tokencmp("sampler")) return TOKEN_HLSL_SAMPLER; - if (tokencmp("sampler1D")) return TOKEN_HLSL_SAMPLER1D; - if (tokencmp("sampler2D")) return TOKEN_HLSL_SAMPLER2D; - if (tokencmp("sampler3D")) return TOKEN_HLSL_SAMPLER3D; - if (tokencmp("samplerCUBE")) return TOKEN_HLSL_SAMPLERCUBE; - if (tokencmp("sampler_state")) return TOKEN_HLSL_SAMPLER_STATE; - if (tokencmp("SamplerState")) return TOKEN_HLSL_SAMPLERSTATE; - if (tokencmp("true")) return TOKEN_HLSL_TRUE; - if (tokencmp("false")) return TOKEN_HLSL_FALSE; - if (tokencmp("SamplerComparisonState")) return TOKEN_HLSL_SAMPLERCOMPARISONSTATE; - if (tokencmp("isolate")) return TOKEN_HLSL_ISOLATE; - if (tokencmp("maxInstructionCount")) return TOKEN_HLSL_MAXINSTRUCTIONCOUNT; - if (tokencmp("noExpressionOptimizations")) return TOKEN_HLSL_NOEXPRESSIONOPTIMIZATIONS; - if (tokencmp("unused")) return TOKEN_HLSL_UNUSED; - if (tokencmp("xps")) return TOKEN_HLSL_XPS; - #undef tokencmp - - // get a canonical copy of the string now, as we'll need it. - token = stringcache_len(ctx->strcache, token, tokenlen); - if (get_usertype(ctx, token) != NULL) - return TOKEN_HLSL_USERTYPE; - return TOKEN_HLSL_IDENTIFIER; - - case TOKEN_EOI: return 0; - default: assert(0 && "unexpected token from lexer\n"); return 0; - } // switch - - return 0; -} // convert_to_lemon_token - - -static void delete_ir(Context *ctx, void *_ir); // !!! FIXME: move this code around. - -static void destroy_context(Context *ctx) -{ - if (ctx != NULL) - { - MOJOSHADER_free f = ((ctx->free != NULL) ? ctx->free : MOJOSHADER_internal_free); - void *d = ctx->malloc_data; - size_t i = 0; - - // !!! FIXME: this is kinda hacky. - const size_t count = buffer_size(ctx->garbage) / sizeof (void *); - if (count > 0) - { - void **garbage = (void **) buffer_flatten(ctx->garbage); - if (garbage != NULL) - { - for (i = 0; i < count; i++) - f(garbage[i], d); - f(garbage, d); - } // if - } // if - buffer_destroy(ctx->garbage); - - delete_compilation_unit(ctx, (MOJOSHADER_astCompilationUnit*)ctx->ast); - destroy_symbolmap(ctx, &ctx->usertypes); - destroy_symbolmap(ctx, &ctx->variables); - stringcache_destroy(ctx->strcache); - errorlist_destroy(ctx->errors); - errorlist_destroy(ctx->warnings); - - if (ctx->ir != NULL) - { - for (i = 0; i <= ctx->user_func_index; i++) - delete_ir(ctx, ctx->ir[i]); - f(ctx->ir, d); - } // if - - // !!! FIXME: more to clean up here, now. - - f(ctx, d); - } // if -} // destroy_context - -static Context *build_context(MOJOSHADER_malloc m, MOJOSHADER_free f, void *d) -{ - if (!m) m = MOJOSHADER_internal_malloc; - if (!f) f = MOJOSHADER_internal_free; - - Context *ctx = (Context *) m(sizeof (Context), d); - if (ctx == NULL) - return NULL; - - memset(ctx, '\0', sizeof (Context)); - ctx->malloc = m; - ctx->free = f; - ctx->malloc_data = d; - //ctx->parse_phase = MOJOSHADER_PARSEPHASE_NOTSTARTED; - create_symbolmap(ctx, &ctx->usertypes); // !!! FIXME: check for failure. - create_symbolmap(ctx, &ctx->variables); // !!! FIXME: check for failure. - ctx->strcache = stringcache_create(MallocBridge, FreeBridge, ctx); // !!! FIXME: check for failure. - ctx->errors = errorlist_create(MallocBridge, FreeBridge, ctx); // !!! FIXME: check for failure. - ctx->warnings = errorlist_create(MallocBridge, FreeBridge, ctx); // !!! FIXME: check for failure. - - // !!! FIXME: this feels hacky. - ctx->garbage = buffer_create(256*sizeof(void*),MallocBridge,FreeBridge,ctx); // !!! FIXME: check for failure. - - ctx->dt_none.type = MOJOSHADER_AST_DATATYPE_NONE; - ctx->dt_bool.type = MOJOSHADER_AST_DATATYPE_BOOL; - ctx->dt_int.type = MOJOSHADER_AST_DATATYPE_INT; - ctx->dt_uint.type = MOJOSHADER_AST_DATATYPE_UINT; - ctx->dt_float.type = MOJOSHADER_AST_DATATYPE_FLOAT; - ctx->dt_float_snorm.type = MOJOSHADER_AST_DATATYPE_FLOAT_SNORM; - ctx->dt_float_unorm.type = MOJOSHADER_AST_DATATYPE_FLOAT_UNORM; - ctx->dt_half.type = MOJOSHADER_AST_DATATYPE_HALF; - ctx->dt_double.type = MOJOSHADER_AST_DATATYPE_DOUBLE; - ctx->dt_string.type = MOJOSHADER_AST_DATATYPE_STRING; - ctx->dt_sampler1d.type = MOJOSHADER_AST_DATATYPE_SAMPLER_1D; - ctx->dt_sampler2d.type = MOJOSHADER_AST_DATATYPE_SAMPLER_2D; - ctx->dt_sampler3d.type = MOJOSHADER_AST_DATATYPE_SAMPLER_3D; - ctx->dt_samplercube.type = MOJOSHADER_AST_DATATYPE_SAMPLER_CUBE; - ctx->dt_samplerstate.type = MOJOSHADER_AST_DATATYPE_SAMPLER_STATE; - ctx->dt_samplercompstate.type = MOJOSHADER_AST_DATATYPE_SAMPLER_COMPARISON_STATE; - - #define INIT_DT_BUFFER(t) \ - ctx->dt_buf_##t.type = MOJOSHADER_AST_DATATYPE_BUFFER; \ - ctx->dt_buf_##t.buffer.base = &ctx->dt_##t; - INIT_DT_BUFFER(bool); - INIT_DT_BUFFER(int); - INIT_DT_BUFFER(uint); - INIT_DT_BUFFER(half); - INIT_DT_BUFFER(float); - INIT_DT_BUFFER(double); - INIT_DT_BUFFER(float_snorm); - INIT_DT_BUFFER(float_unorm); - #undef INIT_DT_BUFFER - - return ctx; -} // build_context - - -// This macro salsa is kinda nasty, but it's the smallest, least error-prone -// way I can find to do this well in C. :/ - -#define ADD_INTRINSIC(fn, ret, params) do { \ - push_function(ctx, fn, \ - build_function_datatype(ctx, ret, STATICARRAYLEN(params), params, 1), \ - 0); \ -} while (0) - -#define ADD_INTRINSIC_VECTOR(typestr, code) do { \ - const MOJOSHADER_astDataType *dt; \ - dt = get_usertype(ctx, typestr "1"); code; \ - dt = get_usertype(ctx, typestr "2"); code; \ - dt = get_usertype(ctx, typestr "3"); code; \ - dt = get_usertype(ctx, typestr "4"); code; \ -} while (0) - -#define ADD_INTRINSIC_VECTOR_FLOAT(code) { \ - ADD_INTRINSIC_VECTOR("float", code); \ - ADD_INTRINSIC_VECTOR("half", code); \ - ADD_INTRINSIC_VECTOR("double", code); \ -} -#define ADD_INTRINSIC_VECTOR_INT(code) { \ - ADD_INTRINSIC_VECTOR("int", code); \ - ADD_INTRINSIC_VECTOR("uint", code); \ -} -#define ADD_INTRINSIC_VECTOR_BOOL(code) { \ - ADD_INTRINSIC_VECTOR("bool", code); \ -} - -#define ADD_INTRINSIC_MATRIX(typestr, code) do { \ - const MOJOSHADER_astDataType *dt; \ - dt = get_usertype(ctx, typestr "1x1"); code; \ - dt = get_usertype(ctx, typestr "1x2"); code; \ - dt = get_usertype(ctx, typestr "1x3"); code; \ - dt = get_usertype(ctx, typestr "1x4"); code; \ - dt = get_usertype(ctx, typestr "2x1"); code; \ - dt = get_usertype(ctx, typestr "2x2"); code; \ - dt = get_usertype(ctx, typestr "2x3"); code; \ - dt = get_usertype(ctx, typestr "2x4"); code; \ - dt = get_usertype(ctx, typestr "3x1"); code; \ - dt = get_usertype(ctx, typestr "3x2"); code; \ - dt = get_usertype(ctx, typestr "3x3"); code; \ - dt = get_usertype(ctx, typestr "3x4"); code; \ - dt = get_usertype(ctx, typestr "4x1"); code; \ - dt = get_usertype(ctx, typestr "4x2"); code; \ - dt = get_usertype(ctx, typestr "4x3"); code; \ - dt = get_usertype(ctx, typestr "4x4"); code; \ -} while (0) - -#define ADD_INTRINSIC_MATRIX_FLOAT(code) { \ - ADD_INTRINSIC_MATRIX("float", code); \ - ADD_INTRINSIC_MATRIX("half", code); \ - ADD_INTRINSIC_MATRIX("double", code); \ -} -#define ADD_INTRINSIC_MATRIX_INT(code) { \ - ADD_INTRINSIC_MATRIX("int", code); \ - ADD_INTRINSIC_MATRIX("uint", code); \ -} -#define ADD_INTRINSIC_MATRIX_BOOL(code) { \ - ADD_INTRINSIC_MATRIX("bool", code); \ -} - -#define ADD_INTRINSIC_ANY(scalar, typestr, code) do { \ - { const MOJOSHADER_astDataType *dt = scalar; code; } \ - ADD_INTRINSIC_VECTOR(typestr, code); \ - ADD_INTRINSIC_MATRIX(typestr, code); \ -} while (0) - -#define ADD_INTRINSIC_ANY_FLOAT(code) do { \ - ADD_INTRINSIC_ANY(&ctx->dt_double, "double", code); \ - ADD_INTRINSIC_ANY(&ctx->dt_half, "half", code); \ - ADD_INTRINSIC_ANY(&ctx->dt_float, "float", code); \ -} while (0) -#define ADD_INTRINSIC_ANY_INT(code) do { \ - ADD_INTRINSIC_ANY(&ctx->dt_uint, "uint", code); \ - ADD_INTRINSIC_ANY(&ctx->dt_int, "int", code); \ -} while (0) - -#define ADD_INTRINSIC_ANY_BOOL(code) ADD_INTRINSIC_ANY(&ctx->dt_bool, "bool", code) - -static void add_intrinsic1(Context *ctx, const char *fn, - const MOJOSHADER_astDataType *ret, - const MOJOSHADER_astDataType *dt1) -{ - const MOJOSHADER_astDataType *params[] = { dt1 }; - ADD_INTRINSIC(fn, ret, params); -} // add_intrinsic1 - -static void add_intrinsic2(Context *ctx, const char *fn, - const MOJOSHADER_astDataType *ret, - const MOJOSHADER_astDataType *dt1, - const MOJOSHADER_astDataType *dt2) -{ - const MOJOSHADER_astDataType *params[] = { dt1, dt2 }; - ADD_INTRINSIC(fn, ret, params); -} // add_intrinsic2 - -static void add_intrinsic3(Context *ctx, const char *fn, - const MOJOSHADER_astDataType *ret, - const MOJOSHADER_astDataType *dt1, - const MOJOSHADER_astDataType *dt2, - const MOJOSHADER_astDataType *dt3) -{ - const MOJOSHADER_astDataType *params[] = { dt1, dt2, dt3 }; - ADD_INTRINSIC(fn, ret, params); -} // add_intrinsic3 - -static void add_intrinsic4(Context *ctx, const char *fn, - const MOJOSHADER_astDataType *ret, - const MOJOSHADER_astDataType *dt1, - const MOJOSHADER_astDataType *dt2, - const MOJOSHADER_astDataType *dt3, - const MOJOSHADER_astDataType *dt4) -{ - const MOJOSHADER_astDataType *params[] = { dt1, dt2, dt3, dt4 }; - ADD_INTRINSIC(fn, ret, params); -} // add_intrinsic4 - -// PLEASE NOTE that add_intrinsic*() is called AFTER the various -// ADD_INTRINSIC_* macros, even though these look like functions that -// should be called first. They might be called multiple times by the macro. -// The variable "dt" is defined by the macro for use by your code. -static void add_intrinsic_SAME1_ANYf(Context *ctx, const char *fn) -{ - ADD_INTRINSIC_ANY_FLOAT(add_intrinsic1(ctx, fn, dt, dt)); -} // add_intrinsic_SAME1_ANYf - -static void add_intrinsic_SAME1_ANYfi(Context *ctx, const char *fn) -{ - ADD_INTRINSIC_ANY_INT(add_intrinsic1(ctx, fn, dt, dt)); - add_intrinsic_SAME1_ANYf(ctx, fn); -} // add_intrinsic_SAME1_ANYfi - -static void add_intrinsic_BOOL_ANYf(Context *ctx, const char *fn) -{ - ADD_INTRINSIC_ANY_FLOAT(add_intrinsic1(ctx, fn, &ctx->dt_bool, dt)); -} // add_intrinsic_BOOL_ANYf - -static void add_intrinsic_BOOL_ANYfib(Context *ctx, const char *fn) -{ - ADD_INTRINSIC_ANY_BOOL(add_intrinsic1(ctx, fn, &ctx->dt_bool, dt)); - ADD_INTRINSIC_ANY_INT(add_intrinsic1(ctx, fn, &ctx->dt_bool, dt)); - add_intrinsic_BOOL_ANYf(ctx, fn); -} // add_intrinsic_BOOL_ANYfib - -static void add_intrinsic_SAME1_ANYf_SAME1(Context *ctx, const char *fn) -{ - ADD_INTRINSIC_ANY_FLOAT(add_intrinsic2(ctx, fn, dt, dt, dt)); -} // add_intrinsic_SAME1_ANYf_SAME1 - -static void add_intrinsic_SAME1_ANYfi_SAME1(Context *ctx, const char *fn) -{ - ADD_INTRINSIC_ANY_INT(add_intrinsic2(ctx, fn, dt, dt, dt)); - add_intrinsic_SAME1_ANYf_SAME1(ctx, fn); -} // add_intrinsic_SAME1_ANYfi_SAME1 - -static void add_intrinsic_SAME1_ANYf_SAME1_SAME1(Context *ctx, const char *fn) -{ - ADD_INTRINSIC_ANY_FLOAT(add_intrinsic3(ctx, fn, dt, dt, dt, dt)); -} // add_intrinsic_SAME1_ANYf_SAME1_SAME1 - -static void add_intrinsic_SAME1_ANYfi_SAME1_SAME1(Context *ctx, const char *fn) -{ - ADD_INTRINSIC_ANY_INT(add_intrinsic3(ctx, fn, dt, dt, dt, dt)); - add_intrinsic_SAME1_ANYf_SAME1_SAME1(ctx, fn); -} // add_intrinsic_SAME1_ANYfi_SAME1_SAME1 - -static void add_intrinsic_SAME1_Mfib(Context *ctx, const char *fn) -{ - ADD_INTRINSIC_MATRIX_BOOL(add_intrinsic1(ctx, fn, dt, dt)); - ADD_INTRINSIC_MATRIX_INT(add_intrinsic1(ctx, fn, dt, dt)); - ADD_INTRINSIC_MATRIX_FLOAT(add_intrinsic1(ctx, fn, dt, dt)); -} // add_intrinsic_SAME1_Mfib - -static void add_intrinsic_SAME1_Vf(Context *ctx, const char *fn) -{ - ADD_INTRINSIC_VECTOR_FLOAT(add_intrinsic1(ctx, fn, dt, dt)); -} // add_intrinsic_SAME1_Vf - -static void add_intrinsic_SAME1_Vf_SAME1_SAME1(Context *ctx, const char *fn) -{ - ADD_INTRINSIC_VECTOR_FLOAT(add_intrinsic3(ctx, fn, dt, dt, dt, dt)); -} // add_intrinsic_SAME1_Vf_SAME1_SAME1 - -static void add_intrinsic_SAME1_Vf_SAME1_f(Context *ctx, const char *fn) -{ - ADD_INTRINSIC_VECTOR_FLOAT(add_intrinsic3(ctx, fn, dt, dt, dt, dt->user.details->vector.base)); -} // add_intrinsic_SAME1_Vf_SAME1_f - -static void add_intrinsic_VOID_ANYf(Context *ctx, const char *fn) -{ - ADD_INTRINSIC_ANY_FLOAT(add_intrinsic1(ctx, fn, NULL, dt)); -} // add_intrinsic_VOID_ANYf - -static void add_intrinsic_VOID_ANYf_SAME1_SAME1(Context *ctx, const char *fn) -{ - ADD_INTRINSIC_ANY_FLOAT(add_intrinsic3(ctx, fn, NULL, dt, dt, dt)); -} // add_intrinsic_VOID_ANYf_SAME1_SAME1 - -static void add_intrinsic_f_SQUAREMATRIXf(Context *ctx, const char *fn) -{ - add_intrinsic1(ctx, fn, &ctx->dt_float, get_usertype(ctx, "float1x1")); - add_intrinsic1(ctx, fn, &ctx->dt_float, get_usertype(ctx, "float2x2")); - add_intrinsic1(ctx, fn, &ctx->dt_float, get_usertype(ctx, "float3x3")); - add_intrinsic1(ctx, fn, &ctx->dt_float, get_usertype(ctx, "float4x4")); -} // add_intrinsic_f_SQUAREMATRIXf - -static void add_intrinsic_f_Vf(Context *ctx, const char *fn) -{ - ADD_INTRINSIC_VECTOR_FLOAT(add_intrinsic1(ctx, fn, dt->user.details->vector.base, dt)); -} // add_intrinsic_f_Vf - -static void add_intrinsic_fi_Vfi_SAME1(Context *ctx, const char *fn) -{ - ADD_INTRINSIC_VECTOR_INT(add_intrinsic2(ctx, fn, dt->user.details->vector.base, dt, dt)); - ADD_INTRINSIC_VECTOR_FLOAT(add_intrinsic2(ctx, fn, dt->user.details->vector.base, dt, dt)); -} // add_intrinsic_fi_Vfi_SAME1 - -static void add_intrinsic_f_Vf_SAME1(Context *ctx, const char *fn) -{ - ADD_INTRINSIC_VECTOR_FLOAT(add_intrinsic2(ctx, fn, dt->user.details->vector.base, dt, dt)); -} // add_intrinsic_f_Vf_SAME1 - -static void add_intrinsic_3f_3f_3f(Context *ctx, const char *fn) -{ - const MOJOSHADER_astDataType *dt = get_usertype(ctx, "float3"); - add_intrinsic2(ctx, fn, dt, dt, dt); -} // add_intrinsic_3f_3f_3f - -static void add_intrinsic_4f_f_f_f(Context *ctx, const char *fn) -{ - const MOJOSHADER_astDataType *f4 = get_usertype(ctx, "float4"); - const MOJOSHADER_astDataType *f = &ctx->dt_float; - add_intrinsic3(ctx, fn, f4, f, f, f); -} // add_intrinsic_4f_f_f_f - -static void add_intrinsic_4f_s1_4f(Context *ctx, const char *fn) -{ - const MOJOSHADER_astDataType *dt = get_usertype(ctx, "float4"); - add_intrinsic2(ctx, fn, dt, &ctx->dt_sampler1d, dt); -} // add_intrinsic_4f_s1_4f - -static void add_intrinsic_4f_s1_f(Context *ctx, const char *fn) -{ - const MOJOSHADER_astDataType *dt = get_usertype(ctx, "float4"); - add_intrinsic2(ctx, fn, dt, &ctx->dt_sampler1d, &ctx->dt_float); -} // add_intrinsic_4f_s1_f - -static void add_intrinsic_4f_s1_f_f_f(Context *ctx, const char *fn) -{ - const MOJOSHADER_astDataType *dt = get_usertype(ctx, "float4"); - const MOJOSHADER_astDataType *f = &ctx->dt_float; - add_intrinsic4(ctx, fn, dt, &ctx->dt_sampler1d, f, f, f); -} // add_intrinsic_4f_s1_f_f_f - -static void add_intrinsic_4f_s2_2f(Context *ctx, const char *fn) -{ - const MOJOSHADER_astDataType *f4 = get_usertype(ctx, "float4"); - const MOJOSHADER_astDataType *f2 = get_usertype(ctx, "float2"); - add_intrinsic2(ctx, fn, f4, &ctx->dt_sampler2d, f2); -} // add_intrinsic_4f_s2_2f - -static void add_intrinsic_4f_s2_2f_2f_2f(Context *ctx, const char *fn) -{ - const MOJOSHADER_astDataType *f4 = get_usertype(ctx, "float4"); - const MOJOSHADER_astDataType *f2 = get_usertype(ctx, "float2"); - add_intrinsic4(ctx, fn, f4, &ctx->dt_sampler2d, f2, f2, f2); -} // add_intrinsic_4f_s2_2f_2f_2f - -static void add_intrinsic_4f_s2_4f(Context *ctx, const char *fn) -{ - const MOJOSHADER_astDataType *f4 = get_usertype(ctx, "float4"); - add_intrinsic2(ctx, fn, f4, &ctx->dt_sampler2d, f4); -} // add_intrinsic_4f_s2_4f - -static void add_intrinsic_4f_s3_3f(Context *ctx, const char *fn) -{ - const MOJOSHADER_astDataType *f4 = get_usertype(ctx, "float4"); - const MOJOSHADER_astDataType *f3 = get_usertype(ctx, "float3"); - add_intrinsic2(ctx, fn, f4, &ctx->dt_sampler3d, f3); -} // add_intrinsic_4f_s3_3f - -static void add_intrinsic_4f_s3_3f_3f_3f(Context *ctx, const char *fn) -{ - const MOJOSHADER_astDataType *f4 = get_usertype(ctx, "float4"); - const MOJOSHADER_astDataType *f3 = get_usertype(ctx, "float3"); - add_intrinsic4(ctx, fn, f4, &ctx->dt_sampler3d, f3, f3, f3); -} // add_intrinsic_4f_s3_3f_3f_3f - -static void add_intrinsic_4f_s3_4f(Context *ctx, const char *fn) -{ - const MOJOSHADER_astDataType *f4 = get_usertype(ctx, "float4"); - add_intrinsic2(ctx, fn, f4, &ctx->dt_sampler3d, f4); -} // add_intrinsic_4f_s3_4f - -static void add_intrinsic_4f_sc_3f(Context *ctx, const char *fn) -{ - const MOJOSHADER_astDataType *f4 = get_usertype(ctx, "float4"); - const MOJOSHADER_astDataType *f3 = get_usertype(ctx, "float3"); - add_intrinsic2(ctx, fn, f4, &ctx->dt_samplercube, f3); -} // add_intrinsic_4f_sc_3f - -static void add_intrinsic_4f_sc_3f_3f_3f(Context *ctx, const char *fn) -{ - const MOJOSHADER_astDataType *f4 = get_usertype(ctx, "float4"); - const MOJOSHADER_astDataType *f3 = get_usertype(ctx, "float3"); - add_intrinsic4(ctx, fn, f4, &ctx->dt_samplercube, f3, f3, f3); -} // add_intrinsic_4f_sc_3f_3f_3f - -static void add_intrinsic_4f_sc_4f(Context *ctx, const char *fn) -{ - const MOJOSHADER_astDataType *f4 = get_usertype(ctx, "float4"); - add_intrinsic2(ctx, fn, f4, &ctx->dt_samplercube, f4); -} // add_intrinsic_4f_sc_4f - -static void add_intrinsic_4i_4f(Context *ctx, const char *fn) -{ - const MOJOSHADER_astDataType *i4 = get_usertype(ctx, "int4"); - const MOJOSHADER_astDataType *f4 = get_usertype(ctx, "float4"); - add_intrinsic1(ctx, fn, i4, f4); -} // add_intrinsic_4i_4f - -static void add_intrinsic_mul(Context *ctx, const char *fn) -{ - // mul() is nasty, since there's a bunch of overloads that aren't just - // related to vector size. - // !!! FIXME: needs half, double, uint... - const MOJOSHADER_astDataType *dtf = &ctx->dt_float; - const MOJOSHADER_astDataType *dti = &ctx->dt_int; - const MOJOSHADER_astDataType *f1 = get_usertype(ctx, "float1"); - const MOJOSHADER_astDataType *f2 = get_usertype(ctx, "float2"); - const MOJOSHADER_astDataType *f3 = get_usertype(ctx, "float3"); - const MOJOSHADER_astDataType *f4 = get_usertype(ctx, "float4"); - const MOJOSHADER_astDataType *i1 = get_usertype(ctx, "int1"); - const MOJOSHADER_astDataType *i2 = get_usertype(ctx, "int2"); - const MOJOSHADER_astDataType *i3 = get_usertype(ctx, "int3"); - const MOJOSHADER_astDataType *i4 = get_usertype(ctx, "int4"); - const MOJOSHADER_astDataType *f1x1 = get_usertype(ctx, "float1x1"); - const MOJOSHADER_astDataType *f1x2 = get_usertype(ctx, "float1x2"); - const MOJOSHADER_astDataType *f1x3 = get_usertype(ctx, "float1x3"); - const MOJOSHADER_astDataType *f1x4 = get_usertype(ctx, "float1x4"); - const MOJOSHADER_astDataType *f2x1 = get_usertype(ctx, "float2x1"); - const MOJOSHADER_astDataType *f2x2 = get_usertype(ctx, "float2x2"); - const MOJOSHADER_astDataType *f2x3 = get_usertype(ctx, "float2x3"); - const MOJOSHADER_astDataType *f2x4 = get_usertype(ctx, "float2x4"); - const MOJOSHADER_astDataType *f3x1 = get_usertype(ctx, "float3x1"); - const MOJOSHADER_astDataType *f3x2 = get_usertype(ctx, "float3x2"); - const MOJOSHADER_astDataType *f3x3 = get_usertype(ctx, "float3x3"); - const MOJOSHADER_astDataType *f3x4 = get_usertype(ctx, "float3x4"); - const MOJOSHADER_astDataType *f4x1 = get_usertype(ctx, "float4x1"); - const MOJOSHADER_astDataType *f4x2 = get_usertype(ctx, "float4x2"); - const MOJOSHADER_astDataType *f4x3 = get_usertype(ctx, "float4x3"); - const MOJOSHADER_astDataType *f4x4 = get_usertype(ctx, "float4x4"); - const MOJOSHADER_astDataType *i1x1 = get_usertype(ctx, "int1x1"); - const MOJOSHADER_astDataType *i1x2 = get_usertype(ctx, "int1x2"); - const MOJOSHADER_astDataType *i1x3 = get_usertype(ctx, "int1x3"); - const MOJOSHADER_astDataType *i1x4 = get_usertype(ctx, "int1x4"); - const MOJOSHADER_astDataType *i2x1 = get_usertype(ctx, "int2x1"); - const MOJOSHADER_astDataType *i2x2 = get_usertype(ctx, "int2x2"); - const MOJOSHADER_astDataType *i2x3 = get_usertype(ctx, "int2x3"); - const MOJOSHADER_astDataType *i2x4 = get_usertype(ctx, "int2x4"); - const MOJOSHADER_astDataType *i3x1 = get_usertype(ctx, "int3x1"); - const MOJOSHADER_astDataType *i3x2 = get_usertype(ctx, "int3x2"); - const MOJOSHADER_astDataType *i3x3 = get_usertype(ctx, "int3x3"); - const MOJOSHADER_astDataType *i3x4 = get_usertype(ctx, "int3x4"); - const MOJOSHADER_astDataType *i4x1 = get_usertype(ctx, "int4x1"); - const MOJOSHADER_astDataType *i4x2 = get_usertype(ctx, "int4x2"); - const MOJOSHADER_astDataType *i4x3 = get_usertype(ctx, "int4x3"); - const MOJOSHADER_astDataType *i4x4 = get_usertype(ctx, "int4x4"); - - // scalar * scalar - add_intrinsic2(ctx, fn, dti, dti, dti); - add_intrinsic2(ctx, fn, dtf, dtf, dtf); - - // scalar * vector - ADD_INTRINSIC_VECTOR_INT(add_intrinsic2(ctx, fn, dt, dti, dt)); - ADD_INTRINSIC_VECTOR_FLOAT(add_intrinsic2(ctx, fn, dt, dtf, dt)); - - // scalar * matrix - ADD_INTRINSIC_MATRIX_INT(add_intrinsic2(ctx, fn, dt, dti, dt)); - ADD_INTRINSIC_MATRIX_FLOAT(add_intrinsic2(ctx, fn, dt, dtf, dt)); - - // vector * scalar - ADD_INTRINSIC_VECTOR_INT(add_intrinsic2(ctx, fn, dt, dt, dti)); - ADD_INTRINSIC_VECTOR_FLOAT(add_intrinsic2(ctx, fn, dt, dt, dtf)); - - // vector * vector - ADD_INTRINSIC_VECTOR_INT(add_intrinsic2(ctx, fn, dti, dt, dt)); - ADD_INTRINSIC_VECTOR_FLOAT(add_intrinsic2(ctx, fn, dtf, dt, dt)); - - // vector * matrix - add_intrinsic2(ctx, fn, i1, i1, i1x1); - add_intrinsic2(ctx, fn, i2, i1, i1x2); - add_intrinsic2(ctx, fn, i3, i1, i1x3); - add_intrinsic2(ctx, fn, i4, i1, i1x4); - add_intrinsic2(ctx, fn, i1, i2, i2x1); - add_intrinsic2(ctx, fn, i2, i2, i2x2); - add_intrinsic2(ctx, fn, i3, i2, i2x3); - add_intrinsic2(ctx, fn, i4, i2, i2x4); - add_intrinsic2(ctx, fn, i1, i3, i3x1); - add_intrinsic2(ctx, fn, i2, i3, i3x2); - add_intrinsic2(ctx, fn, i3, i3, i3x3); - add_intrinsic2(ctx, fn, i4, i3, i3x4); - add_intrinsic2(ctx, fn, i1, i4, i4x1); - add_intrinsic2(ctx, fn, i2, i4, i4x2); - add_intrinsic2(ctx, fn, i3, i4, i4x3); - add_intrinsic2(ctx, fn, i4, i4, i4x4); - add_intrinsic2(ctx, fn, f1, f1, f1x1); - add_intrinsic2(ctx, fn, f2, f1, f1x2); - add_intrinsic2(ctx, fn, f3, f1, f1x3); - add_intrinsic2(ctx, fn, f4, f1, f1x4); - add_intrinsic2(ctx, fn, f1, f2, f2x1); - add_intrinsic2(ctx, fn, f2, f2, f2x2); - add_intrinsic2(ctx, fn, f3, f2, f2x3); - add_intrinsic2(ctx, fn, f4, f2, f2x4); - add_intrinsic2(ctx, fn, f1, f3, f3x1); - add_intrinsic2(ctx, fn, f2, f3, f3x2); - add_intrinsic2(ctx, fn, f3, f3, f3x3); - add_intrinsic2(ctx, fn, f4, f3, f3x4); - add_intrinsic2(ctx, fn, f1, f4, f4x1); - add_intrinsic2(ctx, fn, f2, f4, f4x2); - add_intrinsic2(ctx, fn, f3, f4, f4x3); - add_intrinsic2(ctx, fn, f4, f4, f4x4); - - // matrix * scalar - ADD_INTRINSIC_MATRIX_INT(add_intrinsic2(ctx, fn, dt, dt, dti)); - ADD_INTRINSIC_MATRIX_FLOAT(add_intrinsic2(ctx, fn, dt, dt, dtf)); - - // matrix * vector - add_intrinsic2(ctx, fn, i1, i1x1, i1); - add_intrinsic2(ctx, fn, i1, i1x2, i2); - add_intrinsic2(ctx, fn, i1, i1x3, i3); - add_intrinsic2(ctx, fn, i1, i1x4, i4); - add_intrinsic2(ctx, fn, i2, i2x1, i1); - add_intrinsic2(ctx, fn, i2, i2x2, i2); - add_intrinsic2(ctx, fn, i2, i2x3, i3); - add_intrinsic2(ctx, fn, i2, i2x4, i4); - add_intrinsic2(ctx, fn, i3, i3x1, i1); - add_intrinsic2(ctx, fn, i3, i3x2, i2); - add_intrinsic2(ctx, fn, i3, i3x3, i3); - add_intrinsic2(ctx, fn, i3, i3x4, i4); - add_intrinsic2(ctx, fn, i4, i4x1, i1); - add_intrinsic2(ctx, fn, i4, i4x2, i2); - add_intrinsic2(ctx, fn, i4, i4x3, i3); - add_intrinsic2(ctx, fn, i4, i4x4, i4); - add_intrinsic2(ctx, fn, f1, f1x1, f1); - add_intrinsic2(ctx, fn, f1, f1x2, f2); - add_intrinsic2(ctx, fn, f1, f1x3, f3); - add_intrinsic2(ctx, fn, f1, f1x4, f4); - add_intrinsic2(ctx, fn, f2, f2x1, f1); - add_intrinsic2(ctx, fn, f2, f2x2, f2); - add_intrinsic2(ctx, fn, f2, f2x3, f3); - add_intrinsic2(ctx, fn, f2, f2x4, f4); - add_intrinsic2(ctx, fn, f3, f3x1, f1); - add_intrinsic2(ctx, fn, f3, f3x2, f2); - add_intrinsic2(ctx, fn, f3, f3x3, f3); - add_intrinsic2(ctx, fn, f3, f3x4, f4); - add_intrinsic2(ctx, fn, f4, f4x1, f1); - add_intrinsic2(ctx, fn, f4, f4x2, f2); - add_intrinsic2(ctx, fn, f4, f4x3, f3); - add_intrinsic2(ctx, fn, f4, f4x4, f4); - - // matrix * matrix - add_intrinsic2(ctx, fn, i1x1, i1x1, i1x1); - add_intrinsic2(ctx, fn, i1x2, i1x1, i1x2); - add_intrinsic2(ctx, fn, i1x3, i1x1, i1x3); - add_intrinsic2(ctx, fn, i1x4, i1x1, i1x4); - add_intrinsic2(ctx, fn, i1x1, i1x2, i2x1); - add_intrinsic2(ctx, fn, i1x2, i1x2, i2x2); - add_intrinsic2(ctx, fn, i1x3, i1x2, i2x3); - add_intrinsic2(ctx, fn, i1x4, i1x2, i2x4); - add_intrinsic2(ctx, fn, i1x1, i1x3, i3x1); - add_intrinsic2(ctx, fn, i1x2, i1x3, i3x2); - add_intrinsic2(ctx, fn, i1x3, i1x3, i3x3); - add_intrinsic2(ctx, fn, i1x4, i1x3, i3x4); - add_intrinsic2(ctx, fn, i1x1, i1x4, i4x1); - add_intrinsic2(ctx, fn, i1x2, i1x4, i4x2); - add_intrinsic2(ctx, fn, i1x3, i1x4, i4x3); - add_intrinsic2(ctx, fn, i1x4, i1x4, i4x4); - add_intrinsic2(ctx, fn, i2x1, i2x1, i1x1); - add_intrinsic2(ctx, fn, i2x2, i2x1, i1x2); - add_intrinsic2(ctx, fn, i2x3, i2x1, i1x3); - add_intrinsic2(ctx, fn, i2x4, i2x1, i1x4); - add_intrinsic2(ctx, fn, i2x1, i2x2, i2x1); - add_intrinsic2(ctx, fn, i2x2, i2x2, i2x2); - add_intrinsic2(ctx, fn, i2x3, i2x2, i2x3); - add_intrinsic2(ctx, fn, i2x4, i2x2, i2x4); - add_intrinsic2(ctx, fn, i2x1, i2x3, i3x1); - add_intrinsic2(ctx, fn, i2x2, i2x3, i3x2); - add_intrinsic2(ctx, fn, i2x3, i2x3, i3x3); - add_intrinsic2(ctx, fn, i2x4, i2x3, i3x4); - add_intrinsic2(ctx, fn, i2x1, i2x4, i4x1); - add_intrinsic2(ctx, fn, i2x2, i2x4, i4x2); - add_intrinsic2(ctx, fn, i2x3, i2x4, i4x3); - add_intrinsic2(ctx, fn, i2x4, i2x4, i4x4); - add_intrinsic2(ctx, fn, i3x1, i3x1, i1x1); - add_intrinsic2(ctx, fn, i3x2, i3x1, i1x2); - add_intrinsic2(ctx, fn, i3x3, i3x1, i1x3); - add_intrinsic2(ctx, fn, i3x4, i3x1, i1x4); - add_intrinsic2(ctx, fn, i3x1, i3x2, i2x1); - add_intrinsic2(ctx, fn, i3x2, i3x2, i2x2); - add_intrinsic2(ctx, fn, i3x3, i3x2, i2x3); - add_intrinsic2(ctx, fn, i3x4, i3x2, i2x4); - add_intrinsic2(ctx, fn, i3x1, i3x3, i3x1); - add_intrinsic2(ctx, fn, i3x2, i3x3, i3x2); - add_intrinsic2(ctx, fn, i3x3, i3x3, i3x3); - add_intrinsic2(ctx, fn, i3x4, i3x3, i3x4); - add_intrinsic2(ctx, fn, i3x1, i3x4, i4x1); - add_intrinsic2(ctx, fn, i3x2, i3x4, i4x2); - add_intrinsic2(ctx, fn, i3x3, i3x4, i4x3); - add_intrinsic2(ctx, fn, i3x4, i3x4, i4x4); - add_intrinsic2(ctx, fn, i4x1, i4x1, i1x1); - add_intrinsic2(ctx, fn, i4x2, i4x1, i1x2); - add_intrinsic2(ctx, fn, i4x3, i4x1, i1x3); - add_intrinsic2(ctx, fn, i4x4, i4x1, i1x4); - add_intrinsic2(ctx, fn, i4x1, i4x2, i2x1); - add_intrinsic2(ctx, fn, i4x2, i4x2, i2x2); - add_intrinsic2(ctx, fn, i4x3, i4x2, i2x3); - add_intrinsic2(ctx, fn, i4x4, i4x2, i2x4); - add_intrinsic2(ctx, fn, i4x1, i4x3, i3x1); - add_intrinsic2(ctx, fn, i4x2, i4x3, i3x2); - add_intrinsic2(ctx, fn, i4x3, i4x3, i3x3); - add_intrinsic2(ctx, fn, i4x4, i4x3, i3x4); - add_intrinsic2(ctx, fn, i4x1, i4x4, i4x1); - add_intrinsic2(ctx, fn, i4x2, i4x4, i4x2); - add_intrinsic2(ctx, fn, i4x3, i4x4, i4x3); - add_intrinsic2(ctx, fn, i4x4, i4x4, i4x4); - add_intrinsic2(ctx, fn, f1x1, f1x1, f1x1); - add_intrinsic2(ctx, fn, f1x2, f1x1, f1x2); - add_intrinsic2(ctx, fn, f1x3, f1x1, f1x3); - add_intrinsic2(ctx, fn, f1x4, f1x1, f1x4); - add_intrinsic2(ctx, fn, f1x1, f1x2, f2x1); - add_intrinsic2(ctx, fn, f1x2, f1x2, f2x2); - add_intrinsic2(ctx, fn, f1x3, f1x2, f2x3); - add_intrinsic2(ctx, fn, f1x4, f1x2, f2x4); - add_intrinsic2(ctx, fn, f1x1, f1x3, f3x1); - add_intrinsic2(ctx, fn, f1x2, f1x3, f3x2); - add_intrinsic2(ctx, fn, f1x3, f1x3, f3x3); - add_intrinsic2(ctx, fn, f1x4, f1x3, f3x4); - add_intrinsic2(ctx, fn, f1x1, f1x4, f4x1); - add_intrinsic2(ctx, fn, f1x2, f1x4, f4x2); - add_intrinsic2(ctx, fn, f1x3, f1x4, f4x3); - add_intrinsic2(ctx, fn, f1x4, f1x4, f4x4); - add_intrinsic2(ctx, fn, f2x1, f2x1, f1x1); - add_intrinsic2(ctx, fn, f2x2, f2x1, f1x2); - add_intrinsic2(ctx, fn, f2x3, f2x1, f1x3); - add_intrinsic2(ctx, fn, f2x4, f2x1, f1x4); - add_intrinsic2(ctx, fn, f2x1, f2x2, f2x1); - add_intrinsic2(ctx, fn, f2x2, f2x2, f2x2); - add_intrinsic2(ctx, fn, f2x3, f2x2, f2x3); - add_intrinsic2(ctx, fn, f2x4, f2x2, f2x4); - add_intrinsic2(ctx, fn, f2x1, f2x3, f3x1); - add_intrinsic2(ctx, fn, f2x2, f2x3, f3x2); - add_intrinsic2(ctx, fn, f2x3, f2x3, f3x3); - add_intrinsic2(ctx, fn, f2x4, f2x3, f3x4); - add_intrinsic2(ctx, fn, f2x1, f2x4, f4x1); - add_intrinsic2(ctx, fn, f2x2, f2x4, f4x2); - add_intrinsic2(ctx, fn, f2x3, f2x4, f4x3); - add_intrinsic2(ctx, fn, f2x4, f2x4, f4x4); - add_intrinsic2(ctx, fn, f3x1, f3x1, f1x1); - add_intrinsic2(ctx, fn, f3x2, f3x1, f1x2); - add_intrinsic2(ctx, fn, f3x3, f3x1, f1x3); - add_intrinsic2(ctx, fn, f3x4, f3x1, f1x4); - add_intrinsic2(ctx, fn, f3x1, f3x2, f2x1); - add_intrinsic2(ctx, fn, f3x2, f3x2, f2x2); - add_intrinsic2(ctx, fn, f3x3, f3x2, f2x3); - add_intrinsic2(ctx, fn, f3x4, f3x2, f2x4); - add_intrinsic2(ctx, fn, f3x1, f3x3, f3x1); - add_intrinsic2(ctx, fn, f3x2, f3x3, f3x2); - add_intrinsic2(ctx, fn, f3x3, f3x3, f3x3); - add_intrinsic2(ctx, fn, f3x4, f3x3, f3x4); - add_intrinsic2(ctx, fn, f3x1, f3x4, f4x1); - add_intrinsic2(ctx, fn, f3x2, f3x4, f4x2); - add_intrinsic2(ctx, fn, f3x3, f3x4, f4x3); - add_intrinsic2(ctx, fn, f3x4, f3x4, f4x4); - add_intrinsic2(ctx, fn, f4x1, f4x1, f1x1); - add_intrinsic2(ctx, fn, f4x2, f4x1, f1x2); - add_intrinsic2(ctx, fn, f4x3, f4x1, f1x3); - add_intrinsic2(ctx, fn, f4x4, f4x1, f1x4); - add_intrinsic2(ctx, fn, f4x1, f4x2, f2x1); - add_intrinsic2(ctx, fn, f4x2, f4x2, f2x2); - add_intrinsic2(ctx, fn, f4x3, f4x2, f2x3); - add_intrinsic2(ctx, fn, f4x4, f4x2, f2x4); - add_intrinsic2(ctx, fn, f4x1, f4x3, f3x1); - add_intrinsic2(ctx, fn, f4x2, f4x3, f3x2); - add_intrinsic2(ctx, fn, f4x3, f4x3, f3x3); - add_intrinsic2(ctx, fn, f4x4, f4x3, f3x4); - add_intrinsic2(ctx, fn, f4x1, f4x4, f4x1); - add_intrinsic2(ctx, fn, f4x2, f4x4, f4x2); - add_intrinsic2(ctx, fn, f4x3, f4x4, f4x3); - add_intrinsic2(ctx, fn, f4x4, f4x4, f4x4); -} // add_intrinsic_mul - -static void init_builtins(Context *ctx) -{ - // add in standard typedefs... - const struct - { - const char *str; - const MOJOSHADER_astDataType *datatype; - } types[] = { - { "bool", &ctx->dt_bool }, - { "int", &ctx->dt_int }, - { "uint", &ctx->dt_uint }, - { "half", &ctx->dt_half }, - { "float", &ctx->dt_float }, - { "double", &ctx->dt_double }, - }; - - int i, j, k; - for (i = 0; i < STATICARRAYLEN(types); i++) - { - char buf[32]; - int len; - const MOJOSHADER_astDataType *dt; - - for (j = 1; j <= 4; j++) - { - // "float2" - dt = new_datatype_vector(ctx, types[i].datatype, j); - len = snprintf(buf, sizeof (buf), "%s%d", types[i].str, j); - push_usertype(ctx, stringcache_len(ctx->strcache, buf, len), dt); - for (k = 1; k <= 4; k++) - { - // "float2x2" - dt = new_datatype_matrix(ctx, types[i].datatype, j, k); - len = snprintf(buf, sizeof (buf), "%s%dx%d", types[i].str,j,k); - push_usertype(ctx, stringcache_len(ctx->strcache,buf,len), dt); - } // for - } // for - } // for - - // !!! FIXME: block these out by pixel/vertex/etc shader. - // !!! FIXME: calculate actual shader model (or maybe just let bytecode verifier throw up?). - const int shader_model = 3; - if (shader_model >= 1) - { - add_intrinsic_SAME1_ANYfi(ctx, stringcache(ctx->strcache, "abs")); - add_intrinsic_SAME1_ANYf(ctx, stringcache(ctx->strcache, "acos")); - add_intrinsic_BOOL_ANYfib(ctx, stringcache(ctx->strcache, "all")); - add_intrinsic_BOOL_ANYfib(ctx, stringcache(ctx->strcache, "any")); - add_intrinsic_SAME1_ANYf(ctx, stringcache(ctx->strcache, "asin")); - add_intrinsic_SAME1_ANYf(ctx, stringcache(ctx->strcache, "atan")); - add_intrinsic_SAME1_ANYf_SAME1(ctx, stringcache(ctx->strcache, "atan2")); - add_intrinsic_SAME1_ANYf(ctx, stringcache(ctx->strcache, "ceil")); - add_intrinsic_SAME1_ANYfi_SAME1_SAME1(ctx, stringcache(ctx->strcache, "clamp")); - add_intrinsic_VOID_ANYf(ctx, stringcache(ctx->strcache, "clip")); - add_intrinsic_SAME1_ANYf(ctx, stringcache(ctx->strcache, "cos")); - add_intrinsic_SAME1_ANYf(ctx, stringcache(ctx->strcache, "cosh")); - add_intrinsic_3f_3f_3f(ctx, stringcache(ctx->strcache, "cross")); - add_intrinsic_4i_4f(ctx, stringcache(ctx->strcache, "D3DCOLORtoUBYTE4")); - add_intrinsic_f_Vf_SAME1(ctx, stringcache(ctx->strcache, "distance")); - add_intrinsic_SAME1_ANYf(ctx, stringcache(ctx->strcache, "degrees")); - add_intrinsic_f_SQUAREMATRIXf(ctx, stringcache(ctx->strcache, "determinant")); - add_intrinsic_fi_Vfi_SAME1(ctx, stringcache(ctx->strcache, "dot")); - add_intrinsic_SAME1_ANYf(ctx, stringcache(ctx->strcache, "exp")); - add_intrinsic_SAME1_ANYf(ctx, stringcache(ctx->strcache, "exp2")); - add_intrinsic_SAME1_Vf_SAME1_SAME1(ctx, stringcache(ctx->strcache, "faceforward")); - add_intrinsic_SAME1_ANYf(ctx, stringcache(ctx->strcache, "floor")); - add_intrinsic_SAME1_ANYf_SAME1(ctx, stringcache(ctx->strcache, "fmod")); - add_intrinsic_SAME1_ANYf(ctx, stringcache(ctx->strcache, "frac")); - add_intrinsic_BOOL_ANYf(ctx, stringcache(ctx->strcache, "isfinite")); - add_intrinsic_BOOL_ANYf(ctx, stringcache(ctx->strcache, "isinf")); - add_intrinsic_BOOL_ANYf(ctx, stringcache(ctx->strcache, "isnan")); - add_intrinsic_SAME1_ANYf_SAME1(ctx, stringcache(ctx->strcache, "ldexp")); - add_intrinsic_f_Vf(ctx, stringcache(ctx->strcache, "length")); - add_intrinsic_SAME1_ANYf_SAME1_SAME1(ctx, stringcache(ctx->strcache, "lerp")); - add_intrinsic_4f_f_f_f(ctx, stringcache(ctx->strcache, "lit")); - add_intrinsic_SAME1_ANYf(ctx, stringcache(ctx->strcache, "log")); - add_intrinsic_SAME1_ANYf(ctx, stringcache(ctx->strcache, "log10")); - add_intrinsic_SAME1_ANYf(ctx, stringcache(ctx->strcache, "log2")); - add_intrinsic_SAME1_ANYfi_SAME1(ctx, stringcache(ctx->strcache, "max")); - add_intrinsic_SAME1_ANYfi_SAME1(ctx, stringcache(ctx->strcache, "min")); - add_intrinsic_SAME1_ANYfi_SAME1(ctx, stringcache(ctx->strcache, "modf")); // !!! FIXME: out var? - add_intrinsic_mul(ctx, stringcache(ctx->strcache, "mul")); - add_intrinsic_f_Vf(ctx, stringcache(ctx->strcache, "noise")); - add_intrinsic_SAME1_Vf(ctx, stringcache(ctx->strcache, "normalize")); - add_intrinsic_SAME1_ANYf_SAME1(ctx, stringcache(ctx->strcache, "pow")); - add_intrinsic_SAME1_ANYf(ctx, stringcache(ctx->strcache, "radians")); - add_intrinsic_SAME1_ANYfi_SAME1(ctx, stringcache(ctx->strcache, "reflect")); - add_intrinsic_SAME1_Vf_SAME1_f(ctx, stringcache(ctx->strcache, "refract")); - add_intrinsic_SAME1_ANYf(ctx, stringcache(ctx->strcache, "round")); - add_intrinsic_SAME1_ANYf(ctx, stringcache(ctx->strcache, "rsqrt")); - add_intrinsic_SAME1_ANYf(ctx, stringcache(ctx->strcache, "saturate")); - add_intrinsic_SAME1_ANYf(ctx, stringcache(ctx->strcache, "sign")); - add_intrinsic_SAME1_ANYf(ctx, stringcache(ctx->strcache, "sin")); - add_intrinsic_VOID_ANYf_SAME1_SAME1(ctx, stringcache(ctx->strcache, "sincos")); // !!! FIXME: out var? - add_intrinsic_SAME1_ANYf(ctx, stringcache(ctx->strcache, "sinh")); - add_intrinsic_SAME1_ANYf_SAME1_SAME1(ctx, stringcache(ctx->strcache, "smoothstep")); - add_intrinsic_SAME1_ANYf(ctx, stringcache(ctx->strcache, "sqrt")); - add_intrinsic_SAME1_ANYf_SAME1(ctx, stringcache(ctx->strcache, "step")); - add_intrinsic_SAME1_ANYf(ctx, stringcache(ctx->strcache, "tan")); - add_intrinsic_SAME1_ANYf(ctx, stringcache(ctx->strcache, "tanh")); - add_intrinsic_4f_s1_f(ctx, stringcache(ctx->strcache, "tex1D")); - add_intrinsic_4f_s2_2f(ctx, stringcache(ctx->strcache, "tex2D")); - add_intrinsic_4f_s3_3f(ctx, stringcache(ctx->strcache, "tex3D")); - add_intrinsic_4f_sc_3f(ctx, stringcache(ctx->strcache, "texCUBE")); - add_intrinsic_SAME1_Mfib(ctx, stringcache(ctx->strcache, "transpose")); - add_intrinsic_SAME1_ANYf(ctx, stringcache(ctx->strcache, "trunc")); - } // if - - if (shader_model >= 2) - { - add_intrinsic_SAME1_ANYf(ctx, stringcache(ctx->strcache, "ddx")); - add_intrinsic_SAME1_ANYf(ctx, stringcache(ctx->strcache, "ddy")); - add_intrinsic_SAME1_ANYf_SAME1(ctx, stringcache(ctx->strcache, "frexp")); - add_intrinsic_SAME1_ANYf(ctx, stringcache(ctx->strcache, "fwidth")); - add_intrinsic_4f_s1_f_f_f(ctx, stringcache(ctx->strcache, "tex1D")); - add_intrinsic_4f_s1_4f(ctx, stringcache(ctx->strcache, "tex1Dbias")); - add_intrinsic_4f_s1_f_f_f(ctx, stringcache(ctx->strcache, "tex1Dgrad")); - add_intrinsic_4f_s1_4f(ctx, stringcache(ctx->strcache, "tex1Dproj")); - add_intrinsic_4f_s2_2f_2f_2f(ctx, stringcache(ctx->strcache, "tex2D")); - add_intrinsic_4f_s2_4f(ctx, stringcache(ctx->strcache, "tex2Dbias")); - add_intrinsic_4f_s2_2f_2f_2f(ctx, stringcache(ctx->strcache, "tex2Dgrad")); - add_intrinsic_4f_s2_4f(ctx, stringcache(ctx->strcache, "tex2Dproj")); - add_intrinsic_4f_s3_3f_3f_3f(ctx, stringcache(ctx->strcache, "tex3D")); - add_intrinsic_4f_s3_4f(ctx, stringcache(ctx->strcache, "tex3Dbias")); - add_intrinsic_4f_s3_3f_3f_3f(ctx, stringcache(ctx->strcache, "tex3Dgrad")); - add_intrinsic_4f_s3_4f(ctx, stringcache(ctx->strcache, "tex3Dproj")); - add_intrinsic_4f_sc_3f_3f_3f(ctx, stringcache(ctx->strcache, "texCUBE")); - add_intrinsic_4f_sc_4f(ctx, stringcache(ctx->strcache, "texCUBEbias")); - add_intrinsic_4f_sc_3f_3f_3f(ctx, stringcache(ctx->strcache, "texCUBEgrad")); - add_intrinsic_4f_sc_4f(ctx, stringcache(ctx->strcache, "texCUBEproj")); - } // if - - if (shader_model >= 3) - { - add_intrinsic_4f_s1_4f(ctx, stringcache(ctx->strcache, "tex1Dlod")); - add_intrinsic_4f_s2_4f(ctx, stringcache(ctx->strcache, "tex2Dlod")); - add_intrinsic_4f_s3_4f(ctx, stringcache(ctx->strcache, "tex3Dlod")); - add_intrinsic_4f_sc_4f(ctx, stringcache(ctx->strcache, "texCUBElod")); - } // if -} // init_builtins - - -// parse the source code into an AST. -static void parse_source(Context *ctx, const char *filename, - const char *source, unsigned int sourcelen, - const MOJOSHADER_preprocessorDefine *defines, - unsigned int define_count, - MOJOSHADER_includeOpen include_open, - MOJOSHADER_includeClose include_close) -{ - TokenData data; - unsigned int tokenlen; - Token tokenval; - const char *token; - int lemon_token; - const char *fname; - Preprocessor *pp; - void *parser; - - if (!include_open) include_open = MOJOSHADER_internal_include_open; - if (!include_close) include_close = MOJOSHADER_internal_include_close; - - pp = preprocessor_start(filename, source, sourcelen, include_open, - include_close, defines, define_count, 0, - MallocBridge, FreeBridge, ctx); - if (pp == NULL) - { - assert(ctx->out_of_memory); // shouldn't fail for any other reason. - return; - } // if - - parser = ParseHLSLAlloc(ctx->malloc, ctx->malloc_data); - if (parser == NULL) - { - assert(ctx->out_of_memory); // shouldn't fail for any other reason. - preprocessor_end(pp); - return; - } // if - - // !!! FIXME: check if (parser == NULL)... - - init_builtins(ctx); - - SymbolScope *start_scope = ctx->usertypes.scope; - - #if DEBUG_COMPILER_PARSER - ParseHLSLTrace(stdout, "COMPILER: "); - #endif - - // Run the preprocessor/lexer/parser... - int is_pragma = 0; // !!! FIXME: remove this later when we can parse #pragma. - int skipping = 0; // !!! FIXME: remove this later when we can parse #pragma. - do { - token = preprocessor_nexttoken(pp, &tokenlen, &tokenval); - - if (ctx->out_of_memory) - break; - - fname = preprocessor_sourcepos(pp, &ctx->sourceline); - ctx->sourcefile = fname ? stringcache(ctx->strcache, fname) : 0; - - if ((tokenval == TOKEN_HASH) || (tokenval == TOKEN_HASHHASH)) - tokenval = TOKEN_BAD_CHARS; - - if (tokenval == TOKEN_BAD_CHARS) - { - fail(ctx, "Bad characters in source file"); - continue; - } // else if - - else if (tokenval == TOKEN_PREPROCESSING_ERROR) - { - fail(ctx, token); // this happens to be null-terminated. - continue; - } // else if - - else if (tokenval == TOKEN_PP_PRAGMA) - { - assert(!is_pragma); - is_pragma = 1; - skipping = 1; - continue; - } - - else if (tokenval == ((Token) '\n')) - { - assert(is_pragma); - is_pragma = 0; - skipping = 0; - continue; - } - - else if (skipping) - { - continue; - } - - // !!! FIXME: this is a mess, decide who should be doing this stuff, and only do it once. - lemon_token = convert_to_lemon_token(ctx, token, tokenlen, tokenval); - switch (lemon_token) - { - case TOKEN_HLSL_INT_CONSTANT: - data.i64 = strtoi64(token, tokenlen); - break; - - case TOKEN_HLSL_FLOAT_CONSTANT: - data.dbl = strtodouble(token, tokenlen); - break; - - case TOKEN_HLSL_USERTYPE: - data.string = stringcache_len(ctx->strcache, token, tokenlen); - data.datatype = get_usertype(ctx, data.string); // !!! FIXME: do we need this? It's kind of useless during parsing. - assert(data.datatype != NULL); - break; - - case TOKEN_HLSL_STRING_LITERAL: - case TOKEN_HLSL_IDENTIFIER: - data.string = stringcache_len(ctx->strcache, token, tokenlen); - break; - - default: - data.i64 = 0; - break; - } // switch - - ParseHLSL(parser, lemon_token, data, ctx); - - // this probably isn't perfect, but it's good enough for surviving - // the parse. We'll sort out correctness once we have a tree. - if (lemon_token == TOKEN_HLSL_LBRACE) - push_scope(ctx); - else if (lemon_token == TOKEN_HLSL_RBRACE) - pop_scope(ctx); - } while (tokenval != TOKEN_EOI); - - // Clean out extra usertypes; they are dummies until semantic analysis. - while (ctx->usertypes.scope != start_scope) - pop_symbol(ctx, &ctx->usertypes); - - ParseHLSLFree(parser, ctx->free, ctx->malloc_data); - preprocessor_end(pp); -} // parse_source - - -/* Intermediate representation... */ - -static inline int generate_ir_label(Context *ctx) -{ - return ctx->ir_label_count++; -} // generate_ir_label - -static inline int generate_ir_temp(Context *ctx) -{ - return ctx->ir_temp_count++; -} // generate_ir_temp - -static const LoopLabels *push_ir_loop(Context *ctx, const int isswitch) -{ - // !!! FIXME: cache these allocations? - LoopLabels *retval = Malloc(ctx, sizeof (LoopLabels)); - if (retval) - { - retval->start = (isswitch) ? -1 : generate_ir_label(ctx); - retval->end = generate_ir_label(ctx); - retval->prev = ctx->ir_loop; - ctx->ir_loop = retval; - } // if - - return retval; -} // push_ir_loop - -static void pop_ir_loop(Context *ctx) -{ - assert(ctx->ir_loop != NULL); - LoopLabels *labels = ctx->ir_loop; - ctx->ir_loop = ctx->ir_loop->prev; - Free(ctx, labels); -} // pop_ir_loop - - -#define NEW_IR_NODE(retval, cls, typ) \ - cls *retval = (cls *) Malloc(ctx, sizeof (cls)); \ - do { \ - if (retval == NULL) { return NULL; } \ - retval->ir.type = typ; \ - retval->ir.filename = ctx->sourcefile; \ - retval->ir.line = ctx->sourceline; \ - } while (0) - -#define NEW_IR_EXPR(retval, cls, typ, dt, numelems) \ - cls *retval = (cls *) Malloc(ctx, sizeof (cls)); \ - do { \ - if (retval == NULL) { return NULL; } \ - retval->info.ir.type = typ; \ - retval->info.ir.filename = ctx->sourcefile; \ - retval->info.ir.line = ctx->sourceline; \ - retval->info.type = dt; \ - retval->info.elements = numelems; \ - } while (0) - -// syntactic sugar. -static inline MOJOSHADER_irNode *build_ir(Context *ctx, void *_ast); -static inline MOJOSHADER_irExpression *build_ir_expr(Context *ctx, void *_ast) -{ - MOJOSHADER_irNode *retval = build_ir(ctx, _ast); - assert(!retval || (retval->ir.type > MOJOSHADER_IR_START_RANGE_EXPR)); - assert(!retval || (retval->ir.type < MOJOSHADER_IR_END_RANGE_EXPR)); - return (MOJOSHADER_irExpression *) retval; -} // build_ir_expr - -static inline MOJOSHADER_irStatement *build_ir_stmt(Context *ctx, void *_ast) -{ - MOJOSHADER_irNode *retval = build_ir(ctx, _ast); - assert(!retval || (retval->ir.type > MOJOSHADER_IR_START_RANGE_STMT)); - assert(!retval || (retval->ir.type < MOJOSHADER_IR_END_RANGE_STMT)); - return (MOJOSHADER_irStatement *) retval; -} // build_ir_stmt - - -static MOJOSHADER_irExpression *new_ir_binop(Context *ctx, - const MOJOSHADER_irBinOpType op, - MOJOSHADER_irExpression *left, - MOJOSHADER_irExpression *right) -{ - NEW_IR_EXPR(retval, MOJOSHADER_irBinOp, MOJOSHADER_IR_BINOP, left->info.type, left->info.elements); - assert(left->info.type == right->info.type); - assert(left->info.elements == right->info.elements); - retval->op = op; - retval->left = left; - retval->right = right; - return (MOJOSHADER_irExpression *) retval; -} // new_ir_binop - -static MOJOSHADER_irExpression *new_ir_eseq(Context *ctx, - MOJOSHADER_irStatement *stmt, - MOJOSHADER_irExpression *expr) -{ - NEW_IR_EXPR(retval, MOJOSHADER_irESeq, MOJOSHADER_IR_ESEQ, expr->info.type, expr->info.elements); - retval->stmt = stmt; - retval->expr = expr; - return (MOJOSHADER_irExpression *) retval; -} // new_ir_eseq - -static MOJOSHADER_irExpression *new_ir_temp(Context *ctx, const int index, - const MOJOSHADER_astDataTypeType type, - const int elements) -{ - NEW_IR_EXPR(retval, MOJOSHADER_irTemp, MOJOSHADER_IR_TEMP, type, elements); - retval->index = index; - return (MOJOSHADER_irExpression *) retval; -} // new_ir_temp - - - -#define NEW_IR_BINOP(op,l,r) new_ir_binop(ctx, MOJOSHADER_IR_BINOP_##op, l, r) -#define EASY_IR_BINOP(op) \ - NEW_IR_BINOP(op, build_ir_expr(ctx, ast->binary.left), \ - build_ir_expr(ctx, ast->binary.right)) - -// You have to fill in ->value yourself! -static MOJOSHADER_irExpression *new_ir_constant(Context *ctx, - const MOJOSHADER_astDataTypeType type, - const int elements) -{ - NEW_IR_EXPR(retval, MOJOSHADER_irConstant, MOJOSHADER_IR_CONSTANT, type, elements); - return (MOJOSHADER_irExpression *) retval; -} // new_ir_constant - -static MOJOSHADER_irExpression *new_ir_constint(Context *ctx, const int val) -{ - NEW_IR_EXPR(retval, MOJOSHADER_irConstant, MOJOSHADER_IR_CONSTANT, MOJOSHADER_AST_DATATYPE_INT, 1); - retval->value.ival[0] = val; - return (MOJOSHADER_irExpression *) retval; -} // new_ir_constint - -static MOJOSHADER_irExpression *new_ir_constfloat(Context *ctx, const float val) -{ - NEW_IR_EXPR(retval, MOJOSHADER_irConstant, MOJOSHADER_IR_CONSTANT, MOJOSHADER_AST_DATATYPE_FLOAT, 1); - retval->value.fval[0] = val; - return (MOJOSHADER_irExpression *) retval; -} // new_ir_constfloat - -static MOJOSHADER_irExpression *new_ir_constbool(Context *ctx, const int val) -{ - // !!! FIXME: cache true and false in (ctx), ignore in delete_ir(). - NEW_IR_EXPR(retval, MOJOSHADER_irConstant, MOJOSHADER_IR_CONSTANT, MOJOSHADER_AST_DATATYPE_BOOL, 1); - retval->value.ival[0] = val; - return (MOJOSHADER_irExpression *) retval; -} // new_ir_constbool - -static MOJOSHADER_irExpression *new_ir_convert(Context *ctx, MOJOSHADER_irExpression *expr, - const MOJOSHADER_astDataTypeType type, - const int elements) -{ - NEW_IR_EXPR(retval, MOJOSHADER_irConvert, MOJOSHADER_IR_CONVERT, type, elements); - retval->expr = expr; - return (MOJOSHADER_irExpression *) retval; -} // new_ir_convert - -static MOJOSHADER_irExpression *new_ir_construct(Context *ctx, MOJOSHADER_irExprList *args, - const MOJOSHADER_astDataTypeType type, - const int elements) -{ - NEW_IR_EXPR(retval, MOJOSHADER_irConstruct, MOJOSHADER_IR_CONSTRUCT, type, elements); - retval->args = args; - return (MOJOSHADER_irExpression *) retval; -} // new_ir_construct - -static MOJOSHADER_irExpression *new_ir_call(Context *ctx, const int index, - MOJOSHADER_irExprList *args, - const MOJOSHADER_astDataTypeType type, - const int elements) -{ - NEW_IR_EXPR(retval, MOJOSHADER_irCall, MOJOSHADER_IR_CALL, type, elements); - retval->args = args; - retval->index = index; - return (MOJOSHADER_irExpression *) retval; -} // new_ir_call - -static MOJOSHADER_irExpression *new_ir_swizzle(Context *ctx, - MOJOSHADER_irExpression *expr, - const char *channels, - const MOJOSHADER_astDataTypeType type, - const int elements) -{ - NEW_IR_EXPR(retval, MOJOSHADER_irSwizzle, MOJOSHADER_IR_SWIZZLE, type, elements); - retval->expr = expr; - memcpy(retval->channels, channels, sizeof (retval->channels)); - return (MOJOSHADER_irExpression *) retval; -} // new_ir_swizzle - -static MOJOSHADER_irExpression *new_ir_memory(Context *ctx, const int index, - const MOJOSHADER_astDataTypeType type, - const int elements) -{ - NEW_IR_EXPR(retval, MOJOSHADER_irMemory, MOJOSHADER_IR_MEMORY, type, elements); - retval->index = index; - return (MOJOSHADER_irExpression *) retval; -} // new_ir_memory - -static MOJOSHADER_irExpression *new_ir_array(Context *ctx, - MOJOSHADER_irExpression *array, - MOJOSHADER_irExpression *element, - const MOJOSHADER_astDataTypeType type, - const int elements) -{ - NEW_IR_EXPR(retval, MOJOSHADER_irArray, MOJOSHADER_IR_ARRAY, type, elements); - retval->array = array; - retval->element = element; - return (MOJOSHADER_irExpression *) retval; -} // new_ir_array - -static MOJOSHADER_irStatement *new_ir_seq(Context *ctx, - MOJOSHADER_irStatement *first, - MOJOSHADER_irStatement *next) -{ - assert((first != NULL) || (next != NULL)); - if (first == NULL) // don't generate a SEQ if unnecessary. - return next; - else if (next == NULL) - return first; - - NEW_IR_NODE(retval, MOJOSHADER_irSeq, MOJOSHADER_IR_SEQ); - retval->first = first; - retval->next = next; - return (MOJOSHADER_irStatement *) retval; -} // new_ir_seq - -static MOJOSHADER_irStatement *new_ir_jump(Context *ctx, const int label) -{ - NEW_IR_NODE(retval, MOJOSHADER_irJump, MOJOSHADER_IR_JUMP); - retval->label = label; - return (MOJOSHADER_irStatement *) retval; -} // new_ir_jump - -static MOJOSHADER_irStatement *new_ir_cjump(Context *ctx, - const MOJOSHADER_irConditionType cond, - MOJOSHADER_irExpression *left, - MOJOSHADER_irExpression *right, - const int iftrue, const int iffalse) -{ - NEW_IR_NODE(retval, MOJOSHADER_irCJump, MOJOSHADER_IR_CJUMP); - retval->cond = cond; - retval->left = left; - retval->right = right; - retval->iftrue = iftrue; - retval->iffalse = iffalse; - return (MOJOSHADER_irStatement *) retval; -} // new_ir_cjump - -static MOJOSHADER_irStatement *new_ir_label(Context *ctx, const int index) -{ - NEW_IR_NODE(retval, MOJOSHADER_irLabel, MOJOSHADER_IR_LABEL); - retval->index = index; - return (MOJOSHADER_irStatement *) retval; -} // new_ir_label - -static MOJOSHADER_irStatement *new_ir_move(Context *ctx, - MOJOSHADER_irExpression *dst, - MOJOSHADER_irExpression *src, - const int writemask) -{ - NEW_IR_NODE(retval, MOJOSHADER_irMove, MOJOSHADER_IR_MOVE); - assert(dst->info.type == src->info.type); - assert(dst->info.elements == src->info.elements); - retval->dst = dst; - retval->src = src; - retval->writemask = writemask; - return (MOJOSHADER_irStatement *) retval; -} // new_ir_move - -static MOJOSHADER_irStatement *new_ir_expr_stmt(Context *ctx, MOJOSHADER_irExpression *expr) -{ - NEW_IR_NODE(retval, MOJOSHADER_irExprStmt, MOJOSHADER_IR_EXPR_STMT); - retval->expr = expr; - return (MOJOSHADER_irStatement *) retval; -} // new_ir_expr_stmt - -static MOJOSHADER_irStatement *new_ir_discard(Context *ctx) -{ - NEW_IR_NODE(retval, MOJOSHADER_irDiscard, MOJOSHADER_IR_DISCARD); - return (MOJOSHADER_irStatement *) retval; -} // new_ir_discard - -static MOJOSHADER_irExprList *new_ir_exprlist(Context *ctx, MOJOSHADER_irExpression *expr) -{ - NEW_IR_NODE(retval, MOJOSHADER_irExprList, MOJOSHADER_IR_EXPRLIST); - retval->expr = expr; - retval->next = NULL; - return (MOJOSHADER_irExprList *) retval; -} // new_ir_exprlist - - -// This handles most comparison operators (less-than, equals, etc...) -static MOJOSHADER_irExpression *build_ir_compare(Context *ctx, - const MOJOSHADER_irConditionType operation, - MOJOSHADER_irExpression *left, - MOJOSHADER_irExpression *right, - MOJOSHADER_irExpression *tval, - MOJOSHADER_irExpression *fval) -{ - /* The gist... - cjump x < y, t, f // '<' is whatever operation - t: - move tmp, tval - jump join - f: - move tmp, fval - join: - */ - - const int t = generate_ir_label(ctx); - const int f = generate_ir_label(ctx); - const int join = generate_ir_label(ctx); - const int tmp = generate_ir_temp(ctx); - - assert(tval->info.type == fval->info.type); - assert(tval->info.elements == fval->info.elements); - - const MOJOSHADER_astDataTypeType dt = tval->info.type; - const int elements = tval->info.elements; - - return new_ir_eseq(ctx, - new_ir_seq(ctx, new_ir_cjump(ctx, operation, left, right, t, f), - new_ir_seq(ctx, new_ir_label(ctx, t), - new_ir_seq(ctx, new_ir_move(ctx, new_ir_temp(ctx, tmp, dt, elements), tval, -1), - new_ir_seq(ctx, new_ir_jump(ctx, join), - new_ir_seq(ctx, new_ir_label(ctx, f), - new_ir_seq(ctx, new_ir_move(ctx, new_ir_temp(ctx, tmp, dt, elements), fval, -1), - new_ir_label(ctx, join))))))), - new_ir_temp(ctx, tmp, dt, elements)); -} // build_ir_compare - -#define EASY_IR_COMPARE(op) \ - build_ir_compare(ctx, MOJOSHADER_IR_COND_##op, \ - build_ir_expr(ctx, ast->binary.left), \ - build_ir_expr(ctx, ast->binary.right), \ - new_ir_constbool(ctx, 1), \ - new_ir_constbool(ctx, 0)) - - -// This handles && and || operators. -static MOJOSHADER_irExpression *build_ir_logical_and_or(Context *ctx, - const MOJOSHADER_astExpressionBinary *ast, - const int left_testval) -{ - /* The gist... - cjump left == left_testval, maybe, f - maybe: - cjump right == true, t, f - t: - move tmp, 1 - jump join - f: - move tmp, 0 - join: - */ - - assert(ast->left->datatype->type == MOJOSHADER_AST_DATATYPE_BOOL); - assert(ast->right->datatype->type == MOJOSHADER_AST_DATATYPE_BOOL); - - const int t = generate_ir_label(ctx); - const int f = generate_ir_label(ctx); - const int maybe = generate_ir_label(ctx); - const int join = generate_ir_label(ctx); - const int tmp = generate_ir_temp(ctx); - - return new_ir_eseq(ctx, - new_ir_seq(ctx, new_ir_cjump(ctx, MOJOSHADER_IR_COND_EQL, build_ir_expr(ctx, ast->left), new_ir_constbool(ctx, left_testval), maybe, f), - new_ir_seq(ctx, new_ir_label(ctx, maybe), - new_ir_seq(ctx, new_ir_cjump(ctx, MOJOSHADER_IR_COND_EQL, build_ir_expr(ctx, ast->right), new_ir_constbool(ctx, 1), t, f), - new_ir_seq(ctx, new_ir_label(ctx, t), - new_ir_seq(ctx, new_ir_move(ctx, new_ir_temp(ctx, tmp, MOJOSHADER_AST_DATATYPE_BOOL, 1), new_ir_constbool(ctx, 1), -1), - new_ir_seq(ctx, new_ir_jump(ctx, join), - new_ir_seq(ctx, new_ir_label(ctx, f), - new_ir_seq(ctx, new_ir_move(ctx, new_ir_temp(ctx, tmp, MOJOSHADER_AST_DATATYPE_BOOL, 1), new_ir_constbool(ctx, 0), -1), - new_ir_label(ctx, join))))))))), - new_ir_temp(ctx, tmp, MOJOSHADER_AST_DATATYPE_BOOL, 1)); -} // build_ir_logical_and_or - -static inline MOJOSHADER_irExpression *build_ir_logical_and(Context *ctx, - const MOJOSHADER_astExpressionBinary *ast) -{ - // this needs to not evaluate (right) if (left) is false! - return build_ir_logical_and_or(ctx, ast, 1); -} // build_ir_logical_and - -static inline MOJOSHADER_irExpression *build_ir_logical_or(Context *ctx, - const MOJOSHADER_astExpressionBinary *ast) -{ - // this needs to not evaluate (right) if (left) is true! - return build_ir_logical_and_or(ctx, ast, 0); -} // build_ir_logical_or - -static inline MOJOSHADER_irStatement *build_ir_no_op(Context *ctx) -{ - return new_ir_label(ctx, generate_ir_label(ctx)); -} // build_ir_no_op - -static MOJOSHADER_irStatement *build_ir_ifstmt(Context *ctx, - const MOJOSHADER_astIfStatement *ast) -{ - assert(ast->expr->datatype->type == MOJOSHADER_AST_DATATYPE_BOOL); - - // !!! FIXME: ast->attributes? - - // IF statement without an ELSE. - if (ast->else_statement == NULL) - { - /* The gist... - cjump expr, t, join - t: - statement - join: - */ - - const int t = generate_ir_label(ctx); - const int join = generate_ir_label(ctx); - - return new_ir_seq(ctx, new_ir_cjump(ctx, MOJOSHADER_IR_COND_EQL, build_ir_expr(ctx, ast->expr), new_ir_constbool(ctx, 1), t, join), - new_ir_seq(ctx, new_ir_label(ctx, t), - new_ir_seq(ctx, build_ir_stmt(ctx, ast->statement), - new_ir_seq(ctx, new_ir_label(ctx, join), - build_ir_stmt(ctx, ast->next))))); - } // if - - // IF statement _with_ an ELSE. - /* The gist... - cjump expr, t, f - t: - statement - jump join - f: - elsestatement - join: - */ - - const int t = generate_ir_label(ctx); - const int f = generate_ir_label(ctx); - const int join = generate_ir_label(ctx); - - return new_ir_seq(ctx, new_ir_cjump(ctx, MOJOSHADER_IR_COND_EQL, build_ir_expr(ctx, ast->expr), new_ir_constbool(ctx, 1), t, f), - new_ir_seq(ctx, new_ir_label(ctx, t), - new_ir_seq(ctx, build_ir_stmt(ctx, ast->statement), - new_ir_seq(ctx, new_ir_jump(ctx, join), - new_ir_seq(ctx, new_ir_label(ctx, f), - new_ir_seq(ctx, build_ir_stmt(ctx, ast->else_statement), - new_ir_seq(ctx, new_ir_label(ctx, join), - build_ir_stmt(ctx, ast->next)))))))); -} // build_ir_ifstmt - - -static MOJOSHADER_irStatement *build_ir_forstmt(Context *ctx, - const MOJOSHADER_astForStatement *ast) -{ - // !!! FIXME: ast->unroll - - assert(ast->looptest->datatype->type == MOJOSHADER_AST_DATATYPE_BOOL); - - /* The gist... - initializer // (or var_decl->initializer!) - test: - cjump looptest == true, loop, join - loop: - statement - increment: // needs to be here; this is where "continue" jumps! - counter - jump test - join: - */ - - const int test = generate_ir_label(ctx); - const int loop = generate_ir_label(ctx); - - const LoopLabels *labels = push_ir_loop(ctx, 0); - if (labels == NULL) - return NULL; // out of memory... - - const int increment = labels->start; - const int join = labels->end; - - assert( (ast->var_decl && !ast->initializer) || - (!ast->var_decl && ast->initializer) ); - - MOJOSHADER_irStatement *init = NULL; - if (ast->var_decl != NULL) - { -//sdfsdf - // !!! FIXME: map the initializer to the variable? Need fix to var_decl parsing. -// new_ir_move(ctx, FIXME MAP TO REGISTER ast->var_decl->index, build_ir_expr(ctx, ast->fsdf)); -// FIXME -// init = build_ir_vardecl(ctx, ast->var_decl); - } // if - else - { -// init = build_ir_expr(ctx, ast->initializer); - } // else - - MOJOSHADER_irStatement *retval = - new_ir_seq(ctx, init, - new_ir_seq(ctx, new_ir_label(ctx, test), - new_ir_seq(ctx, new_ir_cjump(ctx, MOJOSHADER_IR_COND_EQL, build_ir_expr(ctx, ast->looptest), new_ir_constbool(ctx, 1), loop, join), - new_ir_seq(ctx, new_ir_label(ctx, loop), - new_ir_seq(ctx, build_ir_stmt(ctx, ast->statement), - new_ir_seq(ctx, new_ir_label(ctx, increment), - new_ir_seq(ctx, new_ir_expr_stmt(ctx, build_ir_expr(ctx, ast->counter)), - new_ir_seq(ctx, new_ir_jump(ctx, test), - new_ir_label(ctx, join))))))))); - - pop_ir_loop(ctx); - - return new_ir_seq(ctx, retval, build_ir_stmt(ctx, ast->next)); -} // build_ir_forstmt - -static MOJOSHADER_irStatement *build_ir_whilestmt(Context *ctx, - const MOJOSHADER_astWhileStatement *ast) -{ - // !!! FIXME: ast->unroll - - assert(ast->expr->datatype->type == MOJOSHADER_AST_DATATYPE_BOOL); - - /* The gist... - loop: - cjump expr == true, t, join - t: - statement - jump loop - join: - */ - - const LoopLabels *labels = push_ir_loop(ctx, 0); - if (labels == NULL) - return NULL; // out of memory... - - const int loop = labels->start; - const int t = generate_ir_label(ctx); - const int join = labels->end; - - MOJOSHADER_irStatement *retval = - new_ir_seq(ctx, new_ir_label(ctx, loop), - new_ir_seq(ctx, new_ir_cjump(ctx, MOJOSHADER_IR_COND_EQL, build_ir_expr(ctx, ast->expr), new_ir_constbool(ctx, 1), t, join), - new_ir_seq(ctx, new_ir_label(ctx, t), - new_ir_seq(ctx, build_ir_stmt(ctx, ast->statement), - new_ir_seq(ctx, new_ir_jump(ctx, loop), - new_ir_label(ctx, join)))))); - - pop_ir_loop(ctx); - - return new_ir_seq(ctx, retval, build_ir_stmt(ctx, ast->next)); -} // build_ir_whilestmt - -static MOJOSHADER_irStatement *build_ir_dostmt(Context *ctx, - const MOJOSHADER_astDoStatement *ast) -{ - // !!! FIXME: ast->unroll - - assert(ast->expr->datatype->type == MOJOSHADER_AST_DATATYPE_BOOL); - - /* The gist... - loop: - statement - cjump expr == true, loop, join - join: - */ - - const LoopLabels *labels = push_ir_loop(ctx, 0); - if (labels == NULL) - return NULL; // out of memory... - - const int loop = labels->start; - const int join = labels->end; - - MOJOSHADER_irStatement *retval = - new_ir_seq(ctx, new_ir_label(ctx, loop), - new_ir_seq(ctx, build_ir_stmt(ctx, ast->statement), - new_ir_seq(ctx, new_ir_cjump(ctx, MOJOSHADER_IR_COND_EQL, build_ir_expr(ctx, ast->expr), new_ir_constbool(ctx, 1), loop, join), - new_ir_label(ctx, join)))); - - pop_ir_loop(ctx); - - return new_ir_seq(ctx, retval, build_ir_stmt(ctx, ast->next)); -} // build_ir_dostmt - -static MOJOSHADER_irStatement *build_ir_switch(Context *ctx, const MOJOSHADER_astSwitchStatement *ast) -{ - // Dithering down to a list of if-statements in all cases - // isn't ideal, but we can't do jumptables in D3D bytecode. - - // !!! FIXME: attributes? - - /* The gist... - move tmp, expr - cjump tmp == case1expr, case1, testcase2 - testcase2: // etc - cjump tmp == case2expr, case2, join - case1: - case1stmt // might have a break in it somewhere. - case2: - case2stmt - join: - */ - - const LoopLabels *labels = push_ir_loop(ctx, 1); - if (labels == NULL) - return NULL; // out of memory... - - const int join = labels->end; - const int elems = datatype_elems(ctx, ast->expr->datatype); - const MOJOSHADER_astDataTypeType dt = datatype_base(ctx, ast->expr->datatype)->type; - - const MOJOSHADER_astSwitchCases *cases = ast->cases; - const int tmp = generate_ir_temp(ctx); - MOJOSHADER_irStatement *startseqs = new_ir_move(ctx, new_ir_temp(ctx, tmp, dt, elems), build_ir_expr(ctx, ast->expr), -1); - MOJOSHADER_irStatement *testseqs = startseqs; - MOJOSHADER_irStatement *startcaseseqs = NULL; - MOJOSHADER_irStatement *caseseqs = NULL; - while (cases) - { - const int t = generate_ir_label(ctx); - const int f = (cases->next == NULL) ? join : generate_ir_label(ctx); - MOJOSHADER_irStatement *cjump = new_ir_cjump(ctx, MOJOSHADER_IR_COND_EQL, build_ir_expr(ctx, cases->expr), new_ir_temp(ctx, tmp, dt, elems), t, f); - - if (cases->next == NULL) // last one, do the join label. - { - testseqs = new_ir_seq(ctx, testseqs, cjump); - caseseqs = new_ir_seq(ctx, caseseqs, new_ir_seq(ctx, new_ir_label(ctx, t), build_ir_stmt(ctx, cases->statement))); - caseseqs = new_ir_seq(ctx, caseseqs, new_ir_label(ctx, f)); - } // if - else - { - testseqs = new_ir_seq(ctx, testseqs, new_ir_seq(ctx, cjump, new_ir_label(ctx, f))); - caseseqs = new_ir_seq(ctx, caseseqs, new_ir_seq(ctx, new_ir_label(ctx, t), build_ir_stmt(ctx, cases->statement))); - } // else - - if (startcaseseqs == NULL) - startcaseseqs = caseseqs; - - cases = cases->next; - } // while - - pop_ir_loop(ctx); - - return new_ir_seq(ctx, startseqs, new_ir_seq(ctx, startcaseseqs, build_ir_stmt(ctx, ast->next))); -} // build_ir_switch - -static MOJOSHADER_irExpression *build_ir_increxpr(Context *ctx, const MOJOSHADER_astDataType *_dt, - const int val) -{ - const MOJOSHADER_astDataType *dt = reduce_datatype(ctx, _dt); - const MOJOSHADER_astDataTypeType type = datatype_base(ctx, dt)->type; - const int elems = datatype_elems(ctx, dt); - MOJOSHADER_irConstant *retval = (MOJOSHADER_irConstant *) new_ir_constant(ctx, type, elems); - int i; - - switch (type) - { - case MOJOSHADER_AST_DATATYPE_BOOL: - case MOJOSHADER_AST_DATATYPE_INT: - case MOJOSHADER_AST_DATATYPE_UINT: - for (i = 0; i < elems; i++) - retval->value.ival[i] = (int) val; - break; - - case MOJOSHADER_AST_DATATYPE_FLOAT: - case MOJOSHADER_AST_DATATYPE_FLOAT_SNORM: - case MOJOSHADER_AST_DATATYPE_FLOAT_UNORM: - case MOJOSHADER_AST_DATATYPE_HALF: - case MOJOSHADER_AST_DATATYPE_DOUBLE: - for (i = 0; i < elems; i++) - retval->value.fval[i] = (float) val; - break; - - default: - assert(0 && "Semantic analysis should have caught this!"); - } // switch - - return (MOJOSHADER_irExpression *) retval; -} // build_ir_increxpr - -static MOJOSHADER_irExpression *build_ir_preincdec(Context *ctx, MOJOSHADER_astExpressionUnary *ast, const MOJOSHADER_irBinOpType binop) -{ - /* The gist... - move expr, expr + 1 - return expr - */ - // !!! FIXME: can you writemask an increment operator? - MOJOSHADER_irExpression *constant = build_ir_increxpr(ctx, ast->datatype, 1); - return new_ir_eseq(ctx, - new_ir_move(ctx, - build_ir_expr(ctx, ast->operand), - new_ir_binop(ctx, binop, build_ir_expr(ctx, ast->operand), constant), -1), - build_ir_expr(ctx, ast->operand)); -} // build_ir_preincdec - -static MOJOSHADER_irExpression *build_ir_postincdec(Context *ctx, MOJOSHADER_astExpressionUnary *ast, const MOJOSHADER_irBinOpType binop) -{ - /* The gist... - move tmp, expr - move expr, expr + 1 - return tmp - */ - - // !!! FIXME: can you writemask an increment operator? - MOJOSHADER_irExpression *constant = build_ir_increxpr(ctx, ast->datatype, 1); - const int tmp = generate_ir_temp(ctx); - return new_ir_eseq(ctx, - new_ir_seq(ctx, - new_ir_move(ctx, new_ir_temp(ctx, tmp, constant->info.type, constant->info.elements), build_ir_expr(ctx, ast->operand), -1), - new_ir_move(ctx, build_ir_expr(ctx, ast->operand), - new_ir_binop(ctx, binop, build_ir_expr(ctx, ast->operand), constant), -1)), - new_ir_temp(ctx, tmp, constant->info.type, constant->info.elements)); -} // build_ir_postincdec - -static MOJOSHADER_irExpression *build_ir_convert(Context *ctx, const MOJOSHADER_astExpressionCast *ast) -{ - const MOJOSHADER_astDataType *dt = reduce_datatype(ctx, ast->datatype); - const MOJOSHADER_astDataTypeType type = datatype_base(ctx, dt)->type; - const int elems = datatype_elems(ctx, dt); - return new_ir_convert(ctx, build_ir_expr(ctx, ast->operand), type, elems); -} // build_ir_convert - -static MOJOSHADER_irExprList *build_ir_exprlist(Context *ctx, MOJOSHADER_astArguments *args) -{ - MOJOSHADER_irExprList *retval = NULL; - MOJOSHADER_irExprList *prev = NULL; - - while (args != NULL) - { - assert((retval && prev) || ((!retval) && (!prev))); - - MOJOSHADER_irExprList *item = new_ir_exprlist(ctx, build_ir_expr(ctx, args->argument)); - if (prev == NULL) - prev = retval = item; - else - prev->next = item; - - args = args->next; - } // while - - return retval; -} // build_ir_exprlist - -static MOJOSHADER_irExpression *build_ir_constructor(Context *ctx, const MOJOSHADER_astExpressionConstructor *ast) -{ - const MOJOSHADER_astDataType *dt = reduce_datatype(ctx, ast->datatype); - const MOJOSHADER_astDataTypeType type = datatype_base(ctx, dt)->type; - const int elems = datatype_elems(ctx, dt); - assert(elems <= 16); // just in case (matrix4x4 constructor is largest). - return new_ir_construct(ctx, build_ir_exprlist(ctx, ast->args), type, elems); -} // build_ir_constructor - -static MOJOSHADER_irExpression *build_ir_call(Context *ctx, const MOJOSHADER_astExpressionCallFunction *ast) -{ - const MOJOSHADER_astDataType *dt = reduce_datatype(ctx, ast->datatype); - const MOJOSHADER_astDataTypeType type = datatype_base(ctx, dt)->type; - const int elems = datatype_elems(ctx, dt); - return new_ir_call(ctx, ast->identifier->index, build_ir_exprlist(ctx, ast->args), type, elems); -} // build_ir_call - -static char swiz_to_channel(const char swiz) -{ - if ((swiz == 'r') || (swiz == 'x')) return 0; - if ((swiz == 'g') || (swiz == 'y')) return 1; - if ((swiz == 'b') || (swiz == 'z')) return 2; - if ((swiz == 'a') || (swiz == 'w')) return 3; - assert(0 && "Should have been caught by semantic analysis."); - return 0; -} // swiz_to_channel - -static MOJOSHADER_irExpression *build_ir_swizzle(Context *ctx, const MOJOSHADER_astExpressionDerefStruct *ast) -{ - const MOJOSHADER_astDataType *dt = reduce_datatype(ctx, ast->datatype); - const MOJOSHADER_astDataTypeType type = datatype_base(ctx, dt)->type; - const int elems = datatype_elems(ctx, dt); - char chans[4] = { 0, 0, 0, 0 }; - const char *swizstr = ast->member; - int i; - - for (i = 0; swizstr[i]; i++) - chans[i] = swiz_to_channel(swizstr[i]); - - return new_ir_swizzle(ctx, build_ir_expr(ctx, ast->identifier), chans, type, elems); -} // build_ir_swizzle - -static MOJOSHADER_irExpression *build_ir_identifier(Context *ctx, const MOJOSHADER_astExpressionIdentifier *ast) -{ - const MOJOSHADER_astDataType *dt = reduce_datatype(ctx, ast->datatype); - const MOJOSHADER_astDataTypeType type = datatype_base(ctx, dt)->type; - const int elems = datatype_elems(ctx, dt); - return new_ir_memory(ctx, ast->index, type, elems); -} // build_ir_identifier - -static MOJOSHADER_irExpression *build_ir_derefstruct(Context *ctx, const MOJOSHADER_astExpressionDerefStruct *ast) -{ - // There are only three possible IR nodes that contain a struct: - // an irTemp, an irMemory, or an irESeq that results in a temp or memory. - // As such, we figure out which it is, and offset appropriately for the - // member. - const MOJOSHADER_astDataType *dt = reduce_datatype(ctx, ast->datatype); - const MOJOSHADER_astDataTypeType type = datatype_base(ctx, dt)->type; - const int elems = datatype_elems(ctx, dt); - MOJOSHADER_irExpression *expr = build_ir_expr(ctx, ast->identifier); - MOJOSHADER_irExpression *finalexpr = expr; - - assert(!ast->isswizzle); - - while (finalexpr->ir.type == MOJOSHADER_IR_ESEQ) - finalexpr = finalexpr->eseq.expr; - - if (finalexpr->ir.type == MOJOSHADER_IR_TEMP) - finalexpr->temp.index += ast->member_index; - else if (finalexpr->ir.type == MOJOSHADER_IR_MEMORY) - finalexpr->memory.index += ast->member_index; - else - assert(0 && "Unexpected condition"); - - // Replace the struct type with the type of the member. - expr->info.type = type; - expr->info.elements = elems; - - return expr; -} // build_ir_derefstruct - -static MOJOSHADER_irExpression *build_ir_derefarray(Context *ctx, const MOJOSHADER_astExpressionBinary *ast) -{ - // In most compilers, arrays dither down to offsets into memory, but - // they're somewhat special in D3D, since they might have to deal with - // vectors, etc...so we keep them as first-class citizens of the IR, - // and let the optimizer/codegen sort it out. - // !!! FIXME: this might be the wrong move. Maybe remove this IR node type? - const MOJOSHADER_astDataType *dt = reduce_datatype(ctx, ast->datatype); - const MOJOSHADER_astDataTypeType type = datatype_base(ctx, dt)->type; - const int elems = datatype_elems(ctx, dt); - - // !!! FIXME: Array dereference of a vector can become a simple swizzle operation, if we have a constant index. - // !!! FIXME: Matrix dereference of a vector can become a simple reference to a temp/memory, if we have a constant index. - return new_ir_array(ctx, build_ir_expr(ctx, ast->left), build_ir_expr(ctx, ast->right), type, elems); -} // build_ir_derefarray - -static MOJOSHADER_irExpression *build_ir_assign_binop(Context *ctx, - const MOJOSHADER_irBinOpType op, - const MOJOSHADER_astExpressionBinary *ast) -{ - MOJOSHADER_irExpression *lvalue = build_ir_expr(ctx, ast->left); - MOJOSHADER_irExpression *rvalue = build_ir_expr(ctx, ast->right); - const MOJOSHADER_astDataTypeType type = lvalue->info.type; - const int elems = lvalue->info.elements; - const int tmp = generate_ir_temp(ctx); - - // Semantic analysis should have inserted casts if necessary. - assert(type == rvalue->info.type); - assert(elems == rvalue->info.elements); - - // The destination must eventually be lvalue, which means memory or temp. - MOJOSHADER_irExpression *dst = lvalue; - while (dst->ir.type == MOJOSHADER_IR_ESEQ) - dst = dst->eseq.expr; - - if (dst->ir.type == MOJOSHADER_IR_TEMP) - dst = new_ir_temp(ctx, dst->temp.index, dst->info.type, dst->info.elements); - else if (dst->ir.type == MOJOSHADER_IR_MEMORY) - dst = new_ir_memory(ctx, dst->memory.index, dst->info.type, dst->info.elements); - else - assert(0 && "Unexpected condition"); - - // !!! FIXME: write masking! - return new_ir_eseq(ctx, - new_ir_seq(ctx, - new_ir_move(ctx, new_ir_temp(ctx, tmp, type, elems), new_ir_binop(ctx, op, lvalue, rvalue), -1), - new_ir_move(ctx, dst, new_ir_temp(ctx, tmp, type, elems), -1)), - new_ir_temp(ctx, tmp, type, elems)); -} // build_ir_assign_binop - -static MOJOSHADER_irExpression *build_ir_assign(Context *ctx, - const MOJOSHADER_astExpressionBinary *ast) -{ - MOJOSHADER_irExpression *lvalue = build_ir_expr(ctx, ast->left); - MOJOSHADER_irExpression *rvalue = build_ir_expr(ctx, ast->right); - const MOJOSHADER_astDataTypeType type = lvalue->info.type; - const int elems = lvalue->info.elements; - const int tmp = generate_ir_temp(ctx); - - // Semantic analysis should have inserted casts if necessary. - assert(type == rvalue->info.type); - assert(elems == rvalue->info.elements); - - // !!! FIXME: write masking! - // !!! FIXME: whole array/struct assignments need to become a sequence of moves. - return new_ir_eseq(ctx, - new_ir_seq(ctx, - new_ir_move(ctx, new_ir_temp(ctx, tmp, type, elems), rvalue, -1), - new_ir_move(ctx, lvalue, new_ir_temp(ctx, tmp, type, elems), -1)), - new_ir_temp(ctx, tmp, type, elems)); -} // build_ir_assign - - -// The AST must be perfect and normalized and sane here. If there are any -// strange corner cases, you should strive to handle them in semantic -// analysis, so conversion to IR can proceed with a minimum of drama. -static void *build_ir_internal(Context *ctx, void *_ast); -static inline MOJOSHADER_irNode *build_ir(Context *ctx, void *_ast) -{ - return (MOJOSHADER_irNode *) build_ir_internal(ctx, _ast); -} // build_ir - -static void *build_ir_internal(Context *ctx, void *_ast) -{ - if ((_ast == NULL) || (ctx->out_of_memory)) - return NULL; - - MOJOSHADER_astNode *ast = (MOJOSHADER_astNode *) _ast; - - // upkeep so we report correct error locations... - ctx->sourcefile = ast->ast.filename; - ctx->sourceline = ast->ast.line; - - switch (ast->ast.type) - { - case MOJOSHADER_AST_OP_PREINCREMENT: // !!! FIXME: sequence points? - return build_ir_preincdec(ctx, &ast->unary, MOJOSHADER_IR_BINOP_ADD); - - case MOJOSHADER_AST_OP_POSTINCREMENT: // !!! FIXME: sequence points? - return build_ir_postincdec(ctx, &ast->unary, MOJOSHADER_IR_BINOP_ADD); - - case MOJOSHADER_AST_OP_PREDECREMENT: // !!! FIXME: sequence points? - return build_ir_preincdec(ctx, &ast->unary, MOJOSHADER_IR_BINOP_SUBTRACT); - - case MOJOSHADER_AST_OP_POSTDECREMENT: // !!! FIXME: sequence points? - return build_ir_postincdec(ctx, &ast->unary, MOJOSHADER_IR_BINOP_SUBTRACT); - - case MOJOSHADER_AST_OP_COMPLEMENT: - return NEW_IR_BINOP(XOR, build_ir_expr(ctx, ast->unary.operand), - new_ir_constint(ctx, 0xFFFFFFFF)); - - case MOJOSHADER_AST_OP_NEGATE: // !!! FIXME: -0.0f != +0.0f - return NEW_IR_BINOP(SUBTRACT, build_ir_increxpr(ctx, ast->unary.datatype, -1), - build_ir_expr(ctx, ast->unary.operand)); - - case MOJOSHADER_AST_OP_NOT: // operand must be bool here! - assert(ast->unary.operand->datatype->type == MOJOSHADER_AST_DATATYPE_BOOL); - return NEW_IR_BINOP(XOR, build_ir_expr(ctx, ast->unary.operand), - new_ir_constint(ctx, 1)); - - case MOJOSHADER_AST_OP_DEREF_ARRAY: - return build_ir_derefarray(ctx, &ast->binary); - - case MOJOSHADER_AST_OP_DEREF_STRUCT: - if (ast->derefstruct.isswizzle) - return build_ir_swizzle(ctx, &ast->derefstruct); - return build_ir_derefstruct(ctx, &ast->derefstruct); - - case MOJOSHADER_AST_OP_COMMA: - // evaluate and throw away left, return right. - return new_ir_eseq(ctx, new_ir_expr_stmt(ctx, build_ir_expr(ctx, ast->binary.left)), - build_ir_expr(ctx, ast->binary.right)); - - case MOJOSHADER_AST_OP_LESSTHAN: return EASY_IR_COMPARE(LT); - case MOJOSHADER_AST_OP_GREATERTHAN: return EASY_IR_COMPARE(GT); - case MOJOSHADER_AST_OP_LESSTHANOREQUAL: return EASY_IR_COMPARE(LEQ); - case MOJOSHADER_AST_OP_GREATERTHANOREQUAL: return EASY_IR_COMPARE(GEQ); - case MOJOSHADER_AST_OP_NOTEQUAL: return EASY_IR_COMPARE(NEQ); - case MOJOSHADER_AST_OP_EQUAL: return EASY_IR_COMPARE(EQL); - - case MOJOSHADER_AST_OP_MULTIPLY: return EASY_IR_BINOP(MULTIPLY); - case MOJOSHADER_AST_OP_DIVIDE: return EASY_IR_BINOP(DIVIDE); - case MOJOSHADER_AST_OP_MODULO: return EASY_IR_BINOP(MODULO); - case MOJOSHADER_AST_OP_ADD: return EASY_IR_BINOP(ADD); - case MOJOSHADER_AST_OP_SUBTRACT: return EASY_IR_BINOP(SUBTRACT); - case MOJOSHADER_AST_OP_LSHIFT: return EASY_IR_BINOP(LSHIFT); - case MOJOSHADER_AST_OP_RSHIFT: return EASY_IR_BINOP(RSHIFT); - case MOJOSHADER_AST_OP_BINARYAND: return EASY_IR_BINOP(AND); - case MOJOSHADER_AST_OP_BINARYXOR: return EASY_IR_BINOP(XOR); - case MOJOSHADER_AST_OP_BINARYOR: return EASY_IR_BINOP(OR); - - case MOJOSHADER_AST_OP_LOGICALAND: - return build_ir_logical_and(ctx, &ast->binary); - - case MOJOSHADER_AST_OP_LOGICALOR: - return build_ir_logical_or(ctx, &ast->binary); - - case MOJOSHADER_AST_OP_ASSIGN: - return build_ir_assign(ctx, &ast->binary); - - case MOJOSHADER_AST_OP_MULASSIGN: return build_ir_assign_binop(ctx, MOJOSHADER_IR_BINOP_MULTIPLY, &ast->binary); - case MOJOSHADER_AST_OP_DIVASSIGN: return build_ir_assign_binop(ctx, MOJOSHADER_IR_BINOP_DIVIDE, &ast->binary); - case MOJOSHADER_AST_OP_MODASSIGN: return build_ir_assign_binop(ctx, MOJOSHADER_IR_BINOP_MODULO, &ast->binary); - case MOJOSHADER_AST_OP_ADDASSIGN: return build_ir_assign_binop(ctx, MOJOSHADER_IR_BINOP_ADD, &ast->binary); - case MOJOSHADER_AST_OP_SUBASSIGN: return build_ir_assign_binop(ctx, MOJOSHADER_IR_BINOP_SUBTRACT, &ast->binary); - case MOJOSHADER_AST_OP_LSHIFTASSIGN: return build_ir_assign_binop(ctx, MOJOSHADER_IR_BINOP_LSHIFT, &ast->binary); - case MOJOSHADER_AST_OP_RSHIFTASSIGN: return build_ir_assign_binop(ctx, MOJOSHADER_IR_BINOP_RSHIFT, &ast->binary); - case MOJOSHADER_AST_OP_ANDASSIGN: return build_ir_assign_binop(ctx, MOJOSHADER_IR_BINOP_AND, &ast->binary); - case MOJOSHADER_AST_OP_XORASSIGN: return build_ir_assign_binop(ctx, MOJOSHADER_IR_BINOP_XOR, &ast->binary); - case MOJOSHADER_AST_OP_ORASSIGN: return build_ir_assign_binop(ctx, MOJOSHADER_IR_BINOP_OR, &ast->binary); - - case MOJOSHADER_AST_OP_CONDITIONAL: - assert(ast->binary.left->datatype->type == MOJOSHADER_AST_DATATYPE_BOOL); - return build_ir_compare(ctx, MOJOSHADER_IR_COND_EQL, - build_ir_expr(ctx, ast->ternary.left), - new_ir_constbool(ctx, 1), - build_ir_expr(ctx, ast->ternary.center), - build_ir_expr(ctx, ast->ternary.right)); - - case MOJOSHADER_AST_OP_IDENTIFIER: - return build_ir_identifier(ctx, &ast->identifier); - - case MOJOSHADER_AST_OP_INT_LITERAL: - return new_ir_constint(ctx, ast->intliteral.value); - - case MOJOSHADER_AST_OP_FLOAT_LITERAL: - return new_ir_constfloat(ctx, ast->floatliteral.value); - - case MOJOSHADER_AST_OP_BOOLEAN_LITERAL: - return new_ir_constbool(ctx, ast->boolliteral.value); - - case MOJOSHADER_AST_OP_CALLFUNC: - return build_ir_call(ctx, &ast->callfunc); - - case MOJOSHADER_AST_OP_CONSTRUCTOR: - return build_ir_constructor(ctx, &ast->constructor); - - case MOJOSHADER_AST_OP_CAST: - return build_ir_convert(ctx, &ast->cast); - - case MOJOSHADER_AST_STATEMENT_BREAK: - { - const LoopLabels *labels = ctx->ir_loop; - assert(labels != NULL); // semantic analysis should catch this. - return new_ir_jump(ctx, labels->end); - } // case - - case MOJOSHADER_AST_STATEMENT_CONTINUE: - { - const LoopLabels *labels = ctx->ir_loop; - assert(labels != NULL); // semantic analysis should catch this. - return new_ir_jump(ctx, labels->start); - } // case - - case MOJOSHADER_AST_STATEMENT_DISCARD: - return new_ir_seq(ctx, new_ir_discard(ctx), build_ir_stmt(ctx, ast->discardstmt.next)); - - case MOJOSHADER_AST_STATEMENT_EMPTY: - return build_ir(ctx, ast->stmt.next); // skip it, do next thing. - - case MOJOSHADER_AST_STATEMENT_EXPRESSION: - return new_ir_seq(ctx, new_ir_expr_stmt(ctx, build_ir_expr(ctx, ast->exprstmt.expr)), build_ir_stmt(ctx, ast->exprstmt.next)); - - case MOJOSHADER_AST_STATEMENT_IF: - return build_ir_ifstmt(ctx, &ast->ifstmt); - - case MOJOSHADER_AST_STATEMENT_TYPEDEF: // ignore this, move on. - return build_ir(ctx, ast->typedefstmt.next); - - case MOJOSHADER_AST_STATEMENT_SWITCH: - return build_ir_switch(ctx, &ast->switchstmt); - - case MOJOSHADER_AST_STATEMENT_STRUCT: // ignore this, move on. - return build_ir(ctx, ast->structstmt.next); - - case MOJOSHADER_AST_STATEMENT_VARDECL: // ignore this, move on. - return build_ir(ctx, ast->vardeclstmt.next); - - case MOJOSHADER_AST_STATEMENT_BLOCK: - return new_ir_seq(ctx, build_ir_stmt(ctx, ast->blockstmt.statements), build_ir_stmt(ctx, ast->blockstmt.next)); - - case MOJOSHADER_AST_STATEMENT_FOR: - return build_ir_forstmt(ctx, &ast->forstmt); - - case MOJOSHADER_AST_STATEMENT_DO: - return build_ir_dostmt(ctx, &ast->dostmt); - - case MOJOSHADER_AST_STATEMENT_WHILE: - return build_ir_whilestmt(ctx, &ast->whilestmt); - - case MOJOSHADER_AST_STATEMENT_RETURN: - { - const int label = ctx->ir_end; - assert(label >= 0); // parser should have caught this! - MOJOSHADER_irStatement *retval = NULL; - if (ast->returnstmt.expr != NULL) - { - // !!! FIXME: whole array/struct returns need to move more into the temp. - const MOJOSHADER_astDataType *dt = reduce_datatype(ctx, ast->returnstmt.expr->datatype); - const MOJOSHADER_astDataTypeType type = datatype_base(ctx, dt)->type; - const int elems = datatype_elems(ctx, dt); - assert(ctx->ir_ret >= 0); - retval = new_ir_move(ctx, new_ir_temp(ctx, ctx->ir_ret, type, elems), build_ir_expr(ctx, ast->returnstmt.expr), -1); - } // if - return new_ir_seq(ctx, retval, new_ir_jump(ctx, label)); - } // case - - case MOJOSHADER_AST_COMPUNIT_TYPEDEF: - case MOJOSHADER_AST_COMPUNIT_STRUCT: - case MOJOSHADER_AST_COMPUNIT_VARIABLE: - case MOJOSHADER_AST_COMPUNIT_FUNCTION: - case MOJOSHADER_AST_ARGUMENTS: - case MOJOSHADER_AST_OP_STRING_LITERAL: - case MOJOSHADER_AST_SWITCH_CASE: - case MOJOSHADER_AST_SCALAR_OR_ARRAY: - case MOJOSHADER_AST_TYPEDEF: - case MOJOSHADER_AST_FUNCTION_PARAMS: - case MOJOSHADER_AST_FUNCTION_SIGNATURE: - case MOJOSHADER_AST_STRUCT_DECLARATION: - case MOJOSHADER_AST_STRUCT_MEMBER: - case MOJOSHADER_AST_VARIABLE_DECLARATION: - case MOJOSHADER_AST_ANNOTATION: - case MOJOSHADER_AST_PACK_OFFSET: - case MOJOSHADER_AST_VARIABLE_LOWLEVEL: - assert(0 && "Shouldn't hit this in build_ir."); - return NULL; - - default: - assert(0 && "unexpected type"); - return NULL; - } // switch -} // build_ir - -static void print_ir(FILE *io, unsigned int depth, void *_ir) -{ - MOJOSHADER_irNode *ir = (MOJOSHADER_irNode *) _ir; - if (ir == NULL) - return; - - const char *fname = strrchr(ir->ir.filename, '/'); - if (fname != NULL) - fname++; - else - { - fname = strrchr(ir->ir.filename, '\\'); - if (fname != NULL) - fname++; - else - fname = ir->ir.filename; - } // else - - int i; - for (i = 0; i < depth; i++) - fprintf(io, " "); - depth++; - - fprintf(io, "[ %s:%d ", fname, ir->ir.line); - - switch (ir->ir.type) - { - case MOJOSHADER_IR_LABEL: - fprintf(io, "LABEL %d ]\n", ir->stmt.label.index); - break; - - case MOJOSHADER_IR_CONSTANT: - fprintf(io, "CONSTANT "); - switch (ir->expr.constant.info.type) - { - case MOJOSHADER_AST_DATATYPE_BOOL: - case MOJOSHADER_AST_DATATYPE_INT: - case MOJOSHADER_AST_DATATYPE_UINT: - for (i = 0; i < ir->expr.constant.info.elements-1; i++) - fprintf(io, "%d, ", ir->expr.constant.value.ival[i]); - if (ir->expr.constant.info.elements > 0) - fprintf(io, "%d", ir->expr.constant.value.ival[i]); - break; - - case MOJOSHADER_AST_DATATYPE_FLOAT: - case MOJOSHADER_AST_DATATYPE_FLOAT_SNORM: - case MOJOSHADER_AST_DATATYPE_FLOAT_UNORM: - case MOJOSHADER_AST_DATATYPE_HALF: - case MOJOSHADER_AST_DATATYPE_DOUBLE: - for (i = 0; i < ir->expr.constant.info.elements-1; i++) - fprintf(io, "%ff, ", ir->expr.constant.value.fval[i]); - if (ir->expr.constant.info.elements > 0) - fprintf(io, "%ff", ir->expr.constant.value.fval[i]); - break; - - default: assert(0 && "shouldn't happen"); - } // switch - fprintf(io, " ]\n"); - break; - - case MOJOSHADER_IR_TEMP: - fprintf(io, "TEMP %d ]\n", ir->expr.temp.index); - break; - - case MOJOSHADER_IR_DISCARD: - fprintf(io, "DISCARD ]\n"); - break; - - case MOJOSHADER_IR_SWIZZLE: - fprintf(io, "SWIZZLE"); - for (i = 0; i < ir->expr.swizzle.info.elements-1; i++) - fprintf(io, " %d", (int) ir->expr.swizzle.channels[i]); - fprintf(io, " ]\n"); - print_ir(io, depth, ir->expr.swizzle.expr); - break; - - case MOJOSHADER_IR_CONSTRUCT: - fprintf(io, "CONSTRUCT ]\n"); - print_ir(io, depth, ir->expr.construct.args); - break; - - case MOJOSHADER_IR_CONVERT: - fprintf(io, "CONVERT ]\n"); - print_ir(io, depth, ir->expr.convert.expr); - break; - - case MOJOSHADER_IR_BINOP: - fprintf(io, "BINOP "); - switch (ir->expr.binop.op) - { - #define PRINT_IR_BINOP(x) \ - case MOJOSHADER_IR_BINOP_##x: fprintf(io, #x); break; - PRINT_IR_BINOP(ADD) - PRINT_IR_BINOP(SUBTRACT) - PRINT_IR_BINOP(MULTIPLY) - PRINT_IR_BINOP(DIVIDE) - PRINT_IR_BINOP(MODULO) - PRINT_IR_BINOP(AND) - PRINT_IR_BINOP(OR) - PRINT_IR_BINOP(XOR) - PRINT_IR_BINOP(LSHIFT) - PRINT_IR_BINOP(RSHIFT) - PRINT_IR_BINOP(UNKNOWN) - #undef PRINT_IR_BINOP - default: assert(0 && "unexpected case"); break; - } // switch - fprintf(io, " ]\n"); - print_ir(io, depth, ir->expr.binop.left); - print_ir(io, depth, ir->expr.binop.right); - break; - - case MOJOSHADER_IR_MEMORY: - fprintf(io, "MEMORY %d ]\n", ir->expr.memory.index); - break; - - case MOJOSHADER_IR_CALL: - fprintf(io, "CALL %d ]\n", ir->expr.call.index); - print_ir(io, depth, ir->expr.call.args); - break; - - case MOJOSHADER_IR_ESEQ: - fprintf(io, "ESEQ ]\n"); - print_ir(io, depth, ir->expr.eseq.stmt); - break; - - case MOJOSHADER_IR_ARRAY: - fprintf(io, "ARRAY ]\n"); - print_ir(io, depth, ir->expr.array.array); - print_ir(io, depth, ir->expr.array.element); - break; - - case MOJOSHADER_IR_MOVE: - fprintf(io, "MOVE ]\n"); - print_ir(io, depth, ir->stmt.move.dst); - print_ir(io, depth, ir->stmt.move.src); - break; - - case MOJOSHADER_IR_EXPR_STMT: - fprintf(io, "EXPRSTMT ]\n"); - print_ir(io, depth, ir->stmt.expr.expr); - break; - - case MOJOSHADER_IR_JUMP: - fprintf(io, "JUMP %d ]\n", ir->stmt.jump.label); - break; - - case MOJOSHADER_IR_CJUMP: - fprintf(io, "CJUMP "); - switch (ir->stmt.cjump.cond) - { - #define PRINT_IR_COND(x) \ - case MOJOSHADER_IR_COND_##x: fprintf(io, #x); break; - PRINT_IR_COND(EQL) - PRINT_IR_COND(NEQ) - PRINT_IR_COND(LT) - PRINT_IR_COND(GT) - PRINT_IR_COND(LEQ) - PRINT_IR_COND(GEQ) - PRINT_IR_COND(UNKNOWN) - #undef PRINT_IR_COND - default: assert(0 && "unexpected case"); break; - } // switch - fprintf(io, " %d %d ]\n", ir->stmt.cjump.iftrue, ir->stmt.cjump.iffalse); - print_ir(io, depth, ir->stmt.cjump.left); - print_ir(io, depth, ir->stmt.cjump.right); - break; - - case MOJOSHADER_IR_SEQ: - fprintf(io, "SEQ ]\n"); - print_ir(io, depth, ir->stmt.seq.first); - print_ir(io, depth, ir->stmt.seq.next); // !!! FIXME: don't recurse? - break; - - case MOJOSHADER_IR_EXPRLIST: - fprintf(io, "EXPRLIST ]\n"); - print_ir(io, depth, ir->misc.exprlist.expr); - print_ir(io, depth, ir->misc.exprlist.next); // !!! FIXME: don't recurse? - break; - - default: assert(0 && "unexpected IR node"); break; - } // switch -} // print_ir - -static void print_whole_ir(Context *ctx, FILE *io) -{ - if (ctx->ir != NULL) - { - int i; - for (i = 0; i <= ctx->user_func_index; i++) - { - printf("[FUNCTION %d ]\n", i); - print_ir(io, 1, ctx->ir[i]); - } // for - } // if -} // print_whole_ir - -static void delete_ir(Context *ctx, void *_ir) -{ - MOJOSHADER_irNode *ir = (MOJOSHADER_irNode *) _ir; - if (ir == NULL) - return; - - switch (ir->ir.type) - { - case MOJOSHADER_IR_JUMP: - case MOJOSHADER_IR_LABEL: - case MOJOSHADER_IR_CONSTANT: - case MOJOSHADER_IR_TEMP: - case MOJOSHADER_IR_DISCARD: - case MOJOSHADER_IR_MEMORY: - break; // nothing extra to free here. - - case MOJOSHADER_IR_BINOP: - delete_ir(ctx, ir->expr.binop.left); - delete_ir(ctx, ir->expr.binop.right); - break; - - case MOJOSHADER_IR_CALL: - delete_ir(ctx, ir->expr.call.args); - break; - - case MOJOSHADER_IR_ESEQ: - delete_ir(ctx, ir->expr.eseq.stmt); - delete_ir(ctx, ir->expr.eseq.expr); - break; - - case MOJOSHADER_IR_ARRAY: - delete_ir(ctx, ir->expr.array.array); - delete_ir(ctx, ir->expr.array.element); - break; - - case MOJOSHADER_IR_MOVE: - delete_ir(ctx, ir->stmt.move.dst); - delete_ir(ctx, ir->stmt.move.src); - break; - - case MOJOSHADER_IR_EXPR_STMT: - delete_ir(ctx, ir->stmt.expr.expr); - break; - - case MOJOSHADER_IR_CJUMP: - delete_ir(ctx, ir->stmt.cjump.left); - delete_ir(ctx, ir->stmt.cjump.right); - break; - - case MOJOSHADER_IR_SEQ: - delete_ir(ctx, ir->stmt.seq.first); - delete_ir(ctx, ir->stmt.seq.next); // !!! FIXME: don't recurse? - break; - - case MOJOSHADER_IR_EXPRLIST: - delete_ir(ctx, ir->misc.exprlist.expr); - delete_ir(ctx, ir->misc.exprlist.next); // !!! FIXME: don't recurse? - break; - - case MOJOSHADER_IR_SWIZZLE: - delete_ir(ctx, ir->expr.swizzle.expr); - break; - - case MOJOSHADER_IR_CONSTRUCT: - delete_ir(ctx, ir->expr.construct.args); - break; - - case MOJOSHADER_IR_CONVERT: - delete_ir(ctx, ir->expr.convert.expr); - break; - - default: assert(0 && "unexpected IR node"); break; - } // switch - - Free(ctx, ir); -} // delete_ir - -static void intermediate_representation(Context *ctx) -{ - const MOJOSHADER_astCompilationUnit *ast = NULL; - const MOJOSHADER_astCompilationUnitFunction *astfn = NULL; - const size_t arraylen = (ctx->user_func_index+1) * sizeof (MOJOSHADER_irStatement *); - - ctx->ir = Malloc(ctx, arraylen); - if (ctx->ir == NULL) - return; - memset(ctx->ir, '\0', arraylen); - - ctx->ir_end = -1; - ctx->ir_ret = -1; - - for (ast = &ctx->ast->compunit; ast != NULL; ast = ast->next) - { - assert(ast->ast.type > MOJOSHADER_AST_COMPUNIT_START_RANGE); - assert(ast->ast.type < MOJOSHADER_AST_COMPUNIT_END_RANGE); - if (ast->ast.type != MOJOSHADER_AST_COMPUNIT_FUNCTION) - continue; // only care about functions right now. - - astfn = (MOJOSHADER_astCompilationUnitFunction *) ast; - if (astfn->definition == NULL) // just a predeclare; skip. - continue; - - assert(ctx->ir_loop == NULL); // parser should have caught this! - assert(ctx->ir_end < 0); // parser should have caught this! - assert(ctx->ir_ret < 0); // parser should have caught this! - const int start = generate_ir_label(ctx); // !!! FIXME: store somewhere. - const int end = generate_ir_label(ctx); - ctx->ir_end = end; - - if (astfn->declaration->datatype != NULL) - ctx->ir_ret = generate_ir_temp(ctx); - - MOJOSHADER_irStatement *funcseq = new_ir_seq(ctx, new_ir_label(ctx, start), build_ir_stmt(ctx, astfn->definition)); - funcseq = new_ir_seq(ctx, funcseq, new_ir_label(ctx, end)); - assert(ctx->ir_loop == NULL); // parser should have caught this! - ctx->ir_end = -1; - ctx->ir_ret = -1; - - assert(astfn->index <= ctx->user_func_index); - assert(ctx->ir[astfn->index] == NULL); - ctx->ir[astfn->index] = funcseq; - } // for - - print_whole_ir(ctx, stdout); - - // done with the AST, nuke it. - // !!! FIXME: we're going to need CTAB data from this at some point. - delete_compilation_unit(ctx, (MOJOSHADER_astCompilationUnit *) ctx->ast); - ctx->ast = NULL; -} // intermediate_representation - - - -static MOJOSHADER_astData MOJOSHADER_out_of_mem_ast_data = { - 1, &MOJOSHADER_out_of_mem_error, 0, 0, 0, 0, 0, 0 -}; - - -// !!! FIXME: cut and paste from assembler. -static const MOJOSHADER_astData *build_failed_ast(Context *ctx) -{ - assert(isfail(ctx)); - - if (ctx->out_of_memory) - return &MOJOSHADER_out_of_mem_ast_data; - - MOJOSHADER_astData *retval = NULL; - retval = (MOJOSHADER_astData *) Malloc(ctx, sizeof (MOJOSHADER_astData)); - if (retval == NULL) - return &MOJOSHADER_out_of_mem_ast_data; - - memset(retval, '\0', sizeof (MOJOSHADER_astData)); - retval->source_profile = ctx->source_profile; - retval->malloc = (ctx->malloc == MOJOSHADER_internal_malloc) ? NULL : ctx->malloc; - retval->free = (ctx->free == MOJOSHADER_internal_free) ? NULL : ctx->free; - retval->malloc_data = ctx->malloc_data; - retval->error_count = errorlist_count(ctx->errors); - retval->errors = errorlist_flatten(ctx->errors); - - if (ctx->out_of_memory) - { - Free(ctx, retval); - return &MOJOSHADER_out_of_mem_ast_data; - } // if - - return retval; -} // build_failed_ast - - -static const MOJOSHADER_astData *build_astdata(Context *ctx) -{ - MOJOSHADER_astData *retval = NULL; - - if (ctx->out_of_memory) - return &MOJOSHADER_out_of_mem_ast_data; - - retval = (MOJOSHADER_astData *) Malloc(ctx, sizeof (MOJOSHADER_astData)); - if (retval == NULL) - return &MOJOSHADER_out_of_mem_ast_data; - - memset(retval, '\0', sizeof (MOJOSHADER_astData)); - retval->malloc = (ctx->malloc == MOJOSHADER_internal_malloc) ? NULL : ctx->malloc; - retval->free = (ctx->free == MOJOSHADER_internal_free) ? NULL : ctx->free; - retval->malloc_data = ctx->malloc_data; - - if (!isfail(ctx)) - { - retval->source_profile = ctx->source_profile; - retval->ast = ctx->ast; - } // if - - retval->error_count = errorlist_count(ctx->errors); - retval->errors = errorlist_flatten(ctx->errors); - if (ctx->out_of_memory) - { - Free(ctx, retval); - return &MOJOSHADER_out_of_mem_ast_data; - } // if - - retval->opaque = ctx; - - return retval; -} // build_astdata - - -static void choose_src_profile(Context *ctx, const char *srcprofile) -{ - ctx->source_profile = srcprofile; - - #define TEST_PROFILE(x) if (strcmp(srcprofile, x) == 0) { return; } - - TEST_PROFILE(MOJOSHADER_SRC_PROFILE_HLSL_VS_1_1); - TEST_PROFILE(MOJOSHADER_SRC_PROFILE_HLSL_VS_2_0); - TEST_PROFILE(MOJOSHADER_SRC_PROFILE_HLSL_VS_3_0); - TEST_PROFILE(MOJOSHADER_SRC_PROFILE_HLSL_PS_1_1); - TEST_PROFILE(MOJOSHADER_SRC_PROFILE_HLSL_PS_1_2); - TEST_PROFILE(MOJOSHADER_SRC_PROFILE_HLSL_PS_1_3); - TEST_PROFILE(MOJOSHADER_SRC_PROFILE_HLSL_PS_1_4); - TEST_PROFILE(MOJOSHADER_SRC_PROFILE_HLSL_PS_2_0); - TEST_PROFILE(MOJOSHADER_SRC_PROFILE_HLSL_PS_3_0); - - #undef TEST_PROFILE - - fail(ctx, "Unknown profile"); -} // choose_src_profile - - -static MOJOSHADER_compileData MOJOSHADER_out_of_mem_compile_data = { - 1, &MOJOSHADER_out_of_mem_error, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 -}; - - -// !!! FIXME: cut and paste from assembler. -static const MOJOSHADER_compileData *build_failed_compile(Context *ctx) -{ - assert(isfail(ctx)); - - MOJOSHADER_compileData *retval = NULL; - retval = (MOJOSHADER_compileData *) Malloc(ctx, sizeof (MOJOSHADER_compileData)); - if (retval == NULL) - return &MOJOSHADER_out_of_mem_compile_data; - - memset(retval, '\0', sizeof (MOJOSHADER_compileData)); - retval->malloc = (ctx->malloc == MOJOSHADER_internal_malloc) ? NULL : ctx->malloc; - retval->free = (ctx->free == MOJOSHADER_internal_free) ? NULL : ctx->free; - retval->malloc_data = ctx->malloc_data; - retval->source_profile = ctx->source_profile; - retval->error_count = errorlist_count(ctx->errors); - retval->errors = errorlist_flatten(ctx->errors); - retval->warning_count = errorlist_count(ctx->warnings); - retval->warnings = errorlist_flatten(ctx->warnings); - - if (ctx->out_of_memory) // in case something failed up there. - { - MOJOSHADER_freeCompileData(retval); - return &MOJOSHADER_out_of_mem_compile_data; - } // if - - return retval; -} // build_failed_compile - - -static const MOJOSHADER_compileData *build_compiledata(Context *ctx) -{ - assert(!isfail(ctx)); - - MOJOSHADER_compileData *retval = NULL; - - retval = (MOJOSHADER_compileData *) Malloc(ctx, sizeof (MOJOSHADER_compileData)); - if (retval == NULL) - return &MOJOSHADER_out_of_mem_compile_data; - - memset(retval, '\0', sizeof (MOJOSHADER_compileData)); - retval->malloc = (ctx->malloc == MOJOSHADER_internal_malloc) ? NULL : ctx->malloc; - retval->free = (ctx->free == MOJOSHADER_internal_free) ? NULL : ctx->free; - retval->malloc_data = ctx->malloc_data; - retval->source_profile = ctx->source_profile; - - if (!isfail(ctx)) - { - // !!! FIXME: build output and output_len here. - } // if - - if (!isfail(ctx)) - { - // !!! FIXME: build symbols and symbol_count here. - } // if - - retval->error_count = errorlist_count(ctx->errors); - retval->errors = errorlist_flatten(ctx->errors); - retval->warning_count = errorlist_count(ctx->warnings); - retval->warnings = errorlist_flatten(ctx->warnings); - - if (ctx->out_of_memory) // in case something failed up there. - { - MOJOSHADER_freeCompileData(retval); - return &MOJOSHADER_out_of_mem_compile_data; - } // if - - return retval; -} // build_compiledata - - -// API entry point... - -// !!! FIXME: move this (and a lot of other things) to mojoshader_ast.c. -const MOJOSHADER_astData *MOJOSHADER_parseAst(const char *srcprofile, - const char *filename, const char *source, - unsigned int sourcelen, - const MOJOSHADER_preprocessorDefine *defs, - unsigned int define_count, - MOJOSHADER_includeOpen include_open, - MOJOSHADER_includeClose include_close, - MOJOSHADER_malloc m, MOJOSHADER_free f, - void *d) -{ - const MOJOSHADER_astData *retval = NULL; - Context *ctx = NULL; - - if ( ((m == NULL) && (f != NULL)) || ((m != NULL) && (f == NULL)) ) - return &MOJOSHADER_out_of_mem_ast_data; // supply both or neither. - - ctx = build_context(m, f, d); - if (ctx == NULL) - return &MOJOSHADER_out_of_mem_ast_data; - - choose_src_profile(ctx, srcprofile); - - if (!isfail(ctx)) - { - parse_source(ctx, filename, source, sourcelen, defs, define_count, - include_open, include_close); - } // if - - if (!isfail(ctx)) - retval = build_astdata(ctx); // ctx isn't destroyed yet! - else - { - retval = (MOJOSHADER_astData *) build_failed_ast(ctx); - destroy_context(ctx); - } // else - - return retval; -} // MOJOSHADER_parseAst - - -void MOJOSHADER_freeAstData(const MOJOSHADER_astData *_data) -{ - MOJOSHADER_astData *data = (MOJOSHADER_astData *) _data; - if ((data == NULL) || (data == &MOJOSHADER_out_of_mem_ast_data)) - return; // no-op. - - // !!! FIXME: this needs to live for deleting the stringcache and the ast. - Context *ctx = (Context *) data->opaque; - MOJOSHADER_free f = (data->free == NULL) ? MOJOSHADER_internal_free : data->free; - void *d = data->malloc_data; - int i; - - // we don't f(data->source_profile), because that's internal static data. - - for (i = 0; i < data->error_count; i++) - { - f((void *) data->errors[i].error, d); - f((void *) data->errors[i].filename, d); - } // for - f((void *) data->errors, d); - - // don't delete data->ast (it'll delete with the context). - f(data, d); - - destroy_context(ctx); // finally safe to destroy this. -} // MOJOSHADER_freeAstData - - -const MOJOSHADER_compileData *MOJOSHADER_compile(const char *srcprofile, - const char *filename, const char *source, - unsigned int sourcelen, - const MOJOSHADER_preprocessorDefine *defs, - unsigned int define_count, - MOJOSHADER_includeOpen include_open, - MOJOSHADER_includeClose include_close, - MOJOSHADER_malloc m, MOJOSHADER_free f, - void *d) -{ - // !!! FIXME: cut and paste from MOJOSHADER_parseAst(). - MOJOSHADER_compileData *retval = NULL; - Context *ctx = NULL; - - if ( ((m == NULL) && (f != NULL)) || ((m != NULL) && (f == NULL)) ) - return &MOJOSHADER_out_of_mem_compile_data; // supply both or neither. - - ctx = build_context(m, f, d); - if (ctx == NULL) - return &MOJOSHADER_out_of_mem_compile_data; - - choose_src_profile(ctx, srcprofile); - - if (!isfail(ctx)) - { - parse_source(ctx, filename, source, sourcelen, defs, define_count, - include_open, include_close); - } // if - - if (!isfail(ctx)) - semantic_analysis(ctx); - - if (!isfail(ctx)) - intermediate_representation(ctx); - - if (isfail(ctx)) - retval = (MOJOSHADER_compileData *) build_failed_compile(ctx); - else - retval = (MOJOSHADER_compileData *) build_compiledata(ctx); - - destroy_context(ctx); - return retval; -} // MOJOSHADER_compile - - -void MOJOSHADER_freeCompileData(const MOJOSHADER_compileData *_data) -{ - MOJOSHADER_compileData *data = (MOJOSHADER_compileData *) _data; - if ((data == NULL) || (data == &MOJOSHADER_out_of_mem_compile_data)) - return; // no-op. - - MOJOSHADER_free f = (data->free == NULL) ? MOJOSHADER_internal_free : data->free; - void *d = data->malloc_data; - int i; - - // we don't f(data->source_profile), because that's internal static data. - - for (i = 0; i < data->error_count; i++) - { - f((void *) data->errors[i].error, d); - f((void *) data->errors[i].filename, d); - } // for - f((void *) data->errors, d); - - for (i = 0; i < data->warning_count; i++) - { - f((void *) data->warnings[i].error, d); - f((void *) data->warnings[i].filename, d); - } // for - f((void *) data->warnings, d); - - for (i = 0; i < data->symbol_count; i++) - { - f((void *) data->symbols[i].name, d); - // !!! FIXME: this is missing stuff (including freeing substructs). - } // for - f((void *) data->symbols, d); - - f((void *) data->output, d); - f(data, d); -} // MOJOSHADER_freeCompileData - -// end of mojoshader_compiler.c ... - diff --git a/Externals/mojoshader/1067/mojoshader_effects.c b/Externals/mojoshader/1067/mojoshader_effects.c deleted file mode 100644 index 4cda1bff..00000000 --- a/Externals/mojoshader/1067/mojoshader_effects.c +++ /dev/null @@ -1,631 +0,0 @@ -/** - * MojoShader; generate shader programs from bytecode of compiled - * Direct3D shaders. - * - * Please see the file LICENSE.txt in the source's root directory. - * - * This file written by Ryan C. Gordon. - */ - -#define __MOJOSHADER_INTERNAL__ 1 -#include "mojoshader_internal.h" - -#include <math.h> - -#if SUPPORT_PRESHADERS -void MOJOSHADER_runPreshader(const MOJOSHADER_preshader *preshader, - const float *inregs, float *outregs) -{ - // this is fairly straightforward, as there aren't any branching - // opcodes in the preshader instruction set (at the moment, at least). - const int scalarstart = (int) MOJOSHADER_PRESHADEROP_SCALAR_OPS; - - double *temps = NULL; - if (preshader->temp_count > 0) - { - temps = (double *) alloca(sizeof (double) * preshader->temp_count); - memset(temps, '\0', sizeof (double) * preshader->temp_count); - } // if - - double dst[4] = { 0, 0, 0, 0 }; - double src[3][4] = { { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 } }; - const double *src0 = &src[0][0]; - const double *src1 = &src[1][0]; - const double *src2 = &src[2][0]; - - MOJOSHADER_preshaderInstruction *inst = preshader->instructions; - int instit; - - for (instit = 0; instit < preshader->instruction_count; instit++, inst++) - { - const MOJOSHADER_preshaderOperand *operand = inst->operands; - const int elems = inst->element_count; - const int elemsbytes = sizeof (double) * elems; - const int isscalarop = (inst->opcode >= scalarstart); - - assert(elems >= 0); - assert(elems <= 4); - - // load up our operands... - int opiter, elemiter; - for (opiter = 0; opiter < inst->operand_count-1; opiter++, operand++) - { - const int isscalar = ((isscalarop) && (opiter == 0)); - const unsigned int index = operand->index; - switch (operand->type) - { - case MOJOSHADER_PRESHADEROPERAND_LITERAL: - { - const double *lit = &preshader->literals[index]; - assert((index + elems) <= preshader->literal_count); - if (!isscalar) - memcpy(&src[opiter][0], lit, elemsbytes); - else - { - const double val = *lit; - for (elemiter = 0; elemiter < elems; elemiter++) - src[opiter][elemiter] = val; - } // else - break; - } // case - - case MOJOSHADER_PRESHADEROPERAND_INPUT: - if (isscalar) - src[opiter][0] = inregs[index]; - else - { - int cpy; - for (cpy = 0; cpy < elems; cpy++) - src[opiter][cpy] = inregs[index+cpy]; - } // else - break; - - case MOJOSHADER_PRESHADEROPERAND_OUTPUT: - if (isscalar) - src[opiter][0] = outregs[index]; - else - { - int cpy; - for (cpy = 0; cpy < elems; cpy++) - src[opiter][cpy] = outregs[index+cpy]; - } // else - break; - - case MOJOSHADER_PRESHADEROPERAND_TEMP: - if (temps != NULL) - { - if (isscalar) - src[opiter][0] = temps[index]; - else - memcpy(src[opiter], temps + index, elemsbytes); - } // if - break; - - default: - assert(0 && "unexpected preshader operand type."); - return; - } // switch - } // for - - // run the actual instruction, store result to dst. - int i; - switch (inst->opcode) - { - #define OPCODE_CASE(op, val) \ - case MOJOSHADER_PRESHADEROP_##op: \ - for (i = 0; i < elems; i++) { dst[i] = val; } \ - break; - - //OPCODE_CASE(NOP, 0.0) // not a real instruction. - OPCODE_CASE(MOV, src0[i]) - OPCODE_CASE(NEG, -src0[i]) - OPCODE_CASE(RCP, 1.0 / src0[i]) - OPCODE_CASE(FRC, src0[i] - floor(src0[i])) - OPCODE_CASE(EXP, exp(src0[i])) - OPCODE_CASE(LOG, log(src0[i])) - OPCODE_CASE(RSQ, 1.0 / sqrt(src0[i])) - OPCODE_CASE(SIN, sin(src0[i])) - OPCODE_CASE(COS, cos(src0[i])) - OPCODE_CASE(ASIN, asin(src0[i])) - OPCODE_CASE(ACOS, acos(src0[i])) - OPCODE_CASE(ATAN, atan(src0[i])) - OPCODE_CASE(MIN, (src0[i] < src1[i]) ? src0[i] : src1[i]) - OPCODE_CASE(MAX, (src0[i] > src1[i]) ? src0[i] : src1[i]) - OPCODE_CASE(LT, (src0[i] < src1[i]) ? 1.0 : 0.0) - OPCODE_CASE(GE, (src0[i] >= src1[i]) ? 1.0 : 0.0) - OPCODE_CASE(ADD, src0[i] + src1[i]) - OPCODE_CASE(MUL, src0[i] * src1[i]) - OPCODE_CASE(ATAN2, atan2(src0[i], src1[i])) - OPCODE_CASE(DIV, src0[i] / src1[i]) - OPCODE_CASE(CMP, (src0[i] >= 0.0) ? src1[i] : src2[i]) - //OPCODE_CASE(NOISE, ???) // !!! FIXME: don't know what this does - //OPCODE_CASE(MOVC, ???) // !!! FIXME: don't know what this does - #undef OPCODE_CASE - - case MOJOSHADER_PRESHADEROP_DOT: - { - double final = 0.0; - for (i = 0; i < elems; i++) - final += src0[i] * src1[i]; - for (i = 0; i < elems; i++) - dst[i] = final; // !!! FIXME: is this right? - } // case - - #define OPCODE_CASE_SCALAR(op, val) \ - case MOJOSHADER_PRESHADEROP_##op##_SCALAR: { \ - const double final = val; \ - for (i = 0; i < elems; i++) { dst[i] = final; } \ - break; \ - } - - OPCODE_CASE_SCALAR(MIN, (src0[0] < src1[0]) ? src0[0] : src1[0]) - OPCODE_CASE_SCALAR(MAX, (src0[0] > src1[0]) ? src0[0] : src1[0]) - OPCODE_CASE_SCALAR(LT, (src0[0] < src1[0]) ? 1.0 : 0.0) - OPCODE_CASE_SCALAR(GE, (src0[0] >= src1[0]) ? 1.0 : 0.0) - OPCODE_CASE_SCALAR(ADD, src0[0] + src1[0]) - OPCODE_CASE_SCALAR(MUL, src0[0] * src1[0]) - OPCODE_CASE_SCALAR(ATAN2, atan2(src0[0], src1[0])) - OPCODE_CASE_SCALAR(DIV, src0[0] / src1[0]) - //OPCODE_CASE_SCALAR(DOT) // !!! FIXME: isn't this just a MUL? - //OPCODE_CASE_SCALAR(NOISE, ???) // !!! FIXME: ? - #undef OPCODE_CASE_SCALAR - - default: - assert(0 && "Unhandled preshader opcode!"); - break; - } // switch - - // Figure out where dst wants to be stored. - if (operand->type == MOJOSHADER_PRESHADEROPERAND_TEMP) - { - assert(preshader->temp_count >= - operand->index + (elemsbytes / sizeof (double))); - memcpy(temps + operand->index, dst, elemsbytes); - } // if - else - { - assert(operand->type == MOJOSHADER_PRESHADEROPERAND_OUTPUT); - for (i = 0; i < elems; i++) - outregs[operand->index + i] = (float) dst[i]; - } // else - } // for -} // MOJOSHADER_runPreshader -#endif - -static MOJOSHADER_effect MOJOSHADER_out_of_mem_effect = { - 1, &MOJOSHADER_out_of_mem_error, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 -}; - -static uint32 readui32(const uint8 **_ptr, uint32 *_len) -{ - uint32 retval = 0; - if (*_len < sizeof (retval)) - *_len = 0; - else - { - const uint32 *ptr = (const uint32 *) *_ptr; - retval = SWAP32(*ptr); - *_ptr += sizeof (retval); - *_len -= sizeof (retval); - } // else - return retval; -} // readui32 - -// !!! FIXME: this is sort of a big, ugly function. -const MOJOSHADER_effect *MOJOSHADER_parseEffect(const char *profile, - const unsigned char *buf, - const unsigned int _len, - const MOJOSHADER_swizzle *swiz, - const unsigned int swizcount, - MOJOSHADER_malloc m, - MOJOSHADER_free f, - void *d) -{ - if ( ((m == NULL) && (f != NULL)) || ((m != NULL) && (f == NULL)) ) - return &MOJOSHADER_out_of_mem_effect; // supply both or neither. - - if (m == NULL) m = MOJOSHADER_internal_malloc; - if (f == NULL) f = MOJOSHADER_internal_free; - - MOJOSHADER_effect *retval = m(sizeof (MOJOSHADER_effect), d); - if (retval == NULL) - return &MOJOSHADER_out_of_mem_effect; // supply both or neither. - memset(retval, '\0', sizeof (*retval)); - - retval->malloc = m; - retval->free = f; - retval->malloc_data = d; - - const uint8 *ptr = (const uint8 *) buf; - uint32 len = (uint32) _len; - size_t siz = 0; - int i, j, k; - - if (len < 8) - goto parseEffect_unexpectedEOF; - - const uint8 *base = NULL; - if (readui32(&ptr, &len) != 0xFEFF0901) // !!! FIXME: is this always magic? - goto parseEffect_notAnEffectsFile; - else - { - const uint32 offset = readui32(&ptr, &len); - base = ptr; -//printf("base offset == %u\n", offset); - if (offset > len) - goto parseEffect_unexpectedEOF; - ptr += offset; - len -= offset; - } // else - - // params... - - if (len < 16) - goto parseEffect_unexpectedEOF; - - const uint32 numparams = readui32(&ptr, &len); - const uint32 numtechniques = readui32(&ptr, &len); - - readui32(&ptr, &len); // !!! FIXME: there are 8 unknown bytes here. Annotations? - /*const uint32 numobjects = */ readui32(&ptr, &len); - - if (numparams > 0) - { - siz = sizeof (MOJOSHADER_effectParam) * numparams; - retval->params = (MOJOSHADER_effectParam *) m(siz, d); - if (retval->params == NULL) - goto parseEffect_outOfMemory; - memset(retval->params, '\0', siz); - - retval->param_count = numparams; - - for (i = 0; i < numparams; i++) - { - if (len < 16) - goto parseEffect_unexpectedEOF; - - const uint32 typeoffset = readui32(&ptr, &len); - /*const uint32 valoffset =*/ readui32(&ptr, &len); - /*const uint32 flags =*/ readui32(&ptr, &len); - const uint32 numannos = readui32(&ptr, &len); - for (j = 0; j < numannos; j++) - { - if (len < 8) - goto parseEffect_unexpectedEOF; - // !!! FIXME: parse annotations. - readui32(&ptr, &len); - readui32(&ptr, &len); - } // for - - const uint8 *typeptr = base + typeoffset; - unsigned int typelen = 9999999; // !!! FIXME - /*const uint32 paramtype =*/ readui32(&typeptr, &typelen); - /*const uint32 paramclass =*/ readui32(&typeptr, &typelen); - const uint32 paramname = readui32(&typeptr, &typelen); - const uint32 paramsemantic = readui32(&typeptr, &typelen); - - // !!! FIXME: sanity checks! - const char *namestr = ((const char *) base) + paramname; - const char *semstr = ((const char *) base) + paramsemantic; - uint32 len; - char *strptr; - len = *((const uint32 *) namestr); - strptr = (char *) m(len + 1, d); - memcpy(strptr, namestr + 4, len); - strptr[len] = '\0'; - retval->params[i].name = strptr; - len = *((const uint32 *) semstr); - strptr = (char *) m(len + 1, d); - memcpy(strptr, semstr + 4, len); - strptr[len] = '\0'; - retval->params[i].semantic = strptr; - } // for - } // if - - uint32 numshaders = 0; // we'll calculate this later. - - // techniques... - - if (numtechniques > 0) - { - siz = sizeof (MOJOSHADER_effectTechnique) * numtechniques; - retval->techniques = (MOJOSHADER_effectTechnique *) m(siz, d); - if (retval->techniques == NULL) - goto parseEffect_outOfMemory; - memset(retval->techniques, '\0', siz); - - retval->technique_count = numtechniques; - - for (i = 0; i < numtechniques; i++) - { - if (len < 12) - goto parseEffect_unexpectedEOF; - - MOJOSHADER_effectTechnique *technique = &retval->techniques[i]; - - const uint32 nameoffset = readui32(&ptr, &len); - const uint32 numannos = readui32(&ptr, &len); - const uint32 numpasses = readui32(&ptr, &len); - - if (nameoffset >= _len) - goto parseEffect_unexpectedEOF; - - if (numannos > 0) - { - // !!! FIXME: expose these to the caller? - for (j = 0; j < numannos; j++) - { - if (len < 8) - goto parseEffect_unexpectedEOF; - readui32(&ptr, &len); // typedef offset - readui32(&ptr, &len); // value offset - } // for - } // if - - // !!! FIXME: verify this doesn't go past EOF looking for a null. - { - const char *namestr = ((char *) base) + nameoffset; - uint32 len = *((const uint32 *) namestr); - char *strptr = (char *) m(len + 1, d); - memcpy(strptr, namestr + 4, len); - strptr[len] = '\0'; - technique->name = strptr; - } - - if (numpasses > 0) - { - technique->pass_count = numpasses; - - siz = sizeof (MOJOSHADER_effectPass) * numpasses; - technique->passes = (MOJOSHADER_effectPass *) m(siz, d); - if (technique->passes == NULL) - goto parseEffect_outOfMemory; - memset(technique->passes, '\0', siz); - - for (j = 0; j < numpasses; j++) - { - if (len < 12) - goto parseEffect_unexpectedEOF; - - MOJOSHADER_effectPass *pass = &technique->passes[j]; - - const uint32 passnameoffset = readui32(&ptr, &len); - const uint32 numannos = readui32(&ptr, &len); - const uint32 numstates = readui32(&ptr, &len); - - if (passnameoffset >= _len) - goto parseEffect_unexpectedEOF; - - // !!! FIXME: verify this doesn't go past EOF looking for a null. - { - const char *namestr = ((char *) base) + passnameoffset; - uint32 len = *((const uint32 *) namestr); - char *strptr = (char *) m(len + 1, d); - memcpy(strptr, namestr + 4, len); - strptr[len] = '\0'; - pass->name = strptr; - } - - if (numannos > 0) - { - for (k = 0; k < numannos; k++) - { - if (len < 8) - goto parseEffect_unexpectedEOF; - // !!! FIXME: do something with this. - readui32(&ptr, &len); - readui32(&ptr, &len); - } // for - } // if - - if (numstates > 0) - { - pass->state_count = numstates; - - siz = sizeof (MOJOSHADER_effectState) * numstates; - pass->states = (MOJOSHADER_effectState *) m(siz, d); - if (pass->states == NULL) - goto parseEffect_outOfMemory; - memset(pass->states, '\0', siz); - - for (k = 0; k < numstates; k++) - { - if (len < 16) - goto parseEffect_unexpectedEOF; - - MOJOSHADER_effectState *state = &pass->states[k]; - const uint32 type = readui32(&ptr, &len); - readui32(&ptr, &len); // !!! FIXME: don't know what this field does. - /*const uint32 offsetend = */ readui32(&ptr, &len); - /*const uint32 offsetstart = */ readui32(&ptr, &len); - state->type = type; - - if ((type == 0x92) || (type == 0x93)) - numshaders++; - } // for - } // if - } // for - } // if - } // for - } // if - - // textures... - - if (len < 8) - goto parseEffect_unexpectedEOF; - - const int numtextures = readui32(&ptr, &len); - const int numobjects = readui32(&ptr, &len); // !!! FIXME: "objects" for lack of a better word. - - if (numtextures > 0) - { - siz = sizeof (MOJOSHADER_effectTexture) * numtextures; - retval->textures = m(siz, d); - if (retval->textures == NULL) - goto parseEffect_outOfMemory; - memset(retval->textures, '\0', siz); - - for (i = 0; i < numtextures; i++) - { - if (len < 8) - goto parseEffect_unexpectedEOF; - - MOJOSHADER_effectTexture *texture = &retval->textures[i]; - const uint32 texparam = readui32(&ptr, &len); - const uint32 texsize = readui32(&ptr, &len); - // apparently texsize will pad out to 32 bits. - const uint32 readsize = (((texsize + 3) / 4) * 4); - if (len < readsize) - goto parseEffect_unexpectedEOF; - - texture->param = texparam; - char *str = m(texsize + 1, d); - if (str == NULL) - goto parseEffect_outOfMemory; - memcpy(str, ptr, texsize); - str[texsize] = '\0'; - texture->name = str; - - ptr += readsize; - len -= readsize; - } // for - } // if - - // shaders... - - if (numshaders > 0) - { - siz = sizeof (MOJOSHADER_effectShader) * numshaders; - retval->shaders = (MOJOSHADER_effectShader *) m(siz, d); - if (retval->shaders == NULL) - goto parseEffect_outOfMemory; - memset(retval->shaders, '\0', siz); - - retval->shader_count = numshaders; - - // !!! FIXME: I wonder if we should pull these from offsets and not - // !!! FIXME: count on them all being in a line like this. - for (i = 0; i < numshaders; i++) - { - if (len < 24) - goto parseEffect_unexpectedEOF; - - MOJOSHADER_effectShader *shader = &retval->shaders[i]; - const uint32 technique = readui32(&ptr, &len); - const uint32 pass = readui32(&ptr, &len); - readui32(&ptr, &len); // !!! FIXME: don't know what this does. - readui32(&ptr, &len); // !!! FIXME: don't know what this does (vertex/pixel/geometry?) - readui32(&ptr, &len); // !!! FIXME: don't know what this does. - const uint32 shadersize = readui32(&ptr, &len); - - if (len < shadersize) - goto parseEffect_unexpectedEOF; - - shader->technique = technique; - shader->pass = pass; - shader->shader = MOJOSHADER_parse(profile, ptr, shadersize, - swiz, swizcount, m, f, d); - - // !!! FIXME: check for errors. - - ptr += shadersize; - len -= shadersize; - } // for - } // if - - // !!! FIXME: we parse this, but don't expose the data, yet. - // mappings ... - assert(numshaders <= numobjects); - const uint32 nummappings = numobjects - numshaders; - if (nummappings > 0) - { - for (i = 0; i < nummappings; i++) - { - if (len < 24) - goto parseEffect_unexpectedEOF; - - /*const uint32 magic = */ readui32(&ptr, &len); - /*const uint32 index = */ readui32(&ptr, &len); - readui32(&ptr, &len); // !!! FIXME: what is this field? - readui32(&ptr, &len); // !!! FIXME: what is this field? - /*const uint32 type = */ readui32(&ptr, &len); - const uint32 mapsize = readui32(&ptr, &len); - if (mapsize > 0) - { - const uint32 readsize = (((mapsize + 3) / 4) * 4); - if (len < readsize) - goto parseEffect_unexpectedEOF; - } // if - } // for - } // if - - retval->profile = (char *) m(strlen(profile) + 1, d); - if (retval->profile == NULL) - goto parseEffect_outOfMemory; - strcpy((char *) retval->profile, profile); - - return retval; - - -// !!! FIXME: do something with this. -parseEffect_notAnEffectsFile: -parseEffect_unexpectedEOF: -parseEffect_outOfMemory: - MOJOSHADER_freeEffect(retval); - return &MOJOSHADER_out_of_mem_effect; -} // MOJOSHADER_parseEffect - - -void MOJOSHADER_freeEffect(const MOJOSHADER_effect *_effect) -{ - MOJOSHADER_effect *effect = (MOJOSHADER_effect *) _effect; - if ((effect == NULL) || (effect == &MOJOSHADER_out_of_mem_effect)) - return; // no-op. - - MOJOSHADER_free f = effect->free; - void *d = effect->malloc_data; - int i, j; - - for (i = 0; i < effect->error_count; i++) - { - f((void *) effect->errors[i].error, d); - f((void *) effect->errors[i].filename, d); - } // for - f((void *) effect->errors, d); - - f((void *) effect->profile, d); - - for (i = 0; i < effect->param_count; i++) - { - f((void *) effect->params[i].name, d); - f((void *) effect->params[i].semantic, d); - } // for - f(effect->params, d); - - for (i = 0; i < effect->technique_count; i++) - { - MOJOSHADER_effectTechnique *technique = &effect->techniques[i]; - f((void *) technique->name, d); - for (j = 0; j < technique->pass_count; j++) - { - f((void *) technique->passes[j].name, d); - f(technique->passes[j].states, d); - } // for - f(technique->passes, d); - } // for - - f(effect->techniques, d); - - for (i = 0; i < effect->texture_count; i++) - f((void *) effect->textures[i].name, d); - f(effect->textures, d); - - for (i = 0; i < effect->shader_count; i++) - MOJOSHADER_freeParseData(effect->shaders[i].shader); - f(effect->shaders, d); - - f(effect, d); -} // MOJOSHADER_freeEffect - -// end of mojoshader_effects.c ... - diff --git a/Externals/mojoshader/1067/mojoshader_internal.h b/Externals/mojoshader/1067/mojoshader_internal.h deleted file mode 100644 index b1b1e091..00000000 --- a/Externals/mojoshader/1067/mojoshader_internal.h +++ /dev/null @@ -1,684 +0,0 @@ -#ifndef _INCLUDE_MOJOSHADER_INTERNAL_H_ -#define _INCLUDE_MOJOSHADER_INTERNAL_H_ - -#ifndef __MOJOSHADER_INTERNAL__ -#error Do not include this header from your applications. -#endif - -// Shader bytecode format is described at MSDN: -// http://msdn.microsoft.com/en-us/library/ff569705.aspx - -#include <stdio.h> -#include <string.h> -#include <stdlib.h> -#include <stdarg.h> -#include <assert.h> - -#include "mojoshader.h" - -#define DEBUG_LEXER 0 -#define DEBUG_PREPROCESSOR 0 -#define DEBUG_ASSEMBLER_PARSER 0 -#define DEBUG_COMPILER_PARSER 0 -#define DEBUG_TOKENIZER \ - (DEBUG_PREPROCESSOR || DEBUG_ASSEMBLER_PARSER || DEBUG_LEXER) - -#if (defined(__APPLE__) && defined(__MACH__) && !defined(__arm__) && !defined(__arm64__)) -#define PLATFORM_MACOSX 1 -#endif - -// This is the highest shader version we currently support. - -#define MAX_SHADER_MAJOR 3 -#define MAX_SHADER_MINOR 255 // vs_3_sw - - -// If SUPPORT_PROFILE_* isn't defined, we assume an implicit desire to support. -// You get all the profiles unless you go out of your way to disable them. - -#ifndef SUPPORT_PROFILE_D3D -#define SUPPORT_PROFILE_D3D 1 -#endif - -#ifndef SUPPORT_PROFILE_BYTECODE -#define SUPPORT_PROFILE_BYTECODE 1 -#endif - -#ifndef SUPPORT_PROFILE_GLSL -#define SUPPORT_PROFILE_GLSL 1 -#endif - -#ifndef SUPPORT_PROFILE_GLSL120 -#define SUPPORT_PROFILE_GLSL120 1 -#endif - -#ifndef SUPPORT_PROFILE_ARB1 -#define SUPPORT_PROFILE_ARB1 0 -#endif - -#ifndef SUPPORT_PROFILE_ARB1_NV -#define SUPPORT_PROFILE_ARB1_NV 0 -#endif - -#if SUPPORT_PROFILE_ARB1_NV && !SUPPORT_PROFILE_ARB1 -#error nv profiles require arb1 profile. Fix your build. -#endif - -#if SUPPORT_PROFILE_GLSL120 && !SUPPORT_PROFILE_GLSL -#error glsl120 profile requires glsl profile. Fix your build. -#endif - - -// Other stuff you can disable... - -// This removes the preshader parsing and execution code. You can save some -// bytes if you have normal shaders and not Effect files. -#ifndef SUPPORT_PRESHADERS -#define SUPPORT_PRESHADERS 0 -#endif - -#if SUPPORT_PRESHADERS -void MOJOSHADER_runPreshader(const MOJOSHADER_preshader*, const float*, float*); -#else -#define MOJOSHADER_runPreshader(a, b) -#endif - - -// Get basic wankery out of the way here... - -#ifdef _WINDOWS -#define ENDLINE_STR "\r\n" -#else -#define ENDLINE_STR "\n" -#endif - -typedef unsigned int uint; // this is a printf() helper. don't use for code. - -#ifdef _MSC_VER -#include <malloc.h> -#define va_copy(a, b) a = b -#define snprintf _snprintf // !!! FIXME: not a safe replacement! -#define vsnprintf _vsnprintf // !!! FIXME: not a safe replacement! -#define strcasecmp stricmp -#define strncasecmp strnicmp -typedef unsigned __int8 uint8; -typedef unsigned __int16 uint16; -typedef unsigned __int32 uint32; -typedef unsigned __int64 uint64; -typedef __int32 int32; -typedef __int64 int64; -#ifdef _WIN64 -typedef __int64 ssize_t; -#elif defined _WIN32 -typedef __int32 ssize_t; -#else -#error Please define your platform. -#endif -// Warning Level 4 considered harmful. :) -#pragma warning(disable: 4100) // "unreferenced formal parameter" -#pragma warning(disable: 4389) // "signed/unsigned mismatch" -#else -#include <stdint.h> -typedef uint8_t uint8; -typedef uint16_t uint16; -typedef uint32_t uint32; -typedef int32_t int32; -typedef int64_t int64; -typedef uint64_t uint64; -#endif - -#ifdef sun -#include <alloca.h> -#endif - -#ifdef __GNUC__ -#define ISPRINTF(x,y) __attribute__((format (printf, x, y))) -#else -#define ISPRINTF(x,y) -#endif - -#define STATICARRAYLEN(x) ( (sizeof ((x))) / (sizeof ((x)[0])) ) - - -// Byteswap magic... - -#if ((defined __GNUC__) && (defined __POWERPC__)) - static inline uint32 SWAP32(uint32 x) - { - __asm__ __volatile__("lwbrx %0,0,%1" : "=r" (x) : "r" (&x)); - return x; - } // SWAP32 - static inline uint16 SWAP16(uint16 x) - { - __asm__ __volatile__("lhbrx %0,0,%1" : "=r" (x) : "r" (&x)); - return x; - } // SWAP16 -#elif defined(__POWERPC__) - static inline uint32 SWAP32(uint32 x) - { - return ( (((x) >> 24) & 0x000000FF) | (((x) >> 8) & 0x0000FF00) | - (((x) << 8) & 0x00FF0000) | (((x) << 24) & 0xFF000000) ); - } // SWAP32 - static inline uint16 SWAP16(uint16 x) - { - return ( (((x) >> 8) & 0x00FF) | (((x) << 8) & 0xFF00) ); - } // SWAP16 -#else -# define SWAP16(x) (x) -# define SWAP32(x) (x) -#endif - -#define SWAPDBL(x) (x) // !!! FIXME - -static inline int Min(const int a, const int b) -{ - return ((a < b) ? a : b); -} // Min - - -// Hashtables... - -typedef struct HashTable HashTable; -typedef uint32 (*HashTable_HashFn)(const void *key, void *data); -typedef int (*HashTable_KeyMatchFn)(const void *a, const void *b, void *data); -typedef void (*HashTable_NukeFn)(const void *key, const void *value, void *data); - -HashTable *hash_create(void *data, const HashTable_HashFn hashfn, - const HashTable_KeyMatchFn keymatchfn, - const HashTable_NukeFn nukefn, - const int stackable, - MOJOSHADER_malloc m, MOJOSHADER_free f, void *d); -void hash_destroy(HashTable *table); -int hash_insert(HashTable *table, const void *key, const void *value); -int hash_remove(HashTable *table, const void *key); -int hash_find(const HashTable *table, const void *key, const void **_value); -int hash_iter(const HashTable *table, const void *key, const void **_value, void **iter); -int hash_iter_keys(const HashTable *table, const void **_key, void **iter); - -uint32 hash_hash_string(const void *sym, void *unused); -int hash_keymatch_string(const void *a, const void *b, void *unused); - - -// String -> String map ... -typedef HashTable StringMap; -StringMap *stringmap_create(const int copy, MOJOSHADER_malloc m, - MOJOSHADER_free f, void *d); -void stringmap_destroy(StringMap *smap); -int stringmap_insert(StringMap *smap, const char *key, const char *value); -int stringmap_remove(StringMap *smap, const char *key); -int stringmap_find(const StringMap *smap, const char *key, const char **_val); - - -// String caching... - -typedef struct StringCache StringCache; -StringCache *stringcache_create(MOJOSHADER_malloc m,MOJOSHADER_free f,void *d); -const char *stringcache(StringCache *cache, const char *str); -const char *stringcache_len(StringCache *cache, const char *str, - const unsigned int len); -const char *stringcache_fmt(StringCache *cache, const char *fmt, ...); -void stringcache_destroy(StringCache *cache); - - -// Error lists... - -typedef struct ErrorList ErrorList; -ErrorList *errorlist_create(MOJOSHADER_malloc m, MOJOSHADER_free f, void *d); -int errorlist_add(ErrorList *list, const char *fname, - const int errpos, const char *str); -int errorlist_add_fmt(ErrorList *list, const char *fname, - const int errpos, const char *fmt, ...) ISPRINTF(4,5); -int errorlist_add_va(ErrorList *list, const char *_fname, - const int errpos, const char *fmt, va_list va); -int errorlist_count(ErrorList *list); -MOJOSHADER_error *errorlist_flatten(ErrorList *list); // resets the list! -void errorlist_destroy(ErrorList *list); - - - -// Dynamic buffers... - -typedef struct Buffer Buffer; -Buffer *buffer_create(size_t blksz,MOJOSHADER_malloc m,MOJOSHADER_free f,void *d); -char *buffer_reserve(Buffer *buffer, const size_t len); -int buffer_append(Buffer *buffer, const void *_data, size_t len); -int buffer_append_fmt(Buffer *buffer, const char *fmt, ...) ISPRINTF(2,3); -int buffer_append_va(Buffer *buffer, const char *fmt, va_list va); -size_t buffer_size(Buffer *buffer); -void buffer_empty(Buffer *buffer); -char *buffer_flatten(Buffer *buffer); -char *buffer_merge(Buffer **buffers, const size_t n, size_t *_len); -void buffer_destroy(Buffer *buffer); -ssize_t buffer_find(Buffer *buffer, const size_t start, - const void *data, const size_t len); - - - -// This is the ID for a D3DXSHADER_CONSTANTTABLE in the bytecode comments. -#define CTAB_ID 0x42415443 // 0x42415443 == 'CTAB' -#define CTAB_SIZE 28 // sizeof (D3DXSHADER_CONSTANTTABLE). -#define CINFO_SIZE 20 // sizeof (D3DXSHADER_CONSTANTINFO). -#define CTYPEINFO_SIZE 16 // sizeof (D3DXSHADER_TYPEINFO). -#define CMEMBERINFO_SIZE 8 // sizeof (D3DXSHADER_STRUCTMEMBERINFO) - -// Preshader magic values... -#define PRES_ID 0x53455250 // 0x53455250 == 'PRES' -#define PRSI_ID 0x49535250 // 0x49535250 == 'PRSI' -#define CLIT_ID 0x54494C43 // 0x54494C43 == 'CLIT' -#define FXLC_ID 0x434C5846 // 0x434C5846 == 'FXLC' - -// we need to reference these by explicit value occasionally... -#define OPCODE_RET 28 -#define OPCODE_IF 40 -#define OPCODE_IFC 41 -#define OPCODE_BREAK 44 -#define OPCODE_BREAKC 45 -#define OPCODE_TEXLD 66 -#define OPCODE_SETP 94 - -// TEXLD becomes a different instruction with these instruction controls. -#define CONTROL_TEXLD 0 -#define CONTROL_TEXLDP 1 -#define CONTROL_TEXLDB 2 - -// #define this to force app to supply an allocator, so there's no reference -// to the C runtime's malloc() and free()... -#if MOJOSHADER_FORCE_ALLOCATOR -#define MOJOSHADER_internal_malloc NULL -#define MOJOSHADER_internal_free NULL -#else -void *MOJOSHADER_internal_malloc(int bytes, void *d); -void MOJOSHADER_internal_free(void *ptr, void *d); -#endif - -#if MOJOSHADER_FORCE_INCLUDE_CALLBACKS -#define MOJOSHADER_internal_include_open NULL -#define MOJOSHADER_internal_include_close NULL -#else -int MOJOSHADER_internal_include_open(MOJOSHADER_includeType inctype, - const char *fname, const char *parent, - const char **outdata, - unsigned int *outbytes, - MOJOSHADER_malloc m, MOJOSHADER_free f, - void *d); - -void MOJOSHADER_internal_include_close(const char *data, MOJOSHADER_malloc m, - MOJOSHADER_free f, void *d); -#endif - - -// result modifiers. -// !!! FIXME: why isn't this an enum? -#define MOD_SATURATE 0x01 -#define MOD_PP 0x02 -#define MOD_CENTROID 0x04 - -typedef enum -{ - REG_TYPE_TEMP = 0, - REG_TYPE_INPUT = 1, - REG_TYPE_CONST = 2, - REG_TYPE_ADDRESS = 3, - REG_TYPE_TEXTURE = 3, // ALSO 3! - REG_TYPE_RASTOUT = 4, - REG_TYPE_ATTROUT = 5, - REG_TYPE_TEXCRDOUT = 6, - REG_TYPE_OUTPUT = 6, // ALSO 6! - REG_TYPE_CONSTINT = 7, - REG_TYPE_COLOROUT = 8, - REG_TYPE_DEPTHOUT = 9, - REG_TYPE_SAMPLER = 10, - REG_TYPE_CONST2 = 11, - REG_TYPE_CONST3 = 12, - REG_TYPE_CONST4 = 13, - REG_TYPE_CONSTBOOL = 14, - REG_TYPE_LOOP = 15, - REG_TYPE_TEMPFLOAT16 = 16, - REG_TYPE_MISCTYPE = 17, - REG_TYPE_LABEL = 18, - REG_TYPE_PREDICATE = 19, - REG_TYPE_MAX = 19 -} RegisterType; - -typedef enum -{ - TEXTURE_TYPE_2D = 2, - TEXTURE_TYPE_CUBE = 3, - TEXTURE_TYPE_VOLUME = 4, -} TextureType; - -typedef enum -{ - RASTOUT_TYPE_POSITION = 0, - RASTOUT_TYPE_FOG = 1, - RASTOUT_TYPE_POINT_SIZE = 2, - RASTOUT_TYPE_MAX = 2 -} RastOutType; - -typedef enum -{ - MISCTYPE_TYPE_POSITION = 0, - MISCTYPE_TYPE_FACE = 1, - MISCTYPE_TYPE_MAX = 1 -} MiscTypeType; - -// source modifiers. -typedef enum -{ - SRCMOD_NONE, - SRCMOD_NEGATE, - SRCMOD_BIAS, - SRCMOD_BIASNEGATE, - SRCMOD_SIGN, - SRCMOD_SIGNNEGATE, - SRCMOD_COMPLEMENT, - SRCMOD_X2, - SRCMOD_X2NEGATE, - SRCMOD_DZ, - SRCMOD_DW, - SRCMOD_ABS, - SRCMOD_ABSNEGATE, - SRCMOD_NOT, - SRCMOD_TOTAL -} SourceMod; - - -typedef struct -{ - const uint32 *token; // this is the unmolested token in the stream. - int regnum; - int relative; - int writemask; // xyzw or rgba (all four, not split out). - int writemask0; // x or red - int writemask1; // y or green - int writemask2; // z or blue - int writemask3; // w or alpha - int orig_writemask; // writemask before mojoshader tweaks it. - int result_mod; - int result_shift; - RegisterType regtype; -} DestArgInfo; - -// NOTE: This will NOT know a dcl_psize output register should be scalar! -// This function doesn't have access to that information. -static inline int scalar_register(const MOJOSHADER_shaderType shader_type, - const RegisterType regtype, const int regnum) -{ - switch (regtype) - { - case REG_TYPE_DEPTHOUT: - case REG_TYPE_CONSTBOOL: - case REG_TYPE_LOOP: - return 1; - - case REG_TYPE_MISCTYPE: - if ( ((const MiscTypeType) regnum) == MISCTYPE_TYPE_FACE ) - return 1; - return 0; - - case REG_TYPE_PREDICATE: - return (shader_type == MOJOSHADER_TYPE_PIXEL) ? 1 : 0; - - default: break; - } // switch - - return 0; -} // scalar_register - - -extern MOJOSHADER_error MOJOSHADER_out_of_mem_error; -extern MOJOSHADER_parseData MOJOSHADER_out_of_mem_data; - - -// preprocessor stuff. - -typedef enum -{ - TOKEN_UNKNOWN = 256, // start past ASCII character values. - - // These are all C-like constructs. Tokens < 256 may be single - // chars (like '+' or whatever). These are just multi-char sequences - // (like "+=" or whatever). - TOKEN_IDENTIFIER, - TOKEN_INT_LITERAL, - TOKEN_FLOAT_LITERAL, - TOKEN_STRING_LITERAL, - TOKEN_RSHIFTASSIGN, - TOKEN_LSHIFTASSIGN, - TOKEN_ADDASSIGN, - TOKEN_SUBASSIGN, - TOKEN_MULTASSIGN, - TOKEN_DIVASSIGN, - TOKEN_MODASSIGN, - TOKEN_XORASSIGN, - TOKEN_ANDASSIGN, - TOKEN_ORASSIGN, - TOKEN_INCREMENT, - TOKEN_DECREMENT, - TOKEN_RSHIFT, - TOKEN_LSHIFT, - TOKEN_ANDAND, - TOKEN_OROR, - TOKEN_LEQ, - TOKEN_GEQ, - TOKEN_EQL, - TOKEN_NEQ, - TOKEN_HASH, - TOKEN_HASHHASH, - - // This is returned at the end of input...no more to process. - TOKEN_EOI, - - // This is returned for char sequences we think are bogus. You'll have - // to judge for yourself. In most cases, you'll probably just fail with - // bogus syntax without explicitly checking for this token. - TOKEN_BAD_CHARS, - - // This is returned if there's an error condition (the error is returned - // as a NULL-terminated string from preprocessor_nexttoken(), instead - // of actual token data). You can continue getting tokens after this - // is reported. It happens for things like missing #includes, etc. - TOKEN_PREPROCESSING_ERROR, - - // These are all caught by the preprocessor. Caller won't ever see them, - // except TOKEN_PP_PRAGMA. - // They control the preprocessor (#includes new files, etc). - TOKEN_PP_INCLUDE, - TOKEN_PP_LINE, - TOKEN_PP_DEFINE, - TOKEN_PP_UNDEF, - TOKEN_PP_IF, - TOKEN_PP_IFDEF, - TOKEN_PP_IFNDEF, - TOKEN_PP_ELSE, - TOKEN_PP_ELIF, - TOKEN_PP_ENDIF, - TOKEN_PP_ERROR, // caught, becomes TOKEN_PREPROCESSING_ERROR - TOKEN_PP_PRAGMA, - TOKEN_INCOMPLETE_COMMENT, // caught, becomes TOKEN_PREPROCESSING_ERROR - TOKEN_PP_UNARY_MINUS, // used internally, never returned. - TOKEN_PP_UNARY_PLUS, // used internally, never returned. -} Token; - - -// This is opaque. -struct Preprocessor; -typedef struct Preprocessor Preprocessor; - -typedef struct Conditional -{ - Token type; - int linenum; - int skipping; - int chosen; - struct Conditional *next; -} Conditional; - -typedef struct Define -{ - const char *identifier; - const char *definition; - const char *original; - const char **parameters; - int paramcount; - struct Define *next; -} Define; - -typedef struct IncludeState -{ - const char *filename; - const char *source_base; - const char *source; - const char *token; - unsigned int tokenlen; - Token tokenval; - int pushedback; - const unsigned char *lexer_marker; - int report_whitespace; - int asm_comments; - unsigned int orig_length; - unsigned int bytes_left; - unsigned int line; - Conditional *conditional_stack; - MOJOSHADER_includeClose close_callback; - struct IncludeState *next; -} IncludeState; - -Token preprocessor_lexer(IncludeState *s); - -// This will only fail if the allocator fails, so it doesn't return any -// error code...NULL on failure. -Preprocessor *preprocessor_start(const char *fname, const char *source, - unsigned int sourcelen, - MOJOSHADER_includeOpen open_callback, - MOJOSHADER_includeClose close_callback, - const MOJOSHADER_preprocessorDefine *defines, - unsigned int define_count, int asm_comments, - MOJOSHADER_malloc m, MOJOSHADER_free f, void *d); - -void preprocessor_end(Preprocessor *pp); -int preprocessor_outofmemory(Preprocessor *pp); -const char *preprocessor_nexttoken(Preprocessor *_ctx, - unsigned int *_len, Token *_token); -const char *preprocessor_sourcepos(Preprocessor *pp, unsigned int *pos); - - -void MOJOSHADER_print_debug_token(const char *subsystem, const char *token, - const unsigned int tokenlen, - const Token tokenval); - -#endif // _INCLUDE_MOJOSHADER_INTERNAL_H_ - - -#if MOJOSHADER_DO_INSTRUCTION_TABLE -// These have to be in the right order! Arrays are indexed by the value -// of the instruction token. - -// INSTRUCTION_STATE means this opcode has to update the state machine -// (we're entering an ELSE block, etc). INSTRUCTION means there's no -// state, just go straight to the emitters. - -// !!! FIXME: Some of these MOJOSHADER_TYPE_ANYs need to have their scope -// !!! FIXME: reduced to just PIXEL or VERTEX. - -INSTRUCTION(NOP, "NOP", 1, NULL, MOJOSHADER_TYPE_ANY) -INSTRUCTION(MOV, "MOV", 1, DS, MOJOSHADER_TYPE_ANY) -INSTRUCTION(ADD, "ADD", 1, DSS, MOJOSHADER_TYPE_ANY) -INSTRUCTION(SUB, "SUB", 1, DSS, MOJOSHADER_TYPE_ANY) -INSTRUCTION(MAD, "MAD", 1, DSSS, MOJOSHADER_TYPE_ANY) -INSTRUCTION(MUL, "MUL", 1, DSS, MOJOSHADER_TYPE_ANY) -INSTRUCTION_STATE(RCP, "RCP", 1, DS, MOJOSHADER_TYPE_ANY) -INSTRUCTION(RSQ, "RSQ", 1, DS, MOJOSHADER_TYPE_ANY) -INSTRUCTION(DP3, "DP3", 1, DSS, MOJOSHADER_TYPE_ANY) -INSTRUCTION_STATE(DP4, "DP4", 1, DSS, MOJOSHADER_TYPE_ANY) -INSTRUCTION(MIN, "MIN", 1, DSS, MOJOSHADER_TYPE_ANY) -INSTRUCTION(MAX, "MAX", 1, DSS, MOJOSHADER_TYPE_ANY) -INSTRUCTION(SLT, "SLT", 1, DSS, MOJOSHADER_TYPE_ANY) -INSTRUCTION(SGE, "SGE", 1, DSS, MOJOSHADER_TYPE_ANY) -INSTRUCTION(EXP, "EXP", 1, DS, MOJOSHADER_TYPE_ANY) -INSTRUCTION_STATE(LOG, "LOG", 1, DS, MOJOSHADER_TYPE_ANY) -INSTRUCTION(LIT, "LIT", 3, DS, MOJOSHADER_TYPE_ANY) -INSTRUCTION(DST, "DST", 1, DSS, MOJOSHADER_TYPE_VERTEX) -INSTRUCTION(LRP, "LRP", 2, DSSS, MOJOSHADER_TYPE_ANY) -INSTRUCTION_STATE(FRC, "FRC", 1, DS, MOJOSHADER_TYPE_ANY) -INSTRUCTION_STATE(M4X4, "M4X4", 4, DSS, MOJOSHADER_TYPE_ANY) -INSTRUCTION_STATE(M4X3, "M4X3", 3, DSS, MOJOSHADER_TYPE_ANY) -INSTRUCTION_STATE(M3X4, "M3X4", 4, DSS, MOJOSHADER_TYPE_ANY) -INSTRUCTION_STATE(M3X3, "M3X3", 3, DSS, MOJOSHADER_TYPE_ANY) -INSTRUCTION_STATE(M3X2, "M3X2", 2, DSS, MOJOSHADER_TYPE_ANY) -INSTRUCTION_STATE(CALL, "CALL", 2, S, MOJOSHADER_TYPE_ANY) -INSTRUCTION_STATE(CALLNZ, "CALLNZ", 3, SS, MOJOSHADER_TYPE_ANY) -INSTRUCTION_STATE(LOOP, "LOOP", 3, SS, MOJOSHADER_TYPE_ANY) -INSTRUCTION_STATE(RET, "RET", 1, NULL, MOJOSHADER_TYPE_ANY) -INSTRUCTION_STATE(ENDLOOP, "ENDLOOP", 2, NULL, MOJOSHADER_TYPE_ANY) -INSTRUCTION_STATE(LABEL, "LABEL", 0, S, MOJOSHADER_TYPE_ANY) -INSTRUCTION_STATE(DCL, "DCL", 0, DCL, MOJOSHADER_TYPE_ANY) -INSTRUCTION_STATE(POW, "POW", 3, DSS, MOJOSHADER_TYPE_ANY) -INSTRUCTION(CRS, "CRS", 2, DSS, MOJOSHADER_TYPE_ANY) -INSTRUCTION(SGN, "SGN", 3, DSSS, MOJOSHADER_TYPE_ANY) -INSTRUCTION(ABS, "ABS", 1, DS, MOJOSHADER_TYPE_ANY) -INSTRUCTION(NRM, "NRM", 3, DS, MOJOSHADER_TYPE_ANY) -INSTRUCTION_STATE(SINCOS, "SINCOS", 8, SINCOS, MOJOSHADER_TYPE_ANY) -INSTRUCTION_STATE(REP, "REP", 3, S, MOJOSHADER_TYPE_ANY) -INSTRUCTION_STATE(ENDREP, "ENDREP", 2, NULL, MOJOSHADER_TYPE_ANY) -INSTRUCTION_STATE(IF, "IF", 3, S, MOJOSHADER_TYPE_ANY) -INSTRUCTION_STATE(IFC, "IF", 3, SS, MOJOSHADER_TYPE_ANY) -INSTRUCTION(ELSE, "ELSE", 1, NULL, MOJOSHADER_TYPE_ANY) // !!! FIXME: state! -INSTRUCTION(ENDIF, "ENDIF", 1, NULL, MOJOSHADER_TYPE_ANY) // !!! FIXME: state! -INSTRUCTION_STATE(BREAK, "BREAK", 1, NULL, MOJOSHADER_TYPE_ANY) -INSTRUCTION_STATE(BREAKC, "BREAK", 3, SS, MOJOSHADER_TYPE_ANY) -INSTRUCTION_STATE(MOVA, "MOVA", 1, DS, MOJOSHADER_TYPE_VERTEX) -INSTRUCTION_STATE(DEFB, "DEFB", 0, DEFB, MOJOSHADER_TYPE_ANY) -INSTRUCTION_STATE(DEFI, "DEFI", 0, DEFI, MOJOSHADER_TYPE_ANY) -INSTRUCTION(RESERVED, 0, 0, NULL, MOJOSHADER_TYPE_UNKNOWN) -INSTRUCTION(RESERVED, 0, 0, NULL, MOJOSHADER_TYPE_UNKNOWN) -INSTRUCTION(RESERVED, 0, 0, NULL, MOJOSHADER_TYPE_UNKNOWN) -INSTRUCTION(RESERVED, 0, 0, NULL, MOJOSHADER_TYPE_UNKNOWN) -INSTRUCTION(RESERVED, 0, 0, NULL, MOJOSHADER_TYPE_UNKNOWN) -INSTRUCTION(RESERVED, 0, 0, NULL, MOJOSHADER_TYPE_UNKNOWN) -INSTRUCTION(RESERVED, 0, 0, NULL, MOJOSHADER_TYPE_UNKNOWN) -INSTRUCTION(RESERVED, 0, 0, NULL, MOJOSHADER_TYPE_UNKNOWN) -INSTRUCTION(RESERVED, 0, 0, NULL, MOJOSHADER_TYPE_UNKNOWN) -INSTRUCTION(RESERVED, 0, 0, NULL, MOJOSHADER_TYPE_UNKNOWN) -INSTRUCTION(RESERVED, 0, 0, NULL, MOJOSHADER_TYPE_UNKNOWN) -INSTRUCTION(RESERVED, 0, 0, NULL, MOJOSHADER_TYPE_UNKNOWN) -INSTRUCTION(RESERVED, 0, 0, NULL, MOJOSHADER_TYPE_UNKNOWN) -INSTRUCTION(RESERVED, 0, 0, NULL, MOJOSHADER_TYPE_UNKNOWN) -INSTRUCTION(RESERVED, 0, 0, NULL, MOJOSHADER_TYPE_UNKNOWN) -INSTRUCTION_STATE(TEXCRD, "TEXCRD", 1, TEXCRD, MOJOSHADER_TYPE_PIXEL) -INSTRUCTION_STATE(TEXKILL, "TEXKILL", 2, D, MOJOSHADER_TYPE_PIXEL) -INSTRUCTION_STATE(TEXLD, "TEXLD", 1, TEXLD, MOJOSHADER_TYPE_PIXEL) -INSTRUCTION(TEXBEM, "TEXBEM", 1, DS, MOJOSHADER_TYPE_PIXEL) -INSTRUCTION(TEXBEML, "TEXBEML", 2, DS, MOJOSHADER_TYPE_PIXEL) -INSTRUCTION(TEXREG2AR, "TEXREG2AR", 1, DS, MOJOSHADER_TYPE_PIXEL) -INSTRUCTION(TEXREG2GB, "TEXREG2GB", 1, DS, MOJOSHADER_TYPE_PIXEL) -INSTRUCTION(TEXM3X2PAD, "TEXM3X2PAD", 1, DS, MOJOSHADER_TYPE_PIXEL) -INSTRUCTION(TEXM3X2TEX, "TEXM3X2TEX", 1, DS, MOJOSHADER_TYPE_PIXEL) -INSTRUCTION(TEXM3X3PAD, "TEXM3X3PAD", 1, DS, MOJOSHADER_TYPE_PIXEL) -INSTRUCTION(TEXM3X3TEX, "TEXM3X3TEX", 1, DS, MOJOSHADER_TYPE_PIXEL) -INSTRUCTION(RESERVED, 0, 0, NULL, MOJOSHADER_TYPE_UNKNOWN) -INSTRUCTION(TEXM3X3SPEC, "TEXM3X3SPEC", 1, DSS, MOJOSHADER_TYPE_PIXEL) -INSTRUCTION(TEXM3X3VSPEC, "TEXM3X3VSPEC", 1, DS, MOJOSHADER_TYPE_PIXEL) -INSTRUCTION(EXPP, "EXPP", 1, DS, MOJOSHADER_TYPE_ANY) -INSTRUCTION_STATE(LOGP, "LOGP", 1, DS, MOJOSHADER_TYPE_ANY) -INSTRUCTION_STATE(CND, "CND", 1, DSSS, MOJOSHADER_TYPE_PIXEL) -INSTRUCTION_STATE(DEF, "DEF", 0, DEF, MOJOSHADER_TYPE_ANY) -INSTRUCTION(TEXREG2RGB, "TEXREG2RGB", 1, DS, MOJOSHADER_TYPE_PIXEL) -INSTRUCTION(TEXDP3TEX, "TEXDP3TEX", 1, DS, MOJOSHADER_TYPE_PIXEL) -INSTRUCTION(TEXM3X2DEPTH, "TEXM3X2DEPTH", 1, DS, MOJOSHADER_TYPE_PIXEL) -INSTRUCTION(TEXDP3, "TEXDP3", 1, DS, MOJOSHADER_TYPE_PIXEL) -INSTRUCTION(TEXM3X3, "TEXM3X3", 1, DS, MOJOSHADER_TYPE_PIXEL) -INSTRUCTION(TEXDEPTH, "TEXDEPTH", 1, D, MOJOSHADER_TYPE_PIXEL) -INSTRUCTION_STATE(CMP, "CMP", 1, DSSS, MOJOSHADER_TYPE_PIXEL) -INSTRUCTION(BEM, "BEM", 2, DSS, MOJOSHADER_TYPE_PIXEL) -INSTRUCTION_STATE(DP2ADD, "DP2ADD", 2, DSSS, MOJOSHADER_TYPE_PIXEL) -INSTRUCTION(DSX, "DSX", 2, DS, MOJOSHADER_TYPE_PIXEL) -INSTRUCTION(DSY, "DSY", 2, DS, MOJOSHADER_TYPE_PIXEL) -INSTRUCTION(TEXLDD, "TEXLDD", 3, DSSSS, MOJOSHADER_TYPE_PIXEL) -INSTRUCTION_STATE(SETP, "SETP", 1, DSS, MOJOSHADER_TYPE_ANY) -INSTRUCTION_STATE(TEXLDL, "TEXLDL", 2, DSS, MOJOSHADER_TYPE_ANY) -INSTRUCTION_STATE(BREAKP, "BREAKP", 3, S, MOJOSHADER_TYPE_ANY) -#endif - -// end of mojoshader_internal.h ... - diff --git a/Externals/mojoshader/1067/mojoshader_lexer.c b/Externals/mojoshader/1067/mojoshader_lexer.c deleted file mode 100644 index 53361788..00000000 --- a/Externals/mojoshader/1067/mojoshader_lexer.c +++ /dev/null @@ -1,1504 +0,0 @@ -/* Generated by re2c 0.13.5 */ -/** - * MojoShader; generate shader programs from bytecode of compiled - * Direct3D shaders. - * - * Please see the file LICENSE.txt in the source's root directory. - * - * This file written by Ryan C. Gordon. - */ - -// This was originally based on examples/pp-c.re from re2c: http://re2c.org/ -// re2c is public domain code. -// -// You build mojoshader_lexer_preprocessor.c from the .re file with re2c... -// re2c -is -o mojoshader_lexer_preprocessor.c mojoshader_lexer_preprocessor.re -// -// Changes to the lexer are done to the .re file, not the C code! -// -// Please note that this isn't a perfect C lexer, since it is used for both -// HLSL and shader assembly language, and follows the quirks of Microsoft's -// tools. - -#define __MOJOSHADER_INTERNAL__ 1 -#include "mojoshader_internal.h" - -typedef unsigned char uchar; - -#define YYMAXFILL 8 -#define RET(t) return update_state(s, eoi, cursor, token, (Token) t) -#define YYCTYPE uchar -#define YYCURSOR cursor -#define YYLIMIT limit -#define YYMARKER s->lexer_marker -#define YYFILL(n) { if ((n) == 1) { cursor = sentinel; limit = cursor + YYMAXFILL; eoi = 1; } } - -static uchar sentinel[YYMAXFILL]; - -static Token update_state(IncludeState *s, int eoi, const uchar *cur, - const uchar *tok, const Token val) -{ - if (eoi) - { - s->bytes_left = 0; - s->source = (const char *) s->source_base + s->orig_length; - if ( (tok >= sentinel) && (tok < (sentinel+YYMAXFILL)) ) - s->token = s->source; - else - s->token = (const char *) tok; - } // if - else - { - s->bytes_left -= (unsigned int) (cur - ((const uchar *) s->source)); - s->source = (const char *) cur; - s->token = (const char *) tok; - } // else - s->tokenlen = (unsigned int) (s->source - s->token); - s->tokenval = val; - return val; -} // update_state - -Token preprocessor_lexer(IncludeState *s) -{ - const uchar *cursor = (const uchar *) s->source; - const uchar *token = cursor; - const uchar *matchptr; - const uchar *limit = cursor + s->bytes_left; - int eoi = 0; - int saw_newline = 0; - - - - // preprocessor directives are only valid at start of line. - if (s->tokenval == ((Token) '\n')) - goto ppdirective; // may jump back to scanner_loop. - -scanner_loop: - if (YYLIMIT == YYCURSOR) YYFILL(1); - token = cursor; - - -{ - YYCTYPE yych; - unsigned int yyaccept = 0; - - if ((YYLIMIT - YYCURSOR) < 5) YYFILL(5); - yych = *YYCURSOR; - switch (yych) { - case 0x00: goto yy61; - case '\t': - case '\v': - case '\f': - case ' ': goto yy63; - case '\n': goto yy65; - case '\r': goto yy67; - case '!': goto yy35; - case '"': goto yy14; - case '#': goto yy37; - case '%': goto yy25; - case '&': goto yy29; - case '\'': goto yy11; - case '(': goto yy39; - case ')': goto yy41; - case '*': goto yy23; - case '+': goto yy19; - case ',': goto yy47; - case '-': goto yy21; - case '.': goto yy12; - case '/': goto yy4; - case '0': goto yy8; - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto yy10; - case ':': goto yy51; - case ';': goto yy59; - case '<': goto yy17; - case '=': goto yy33; - case '>': goto yy15; - case '?': goto yy57; - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto yy6; - case '[': goto yy43; - case '\\': goto yy2; - case ']': goto yy45; - case '^': goto yy27; - case '{': goto yy53; - case '|': goto yy31; - case '}': goto yy55; - case '~': goto yy49; - default: goto yy68; - } -yy2: - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych <= 0x08) goto yy3; - if (yych <= '\r') goto yy177; - if (yych == ' ') goto yy177; -yy3: - { goto bad_chars; } -yy4: - ++YYCURSOR; - if ((yych = *YYCURSOR) <= '.') { - if (yych == '*') goto yy174; - } else { - if (yych <= '/') goto yy172; - if (yych == '=') goto yy170; - } - { RET('/'); } -yy6: - ++YYCURSOR; - yych = *YYCURSOR; - goto yy169; -yy7: - { RET(TOKEN_IDENTIFIER); } -yy8: - yyaccept = 1; - yych = *(YYMARKER = ++YYCURSOR); - if (yych <= 'X') { - if (yych <= 'T') { - if (yych == 'L') goto yy144; - goto yy160; - } else { - if (yych <= 'U') goto yy144; - if (yych <= 'W') goto yy160; - goto yy161; - } - } else { - if (yych <= 't') { - if (yych == 'l') goto yy144; - goto yy160; - } else { - if (yych <= 'u') goto yy144; - if (yych == 'x') goto yy161; - goto yy160; - } - } -yy9: - { RET(TOKEN_INT_LITERAL); } -yy10: - yyaccept = 1; - yych = *(YYMARKER = ++YYCURSOR); - goto yy142; -yy11: - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych == '\n') goto yy3; - if (yych == '\r') goto yy3; - goto yy132; -yy12: - ++YYCURSOR; - if ((yych = *YYCURSOR) <= '/') goto yy13; - if (yych <= '9') goto yy123; -yy13: - { RET('.'); } -yy14: - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych == '\n') goto yy3; - if (yych == '\r') goto yy3; - goto yy113; -yy15: - ++YYCURSOR; - if ((yych = *YYCURSOR) <= '<') goto yy16; - if (yych <= '=') goto yy106; - if (yych <= '>') goto yy108; -yy16: - { RET('>'); } -yy17: - ++YYCURSOR; - if ((yych = *YYCURSOR) <= ';') goto yy18; - if (yych <= '<') goto yy102; - if (yych <= '=') goto yy100; -yy18: - { RET('<'); } -yy19: - ++YYCURSOR; - if ((yych = *YYCURSOR) == '+') goto yy96; - if (yych == '=') goto yy98; - { RET('+'); } -yy21: - ++YYCURSOR; - if ((yych = *YYCURSOR) == '-') goto yy92; - if (yych == '=') goto yy94; - { RET('-'); } -yy23: - ++YYCURSOR; - if ((yych = *YYCURSOR) == '=') goto yy90; - { RET('*'); } -yy25: - ++YYCURSOR; - if ((yych = *YYCURSOR) == '=') goto yy88; - { RET('%'); } -yy27: - ++YYCURSOR; - if ((yych = *YYCURSOR) == '=') goto yy86; - { RET('^'); } -yy29: - ++YYCURSOR; - if ((yych = *YYCURSOR) == '&') goto yy82; - if (yych == '=') goto yy84; - { RET('&'); } -yy31: - ++YYCURSOR; - if ((yych = *YYCURSOR) == '=') goto yy80; - if (yych == '|') goto yy78; - { RET('|'); } -yy33: - ++YYCURSOR; - if ((yych = *YYCURSOR) == '=') goto yy76; - { RET('='); } -yy35: - ++YYCURSOR; - if ((yych = *YYCURSOR) == '=') goto yy74; - { RET('!'); } -yy37: - ++YYCURSOR; - if ((yych = *YYCURSOR) == '#') goto yy72; - { RET(TOKEN_HASH); } -yy39: - ++YYCURSOR; - { RET('('); } -yy41: - ++YYCURSOR; - { RET(')'); } -yy43: - ++YYCURSOR; - { RET('['); } -yy45: - ++YYCURSOR; - { RET(']'); } -yy47: - ++YYCURSOR; - { RET(','); } -yy49: - ++YYCURSOR; - { RET('~'); } -yy51: - ++YYCURSOR; - { RET(':'); } -yy53: - ++YYCURSOR; - { RET('{'); } -yy55: - ++YYCURSOR; - { RET('}'); } -yy57: - ++YYCURSOR; - { RET('?'); } -yy59: - ++YYCURSOR; - { if (s->asm_comments) goto singlelinecomment; RET(';'); } -yy61: - ++YYCURSOR; - { if (eoi) { RET(TOKEN_EOI); } goto bad_chars; } -yy63: - ++YYCURSOR; - yych = *YYCURSOR; - goto yy71; -yy64: - { if (s->report_whitespace) RET(' '); goto scanner_loop; } -yy65: - ++YYCURSOR; -yy66: - { s->line++; RET('\n'); } -yy67: - yych = *++YYCURSOR; - if (yych == '\n') goto yy69; - goto yy66; -yy68: - yych = *++YYCURSOR; - goto yy3; -yy69: - yych = *++YYCURSOR; - goto yy66; -yy70: - ++YYCURSOR; - if (YYLIMIT <= YYCURSOR) YYFILL(1); - yych = *YYCURSOR; -yy71: - if (yych <= '\n') { - if (yych == '\t') goto yy70; - goto yy64; - } else { - if (yych <= '\f') goto yy70; - if (yych == ' ') goto yy70; - goto yy64; - } -yy72: - ++YYCURSOR; - { RET(TOKEN_HASHHASH); } -yy74: - ++YYCURSOR; - { RET(TOKEN_NEQ); } -yy76: - ++YYCURSOR; - { RET(TOKEN_EQL); } -yy78: - ++YYCURSOR; - { RET(TOKEN_OROR); } -yy80: - ++YYCURSOR; - { RET(TOKEN_ORASSIGN); } -yy82: - ++YYCURSOR; - { RET(TOKEN_ANDAND); } -yy84: - ++YYCURSOR; - { RET(TOKEN_ANDASSIGN); } -yy86: - ++YYCURSOR; - { RET(TOKEN_XORASSIGN); } -yy88: - ++YYCURSOR; - { RET(TOKEN_MODASSIGN); } -yy90: - ++YYCURSOR; - { RET(TOKEN_MULTASSIGN); } -yy92: - ++YYCURSOR; - { RET(TOKEN_DECREMENT); } -yy94: - ++YYCURSOR; - { RET(TOKEN_SUBASSIGN); } -yy96: - ++YYCURSOR; - { RET(TOKEN_INCREMENT); } -yy98: - ++YYCURSOR; - { RET(TOKEN_ADDASSIGN); } -yy100: - ++YYCURSOR; - { RET(TOKEN_LEQ); } -yy102: - ++YYCURSOR; - if ((yych = *YYCURSOR) == '=') goto yy104; - { RET(TOKEN_LSHIFT); } -yy104: - ++YYCURSOR; - { RET(TOKEN_LSHIFTASSIGN); } -yy106: - ++YYCURSOR; - { RET(TOKEN_GEQ); } -yy108: - ++YYCURSOR; - if ((yych = *YYCURSOR) == '=') goto yy110; - { RET(TOKEN_RSHIFT); } -yy110: - ++YYCURSOR; - { RET(TOKEN_RSHIFTASSIGN); } -yy112: - ++YYCURSOR; - if (YYLIMIT <= YYCURSOR) YYFILL(1); - yych = *YYCURSOR; -yy113: - if (yych <= '\r') { - if (yych == '\n') goto yy114; - if (yych <= '\f') goto yy112; - } else { - if (yych <= '"') { - if (yych <= '!') goto yy112; - goto yy116; - } else { - if (yych == '\\') goto yy115; - goto yy112; - } - } -yy114: - YYCURSOR = YYMARKER; - if (yyaccept <= 1) { - if (yyaccept <= 0) { - goto yy3; - } else { - goto yy9; - } - } else { - goto yy125; - } -yy115: - ++YYCURSOR; - if (YYLIMIT <= YYCURSOR) YYFILL(1); - yych = *YYCURSOR; - if (yych <= 'b') { - if (yych <= '7') { - if (yych <= '&') { - if (yych == '"') goto yy112; - goto yy114; - } else { - if (yych <= '\'') goto yy112; - if (yych <= '/') goto yy114; - goto yy119; - } - } else { - if (yych <= '[') { - if (yych == '?') goto yy112; - goto yy114; - } else { - if (yych <= '\\') goto yy112; - if (yych <= '`') goto yy114; - goto yy112; - } - } - } else { - if (yych <= 'r') { - if (yych <= 'm') { - if (yych == 'f') goto yy112; - goto yy114; - } else { - if (yych <= 'n') goto yy112; - if (yych <= 'q') goto yy114; - goto yy112; - } - } else { - if (yych <= 'u') { - if (yych == 't') goto yy112; - goto yy114; - } else { - if (yych <= 'v') goto yy112; - if (yych == 'x') goto yy118; - goto yy114; - } - } - } -yy116: - ++YYCURSOR; - { RET(TOKEN_STRING_LITERAL); } -yy118: - ++YYCURSOR; - if (YYLIMIT <= YYCURSOR) YYFILL(1); - yych = *YYCURSOR; - if (yych <= '@') { - if (yych <= '/') goto yy114; - if (yych <= '9') goto yy121; - goto yy114; - } else { - if (yych <= 'F') goto yy121; - if (yych <= '`') goto yy114; - if (yych <= 'f') goto yy121; - goto yy114; - } -yy119: - ++YYCURSOR; - if (YYLIMIT <= YYCURSOR) YYFILL(1); - yych = *YYCURSOR; - if (yych <= '!') { - if (yych <= '\n') { - if (yych <= '\t') goto yy112; - goto yy114; - } else { - if (yych == '\r') goto yy114; - goto yy112; - } - } else { - if (yych <= '7') { - if (yych <= '"') goto yy116; - if (yych <= '/') goto yy112; - goto yy119; - } else { - if (yych == '\\') goto yy115; - goto yy112; - } - } -yy121: - ++YYCURSOR; - if (YYLIMIT <= YYCURSOR) YYFILL(1); - yych = *YYCURSOR; - if (yych <= '/') { - if (yych <= '\f') { - if (yych == '\n') goto yy114; - goto yy112; - } else { - if (yych <= '\r') goto yy114; - if (yych == '"') goto yy116; - goto yy112; - } - } else { - if (yych <= '[') { - if (yych <= '9') goto yy121; - if (yych <= '@') goto yy112; - if (yych <= 'F') goto yy121; - goto yy112; - } else { - if (yych <= '\\') goto yy115; - if (yych <= '`') goto yy112; - if (yych <= 'f') goto yy121; - goto yy112; - } - } -yy123: - yyaccept = 2; - YYMARKER = ++YYCURSOR; - if ((YYLIMIT - YYCURSOR) < 3) YYFILL(3); - yych = *YYCURSOR; - if (yych <= 'G') { - if (yych <= 'D') { - if (yych <= '/') goto yy125; - if (yych <= '9') goto yy123; - } else { - if (yych <= 'E') goto yy126; - if (yych <= 'F') goto yy127; - } - } else { - if (yych <= 'e') { - if (yych <= 'H') goto yy127; - if (yych >= 'e') goto yy126; - } else { - if (yych == 'g') goto yy125; - if (yych <= 'h') goto yy127; - } - } -yy125: - { RET(TOKEN_FLOAT_LITERAL); } -yy126: - yych = *++YYCURSOR; - if (yych <= ',') { - if (yych == '+') goto yy128; - goto yy114; - } else { - if (yych <= '-') goto yy128; - if (yych <= '/') goto yy114; - if (yych <= '9') goto yy129; - goto yy114; - } -yy127: - yych = *++YYCURSOR; - goto yy125; -yy128: - yych = *++YYCURSOR; - if (yych <= '/') goto yy114; - if (yych >= ':') goto yy114; -yy129: - ++YYCURSOR; - if (YYLIMIT <= YYCURSOR) YYFILL(1); - yych = *YYCURSOR; - if (yych <= 'G') { - if (yych <= '9') { - if (yych <= '/') goto yy125; - goto yy129; - } else { - if (yych == 'F') goto yy127; - goto yy125; - } - } else { - if (yych <= 'f') { - if (yych <= 'H') goto yy127; - if (yych <= 'e') goto yy125; - goto yy127; - } else { - if (yych == 'h') goto yy127; - goto yy125; - } - } -yy131: - ++YYCURSOR; - if (YYLIMIT <= YYCURSOR) YYFILL(1); - yych = *YYCURSOR; -yy132: - if (yych <= '\r') { - if (yych == '\n') goto yy114; - if (yych <= '\f') goto yy131; - goto yy114; - } else { - if (yych <= '\'') { - if (yych <= '&') goto yy131; - goto yy134; - } else { - if (yych != '\\') goto yy131; - } - } -yy133: - ++YYCURSOR; - if (YYLIMIT <= YYCURSOR) YYFILL(1); - yych = *YYCURSOR; - if (yych <= 'b') { - if (yych <= '7') { - if (yych <= '&') { - if (yych == '"') goto yy131; - goto yy114; - } else { - if (yych <= '\'') goto yy131; - if (yych <= '/') goto yy114; - goto yy136; - } - } else { - if (yych <= '[') { - if (yych == '?') goto yy131; - goto yy114; - } else { - if (yych <= '\\') goto yy131; - if (yych <= '`') goto yy114; - goto yy131; - } - } - } else { - if (yych <= 'r') { - if (yych <= 'm') { - if (yych == 'f') goto yy131; - goto yy114; - } else { - if (yych <= 'n') goto yy131; - if (yych <= 'q') goto yy114; - goto yy131; - } - } else { - if (yych <= 'u') { - if (yych == 't') goto yy131; - goto yy114; - } else { - if (yych <= 'v') goto yy131; - if (yych == 'x') goto yy135; - goto yy114; - } - } - } -yy134: - yych = *++YYCURSOR; - goto yy9; -yy135: - ++YYCURSOR; - if (YYLIMIT <= YYCURSOR) YYFILL(1); - yych = *YYCURSOR; - if (yych <= '@') { - if (yych <= '/') goto yy114; - if (yych <= '9') goto yy138; - goto yy114; - } else { - if (yych <= 'F') goto yy138; - if (yych <= '`') goto yy114; - if (yych <= 'f') goto yy138; - goto yy114; - } -yy136: - ++YYCURSOR; - if (YYLIMIT <= YYCURSOR) YYFILL(1); - yych = *YYCURSOR; - if (yych <= '&') { - if (yych <= '\n') { - if (yych <= '\t') goto yy131; - goto yy114; - } else { - if (yych == '\r') goto yy114; - goto yy131; - } - } else { - if (yych <= '7') { - if (yych <= '\'') goto yy134; - if (yych <= '/') goto yy131; - goto yy136; - } else { - if (yych == '\\') goto yy133; - goto yy131; - } - } -yy138: - ++YYCURSOR; - if (YYLIMIT <= YYCURSOR) YYFILL(1); - yych = *YYCURSOR; - if (yych <= '/') { - if (yych <= '\f') { - if (yych == '\n') goto yy114; - goto yy131; - } else { - if (yych <= '\r') goto yy114; - if (yych == '\'') goto yy134; - goto yy131; - } - } else { - if (yych <= '[') { - if (yych <= '9') goto yy138; - if (yych <= '@') goto yy131; - if (yych <= 'F') goto yy138; - goto yy131; - } else { - if (yych <= '\\') goto yy133; - if (yych <= '`') goto yy131; - if (yych <= 'f') goto yy138; - goto yy131; - } - } -yy140: - yyaccept = 2; - yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'E') goto yy151; - if (yych == 'e') goto yy151; - goto yy150; -yy141: - yyaccept = 1; - YYMARKER = ++YYCURSOR; - if ((YYLIMIT - YYCURSOR) < 4) YYFILL(4); - yych = *YYCURSOR; -yy142: - if (yych <= 'L') { - if (yych <= '9') { - if (yych == '.') goto yy140; - if (yych <= '/') goto yy9; - goto yy141; - } else { - if (yych == 'E') goto yy143; - if (yych <= 'K') goto yy9; - goto yy144; - } - } else { - if (yych <= 'e') { - if (yych == 'U') goto yy144; - if (yych <= 'd') goto yy9; - } else { - if (yych <= 'l') { - if (yych <= 'k') goto yy9; - goto yy144; - } else { - if (yych == 'u') goto yy144; - goto yy9; - } - } - } -yy143: - yych = *++YYCURSOR; - if (yych <= ',') { - if (yych == '+') goto yy146; - goto yy114; - } else { - if (yych <= '-') goto yy146; - if (yych <= '/') goto yy114; - if (yych <= '9') goto yy147; - goto yy114; - } -yy144: - ++YYCURSOR; - if (YYLIMIT <= YYCURSOR) YYFILL(1); - yych = *YYCURSOR; - if (yych <= 'U') { - if (yych == 'L') goto yy144; - if (yych <= 'T') goto yy9; - goto yy144; - } else { - if (yych <= 'l') { - if (yych <= 'k') goto yy9; - goto yy144; - } else { - if (yych == 'u') goto yy144; - goto yy9; - } - } -yy146: - yych = *++YYCURSOR; - if (yych <= '/') goto yy114; - if (yych >= ':') goto yy114; -yy147: - ++YYCURSOR; - if (YYLIMIT <= YYCURSOR) YYFILL(1); - yych = *YYCURSOR; - if (yych <= 'G') { - if (yych <= '9') { - if (yych <= '/') goto yy125; - goto yy147; - } else { - if (yych == 'F') goto yy127; - goto yy125; - } - } else { - if (yych <= 'f') { - if (yych <= 'H') goto yy127; - if (yych <= 'e') goto yy125; - goto yy127; - } else { - if (yych == 'h') goto yy127; - goto yy125; - } - } -yy149: - yyaccept = 2; - YYMARKER = ++YYCURSOR; - if ((YYLIMIT - YYCURSOR) < 3) YYFILL(3); - yych = *YYCURSOR; -yy150: - if (yych <= 'G') { - if (yych <= 'D') { - if (yych <= '/') goto yy125; - if (yych <= '9') goto yy149; - goto yy125; - } else { - if (yych <= 'E') goto yy155; - if (yych <= 'F') goto yy127; - goto yy125; - } - } else { - if (yych <= 'e') { - if (yych <= 'H') goto yy127; - if (yych <= 'd') goto yy125; - goto yy155; - } else { - if (yych == 'g') goto yy125; - if (yych <= 'h') goto yy127; - goto yy125; - } - } -yy151: - yych = *++YYCURSOR; - if (yych <= ',') { - if (yych != '+') goto yy114; - } else { - if (yych <= '-') goto yy152; - if (yych <= '/') goto yy114; - if (yych <= '9') goto yy153; - goto yy114; - } -yy152: - yych = *++YYCURSOR; - if (yych <= '/') goto yy114; - if (yych >= ':') goto yy114; -yy153: - ++YYCURSOR; - if (YYLIMIT <= YYCURSOR) YYFILL(1); - yych = *YYCURSOR; - if (yych <= 'G') { - if (yych <= '9') { - if (yych <= '/') goto yy125; - goto yy153; - } else { - if (yych == 'F') goto yy127; - goto yy125; - } - } else { - if (yych <= 'f') { - if (yych <= 'H') goto yy127; - if (yych <= 'e') goto yy125; - goto yy127; - } else { - if (yych == 'h') goto yy127; - goto yy125; - } - } -yy155: - yych = *++YYCURSOR; - if (yych <= ',') { - if (yych != '+') goto yy114; - } else { - if (yych <= '-') goto yy156; - if (yych <= '/') goto yy114; - if (yych <= '9') goto yy157; - goto yy114; - } -yy156: - yych = *++YYCURSOR; - if (yych <= '/') goto yy114; - if (yych >= ':') goto yy114; -yy157: - ++YYCURSOR; - if (YYLIMIT <= YYCURSOR) YYFILL(1); - yych = *YYCURSOR; - if (yych <= 'G') { - if (yych <= '9') { - if (yych <= '/') goto yy125; - goto yy157; - } else { - if (yych == 'F') goto yy127; - goto yy125; - } - } else { - if (yych <= 'f') { - if (yych <= 'H') goto yy127; - if (yych <= 'e') goto yy125; - goto yy127; - } else { - if (yych == 'h') goto yy127; - goto yy125; - } - } -yy159: - yyaccept = 1; - YYMARKER = ++YYCURSOR; - if ((YYLIMIT - YYCURSOR) < 4) YYFILL(4); - yych = *YYCURSOR; -yy160: - if (yych <= 'L') { - if (yych <= '9') { - if (yych == '.') goto yy140; - if (yych <= '/') goto yy9; - goto yy159; - } else { - if (yych == 'E') goto yy143; - if (yych <= 'K') goto yy9; - goto yy166; - } - } else { - if (yych <= 'e') { - if (yych == 'U') goto yy166; - if (yych <= 'd') goto yy9; - goto yy143; - } else { - if (yych <= 'l') { - if (yych <= 'k') goto yy9; - goto yy166; - } else { - if (yych == 'u') goto yy166; - goto yy9; - } - } - } -yy161: - yych = *++YYCURSOR; - if (yych <= '@') { - if (yych <= '/') goto yy114; - if (yych >= ':') goto yy114; - } else { - if (yych <= 'F') goto yy162; - if (yych <= '`') goto yy114; - if (yych >= 'g') goto yy114; - } -yy162: - ++YYCURSOR; - if (YYLIMIT <= YYCURSOR) YYFILL(1); - yych = *YYCURSOR; - if (yych <= 'T') { - if (yych <= '@') { - if (yych <= '/') goto yy9; - if (yych <= '9') goto yy162; - goto yy9; - } else { - if (yych <= 'F') goto yy162; - if (yych != 'L') goto yy9; - } - } else { - if (yych <= 'k') { - if (yych <= 'U') goto yy164; - if (yych <= '`') goto yy9; - if (yych <= 'f') goto yy162; - goto yy9; - } else { - if (yych <= 'l') goto yy164; - if (yych != 'u') goto yy9; - } - } -yy164: - ++YYCURSOR; - if (YYLIMIT <= YYCURSOR) YYFILL(1); - yych = *YYCURSOR; - if (yych <= 'U') { - if (yych == 'L') goto yy164; - if (yych <= 'T') goto yy9; - goto yy164; - } else { - if (yych <= 'l') { - if (yych <= 'k') goto yy9; - goto yy164; - } else { - if (yych == 'u') goto yy164; - goto yy9; - } - } -yy166: - ++YYCURSOR; - if (YYLIMIT <= YYCURSOR) YYFILL(1); - yych = *YYCURSOR; - if (yych <= 'U') { - if (yych == 'L') goto yy166; - if (yych <= 'T') goto yy9; - goto yy166; - } else { - if (yych <= 'l') { - if (yych <= 'k') goto yy9; - goto yy166; - } else { - if (yych == 'u') goto yy166; - goto yy9; - } - } -yy168: - ++YYCURSOR; - if (YYLIMIT <= YYCURSOR) YYFILL(1); - yych = *YYCURSOR; -yy169: - if (yych <= 'Z') { - if (yych <= '/') goto yy7; - if (yych <= '9') goto yy168; - if (yych <= '@') goto yy7; - goto yy168; - } else { - if (yych <= '_') { - if (yych <= '^') goto yy7; - goto yy168; - } else { - if (yych <= '`') goto yy7; - if (yych <= 'z') goto yy168; - goto yy7; - } - } -yy170: - ++YYCURSOR; - { RET(TOKEN_DIVASSIGN); } -yy172: - ++YYCURSOR; - { goto singlelinecomment; } -yy174: - ++YYCURSOR; - { goto multilinecomment; } -yy176: - ++YYCURSOR; - if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); - yych = *YYCURSOR; -yy177: - if (yych <= '\f') { - if (yych <= 0x08) goto yy114; - if (yych != '\n') goto yy176; - } else { - if (yych <= '\r') goto yy180; - if (yych == ' ') goto yy176; - goto yy114; - } -yy178: - ++YYCURSOR; -yy179: - { s->line++; goto scanner_loop; } -yy180: - ++YYCURSOR; - if ((yych = *YYCURSOR) == '\n') goto yy178; - goto yy179; -} - - -multilinecomment: - if (YYLIMIT == YYCURSOR) YYFILL(1); - matchptr = cursor; -// The "*\/" is just to avoid screwing up text editor syntax highlighting. - -{ - YYCTYPE yych; - if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); - yych = *YYCURSOR; - if (yych <= '\f') { - if (yych <= 0x00) goto yy188; - if (yych == '\n') goto yy185; - goto yy190; - } else { - if (yych <= '\r') goto yy187; - if (yych != '*') goto yy190; - } - ++YYCURSOR; - if ((yych = *YYCURSOR) == '/') goto yy192; -yy184: - { goto multilinecomment; } -yy185: - ++YYCURSOR; -yy186: - { - s->line++; - token = matchptr; - saw_newline = 1; - goto multilinecomment; - } -yy187: - yych = *++YYCURSOR; - if (yych == '\n') goto yy191; - goto yy186; -yy188: - ++YYCURSOR; - { - if (eoi) - RET(TOKEN_INCOMPLETE_COMMENT); - goto multilinecomment; - } -yy190: - yych = *++YYCURSOR; - goto yy184; -yy191: - yych = *++YYCURSOR; - goto yy186; -yy192: - ++YYCURSOR; - { - if (saw_newline) - RET('\n'); - else if (s->report_whitespace) - RET(' '); - goto scanner_loop; - } -} - - -singlelinecomment: - if (YYLIMIT == YYCURSOR) YYFILL(1); - matchptr = cursor; - -{ - YYCTYPE yych; - if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); - yych = *YYCURSOR; - if (yych <= '\n') { - if (yych <= 0x00) goto yy199; - if (yych <= '\t') goto yy201; - } else { - if (yych == '\r') goto yy198; - goto yy201; - } - ++YYCURSOR; -yy197: - { s->line++; token = matchptr; RET('\n'); } -yy198: - yych = *++YYCURSOR; - if (yych == '\n') goto yy203; - goto yy197; -yy199: - ++YYCURSOR; - { if (eoi) { RET(TOKEN_EOI); } goto singlelinecomment; } -yy201: - ++YYCURSOR; - { goto singlelinecomment; } -yy203: - ++YYCURSOR; - yych = *YYCURSOR; - goto yy197; -} - - -ppdirective: - if (YYLIMIT == YYCURSOR) YYFILL(1); - -{ - YYCTYPE yych; - unsigned int yyaccept = 0; - if ((YYLIMIT - YYCURSOR) < 8) YYFILL(8); - yych = *YYCURSOR; - if (yych <= '\f') { - if (yych == '\t') goto yy208; - if (yych <= '\n') goto yy210; - goto yy208; - } else { - if (yych <= ' ') { - if (yych <= 0x1F) goto yy210; - goto yy208; - } else { - if (yych != '#') goto yy210; - } - } - yyaccept = 0; - yych = *(YYMARKER = ++YYCURSOR); - if (yych <= 'h') { - if (yych <= 0x1F) { - if (yych == '\t') goto yy214; - } else { - if (yych <= ' ') goto yy214; - if (yych <= 'c') goto yy207; - if (yych <= 'e') goto yy214; - } - } else { - if (yych <= 'o') { - if (yych <= 'i') goto yy214; - if (yych == 'l') goto yy214; - } else { - if (yych <= 'p') goto yy214; - if (yych == 'u') goto yy214; - } - } -yy207: - { - token = cursor = (const uchar *) s->source; - limit = cursor + s->bytes_left; - goto scanner_loop; - } -yy208: - ++YYCURSOR; - yych = *YYCURSOR; - goto yy212; -yy209: - { goto ppdirective; } -yy210: - yych = *++YYCURSOR; - goto yy207; -yy211: - ++YYCURSOR; - if (YYLIMIT <= YYCURSOR) YYFILL(1); - yych = *YYCURSOR; -yy212: - if (yych <= '\n') { - if (yych == '\t') goto yy211; - goto yy209; - } else { - if (yych <= '\f') goto yy211; - if (yych == ' ') goto yy211; - goto yy209; - } -yy213: - ++YYCURSOR; - if ((YYLIMIT - YYCURSOR) < 7) YYFILL(7); - yych = *YYCURSOR; -yy214: - if (yych <= 'h') { - if (yych <= ' ') { - if (yych == '\t') goto yy213; - if (yych >= ' ') goto yy213; - } else { - if (yych <= 'c') goto yy215; - if (yych <= 'd') goto yy220; - if (yych <= 'e') goto yy217; - } - } else { - if (yych <= 'o') { - if (yych <= 'i') goto yy218; - if (yych == 'l') goto yy221; - } else { - if (yych <= 'p') goto yy216; - if (yych == 'u') goto yy219; - } - } -yy215: - YYCURSOR = YYMARKER; - if (yyaccept <= 0) { - goto yy207; - } else { - goto yy239; - } -yy216: - yych = *++YYCURSOR; - if (yych == 'r') goto yy272; - goto yy215; -yy217: - yych = *++YYCURSOR; - if (yych <= 'm') { - if (yych == 'l') goto yy255; - goto yy215; - } else { - if (yych <= 'n') goto yy256; - if (yych == 'r') goto yy257; - goto yy215; - } -yy218: - yych = *++YYCURSOR; - if (yych == 'f') goto yy238; - if (yych == 'n') goto yy237; - goto yy215; -yy219: - yych = *++YYCURSOR; - if (yych == 'n') goto yy232; - goto yy215; -yy220: - yych = *++YYCURSOR; - if (yych == 'e') goto yy226; - goto yy215; -yy221: - yych = *++YYCURSOR; - if (yych != 'i') goto yy215; - yych = *++YYCURSOR; - if (yych != 'n') goto yy215; - yych = *++YYCURSOR; - if (yych != 'e') goto yy215; - ++YYCURSOR; - { RET(TOKEN_PP_LINE); } -yy226: - yych = *++YYCURSOR; - if (yych != 'f') goto yy215; - yych = *++YYCURSOR; - if (yych != 'i') goto yy215; - yych = *++YYCURSOR; - if (yych != 'n') goto yy215; - yych = *++YYCURSOR; - if (yych != 'e') goto yy215; - ++YYCURSOR; - { RET(TOKEN_PP_DEFINE); } -yy232: - yych = *++YYCURSOR; - if (yych != 'd') goto yy215; - yych = *++YYCURSOR; - if (yych != 'e') goto yy215; - yych = *++YYCURSOR; - if (yych != 'f') goto yy215; - ++YYCURSOR; - { RET(TOKEN_PP_UNDEF); } -yy237: - yych = *++YYCURSOR; - if (yych == 'c') goto yy249; - goto yy215; -yy238: - yyaccept = 1; - yych = *(YYMARKER = ++YYCURSOR); - if (yych == 'd') goto yy241; - if (yych == 'n') goto yy240; -yy239: - { RET(TOKEN_PP_IF); } -yy240: - yych = *++YYCURSOR; - if (yych == 'd') goto yy245; - goto yy215; -yy241: - yych = *++YYCURSOR; - if (yych != 'e') goto yy215; - yych = *++YYCURSOR; - if (yych != 'f') goto yy215; - ++YYCURSOR; - { RET(TOKEN_PP_IFDEF); } -yy245: - yych = *++YYCURSOR; - if (yych != 'e') goto yy215; - yych = *++YYCURSOR; - if (yych != 'f') goto yy215; - ++YYCURSOR; - { RET(TOKEN_PP_IFNDEF); } -yy249: - yych = *++YYCURSOR; - if (yych != 'l') goto yy215; - yych = *++YYCURSOR; - if (yych != 'u') goto yy215; - yych = *++YYCURSOR; - if (yych != 'd') goto yy215; - yych = *++YYCURSOR; - if (yych != 'e') goto yy215; - ++YYCURSOR; - { RET(TOKEN_PP_INCLUDE); } -yy255: - yych = *++YYCURSOR; - if (yych == 'i') goto yy266; - if (yych == 's') goto yy267; - goto yy215; -yy256: - yych = *++YYCURSOR; - if (yych == 'd') goto yy262; - goto yy215; -yy257: - yych = *++YYCURSOR; - if (yych != 'r') goto yy215; - yych = *++YYCURSOR; - if (yych != 'o') goto yy215; - yych = *++YYCURSOR; - if (yych != 'r') goto yy215; - ++YYCURSOR; - { RET(TOKEN_PP_ERROR); } -yy262: - yych = *++YYCURSOR; - if (yych != 'i') goto yy215; - yych = *++YYCURSOR; - if (yych != 'f') goto yy215; - ++YYCURSOR; - { RET(TOKEN_PP_ENDIF); } -yy266: - yych = *++YYCURSOR; - if (yych == 'f') goto yy270; - goto yy215; -yy267: - yych = *++YYCURSOR; - if (yych != 'e') goto yy215; - ++YYCURSOR; - { RET(TOKEN_PP_ELSE); } -yy270: - ++YYCURSOR; - { RET(TOKEN_PP_ELIF); } -yy272: - yych = *++YYCURSOR; - if (yych != 'a') goto yy215; - yych = *++YYCURSOR; - if (yych != 'g') goto yy215; - yych = *++YYCURSOR; - if (yych != 'm') goto yy215; - yych = *++YYCURSOR; - if (yych != 'a') goto yy215; - ++YYCURSOR; - { RET(TOKEN_PP_PRAGMA); } -} - - -bad_chars: - if (YYLIMIT == YYCURSOR) YYFILL(1); - -{ - YYCTYPE yych; - if (YYLIMIT <= YYCURSOR) YYFILL(1); - yych = *YYCURSOR; - if (yych <= '#') { - if (yych <= '\r') { - if (yych <= 0x00) goto yy282; - if (yych <= 0x08) goto yy284; - } else { - if (yych <= 0x1F) goto yy284; - if (yych == '"') goto yy284; - } - } else { - if (yych <= '@') { - if (yych <= '$') goto yy284; - if (yych >= '@') goto yy284; - } else { - if (yych == '`') goto yy284; - if (yych >= 0x7F) goto yy284; - } - } - ++YYCURSOR; - { cursor--; RET(TOKEN_BAD_CHARS); } -yy282: - ++YYCURSOR; - { - if (eoi) - { - assert( !((token >= sentinel) && - (token < sentinel+YYMAXFILL)) ); - eoi = 0; - cursor = (uchar *) s->source_base + s->orig_length; - RET(TOKEN_BAD_CHARS); // next call will be EOI. - } - goto bad_chars; - } -yy284: - ++YYCURSOR; - { goto bad_chars; } -} - - - assert(0 && "Shouldn't hit this code"); - RET(TOKEN_UNKNOWN); -} // preprocessor_lexer - -// end of mojoshader_lexer_preprocessor.re (or .c) ... - diff --git a/Externals/mojoshader/1067/mojoshader_lexer.re b/Externals/mojoshader/1067/mojoshader_lexer.re deleted file mode 100644 index 0ac656ae..00000000 --- a/Externals/mojoshader/1067/mojoshader_lexer.re +++ /dev/null @@ -1,249 +0,0 @@ -/** - * MojoShader; generate shader programs from bytecode of compiled - * Direct3D shaders. - * - * Please see the file LICENSE.txt in the source's root directory. - * - * This file written by Ryan C. Gordon. - */ - -// This was originally based on examples/pp-c.re from re2c: http://re2c.org/ -// re2c is public domain code. -// -// You build mojoshader_lexer_preprocessor.c from the .re file with re2c... -// re2c -is -o mojoshader_lexer_preprocessor.c mojoshader_lexer_preprocessor.re -// -// Changes to the lexer are done to the .re file, not the C code! -// -// Please note that this isn't a perfect C lexer, since it is used for both -// HLSL and shader assembly language, and follows the quirks of Microsoft's -// tools. - -#define __MOJOSHADER_INTERNAL__ 1 -#include "mojoshader_internal.h" - -typedef unsigned char uchar; - -/*!max:re2c */ -#define RET(t) return update_state(s, eoi, cursor, token, (Token) t) -#define YYCTYPE uchar -#define YYCURSOR cursor -#define YYLIMIT limit -#define YYMARKER s->lexer_marker -#define YYFILL(n) { if ((n) == 1) { cursor = sentinel; limit = cursor + YYMAXFILL; eoi = 1; } } - -static uchar sentinel[YYMAXFILL]; - -static Token update_state(IncludeState *s, int eoi, const uchar *cur, - const uchar *tok, const Token val) -{ - if (eoi) - { - s->bytes_left = 0; - s->source = (const char *) s->source_base + s->orig_length; - if ( (tok >= sentinel) && (tok < (sentinel+YYMAXFILL)) ) - s->token = s->source; - else - s->token = (const char *) tok; - } // if - else - { - s->bytes_left -= (unsigned int) (cur - ((const uchar *) s->source)); - s->source = (const char *) cur; - s->token = (const char *) tok; - } // else - s->tokenlen = (unsigned int) (s->source - s->token); - s->tokenval = val; - return val; -} // update_state - -Token preprocessor_lexer(IncludeState *s) -{ - const uchar *cursor = (const uchar *) s->source; - const uchar *token = cursor; - const uchar *matchptr; - const uchar *limit = cursor + s->bytes_left; - int eoi = 0; - int saw_newline = 0; - -/*!re2c - ANY = [\000-\377]; - ANYLEGAL = [a-zA-Z0-9_/'*=+%^&|!#<>()[{}.,~^:;? \t\v\f\r\n\-\]\\]; - O = [0-7]; - D = [0-9]; - L = [a-zA-Z_]; - H = [a-fA-F0-9]; - E = [Ee] [+-]? D+; - FS = [fFhH]; - IS = [uUlL]*; - ESC = [\\] ([abfnrtv?'"\\] | "x" H+ | O+); - PP = "#" [ \t]*; - NEWLINE = ("\r\n" | "\r" | "\n"); - WHITESPACE = [ \t\v\f]+; -*/ - - // preprocessor directives are only valid at start of line. - if (s->tokenval == ((Token) '\n')) - goto ppdirective; // may jump back to scanner_loop. - -scanner_loop: - if (YYLIMIT == YYCURSOR) YYFILL(1); - token = cursor; - -/*!re2c - "\\" [ \t\v\f]* NEWLINE { s->line++; goto scanner_loop; } - - "/*" { goto multilinecomment; } - "//" { goto singlelinecomment; } - - L (L|D)* { RET(TOKEN_IDENTIFIER); } - - ("0" [xX] H+ IS?) | ("0" D+ IS?) | (D+ IS?) | - (['] (ESC|ANY\[\r\n\\'])* [']) - { RET(TOKEN_INT_LITERAL); } - - (D+ E FS?) | (D* "." D+ E? FS?) | (D+ "." D* E? FS?) - { RET(TOKEN_FLOAT_LITERAL); } - - (["] (ESC|ANY\[\r\n\\"])* ["]) - { RET(TOKEN_STRING_LITERAL); } - - ">>=" { RET(TOKEN_RSHIFTASSIGN); } - "<<=" { RET(TOKEN_LSHIFTASSIGN); } - "+=" { RET(TOKEN_ADDASSIGN); } - "-=" { RET(TOKEN_SUBASSIGN); } - "*=" { RET(TOKEN_MULTASSIGN); } - "/=" { RET(TOKEN_DIVASSIGN); } - "%=" { RET(TOKEN_MODASSIGN); } - "^=" { RET(TOKEN_XORASSIGN); } - "&=" { RET(TOKEN_ANDASSIGN); } - "|=" { RET(TOKEN_ORASSIGN); } - "++" { RET(TOKEN_INCREMENT); } - "--" { RET(TOKEN_DECREMENT); } - ">>" { RET(TOKEN_RSHIFT); } - "<<" { RET(TOKEN_LSHIFT); } - "&&" { RET(TOKEN_ANDAND); } - "||" { RET(TOKEN_OROR); } - "<=" { RET(TOKEN_LEQ); } - ">=" { RET(TOKEN_GEQ); } - "==" { RET(TOKEN_EQL); } - "!=" { RET(TOKEN_NEQ); } - "#" { RET(TOKEN_HASH); } - "##" { RET(TOKEN_HASHHASH); } - "(" { RET('('); } - ")" { RET(')'); } - "[" { RET('['); } - "]" { RET(']'); } - "." { RET('.'); } - "," { RET(','); } - "&" { RET('&'); } - "!" { RET('!'); } - "~" { RET('~'); } - "-" { RET('-'); } - "+" { RET('+'); } - "*" { RET('*'); } - "/" { RET('/'); } - "%" { RET('%'); } - "<" { RET('<'); } - ">" { RET('>'); } - "^" { RET('^'); } - "|" { RET('|'); } - ":" { RET(':'); } - "{" { RET('{'); } - "}" { RET('}'); } - "=" { RET('='); } - "?" { RET('?'); } - - ";" { if (s->asm_comments) goto singlelinecomment; RET(';'); } - - "\000" { if (eoi) { RET(TOKEN_EOI); } goto bad_chars; } - - WHITESPACE { if (s->report_whitespace) RET(' '); goto scanner_loop; } - NEWLINE { s->line++; RET('\n'); } - ANY { goto bad_chars; } -*/ - -multilinecomment: - if (YYLIMIT == YYCURSOR) YYFILL(1); - matchptr = cursor; -// The "*\/" is just to avoid screwing up text editor syntax highlighting. -/*!re2c - "*\/" { - if (saw_newline) - RET('\n'); - else if (s->report_whitespace) - RET(' '); - goto scanner_loop; - } - NEWLINE { - s->line++; - token = matchptr; - saw_newline = 1; - goto multilinecomment; - } - "\000" { - if (eoi) - RET(TOKEN_INCOMPLETE_COMMENT); - goto multilinecomment; - } - ANY { goto multilinecomment; } -*/ - -singlelinecomment: - if (YYLIMIT == YYCURSOR) YYFILL(1); - matchptr = cursor; -/*!re2c - NEWLINE { s->line++; token = matchptr; RET('\n'); } - "\000" { if (eoi) { RET(TOKEN_EOI); } goto singlelinecomment; } - ANY { goto singlelinecomment; } -*/ - -ppdirective: - if (YYLIMIT == YYCURSOR) YYFILL(1); -/*!re2c - PP "include" { RET(TOKEN_PP_INCLUDE); } - PP "line" { RET(TOKEN_PP_LINE); } - PP "define" { RET(TOKEN_PP_DEFINE); } - PP "undef" { RET(TOKEN_PP_UNDEF); } - PP "if" { RET(TOKEN_PP_IF); } - PP "ifdef" { RET(TOKEN_PP_IFDEF); } - PP "ifndef" { RET(TOKEN_PP_IFNDEF); } - PP "else" { RET(TOKEN_PP_ELSE); } - PP "elif" { RET(TOKEN_PP_ELIF); } - PP "endif" { RET(TOKEN_PP_ENDIF); } - PP "error" { RET(TOKEN_PP_ERROR); } - PP "pragma" { RET(TOKEN_PP_PRAGMA); } - WHITESPACE { goto ppdirective; } - - ANY { - token = cursor = (const uchar *) s->source; - limit = cursor + s->bytes_left; - goto scanner_loop; - } -*/ - -bad_chars: - if (YYLIMIT == YYCURSOR) YYFILL(1); -/*!re2c - ANYLEGAL { cursor--; RET(TOKEN_BAD_CHARS); } - "\000" { - if (eoi) - { - assert( !((token >= sentinel) && - (token < sentinel+YYMAXFILL)) ); - eoi = 0; - cursor = (uchar *) s->source_base + s->orig_length; - RET(TOKEN_BAD_CHARS); // next call will be EOI. - } - goto bad_chars; - } - - ANY { goto bad_chars; } -*/ - - assert(0 && "Shouldn't hit this code"); - RET(TOKEN_UNKNOWN); -} // preprocessor_lexer - -// end of mojoshader_lexer_preprocessor.re (or .c) ... - diff --git a/Externals/mojoshader/1067/mojoshader_opengl.c b/Externals/mojoshader/1067/mojoshader_opengl.c deleted file mode 100644 index b8b74e43..00000000 --- a/Externals/mojoshader/1067/mojoshader_opengl.c +++ /dev/null @@ -1,2308 +0,0 @@ -/** - * MojoShader; generate shader programs from bytecode of compiled - * Direct3D shaders. - * - * Please see the file LICENSE.txt in the source's root directory. - * - * This file written by Ryan C. Gordon. - */ - -// !!! FIXME: preshaders shouldn't be handled in here at all. This should -// !!! FIXME: be in the Effects API, once that's actually written. - -#include <stdio.h> -#include <string.h> -#include <stdlib.h> -#include <stdarg.h> -#include <assert.h> - -// !!! FIXME: most of these _MSC_VER should probably be _WINDOWS? -#ifdef _MSC_VER -#define WIN32_LEAN_AND_MEAN 1 -#include <windows.h> // GL headers need this for WINGDIAPI definition. -#endif - -#if (defined(__APPLE__) && defined(__MACH__) && !defined(__arm__) && !defined(__arm64__)) -#define PLATFORM_MACOSX 1 -#endif - -#if PLATFORM_MACOSX -#include <Carbon/Carbon.h> -#endif - -#define __MOJOSHADER_INTERNAL__ 1 -#include "mojoshader_internal.h" - -#define GL_GLEXT_LEGACY 1 -#include "GL/gl.h" -#include "GL/glext.h" - -#ifndef GL_HALF_FLOAT -#define GL_HALF_FLOAT 0x140B -#endif - -#ifndef GL_HALF_FLOAT_OES -#define GL_HALF_FLOAT_OES 0x8D61 -#endif - -// this happens to be the same value for ARB1 and GLSL. -#ifndef GL_PROGRAM_POINT_SIZE -#define GL_PROGRAM_POINT_SIZE 0x8642 -#endif - -struct MOJOSHADER_glShader -{ - const MOJOSHADER_parseData *parseData; - GLuint handle; - uint32 refcount; -}; - -typedef struct -{ - MOJOSHADER_shaderType shader_type; - const MOJOSHADER_uniform *uniform; - GLint location; -} UniformMap; - -typedef struct -{ - const MOJOSHADER_attribute *attribute; - GLint location; -} AttributeMap; - -struct MOJOSHADER_glProgram -{ - MOJOSHADER_glShader *vertex; - MOJOSHADER_glShader *fragment; - GLuint handle; - uint32 generation; - uint32 uniform_count; - UniformMap *uniforms; - uint32 attribute_count; - AttributeMap *attributes; - size_t vs_uniforms_float4_count; - GLfloat *vs_uniforms_float4; - size_t vs_uniforms_int4_count; - GLint *vs_uniforms_int4; - size_t vs_uniforms_bool_count; - GLint *vs_uniforms_bool; - size_t ps_uniforms_float4_count; - GLfloat *ps_uniforms_float4; - size_t ps_uniforms_int4_count; - GLint *ps_uniforms_int4; - size_t ps_uniforms_bool_count; - GLint *ps_uniforms_bool; - - size_t vs_preshader_reg_count; - GLfloat *vs_preshader_regs; - size_t ps_preshader_reg_count; - GLfloat *ps_preshader_regs; - - uint32 refcount; - - int uses_pointsize; - - // GLSL uses these...location of uniform arrays. - GLint vs_float4_loc; - GLint vs_int4_loc; - GLint vs_bool_loc; - GLint ps_float4_loc; - GLint ps_int4_loc; - GLint ps_bool_loc; -}; - -#ifndef WINGDIAPI -#define WINGDIAPI -#endif - -// Entry points in base OpenGL that lack function pointer prototypes... -typedef WINGDIAPI void (APIENTRYP PFNGLGETINTEGERVPROC) (GLenum pname, GLint *params); -typedef WINGDIAPI const GLubyte * (APIENTRYP PFNGLGETSTRINGPROC) (GLenum name); -typedef WINGDIAPI GLenum (APIENTRYP PFNGLGETERRORPROC) (void); -typedef WINGDIAPI void (APIENTRYP PFNGLENABLEPROC) (GLenum cap); -typedef WINGDIAPI void (APIENTRYP PFNGLDISABLEPROC) (GLenum cap); - -// Max entries for each register file type... -#define MAX_REG_FILE_F 8192 -#define MAX_REG_FILE_I 2047 -#define MAX_REG_FILE_B 2047 - -struct MOJOSHADER_glContext -{ - // Allocators... - MOJOSHADER_malloc malloc_fn; - MOJOSHADER_free free_fn; - void *malloc_data; - - // The constant register files... - // !!! FIXME: Man, it kills me how much memory this takes... - // !!! FIXME: ... make this dynamically allocated on demand. - GLfloat vs_reg_file_f[MAX_REG_FILE_F * 4]; - GLint vs_reg_file_i[MAX_REG_FILE_I * 4]; - uint8 vs_reg_file_b[MAX_REG_FILE_B]; - GLfloat ps_reg_file_f[MAX_REG_FILE_F * 4]; - GLint ps_reg_file_i[MAX_REG_FILE_I * 4]; - uint8 ps_reg_file_b[MAX_REG_FILE_B]; - GLuint sampler_reg_file[16]; - - // This increments every time we change the register files. - uint32 generation; - - // This keeps track of implicitly linked programs. - HashTable *linker_cache; - - // This tells us which vertex attribute arrays we have enabled. - GLint max_attrs; - uint8 want_attr[32]; - uint8 have_attr[32]; - - // rarely used, so we don't touch when we don't have to. - int pointsize_enabled; - - // GL stuff... - int opengl_major; - int opengl_minor; - MOJOSHADER_glProgram *bound_program; - char profile[16]; - - // Extensions... - int have_base_opengl; - int have_GL_ARB_vertex_program; - int have_GL_ARB_fragment_program; - int have_GL_NV_vertex_program2_option; - int have_GL_NV_fragment_program2; - int have_GL_NV_vertex_program3; - int have_GL_NV_gpu_program4; - int have_GL_ARB_shader_objects; - int have_GL_ARB_vertex_shader; - int have_GL_ARB_fragment_shader; - int have_GL_ARB_shading_language_100; - int have_GL_NV_half_float; - int have_GL_ARB_half_float_vertex; - int have_GL_OES_vertex_half_float; - - // Entry points... - PFNGLGETSTRINGPROC glGetString; - PFNGLGETERRORPROC glGetError; - PFNGLGETINTEGERVPROC glGetIntegerv; - PFNGLENABLEPROC glEnable; - PFNGLDISABLEPROC glDisable; - PFNGLDELETEOBJECTARBPROC glDeleteObject; - PFNGLATTACHOBJECTARBPROC glAttachObject; - PFNGLCOMPILESHADERARBPROC glCompileShader; - PFNGLCREATEPROGRAMOBJECTARBPROC glCreateProgramObject; - PFNGLCREATESHADEROBJECTARBPROC glCreateShaderObject; - PFNGLDISABLEVERTEXATTRIBARRAYARBPROC glDisableVertexAttribArray; - PFNGLENABLEVERTEXATTRIBARRAYARBPROC glEnableVertexAttribArray; - PFNGLGETATTRIBLOCATIONARBPROC glGetAttribLocation; - PFNGLGETINFOLOGARBPROC glGetInfoLog; - PFNGLGETOBJECTPARAMETERIVARBPROC glGetObjectParameteriv; - PFNGLGETUNIFORMLOCATIONARBPROC glGetUniformLocation; - PFNGLLINKPROGRAMARBPROC glLinkProgram; - PFNGLSHADERSOURCEARBPROC glShaderSource; - PFNGLUNIFORM1IARBPROC glUniform1i; - PFNGLUNIFORM1IVARBPROC glUniform1iv; - PFNGLUNIFORM4FVARBPROC glUniform4fv; - PFNGLUNIFORM4IVARBPROC glUniform4iv; - PFNGLUSEPROGRAMOBJECTARBPROC glUseProgramObject; - PFNGLVERTEXATTRIBPOINTERARBPROC glVertexAttribPointer; - PFNGLGETPROGRAMIVARBPROC glGetProgramivARB; - PFNGLGETPROGRAMSTRINGARBPROC glGetProgramStringARB; - PFNGLPROGRAMLOCALPARAMETER4FVARBPROC glProgramLocalParameter4fvARB; - PFNGLPROGRAMLOCALPARAMETERI4IVNVPROC glProgramLocalParameterI4ivNV; - PFNGLDELETEPROGRAMSARBPROC glDeleteProgramsARB; - PFNGLGENPROGRAMSARBPROC glGenProgramsARB; - PFNGLBINDPROGRAMARBPROC glBindProgramARB; - PFNGLPROGRAMSTRINGARBPROC glProgramStringARB; - - // interface for profile-specific things. - int (*profileMaxUniforms)(MOJOSHADER_shaderType shader_type); - int (*profileCompileShader)(const MOJOSHADER_parseData *pd, GLuint *s); - void (*profileDeleteShader)(const GLuint shader); - void (*profileDeleteProgram)(const GLuint program); - GLint (*profileGetAttribLocation)(MOJOSHADER_glProgram *program, int idx); - GLint (*profileGetUniformLocation)(MOJOSHADER_glProgram *program, MOJOSHADER_glShader *shader, int idx); - GLint (*profileGetSamplerLocation)(MOJOSHADER_glProgram *, MOJOSHADER_glShader *, int); - GLuint (*profileLinkProgram)(MOJOSHADER_glShader *, MOJOSHADER_glShader *); - void (*profileFinalInitProgram)(MOJOSHADER_glProgram *program); - void (*profileUseProgramObject)(MOJOSHADER_glProgram *program); - void (*profilePushConstantArray)(MOJOSHADER_glProgram *, const MOJOSHADER_uniform *, const GLfloat *); - void (*profilePushUniforms)(void); - void (*profilePushSampler)(GLint loc, GLuint sampler); - int (*profileMustPushConstantArrays)(void); - int (*profileMustPushSamplers)(void); -}; - - -static MOJOSHADER_glContext *ctx = NULL; - -// Error state... -static char error_buffer[1024] = { '\0' }; - -static void set_error(const char *str) -{ - snprintf(error_buffer, sizeof (error_buffer), "%s", str); -} // set_error - -#if PLATFORM_MACOSX -static inline int macosx_version_atleast(int x, int y, int z) -{ - static int checked = 0; - static int combined = 0; - - if (!checked) - { - SInt32 ver, major, minor, patch; - int convert = 0; - - if (Gestalt(gestaltSystemVersion, &ver) != noErr) - ver = 0x1000; // oh well. - else if (ver < 0x1030) - convert = 1; // split (ver) into (major),(minor),(patch). - else - { - // presumably this won't fail. But if it does, we'll just use the - // original version value. This might cut the value--10.12.11 will - // come out to 10.9.9, for example--but it's better than nothing. - if (Gestalt(gestaltSystemVersionMajor, &major) != noErr) - convert = 1; - else if (Gestalt(gestaltSystemVersionMinor, &minor) != noErr) - convert = 1; - else if (Gestalt(gestaltSystemVersionBugFix, &patch) != noErr) - convert = 1; - } // else - - if (convert) - { - major = ((ver & 0xFF00) >> 8); - major = (((major / 16) * 10) + (major % 16)); - minor = ((ver & 0xF0) >> 4); - patch = (ver & 0xF); - } // if - - combined = (major << 16) | (minor << 8) | patch; - checked = 1; - } // if - - return (combined >= ((x << 16) | (y << 8) | z)); -} // macosx_version_atleast -#endif - -static inline void out_of_memory(void) -{ - set_error("out of memory"); -} // out_of_memory - -static inline void *Malloc(const size_t len) -{ - void *retval = ctx->malloc_fn((int) len, ctx->malloc_data); - if (retval == NULL) - out_of_memory(); - return retval; -} // Malloc - -static inline void Free(void *ptr) -{ - if (ptr != NULL) - ctx->free_fn(ptr, ctx->malloc_data); -} // Free - - -static inline void toggle_gl_state(GLenum state, int val) -{ - if (val) - ctx->glEnable(state); - else - ctx->glDisable(state); -} // toggle_gl_state - - -// profile-specific implementations... - -#if SUPPORT_PROFILE_GLSL -static inline GLenum glsl_shader_type(const MOJOSHADER_shaderType t) -{ - if (t == MOJOSHADER_TYPE_VERTEX) - return GL_VERTEX_SHADER; - else if (t == MOJOSHADER_TYPE_PIXEL) - return GL_FRAGMENT_SHADER; - - // !!! FIXME: geometry shaders? - return GL_NONE; -} // glsl_shader_type - - -static int impl_GLSL_MustPushConstantArrays(void) { return 1; } -static int impl_GLSL_MustPushSamplers(void) { return 1; } - -static int impl_GLSL_MaxUniforms(MOJOSHADER_shaderType shader_type) -{ - GLenum pname = GL_NONE; - GLint val = 0; - if (shader_type == MOJOSHADER_TYPE_VERTEX) - pname = GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB; - else if (shader_type == MOJOSHADER_TYPE_PIXEL) - pname = GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB; - else - return -1; - - ctx->glGetIntegerv(pname, &val); - return (int) val; -} // impl_GLSL_MaxUniforms - - -static int impl_GLSL_CompileShader(const MOJOSHADER_parseData *pd, GLuint *s) -{ - GLint ok = 0; - GLint shaderlen = (GLint) pd->output_len; - const GLenum shader_type = glsl_shader_type(pd->shader_type); - GLuint shader = ctx->glCreateShaderObject(shader_type); - - ctx->glShaderSource(shader, 1, (const GLchar **) &pd->output, &shaderlen); - ctx->glCompileShader(shader); - ctx->glGetObjectParameteriv(shader, GL_OBJECT_COMPILE_STATUS_ARB, &ok); - - if (!ok) - { - GLsizei len = 0; - ctx->glGetInfoLog(shader, sizeof (error_buffer), &len, - (GLchar *) error_buffer); - *s = 0; - return 0; - } // if - - *s = shader; - return 1; -} // impl_GLSL_CompileShader - - -static void impl_GLSL_DeleteShader(const GLuint shader) -{ - ctx->glDeleteObject(shader); -} // impl_GLSL_DeleteShader - - -static void impl_GLSL_DeleteProgram(const GLuint program) -{ - ctx->glDeleteObject(program); -} // impl_GLSL_DeleteProgram - - -static GLint impl_GLSL_GetUniformLocation(MOJOSHADER_glProgram *program, - MOJOSHADER_glShader *shader, int idx) -{ - return 0; // no-op, we push this as one big-ass array now. -} // impl_GLSL_GetUniformLocation - - -static GLint impl_GLSL_GetSamplerLocation(MOJOSHADER_glProgram *program, - MOJOSHADER_glShader *shader, int idx) -{ - return ctx->glGetUniformLocation(program->handle, - shader->parseData->samplers[idx].name); -} // impl_GLSL_GetSamplerLocation - - -static GLint impl_GLSL_GetAttribLocation(MOJOSHADER_glProgram *program, int idx) -{ - const MOJOSHADER_parseData *pd = program->vertex->parseData; - const MOJOSHADER_attribute *a = pd->attributes; - return ctx->glGetAttribLocation(program->handle, a[idx].name); -} // impl_GLSL_GetAttribLocation - - -static GLuint impl_GLSL_LinkProgram(MOJOSHADER_glShader *vshader, - MOJOSHADER_glShader *pshader) -{ - const GLuint program = ctx->glCreateProgramObject(); - - if (vshader != NULL) ctx->glAttachObject(program, vshader->handle); - if (pshader != NULL) ctx->glAttachObject(program, pshader->handle); - - ctx->glLinkProgram(program); - - GLint ok = 0; - ctx->glGetObjectParameteriv(program, GL_OBJECT_LINK_STATUS_ARB, &ok); - if (!ok) - { - GLsizei len = 0; - ctx->glGetInfoLog(program, sizeof (error_buffer), &len, (GLchar *) error_buffer); - ctx->glDeleteObject(program); - return 0; - } // if - - return program; -} // impl_GLSL_LinkProgram - - -static void impl_GLSL_FinalInitProgram(MOJOSHADER_glProgram *program) -{ - program->vs_float4_loc = - ctx->glGetUniformLocation(program->handle, "vs_uniforms_vec4"); - program->vs_int4_loc = - ctx->glGetUniformLocation(program->handle, "vs_uniforms_ivec4"); - program->vs_bool_loc = - ctx->glGetUniformLocation(program->handle, "vs_uniforms_bool"); - program->ps_float4_loc = - ctx->glGetUniformLocation(program->handle, "ps_uniforms_vec4"); - program->ps_int4_loc = - ctx->glGetUniformLocation(program->handle, "ps_uniforms_ivec4"); - program->ps_bool_loc = - ctx->glGetUniformLocation(program->handle, "ps_uniforms_bool"); -} // impl_GLSL_FinalInitProgram - - -static void impl_GLSL_UseProgramObject(MOJOSHADER_glProgram *program) -{ - ctx->glUseProgramObject((program != NULL) ? program->handle : 0); -} // impl_GLSL_UseProgramObject - - -static void impl_GLSL_PushConstantArray(MOJOSHADER_glProgram *program, - const MOJOSHADER_uniform *u, - const GLfloat *f) -{ - const GLint loc = ctx->glGetUniformLocation(program->handle, u->name); - if (loc >= 0) // not optimized out? - ctx->glUniform4fv(loc, u->array_count, f); -} // impl_GLSL_PushConstantArray - - -static void impl_GLSL_PushUniforms(void) -{ - const MOJOSHADER_glProgram *program = ctx->bound_program; - - assert(program->uniform_count > 0); // don't call with nothing to do! - - if (program->vs_float4_loc != -1) - { - ctx->glUniform4fv(program->vs_float4_loc, - program->vs_uniforms_float4_count, - program->vs_uniforms_float4); - } // if - - if (program->vs_int4_loc != -1) - { - ctx->glUniform4iv(program->vs_int4_loc, - program->vs_uniforms_int4_count, - program->vs_uniforms_int4); - } // if - - if (program->vs_bool_loc != -1) - { - ctx->glUniform1iv(program->vs_bool_loc, - program->vs_uniforms_bool_count, - program->vs_uniforms_bool); - } // if - - if (program->ps_float4_loc != -1) - { - ctx->glUniform4fv(program->ps_float4_loc, - program->ps_uniforms_float4_count, - program->ps_uniforms_float4); - } // if - - if (program->ps_int4_loc != -1) - { - ctx->glUniform4iv(program->ps_int4_loc, - program->ps_uniforms_int4_count, - program->ps_uniforms_int4); - } // if - - if (program->ps_bool_loc != -1) - { - ctx->glUniform1iv(program->ps_bool_loc, - program->ps_uniforms_bool_count, - program->ps_uniforms_bool); - } // if -} // impl_GLSL_PushUniforms - - -static void impl_GLSL_PushSampler(GLint loc, GLuint sampler) -{ - ctx->glUniform1i(loc, sampler); -} // impl_GLSL_PushSampler - -#endif // SUPPORT_PROFILE_GLSL - - -#if SUPPORT_PROFILE_ARB1 -static inline GLenum arb1_shader_type(const MOJOSHADER_shaderType t) -{ - if (t == MOJOSHADER_TYPE_VERTEX) - return GL_VERTEX_PROGRAM_ARB; - else if (t == MOJOSHADER_TYPE_PIXEL) - return GL_FRAGMENT_PROGRAM_ARB; - - // !!! FIXME: geometry shaders? - return GL_NONE; -} // arb1_shader_type - -static int impl_ARB1_MustPushConstantArrays(void) { return 0; } -static int impl_ARB1_MustPushSamplers(void) { return 0; } - -static int impl_ARB1_MaxUniforms(MOJOSHADER_shaderType shader_type) -{ - GLint retval = 0; - const GLenum program_type = arb1_shader_type(shader_type); - if (program_type == GL_NONE) - return -1; - - ctx->glGetProgramivARB(program_type, GL_MAX_PROGRAM_PARAMETERS_ARB, &retval); - return (int) retval; // !!! FIXME: times four? -} // impl_ARB1_MaxUniforms - - -static int impl_ARB1_CompileShader(const MOJOSHADER_parseData *pd, GLuint *s) -{ - GLint shaderlen = (GLint) pd->output_len; - const GLenum shader_type = arb1_shader_type(pd->shader_type); - GLuint shader = 0; - ctx->glGenProgramsARB(1, &shader); - - ctx->glGetError(); // flush any existing error state. - ctx->glBindProgramARB(shader_type, shader); - ctx->glProgramStringARB(shader_type, GL_PROGRAM_FORMAT_ASCII_ARB, - shaderlen, pd->output); - - if (ctx->glGetError() == GL_INVALID_OPERATION) - { - GLint pos = 0; - ctx->glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &pos); - const GLubyte *errstr = ctx->glGetString(GL_PROGRAM_ERROR_STRING_ARB); - snprintf(error_buffer, sizeof (error_buffer), - "ARB1 compile error at position %d: %s", - (int) pos, (const char *) errstr); - ctx->glBindProgramARB(shader_type, 0); - ctx->glDeleteProgramsARB(1, &shader); - *s = 0; - return 0; - } // if - - *s = shader; - return 1; -} // impl_ARB1_CompileShader - - -static void impl_ARB1_DeleteShader(const GLuint _shader) -{ - GLuint shader = _shader; // const removal. - ctx->glDeleteProgramsARB(1, &shader); -} // impl_ARB1_DeleteShader - - -static void impl_ARB1_DeleteProgram(const GLuint program) -{ - // no-op. ARB1 doesn't have real linked programs. -} // impl_GLSL_DeleteProgram - -static GLint impl_ARB1_GetUniformLocation(MOJOSHADER_glProgram *program, - MOJOSHADER_glShader *shader, int idx) -{ - return 0; // no-op, we push this as one big-ass array now. -} // impl_ARB1_GetUniformLocation - -static GLint impl_ARB1_GetSamplerLocation(MOJOSHADER_glProgram *program, - MOJOSHADER_glShader *shader, int idx) -{ - return shader->parseData->samplers[idx].index; -} // impl_ARB1_GetSamplerLocation - - -static GLint impl_ARB1_GetAttribLocation(MOJOSHADER_glProgram *program, int idx) -{ - return idx; // map to vertex arrays in the same order as the parseData. -} // impl_ARB1_GetAttribLocation - - -static GLuint impl_ARB1_LinkProgram(MOJOSHADER_glShader *vshader, - MOJOSHADER_glShader *pshader) -{ - // there is no formal linking in ARB1...just return a unique value. - static GLuint retval = 1; - return retval++; -} // impl_ARB1_LinkProgram - - -static void impl_ARB1_FinalInitProgram(MOJOSHADER_glProgram *program) -{ - // no-op. -} // impl_ARB1_FinalInitProgram - - -static void impl_ARB1_UseProgramObject(MOJOSHADER_glProgram *program) -{ - GLuint vhandle = 0; - GLuint phandle = 0; - if (program != NULL) - { - if (program->vertex != NULL) - vhandle = program->vertex->handle; - if (program->fragment != NULL) - phandle = program->fragment->handle; - } // if - - toggle_gl_state(GL_VERTEX_PROGRAM_ARB, vhandle != 0); - toggle_gl_state(GL_FRAGMENT_PROGRAM_ARB, phandle != 0); - - ctx->glBindProgramARB(GL_VERTEX_PROGRAM_ARB, vhandle); - ctx->glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, phandle); -} // impl_ARB1_UseProgramObject - - -static void impl_ARB1_PushConstantArray(MOJOSHADER_glProgram *program, - const MOJOSHADER_uniform *u, - const GLfloat *f) -{ - // no-op. Constant arrays are defined in source code for arb1. -} // impl_ARB1_PushConstantArray - - -static void impl_ARB1_PushUniforms(void) -{ - // vertex shader uniforms come first in program->uniforms array. - MOJOSHADER_shaderType shader_type = MOJOSHADER_TYPE_VERTEX; - GLenum arb_shader_type = arb1_shader_type(shader_type); - const MOJOSHADER_glProgram *program = ctx->bound_program; - const uint32 count = program->uniform_count; - const GLfloat *srcf = program->vs_uniforms_float4; - const GLint *srci = program->vs_uniforms_int4; - const GLint *srcb = program->vs_uniforms_bool; - GLint loc = 0; - uint32 i; - - assert(count > 0); // shouldn't call this with nothing to do! - - for (i = 0; i < count; i++) - { - UniformMap *map = &program->uniforms[i]; - const MOJOSHADER_shaderType uniform_shader_type = map->shader_type; - const MOJOSHADER_uniform *u = map->uniform; - const MOJOSHADER_uniformType type = u->type; - const int size = u->array_count ? u->array_count : 1; - - assert(!u->constant); - - // Did we switch from vertex to pixel (to geometry, etc)? - if (shader_type != uniform_shader_type) - { - // we start with vertex, move to pixel, then to geometry, etc. - // The array should always be sorted as such. - if (uniform_shader_type == MOJOSHADER_TYPE_PIXEL) - { - assert(shader_type == MOJOSHADER_TYPE_VERTEX); - srcf = program->ps_uniforms_float4; - srci = program->ps_uniforms_int4; - srcb = program->ps_uniforms_bool; - loc = 0; - } // if - else - { - // These should be ordered vertex, then pixel, then geometry. - assert(0 && "Unexpected shader type"); - } // else - - shader_type = uniform_shader_type; - arb_shader_type = arb1_shader_type(uniform_shader_type); - } // if - - if (type == MOJOSHADER_UNIFORM_FLOAT) - { - int i; - for (i = 0; i < size; i++, srcf += 4, loc++) - ctx->glProgramLocalParameter4fvARB(arb_shader_type, loc, srcf); - } // if - else if (type == MOJOSHADER_UNIFORM_INT) - { - int i; - if (ctx->have_GL_NV_gpu_program4) - { - // GL_NV_gpu_program4 has integer uniform loading support. - for (i = 0; i < size; i++, srci += 4, loc++) - ctx->glProgramLocalParameterI4ivNV(arb_shader_type, loc, srci); - } // if - else - { - for (i = 0; i < size; i++, srci += 4, loc++) - { - const GLfloat fv[4] = { - (GLfloat) srci[0], (GLfloat) srci[1], - (GLfloat) srci[2], (GLfloat) srci[3] - }; - ctx->glProgramLocalParameter4fvARB(arb_shader_type, loc, fv); - } // for - } // else - } // else if - else if (type == MOJOSHADER_UNIFORM_BOOL) - { - int i; - if (ctx->have_GL_NV_gpu_program4) - { - // GL_NV_gpu_program4 has integer uniform loading support. - for (i = 0; i < size; i++, srcb++, loc++) - { - const GLint ib = (GLint) ((*srcb) ? 1 : 0); - const GLint iv[4] = { ib, ib, ib, ib }; - ctx->glProgramLocalParameterI4ivNV(arb_shader_type, loc, iv); - } // for - } // if - else - { - for (i = 0; i < size; i++, srcb++, loc++) - { - const GLfloat fb = (GLfloat) ((*srcb) ? 1.0f : 0.0f); - const GLfloat fv[4] = { fb, fb, fb, fb }; - ctx->glProgramLocalParameter4fvARB(arb_shader_type, loc, fv); - } // for - } // else - } // else if - } // for -} // impl_ARB1_PushUniforms - -static void impl_ARB1_PushSampler(GLint loc, GLuint sampler) -{ - // no-op in this profile...arb1 uses the texture units as-is. - assert(loc == (GLint) sampler); -} // impl_ARB1_PushSampler - -#endif // SUPPORT_PROFILE_ARB1 - - -const char *MOJOSHADER_glGetError(void) -{ - return error_buffer; -} // MOJOSHADER_glGetError - - -static void *loadsym(MOJOSHADER_glGetProcAddress lookup, void *d, - const char *fn, int *ext) -{ - void *retval = NULL; - if (lookup != NULL) - { - retval = lookup(fn, d); - if (retval == NULL) - { - char arbfn[64]; - snprintf(arbfn, sizeof (arbfn), "%sARB", fn); - retval = lookup(arbfn, d); - } // if - } // if - - if (retval == NULL) - *ext = 0; - - return retval; -} // loadsym - -static void lookup_entry_points(MOJOSHADER_glGetProcAddress lookup, void *d) -{ - #define DO_LOOKUP(ext, typ, fn) { \ - ctx->fn = (typ) loadsym(lookup, d, #fn, &ctx->have_##ext); \ - } - - DO_LOOKUP(base_opengl, PFNGLGETSTRINGPROC, glGetString); - DO_LOOKUP(base_opengl, PFNGLGETERRORPROC, glGetError); - DO_LOOKUP(base_opengl, PFNGLGETINTEGERVPROC, glGetIntegerv); - DO_LOOKUP(base_opengl, PFNGLENABLEPROC, glEnable); - DO_LOOKUP(base_opengl, PFNGLDISABLEPROC, glDisable); - DO_LOOKUP(GL_ARB_shader_objects, PFNGLDELETEOBJECTARBPROC, glDeleteObject); - DO_LOOKUP(GL_ARB_shader_objects, PFNGLATTACHOBJECTARBPROC, glAttachObject); - DO_LOOKUP(GL_ARB_shader_objects, PFNGLCOMPILESHADERARBPROC, glCompileShader); - DO_LOOKUP(GL_ARB_shader_objects, PFNGLCREATEPROGRAMOBJECTARBPROC, glCreateProgramObject); - DO_LOOKUP(GL_ARB_shader_objects, PFNGLCREATESHADEROBJECTARBPROC, glCreateShaderObject); - DO_LOOKUP(GL_ARB_shader_objects, PFNGLGETINFOLOGARBPROC, glGetInfoLog); - DO_LOOKUP(GL_ARB_shader_objects, PFNGLGETOBJECTPARAMETERIVARBPROC, glGetObjectParameteriv); - DO_LOOKUP(GL_ARB_shader_objects, PFNGLGETUNIFORMLOCATIONARBPROC, glGetUniformLocation); - DO_LOOKUP(GL_ARB_shader_objects, PFNGLLINKPROGRAMARBPROC, glLinkProgram); - DO_LOOKUP(GL_ARB_shader_objects, PFNGLSHADERSOURCEARBPROC, glShaderSource); - DO_LOOKUP(GL_ARB_shader_objects, PFNGLUNIFORM1IARBPROC, glUniform1i); - DO_LOOKUP(GL_ARB_shader_objects, PFNGLUNIFORM1IVARBPROC, glUniform1iv); - DO_LOOKUP(GL_ARB_shader_objects, PFNGLUNIFORM4FVARBPROC, glUniform4fv); - DO_LOOKUP(GL_ARB_shader_objects, PFNGLUNIFORM4IVARBPROC, glUniform4iv); - DO_LOOKUP(GL_ARB_shader_objects, PFNGLUSEPROGRAMOBJECTARBPROC, glUseProgramObject); - DO_LOOKUP(GL_ARB_vertex_shader, PFNGLDISABLEVERTEXATTRIBARRAYARBPROC, glDisableVertexAttribArray); - DO_LOOKUP(GL_ARB_vertex_shader, PFNGLENABLEVERTEXATTRIBARRAYARBPROC, glEnableVertexAttribArray); - DO_LOOKUP(GL_ARB_vertex_shader, PFNGLGETATTRIBLOCATIONARBPROC, glGetAttribLocation); - DO_LOOKUP(GL_ARB_vertex_shader, PFNGLVERTEXATTRIBPOINTERARBPROC, glVertexAttribPointer); - DO_LOOKUP(GL_ARB_vertex_program, PFNGLVERTEXATTRIBPOINTERARBPROC, glVertexAttribPointer); - DO_LOOKUP(GL_ARB_vertex_program, PFNGLGETPROGRAMIVARBPROC, glGetProgramivARB); - DO_LOOKUP(GL_ARB_vertex_program, PFNGLGETPROGRAMSTRINGARBPROC, glGetProgramStringARB); - DO_LOOKUP(GL_ARB_vertex_program, PFNGLPROGRAMLOCALPARAMETER4FVARBPROC, glProgramLocalParameter4fvARB); - DO_LOOKUP(GL_ARB_vertex_program, PFNGLDELETEPROGRAMSARBPROC, glDeleteProgramsARB); - DO_LOOKUP(GL_ARB_vertex_program, PFNGLGENPROGRAMSARBPROC, glGenProgramsARB); - DO_LOOKUP(GL_ARB_vertex_program, PFNGLBINDPROGRAMARBPROC, glBindProgramARB); - DO_LOOKUP(GL_ARB_vertex_program, PFNGLPROGRAMSTRINGARBPROC, glProgramStringARB); - DO_LOOKUP(GL_NV_gpu_program4, PFNGLPROGRAMLOCALPARAMETERI4IVNVPROC, glProgramLocalParameterI4ivNV); - - #undef DO_LOOKUP -} // lookup_entry_points - - -static int verify_extension(const char *ext, int have, const char *extlist, - int major, int minor) -{ - if (have == 0) - return 0; // don't bother checking, we're missing an entry point. - - else if (!ctx->have_base_opengl) - return 0; // don't bother checking, we're missing basic functionality. - - // See if it's in the spec for this GL implementation's version. - if (major >= 0) - { - if ( ((ctx->opengl_major << 16) | (ctx->opengl_minor & 0xFFFF)) >= - ((major << 16) | (minor & 0xFFFF)) ) - return 1; - } // if - - // Not available in the GL version, check the extension list. - const char *ptr = strstr(extlist, ext); - if (ptr == NULL) - return 0; - - const char endchar = ptr[strlen(ext)]; - if ((endchar == '\0') || (endchar == ' ')) - return 1; // extension is in the list. - - return 0; // just not supported, fail. -} // verify_extension - - -static void parse_opengl_version_str(const char *verstr, int *maj, int *min) -{ - if (verstr == NULL) - *maj = *min = 0; - else - sscanf(verstr, "%d.%d", maj, min); -} // parse_opengl_version_str - - -static inline void parse_opengl_version(const char *verstr) -{ - parse_opengl_version_str(verstr, &ctx->opengl_major, &ctx->opengl_minor); -} // parse_opengl_version - - -#if SUPPORT_PROFILE_GLSL -static int glsl_version_atleast(int maj, int min) -{ - int glslmin = 0; - int glslmaj = 0; - ctx->glGetError(); // flush any existing error state. - const GLenum enumval = GL_SHADING_LANGUAGE_VERSION_ARB; - const char *str = (const char *) ctx->glGetString(enumval); - if (ctx->glGetError() == GL_INVALID_ENUM) - return 0; // this is a basic, 1.0-compliant implementation. - parse_opengl_version_str(str, &glslmaj, &glslmin); - return ( (glslmaj > maj) || ((glslmaj == maj) && (glslmin >= min)) ); -} // glsl_version_atleast -#endif - - -static void load_extensions(MOJOSHADER_glGetProcAddress lookup, void *d) -{ - const char *extlist = NULL; - - ctx->have_base_opengl = 1; - ctx->have_GL_ARB_vertex_program = 1; - ctx->have_GL_ARB_fragment_program = 1; - ctx->have_GL_NV_vertex_program2_option = 1; - ctx->have_GL_NV_fragment_program2 = 1; - ctx->have_GL_NV_vertex_program3 = 1; - ctx->have_GL_NV_gpu_program4 = 1; - ctx->have_GL_ARB_shader_objects = 1; - ctx->have_GL_ARB_vertex_shader = 1; - ctx->have_GL_ARB_fragment_shader = 1; - ctx->have_GL_ARB_shading_language_100 = 1; - ctx->have_GL_NV_half_float = 1; - ctx->have_GL_ARB_half_float_vertex = 1; - ctx->have_GL_OES_vertex_half_float = 1; - - lookup_entry_points(lookup, d); - - if (!ctx->have_base_opengl) - set_error("missing basic OpenGL entry points"); - else - { - parse_opengl_version((const char *) ctx->glGetString(GL_VERSION)); - extlist = (const char *) ctx->glGetString(GL_EXTENSIONS); - } // else - - if (extlist == NULL) - extlist = ""; // just in case. - - #define VERIFY_EXT(ext, major, minor) \ - ctx->have_##ext = verify_extension(#ext, ctx->have_##ext, extlist, major, minor) - - VERIFY_EXT(GL_ARB_vertex_program, -1, -1); - VERIFY_EXT(GL_ARB_fragment_program, -1, -1); - VERIFY_EXT(GL_ARB_shader_objects, 2, 0); - VERIFY_EXT(GL_ARB_vertex_shader, 2, 0); - VERIFY_EXT(GL_ARB_fragment_shader, 2, 0); - VERIFY_EXT(GL_ARB_shading_language_100, 2, 0); - VERIFY_EXT(GL_NV_vertex_program2_option, -1, -1); - VERIFY_EXT(GL_NV_fragment_program2, -1, -1); - VERIFY_EXT(GL_NV_vertex_program3, -1, -1); - VERIFY_EXT(GL_NV_half_float, -1, -1); - VERIFY_EXT(GL_ARB_half_float_vertex, 3, 0); - VERIFY_EXT(GL_OES_vertex_half_float, -1, -1); - - #undef VERIFY_EXT -} // load_extensions - - -static int valid_profile(const char *profile) -{ -#if SUPPORT_PROFILE_GLSL - // If running on Mac OS X <= 10.4, don't ever pick GLSL, even if - // the system claims it is available. - #if PLATFORM_MACOSX - const int allow_glsl = macosx_version_atleast(10, 5, 0); - #else - const int allow_glsl = 1; - #endif -#endif - - if (!ctx->have_base_opengl) - return 0; - - #define MUST_HAVE(p, x) \ - if (!ctx->have_##x) { set_error(#p " profile needs " #x); return 0; } - - if (profile == NULL) - { - set_error("NULL profile"); - return 0; - } // if - - #if SUPPORT_PROFILE_ARB1 - else if (strcmp(profile, MOJOSHADER_PROFILE_ARB1) == 0) - { - MUST_HAVE(MOJOSHADER_PROFILE_ARB1, GL_ARB_vertex_program); - MUST_HAVE(MOJOSHADER_PROFILE_ARB1, GL_ARB_fragment_program); - } // else if - #endif - - #if SUPPORT_PROFILE_ARB1_NV - else if (strcmp(profile, MOJOSHADER_PROFILE_NV2) == 0) - { - MUST_HAVE(MOJOSHADER_PROFILE_NV2, GL_ARB_vertex_program); - MUST_HAVE(MOJOSHADER_PROFILE_NV2, GL_ARB_fragment_program); - MUST_HAVE(MOJOSHADER_PROFILE_NV2, GL_NV_vertex_program2_option); - MUST_HAVE(MOJOSHADER_PROFILE_NV2, GL_NV_fragment_program2); - } // else if - - else if (strcmp(profile, MOJOSHADER_PROFILE_NV3) == 0) - { - MUST_HAVE(MOJOSHADER_PROFILE_NV3, GL_ARB_vertex_program); - MUST_HAVE(MOJOSHADER_PROFILE_NV3, GL_ARB_fragment_program); - MUST_HAVE(MOJOSHADER_PROFILE_NV3, GL_NV_vertex_program3); - MUST_HAVE(MOJOSHADER_PROFILE_NV3, GL_NV_fragment_program2); - } // else if - - else if (strcmp(profile, MOJOSHADER_PROFILE_NV4) == 0) - { - MUST_HAVE(MOJOSHADER_PROFILE_NV4, GL_NV_gpu_program4); - } // else if - #endif - - #if SUPPORT_PROFILE_GLSL120 - else if ((allow_glsl) && (strcmp(profile, MOJOSHADER_PROFILE_GLSL120) == 0)) - { - MUST_HAVE(MOJOSHADER_PROFILE_GLSL, GL_ARB_shader_objects); - MUST_HAVE(MOJOSHADER_PROFILE_GLSL, GL_ARB_vertex_shader); - MUST_HAVE(MOJOSHADER_PROFILE_GLSL, GL_ARB_fragment_shader); - MUST_HAVE(MOJOSHADER_PROFILE_GLSL, GL_ARB_shading_language_100); - // if you got here, you have all the extensions. - if (!glsl_version_atleast(1, 20)) - return 0; - } // else if - #endif - - #if SUPPORT_PROFILE_GLSL - else if ((allow_glsl) && (strcmp(profile, MOJOSHADER_PROFILE_GLSL) == 0)) - { - MUST_HAVE(MOJOSHADER_PROFILE_GLSL, GL_ARB_shader_objects); - MUST_HAVE(MOJOSHADER_PROFILE_GLSL, GL_ARB_vertex_shader); - MUST_HAVE(MOJOSHADER_PROFILE_GLSL, GL_ARB_fragment_shader); - MUST_HAVE(MOJOSHADER_PROFILE_GLSL, GL_ARB_shading_language_100); - } // else if - #endif - - else - { - set_error("unknown or unsupported profile"); - return 0; - } // else - - #undef MUST_HAVE - - return 1; -} // valid_profile - - -static const char *profile_priorities[] = { -#if SUPPORT_PROFILE_GLSL120 - MOJOSHADER_PROFILE_GLSL120, -#endif -#if SUPPORT_PROFILE_GLSL - MOJOSHADER_PROFILE_GLSL, -#endif -#if SUPPORT_PROFILE_ARB1_NV - MOJOSHADER_PROFILE_NV4, - MOJOSHADER_PROFILE_NV3, - MOJOSHADER_PROFILE_NV2, -#endif -#if SUPPORT_PROFILE_ARB1 - MOJOSHADER_PROFILE_ARB1, -#endif -}; - -int MOJOSHADER_glAvailableProfiles(MOJOSHADER_glGetProcAddress lookup, void *d, - const char **profs, const int size) -{ - int retval = 0; - MOJOSHADER_glContext _ctx; - MOJOSHADER_glContext *current_ctx = ctx; - - ctx = &_ctx; - memset(ctx, '\0', sizeof (MOJOSHADER_glContext)); - load_extensions(lookup, d); - - if (ctx->have_base_opengl) - { - size_t i; - for (i = 0; i < STATICARRAYLEN(profile_priorities); i++) - { - const char *profile = profile_priorities[i]; - if (valid_profile(profile)) - { - if (retval < size) - profs[retval] = profile; - retval++; - } // if - } // for - } // if - - ctx = current_ctx; - return retval; -} // MOJOSHADER_glAvailableProfiles - - -const char *MOJOSHADER_glBestProfile(MOJOSHADER_glGetProcAddress gpa, void *d) -{ - const char *prof[STATICARRAYLEN(profile_priorities)]; - if (MOJOSHADER_glAvailableProfiles(gpa, d, prof, STATICARRAYLEN(prof)) <= 0) - { - set_error("no profiles available"); - return NULL; - } // if - - return prof[0]; // profiles are sorted "best" to "worst." -} // MOJOSHADER_glBestProfile - - -MOJOSHADER_glContext *MOJOSHADER_glCreateContext(const char *profile, - MOJOSHADER_glGetProcAddress lookup, - void *lookup_d, - MOJOSHADER_malloc m, MOJOSHADER_free f, - void *malloc_d) -{ - MOJOSHADER_glContext *retval = NULL; - MOJOSHADER_glContext *current_ctx = ctx; - - ctx = NULL; - - if (m == NULL) m = MOJOSHADER_internal_malloc; - if (f == NULL) f = MOJOSHADER_internal_free; - - ctx = (MOJOSHADER_glContext *) m(sizeof (MOJOSHADER_glContext), malloc_d); - if (ctx == NULL) - { - out_of_memory(); - goto init_fail; - } // if - - memset(ctx, '\0', sizeof (MOJOSHADER_glContext)); - ctx->malloc_fn = m; - ctx->free_fn = f; - ctx->malloc_data = malloc_d; - snprintf(ctx->profile, sizeof (ctx->profile), "%s", profile); - - load_extensions(lookup, lookup_d); - if (!valid_profile(profile)) - goto init_fail; - - MOJOSHADER_glBindProgram(NULL); - - // !!! FIXME: generalize this part. - if (profile == NULL) {} - - // We don't check SUPPORT_PROFILE_GLSL120 here, since valid_profile() does. -#if SUPPORT_PROFILE_GLSL - else if ( (strcmp(profile, MOJOSHADER_PROFILE_GLSL) == 0) || - (strcmp(profile, MOJOSHADER_PROFILE_GLSL120) == 0) ) - { - ctx->profileMaxUniforms = impl_GLSL_MaxUniforms; - ctx->profileCompileShader = impl_GLSL_CompileShader; - ctx->profileDeleteShader = impl_GLSL_DeleteShader; - ctx->profileDeleteProgram = impl_GLSL_DeleteProgram; - ctx->profileGetAttribLocation = impl_GLSL_GetAttribLocation; - ctx->profileGetUniformLocation = impl_GLSL_GetUniformLocation; - ctx->profileGetSamplerLocation = impl_GLSL_GetSamplerLocation; - ctx->profileLinkProgram = impl_GLSL_LinkProgram; - ctx->profileFinalInitProgram = impl_GLSL_FinalInitProgram; - ctx->profileUseProgramObject = impl_GLSL_UseProgramObject; - ctx->profilePushConstantArray = impl_GLSL_PushConstantArray; - ctx->profilePushUniforms = impl_GLSL_PushUniforms; - ctx->profilePushSampler = impl_GLSL_PushSampler; - ctx->profileMustPushConstantArrays = impl_GLSL_MustPushConstantArrays; - ctx->profileMustPushSamplers = impl_GLSL_MustPushSamplers; - } // if -#endif - - // We don't check SUPPORT_PROFILE_ARB1_NV here, since valid_profile() does. -#if SUPPORT_PROFILE_ARB1 - else if ( (strcmp(profile, MOJOSHADER_PROFILE_ARB1) == 0) || - (strcmp(profile, MOJOSHADER_PROFILE_NV2) == 0) || - (strcmp(profile, MOJOSHADER_PROFILE_NV3) == 0) || - (strcmp(profile, MOJOSHADER_PROFILE_NV4) == 0) ) - { - ctx->profileMaxUniforms = impl_ARB1_MaxUniforms; - ctx->profileCompileShader = impl_ARB1_CompileShader; - ctx->profileDeleteShader = impl_ARB1_DeleteShader; - ctx->profileDeleteProgram = impl_ARB1_DeleteProgram; - ctx->profileGetAttribLocation = impl_ARB1_GetAttribLocation; - ctx->profileGetUniformLocation = impl_ARB1_GetUniformLocation; - ctx->profileGetSamplerLocation = impl_ARB1_GetSamplerLocation; - ctx->profileLinkProgram = impl_ARB1_LinkProgram; - ctx->profileFinalInitProgram = impl_ARB1_FinalInitProgram; - ctx->profileUseProgramObject = impl_ARB1_UseProgramObject; - ctx->profilePushConstantArray = impl_ARB1_PushConstantArray; - ctx->profilePushUniforms = impl_ARB1_PushUniforms; - ctx->profilePushSampler = impl_ARB1_PushSampler; - ctx->profileMustPushConstantArrays = impl_ARB1_MustPushConstantArrays; - ctx->profileMustPushSamplers = impl_ARB1_MustPushSamplers; - } // if -#endif - - assert(ctx->profileMaxUniforms != NULL); - assert(ctx->profileCompileShader != NULL); - assert(ctx->profileDeleteShader != NULL); - assert(ctx->profileDeleteProgram != NULL); - assert(ctx->profileMaxUniforms != NULL); - assert(ctx->profileGetAttribLocation != NULL); - assert(ctx->profileGetUniformLocation != NULL); - assert(ctx->profileGetSamplerLocation != NULL); - assert(ctx->profileLinkProgram != NULL); - assert(ctx->profileFinalInitProgram != NULL); - assert(ctx->profileUseProgramObject != NULL); - assert(ctx->profilePushConstantArray != NULL); - assert(ctx->profilePushUniforms != NULL); - assert(ctx->profilePushSampler != NULL); - assert(ctx->profileMustPushConstantArrays != NULL); - assert(ctx->profileMustPushSamplers != NULL); - - retval = ctx; - ctx = current_ctx; - return retval; - -init_fail: - if (ctx != NULL) - f(ctx, malloc_d); - ctx = current_ctx; - return NULL; -} // MOJOSHADER_glCreateContext - - -void MOJOSHADER_glMakeContextCurrent(MOJOSHADER_glContext *_ctx) -{ - ctx = _ctx; -} // MOJOSHADER_glMakeContextCurrent - - -int MOJOSHADER_glMaxUniforms(MOJOSHADER_shaderType shader_type) -{ - return ctx->profileMaxUniforms(shader_type); -} // MOJOSHADER_glMaxUniforms - - -MOJOSHADER_glShader *MOJOSHADER_glCompileShader(const unsigned char *tokenbuf, - const unsigned int bufsize, - const MOJOSHADER_swizzle *swiz, - const unsigned int swizcount) -{ - MOJOSHADER_glShader *retval = NULL; - GLuint shader = 0; - const MOJOSHADER_parseData *pd = MOJOSHADER_parse(ctx->profile, tokenbuf, - bufsize, swiz, swizcount, - ctx->malloc_fn, - ctx->free_fn, - ctx->malloc_data); - if (pd->error_count > 0) - { - // !!! FIXME: put multiple errors in the buffer? Don't use - // !!! FIXME: MOJOSHADER_glGetError() for this? - set_error(pd->errors[0].error); - goto compile_shader_fail; - } // if - - retval = (MOJOSHADER_glShader *) Malloc(sizeof (MOJOSHADER_glShader)); - if (retval == NULL) - goto compile_shader_fail; - - if (!ctx->profileCompileShader(pd, &shader)) - goto compile_shader_fail; - - retval->parseData = pd; - retval->handle = shader; - retval->refcount = 1; - return retval; - -compile_shader_fail: - MOJOSHADER_freeParseData(pd); - Free(retval); - if (shader != 0) - ctx->profileDeleteShader(shader); - return NULL; -} // MOJOSHADER_glCompileShader - - -const MOJOSHADER_parseData *MOJOSHADER_glGetShaderParseData( - MOJOSHADER_glShader *shader) -{ - return (shader != NULL) ? shader->parseData : NULL; -} // MOJOSHADER_glGetShaderParseData - - -static void shader_unref(MOJOSHADER_glShader *shader) -{ - if (shader != NULL) - { - const uint32 refcount = shader->refcount; - if (refcount > 1) - shader->refcount--; - else - { - ctx->profileDeleteShader(shader->handle); - MOJOSHADER_freeParseData(shader->parseData); - Free(shader); - } // else - } // if -} // shader_unref - - -static void program_unref(MOJOSHADER_glProgram *program) -{ - if (program != NULL) - { - const uint32 refcount = program->refcount; - if (refcount > 1) - program->refcount--; - else - { - ctx->profileDeleteProgram(program->handle); - shader_unref(program->vertex); - shader_unref(program->fragment); - Free(program->vs_preshader_regs); - Free(program->ps_preshader_regs); - Free(program->vs_uniforms_float4); - Free(program->vs_uniforms_int4); - Free(program->vs_uniforms_bool); - Free(program->ps_uniforms_float4); - Free(program->ps_uniforms_int4); - Free(program->ps_uniforms_bool); - Free(program->uniforms); - Free(program->attributes); - Free(program); - } // else - } // if -} // program_unref - - -static void fill_constant_array(GLfloat *f, const int base, const int size, - const MOJOSHADER_parseData *pd) -{ - int i; - int filled = 0; - for (i = 0; i < pd->constant_count; i++) - { - const MOJOSHADER_constant *c = &pd->constants[i]; - if (c->type != MOJOSHADER_UNIFORM_FLOAT) - continue; - else if (c->index < base) - continue; - else if (c->index >= (base+size)) - continue; - memcpy(&f[(c->index-base) * 4], &c->value.f, sizeof (c->value.f)); - filled++; - } // for - - assert(filled == size); -} // fill_constant_array - - -static int lookup_uniforms(MOJOSHADER_glProgram *program, - MOJOSHADER_glShader *shader, int *bound) -{ - const MOJOSHADER_parseData *pd = shader->parseData; - const MOJOSHADER_shaderType shader_type = pd->shader_type; - uint32 float4_count = 0; - uint32 int4_count = 0; - uint32 bool_count = 0; - int i; - - for (i = 0; i < pd->uniform_count; i++) - { - const MOJOSHADER_uniform *u = &pd->uniforms[i]; - - if (u->constant) - { - // only do constants once, at link time. These aren't changed ever. - if (ctx->profileMustPushConstantArrays()) - { - const int base = u->index; - const int size = u->array_count; - GLfloat *f = (GLfloat *) alloca(sizeof (GLfloat) * (size * 4)); - fill_constant_array(f, base, size, pd); - if (!(*bound)) - { - ctx->profileUseProgramObject(program); - *bound = 1; - } // if - ctx->profilePushConstantArray(program, u, f); - } // if - } // if - - else - { - const GLint loc = ctx->profileGetUniformLocation(program, shader, i); - if (loc != -1) // -1 means it was optimized out, or failure. - { - const int regcount = u->array_count; - UniformMap *map = &program->uniforms[program->uniform_count]; - map->shader_type = shader_type; - map->uniform = u; - map->location = (GLuint) loc; - program->uniform_count++; - - if (u->type == MOJOSHADER_UNIFORM_FLOAT) - float4_count += regcount ? regcount : 1; - else if (u->type == MOJOSHADER_UNIFORM_INT) - int4_count += regcount ? regcount : 1; - else if (u->type == MOJOSHADER_UNIFORM_BOOL) - bool_count += regcount ? regcount : 1; - else - assert(0 && "Unexpected register type"); - } // if - } // else - } // for - - #define MAKE_ARRAY(typ, gltyp, siz, count) \ - if (count) { \ - const size_t buflen = sizeof (gltyp) * siz * count; \ - gltyp *ptr = (gltyp *) Malloc(buflen); \ - if (ptr == NULL) { \ - return 0; \ - } else if (shader_type == MOJOSHADER_TYPE_VERTEX) { \ - program->vs_uniforms_##typ = ptr; \ - program->vs_uniforms_##typ##_count = count; \ - } else if (shader_type == MOJOSHADER_TYPE_PIXEL) { \ - program->ps_uniforms_##typ = ptr; \ - program->ps_uniforms_##typ##_count = count; \ - } else { \ - assert(0 && "unsupported shader type"); \ - } \ - memset(ptr, '\0', buflen); \ - } - - MAKE_ARRAY(float4, GLfloat, 4, float4_count); - MAKE_ARRAY(int4, GLint, 4, int4_count); - MAKE_ARRAY(bool, GLint, 1, bool_count); - - #undef MAKE_ARRAY - - if (pd->preshader) - { - unsigned int largest = 0; - const MOJOSHADER_symbol *sym = pd->preshader->symbols; - for (i = 0; i < pd->preshader->symbol_count; i++, sym++) - { - const unsigned int val = sym->register_index + sym->register_count; - if (val > largest) - largest = val; - } // for - - if (largest > 0) - { - const size_t len = largest * sizeof (GLfloat) * 4; - GLfloat *buf = (GLfloat *) Malloc(len); - if (buf == NULL) - return 0; - memset(buf, '\0', len); - - if (shader_type == MOJOSHADER_TYPE_VERTEX) - { - program->vs_preshader_reg_count = largest; - program->vs_preshader_regs = buf; - } // if - else if (shader_type == MOJOSHADER_TYPE_PIXEL) - { - program->ps_preshader_reg_count = largest; - program->ps_preshader_regs = buf; - } // else if - } // if - } // if - - return 1; -} // lookup_uniforms - - -static void lookup_samplers(MOJOSHADER_glProgram *program, - MOJOSHADER_glShader *shader, int *bound) -{ - const MOJOSHADER_parseData *pd = shader->parseData; - const MOJOSHADER_sampler *s = pd->samplers; - int i; - - if ((pd->sampler_count == 0) || (!ctx->profileMustPushSamplers())) - return; // nothing to do here, so don't bother binding, etc. - - // Link up the Samplers. These never change after link time, since they - // are meant to be constant texture unit ids and not textures. - - if (!(*bound)) - { - ctx->profileUseProgramObject(program); - *bound = 1; - } // if - - for (i = 0; i < pd->sampler_count; i++) - { - const GLint loc = ctx->profileGetSamplerLocation(program, shader, i); - if (loc >= 0) // maybe the Sampler was optimized out? - ctx->profilePushSampler(loc, s[i].index); - } // for -} // lookup_samplers - - -// Right now, this just decides if we have to toggle pointsize support later. -static void lookup_outputs(MOJOSHADER_glProgram *program, - MOJOSHADER_glShader *shader) -{ - const MOJOSHADER_parseData *pd = shader->parseData; - int i; - - for (i = 0; i < pd->output_count; i++) - { - if (pd->outputs[i].usage == MOJOSHADER_USAGE_POINTSIZE) - { - program->uses_pointsize = 1; - break; - } // if - } // for -} // lookup_outputs - - -static int lookup_attributes(MOJOSHADER_glProgram *program) -{ - int i; - const MOJOSHADER_parseData *pd = program->vertex->parseData; - const MOJOSHADER_attribute *a = pd->attributes; - - for (i = 0; i < pd->attribute_count; i++) - { - const GLint loc = ctx->profileGetAttribLocation(program, i); - if (loc >= 0) // maybe the Attribute was optimized out? - { - AttributeMap *map = &program->attributes[program->attribute_count]; - map->attribute = &a[i]; - map->location = loc; - program->attribute_count++; - - if (((size_t)loc) > STATICARRAYLEN(ctx->want_attr)) - { - assert(0 && "Static array is too small."); // laziness fail. - return 0; - } // if - } // if - } // for - - return 1; -} // lookup_attributes - - -// !!! FIXME: misnamed -// build a list of indexes that need to be overwritten with constant values -// when pushing a uniform array to the GL. -static int build_constants_lists(MOJOSHADER_glProgram *program) -{ - int i; - const int count = program->uniform_count; - for (i = 0; i < count; i++) - { - UniformMap *map = &program->uniforms[i]; - const MOJOSHADER_uniform *u = map->uniform; - const int size = u->array_count; - - assert(!u->constant); - - if (size == 0) - continue; // nothing to see here. - - // only use arrays for 'c' registers. - assert(u->type == MOJOSHADER_UNIFORM_FLOAT); - - // !!! FIXME: deal with this. - } // for - - return 1; -} // build_constants_lists - - -MOJOSHADER_glProgram *MOJOSHADER_glLinkProgram(MOJOSHADER_glShader *vshader, - MOJOSHADER_glShader *pshader) -{ - int bound = 0; - - if ((vshader == NULL) && (pshader == NULL)) - return NULL; - - int numregs = 0; - MOJOSHADER_glProgram *retval = NULL; - const GLuint program = ctx->profileLinkProgram(vshader, pshader); - if (program == 0) - goto link_program_fail; - - retval = (MOJOSHADER_glProgram *) Malloc(sizeof (MOJOSHADER_glProgram)); - if (retval == NULL) - goto link_program_fail; - memset(retval, '\0', sizeof (MOJOSHADER_glProgram)); - - numregs = 0; - if (vshader != NULL) numregs += vshader->parseData->uniform_count; - if (pshader != NULL) numregs += pshader->parseData->uniform_count; - if (numregs > 0) - { - const size_t len = sizeof (UniformMap) * numregs; - retval->uniforms = (UniformMap *) Malloc(len); - if (retval->uniforms == NULL) - goto link_program_fail; - memset(retval->uniforms, '\0', len); - } // if - - retval->handle = program; - retval->vertex = vshader; - retval->fragment = pshader; - retval->generation = ctx->generation - 1; - retval->refcount = 1; - - if (vshader != NULL) - { - if (vshader->parseData->attribute_count > 0) - { - const int count = vshader->parseData->attribute_count; - const size_t len = sizeof (AttributeMap) * count; - retval->attributes = (AttributeMap *) Malloc(len); - if (retval->attributes == NULL) - goto link_program_fail; - - memset(retval->attributes, '\0', len); - if (!lookup_attributes(retval)) - goto link_program_fail; - } // if - - if (!lookup_uniforms(retval, vshader, &bound)) - goto link_program_fail; - lookup_samplers(retval, vshader, &bound); - lookup_outputs(retval, pshader); - vshader->refcount++; - } // if - - if (pshader != NULL) - { - if (!lookup_uniforms(retval, pshader, &bound)) - goto link_program_fail; - lookup_samplers(retval, pshader, &bound); - lookup_outputs(retval, pshader); - pshader->refcount++; - } // if - - if (!build_constants_lists(retval)) - goto link_program_fail; - - if (bound) // reset the old binding. - ctx->profileUseProgramObject(ctx->bound_program); - - ctx->profileFinalInitProgram(retval); - - return retval; - -link_program_fail: - if (retval != NULL) - { - Free(retval->vs_uniforms_float4); - Free(retval->vs_uniforms_int4); - Free(retval->vs_uniforms_bool); - Free(retval->ps_uniforms_float4); - Free(retval->ps_uniforms_int4); - Free(retval->ps_uniforms_bool); - Free(retval->uniforms); - Free(retval->attributes); - Free(retval); - } // if - - if (program != 0) - ctx->profileDeleteProgram(program); - - if (bound) - ctx->profileUseProgramObject(ctx->bound_program); - - return NULL; -} // MOJOSHADER_glLinkProgram - - -static void update_enabled_arrays(void) -{ - int highest_enabled = 0; - int i; - - // Enable/disable vertex arrays to match our needs. - // this happens to work in both ARB1 and GLSL, but if something alien - // shows up, we'll have to split these into profile*() functions. - for (i = 0; i < ctx->max_attrs; i++) - { - const int want = (const int) ctx->want_attr[i]; - const int have = (const int) ctx->have_attr[i]; - if (want != have) - { - if (want) - ctx->glEnableVertexAttribArray(i); - else - ctx->glDisableVertexAttribArray(i); - ctx->have_attr[i] = ctx->want_attr[i]; - } // if - - if (want) - highest_enabled = i + 1; - } // for - - ctx->max_attrs = highest_enabled; // trim unneeded iterations next time. -} // update_enabled_arrays - - -void MOJOSHADER_glBindProgram(MOJOSHADER_glProgram *program) -{ - if (program == ctx->bound_program) - return; // nothing to do. - - if (program != NULL) - program->refcount++; - - memset(ctx->want_attr, '\0', sizeof (ctx->want_attr[0]) * ctx->max_attrs); - - // If no program bound, disable all arrays, in case we're switching to - // fixed function pipeline. Otherwise, we try to minimize state changes - // by toggling just the changed set of needed arrays in ProgramReady(). - if (program == NULL) - update_enabled_arrays(); - - ctx->profileUseProgramObject(program); - program_unref(ctx->bound_program); - ctx->bound_program = program; -} // MOJOSHADER_glBindProgram - - -typedef struct -{ - MOJOSHADER_glShader *vertex; - MOJOSHADER_glShader *fragment; -} BoundShaders; - -static uint32 hash_shaders(const void *sym, void *data) -{ - (void) data; - const BoundShaders *s = (const BoundShaders *) sym; - const uint32 v = (s->vertex) ? (uint32) s->vertex->handle : 0; - const uint32 f = (s->fragment) ? (uint32) s->fragment->handle : 0; - return ((v & 0xFFFF) << 16) | (f & 0xFFFF); -} // hash_shaders - -static int match_shaders(const void *_a, const void *_b, void *data) -{ - (void) data; - const BoundShaders *a = (const BoundShaders *) _a; - const BoundShaders *b = (const BoundShaders *) _b; - - const GLuint av = (a->vertex) ? a->vertex->handle : 0; - const GLuint bv = (b->vertex) ? b->vertex->handle : 0; - if (av != bv) - return 0; - - const GLuint af = (a->fragment) ? a->fragment->handle : 0; - const GLuint bf = (b->fragment) ? b->fragment->handle : 0; - if (af != bf) - return 0; - - return 1; -} // match_shaders - -static void nuke_shaders(const void *key, const void *value, void *data) -{ - (void) data; - Free((void *) key); // this was a BoundShaders struct. - MOJOSHADER_glDeleteProgram((MOJOSHADER_glProgram *) value); -} // nuke_shaders - -void MOJOSHADER_glBindShaders(MOJOSHADER_glShader *v, MOJOSHADER_glShader *p) -{ - if ((v == NULL) && (p == NULL)) - { - MOJOSHADER_glBindProgram(NULL); - return; - } // if - - // !!! FIXME: eventually support GL_EXT_separate_shader_objects. - if (ctx->linker_cache == NULL) - { - ctx->linker_cache = hash_create(NULL, hash_shaders, match_shaders, - nuke_shaders, 0, ctx->malloc_fn, - ctx->free_fn, ctx->malloc_data); - - if (ctx->linker_cache == NULL) - { - out_of_memory(); - return; - } // if - } // if - - MOJOSHADER_glProgram *program = NULL; - BoundShaders shaders; - shaders.vertex = v; - shaders.fragment = p; - - const void *val = NULL; - if (hash_find(ctx->linker_cache, &shaders, &val)) - program = (MOJOSHADER_glProgram *) val; - else - { - program = MOJOSHADER_glLinkProgram(v, p); - if (program == NULL) - return; - - BoundShaders *item = (BoundShaders *) Malloc(sizeof (BoundShaders)); - if (item == NULL) - { - MOJOSHADER_glDeleteProgram(program); - return; - } // if - - memcpy(item, &shaders, sizeof (BoundShaders)); - if (hash_insert(ctx->linker_cache, item, program) != 1) - { - Free(item); - MOJOSHADER_glDeleteProgram(program); - out_of_memory(); - return; - } // if - } // else - - assert(program != NULL); - MOJOSHADER_glBindProgram(program); -} // MOJOSHADER_glBindShaders - - -static inline uint minuint(const uint a, const uint b) -{ - return ((a < b) ? a : b); -} // minuint - - -void MOJOSHADER_glSetVertexShaderUniformF(unsigned int idx, const float *data, - unsigned int vec4n) -{ - const uint maxregs = STATICARRAYLEN(ctx->vs_reg_file_f) / 4; - if (idx < maxregs) - { - assert(sizeof (GLfloat) == sizeof (float)); - const uint cpy = (minuint(maxregs - idx, vec4n) * sizeof (*data)) * 4; - memcpy(ctx->vs_reg_file_f + (idx * 4), data, cpy); - ctx->generation++; - } // if -} // MOJOSHADER_glSetVertexShaderUniformF - - -void MOJOSHADER_glGetVertexShaderUniformF(unsigned int idx, float *data, - unsigned int vec4n) -{ - const uint maxregs = STATICARRAYLEN(ctx->vs_reg_file_f) / 4; - if (idx < maxregs) - { - assert(sizeof (GLfloat) == sizeof (float)); - const uint cpy = (minuint(maxregs - idx, vec4n) * sizeof (*data)) * 4; - memcpy(data, ctx->vs_reg_file_f + (idx * 4), cpy); - } // if -} // MOJOSHADER_glGetVertexShaderUniformF - - -void MOJOSHADER_glSetVertexShaderUniformI(unsigned int idx, const int *data, - unsigned int ivec4n) -{ - const uint maxregs = STATICARRAYLEN(ctx->vs_reg_file_i) / 4; - if (idx < maxregs) - { - assert(sizeof (GLint) == sizeof (int)); - const uint cpy = (minuint(maxregs - idx, ivec4n) * sizeof (*data)) * 4; - memcpy(ctx->vs_reg_file_i + (idx * 4), data, cpy); - ctx->generation++; - } // if -} // MOJOSHADER_glSetVertexShaderUniformI - - -void MOJOSHADER_glGetVertexShaderUniformI(unsigned int idx, int *data, - unsigned int ivec4n) -{ - const uint maxregs = STATICARRAYLEN(ctx->vs_reg_file_i) / 4; - if (idx < maxregs) - { - assert(sizeof (GLint) == sizeof (int)); - const uint cpy = (minuint(maxregs - idx, ivec4n) * sizeof (*data)) * 4; - memcpy(data, ctx->vs_reg_file_i + (idx * 4), cpy); - } // if -} // MOJOSHADER_glGetVertexShaderUniformI - - -void MOJOSHADER_glSetVertexShaderUniformB(unsigned int idx, const int *data, - unsigned int bcount) -{ - const uint maxregs = STATICARRAYLEN(ctx->vs_reg_file_f) / 4; - if (idx < maxregs) - { - uint8 *wptr = ctx->vs_reg_file_b + idx; - uint8 *endptr = wptr + minuint(maxregs - idx, bcount); - while (wptr != endptr) - *(wptr++) = *(data++) ? 1 : 0; - ctx->generation++; - } // if -} // MOJOSHADER_glSetVertexShaderUniformB - - -void MOJOSHADER_glGetVertexShaderUniformB(unsigned int idx, int *data, - unsigned int bcount) -{ - const uint maxregs = STATICARRAYLEN(ctx->vs_reg_file_f) / 4; - if (idx < maxregs) - { - uint8 *rptr = ctx->vs_reg_file_b + idx; - uint8 *endptr = rptr + minuint(maxregs - idx, bcount); - while (rptr != endptr) - *(data++) = (int) *(rptr++); - } // if -} // MOJOSHADER_glGetVertexShaderUniformB - - -void MOJOSHADER_glSetPixelShaderUniformF(unsigned int idx, const float *data, - unsigned int vec4n) -{ - const uint maxregs = STATICARRAYLEN(ctx->ps_reg_file_f) / 4; - if (idx < maxregs) - { - assert(sizeof (GLfloat) == sizeof (float)); - const uint cpy = (minuint(maxregs - idx, vec4n) * sizeof (*data)) * 4; - memcpy(ctx->ps_reg_file_f + (idx * 4), data, cpy); - ctx->generation++; - } // if -} // MOJOSHADER_glSetPixelShaderUniformF - - -void MOJOSHADER_glGetPixelShaderUniformF(unsigned int idx, float *data, - unsigned int vec4n) -{ - const uint maxregs = STATICARRAYLEN(ctx->ps_reg_file_f) / 4; - if (idx < maxregs) - { - assert(sizeof (GLfloat) == sizeof (float)); - const uint cpy = (minuint(maxregs - idx, vec4n) * sizeof (*data)) * 4; - memcpy(data, ctx->ps_reg_file_f + (idx * 4), cpy); - } // if -} // MOJOSHADER_glGetPixelShaderUniformF - - -void MOJOSHADER_glSetPixelShaderUniformI(unsigned int idx, const int *data, - unsigned int ivec4n) -{ - const uint maxregs = STATICARRAYLEN(ctx->ps_reg_file_i) / 4; - if (idx < maxregs) - { - assert(sizeof (GLint) == sizeof (int)); - const uint cpy = (minuint(maxregs - idx, ivec4n) * sizeof (*data)) * 4; - memcpy(ctx->ps_reg_file_i + (idx * 4), data, cpy); - ctx->generation++; - } // if -} // MOJOSHADER_glSetPixelShaderUniformI - - -void MOJOSHADER_glGetPixelShaderUniformI(unsigned int idx, int *data, - unsigned int ivec4n) -{ - const uint maxregs = STATICARRAYLEN(ctx->ps_reg_file_i) / 4; - if (idx < maxregs) - { - assert(sizeof (GLint) == sizeof (int)); - const uint cpy = (minuint(maxregs - idx, ivec4n) * sizeof (*data)) * 4; - memcpy(data, ctx->ps_reg_file_i + (idx * 4), cpy); - } // if -} // MOJOSHADER_glGetPixelShaderUniformI - - -void MOJOSHADER_glSetPixelShaderUniformB(unsigned int idx, const int *data, - unsigned int bcount) -{ - const uint maxregs = STATICARRAYLEN(ctx->ps_reg_file_f) / 4; - if (idx < maxregs) - { - uint8 *wptr = ctx->ps_reg_file_b + idx; - uint8 *endptr = wptr + minuint(maxregs - idx, bcount); - while (wptr != endptr) - *(wptr++) = *(data++) ? 1 : 0; - ctx->generation++; - } // if -} // MOJOSHADER_glSetPixelShaderUniformB - - -void MOJOSHADER_glGetPixelShaderUniformB(unsigned int idx, int *data, - unsigned int bcount) -{ - const uint maxregs = STATICARRAYLEN(ctx->ps_reg_file_f) / 4; - if (idx < maxregs) - { - uint8 *rptr = ctx->ps_reg_file_b + idx; - uint8 *endptr = rptr + minuint(maxregs - idx, bcount); - while (rptr != endptr) - *(data++) = (int) *(rptr++); - } // if -} // MOJOSHADER_glGetPixelShaderUniformB - - -static inline GLenum opengl_attr_type(const MOJOSHADER_attributeType type) -{ - switch (type) - { - case MOJOSHADER_ATTRIBUTE_UNKNOWN: return GL_NONE; // oh well. - case MOJOSHADER_ATTRIBUTE_BYTE: return GL_BYTE; - case MOJOSHADER_ATTRIBUTE_UBYTE: return GL_UNSIGNED_BYTE; - case MOJOSHADER_ATTRIBUTE_SHORT: return GL_SHORT; - case MOJOSHADER_ATTRIBUTE_USHORT: return GL_UNSIGNED_SHORT; - case MOJOSHADER_ATTRIBUTE_INT: return GL_INT; - case MOJOSHADER_ATTRIBUTE_UINT: return GL_UNSIGNED_INT; - case MOJOSHADER_ATTRIBUTE_FLOAT: return GL_FLOAT; - case MOJOSHADER_ATTRIBUTE_DOUBLE: return GL_DOUBLE; - - case MOJOSHADER_ATTRIBUTE_HALF_FLOAT: - if (ctx->have_GL_NV_half_float) - return GL_HALF_FLOAT_NV; - else if (ctx->have_GL_ARB_half_float_vertex) - return GL_HALF_FLOAT; - else if (ctx->have_GL_OES_vertex_half_float) - return GL_HALF_FLOAT; - break; - } // switch - - return GL_NONE; // oh well. Raises a GL error later. -} // opengl_attr_type - - -// !!! FIXME: shouldn't (index) be unsigned? -void MOJOSHADER_glSetVertexAttribute(MOJOSHADER_usage usage, - int index, unsigned int size, - MOJOSHADER_attributeType type, - int normalized, unsigned int stride, - const void *ptr) -{ - if ((ctx->bound_program == NULL) || (ctx->bound_program->vertex == NULL)) - return; - - const GLenum gl_type = opengl_attr_type(type); - const GLboolean norm = (normalized) ? GL_TRUE : GL_FALSE; - const int count = ctx->bound_program->attribute_count; - GLint gl_index = 0; - int i; - - for (i = 0; i < count; i++) - { - const AttributeMap *map = &ctx->bound_program->attributes[i]; - const MOJOSHADER_attribute *a = map->attribute; - - // !!! FIXME: is this array guaranteed to be sorted by usage? - // !!! FIXME: if so, we can break if a->usage > usage. - - if ((a->usage == usage) && (a->index == index)) - { - gl_index = map->location; - break; - } // if - } // for - - if (i == count) - return; // nothing to do, this shader doesn't use this stream. - - // this happens to work in both ARB1 and GLSL, but if something alien - // shows up, we'll have to split these into profile*() functions. - ctx->glVertexAttribPointer(gl_index, size, gl_type, norm, stride, ptr); - - // flag this array as in use, so we can enable it later. - ctx->want_attr[gl_index] = 1; - if (ctx->max_attrs < (gl_index + 1)) - ctx->max_attrs = gl_index + 1; -} // MOJOSHADER_glSetVertexAttribute - - -void MOJOSHADER_glSetVertexPreshaderUniformF(unsigned int idx, - const float *data, - unsigned int vec4n) -{ - MOJOSHADER_glProgram *program = ctx->bound_program; - if (program == NULL) - return; // nothing to do. - - const uint maxregs = program->vs_preshader_reg_count; - if (idx < maxregs) - { - assert(sizeof (GLfloat) == sizeof (float)); - const uint cpy = (minuint(maxregs - idx, vec4n) * sizeof (*data)) * 4; - memcpy(program->vs_preshader_regs + (idx * 4), data, cpy); - program->generation = ctx->generation-1; - } // if -} // MOJOSHADER_glSetVertexPreshaderUniformF - - -void MOJOSHADER_glGetVertexPreshaderUniformF(unsigned int idx, float *data, - unsigned int vec4n) -{ - MOJOSHADER_glProgram *program = ctx->bound_program; - if (program == NULL) - return; // nothing to do. - - const uint maxregs = program->vs_preshader_reg_count; - if (idx < maxregs) - { - assert(sizeof (GLfloat) == sizeof (float)); - const uint cpy = (minuint(maxregs - idx, vec4n) * sizeof (*data)) * 4; - memcpy(data, program->vs_preshader_regs + (idx * 4), cpy); - } // if -} // MOJOSHADER_glGetVertexPreshaderUniformF - - -void MOJOSHADER_glSetPixelPreshaderUniformF(unsigned int idx, - const float *data, - unsigned int vec4n) -{ - MOJOSHADER_glProgram *program = ctx->bound_program; - if (program == NULL) - return; // nothing to do. - - const uint maxregs = program->ps_preshader_reg_count; - if (idx < maxregs) - { - assert(sizeof (GLfloat) == sizeof (float)); - const uint cpy = (minuint(maxregs - idx, vec4n) * sizeof (*data)) * 4; - memcpy(program->ps_preshader_regs + (idx * 4), data, cpy); - program->generation = ctx->generation-1; - } // if -} // MOJOSHADER_glSetPixelPreshaderUniformF - - -void MOJOSHADER_glGetPixelPreshaderUniformF(unsigned int idx, float *data, - unsigned int vec4n) -{ - MOJOSHADER_glProgram *program = ctx->bound_program; - if (program == NULL) - return; // nothing to do. - - const uint maxregs = program->ps_preshader_reg_count; - if (idx < maxregs) - { - assert(sizeof (GLfloat) == sizeof (float)); - const uint cpy = (minuint(maxregs - idx, vec4n) * sizeof (*data)) * 4; - memcpy(data, program->ps_preshader_regs + (idx * 4), cpy); - } // if -} // MOJOSHADER_glGetPixelPreshaderUniformF - - -void MOJOSHADER_glProgramReady(void) -{ - MOJOSHADER_glProgram *program = ctx->bound_program; - - if (program == NULL) - return; // nothing to do. - - // Toggle vertex attribute arrays on/off, based on our needs. - update_enabled_arrays(); - - if (program->uses_pointsize != ctx->pointsize_enabled) - { - if (program->uses_pointsize) - ctx->glEnable(GL_PROGRAM_POINT_SIZE); - else - ctx->glDisable(GL_PROGRAM_POINT_SIZE); - ctx->pointsize_enabled = program->uses_pointsize; - } // if - - // push Uniforms to the program from our register files... - if ((program->uniform_count) && (program->generation != ctx->generation)) - { - // vertex shader uniforms come first in program->uniforms array. - const uint32 count = program->uniform_count; - const GLfloat *srcf = ctx->vs_reg_file_f; - const GLint *srci = ctx->vs_reg_file_i; - const uint8 *srcb = ctx->vs_reg_file_b; - MOJOSHADER_shaderType shader_type = MOJOSHADER_TYPE_VERTEX; - GLfloat *dstf = program->vs_uniforms_float4; - GLint *dsti = program->vs_uniforms_int4; - GLint *dstb = program->vs_uniforms_bool; - const MOJOSHADER_preshader *preshader = NULL; - uint32 i; - - #if SUPPORT_PRESHADERS - int ran_preshader = 0; - if (program->vertex) - { - preshader = program->vertex->parseData->preshader; - if (preshader) - { - MOJOSHADER_runPreshader(preshader, program->vs_preshader_regs, - ctx->vs_reg_file_f); - ran_preshader = 1; - } // if - } // if - - if (program->fragment) - { - preshader = program->fragment->parseData->preshader; - if (preshader) - { - MOJOSHADER_runPreshader(preshader, program->ps_preshader_regs, - ctx->ps_reg_file_f); - ran_preshader = 1; - } // if - } // if - - if (ran_preshader) - ctx->generation++; - #endif - - for (i = 0; i < count; i++) - { - UniformMap *map = &program->uniforms[i]; - const MOJOSHADER_shaderType uniform_shader_type = map->shader_type; - const MOJOSHADER_uniform *u = map->uniform; - const MOJOSHADER_uniformType type = u->type; - const int index = u->index; - const int size = u->array_count ? u->array_count : 1; - - assert(!u->constant); - - // Did we switch from vertex to pixel (to geometry, etc)? - if (shader_type != uniform_shader_type) - { - // we start with vertex, move to pixel, then to geometry, etc. - // The array should always be sorted as such. - if (uniform_shader_type == MOJOSHADER_TYPE_PIXEL) - { - assert(shader_type == MOJOSHADER_TYPE_VERTEX); - srcf = ctx->ps_reg_file_f; - srci = ctx->ps_reg_file_i; - srcb = ctx->ps_reg_file_b; - dstf = program->ps_uniforms_float4; - dsti = program->ps_uniforms_int4; - dstb = program->ps_uniforms_bool; - } // if - else - { - // Should be ordered vertex, then pixel, then geometry. - assert(0 && "Unexpected shader type"); - } // else - - shader_type = uniform_shader_type; - } // if - - if (type == MOJOSHADER_UNIFORM_FLOAT) - { - const size_t count = 4 * size; - const GLfloat *f = &srcf[index * 4]; - memcpy(dstf, f, sizeof (GLfloat) * count); - dstf += count; - } // if - else if (type == MOJOSHADER_UNIFORM_INT) - { - const size_t count = 4 * size; - const GLint *i = &srci[index * 4]; - memcpy(dsti, i, sizeof (GLint) * count); - dsti += count; - } // else if - else if (type == MOJOSHADER_UNIFORM_BOOL) - { - const size_t count = size; - const uint8 *b = &srcb[index]; - size_t i; - for (i = 0; i < count; i++) - dstb[i] = (GLint) b[i]; - dstb += count; - } // else if - - // !!! FIXME: set constants that overlap the array. - } // for - - program->generation = ctx->generation; - - ctx->profilePushUniforms(); - } // if -} // MOJOSHADER_glProgramReady - - -void MOJOSHADER_glDeleteProgram(MOJOSHADER_glProgram *program) -{ - program_unref(program); -} // MOJOSHADER_glDeleteProgram - - -void MOJOSHADER_glDeleteShader(MOJOSHADER_glShader *shader) -{ - // See if this was bound as an unlinked program anywhere... - if (ctx->linker_cache) - { - const void *key = NULL; - void *iter = NULL; - int morekeys = hash_iter_keys(ctx->linker_cache, &key, &iter); - while (morekeys) - { - const BoundShaders *shaders = (const BoundShaders *) key; - // Do this here so we don't confuse the iteration by removing... - morekeys = hash_iter_keys(ctx->linker_cache, &key, &iter); - if ((shaders->vertex == shader) || (shaders->fragment == shader)) - { - // Deletes the linked program, which will unref the shader. - hash_remove(ctx->linker_cache, shaders); - } // if - } // while - } // if - - shader_unref(shader); -} // MOJOSHADER_glDeleteShader - - -void MOJOSHADER_glDestroyContext(MOJOSHADER_glContext *_ctx) -{ - MOJOSHADER_glContext *current_ctx = ctx; - ctx = _ctx; - MOJOSHADER_glBindProgram(NULL); - lookup_entry_points(NULL, NULL); // !!! FIXME: is there a value to this? - if (ctx->linker_cache) - hash_destroy(ctx->linker_cache); - Free(ctx); - ctx = ((current_ctx == _ctx) ? NULL : current_ctx); -} // MOJOSHADER_glDestroyContext - -// end of mojoshader_opengl.c ... - diff --git a/Externals/mojoshader/1067/mojoshader_parser_hlsl.h b/Externals/mojoshader/1067/mojoshader_parser_hlsl.h deleted file mode 100644 index 2e9d2e41..00000000 --- a/Externals/mojoshader/1067/mojoshader_parser_hlsl.h +++ /dev/null @@ -1,4272 +0,0 @@ -/* - * My changes over the original lempar.c from SQLite are encased in - * #if __MOJOSHADER__ blocks. --ryan. - */ -#ifndef __MOJOSHADER__ -#define __MOJOSHADER__ 1 -#endif - -#if !__MOJOSHADER__ -#define LEMON_SUPPORT_TRACING (!defined(NDEBUG)) -#endif - -/* Driver template for the LEMON parser generator. -** The original author(s) of lempar.c disclaim copyright to this source code. -** However, changes made for MojoShader fall under the same license as the -** rest of MojoShader. Please see the file LICENSE.txt in the source's root -** directory. -*/ -/* First off, code is included that follows the "include" declaration -** in the input grammar file. */ -#include <stdio.h> -#line 31 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" - -#ifndef __MOJOSHADER_HLSL_COMPILER__ -#error Do not compile this file directly. -#endif -#line 28 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" -/* Next is all token values, in a form suitable for use by makeheaders. -** This section will be null unless lemon is run with the -m switch. -*/ -/* -** These constants (all generated automatically by the parser generator) -** specify the various kinds of tokens (terminals) that the parser -** understands. -** -** Each symbol here is a terminal symbol in the grammar. -*/ -#define TOKEN_HLSL_COMMA 1 -#define TOKEN_HLSL_ASSIGN 2 -#define TOKEN_HLSL_ADDASSIGN 3 -#define TOKEN_HLSL_SUBASSIGN 4 -#define TOKEN_HLSL_MULASSIGN 5 -#define TOKEN_HLSL_DIVASSIGN 6 -#define TOKEN_HLSL_MODASSIGN 7 -#define TOKEN_HLSL_LSHIFTASSIGN 8 -#define TOKEN_HLSL_RSHIFTASSIGN 9 -#define TOKEN_HLSL_ANDASSIGN 10 -#define TOKEN_HLSL_ORASSIGN 11 -#define TOKEN_HLSL_XORASSIGN 12 -#define TOKEN_HLSL_QUESTION 13 -#define TOKEN_HLSL_OROR 14 -#define TOKEN_HLSL_ANDAND 15 -#define TOKEN_HLSL_OR 16 -#define TOKEN_HLSL_XOR 17 -#define TOKEN_HLSL_AND 18 -#define TOKEN_HLSL_EQL 19 -#define TOKEN_HLSL_NEQ 20 -#define TOKEN_HLSL_LT 21 -#define TOKEN_HLSL_LEQ 22 -#define TOKEN_HLSL_GT 23 -#define TOKEN_HLSL_GEQ 24 -#define TOKEN_HLSL_LSHIFT 25 -#define TOKEN_HLSL_RSHIFT 26 -#define TOKEN_HLSL_PLUS 27 -#define TOKEN_HLSL_MINUS 28 -#define TOKEN_HLSL_STAR 29 -#define TOKEN_HLSL_SLASH 30 -#define TOKEN_HLSL_PERCENT 31 -#define TOKEN_HLSL_TYPECAST 32 -#define TOKEN_HLSL_EXCLAMATION 33 -#define TOKEN_HLSL_COMPLEMENT 34 -#define TOKEN_HLSL_MINUSMINUS 35 -#define TOKEN_HLSL_PLUSPLUS 36 -#define TOKEN_HLSL_DOT 37 -#define TOKEN_HLSL_LBRACKET 38 -#define TOKEN_HLSL_RBRACKET 39 -#define TOKEN_HLSL_LPAREN 40 -#define TOKEN_HLSL_RPAREN 41 -#define TOKEN_HLSL_ELSE 42 -#define TOKEN_HLSL_SEMICOLON 43 -#define TOKEN_HLSL_TYPEDEF 44 -#define TOKEN_HLSL_CONST 45 -#define TOKEN_HLSL_IDENTIFIER 46 -#define TOKEN_HLSL_VOID 47 -#define TOKEN_HLSL_INLINE 48 -#define TOKEN_HLSL_IN 49 -#define TOKEN_HLSL_INOUT 50 -#define TOKEN_HLSL_OUT 51 -#define TOKEN_HLSL_UNIFORM 52 -#define TOKEN_HLSL_COLON 53 -#define TOKEN_HLSL_LINEAR 54 -#define TOKEN_HLSL_CENTROID 55 -#define TOKEN_HLSL_NOINTERPOLATION 56 -#define TOKEN_HLSL_NOPERSPECTIVE 57 -#define TOKEN_HLSL_SAMPLE 58 -#define TOKEN_HLSL_EXTERN 59 -#define TOKEN_HLSL_SHARED 60 -#define TOKEN_HLSL_STATIC 61 -#define TOKEN_HLSL_VOLATILE 62 -#define TOKEN_HLSL_ROWMAJOR 63 -#define TOKEN_HLSL_COLUMNMAJOR 64 -#define TOKEN_HLSL_LBRACE 65 -#define TOKEN_HLSL_RBRACE 66 -#define TOKEN_HLSL_STRUCT 67 -#define TOKEN_HLSL_PACKOFFSET 68 -#define TOKEN_HLSL_REGISTER 69 -#define TOKEN_HLSL_USERTYPE 70 -#define TOKEN_HLSL_SAMPLER 71 -#define TOKEN_HLSL_SAMPLER1D 72 -#define TOKEN_HLSL_SAMPLER2D 73 -#define TOKEN_HLSL_SAMPLER3D 74 -#define TOKEN_HLSL_SAMPLERCUBE 75 -#define TOKEN_HLSL_SAMPLER_STATE 76 -#define TOKEN_HLSL_SAMPLERSTATE 77 -#define TOKEN_HLSL_SAMPLERCOMPARISONSTATE 78 -#define TOKEN_HLSL_BOOL 79 -#define TOKEN_HLSL_INT 80 -#define TOKEN_HLSL_UINT 81 -#define TOKEN_HLSL_HALF 82 -#define TOKEN_HLSL_FLOAT 83 -#define TOKEN_HLSL_DOUBLE 84 -#define TOKEN_HLSL_STRING 85 -#define TOKEN_HLSL_SNORM 86 -#define TOKEN_HLSL_UNORM 87 -#define TOKEN_HLSL_BUFFER 88 -#define TOKEN_HLSL_VECTOR 89 -#define TOKEN_HLSL_INT_CONSTANT 90 -#define TOKEN_HLSL_MATRIX 91 -#define TOKEN_HLSL_ISOLATE 92 -#define TOKEN_HLSL_MAXINSTRUCTIONCOUNT 93 -#define TOKEN_HLSL_NOEXPRESSIONOPTIMIZATIONS 94 -#define TOKEN_HLSL_REMOVEUNUSEDINPUTS 95 -#define TOKEN_HLSL_UNUSED 96 -#define TOKEN_HLSL_XPS 97 -#define TOKEN_HLSL_BREAK 98 -#define TOKEN_HLSL_CONTINUE 99 -#define TOKEN_HLSL_DISCARD 100 -#define TOKEN_HLSL_DO 101 -#define TOKEN_HLSL_WHILE 102 -#define TOKEN_HLSL_RETURN 103 -#define TOKEN_HLSL_UNROLL 104 -#define TOKEN_HLSL_LOOP 105 -#define TOKEN_HLSL_FOR 106 -#define TOKEN_HLSL_BRANCH 107 -#define TOKEN_HLSL_IF 108 -#define TOKEN_HLSL_FLATTEN 109 -#define TOKEN_HLSL_IFALL 110 -#define TOKEN_HLSL_IFANY 111 -#define TOKEN_HLSL_PREDICATE 112 -#define TOKEN_HLSL_PREDICATEBLOCK 113 -#define TOKEN_HLSL_SWITCH 114 -#define TOKEN_HLSL_FORCECASE 115 -#define TOKEN_HLSL_CALL 116 -#define TOKEN_HLSL_CASE 117 -#define TOKEN_HLSL_DEFAULT 118 -#define TOKEN_HLSL_FLOAT_CONSTANT 119 -#define TOKEN_HLSL_STRING_LITERAL 120 -#define TOKEN_HLSL_TRUE 121 -#define TOKEN_HLSL_FALSE 122 -/* Make sure the INTERFACE macro is defined. -*/ -#ifndef INTERFACE -# define INTERFACE 1 -#endif -/* The next thing included is series of defines which control -** various aspects of the generated parser. -** YYCODETYPE is the data type used for storing terminal -** and nonterminal numbers. "unsigned char" is -** used if there are fewer than 250 terminals -** and nonterminals. "int" is used otherwise. -** YYNOCODE is a number of type YYCODETYPE which corresponds -** to no legal terminal or nonterminal number. This -** number is used to fill in empty slots of the hash -** table. -** YYFALLBACK If defined, this indicates that one or more tokens -** have fall-back values which should be used if the -** original value of the token will not parse. -** YYACTIONTYPE is the data type used for storing terminal -** and nonterminal numbers. "unsigned char" is -** used if there are fewer than 250 rules and -** states combined. "int" is used otherwise. -** ParseHLSLTOKENTYPE is the data type used for minor tokens given -** directly to the parser from the tokenizer. -** YYMINORTYPE is the data type used for all minor tokens. -** This is typically a union of many types, one of -** which is ParseHLSLTOKENTYPE. The entry in the union -** for base tokens is called "yy0". -** YYSTACKDEPTH is the maximum depth of the parser's stack. If -** zero the stack is dynamically sized using realloc() -** ParseHLSLARG_SDECL A static variable declaration for the %extra_argument -** ParseHLSLARG_PDECL A parameter declaration for the %extra_argument -** ParseHLSLARG_STORE Code to store %extra_argument into yypParser -** ParseHLSLARG_FETCH Code to extract %extra_argument from yypParser -** YYNSTATE the combined number of states. -** YYNRULE the number of rules in the grammar -** YYERRORSYMBOL is the code number of the error symbol. If not -** defined, then do no error processing. -*/ -#define YYCODETYPE unsigned char -#define YYNOCODE 198 -#define YYACTIONTYPE unsigned short int -#define ParseHLSLTOKENTYPE TokenData -typedef union { - int yyinit; - ParseHLSLTOKENTYPE yy0; - MOJOSHADER_astPackOffset * yy8; - MOJOSHADER_astVariableDeclaration * yy24; - MOJOSHADER_astArguments * yy26; - const MOJOSHADER_astDataType * yy37; - MOJOSHADER_astTypedef * yy71; - MOJOSHADER_astInputModifier yy75; - MOJOSHADER_astVariableLowLevel * yy82; - MOJOSHADER_astInterpolationModifier yy111; - MOJOSHADER_astCompilationUnit * yy139; - MOJOSHADER_astSwitchCases * yy165; - MOJOSHADER_astFunctionStorageClass yy175; - MOJOSHADER_astStatement * yy233; - MOJOSHADER_astStructDeclaration * yy249; - MOJOSHADER_astAnnotations * yy268; - int yy270; - const char * yy306; - MOJOSHADER_astFunctionParameters * yy307; - MOJOSHADER_astExpression * yy322; - MOJOSHADER_astStructMembers * yy346; - MOJOSHADER_astFunctionSignature * yy364; - MOJOSHADER_astScalarOrArray * yy380; -} YYMINORTYPE; -#ifndef YYSTACKDEPTH -#define YYSTACKDEPTH 100 -#endif -#define ParseHLSLARG_SDECL Context *ctx ; -#define ParseHLSLARG_PDECL , Context *ctx -#define ParseHLSLARG_FETCH Context *ctx = yypParser->ctx -#define ParseHLSLARG_STORE yypParser->ctx = ctx -#define YYNSTATE 525 -#define YYNRULE 288 -#define YY_NO_ACTION (YYNSTATE+YYNRULE+2) -#define YY_ACCEPT_ACTION (YYNSTATE+YYNRULE+1) -#define YY_ERROR_ACTION (YYNSTATE+YYNRULE) - -/* The yyzerominor constant is used to initialize instances of -** YYMINORTYPE objects to zero. */ -static const YYMINORTYPE yyzerominor = { 0 }; - -/* Define the yytestcase() macro to be a no-op if is not already defined -** otherwise. -** -** Applications can choose to define yytestcase() in the %include section -** to a macro that can assist in verifying code coverage. For production -** code the yytestcase() macro should be turned off. But it is useful -** for testing. -*/ -#ifndef yytestcase -# define yytestcase(X) -#endif - - -/* Next are the tables used to determine what action to take based on the -** current state and lookahead token. These tables are used to implement -** functions that take a state number and lookahead value and return an -** action integer. -** -** Suppose the action integer is N. Then the action is determined as -** follows -** -** 0 <= N < YYNSTATE Shift N. That is, push the lookahead -** token onto the stack and goto state N. -** -** YYNSTATE <= N < YYNSTATE+YYNRULE Reduce by rule N-YYNSTATE. -** -** N == YYNSTATE+YYNRULE A syntax error has occurred. -** -** N == YYNSTATE+YYNRULE+1 The parser accepts its input. -** -** N == YYNSTATE+YYNRULE+2 No such action. Denotes unused -** slots in the yy_action[] table. -** -** The action table is constructed as a single large table named yy_action[]. -** Given state S and lookahead X, the action is computed as -** -** yy_action[ yy_shift_ofst[S] + X ] -** -** If the index value yy_shift_ofst[S]+X is out of range or if the value -** yy_lookahead[yy_shift_ofst[S]+X] is not equal to X or if yy_shift_ofst[S] -** is equal to YY_SHIFT_USE_DFLT, it means that the action is not in the table -** and that yy_default[S] should be used instead. -** -** The formula above is for computing the action when the lookahead is -** a terminal symbol. If the lookahead is a non-terminal (as occurs after -** a reduce action) then the yy_reduce_ofst[] array is used in place of -** the yy_shift_ofst[] array and YY_REDUCE_USE_DFLT is used in place of -** YY_SHIFT_USE_DFLT. -** -** The following are the tables generated in this section: -** -** yy_action[] A single table containing all actions. -** yy_lookahead[] A table containing the lookahead for each entry in -** yy_action. Used to detect hash collisions. -** yy_shift_ofst[] For each state, the offset into yy_action for -** shifting terminals. -** yy_reduce_ofst[] For each state, the offset into yy_action for -** shifting non-terminals after a reduce. -** yy_default[] Default action for each state. -*/ -#define YY_ACTTAB_COUNT (5407) -static const YYACTIONTYPE yy_action[] = { - /* 0 */ 86, 85, 446, 447, 264, 46, 83, 84, 90, 91, - /* 10 */ 39, 123, 88, 47, 27, 114, 344, 97, 405, 143, - /* 20 */ 104, 422, 82, 81, 80, 407, 348, 140, 139, 410, - /* 30 */ 78, 77, 411, 409, 408, 406, 404, 403, 1, 383, - /* 40 */ 249, 495, 60, 511, 510, 509, 508, 507, 506, 505, - /* 50 */ 504, 503, 502, 501, 500, 499, 498, 497, 496, 295, - /* 60 */ 294, 293, 282, 482, 278, 250, 398, 397, 396, 395, - /* 70 */ 394, 248, 247, 246, 334, 338, 37, 40, 214, 336, - /* 80 */ 518, 333, 74, 72, 73, 71, 39, 332, 494, 100, - /* 90 */ 86, 85, 481, 480, 479, 478, 83, 84, 90, 91, - /* 100 */ 186, 123, 413, 47, 27, 115, 344, 97, 405, 143, - /* 110 */ 362, 429, 70, 69, 432, 407, 361, 140, 139, 410, - /* 120 */ 140, 139, 411, 409, 408, 406, 404, 403, 1, 384, - /* 130 */ 249, 76, 75, 511, 510, 509, 508, 507, 506, 505, - /* 140 */ 504, 503, 502, 501, 500, 499, 498, 497, 496, 295, - /* 150 */ 294, 293, 282, 482, 278, 146, 398, 397, 396, 395, - /* 160 */ 394, 248, 247, 246, 334, 338, 37, 369, 371, 336, - /* 170 */ 119, 333, 370, 366, 368, 132, 310, 332, 367, 100, - /* 180 */ 86, 85, 481, 480, 479, 478, 83, 84, 90, 91, - /* 190 */ 180, 123, 413, 47, 113, 423, 344, 97, 405, 143, - /* 200 */ 416, 140, 139, 493, 417, 407, 140, 139, 100, 410, - /* 210 */ 140, 139, 411, 409, 408, 406, 404, 403, 1, 181, - /* 220 */ 249, 413, 60, 511, 510, 509, 508, 507, 506, 505, - /* 230 */ 504, 503, 502, 501, 500, 499, 498, 497, 496, 295, - /* 240 */ 294, 293, 282, 482, 278, 63, 436, 117, 418, 138, - /* 250 */ 492, 248, 247, 246, 334, 338, 37, 415, 122, 336, - /* 260 */ 121, 333, 477, 140, 139, 62, 63, 332, 263, 259, - /* 270 */ 86, 85, 481, 480, 479, 478, 83, 84, 90, 91, - /* 280 */ 391, 261, 24, 47, 61, 434, 33, 515, 405, 143, - /* 290 */ 512, 517, 516, 514, 513, 407, 363, 365, 100, 410, - /* 300 */ 438, 364, 411, 409, 408, 406, 404, 403, 48, 181, - /* 310 */ 249, 413, 60, 511, 510, 509, 508, 507, 506, 505, - /* 320 */ 504, 503, 502, 501, 500, 499, 498, 497, 496, 295, - /* 330 */ 294, 293, 282, 482, 278, 263, 259, 352, 118, 340, - /* 340 */ 345, 109, 102, 130, 306, 122, 474, 428, 443, 122, - /* 350 */ 475, 152, 241, 94, 360, 399, 491, 421, 400, 252, - /* 360 */ 359, 296, 481, 480, 479, 478, 170, 24, 60, 515, - /* 370 */ 38, 79, 512, 517, 516, 514, 513, 18, 346, 60, - /* 380 */ 223, 219, 218, 216, 251, 339, 135, 402, 60, 476, - /* 390 */ 150, 401, 60, 450, 145, 467, 157, 199, 198, 149, - /* 400 */ 191, 272, 271, 269, 267, 189, 462, 352, 220, 340, - /* 410 */ 345, 109, 102, 502, 501, 500, 499, 498, 497, 496, - /* 420 */ 295, 294, 60, 94, 100, 399, 390, 522, 21, 252, - /* 430 */ 490, 3, 426, 489, 343, 38, 170, 437, 60, 515, - /* 440 */ 60, 296, 512, 517, 516, 514, 513, 5, 346, 1, - /* 450 */ 223, 219, 218, 216, 318, 339, 135, 296, 27, 476, - /* 460 */ 150, 27, 20, 450, 145, 467, 157, 199, 198, 149, - /* 470 */ 191, 272, 271, 269, 267, 189, 462, 105, 215, 285, - /* 480 */ 105, 352, 341, 340, 345, 109, 102, 502, 501, 500, - /* 490 */ 499, 498, 497, 496, 295, 294, 101, 94, 488, 399, - /* 500 */ 126, 487, 112, 252, 320, 40, 214, 103, 414, 184, - /* 510 */ 170, 283, 154, 515, 140, 139, 512, 517, 516, 514, - /* 520 */ 513, 4, 346, 486, 223, 219, 218, 216, 60, 339, - /* 530 */ 135, 60, 213, 476, 150, 134, 125, 450, 145, 467, - /* 540 */ 157, 199, 198, 149, 191, 272, 271, 269, 267, 189, - /* 550 */ 462, 352, 137, 340, 345, 109, 102, 280, 60, 515, - /* 560 */ 60, 60, 512, 517, 516, 514, 513, 94, 485, 399, - /* 570 */ 36, 17, 179, 252, 292, 291, 290, 289, 288, 287, - /* 580 */ 170, 286, 284, 515, 60, 124, 512, 517, 516, 514, - /* 590 */ 513, 60, 222, 60, 223, 219, 218, 216, 14, 339, - /* 600 */ 135, 12, 31, 476, 150, 144, 60, 450, 145, 467, - /* 610 */ 157, 199, 198, 149, 191, 272, 271, 269, 267, 189, - /* 620 */ 462, 27, 133, 312, 279, 352, 35, 340, 345, 109, - /* 630 */ 102, 10, 515, 9, 276, 512, 517, 516, 514, 513, - /* 640 */ 60, 94, 275, 399, 131, 308, 274, 252, 29, 420, - /* 650 */ 138, 273, 484, 68, 170, 67, 65, 515, 64, 448, - /* 660 */ 512, 517, 516, 514, 513, 262, 350, 185, 223, 219, - /* 670 */ 218, 216, 184, 339, 135, 209, 260, 476, 150, 259, - /* 680 */ 6, 450, 145, 467, 157, 199, 198, 149, 191, 272, - /* 690 */ 271, 269, 267, 189, 462, 352, 435, 340, 345, 109, - /* 700 */ 102, 258, 515, 257, 433, 512, 517, 516, 514, 513, - /* 710 */ 60, 94, 263, 399, 419, 89, 389, 252, 436, 385, - /* 720 */ 381, 380, 379, 244, 170, 377, 243, 515, 136, 239, - /* 730 */ 512, 517, 516, 514, 513, 153, 217, 240, 223, 219, - /* 740 */ 218, 216, 151, 339, 135, 177, 176, 476, 150, 141, - /* 750 */ 234, 450, 145, 467, 157, 199, 198, 149, 191, 272, - /* 760 */ 271, 269, 267, 189, 462, 232, 358, 357, 230, 352, - /* 770 */ 356, 340, 345, 109, 102, 228, 515, 355, 226, 512, - /* 780 */ 517, 516, 514, 513, 224, 94, 22, 399, 354, 353, - /* 790 */ 44, 252, 221, 43, 351, 42, 19, 41, 170, 120, - /* 800 */ 2, 515, 212, 88, 512, 517, 516, 514, 513, 316, - /* 810 */ 349, 93, 223, 219, 218, 216, 107, 339, 135, 106, - /* 820 */ 305, 476, 150, 303, 204, 450, 145, 467, 157, 199, - /* 830 */ 198, 149, 191, 272, 271, 269, 267, 189, 462, 352, - /* 840 */ 87, 340, 345, 109, 102, 300, 520, 296, 483, 38, - /* 850 */ 439, 256, 431, 430, 27, 94, 255, 399, 253, 388, - /* 860 */ 250, 252, 474, 337, 372, 23, 317, 1, 170, 313, - /* 870 */ 311, 515, 521, 309, 512, 517, 516, 514, 513, 307, - /* 880 */ 382, 281, 223, 219, 218, 216, 347, 339, 135, 242, - /* 890 */ 184, 476, 150, 158, 299, 450, 145, 467, 157, 199, - /* 900 */ 198, 149, 191, 272, 271, 269, 267, 189, 462, 815, - /* 910 */ 815, 277, 815, 352, 815, 340, 345, 109, 102, 815, - /* 920 */ 815, 815, 815, 815, 815, 815, 815, 815, 815, 94, - /* 930 */ 815, 399, 815, 815, 815, 252, 815, 815, 815, 815, - /* 940 */ 815, 815, 170, 815, 815, 515, 815, 815, 512, 517, - /* 950 */ 516, 514, 513, 815, 335, 815, 223, 219, 218, 216, - /* 960 */ 815, 339, 135, 815, 815, 476, 150, 815, 815, 450, - /* 970 */ 145, 467, 157, 199, 198, 149, 191, 272, 271, 269, - /* 980 */ 267, 189, 462, 352, 815, 340, 345, 109, 102, 815, - /* 990 */ 815, 815, 815, 815, 815, 815, 815, 815, 815, 94, - /* 1000 */ 815, 399, 815, 815, 815, 252, 815, 815, 815, 815, - /* 1010 */ 815, 815, 170, 815, 815, 515, 815, 815, 512, 517, - /* 1020 */ 516, 514, 513, 815, 331, 815, 223, 219, 218, 216, - /* 1030 */ 815, 339, 135, 815, 815, 476, 150, 815, 815, 450, - /* 1040 */ 145, 467, 157, 199, 198, 149, 191, 272, 271, 269, - /* 1050 */ 267, 189, 462, 815, 815, 815, 815, 352, 815, 340, - /* 1060 */ 345, 109, 102, 815, 815, 815, 815, 815, 815, 815, - /* 1070 */ 815, 815, 815, 94, 815, 399, 815, 815, 815, 252, - /* 1080 */ 815, 815, 815, 815, 815, 815, 170, 815, 815, 515, - /* 1090 */ 815, 815, 512, 517, 516, 514, 513, 815, 330, 815, - /* 1100 */ 223, 219, 218, 216, 815, 339, 135, 815, 815, 476, - /* 1110 */ 150, 815, 815, 450, 145, 467, 157, 199, 198, 149, - /* 1120 */ 191, 272, 271, 269, 267, 189, 462, 352, 815, 340, - /* 1130 */ 345, 109, 102, 815, 815, 815, 815, 815, 815, 815, - /* 1140 */ 815, 815, 815, 94, 815, 399, 815, 815, 815, 252, - /* 1150 */ 815, 815, 815, 815, 815, 815, 170, 815, 815, 515, - /* 1160 */ 815, 815, 512, 517, 516, 514, 513, 815, 329, 815, - /* 1170 */ 223, 219, 218, 216, 815, 339, 135, 815, 815, 476, - /* 1180 */ 150, 815, 815, 450, 145, 467, 157, 199, 198, 149, - /* 1190 */ 191, 272, 271, 269, 267, 189, 462, 815, 815, 815, - /* 1200 */ 815, 352, 815, 340, 345, 109, 102, 815, 815, 815, - /* 1210 */ 815, 815, 815, 815, 815, 815, 815, 94, 815, 399, - /* 1220 */ 815, 815, 815, 252, 815, 815, 815, 815, 815, 815, - /* 1230 */ 170, 815, 815, 515, 815, 815, 512, 517, 516, 514, - /* 1240 */ 513, 815, 328, 815, 223, 219, 218, 216, 815, 339, - /* 1250 */ 135, 815, 815, 476, 150, 815, 815, 450, 145, 467, - /* 1260 */ 157, 199, 198, 149, 191, 272, 271, 269, 267, 189, - /* 1270 */ 462, 352, 815, 340, 345, 109, 102, 815, 815, 815, - /* 1280 */ 815, 815, 815, 815, 815, 815, 815, 94, 815, 399, - /* 1290 */ 815, 815, 815, 252, 815, 815, 815, 815, 815, 815, - /* 1300 */ 170, 815, 815, 515, 815, 815, 512, 517, 516, 514, - /* 1310 */ 513, 815, 327, 815, 223, 219, 218, 216, 815, 339, - /* 1320 */ 135, 815, 815, 476, 150, 815, 815, 450, 145, 467, - /* 1330 */ 157, 199, 198, 149, 191, 272, 271, 269, 267, 189, - /* 1340 */ 462, 815, 815, 815, 815, 352, 815, 340, 345, 109, - /* 1350 */ 102, 815, 815, 815, 815, 815, 815, 815, 815, 815, - /* 1360 */ 815, 94, 815, 399, 815, 815, 815, 252, 815, 815, - /* 1370 */ 815, 815, 815, 815, 170, 815, 815, 515, 815, 815, - /* 1380 */ 512, 517, 516, 514, 513, 815, 326, 815, 223, 219, - /* 1390 */ 218, 216, 815, 339, 135, 815, 815, 476, 150, 815, - /* 1400 */ 815, 450, 145, 467, 157, 199, 198, 149, 191, 272, - /* 1410 */ 271, 269, 267, 189, 462, 352, 815, 340, 345, 109, - /* 1420 */ 102, 815, 815, 815, 815, 815, 815, 815, 815, 815, - /* 1430 */ 815, 94, 815, 399, 815, 815, 815, 252, 815, 815, - /* 1440 */ 815, 815, 815, 815, 170, 815, 815, 515, 815, 815, - /* 1450 */ 512, 517, 516, 514, 513, 815, 325, 815, 223, 219, - /* 1460 */ 218, 216, 815, 339, 135, 815, 815, 476, 150, 815, - /* 1470 */ 815, 450, 145, 467, 157, 199, 198, 149, 191, 272, - /* 1480 */ 271, 269, 267, 189, 462, 815, 815, 815, 815, 352, - /* 1490 */ 815, 340, 345, 109, 102, 815, 815, 815, 815, 815, - /* 1500 */ 815, 815, 815, 815, 815, 94, 815, 399, 815, 815, - /* 1510 */ 815, 252, 815, 815, 815, 815, 815, 815, 170, 815, - /* 1520 */ 815, 515, 815, 815, 512, 517, 516, 514, 513, 815, - /* 1530 */ 324, 815, 223, 219, 218, 216, 815, 339, 135, 815, - /* 1540 */ 815, 476, 150, 815, 815, 450, 145, 467, 157, 199, - /* 1550 */ 198, 149, 191, 272, 271, 269, 267, 189, 462, 352, - /* 1560 */ 815, 340, 345, 109, 102, 815, 815, 815, 815, 815, - /* 1570 */ 815, 815, 815, 815, 815, 94, 815, 399, 815, 815, - /* 1580 */ 815, 252, 815, 815, 815, 815, 815, 815, 170, 815, - /* 1590 */ 815, 515, 815, 815, 512, 517, 516, 514, 513, 815, - /* 1600 */ 323, 815, 223, 219, 218, 216, 815, 339, 135, 815, - /* 1610 */ 815, 476, 150, 815, 815, 450, 145, 467, 157, 199, - /* 1620 */ 198, 149, 191, 272, 271, 269, 267, 189, 462, 815, - /* 1630 */ 815, 815, 815, 352, 815, 340, 345, 109, 102, 815, - /* 1640 */ 815, 815, 815, 815, 815, 815, 815, 815, 815, 94, - /* 1650 */ 815, 399, 815, 815, 815, 252, 815, 815, 815, 815, - /* 1660 */ 815, 815, 170, 815, 815, 515, 815, 815, 512, 517, - /* 1670 */ 516, 514, 513, 815, 322, 815, 223, 219, 218, 216, - /* 1680 */ 815, 339, 135, 815, 815, 476, 150, 815, 815, 450, - /* 1690 */ 145, 467, 157, 199, 198, 149, 191, 272, 271, 269, - /* 1700 */ 267, 189, 462, 352, 815, 340, 345, 109, 102, 815, - /* 1710 */ 815, 815, 815, 815, 815, 815, 815, 815, 815, 94, - /* 1720 */ 815, 399, 815, 815, 815, 252, 815, 815, 815, 815, - /* 1730 */ 815, 815, 170, 525, 815, 515, 815, 815, 512, 517, - /* 1740 */ 516, 514, 513, 815, 321, 815, 223, 219, 218, 216, - /* 1750 */ 815, 339, 135, 815, 815, 476, 150, 815, 815, 450, - /* 1760 */ 145, 467, 157, 199, 198, 149, 191, 272, 271, 269, - /* 1770 */ 267, 189, 462, 815, 815, 815, 815, 97, 405, 815, - /* 1780 */ 205, 298, 815, 815, 815, 407, 815, 815, 815, 410, - /* 1790 */ 815, 815, 411, 409, 408, 406, 404, 403, 815, 815, - /* 1800 */ 249, 815, 815, 511, 510, 509, 508, 507, 506, 505, - /* 1810 */ 504, 503, 502, 501, 500, 499, 498, 497, 496, 295, - /* 1820 */ 294, 293, 282, 815, 278, 86, 85, 815, 815, 815, - /* 1830 */ 815, 83, 84, 90, 91, 815, 815, 519, 47, 815, - /* 1840 */ 815, 815, 815, 815, 143, 815, 815, 86, 85, 815, - /* 1850 */ 815, 815, 815, 83, 84, 90, 91, 815, 815, 815, - /* 1860 */ 47, 444, 815, 815, 815, 815, 143, 815, 511, 510, - /* 1870 */ 509, 508, 507, 506, 505, 504, 503, 502, 501, 500, - /* 1880 */ 499, 498, 497, 496, 295, 294, 293, 282, 482, 278, - /* 1890 */ 511, 510, 509, 508, 507, 506, 505, 504, 503, 502, - /* 1900 */ 501, 500, 499, 498, 497, 496, 295, 294, 293, 282, - /* 1910 */ 482, 278, 815, 815, 815, 86, 85, 481, 480, 479, - /* 1920 */ 478, 83, 84, 90, 91, 815, 815, 815, 47, 815, - /* 1930 */ 815, 342, 815, 815, 143, 815, 815, 86, 85, 481, - /* 1940 */ 480, 479, 478, 83, 84, 90, 91, 815, 815, 815, - /* 1950 */ 47, 815, 815, 34, 815, 815, 143, 815, 511, 510, - /* 1960 */ 509, 508, 507, 506, 505, 504, 503, 502, 501, 500, - /* 1970 */ 499, 498, 497, 496, 295, 294, 293, 282, 482, 278, - /* 1980 */ 511, 510, 509, 508, 507, 506, 505, 504, 503, 502, - /* 1990 */ 501, 500, 499, 498, 497, 496, 295, 294, 293, 282, - /* 2000 */ 482, 278, 815, 815, 815, 86, 85, 481, 480, 479, - /* 2010 */ 478, 83, 84, 90, 91, 815, 815, 815, 47, 16, - /* 2020 */ 815, 815, 815, 815, 143, 815, 815, 86, 85, 481, - /* 2030 */ 480, 479, 478, 83, 84, 90, 91, 815, 815, 815, - /* 2040 */ 47, 15, 815, 815, 815, 815, 143, 815, 511, 510, - /* 2050 */ 509, 508, 507, 506, 505, 504, 503, 502, 501, 500, - /* 2060 */ 499, 498, 497, 496, 295, 294, 293, 282, 482, 278, - /* 2070 */ 511, 510, 509, 508, 507, 506, 505, 504, 503, 502, - /* 2080 */ 501, 500, 499, 498, 497, 496, 295, 294, 293, 282, - /* 2090 */ 482, 278, 815, 815, 815, 86, 85, 481, 480, 479, - /* 2100 */ 478, 83, 84, 90, 91, 815, 815, 815, 47, 815, - /* 2110 */ 815, 32, 815, 815, 143, 815, 815, 86, 85, 481, - /* 2120 */ 480, 479, 478, 83, 84, 90, 91, 815, 815, 815, - /* 2130 */ 47, 13, 815, 815, 815, 815, 143, 815, 511, 510, - /* 2140 */ 509, 508, 507, 506, 505, 504, 503, 502, 501, 500, - /* 2150 */ 499, 498, 497, 496, 295, 294, 293, 282, 482, 278, - /* 2160 */ 511, 510, 509, 508, 507, 506, 505, 504, 503, 502, - /* 2170 */ 501, 500, 499, 498, 497, 496, 295, 294, 293, 282, - /* 2180 */ 482, 278, 815, 815, 815, 86, 85, 481, 480, 479, - /* 2190 */ 478, 83, 84, 90, 91, 815, 815, 815, 47, 11, - /* 2200 */ 815, 815, 815, 815, 143, 815, 815, 86, 85, 481, - /* 2210 */ 480, 479, 478, 83, 84, 90, 91, 815, 815, 815, - /* 2220 */ 47, 815, 815, 28, 815, 815, 143, 815, 511, 510, - /* 2230 */ 509, 508, 507, 506, 505, 504, 503, 502, 501, 500, - /* 2240 */ 499, 498, 497, 496, 295, 294, 293, 282, 482, 278, - /* 2250 */ 511, 510, 509, 508, 507, 506, 505, 504, 503, 502, - /* 2260 */ 501, 500, 499, 498, 497, 496, 295, 294, 293, 282, - /* 2270 */ 482, 278, 815, 815, 815, 86, 85, 481, 480, 479, - /* 2280 */ 478, 83, 84, 90, 91, 815, 815, 815, 47, 8, - /* 2290 */ 815, 815, 815, 815, 143, 815, 815, 86, 85, 481, - /* 2300 */ 480, 479, 478, 83, 84, 90, 91, 815, 815, 815, - /* 2310 */ 47, 7, 815, 815, 815, 815, 143, 815, 511, 510, - /* 2320 */ 509, 508, 507, 506, 505, 504, 503, 502, 501, 500, - /* 2330 */ 499, 498, 497, 496, 295, 294, 293, 282, 482, 278, - /* 2340 */ 511, 510, 509, 508, 507, 506, 505, 504, 503, 502, - /* 2350 */ 501, 500, 499, 498, 497, 496, 295, 294, 293, 282, - /* 2360 */ 482, 278, 815, 815, 815, 86, 85, 481, 480, 479, - /* 2370 */ 478, 83, 84, 90, 91, 815, 815, 815, 47, 815, - /* 2380 */ 815, 815, 815, 815, 143, 815, 815, 815, 815, 481, - /* 2390 */ 480, 479, 478, 815, 815, 815, 815, 815, 815, 815, - /* 2400 */ 815, 815, 815, 26, 815, 815, 815, 815, 511, 510, - /* 2410 */ 509, 508, 507, 506, 505, 504, 503, 502, 501, 500, - /* 2420 */ 499, 498, 497, 496, 295, 294, 293, 282, 482, 278, - /* 2430 */ 815, 86, 85, 815, 121, 815, 815, 83, 84, 90, - /* 2440 */ 91, 815, 815, 96, 47, 815, 815, 815, 815, 815, - /* 2450 */ 143, 815, 92, 386, 387, 815, 815, 481, 480, 479, - /* 2460 */ 478, 515, 815, 815, 512, 517, 516, 514, 513, 25, - /* 2470 */ 815, 815, 815, 815, 511, 510, 509, 508, 507, 506, - /* 2480 */ 505, 504, 503, 502, 501, 500, 499, 498, 497, 496, - /* 2490 */ 295, 294, 293, 282, 482, 278, 815, 86, 85, 815, - /* 2500 */ 815, 815, 815, 83, 84, 90, 91, 815, 815, 815, - /* 2510 */ 45, 815, 815, 815, 815, 815, 143, 815, 815, 815, - /* 2520 */ 815, 815, 815, 481, 480, 479, 478, 59, 55, 54, - /* 2530 */ 58, 57, 56, 53, 52, 51, 49, 50, 815, 815, - /* 2540 */ 511, 510, 509, 508, 507, 506, 505, 504, 503, 502, - /* 2550 */ 501, 500, 499, 498, 497, 496, 295, 294, 293, 282, - /* 2560 */ 482, 278, 815, 815, 815, 815, 815, 815, 86, 85, - /* 2570 */ 815, 208, 815, 815, 83, 84, 90, 91, 314, 98, - /* 2580 */ 815, 47, 815, 815, 815, 815, 815, 143, 815, 481, - /* 2590 */ 480, 479, 478, 815, 815, 815, 815, 815, 515, 815, - /* 2600 */ 815, 512, 517, 516, 514, 513, 815, 815, 815, 815, - /* 2610 */ 815, 511, 510, 509, 508, 507, 506, 505, 504, 503, - /* 2620 */ 502, 501, 500, 499, 498, 497, 496, 295, 294, 293, - /* 2630 */ 282, 482, 278, 815, 378, 245, 376, 375, 374, 373, - /* 2640 */ 815, 815, 815, 815, 815, 815, 178, 238, 815, 237, - /* 2650 */ 815, 236, 235, 233, 231, 229, 815, 227, 225, 815, - /* 2660 */ 481, 480, 479, 478, 97, 405, 815, 205, 298, 815, - /* 2670 */ 815, 815, 407, 815, 815, 815, 410, 815, 815, 411, - /* 2680 */ 409, 408, 406, 404, 403, 815, 815, 249, 815, 815, - /* 2690 */ 511, 510, 509, 508, 507, 506, 505, 504, 503, 502, - /* 2700 */ 501, 500, 499, 498, 497, 496, 295, 294, 293, 282, - /* 2710 */ 405, 278, 815, 815, 815, 815, 815, 407, 815, 815, - /* 2720 */ 815, 410, 815, 815, 411, 409, 408, 406, 404, 403, - /* 2730 */ 815, 815, 815, 815, 815, 511, 510, 509, 508, 507, - /* 2740 */ 506, 505, 504, 503, 502, 501, 500, 499, 498, 497, - /* 2750 */ 496, 295, 294, 293, 282, 30, 278, 815, 815, 111, - /* 2760 */ 102, 815, 815, 815, 815, 815, 815, 815, 815, 121, - /* 2770 */ 815, 94, 815, 399, 815, 815, 815, 252, 96, 815, - /* 2780 */ 815, 815, 815, 815, 168, 815, 815, 515, 392, 387, - /* 2790 */ 512, 517, 516, 514, 513, 815, 515, 815, 815, 512, - /* 2800 */ 517, 516, 514, 513, 815, 815, 815, 476, 150, 815, - /* 2810 */ 815, 450, 145, 467, 157, 199, 198, 149, 191, 272, - /* 2820 */ 271, 269, 267, 189, 462, 815, 398, 397, 396, 395, - /* 2830 */ 394, 815, 815, 815, 815, 815, 815, 815, 393, 815, - /* 2840 */ 815, 815, 511, 510, 509, 508, 507, 506, 505, 504, - /* 2850 */ 503, 502, 501, 500, 499, 498, 497, 496, 295, 294, - /* 2860 */ 293, 282, 815, 278, 815, 815, 398, 397, 396, 395, - /* 2870 */ 394, 815, 815, 815, 815, 815, 815, 815, 815, 815, - /* 2880 */ 815, 815, 511, 510, 509, 508, 507, 506, 505, 504, - /* 2890 */ 503, 502, 501, 500, 499, 498, 497, 496, 295, 294, - /* 2900 */ 293, 282, 315, 278, 207, 304, 206, 302, 815, 815, - /* 2910 */ 815, 815, 815, 815, 815, 815, 815, 815, 815, 815, - /* 2920 */ 815, 815, 815, 815, 815, 511, 510, 509, 508, 507, - /* 2930 */ 506, 505, 504, 503, 502, 501, 500, 499, 498, 497, - /* 2940 */ 496, 295, 294, 293, 282, 815, 278, 207, 304, 206, - /* 2950 */ 302, 815, 815, 815, 815, 815, 815, 815, 815, 815, - /* 2960 */ 815, 815, 815, 815, 815, 815, 815, 815, 511, 510, - /* 2970 */ 509, 508, 507, 506, 505, 504, 503, 502, 501, 500, - /* 2980 */ 499, 498, 497, 496, 295, 294, 293, 282, 142, 278, - /* 2990 */ 815, 815, 815, 815, 815, 815, 815, 815, 815, 815, - /* 3000 */ 208, 815, 815, 815, 815, 211, 210, 301, 98, 815, - /* 3010 */ 815, 815, 424, 815, 815, 515, 815, 425, 512, 517, - /* 3020 */ 516, 514, 513, 815, 815, 815, 815, 515, 815, 142, - /* 3030 */ 512, 517, 516, 514, 513, 476, 150, 815, 815, 450, - /* 3040 */ 145, 467, 157, 199, 198, 149, 191, 272, 271, 269, - /* 3050 */ 267, 189, 462, 254, 815, 815, 515, 182, 815, 512, - /* 3060 */ 517, 516, 514, 513, 815, 815, 815, 815, 815, 815, - /* 3070 */ 142, 815, 815, 815, 815, 815, 476, 150, 815, 815, - /* 3080 */ 450, 145, 467, 157, 199, 198, 149, 191, 272, 271, - /* 3090 */ 269, 267, 189, 462, 254, 815, 815, 515, 183, 815, - /* 3100 */ 512, 517, 516, 514, 513, 815, 815, 815, 815, 815, - /* 3110 */ 815, 142, 815, 815, 815, 815, 815, 476, 150, 815, - /* 3120 */ 815, 450, 145, 467, 157, 199, 198, 149, 191, 272, - /* 3130 */ 271, 269, 267, 189, 462, 254, 815, 815, 515, 427, - /* 3140 */ 815, 512, 517, 516, 514, 513, 815, 815, 815, 815, - /* 3150 */ 815, 815, 127, 815, 815, 815, 815, 815, 476, 150, - /* 3160 */ 815, 815, 450, 145, 467, 157, 199, 198, 149, 191, - /* 3170 */ 272, 271, 269, 267, 189, 462, 201, 815, 815, 515, - /* 3180 */ 815, 815, 512, 517, 516, 514, 513, 815, 815, 815, - /* 3190 */ 815, 815, 815, 142, 815, 815, 815, 815, 815, 476, - /* 3200 */ 150, 815, 815, 450, 145, 467, 157, 199, 198, 149, - /* 3210 */ 191, 272, 271, 269, 267, 189, 462, 200, 815, 815, - /* 3220 */ 515, 815, 815, 512, 517, 516, 514, 513, 815, 815, - /* 3230 */ 815, 815, 815, 815, 142, 815, 815, 815, 815, 815, - /* 3240 */ 476, 150, 815, 815, 450, 145, 467, 157, 199, 198, - /* 3250 */ 149, 191, 272, 271, 269, 267, 189, 462, 201, 815, - /* 3260 */ 815, 515, 815, 815, 512, 517, 516, 514, 513, 815, - /* 3270 */ 815, 815, 815, 815, 815, 142, 815, 815, 815, 815, - /* 3280 */ 815, 476, 150, 815, 815, 450, 145, 467, 157, 199, - /* 3290 */ 198, 149, 191, 272, 271, 269, 267, 189, 462, 175, - /* 3300 */ 815, 815, 515, 815, 815, 512, 517, 516, 514, 513, - /* 3310 */ 815, 815, 815, 815, 815, 815, 142, 815, 815, 815, - /* 3320 */ 815, 815, 476, 150, 815, 815, 450, 145, 467, 157, - /* 3330 */ 199, 198, 149, 191, 272, 271, 269, 267, 189, 462, - /* 3340 */ 174, 815, 815, 515, 815, 815, 512, 517, 516, 514, - /* 3350 */ 513, 815, 815, 815, 815, 815, 815, 142, 815, 815, - /* 3360 */ 815, 815, 815, 476, 150, 815, 815, 450, 145, 467, - /* 3370 */ 157, 199, 198, 149, 191, 272, 271, 269, 267, 189, - /* 3380 */ 462, 173, 815, 815, 515, 815, 815, 512, 517, 516, - /* 3390 */ 514, 513, 815, 815, 815, 815, 815, 815, 142, 815, - /* 3400 */ 815, 815, 815, 815, 476, 150, 815, 815, 450, 145, - /* 3410 */ 467, 157, 199, 198, 149, 191, 272, 271, 269, 267, - /* 3420 */ 189, 462, 172, 815, 815, 515, 815, 815, 512, 517, - /* 3430 */ 516, 514, 513, 815, 815, 815, 815, 815, 815, 142, - /* 3440 */ 815, 815, 815, 815, 815, 476, 150, 815, 815, 450, - /* 3450 */ 145, 467, 157, 199, 198, 149, 191, 272, 271, 269, - /* 3460 */ 267, 189, 462, 171, 815, 815, 515, 815, 815, 512, - /* 3470 */ 517, 516, 514, 513, 815, 815, 815, 815, 815, 815, - /* 3480 */ 142, 815, 815, 815, 815, 815, 476, 150, 815, 815, - /* 3490 */ 450, 145, 467, 157, 199, 198, 149, 191, 272, 271, - /* 3500 */ 269, 267, 189, 462, 202, 815, 815, 515, 815, 815, - /* 3510 */ 512, 517, 516, 514, 513, 815, 815, 815, 815, 815, - /* 3520 */ 142, 815, 815, 815, 815, 815, 815, 476, 150, 815, - /* 3530 */ 815, 450, 145, 467, 157, 199, 198, 149, 191, 272, - /* 3540 */ 271, 269, 267, 189, 462, 815, 815, 515, 815, 815, - /* 3550 */ 512, 517, 516, 514, 513, 815, 815, 815, 815, 815, - /* 3560 */ 815, 142, 815, 815, 815, 815, 815, 476, 150, 815, - /* 3570 */ 187, 441, 145, 467, 157, 199, 198, 149, 191, 272, - /* 3580 */ 271, 269, 267, 189, 462, 169, 815, 815, 515, 815, - /* 3590 */ 815, 512, 517, 516, 514, 513, 815, 815, 815, 815, - /* 3600 */ 815, 815, 142, 815, 815, 815, 815, 815, 476, 150, - /* 3610 */ 815, 815, 450, 145, 467, 157, 199, 198, 149, 191, - /* 3620 */ 272, 271, 269, 267, 189, 462, 167, 815, 815, 515, - /* 3630 */ 815, 815, 512, 517, 516, 514, 513, 815, 815, 815, - /* 3640 */ 815, 815, 815, 142, 815, 815, 815, 815, 815, 476, - /* 3650 */ 150, 815, 815, 450, 145, 467, 157, 199, 198, 149, - /* 3660 */ 191, 272, 271, 269, 267, 189, 462, 166, 815, 815, - /* 3670 */ 515, 815, 815, 512, 517, 516, 514, 513, 815, 815, - /* 3680 */ 815, 815, 815, 815, 142, 815, 815, 815, 815, 815, - /* 3690 */ 476, 150, 815, 815, 450, 145, 467, 157, 199, 198, - /* 3700 */ 149, 191, 272, 271, 269, 267, 189, 462, 165, 815, - /* 3710 */ 815, 515, 815, 815, 512, 517, 516, 514, 513, 815, - /* 3720 */ 815, 815, 815, 815, 815, 142, 815, 815, 815, 815, - /* 3730 */ 815, 476, 150, 815, 815, 450, 145, 467, 157, 199, - /* 3740 */ 198, 149, 191, 272, 271, 269, 267, 189, 462, 163, - /* 3750 */ 815, 815, 515, 815, 815, 512, 517, 516, 514, 513, - /* 3760 */ 815, 815, 815, 815, 815, 815, 142, 815, 815, 815, - /* 3770 */ 815, 815, 476, 150, 815, 815, 450, 145, 467, 157, - /* 3780 */ 199, 198, 149, 191, 272, 271, 269, 267, 189, 462, - /* 3790 */ 164, 815, 815, 515, 815, 815, 512, 517, 516, 514, - /* 3800 */ 513, 815, 815, 815, 815, 815, 815, 142, 815, 815, - /* 3810 */ 815, 815, 815, 476, 150, 815, 815, 450, 145, 467, - /* 3820 */ 157, 199, 198, 149, 191, 272, 271, 269, 267, 189, - /* 3830 */ 462, 162, 815, 815, 515, 815, 815, 512, 517, 516, - /* 3840 */ 514, 513, 815, 815, 815, 815, 815, 815, 142, 815, - /* 3850 */ 815, 815, 815, 815, 476, 150, 815, 815, 450, 145, - /* 3860 */ 467, 157, 199, 198, 149, 191, 272, 271, 269, 267, - /* 3870 */ 189, 462, 161, 815, 815, 515, 815, 815, 512, 517, - /* 3880 */ 516, 514, 513, 815, 815, 815, 815, 815, 815, 142, - /* 3890 */ 815, 815, 815, 815, 815, 476, 150, 815, 815, 450, - /* 3900 */ 145, 467, 157, 199, 198, 149, 191, 272, 271, 269, - /* 3910 */ 267, 189, 462, 160, 815, 815, 515, 815, 815, 512, - /* 3920 */ 517, 516, 514, 513, 815, 815, 815, 815, 815, 815, - /* 3930 */ 142, 815, 815, 815, 815, 815, 476, 150, 815, 815, - /* 3940 */ 450, 145, 467, 157, 199, 198, 149, 191, 272, 271, - /* 3950 */ 269, 267, 189, 462, 159, 815, 815, 515, 815, 815, - /* 3960 */ 512, 517, 516, 514, 513, 815, 815, 815, 815, 815, - /* 3970 */ 142, 815, 815, 815, 815, 815, 815, 476, 150, 815, - /* 3980 */ 815, 450, 145, 467, 157, 199, 198, 149, 191, 272, - /* 3990 */ 271, 269, 267, 189, 462, 815, 815, 515, 815, 815, - /* 4000 */ 512, 517, 516, 514, 513, 815, 815, 815, 142, 815, - /* 4010 */ 815, 815, 815, 815, 815, 815, 815, 476, 150, 815, - /* 4020 */ 815, 440, 145, 467, 157, 199, 198, 149, 191, 272, - /* 4030 */ 271, 269, 267, 189, 462, 515, 815, 815, 512, 517, - /* 4040 */ 516, 514, 513, 815, 815, 815, 142, 815, 815, 815, - /* 4050 */ 815, 815, 815, 815, 815, 476, 150, 815, 815, 461, - /* 4060 */ 145, 467, 157, 199, 198, 149, 191, 272, 271, 269, - /* 4070 */ 267, 189, 462, 515, 815, 815, 512, 517, 516, 514, - /* 4080 */ 513, 815, 815, 815, 142, 815, 815, 815, 815, 815, - /* 4090 */ 815, 815, 815, 476, 150, 815, 815, 460, 145, 467, - /* 4100 */ 157, 199, 198, 149, 191, 272, 271, 269, 267, 189, - /* 4110 */ 462, 515, 815, 815, 512, 517, 516, 514, 513, 815, - /* 4120 */ 815, 815, 142, 815, 815, 815, 815, 815, 815, 815, - /* 4130 */ 815, 476, 150, 815, 815, 459, 145, 467, 157, 199, - /* 4140 */ 198, 149, 191, 272, 271, 269, 267, 189, 462, 515, - /* 4150 */ 815, 815, 512, 517, 516, 514, 513, 815, 815, 815, - /* 4160 */ 142, 815, 815, 815, 815, 815, 815, 815, 815, 476, - /* 4170 */ 150, 815, 815, 458, 145, 467, 157, 199, 198, 149, - /* 4180 */ 191, 272, 271, 269, 267, 189, 462, 515, 815, 815, - /* 4190 */ 512, 517, 516, 514, 513, 815, 815, 815, 142, 815, - /* 4200 */ 815, 815, 815, 815, 815, 815, 815, 476, 150, 815, - /* 4210 */ 815, 457, 145, 467, 157, 199, 198, 149, 191, 272, - /* 4220 */ 271, 269, 267, 189, 462, 515, 815, 815, 512, 517, - /* 4230 */ 516, 514, 513, 815, 815, 815, 142, 815, 815, 815, - /* 4240 */ 815, 815, 815, 815, 815, 476, 150, 815, 815, 456, - /* 4250 */ 145, 467, 157, 199, 198, 149, 191, 272, 271, 269, - /* 4260 */ 267, 189, 462, 515, 815, 815, 512, 517, 516, 514, - /* 4270 */ 513, 815, 815, 815, 142, 815, 815, 815, 815, 815, - /* 4280 */ 815, 815, 815, 476, 150, 815, 815, 455, 145, 467, - /* 4290 */ 157, 199, 198, 149, 191, 272, 271, 269, 267, 189, - /* 4300 */ 462, 515, 815, 815, 512, 517, 516, 514, 513, 815, - /* 4310 */ 815, 815, 142, 815, 815, 815, 815, 815, 815, 815, - /* 4320 */ 815, 476, 150, 815, 815, 454, 145, 467, 157, 199, - /* 4330 */ 198, 149, 191, 272, 271, 269, 267, 189, 462, 515, - /* 4340 */ 815, 815, 512, 517, 516, 514, 513, 815, 815, 815, - /* 4350 */ 142, 815, 815, 815, 815, 815, 815, 815, 815, 476, - /* 4360 */ 150, 815, 815, 453, 145, 467, 157, 199, 198, 149, - /* 4370 */ 191, 272, 271, 269, 267, 189, 462, 515, 815, 815, - /* 4380 */ 512, 517, 516, 514, 513, 815, 815, 815, 142, 815, - /* 4390 */ 815, 815, 815, 815, 815, 815, 815, 476, 150, 815, - /* 4400 */ 815, 452, 145, 467, 157, 199, 198, 149, 191, 272, - /* 4410 */ 271, 269, 267, 189, 462, 515, 815, 815, 512, 517, - /* 4420 */ 516, 514, 513, 815, 815, 815, 142, 815, 815, 815, - /* 4430 */ 815, 815, 815, 815, 815, 476, 150, 815, 815, 451, - /* 4440 */ 145, 467, 157, 199, 198, 149, 191, 272, 271, 269, - /* 4450 */ 267, 189, 462, 515, 815, 815, 512, 517, 516, 514, - /* 4460 */ 513, 815, 815, 815, 815, 815, 99, 815, 815, 815, - /* 4470 */ 815, 815, 815, 476, 150, 815, 815, 442, 145, 467, - /* 4480 */ 157, 199, 198, 149, 191, 272, 271, 269, 267, 189, - /* 4490 */ 462, 511, 510, 509, 508, 507, 506, 505, 504, 503, - /* 4500 */ 502, 501, 500, 499, 498, 497, 496, 295, 294, 293, - /* 4510 */ 282, 815, 278, 815, 205, 815, 815, 815, 815, 815, - /* 4520 */ 815, 815, 815, 815, 815, 815, 815, 815, 815, 815, - /* 4530 */ 142, 815, 815, 815, 815, 815, 815, 511, 510, 509, - /* 4540 */ 508, 507, 506, 505, 504, 503, 502, 501, 500, 499, - /* 4550 */ 498, 497, 496, 295, 294, 293, 282, 515, 278, 815, - /* 4560 */ 512, 517, 516, 514, 513, 815, 815, 815, 815, 815, - /* 4570 */ 815, 815, 815, 815, 815, 815, 815, 476, 150, 815, - /* 4580 */ 815, 815, 468, 467, 157, 199, 198, 149, 191, 272, - /* 4590 */ 271, 269, 267, 189, 463, 815, 815, 815, 815, 815, - /* 4600 */ 815, 511, 510, 509, 508, 507, 506, 505, 504, 503, - /* 4610 */ 502, 501, 500, 499, 498, 497, 496, 295, 294, 293, - /* 4620 */ 282, 142, 278, 815, 814, 66, 297, 523, 128, 815, - /* 4630 */ 319, 108, 110, 815, 95, 129, 815, 815, 815, 815, - /* 4640 */ 815, 815, 815, 94, 815, 399, 815, 815, 515, 252, - /* 4650 */ 815, 512, 517, 516, 514, 513, 815, 815, 815, 515, - /* 4660 */ 815, 815, 512, 517, 516, 514, 513, 815, 476, 150, - /* 4670 */ 142, 815, 815, 468, 467, 157, 199, 198, 149, 191, - /* 4680 */ 272, 271, 269, 267, 188, 815, 815, 815, 815, 815, - /* 4690 */ 815, 815, 815, 815, 815, 815, 815, 515, 815, 815, - /* 4700 */ 512, 517, 516, 514, 513, 815, 815, 815, 815, 815, - /* 4710 */ 142, 815, 815, 815, 815, 815, 815, 476, 150, 815, - /* 4720 */ 116, 815, 468, 467, 157, 199, 198, 149, 191, 272, - /* 4730 */ 271, 269, 265, 412, 815, 815, 815, 515, 815, 815, - /* 4740 */ 512, 517, 516, 514, 513, 142, 815, 515, 815, 815, - /* 4750 */ 512, 517, 516, 514, 513, 815, 815, 476, 150, 815, - /* 4760 */ 815, 815, 468, 467, 157, 199, 198, 149, 191, 272, - /* 4770 */ 271, 266, 515, 815, 815, 512, 517, 516, 514, 513, - /* 4780 */ 815, 142, 815, 815, 815, 815, 815, 815, 815, 815, - /* 4790 */ 815, 815, 476, 150, 815, 815, 815, 468, 467, 157, - /* 4800 */ 199, 198, 149, 191, 272, 268, 815, 815, 515, 815, - /* 4810 */ 815, 512, 517, 516, 514, 513, 815, 815, 815, 815, - /* 4820 */ 815, 815, 815, 815, 815, 815, 815, 815, 476, 150, - /* 4830 */ 815, 815, 815, 468, 467, 157, 199, 198, 149, 191, - /* 4840 */ 270, 815, 815, 815, 524, 523, 128, 815, 319, 108, - /* 4850 */ 110, 815, 95, 129, 815, 815, 815, 815, 142, 815, - /* 4860 */ 815, 94, 815, 399, 815, 815, 815, 252, 815, 815, - /* 4870 */ 142, 815, 815, 815, 815, 815, 815, 515, 815, 815, - /* 4880 */ 512, 517, 516, 514, 513, 515, 815, 815, 512, 517, - /* 4890 */ 516, 514, 513, 815, 815, 815, 815, 515, 815, 815, - /* 4900 */ 512, 517, 516, 514, 513, 476, 150, 815, 142, 815, - /* 4910 */ 468, 467, 157, 199, 198, 149, 190, 476, 150, 815, - /* 4920 */ 815, 815, 468, 467, 157, 199, 198, 148, 815, 815, - /* 4930 */ 815, 815, 815, 815, 815, 515, 815, 815, 512, 517, - /* 4940 */ 516, 514, 513, 815, 142, 815, 815, 815, 815, 815, - /* 4950 */ 815, 815, 815, 815, 815, 476, 150, 815, 815, 815, - /* 4960 */ 468, 467, 157, 199, 198, 147, 815, 815, 815, 815, - /* 4970 */ 815, 515, 815, 815, 512, 517, 516, 514, 513, 142, - /* 4980 */ 815, 815, 815, 815, 815, 815, 815, 815, 815, 815, - /* 4990 */ 815, 476, 150, 815, 815, 815, 468, 467, 157, 199, - /* 5000 */ 195, 815, 815, 815, 815, 815, 515, 815, 815, 512, - /* 5010 */ 517, 516, 514, 513, 142, 815, 815, 815, 815, 815, - /* 5020 */ 815, 815, 815, 815, 142, 815, 476, 150, 815, 815, - /* 5030 */ 815, 468, 467, 157, 199, 194, 815, 815, 815, 815, - /* 5040 */ 815, 515, 815, 815, 512, 517, 516, 514, 513, 815, - /* 5050 */ 815, 515, 815, 815, 512, 517, 516, 514, 513, 142, - /* 5060 */ 815, 476, 150, 815, 815, 815, 468, 467, 157, 199, - /* 5070 */ 193, 476, 150, 815, 815, 815, 468, 467, 157, 199, - /* 5080 */ 192, 815, 815, 815, 815, 815, 515, 815, 142, 512, - /* 5090 */ 517, 516, 514, 513, 815, 815, 815, 142, 815, 815, - /* 5100 */ 815, 815, 815, 815, 815, 815, 476, 150, 815, 815, - /* 5110 */ 815, 468, 467, 157, 197, 515, 815, 815, 512, 517, - /* 5120 */ 516, 514, 513, 815, 515, 142, 815, 512, 517, 516, - /* 5130 */ 514, 513, 815, 815, 815, 476, 150, 815, 815, 815, - /* 5140 */ 468, 467, 157, 196, 476, 150, 815, 815, 815, 468, - /* 5150 */ 467, 156, 515, 815, 815, 512, 517, 516, 514, 513, - /* 5160 */ 208, 815, 815, 815, 815, 203, 210, 301, 98, 815, - /* 5170 */ 815, 815, 476, 150, 142, 815, 815, 468, 467, 155, - /* 5180 */ 815, 815, 815, 815, 142, 815, 815, 515, 815, 815, - /* 5190 */ 512, 517, 516, 514, 513, 815, 815, 815, 815, 815, - /* 5200 */ 815, 515, 815, 815, 512, 517, 516, 514, 513, 815, - /* 5210 */ 815, 515, 142, 815, 512, 517, 516, 514, 513, 815, - /* 5220 */ 815, 476, 150, 142, 815, 815, 468, 472, 815, 815, - /* 5230 */ 815, 476, 150, 815, 815, 815, 468, 471, 815, 515, - /* 5240 */ 815, 815, 512, 517, 516, 514, 513, 142, 815, 815, - /* 5250 */ 515, 815, 815, 512, 517, 516, 514, 513, 142, 476, - /* 5260 */ 150, 815, 815, 815, 468, 470, 815, 815, 815, 815, - /* 5270 */ 476, 150, 815, 815, 515, 468, 469, 512, 517, 516, - /* 5280 */ 514, 513, 142, 815, 815, 515, 815, 815, 512, 517, - /* 5290 */ 516, 514, 513, 142, 476, 150, 815, 815, 815, 468, - /* 5300 */ 466, 815, 815, 815, 815, 476, 150, 815, 815, 515, - /* 5310 */ 468, 465, 512, 517, 516, 514, 513, 142, 815, 815, - /* 5320 */ 515, 815, 815, 512, 517, 516, 514, 513, 815, 476, - /* 5330 */ 150, 815, 815, 815, 468, 464, 815, 815, 815, 815, - /* 5340 */ 476, 150, 815, 815, 515, 468, 445, 512, 517, 516, - /* 5350 */ 514, 513, 815, 815, 142, 815, 815, 815, 815, 815, - /* 5360 */ 815, 815, 815, 815, 476, 150, 815, 815, 815, 449, - /* 5370 */ 815, 815, 815, 815, 815, 815, 815, 815, 815, 815, - /* 5380 */ 815, 515, 815, 815, 512, 517, 516, 514, 513, 815, - /* 5390 */ 815, 815, 815, 815, 815, 815, 815, 815, 815, 815, - /* 5400 */ 815, 476, 150, 815, 815, 815, 473, -}; -static const YYCODETYPE yy_lookahead[] = { - /* 0 */ 27, 28, 35, 36, 37, 38, 33, 34, 35, 36, - /* 10 */ 38, 38, 40, 40, 2, 142, 43, 44, 45, 46, - /* 20 */ 147, 148, 29, 30, 31, 52, 66, 154, 155, 56, - /* 30 */ 27, 28, 59, 60, 61, 62, 63, 64, 65, 66, - /* 40 */ 67, 83, 1, 70, 71, 72, 73, 74, 75, 76, - /* 50 */ 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, - /* 60 */ 87, 88, 89, 90, 91, 53, 54, 55, 56, 57, - /* 70 */ 58, 98, 99, 100, 101, 102, 103, 117, 118, 106, - /* 80 */ 39, 108, 21, 22, 23, 24, 38, 114, 83, 133, - /* 90 */ 27, 28, 119, 120, 121, 122, 33, 34, 35, 36, - /* 100 */ 144, 38, 146, 40, 2, 142, 43, 44, 45, 46, - /* 110 */ 108, 148, 19, 20, 148, 52, 114, 154, 155, 56, - /* 120 */ 154, 155, 59, 60, 61, 62, 63, 64, 65, 66, - /* 130 */ 67, 25, 26, 70, 71, 72, 73, 74, 75, 76, - /* 140 */ 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, - /* 150 */ 87, 88, 89, 90, 91, 21, 54, 55, 56, 57, - /* 160 */ 58, 98, 99, 100, 101, 102, 103, 101, 102, 106, - /* 170 */ 136, 108, 106, 101, 102, 141, 142, 114, 106, 133, - /* 180 */ 27, 28, 119, 120, 121, 122, 33, 34, 35, 36, - /* 190 */ 144, 38, 146, 40, 142, 148, 43, 44, 45, 46, - /* 200 */ 148, 154, 155, 23, 148, 52, 154, 155, 133, 56, - /* 210 */ 154, 155, 59, 60, 61, 62, 63, 64, 65, 144, - /* 220 */ 67, 146, 1, 70, 71, 72, 73, 74, 75, 76, - /* 230 */ 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, - /* 240 */ 87, 88, 89, 90, 91, 14, 46, 157, 158, 159, - /* 250 */ 23, 98, 99, 100, 101, 102, 103, 148, 1, 106, - /* 260 */ 132, 108, 41, 154, 155, 13, 14, 114, 68, 69, - /* 270 */ 27, 28, 119, 120, 121, 122, 33, 34, 35, 36, - /* 280 */ 152, 37, 1, 40, 53, 41, 43, 159, 45, 46, - /* 290 */ 162, 163, 164, 165, 166, 52, 101, 102, 133, 56, - /* 300 */ 43, 106, 59, 60, 61, 62, 63, 64, 1, 144, - /* 310 */ 67, 146, 1, 70, 71, 72, 73, 74, 75, 76, - /* 320 */ 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, - /* 330 */ 87, 88, 89, 90, 91, 68, 69, 127, 136, 129, - /* 340 */ 130, 131, 132, 141, 142, 1, 181, 66, 41, 1, - /* 350 */ 39, 39, 40, 143, 108, 145, 23, 23, 43, 149, - /* 360 */ 114, 46, 119, 120, 121, 122, 156, 1, 1, 159, - /* 370 */ 40, 41, 162, 163, 164, 165, 166, 167, 168, 1, - /* 380 */ 170, 171, 172, 173, 1, 175, 176, 43, 1, 179, - /* 390 */ 180, 43, 1, 183, 184, 185, 186, 187, 188, 189, - /* 400 */ 190, 191, 192, 193, 194, 195, 196, 127, 41, 129, - /* 410 */ 130, 131, 132, 79, 80, 81, 82, 83, 84, 85, - /* 420 */ 86, 87, 1, 143, 133, 145, 43, 43, 41, 149, - /* 430 */ 23, 53, 66, 23, 43, 40, 156, 146, 1, 159, - /* 440 */ 1, 46, 162, 163, 164, 165, 166, 167, 168, 65, - /* 450 */ 170, 171, 172, 173, 43, 175, 176, 46, 2, 179, - /* 460 */ 180, 2, 41, 183, 184, 185, 186, 187, 188, 189, - /* 470 */ 190, 191, 192, 193, 194, 195, 196, 21, 41, 83, - /* 480 */ 21, 127, 43, 129, 130, 131, 132, 79, 80, 81, - /* 490 */ 82, 83, 84, 85, 86, 87, 136, 143, 23, 145, - /* 500 */ 174, 23, 142, 149, 178, 117, 118, 147, 148, 53, - /* 510 */ 156, 83, 53, 159, 154, 155, 162, 163, 164, 165, - /* 520 */ 166, 167, 168, 23, 170, 171, 172, 173, 1, 175, - /* 530 */ 176, 1, 132, 179, 180, 135, 21, 183, 184, 185, - /* 540 */ 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, - /* 550 */ 196, 127, 133, 129, 130, 131, 132, 1, 1, 159, - /* 560 */ 1, 1, 162, 163, 164, 165, 166, 143, 23, 145, - /* 570 */ 43, 41, 153, 149, 79, 80, 81, 82, 83, 84, - /* 580 */ 156, 86, 87, 159, 1, 21, 162, 163, 164, 165, - /* 590 */ 166, 1, 168, 1, 170, 171, 172, 173, 41, 175, - /* 600 */ 176, 41, 43, 179, 180, 132, 1, 183, 184, 185, - /* 610 */ 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, - /* 620 */ 196, 2, 141, 142, 90, 127, 43, 129, 130, 131, - /* 630 */ 132, 41, 159, 41, 1, 162, 163, 164, 165, 166, - /* 640 */ 1, 143, 90, 145, 141, 142, 1, 149, 43, 158, - /* 650 */ 159, 90, 23, 18, 156, 17, 16, 159, 15, 46, - /* 660 */ 162, 163, 164, 165, 166, 40, 168, 46, 170, 171, - /* 670 */ 172, 173, 53, 175, 176, 132, 46, 179, 180, 69, - /* 680 */ 41, 183, 184, 185, 186, 187, 188, 189, 190, 191, - /* 690 */ 192, 193, 194, 195, 196, 127, 41, 129, 130, 131, - /* 700 */ 132, 40, 159, 46, 41, 162, 163, 164, 165, 166, - /* 710 */ 1, 143, 68, 145, 43, 65, 46, 149, 46, 46, - /* 720 */ 43, 43, 43, 40, 156, 41, 90, 159, 39, 41, - /* 730 */ 162, 163, 164, 165, 166, 39, 168, 90, 170, 171, - /* 740 */ 172, 173, 39, 175, 176, 39, 39, 179, 180, 132, - /* 750 */ 39, 183, 184, 185, 186, 187, 188, 189, 190, 191, - /* 760 */ 192, 193, 194, 195, 196, 39, 108, 108, 39, 127, - /* 770 */ 108, 129, 130, 131, 132, 39, 159, 108, 39, 162, - /* 780 */ 163, 164, 165, 166, 39, 143, 101, 145, 114, 114, - /* 790 */ 40, 149, 102, 40, 43, 40, 42, 40, 156, 65, - /* 800 */ 53, 159, 46, 40, 162, 163, 164, 165, 166, 41, - /* 810 */ 168, 1, 170, 171, 172, 173, 46, 175, 176, 46, - /* 820 */ 51, 179, 180, 49, 46, 183, 184, 185, 186, 187, - /* 830 */ 188, 189, 190, 191, 192, 193, 194, 195, 196, 127, - /* 840 */ 40, 129, 130, 131, 132, 41, 133, 46, 181, 40, - /* 850 */ 133, 53, 155, 154, 2, 143, 53, 145, 142, 136, - /* 860 */ 53, 149, 181, 177, 129, 40, 136, 65, 156, 142, - /* 870 */ 142, 159, 129, 142, 162, 163, 164, 165, 166, 142, - /* 880 */ 168, 159, 170, 171, 172, 173, 178, 175, 176, 169, - /* 890 */ 53, 179, 180, 46, 136, 183, 184, 185, 186, 187, - /* 900 */ 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, - /* 910 */ 197, 159, 197, 127, 197, 129, 130, 131, 132, 197, - /* 920 */ 197, 197, 197, 197, 197, 197, 197, 197, 197, 143, - /* 930 */ 197, 145, 197, 197, 197, 149, 197, 197, 197, 197, - /* 940 */ 197, 197, 156, 197, 197, 159, 197, 197, 162, 163, - /* 950 */ 164, 165, 166, 197, 168, 197, 170, 171, 172, 173, - /* 960 */ 197, 175, 176, 197, 197, 179, 180, 197, 197, 183, - /* 970 */ 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, - /* 980 */ 194, 195, 196, 127, 197, 129, 130, 131, 132, 197, - /* 990 */ 197, 197, 197, 197, 197, 197, 197, 197, 197, 143, - /* 1000 */ 197, 145, 197, 197, 197, 149, 197, 197, 197, 197, - /* 1010 */ 197, 197, 156, 197, 197, 159, 197, 197, 162, 163, - /* 1020 */ 164, 165, 166, 197, 168, 197, 170, 171, 172, 173, - /* 1030 */ 197, 175, 176, 197, 197, 179, 180, 197, 197, 183, - /* 1040 */ 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, - /* 1050 */ 194, 195, 196, 197, 197, 197, 197, 127, 197, 129, - /* 1060 */ 130, 131, 132, 197, 197, 197, 197, 197, 197, 197, - /* 1070 */ 197, 197, 197, 143, 197, 145, 197, 197, 197, 149, - /* 1080 */ 197, 197, 197, 197, 197, 197, 156, 197, 197, 159, - /* 1090 */ 197, 197, 162, 163, 164, 165, 166, 197, 168, 197, - /* 1100 */ 170, 171, 172, 173, 197, 175, 176, 197, 197, 179, - /* 1110 */ 180, 197, 197, 183, 184, 185, 186, 187, 188, 189, - /* 1120 */ 190, 191, 192, 193, 194, 195, 196, 127, 197, 129, - /* 1130 */ 130, 131, 132, 197, 197, 197, 197, 197, 197, 197, - /* 1140 */ 197, 197, 197, 143, 197, 145, 197, 197, 197, 149, - /* 1150 */ 197, 197, 197, 197, 197, 197, 156, 197, 197, 159, - /* 1160 */ 197, 197, 162, 163, 164, 165, 166, 197, 168, 197, - /* 1170 */ 170, 171, 172, 173, 197, 175, 176, 197, 197, 179, - /* 1180 */ 180, 197, 197, 183, 184, 185, 186, 187, 188, 189, - /* 1190 */ 190, 191, 192, 193, 194, 195, 196, 197, 197, 197, - /* 1200 */ 197, 127, 197, 129, 130, 131, 132, 197, 197, 197, - /* 1210 */ 197, 197, 197, 197, 197, 197, 197, 143, 197, 145, - /* 1220 */ 197, 197, 197, 149, 197, 197, 197, 197, 197, 197, - /* 1230 */ 156, 197, 197, 159, 197, 197, 162, 163, 164, 165, - /* 1240 */ 166, 197, 168, 197, 170, 171, 172, 173, 197, 175, - /* 1250 */ 176, 197, 197, 179, 180, 197, 197, 183, 184, 185, - /* 1260 */ 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, - /* 1270 */ 196, 127, 197, 129, 130, 131, 132, 197, 197, 197, - /* 1280 */ 197, 197, 197, 197, 197, 197, 197, 143, 197, 145, - /* 1290 */ 197, 197, 197, 149, 197, 197, 197, 197, 197, 197, - /* 1300 */ 156, 197, 197, 159, 197, 197, 162, 163, 164, 165, - /* 1310 */ 166, 197, 168, 197, 170, 171, 172, 173, 197, 175, - /* 1320 */ 176, 197, 197, 179, 180, 197, 197, 183, 184, 185, - /* 1330 */ 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, - /* 1340 */ 196, 197, 197, 197, 197, 127, 197, 129, 130, 131, - /* 1350 */ 132, 197, 197, 197, 197, 197, 197, 197, 197, 197, - /* 1360 */ 197, 143, 197, 145, 197, 197, 197, 149, 197, 197, - /* 1370 */ 197, 197, 197, 197, 156, 197, 197, 159, 197, 197, - /* 1380 */ 162, 163, 164, 165, 166, 197, 168, 197, 170, 171, - /* 1390 */ 172, 173, 197, 175, 176, 197, 197, 179, 180, 197, - /* 1400 */ 197, 183, 184, 185, 186, 187, 188, 189, 190, 191, - /* 1410 */ 192, 193, 194, 195, 196, 127, 197, 129, 130, 131, - /* 1420 */ 132, 197, 197, 197, 197, 197, 197, 197, 197, 197, - /* 1430 */ 197, 143, 197, 145, 197, 197, 197, 149, 197, 197, - /* 1440 */ 197, 197, 197, 197, 156, 197, 197, 159, 197, 197, - /* 1450 */ 162, 163, 164, 165, 166, 197, 168, 197, 170, 171, - /* 1460 */ 172, 173, 197, 175, 176, 197, 197, 179, 180, 197, - /* 1470 */ 197, 183, 184, 185, 186, 187, 188, 189, 190, 191, - /* 1480 */ 192, 193, 194, 195, 196, 197, 197, 197, 197, 127, - /* 1490 */ 197, 129, 130, 131, 132, 197, 197, 197, 197, 197, - /* 1500 */ 197, 197, 197, 197, 197, 143, 197, 145, 197, 197, - /* 1510 */ 197, 149, 197, 197, 197, 197, 197, 197, 156, 197, - /* 1520 */ 197, 159, 197, 197, 162, 163, 164, 165, 166, 197, - /* 1530 */ 168, 197, 170, 171, 172, 173, 197, 175, 176, 197, - /* 1540 */ 197, 179, 180, 197, 197, 183, 184, 185, 186, 187, - /* 1550 */ 188, 189, 190, 191, 192, 193, 194, 195, 196, 127, - /* 1560 */ 197, 129, 130, 131, 132, 197, 197, 197, 197, 197, - /* 1570 */ 197, 197, 197, 197, 197, 143, 197, 145, 197, 197, - /* 1580 */ 197, 149, 197, 197, 197, 197, 197, 197, 156, 197, - /* 1590 */ 197, 159, 197, 197, 162, 163, 164, 165, 166, 197, - /* 1600 */ 168, 197, 170, 171, 172, 173, 197, 175, 176, 197, - /* 1610 */ 197, 179, 180, 197, 197, 183, 184, 185, 186, 187, - /* 1620 */ 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, - /* 1630 */ 197, 197, 197, 127, 197, 129, 130, 131, 132, 197, - /* 1640 */ 197, 197, 197, 197, 197, 197, 197, 197, 197, 143, - /* 1650 */ 197, 145, 197, 197, 197, 149, 197, 197, 197, 197, - /* 1660 */ 197, 197, 156, 197, 197, 159, 197, 197, 162, 163, - /* 1670 */ 164, 165, 166, 197, 168, 197, 170, 171, 172, 173, - /* 1680 */ 197, 175, 176, 197, 197, 179, 180, 197, 197, 183, - /* 1690 */ 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, - /* 1700 */ 194, 195, 196, 127, 197, 129, 130, 131, 132, 197, - /* 1710 */ 197, 197, 197, 197, 197, 197, 197, 197, 197, 143, - /* 1720 */ 197, 145, 197, 197, 197, 149, 197, 197, 197, 197, - /* 1730 */ 197, 197, 156, 0, 197, 159, 197, 197, 162, 163, - /* 1740 */ 164, 165, 166, 197, 168, 197, 170, 171, 172, 173, - /* 1750 */ 197, 175, 176, 197, 197, 179, 180, 197, 197, 183, - /* 1760 */ 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, - /* 1770 */ 194, 195, 196, 197, 197, 197, 197, 44, 45, 197, - /* 1780 */ 47, 48, 197, 197, 197, 52, 197, 197, 197, 56, - /* 1790 */ 197, 197, 59, 60, 61, 62, 63, 64, 197, 197, - /* 1800 */ 67, 197, 197, 70, 71, 72, 73, 74, 75, 76, - /* 1810 */ 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, - /* 1820 */ 87, 88, 89, 197, 91, 27, 28, 197, 197, 197, - /* 1830 */ 197, 33, 34, 35, 36, 197, 197, 39, 40, 197, - /* 1840 */ 197, 197, 197, 197, 46, 197, 197, 27, 28, 197, - /* 1850 */ 197, 197, 197, 33, 34, 35, 36, 197, 197, 197, - /* 1860 */ 40, 41, 197, 197, 197, 197, 46, 197, 70, 71, - /* 1870 */ 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, - /* 1880 */ 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, - /* 1890 */ 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, - /* 1900 */ 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, - /* 1910 */ 90, 91, 197, 197, 197, 27, 28, 119, 120, 121, - /* 1920 */ 122, 33, 34, 35, 36, 197, 197, 197, 40, 197, - /* 1930 */ 197, 43, 197, 197, 46, 197, 197, 27, 28, 119, - /* 1940 */ 120, 121, 122, 33, 34, 35, 36, 197, 197, 197, - /* 1950 */ 40, 197, 197, 43, 197, 197, 46, 197, 70, 71, - /* 1960 */ 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, - /* 1970 */ 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, - /* 1980 */ 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, - /* 1990 */ 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, - /* 2000 */ 90, 91, 197, 197, 197, 27, 28, 119, 120, 121, - /* 2010 */ 122, 33, 34, 35, 36, 197, 197, 197, 40, 41, - /* 2020 */ 197, 197, 197, 197, 46, 197, 197, 27, 28, 119, - /* 2030 */ 120, 121, 122, 33, 34, 35, 36, 197, 197, 197, - /* 2040 */ 40, 41, 197, 197, 197, 197, 46, 197, 70, 71, - /* 2050 */ 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, - /* 2060 */ 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, - /* 2070 */ 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, - /* 2080 */ 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, - /* 2090 */ 90, 91, 197, 197, 197, 27, 28, 119, 120, 121, - /* 2100 */ 122, 33, 34, 35, 36, 197, 197, 197, 40, 197, - /* 2110 */ 197, 43, 197, 197, 46, 197, 197, 27, 28, 119, - /* 2120 */ 120, 121, 122, 33, 34, 35, 36, 197, 197, 197, - /* 2130 */ 40, 41, 197, 197, 197, 197, 46, 197, 70, 71, - /* 2140 */ 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, - /* 2150 */ 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, - /* 2160 */ 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, - /* 2170 */ 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, - /* 2180 */ 90, 91, 197, 197, 197, 27, 28, 119, 120, 121, - /* 2190 */ 122, 33, 34, 35, 36, 197, 197, 197, 40, 41, - /* 2200 */ 197, 197, 197, 197, 46, 197, 197, 27, 28, 119, - /* 2210 */ 120, 121, 122, 33, 34, 35, 36, 197, 197, 197, - /* 2220 */ 40, 197, 197, 43, 197, 197, 46, 197, 70, 71, - /* 2230 */ 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, - /* 2240 */ 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, - /* 2250 */ 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, - /* 2260 */ 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, - /* 2270 */ 90, 91, 197, 197, 197, 27, 28, 119, 120, 121, - /* 2280 */ 122, 33, 34, 35, 36, 197, 197, 197, 40, 41, - /* 2290 */ 197, 197, 197, 197, 46, 197, 197, 27, 28, 119, - /* 2300 */ 120, 121, 122, 33, 34, 35, 36, 197, 197, 197, - /* 2310 */ 40, 41, 197, 197, 197, 197, 46, 197, 70, 71, - /* 2320 */ 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, - /* 2330 */ 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, - /* 2340 */ 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, - /* 2350 */ 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, - /* 2360 */ 90, 91, 197, 197, 197, 27, 28, 119, 120, 121, - /* 2370 */ 122, 33, 34, 35, 36, 197, 197, 197, 40, 197, - /* 2380 */ 197, 197, 197, 197, 46, 197, 197, 197, 197, 119, - /* 2390 */ 120, 121, 122, 197, 197, 197, 197, 197, 197, 197, - /* 2400 */ 197, 197, 197, 65, 197, 197, 197, 197, 70, 71, - /* 2410 */ 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, - /* 2420 */ 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, - /* 2430 */ 197, 27, 28, 197, 132, 197, 197, 33, 34, 35, - /* 2440 */ 36, 197, 197, 141, 40, 197, 197, 197, 197, 197, - /* 2450 */ 46, 197, 150, 151, 152, 197, 197, 119, 120, 121, - /* 2460 */ 122, 159, 197, 197, 162, 163, 164, 165, 166, 65, - /* 2470 */ 197, 197, 197, 197, 70, 71, 72, 73, 74, 75, - /* 2480 */ 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, - /* 2490 */ 86, 87, 88, 89, 90, 91, 197, 27, 28, 197, - /* 2500 */ 197, 197, 197, 33, 34, 35, 36, 197, 197, 197, - /* 2510 */ 40, 197, 197, 197, 197, 197, 46, 197, 197, 197, - /* 2520 */ 197, 197, 197, 119, 120, 121, 122, 2, 3, 4, - /* 2530 */ 5, 6, 7, 8, 9, 10, 11, 12, 197, 197, - /* 2540 */ 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, - /* 2550 */ 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, - /* 2560 */ 90, 91, 197, 197, 197, 197, 197, 197, 27, 28, - /* 2570 */ 197, 132, 197, 197, 33, 34, 35, 36, 139, 140, - /* 2580 */ 197, 40, 197, 197, 197, 197, 197, 46, 197, 119, - /* 2590 */ 120, 121, 122, 197, 197, 197, 197, 197, 159, 197, - /* 2600 */ 197, 162, 163, 164, 165, 166, 197, 197, 197, 197, - /* 2610 */ 197, 70, 71, 72, 73, 74, 75, 76, 77, 78, - /* 2620 */ 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, - /* 2630 */ 89, 90, 91, 197, 92, 93, 94, 95, 96, 97, - /* 2640 */ 197, 197, 197, 197, 197, 197, 104, 105, 197, 107, - /* 2650 */ 197, 109, 110, 111, 112, 113, 197, 115, 116, 197, - /* 2660 */ 119, 120, 121, 122, 44, 45, 197, 47, 48, 197, - /* 2670 */ 197, 197, 52, 197, 197, 197, 56, 197, 197, 59, - /* 2680 */ 60, 61, 62, 63, 64, 197, 197, 67, 197, 197, - /* 2690 */ 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, - /* 2700 */ 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, - /* 2710 */ 45, 91, 197, 197, 197, 197, 197, 52, 197, 197, - /* 2720 */ 197, 56, 197, 197, 59, 60, 61, 62, 63, 64, - /* 2730 */ 197, 197, 197, 197, 197, 70, 71, 72, 73, 74, - /* 2740 */ 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, - /* 2750 */ 85, 86, 87, 88, 89, 127, 91, 197, 197, 131, - /* 2760 */ 132, 197, 197, 197, 197, 197, 197, 197, 197, 132, - /* 2770 */ 197, 143, 197, 145, 197, 197, 197, 149, 141, 197, - /* 2780 */ 197, 197, 197, 197, 156, 197, 197, 159, 151, 152, - /* 2790 */ 162, 163, 164, 165, 166, 197, 159, 197, 197, 162, - /* 2800 */ 163, 164, 165, 166, 197, 197, 197, 179, 180, 197, - /* 2810 */ 197, 183, 184, 185, 186, 187, 188, 189, 190, 191, - /* 2820 */ 192, 193, 194, 195, 196, 197, 54, 55, 56, 57, - /* 2830 */ 58, 197, 197, 197, 197, 197, 197, 197, 66, 197, - /* 2840 */ 197, 197, 70, 71, 72, 73, 74, 75, 76, 77, - /* 2850 */ 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, - /* 2860 */ 88, 89, 197, 91, 197, 197, 54, 55, 56, 57, - /* 2870 */ 58, 197, 197, 197, 197, 197, 197, 197, 197, 197, - /* 2880 */ 197, 197, 70, 71, 72, 73, 74, 75, 76, 77, - /* 2890 */ 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, - /* 2900 */ 88, 89, 47, 91, 49, 50, 51, 52, 197, 197, - /* 2910 */ 197, 197, 197, 197, 197, 197, 197, 197, 197, 197, - /* 2920 */ 197, 197, 197, 197, 197, 70, 71, 72, 73, 74, - /* 2930 */ 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, - /* 2940 */ 85, 86, 87, 88, 89, 197, 91, 49, 50, 51, - /* 2950 */ 52, 197, 197, 197, 197, 197, 197, 197, 197, 197, - /* 2960 */ 197, 197, 197, 197, 197, 197, 197, 197, 70, 71, - /* 2970 */ 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, - /* 2980 */ 82, 83, 84, 85, 86, 87, 88, 89, 132, 91, - /* 2990 */ 197, 197, 197, 197, 197, 197, 197, 197, 197, 197, - /* 3000 */ 132, 197, 197, 197, 197, 137, 138, 139, 140, 197, - /* 3010 */ 197, 197, 156, 197, 197, 159, 197, 161, 162, 163, - /* 3020 */ 164, 165, 166, 197, 197, 197, 197, 159, 197, 132, - /* 3030 */ 162, 163, 164, 165, 166, 179, 180, 197, 197, 183, - /* 3040 */ 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, - /* 3050 */ 194, 195, 196, 156, 197, 197, 159, 160, 197, 162, - /* 3060 */ 163, 164, 165, 166, 197, 197, 197, 197, 197, 197, - /* 3070 */ 132, 197, 197, 197, 197, 197, 179, 180, 197, 197, - /* 3080 */ 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, - /* 3090 */ 193, 194, 195, 196, 156, 197, 197, 159, 160, 197, - /* 3100 */ 162, 163, 164, 165, 166, 197, 197, 197, 197, 197, - /* 3110 */ 197, 132, 197, 197, 197, 197, 197, 179, 180, 197, - /* 3120 */ 197, 183, 184, 185, 186, 187, 188, 189, 190, 191, - /* 3130 */ 192, 193, 194, 195, 196, 156, 197, 197, 159, 160, - /* 3140 */ 197, 162, 163, 164, 165, 166, 197, 197, 197, 197, - /* 3150 */ 197, 197, 132, 197, 197, 197, 197, 197, 179, 180, - /* 3160 */ 197, 197, 183, 184, 185, 186, 187, 188, 189, 190, - /* 3170 */ 191, 192, 193, 194, 195, 196, 156, 197, 197, 159, - /* 3180 */ 197, 197, 162, 163, 164, 165, 166, 197, 197, 197, - /* 3190 */ 197, 197, 197, 132, 197, 197, 197, 197, 197, 179, - /* 3200 */ 180, 197, 197, 183, 184, 185, 186, 187, 188, 189, - /* 3210 */ 190, 191, 192, 193, 194, 195, 196, 156, 197, 197, - /* 3220 */ 159, 197, 197, 162, 163, 164, 165, 166, 197, 197, - /* 3230 */ 197, 197, 197, 197, 132, 197, 197, 197, 197, 197, - /* 3240 */ 179, 180, 197, 197, 183, 184, 185, 186, 187, 188, - /* 3250 */ 189, 190, 191, 192, 193, 194, 195, 196, 156, 197, - /* 3260 */ 197, 159, 197, 197, 162, 163, 164, 165, 166, 197, - /* 3270 */ 197, 197, 197, 197, 197, 132, 197, 197, 197, 197, - /* 3280 */ 197, 179, 180, 197, 197, 183, 184, 185, 186, 187, - /* 3290 */ 188, 189, 190, 191, 192, 193, 194, 195, 196, 156, - /* 3300 */ 197, 197, 159, 197, 197, 162, 163, 164, 165, 166, - /* 3310 */ 197, 197, 197, 197, 197, 197, 132, 197, 197, 197, - /* 3320 */ 197, 197, 179, 180, 197, 197, 183, 184, 185, 186, - /* 3330 */ 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, - /* 3340 */ 156, 197, 197, 159, 197, 197, 162, 163, 164, 165, - /* 3350 */ 166, 197, 197, 197, 197, 197, 197, 132, 197, 197, - /* 3360 */ 197, 197, 197, 179, 180, 197, 197, 183, 184, 185, - /* 3370 */ 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, - /* 3380 */ 196, 156, 197, 197, 159, 197, 197, 162, 163, 164, - /* 3390 */ 165, 166, 197, 197, 197, 197, 197, 197, 132, 197, - /* 3400 */ 197, 197, 197, 197, 179, 180, 197, 197, 183, 184, - /* 3410 */ 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, - /* 3420 */ 195, 196, 156, 197, 197, 159, 197, 197, 162, 163, - /* 3430 */ 164, 165, 166, 197, 197, 197, 197, 197, 197, 132, - /* 3440 */ 197, 197, 197, 197, 197, 179, 180, 197, 197, 183, - /* 3450 */ 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, - /* 3460 */ 194, 195, 196, 156, 197, 197, 159, 197, 197, 162, - /* 3470 */ 163, 164, 165, 166, 197, 197, 197, 197, 197, 197, - /* 3480 */ 132, 197, 197, 197, 197, 197, 179, 180, 197, 197, - /* 3490 */ 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, - /* 3500 */ 193, 194, 195, 196, 156, 197, 197, 159, 197, 197, - /* 3510 */ 162, 163, 164, 165, 166, 197, 197, 197, 197, 197, - /* 3520 */ 132, 197, 197, 197, 197, 197, 197, 179, 180, 197, - /* 3530 */ 197, 183, 184, 185, 186, 187, 188, 189, 190, 191, - /* 3540 */ 192, 193, 194, 195, 196, 197, 197, 159, 197, 197, - /* 3550 */ 162, 163, 164, 165, 166, 197, 197, 197, 197, 197, - /* 3560 */ 197, 132, 197, 197, 197, 197, 197, 179, 180, 197, - /* 3570 */ 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, - /* 3580 */ 192, 193, 194, 195, 196, 156, 197, 197, 159, 197, - /* 3590 */ 197, 162, 163, 164, 165, 166, 197, 197, 197, 197, - /* 3600 */ 197, 197, 132, 197, 197, 197, 197, 197, 179, 180, - /* 3610 */ 197, 197, 183, 184, 185, 186, 187, 188, 189, 190, - /* 3620 */ 191, 192, 193, 194, 195, 196, 156, 197, 197, 159, - /* 3630 */ 197, 197, 162, 163, 164, 165, 166, 197, 197, 197, - /* 3640 */ 197, 197, 197, 132, 197, 197, 197, 197, 197, 179, - /* 3650 */ 180, 197, 197, 183, 184, 185, 186, 187, 188, 189, - /* 3660 */ 190, 191, 192, 193, 194, 195, 196, 156, 197, 197, - /* 3670 */ 159, 197, 197, 162, 163, 164, 165, 166, 197, 197, - /* 3680 */ 197, 197, 197, 197, 132, 197, 197, 197, 197, 197, - /* 3690 */ 179, 180, 197, 197, 183, 184, 185, 186, 187, 188, - /* 3700 */ 189, 190, 191, 192, 193, 194, 195, 196, 156, 197, - /* 3710 */ 197, 159, 197, 197, 162, 163, 164, 165, 166, 197, - /* 3720 */ 197, 197, 197, 197, 197, 132, 197, 197, 197, 197, - /* 3730 */ 197, 179, 180, 197, 197, 183, 184, 185, 186, 187, - /* 3740 */ 188, 189, 190, 191, 192, 193, 194, 195, 196, 156, - /* 3750 */ 197, 197, 159, 197, 197, 162, 163, 164, 165, 166, - /* 3760 */ 197, 197, 197, 197, 197, 197, 132, 197, 197, 197, - /* 3770 */ 197, 197, 179, 180, 197, 197, 183, 184, 185, 186, - /* 3780 */ 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, - /* 3790 */ 156, 197, 197, 159, 197, 197, 162, 163, 164, 165, - /* 3800 */ 166, 197, 197, 197, 197, 197, 197, 132, 197, 197, - /* 3810 */ 197, 197, 197, 179, 180, 197, 197, 183, 184, 185, - /* 3820 */ 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, - /* 3830 */ 196, 156, 197, 197, 159, 197, 197, 162, 163, 164, - /* 3840 */ 165, 166, 197, 197, 197, 197, 197, 197, 132, 197, - /* 3850 */ 197, 197, 197, 197, 179, 180, 197, 197, 183, 184, - /* 3860 */ 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, - /* 3870 */ 195, 196, 156, 197, 197, 159, 197, 197, 162, 163, - /* 3880 */ 164, 165, 166, 197, 197, 197, 197, 197, 197, 132, - /* 3890 */ 197, 197, 197, 197, 197, 179, 180, 197, 197, 183, - /* 3900 */ 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, - /* 3910 */ 194, 195, 196, 156, 197, 197, 159, 197, 197, 162, - /* 3920 */ 163, 164, 165, 166, 197, 197, 197, 197, 197, 197, - /* 3930 */ 132, 197, 197, 197, 197, 197, 179, 180, 197, 197, - /* 3940 */ 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, - /* 3950 */ 193, 194, 195, 196, 156, 197, 197, 159, 197, 197, - /* 3960 */ 162, 163, 164, 165, 166, 197, 197, 197, 197, 197, - /* 3970 */ 132, 197, 197, 197, 197, 197, 197, 179, 180, 197, - /* 3980 */ 197, 183, 184, 185, 186, 187, 188, 189, 190, 191, - /* 3990 */ 192, 193, 194, 195, 196, 197, 197, 159, 197, 197, - /* 4000 */ 162, 163, 164, 165, 166, 197, 197, 197, 132, 197, - /* 4010 */ 197, 197, 197, 197, 197, 197, 197, 179, 180, 197, - /* 4020 */ 197, 183, 184, 185, 186, 187, 188, 189, 190, 191, - /* 4030 */ 192, 193, 194, 195, 196, 159, 197, 197, 162, 163, - /* 4040 */ 164, 165, 166, 197, 197, 197, 132, 197, 197, 197, - /* 4050 */ 197, 197, 197, 197, 197, 179, 180, 197, 197, 183, - /* 4060 */ 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, - /* 4070 */ 194, 195, 196, 159, 197, 197, 162, 163, 164, 165, - /* 4080 */ 166, 197, 197, 197, 132, 197, 197, 197, 197, 197, - /* 4090 */ 197, 197, 197, 179, 180, 197, 197, 183, 184, 185, - /* 4100 */ 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, - /* 4110 */ 196, 159, 197, 197, 162, 163, 164, 165, 166, 197, - /* 4120 */ 197, 197, 132, 197, 197, 197, 197, 197, 197, 197, - /* 4130 */ 197, 179, 180, 197, 197, 183, 184, 185, 186, 187, - /* 4140 */ 188, 189, 190, 191, 192, 193, 194, 195, 196, 159, - /* 4150 */ 197, 197, 162, 163, 164, 165, 166, 197, 197, 197, - /* 4160 */ 132, 197, 197, 197, 197, 197, 197, 197, 197, 179, - /* 4170 */ 180, 197, 197, 183, 184, 185, 186, 187, 188, 189, - /* 4180 */ 190, 191, 192, 193, 194, 195, 196, 159, 197, 197, - /* 4190 */ 162, 163, 164, 165, 166, 197, 197, 197, 132, 197, - /* 4200 */ 197, 197, 197, 197, 197, 197, 197, 179, 180, 197, - /* 4210 */ 197, 183, 184, 185, 186, 187, 188, 189, 190, 191, - /* 4220 */ 192, 193, 194, 195, 196, 159, 197, 197, 162, 163, - /* 4230 */ 164, 165, 166, 197, 197, 197, 132, 197, 197, 197, - /* 4240 */ 197, 197, 197, 197, 197, 179, 180, 197, 197, 183, - /* 4250 */ 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, - /* 4260 */ 194, 195, 196, 159, 197, 197, 162, 163, 164, 165, - /* 4270 */ 166, 197, 197, 197, 132, 197, 197, 197, 197, 197, - /* 4280 */ 197, 197, 197, 179, 180, 197, 197, 183, 184, 185, - /* 4290 */ 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, - /* 4300 */ 196, 159, 197, 197, 162, 163, 164, 165, 166, 197, - /* 4310 */ 197, 197, 132, 197, 197, 197, 197, 197, 197, 197, - /* 4320 */ 197, 179, 180, 197, 197, 183, 184, 185, 186, 187, - /* 4330 */ 188, 189, 190, 191, 192, 193, 194, 195, 196, 159, - /* 4340 */ 197, 197, 162, 163, 164, 165, 166, 197, 197, 197, - /* 4350 */ 132, 197, 197, 197, 197, 197, 197, 197, 197, 179, - /* 4360 */ 180, 197, 197, 183, 184, 185, 186, 187, 188, 189, - /* 4370 */ 190, 191, 192, 193, 194, 195, 196, 159, 197, 197, - /* 4380 */ 162, 163, 164, 165, 166, 197, 197, 197, 132, 197, - /* 4390 */ 197, 197, 197, 197, 197, 197, 197, 179, 180, 197, - /* 4400 */ 197, 183, 184, 185, 186, 187, 188, 189, 190, 191, - /* 4410 */ 192, 193, 194, 195, 196, 159, 197, 197, 162, 163, - /* 4420 */ 164, 165, 166, 197, 197, 197, 132, 197, 197, 197, - /* 4430 */ 197, 197, 197, 197, 197, 179, 180, 197, 197, 183, - /* 4440 */ 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, - /* 4450 */ 194, 195, 196, 159, 197, 197, 162, 163, 164, 165, - /* 4460 */ 166, 197, 197, 197, 197, 197, 45, 197, 197, 197, - /* 4470 */ 197, 197, 197, 179, 180, 197, 197, 183, 184, 185, - /* 4480 */ 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, - /* 4490 */ 196, 70, 71, 72, 73, 74, 75, 76, 77, 78, - /* 4500 */ 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, - /* 4510 */ 89, 197, 91, 197, 47, 197, 197, 197, 197, 197, - /* 4520 */ 197, 197, 197, 197, 197, 197, 197, 197, 197, 197, - /* 4530 */ 132, 197, 197, 197, 197, 197, 197, 70, 71, 72, - /* 4540 */ 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, - /* 4550 */ 83, 84, 85, 86, 87, 88, 89, 159, 91, 197, - /* 4560 */ 162, 163, 164, 165, 166, 197, 197, 197, 197, 197, - /* 4570 */ 197, 197, 197, 197, 197, 197, 197, 179, 180, 197, - /* 4580 */ 197, 197, 184, 185, 186, 187, 188, 189, 190, 191, - /* 4590 */ 192, 193, 194, 195, 196, 197, 197, 197, 197, 197, - /* 4600 */ 197, 70, 71, 72, 73, 74, 75, 76, 77, 78, - /* 4610 */ 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, - /* 4620 */ 89, 132, 91, 197, 124, 125, 126, 127, 128, 197, - /* 4630 */ 130, 131, 132, 197, 134, 135, 197, 197, 197, 197, - /* 4640 */ 197, 197, 197, 143, 197, 145, 197, 197, 159, 149, - /* 4650 */ 197, 162, 163, 164, 165, 166, 197, 197, 197, 159, - /* 4660 */ 197, 197, 162, 163, 164, 165, 166, 197, 179, 180, - /* 4670 */ 132, 197, 197, 184, 185, 186, 187, 188, 189, 190, - /* 4680 */ 191, 192, 193, 194, 195, 197, 197, 197, 197, 197, - /* 4690 */ 197, 197, 197, 197, 197, 197, 197, 159, 197, 197, - /* 4700 */ 162, 163, 164, 165, 166, 197, 197, 197, 197, 197, - /* 4710 */ 132, 197, 197, 197, 197, 197, 197, 179, 180, 197, - /* 4720 */ 132, 197, 184, 185, 186, 187, 188, 189, 190, 191, - /* 4730 */ 192, 193, 194, 145, 197, 197, 197, 159, 197, 197, - /* 4740 */ 162, 163, 164, 165, 166, 132, 197, 159, 197, 197, - /* 4750 */ 162, 163, 164, 165, 166, 197, 197, 179, 180, 197, - /* 4760 */ 197, 197, 184, 185, 186, 187, 188, 189, 190, 191, - /* 4770 */ 192, 193, 159, 197, 197, 162, 163, 164, 165, 166, - /* 4780 */ 197, 132, 197, 197, 197, 197, 197, 197, 197, 197, - /* 4790 */ 197, 197, 179, 180, 197, 197, 197, 184, 185, 186, - /* 4800 */ 187, 188, 189, 190, 191, 192, 197, 197, 159, 197, - /* 4810 */ 197, 162, 163, 164, 165, 166, 197, 197, 197, 197, - /* 4820 */ 197, 197, 197, 197, 197, 197, 197, 197, 179, 180, - /* 4830 */ 197, 197, 197, 184, 185, 186, 187, 188, 189, 190, - /* 4840 */ 191, 197, 197, 197, 126, 127, 128, 197, 130, 131, - /* 4850 */ 132, 197, 134, 135, 197, 197, 197, 197, 132, 197, - /* 4860 */ 197, 143, 197, 145, 197, 197, 197, 149, 197, 197, - /* 4870 */ 132, 197, 197, 197, 197, 197, 197, 159, 197, 197, - /* 4880 */ 162, 163, 164, 165, 166, 159, 197, 197, 162, 163, - /* 4890 */ 164, 165, 166, 197, 197, 197, 197, 159, 197, 197, - /* 4900 */ 162, 163, 164, 165, 166, 179, 180, 197, 132, 197, - /* 4910 */ 184, 185, 186, 187, 188, 189, 190, 179, 180, 197, - /* 4920 */ 197, 197, 184, 185, 186, 187, 188, 189, 197, 197, - /* 4930 */ 197, 197, 197, 197, 197, 159, 197, 197, 162, 163, - /* 4940 */ 164, 165, 166, 197, 132, 197, 197, 197, 197, 197, - /* 4950 */ 197, 197, 197, 197, 197, 179, 180, 197, 197, 197, - /* 4960 */ 184, 185, 186, 187, 188, 189, 197, 197, 197, 197, - /* 4970 */ 197, 159, 197, 197, 162, 163, 164, 165, 166, 132, - /* 4980 */ 197, 197, 197, 197, 197, 197, 197, 197, 197, 197, - /* 4990 */ 197, 179, 180, 197, 197, 197, 184, 185, 186, 187, - /* 5000 */ 188, 197, 197, 197, 197, 197, 159, 197, 197, 162, - /* 5010 */ 163, 164, 165, 166, 132, 197, 197, 197, 197, 197, - /* 5020 */ 197, 197, 197, 197, 132, 197, 179, 180, 197, 197, - /* 5030 */ 197, 184, 185, 186, 187, 188, 197, 197, 197, 197, - /* 5040 */ 197, 159, 197, 197, 162, 163, 164, 165, 166, 197, - /* 5050 */ 197, 159, 197, 197, 162, 163, 164, 165, 166, 132, - /* 5060 */ 197, 179, 180, 197, 197, 197, 184, 185, 186, 187, - /* 5070 */ 188, 179, 180, 197, 197, 197, 184, 185, 186, 187, - /* 5080 */ 188, 197, 197, 197, 197, 197, 159, 197, 132, 162, - /* 5090 */ 163, 164, 165, 166, 197, 197, 197, 132, 197, 197, - /* 5100 */ 197, 197, 197, 197, 197, 197, 179, 180, 197, 197, - /* 5110 */ 197, 184, 185, 186, 187, 159, 197, 197, 162, 163, - /* 5120 */ 164, 165, 166, 197, 159, 132, 197, 162, 163, 164, - /* 5130 */ 165, 166, 197, 197, 197, 179, 180, 197, 197, 197, - /* 5140 */ 184, 185, 186, 187, 179, 180, 197, 197, 197, 184, - /* 5150 */ 185, 186, 159, 197, 197, 162, 163, 164, 165, 166, - /* 5160 */ 132, 197, 197, 197, 197, 137, 138, 139, 140, 197, - /* 5170 */ 197, 197, 179, 180, 132, 197, 197, 184, 185, 186, - /* 5180 */ 197, 197, 197, 197, 132, 197, 197, 159, 197, 197, - /* 5190 */ 162, 163, 164, 165, 166, 197, 197, 197, 197, 197, - /* 5200 */ 197, 159, 197, 197, 162, 163, 164, 165, 166, 197, - /* 5210 */ 197, 159, 132, 197, 162, 163, 164, 165, 166, 197, - /* 5220 */ 197, 179, 180, 132, 197, 197, 184, 185, 197, 197, - /* 5230 */ 197, 179, 180, 197, 197, 197, 184, 185, 197, 159, - /* 5240 */ 197, 197, 162, 163, 164, 165, 166, 132, 197, 197, - /* 5250 */ 159, 197, 197, 162, 163, 164, 165, 166, 132, 179, - /* 5260 */ 180, 197, 197, 197, 184, 185, 197, 197, 197, 197, - /* 5270 */ 179, 180, 197, 197, 159, 184, 185, 162, 163, 164, - /* 5280 */ 165, 166, 132, 197, 197, 159, 197, 197, 162, 163, - /* 5290 */ 164, 165, 166, 132, 179, 180, 197, 197, 197, 184, - /* 5300 */ 185, 197, 197, 197, 197, 179, 180, 197, 197, 159, - /* 5310 */ 184, 185, 162, 163, 164, 165, 166, 132, 197, 197, - /* 5320 */ 159, 197, 197, 162, 163, 164, 165, 166, 197, 179, - /* 5330 */ 180, 197, 197, 197, 184, 185, 197, 197, 197, 197, - /* 5340 */ 179, 180, 197, 197, 159, 184, 185, 162, 163, 164, - /* 5350 */ 165, 166, 197, 197, 132, 197, 197, 197, 197, 197, - /* 5360 */ 197, 197, 197, 197, 179, 180, 197, 197, 197, 184, - /* 5370 */ 197, 197, 197, 197, 197, 197, 197, 197, 197, 197, - /* 5380 */ 197, 159, 197, 197, 162, 163, 164, 165, 166, 197, - /* 5390 */ 197, 197, 197, 197, 197, 197, 197, 197, 197, 197, - /* 5400 */ 197, 179, 180, 197, 197, 197, 184, -}; -#define YY_SHIFT_USE_DFLT (-43) -#define YY_SHIFT_COUNT (296) -#define YY_SHIFT_MIN (-42) -#define YY_SHIFT_MAX (4531) -static const short yy_shift_ofst[] = { - /* 0 */ 2620, 63, 153, 153, -27, 153, 153, 153, 153, 153, - /* 10 */ 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, - /* 20 */ 153, 153, 153, 243, 2404, 2404, 2404, 2338, 2270, 2248, - /* 30 */ 2180, 2158, 2090, 2068, 2000, 1978, 1910, 1888, 1820, 1798, - /* 40 */ 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, - /* 50 */ 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, - /* 60 */ 2541, 2541, 2541, 2541, 2541, 2541, 1733, 2541, 2541, 2541, - /* 70 */ 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, - /* 80 */ 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2855, 2855, 2812, - /* 90 */ 2470, 2470, 2772, 2898, 2665, 4467, 4531, 4421, 4531, 4531, - /* 100 */ 459, 456, 395, 619, 619, 408, 12, 12, 411, 315, - /* 110 */ 847, 801, 837, 837, 837, 837, 801, 334, 102, 102, - /* 120 */ 388, 801, 801, 2542, 408, 408, -40, 330, 384, 807, - /* 130 */ 852, 852, 852, 852, 807, 825, 802, 807, 852, 803, - /* 140 */ 798, 801, 809, 809, 801, 2525, 495, 61, 61, 61, - /* 150 */ -33, 195, 72, 66, 200, -7, -7, -7, -28, 639, - /* 160 */ 592, 605, 590, 559, 560, 557, 530, 583, 527, 439, - /* 170 */ 391, 378, 437, 421, 387, 367, 246, 2, 312, 383, - /* 180 */ 348, 344, 366, 281, 267, 244, 257, 307, 231, 252, - /* 190 */ 93, 93, 106, 106, 106, 106, 3, 3, 106, 3, - /* 200 */ 311, 221, 41, 804, 800, 778, 774, 769, 773, 770, - /* 210 */ 810, 768, 763, 756, 747, 734, 757, 754, 755, 753, - /* 220 */ 751, 750, 690, 685, 675, 745, 674, 739, 669, 736, - /* 230 */ 662, 729, 659, 726, 658, 711, 707, 706, 703, 696, - /* 240 */ 688, 647, 689, 684, 636, 683, 679, 678, 677, 673, - /* 250 */ 672, 670, 650, 671, 709, 644, 610, 663, 657, 661, - /* 260 */ 655, 630, 621, 625, 613, 643, 640, 643, 638, 640, - /* 270 */ 635, 638, 635, 629, 561, 645, 552, 633, 564, 545, - /* 280 */ 534, 556, 515, 500, 428, 478, 396, 475, 410, 407, - /* 290 */ 333, 227, 180, 134, 5, -42, 48, -}; -#define YY_REDUCE_USE_DFLT (-128) -#define YY_REDUCE_COUNT (144) -#define YY_REDUCE_MIN (-127) -#define YY_REDUCE_MAX (5222) -static const short yy_reduce_ofst[] = { - /* 0 */ 4500, 354, 280, 210, 712, 712, 1576, 1506, 1432, 1362, - /* 10 */ 1288, 1218, 1144, 1074, 1000, 930, 856, 786, 712, 642, - /* 20 */ 568, 498, 424, 2628, 2979, 2938, 2897, 2856, 3798, 3757, - /* 30 */ 3716, 3675, 3634, 3593, 3552, 3511, 3470, 3429, 3388, 3348, - /* 40 */ 3307, 3266, 3225, 3184, 3143, 3102, 3061, 3020, 4294, 4256, - /* 50 */ 4218, 4180, 4142, 4104, 4066, 4028, 3990, 3952, 3914, 3876, - /* 60 */ 3838, 4398, 4489, 4538, 4578, 4613, 4718, 4649, 4726, 4776, - /* 70 */ 4738, 4892, 4882, 4847, 4812, 4956, 4927, 4993, 4965, 5161, - /* 80 */ 5150, 5126, 5115, 5091, 5080, 5052, 5042, 5028, 2868, 2302, - /* 90 */ 5222, 5185, 2637, 2439, 4588, 400, 128, 617, 543, 473, - /* 100 */ 360, -127, 165, 52, -37, 90, 202, 34, 46, 46, - /* 110 */ 75, 46, 109, 56, 47, -34, -44, 491, 503, 481, - /* 120 */ 326, 419, 291, 720, 752, 722, 708, 681, 743, 758, - /* 130 */ 737, 731, 728, 727, 730, 686, 735, 723, 716, 699, - /* 140 */ 697, 717, 681, 667, 713, -}; -static const YYACTIONTYPE yy_default[] = { - /* 0 */ 813, 813, 741, 739, 813, 740, 813, 813, 813, 813, - /* 10 */ 813, 813, 813, 813, 813, 813, 813, 813, 738, 813, - /* 20 */ 813, 813, 813, 813, 813, 813, 813, 813, 813, 813, - /* 30 */ 813, 813, 813, 813, 813, 813, 813, 813, 813, 813, - /* 40 */ 813, 813, 813, 813, 813, 813, 813, 813, 813, 813, - /* 50 */ 813, 813, 813, 813, 813, 813, 813, 813, 813, 813, - /* 60 */ 813, 813, 813, 813, 813, 813, 813, 813, 813, 813, - /* 70 */ 813, 813, 813, 813, 813, 813, 813, 813, 813, 813, - /* 80 */ 813, 813, 813, 813, 813, 813, 813, 544, 544, 813, - /* 90 */ 813, 813, 813, 813, 813, 813, 813, 813, 813, 813, - /* 100 */ 606, 598, 813, 602, 594, 813, 562, 554, 813, 813, - /* 110 */ 813, 813, 604, 600, 596, 592, 813, 813, 558, 550, - /* 120 */ 813, 813, 813, 813, 813, 813, 813, 813, 813, 538, - /* 130 */ 560, 556, 552, 548, 536, 813, 813, 614, 813, 620, - /* 140 */ 619, 813, 813, 742, 813, 767, 813, 786, 785, 784, - /* 150 */ 760, 813, 813, 813, 813, 775, 774, 773, 623, 813, - /* 160 */ 813, 813, 813, 813, 813, 813, 813, 813, 813, 813, - /* 170 */ 813, 813, 813, 813, 813, 813, 813, 813, 813, 813, - /* 180 */ 813, 813, 813, 813, 813, 813, 813, 813, 813, 797, - /* 190 */ 788, 787, 783, 782, 781, 780, 778, 777, 779, 776, - /* 200 */ 813, 813, 813, 813, 813, 813, 565, 563, 813, 813, - /* 210 */ 543, 813, 813, 813, 813, 813, 813, 689, 813, 813, - /* 220 */ 813, 813, 813, 813, 813, 813, 813, 813, 813, 813, - /* 230 */ 813, 813, 813, 813, 813, 813, 813, 813, 813, 813, - /* 240 */ 813, 813, 813, 813, 813, 813, 813, 813, 813, 813, - /* 250 */ 813, 813, 813, 813, 631, 813, 813, 813, 813, 813, - /* 260 */ 813, 813, 813, 813, 813, 796, 794, 795, 792, 793, - /* 270 */ 790, 791, 789, 813, 813, 813, 813, 813, 813, 813, - /* 280 */ 813, 813, 813, 813, 813, 813, 813, 813, 813, 813, - /* 290 */ 813, 813, 813, 813, 813, 813, 623, 526, 541, 537, - /* 300 */ 540, 545, 568, 567, 564, 566, 561, 559, 557, 555, - /* 310 */ 553, 551, 549, 547, 546, 542, 539, 535, 532, 531, - /* 320 */ 736, 718, 717, 719, 716, 712, 711, 710, 709, 714, - /* 330 */ 713, 715, 735, 730, 723, 708, 707, 703, 702, 698, - /* 340 */ 697, 696, 695, 694, 693, 692, 673, 737, 691, 690, - /* 350 */ 688, 687, 685, 734, 733, 729, 728, 727, 726, 731, - /* 360 */ 725, 732, 724, 722, 706, 701, 721, 705, 700, 720, - /* 370 */ 704, 699, 684, 680, 679, 678, 677, 676, 675, 683, - /* 380 */ 682, 681, 674, 672, 671, 608, 609, 612, 615, 616, - /* 390 */ 613, 611, 610, 607, 574, 573, 572, 571, 570, 578, - /* 400 */ 686, 577, 576, 588, 587, 586, 585, 584, 583, 582, - /* 410 */ 581, 580, 579, 589, 605, 603, 601, 599, 628, 630, - /* 420 */ 629, 627, 597, 595, 636, 635, 634, 633, 632, 593, - /* 430 */ 618, 617, 591, 626, 625, 624, 569, 590, 575, 534, - /* 440 */ 812, 758, 759, 757, 756, 768, 755, 754, 753, 761, - /* 450 */ 811, 810, 809, 808, 807, 806, 805, 804, 803, 802, - /* 460 */ 801, 800, 799, 798, 772, 771, 770, 769, 767, 766, - /* 470 */ 765, 764, 763, 762, 752, 750, 749, 748, 747, 746, - /* 480 */ 745, 744, 743, 751, 670, 669, 668, 667, 666, 665, - /* 490 */ 664, 663, 662, 661, 660, 659, 658, 657, 656, 655, - /* 500 */ 654, 653, 652, 651, 650, 649, 648, 647, 646, 645, - /* 510 */ 644, 643, 642, 641, 640, 639, 638, 637, 622, 621, - /* 520 */ 533, 530, 529, 528, 527, -}; - -/* The next table maps tokens into fallback tokens. If a construct -** like the following: -** -** %fallback ID X Y Z. -** -** appears in the grammar, then ID becomes a fallback token for X, Y, -** and Z. Whenever one of the tokens X, Y, or Z is input to the parser -** but it does not parse, the type of the token is changed to ID and -** the parse is retried before an error is thrown. -*/ -#ifdef YYFALLBACK -static const YYCODETYPE yyFallback[] = { -}; -#endif /* YYFALLBACK */ - -/* The following structure represents a single element of the -** parser's stack. Information stored includes: -** -** + The state number for the parser at this level of the stack. -** -** + The value of the token stored at this level of the stack. -** (In other words, the "major" token.) -** -** + The semantic value stored at this level of the stack. This is -** the information used by the action routines in the grammar. -** It is sometimes called the "minor" token. -*/ -struct yyStackEntry { - YYACTIONTYPE stateno; /* The state-number */ - YYCODETYPE major; /* The major token value. This is the code - ** number for the token at this stack level */ - YYMINORTYPE minor; /* The user-supplied minor token value. This - ** is the value of the token */ -}; -typedef struct yyStackEntry yyStackEntry; - -/* The state of the parser is completely contained in an instance of -** the following structure */ -struct yyParser { - int yyidx; /* Index of top element in stack */ -#ifdef YYTRACKMAXSTACKDEPTH - int yyidxMax; /* Maximum value of yyidx */ -#endif - int yyerrcnt; /* Shifts left before out of the error */ - ParseHLSLARG_SDECL /* A place to hold %extra_argument */ -#if YYSTACKDEPTH<=0 - int yystksz; /* Current side of the stack */ - yyStackEntry *yystack; /* The parser's stack */ -#else - yyStackEntry yystack[YYSTACKDEPTH]; /* The parser's stack */ -#endif -}; -typedef struct yyParser yyParser; - -#if LEMON_SUPPORT_TRACING /* __MOJOSHADER__ */ -#include <stdio.h> -static FILE *yyTraceFILE = 0; -static char *yyTracePrompt = 0; -#endif /* NDEBUG */ - -#if LEMON_SUPPORT_TRACING /* __MOJOSHADER__ */ -/* -** Turn parser tracing on by giving a stream to which to write the trace -** and a prompt to preface each trace message. Tracing is turned off -** by making either argument NULL -** -** Inputs: -** <ul> -** <li> A FILE* to which trace output should be written. -** If NULL, then tracing is turned off. -** <li> A prefix string written at the beginning of every -** line of trace output. If NULL, then tracing is -** turned off. -** </ul> -** -** Outputs: -** None. -*/ -#if __MOJOSHADER__ -static -#endif -void ParseHLSLTrace(FILE *TraceFILE, char *zTracePrompt){ - yyTraceFILE = TraceFILE; - yyTracePrompt = zTracePrompt; - if( yyTraceFILE==0 ) yyTracePrompt = 0; - else if( yyTracePrompt==0 ) yyTraceFILE = 0; -} -#endif /* NDEBUG */ - -#if LEMON_SUPPORT_TRACING /* __MOJOSHADER__ */ -/* For tracing shifts, the names of all terminals and nonterminals -** are required. The following table supplies these names */ -static const char *const yyTokenName[] = { - "$", "COMMA", "ASSIGN", "ADDASSIGN", - "SUBASSIGN", "MULASSIGN", "DIVASSIGN", "MODASSIGN", - "LSHIFTASSIGN", "RSHIFTASSIGN", "ANDASSIGN", "ORASSIGN", - "XORASSIGN", "QUESTION", "OROR", "ANDAND", - "OR", "XOR", "AND", "EQL", - "NEQ", "LT", "LEQ", "GT", - "GEQ", "LSHIFT", "RSHIFT", "PLUS", - "MINUS", "STAR", "SLASH", "PERCENT", - "TYPECAST", "EXCLAMATION", "COMPLEMENT", "MINUSMINUS", - "PLUSPLUS", "DOT", "LBRACKET", "RBRACKET", - "LPAREN", "RPAREN", "ELSE", "SEMICOLON", - "TYPEDEF", "CONST", "IDENTIFIER", "VOID", - "INLINE", "IN", "INOUT", "OUT", - "UNIFORM", "COLON", "LINEAR", "CENTROID", - "NOINTERPOLATION", "NOPERSPECTIVE", "SAMPLE", "EXTERN", - "SHARED", "STATIC", "VOLATILE", "ROWMAJOR", - "COLUMNMAJOR", "LBRACE", "RBRACE", "STRUCT", - "PACKOFFSET", "REGISTER", "USERTYPE", "SAMPLER", - "SAMPLER1D", "SAMPLER2D", "SAMPLER3D", "SAMPLERCUBE", - "SAMPLER_STATE", "SAMPLERSTATE", "SAMPLERCOMPARISONSTATE", "BOOL", - "INT", "UINT", "HALF", "FLOAT", - "DOUBLE", "STRING", "SNORM", "UNORM", - "BUFFER", "VECTOR", "INT_CONSTANT", "MATRIX", - "ISOLATE", "MAXINSTRUCTIONCOUNT", "NOEXPRESSIONOPTIMIZATIONS", "REMOVEUNUSEDINPUTS", - "UNUSED", "XPS", "BREAK", "CONTINUE", - "DISCARD", "DO", "WHILE", "RETURN", - "UNROLL", "LOOP", "FOR", "BRANCH", - "IF", "FLATTEN", "IFALL", "IFANY", - "PREDICATE", "PREDICATEBLOCK", "SWITCH", "FORCECASE", - "CALL", "CASE", "DEFAULT", "FLOAT_CONSTANT", - "STRING_LITERAL", "TRUE", "FALSE", "error", - "shader", "compilation_units", "compilation_unit", "variable_declaration", - "function_signature", "statement_block", "typedef", "struct_declaration", - "datatype", "scalar_or_array", "function_storageclass", "function_details", - "semantic", "function_parameters", "function_parameter_list", "function_parameter", - "input_modifier", "interpolation_mod", "initializer", "variable_attribute_list", - "variable_declaration_details_list", "variable_attribute", "variable_declaration_details", "annotations", - "variable_lowlevel", "struct_intro", "struct_member_list", "struct_member", - "struct_member_details", "struct_member_item_list", "packoffset", "register", - "expression", "annotation_list", "annotation", "datatype_scalar", - "initializer_block_list", "initializer_block", "intrinsic_datatype", "datatype_vector", - "datatype_matrix", "datatype_sampler", "datatype_buffer", "statement_list", - "statement", "statement_attribute", "do_intro", "while_intro", - "if_intro", "switch_intro", "switch_case_list", "for_statement", - "for_intro", "for_details", "switch_case", "primary_expr", - "postfix_expr", "arguments", "argument_list", "assignment_expr", - "unary_expr", "cast_expr", "multiplicative_expr", "additive_expr", - "shift_expr", "relational_expr", "equality_expr", "and_expr", - "exclusive_or_expr", "inclusive_or_expr", "logical_and_expr", "logical_or_expr", - "conditional_expr", -}; -#endif /* NDEBUG */ - -#if LEMON_SUPPORT_TRACING /* __MOJOSHADER__ */ -/* For tracing reduce actions, the names of all rules are required. -*/ -static const char *const yyRuleName[] = { - /* 0 */ "shader ::= compilation_units", - /* 1 */ "compilation_units ::= compilation_unit", - /* 2 */ "compilation_units ::= compilation_units compilation_unit", - /* 3 */ "compilation_unit ::= variable_declaration", - /* 4 */ "compilation_unit ::= function_signature SEMICOLON", - /* 5 */ "compilation_unit ::= function_signature statement_block", - /* 6 */ "compilation_unit ::= typedef", - /* 7 */ "compilation_unit ::= struct_declaration SEMICOLON", - /* 8 */ "typedef ::= TYPEDEF CONST datatype scalar_or_array", - /* 9 */ "typedef ::= TYPEDEF datatype scalar_or_array", - /* 10 */ "function_signature ::= function_storageclass function_details semantic", - /* 11 */ "function_signature ::= function_storageclass function_details", - /* 12 */ "function_signature ::= function_details semantic", - /* 13 */ "function_signature ::= function_details", - /* 14 */ "function_details ::= datatype IDENTIFIER LPAREN function_parameters RPAREN", - /* 15 */ "function_details ::= VOID IDENTIFIER LPAREN function_parameters RPAREN", - /* 16 */ "function_storageclass ::= INLINE", - /* 17 */ "function_parameters ::= VOID", - /* 18 */ "function_parameters ::= function_parameter_list", - /* 19 */ "function_parameters ::=", - /* 20 */ "function_parameter_list ::= function_parameter", - /* 21 */ "function_parameter_list ::= function_parameter_list COMMA function_parameter", - /* 22 */ "function_parameter ::= input_modifier datatype IDENTIFIER semantic interpolation_mod initializer", - /* 23 */ "function_parameter ::= input_modifier datatype IDENTIFIER semantic interpolation_mod", - /* 24 */ "function_parameter ::= input_modifier datatype IDENTIFIER semantic initializer", - /* 25 */ "function_parameter ::= input_modifier datatype IDENTIFIER semantic", - /* 26 */ "function_parameter ::= input_modifier datatype IDENTIFIER interpolation_mod initializer", - /* 27 */ "function_parameter ::= input_modifier datatype IDENTIFIER interpolation_mod", - /* 28 */ "function_parameter ::= input_modifier datatype IDENTIFIER initializer", - /* 29 */ "function_parameter ::= input_modifier datatype IDENTIFIER", - /* 30 */ "function_parameter ::= datatype IDENTIFIER semantic interpolation_mod initializer", - /* 31 */ "function_parameter ::= datatype IDENTIFIER semantic interpolation_mod", - /* 32 */ "function_parameter ::= datatype IDENTIFIER semantic initializer", - /* 33 */ "function_parameter ::= datatype IDENTIFIER semantic", - /* 34 */ "function_parameter ::= datatype IDENTIFIER interpolation_mod initializer", - /* 35 */ "function_parameter ::= datatype IDENTIFIER interpolation_mod", - /* 36 */ "function_parameter ::= datatype IDENTIFIER initializer", - /* 37 */ "function_parameter ::= datatype IDENTIFIER", - /* 38 */ "input_modifier ::= IN", - /* 39 */ "input_modifier ::= INOUT", - /* 40 */ "input_modifier ::= OUT", - /* 41 */ "input_modifier ::= IN OUT", - /* 42 */ "input_modifier ::= OUT IN", - /* 43 */ "input_modifier ::= UNIFORM", - /* 44 */ "semantic ::= COLON IDENTIFIER", - /* 45 */ "interpolation_mod ::= LINEAR", - /* 46 */ "interpolation_mod ::= CENTROID", - /* 47 */ "interpolation_mod ::= NOINTERPOLATION", - /* 48 */ "interpolation_mod ::= NOPERSPECTIVE", - /* 49 */ "interpolation_mod ::= SAMPLE", - /* 50 */ "variable_declaration ::= variable_attribute_list datatype variable_declaration_details_list SEMICOLON", - /* 51 */ "variable_declaration ::= datatype variable_declaration_details_list SEMICOLON", - /* 52 */ "variable_declaration ::= struct_declaration variable_declaration_details_list SEMICOLON", - /* 53 */ "variable_attribute_list ::= variable_attribute", - /* 54 */ "variable_attribute_list ::= variable_attribute_list variable_attribute", - /* 55 */ "variable_attribute ::= EXTERN", - /* 56 */ "variable_attribute ::= NOINTERPOLATION", - /* 57 */ "variable_attribute ::= SHARED", - /* 58 */ "variable_attribute ::= STATIC", - /* 59 */ "variable_attribute ::= UNIFORM", - /* 60 */ "variable_attribute ::= VOLATILE", - /* 61 */ "variable_attribute ::= CONST", - /* 62 */ "variable_attribute ::= ROWMAJOR", - /* 63 */ "variable_attribute ::= COLUMNMAJOR", - /* 64 */ "variable_declaration_details_list ::= variable_declaration_details", - /* 65 */ "variable_declaration_details_list ::= variable_declaration_details_list COMMA variable_declaration_details", - /* 66 */ "variable_declaration_details ::= scalar_or_array semantic annotations initializer variable_lowlevel", - /* 67 */ "variable_declaration_details ::= scalar_or_array semantic annotations initializer", - /* 68 */ "variable_declaration_details ::= scalar_or_array semantic annotations variable_lowlevel", - /* 69 */ "variable_declaration_details ::= scalar_or_array semantic annotations", - /* 70 */ "variable_declaration_details ::= scalar_or_array semantic initializer variable_lowlevel", - /* 71 */ "variable_declaration_details ::= scalar_or_array semantic initializer", - /* 72 */ "variable_declaration_details ::= scalar_or_array semantic variable_lowlevel", - /* 73 */ "variable_declaration_details ::= scalar_or_array semantic", - /* 74 */ "variable_declaration_details ::= scalar_or_array annotations initializer variable_lowlevel", - /* 75 */ "variable_declaration_details ::= scalar_or_array annotations initializer", - /* 76 */ "variable_declaration_details ::= scalar_or_array annotations variable_lowlevel", - /* 77 */ "variable_declaration_details ::= scalar_or_array annotations", - /* 78 */ "variable_declaration_details ::= scalar_or_array initializer variable_lowlevel", - /* 79 */ "variable_declaration_details ::= scalar_or_array initializer", - /* 80 */ "variable_declaration_details ::= scalar_or_array variable_lowlevel", - /* 81 */ "variable_declaration_details ::= scalar_or_array", - /* 82 */ "struct_declaration ::= struct_intro LBRACE struct_member_list RBRACE", - /* 83 */ "struct_intro ::= STRUCT IDENTIFIER", - /* 84 */ "struct_member_list ::= struct_member", - /* 85 */ "struct_member_list ::= struct_member_list struct_member", - /* 86 */ "struct_member ::= interpolation_mod struct_member_details", - /* 87 */ "struct_member ::= struct_member_details", - /* 88 */ "struct_member_details ::= datatype struct_member_item_list SEMICOLON", - /* 89 */ "struct_member_item_list ::= scalar_or_array", - /* 90 */ "struct_member_item_list ::= scalar_or_array semantic", - /* 91 */ "struct_member_item_list ::= struct_member_item_list COMMA IDENTIFIER", - /* 92 */ "variable_lowlevel ::= packoffset register", - /* 93 */ "variable_lowlevel ::= register packoffset", - /* 94 */ "variable_lowlevel ::= packoffset", - /* 95 */ "variable_lowlevel ::= register", - /* 96 */ "scalar_or_array ::= IDENTIFIER LBRACKET RBRACKET", - /* 97 */ "scalar_or_array ::= IDENTIFIER LBRACKET expression RBRACKET", - /* 98 */ "scalar_or_array ::= IDENTIFIER", - /* 99 */ "packoffset ::= COLON PACKOFFSET LPAREN IDENTIFIER DOT IDENTIFIER RPAREN", - /* 100 */ "packoffset ::= COLON PACKOFFSET LPAREN IDENTIFIER RPAREN", - /* 101 */ "register ::= COLON REGISTER LPAREN IDENTIFIER RPAREN", - /* 102 */ "annotations ::= LT annotation_list GT", - /* 103 */ "annotation_list ::= annotation", - /* 104 */ "annotation_list ::= annotation_list annotation", - /* 105 */ "annotation ::= datatype_scalar initializer SEMICOLON", - /* 106 */ "initializer_block_list ::= expression", - /* 107 */ "initializer_block_list ::= LBRACE initializer_block_list RBRACE", - /* 108 */ "initializer_block_list ::= initializer_block_list COMMA initializer_block_list", - /* 109 */ "initializer_block ::= LBRACE initializer_block_list RBRACE", - /* 110 */ "initializer ::= ASSIGN initializer_block", - /* 111 */ "initializer ::= ASSIGN expression", - /* 112 */ "intrinsic_datatype ::= datatype_vector", - /* 113 */ "intrinsic_datatype ::= datatype_matrix", - /* 114 */ "intrinsic_datatype ::= datatype_scalar", - /* 115 */ "intrinsic_datatype ::= datatype_sampler", - /* 116 */ "intrinsic_datatype ::= datatype_buffer", - /* 117 */ "datatype ::= intrinsic_datatype", - /* 118 */ "datatype ::= USERTYPE", - /* 119 */ "datatype_sampler ::= SAMPLER", - /* 120 */ "datatype_sampler ::= SAMPLER1D", - /* 121 */ "datatype_sampler ::= SAMPLER2D", - /* 122 */ "datatype_sampler ::= SAMPLER3D", - /* 123 */ "datatype_sampler ::= SAMPLERCUBE", - /* 124 */ "datatype_sampler ::= SAMPLER_STATE", - /* 125 */ "datatype_sampler ::= SAMPLERSTATE", - /* 126 */ "datatype_sampler ::= SAMPLERCOMPARISONSTATE", - /* 127 */ "datatype_scalar ::= BOOL", - /* 128 */ "datatype_scalar ::= INT", - /* 129 */ "datatype_scalar ::= UINT", - /* 130 */ "datatype_scalar ::= HALF", - /* 131 */ "datatype_scalar ::= FLOAT", - /* 132 */ "datatype_scalar ::= DOUBLE", - /* 133 */ "datatype_scalar ::= STRING", - /* 134 */ "datatype_scalar ::= SNORM FLOAT", - /* 135 */ "datatype_scalar ::= UNORM FLOAT", - /* 136 */ "datatype_buffer ::= BUFFER LT BOOL GT", - /* 137 */ "datatype_buffer ::= BUFFER LT INT GT", - /* 138 */ "datatype_buffer ::= BUFFER LT UINT GT", - /* 139 */ "datatype_buffer ::= BUFFER LT HALF GT", - /* 140 */ "datatype_buffer ::= BUFFER LT FLOAT GT", - /* 141 */ "datatype_buffer ::= BUFFER LT DOUBLE GT", - /* 142 */ "datatype_buffer ::= BUFFER LT SNORM FLOAT GT", - /* 143 */ "datatype_buffer ::= BUFFER LT UNORM FLOAT GT", - /* 144 */ "datatype_vector ::= VECTOR LT datatype_scalar COMMA INT_CONSTANT GT", - /* 145 */ "datatype_matrix ::= MATRIX LT datatype_scalar COMMA INT_CONSTANT COMMA INT_CONSTANT GT", - /* 146 */ "statement_block ::= LBRACE RBRACE", - /* 147 */ "statement_block ::= LBRACE statement_list RBRACE", - /* 148 */ "statement_list ::= statement", - /* 149 */ "statement_list ::= statement_list statement", - /* 150 */ "statement_attribute ::= ISOLATE", - /* 151 */ "statement_attribute ::= MAXINSTRUCTIONCOUNT LPAREN INT_CONSTANT RPAREN", - /* 152 */ "statement_attribute ::= NOEXPRESSIONOPTIMIZATIONS", - /* 153 */ "statement_attribute ::= REMOVEUNUSEDINPUTS", - /* 154 */ "statement_attribute ::= UNUSED", - /* 155 */ "statement_attribute ::= XPS", - /* 156 */ "statement ::= BREAK SEMICOLON", - /* 157 */ "statement ::= CONTINUE SEMICOLON", - /* 158 */ "statement ::= DISCARD SEMICOLON", - /* 159 */ "statement ::= LBRACKET statement_attribute RBRACKET statement_block", - /* 160 */ "statement ::= variable_declaration", - /* 161 */ "statement ::= struct_declaration SEMICOLON", - /* 162 */ "statement ::= do_intro DO statement WHILE LPAREN expression RPAREN SEMICOLON", - /* 163 */ "statement ::= while_intro LPAREN expression RPAREN statement", - /* 164 */ "statement ::= if_intro LPAREN expression RPAREN statement", - /* 165 */ "statement ::= if_intro LPAREN expression RPAREN statement ELSE statement", - /* 166 */ "statement ::= switch_intro LPAREN expression RPAREN LBRACE switch_case_list RBRACE", - /* 167 */ "statement ::= typedef", - /* 168 */ "statement ::= SEMICOLON", - /* 169 */ "statement ::= expression SEMICOLON", - /* 170 */ "statement ::= RETURN SEMICOLON", - /* 171 */ "statement ::= RETURN expression SEMICOLON", - /* 172 */ "statement ::= statement_block", - /* 173 */ "statement ::= for_statement", - /* 174 */ "while_intro ::= LBRACKET UNROLL LPAREN INT_CONSTANT RPAREN RBRACKET WHILE", - /* 175 */ "while_intro ::= LBRACKET UNROLL RBRACKET WHILE", - /* 176 */ "while_intro ::= LBRACKET LOOP RBRACKET WHILE", - /* 177 */ "while_intro ::= WHILE", - /* 178 */ "for_statement ::= for_intro for_details", - /* 179 */ "for_intro ::= LBRACKET UNROLL LPAREN INT_CONSTANT RPAREN RBRACKET FOR", - /* 180 */ "for_intro ::= LBRACKET UNROLL RBRACKET FOR", - /* 181 */ "for_intro ::= LBRACKET LOOP RBRACKET FOR", - /* 182 */ "for_intro ::= FOR", - /* 183 */ "for_details ::= LPAREN expression SEMICOLON expression SEMICOLON expression RPAREN statement", - /* 184 */ "for_details ::= LPAREN SEMICOLON SEMICOLON RPAREN statement", - /* 185 */ "for_details ::= LPAREN SEMICOLON SEMICOLON expression RPAREN statement", - /* 186 */ "for_details ::= LPAREN SEMICOLON expression SEMICOLON RPAREN statement", - /* 187 */ "for_details ::= LPAREN SEMICOLON expression SEMICOLON expression RPAREN statement", - /* 188 */ "for_details ::= LPAREN expression SEMICOLON SEMICOLON RPAREN statement", - /* 189 */ "for_details ::= LPAREN expression SEMICOLON SEMICOLON expression RPAREN statement", - /* 190 */ "for_details ::= LPAREN expression SEMICOLON expression SEMICOLON RPAREN statement", - /* 191 */ "for_details ::= LPAREN variable_declaration expression SEMICOLON expression RPAREN statement", - /* 192 */ "for_details ::= LPAREN variable_declaration SEMICOLON RPAREN statement", - /* 193 */ "for_details ::= LPAREN variable_declaration SEMICOLON expression RPAREN statement", - /* 194 */ "for_details ::= LPAREN variable_declaration expression SEMICOLON RPAREN statement", - /* 195 */ "do_intro ::= LBRACKET UNROLL LPAREN INT_CONSTANT RPAREN RBRACKET DO", - /* 196 */ "do_intro ::= LBRACKET UNROLL RBRACKET DO", - /* 197 */ "do_intro ::= LBRACKET LOOP RBRACKET DO", - /* 198 */ "do_intro ::= DO", - /* 199 */ "if_intro ::= LBRACKET BRANCH RBRACKET IF", - /* 200 */ "if_intro ::= LBRACKET FLATTEN RBRACKET IF", - /* 201 */ "if_intro ::= LBRACKET IFALL RBRACKET IF", - /* 202 */ "if_intro ::= LBRACKET IFANY RBRACKET IF", - /* 203 */ "if_intro ::= LBRACKET PREDICATE RBRACKET IF", - /* 204 */ "if_intro ::= LBRACKET PREDICATEBLOCK RBRACKET IF", - /* 205 */ "if_intro ::= IF", - /* 206 */ "switch_intro ::= LBRACKET FLATTEN RBRACKET SWITCH", - /* 207 */ "switch_intro ::= LBRACKET BRANCH RBRACKET SWITCH", - /* 208 */ "switch_intro ::= LBRACKET FORCECASE RBRACKET SWITCH", - /* 209 */ "switch_intro ::= LBRACKET CALL RBRACKET SWITCH", - /* 210 */ "switch_intro ::= SWITCH", - /* 211 */ "switch_case_list ::= switch_case", - /* 212 */ "switch_case_list ::= switch_case_list switch_case", - /* 213 */ "switch_case ::= CASE expression COLON statement_list", - /* 214 */ "switch_case ::= CASE expression COLON", - /* 215 */ "switch_case ::= DEFAULT COLON statement_list", - /* 216 */ "switch_case ::= DEFAULT COLON", - /* 217 */ "primary_expr ::= IDENTIFIER", - /* 218 */ "primary_expr ::= INT_CONSTANT", - /* 219 */ "primary_expr ::= FLOAT_CONSTANT", - /* 220 */ "primary_expr ::= STRING_LITERAL", - /* 221 */ "primary_expr ::= TRUE", - /* 222 */ "primary_expr ::= FALSE", - /* 223 */ "primary_expr ::= LPAREN expression RPAREN", - /* 224 */ "postfix_expr ::= primary_expr", - /* 225 */ "postfix_expr ::= postfix_expr LBRACKET expression RBRACKET", - /* 226 */ "postfix_expr ::= IDENTIFIER arguments", - /* 227 */ "postfix_expr ::= datatype arguments", - /* 228 */ "postfix_expr ::= postfix_expr DOT IDENTIFIER", - /* 229 */ "postfix_expr ::= postfix_expr PLUSPLUS", - /* 230 */ "postfix_expr ::= postfix_expr MINUSMINUS", - /* 231 */ "arguments ::= LPAREN RPAREN", - /* 232 */ "arguments ::= LPAREN argument_list RPAREN", - /* 233 */ "argument_list ::= assignment_expr", - /* 234 */ "argument_list ::= argument_list COMMA assignment_expr", - /* 235 */ "unary_expr ::= postfix_expr", - /* 236 */ "unary_expr ::= PLUSPLUS unary_expr", - /* 237 */ "unary_expr ::= MINUSMINUS unary_expr", - /* 238 */ "unary_expr ::= PLUS cast_expr", - /* 239 */ "unary_expr ::= MINUS cast_expr", - /* 240 */ "unary_expr ::= COMPLEMENT cast_expr", - /* 241 */ "unary_expr ::= EXCLAMATION cast_expr", - /* 242 */ "cast_expr ::= unary_expr", - /* 243 */ "cast_expr ::= LPAREN datatype RPAREN cast_expr", - /* 244 */ "multiplicative_expr ::= cast_expr", - /* 245 */ "multiplicative_expr ::= multiplicative_expr STAR cast_expr", - /* 246 */ "multiplicative_expr ::= multiplicative_expr SLASH cast_expr", - /* 247 */ "multiplicative_expr ::= multiplicative_expr PERCENT cast_expr", - /* 248 */ "additive_expr ::= multiplicative_expr", - /* 249 */ "additive_expr ::= additive_expr PLUS multiplicative_expr", - /* 250 */ "additive_expr ::= additive_expr MINUS multiplicative_expr", - /* 251 */ "shift_expr ::= additive_expr", - /* 252 */ "shift_expr ::= shift_expr LSHIFT additive_expr", - /* 253 */ "shift_expr ::= shift_expr RSHIFT additive_expr", - /* 254 */ "relational_expr ::= shift_expr", - /* 255 */ "relational_expr ::= relational_expr LT shift_expr", - /* 256 */ "relational_expr ::= relational_expr GT shift_expr", - /* 257 */ "relational_expr ::= relational_expr LEQ shift_expr", - /* 258 */ "relational_expr ::= relational_expr GEQ shift_expr", - /* 259 */ "equality_expr ::= relational_expr", - /* 260 */ "equality_expr ::= equality_expr EQL relational_expr", - /* 261 */ "equality_expr ::= equality_expr NEQ relational_expr", - /* 262 */ "and_expr ::= equality_expr", - /* 263 */ "and_expr ::= and_expr AND equality_expr", - /* 264 */ "exclusive_or_expr ::= and_expr", - /* 265 */ "exclusive_or_expr ::= exclusive_or_expr XOR and_expr", - /* 266 */ "inclusive_or_expr ::= exclusive_or_expr", - /* 267 */ "inclusive_or_expr ::= inclusive_or_expr OR exclusive_or_expr", - /* 268 */ "logical_and_expr ::= inclusive_or_expr", - /* 269 */ "logical_and_expr ::= logical_and_expr ANDAND inclusive_or_expr", - /* 270 */ "logical_or_expr ::= logical_and_expr", - /* 271 */ "logical_or_expr ::= logical_or_expr OROR logical_and_expr", - /* 272 */ "conditional_expr ::= logical_or_expr", - /* 273 */ "conditional_expr ::= logical_or_expr QUESTION logical_or_expr COLON conditional_expr", - /* 274 */ "assignment_expr ::= conditional_expr", - /* 275 */ "assignment_expr ::= unary_expr ASSIGN assignment_expr", - /* 276 */ "assignment_expr ::= unary_expr MULASSIGN assignment_expr", - /* 277 */ "assignment_expr ::= unary_expr DIVASSIGN assignment_expr", - /* 278 */ "assignment_expr ::= unary_expr MODASSIGN assignment_expr", - /* 279 */ "assignment_expr ::= unary_expr ADDASSIGN assignment_expr", - /* 280 */ "assignment_expr ::= unary_expr SUBASSIGN assignment_expr", - /* 281 */ "assignment_expr ::= unary_expr LSHIFTASSIGN assignment_expr", - /* 282 */ "assignment_expr ::= unary_expr RSHIFTASSIGN assignment_expr", - /* 283 */ "assignment_expr ::= unary_expr ANDASSIGN assignment_expr", - /* 284 */ "assignment_expr ::= unary_expr XORASSIGN assignment_expr", - /* 285 */ "assignment_expr ::= unary_expr ORASSIGN assignment_expr", - /* 286 */ "expression ::= assignment_expr", - /* 287 */ "expression ::= expression COMMA assignment_expr", -}; -#endif /* NDEBUG */ - - -#if YYSTACKDEPTH<=0 -/* -** Try to increase the size of the parser stack. -*/ -static void yyGrowStack(yyParser *p){ - int newSize; - yyStackEntry *pNew; - - newSize = p->yystksz*2 + 100; - pNew = realloc(p->yystack, newSize*sizeof(pNew[0])); - if( pNew ){ - p->yystack = pNew; - p->yystksz = newSize; -#if LEMON_SUPPORT_TRACING /* __MOJOSHADER__ */ - if( yyTraceFILE ){ - fprintf(yyTraceFILE,"%sStack grows to %d entries!\n", - yyTracePrompt, p->yystksz); - } -#endif - } -} -#endif - -/* -** This function allocates a new parser. -** The only argument is a pointer to a function which works like -** malloc. -** -** Inputs: -** A pointer to the function used to allocate memory. -** -** Outputs: -** A pointer to a parser. This pointer is used in subsequent calls -** to ParseHLSL and ParseHLSLFree. -*/ -#if __MOJOSHADER__ -static void *ParseHLSLAlloc(void *(*mallocProc)(int,void *), void *malloc_data){ - yyParser *pParser; - pParser = (yyParser*)(*mallocProc)( (int)sizeof(yyParser), malloc_data ); -#else -void *ParseHLSLAlloc(void *(*mallocProc)(size_t)){ - yyParser *pParser; - pParser = (yyParser*)(*mallocProc)( (size_t)sizeof(yyParser) ); -#endif - if( pParser ){ - pParser->yyidx = -1; -#ifdef YYTRACKMAXSTACKDEPTH - pParser->yyidxMax = 0; -#endif -#if YYSTACKDEPTH<=0 - pParser->yystack = NULL; - pParser->yystksz = 0; - yyGrowStack(pParser); -#endif - } - return pParser; -} - -/* The following function deletes the value associated with a -** symbol. The symbol can be either a terminal or nonterminal. -** "yymajor" is the symbol code, and "yypminor" is a pointer to -** the value. -*/ -static void yy_destructor( - yyParser *yypParser, /* The parser */ - YYCODETYPE yymajor, /* Type code for object to destroy */ - YYMINORTYPE *yypminor /* The object to be destroyed */ -){ - ParseHLSLARG_FETCH; - switch( yymajor ){ - /* Here is inserted the actions which take place when a - ** terminal or non-terminal is destroyed. This can happen - ** when the symbol is popped from the stack during a - ** reduce or during error processing or when a parser is - ** being destroyed before it is finished parsing. - ** - ** Note: during a reduce, the only symbols destroyed are those - ** which appear on the RHS of the rule, but which are not used - ** inside the C code. - */ - case 125: /* compilation_units */ - case 126: /* compilation_unit */ -{ -#line 81 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" - delete_compilation_unit(ctx, (yypminor->yy139)); -#line 2033 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" -} - break; - case 127: /* variable_declaration */ - case 144: /* variable_declaration_details_list */ - case 146: /* variable_declaration_details */ -{ -#line 175 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" - delete_variable_declaration(ctx, (yypminor->yy24)); -#line 2042 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" -} - break; - case 128: /* function_signature */ - case 135: /* function_details */ -{ -#line 102 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" - delete_function_signature(ctx, (yypminor->yy364)); -#line 2050 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" -} - break; - case 129: /* statement_block */ - case 167: /* statement_list */ - case 168: /* statement */ - case 175: /* for_statement */ - case 177: /* for_details */ -{ -#line 354 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" - delete_statement(ctx, (yypminor->yy233)); -#line 2061 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" -} - break; - case 130: /* typedef */ -{ -#line 96 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" - delete_typedef(ctx, (yypminor->yy71)); -#line 2068 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" -} - break; - case 131: /* struct_declaration */ -{ -#line 224 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" - delete_struct_declaration(ctx, (yypminor->yy249)); -#line 2075 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" -} - break; - case 133: /* scalar_or_array */ -{ -#line 260 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" - delete_scalar_or_array(ctx, (yypminor->yy380)); -#line 2082 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" -} - break; - case 137: /* function_parameters */ - case 138: /* function_parameter_list */ - case 139: /* function_parameter */ -{ -#line 124 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" - delete_function_params(ctx, (yypminor->yy307)); -#line 2091 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" -} - break; - case 142: /* initializer */ - case 156: /* expression */ - case 160: /* initializer_block_list */ - case 161: /* initializer_block */ - case 179: /* primary_expr */ - case 180: /* postfix_expr */ - case 183: /* assignment_expr */ - case 184: /* unary_expr */ - case 185: /* cast_expr */ - case 186: /* multiplicative_expr */ - case 187: /* additive_expr */ - case 188: /* shift_expr */ - case 189: /* relational_expr */ - case 190: /* equality_expr */ - case 191: /* and_expr */ - case 192: /* exclusive_or_expr */ - case 193: /* inclusive_or_expr */ - case 194: /* logical_and_expr */ - case 195: /* logical_or_expr */ - case 196: /* conditional_expr */ -{ -#line 301 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" - delete_expr(ctx, (yypminor->yy322)); -#line 2117 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" -} - break; - case 147: /* annotations */ - case 157: /* annotation_list */ - case 158: /* annotation */ -{ -#line 277 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" - delete_annotation(ctx, (yypminor->yy268)); -#line 2126 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" -} - break; - case 148: /* variable_lowlevel */ -{ -#line 252 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" - delete_variable_lowlevel(ctx, (yypminor->yy82)); -#line 2133 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" -} - break; - case 150: /* struct_member_list */ - case 151: /* struct_member */ - case 152: /* struct_member_details */ - case 153: /* struct_member_item_list */ -{ -#line 232 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" - delete_struct_member(ctx, (yypminor->yy346)); -#line 2143 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" -} - break; - case 154: /* packoffset */ -{ -#line 266 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" - delete_pack_offset(ctx, (yypminor->yy8)); -#line 2150 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" -} - break; - case 174: /* switch_case_list */ - case 178: /* switch_case */ -{ -#line 450 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" - delete_switch_case(ctx, (yypminor->yy165)); -#line 2158 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" -} - break; - case 181: /* arguments */ - case 182: /* argument_list */ -{ -#line 485 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" - delete_arguments(ctx, (yypminor->yy26)); -#line 2166 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" -} - break; - default: break; /* If no destructor action specified: do nothing */ - } -} - -/* -** Pop the parser's stack once. -** -** If there is a destructor routine associated with the token which -** is popped from the stack, then call it. -** -** Return the major token number for the symbol popped. -*/ -static int yy_pop_parser_stack(yyParser *pParser){ - YYCODETYPE yymajor; - yyStackEntry *yytos = &pParser->yystack[pParser->yyidx]; - - if( pParser->yyidx<0 ) return 0; -#if LEMON_SUPPORT_TRACING /* __MOJOSHADER__ */ - if( yyTraceFILE && pParser->yyidx>=0 ){ - fprintf(yyTraceFILE,"%sPopping %s\n", - yyTracePrompt, - yyTokenName[yytos->major]); - } -#endif - yymajor = yytos->major; - yy_destructor(pParser, yymajor, &yytos->minor); - pParser->yyidx--; - return yymajor; -} - -/* -** Deallocate and destroy a parser. Destructors are all called for -** all stack elements before shutting the parser down. -** -** Inputs: -** <ul> -** <li> A pointer to the parser. This should be a pointer -** obtained from ParseHLSLAlloc. -** <li> A pointer to a function used to reclaim memory obtained -** from malloc. -** </ul> -*/ -#if __MOJOSHADER__ -static -#endif -void ParseHLSLFree( - void *p, /* The parser to be deleted */ -#if __MOJOSHADER__ - void (*freeProc)(void*,void*), /* Function used to reclaim memory */ - void *malloc_data -#else - void (*freeProc)(void*) /* Function used to reclaim memory */ -#endif -){ - yyParser *pParser = (yyParser*)p; - if( pParser==0 ) return; - while( pParser->yyidx>=0 ) yy_pop_parser_stack(pParser); -#if YYSTACKDEPTH<=0 - free(pParser->yystack); -#endif -#if __MOJOSHADER__ - (*freeProc)((void*)pParser, malloc_data); -#else - (*freeProc)((void*)pParser); -#endif -} - -/* -** Return the peak depth of the stack for a parser. -*/ -#ifdef YYTRACKMAXSTACKDEPTH -static int ParseHLSLStackPeak(void *p){ - yyParser *pParser = (yyParser*)p; - return pParser->yyidxMax; -} -#endif - -/* -** Find the appropriate action for a parser given the terminal -** look-ahead token iLookAhead. -** -** If the look-ahead token is YYNOCODE, then check to see if the action is -** independent of the look-ahead. If it is, return the action, otherwise -** return YY_NO_ACTION. -*/ -static int yy_find_shift_action( - yyParser *pParser, /* The parser */ - YYCODETYPE iLookAhead /* The look-ahead token */ -){ - int i; - int stateno = pParser->yystack[pParser->yyidx].stateno; - - if( stateno>YY_SHIFT_COUNT - || (i = yy_shift_ofst[stateno])==YY_SHIFT_USE_DFLT ){ - return yy_default[stateno]; - } - assert( iLookAhead!=YYNOCODE ); - i += iLookAhead; - if( i<0 || i>=YY_ACTTAB_COUNT || yy_lookahead[i]!=iLookAhead ){ - if( iLookAhead>0 ){ -#ifdef YYFALLBACK - YYCODETYPE iFallback; /* Fallback token */ - if( iLookAhead<sizeof(yyFallback)/sizeof(yyFallback[0]) - && (iFallback = yyFallback[iLookAhead])!=0 ){ -#if LEMON_SUPPORT_TRACING /* __MOJOSHADER__ */ - if( yyTraceFILE ){ - fprintf(yyTraceFILE, "%sFALLBACK %s => %s\n", - yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[iFallback]); - } -#endif - return yy_find_shift_action(pParser, iFallback); - } -#endif -#ifdef YYWILDCARD - { - int j = i - iLookAhead + YYWILDCARD; - if( -#if YY_SHIFT_MIN+YYWILDCARD<0 - j>=0 && -#endif -#if YY_SHIFT_MAX+YYWILDCARD>=YY_ACTTAB_COUNT - j<YY_ACTTAB_COUNT && -#endif - yy_lookahead[j]==YYWILDCARD - ){ -#if LEMON_SUPPORT_TRACING /* __MOJOSHADER__ */ - if( yyTraceFILE ){ - fprintf(yyTraceFILE, "%sWILDCARD %s => %s\n", - yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[YYWILDCARD]); - } -#endif /* NDEBUG */ - return yy_action[j]; - } - } -#endif /* YYWILDCARD */ - } - return yy_default[stateno]; - }else{ - return yy_action[i]; - } -} - -/* -** Find the appropriate action for a parser given the non-terminal -** look-ahead token iLookAhead. -** -** If the look-ahead token is YYNOCODE, then check to see if the action is -** independent of the look-ahead. If it is, return the action, otherwise -** return YY_NO_ACTION. -*/ -static int yy_find_reduce_action( - int stateno, /* Current state number */ - YYCODETYPE iLookAhead /* The look-ahead token */ -){ - int i; -#ifdef YYERRORSYMBOL - if( stateno>YY_REDUCE_COUNT ){ - return yy_default[stateno]; - } -#else - assert( stateno<=YY_REDUCE_COUNT ); -#endif - i = yy_reduce_ofst[stateno]; - assert( i!=YY_REDUCE_USE_DFLT ); - assert( iLookAhead!=YYNOCODE ); - i += iLookAhead; -#ifdef YYERRORSYMBOL - if( i<0 || i>=YY_ACTTAB_COUNT || yy_lookahead[i]!=iLookAhead ){ - return yy_default[stateno]; - } -#else - assert( i>=0 && i<YY_ACTTAB_COUNT ); - assert( yy_lookahead[i]==iLookAhead ); -#endif - return yy_action[i]; -} - -/* -** The following routine is called if the stack overflows. -*/ -static void yyStackOverflow(yyParser *yypParser, YYMINORTYPE *yypMinor){ - ParseHLSLARG_FETCH; - yypParser->yyidx--; -#if LEMON_SUPPORT_TRACING /* __MOJOSHADER__ */ - if( yyTraceFILE ){ - fprintf(yyTraceFILE,"%sStack Overflow!\n",yyTracePrompt); - } -#endif - while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser); - /* Here code is inserted which will execute if the parser - ** stack every overflows */ -#line 47 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" - - // !!! FIXME: make this a proper fail() function. - fail(ctx, "Giving up. Parser stack overflow"); -#line 2364 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - ParseHLSLARG_STORE; /* Suppress warning about unused %extra_argument var */ -} - -/* -** Perform a shift action. -*/ -static void yy_shift( - yyParser *yypParser, /* The parser to be shifted */ - int yyNewState, /* The new state to shift in */ - int yyMajor, /* The major token to shift in */ - YYMINORTYPE *yypMinor /* Pointer to the minor token to shift in */ -){ - yyStackEntry *yytos; - yypParser->yyidx++; -#ifdef YYTRACKMAXSTACKDEPTH - if( yypParser->yyidx>yypParser->yyidxMax ){ - yypParser->yyidxMax = yypParser->yyidx; - } -#endif -#if YYSTACKDEPTH>0 - if( yypParser->yyidx>=YYSTACKDEPTH ){ - yyStackOverflow(yypParser, yypMinor); - return; - } -#else - if( yypParser->yyidx>=yypParser->yystksz ){ - yyGrowStack(yypParser); - if( yypParser->yyidx>=yypParser->yystksz ){ - yyStackOverflow(yypParser, yypMinor); - return; - } - } -#endif - yytos = &yypParser->yystack[yypParser->yyidx]; - yytos->stateno = (YYACTIONTYPE)yyNewState; - yytos->major = (YYCODETYPE)yyMajor; - yytos->minor = *yypMinor; -#if LEMON_SUPPORT_TRACING /* __MOJOSHADER__ */ - if( yyTraceFILE && yypParser->yyidx>0 ){ - int i; - fprintf(yyTraceFILE,"%sShift %d\n",yyTracePrompt,yyNewState); - fprintf(yyTraceFILE,"%sStack:",yyTracePrompt); - for(i=1; i<=yypParser->yyidx; i++) - fprintf(yyTraceFILE," %s",yyTokenName[yypParser->yystack[i].major]); - fprintf(yyTraceFILE,"\n"); - } -#endif -} - -/* The following table contains information about every rule that -** is used during the reduce. -*/ -static const struct { - YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */ - unsigned char nrhs; /* Number of right-hand side symbols in the rule */ -} yyRuleInfo[] = { - { 124, 1 }, - { 125, 1 }, - { 125, 2 }, - { 126, 1 }, - { 126, 2 }, - { 126, 2 }, - { 126, 1 }, - { 126, 2 }, - { 130, 4 }, - { 130, 3 }, - { 128, 3 }, - { 128, 2 }, - { 128, 2 }, - { 128, 1 }, - { 135, 5 }, - { 135, 5 }, - { 134, 1 }, - { 137, 1 }, - { 137, 1 }, - { 137, 0 }, - { 138, 1 }, - { 138, 3 }, - { 139, 6 }, - { 139, 5 }, - { 139, 5 }, - { 139, 4 }, - { 139, 5 }, - { 139, 4 }, - { 139, 4 }, - { 139, 3 }, - { 139, 5 }, - { 139, 4 }, - { 139, 4 }, - { 139, 3 }, - { 139, 4 }, - { 139, 3 }, - { 139, 3 }, - { 139, 2 }, - { 140, 1 }, - { 140, 1 }, - { 140, 1 }, - { 140, 2 }, - { 140, 2 }, - { 140, 1 }, - { 136, 2 }, - { 141, 1 }, - { 141, 1 }, - { 141, 1 }, - { 141, 1 }, - { 141, 1 }, - { 127, 4 }, - { 127, 3 }, - { 127, 3 }, - { 143, 1 }, - { 143, 2 }, - { 145, 1 }, - { 145, 1 }, - { 145, 1 }, - { 145, 1 }, - { 145, 1 }, - { 145, 1 }, - { 145, 1 }, - { 145, 1 }, - { 145, 1 }, - { 144, 1 }, - { 144, 3 }, - { 146, 5 }, - { 146, 4 }, - { 146, 4 }, - { 146, 3 }, - { 146, 4 }, - { 146, 3 }, - { 146, 3 }, - { 146, 2 }, - { 146, 4 }, - { 146, 3 }, - { 146, 3 }, - { 146, 2 }, - { 146, 3 }, - { 146, 2 }, - { 146, 2 }, - { 146, 1 }, - { 131, 4 }, - { 149, 2 }, - { 150, 1 }, - { 150, 2 }, - { 151, 2 }, - { 151, 1 }, - { 152, 3 }, - { 153, 1 }, - { 153, 2 }, - { 153, 3 }, - { 148, 2 }, - { 148, 2 }, - { 148, 1 }, - { 148, 1 }, - { 133, 3 }, - { 133, 4 }, - { 133, 1 }, - { 154, 7 }, - { 154, 5 }, - { 155, 5 }, - { 147, 3 }, - { 157, 1 }, - { 157, 2 }, - { 158, 3 }, - { 160, 1 }, - { 160, 3 }, - { 160, 3 }, - { 161, 3 }, - { 142, 2 }, - { 142, 2 }, - { 162, 1 }, - { 162, 1 }, - { 162, 1 }, - { 162, 1 }, - { 162, 1 }, - { 132, 1 }, - { 132, 1 }, - { 165, 1 }, - { 165, 1 }, - { 165, 1 }, - { 165, 1 }, - { 165, 1 }, - { 165, 1 }, - { 165, 1 }, - { 165, 1 }, - { 159, 1 }, - { 159, 1 }, - { 159, 1 }, - { 159, 1 }, - { 159, 1 }, - { 159, 1 }, - { 159, 1 }, - { 159, 2 }, - { 159, 2 }, - { 166, 4 }, - { 166, 4 }, - { 166, 4 }, - { 166, 4 }, - { 166, 4 }, - { 166, 4 }, - { 166, 5 }, - { 166, 5 }, - { 163, 6 }, - { 164, 8 }, - { 129, 2 }, - { 129, 3 }, - { 167, 1 }, - { 167, 2 }, - { 169, 1 }, - { 169, 4 }, - { 169, 1 }, - { 169, 1 }, - { 169, 1 }, - { 169, 1 }, - { 168, 2 }, - { 168, 2 }, - { 168, 2 }, - { 168, 4 }, - { 168, 1 }, - { 168, 2 }, - { 168, 8 }, - { 168, 5 }, - { 168, 5 }, - { 168, 7 }, - { 168, 7 }, - { 168, 1 }, - { 168, 1 }, - { 168, 2 }, - { 168, 2 }, - { 168, 3 }, - { 168, 1 }, - { 168, 1 }, - { 171, 7 }, - { 171, 4 }, - { 171, 4 }, - { 171, 1 }, - { 175, 2 }, - { 176, 7 }, - { 176, 4 }, - { 176, 4 }, - { 176, 1 }, - { 177, 8 }, - { 177, 5 }, - { 177, 6 }, - { 177, 6 }, - { 177, 7 }, - { 177, 6 }, - { 177, 7 }, - { 177, 7 }, - { 177, 7 }, - { 177, 5 }, - { 177, 6 }, - { 177, 6 }, - { 170, 7 }, - { 170, 4 }, - { 170, 4 }, - { 170, 1 }, - { 172, 4 }, - { 172, 4 }, - { 172, 4 }, - { 172, 4 }, - { 172, 4 }, - { 172, 4 }, - { 172, 1 }, - { 173, 4 }, - { 173, 4 }, - { 173, 4 }, - { 173, 4 }, - { 173, 1 }, - { 174, 1 }, - { 174, 2 }, - { 178, 4 }, - { 178, 3 }, - { 178, 3 }, - { 178, 2 }, - { 179, 1 }, - { 179, 1 }, - { 179, 1 }, - { 179, 1 }, - { 179, 1 }, - { 179, 1 }, - { 179, 3 }, - { 180, 1 }, - { 180, 4 }, - { 180, 2 }, - { 180, 2 }, - { 180, 3 }, - { 180, 2 }, - { 180, 2 }, - { 181, 2 }, - { 181, 3 }, - { 182, 1 }, - { 182, 3 }, - { 184, 1 }, - { 184, 2 }, - { 184, 2 }, - { 184, 2 }, - { 184, 2 }, - { 184, 2 }, - { 184, 2 }, - { 185, 1 }, - { 185, 4 }, - { 186, 1 }, - { 186, 3 }, - { 186, 3 }, - { 186, 3 }, - { 187, 1 }, - { 187, 3 }, - { 187, 3 }, - { 188, 1 }, - { 188, 3 }, - { 188, 3 }, - { 189, 1 }, - { 189, 3 }, - { 189, 3 }, - { 189, 3 }, - { 189, 3 }, - { 190, 1 }, - { 190, 3 }, - { 190, 3 }, - { 191, 1 }, - { 191, 3 }, - { 192, 1 }, - { 192, 3 }, - { 193, 1 }, - { 193, 3 }, - { 194, 1 }, - { 194, 3 }, - { 195, 1 }, - { 195, 3 }, - { 196, 1 }, - { 196, 5 }, - { 183, 1 }, - { 183, 3 }, - { 183, 3 }, - { 183, 3 }, - { 183, 3 }, - { 183, 3 }, - { 183, 3 }, - { 183, 3 }, - { 183, 3 }, - { 183, 3 }, - { 183, 3 }, - { 183, 3 }, - { 156, 1 }, - { 156, 3 }, -}; - -static void yy_accept(yyParser*); /* Forward Declaration */ - -/* -** Perform a reduce action and the shift that must immediately -** follow the reduce. -*/ -static void yy_reduce( - yyParser *yypParser, /* The parser */ - int yyruleno /* Number of the rule by which to reduce */ -){ - int yygoto; /* The next state */ - int yyact; /* The next action */ - YYMINORTYPE yygotominor; /* The LHS of the rule reduced */ - yyStackEntry *yymsp; /* The top of the parser's stack */ - int yysize; /* Amount to pop the stack */ - ParseHLSLARG_FETCH; - yymsp = &yypParser->yystack[yypParser->yyidx]; -#if LEMON_SUPPORT_TRACING /* __MOJOSHADER__ */ - if( yyTraceFILE && yyruleno>=0 - && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){ - fprintf(yyTraceFILE, "%sReduce [%s].\n", yyTracePrompt, - yyRuleName[yyruleno]); - } -#endif /* NDEBUG */ - - /* Silence complaints from purify about yygotominor being uninitialized - ** in some cases when it is copied into the stack after the following - ** switch. yygotominor is uninitialized when a rule reduces that does - ** not set the value of its left-hand side nonterminal. Leaving the - ** value of the nonterminal uninitialized is utterly harmless as long - ** as the value is never used. So really the only thing this code - ** accomplishes is to quieten purify. - ** - ** 2007-01-16: The wireshark project (www.wireshark.org) reports that - ** without this code, their parser segfaults. I'm not sure what there - ** parser is doing to make this happen. This is the second bug report - ** from wireshark this week. Clearly they are stressing Lemon in ways - ** that it has not been previously stressed... (SQLite ticket #2172) - */ - /*memset(&yygotominor, 0, sizeof(yygotominor));*/ - yygotominor = yyzerominor; - - - switch( yyruleno ){ - /* Beginning here are the reduction cases. A typical example - ** follows: - ** case 0: - ** #line <lineno> <grammarfile> - ** { ... } // User supplied code - ** #line <lineno> <thisfile> - ** break; - */ - case 0: /* shader ::= compilation_units */ -#line 78 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ assert(ctx->ast == NULL); REVERSE_LINKED_LIST(MOJOSHADER_astCompilationUnit, yymsp[0].minor.yy139); ctx->ast = (MOJOSHADER_astNode *) yymsp[0].minor.yy139; } -#line 2766 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 1: /* compilation_units ::= compilation_unit */ -#line 82 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy139 = yymsp[0].minor.yy139; } -#line 2771 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 2: /* compilation_units ::= compilation_units compilation_unit */ -#line 83 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ if (yymsp[0].minor.yy139) { yymsp[0].minor.yy139->next = yymsp[-1].minor.yy139; yygotominor.yy139 = yymsp[0].minor.yy139; } } -#line 2776 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 3: /* compilation_unit ::= variable_declaration */ -#line 88 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy139 = new_global_variable(ctx, yymsp[0].minor.yy24); } -#line 2781 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 4: /* compilation_unit ::= function_signature SEMICOLON */ -#line 89 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy139 = new_function(ctx, yymsp[-1].minor.yy364, NULL); } -#line 2786 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 5: /* compilation_unit ::= function_signature statement_block */ -#line 90 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy139 = new_function(ctx, yymsp[-1].minor.yy364, yymsp[0].minor.yy233); } -#line 2791 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 6: /* compilation_unit ::= typedef */ -#line 91 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy139 = new_global_typedef(ctx, yymsp[0].minor.yy71); } -#line 2796 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 7: /* compilation_unit ::= struct_declaration SEMICOLON */ -#line 92 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy139 = new_global_struct(ctx, yymsp[-1].minor.yy249); } -#line 2801 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 8: /* typedef ::= TYPEDEF CONST datatype scalar_or_array */ -#line 98 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy71 = new_typedef(ctx, 1, yymsp[-1].minor.yy37, yymsp[0].minor.yy380); push_usertype(ctx, yymsp[0].minor.yy380->identifier, yygotominor.yy71->datatype); } -#line 2806 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 9: /* typedef ::= TYPEDEF datatype scalar_or_array */ -#line 99 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy71 = new_typedef(ctx, 0, yymsp[-1].minor.yy37, yymsp[0].minor.yy380); push_usertype(ctx, yymsp[0].minor.yy380->identifier, yygotominor.yy71->datatype); } -#line 2811 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 10: /* function_signature ::= function_storageclass function_details semantic */ -#line 103 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy364 = yymsp[-1].minor.yy364; yygotominor.yy364->storage_class = yymsp[-2].minor.yy175; yygotominor.yy364->semantic = yymsp[0].minor.yy306; } -#line 2816 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 11: /* function_signature ::= function_storageclass function_details */ -#line 104 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy364 = yymsp[0].minor.yy364; yygotominor.yy364->storage_class = yymsp[-1].minor.yy175; } -#line 2821 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 12: /* function_signature ::= function_details semantic */ -#line 105 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy364 = yymsp[-1].minor.yy364; yygotominor.yy364->semantic = yymsp[0].minor.yy306; } -#line 2826 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 13: /* function_signature ::= function_details */ -#line 106 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy364 = yymsp[0].minor.yy364; } -#line 2831 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 14: /* function_details ::= datatype IDENTIFIER LPAREN function_parameters RPAREN */ -#line 110 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy364 = new_function_signature(ctx, yymsp[-4].minor.yy37, yymsp[-3].minor.yy0.string, yymsp[-1].minor.yy307); } -#line 2836 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 15: /* function_details ::= VOID IDENTIFIER LPAREN function_parameters RPAREN */ -#line 111 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy364 = new_function_signature(ctx, NULL, yymsp[-3].minor.yy0.string, yymsp[-1].minor.yy307); } -#line 2841 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 16: /* function_storageclass ::= INLINE */ -#line 121 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy175 = MOJOSHADER_AST_FNSTORECLS_INLINE; } -#line 2846 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 17: /* function_parameters ::= VOID */ - case 19: /* function_parameters ::= */ yytestcase(yyruleno==19); -#line 125 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy307 = NULL; } -#line 2852 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 18: /* function_parameters ::= function_parameter_list */ -#line 126 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ REVERSE_LINKED_LIST(MOJOSHADER_astFunctionParameters, yymsp[0].minor.yy307); yygotominor.yy307 = yymsp[0].minor.yy307; } -#line 2857 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 20: /* function_parameter_list ::= function_parameter */ -#line 131 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy307 = yymsp[0].minor.yy307; } -#line 2862 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 21: /* function_parameter_list ::= function_parameter_list COMMA function_parameter */ -#line 132 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yymsp[0].minor.yy307->next = yymsp[-2].minor.yy307; yygotominor.yy307 = yymsp[0].minor.yy307; } -#line 2867 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 22: /* function_parameter ::= input_modifier datatype IDENTIFIER semantic interpolation_mod initializer */ -#line 138 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy307 = new_function_param(ctx, yymsp[-5].minor.yy75, yymsp[-4].minor.yy37, yymsp[-3].minor.yy0.string, yymsp[-2].minor.yy306, yymsp[-1].minor.yy111, yymsp[0].minor.yy322); } -#line 2872 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 23: /* function_parameter ::= input_modifier datatype IDENTIFIER semantic interpolation_mod */ -#line 139 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy307 = new_function_param(ctx, yymsp[-4].minor.yy75, yymsp[-3].minor.yy37, yymsp[-2].minor.yy0.string, yymsp[-1].minor.yy306, yymsp[0].minor.yy111, NULL); } -#line 2877 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 24: /* function_parameter ::= input_modifier datatype IDENTIFIER semantic initializer */ -#line 140 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy307 = new_function_param(ctx, yymsp[-4].minor.yy75, yymsp[-3].minor.yy37, yymsp[-2].minor.yy0.string, yymsp[-1].minor.yy306, MOJOSHADER_AST_INTERPMOD_NONE, yymsp[0].minor.yy322); } -#line 2882 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 25: /* function_parameter ::= input_modifier datatype IDENTIFIER semantic */ -#line 141 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy307 = new_function_param(ctx, yymsp[-3].minor.yy75, yymsp[-2].minor.yy37, yymsp[-1].minor.yy0.string, yymsp[0].minor.yy306, MOJOSHADER_AST_INTERPMOD_NONE, NULL); } -#line 2887 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 26: /* function_parameter ::= input_modifier datatype IDENTIFIER interpolation_mod initializer */ -#line 142 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy307 = new_function_param(ctx, yymsp[-4].minor.yy75, yymsp[-3].minor.yy37, yymsp[-2].minor.yy0.string, NULL, yymsp[-1].minor.yy111, yymsp[0].minor.yy322); } -#line 2892 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 27: /* function_parameter ::= input_modifier datatype IDENTIFIER interpolation_mod */ -#line 143 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy307 = new_function_param(ctx, yymsp[-3].minor.yy75, yymsp[-2].minor.yy37, yymsp[-1].minor.yy0.string, NULL, yymsp[0].minor.yy111, NULL); } -#line 2897 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 28: /* function_parameter ::= input_modifier datatype IDENTIFIER initializer */ -#line 144 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy307 = new_function_param(ctx, yymsp[-3].minor.yy75, yymsp[-2].minor.yy37, yymsp[-1].minor.yy0.string, NULL, MOJOSHADER_AST_INTERPMOD_NONE, yymsp[0].minor.yy322); } -#line 2902 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 29: /* function_parameter ::= input_modifier datatype IDENTIFIER */ -#line 145 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy307 = new_function_param(ctx, yymsp[-2].minor.yy75, yymsp[-1].minor.yy37, yymsp[0].minor.yy0.string, NULL, MOJOSHADER_AST_INTERPMOD_NONE, NULL); } -#line 2907 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 30: /* function_parameter ::= datatype IDENTIFIER semantic interpolation_mod initializer */ -#line 146 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy307 = new_function_param(ctx, MOJOSHADER_AST_INPUTMOD_NONE, yymsp[-4].minor.yy37, yymsp[-3].minor.yy0.string, yymsp[-2].minor.yy306, yymsp[-1].minor.yy111, yymsp[0].minor.yy322); } -#line 2912 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 31: /* function_parameter ::= datatype IDENTIFIER semantic interpolation_mod */ -#line 147 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy307 = new_function_param(ctx, MOJOSHADER_AST_INPUTMOD_NONE, yymsp[-3].minor.yy37, yymsp[-2].minor.yy0.string, yymsp[-1].minor.yy306, yymsp[0].minor.yy111, NULL); } -#line 2917 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 32: /* function_parameter ::= datatype IDENTIFIER semantic initializer */ -#line 148 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy307 = new_function_param(ctx, MOJOSHADER_AST_INPUTMOD_NONE, yymsp[-3].minor.yy37, yymsp[-2].minor.yy0.string, yymsp[-1].minor.yy306, MOJOSHADER_AST_INTERPMOD_NONE, yymsp[0].minor.yy322); } -#line 2922 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 33: /* function_parameter ::= datatype IDENTIFIER semantic */ -#line 149 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy307 = new_function_param(ctx, MOJOSHADER_AST_INPUTMOD_NONE, yymsp[-2].minor.yy37, yymsp[-1].minor.yy0.string, yymsp[0].minor.yy306, MOJOSHADER_AST_INTERPMOD_NONE, NULL); } -#line 2927 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 34: /* function_parameter ::= datatype IDENTIFIER interpolation_mod initializer */ -#line 150 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy307 = new_function_param(ctx, MOJOSHADER_AST_INPUTMOD_NONE, yymsp[-3].minor.yy37, yymsp[-2].minor.yy0.string, NULL, yymsp[-1].minor.yy111, yymsp[0].minor.yy322); } -#line 2932 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 35: /* function_parameter ::= datatype IDENTIFIER interpolation_mod */ -#line 151 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy307 = new_function_param(ctx, MOJOSHADER_AST_INPUTMOD_NONE, yymsp[-2].minor.yy37, yymsp[-1].minor.yy0.string, NULL, yymsp[0].minor.yy111, NULL); } -#line 2937 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 36: /* function_parameter ::= datatype IDENTIFIER initializer */ -#line 152 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy307 = new_function_param(ctx, MOJOSHADER_AST_INPUTMOD_NONE, yymsp[-2].minor.yy37, yymsp[-1].minor.yy0.string, NULL, MOJOSHADER_AST_INTERPMOD_NONE, yymsp[0].minor.yy322); } -#line 2942 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 37: /* function_parameter ::= datatype IDENTIFIER */ -#line 153 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy307 = new_function_param(ctx, MOJOSHADER_AST_INPUTMOD_NONE, yymsp[-1].minor.yy37, yymsp[0].minor.yy0.string, NULL, MOJOSHADER_AST_INTERPMOD_NONE, NULL); } -#line 2947 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 38: /* input_modifier ::= IN */ -#line 156 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy75 = MOJOSHADER_AST_INPUTMOD_IN; } -#line 2952 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 39: /* input_modifier ::= INOUT */ - case 41: /* input_modifier ::= IN OUT */ yytestcase(yyruleno==41); - case 42: /* input_modifier ::= OUT IN */ yytestcase(yyruleno==42); -#line 157 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy75 = MOJOSHADER_AST_INPUTMOD_INOUT; } -#line 2959 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 40: /* input_modifier ::= OUT */ -#line 158 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy75 = MOJOSHADER_AST_INPUTMOD_OUT; } -#line 2964 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 43: /* input_modifier ::= UNIFORM */ -#line 161 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy75 = MOJOSHADER_AST_INPUTMOD_UNIFORM; } -#line 2969 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 44: /* semantic ::= COLON IDENTIFIER */ -#line 164 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy306 = yymsp[0].minor.yy0.string; } -#line 2974 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 45: /* interpolation_mod ::= LINEAR */ -#line 168 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy111 = MOJOSHADER_AST_INTERPMOD_LINEAR; } -#line 2979 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 46: /* interpolation_mod ::= CENTROID */ -#line 169 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy111 = MOJOSHADER_AST_INTERPMOD_CENTROID; } -#line 2984 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 47: /* interpolation_mod ::= NOINTERPOLATION */ -#line 170 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy111 = MOJOSHADER_AST_INTERPMOD_NOINTERPOLATION; } -#line 2989 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 48: /* interpolation_mod ::= NOPERSPECTIVE */ -#line 171 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy111 = MOJOSHADER_AST_INTERPMOD_NOPERSPECTIVE; } -#line 2994 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 49: /* interpolation_mod ::= SAMPLE */ -#line 172 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy111 = MOJOSHADER_AST_INTERPMOD_SAMPLE; } -#line 2999 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 50: /* variable_declaration ::= variable_attribute_list datatype variable_declaration_details_list SEMICOLON */ -#line 176 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ REVERSE_LINKED_LIST(MOJOSHADER_astVariableDeclaration, yymsp[-1].minor.yy24); yygotominor.yy24 = yymsp[-1].minor.yy24; yygotominor.yy24->attributes = yymsp[-3].minor.yy270; yygotominor.yy24->datatype = yymsp[-2].minor.yy37; } -#line 3004 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 51: /* variable_declaration ::= datatype variable_declaration_details_list SEMICOLON */ -#line 177 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ REVERSE_LINKED_LIST(MOJOSHADER_astVariableDeclaration, yymsp[-1].minor.yy24); yygotominor.yy24 = yymsp[-1].minor.yy24; yygotominor.yy24->datatype = yymsp[-2].minor.yy37; } -#line 3009 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 52: /* variable_declaration ::= struct_declaration variable_declaration_details_list SEMICOLON */ -#line 179 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ REVERSE_LINKED_LIST(MOJOSHADER_astVariableDeclaration, yymsp[-1].minor.yy24); yygotominor.yy24 = yymsp[-1].minor.yy24; yygotominor.yy24->anonymous_datatype = yymsp[-2].minor.yy249; } -#line 3014 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 53: /* variable_attribute_list ::= variable_attribute */ -#line 182 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy270 = yymsp[0].minor.yy270; } -#line 3019 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 54: /* variable_attribute_list ::= variable_attribute_list variable_attribute */ -#line 183 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy270 = yymsp[-1].minor.yy270 | yymsp[0].minor.yy270; } -#line 3024 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 55: /* variable_attribute ::= EXTERN */ -#line 186 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy270 = MOJOSHADER_AST_VARATTR_EXTERN; } -#line 3029 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 56: /* variable_attribute ::= NOINTERPOLATION */ -#line 187 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy270 = MOJOSHADER_AST_VARATTR_NOINTERPOLATION; } -#line 3034 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 57: /* variable_attribute ::= SHARED */ -#line 188 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy270 = MOJOSHADER_AST_VARATTR_SHARED; } -#line 3039 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 58: /* variable_attribute ::= STATIC */ -#line 189 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy270 = MOJOSHADER_AST_VARATTR_STATIC; } -#line 3044 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 59: /* variable_attribute ::= UNIFORM */ -#line 190 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy270 = MOJOSHADER_AST_VARATTR_UNIFORM; } -#line 3049 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 60: /* variable_attribute ::= VOLATILE */ -#line 191 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy270 = MOJOSHADER_AST_VARATTR_VOLATILE; } -#line 3054 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 61: /* variable_attribute ::= CONST */ -#line 192 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy270 = MOJOSHADER_AST_VARATTR_CONST; } -#line 3059 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 62: /* variable_attribute ::= ROWMAJOR */ -#line 193 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy270 = MOJOSHADER_AST_VARATTR_ROWMAJOR; } -#line 3064 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 63: /* variable_attribute ::= COLUMNMAJOR */ -#line 194 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy270 = MOJOSHADER_AST_VARATTR_COLUMNMAJOR; } -#line 3069 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 64: /* variable_declaration_details_list ::= variable_declaration_details */ -#line 198 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy24 = yymsp[0].minor.yy24; } -#line 3074 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 65: /* variable_declaration_details_list ::= variable_declaration_details_list COMMA variable_declaration_details */ -#line 199 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy24 = yymsp[0].minor.yy24; yygotominor.yy24->next = yymsp[-2].minor.yy24; } -#line 3079 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 66: /* variable_declaration_details ::= scalar_or_array semantic annotations initializer variable_lowlevel */ -#line 203 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy24 = new_variable_declaration(ctx, yymsp[-4].minor.yy380, yymsp[-3].minor.yy306, yymsp[-2].minor.yy268, yymsp[-1].minor.yy322, yymsp[0].minor.yy82); } -#line 3084 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 67: /* variable_declaration_details ::= scalar_or_array semantic annotations initializer */ -#line 204 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy24 = new_variable_declaration(ctx, yymsp[-3].minor.yy380, yymsp[-2].minor.yy306, yymsp[-1].minor.yy268, yymsp[0].minor.yy322, NULL); } -#line 3089 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 68: /* variable_declaration_details ::= scalar_or_array semantic annotations variable_lowlevel */ -#line 205 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy24 = new_variable_declaration(ctx, yymsp[-3].minor.yy380, yymsp[-2].minor.yy306, yymsp[-1].minor.yy268, NULL, yymsp[0].minor.yy82); } -#line 3094 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 69: /* variable_declaration_details ::= scalar_or_array semantic annotations */ -#line 206 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy24 = new_variable_declaration(ctx, yymsp[-2].minor.yy380, yymsp[-1].minor.yy306, yymsp[0].minor.yy268, NULL, NULL); } -#line 3099 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 70: /* variable_declaration_details ::= scalar_or_array semantic initializer variable_lowlevel */ -#line 207 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy24 = new_variable_declaration(ctx, yymsp[-3].minor.yy380, yymsp[-2].minor.yy306, NULL, yymsp[-1].minor.yy322, yymsp[0].minor.yy82); } -#line 3104 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 71: /* variable_declaration_details ::= scalar_or_array semantic initializer */ -#line 208 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy24 = new_variable_declaration(ctx, yymsp[-2].minor.yy380, yymsp[-1].minor.yy306, NULL, yymsp[0].minor.yy322, NULL); } -#line 3109 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 72: /* variable_declaration_details ::= scalar_or_array semantic variable_lowlevel */ -#line 209 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy24 = new_variable_declaration(ctx, yymsp[-2].minor.yy380, yymsp[-1].minor.yy306, NULL, NULL, yymsp[0].minor.yy82); } -#line 3114 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 73: /* variable_declaration_details ::= scalar_or_array semantic */ -#line 210 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy24 = new_variable_declaration(ctx, yymsp[-1].minor.yy380, yymsp[0].minor.yy306, NULL, NULL, NULL); } -#line 3119 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 74: /* variable_declaration_details ::= scalar_or_array annotations initializer variable_lowlevel */ -#line 211 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy24 = new_variable_declaration(ctx, yymsp[-3].minor.yy380, NULL, yymsp[-2].minor.yy268, yymsp[-1].minor.yy322, yymsp[0].minor.yy82); } -#line 3124 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 75: /* variable_declaration_details ::= scalar_or_array annotations initializer */ -#line 212 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy24 = new_variable_declaration(ctx, yymsp[-2].minor.yy380, NULL, yymsp[-1].minor.yy268, yymsp[0].minor.yy322, NULL); } -#line 3129 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 76: /* variable_declaration_details ::= scalar_or_array annotations variable_lowlevel */ -#line 213 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy24 = new_variable_declaration(ctx, yymsp[-2].minor.yy380, NULL, yymsp[-1].minor.yy268, NULL, yymsp[0].minor.yy82); } -#line 3134 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 77: /* variable_declaration_details ::= scalar_or_array annotations */ -#line 214 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy24 = new_variable_declaration(ctx, yymsp[-1].minor.yy380, NULL, yymsp[0].minor.yy268, NULL, NULL); } -#line 3139 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 78: /* variable_declaration_details ::= scalar_or_array initializer variable_lowlevel */ -#line 215 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy24 = new_variable_declaration(ctx, yymsp[-2].minor.yy380, NULL, NULL, yymsp[-1].minor.yy322, yymsp[0].minor.yy82); } -#line 3144 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 79: /* variable_declaration_details ::= scalar_or_array initializer */ -#line 216 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy24 = new_variable_declaration(ctx, yymsp[-1].minor.yy380, NULL, NULL, yymsp[0].minor.yy322, NULL); } -#line 3149 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 80: /* variable_declaration_details ::= scalar_or_array variable_lowlevel */ -#line 217 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy24 = new_variable_declaration(ctx, yymsp[-1].minor.yy380, NULL, NULL, NULL, yymsp[0].minor.yy82); } -#line 3154 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 81: /* variable_declaration_details ::= scalar_or_array */ -#line 218 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy24 = new_variable_declaration(ctx, yymsp[0].minor.yy380, NULL, NULL, NULL, NULL); } -#line 3159 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 82: /* struct_declaration ::= struct_intro LBRACE struct_member_list RBRACE */ -#line 225 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ REVERSE_LINKED_LIST(MOJOSHADER_astStructMembers, yymsp[-1].minor.yy346); yygotominor.yy249 = new_struct_declaration(ctx, yymsp[-3].minor.yy306, yymsp[-1].minor.yy346); } -#line 3164 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 83: /* struct_intro ::= STRUCT IDENTIFIER */ -#line 229 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy306 = yymsp[0].minor.yy0.string; push_usertype(ctx, yygotominor.yy306, &ctx->dt_none); } -#line 3169 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 84: /* struct_member_list ::= struct_member */ - case 87: /* struct_member ::= struct_member_details */ yytestcase(yyruleno==87); -#line 233 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy346 = yymsp[0].minor.yy346; } -#line 3175 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 85: /* struct_member_list ::= struct_member_list struct_member */ -#line 234 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy346 = yymsp[0].minor.yy346; MOJOSHADER_astStructMembers *i = yygotominor.yy346; while (i->next) { i = i->next; } i->next = yymsp[-1].minor.yy346; } -#line 3180 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 86: /* struct_member ::= interpolation_mod struct_member_details */ -#line 238 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ MOJOSHADER_astStructMembers *i = yymsp[0].minor.yy346; yygotominor.yy346 = yymsp[0].minor.yy346; while (i) { i->interpolation_mod = yymsp[-1].minor.yy111; i = i->next; } } -#line 3185 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 88: /* struct_member_details ::= datatype struct_member_item_list SEMICOLON */ -#line 243 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ MOJOSHADER_astStructMembers *i = yymsp[-1].minor.yy346; yygotominor.yy346 = yymsp[-1].minor.yy346; while (i) { i->datatype = yymsp[-2].minor.yy37; i = i->next; } } -#line 3190 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 89: /* struct_member_item_list ::= scalar_or_array */ -#line 247 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy346 = new_struct_member(ctx, yymsp[0].minor.yy380, NULL); } -#line 3195 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 90: /* struct_member_item_list ::= scalar_or_array semantic */ -#line 248 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy346 = new_struct_member(ctx, yymsp[-1].minor.yy380, yymsp[0].minor.yy306); } -#line 3200 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 91: /* struct_member_item_list ::= struct_member_item_list COMMA IDENTIFIER */ -#line 249 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy346 = new_struct_member(ctx, new_scalar_or_array(ctx, yymsp[0].minor.yy0.string, 0, NULL), NULL); yygotominor.yy346->next = yymsp[-2].minor.yy346; yygotominor.yy346->semantic = yymsp[-2].minor.yy346->semantic; } -#line 3205 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 92: /* variable_lowlevel ::= packoffset register */ -#line 253 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy82 = new_variable_lowlevel(ctx, yymsp[-1].minor.yy8, yymsp[0].minor.yy306); } -#line 3210 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 93: /* variable_lowlevel ::= register packoffset */ -#line 254 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy82 = new_variable_lowlevel(ctx, yymsp[0].minor.yy8, yymsp[-1].minor.yy306); } -#line 3215 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 94: /* variable_lowlevel ::= packoffset */ -#line 255 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy82 = new_variable_lowlevel(ctx, yymsp[0].minor.yy8, NULL); } -#line 3220 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 95: /* variable_lowlevel ::= register */ -#line 256 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy82 = new_variable_lowlevel(ctx, NULL, yymsp[0].minor.yy306); } -#line 3225 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 96: /* scalar_or_array ::= IDENTIFIER LBRACKET RBRACKET */ -#line 261 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy380 = new_scalar_or_array(ctx, yymsp[-2].minor.yy0.string, 1, NULL); } -#line 3230 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 97: /* scalar_or_array ::= IDENTIFIER LBRACKET expression RBRACKET */ -#line 262 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy380 = new_scalar_or_array(ctx, yymsp[-3].minor.yy0.string, 1, yymsp[-1].minor.yy322); } -#line 3235 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 98: /* scalar_or_array ::= IDENTIFIER */ -#line 263 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy380 = new_scalar_or_array(ctx, yymsp[0].minor.yy0.string, 0, NULL); } -#line 3240 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 99: /* packoffset ::= COLON PACKOFFSET LPAREN IDENTIFIER DOT IDENTIFIER RPAREN */ -#line 267 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy8 = new_pack_offset(ctx, yymsp[-3].minor.yy0.string, yymsp[-1].minor.yy0.string); } -#line 3245 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 100: /* packoffset ::= COLON PACKOFFSET LPAREN IDENTIFIER RPAREN */ -#line 268 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy8 = new_pack_offset(ctx, yymsp[-1].minor.yy0.string, NULL); } -#line 3250 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 101: /* register ::= COLON REGISTER LPAREN IDENTIFIER RPAREN */ -#line 274 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy306 = yymsp[-1].minor.yy0.string; } -#line 3255 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 102: /* annotations ::= LT annotation_list GT */ -#line 278 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ REVERSE_LINKED_LIST(MOJOSHADER_astAnnotations, yymsp[-1].minor.yy268); yygotominor.yy268 = yymsp[-1].minor.yy268; } -#line 3260 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 103: /* annotation_list ::= annotation */ -#line 282 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy268 = yymsp[0].minor.yy268; } -#line 3265 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 104: /* annotation_list ::= annotation_list annotation */ -#line 283 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy268 = yymsp[0].minor.yy268; yygotominor.yy268->next = yymsp[-1].minor.yy268; } -#line 3270 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 105: /* annotation ::= datatype_scalar initializer SEMICOLON */ -#line 288 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy268 = new_annotation(ctx, yymsp[-2].minor.yy37, yymsp[-1].minor.yy322); } -#line 3275 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 106: /* initializer_block_list ::= expression */ - case 110: /* initializer ::= ASSIGN initializer_block */ yytestcase(yyruleno==110); - case 111: /* initializer ::= ASSIGN expression */ yytestcase(yyruleno==111); - case 224: /* postfix_expr ::= primary_expr */ yytestcase(yyruleno==224); - case 235: /* unary_expr ::= postfix_expr */ yytestcase(yyruleno==235); - case 238: /* unary_expr ::= PLUS cast_expr */ yytestcase(yyruleno==238); - case 242: /* cast_expr ::= unary_expr */ yytestcase(yyruleno==242); - case 244: /* multiplicative_expr ::= cast_expr */ yytestcase(yyruleno==244); - case 248: /* additive_expr ::= multiplicative_expr */ yytestcase(yyruleno==248); - case 251: /* shift_expr ::= additive_expr */ yytestcase(yyruleno==251); - case 254: /* relational_expr ::= shift_expr */ yytestcase(yyruleno==254); - case 259: /* equality_expr ::= relational_expr */ yytestcase(yyruleno==259); - case 262: /* and_expr ::= equality_expr */ yytestcase(yyruleno==262); - case 264: /* exclusive_or_expr ::= and_expr */ yytestcase(yyruleno==264); - case 266: /* inclusive_or_expr ::= exclusive_or_expr */ yytestcase(yyruleno==266); - case 268: /* logical_and_expr ::= inclusive_or_expr */ yytestcase(yyruleno==268); - case 270: /* logical_or_expr ::= logical_and_expr */ yytestcase(yyruleno==270); - case 272: /* conditional_expr ::= logical_or_expr */ yytestcase(yyruleno==272); - case 274: /* assignment_expr ::= conditional_expr */ yytestcase(yyruleno==274); - case 286: /* expression ::= assignment_expr */ yytestcase(yyruleno==286); -#line 292 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy322 = yymsp[0].minor.yy322; } -#line 3299 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 107: /* initializer_block_list ::= LBRACE initializer_block_list RBRACE */ - case 109: /* initializer_block ::= LBRACE initializer_block_list RBRACE */ yytestcase(yyruleno==109); - case 223: /* primary_expr ::= LPAREN expression RPAREN */ yytestcase(yyruleno==223); -#line 293 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy322 = yymsp[-1].minor.yy322; } -#line 3306 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 108: /* initializer_block_list ::= initializer_block_list COMMA initializer_block_list */ - case 287: /* expression ::= expression COMMA assignment_expr */ yytestcase(yyruleno==287); -#line 294 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy322 = new_binary_expr(ctx, MOJOSHADER_AST_OP_COMMA, yymsp[-2].minor.yy322, yymsp[0].minor.yy322); } -#line 3312 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 112: /* intrinsic_datatype ::= datatype_vector */ - case 113: /* intrinsic_datatype ::= datatype_matrix */ yytestcase(yyruleno==113); - case 114: /* intrinsic_datatype ::= datatype_scalar */ yytestcase(yyruleno==114); - case 115: /* intrinsic_datatype ::= datatype_sampler */ yytestcase(yyruleno==115); - case 116: /* intrinsic_datatype ::= datatype_buffer */ yytestcase(yyruleno==116); - case 117: /* datatype ::= intrinsic_datatype */ yytestcase(yyruleno==117); -#line 306 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy37 = yymsp[0].minor.yy37; } -#line 3322 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 118: /* datatype ::= USERTYPE */ -#line 314 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy37 = yymsp[0].minor.yy0.datatype; } -#line 3327 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 119: /* datatype_sampler ::= SAMPLER */ - case 121: /* datatype_sampler ::= SAMPLER2D */ yytestcase(yyruleno==121); -#line 317 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy37 = &ctx->dt_sampler2d; } -#line 3333 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 120: /* datatype_sampler ::= SAMPLER1D */ -#line 318 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy37 = &ctx->dt_sampler1d; } -#line 3338 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 122: /* datatype_sampler ::= SAMPLER3D */ -#line 320 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy37 = &ctx->dt_sampler3d; } -#line 3343 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 123: /* datatype_sampler ::= SAMPLERCUBE */ -#line 321 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy37 = &ctx->dt_samplercube; } -#line 3348 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 124: /* datatype_sampler ::= SAMPLER_STATE */ - case 125: /* datatype_sampler ::= SAMPLERSTATE */ yytestcase(yyruleno==125); -#line 322 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy37 = &ctx->dt_samplerstate; } -#line 3354 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 126: /* datatype_sampler ::= SAMPLERCOMPARISONSTATE */ -#line 324 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy37 = &ctx->dt_samplercompstate; } -#line 3359 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 127: /* datatype_scalar ::= BOOL */ -#line 327 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy37 = &ctx->dt_bool; } -#line 3364 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 128: /* datatype_scalar ::= INT */ -#line 328 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy37 = &ctx->dt_int; } -#line 3369 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 129: /* datatype_scalar ::= UINT */ -#line 329 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy37 = &ctx->dt_uint; } -#line 3374 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 130: /* datatype_scalar ::= HALF */ -#line 330 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy37 = &ctx->dt_half; } -#line 3379 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 131: /* datatype_scalar ::= FLOAT */ -#line 331 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy37 = &ctx->dt_float; } -#line 3384 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 132: /* datatype_scalar ::= DOUBLE */ -#line 332 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy37 = &ctx->dt_double; } -#line 3389 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 133: /* datatype_scalar ::= STRING */ -#line 333 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy37 = &ctx->dt_string; } -#line 3394 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 134: /* datatype_scalar ::= SNORM FLOAT */ -#line 334 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy37 = &ctx->dt_float_snorm; } -#line 3399 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 135: /* datatype_scalar ::= UNORM FLOAT */ -#line 335 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy37 = &ctx->dt_float_unorm; } -#line 3404 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 136: /* datatype_buffer ::= BUFFER LT BOOL GT */ -#line 338 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy37 = &ctx->dt_buf_bool; } -#line 3409 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 137: /* datatype_buffer ::= BUFFER LT INT GT */ -#line 339 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy37 = &ctx->dt_buf_int; } -#line 3414 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 138: /* datatype_buffer ::= BUFFER LT UINT GT */ -#line 340 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy37 = &ctx->dt_buf_uint; } -#line 3419 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 139: /* datatype_buffer ::= BUFFER LT HALF GT */ -#line 341 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy37 = &ctx->dt_buf_half; } -#line 3424 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 140: /* datatype_buffer ::= BUFFER LT FLOAT GT */ -#line 342 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy37 = &ctx->dt_buf_float; } -#line 3429 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 141: /* datatype_buffer ::= BUFFER LT DOUBLE GT */ -#line 343 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy37 = &ctx->dt_buf_double; } -#line 3434 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 142: /* datatype_buffer ::= BUFFER LT SNORM FLOAT GT */ -#line 344 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy37 = &ctx->dt_buf_float_snorm; } -#line 3439 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 143: /* datatype_buffer ::= BUFFER LT UNORM FLOAT GT */ -#line 345 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy37 = &ctx->dt_buf_float_unorm; } -#line 3444 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 144: /* datatype_vector ::= VECTOR LT datatype_scalar COMMA INT_CONSTANT GT */ -#line 348 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy37 = new_datatype_vector(ctx, yymsp[-3].minor.yy37, (int) yymsp[-1].minor.yy0.i64); } -#line 3449 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 145: /* datatype_matrix ::= MATRIX LT datatype_scalar COMMA INT_CONSTANT COMMA INT_CONSTANT GT */ -#line 351 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy37 = new_datatype_matrix(ctx, yymsp[-5].minor.yy37, (int) yymsp[-3].minor.yy0.i64, (int) yymsp[-1].minor.yy0.i64); } -#line 3454 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 146: /* statement_block ::= LBRACE RBRACE */ -#line 355 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy233 = new_block_statement(ctx, NULL); } -#line 3459 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 147: /* statement_block ::= LBRACE statement_list RBRACE */ -#line 356 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ REVERSE_LINKED_LIST(MOJOSHADER_astStatement, yymsp[-1].minor.yy233); yygotominor.yy233 = new_block_statement(ctx, yymsp[-1].minor.yy233); } -#line 3464 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 148: /* statement_list ::= statement */ - case 172: /* statement ::= statement_block */ yytestcase(yyruleno==172); - case 173: /* statement ::= for_statement */ yytestcase(yyruleno==173); -#line 360 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy233 = yymsp[0].minor.yy233; } -#line 3471 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 149: /* statement_list ::= statement_list statement */ -#line 361 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy233 = yymsp[0].minor.yy233; yygotominor.yy233->next = yymsp[-1].minor.yy233; } -#line 3476 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 150: /* statement_attribute ::= ISOLATE */ - case 151: /* statement_attribute ::= MAXINSTRUCTIONCOUNT LPAREN INT_CONSTANT RPAREN */ yytestcase(yyruleno==151); - case 152: /* statement_attribute ::= NOEXPRESSIONOPTIMIZATIONS */ yytestcase(yyruleno==152); - case 153: /* statement_attribute ::= REMOVEUNUSEDINPUTS */ yytestcase(yyruleno==153); - case 154: /* statement_attribute ::= UNUSED */ yytestcase(yyruleno==154); - case 155: /* statement_attribute ::= XPS */ yytestcase(yyruleno==155); - case 176: /* while_intro ::= LBRACKET LOOP RBRACKET WHILE */ yytestcase(yyruleno==176); - case 181: /* for_intro ::= LBRACKET LOOP RBRACKET FOR */ yytestcase(yyruleno==181); - case 197: /* do_intro ::= LBRACKET LOOP RBRACKET DO */ yytestcase(yyruleno==197); -#line 367 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy270 = 0; } -#line 3489 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 156: /* statement ::= BREAK SEMICOLON */ -#line 376 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy233 = new_break_statement(ctx); } -#line 3494 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 157: /* statement ::= CONTINUE SEMICOLON */ -#line 377 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy233 = new_continue_statement(ctx); } -#line 3499 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 158: /* statement ::= DISCARD SEMICOLON */ -#line 378 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy233 = new_discard_statement(ctx); } -#line 3504 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 159: /* statement ::= LBRACKET statement_attribute RBRACKET statement_block */ -#line 379 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy233 = yymsp[0].minor.yy233; /* !!! FIXME: yygotominor.yy233->attributes = yymsp[-2].minor.yy270;*/ yymsp[-2].minor.yy270 = 0; } -#line 3509 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 160: /* statement ::= variable_declaration */ -#line 380 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy233 = new_vardecl_statement(ctx, yymsp[0].minor.yy24); } -#line 3514 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 161: /* statement ::= struct_declaration SEMICOLON */ -#line 381 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy233 = new_struct_statement(ctx, yymsp[-1].minor.yy249); } -#line 3519 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 162: /* statement ::= do_intro DO statement WHILE LPAREN expression RPAREN SEMICOLON */ -#line 382 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy233 = new_do_statement(ctx, yymsp[-7].minor.yy270, yymsp[-5].minor.yy233, yymsp[-2].minor.yy322); } -#line 3524 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 163: /* statement ::= while_intro LPAREN expression RPAREN statement */ -#line 383 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy233 = new_while_statement(ctx, yymsp[-4].minor.yy270, yymsp[-2].minor.yy322, yymsp[0].minor.yy233); } -#line 3529 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 164: /* statement ::= if_intro LPAREN expression RPAREN statement */ -#line 384 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy233 = new_if_statement(ctx, yymsp[-4].minor.yy270, yymsp[-2].minor.yy322, yymsp[0].minor.yy233, NULL); } -#line 3534 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 165: /* statement ::= if_intro LPAREN expression RPAREN statement ELSE statement */ -#line 385 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy233 = new_if_statement(ctx, yymsp[-6].minor.yy270, yymsp[-4].minor.yy322, yymsp[-2].minor.yy233, yymsp[0].minor.yy233); } -#line 3539 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 166: /* statement ::= switch_intro LPAREN expression RPAREN LBRACE switch_case_list RBRACE */ -#line 386 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ REVERSE_LINKED_LIST(MOJOSHADER_astSwitchCases, yymsp[-1].minor.yy165); yygotominor.yy233 = new_switch_statement(ctx, yymsp[-6].minor.yy270, yymsp[-4].minor.yy322, yymsp[-1].minor.yy165); } -#line 3544 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 167: /* statement ::= typedef */ -#line 387 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy233 = new_typedef_statement(ctx, yymsp[0].minor.yy71); } -#line 3549 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 168: /* statement ::= SEMICOLON */ -#line 388 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy233 = new_empty_statement(ctx); } -#line 3554 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 169: /* statement ::= expression SEMICOLON */ -#line 389 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy233 = new_expr_statement(ctx, yymsp[-1].minor.yy322); } -#line 3559 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 170: /* statement ::= RETURN SEMICOLON */ -#line 390 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy233 = new_return_statement(ctx, NULL); } -#line 3564 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 171: /* statement ::= RETURN expression SEMICOLON */ -#line 391 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy233 = new_return_statement(ctx, yymsp[-1].minor.yy322); } -#line 3569 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 174: /* while_intro ::= LBRACKET UNROLL LPAREN INT_CONSTANT RPAREN RBRACKET WHILE */ - case 179: /* for_intro ::= LBRACKET UNROLL LPAREN INT_CONSTANT RPAREN RBRACKET FOR */ yytestcase(yyruleno==179); -#line 397 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy270 = (yymsp[-3].minor.yy0.i64 < 0) ? 0 : yymsp[-3].minor.yy0.i64; } -#line 3575 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 175: /* while_intro ::= LBRACKET UNROLL RBRACKET WHILE */ - case 180: /* for_intro ::= LBRACKET UNROLL RBRACKET FOR */ yytestcase(yyruleno==180); - case 196: /* do_intro ::= LBRACKET UNROLL RBRACKET DO */ yytestcase(yyruleno==196); -#line 398 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy270 = -1; } -#line 3582 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 177: /* while_intro ::= WHILE */ - case 182: /* for_intro ::= FOR */ yytestcase(yyruleno==182); - case 198: /* do_intro ::= DO */ yytestcase(yyruleno==198); -#line 400 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy270 = -2; } -#line 3589 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 178: /* for_statement ::= for_intro for_details */ -#line 404 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy233 = yymsp[0].minor.yy233; ((MOJOSHADER_astForStatement *) yygotominor.yy233)->unroll = yymsp[-1].minor.yy270; } -#line 3594 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 183: /* for_details ::= LPAREN expression SEMICOLON expression SEMICOLON expression RPAREN statement */ -#line 414 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy233 = new_for_statement(ctx, NULL, yymsp[-6].minor.yy322, yymsp[-4].minor.yy322, yymsp[-2].minor.yy322, yymsp[0].minor.yy233); } -#line 3599 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 184: /* for_details ::= LPAREN SEMICOLON SEMICOLON RPAREN statement */ -#line 415 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy233 = new_for_statement(ctx, NULL, NULL, NULL, NULL, yymsp[0].minor.yy233); } -#line 3604 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 185: /* for_details ::= LPAREN SEMICOLON SEMICOLON expression RPAREN statement */ -#line 416 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy233 = new_for_statement(ctx, NULL, NULL, NULL, yymsp[-2].minor.yy322, yymsp[0].minor.yy233); } -#line 3609 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 186: /* for_details ::= LPAREN SEMICOLON expression SEMICOLON RPAREN statement */ -#line 417 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy233 = new_for_statement(ctx, NULL, NULL, yymsp[-3].minor.yy322, NULL, yymsp[0].minor.yy233); } -#line 3614 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 187: /* for_details ::= LPAREN SEMICOLON expression SEMICOLON expression RPAREN statement */ -#line 418 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy233 = new_for_statement(ctx, NULL, NULL, yymsp[-4].minor.yy322, yymsp[-2].minor.yy322, yymsp[0].minor.yy233); } -#line 3619 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 188: /* for_details ::= LPAREN expression SEMICOLON SEMICOLON RPAREN statement */ -#line 419 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy233 = new_for_statement(ctx, NULL, yymsp[-4].minor.yy322, NULL, NULL, yymsp[0].minor.yy233); } -#line 3624 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 189: /* for_details ::= LPAREN expression SEMICOLON SEMICOLON expression RPAREN statement */ -#line 420 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy233 = new_for_statement(ctx, NULL, yymsp[-5].minor.yy322, NULL, yymsp[-2].minor.yy322, yymsp[0].minor.yy233); } -#line 3629 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 190: /* for_details ::= LPAREN expression SEMICOLON expression SEMICOLON RPAREN statement */ -#line 421 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy233 = new_for_statement(ctx, NULL, yymsp[-5].minor.yy322, yymsp[-3].minor.yy322, NULL, yymsp[0].minor.yy233); } -#line 3634 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 191: /* for_details ::= LPAREN variable_declaration expression SEMICOLON expression RPAREN statement */ -#line 422 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy233 = new_for_statement(ctx, yymsp[-5].minor.yy24, NULL, yymsp[-4].minor.yy322, yymsp[-2].minor.yy322, yymsp[0].minor.yy233); } -#line 3639 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 192: /* for_details ::= LPAREN variable_declaration SEMICOLON RPAREN statement */ -#line 423 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy233 = new_for_statement(ctx, yymsp[-3].minor.yy24, NULL, NULL, NULL, yymsp[0].minor.yy233); } -#line 3644 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 193: /* for_details ::= LPAREN variable_declaration SEMICOLON expression RPAREN statement */ -#line 424 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy233 = new_for_statement(ctx, yymsp[-4].minor.yy24, NULL, yymsp[-2].minor.yy322, NULL, yymsp[0].minor.yy233); } -#line 3649 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 194: /* for_details ::= LPAREN variable_declaration expression SEMICOLON RPAREN statement */ -#line 425 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy233 = new_for_statement(ctx, yymsp[-4].minor.yy24, NULL, yymsp[-3].minor.yy322, NULL, yymsp[0].minor.yy233); } -#line 3654 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 195: /* do_intro ::= LBRACKET UNROLL LPAREN INT_CONSTANT RPAREN RBRACKET DO */ -#line 428 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy270 = (yymsp[-3].minor.yy0.i64 < 0) ? 0 : (int) yymsp[-3].minor.yy0.i64; } -#line 3659 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 199: /* if_intro ::= LBRACKET BRANCH RBRACKET IF */ -#line 434 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy270 = MOJOSHADER_AST_IFATTR_BRANCH; } -#line 3664 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 200: /* if_intro ::= LBRACKET FLATTEN RBRACKET IF */ -#line 435 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy270 = MOJOSHADER_AST_IFATTR_FLATTEN; } -#line 3669 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 201: /* if_intro ::= LBRACKET IFALL RBRACKET IF */ -#line 436 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy270 = MOJOSHADER_AST_IFATTR_IFALL; } -#line 3674 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 202: /* if_intro ::= LBRACKET IFANY RBRACKET IF */ -#line 437 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy270 = MOJOSHADER_AST_IFATTR_IFANY; } -#line 3679 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 203: /* if_intro ::= LBRACKET PREDICATE RBRACKET IF */ -#line 438 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy270 = MOJOSHADER_AST_IFATTR_PREDICATE; } -#line 3684 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 204: /* if_intro ::= LBRACKET PREDICATEBLOCK RBRACKET IF */ -#line 439 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy270 = MOJOSHADER_AST_IFATTR_PREDICATEBLOCK; } -#line 3689 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 205: /* if_intro ::= IF */ -#line 440 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy270 = MOJOSHADER_AST_IFATTR_NONE; } -#line 3694 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 206: /* switch_intro ::= LBRACKET FLATTEN RBRACKET SWITCH */ -#line 443 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy270 = MOJOSHADER_AST_SWITCHATTR_FLATTEN; } -#line 3699 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 207: /* switch_intro ::= LBRACKET BRANCH RBRACKET SWITCH */ -#line 444 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy270 = MOJOSHADER_AST_SWITCHATTR_BRANCH; } -#line 3704 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 208: /* switch_intro ::= LBRACKET FORCECASE RBRACKET SWITCH */ -#line 445 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy270 = MOJOSHADER_AST_SWITCHATTR_FORCECASE; } -#line 3709 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 209: /* switch_intro ::= LBRACKET CALL RBRACKET SWITCH */ -#line 446 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy270 = MOJOSHADER_AST_SWITCHATTR_CALL; } -#line 3714 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 210: /* switch_intro ::= SWITCH */ -#line 447 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy270 = MOJOSHADER_AST_SWITCHATTR_NONE; } -#line 3719 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 211: /* switch_case_list ::= switch_case */ -#line 451 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy165 = yymsp[0].minor.yy165; } -#line 3724 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 212: /* switch_case_list ::= switch_case_list switch_case */ -#line 452 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy165 = yymsp[0].minor.yy165; yygotominor.yy165->next = yymsp[-1].minor.yy165; } -#line 3729 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 213: /* switch_case ::= CASE expression COLON statement_list */ -#line 458 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ REVERSE_LINKED_LIST(MOJOSHADER_astStatement, yymsp[0].minor.yy233); yygotominor.yy165 = new_switch_case(ctx, yymsp[-2].minor.yy322, yymsp[0].minor.yy233); } -#line 3734 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 214: /* switch_case ::= CASE expression COLON */ -#line 459 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy165 = new_switch_case(ctx, yymsp[-1].minor.yy322, NULL); } -#line 3739 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 215: /* switch_case ::= DEFAULT COLON statement_list */ -#line 460 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ REVERSE_LINKED_LIST(MOJOSHADER_astStatement, yymsp[0].minor.yy233); yygotominor.yy165 = new_switch_case(ctx, NULL, yymsp[0].minor.yy233); } -#line 3744 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 216: /* switch_case ::= DEFAULT COLON */ -#line 461 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy165 = new_switch_case(ctx, NULL, NULL); } -#line 3749 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 217: /* primary_expr ::= IDENTIFIER */ -#line 466 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy322 = new_identifier_expr(ctx, yymsp[0].minor.yy0.string); } -#line 3754 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 218: /* primary_expr ::= INT_CONSTANT */ -#line 467 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy322 = new_literal_int_expr(ctx, yymsp[0].minor.yy0.i64); } -#line 3759 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 219: /* primary_expr ::= FLOAT_CONSTANT */ -#line 468 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy322 = new_literal_float_expr(ctx, yymsp[0].minor.yy0.dbl); } -#line 3764 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 220: /* primary_expr ::= STRING_LITERAL */ -#line 469 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy322 = new_literal_string_expr(ctx, yymsp[0].minor.yy0.string); } -#line 3769 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 221: /* primary_expr ::= TRUE */ -#line 470 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy322 = new_literal_boolean_expr(ctx, 1); } -#line 3774 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 222: /* primary_expr ::= FALSE */ -#line 471 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy322 = new_literal_boolean_expr(ctx, 0); } -#line 3779 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 225: /* postfix_expr ::= postfix_expr LBRACKET expression RBRACKET */ -#line 477 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy322 = new_binary_expr(ctx, MOJOSHADER_AST_OP_DEREF_ARRAY, yymsp[-3].minor.yy322, yymsp[-1].minor.yy322); } -#line 3784 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 226: /* postfix_expr ::= IDENTIFIER arguments */ -#line 478 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy322 = new_callfunc_expr(ctx, yymsp[-1].minor.yy0.string, yymsp[0].minor.yy26); } -#line 3789 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 227: /* postfix_expr ::= datatype arguments */ -#line 479 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy322 = new_constructor_expr(ctx, yymsp[-1].minor.yy37, yymsp[0].minor.yy26); } -#line 3794 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 228: /* postfix_expr ::= postfix_expr DOT IDENTIFIER */ -#line 480 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy322 = new_deref_struct_expr(ctx, yymsp[-2].minor.yy322, yymsp[0].minor.yy0.string); } -#line 3799 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 229: /* postfix_expr ::= postfix_expr PLUSPLUS */ -#line 481 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy322 = new_unary_expr(ctx, MOJOSHADER_AST_OP_POSTINCREMENT, yymsp[-1].minor.yy322); } -#line 3804 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 230: /* postfix_expr ::= postfix_expr MINUSMINUS */ -#line 482 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy322 = new_unary_expr(ctx, MOJOSHADER_AST_OP_POSTDECREMENT, yymsp[-1].minor.yy322); } -#line 3809 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 231: /* arguments ::= LPAREN RPAREN */ -#line 486 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy26 = NULL; } -#line 3814 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 232: /* arguments ::= LPAREN argument_list RPAREN */ -#line 487 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ REVERSE_LINKED_LIST(MOJOSHADER_astArguments, yymsp[-1].minor.yy26); yygotominor.yy26 = yymsp[-1].minor.yy26; } -#line 3819 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 233: /* argument_list ::= assignment_expr */ -#line 491 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy26 = new_argument(ctx, yymsp[0].minor.yy322); } -#line 3824 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 234: /* argument_list ::= argument_list COMMA assignment_expr */ -#line 492 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy26 = new_argument(ctx, yymsp[0].minor.yy322); yygotominor.yy26->next = yymsp[-2].minor.yy26; } -#line 3829 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 236: /* unary_expr ::= PLUSPLUS unary_expr */ -#line 497 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy322 = new_unary_expr(ctx, MOJOSHADER_AST_OP_PREINCREMENT, yymsp[0].minor.yy322); } -#line 3834 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 237: /* unary_expr ::= MINUSMINUS unary_expr */ -#line 498 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy322 = new_unary_expr(ctx, MOJOSHADER_AST_OP_PREDECREMENT, yymsp[0].minor.yy322); } -#line 3839 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 239: /* unary_expr ::= MINUS cast_expr */ -#line 500 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy322 = new_unary_expr(ctx, MOJOSHADER_AST_OP_NEGATE, yymsp[0].minor.yy322); } -#line 3844 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 240: /* unary_expr ::= COMPLEMENT cast_expr */ -#line 501 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy322 = new_unary_expr(ctx, MOJOSHADER_AST_OP_COMPLEMENT, yymsp[0].minor.yy322); } -#line 3849 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 241: /* unary_expr ::= EXCLAMATION cast_expr */ -#line 502 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy322 = new_unary_expr(ctx, MOJOSHADER_AST_OP_NOT, yymsp[0].minor.yy322); } -#line 3854 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 243: /* cast_expr ::= LPAREN datatype RPAREN cast_expr */ -#line 507 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy322 = new_cast_expr(ctx, yymsp[-2].minor.yy37, yymsp[0].minor.yy322); } -#line 3859 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 245: /* multiplicative_expr ::= multiplicative_expr STAR cast_expr */ -#line 512 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy322 = new_binary_expr(ctx, MOJOSHADER_AST_OP_MULTIPLY, yymsp[-2].minor.yy322, yymsp[0].minor.yy322); } -#line 3864 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 246: /* multiplicative_expr ::= multiplicative_expr SLASH cast_expr */ -#line 513 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy322 = new_binary_expr(ctx, MOJOSHADER_AST_OP_DIVIDE, yymsp[-2].minor.yy322, yymsp[0].minor.yy322); } -#line 3869 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 247: /* multiplicative_expr ::= multiplicative_expr PERCENT cast_expr */ -#line 514 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy322 = new_binary_expr(ctx, MOJOSHADER_AST_OP_MODULO, yymsp[-2].minor.yy322, yymsp[0].minor.yy322); } -#line 3874 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 249: /* additive_expr ::= additive_expr PLUS multiplicative_expr */ -#line 519 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy322 = new_binary_expr(ctx, MOJOSHADER_AST_OP_ADD, yymsp[-2].minor.yy322, yymsp[0].minor.yy322); } -#line 3879 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 250: /* additive_expr ::= additive_expr MINUS multiplicative_expr */ -#line 520 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy322 = new_binary_expr(ctx, MOJOSHADER_AST_OP_SUBTRACT, yymsp[-2].minor.yy322, yymsp[0].minor.yy322); } -#line 3884 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 252: /* shift_expr ::= shift_expr LSHIFT additive_expr */ -#line 525 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy322 = new_binary_expr(ctx, MOJOSHADER_AST_OP_LSHIFT, yymsp[-2].minor.yy322, yymsp[0].minor.yy322); } -#line 3889 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 253: /* shift_expr ::= shift_expr RSHIFT additive_expr */ -#line 526 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy322 = new_binary_expr(ctx, MOJOSHADER_AST_OP_RSHIFT, yymsp[-2].minor.yy322, yymsp[0].minor.yy322); } -#line 3894 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 255: /* relational_expr ::= relational_expr LT shift_expr */ -#line 531 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy322 = new_binary_expr(ctx, MOJOSHADER_AST_OP_LESSTHAN, yymsp[-2].minor.yy322, yymsp[0].minor.yy322); } -#line 3899 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 256: /* relational_expr ::= relational_expr GT shift_expr */ -#line 532 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy322 = new_binary_expr(ctx, MOJOSHADER_AST_OP_GREATERTHAN, yymsp[-2].minor.yy322, yymsp[0].minor.yy322); } -#line 3904 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 257: /* relational_expr ::= relational_expr LEQ shift_expr */ -#line 533 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy322 = new_binary_expr(ctx, MOJOSHADER_AST_OP_LESSTHANOREQUAL, yymsp[-2].minor.yy322, yymsp[0].minor.yy322); } -#line 3909 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 258: /* relational_expr ::= relational_expr GEQ shift_expr */ -#line 534 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy322 = new_binary_expr(ctx, MOJOSHADER_AST_OP_GREATERTHANOREQUAL, yymsp[-2].minor.yy322, yymsp[0].minor.yy322); } -#line 3914 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 260: /* equality_expr ::= equality_expr EQL relational_expr */ -#line 539 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy322 = new_binary_expr(ctx, MOJOSHADER_AST_OP_EQUAL, yymsp[-2].minor.yy322, yymsp[0].minor.yy322); } -#line 3919 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 261: /* equality_expr ::= equality_expr NEQ relational_expr */ -#line 540 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy322 = new_binary_expr(ctx, MOJOSHADER_AST_OP_NOTEQUAL, yymsp[-2].minor.yy322, yymsp[0].minor.yy322); } -#line 3924 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 263: /* and_expr ::= and_expr AND equality_expr */ -#line 545 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy322 = new_binary_expr(ctx, MOJOSHADER_AST_OP_BINARYAND, yymsp[-2].minor.yy322, yymsp[0].minor.yy322); } -#line 3929 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 265: /* exclusive_or_expr ::= exclusive_or_expr XOR and_expr */ -#line 550 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy322 = new_binary_expr(ctx, MOJOSHADER_AST_OP_BINARYXOR, yymsp[-2].minor.yy322, yymsp[0].minor.yy322); } -#line 3934 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 267: /* inclusive_or_expr ::= inclusive_or_expr OR exclusive_or_expr */ -#line 555 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy322 = new_binary_expr(ctx, MOJOSHADER_AST_OP_BINARYOR, yymsp[-2].minor.yy322, yymsp[0].minor.yy322); } -#line 3939 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 269: /* logical_and_expr ::= logical_and_expr ANDAND inclusive_or_expr */ -#line 560 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy322 = new_binary_expr(ctx, MOJOSHADER_AST_OP_LOGICALAND, yymsp[-2].minor.yy322, yymsp[0].minor.yy322); } -#line 3944 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 271: /* logical_or_expr ::= logical_or_expr OROR logical_and_expr */ -#line 565 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy322 = new_binary_expr(ctx, MOJOSHADER_AST_OP_LOGICALOR, yymsp[-2].minor.yy322, yymsp[0].minor.yy322); } -#line 3949 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 273: /* conditional_expr ::= logical_or_expr QUESTION logical_or_expr COLON conditional_expr */ -#line 570 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy322 = new_ternary_expr(ctx, MOJOSHADER_AST_OP_CONDITIONAL, yymsp[-4].minor.yy322, yymsp[-2].minor.yy322, yymsp[0].minor.yy322); } -#line 3954 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 275: /* assignment_expr ::= unary_expr ASSIGN assignment_expr */ -#line 575 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy322 = new_binary_expr(ctx, MOJOSHADER_AST_OP_ASSIGN, yymsp[-2].minor.yy322, yymsp[0].minor.yy322); } -#line 3959 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 276: /* assignment_expr ::= unary_expr MULASSIGN assignment_expr */ -#line 576 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy322 = new_binary_expr(ctx, MOJOSHADER_AST_OP_MULASSIGN, yymsp[-2].minor.yy322, yymsp[0].minor.yy322); } -#line 3964 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 277: /* assignment_expr ::= unary_expr DIVASSIGN assignment_expr */ -#line 577 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy322 = new_binary_expr(ctx, MOJOSHADER_AST_OP_DIVASSIGN, yymsp[-2].minor.yy322, yymsp[0].minor.yy322); } -#line 3969 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 278: /* assignment_expr ::= unary_expr MODASSIGN assignment_expr */ -#line 578 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy322 = new_binary_expr(ctx, MOJOSHADER_AST_OP_MODASSIGN, yymsp[-2].minor.yy322, yymsp[0].minor.yy322); } -#line 3974 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 279: /* assignment_expr ::= unary_expr ADDASSIGN assignment_expr */ -#line 579 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy322 = new_binary_expr(ctx, MOJOSHADER_AST_OP_ADDASSIGN, yymsp[-2].minor.yy322, yymsp[0].minor.yy322); } -#line 3979 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 280: /* assignment_expr ::= unary_expr SUBASSIGN assignment_expr */ -#line 580 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy322 = new_binary_expr(ctx, MOJOSHADER_AST_OP_SUBASSIGN, yymsp[-2].minor.yy322, yymsp[0].minor.yy322); } -#line 3984 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 281: /* assignment_expr ::= unary_expr LSHIFTASSIGN assignment_expr */ -#line 581 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy322 = new_binary_expr(ctx, MOJOSHADER_AST_OP_LSHIFTASSIGN, yymsp[-2].minor.yy322, yymsp[0].minor.yy322); } -#line 3989 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 282: /* assignment_expr ::= unary_expr RSHIFTASSIGN assignment_expr */ -#line 582 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy322 = new_binary_expr(ctx, MOJOSHADER_AST_OP_RSHIFTASSIGN, yymsp[-2].minor.yy322, yymsp[0].minor.yy322); } -#line 3994 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 283: /* assignment_expr ::= unary_expr ANDASSIGN assignment_expr */ -#line 583 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy322 = new_binary_expr(ctx, MOJOSHADER_AST_OP_ANDASSIGN, yymsp[-2].minor.yy322, yymsp[0].minor.yy322); } -#line 3999 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 284: /* assignment_expr ::= unary_expr XORASSIGN assignment_expr */ -#line 584 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy322 = new_binary_expr(ctx, MOJOSHADER_AST_OP_XORASSIGN, yymsp[-2].minor.yy322, yymsp[0].minor.yy322); } -#line 4004 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - case 285: /* assignment_expr ::= unary_expr ORASSIGN assignment_expr */ -#line 585 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" -{ yygotominor.yy322 = new_binary_expr(ctx, MOJOSHADER_AST_OP_ORASSIGN, yymsp[-2].minor.yy322, yymsp[0].minor.yy322); } -#line 4009 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - break; - default: - break; - }; - yygoto = yyRuleInfo[yyruleno].lhs; - yysize = yyRuleInfo[yyruleno].nrhs; - yypParser->yyidx -= yysize; - yyact = yy_find_reduce_action(yymsp[-yysize].stateno,(YYCODETYPE)yygoto); - if( yyact < YYNSTATE ){ -#if LEMON_SUPPORT_TRACING /* __MOJOSHADER__ */ - /* If we are not debugging and the reduce action popped at least - ** one element off the stack, then we can push the new element back - ** onto the stack here, and skip the stack overflow test in yy_shift(). - ** That gives a significant speed improvement. */ - if( yysize ){ - yypParser->yyidx++; - yymsp -= yysize-1; - yymsp->stateno = (YYACTIONTYPE)yyact; - yymsp->major = (YYCODETYPE)yygoto; - yymsp->minor = yygotominor; - }else -#endif - { - yy_shift(yypParser,yyact,yygoto,&yygotominor); - } - }else{ - assert( yyact == YYNSTATE + YYNRULE + 1 ); - yy_accept(yypParser); - } -} - -/* -** The following code executes when the parse fails -*/ -#ifndef YYNOERRORRECOVERY -static void yy_parse_failed( - yyParser *yypParser /* The parser */ -){ - ParseHLSLARG_FETCH; -#if LEMON_SUPPORT_TRACING /* __MOJOSHADER__ */ - if( yyTraceFILE ){ - fprintf(yyTraceFILE,"%sFail!\n",yyTracePrompt); - } -#endif - while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser); - /* Here code is inserted which will be executed whenever the - ** parser fails */ -#line 42 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" - - // !!! FIXME: make this a proper fail() function. - fail(ctx, "Giving up. Parser is hopelessly lost..."); -#line 4061 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - ParseHLSLARG_STORE; /* Suppress warning about unused %extra_argument variable */ -} -#endif /* YYNOERRORRECOVERY */ - -/* -** The following code executes when a syntax error first occurs. -*/ -static void yy_syntax_error( - yyParser *yypParser, /* The parser */ - int yymajor, /* The major type of the error token */ - YYMINORTYPE yyminor /* The minor type of the error token */ -){ - ParseHLSLARG_FETCH; -#define TOKEN (yyminor.yy0) -#line 37 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.lemon" - - // !!! FIXME: make this a proper fail() function. - fail(ctx, "Syntax error"); -#line 4080 "C:/p4droid/PhysX-3.0_Android/externals/mojoshader/mojoshader_parser_hlsl.h" - ParseHLSLARG_STORE; /* Suppress warning about unused %extra_argument variable */ -} - -/* -** The following is executed when the parser accepts -*/ -static void yy_accept( - yyParser *yypParser /* The parser */ -){ - ParseHLSLARG_FETCH; -#if LEMON_SUPPORT_TRACING /* __MOJOSHADER__ */ - if( yyTraceFILE ){ - fprintf(yyTraceFILE,"%sAccept!\n",yyTracePrompt); - } -#endif - while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser); - /* Here code is inserted which will be executed whenever the - ** parser accepts */ - ParseHLSLARG_STORE; /* Suppress warning about unused %extra_argument variable */ -} - -/* The main parser program. -** The first argument is a pointer to a structure obtained from -** "ParseHLSLAlloc" which describes the current state of the parser. -** The second argument is the major token number. The third is -** the minor token. The fourth optional argument is whatever the -** user wants (and specified in the grammar) and is available for -** use by the action routines. -** -** Inputs: -** <ul> -** <li> A pointer to the parser (an opaque structure.) -** <li> The major token number. -** <li> The minor token number. -** <li> An option argument of a grammar-specified type. -** </ul> -** -** Outputs: -** None. -*/ -#if __MOJOSHADER__ -static -#endif -void ParseHLSL( - void *yyp, /* The parser */ - int yymajor, /* The major token code number */ - ParseHLSLTOKENTYPE yyminor /* The value for the token */ - ParseHLSLARG_PDECL /* Optional %extra_argument parameter */ -){ - YYMINORTYPE yyminorunion; - int yyact; /* The parser action. */ - int yyendofinput; /* True if we are at the end of input */ -#ifdef YYERRORSYMBOL - int yyerrorhit = 0; /* True if yymajor has invoked an error */ -#endif - yyParser *yypParser; /* The parser */ - - /* (re)initialize the parser, if necessary */ - yypParser = (yyParser*)yyp; - if( yypParser->yyidx<0 ){ -#if YYSTACKDEPTH<=0 - if( yypParser->yystksz <=0 ){ - /*memset(&yyminorunion, 0, sizeof(yyminorunion));*/ - yyminorunion = yyzerominor; - yyStackOverflow(yypParser, &yyminorunion); - return; - } -#endif - yypParser->yyidx = 0; - yypParser->yyerrcnt = -1; - yypParser->yystack[0].stateno = 0; - yypParser->yystack[0].major = 0; - } - yyminorunion.yy0 = yyminor; - yyendofinput = (yymajor==0); - ParseHLSLARG_STORE; - -#if LEMON_SUPPORT_TRACING /* __MOJOSHADER__ */ - if( yyTraceFILE ){ - fprintf(yyTraceFILE,"%sInput %s\n",yyTracePrompt,yyTokenName[yymajor]); - } -#endif - - do{ - yyact = yy_find_shift_action(yypParser,(YYCODETYPE)yymajor); - if( yyact<YYNSTATE ){ - assert( !yyendofinput ); /* Impossible to shift the $ token */ - yy_shift(yypParser,yyact,yymajor,&yyminorunion); - yypParser->yyerrcnt--; - yymajor = YYNOCODE; - }else if( yyact < YYNSTATE + YYNRULE ){ - yy_reduce(yypParser,yyact-YYNSTATE); - }else{ - assert( yyact == YY_ERROR_ACTION ); -#ifdef YYERRORSYMBOL - int yymx; -#endif -#if LEMON_SUPPORT_TRACING /* __MOJOSHADER__ */ - if( yyTraceFILE ){ - fprintf(yyTraceFILE,"%sSyntax Error!\n",yyTracePrompt); - } -#endif -#ifdef YYERRORSYMBOL - /* A syntax error has occurred. - ** The response to an error depends upon whether or not the - ** grammar defines an error token "ERROR". - ** - ** This is what we do if the grammar does define ERROR: - ** - ** * Call the %syntax_error function. - ** - ** * Begin popping the stack until we enter a state where - ** it is legal to shift the error symbol, then shift - ** the error symbol. - ** - ** * Set the error count to three. - ** - ** * Begin accepting and shifting new tokens. No new error - ** processing will occur until three tokens have been - ** shifted successfully. - ** - */ - if( yypParser->yyerrcnt<0 ){ - yy_syntax_error(yypParser,yymajor,yyminorunion); - } - yymx = yypParser->yystack[yypParser->yyidx].major; - if( yymx==YYERRORSYMBOL || yyerrorhit ){ -#if LEMON_SUPPORT_TRACING /* __MOJOSHADER__ */ - if( yyTraceFILE ){ - fprintf(yyTraceFILE,"%sDiscard input token %s\n", - yyTracePrompt,yyTokenName[yymajor]); - } -#endif - yy_destructor(yypParser, (YYCODETYPE)yymajor,&yyminorunion); - yymajor = YYNOCODE; - }else{ - while( - yypParser->yyidx >= 0 && - yymx != YYERRORSYMBOL && - (yyact = yy_find_reduce_action( - yypParser->yystack[yypParser->yyidx].stateno, - YYERRORSYMBOL)) >= YYNSTATE - ){ - yy_pop_parser_stack(yypParser); - } - if( yypParser->yyidx < 0 || yymajor==0 ){ - yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion); - yy_parse_failed(yypParser); - yymajor = YYNOCODE; - }else if( yymx!=YYERRORSYMBOL ){ - YYMINORTYPE u2; - u2.YYERRSYMDT = 0; - yy_shift(yypParser,yyact,YYERRORSYMBOL,&u2); - } - } - yypParser->yyerrcnt = 3; - yyerrorhit = 1; -#elif defined(YYNOERRORRECOVERY) - /* If the YYNOERRORRECOVERY macro is defined, then do not attempt to - ** do any kind of error recovery. Instead, simply invoke the syntax - ** error routine and continue going as if nothing had happened. - ** - ** Applications can set this macro (for example inside %include) if - ** they intend to abandon the parse upon the first syntax error seen. - */ - yy_syntax_error(yypParser,yymajor,yyminorunion); - yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion); - yymajor = YYNOCODE; - -#else /* YYERRORSYMBOL is not defined */ - /* This is what we do if the grammar does not define ERROR: - ** - ** * Report an error message, and throw away the input token. - ** - ** * If the input token is $, then fail the parse. - ** - ** As before, subsequent error messages are suppressed until - ** three input tokens have been successfully shifted. - */ - if( yypParser->yyerrcnt<=0 ){ - yy_syntax_error(yypParser,yymajor,yyminorunion); - } - yypParser->yyerrcnt = 3; - yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion); - if( yyendofinput ){ - yy_parse_failed(yypParser); - } - yymajor = YYNOCODE; -#endif - } - }while( yymajor!=YYNOCODE && yypParser->yyidx>=0 ); - return; -} diff --git a/Externals/mojoshader/1067/mojoshader_parser_hlsl.lemon b/Externals/mojoshader/1067/mojoshader_parser_hlsl.lemon deleted file mode 100644 index 5870c6fa..00000000 --- a/Externals/mojoshader/1067/mojoshader_parser_hlsl.lemon +++ /dev/null @@ -1,593 +0,0 @@ -/** - * MojoShader; generate shader programs from bytecode of compiled - * Direct3D shaders. - * - * Please see the file LICENSE.txt in the source's root directory. - * - * This file written by Ryan C. Gordon. - */ - -// This is a Lemon Parser grammar for HLSL. It is based on an ANSI C YACC -// grammar by Jeff Lee: http://www.lysator.liu.se/c/ANSI-C-grammar-y.html - -// Lemon is here: http://www.hwaci.com/sw/lemon/ ... the source is included -// with MojoShader, and built with the library, so you don't have to track -// down the dependency. - -// HLSL syntax is described, informally, here: -// http://msdn.microsoft.com/en-us/library/bb509615(VS.85).aspx - -%name ParseHLSL - -// Some shift-reduce conflicts are basically unavoidable, but if the final -// conflict count matches this value, we consider it known and acceptable. -%expect 2 - -%start_symbol shader -%token_prefix TOKEN_HLSL_ -%token_type { TokenData } -%extra_argument { Context *ctx } - -%include { -#ifndef __MOJOSHADER_HLSL_COMPILER__ -#error Do not compile this file directly. -#endif -} - -%syntax_error { - // !!! FIXME: make this a proper fail() function. - fail(ctx, "Syntax error"); -} - -%parse_failure { - // !!! FIXME: make this a proper fail() function. - fail(ctx, "Giving up. Parser is hopelessly lost..."); -} - -%stack_overflow { - // !!! FIXME: make this a proper fail() function. - fail(ctx, "Giving up. Parser stack overflow"); -} - -// operator precedence (matches C spec)... - -%left COMMA. -%right ASSIGN ADDASSIGN SUBASSIGN MULASSIGN DIVASSIGN MODASSIGN LSHIFTASSIGN - RSHIFTASSIGN ANDASSIGN ORASSIGN XORASSIGN. -%right QUESTION. -%left OROR. -%left ANDAND. -%left OR. -%left XOR. -%left AND. -%left EQL NEQ. -%left LT LEQ GT GEQ. -%left LSHIFT RSHIFT. -%left PLUS MINUS. -%left STAR SLASH PERCENT. -%right TYPECAST EXCLAMATION COMPLEMENT MINUSMINUS PLUSPLUS. -%left DOT LBRACKET RBRACKET LPAREN RPAREN. - -// bump up the precedence of ELSE, to avoid shift/reduce conflict on the -// usual "dangling else ambiguity" ... -%right ELSE. - - -// The rules... - -shader ::= compilation_units(B). { assert(ctx->ast == NULL); REVERSE_LINKED_LIST(MOJOSHADER_astCompilationUnit, B); ctx->ast = (MOJOSHADER_astNode *) B; } - -%type compilation_units { MOJOSHADER_astCompilationUnit * } -%destructor compilation_units { delete_compilation_unit(ctx, $$); } -compilation_units(A) ::= compilation_unit(B). { A = B; } -compilation_units(A) ::= compilation_units(B) compilation_unit(C). { if (C) { C->next = B; A = C; } } - -%type compilation_unit { MOJOSHADER_astCompilationUnit * } -%destructor compilation_unit { delete_compilation_unit(ctx, $$); } -//compilation_unit(A) ::= PRAGMA . { A = NULL; } // !!! FIXME: deal with pragmas. -compilation_unit(A) ::= variable_declaration(B). { A = new_global_variable(ctx, B); } -compilation_unit(A) ::= function_signature(B) SEMICOLON. { A = new_function(ctx, B, NULL); } -compilation_unit(A) ::= function_signature(B) statement_block(C). { A = new_function(ctx, B, C); } -compilation_unit(A) ::= typedef(B). { A = new_global_typedef(ctx, B); } -compilation_unit(A) ::= struct_declaration(B) SEMICOLON. { A = new_global_struct(ctx, B); } -//compilation_unit(A) ::= error SEMICOLON. { A = NULL; } // !!! FIXME: research using the error nonterminal - -%type typedef { MOJOSHADER_astTypedef * } -%destructor typedef { delete_typedef(ctx, $$); } -// !!! FIXME: should CONST be here, or in datatype? -typedef(A) ::= TYPEDEF CONST datatype(B) scalar_or_array(C). { A = new_typedef(ctx, 1, B, C); push_usertype(ctx, C->identifier, A->datatype); } -typedef(A) ::= TYPEDEF datatype(B) scalar_or_array(C). { A = new_typedef(ctx, 0, B, C); push_usertype(ctx, C->identifier, A->datatype); } - -%type function_signature { MOJOSHADER_astFunctionSignature * } -%destructor function_signature { delete_function_signature(ctx, $$); } -function_signature(A) ::= function_storageclass(B) function_details(C) semantic(D). { A = C; A->storage_class = B; A->semantic = D; } -function_signature(A) ::= function_storageclass(B) function_details(C). { A = C; A->storage_class = B; } -function_signature(A) ::= function_details(B) semantic(C). { A = B; A->semantic = C; } -function_signature(A) ::= function_details(B). { A = B; } - -%type function_details { MOJOSHADER_astFunctionSignature * } -%destructor function_details { delete_function_signature(ctx, $$); } -function_details(A) ::= datatype(B) IDENTIFIER(C) LPAREN function_parameters(D) RPAREN. { A = new_function_signature(ctx, B, C.string, D); } -function_details(A) ::= VOID IDENTIFIER(B) LPAREN function_parameters(C) RPAREN. { A = new_function_signature(ctx, NULL, B.string, C); } - -// !!! FIXME: there is a "target" storage class that is the name of the -// !!! FIXME: platform that this function is meant for...but I don't know -// !!! FIXME: what tokens are valid here. - -// !!! FIXME: Also, the docs say "one of" inline or target, but I bet you can -// !!! FIXME: specify both. -%type function_storageclass { MOJOSHADER_astFunctionStorageClass } -//function_storageclass(A) ::= target(B). { A = B; } -function_storageclass(A) ::= INLINE. { A = MOJOSHADER_AST_FNSTORECLS_INLINE; } - -%type function_parameters { MOJOSHADER_astFunctionParameters * } -%destructor function_parameters { delete_function_params(ctx, $$); } -function_parameters(A) ::= VOID. { A = NULL; } -function_parameters(A) ::= function_parameter_list(B). { REVERSE_LINKED_LIST(MOJOSHADER_astFunctionParameters, B); A = B; } -function_parameters(A) ::= . { A = NULL; } - -%type function_parameter_list { MOJOSHADER_astFunctionParameters * } -%destructor function_parameter_list { delete_function_params(ctx, $$); } -function_parameter_list(A) ::= function_parameter(B). { A = B; } -function_parameter_list(A) ::= function_parameter_list(B) COMMA function_parameter(C). { C->next = B; A = C; } - -// !!! FIXME: this is pretty unreadable. -// !!! FIXME: CONST? -%type function_parameter { MOJOSHADER_astFunctionParameters * } -%destructor function_parameter { delete_function_params(ctx, $$); } -function_parameter(A) ::= input_modifier(B) datatype(C) IDENTIFIER(D) semantic(E) interpolation_mod(F) initializer(G). { A = new_function_param(ctx, B, C, D.string, E, F, G); } -function_parameter(A) ::= input_modifier(B) datatype(C) IDENTIFIER(D) semantic(E) interpolation_mod(F). { A = new_function_param(ctx, B, C, D.string, E, F, NULL); } -function_parameter(A) ::= input_modifier(B) datatype(C) IDENTIFIER(D) semantic(E) initializer(F). { A = new_function_param(ctx, B, C, D.string, E, MOJOSHADER_AST_INTERPMOD_NONE, F); } -function_parameter(A) ::= input_modifier(B) datatype(C) IDENTIFIER(D) semantic(E). { A = new_function_param(ctx, B, C, D.string, E, MOJOSHADER_AST_INTERPMOD_NONE, NULL); } -function_parameter(A) ::= input_modifier(B) datatype(C) IDENTIFIER(D) interpolation_mod(E) initializer(F). { A = new_function_param(ctx, B, C, D.string, NULL, E, F); } -function_parameter(A) ::= input_modifier(B) datatype(C) IDENTIFIER(D) interpolation_mod(E). { A = new_function_param(ctx, B, C, D.string, NULL, E, NULL); } -function_parameter(A) ::= input_modifier(B) datatype(C) IDENTIFIER(D) initializer(E). { A = new_function_param(ctx, B, C, D.string, NULL, MOJOSHADER_AST_INTERPMOD_NONE, E); } -function_parameter(A) ::= input_modifier(B) datatype(C) IDENTIFIER(D). { A = new_function_param(ctx, B, C, D.string, NULL, MOJOSHADER_AST_INTERPMOD_NONE, NULL); } -function_parameter(A) ::= datatype(B) IDENTIFIER(C) semantic(D) interpolation_mod(E) initializer(F). { A = new_function_param(ctx, MOJOSHADER_AST_INPUTMOD_NONE, B, C.string, D, E, F); } -function_parameter(A) ::= datatype(B) IDENTIFIER(C) semantic(D) interpolation_mod(E). { A = new_function_param(ctx, MOJOSHADER_AST_INPUTMOD_NONE, B, C.string, D, E, NULL); } -function_parameter(A) ::= datatype(B) IDENTIFIER(C) semantic(D) initializer(E). { A = new_function_param(ctx, MOJOSHADER_AST_INPUTMOD_NONE, B, C.string, D, MOJOSHADER_AST_INTERPMOD_NONE, E); } -function_parameter(A) ::= datatype(B) IDENTIFIER(C) semantic(D). { A = new_function_param(ctx, MOJOSHADER_AST_INPUTMOD_NONE, B, C.string, D, MOJOSHADER_AST_INTERPMOD_NONE, NULL); } -function_parameter(A) ::= datatype(B) IDENTIFIER(C) interpolation_mod(D) initializer(E). { A = new_function_param(ctx, MOJOSHADER_AST_INPUTMOD_NONE, B, C.string, NULL, D, E); } -function_parameter(A) ::= datatype(B) IDENTIFIER(C) interpolation_mod(D). { A = new_function_param(ctx, MOJOSHADER_AST_INPUTMOD_NONE, B, C.string, NULL, D, NULL); } -function_parameter(A) ::= datatype(B) IDENTIFIER(C) initializer(D). { A = new_function_param(ctx, MOJOSHADER_AST_INPUTMOD_NONE, B, C.string, NULL, MOJOSHADER_AST_INTERPMOD_NONE, D); } -function_parameter(A) ::= datatype(B) IDENTIFIER(C). { A = new_function_param(ctx, MOJOSHADER_AST_INPUTMOD_NONE, B, C.string, NULL, MOJOSHADER_AST_INTERPMOD_NONE, NULL); } - -%type input_modifier { MOJOSHADER_astInputModifier } -input_modifier(A) ::= IN. { A = MOJOSHADER_AST_INPUTMOD_IN; } -input_modifier(A) ::= INOUT. { A = MOJOSHADER_AST_INPUTMOD_INOUT; } -input_modifier(A) ::= OUT. { A = MOJOSHADER_AST_INPUTMOD_OUT; } -input_modifier(A) ::= IN OUT. { A = MOJOSHADER_AST_INPUTMOD_INOUT; } -input_modifier(A) ::= OUT IN. { A = MOJOSHADER_AST_INPUTMOD_INOUT; } -input_modifier(A) ::= UNIFORM. { A = MOJOSHADER_AST_INPUTMOD_UNIFORM; } - -%type semantic { const char * } -semantic(A) ::= COLON IDENTIFIER(B). { A = B.string; } - -// DX10 only? -%type interpolation_mod { MOJOSHADER_astInterpolationModifier } -interpolation_mod(A) ::= LINEAR. { A = MOJOSHADER_AST_INTERPMOD_LINEAR; } -interpolation_mod(A) ::= CENTROID. { A = MOJOSHADER_AST_INTERPMOD_CENTROID; } -interpolation_mod(A) ::= NOINTERPOLATION. { A = MOJOSHADER_AST_INTERPMOD_NOINTERPOLATION; } -interpolation_mod(A) ::= NOPERSPECTIVE. { A = MOJOSHADER_AST_INTERPMOD_NOPERSPECTIVE; } -interpolation_mod(A) ::= SAMPLE. { A = MOJOSHADER_AST_INTERPMOD_SAMPLE; } - -%type variable_declaration { MOJOSHADER_astVariableDeclaration * } -%destructor variable_declaration { delete_variable_declaration(ctx, $$); } -variable_declaration(A) ::= variable_attribute_list(B) datatype(C) variable_declaration_details_list(D) SEMICOLON. { REVERSE_LINKED_LIST(MOJOSHADER_astVariableDeclaration, D); A = D; A->attributes = B; A->datatype = C; } -variable_declaration(A) ::= datatype(B) variable_declaration_details_list(C) SEMICOLON. { REVERSE_LINKED_LIST(MOJOSHADER_astVariableDeclaration, C); A = C; A->datatype = B; } -// !!! FIXME: this expects "struct Identifier {} varname" ... that "Identifier" is wrong. -variable_declaration(A) ::= struct_declaration(B) variable_declaration_details_list(C) SEMICOLON. { REVERSE_LINKED_LIST(MOJOSHADER_astVariableDeclaration, C); A = C; A->anonymous_datatype = B; } - -%type variable_attribute_list { int } -variable_attribute_list(A) ::= variable_attribute(B). { A = B; } -variable_attribute_list(A) ::= variable_attribute_list(B) variable_attribute(C). { A = B | C; } - -%type variable_attribute { int } -variable_attribute(A) ::= EXTERN. { A = MOJOSHADER_AST_VARATTR_EXTERN; } -variable_attribute(A) ::= NOINTERPOLATION. { A = MOJOSHADER_AST_VARATTR_NOINTERPOLATION; } -variable_attribute(A) ::= SHARED. { A = MOJOSHADER_AST_VARATTR_SHARED; } -variable_attribute(A) ::= STATIC. { A = MOJOSHADER_AST_VARATTR_STATIC; } -variable_attribute(A) ::= UNIFORM. { A = MOJOSHADER_AST_VARATTR_UNIFORM; } -variable_attribute(A) ::= VOLATILE. { A = MOJOSHADER_AST_VARATTR_VOLATILE; } -variable_attribute(A) ::= CONST. { A = MOJOSHADER_AST_VARATTR_CONST; } -variable_attribute(A) ::= ROWMAJOR. { A = MOJOSHADER_AST_VARATTR_ROWMAJOR; } -variable_attribute(A) ::= COLUMNMAJOR. { A = MOJOSHADER_AST_VARATTR_COLUMNMAJOR; } - -%type variable_declaration_details_list { MOJOSHADER_astVariableDeclaration * } -%destructor variable_declaration_details_list { delete_variable_declaration(ctx, $$); } -variable_declaration_details_list(A) ::= variable_declaration_details(B). { A = B; } -variable_declaration_details_list(A) ::= variable_declaration_details_list(B) COMMA variable_declaration_details(C). { A = C; A->next = B; } - -%type variable_declaration_details { MOJOSHADER_astVariableDeclaration * } -%destructor variable_declaration_details { delete_variable_declaration(ctx, $$); } -variable_declaration_details(A) ::= scalar_or_array(B) semantic(C) annotations(D) initializer(E) variable_lowlevel(F). { A = new_variable_declaration(ctx, B, C, D, E, F); } -variable_declaration_details(A) ::= scalar_or_array(B) semantic(C) annotations(D) initializer(E). { A = new_variable_declaration(ctx, B, C, D, E, NULL); } -variable_declaration_details(A) ::= scalar_or_array(B) semantic(C) annotations(D) variable_lowlevel(E). { A = new_variable_declaration(ctx, B, C, D, NULL, E); } -variable_declaration_details(A) ::= scalar_or_array(B) semantic(C) annotations(D). { A = new_variable_declaration(ctx, B, C, D, NULL, NULL); } -variable_declaration_details(A) ::= scalar_or_array(B) semantic(C) initializer(D) variable_lowlevel(E). { A = new_variable_declaration(ctx, B, C, NULL, D, E); } -variable_declaration_details(A) ::= scalar_or_array(B) semantic(C) initializer(D). { A = new_variable_declaration(ctx, B, C, NULL, D, NULL); } -variable_declaration_details(A) ::= scalar_or_array(B) semantic(C) variable_lowlevel(D). { A = new_variable_declaration(ctx, B, C, NULL, NULL, D); } -variable_declaration_details(A) ::= scalar_or_array(B) semantic(C). { A = new_variable_declaration(ctx, B, C, NULL, NULL, NULL); } -variable_declaration_details(A) ::= scalar_or_array(B) annotations(C) initializer(D) variable_lowlevel(E). { A = new_variable_declaration(ctx, B, NULL, C, D, E); } -variable_declaration_details(A) ::= scalar_or_array(B) annotations(C) initializer(D). { A = new_variable_declaration(ctx, B, NULL, C, D, NULL); } -variable_declaration_details(A) ::= scalar_or_array(B) annotations(C) variable_lowlevel(D). { A = new_variable_declaration(ctx, B, NULL, C, NULL, D); } -variable_declaration_details(A) ::= scalar_or_array(B) annotations(C). { A = new_variable_declaration(ctx, B, NULL, C, NULL, NULL); } -variable_declaration_details(A) ::= scalar_or_array(B) initializer(C) variable_lowlevel(D). { A = new_variable_declaration(ctx, B, NULL, NULL, C, D); } -variable_declaration_details(A) ::= scalar_or_array(B) initializer(C). { A = new_variable_declaration(ctx, B, NULL, NULL, C, NULL); } -variable_declaration_details(A) ::= scalar_or_array(B) variable_lowlevel(C). { A = new_variable_declaration(ctx, B, NULL, NULL, NULL, C); } -variable_declaration_details(A) ::= scalar_or_array(B). { A = new_variable_declaration(ctx, B, NULL, NULL, NULL, NULL); } - -// !!! FIXME: we don't handle full sampler declarations at the moment. - - -%type struct_declaration { MOJOSHADER_astStructDeclaration * } -%destructor struct_declaration { delete_struct_declaration(ctx, $$); } -struct_declaration(A) ::= struct_intro(B) LBRACE struct_member_list(C) RBRACE. { REVERSE_LINKED_LIST(MOJOSHADER_astStructMembers, C); A = new_struct_declaration(ctx, B, C); } - -// This has to be separate from struct_declaration so that the struct is in the usertypemap when parsing its members. -%type struct_intro { const char * } -struct_intro(A) ::= STRUCT IDENTIFIER(B). { A = B.string; push_usertype(ctx, A, &ctx->dt_none); } // datatype is bogus until semantic analysis. - -%type struct_member_list { MOJOSHADER_astStructMembers * } -%destructor struct_member_list { delete_struct_member(ctx, $$); } -struct_member_list(A) ::= struct_member(B). { A = B; } -struct_member_list(A) ::= struct_member_list(B) struct_member(C). { A = C; MOJOSHADER_astStructMembers *i = A; while (i->next) { i = i->next; } i->next = B; } - -%type struct_member { MOJOSHADER_astStructMembers * } -%destructor struct_member { delete_struct_member(ctx, $$); } -struct_member(A) ::= interpolation_mod(B) struct_member_details(C). { MOJOSHADER_astStructMembers *i = C; A = C; while (i) { i->interpolation_mod = B; i = i->next; } } -struct_member(A) ::= struct_member_details(B). { A = B; } - -%type struct_member_details { MOJOSHADER_astStructMembers * } -%destructor struct_member_details { delete_struct_member(ctx, $$); } -struct_member_details(A) ::= datatype(B) struct_member_item_list(C) SEMICOLON. { MOJOSHADER_astStructMembers *i = C; A = C; while (i) { i->datatype = B; i = i->next; } } - -%type struct_member_item_list { MOJOSHADER_astStructMembers * } -%destructor struct_member_item_list { delete_struct_member(ctx, $$); } -struct_member_item_list(A) ::= scalar_or_array(B). { A = new_struct_member(ctx, B, NULL); } -struct_member_item_list(A) ::= scalar_or_array(B) semantic(C). { A = new_struct_member(ctx, B, C); } -struct_member_item_list(A) ::= struct_member_item_list(B) COMMA IDENTIFIER(C). { A = new_struct_member(ctx, new_scalar_or_array(ctx, C.string, 0, NULL), NULL); A->next = B; A->semantic = B->semantic; } - -%type variable_lowlevel { MOJOSHADER_astVariableLowLevel * } -%destructor variable_lowlevel { delete_variable_lowlevel(ctx, $$); } -variable_lowlevel(A) ::= packoffset(B) register(C). { A = new_variable_lowlevel(ctx, B, C); } -variable_lowlevel(A) ::= register(B) packoffset(C). { A = new_variable_lowlevel(ctx, C, B); } -variable_lowlevel(A) ::= packoffset(B). { A = new_variable_lowlevel(ctx, B, NULL); } -variable_lowlevel(A) ::= register(B). { A = new_variable_lowlevel(ctx, NULL, B); } - -// !!! FIXME: I sort of hate this type name. -%type scalar_or_array { MOJOSHADER_astScalarOrArray * } -%destructor scalar_or_array { delete_scalar_or_array(ctx, $$); } -scalar_or_array(A) ::= IDENTIFIER(B) LBRACKET RBRACKET. { A = new_scalar_or_array(ctx, B.string, 1, NULL); } -scalar_or_array(A) ::= IDENTIFIER(B) LBRACKET expression(C) RBRACKET. { A = new_scalar_or_array(ctx, B.string, 1, C); } -scalar_or_array(A) ::= IDENTIFIER(B). { A = new_scalar_or_array(ctx, B.string, 0, NULL); } - -%type packoffset { MOJOSHADER_astPackOffset * } -%destructor packoffset { delete_pack_offset(ctx, $$); } -packoffset(A) ::= COLON PACKOFFSET LPAREN IDENTIFIER(B) DOT IDENTIFIER(C) RPAREN. { A = new_pack_offset(ctx, B.string, C.string); } -packoffset(A) ::= COLON PACKOFFSET LPAREN IDENTIFIER(B) RPAREN. { A = new_pack_offset(ctx, B.string, NULL); } - -// !!! FIXME: can take a profile, like ": register(ps_5_0, s)" -// !!! FIXME: IDENTIFIER is wrong: "s[2]" works, apparently. Use scalar_or_array instead? -// !!! FIXME: (these might be SM4 features) -%type register { const char * } -register(A) ::= COLON REGISTER LPAREN IDENTIFIER(B) RPAREN. { A = B.string; } - -%type annotations { MOJOSHADER_astAnnotations * } -%destructor annotations { delete_annotation(ctx, $$); } -annotations(A) ::= LT annotation_list(B) GT. { REVERSE_LINKED_LIST(MOJOSHADER_astAnnotations, B); A = B; } - -%type annotation_list { MOJOSHADER_astAnnotations * } -%destructor annotation_list { delete_annotation(ctx, $$); } -annotation_list(A) ::= annotation(B). { A = B; } -annotation_list(A) ::= annotation_list(B) annotation(C). { A = C; A->next = B; } - -// !!! FIXME: can this take a USERTYPE if we typedef'd a scalar type? -%type annotation { MOJOSHADER_astAnnotations * } -%destructor annotation { delete_annotation(ctx, $$); } -annotation(A) ::= datatype_scalar(B) initializer(C) SEMICOLON. { A = new_annotation(ctx, B, C); } - -%type initializer_block_list { MOJOSHADER_astExpression * } -%destructor initializer_block_list { delete_expr(ctx, $$); } -initializer_block_list(A) ::= expression(B). { A = B; } -initializer_block_list(A) ::= LBRACE initializer_block_list(B) RBRACE. { A = B; } -initializer_block_list(A) ::= initializer_block_list(B) COMMA initializer_block_list(C). { A = new_binary_expr(ctx, MOJOSHADER_AST_OP_COMMA, B, C); } - -%type initializer_block { MOJOSHADER_astExpression * } -%destructor initializer_block { delete_expr(ctx, $$); } -initializer_block(A) ::= LBRACE initializer_block_list(B) RBRACE. { A = B; } - -%type initializer { MOJOSHADER_astExpression * } -%destructor initializer { delete_expr(ctx, $$); } -initializer(A) ::= ASSIGN initializer_block(B). { A = B; } -initializer(A) ::= ASSIGN expression(B). { A = B; } - -%type intrinsic_datatype { const MOJOSHADER_astDataType * } -intrinsic_datatype(A) ::= datatype_vector(B). { A = B; } -intrinsic_datatype(A) ::= datatype_matrix(B). { A = B; } -intrinsic_datatype(A) ::= datatype_scalar(B). { A = B; } -intrinsic_datatype(A) ::= datatype_sampler(B). { A = B; } -intrinsic_datatype(A) ::= datatype_buffer(B). { A = B; } - -%type datatype { const MOJOSHADER_astDataType * } -datatype(A) ::= intrinsic_datatype(B). { A = B; } -datatype(A) ::= USERTYPE(B). { A = B.datatype; } - -%type datatype_sampler { const MOJOSHADER_astDataType * } -datatype_sampler(A) ::= SAMPLER. { A = &ctx->dt_sampler2d; } -datatype_sampler(A) ::= SAMPLER1D. { A = &ctx->dt_sampler1d; } -datatype_sampler(A) ::= SAMPLER2D. { A = &ctx->dt_sampler2d; } -datatype_sampler(A) ::= SAMPLER3D. { A = &ctx->dt_sampler3d; } -datatype_sampler(A) ::= SAMPLERCUBE. { A = &ctx->dt_samplercube; } -datatype_sampler(A) ::= SAMPLER_STATE. { A = &ctx->dt_samplerstate; } -datatype_sampler(A) ::= SAMPLERSTATE. { A = &ctx->dt_samplerstate; } -datatype_sampler(A) ::= SAMPLERCOMPARISONSTATE. { A = &ctx->dt_samplercompstate; } - -%type datatype_scalar { const MOJOSHADER_astDataType * } -datatype_scalar(A) ::= BOOL. { A = &ctx->dt_bool; } -datatype_scalar(A) ::= INT. { A = &ctx->dt_int; } -datatype_scalar(A) ::= UINT. { A = &ctx->dt_uint; } -datatype_scalar(A) ::= HALF. { A = &ctx->dt_half; } -datatype_scalar(A) ::= FLOAT. { A = &ctx->dt_float; } -datatype_scalar(A) ::= DOUBLE. { A = &ctx->dt_double; } -datatype_scalar(A) ::= STRING. { A = &ctx->dt_string; } // this is for the effects framework, not HLSL. -datatype_scalar(A) ::= SNORM FLOAT. { A = &ctx->dt_float_snorm; } -datatype_scalar(A) ::= UNORM FLOAT. { A = &ctx->dt_float_unorm; } - -%type datatype_buffer { const MOJOSHADER_astDataType * } -datatype_buffer(A) ::= BUFFER LT BOOL GT. { A = &ctx->dt_buf_bool; } -datatype_buffer(A) ::= BUFFER LT INT GT. { A = &ctx->dt_buf_int; } -datatype_buffer(A) ::= BUFFER LT UINT GT. { A = &ctx->dt_buf_uint; } -datatype_buffer(A) ::= BUFFER LT HALF GT. { A = &ctx->dt_buf_half; } -datatype_buffer(A) ::= BUFFER LT FLOAT GT. { A = &ctx->dt_buf_float; } -datatype_buffer(A) ::= BUFFER LT DOUBLE GT. { A = &ctx->dt_buf_double; } -datatype_buffer(A) ::= BUFFER LT SNORM FLOAT GT. { A = &ctx->dt_buf_float_snorm; } -datatype_buffer(A) ::= BUFFER LT UNORM FLOAT GT. { A = &ctx->dt_buf_float_unorm; } - -%type datatype_vector { const MOJOSHADER_astDataType * } -datatype_vector(A) ::= VECTOR LT datatype_scalar(B) COMMA INT_CONSTANT(C) GT. { A = new_datatype_vector(ctx, B, (int) C.i64); } - -%type datatype_matrix { const MOJOSHADER_astDataType * } -datatype_matrix(A) ::= MATRIX LT datatype_scalar(B) COMMA INT_CONSTANT(C) COMMA INT_CONSTANT(D) GT. { A = new_datatype_matrix(ctx, B, (int) C.i64, (int) D.i64); } - -%type statement_block { MOJOSHADER_astStatement * } -%destructor statement_block { delete_statement(ctx, $$); } -statement_block(A) ::= LBRACE RBRACE. { A = new_block_statement(ctx, NULL); } -statement_block(A) ::= LBRACE statement_list(B) RBRACE. { REVERSE_LINKED_LIST(MOJOSHADER_astStatement, B); A = new_block_statement(ctx, B); } - -%type statement_list { MOJOSHADER_astStatement * } -%destructor statement_list { delete_statement(ctx, $$); } -statement_list(A) ::= statement(B). { A = B; } -statement_list(A) ::= statement_list(B) statement(C). { A = C; A->next = B; } - -// These are for Shader Model 4 and Xbox 360 only, apparently. -// !!! FIXME: ...so we ignore them for now. -// !!! FIXME: can these stack? "[isolate][unused]{}" or something? -%type statement_attribute { int } -statement_attribute(A) ::= ISOLATE. { A = 0; } // !!! FIXME -statement_attribute(A) ::= MAXINSTRUCTIONCOUNT LPAREN INT_CONSTANT RPAREN. { A = 0; } // !!! FIXME -statement_attribute(A) ::= NOEXPRESSIONOPTIMIZATIONS. { A = 0; } // !!! FIXME -statement_attribute(A) ::= REMOVEUNUSEDINPUTS. { A = 0; } // !!! FIXME -statement_attribute(A) ::= UNUSED. { A = 0; } // !!! FIXME -statement_attribute(A) ::= XPS. { A = 0; } // !!! FIXME - -%type statement { MOJOSHADER_astStatement * } -%destructor statement { delete_statement(ctx, $$); } -statement(A) ::= BREAK SEMICOLON. { A = new_break_statement(ctx); } -statement(A) ::= CONTINUE SEMICOLON. { A = new_continue_statement(ctx); } -statement(A) ::= DISCARD SEMICOLON. { A = new_discard_statement(ctx); } -statement(A) ::= LBRACKET statement_attribute(B) RBRACKET statement_block(C). { A = C; /* !!! FIXME: A->attributes = B;*/ B = 0; } -statement(A) ::= variable_declaration(B). { A = new_vardecl_statement(ctx, B); } -statement(A) ::= struct_declaration(B) SEMICOLON. { A = new_struct_statement(ctx, B); } -statement(A) ::= do_intro(B) DO statement(C) WHILE LPAREN expression(D) RPAREN SEMICOLON. { A = new_do_statement(ctx, B, C, D); } -statement(A) ::= while_intro(B) LPAREN expression(C) RPAREN statement(D). { A = new_while_statement(ctx, B, C, D); } -statement(A) ::= if_intro(B) LPAREN expression(C) RPAREN statement(D). { A = new_if_statement(ctx, B, C, D, NULL); } -statement(A) ::= if_intro(B) LPAREN expression(C) RPAREN statement(D) ELSE statement(E). { A = new_if_statement(ctx, B, C, D, E); } -statement(A) ::= switch_intro(B) LPAREN expression(C) RPAREN LBRACE switch_case_list(D) RBRACE. { REVERSE_LINKED_LIST(MOJOSHADER_astSwitchCases, D); A = new_switch_statement(ctx, B, C, D); } -statement(A) ::= typedef(B). { A = new_typedef_statement(ctx, B); } -statement(A) ::= SEMICOLON. { A = new_empty_statement(ctx); } -statement(A) ::= expression(B) SEMICOLON. { A = new_expr_statement(ctx, B); } -statement(A) ::= RETURN SEMICOLON. { A = new_return_statement(ctx, NULL); } -statement(A) ::= RETURN expression(B) SEMICOLON. { A = new_return_statement(ctx, B); } -statement(A) ::= statement_block(B). { A = B; } -statement(A) ::= for_statement(B). { A = B; } -//statement(A) ::= error SEMICOLON. { A = NULL; } // !!! FIXME: research using the error nonterminal - -%type while_intro { int } -while_intro(A) ::= LBRACKET UNROLL LPAREN INT_CONSTANT(B) RPAREN RBRACKET WHILE. { A = (B.i64 < 0) ? 0 : B.i64; } -while_intro(A) ::= LBRACKET UNROLL RBRACKET WHILE. { A = -1; } -while_intro(A) ::= LBRACKET LOOP RBRACKET WHILE. { A = 0; } -while_intro(A) ::= WHILE. { A = -2; } - -%type for_statement { MOJOSHADER_astStatement * } -%destructor for_statement { delete_statement(ctx, $$); } -for_statement(A) ::= for_intro(B) for_details(C). { A = C; ((MOJOSHADER_astForStatement *) A)->unroll = B; } - -%type for_intro { int } -for_intro(A) ::= LBRACKET UNROLL LPAREN INT_CONSTANT(B) RPAREN RBRACKET FOR. { A = (B.i64 < 0) ? 0 : B.i64; } -for_intro(A) ::= LBRACKET UNROLL RBRACKET FOR. { A = -1; } -for_intro(A) ::= LBRACKET LOOP RBRACKET FOR. { A = 0; } -for_intro(A) ::= FOR. { A = -2; } - -%type for_details { MOJOSHADER_astStatement * } -%destructor for_details { delete_statement(ctx, $$); } -for_details(A) ::= LPAREN expression(B) SEMICOLON expression(C) SEMICOLON expression(D) RPAREN statement(E). { A = new_for_statement(ctx, NULL, B, C, D, E); } -for_details(A) ::= LPAREN SEMICOLON SEMICOLON RPAREN statement(B). { A = new_for_statement(ctx, NULL, NULL, NULL, NULL, B); } -for_details(A) ::= LPAREN SEMICOLON SEMICOLON expression(B) RPAREN statement(C). { A = new_for_statement(ctx, NULL, NULL, NULL, B, C); } -for_details(A) ::= LPAREN SEMICOLON expression(B) SEMICOLON RPAREN statement(C). { A = new_for_statement(ctx, NULL, NULL, B, NULL, C); } -for_details(A) ::= LPAREN SEMICOLON expression(B) SEMICOLON expression(C) RPAREN statement(D). { A = new_for_statement(ctx, NULL, NULL, B, C, D); } -for_details(A) ::= LPAREN expression(B) SEMICOLON SEMICOLON RPAREN statement(C). { A = new_for_statement(ctx, NULL, B, NULL, NULL, C); } -for_details(A) ::= LPAREN expression(B) SEMICOLON SEMICOLON expression(C) RPAREN statement(D). { A = new_for_statement(ctx, NULL, B, NULL, C, D); } -for_details(A) ::= LPAREN expression(B) SEMICOLON expression(C) SEMICOLON RPAREN statement(D). { A = new_for_statement(ctx, NULL, B, C, NULL, D); } -for_details(A) ::= LPAREN variable_declaration(B) expression(C) SEMICOLON expression(D) RPAREN statement(E). { A = new_for_statement(ctx, B, NULL, C, D, E); } -for_details(A) ::= LPAREN variable_declaration(B) SEMICOLON RPAREN statement(C). { A = new_for_statement(ctx, B, NULL, NULL, NULL, C); } -for_details(A) ::= LPAREN variable_declaration(B) SEMICOLON expression(C) RPAREN statement(D). { A = new_for_statement(ctx, B, NULL, C, NULL, D); } -for_details(A) ::= LPAREN variable_declaration(B) expression(C) SEMICOLON RPAREN statement(D). { A = new_for_statement(ctx, B, NULL, C, NULL, D); } - -%type do_intro { int } -do_intro(A) ::= LBRACKET UNROLL LPAREN INT_CONSTANT(B) RPAREN RBRACKET DO. { A = (B.i64 < 0) ? 0 : (int) B.i64; } -do_intro(A) ::= LBRACKET UNROLL RBRACKET DO. { A = -1; } -do_intro(A) ::= LBRACKET LOOP RBRACKET DO. { A = 0; } -do_intro(A) ::= DO. { A = -2; } - -%type if_intro { int } -if_intro(A) ::= LBRACKET BRANCH RBRACKET IF. { A = MOJOSHADER_AST_IFATTR_BRANCH; } -if_intro(A) ::= LBRACKET FLATTEN RBRACKET IF. { A = MOJOSHADER_AST_IFATTR_FLATTEN; } -if_intro(A) ::= LBRACKET IFALL RBRACKET IF. { A = MOJOSHADER_AST_IFATTR_IFALL; } -if_intro(A) ::= LBRACKET IFANY RBRACKET IF. { A = MOJOSHADER_AST_IFATTR_IFANY; } -if_intro(A) ::= LBRACKET PREDICATE RBRACKET IF. { A = MOJOSHADER_AST_IFATTR_PREDICATE; } -if_intro(A) ::= LBRACKET PREDICATEBLOCK RBRACKET IF. { A = MOJOSHADER_AST_IFATTR_PREDICATEBLOCK; } -if_intro(A) ::= IF. { A = MOJOSHADER_AST_IFATTR_NONE; } - -%type switch_intro { int } -switch_intro(A) ::= LBRACKET FLATTEN RBRACKET SWITCH. { A = MOJOSHADER_AST_SWITCHATTR_FLATTEN; } -switch_intro(A) ::= LBRACKET BRANCH RBRACKET SWITCH. { A = MOJOSHADER_AST_SWITCHATTR_BRANCH; } -switch_intro(A) ::= LBRACKET FORCECASE RBRACKET SWITCH. { A = MOJOSHADER_AST_SWITCHATTR_FORCECASE; } -switch_intro(A) ::= LBRACKET CALL RBRACKET SWITCH. { A = MOJOSHADER_AST_SWITCHATTR_CALL; } -switch_intro(A) ::= SWITCH. { A = MOJOSHADER_AST_SWITCHATTR_NONE; } - -%type switch_case_list { MOJOSHADER_astSwitchCases * } -%destructor switch_case_list { delete_switch_case(ctx, $$); } -switch_case_list(A) ::= switch_case(B). { A = B; } -switch_case_list(A) ::= switch_case_list(B) switch_case(C). { A = C; A->next = B; } - -// You can do math here, apparently, as long as it produces an int constant. -// ...so "case 3+2:" works. -%type switch_case { MOJOSHADER_astSwitchCases * } -%destructor switch_case { delete_switch_case(ctx, $$); } -switch_case(A) ::= CASE expression(B) COLON statement_list(C). { REVERSE_LINKED_LIST(MOJOSHADER_astStatement, C); A = new_switch_case(ctx, B, C); } -switch_case(A) ::= CASE expression(B) COLON. { A = new_switch_case(ctx, B, NULL); } -switch_case(A) ::= DEFAULT COLON statement_list(B). { REVERSE_LINKED_LIST(MOJOSHADER_astStatement, B); A = new_switch_case(ctx, NULL, B); } -switch_case(A) ::= DEFAULT COLON. { A = new_switch_case(ctx, NULL, NULL); } - -// the expression stuff is based on Jeff Lee's ANSI C grammar. -%type primary_expr { MOJOSHADER_astExpression * } -%destructor primary_expr { delete_expr(ctx, $$); } -primary_expr(A) ::= IDENTIFIER(B). { A = new_identifier_expr(ctx, B.string); } -primary_expr(A) ::= INT_CONSTANT(B). { A = new_literal_int_expr(ctx, B.i64); } -primary_expr(A) ::= FLOAT_CONSTANT(B). { A = new_literal_float_expr(ctx, B.dbl); } -primary_expr(A) ::= STRING_LITERAL(B). { A = new_literal_string_expr(ctx, B.string); } -primary_expr(A) ::= TRUE. { A = new_literal_boolean_expr(ctx, 1); } -primary_expr(A) ::= FALSE. { A = new_literal_boolean_expr(ctx, 0); } -primary_expr(A) ::= LPAREN expression(B) RPAREN. { A = B; } - -%type postfix_expr { MOJOSHADER_astExpression * } -%destructor postfix_expr { delete_expr(ctx, $$); } -postfix_expr(A) ::= primary_expr(B). { A = B; } -postfix_expr(A) ::= postfix_expr(B) LBRACKET expression(C) RBRACKET. { A = new_binary_expr(ctx, MOJOSHADER_AST_OP_DEREF_ARRAY, B, C); } -postfix_expr(A) ::= IDENTIFIER(B) arguments(C). { A = new_callfunc_expr(ctx, B.string, C); } -postfix_expr(A) ::= datatype(B) arguments(C). { A = new_constructor_expr(ctx, B, C); } // HLSL constructor -postfix_expr(A) ::= postfix_expr(B) DOT IDENTIFIER(C). { A = new_deref_struct_expr(ctx, B, C.string); } -postfix_expr(A) ::= postfix_expr(B) PLUSPLUS. { A = new_unary_expr(ctx, MOJOSHADER_AST_OP_POSTINCREMENT, B); } -postfix_expr(A) ::= postfix_expr(B) MINUSMINUS. { A = new_unary_expr(ctx, MOJOSHADER_AST_OP_POSTDECREMENT, B); } - -%type arguments { MOJOSHADER_astArguments * } -%destructor arguments { delete_arguments(ctx, $$); } -arguments(A) ::= LPAREN RPAREN. { A = NULL; } -arguments(A) ::= LPAREN argument_list(B) RPAREN. { REVERSE_LINKED_LIST(MOJOSHADER_astArguments, B); A = B; } - -%type argument_list { MOJOSHADER_astArguments * } -%destructor argument_list { delete_arguments(ctx, $$); } -argument_list(A) ::= assignment_expr(B). { A = new_argument(ctx, B); } -argument_list(A) ::= argument_list(B) COMMA assignment_expr(C). { A = new_argument(ctx, C); A->next = B; } - -%type unary_expr { MOJOSHADER_astExpression * } -%destructor unary_expr { delete_expr(ctx, $$); } -unary_expr(A) ::= postfix_expr(B). { A = B; } -unary_expr(A) ::= PLUSPLUS unary_expr(B). { A = new_unary_expr(ctx, MOJOSHADER_AST_OP_PREINCREMENT, B); } -unary_expr(A) ::= MINUSMINUS unary_expr(B). { A = new_unary_expr(ctx, MOJOSHADER_AST_OP_PREDECREMENT, B); } -unary_expr(A) ::= PLUS cast_expr(B). { A = B; } // unary "+x" is always a no-op, so throw it away here. -unary_expr(A) ::= MINUS cast_expr(B). { A = new_unary_expr(ctx, MOJOSHADER_AST_OP_NEGATE, B); } -unary_expr(A) ::= COMPLEMENT cast_expr(B). { A = new_unary_expr(ctx, MOJOSHADER_AST_OP_COMPLEMENT, B); } -unary_expr(A) ::= EXCLAMATION cast_expr(B). { A = new_unary_expr(ctx, MOJOSHADER_AST_OP_NOT, B); } - -%type cast_expr { MOJOSHADER_astExpression * } -%destructor cast_expr { delete_expr(ctx, $$); } -cast_expr(A) ::= unary_expr(B). { A = B; } -cast_expr(A) ::= LPAREN datatype(B) RPAREN cast_expr(C). { A = new_cast_expr(ctx, B, C); } - -%type multiplicative_expr { MOJOSHADER_astExpression * } -%destructor multiplicative_expr { delete_expr(ctx, $$); } -multiplicative_expr(A) ::= cast_expr(B). { A = B; } -multiplicative_expr(A) ::= multiplicative_expr(B) STAR cast_expr(C). { A = new_binary_expr(ctx, MOJOSHADER_AST_OP_MULTIPLY, B, C); } -multiplicative_expr(A) ::= multiplicative_expr(B) SLASH cast_expr(C). { A = new_binary_expr(ctx, MOJOSHADER_AST_OP_DIVIDE, B, C); } -multiplicative_expr(A) ::= multiplicative_expr(B) PERCENT cast_expr(C). { A = new_binary_expr(ctx, MOJOSHADER_AST_OP_MODULO, B, C); } - -%type additive_expr { MOJOSHADER_astExpression * } -%destructor additive_expr { delete_expr(ctx, $$); } -additive_expr(A) ::= multiplicative_expr(B). { A = B; } -additive_expr(A) ::= additive_expr(B) PLUS multiplicative_expr(C). { A = new_binary_expr(ctx, MOJOSHADER_AST_OP_ADD, B, C); } -additive_expr(A) ::= additive_expr(B) MINUS multiplicative_expr(C). { A = new_binary_expr(ctx, MOJOSHADER_AST_OP_SUBTRACT, B, C); } - -%type shift_expr { MOJOSHADER_astExpression * } -%destructor shift_expr { delete_expr(ctx, $$); } -shift_expr(A) ::= additive_expr(B). { A = B; } -shift_expr(A) ::= shift_expr(B) LSHIFT additive_expr(C). { A = new_binary_expr(ctx, MOJOSHADER_AST_OP_LSHIFT, B, C); } -shift_expr(A) ::= shift_expr(B) RSHIFT additive_expr(C). { A = new_binary_expr(ctx, MOJOSHADER_AST_OP_RSHIFT, B, C); } - -%type relational_expr { MOJOSHADER_astExpression * } -%destructor relational_expr { delete_expr(ctx, $$); } -relational_expr(A) ::= shift_expr(B). { A = B; } -relational_expr(A) ::= relational_expr(B) LT shift_expr(C). { A = new_binary_expr(ctx, MOJOSHADER_AST_OP_LESSTHAN, B, C); } -relational_expr(A) ::= relational_expr(B) GT shift_expr(C). { A = new_binary_expr(ctx, MOJOSHADER_AST_OP_GREATERTHAN, B, C); } -relational_expr(A) ::= relational_expr(B) LEQ shift_expr(C). { A = new_binary_expr(ctx, MOJOSHADER_AST_OP_LESSTHANOREQUAL, B, C); } -relational_expr(A) ::= relational_expr(B) GEQ shift_expr(C). { A = new_binary_expr(ctx, MOJOSHADER_AST_OP_GREATERTHANOREQUAL, B, C); } - -%type equality_expr { MOJOSHADER_astExpression * } -%destructor equality_expr { delete_expr(ctx, $$); } -equality_expr(A) ::= relational_expr(B). { A = B; } -equality_expr(A) ::= equality_expr(B) EQL relational_expr(C). { A = new_binary_expr(ctx, MOJOSHADER_AST_OP_EQUAL, B, C); } -equality_expr(A) ::= equality_expr(B) NEQ relational_expr(C). { A = new_binary_expr(ctx, MOJOSHADER_AST_OP_NOTEQUAL, B, C); } - -%type and_expr { MOJOSHADER_astExpression * } -%destructor and_expr { delete_expr(ctx, $$); } -and_expr(A) ::= equality_expr(B). { A = B; } -and_expr(A) ::= and_expr(B) AND equality_expr(C). { A = new_binary_expr(ctx, MOJOSHADER_AST_OP_BINARYAND, B, C); } - -%type exclusive_or_expr { MOJOSHADER_astExpression * } -%destructor exclusive_or_expr { delete_expr(ctx, $$); } -exclusive_or_expr(A) ::= and_expr(B). { A = B; } -exclusive_or_expr(A) ::= exclusive_or_expr(B) XOR and_expr(C). { A = new_binary_expr(ctx, MOJOSHADER_AST_OP_BINARYXOR, B, C); } - -%type inclusive_or_expr { MOJOSHADER_astExpression * } -%destructor inclusive_or_expr { delete_expr(ctx, $$); } -inclusive_or_expr(A) ::= exclusive_or_expr(B). { A = B; } -inclusive_or_expr(A) ::= inclusive_or_expr(B) OR exclusive_or_expr(C). { A = new_binary_expr(ctx, MOJOSHADER_AST_OP_BINARYOR, B, C); } - -%type logical_and_expr { MOJOSHADER_astExpression * } -%destructor logical_and_expr { delete_expr(ctx, $$); } -logical_and_expr(A) ::= inclusive_or_expr(B). { A = B; } -logical_and_expr(A) ::= logical_and_expr(B) ANDAND inclusive_or_expr(C). { A = new_binary_expr(ctx, MOJOSHADER_AST_OP_LOGICALAND, B, C); } - -%type logical_or_expr { MOJOSHADER_astExpression * } -%destructor logical_or_expr { delete_expr(ctx, $$); } -logical_or_expr(A) ::= logical_and_expr(B). { A = B; } -logical_or_expr(A) ::= logical_or_expr(B) OROR logical_and_expr(C). { A = new_binary_expr(ctx, MOJOSHADER_AST_OP_LOGICALOR, B, C); } - -%type conditional_expr { MOJOSHADER_astExpression * } -%destructor conditional_expr { delete_expr(ctx, $$); } -conditional_expr(A) ::= logical_or_expr(B). { A = B; } -conditional_expr(A) ::= logical_or_expr(B) QUESTION logical_or_expr(C) COLON conditional_expr(D). { A = new_ternary_expr(ctx, MOJOSHADER_AST_OP_CONDITIONAL, B, C, D); } - -%type assignment_expr { MOJOSHADER_astExpression * } -%destructor assignment_expr { delete_expr(ctx, $$); } -assignment_expr(A) ::= conditional_expr(B). { A = B; } -assignment_expr(A) ::= unary_expr(B) ASSIGN assignment_expr(C). { A = new_binary_expr(ctx, MOJOSHADER_AST_OP_ASSIGN, B, C); } -assignment_expr(A) ::= unary_expr(B) MULASSIGN assignment_expr(C). { A = new_binary_expr(ctx, MOJOSHADER_AST_OP_MULASSIGN, B, C); } -assignment_expr(A) ::= unary_expr(B) DIVASSIGN assignment_expr(C). { A = new_binary_expr(ctx, MOJOSHADER_AST_OP_DIVASSIGN, B, C); } -assignment_expr(A) ::= unary_expr(B) MODASSIGN assignment_expr(C). { A = new_binary_expr(ctx, MOJOSHADER_AST_OP_MODASSIGN, B, C); } -assignment_expr(A) ::= unary_expr(B) ADDASSIGN assignment_expr(C). { A = new_binary_expr(ctx, MOJOSHADER_AST_OP_ADDASSIGN, B, C); } -assignment_expr(A) ::= unary_expr(B) SUBASSIGN assignment_expr(C). { A = new_binary_expr(ctx, MOJOSHADER_AST_OP_SUBASSIGN, B, C); } -assignment_expr(A) ::= unary_expr(B) LSHIFTASSIGN assignment_expr(C). { A = new_binary_expr(ctx, MOJOSHADER_AST_OP_LSHIFTASSIGN, B, C); } -assignment_expr(A) ::= unary_expr(B) RSHIFTASSIGN assignment_expr(C). { A = new_binary_expr(ctx, MOJOSHADER_AST_OP_RSHIFTASSIGN, B, C); } -assignment_expr(A) ::= unary_expr(B) ANDASSIGN assignment_expr(C). { A = new_binary_expr(ctx, MOJOSHADER_AST_OP_ANDASSIGN, B, C); } -assignment_expr(A) ::= unary_expr(B) XORASSIGN assignment_expr(C). { A = new_binary_expr(ctx, MOJOSHADER_AST_OP_XORASSIGN, B, C); } -assignment_expr(A) ::= unary_expr(B) ORASSIGN assignment_expr(C). { A = new_binary_expr(ctx, MOJOSHADER_AST_OP_ORASSIGN, B, C); } - -%type expression { MOJOSHADER_astExpression * } -%destructor expression { delete_expr(ctx, $$); } -expression(A) ::= assignment_expr(B). { A = B; } -expression(A) ::= expression(B) COMMA assignment_expr(C). { A = new_binary_expr(ctx, MOJOSHADER_AST_OP_COMMA, B, C); } - -// end of mojoshader_parser_hlsl.lemon ... - diff --git a/Externals/mojoshader/1067/mojoshader_preprocessor.c b/Externals/mojoshader/1067/mojoshader_preprocessor.c deleted file mode 100644 index 233566ae..00000000 --- a/Externals/mojoshader/1067/mojoshader_preprocessor.c +++ /dev/null @@ -1,2362 +0,0 @@ -/** - * MojoShader; generate shader programs from bytecode of compiled - * Direct3D shaders. - * - * Please see the file LICENSE.txt in the source's root directory. - * - * This file written by Ryan C. Gordon. - */ - -#define __MOJOSHADER_INTERNAL__ 1 -#include "mojoshader_internal.h" - -#if DEBUG_PREPROCESSOR - #define print_debug_token(token, len, val) \ - MOJOSHADER_print_debug_token("PREPROCESSOR", token, len, val) -#else - #define print_debug_token(token, len, val) -#endif - -#if DEBUG_LEXER -static Token debug_preprocessor_lexer(IncludeState *s) -{ - const Token retval = preprocessor_lexer(s); - MOJOSHADER_print_debug_token("LEXER", s->token, s->tokenlen, retval); - return retval; -} // debug_preprocessor_lexer -#define preprocessor_lexer(s) debug_preprocessor_lexer(s) -#endif - -#if DEBUG_TOKENIZER -static void print_debug_lexing_position(IncludeState *s) -{ - if (s != NULL) - printf("NOW LEXING %s:%d ...\n", s->filename, s->line); -} // print_debug_lexing_position -#else -#define print_debug_lexing_position(s) -#endif - -typedef struct Context -{ - int isfail; - int out_of_memory; - char failstr[256]; - int recursion_count; - int asm_comments; - int parsing_pragma; - Conditional *conditional_pool; - IncludeState *include_stack; - IncludeState *include_pool; - Define *define_hashtable[256]; - Define *define_pool; - Define *file_macro; - Define *line_macro; - StringCache *filename_cache; - MOJOSHADER_includeOpen open_callback; - MOJOSHADER_includeClose close_callback; - MOJOSHADER_malloc malloc; - MOJOSHADER_free free; - void *malloc_data; -} Context; - - -// Convenience functions for allocators... - -static inline void out_of_memory(Context *ctx) -{ - ctx->out_of_memory = 1; -} // out_of_memory - -static inline void *Malloc(Context *ctx, const size_t len) -{ - void *retval = ctx->malloc((int) len, ctx->malloc_data); - if (retval == NULL) - out_of_memory(ctx); - return retval; -} // Malloc - -static inline void Free(Context *ctx, void *ptr) -{ - ctx->free(ptr, ctx->malloc_data); -} // Free - -static void *MallocBridge(int bytes, void *data) -{ - return Malloc((Context *) data, (size_t) bytes); -} // MallocBridge - -static void FreeBridge(void *ptr, void *data) -{ - Free((Context *) data, ptr); -} // FreeBridge - -static inline char *StrDup(Context *ctx, const char *str) -{ - char *retval = (char *) Malloc(ctx, strlen(str) + 1); - if (retval != NULL) - strcpy(retval, str); - return retval; -} // StrDup - -static void failf(Context *ctx, const char *fmt, ...) ISPRINTF(2,3); -static void failf(Context *ctx, const char *fmt, ...) -{ - ctx->isfail = 1; - va_list ap; - va_start(ap, fmt); - vsnprintf(ctx->failstr, sizeof (ctx->failstr), fmt, ap); - va_end(ap); -} // failf - -static inline void fail(Context *ctx, const char *reason) -{ - failf(ctx, "%s", reason); -} // fail - - -#if DEBUG_TOKENIZER -void MOJOSHADER_print_debug_token(const char *subsystem, const char *token, - const unsigned int tokenlen, - const Token tokenval) -{ - printf("%s TOKEN: \"", subsystem); - unsigned int i; - for (i = 0; i < tokenlen; i++) - { - if (token[i] == '\n') - printf("\\n"); - else if (token[i] == '\\') - printf("\\\\"); - else - printf("%c", token[i]); - } // for - printf("\" ("); - switch (tokenval) - { - #define TOKENCASE(x) case x: printf("%s", #x); break - TOKENCASE(TOKEN_UNKNOWN); - TOKENCASE(TOKEN_IDENTIFIER); - TOKENCASE(TOKEN_INT_LITERAL); - TOKENCASE(TOKEN_FLOAT_LITERAL); - TOKENCASE(TOKEN_STRING_LITERAL); - TOKENCASE(TOKEN_ADDASSIGN); - TOKENCASE(TOKEN_SUBASSIGN); - TOKENCASE(TOKEN_MULTASSIGN); - TOKENCASE(TOKEN_DIVASSIGN); - TOKENCASE(TOKEN_MODASSIGN); - TOKENCASE(TOKEN_XORASSIGN); - TOKENCASE(TOKEN_ANDASSIGN); - TOKENCASE(TOKEN_ORASSIGN); - TOKENCASE(TOKEN_INCREMENT); - TOKENCASE(TOKEN_DECREMENT); - TOKENCASE(TOKEN_RSHIFT); - TOKENCASE(TOKEN_LSHIFT); - TOKENCASE(TOKEN_ANDAND); - TOKENCASE(TOKEN_OROR); - TOKENCASE(TOKEN_LEQ); - TOKENCASE(TOKEN_GEQ); - TOKENCASE(TOKEN_EQL); - TOKENCASE(TOKEN_NEQ); - TOKENCASE(TOKEN_HASH); - TOKENCASE(TOKEN_HASHHASH); - TOKENCASE(TOKEN_PP_INCLUDE); - TOKENCASE(TOKEN_PP_LINE); - TOKENCASE(TOKEN_PP_DEFINE); - TOKENCASE(TOKEN_PP_UNDEF); - TOKENCASE(TOKEN_PP_IF); - TOKENCASE(TOKEN_PP_IFDEF); - TOKENCASE(TOKEN_PP_IFNDEF); - TOKENCASE(TOKEN_PP_ELSE); - TOKENCASE(TOKEN_PP_ELIF); - TOKENCASE(TOKEN_PP_ENDIF); - TOKENCASE(TOKEN_PP_ERROR); - TOKENCASE(TOKEN_PP_PRAGMA); - TOKENCASE(TOKEN_INCOMPLETE_COMMENT); - TOKENCASE(TOKEN_BAD_CHARS); - TOKENCASE(TOKEN_EOI); - TOKENCASE(TOKEN_PREPROCESSING_ERROR); - #undef TOKENCASE - - case ((Token) '\n'): - printf("'\\n'"); - break; - - case ((Token) '\\'): - printf("'\\\\'"); - break; - - default: - assert(((int)tokenval) < 256); - printf("'%c'", (char) tokenval); - break; - } // switch - printf(")\n"); -} // MOJOSHADER_print_debug_token -#endif - - - -#if !MOJOSHADER_FORCE_INCLUDE_CALLBACKS - -// !!! FIXME: most of these _MSC_VER should probably be _WINDOWS? -#ifdef _MSC_VER -#define WIN32_LEAN_AND_MEAN 1 -#include <windows.h> // GL headers need this for WINGDIAPI definition. -#else -#include <sys/stat.h> -#include <fcntl.h> -#include <unistd.h> -#endif - -int MOJOSHADER_internal_include_open(MOJOSHADER_includeType inctype, - const char *fname, const char *parent, - const char **outdata, - unsigned int *outbytes, - MOJOSHADER_malloc m, MOJOSHADER_free f, - void *d) -{ -#ifdef _MSC_VER - WCHAR wpath[MAX_PATH]; - if (!MultiByteToWideChar(CP_UTF8, 0, fname, -1, wpath, MAX_PATH)) - return 0; - - const DWORD share = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE; - const HANDLE handle = CreateFileW(wpath, FILE_GENERIC_READ, share, - NULL, OPEN_EXISTING, NULL, NULL); - if (handle == INVALID_HANDLE_VALUE) - return 0; - - const DWORD fileSize = GetFileSize(handle, NULL); - if (fileSize == INVALID_FILE_SIZE) - { - CloseHandle(handle); - return 0; - } // if - - char *data = (char *) m(fileSize, d); - if (data == NULL) - { - CloseHandle(handle); - return 0; - } // if - - DWORD readLength = 0; - if (!ReadFile(handle, data, fileSize, &readLength, NULL)) - { - CloseHandle(handle); - f(data, d); - return 0; - } // if - - CloseHandle(handle); - - if (readLength != fileSize) - { - f(data, d); - return 0; - } // if - *outdata = data; - *outbytes = fileSize; - return 1; -#else - struct stat statbuf; - if (stat(fname, &statbuf) == -1) - return 0; - char *data = (char *) m(statbuf.st_size, d); - if (data == NULL) - return 0; - const int fd = open(fname, O_RDONLY); - if (fd == -1) - { - f(data, d); - return 0; - } // if - if (read(fd, data, statbuf.st_size) != statbuf.st_size) - { - f(data, d); - close(fd); - return 0; - } // if - close(fd); - *outdata = data; - *outbytes = (unsigned int) statbuf.st_size; - return 1; -#endif -} // MOJOSHADER_internal_include_open - - -void MOJOSHADER_internal_include_close(const char *data, MOJOSHADER_malloc m, - MOJOSHADER_free f, void *d) -{ - f((void *) data, d); -} // MOJOSHADER_internal_include_close -#endif // !MOJOSHADER_FORCE_INCLUDE_CALLBACKS - - -// !!! FIXME: maybe use these pool magic elsewhere? -// !!! FIXME: maybe just get rid of this? (maybe the fragmentation isn't a big deal?) - -// Pool stuff... -// ugh, I hate this macro salsa. -#define FREE_POOL(type, poolname) \ - static void free_##poolname##_pool(Context *ctx) { \ - type *item = ctx->poolname##_pool; \ - while (item != NULL) { \ - type *next = item->next; \ - Free(ctx, item); \ - item = next; \ - } \ - } - -#define GET_POOL(type, poolname) \ - static type *get_##poolname(Context *ctx) { \ - type *retval = ctx->poolname##_pool; \ - if (retval != NULL) \ - ctx->poolname##_pool = retval->next; \ - else \ - retval = (type *) Malloc(ctx, sizeof (type)); \ - if (retval != NULL) \ - memset(retval, '\0', sizeof (type)); \ - return retval; \ - } - -#define PUT_POOL(type, poolname) \ - static void put_##poolname(Context *ctx, type *item) { \ - item->next = ctx->poolname##_pool; \ - ctx->poolname##_pool = item; \ - } - -#define IMPLEMENT_POOL(type, poolname) \ - FREE_POOL(type, poolname) \ - GET_POOL(type, poolname) \ - PUT_POOL(type, poolname) - -IMPLEMENT_POOL(Conditional, conditional) -IMPLEMENT_POOL(IncludeState, include) -IMPLEMENT_POOL(Define, define) - - -// Preprocessor define hashtable stuff... - -// !!! FIXME: why isn't this using mojoshader_common.c's code? - -// this is djb's xor hashing function. -static inline uint32 hash_string_djbxor(const char *sym) -{ - register uint32 hash = 5381; - while (*sym) - hash = ((hash << 5) + hash) ^ *(sym++); - return hash; -} // hash_string_djbxor - -static inline uint8 hash_define(const char *sym) -{ - return (uint8) hash_string_djbxor(sym); -} // hash_define - - -static int add_define(Context *ctx, const char *sym, const char *val, - char **parameters, int paramcount) -{ - const uint8 hash = hash_define(sym); - Define *bucket = ctx->define_hashtable[hash]; - while (bucket) - { - if (strcmp(bucket->identifier, sym) == 0) - { - failf(ctx, "'%s' already defined", sym); // !!! FIXME: warning? - // !!! FIXME: gcc reports the location of previous #define here. - return 0; - } // if - bucket = bucket->next; - } // while - - bucket = get_define(ctx); - if (bucket == NULL) - return 0; - - bucket->definition = val; - bucket->original = NULL; - bucket->identifier = sym; - bucket->parameters = (const char **) parameters; - bucket->paramcount = paramcount; - bucket->next = ctx->define_hashtable[hash]; - ctx->define_hashtable[hash] = bucket; - return 1; -} // add_define - - -static void free_define(Context *ctx, Define *def) -{ - if (def != NULL) - { - int i; - for (i = 0; i < def->paramcount; i++) - Free(ctx, (void *) def->parameters[i]); - Free(ctx, (void *) def->parameters); - Free(ctx, (void *) def->identifier); - Free(ctx, (void *) def->definition); - Free(ctx, (void *) def->original); - put_define(ctx, def); - } // if -} // free_define - - -static int remove_define(Context *ctx, const char *sym) -{ - const uint8 hash = hash_define(sym); - Define *bucket = ctx->define_hashtable[hash]; - Define *prev = NULL; - while (bucket) - { - if (strcmp(bucket->identifier, sym) == 0) - { - if (prev == NULL) - ctx->define_hashtable[hash] = bucket->next; - else - prev->next = bucket->next; - free_define(ctx, bucket); - return 1; - } // if - prev = bucket; - bucket = bucket->next; - } // while - - return 0; -} // remove_define - - -static const Define *find_define(Context *ctx, const char *sym) -{ - if ( (ctx->file_macro) && (strcmp(sym, "__FILE__") == 0) ) - { - Free(ctx, (char *) ctx->file_macro->definition); - const IncludeState *state = ctx->include_stack; - const char *fname = state ? state->filename : ""; - const size_t len = strlen(fname) + 2; - char *str = (char *) Malloc(ctx, len); - if (!str) - return NULL; - str[0] = '\"'; - memcpy(str + 1, fname, len - 2); - str[len - 1] = '\"'; - ctx->file_macro->definition = str; - return ctx->file_macro; - } // if - - else if ( (ctx->line_macro) && (strcmp(sym, "__LINE__") == 0) ) - { - Free(ctx, (char *) ctx->line_macro->definition); - const IncludeState *state = ctx->include_stack; - const size_t bufsize = 32; - char *str = (char *) Malloc(ctx, bufsize); - if (!str) - return 0; - - const size_t len = snprintf(str, bufsize, "%u", state->line); - assert(len < bufsize); - ctx->line_macro->definition = str; - return ctx->line_macro; - } // else - - const uint8 hash = hash_define(sym); - Define *bucket = ctx->define_hashtable[hash]; - while (bucket) - { - if (strcmp(bucket->identifier, sym) == 0) - return bucket; - bucket = bucket->next; - } // while - return NULL; -} // find_define - - -static const Define *find_define_by_token(Context *ctx) -{ - IncludeState *state = ctx->include_stack; - assert(state->tokenval == TOKEN_IDENTIFIER); - char *sym = (char *) alloca(state->tokenlen+1); - memcpy(sym, state->token, state->tokenlen); - sym[state->tokenlen] = '\0'; - return find_define(ctx, sym); -} // find_define_by_token - - -static const Define *find_macro_arg(const IncludeState *state, - const Define *defines) -{ - const Define *def = NULL; - char *sym = (char *) alloca(state->tokenlen + 1); - memcpy(sym, state->token, state->tokenlen); - sym[state->tokenlen] = '\0'; - - for (def = defines; def != NULL; def = def->next) - { - assert(def->parameters == NULL); // args can't have args! - assert(def->paramcount == 0); // args can't have args! - if (strcmp(def->identifier, sym) == 0) - break; - } // while - - return def; -} // find_macro_arg - - -static void put_all_defines(Context *ctx) -{ - size_t i; - for (i = 0; i < STATICARRAYLEN(ctx->define_hashtable); i++) - { - Define *bucket = ctx->define_hashtable[i]; - ctx->define_hashtable[i] = NULL; - while (bucket) - { - Define *next = bucket->next; - free_define(ctx, bucket); - bucket = next; - } // while - } // for -} // put_all_defines - - -static int push_source(Context *ctx, const char *fname, const char *source, - unsigned int srclen, unsigned int linenum, - MOJOSHADER_includeClose close_callback) -{ - IncludeState *state = get_include(ctx); - if (state == NULL) - return 0; - - if (fname != NULL) - { - state->filename = stringcache(ctx->filename_cache, fname); - if (state->filename == NULL) - { - put_include(ctx, state); - return 0; - } // if - } // if - - state->close_callback = close_callback; - state->source_base = source; - state->source = source; - state->token = source; - state->tokenval = ((Token) '\n'); - state->orig_length = srclen; - state->bytes_left = srclen; - state->line = linenum; - state->next = ctx->include_stack; - state->asm_comments = ctx->asm_comments; - - print_debug_lexing_position(state); - - ctx->include_stack = state; - - return 1; -} // push_source - - -static void pop_source(Context *ctx) -{ - IncludeState *state = ctx->include_stack; - assert(state != NULL); // more pops than pushes! - if (state == NULL) - return; - - if (state->close_callback) - { - state->close_callback(state->source_base, ctx->malloc, - ctx->free, ctx->malloc_data); - } // if - - // state->filename is a pointer to the filename cache; don't free it here! - - Conditional *cond = state->conditional_stack; - while (cond) - { - Conditional *next = cond->next; - put_conditional(ctx, cond); - cond = next; - } // while - - ctx->include_stack = state->next; - - print_debug_lexing_position(ctx->include_stack); - - put_include(ctx, state); -} // pop_source - - -static void close_define_include(const char *data, MOJOSHADER_malloc m, - MOJOSHADER_free f, void *d) -{ - f((void *) data, d); -} // close_define_include - - -Preprocessor *preprocessor_start(const char *fname, const char *source, - unsigned int sourcelen, - MOJOSHADER_includeOpen open_callback, - MOJOSHADER_includeClose close_callback, - const MOJOSHADER_preprocessorDefine *defines, - unsigned int define_count, int asm_comments, - MOJOSHADER_malloc m, MOJOSHADER_free f, void *d) -{ - int okay = 1; - unsigned int i = 0; - - // the preprocessor is internal-only, so we verify all these are != NULL. - assert(m != NULL); - assert(f != NULL); - - Context *ctx = (Context *) m(sizeof (Context), d); - if (ctx == NULL) - return NULL; - - memset(ctx, '\0', sizeof (Context)); - ctx->malloc = m; - ctx->free = f; - ctx->malloc_data = d; - ctx->open_callback = open_callback; - ctx->close_callback = close_callback; - ctx->asm_comments = asm_comments; - - ctx->filename_cache = stringcache_create(MallocBridge, FreeBridge, ctx); - okay = ((okay) && (ctx->filename_cache != NULL)); - - ctx->file_macro = get_define(ctx); - okay = ((okay) && (ctx->file_macro != NULL)); - if ((okay) && (ctx->file_macro)) - okay = ((ctx->file_macro->identifier = StrDup(ctx, "__FILE__")) != 0); - - ctx->line_macro = get_define(ctx); - okay = ((okay) && (ctx->line_macro != NULL)); - if ((okay) && (ctx->line_macro)) - okay = ((ctx->line_macro->identifier = StrDup(ctx, "__LINE__")) != 0); - - // let the usual preprocessor parser sort these out. - char *define_include = NULL; - unsigned int define_include_len = 0; - if ((okay) && (define_count > 0)) - { - Buffer *predefbuf = buffer_create(256, MallocBridge, FreeBridge, ctx); - okay = okay && (predefbuf != NULL); - for (i = 0; okay && (i < define_count); i++) - { - okay = okay && buffer_append_fmt(predefbuf, "#define %s %s\n", - defines[i].identifier, defines[i].definition); - } // for - - define_include_len = buffer_size(predefbuf); - if (define_include_len > 0) - { - define_include = buffer_flatten(predefbuf); - okay = okay && (define_include != NULL); - } // if - buffer_destroy(predefbuf); - } // if - - if ((okay) && (!push_source(ctx,fname,source,sourcelen,1,NULL))) - okay = 0; - - if ((okay) && (define_include_len > 0)) - { - assert(define_include != NULL); - okay = push_source(ctx, "<predefined macros>", define_include, - define_include_len, 1, close_define_include); - } // if - - if (!okay) - { - preprocessor_end((Preprocessor *) ctx); - return NULL; - } // if - - return (Preprocessor *) ctx; -} // preprocessor_start - - -void preprocessor_end(Preprocessor *_ctx) -{ - Context *ctx = (Context *) _ctx; - if (ctx == NULL) - return; - - while (ctx->include_stack != NULL) - pop_source(ctx); - - put_all_defines(ctx); - - if (ctx->filename_cache != NULL) - stringcache_destroy(ctx->filename_cache); - - free_define(ctx, ctx->file_macro); - free_define(ctx, ctx->line_macro); - free_define_pool(ctx); - free_conditional_pool(ctx); - free_include_pool(ctx); - - Free(ctx, ctx); -} // preprocessor_end - - -int preprocessor_outofmemory(Preprocessor *_ctx) -{ - Context *ctx = (Context *) _ctx; - return ctx->out_of_memory; -} // preprocessor_outofmemory - - -static inline void pushback(IncludeState *state) -{ - #if DEBUG_PREPROCESSOR - printf("PREPROCESSOR PUSHBACK\n"); - #endif - assert(!state->pushedback); - state->pushedback = 1; -} // pushback - - -static Token lexer(IncludeState *state) -{ - if (!state->pushedback) - return preprocessor_lexer(state); - state->pushedback = 0; - return state->tokenval; -} // lexer - - -// !!! FIXME: parsing fails on preprocessor directives should skip rest of line. -static int require_newline(IncludeState *state) -{ - const Token token = lexer(state); - pushback(state); // rewind no matter what. - return ( (token == TOKEN_INCOMPLETE_COMMENT) || // call it an eol. - (token == ((Token) '\n')) || (token == TOKEN_EOI) ); -} // require_newline - -// !!! FIXME: didn't we implement this by hand elsewhere? -static int token_to_int(IncludeState *state) -{ - assert(state->tokenval == TOKEN_INT_LITERAL); - char *buf = (char *) alloca(state->tokenlen+1); - memcpy(buf, state->token, state->tokenlen); - buf[state->tokenlen] = '\0'; - return atoi(buf); -} // token_to_int - - -static void handle_pp_include(Context *ctx) -{ - IncludeState *state = ctx->include_stack; - Token token = lexer(state); - MOJOSHADER_includeType incltype; - char *filename = NULL; - int bogus = 0; - - if (token == TOKEN_STRING_LITERAL) - incltype = MOJOSHADER_INCLUDETYPE_LOCAL; - else if (token == ((Token) '<')) - { - incltype = MOJOSHADER_INCLUDETYPE_SYSTEM; - // can't use lexer, since every byte between the < > pair is - // considered part of the filename. :/ - while (!bogus) - { - if ( !(bogus = (state->bytes_left == 0)) ) - { - const char ch = *state->source; - if ( !(bogus = ((ch == '\r') || (ch == '\n'))) ) - { - state->source++; - state->bytes_left--; - - if (ch == '>') - break; - } // if - } // if - } // while - } // else if - else - { - bogus = 1; - } // else - - if (!bogus) - { - state->token++; // skip '<' or '\"'... - const unsigned int len = ((unsigned int) (state->source-state->token)); - filename = (char *) alloca(len); - memcpy(filename, state->token, len-1); - filename[len-1] = '\0'; - bogus = !require_newline(state); - } // if - - if (bogus) - { - fail(ctx, "Invalid #include directive"); - return; - } // else - - const char *newdata = NULL; - unsigned int newbytes = 0; - if ((ctx->open_callback == NULL) || (ctx->close_callback == NULL)) - { - fail(ctx, "Saw #include, but no include callbacks defined"); - return; - } // if - - if (!ctx->open_callback(incltype, filename, state->source_base, - &newdata, &newbytes, ctx->malloc, - ctx->free, ctx->malloc_data)) - { - fail(ctx, "Include callback failed"); // !!! FIXME: better error - return; - } // if - - MOJOSHADER_includeClose callback = ctx->close_callback; - if (!push_source(ctx, filename, newdata, newbytes, 1, callback)) - { - assert(ctx->out_of_memory); - ctx->close_callback(newdata, ctx->malloc, ctx->free, ctx->malloc_data); - } // if -} // handle_pp_include - - -static void handle_pp_line(Context *ctx) -{ - IncludeState *state = ctx->include_stack; - char *filename = NULL; - int linenum = 0; - int bogus = 0; - - if (lexer(state) != TOKEN_INT_LITERAL) - bogus = 1; - else - linenum = token_to_int(state); - - if (!bogus) - { - Token t = lexer(state); - if (t == ((Token) '\n')) - { - state->line = linenum; - return; - } - bogus = (t != TOKEN_STRING_LITERAL); - } - - if (!bogus) - { - state->token++; // skip '\"'... - filename = (char *) alloca(state->tokenlen); - memcpy(filename, state->token, state->tokenlen-1); - filename[state->tokenlen-1] = '\0'; - bogus = !require_newline(state); - } // if - - if (bogus) - { - fail(ctx, "Invalid #line directive"); - return; - } // if - - const char *cached = stringcache(ctx->filename_cache, filename); - state->filename = cached; // may be NULL if stringcache() failed. - state->line = linenum; -} // handle_pp_line - - -static void handle_pp_error(Context *ctx) -{ - IncludeState *state = ctx->include_stack; - char *ptr = ctx->failstr; - int avail = sizeof (ctx->failstr) - 1; - int cpy = 0; - int done = 0; - - const char *prefix = "#error"; - const size_t prefixlen = strlen(prefix); - strcpy(ctx->failstr, prefix); - avail -= prefixlen; - ptr += prefixlen; - - state->report_whitespace = 1; - while (!done) - { - const Token token = lexer(state); - switch (token) - { - case ((Token) '\n'): - state->line--; // make sure error is on the right line. - // fall through! - case TOKEN_INCOMPLETE_COMMENT: - case TOKEN_EOI: - pushback(state); // move back so we catch this later. - done = 1; - break; - - case ((Token) ' '): - if (!avail) - break; - *(ptr++) = ' '; - avail--; - break; - - default: - cpy = Min(avail, (int) state->tokenlen); - if (cpy) - memcpy(ptr, state->token, cpy); - ptr += cpy; - avail -= cpy; - break; - } // switch - } // while - - *ptr = '\0'; - state->report_whitespace = 0; - ctx->isfail = 1; -} // handle_pp_error - - -static void handle_pp_define(Context *ctx) -{ - IncludeState *state = ctx->include_stack; - int done = 0; - - if (lexer(state) != TOKEN_IDENTIFIER) - { - fail(ctx, "Macro names must be identifiers"); - return; - } // if - - char *definition = NULL; - char *sym = (char *) Malloc(ctx, state->tokenlen+1); - if (sym == NULL) - return; - memcpy(sym, state->token, state->tokenlen); - sym[state->tokenlen] = '\0'; - - if (strcmp(sym, "defined") == 0) - { - Free(ctx, sym); - fail(ctx, "'defined' cannot be used as a macro name"); - return; - } // if - - // Don't treat these symbols as special anymore if they get (re)#defined. - if (strcmp(sym, "__FILE__") == 0) - { - if (ctx->file_macro) - { - failf(ctx, "'%s' already defined", sym); // !!! FIXME: warning? - free_define(ctx, ctx->file_macro); - ctx->file_macro = NULL; - } // if - } // if - else if (strcmp(sym, "__LINE__") == 0) - { - if (ctx->line_macro) - { - failf(ctx, "'%s' already defined", sym); // !!! FIXME: warning? - free_define(ctx, ctx->line_macro); - ctx->line_macro = NULL; - } // if - } // else if - - // #define a(b) is different than #define a (b) :( - state->report_whitespace = 1; - lexer(state); - state->report_whitespace = 0; - - int params = 0; - char **idents = NULL; - static const char space = ' '; - - if (state->tokenval == ((Token) ' ')) - lexer(state); // skip it. - else if (state->tokenval == ((Token) '(')) - { - IncludeState saved; - memcpy(&saved, state, sizeof (IncludeState)); - while (1) - { - if (lexer(state) != TOKEN_IDENTIFIER) - break; - params++; - if (lexer(state) != ((Token) ',')) - break; - } // while - - if (state->tokenval != ((Token) ')')) - { - fail(ctx, "syntax error in macro parameter list"); - goto handle_pp_define_failed; - } // if - - if (params == 0) // special case for void args: "#define a() b" - params = -1; - else - { - idents = (char **) Malloc(ctx, sizeof (char *) * params); - if (idents == NULL) - goto handle_pp_define_failed; - - // roll all the way back, do it again. - memcpy(state, &saved, sizeof (IncludeState)); - memset(idents, '\0', sizeof (char *) * params); - - int i; - for (i = 0; i < params; i++) - { - lexer(state); - assert(state->tokenval == TOKEN_IDENTIFIER); - - char *dst = (char *) Malloc(ctx, state->tokenlen+1); - if (dst == NULL) - break; - - memcpy(dst, state->token, state->tokenlen); - dst[state->tokenlen] = '\0'; - idents[i] = dst; - - if (i < (params-1)) - { - lexer(state); - assert(state->tokenval == ((Token) ',')); - } // if - } // for - - if (i != params) - { - assert(ctx->out_of_memory); - goto handle_pp_define_failed; - } // if - - lexer(state); - assert(state->tokenval == ((Token) ')')); - } // else - - lexer(state); - } // else if - - pushback(state); - - Buffer *buffer = buffer_create(128, MallocBridge, FreeBridge, ctx); - - state->report_whitespace = 1; - while ((!done) && (!ctx->out_of_memory)) - { - const Token token = lexer(state); - switch (token) - { - case TOKEN_INCOMPLETE_COMMENT: - case TOKEN_EOI: - pushback(state); // move back so we catch this later. - done = 1; - break; - - case ((Token) '\n'): - done = 1; - break; - - case ((Token) ' '): // may not actually point to ' '. - assert(buffer_size(buffer) > 0); - buffer_append(buffer, &space, 1); - break; - - default: - buffer_append(buffer, state->token, state->tokenlen); - break; - } // switch - } // while - state->report_whitespace = 0; - - size_t buflen = buffer_size(buffer) + 1; - if (!ctx->out_of_memory) - definition = buffer_flatten(buffer); - - buffer_destroy(buffer); - - if (ctx->out_of_memory) - goto handle_pp_define_failed; - - int hashhash_error = 0; - if ((buflen > 2) && (definition[0] == '#') && (definition[1] == '#')) - { - hashhash_error = 1; - buflen -= 2; - memmove(definition, definition + 2, buflen); - } // if - - if (buflen > 2) - { - char *ptr = (definition + buflen) - 2; - if (*ptr == ' ') - { - ptr--; - buflen--; - } // if - if ((buflen > 2) && (ptr[0] == '#') && (ptr[-1] == '#')) - { - hashhash_error = 1; - buflen -= 2; - ptr[-1] = '\0'; - } // if - } // if - - if (hashhash_error) - fail(ctx, "'##' cannot appear at either end of a macro expansion"); - - assert(done); - - if (!add_define(ctx, sym, definition, idents, params)) - goto handle_pp_define_failed; - - return; - -handle_pp_define_failed: - Free(ctx, sym); - Free(ctx, definition); - if (idents != NULL) - { - while (params--) - Free(ctx, idents[params]); - } // if - Free(ctx, idents); -} // handle_pp_define - - -static void handle_pp_undef(Context *ctx) -{ - IncludeState *state = ctx->include_stack; - - if (lexer(state) != TOKEN_IDENTIFIER) - { - fail(ctx, "Macro names must be indentifiers"); - return; - } // if - - char *sym = (char *) alloca(state->tokenlen+1); - memcpy(sym, state->token, state->tokenlen); - sym[state->tokenlen] = '\0'; - - if (!require_newline(state)) - { - fail(ctx, "Invalid #undef directive"); - return; - } // if - - if (strcmp(sym, "__FILE__") == 0) - { - if (ctx->file_macro) - { - failf(ctx, "undefining \"%s\"", sym); // !!! FIXME: should be warning. - free_define(ctx, ctx->file_macro); - ctx->file_macro = NULL; - } // if - } // if - else if (strcmp(sym, "__LINE__") == 0) - { - if (ctx->line_macro) - { - failf(ctx, "undefining \"%s\"", sym); // !!! FIXME: should be warning. - free_define(ctx, ctx->line_macro); - ctx->line_macro = NULL; - } // if - } // if - - remove_define(ctx, sym); -} // handle_pp_undef - - -static Conditional *_handle_pp_ifdef(Context *ctx, const Token type) -{ - IncludeState *state = ctx->include_stack; - - assert((type == TOKEN_PP_IFDEF) || (type == TOKEN_PP_IFNDEF)); - - if (lexer(state) != TOKEN_IDENTIFIER) - { - fail(ctx, "Macro names must be indentifiers"); - return NULL; - } // if - - char *sym = (char *) alloca(state->tokenlen+1); - memcpy(sym, state->token, state->tokenlen); - sym[state->tokenlen] = '\0'; - - if (!require_newline(state)) - { - if (type == TOKEN_PP_IFDEF) - fail(ctx, "Invalid #ifdef directive"); - else - fail(ctx, "Invalid #ifndef directive"); - return NULL; - } // if - - Conditional *conditional = get_conditional(ctx); - assert((conditional != NULL) || (ctx->out_of_memory)); - if (conditional == NULL) - return NULL; - - Conditional *parent = state->conditional_stack; - const int found = (find_define(ctx, sym) != NULL); - const int chosen = (type == TOKEN_PP_IFDEF) ? found : !found; - const int skipping = ( (((parent) && (parent->skipping))) || (!chosen) ); - - conditional->type = type; - conditional->linenum = state->line - 1; - conditional->skipping = skipping; - conditional->chosen = chosen; - conditional->next = parent; - state->conditional_stack = conditional; - return conditional; -} // _handle_pp_ifdef - - -static inline void handle_pp_ifdef(Context *ctx) -{ - _handle_pp_ifdef(ctx, TOKEN_PP_IFDEF); -} // handle_pp_ifdef - - -static inline void handle_pp_ifndef(Context *ctx) -{ - _handle_pp_ifdef(ctx, TOKEN_PP_IFNDEF); -} // handle_pp_ifndef - - -static int replace_and_push_macro(Context *ctx, const Define *def, - const Define *params) -{ - char *final = NULL; - - // We push the #define and lex it, building a buffer with argument - // replacement, stringification, and concatenation. - Buffer *buffer = buffer_create(128, MallocBridge, FreeBridge, ctx); - if (buffer == NULL) - return 0; - - IncludeState *state = ctx->include_stack; - if (!push_source(ctx, state->filename, def->definition, - strlen(def->definition), state->line, NULL)) - { - buffer_destroy(buffer); - return 0; - } // if - - state = ctx->include_stack; - while (lexer(state) != TOKEN_EOI) - { - int wantorig = 0; - const Define *arg = NULL; - - // put a space between tokens if we're not concatenating. - if (state->tokenval == TOKEN_HASHHASH) // concatenate? - { - wantorig = 1; - lexer(state); - assert(state->tokenval != TOKEN_EOI); - } // if - else - { - if (buffer_size(buffer) > 0) - { - if (!buffer_append(buffer, " ", 1)) - goto replace_and_push_macro_failed; - } // if - } // else - - const char *data = state->token; - unsigned int len = state->tokenlen; - - if (state->tokenval == TOKEN_HASH) // stringify? - { - lexer(state); - assert(state->tokenval != TOKEN_EOI); // we checked for this. - - if (!buffer_append(buffer, "\"", 1)) - goto replace_and_push_macro_failed; - - if (state->tokenval == TOKEN_IDENTIFIER) - { - arg = find_macro_arg(state, params); - if (arg != NULL) - { - data = arg->original; - len = strlen(data); - } // if - } // if - - if (!buffer_append(buffer, data, len)) - goto replace_and_push_macro_failed; - - if (!buffer_append(buffer, "\"", 1)) - goto replace_and_push_macro_failed; - - continue; - } // if - - if (state->tokenval == TOKEN_IDENTIFIER) - { - arg = find_macro_arg(state, params); - if (arg != NULL) - { - if (!wantorig) - { - wantorig = (lexer(state) == TOKEN_HASHHASH); - pushback(state); - } // if - data = wantorig ? arg->original : arg->definition; - len = strlen(data); - } // if - } // if - - if (!buffer_append(buffer, data, len)) - goto replace_and_push_macro_failed; - } // while - - final = buffer_flatten(buffer); - if (!final) - goto replace_and_push_macro_failed; - - buffer_destroy(buffer); - pop_source(ctx); // ditch the macro. - state = ctx->include_stack; - if (!push_source(ctx, state->filename, final, strlen(final), state->line, - close_define_include)) - { - Free(ctx, final); - return 0; - } // if - - return 1; - -replace_and_push_macro_failed: - pop_source(ctx); - buffer_destroy(buffer); - return 0; -} // replace_and_push_macro - - -static int handle_macro_args(Context *ctx, const char *sym, const Define *def) -{ - int retval = 0; - IncludeState *state = ctx->include_stack; - Define *params = NULL; - const int expected = (def->paramcount < 0) ? 0 : def->paramcount; - int saw_params = 0; - IncludeState saved; // can't pushback, we need the original token. - memcpy(&saved, state, sizeof (IncludeState)); - if (lexer(state) != ((Token) '(')) - { - memcpy(state, &saved, sizeof (IncludeState)); - goto handle_macro_args_failed; // gcc abandons replacement, too. - } // if - - state->report_whitespace = 1; - - int void_call = 0; - int paren = 1; - while (paren > 0) - { - Buffer *buffer = buffer_create(128, MallocBridge, FreeBridge, ctx); - Buffer *origbuffer = buffer_create(128, MallocBridge, FreeBridge, ctx); - - Token t = lexer(state); - - assert(!void_call); - - while (1) - { - const char *origexpr = state->token; - unsigned int origexprlen = state->tokenlen; - const char *expr = state->token; - unsigned int exprlen = state->tokenlen; - - if (t == ((Token) '(')) - paren++; - - else if (t == ((Token) ')')) - { - paren--; - if (paren < 1) // end of macro? - break; - } // else if - - else if (t == ((Token) ',')) - { - if (paren == 1) // new macro arg? - break; - } // else if - - else if (t == ((Token) ' ')) - { - // don't add whitespace to the start, so we recognize - // void calls correctly. - origexpr = expr = " "; - origexprlen = (buffer_size(origbuffer) == 0) ? 0 : 1; - exprlen = (buffer_size(buffer) == 0) ? 0 : 1; - } // else if - - else if (t == TOKEN_IDENTIFIER) - { - const Define *def = find_define_by_token(ctx); - // don't replace macros with arguments so they replace correctly, later. - if ((def) && (def->paramcount == 0)) - { - expr = def->definition; - exprlen = strlen(def->definition); - } // if - } // else if - - else if ((t == TOKEN_INCOMPLETE_COMMENT) || (t == TOKEN_EOI)) - { - pushback(state); - fail(ctx, "Unterminated macro list"); - goto handle_macro_args_failed; - } // else if - - assert(expr != NULL); - - if (!buffer_append(buffer, expr, exprlen)) - goto handle_macro_args_failed; - - if (!buffer_append(origbuffer, origexpr, origexprlen)) - goto handle_macro_args_failed; - - t = lexer(state); - } // while - - if (buffer_size(buffer) == 0) - void_call = ((saw_params == 0) && (paren == 0)); - - if (saw_params < expected) - { - const int origdeflen = (int) buffer_size(origbuffer); - char *origdefinition = buffer_flatten(origbuffer); - const int deflen = (int) buffer_size(buffer); - char *definition = buffer_flatten(buffer); - Define *p = get_define(ctx); - if ((!origdefinition) || (!definition) || (!p)) - { - Free(ctx, origdefinition); - Free(ctx, definition); - buffer_destroy(origbuffer); - buffer_destroy(buffer); - free_define(ctx, p); - goto handle_macro_args_failed; - } // if - - // trim any whitespace from the end of the string... - int i; - for (i = deflen - 1; i >= 0; i--) - { - if (definition[i] == ' ') - definition[i] = '\0'; - else - break; - } // for - - for (i = origdeflen - 1; i >= 0; i--) - { - if (origdefinition[i] == ' ') - origdefinition[i] = '\0'; - else - break; - } // for - - p->identifier = def->parameters[saw_params]; - p->definition = definition; - p->original = origdefinition; - p->next = params; - params = p; - } // if - - buffer_destroy(buffer); - buffer_destroy(origbuffer); - saw_params++; - } // while - - assert(paren == 0); - - // "a()" should match "#define a()" ... - if ((expected == 0) && (saw_params == 1) && (void_call)) - { - assert(params == NULL); - saw_params = 0; - } // if - - if (saw_params != expected) - { - failf(ctx, "macro '%s' passed %d arguments, but requires %d", - sym, saw_params, expected); - goto handle_macro_args_failed; - } // if - - // this handles arg replacement and the '##' and '#' operators. - retval = replace_and_push_macro(ctx, def, params); - -handle_macro_args_failed: - while (params) - { - Define *next = params->next; - params->identifier = NULL; - free_define(ctx, params); - params = next; - } // while - - state->report_whitespace = 0; - return retval; -} // handle_macro_args - - -static int handle_pp_identifier(Context *ctx) -{ - if (ctx->recursion_count++ >= 256) // !!! FIXME: gcc can figure this out. - { - fail(ctx, "Recursing macros"); - return 0; - } // if - - IncludeState *state = ctx->include_stack; - const char *fname = state->filename; - const unsigned int line = state->line; - char *sym = (char *) alloca(state->tokenlen+1); - memcpy(sym, state->token, state->tokenlen); - sym[state->tokenlen] = '\0'; - - // Is this identifier #defined? - const Define *def = find_define(ctx, sym); - if (def == NULL) - return 0; // just send the token through unchanged. - else if (def->paramcount != 0) - return handle_macro_args(ctx, sym, def); - - const size_t deflen = strlen(def->definition); - return push_source(ctx, fname, def->definition, deflen, line, NULL); -} // handle_pp_identifier - - -static int find_precedence(const Token token) -{ - // operator precedence, left and right associative... - typedef struct { int precedence; Token token; } Precedence; - static const Precedence ops[] = { - { 0, TOKEN_OROR }, { 1, TOKEN_ANDAND }, { 2, ((Token) '|') }, - { 3, ((Token) '^') }, { 4, ((Token) '&') }, { 5, TOKEN_NEQ }, - { 6, TOKEN_EQL }, { 7, ((Token) '<') }, { 7, ((Token) '>') }, - { 7, TOKEN_LEQ }, { 7, TOKEN_GEQ }, { 8, TOKEN_LSHIFT }, - { 8, TOKEN_RSHIFT }, { 9, ((Token) '-') }, { 9, ((Token) '+') }, - { 10, ((Token) '%') }, { 10, ((Token) '/') }, { 10, ((Token) '*') }, - { 11, TOKEN_PP_UNARY_PLUS }, { 11, TOKEN_PP_UNARY_MINUS }, - { 11, ((Token) '!') }, { 11, ((Token) '~') }, - }; - - size_t i; - for (i = 0; i < STATICARRAYLEN(ops); i++) - { - if (ops[i].token == token) - return ops[i].precedence; - } // for - - return -1; -} // find_precedence - -// !!! FIXME: we're using way too much stack space here... -typedef struct RpnTokens -{ - int isoperator; - int value; -} RpnTokens; - -static long interpret_rpn(const RpnTokens *tokens, int tokencount, int *error) -{ - long stack[128]; - size_t stacksize = 0; - - *error = 1; - - #define NEED_X_TOKENS(x) do { if (stacksize < x) return 0; } while (0) - - #define BINARY_OPERATION(op) do { \ - NEED_X_TOKENS(2); \ - stack[stacksize-2] = stack[stacksize-2] op stack[stacksize-1]; \ - stacksize--; \ - } while (0) - - #define UNARY_OPERATION(op) do { \ - NEED_X_TOKENS(1); \ - stack[stacksize-1] = op stack[stacksize-1]; \ - } while (0) - - while (tokencount-- > 0) - { - if (!tokens->isoperator) - { - assert(stacksize < STATICARRAYLEN(stack)); - stack[stacksize++] = (long) tokens->value; - tokens++; - continue; - } // if - - // operators. - switch (tokens->value) - { - case '!': UNARY_OPERATION(!); break; - case '~': UNARY_OPERATION(~); break; - case TOKEN_PP_UNARY_MINUS: UNARY_OPERATION(-); break; - case TOKEN_PP_UNARY_PLUS: UNARY_OPERATION(+); break; - case TOKEN_OROR: BINARY_OPERATION(||); break; - case TOKEN_ANDAND: BINARY_OPERATION(&&); break; - case '|': BINARY_OPERATION(|); break; - case '^': BINARY_OPERATION(^); break; - case '&': BINARY_OPERATION(&); break; - case TOKEN_NEQ: BINARY_OPERATION(!=); break; - case TOKEN_EQL: BINARY_OPERATION(==); break; - case '<': BINARY_OPERATION(<); break; - case '>': BINARY_OPERATION(>); break; - case TOKEN_LEQ: BINARY_OPERATION(<=); break; - case TOKEN_GEQ: BINARY_OPERATION(>=); break; - case TOKEN_LSHIFT: BINARY_OPERATION(<<); break; - case TOKEN_RSHIFT: BINARY_OPERATION(>>); break; - case '-': BINARY_OPERATION(-); break; - case '+': BINARY_OPERATION(+); break; - case '%': BINARY_OPERATION(%); break; - case '/': BINARY_OPERATION(/); break; - case '*': BINARY_OPERATION(*); break; - default: return 0; - } // switch - - tokens++; - } // while - - #undef NEED_X_TOKENS - #undef BINARY_OPERATION - #undef UNARY_OPERATION - - if (stacksize != 1) - return 0; - - *error = 0; - return stack[0]; -} // interpret_rpn - -// http://en.wikipedia.org/wiki/Shunting_yard_algorithm -// Convert from infix to postfix, then use this for constant folding. -// Everything that parses should fold down to a constant value: any -// identifiers that aren't resolved as macros become zero. Anything we -// don't explicitly expect becomes a parsing error. -// returns 1 (true), 0 (false), or -1 (error) -static int reduce_pp_expression(Context *ctx) -{ - IncludeState *orig_state = ctx->include_stack; - RpnTokens output[128]; - Token stack[64]; - Token previous_token = TOKEN_UNKNOWN; - size_t outputsize = 0; - size_t stacksize = 0; - int matched = 0; - int done = 0; - - #define ADD_TO_OUTPUT(op, val) \ - assert(outputsize < STATICARRAYLEN(output)); \ - output[outputsize].isoperator = op; \ - output[outputsize].value = val; \ - outputsize++; - - #define PUSH_TO_STACK(t) \ - assert(stacksize < STATICARRAYLEN(stack)); \ - stack[stacksize] = t; \ - stacksize++; - - while (!done) - { - IncludeState *state = ctx->include_stack; - Token token = lexer(state); - int isleft = 1; - int precedence = -1; - - if ( (token == ((Token) '!')) || (token == ((Token) '~')) ) - isleft = 0; - else if (token == ((Token) '-')) - { - if ((isleft = (previous_token == TOKEN_INT_LITERAL)) == 0) - token = TOKEN_PP_UNARY_MINUS; - } // else if - else if (token == ((Token) '+')) - { - if ((isleft = (previous_token == TOKEN_INT_LITERAL)) == 0) - token = TOKEN_PP_UNARY_PLUS; - } // else if - - if (token != TOKEN_IDENTIFIER) - ctx->recursion_count = 0; - - switch (token) - { - case TOKEN_EOI: - if (state != orig_state) // end of a substate, or the expr? - { - pop_source(ctx); - continue; // substate, go again with the parent state. - } // if - done = 1; // the expression itself is done. - break; - - case ((Token) '\n'): - done = 1; - break; // we're done! - - case TOKEN_IDENTIFIER: - if (handle_pp_identifier(ctx)) - continue; // go again with new IncludeState. - - if ( (state->tokenlen == 7) && - (memcmp(state->token, "defined", 7) == 0) ) - { - token = lexer(state); - const int paren = (token == ((Token) '(')); - if (paren) // gcc doesn't let us nest parens here, either. - token = lexer(state); - if (token != TOKEN_IDENTIFIER) - { - fail(ctx, "operator 'defined' requires an identifier"); - return -1; - } // if - const int found = (find_define_by_token(ctx) != NULL); - - if (paren) - { - if (lexer(state) != ((Token) ')')) - { - fail(ctx, "Unmatched ')'"); - return -1; - } // if - } // if - - ADD_TO_OUTPUT(0, found); - continue; - } // if - - // can't replace identifier with a number? It becomes zero. - token = TOKEN_INT_LITERAL; - ADD_TO_OUTPUT(0, 0); - break; - - case TOKEN_INT_LITERAL: - ADD_TO_OUTPUT(0, token_to_int(state)); - break; - - case ((Token) '('): - PUSH_TO_STACK((Token) '('); - break; - - case ((Token) ')'): - matched = 0; - while (stacksize > 0) - { - const Token t = stack[--stacksize]; - if (t == ((Token) '(')) - { - matched = 1; - break; - } // if - ADD_TO_OUTPUT(1, t); - } // while - - if (!matched) - { - fail(ctx, "Unmatched ')'"); - return -1; - } // if - break; - - default: - precedence = find_precedence(token); - // bogus token, or two operators together. - if (precedence < 0) - { - pushback(state); - fail(ctx, "Invalid expression"); - return -1; - } // if - - else // it's an operator. - { - while (stacksize > 0) - { - const Token t = stack[stacksize-1]; - const int p = find_precedence(t); - if ( (p >= 0) && - ( ((isleft) && (precedence <= p)) || - ((!isleft) && (precedence < p)) ) ) - { - stacksize--; - ADD_TO_OUTPUT(1, t); - } // if - else - { - break; - } // else - } // while - PUSH_TO_STACK(token); - } // else - break; - } // switch - previous_token = token; - } // while - - while (stacksize > 0) - { - const Token t = stack[--stacksize]; - if (t == ((Token) '(')) - { - fail(ctx, "Unmatched ')'"); - return -1; - } // if - ADD_TO_OUTPUT(1, t); - } // while - - #undef ADD_TO_OUTPUT - #undef PUSH_TO_STACK - - // okay, you now have some validated data in reverse polish notation. - #if DEBUG_PREPROCESSOR - printf("PREPROCESSOR EXPRESSION RPN:"); - int i = 0; - for (i = 0; i < outputsize; i++) - { - if (!output[i].isoperator) - printf(" %d", output[i].value); - else - { - switch (output[i].value) - { - case TOKEN_OROR: printf(" ||"); break; - case TOKEN_ANDAND: printf(" &&"); break; - case TOKEN_NEQ: printf(" !="); break; - case TOKEN_EQL: printf(" =="); break; - case TOKEN_LEQ: printf(" <="); break; - case TOKEN_GEQ: printf(" >="); break; - case TOKEN_LSHIFT: printf(" <<"); break; - case TOKEN_RSHIFT: printf(" >>"); break; - case TOKEN_PP_UNARY_PLUS: printf(" +"); break; - case TOKEN_PP_UNARY_MINUS: printf(" -"); break; - default: printf(" %c", output[i].value); break; - } // switch - } // else - } // for - printf("\n"); - #endif - - int error = 0; - const long val = interpret_rpn(output, outputsize, &error); - - #if DEBUG_PREPROCESSOR - printf("PREPROCESSOR RPN RESULT: %ld%s\n", val, error ? " (ERROR)" : ""); - #endif - - if (error) - { - fail(ctx, "Invalid expression"); - return -1; - } // if - - return ((val) ? 1 : 0); -} // reduce_pp_expression - - -static Conditional *handle_pp_if(Context *ctx) -{ - IncludeState *state = ctx->include_stack; - const int result = reduce_pp_expression(ctx); - if (result == -1) - return NULL; - - Conditional *conditional = get_conditional(ctx); - assert((conditional != NULL) || (ctx->out_of_memory)); - if (conditional == NULL) - return NULL; - - Conditional *parent = state->conditional_stack; - const int chosen = result; - const int skipping = ( (((parent) && (parent->skipping))) || (!chosen) ); - - conditional->type = TOKEN_PP_IF; - conditional->linenum = state->line - 1; - conditional->skipping = skipping; - conditional->chosen = chosen; - conditional->next = parent; - state->conditional_stack = conditional; - return conditional; -} // handle_pp_if - - -static void handle_pp_elif(Context *ctx) -{ - const int rc = reduce_pp_expression(ctx); - if (rc == -1) - return; - - IncludeState *state = ctx->include_stack; - Conditional *cond = state->conditional_stack; - if (cond == NULL) - fail(ctx, "#elif without #if"); - else if (cond->type == TOKEN_PP_ELSE) - fail(ctx, "#elif after #else"); - else - { - const Conditional *parent = cond->next; - cond->type = TOKEN_PP_ELIF; - cond->skipping = (parent && parent->skipping) || cond->chosen || !rc; - if (!cond->chosen) - cond->chosen = rc; - } // else -} // handle_pp_elif - - -static void handle_pp_else(Context *ctx) -{ - IncludeState *state = ctx->include_stack; - Conditional *cond = state->conditional_stack; - - if (!require_newline(state)) - fail(ctx, "Invalid #else directive"); - else if (cond == NULL) - fail(ctx, "#else without #if"); - else if (cond->type == TOKEN_PP_ELSE) - fail(ctx, "#else after #else"); - else - { - const Conditional *parent = cond->next; - cond->type = TOKEN_PP_ELSE; - cond->skipping = (parent && parent->skipping) || cond->chosen; - if (!cond->chosen) - cond->chosen = 1; - } // else -} // handle_pp_else - - -static void handle_pp_endif(Context *ctx) -{ - IncludeState *state = ctx->include_stack; - Conditional *cond = state->conditional_stack; - - if (!require_newline(state)) - fail(ctx, "Invalid #endif directive"); - else if (cond == NULL) - fail(ctx, "Unmatched #endif"); - else - { - state->conditional_stack = cond->next; // pop it. - put_conditional(ctx, cond); - } // else -} // handle_pp_endif - - -static void unterminated_pp_condition(Context *ctx) -{ - IncludeState *state = ctx->include_stack; - Conditional *cond = state->conditional_stack; - - // !!! FIXME: report the line number where the #if is, not the EOI. - switch (cond->type) - { - case TOKEN_PP_IF: fail(ctx, "Unterminated #if"); break; - case TOKEN_PP_IFDEF: fail(ctx, "Unterminated #ifdef"); break; - case TOKEN_PP_IFNDEF: fail(ctx, "Unterminated #ifndef"); break; - case TOKEN_PP_ELSE: fail(ctx, "Unterminated #else"); break; - case TOKEN_PP_ELIF: fail(ctx, "Unterminated #elif"); break; - default: assert(0 && "Shouldn't hit this case"); break; - } // switch - - // pop this conditional, we'll report the next error next time... - - state->conditional_stack = cond->next; // pop it. - put_conditional(ctx, cond); -} // unterminated_pp_condition - - -static inline const char *_preprocessor_nexttoken(Preprocessor *_ctx, - unsigned int *_len, Token *_token) -{ - Context *ctx = (Context *) _ctx; - - while (1) - { - if (ctx->isfail) - { - ctx->isfail = 0; - *_token = TOKEN_PREPROCESSING_ERROR; - *_len = strlen(ctx->failstr); - return ctx->failstr; - } // if - - IncludeState *state = ctx->include_stack; - if (state == NULL) - { - *_token = TOKEN_EOI; - *_len = 0; - return NULL; // we're done! - } // if - - const Conditional *cond = state->conditional_stack; - const int skipping = ((cond != NULL) && (cond->skipping)); - - const Token token = lexer(state); - - if (token != TOKEN_IDENTIFIER) - ctx->recursion_count = 0; - - if (token == TOKEN_EOI) - { - assert(state->bytes_left == 0); - if (state->conditional_stack != NULL) - { - unterminated_pp_condition(ctx); - continue; // returns an error. - } // if - - pop_source(ctx); - continue; // pick up again after parent's #include line. - } // if - - else if (token == TOKEN_INCOMPLETE_COMMENT) - { - fail(ctx, "Incomplete multiline comment"); - continue; // will return at top of loop. - } // else if - - else if (token == TOKEN_PP_IFDEF) - { - handle_pp_ifdef(ctx); - continue; // get the next thing. - } // else if - - else if (token == TOKEN_PP_IFNDEF) - { - handle_pp_ifndef(ctx); - continue; // get the next thing. - } // else if - - else if (token == TOKEN_PP_IF) - { - handle_pp_if(ctx); - continue; // get the next thing. - } // else if - - else if (token == TOKEN_PP_ELIF) - { - handle_pp_elif(ctx); - continue; // get the next thing. - } // else if - - else if (token == TOKEN_PP_ENDIF) - { - handle_pp_endif(ctx); - continue; // get the next thing. - } // else if - - else if (token == TOKEN_PP_ELSE) - { - handle_pp_else(ctx); - continue; // get the next thing. - } // else if - - // NOTE: Conditionals must be above (skipping) test. - else if (skipping) - continue; // just keep dumping tokens until we get end of block. - - else if (token == TOKEN_PP_INCLUDE) - { - handle_pp_include(ctx); - continue; // will return error or use new top of include_stack. - } // else if - - else if (token == TOKEN_PP_LINE) - { - handle_pp_line(ctx); - continue; // get the next thing. - } // else if - - else if (token == TOKEN_PP_ERROR) - { - handle_pp_error(ctx); - continue; // will return at top of loop. - } // else if - - else if (token == TOKEN_PP_DEFINE) - { - handle_pp_define(ctx); - continue; // will return at top of loop. - } // else if - - else if (token == TOKEN_PP_UNDEF) - { - handle_pp_undef(ctx); - continue; // will return at top of loop. - } // else if - - else if (token == TOKEN_PP_PRAGMA) - { - ctx->parsing_pragma = 1; - } // else if - - if (token == TOKEN_IDENTIFIER) - { - if (handle_pp_identifier(ctx)) - continue; // pushed the include_stack. - } // else if - - else if (token == ((Token) '\n')) - { - print_debug_lexing_position(state); - if (ctx->parsing_pragma) // let this one through. - ctx->parsing_pragma = 0; - else - { - // preprocessor is line-oriented, nothing else gets newlines. - continue; // get the next thing. - } // else - } // else if - - assert(!skipping); - *_token = token; - *_len = state->tokenlen; - return state->token; - } // while - - assert(0 && "shouldn't hit this code"); - *_token = TOKEN_UNKNOWN; - *_len = 0; - return NULL; -} // _preprocessor_nexttoken - - -const char *preprocessor_nexttoken(Preprocessor *ctx, unsigned int *len, - Token *token) -{ - const char *retval = _preprocessor_nexttoken(ctx, len, token); - print_debug_token(retval, *len, *token); - return retval; -} // preprocessor_nexttoken - - -const char *preprocessor_sourcepos(Preprocessor *_ctx, unsigned int *pos) -{ - Context *ctx = (Context *) _ctx; - if (ctx->include_stack == NULL) - { - *pos = 0; - return NULL; - } // if - - *pos = ctx->include_stack->line; - return ctx->include_stack->filename; -} // preprocessor_sourcepos - - -static void indent_buffer(Buffer *buffer, int n, const int newline) -{ - static char spaces[4] = { ' ', ' ', ' ', ' ' }; - if (newline) - { - while (n--) - { - if (!buffer_append(buffer, spaces, sizeof (spaces))) - return; - } // while - } // if - else - { - if (!buffer_append(buffer, spaces, 1)) - return; - } // else -} // indent_buffer - - -static const MOJOSHADER_preprocessData out_of_mem_data_preprocessor = { - 1, &MOJOSHADER_out_of_mem_error, 0, 0, 0, 0, 0 -}; - - -// public API... - -const MOJOSHADER_preprocessData *MOJOSHADER_preprocess(const char *filename, - const char *source, unsigned int sourcelen, - const MOJOSHADER_preprocessorDefine *defines, - unsigned int define_count, - MOJOSHADER_includeOpen include_open, - MOJOSHADER_includeClose include_close, - MOJOSHADER_malloc m, MOJOSHADER_free f, void *d) -{ - MOJOSHADER_preprocessData *retval = NULL; - Preprocessor *pp = NULL; - ErrorList *errors = NULL; - Buffer *buffer = NULL; - Token token = TOKEN_UNKNOWN; - const char *tokstr = NULL; - int nl = 1; - int indent = 0; - unsigned int len = 0; - char *output = NULL; - int errcount = 0; - size_t total_bytes = 0; - - // !!! FIXME: what's wrong with ENDLINE_STR? - #ifdef _WINDOWS - static const char endline[] = { '\r', '\n' }; - #else - static const char endline[] = { '\n' }; - #endif - - if (!m) m = MOJOSHADER_internal_malloc; - if (!f) f = MOJOSHADER_internal_free; - if (!include_open) include_open = MOJOSHADER_internal_include_open; - if (!include_close) include_close = MOJOSHADER_internal_include_close; - - pp = preprocessor_start(filename, source, sourcelen, - include_open, include_close, - defines, define_count, 0, m, f, d); - if (pp == NULL) - goto preprocess_out_of_mem; - - errors = errorlist_create(MallocBridge, FreeBridge, pp); - if (errors == NULL) - goto preprocess_out_of_mem; - - buffer = buffer_create(4096, MallocBridge, FreeBridge, pp); - if (buffer == NULL) - goto preprocess_out_of_mem; - - while ((tokstr = preprocessor_nexttoken(pp, &len, &token)) != NULL) - { - int isnewline = 0; - - assert(token != TOKEN_EOI); - - if (preprocessor_outofmemory(pp)) - goto preprocess_out_of_mem; - - // Microsoft's preprocessor is weird. - // It ignores newlines, and then inserts its own around certain - // tokens. For example, after a semicolon. This allows HLSL code to - // be mostly readable, instead of a stream of tokens. - if ( (token == ((Token) '}')) || (token == ((Token) ';')) ) - { - if ( (token == ((Token) '}')) && (indent > 0) ) - indent--; - - indent_buffer(buffer, indent, nl); - buffer_append(buffer, tokstr, len); - buffer_append(buffer, endline, sizeof (endline)); - - isnewline = 1; - } // if - - else if (token == ((Token) '\n')) - { - buffer_append(buffer, endline, sizeof (endline)); - isnewline = 1; - } // else if - - else if (token == ((Token) '{')) - { - buffer_append(buffer, endline, sizeof (endline)); - indent_buffer(buffer, indent, 1); - buffer_append(buffer, "{", 1); - buffer_append(buffer, endline, sizeof (endline)); - indent++; - isnewline = 1; - } // else if - - else if (token == TOKEN_PREPROCESSING_ERROR) - { - unsigned int pos = 0; - const char *fname = preprocessor_sourcepos(pp, &pos); - errorlist_add(errors, fname, (int) pos, tokstr); - } // else if - - else - { - indent_buffer(buffer, indent, nl); - buffer_append(buffer, tokstr, len); - } // else - - nl = isnewline; - } // while - - assert(token == TOKEN_EOI); - - total_bytes = buffer_size(buffer); - output = buffer_flatten(buffer); - buffer_destroy(buffer); - buffer = NULL; // don't free this pointer again. - - if (output == NULL) - goto preprocess_out_of_mem; - - retval = (MOJOSHADER_preprocessData *) m(sizeof (*retval), d); - if (retval == NULL) - goto preprocess_out_of_mem; - - memset(retval, '\0', sizeof (*retval)); - errcount = errorlist_count(errors); - if (errcount > 0) - { - retval->error_count = errcount; - retval->errors = errorlist_flatten(errors); - if (retval->errors == NULL) - goto preprocess_out_of_mem; - } // if - - retval->output = output; - retval->output_len = total_bytes; - retval->malloc = m; - retval->free = f; - retval->malloc_data = d; - - errorlist_destroy(errors); - preprocessor_end(pp); - return retval; - -preprocess_out_of_mem: - if (retval != NULL) - f(retval->errors, d); - f(retval, d); - f(output, d); - buffer_destroy(buffer); - errorlist_destroy(errors); - preprocessor_end(pp); - return &out_of_mem_data_preprocessor; -} // MOJOSHADER_preprocess - - -void MOJOSHADER_freePreprocessData(const MOJOSHADER_preprocessData *_data) -{ - MOJOSHADER_preprocessData *data = (MOJOSHADER_preprocessData *) _data; - if ((data == NULL) || (data == &out_of_mem_data_preprocessor)) - return; - - MOJOSHADER_free f = (data->free == NULL) ? MOJOSHADER_internal_free : data->free; - void *d = data->malloc_data; - int i; - - f((void *) data->output, d); - - for (i = 0; i < data->error_count; i++) - { - f((void *) data->errors[i].error, d); - f((void *) data->errors[i].filename, d); - } // for - f(data->errors, d); - - f(data, d); -} // MOJOSHADER_freePreprocessData - - -// end of mojoshader_preprocessor.c ... - diff --git a/Externals/mojoshader/1067/mojoshader_version.h b/Externals/mojoshader/1067/mojoshader_version.h deleted file mode 100644 index 6122d930..00000000 --- a/Externals/mojoshader/1067/mojoshader_version.h +++ /dev/null @@ -1,11 +0,0 @@ -/* This file was autogenerated. Do not edit! */ - -#ifndef _INCL_MOJOSHADER_VERSION_H_ - -#define _INCL_MOJOSHADER_VERSION_H_ - -#define MOJOSHADER_VERSION 1056 - -#define MOJOSHADER_CHANGESET "hg-1056:73c697a7e950" - -#endif diff --git a/Externals/pvrt/1/pvrt.h b/Externals/pvrt/1/pvrt.h deleted file mode 100644 index 424bf307..00000000 --- a/Externals/pvrt/1/pvrt.h +++ /dev/null @@ -1,86 +0,0 @@ - - -#ifndef __PVRT_H__ -#define __PVRT_H__ - -#include <OpenGLES/ES1/gl.h> -#include <OpenGLES/ES1/glext.h> -#include <assert.h> - -#include <CoreFoundation/CFByteOrder.h> - -#define PVR_TEXTURE_FLAG_TYPE_MASK 0xff - -static const char* gPVRTexIdentifier = "PVR!"; - -enum -{ - kPVRTextureFlagTypePVRTC_2 = 24, - kPVRTextureFlagTypePVRTC_4 -}; - -struct PVRTexHeader -{ - uint32_t headerLength; - uint32_t height; - uint32_t width; - uint32_t numMipmaps; - uint32_t flags; - uint32_t dataLength; - uint32_t bpp; - uint32_t bitmaskRed; - uint32_t bitmaskGreen; - uint32_t bitmaskBlue; - uint32_t bitmaskAlpha; - uint32_t pvrTag; - uint32_t numSurfs; -}; - -struct PVRTextureInfo -{ - PVRTextureInfo(const char* buffer) : - data(NULL), - width(0), - height(0), - glFormat(GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG), - hasAlpha(false) - { - const PVRTexHeader* header = reinterpret_cast<const PVRTexHeader*>(buffer); - uint32_t pvrTag = CFSwapInt32LittleToHost(header->pvrTag); - - if (gPVRTexIdentifier[0] != ((pvrTag >> 0) & 0xff) || - gPVRTexIdentifier[1] != ((pvrTag >> 8) & 0xff) || - gPVRTexIdentifier[2] != ((pvrTag >> 16) & 0xff) || - gPVRTexIdentifier[3] != ((pvrTag >> 24) & 0xff)) - { - return; - } - - uint32_t flags = CFSwapInt32LittleToHost(header->flags); - uint32_t formatFlags = flags & PVR_TEXTURE_FLAG_TYPE_MASK; - - if (formatFlags == kPVRTextureFlagTypePVRTC_4 || formatFlags == kPVRTextureFlagTypePVRTC_2) - { - if (formatFlags == kPVRTextureFlagTypePVRTC_4) - glFormat = GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG; - else if (formatFlags == kPVRTextureFlagTypePVRTC_2) - glFormat = GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG; - - width = CFSwapInt32LittleToHost(header->width); - height = CFSwapInt32LittleToHost(header->height); - - hasAlpha = CFSwapInt32LittleToHost(header->bitmaskAlpha) == true; - mipCount = CFSwapInt32LittleToHost(header->numMipmaps); - data = buffer + sizeof(PVRTexHeader); - } - } - - const char* data; - uint32_t width; - uint32_t height; - uint32_t mipCount; - GLenum glFormat; - bool hasAlpha; -}; - -#endif |