/* * Mesa 3-D graphics library * Version: 6.2 * * Copyright (C) 1999-2004 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /** * \file arbprogram.syn * ARB_fragment/vertex_program syntax * \author Michal Krol */ .syntax program; /* This value must be incremented every time emit code values or structure of the production array changes. This value is placed at the beginning of the production array. The loader compares the value with its REVISION value. If they do not match, the loader is not up to date. */ .emtcode REVISION 0x0a /* program type */ .emtcode FRAGMENT_PROGRAM 0x01 .emtcode VERTEX_PROGRAM 0x02 /* program section */ .emtcode OPTION 0x01 .emtcode INSTRUCTION 0x02 .emtcode DECLARATION 0x03 .emtcode END 0x04 /* GL_ARB_fragment_program option */ .emtcode ARB_PRECISION_HINT_FASTEST 0x00 .emtcode ARB_PRECISION_HINT_NICEST 0x01 .emtcode ARB_FOG_EXP 0x02 .emtcode ARB_FOG_EXP2 0x03 .emtcode ARB_FOG_LINEAR 0x04 /* GL_ARB_vertex_program option */ .emtcode ARB_POSITION_INVARIANT 0x05 /* GL_ARB_fragment_program_shadow option */ .emtcode ARB_FRAGMENT_PROGRAM_SHADOW 0x06 /* GL_ARB_draw_buffers option */ .emtcode ARB_DRAW_BUFFERS 0x07 /* GL_MESA_texture_array option */ .emtcode MESA_TEXTURE_ARRAY 0x08 /* GL_ARB_fragment_program instruction class */ .emtcode OP_ALU_INST 0x00 .emtcode OP_TEX_INST 0x01 /* GL_ARB_vertex_program instruction class */ /* OP_ALU_INST */ /* GL_ARB_fragment_program instruction type */ .emtcode OP_ALU_VECTOR 0x00 .emtcode OP_ALU_SCALAR 0x01 .emtcode OP_ALU_BINSC 0x02 .emtcode OP_ALU_BIN 0x03 .emtcode OP_ALU_TRI 0x04 .emtcode OP_ALU_SWZ 0x05 .emtcode OP_TEX_SAMPLE 0x06 .emtcode OP_TEX_KIL 0x07 /* GL_ARB_vertex_program instruction type */ .emtcode OP_ALU_ARL 0x08 /* OP_ALU_VECTOR */ /* OP_ALU_SCALAR */ /* OP_ALU_BINSC */ /* OP_ALU_BIN */ /* OP_ALU_TRI */ /* OP_ALU_SWZ */ /* GL_ARB_fragment_program instruction code */ .emtcode OP_ABS 0x00 .emtcode OP_ABS_SAT 0x1B .emtcode OP_FLR 0x09 .emtcode OP_FLR_SAT 0x26 .emtcode OP_FRC 0x0A .emtcode OP_FRC_SAT 0x27 .emtcode OP_LIT 0x0C .emtcode OP_LIT_SAT 0x2A .emtcode OP_MOV 0x11 .emtcode OP_MOV_SAT 0x30 .emtcode OP_COS 0x1F .emtcode OP_COS_SAT 0x20 .emtcode OP_EX2 0x07 .emtcode OP_EX2_SAT 0x25 .emtcode OP_LG2 0x0B .emtcode OP_LG2_SAT 0x29 .emtcode OP_RCP 0x14 .emtcode OP_RCP_SAT 0x33 .emtcode OP_RSQ 0x15 .emtcode OP_RSQ_SAT 0x34 .emtcode OP_SIN 0x38 .emtcode OP_SIN_SAT 0x39 .emtcode OP_SCS 0x35 .emtcode OP_SCS_SAT 0x36 .emtcode OP_POW 0x13 .emtcode OP_POW_SAT 0x32 .emtcode OP_ADD 0x01 .emtcode OP_ADD_SAT 0x1C .emtcode OP_DP3 0x03 .emtcode OP_DP3_SAT 0x21 .emtcode OP_DP4 0x04 .emtcode OP_DP4_SAT 0x22 .emtcode OP_DPH 0x05 .emtcode OP_DPH_SAT 0x23 .emtcode OP_DST 0x06 .emtcode OP_DST_SAT 0x24 .emtcode OP_MAX 0x0F .emtcode OP_MAX_SAT 0x2E .emtcode OP_MIN 0x10 .emtcode OP_MIN_SAT 0x2F .emtcode OP_MUL 0x12 .emtcode OP_MUL_SAT 0x31 .emtcode OP_SGE 0x16 .emtcode OP_SGE_SAT 0x37 .emtcode OP_SLT 0x17 .emtcode OP_SLT_SAT 0x3A .emtcode OP_SUB 0x18 .emtcode OP_SUB_SAT 0x3B .emtcode OP_XPD 0x1A .emtcode OP_XPD_SAT 0x43 .emtcode OP_CMP 0x1D .emtcode OP_CMP_SAT 0x1E .emtcode OP_LRP 0x2B .emtcode OP_LRP_SAT 0x2C .emtcode OP_MAD 0x0E .emtcode OP_MAD_SAT 0x2D .emtcode OP_SWZ 0x19 .emtcode OP_SWZ_SAT 0x3C .emtcode OP_TEX 0x3D .emtcode OP_TEX_SAT 0x3E .emtcode OP_TXB 0x3F .emtcode OP_TXB_SAT 0x40 .emtcode OP_TXP 0x41 .emtcode OP_TXP_SAT 0x42 .emtcode OP_KIL 0x28 /* GL_ARB_vertex_program instruction code */ .emtcode OP_ARL 0x02 /* OP_ABS */ /* OP_FLR */ /* OP_FRC */ /* OP_LIT */ /* OP_MOV */ /* OP_EX2 */ .emtcode OP_EXP 0x08 /* OP_LG2 */ .emtcode OP_LOG 0x0D /* OP_RCP */ /* OP_RSQ */ /* OP_POW */ /* OP_ADD */ /* OP_DP3 */ /* OP_DP4 */ /* OP_DPH */ /* OP_DST */ /* OP_MAX */ /* OP_MIN */ /* OP_MUL */ /* OP_SGE */ /* OP_SLT */ /* OP_SUB */ /* OP_XPD */ /* OP_MAD */ /* OP_SWZ */ /* fragment attribute binding */ .emtcode FRAGMENT_ATTRIB_COLOR 0x01 .emtcode FRAGMENT_ATTRIB_TEXCOORD 0x02 .emtcode FRAGMENT_ATTRIB_FOGCOORD 0x03 .emtcode FRAGMENT_ATTRIB_POSITION 0x04 /* vertex attribute binding */ .emtcode VERTEX_ATTRIB_POSITION 0x01 .emtcode VERTEX_ATTRIB_WEIGHT 0x02 .emtcode VERTEX_ATTRIB_NORMAL 0x03 .emtcode VERTEX_ATTRIB_COLOR 0x04 .emtcode VERTEX_ATTRIB_FOGCOORD 0x05 .emtcode VERTEX_ATTRIB_TEXCOORD 0x06 .emtcode VERTEX_ATTRIB_MATRIXINDEX 0x07 .emtcode VERTEX_ATTRIB_GENERIC 0x08 /* fragment result binding */ .emtcode FRAGMENT_RESULT_COLOR 0x01 .emtcode FRAGMENT_RESULT_DEPTH 0x02 /* vertex result binding */ .emtcode VERTEX_RESULT_POSITION 0x01 .emtcode VERTEX_RESULT_COLOR 0x02 .emtcode VERTEX_RESULT_FOGCOORD 0x03 .emtcode VERTEX_RESULT_POINTSIZE 0x04 .emtcode VERTEX_RESULT_TEXCOORD 0x05 /* texture target */ .emtcode TEXTARGET_1D 0x01 .emtcode TEXTARGET_2D 0x02 .emtcode TEXTARGET_3D 0x03 .emtcode TEXTARGET_RECT 0x04 .emtcode TEXTARGET_CUBE 0x05 /* GL_ARB_fragment_program_shadow */ .emtcode TEXTARGET_SHADOW1D 0x06 .emtcode TEXTARGET_SHADOW2D 0x07 .emtcode TEXTARGET_SHADOWRECT 0x08 /* GL_MESA_texture_array */ .emtcode TEXTARGET_1D_ARRAY 0x09 .emtcode TEXTARGET_2D_ARRAY 0x0a .emtcode TEXTARGET_SHADOW1D_ARRAY 0x0b .emtcode TEXTARGET_SHADOW2D_ARRAY 0x0c /* face type */ .emtcode FACE_FRONT 0x00 .emtcode FACE_BACK 0x01 /* color type */ .emtcode COLOR_PRIMARY 0x00 .emtcode COLOR_SECONDARY 0x01 /* component */ .emtcode COMPONENT_X 0x00 .emtcode COMPONENT_Y 0x01 .emtcode COMPONENT_Z 0x02 .emtcode COMPONENT_W 0x03 .emtcode COMPONENT_0 0x04 .emtcode COMPONENT_1 0x05 /* array index type */ .emtcode ARRAY_INDEX_ABSOLUTE 0x00 .emtcode ARRAY_INDEX_RELATIVE 0x01 /* matrix name */ .emtcode MATRIX_MODELVIEW 0x01 .emtcode MATRIX_PROJECTION 0x02 .emtcode MATRIX_MVP 0x03 .emtcode MATRIX_TEXTURE 0x04 .emtcode MATRIX_PALETTE 0x05 .emtcode MATRIX_PROGRAM 0x06 /* matrix modifier */ .emtcode MATRIX_MODIFIER_IDENTITY 0x00 .emtcode MATRIX_MODIFIER_INVERSE 0x01 .emtcode MATRIX_MODIFIER_TRANSPOSE 0x02 .emtcode MATRIX_MODIFIER_INVTRANS 0x03 /* constant type */ .emtcode CONSTANT_SCALAR 0x01 .emtcode CONSTANT_VECTOR 0x02 /* program param type */ .emtcode PROGRAM_PARAM_ENV 0x01 .emtcode PROGRAM_PARAM_LOCAL 0x02 /* register type */ .emtcode REGISTER_ATTRIB 0x01 .emtcode REGISTER_PARAM 0x02 .emtcode REGISTER_RESULT 0x03 .emtcode REGISTER_ESTABLISHED_NAME 0x04 /* param binding */ .emtcode PARAM_NULL 0x00 .emtcode PARAM_ARRAY_ELEMENT 0x01 .emtcode PARAM_STATE_ELEMENT 0x02 .emtcode PARAM_PROGRAM_ELEMENT 0x03 .emtcode PARAM_PROGRAM_ELEMENTS 0x04 .emtcode PARAM_CONSTANT 0x05 /* param state property */ .emtcode STATE_MATERIAL 0x01 .emtcode STATE_LIGHT 0x02 .emtcode STATE_LIGHT_MODEL 0x03 .emtcode STATE_LIGHT_PROD 0x04 .emtcode STATE_FOG 0x05 .emtcode STATE_MATRIX_ROWS 0x06 /* GL_ARB_fragment_program */ .emtcode STATE_TEX_ENV 0x07 .emtcode STATE_DEPTH 0x08 /* GL_ARB_vertex_program */ .emtcode STATE_TEX_GEN 0x09 .emtcode STATE_CLIP_PLANE 0x0A .emtcode STATE_POINT 0x0B /* state material property */ .emtcode MATERIAL_AMBIENT 0x01 .emtcode MATERIAL_DIFFUSE 0x02 .emtcode MATERIAL_SPECULAR 0x03 .emtcode MATERIAL_EMISSION 0x04 .emtcode MATERIAL_SHININESS 0x05 /* state light property */ .emtcode LIGHT_AMBIENT 0x01 .emtcode LIGHT_DIFFUSE 0x02 .emtcode LIGHT_SPECULAR 0x03 .emtcode LIGHT_POSITION 0x04 .emtcode LIGHT_ATTENUATION 0x05 .emtcode LIGHT_HALF 0x06 .emtcode LIGHT_SPOT_DIRECTION 0x07 /* state light model property */ .emtcode LIGHT_MODEL_AMBIENT 0x01 .emtcode LIGHT_MODEL_SCENECOLOR 0x02 /* state light product property */ .emtcode LIGHT_PROD_AMBIENT 0x01 .emtcode LIGHT_PROD_DIFFUSE 0x02 .emtcode LIGHT_PROD_SPECULAR 0x03 /* state texture environment property */ .emtcode TEX_ENV_COLOR 0x01 /* state texture generation coord property */ .emtcode TEX_GEN_EYE 0x01 .emtcode TEX_GEN_OBJECT 0x02 /* state fog property */ .emtcode FOG_COLOR 0x01 .emtcode FOG_PARAMS 0x02 /* state depth property */ .emtcode DEPTH_RANGE 0x01 /* state point parameters property */ .emtcode POINT_SIZE 0x01 .emtcode POINT_ATTENUATION 0x02 /* declaration */ .emtcode ATTRIB 0x01 .emtcode PARAM 0x02 .emtcode TEMP 0x03 .emtcode OUTPUT 0x04 .emtcode ALIAS 0x05 /* GL_ARB_vertex_program */ .emtcode ADDRESS 0x06 /* error messages */ .errtext UNKNOWN_PROGRAM_SIGNATURE "1001: '$e_signature$': unknown program signature" .errtext MISSING_END_OR_INVALID_STATEMENT "1002: '$e_statement$': invalid statement" .errtext CODE_AFTER_END "1003: '$e_statement$': code after 'END' keyword" .errtext INVALID_PROGRAM_OPTION "1004: '$e_identifier$': invalid program option" .errtext EXT_SWIZ_COMP_EXPECTED "1005: extended swizzle component expected but '$e_token$' found" .errtext TEX_TARGET_EXPECTED "1006: texture target expected but '$e_token$' found" .errtext TEXTURE_EXPECTED "1007: 'texture' expected but '$e_identifier$' found" .errtext SOURCE_REGISTER_EXPECTED "1008: source register expected but '$e_token$' found" .errtext DESTINATION_REGISTER_EXPECTED "1009: destination register expected but '$e_token$' found" .errtext INVALID_ADDRESS_COMPONENT "1010: '$e_identifier$': invalid address component" .errtext INVALID_ADDRESS_WRITEMASK "1011: '$e_identifier$': invalid address writemask" .errtext INVALID_COMPONENT "1012: '$e_charordigit$': invalid component" .errtext INVALID_SUFFIX "1013: '$e_identifier$': invalid suffix" .errtext INVALID_WRITEMASK "1014: '$e_identifier$': invalid writemask" .errtext FRAGMENT_EXPECTED "1015: 'fragment' expected but '$e_identifier$' found" .errtext VERTEX_EXPECTED "1016: 'vertex' expected but '$e_identifier$' found" .errtext INVALID_FRAGMENT_PROPERTY "1017: '$e_identifier$': invalid fragment property" .errtext INVALID_VERTEX_PROPERTY "1018: '$e_identifier$': invalid vertex property" .errtext INVALID_STATE_PROPERTY "1019: '$e_identifier$': invalid state property" .errtext INVALID_MATERIAL_PROPERTY "1020: '$e_identifier$': invalid material property" .errtext INVALID_LIGHT_PROPERTY "1021: '$e_identifier$': invalid light property" .errtext INVALID_SPOT_PROPERTY "1022: '$e_identifier$': invalid spot property" .errtext INVALID_LIGHTMODEL_PROPERTY "1023: '$e_identifier$': invalid light model property" .errtext INVALID_LIGHTPROD_PROPERTY "1024: '$e_identifier$': invalid light product property" .errtext INVALID_TEXENV_PROPERTY "1025: '$e_identifier$': invalid texture environment property" .errtext INVALID_TEXGEN_PROPERTY "1026: '$e_identifier$': invalid texture generating property" .errtext INVALID_TEXGEN_COORD "1027: '$e_identifier$': invalid texture generating coord" .errtext INVALID_FOG_PROPERTY "1028: '$e_identifier$': invalid fog property" .errtext INVALID_DEPTH_PROPERTY "1029: '$e_identifier$': invalid depth property" .errtext INVALID_CLIPPLANE_PROPERTY "1030: '$e_identifier$': invalid clip plane property" .errtext INVALID_POINT_PROPERTY "1031: '$e_identifier$': invalid point property" .errtext MATRIX_ROW_SELECTOR_OR_MODIFIER_EXPECTED "1032: matrix row selector or modifier expected but '$e_token$' found" .errtext INVALID_MATRIX_NAME "1033: '$e_identifier$': invalid matrix name" .errtext INVALID_PROGRAM_PROPERTY "1034: '$e_identifier$': invalid program property" .errtext RESULT_EXPECTED "1035: 'result' expected but '$e_token$' found" .errtext INVALID_RESULT_PROPERTY "1036: '$e_identifier$': invalid result property" .errtext INVALID_FACE_PROPERTY "1037: '$e_identifier$': invalid face property" .errtext INVALID_COLOR_PROPERTY "1038: '$e_identifier$': invalid color property" .errtext IDENTIFIER_EXPECTED "1039: identifier expected but '$e_token$' found" .errtext RESERVED_KEYWORD "1040: use of reserved keyword as an identifier" .errtext INTEGER_EXPECTED "1041: integer value expected but '$e_token$' found" .errtext MISSING_SEMICOLON "1042: ';' expected but '$e_token$' found" .errtext MISSING_COMMA "1043: ',' expected but '$e_token$' found" .errtext MISSING_LBRACKET "1044: '[' expected but '$e_token$' found" .errtext MISSING_RBRACKET "1045: ']' expected but '$e_token$' found" .errtext MISSING_DOT "1046: '.' expected but '$e_token$' found" .errtext MISSING_EQUAL "1047: '=' expected but '$e_token$' found" .errtext MISSING_LBRACE "1048: '{' expected but '$e_token$' found" .errtext MISSING_RBRACE "1049: '}' expected but '$e_token$' found" .errtext MISSING_DOTDOT "1050: '..' expected but '$e_token$' found" .errtext MISSING_FRACTION_OR_EXPONENT "1051: missing fraction part or exponent" .errtext MISSING_DOT_OR_EXPONENT "1052: missing '.' or exponent" .errtext EXPONENT_VALUE_EXPECTED "1053: exponent value expected" .errtext INTEGER_OUT_OF_RANGE "1054: integer value out of range" .errtext OPERATION_NEEDS_DESTINATION_VARIABLE "1055: operation needs destination variable" .errtext OPERATION_NEEDS_SOURCE_VARIABLE "1056: operation needs source variable" .errtext ADDRESS_REGISTER_EXPECTED "1057: address register expected but '$e_token$' found" .errtext ADDRESS_REGISTER_OR_INTEGER_EXPECTED "1058: address register or integer literal expected but '$e_token$' found" /* extension presence condition registers */ /* GL_ARB_vertex_blend */ /* GL_EXT_vertex_weighting */ .regbyte vertex_blend 0x00 /* GL_ARB_matrix_palette */ .regbyte matrix_palette 0x00 /* GL_ARB_point_parameters */ /* GL_EXT_point_parameters */ .regbyte point_parameters 0x00 /* GL_EXT_secondary_color */ .regbyte secondary_color 0x00 /* GL_EXT_fog_coord */ .regbyte fog_coord 0x00 /* GL_EXT_texture_rectangle */ /* GL_NV_texture_rectangle */ .regbyte texture_rectangle 0x00 /* GL_ARB_fragment_program_shadow */ .regbyte fragment_program_shadow 0x00 /* GL_ARB_draw_buffers */ .regbyte draw_buffers 0x00 /* GL_MESA_texture_array */ .regbyte texture_array 0x00 /* option presence condition registers */ /* they are all initially set to zero - when a particular OPTION is encountered, the appropriate */ /* register is set to 1 to indicate that the OPTION was specified. */ /* GL_ARB_fragment_program */ .regbyte ARB_precision_hint_fastest 0x00 .regbyte ARB_precision_hint_nicest 0x00 .regbyte ARB_fog_exp 0x00 .regbyte ARB_fog_exp2 0x00 .regbyte ARB_fog_linear 0x00 /* GL_ARB_vertex_program */ .regbyte ARB_position_invariant 0x00 /* GL_ARB_fragment_program_shadow */ .regbyte ARB_fragment_program_shadow 0x00 /* GL_ARB_draw_buffers */ .regbyte ARB_draw_buffers 0x00 /* GL_MESA_texture_array */ .regbyte MESA_texture_array 0x00 /* program target condition register */ /* this syntax script deals with two program targets - VERTEX_PROGRAM and FRAGMENT_PROGRAM. */ /* to distinguish between them we need a register that will store for us the current target. */ /* the client will typically set the register to apropriate value before parsing a particular */ /* program. the mapping between program targets and their values is listed below. */ /* */ /* program target register value */ /* ---------------------------------------------- */ /* FRAGMENT_PROGRAM 0x10 */ /* VERTEX_PROGRAM 0x20 */ /* */ /* the initial value of the register is 0 to catch potential errors with not setting the register */ /* with the proper value. */ .regbyte program_target 0x00 /* ::= "END" */ program programs .error UNKNOWN_PROGRAM_SIGNATURE .emit REVISION; programs .if (program_target == 0x10) frag_program_1_0 .emit FRAGMENT_PROGRAM .emit 0x01 .emit 0x00 .or .if (program_target == 0x20) vert_program_1_0 .emit VERTEX_PROGRAM .emit 0x01 .emit 0x00; frag_program_1_0 '!' .and '!' .and 'A' .and 'R' .and 'B' .and 'f' .and 'p' .and '1' .and '.' .and '0' .and optional_space .and fp_optionSequence .and fp_statementSequence .and "END" .error MISSING_END_OR_INVALID_STATEMENT .emit END .and optional_space .and '\0' .error CODE_AFTER_END; vert_program_1_0 '!' .and '!' .and 'A' .and 'R' .and 'B' .and 'v' .and 'p' .and '1' .and '.' .and '0' .and optional_space .and vp_optionSequence .and vp_statementSequence .and "END" .error MISSING_END_OR_INVALID_STATEMENT .emit END .and optional_space .and '\0' .error CODE_AFTER_END; /* ::=