2 * Mesa 3-D graphics library
5 * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 * \file arbprogram.syn
27 * ARB_fragment/vertex_program syntax
34 This value must be incremented every time emit code values or structure of the production
35 array changes. This value is placed at the beginning of the production array. The loader
36 compares the value with its REVISION value. If they do not match, the loader is not up
39 .emtcode REVISION 0x0a
42 .emtcode FRAGMENT_PROGRAM 0x01
43 .emtcode VERTEX_PROGRAM 0x02
47 .emtcode INSTRUCTION 0x02
48 .emtcode DECLARATION 0x03
51 /* GL_ARB_fragment_program option */
52 .emtcode ARB_PRECISION_HINT_FASTEST 0x00
53 .emtcode ARB_PRECISION_HINT_NICEST 0x01
54 .emtcode ARB_FOG_EXP 0x02
55 .emtcode ARB_FOG_EXP2 0x03
56 .emtcode ARB_FOG_LINEAR 0x04
58 /* GL_ARB_vertex_program option */
59 .emtcode ARB_POSITION_INVARIANT 0x05
61 /* GL_ARB_fragment_program_shadow option */
62 .emtcode ARB_FRAGMENT_PROGRAM_SHADOW 0x06
64 /* GL_ARB_draw_buffers option */
65 .emtcode ARB_DRAW_BUFFERS 0x07
67 /* GL_MESA_texture_array option */
68 .emtcode MESA_TEXTURE_ARRAY 0x08
70 /* GL_ARB_fragment_program instruction class */
71 .emtcode OP_ALU_INST 0x00
72 .emtcode OP_TEX_INST 0x01
74 /* GL_ARB_vertex_program instruction class */
77 /* GL_ARB_fragment_program instruction type */
78 .emtcode OP_ALU_VECTOR 0x00
79 .emtcode OP_ALU_SCALAR 0x01
80 .emtcode OP_ALU_BINSC 0x02
81 .emtcode OP_ALU_BIN 0x03
82 .emtcode OP_ALU_TRI 0x04
83 .emtcode OP_ALU_SWZ 0x05
84 .emtcode OP_TEX_SAMPLE 0x06
85 .emtcode OP_TEX_KIL 0x07
87 /* GL_ARB_vertex_program instruction type */
88 .emtcode OP_ALU_ARL 0x08
96 /* GL_ARB_fragment_program instruction code */
98 .emtcode OP_ABS_SAT 0x1B
100 .emtcode OP_FLR_SAT 0x26
102 .emtcode OP_FRC_SAT 0x27
104 .emtcode OP_LIT_SAT 0x2A
106 .emtcode OP_MOV_SAT 0x30
108 .emtcode OP_COS_SAT 0x20
110 .emtcode OP_EX2_SAT 0x25
112 .emtcode OP_LG2_SAT 0x29
114 .emtcode OP_RCP_SAT 0x33
116 .emtcode OP_RSQ_SAT 0x34
118 .emtcode OP_SIN_SAT 0x39
120 .emtcode OP_SCS_SAT 0x36
122 .emtcode OP_POW_SAT 0x32
124 .emtcode OP_ADD_SAT 0x1C
126 .emtcode OP_DP3_SAT 0x21
128 .emtcode OP_DP4_SAT 0x22
130 .emtcode OP_DPH_SAT 0x23
132 .emtcode OP_DST_SAT 0x24
134 .emtcode OP_MAX_SAT 0x2E
136 .emtcode OP_MIN_SAT 0x2F
138 .emtcode OP_MUL_SAT 0x31
140 .emtcode OP_SGE_SAT 0x37
142 .emtcode OP_SLT_SAT 0x3A
144 .emtcode OP_SUB_SAT 0x3B
146 .emtcode OP_XPD_SAT 0x43
148 .emtcode OP_CMP_SAT 0x1E
150 .emtcode OP_LRP_SAT 0x2C
152 .emtcode OP_MAD_SAT 0x2D
154 .emtcode OP_SWZ_SAT 0x3C
156 .emtcode OP_TEX_SAT 0x3E
158 .emtcode OP_TXB_SAT 0x40
160 .emtcode OP_TXP_SAT 0x42
163 /* GL_ARB_vertex_program instruction code */
192 /* fragment attribute binding */
193 .emtcode FRAGMENT_ATTRIB_COLOR 0x01
194 .emtcode FRAGMENT_ATTRIB_TEXCOORD 0x02
195 .emtcode FRAGMENT_ATTRIB_FOGCOORD 0x03
196 .emtcode FRAGMENT_ATTRIB_POSITION 0x04
198 /* vertex attribute binding */
199 .emtcode VERTEX_ATTRIB_POSITION 0x01
200 .emtcode VERTEX_ATTRIB_WEIGHT 0x02
201 .emtcode VERTEX_ATTRIB_NORMAL 0x03
202 .emtcode VERTEX_ATTRIB_COLOR 0x04
203 .emtcode VERTEX_ATTRIB_FOGCOORD 0x05
204 .emtcode VERTEX_ATTRIB_TEXCOORD 0x06
205 .emtcode VERTEX_ATTRIB_MATRIXINDEX 0x07
206 .emtcode VERTEX_ATTRIB_GENERIC 0x08
208 /* fragment result binding */
209 .emtcode FRAGMENT_RESULT_COLOR 0x01
210 .emtcode FRAGMENT_RESULT_DEPTH 0x02
212 /* vertex result binding */
213 .emtcode VERTEX_RESULT_POSITION 0x01
214 .emtcode VERTEX_RESULT_COLOR 0x02
215 .emtcode VERTEX_RESULT_FOGCOORD 0x03
216 .emtcode VERTEX_RESULT_POINTSIZE 0x04
217 .emtcode VERTEX_RESULT_TEXCOORD 0x05
220 .emtcode TEXTARGET_1D 0x01
221 .emtcode TEXTARGET_2D 0x02
222 .emtcode TEXTARGET_3D 0x03
223 .emtcode TEXTARGET_RECT 0x04
224 .emtcode TEXTARGET_CUBE 0x05
225 /* GL_ARB_fragment_program_shadow */
226 .emtcode TEXTARGET_SHADOW1D 0x06
227 .emtcode TEXTARGET_SHADOW2D 0x07
228 .emtcode TEXTARGET_SHADOWRECT 0x08
229 /* GL_MESA_texture_array */
230 .emtcode TEXTARGET_1D_ARRAY 0x09
231 .emtcode TEXTARGET_2D_ARRAY 0x0a
232 .emtcode TEXTARGET_SHADOW1D_ARRAY 0x0b
233 .emtcode TEXTARGET_SHADOW2D_ARRAY 0x0c
236 .emtcode FACE_FRONT 0x00
237 .emtcode FACE_BACK 0x01
240 .emtcode COLOR_PRIMARY 0x00
241 .emtcode COLOR_SECONDARY 0x01
244 .emtcode COMPONENT_X 0x00
245 .emtcode COMPONENT_Y 0x01
246 .emtcode COMPONENT_Z 0x02
247 .emtcode COMPONENT_W 0x03
248 .emtcode COMPONENT_0 0x04
249 .emtcode COMPONENT_1 0x05
251 /* array index type */
252 .emtcode ARRAY_INDEX_ABSOLUTE 0x00
253 .emtcode ARRAY_INDEX_RELATIVE 0x01
256 .emtcode MATRIX_MODELVIEW 0x01
257 .emtcode MATRIX_PROJECTION 0x02
258 .emtcode MATRIX_MVP 0x03
259 .emtcode MATRIX_TEXTURE 0x04
260 .emtcode MATRIX_PALETTE 0x05
261 .emtcode MATRIX_PROGRAM 0x06
263 /* matrix modifier */
264 .emtcode MATRIX_MODIFIER_IDENTITY 0x00
265 .emtcode MATRIX_MODIFIER_INVERSE 0x01
266 .emtcode MATRIX_MODIFIER_TRANSPOSE 0x02
267 .emtcode MATRIX_MODIFIER_INVTRANS 0x03
270 .emtcode CONSTANT_SCALAR 0x01
271 .emtcode CONSTANT_VECTOR 0x02
273 /* program param type */
274 .emtcode PROGRAM_PARAM_ENV 0x01
275 .emtcode PROGRAM_PARAM_LOCAL 0x02
278 .emtcode REGISTER_ATTRIB 0x01
279 .emtcode REGISTER_PARAM 0x02
280 .emtcode REGISTER_RESULT 0x03
281 .emtcode REGISTER_ESTABLISHED_NAME 0x04
284 .emtcode PARAM_NULL 0x00
285 .emtcode PARAM_ARRAY_ELEMENT 0x01
286 .emtcode PARAM_STATE_ELEMENT 0x02
287 .emtcode PARAM_PROGRAM_ELEMENT 0x03
288 .emtcode PARAM_PROGRAM_ELEMENTS 0x04
289 .emtcode PARAM_CONSTANT 0x05
291 /* param state property */
292 .emtcode STATE_MATERIAL 0x01
293 .emtcode STATE_LIGHT 0x02
294 .emtcode STATE_LIGHT_MODEL 0x03
295 .emtcode STATE_LIGHT_PROD 0x04
296 .emtcode STATE_FOG 0x05
297 .emtcode STATE_MATRIX_ROWS 0x06
298 /* GL_ARB_fragment_program */
299 .emtcode STATE_TEX_ENV 0x07
300 .emtcode STATE_DEPTH 0x08
301 /* GL_ARB_vertex_program */
302 .emtcode STATE_TEX_GEN 0x09
303 .emtcode STATE_CLIP_PLANE 0x0A
304 .emtcode STATE_POINT 0x0B
306 /* state material property */
307 .emtcode MATERIAL_AMBIENT 0x01
308 .emtcode MATERIAL_DIFFUSE 0x02
309 .emtcode MATERIAL_SPECULAR 0x03
310 .emtcode MATERIAL_EMISSION 0x04
311 .emtcode MATERIAL_SHININESS 0x05
313 /* state light property */
314 .emtcode LIGHT_AMBIENT 0x01
315 .emtcode LIGHT_DIFFUSE 0x02
316 .emtcode LIGHT_SPECULAR 0x03
317 .emtcode LIGHT_POSITION 0x04
318 .emtcode LIGHT_ATTENUATION 0x05
319 .emtcode LIGHT_HALF 0x06
320 .emtcode LIGHT_SPOT_DIRECTION 0x07
322 /* state light model property */
323 .emtcode LIGHT_MODEL_AMBIENT 0x01
324 .emtcode LIGHT_MODEL_SCENECOLOR 0x02
326 /* state light product property */
327 .emtcode LIGHT_PROD_AMBIENT 0x01
328 .emtcode LIGHT_PROD_DIFFUSE 0x02
329 .emtcode LIGHT_PROD_SPECULAR 0x03
331 /* state texture environment property */
332 .emtcode TEX_ENV_COLOR 0x01
334 /* state texture generation coord property */
335 .emtcode TEX_GEN_EYE 0x01
336 .emtcode TEX_GEN_OBJECT 0x02
338 /* state fog property */
339 .emtcode FOG_COLOR 0x01
340 .emtcode FOG_PARAMS 0x02
342 /* state depth property */
343 .emtcode DEPTH_RANGE 0x01
345 /* state point parameters property */
346 .emtcode POINT_SIZE 0x01
347 .emtcode POINT_ATTENUATION 0x02
355 /* GL_ARB_vertex_program */
356 .emtcode ADDRESS 0x06
359 .errtext UNKNOWN_PROGRAM_SIGNATURE "1001: '$e_signature$': unknown program signature"
360 .errtext MISSING_END_OR_INVALID_STATEMENT "1002: '$e_statement$': invalid statement"
361 .errtext CODE_AFTER_END "1003: '$e_statement$': code after 'END' keyword"
362 .errtext INVALID_PROGRAM_OPTION "1004: '$e_identifier$': invalid program option"
363 .errtext EXT_SWIZ_COMP_EXPECTED "1005: extended swizzle component expected but '$e_token$' found"
364 .errtext TEX_TARGET_EXPECTED "1006: texture target expected but '$e_token$' found"
365 .errtext TEXTURE_EXPECTED "1007: 'texture' expected but '$e_identifier$' found"
366 .errtext SOURCE_REGISTER_EXPECTED "1008: source register expected but '$e_token$' found"
367 .errtext DESTINATION_REGISTER_EXPECTED "1009: destination register expected but '$e_token$' found"
368 .errtext INVALID_ADDRESS_COMPONENT "1010: '$e_identifier$': invalid address component"
369 .errtext INVALID_ADDRESS_WRITEMASK "1011: '$e_identifier$': invalid address writemask"
370 .errtext INVALID_COMPONENT "1012: '$e_charordigit$': invalid component"
371 .errtext INVALID_SUFFIX "1013: '$e_identifier$': invalid suffix"
372 .errtext INVALID_WRITEMASK "1014: '$e_identifier$': invalid writemask"
373 .errtext FRAGMENT_EXPECTED "1015: 'fragment' expected but '$e_identifier$' found"
374 .errtext VERTEX_EXPECTED "1016: 'vertex' expected but '$e_identifier$' found"
375 .errtext INVALID_FRAGMENT_PROPERTY "1017: '$e_identifier$': invalid fragment property"
376 .errtext INVALID_VERTEX_PROPERTY "1018: '$e_identifier$': invalid vertex property"
377 .errtext INVALID_STATE_PROPERTY "1019: '$e_identifier$': invalid state property"
378 .errtext INVALID_MATERIAL_PROPERTY "1020: '$e_identifier$': invalid material property"
379 .errtext INVALID_LIGHT_PROPERTY "1021: '$e_identifier$': invalid light property"
380 .errtext INVALID_SPOT_PROPERTY "1022: '$e_identifier$': invalid spot property"
381 .errtext INVALID_LIGHTMODEL_PROPERTY "1023: '$e_identifier$': invalid light model property"
382 .errtext INVALID_LIGHTPROD_PROPERTY "1024: '$e_identifier$': invalid light product property"
383 .errtext INVALID_TEXENV_PROPERTY "1025: '$e_identifier$': invalid texture environment property"
384 .errtext INVALID_TEXGEN_PROPERTY "1026: '$e_identifier$': invalid texture generating property"
385 .errtext INVALID_TEXGEN_COORD "1027: '$e_identifier$': invalid texture generating coord"
386 .errtext INVALID_FOG_PROPERTY "1028: '$e_identifier$': invalid fog property"
387 .errtext INVALID_DEPTH_PROPERTY "1029: '$e_identifier$': invalid depth property"
388 .errtext INVALID_CLIPPLANE_PROPERTY "1030: '$e_identifier$': invalid clip plane property"
389 .errtext INVALID_POINT_PROPERTY "1031: '$e_identifier$': invalid point property"
390 .errtext MATRIX_ROW_SELECTOR_OR_MODIFIER_EXPECTED "1032: matrix row selector or modifier expected but '$e_token$' found"
391 .errtext INVALID_MATRIX_NAME "1033: '$e_identifier$': invalid matrix name"
392 .errtext INVALID_PROGRAM_PROPERTY "1034: '$e_identifier$': invalid program property"
393 .errtext RESULT_EXPECTED "1035: 'result' expected but '$e_token$' found"
394 .errtext INVALID_RESULT_PROPERTY "1036: '$e_identifier$': invalid result property"
395 .errtext INVALID_FACE_PROPERTY "1037: '$e_identifier$': invalid face property"
396 .errtext INVALID_COLOR_PROPERTY "1038: '$e_identifier$': invalid color property"
397 .errtext IDENTIFIER_EXPECTED "1039: identifier expected but '$e_token$' found"
398 .errtext RESERVED_KEYWORD "1040: use of reserved keyword as an identifier"
399 .errtext INTEGER_EXPECTED "1041: integer value expected but '$e_token$' found"
400 .errtext MISSING_SEMICOLON "1042: ';' expected but '$e_token$' found"
401 .errtext MISSING_COMMA "1043: ',' expected but '$e_token$' found"
402 .errtext MISSING_LBRACKET "1044: '[' expected but '$e_token$' found"
403 .errtext MISSING_RBRACKET "1045: ']' expected but '$e_token$' found"
404 .errtext MISSING_DOT "1046: '.' expected but '$e_token$' found"
405 .errtext MISSING_EQUAL "1047: '=' expected but '$e_token$' found"
406 .errtext MISSING_LBRACE "1048: '{' expected but '$e_token$' found"
407 .errtext MISSING_RBRACE "1049: '}' expected but '$e_token$' found"
408 .errtext MISSING_DOTDOT "1050: '..' expected but '$e_token$' found"
409 .errtext MISSING_FRACTION_OR_EXPONENT "1051: missing fraction part or exponent"
410 .errtext MISSING_DOT_OR_EXPONENT "1052: missing '.' or exponent"
411 .errtext EXPONENT_VALUE_EXPECTED "1053: exponent value expected"
412 .errtext INTEGER_OUT_OF_RANGE "1054: integer value out of range"
413 .errtext OPERATION_NEEDS_DESTINATION_VARIABLE "1055: operation needs destination variable"
414 .errtext OPERATION_NEEDS_SOURCE_VARIABLE "1056: operation needs source variable"
415 .errtext ADDRESS_REGISTER_EXPECTED "1057: address register expected but '$e_token$' found"
416 .errtext ADDRESS_REGISTER_OR_INTEGER_EXPECTED "1058: address register or integer literal expected but '$e_token$' found"
418 /* extension presence condition registers */
420 /* GL_ARB_vertex_blend */
421 /* GL_EXT_vertex_weighting */
422 .regbyte vertex_blend 0x00
424 /* GL_ARB_matrix_palette */
425 .regbyte matrix_palette 0x00
427 /* GL_ARB_point_parameters */
428 /* GL_EXT_point_parameters */
429 .regbyte point_parameters 0x00
431 /* GL_EXT_secondary_color */
432 .regbyte secondary_color 0x00
434 /* GL_EXT_fog_coord */
435 .regbyte fog_coord 0x00
437 /* GL_EXT_texture_rectangle */
438 /* GL_NV_texture_rectangle */
439 .regbyte texture_rectangle 0x00
441 /* GL_ARB_fragment_program_shadow */
442 .regbyte fragment_program_shadow 0x00
444 /* GL_ARB_draw_buffers */
445 .regbyte draw_buffers 0x00
447 /* GL_MESA_texture_array */
448 .regbyte texture_array 0x00
450 /* option presence condition registers */
451 /* they are all initially set to zero - when a particular OPTION is encountered, the appropriate */
452 /* register is set to 1 to indicate that the OPTION was specified. */
454 /* GL_ARB_fragment_program */
455 .regbyte ARB_precision_hint_fastest 0x00
456 .regbyte ARB_precision_hint_nicest 0x00
457 .regbyte ARB_fog_exp 0x00
458 .regbyte ARB_fog_exp2 0x00
459 .regbyte ARB_fog_linear 0x00
461 /* GL_ARB_vertex_program */
462 .regbyte ARB_position_invariant 0x00
464 /* GL_ARB_fragment_program_shadow */
465 .regbyte ARB_fragment_program_shadow 0x00
467 /* GL_ARB_draw_buffers */
468 .regbyte ARB_draw_buffers 0x00
470 /* GL_MESA_texture_array */
471 .regbyte MESA_texture_array 0x00
473 /* program target condition register */
474 /* this syntax script deals with two program targets - VERTEX_PROGRAM and FRAGMENT_PROGRAM. */
475 /* to distinguish between them we need a register that will store for us the current target. */
476 /* the client will typically set the register to apropriate value before parsing a particular */
477 /* program. the mapping between program targets and their values is listed below. */
479 /* program target register value */
480 /* ---------------------------------------------- */
481 /* FRAGMENT_PROGRAM 0x10 */
482 /* VERTEX_PROGRAM 0x20 */
484 /* the initial value of the register is 0 to catch potential errors with not setting the register */
485 /* with the proper value. */
486 .regbyte program_target 0x00
489 <program> ::= <optionSequence> <statementSequence> "END"
492 programs .error UNKNOWN_PROGRAM_SIGNATURE .emit REVISION;
494 .if (program_target == 0x10) frag_program_1_0 .emit FRAGMENT_PROGRAM .emit 0x01 .emit 0x00 .or
495 .if (program_target == 0x20) vert_program_1_0 .emit VERTEX_PROGRAM .emit 0x01 .emit 0x00;
497 '!' .and '!' .and 'A' .and 'R' .and 'B' .and 'f' .and 'p' .and '1' .and '.' .and '0' .and
498 optional_space .and fp_optionSequence .and fp_statementSequence .and
499 "END" .error MISSING_END_OR_INVALID_STATEMENT .emit END .and optional_space .and
500 '\0' .error CODE_AFTER_END;
502 '!' .and '!' .and 'A' .and 'R' .and 'B' .and 'v' .and 'p' .and '1' .and '.' .and '0' .and
503 optional_space .and vp_optionSequence .and vp_statementSequence .and
504 "END" .error MISSING_END_OR_INVALID_STATEMENT .emit END .and optional_space .and
505 '\0' .error CODE_AFTER_END;
508 <optionSequence> ::= <optionSequence> <option>
517 <option> ::= "OPTION" <identifier> ";"
519 NOTE: options ARB_precision_hint_nicest and ARB_precision_hint_fastest are exclusive. When one of
520 these options is encountered, the other one is automatically disabled.
521 the same applies to options ARB_fog_exp, ARB_fog_exp2 and ARB_fog_linear.
524 "OPTION" .emit OPTION .and space .error IDENTIFIER_EXPECTED .and
525 fp_optionString .error INVALID_PROGRAM_OPTION .and semicolon;
527 "OPTION" .emit OPTION .and space .error IDENTIFIER_EXPECTED .and
528 vp_optionString .error INVALID_PROGRAM_OPTION .and semicolon;
530 .if (ARB_precision_hint_nicest == 0x00) "ARB_precision_hint_fastest"
531 .emit ARB_PRECISION_HINT_FASTEST .load ARB_precision_hint_fastest 0x01 .or
532 .if (ARB_precision_hint_fastest == 0x00) "ARB_precision_hint_nicest"
533 .emit ARB_PRECISION_HINT_NICEST .load ARB_precision_hint_nicest 0x01 .or
534 fp_ARB_fog_exp .emit ARB_FOG_EXP .load ARB_fog_exp 0x01 .or
535 fp_ARB_fog_exp2 .emit ARB_FOG_EXP2 .load ARB_fog_exp2 0x01 .or
536 fp_ARB_fog_linear .emit ARB_FOG_LINEAR .load ARB_fog_linear 0x01 .or
537 .if (fragment_program_shadow != 0x00) "ARB_fragment_program_shadow"
538 .emit ARB_FRAGMENT_PROGRAM_SHADOW .load ARB_fragment_program_shadow 0x01 .or
539 .if (draw_buffers != 0x00) "ARB_draw_buffers" .emit ARB_DRAW_BUFFERS
540 .load ARB_draw_buffers 0x01 .or
541 .if (texture_array != 0x00) "MESA_texture_array" .emit MESA_TEXTURE_ARRAY
542 .load MESA_texture_array 0x01;
544 "ARB_position_invariant" .emit ARB_POSITION_INVARIANT .load ARB_position_invariant 0x01;
546 .if (ARB_fog_exp2 == 0x00) .true .and .if (ARB_fog_linear == 0x00) "ARB_fog_exp";
548 .if (ARB_fog_exp == 0x00) .true .and .if (ARB_fog_linear == 0x00) "ARB_fog_exp2";
550 .if (ARB_fog_exp == 0x00) .true .and .if (ARB_fog_exp2 == 0x00) "ARB_fog_linear";
553 <statementSequence> ::= <statementSequence> <statement>
562 <statement> ::= <instruction> ";"
563 | <namingStatement> ";"
565 NOTE: ".emit $" in the definitions below means that we output instruction position (offset of
566 the first character of instruction) for program debugging purposes.
569 fp_statement_1 .or fp_statement_2;
571 vp_statement_1 .or vp_statement_2;
573 fp_instruction .emit INSTRUCTION .emit $ .and semicolon;
575 fp_namingStatement .emit DECLARATION .and semicolon;
577 vp_instruction .emit INSTRUCTION .emit $ .and semicolon;
579 vp_namingStatement .emit DECLARATION .and semicolon;
583 <instruction> ::= <ALUInstruction>
587 <instruction> ::= <ARL_instruction>
588 | <VECTORop_instruction>
589 | <SCALARop_instruction>
590 | <BINSCop_instruction>
591 | <BINop_instruction>
592 | <TRIop_instruction>
596 ALUInstruction .emit OP_ALU_INST .or
597 TexInstruction .emit OP_TEX_INST;
599 ARL_instruction .emit OP_ALU_ARL .or
600 vp_VECTORop_instruction .emit OP_ALU_VECTOR .or
601 vp_SCALARop_instruction .emit OP_ALU_SCALAR .or
602 vp_BINSCop_instruction .emit OP_ALU_BINSC .or
603 vp_BINop_instruction .emit OP_ALU_BIN .or
604 vp_TRIop_instruction .emit OP_ALU_TRI .or
605 vp_SWZ_instruction .emit OP_ALU_SWZ;
609 <ALUInstruction> ::= <VECTORop_instruction>
610 | <SCALARop_instruction>
611 | <BINSCop_instruction>
612 | <BINop_instruction>
613 | <TRIop_instruction>
617 fp_VECTORop_instruction .emit OP_ALU_VECTOR .or
618 fp_SCALARop_instruction .emit OP_ALU_SCALAR .or
619 fp_BINSCop_instruction .emit OP_ALU_BINSC .or
620 fp_BINop_instruction .emit OP_ALU_BIN .or
621 fp_TRIop_instruction .emit OP_ALU_TRI .or
622 fp_SWZ_instruction .emit OP_ALU_SWZ;
626 <TexInstruction> ::= <SAMPLE_instruction>
630 SAMPLE_instruction .emit OP_TEX_SAMPLE .or
631 KIL_instruction .emit OP_TEX_KIL;
635 <ARL_instruction> ::= "ARL" <maskedAddrReg> "," <scalarSrcReg>
638 "ARL" .emit OP_ARL .and space_dst .and maskedAddrReg .and comma .and vp_scalarSrcReg;
642 <VECTORop_instruction> ::= <VECTORop> <maskedDstReg> ","
646 <VECTORop_instruction> ::= <VECTORop> <maskedDstReg> "," <swizzleSrcReg>
648 fp_VECTORop_instruction
649 fp_VECTORop .and space_dst .and fp_maskedDstReg .and comma .and vectorSrcReg;
650 vp_VECTORop_instruction
651 vp_VECTORop .and space_dst .and vp_maskedDstReg .and comma .and swizzleSrcReg;
655 <VECTORop> ::= "ABS" | "ABS_SAT"
669 "ABS" .emit OP_ABS .or "ABS_SAT" .emit OP_ABS_SAT .or
670 "FLR" .emit OP_FLR .or "FLR_SAT" .emit OP_FLR_SAT .or
671 "FRC" .emit OP_FRC .or "FRC_SAT" .emit OP_FRC_SAT .or
672 "LIT" .emit OP_LIT .or "LIT_SAT" .emit OP_LIT_SAT .or
673 "MOV" .emit OP_MOV .or "MOV_SAT" .emit OP_MOV_SAT;
675 "ABS" .emit OP_ABS .or
676 "FLR" .emit OP_FLR .or
677 "FRC" .emit OP_FRC .or
678 "LIT" .emit OP_LIT .or
682 <SCALARop_instruction> ::= <SCALARop> <maskedDstReg> "," <scalarSrcReg>
684 fp_SCALARop_instruction
685 fp_SCALARop .and space_dst .and fp_maskedDstReg .and comma .and fp_scalarSrcReg;
686 vp_SCALARop_instruction
687 vp_SCALARop .and space_dst .and vp_maskedDstReg .and comma .and vp_scalarSrcReg;
691 <SCALARop> ::= "COS" | "COS_SAT"
708 "COS" .emit OP_COS .or "COS_SAT" .emit OP_COS_SAT .or
709 "EX2" .emit OP_EX2 .or "EX2_SAT" .emit OP_EX2_SAT .or
710 "LG2" .emit OP_LG2 .or "LG2_SAT" .emit OP_LG2_SAT .or
711 "RCP" .emit OP_RCP .or "RCP_SAT" .emit OP_RCP_SAT .or
712 "RSQ" .emit OP_RSQ .or "RSQ_SAT" .emit OP_RSQ_SAT .or
713 "SIN" .emit OP_SIN .or "SIN_SAT" .emit OP_SIN_SAT .or
714 "SCS" .emit OP_SCS .or "SCS_SAT" .emit OP_SCS_SAT;
716 "EX2" .emit OP_EX2 .or
717 "EXP" .emit OP_EXP .or
718 "LG2" .emit OP_LG2 .or
719 "LOG" .emit OP_LOG .or
720 "RCP" .emit OP_RCP .or
724 <BINSCop_instruction> ::= <BINSCop> <maskedDstReg> "," <scalarSrcReg> ","
727 fp_BINSCop_instruction
728 fp_BINSCop .and space_dst .and fp_maskedDstReg .and comma .and fp_scalarSrcReg .and comma .and
730 vp_BINSCop_instruction
731 vp_BINSCop .and space_dst .and vp_maskedDstReg .and comma .and vp_scalarSrcReg .and comma .and
736 <BINSCop> ::= "POW" | "POW_SAT"
742 "POW" .emit OP_POW .or "POW_SAT" .emit OP_POW_SAT;
748 <BINop_instruction> ::= <BINop> <maskedDstReg> ","
749 <vectorSrcReg> "," <vectorSrcReg>
752 <BINop_instruction> ::= <BINop> <maskedDstReg> ","
753 <swizzleSrcReg> "," <swizzleSrcReg>
756 fp_BINop .and space_dst .and fp_maskedDstReg .and comma .and vectorSrcReg .and comma .and
759 vp_BINop .and space_dst .and vp_maskedDstReg .and comma .and swizzleSrcReg .and comma .and
764 <BINop> ::= "ADD" | "ADD_SAT"
792 "ADD" .emit OP_ADD .or "ADD_SAT" .emit OP_ADD_SAT .or
793 "DP3" .emit OP_DP3 .or "DP3_SAT" .emit OP_DP3_SAT .or
794 "DP4" .emit OP_DP4 .or "DP4_SAT" .emit OP_DP4_SAT .or
795 "DPH" .emit OP_DPH .or "DPH_SAT" .emit OP_DPH_SAT .or
796 "DST" .emit OP_DST .or "DST_SAT" .emit OP_DST_SAT .or
797 "MAX" .emit OP_MAX .or "MAX_SAT" .emit OP_MAX_SAT .or
798 "MIN" .emit OP_MIN .or "MIN_SAT" .emit OP_MIN_SAT .or
799 "MUL" .emit OP_MUL .or "MUL_SAT" .emit OP_MUL_SAT .or
800 "SGE" .emit OP_SGE .or "SGE_SAT" .emit OP_SGE_SAT .or
801 "SLT" .emit OP_SLT .or "SLT_SAT" .emit OP_SLT_SAT .or
802 "SUB" .emit OP_SUB .or "SUB_SAT" .emit OP_SUB_SAT .or
803 "XPD" .emit OP_XPD .or "XPD_SAT" .emit OP_XPD_SAT;
805 "ADD" .emit OP_ADD .or
806 "DP3" .emit OP_DP3 .or
807 "DP4" .emit OP_DP4 .or
808 "DPH" .emit OP_DPH .or
809 "DST" .emit OP_DST .or
810 "MAX" .emit OP_MAX .or
811 "MIN" .emit OP_MIN .or
812 "MUL" .emit OP_MUL .or
813 "SGE" .emit OP_SGE .or
814 "SLT" .emit OP_SLT .or
815 "SUB" .emit OP_SUB .or
820 <TRIop_instruction> ::= <TRIop> <maskedDstReg> ","
821 <vectorSrcReg> "," <vectorSrcReg> ","
825 <TRIop_instruction> ::= <TRIop> <maskedDstReg> ","
826 <swizzleSrcReg> "," <swizzleSrcReg> ","
830 fp_TRIop .and space_dst .and fp_maskedDstReg .and comma .and vectorSrcReg .and comma .and
831 vectorSrcReg .and comma .and vectorSrcReg;
833 vp_TRIop .and space_dst .and vp_maskedDstReg .and comma .and swizzleSrcReg .and comma .and
834 swizzleSrcReg .and comma .and swizzleSrcReg;
838 <TRIop> ::= "CMP" | "CMP_SAT"
846 "CMP" .emit OP_CMP .or "CMP_SAT" .emit OP_CMP_SAT .or
847 "LRP" .emit OP_LRP .or "LRP_SAT" .emit OP_LRP_SAT .or
848 "MAD" .emit OP_MAD .or "MAD_SAT" .emit OP_MAD_SAT;
854 <SWZ_instruction> ::= <SWZop> <maskedDstReg> ","
855 <srcReg> "," <extendedSwizzle>
858 <SWZ_instruction> ::= "SWZ" <maskedDstReg> "," <srcReg> ","
862 SWZop .and space_dst .and fp_maskedDstReg .and comma .and fp_srcReg .and comma .and
863 fp_extendedSwizzle .error EXT_SWIZ_COMP_EXPECTED;
865 "SWZ" .emit OP_SWZ .and space_dst .and vp_maskedDstReg .and comma .and vp_srcReg .and comma .and
866 vp_extendedSwizzle .error EXT_SWIZ_COMP_EXPECTED;
870 <SWZop> ::= "SWZ" | "SWZ_SAT"
873 "SWZ" .emit OP_SWZ .or "SWZ_SAT" .emit OP_SWZ_SAT;
877 <SAMPLE_instruction> ::= <SAMPLEop> <maskedDstReg> ","
878 <vectorSrcReg> "," <texImageUnit> ","
882 SAMPLEop .and space_dst .and fp_maskedDstReg .and comma .and vectorSrcReg .and comma .and
883 texImageUnit .and comma .and texTarget .error TEX_TARGET_EXPECTED;
887 <SAMPLEop> ::= "TEX" | "TEX_SAT"
892 "TEX" .emit OP_TEX .or "TEX_SAT" .emit OP_TEX_SAT .or
893 "TXB" .emit OP_TXB .or "TXB_SAT" .emit OP_TXB_SAT .or
894 "TXP" .emit OP_TXP .or "TXP_SAT" .emit OP_TXP_SAT;
898 <KIL_instruction> ::= "KIL" <vectorSrcReg>
901 "KIL" .emit OP_KIL .and space_src .and vectorSrcReg;
905 <texImageUnit> ::= "texture" <optTexImageUnitNum>
908 "texture" .error TEXTURE_EXPECTED .and optTexImageUnitNum;
917 | <shadowTarget> (if option ARB_fragment_program_shadow present)
918 | <arrayTarget> (if option MESA_texture_array present)
921 "1D" .emit TEXTARGET_1D .or
922 "2D" .emit TEXTARGET_2D .or
923 "3D" .emit TEXTARGET_3D .or
924 .if (texture_rectangle != 0x00) "RECT" .emit TEXTARGET_RECT .or
925 "CUBE" .emit TEXTARGET_CUBE .or
926 .if (ARB_fragment_program_shadow != 0x00) shadowTarget .or
927 .if (MESA_texture_array != 0x00) arrayTarget;
930 GL_ARB_fragment_program_shadow
931 <shadowTarget> ::= "SHADOW1D"
934 | <shadowArrayTarget> (if option MESA_texture_array present)
937 "SHADOW1D" .emit TEXTARGET_SHADOW1D .or
938 "SHADOW2D" .emit TEXTARGET_SHADOW2D .or
939 .if (texture_rectangle != 0x00) "SHADOWRECT" .emit TEXTARGET_SHADOWRECT .or
940 .if (MESA_texture_array != 0x00) shadowArrayTarget;
943 GL_MESA_texture_array
945 <arrayTarget> ::= "ARRAY1D"
948 <shadowArrayTarget> ::= "SHADOWARRAY1D"
953 "ARRAY1D" .emit TEXTARGET_1D_ARRAY .or
954 "ARRAY2D" .emit TEXTARGET_2D_ARRAY;
957 "SHADOWARRAY1D" .emit TEXTARGET_SHADOW1D_ARRAY .or
958 "SHADOWARRAY2D" .emit TEXTARGET_SHADOW2D_ARRAY;
962 <optTexImageUnitNum> ::= ""
963 | "[" <texImageUnitNum> "]"
966 optTexImageUnitNum_1 .or .true .emit 0x00;
968 lbracket_ne .and texImageUnitNum .and rbracket;
972 <texImageUnitNum> ::= <integer> from 0 to
973 MAX_TEXTURE_IMAGE_UNITS_ARB-1
979 <scalarSrcReg> ::= <optionalSign> <srcReg> <scalarSuffix>
982 optionalSign .and fp_srcReg .and fp_scalarSuffix;
984 optionalSign .and vp_srcReg .and vp_scalarSuffix;
988 <swizzleSrcReg> ::= <optionalSign> <srcReg> <swizzleSuffix>
991 optionalSign .and vp_srcReg .and swizzleSuffix;
995 <vectorSrcReg> ::= <optionalSign> <srcReg> <optionalSuffix>
998 optionalSign .and fp_srcReg .and optionalSuffix;
1001 <maskedDstReg> ::= <dstReg> <optionalMask>
1004 fp_dstReg .and fp_optionalMask;
1006 vp_dstReg .and vp_optionalMask;
1010 <maskedAddrReg> ::= <addrReg> <addrWriteMask>
1013 addrReg .error ADDRESS_REGISTER_EXPECTED .and addrWriteMask;
1017 <extendedSwizzle> ::= <xyzwExtendedSwizzle>
1018 | <rgbaExtendedSwizzle>
1021 <extendedSwizzle> ::= <extSwizComp> "," <extSwizComp> ","
1022 <extSwizComp> "," <extSwizComp>
1024 NOTE: do NOT change the order of <rgbaExtendedSwizzle> and <xyzwExtendedSwizzle> rulez
1027 rgbaExtendedSwizzle .or xyzwExtendedSwizzle;
1029 extSwizComp .and comma .and
1030 extSwizComp .error EXT_SWIZ_COMP_EXPECTED .and comma .and
1031 extSwizComp .error EXT_SWIZ_COMP_EXPECTED .and comma .and
1032 extSwizComp .error EXT_SWIZ_COMP_EXPECTED;
1036 <xyzwExtendedSwizzle> ::= <xyzwExtSwizComp> "," <xyzwExtSwizComp> ","
1037 <xyzwExtSwizComp> "," <xyzwExtSwizComp>
1040 xyzwExtSwizComp .and comma .and
1041 xyzwExtSwizComp .error EXT_SWIZ_COMP_EXPECTED .and comma .and
1042 xyzwExtSwizComp .error EXT_SWIZ_COMP_EXPECTED .and comma .and
1043 xyzwExtSwizComp .error EXT_SWIZ_COMP_EXPECTED;
1047 <rgbaExtendedSwizzle> ::= <rgbaExtSwizComp> "," <rgbaExtSwizComp> ","
1048 <rgbaExtSwizComp> "," <rgbaExtSwizComp>
1051 rgbaExtendedSwizzle_1 .or rgbaExtendedSwizzle_2 .or rgbaExtendedSwizzle_3 .or
1052 rgbaExtendedSwizzle_4;
1053 rgbaExtendedSwizzle_1
1054 rgbaExtSwizComp_digit .and comma .and rgbaExtSwizComp_digit .and comma .and
1055 rgbaExtSwizComp_digit .and comma .and rgbaExtSwizComp;
1056 rgbaExtendedSwizzle_2
1057 rgbaExtSwizComp_digit .and comma .and rgbaExtSwizComp_digit .and comma .and
1058 rgbaExtSwizComp_alpha .and comma .and rgbaExtSwizComp .error EXT_SWIZ_COMP_EXPECTED;
1059 rgbaExtendedSwizzle_3
1060 rgbaExtSwizComp_digit .and comma .and rgbaExtSwizComp_alpha .and comma .and
1061 rgbaExtSwizComp .error EXT_SWIZ_COMP_EXPECTED .and comma .and
1062 rgbaExtSwizComp .error EXT_SWIZ_COMP_EXPECTED;
1063 rgbaExtendedSwizzle_4
1064 rgbaExtSwizComp_alpha .and comma .and
1065 rgbaExtSwizComp .error EXT_SWIZ_COMP_EXPECTED .and comma .and
1066 rgbaExtSwizComp .error EXT_SWIZ_COMP_EXPECTED .and comma .and
1067 rgbaExtSwizComp .error EXT_SWIZ_COMP_EXPECTED;
1071 <xyzwExtSwizComp> ::= <optionalSign> <xyzwExtSwizSel>
1074 optionalSign .and xyzwExtSwizSel;
1078 <rgbaExtSwizComp> ::= <optionalSign> <rgbaExtSwizSel>
1081 optionalSign .and rgbaExtSwizSel;
1082 rgbaExtSwizComp_digit
1083 optionalSign .and rgbaExtSwizSel_digit;
1084 rgbaExtSwizComp_alpha
1085 optionalSign .and rgbaExtSwizSel_alpha;
1089 <extSwizComp> ::= <optionalSign> <extSwizSel>
1092 optionalSign .and extSwizSel;
1096 <xyzwExtSwizSel> ::= "0"
1101 "0" .emit COMPONENT_0 .or "1" .emit COMPONENT_1 .or xyzwComponent_single;
1105 <rgbaExtSwizSel> ::= "0"
1110 rgbaExtSwizSel_digit .or rgbaExtSwizSel_alpha;
1111 rgbaExtSwizSel_digit
1112 "0" .emit COMPONENT_0 .or "1" .emit COMPONENT_1;
1113 rgbaExtSwizSel_alpha
1114 rgbaComponent_single;
1118 <extSwizSel> ::= "0"
1123 "0" .emit COMPONENT_0 .or "1" .emit COMPONENT_1 .or vp_component_single;
1127 <srcReg> ::= <fragmentAttribReg>
1132 <srcReg> ::= <vertexAttribReg>
1137 fp_srcReg_1 .error SOURCE_REGISTER_EXPECTED;
1139 vp_srcReg_1 .error SOURCE_REGISTER_EXPECTED;
1141 fragmentAttribReg .emit REGISTER_ATTRIB .or
1142 fp_progParamReg .emit REGISTER_PARAM .or
1143 fp_temporaryReg .emit REGISTER_ESTABLISHED_NAME;
1145 vertexAttribReg .emit REGISTER_ATTRIB .or
1146 vp_progParamReg .emit REGISTER_PARAM .or
1147 vp_temporaryReg .emit REGISTER_ESTABLISHED_NAME;
1151 <dstReg> ::= <temporaryReg>
1152 | <fragmentResultReg>
1155 <dstReg> ::= <temporaryReg>
1159 fp_dstReg_1 .error DESTINATION_REGISTER_EXPECTED;
1161 vp_dstReg_1 .error DESTINATION_REGISTER_EXPECTED;
1163 fragmentResultReg .emit REGISTER_RESULT .or
1164 fp_temporaryReg .emit REGISTER_ESTABLISHED_NAME;
1166 vertexResultReg .emit REGISTER_RESULT .or
1167 vp_temporaryReg .emit REGISTER_ESTABLISHED_NAME;
1171 <fragmentAttribReg> ::= <establishedName>
1172 | <fragAttribBinding>
1174 NOTE: <establishedName> is driven by <temporaryReg> rule at the end of <srcReg>
1177 /*fp_establishedName .or */fragAttribBinding;
1181 <vertexAttribReg> ::= <establishedName>
1182 | <vtxAttribBinding>
1184 NOTE: <establishedName> is driven by <temporaryReg> rule at the end of <srcReg>
1190 <temporaryReg> ::= <establishedName>
1193 fp_establishedName_no_error_on_identifier;
1195 vp_establishedName_no_error_on_identifier;
1199 <progParamReg> ::= <progParamSingle>
1200 | <progParamArray> "[" <progParamArrayAbs> "]"
1201 | <paramSingleItemUse>
1204 <progParamReg> ::= <progParamSingle>
1205 | <progParamArray> "[" <progParamArrayMem> "]"
1206 | <paramSingleItemUse>
1209 fp_paramSingleItemUse .or fp_progParamReg_1 .or fp_progParamSingle;
1211 vp_paramSingleItemUse .or vp_progParamReg_1 .or vp_progParamSingle;
1213 fp_progParamArray .emit PARAM_ARRAY_ELEMENT .and lbracket_ne .and progParamArrayAbs .and
1216 vp_progParamArray .emit PARAM_ARRAY_ELEMENT .and lbracket_ne .and progParamArrayMem .and
1220 <progParamSingle> ::= <establishedName>
1222 NOTE: <establishedName> is driven by <temporaryReg> rule at the end of <srcReg>
1230 <progParamArray> ::= <establishedName>
1233 fp_establishedName_no_error_on_identifier;
1235 vp_establishedName_no_error_on_identifier;
1239 <progParamArrayMem> ::= <progParamArrayAbs>
1240 | <progParamArrayRel>
1243 progParamArrayAbs .or progParamArrayRel;
1246 <progParamArrayAbs> ::= <integer>
1249 integer_ne .emit ARRAY_INDEX_ABSOLUTE;
1253 <progParamArrayRel> ::= <addrReg> <addrComponent> <addrRegRelOffset>
1256 addrReg .error ADDRESS_REGISTER_OR_INTEGER_EXPECTED .emit ARRAY_INDEX_RELATIVE .and
1257 addrComponent .and addrRegRelOffset;
1261 <addrRegRelOffset> ::= ""
1262 | "+" <addrRegPosOffset>
1263 | "-" <addrRegNegOffset>
1266 addrRegRelOffset_1 .or addrRegRelOffset_2 .or .true .emit 0x00;
1268 plus_ne .and addrRegPosOffset;
1270 minus_ne .and addrRegNegOffset;
1274 <addrRegPosOffset> ::= <integer> from 0 to 63
1281 <addrRegNegOffset> ::= <integer> from 0 to 64
1288 <fragmentResultReg> ::= <establishedName>
1291 NOTE: <establishedName> is driven by <temporaryReg> rule at the end of <dstReg>
1298 <vertexResultReg> ::= <establishedName>
1301 NOTE: <establishedName> is driven by <temporaryReg> rule at the end of <dstReg>
1308 <addrReg> ::= <establishedName>
1311 vp_establishedName_no_error_on_identifier;
1315 <addrComponent> ::= "." "x"
1318 dot .and "x" .error INVALID_ADDRESS_COMPONENT .emit COMPONENT_X .emit COMPONENT_X
1319 .emit COMPONENT_X .emit COMPONENT_X;
1323 <addrWriteMask> ::= "." "x"
1326 dot .and "x" .error INVALID_ADDRESS_WRITEMASK .emit 0x08;
1329 <scalarSuffix> ::= "." <component>
1332 dot .and fp_component_single .error INVALID_COMPONENT;
1334 dot .and vp_component_single .error INVALID_COMPONENT;
1338 <swizzleSuffix> ::= ""
1340 | "." <component> <component>
1341 <component> <component>
1345 .true .emit COMPONENT_X .emit COMPONENT_Y .emit COMPONENT_Z .emit COMPONENT_W;
1347 dot_ne .and swizzleSuffix_2 .error INVALID_SUFFIX;
1349 swizzleSuffix_3 .or swizzleSuffix_4;
1351 vp_component_multi .and vp_component_multi .and vp_component_multi .error INVALID_COMPONENT .and
1352 vp_component_multi .error INVALID_COMPONENT;
1354 "x" .emit COMPONENT_X .emit COMPONENT_X .emit COMPONENT_X .emit COMPONENT_X .or
1355 "y" .emit COMPONENT_Y .emit COMPONENT_Y .emit COMPONENT_Y .emit COMPONENT_Y .or
1356 "z" .emit COMPONENT_Z .emit COMPONENT_Z .emit COMPONENT_Z .emit COMPONENT_Z .or
1357 "w" .emit COMPONENT_W .emit COMPONENT_W .emit COMPONENT_W .emit COMPONENT_W;
1361 <optionalSuffix> ::= ""
1363 | "." <xyzwComponent> <xyzwComponent>
1364 <xyzwComponent> <xyzwComponent>
1365 | "." <rgbaComponent> <rgbaComponent>
1366 <rgbaComponent> <rgbaComponent>
1369 optionalSuffix_1 .or
1370 .true .emit COMPONENT_X .emit COMPONENT_Y .emit COMPONENT_Z .emit COMPONENT_W;
1372 dot_ne .and optionalSuffix_2 .error INVALID_SUFFIX;
1374 optionalSuffix_3 .or optionalSuffix_4 .or optionalSuffix_5;
1376 xyzwComponent_multi .and xyzwComponent_multi .and
1377 xyzwComponent_multi .error INVALID_COMPONENT .and xyzwComponent_multi .error INVALID_COMPONENT;
1379 rgbaComponent_multi .and rgbaComponent_multi .and
1380 rgbaComponent_multi .error INVALID_COMPONENT .and rgbaComponent_multi .error INVALID_COMPONENT;
1382 "x" .emit COMPONENT_X .emit COMPONENT_X .emit COMPONENT_X .emit COMPONENT_X .or
1383 "y" .emit COMPONENT_Y .emit COMPONENT_Y .emit COMPONENT_Y .emit COMPONENT_Y .or
1384 "z" .emit COMPONENT_Z .emit COMPONENT_Z .emit COMPONENT_Z .emit COMPONENT_Z .or
1385 "w" .emit COMPONENT_W .emit COMPONENT_W .emit COMPONENT_W .emit COMPONENT_W .or
1386 "r" .emit COMPONENT_X .emit COMPONENT_X .emit COMPONENT_X .emit COMPONENT_X .or
1387 "g" .emit COMPONENT_Y .emit COMPONENT_Y .emit COMPONENT_Y .emit COMPONENT_Y .or
1388 "b" .emit COMPONENT_Z .emit COMPONENT_Z .emit COMPONENT_Z .emit COMPONENT_Z .or
1389 "a" .emit COMPONENT_W .emit COMPONENT_W .emit COMPONENT_W .emit COMPONENT_W;
1393 <component> ::= <xyzwComponent>
1403 xyzwComponent_single .or rgbaComponent_single;
1405 'x' .emit COMPONENT_X .or 'y' .emit COMPONENT_Y .or 'z' .emit COMPONENT_Z .or
1406 'w' .emit COMPONENT_W;
1408 "x" .emit COMPONENT_X .or "y" .emit COMPONENT_Y .or "z" .emit COMPONENT_Z .or
1409 "w" .emit COMPONENT_W;
1413 <xyzwComponent> ::= "x" | "y" | "z" | "w"
1416 'x' .emit COMPONENT_X .or 'y' .emit COMPONENT_Y .or 'z' .emit COMPONENT_Z .or
1417 'w' .emit COMPONENT_W;
1418 xyzwComponent_single
1419 "x" .emit COMPONENT_X .or "y" .emit COMPONENT_Y .or "z" .emit COMPONENT_Z .or
1420 "w" .emit COMPONENT_W;
1424 <rgbaComponent> ::= "r" | "g" | "b" | "a"
1427 'r' .emit COMPONENT_X .or 'g' .emit COMPONENT_Y .or 'b' .emit COMPONENT_Z .or
1428 'a' .emit COMPONENT_W;
1429 rgbaComponent_single
1430 "r" .emit COMPONENT_X .or "g" .emit COMPONENT_Y .or "b" .emit COMPONENT_Z .or
1431 "a" .emit COMPONENT_W;
1435 <optionalMask> ::= ""
1440 <optionalMask> ::= ""
1457 NOTE: do NOT change the order of <rgbaMask> and <xyzwMask> rulez
1460 rgbaMask .or xyzwMask .or .true .emit 0x0F;
1462 xyzwMask .or .true .emit 0x0F;
1466 <xyzwMask> ::= "." "x"
1482 NOTE: <xyzwMask> is also referenced by the vertex program symbol <optionalMask>.
1485 dot_ne .and xyzwMask_1 .error INVALID_WRITEMASK;
1487 "xyzw" .emit 0x0F .or "xyz" .emit 0x0E .or "xyw" .emit 0x0D .or "xy" .emit 0x0C .or
1488 "xzw" .emit 0x0B .or "xz" .emit 0x0A .or "xw" .emit 0x09 .or "x" .emit 0x08 .or
1489 "yzw" .emit 0x07 .or "yz" .emit 0x06 .or "yw" .emit 0x05 .or "y" .emit 0x04 .or
1490 "zw" .emit 0x03 .or "z" .emit 0x02 .or "w" .emit 0x01;
1494 <rgbaMask> ::= "." "r"
1511 dot_ne .and rgbaMask_1;
1513 "rgba" .emit 0x0F .or "rgb" .emit 0x0E .or "rga" .emit 0x0D .or "rg" .emit 0x0C .or
1514 "rba" .emit 0x0B .or "rb" .emit 0x0A .or "ra" .emit 0x09 .or "r" .emit 0x08 .or
1515 "gba" .emit 0x07 .or "gb" .emit 0x06 .or "ga" .emit 0x05 .or "g" .emit 0x04 .or
1516 "ba" .emit 0x03 .or "b" .emit 0x02 .or "a" .emit 0x01;
1520 <namingStatement> ::= <ATTRIB_statement>
1523 | <OUTPUT_statement>
1527 <namingStatement> ::= <ATTRIB_statement>
1530 | <ADDRESS_statement>
1531 | <OUTPUT_statement>
1535 fp_ATTRIB_statement .emit ATTRIB .or
1536 fp_PARAM_statement .emit PARAM .or
1537 fp_TEMP_statement .emit TEMP .or
1538 fp_OUTPUT_statement .emit OUTPUT .or
1539 fp_ALIAS_statement .emit ALIAS;
1541 vp_ATTRIB_statement .emit ATTRIB .or
1542 vp_PARAM_statement .emit PARAM .or
1543 vp_TEMP_statement .emit TEMP .or
1544 ADDRESS_statement .emit ADDRESS .or
1545 vp_OUTPUT_statement .emit OUTPUT .or
1546 vp_ALIAS_statement .emit ALIAS;
1550 <ATTRIB_statement> ::= "ATTRIB" <establishName> "="
1554 <ATTRIB_statement> ::= "ATTRIB" <establishName> "="
1558 "ATTRIB" .and space .and fp_establishName .and equal .and
1559 fragAttribBinding .error FRAGMENT_EXPECTED;
1561 "ATTRIB" .and space .and vp_establishName .and equal .and
1562 vtxAttribBinding .error VERTEX_EXPECTED;
1566 <fragAttribBinding> ::= "fragment" "." <fragAttribItem>
1569 "fragment" .and dot .and fragAttribItem .error INVALID_FRAGMENT_PROPERTY;
1573 <vtxAttribBinding> ::= "vertex" "." <vtxAttribItem>
1576 "vertex" .and dot .and vtxAttribItem .error INVALID_VERTEX_PROPERTY;
1580 <fragAttribItem> ::= "color" <optColorType>
1581 | "texcoord" <optTexCoordNum>
1586 fragAttribItem_1 .emit FRAGMENT_ATTRIB_COLOR .or
1587 fragAttribItem_2 .emit FRAGMENT_ATTRIB_TEXCOORD .or
1588 .if (fog_coord != 0x00) "fogcoord" .emit FRAGMENT_ATTRIB_FOGCOORD .or
1589 "position" .emit FRAGMENT_ATTRIB_POSITION;
1591 "color" .and optColorType;
1593 "texcoord" .and optTexCoordNum;
1597 <vtxAttribItem> ::= "position"
1598 | "weight" <vtxOptWeightNum>
1600 | "color" <optColorType>
1602 | "texcoord" <optTexCoordNum>
1603 | "matrixindex" "[" <vtxWeightNum> "]"
1604 | "attrib" "[" <vtxAttribNum> "]"
1607 "position" .emit VERTEX_ATTRIB_POSITION .or
1608 .if (vertex_blend != 0x00) vtxAttribItem_1 .emit VERTEX_ATTRIB_WEIGHT .or
1609 "normal" .emit VERTEX_ATTRIB_NORMAL .or
1610 vtxAttribItem_2 .emit VERTEX_ATTRIB_COLOR .or
1611 "fogcoord" .emit VERTEX_ATTRIB_FOGCOORD .or
1612 vtxAttribItem_3 .emit VERTEX_ATTRIB_TEXCOORD .or
1613 .if (matrix_palette != 0x00) vtxAttribItem_4 .emit VERTEX_ATTRIB_MATRIXINDEX .or
1614 vtxAttribItem_5 .emit VERTEX_ATTRIB_GENERIC;
1616 "weight" .and vtxOptWeightNum;
1618 "color" .and optColorType;
1620 "texcoord" .and optTexCoordNum;
1622 "matrixindex" .and lbracket .and vtxWeightNum .and rbracket;
1624 "attrib" .and lbracket .and vtxAttribNum .and rbracket;
1628 <vtxAttribNum> ::= <integer> from 0 to MAX_VERTEX_ATTRIBS_ARB-1
1635 <vtxOptWeightNum> ::= ""
1636 | "[" <vtxWeightNum> "]"
1639 vtxOptWeightNum_1 .or .true .emit 0x00;
1641 lbracket_ne .and vtxWeightNum .and rbracket;
1645 <vtxWeightNum> ::= <integer> from 0 to MAX_VERTEX_UNITS_ARB-1,
1646 must be divisible by four
1652 <PARAM_statement> ::= <PARAM_singleStmt>
1653 | <PARAM_multipleStmt>
1656 fp_PARAM_multipleStmt .or fp_PARAM_singleStmt;
1658 vp_PARAM_multipleStmt .or vp_PARAM_singleStmt;
1661 <PARAM_singleStmt> ::= "PARAM" <establishName> <paramSingleInit>
1664 "PARAM" .and space .and fp_establishName .and .true .emit 0x00 .and fp_paramSingleInit .and
1665 .true .emit PARAM_NULL;
1667 "PARAM" .and space .and vp_establishName .and .true .emit 0x00 .and vp_paramSingleInit .and
1668 .true .emit PARAM_NULL;
1671 <PARAM_multipleStmt> ::= "PARAM" <establishName> "[" <optArraySize> "]"
1674 fp_PARAM_multipleStmt
1675 "PARAM" .and space .and fp_establishName .and lbracket_ne .and optArraySize .and rbracket .and
1676 fp_paramMultipleInit .and .true .emit PARAM_NULL;
1677 vp_PARAM_multipleStmt
1678 "PARAM" .and space .and vp_establishName .and lbracket_ne .and optArraySize .and rbracket .and
1679 vp_paramMultipleInit .and .true .emit PARAM_NULL;
1682 <optArraySize> ::= ""
1683 | <integer> from 1 to MAX_PROGRAM_PARAMETERS_ARB
1684 (maximum number of allowed program
1691 <paramSingleInit> ::= "=" <paramSingleItemDecl>
1694 equal .and fp_paramSingleItemDecl;
1696 equal .and vp_paramSingleItemDecl;
1699 <paramMultipleInit> ::= "=" "{" <paramMultInitList> "}"
1701 fp_paramMultipleInit
1702 equal .and lbrace .and fp_paramMultInitList .and rbrace;
1703 vp_paramMultipleInit
1704 equal .and lbrace .and vp_paramMultInitList .and rbrace;
1707 <paramMultInitList> ::= <paramMultipleItem>
1708 | <paramMultipleItem> "," <paramMultiInitList>
1710 fp_paramMultInitList
1711 fp_paramMultInitList_1 .or fp_paramMultipleItem;
1712 vp_paramMultInitList
1713 vp_paramMultInitList_1 .or vp_paramMultipleItem;
1714 fp_paramMultInitList_1
1715 fp_paramMultipleItem .and comma_ne .and fp_paramMultInitList;
1716 vp_paramMultInitList_1
1717 vp_paramMultipleItem .and comma_ne .and vp_paramMultInitList;
1720 <paramSingleItemDecl> ::= <stateSingleItem>
1721 | <programSingleItem>
1724 fp_paramSingleItemDecl
1725 fp_stateSingleItem .emit PARAM_STATE_ELEMENT .or
1726 programSingleItem .emit PARAM_PROGRAM_ELEMENT .or
1727 paramConstDecl .emit PARAM_CONSTANT;
1728 vp_paramSingleItemDecl
1729 vp_stateSingleItem .emit PARAM_STATE_ELEMENT .or
1730 programSingleItem .emit PARAM_PROGRAM_ELEMENT .or
1731 paramConstDecl .emit PARAM_CONSTANT;
1734 <paramSingleItemUse> ::= <stateSingleItem>
1735 | <programSingleItem>
1738 fp_paramSingleItemUse
1739 fp_stateSingleItem .emit PARAM_STATE_ELEMENT .or
1740 programSingleItem .emit PARAM_PROGRAM_ELEMENT .or
1741 paramConstUse .emit PARAM_CONSTANT;
1742 vp_paramSingleItemUse
1743 vp_stateSingleItem .emit PARAM_STATE_ELEMENT .or
1744 programSingleItem .emit PARAM_PROGRAM_ELEMENT .or
1745 paramConstUse .emit PARAM_CONSTANT;
1748 <paramMultipleItem> ::= <stateMultipleItem>
1749 | <programMultipleItem>
1752 fp_paramMultipleItem
1753 fp_stateMultipleItem .emit PARAM_STATE_ELEMENT .or
1754 programMultipleItem .emit PARAM_PROGRAM_ELEMENT .or
1755 paramConstDecl .emit PARAM_CONSTANT;
1756 vp_paramMultipleItem
1757 vp_stateMultipleItem .emit PARAM_STATE_ELEMENT .or
1758 programMultipleItem .emit PARAM_PROGRAM_ELEMENT .or
1759 paramConstDecl .emit PARAM_CONSTANT;
1762 <stateMultipleItem> ::= <stateSingleItem>
1763 | "state" "." <stateMatrixRows>
1765 fp_stateMultipleItem
1766 stateMultipleItem_1 .or fp_stateSingleItem;
1767 vp_stateMultipleItem
1768 stateMultipleItem_1 .or vp_stateSingleItem;
1770 "state" .and dot .and stateMatrixRows .emit STATE_MATRIX_ROWS;
1774 <stateSingleItem> ::= "state" "." <stateMaterialItem>
1775 | "state" "." <stateLightItem>
1776 | "state" "." <stateLightModelItem>
1777 | "state" "." <stateLightProdItem>
1778 | "state" "." <stateTexEnvItem>
1779 | "state" "." <stateFogItem>
1780 | "state" "." <stateDepthItem>
1781 | "state" "." <stateMatrixRow>
1784 <stateSingleItem> ::= "state" "." <stateMaterialItem>
1785 | "state" "." <stateLightItem>
1786 | "state" "." <stateLightModelItem>
1787 | "state" "." <stateLightProdItem>
1788 | "state" "." <stateTexGenItem>
1789 | "state" "." <stateFogItem>
1790 | "state" "." <stateClipPlaneItem>
1791 | "state" "." <statePointItem>
1792 | "state" "." <stateMatrixRow>
1795 "state" .and dot .and fp_stateSingleItem_1 .error INVALID_STATE_PROPERTY;
1797 "state" .and dot .and vp_stateSingleItem_1 .error INVALID_STATE_PROPERTY;
1798 fp_stateSingleItem_1
1799 stateSingleItem_1 .or stateSingleItem_2 .or stateSingleItem_3 .or stateSingleItem_4 .or
1800 stateSingleItem_5 .or stateSingleItem_7 .or stateSingleItem_8 .or stateSingleItem_11;
1801 vp_stateSingleItem_1
1802 stateSingleItem_1 .or stateSingleItem_2 .or stateSingleItem_3 .or stateSingleItem_4 .or
1803 stateSingleItem_6 .or stateSingleItem_7 .or stateSingleItem_9 .or stateSingleItem_10 .or
1806 stateMaterialItem .emit STATE_MATERIAL;
1808 stateLightItem .emit STATE_LIGHT;
1810 stateLightModelItem .emit STATE_LIGHT_MODEL;
1812 stateLightProdItem .emit STATE_LIGHT_PROD;
1814 stateTexEnvItem .emit STATE_TEX_ENV;
1816 stateTexGenItem .emit STATE_TEX_GEN;
1818 stateFogItem .emit STATE_FOG;
1820 stateDepthItem .emit STATE_DEPTH;
1822 stateClipPlaneItem .emit STATE_CLIP_PLANE;
1824 statePointItem .emit STATE_POINT;
1826 stateMatrixRow .emit STATE_MATRIX_ROWS;
1829 <stateMaterialItem> ::= "material" <optFaceType> "." <stateMatProperty>
1832 "material" .and optFaceType .and dot .and stateMatProperty .error INVALID_MATERIAL_PROPERTY;
1835 <stateMatProperty> ::= "ambient"
1842 "ambient" .emit MATERIAL_AMBIENT .or
1843 "diffuse" .emit MATERIAL_DIFFUSE .or
1844 "specular" .emit MATERIAL_SPECULAR .or
1845 "emission" .emit MATERIAL_EMISSION .or
1846 "shininess" .emit MATERIAL_SHININESS;
1849 <stateLightItem> ::= "light" "[" <stateLightNumber> "]" "."
1850 <stateLightProperty>
1853 "light" .and lbracket .and stateLightNumber .and rbracket .and dot .and
1854 stateLightProperty .error INVALID_LIGHT_PROPERTY;
1857 <stateLightProperty> ::= "ambient"
1862 | "spot" "." <stateSpotProperty>
1866 "ambient" .emit LIGHT_AMBIENT .or
1867 "diffuse" .emit LIGHT_DIFFUSE .or
1868 "specular" .emit LIGHT_SPECULAR .or
1869 "position" .emit LIGHT_POSITION .or
1870 "attenuation" .emit LIGHT_ATTENUATION .or
1871 stateLightProperty_1 .emit LIGHT_SPOT_DIRECTION .or
1872 "half" .emit LIGHT_HALF;
1873 stateLightProperty_1
1874 "spot" .and dot .and stateSpotProperty .error INVALID_SPOT_PROPERTY;
1877 <stateSpotProperty> ::= "direction"
1883 <stateLightModelItem> ::= "lightmodel" <stateLModProperty>
1886 "lightmodel" .and stateLModProperty .error INVALID_LIGHTMODEL_PROPERTY;
1889 <stateLModProperty> ::= "." "ambient"
1890 | <optFaceType> "." "scenecolor"
1893 stateLModProperty_1 .or stateLModProperty_2;
1895 dot .and "ambient" .emit LIGHT_MODEL_AMBIENT;
1897 stateLModProperty_3 .emit LIGHT_MODEL_SCENECOLOR;
1899 optFaceType .and dot .and "scenecolor";
1902 <stateLightProdItem> ::= "lightprod" "[" <stateLightNumber> "]"
1903 <optFaceType> "." <stateLProdProperty>
1906 "lightprod" .and lbracket .and stateLightNumber .and rbracket .and optFaceType .and dot .and
1907 stateLProdProperty .error INVALID_LIGHTPROD_PROPERTY;
1910 <stateLProdProperty> ::= "ambient"
1915 "ambient" .emit LIGHT_PROD_AMBIENT .or
1916 "diffuse" .emit LIGHT_PROD_DIFFUSE .or
1917 "specular" .emit LIGHT_PROD_SPECULAR;
1920 <stateLightNumber> ::= <integer> from 0 to MAX_LIGHTS-1
1927 <stateTexEnvItem> ::= "texenv" <optLegacyTexUnitNum> "."
1928 <stateTexEnvProperty>
1931 "texenv" .and optLegacyTexUnitNum .and dot .and
1932 stateTexEnvProperty .error INVALID_TEXENV_PROPERTY;
1936 <stateTexEnvProperty> ::= "color"
1939 "color" .emit TEX_ENV_COLOR;
1943 <optLegacyTexUnitNum> ::= ""
1944 | "[" <legacyTexUnitNum> "]"
1947 optLegacyTexUnitNum_1 .or .true .emit 0x00;
1948 optLegacyTexUnitNum_1
1949 lbracket_ne .and legacyTexUnitNum .and rbracket;
1953 <legacyTexUnitNum> ::= <integer> from 0 to MAX_TEXTURE_UNITS-1
1960 <stateTexGenItem> ::= "texgen" <optTexCoordNum> "."
1961 <stateTexGenType> "." <stateTexGenCoord>
1964 "texgen" .and optTexCoordNum .and dot .and stateTexGenType .error INVALID_TEXGEN_PROPERTY .and
1965 dot .and stateTexGenCoord .error INVALID_TEXGEN_COORD;
1969 <stateTexGenType> ::= "eye"
1973 "eye" .emit TEX_GEN_EYE .or
1974 "object" .emit TEX_GEN_OBJECT;
1978 <stateTexGenCoord> ::= "s"
1984 "s" .emit COMPONENT_X .or
1985 "t" .emit COMPONENT_Y .or
1986 "r" .emit COMPONENT_Z .or
1987 "q" .emit COMPONENT_W;
1990 <stateFogItem> ::= "fog" "." <stateFogProperty>
1993 "fog" .and dot .and stateFogProperty .error INVALID_FOG_PROPERTY;
1996 <stateFogProperty> ::= "color"
2000 "color" .emit FOG_COLOR .or
2001 "params" .emit FOG_PARAMS;
2005 <stateDepthItem> ::= "depth" "." <stateDepthProperty>
2008 "depth" .and dot .and stateDepthProperty .error INVALID_DEPTH_PROPERTY;
2012 <stateDepthProperty> ::= "range"
2015 "range" .emit DEPTH_RANGE;
2019 <stateClipPlaneItem> ::= "clip" "[" <stateClipPlaneNum> "]" "." "plane"
2022 "clip" .and lbracket .and stateClipPlaneNum .and rbracket .and dot .and
2023 "plane" .error INVALID_CLIPPLANE_PROPERTY;
2027 <stateClipPlaneNum> ::= <integer> from 0 to MAX_CLIP_PLANES-1
2034 <statePointItem> ::= "point" "." <statePointProperty>
2037 "point" .and dot .and statePointProperty .error INVALID_POINT_PROPERTY;
2041 <statePointProperty> ::= "size"
2045 "size" .emit POINT_SIZE .or
2046 .if (point_parameters != 0x00) "attenuation" .emit POINT_ATTENUATION;
2049 <stateMatrixRow> ::= <stateMatrixItem> "." "row" "["
2050 <stateMatrixRowNum> "]"
2053 stateMatrixItem .and dot .and "row" .error MATRIX_ROW_SELECTOR_OR_MODIFIER_EXPECTED .and
2054 lbracket .and stateMatrixRowNum .and rbracket .emit 0x0;
2057 <stateMatrixRows> ::= <stateMatrixItem> <optMatrixRows>
2060 stateMatrixItem .and optMatrixRows;
2063 <optMatrixRows> ::= ""
2064 | "." "row" "[" <stateMatrixRowNum> ".."
2065 <stateMatrixRowNum> "]"
2068 optMatrixRows_1 .or .true .emit 0x0 .emit '3' .emit 0x0 .emit $;
2070 dot_ne .and "row" .error MATRIX_ROW_SELECTOR_OR_MODIFIER_EXPECTED .and lbracket .and
2071 stateMatrixRowNum .and dotdot .and stateMatrixRowNum .and rbracket;
2074 <stateMatrixItem> ::= "matrix" "." <stateMatrixName>
2075 <stateOptMatModifier>
2078 "matrix" .and dot .and stateMatrixName .error INVALID_MATRIX_NAME .and stateOptMatModifier;
2081 <stateOptMatModifier> ::= ""
2082 | "." <stateMatModifier>
2085 stateOptMatModifier_1 .or .true .emit MATRIX_MODIFIER_IDENTITY;
2086 stateOptMatModifier_1
2087 dot_ne .and stateMatModifier;
2090 <stateMatModifier> ::= "inverse"
2095 "inverse" .emit MATRIX_MODIFIER_INVERSE .or
2096 "transpose" .emit MATRIX_MODIFIER_TRANSPOSE .or
2097 "invtrans" .emit MATRIX_MODIFIER_INVTRANS;
2100 <stateMatrixRowNum> ::= <integer> from 0 to 3
2106 <stateMatrixName> ::= "modelview" <stateOptModMatNum>
2109 | "texture" <optTexCoordNum>
2110 | "palette" "[" <statePaletteMatNum> "]"
2111 | "program" "[" <stateProgramMatNum> "]"
2114 stateMatrixName_1_1 .emit MATRIX_MODELVIEW .or
2115 "projection" .emit MATRIX_PROJECTION .or
2116 "mvp" .emit MATRIX_MVP .or
2117 stateMatrixName_1_2 .emit MATRIX_TEXTURE .or
2118 .if (matrix_palette != 0x00) stateMatrixName_1_3 .emit MATRIX_PALETTE .or
2119 stateMatrixName_1_4 .emit MATRIX_PROGRAM;
2121 "modelview" .and stateOptModMatNum;
2123 "texture" .and optTexCoordNum;
2125 "palette" .and lbracket .and statePaletteMatNum .and rbracket;
2127 "program" .and lbracket .and stateProgramMatNum .and rbracket;
2130 <stateOptModMatNum> ::= ""
2131 | "[" <stateModMatNum> "]"
2134 .if (vertex_blend != 0x00) stateOptModMatNum_1 .or
2137 lbracket_ne .and stateModMatNum .and rbracket;
2140 <stateModMatNum> ::= <integer> from 0 to MAX_VERTEX_UNITS_ARB-1
2146 <optTexCoordNum> ::= ""
2147 | "[" <texCoordNum> "]"
2150 optTexCoordNum_1 .or .true .emit 0x00;
2152 lbracket_ne .and texCoordNum .and rbracket;
2155 <texCoordNum> ::= <integer> from 0 to MAX_TEXTURE_COORDS_ARB-1
2161 <statePaletteMatNum> ::= <integer> from 0 to MAX_PALETTE_MATRICES_ARB-1
2167 <stateProgramMatNum> ::= <integer> from 0 to MAX_PROGRAM_MATRICES_ARB-1
2173 <programSingleItem> ::= <progEnvParam>
2176 NOTE: <programSingleItem> has been modified for correct error handling. If program property
2177 is neither "env" nor "local" INVALID_PROGRAM_PROPERTY is generated.
2180 "program" .and dot .and programSingleItem_1 .error INVALID_PROGRAM_PROPERTY;
2182 progEnvParam .or progLocalParam;
2185 <programMultipleItem> ::= <progEnvParams>
2188 NOTE: <programMultipleItem> has been modified for correct error handling. If program property
2189 is neither "env" nor "local" INVALID_PROGRAM_PROPERTY is generated.
2192 "program" .and dot .and programMultipleItem_1 .error INVALID_PROGRAM_PROPERTY;
2193 programMultipleItem_1
2194 progEnvParams .or progLocalParams;
2197 <progEnvParams> ::= "program" "." "env"
2198 "[" <progEnvParamNums> "]"
2200 NOTE: "program" "." has been moved to <programMultipleItem>.
2203 "env" .emit PROGRAM_PARAM_ENV .and lbracket .and progEnvParamNums .and rbracket;
2206 <progEnvParamNums> ::= <progEnvParamNum>
2207 | <progEnvParamNum> ".." <progEnvParamNum>
2210 progEnvParamNums_1 .or progEnvParamNums_2;
2212 progEnvParamNum .and dotdot_ne .and progEnvParamNum;
2214 progEnvParamNum .and .true .emit 0x00;
2217 <progEnvParam> ::= "program" "." "env"
2218 "[" <progEnvParamNum> "]"
2220 NOTE: "program" "." has been moved to <programSingleItem>.
2223 "env" .emit PROGRAM_PARAM_ENV .and lbracket .and progEnvParamNum .and rbracket .emit 0x00;
2226 <progLocalParams> ::= "program" "." "local"
2227 "[" <progLocalParamNums> "]"
2229 NOTE: "program" "." has been moved to <programMultipleItem>.
2232 "local" .emit PROGRAM_PARAM_LOCAL .and lbracket .and progLocalParamNums .and rbracket;
2235 <progLocalParamNums> ::= <progLocalParamNum>
2236 | <progLocalParamNum> ".." <progLocalParamNum>
2239 progLocalParamNums_1 .or progLocalParamNums_2;
2240 progLocalParamNums_1
2241 progLocalParamNum .and dotdot_ne .and progLocalParamNum;
2242 progLocalParamNums_2
2243 progLocalParamNum .and .true .emit 0x00;
2246 <progLocalParam> ::= "program" "." "local"
2247 "[" <progLocalParamNum> "]"
2249 NOTE: "program" "." has been moved to <programSingleItem>.
2252 "local" .emit PROGRAM_PARAM_LOCAL .and lbracket .and progLocalParamNum .and rbracket .emit 0x00;
2255 <progEnvParamNum> ::= <integer> from 0 to
2256 MAX_PROGRAM_ENV_PARAMETERS_ARB - 1
2262 <progLocalParamNum> ::= <integer> from 0 to
2263 MAX_PROGRAM_LOCAL_PARAMETERS_ARB - 1
2269 <paramConstDecl> ::= <paramConstScalarDecl>
2270 | <paramConstVector>
2273 paramConstScalarDecl .emit CONSTANT_SCALAR .or paramConstVector .emit CONSTANT_VECTOR;
2276 <paramConstUse> ::= <paramConstScalarUse>
2277 | <paramConstVector>
2280 paramConstScalarUse .emit CONSTANT_SCALAR .or paramConstVector .emit CONSTANT_VECTOR;
2283 <paramConstScalarDecl> ::= <signedFloatConstant>
2285 paramConstScalarDecl
2286 signedFloatConstant;
2289 <paramConstScalarUse> ::= <floatConstant>
2295 <paramConstVector> ::= "{" <signedFloatConstant> "}"
2296 | "{" <signedFloatConstant> ","
2297 <signedFloatConstant> "}"
2298 | "{" <signedFloatConstant> ","
2299 <signedFloatConstant> ","
2300 <signedFloatConstant> "}"
2301 | "{" <signedFloatConstant> ","
2302 <signedFloatConstant> ","
2303 <signedFloatConstant> ","
2304 <signedFloatConstant> "}"
2307 paramConstVector_4 .emit 0x04 .or paramConstVector_3 .emit 0x03 .or
2308 paramConstVector_2 .emit 0x02 .or paramConstVector_1 .emit 0x01;
2310 lbrace_ne .and signedFloatConstant .and rbrace;
2312 lbrace_ne .and signedFloatConstant .and comma_ne .and signedFloatConstant .and rbrace;
2314 lbrace_ne .and signedFloatConstant .and comma_ne .and signedFloatConstant .and comma_ne .and
2315 signedFloatConstant .and rbrace;
2317 lbrace_ne .and signedFloatConstant .and comma_ne .and signedFloatConstant .and comma_ne .and
2318 signedFloatConstant .and comma_ne .and signedFloatConstant .and rbrace;
2321 <signedFloatConstant> ::= <optionalSign> <floatConstant>
2324 optionalSign .and floatConstant;
2327 <floatConstant> ::= see text
2328 The <floatConstant> rule matches a floating-point constant consisting
2329 of an integer part, a decimal point, a fraction part, an "e" or
2330 "E", and an optionally signed integer exponent. The integer and
2331 fraction parts both consist of a sequence of one or more digits ("0"
2332 through "9"). Either the integer part or the fraction parts (not
2333 both) may be missing; either the decimal point or the "e" (or "E")
2334 and the exponent (not both) may be missing.
2340 <optionalSign> ::= ""
2348 <TEMP_statement> ::= "TEMP" <varNameList>
2351 "TEMP" .and space .and fp_varNameList .and .true .emit 0x00;
2353 "TEMP" .and space .and vp_varNameList .and .true .emit 0x00;
2357 <ADDRESS_statement> ::= "ADDRESS" <varNameList>
2360 "ADDRESS" .and space .and vp_varNameList .and .true .emit 0x00;
2363 <varNameList> ::= <establishName>
2364 | <establishName> "," <varNameList>
2367 fp_varNameList_1 .or fp_establishName;
2369 vp_varNameList_1 .or vp_establishName;
2371 fp_establishName .and comma_ne .and fp_varNameList;
2373 vp_establishName .and comma_ne .and vp_varNameList;
2376 <OUTPUT_statement> ::= "OUTPUT" <establishName> "="
2380 "OUTPUT" .and space .and fp_establishName .and equal .and
2381 fp_resultBinding .error RESULT_EXPECTED;
2383 "OUTPUT" .and space .and vp_establishName .and equal .and
2384 vp_resultBinding .error RESULT_EXPECTED;
2388 <resultBinding> ::= "result" "." "color"
2389 | "result" "." "color" <optOutputColorNum> (if option ARB_draw_buffers present)
2390 | "result" "." "depth"
2393 <resultBinding> ::= "result" "." "position"
2394 | "result" "." <resultColBinding>
2395 | "result" "." "fogcoord"
2396 | "result" "." "pointsize"
2397 | "result" "." "texcoord" <optTexCoordNum>
2400 "result" .and dot .and fp_resultBinding_1 .error INVALID_RESULT_PROPERTY;
2402 "result" .and dot .and vp_resultBinding_1 .error INVALID_RESULT_PROPERTY;
2404 fp_resultBinding_2 .emit FRAGMENT_RESULT_COLOR .or
2405 "depth" .emit FRAGMENT_RESULT_DEPTH;
2407 "color" .and optOutputColorNum;
2409 .if (ARB_position_invariant == 0x00) "position" .emit VERTEX_RESULT_POSITION .or
2410 resultColBinding .emit VERTEX_RESULT_COLOR .or
2411 "fogcoord" .emit VERTEX_RESULT_FOGCOORD .or
2412 "pointsize" .emit VERTEX_RESULT_POINTSIZE .or
2413 vp_resultBinding_2 .emit VERTEX_RESULT_TEXCOORD;
2415 "texcoord" .and optTexCoordNum;
2419 <optOutputColorNum> ::= ""
2420 | "[" <outputColorNum> "]"
2423 .if (ARB_draw_buffers != 0x00) optOutputColorNum_1 .or .true .emit 0x00;
2425 lbracket_ne .and outputColorNum .and rbracket;
2429 <outputColorNum> ::= <integer> from 0 to MAX_DRAW_BUFFERS_ARB-1
2436 <resultColBinding> ::= "color" <optFaceType> <optColorType>
2439 "color" .and optFaceType .and optColorType;
2442 <optFaceType> ::= ""
2447 FaceType .or .true .emit FACE_FRONT;
2449 dot_ne .and FaceProperty;
2451 "front" .emit FACE_FRONT .or "back" .emit FACE_BACK;
2454 <optColorType> ::= ""
2459 ColorType .or .true .emit COLOR_PRIMARY;
2461 dot_ne .and ColorProperty;
2463 "primary" .emit COLOR_PRIMARY .or
2464 .if (secondary_color != 0x00) "secondary" .emit COLOR_SECONDARY;
2467 <ALIAS_statement> ::= "ALIAS" <establishName> "="
2471 "ALIAS" .and fp_ALIAS_statement_1 .error IDENTIFIER_EXPECTED .and equal .and fp_establishedName;
2473 "ALIAS" .and vp_ALIAS_statement_1 .error IDENTIFIER_EXPECTED .and equal .and vp_establishedName;
2474 fp_ALIAS_statement_1
2475 space .and fp_establishName;
2476 vp_ALIAS_statement_1
2477 space .and vp_establishName;
2480 <establishName> ::= <identifier>
2488 <establishedName> ::= <identifier>
2494 fp_establishedName_no_error_on_identifier
2496 vp_establishedName_no_error_on_identifier
2501 <identifier> ::= see text
2502 The <identifier> rule matches a sequence of one or more letters ("A"
2503 through "Z", "a" through "z"), digits ("0" through "9), underscores
2504 ("_"), or dollar signs ("$"); the first character must not be a
2505 number. Upper and lower case letters are considered different
2506 (names are case-sensitive). The following strings are reserved
2507 keywords and may not be used as identifiers:
2509 ABS, ABS_SAT, ADD, ADD_SAT, ALIAS, ATTRIB, CMP, CMP_SAT, COS,
2510 COS_SAT, DP3, DP3_SAT, DP4, DP4_SAT, DPH, DPH_SAT, DST, DST_SAT,
2511 END, EX2, EX2_SAT, FLR, FLR_SAT, FRC, FRC_SAT, KIL, LG2,
2512 LG2_SAT, LIT, LIT_SAT, LRP, LRP_SAT, MAD, MAD_SAT, MAX, MAX_SAT,
2513 MIN, MIN_SAT, MOV, MOV_SAT, MUL, MUL_SAT, OPTION, OUTPUT, PARAM,
2514 POW, POW_SAT, RCP, RCP_SAT, RSQ, RSQ_SAT, SIN, SIN_SAT, SCS,
2515 SCS_SAT, SGE, SGE_SAT, SLT, SLT_SAT, SUB, SUB_SAT, SWZ, SWZ_SAT,
2516 TEMP, TEX, TEX_SAT, TXB, TXB_SAT, TXP, TXP_SAT, XPD, XPD_SAT,
2517 fragment, program, result, state, and texture.
2520 <identifier> ::= see text
2521 The <identifier> rule matches a sequence of one or more letters ("A"
2522 through "Z", "a" through "z"), digits ("0" through "9), underscores ("_"),
2523 or dollar signs ("$"); the first character must not be a number. Upper
2524 and lower case letters are considered different (names are
2525 case-sensitive). The following strings are reserved keywords and may not
2526 be used as identifiers:
2528 ABS, ADD, ADDRESS, ALIAS, ARL, ATTRIB, DP3, DP4, DPH, DST, END, EX2,
2529 EXP, FLR, FRC, LG2, LIT, LOG, MAD, MAX, MIN, MOV, MUL, OPTION, OUTPUT,
2530 PARAM, POW, RCP, RSQ, SGE, SLT, SUB, SWZ, TEMP, XPD, program, result,
2534 fp_identifier_ne .error IDENTIFIER_EXPECTED;
2536 vp_identifier_ne .error IDENTIFIER_EXPECTED;
2538 fp_not_reserved_identifier .and identifier_ne;
2540 vp_not_reserved_identifier .and identifier_ne;
2542 fp_not_reserved_identifier
2543 fp_not_reserved_identifier_1 .or .true;
2544 fp_not_reserved_identifier_1
2545 fp_reserved_identifier .and .false .error RESERVED_KEYWORD;
2546 vp_not_reserved_identifier
2547 vp_not_reserved_identifier_1 .or .true;
2548 vp_not_reserved_identifier_1
2549 vp_reserved_identifier .and .false .error RESERVED_KEYWORD;
2551 fp_reserved_identifier
2552 "ABS" .or "ABS_SAT" .or "ADD" .or "ADD_SAT" .or "ALIAS" .or "ATTRIB" .or "CMP" .or "CMP_SAT" .or
2553 "COS" .or "COS_SAT" .or "DP3" .or "DP3_SAT" .or "DP4" .or "DP4_SAT" .or "DPH" .or "DPH_SAT" .or
2554 "DST" .or "DST_SAT" .or "END" .or "EX2" .or "EX2_SAT" .or "FLR" .or "FLR_SAT" .or "FRC" .or
2555 "FRC_SAT" .or "KIL" .or "LG2" .or "LG2_SAT" .or "LIT" .or "LIT_SAT" .or "LRP" .or "LRP_SAT" .or
2556 "MAD" .or "MAD_SAT" .or "MAX" .or "MAX_SAT" .or "MIN" .or "MIN_SAT" .or "MOV" .or "MOV_SAT" .or
2557 "MUL" .or "MUL_SAT" .or "OPTION" .or "OUTPUT" .or "PARAM" .or "POW" .or "POW_SAT" .or "RCP" .or
2558 "RCP_SAT" .or "RSQ" .or "RSQ_SAT" .or "SIN" .or "SIN_SAT" .or "SCS" .or "SCS_SAT" .or "SGE" .or
2559 "SGE_SAT" .or "SLT" .or "SLT_SAT" .or "SUB" .or "SUB_SAT" .or "SWZ" .or "SWZ_SAT" .or "TEMP" .or
2560 "TEX" .or "TEX_SAT" .or "TXB" .or "TXB_SAT" .or "TXP" .or "TXP_SAT" .or "XPD" .or "XPD_SAT" .or
2561 "fragment" .or "program" .or "result" .or "state" .or "texture";
2562 vp_reserved_identifier
2563 "ABS" .or "ADD" .or "ADDRESS" .or "ALIAS" .or "ARL" .or "ATTRIB" .or "DP3" .or "DP4" .or
2564 "DPH" .or "DST" .or "END" .or "EX2" .or "EXP" .or "FLR" .or "FRC" .or "LG2" .or "LIT" .or
2565 "LOG" .or "MAD" .or "MAX" .or "MIN" .or "MOV" .or "MUL" .or "OPTION" .or "OUTPUT" .or
2566 "PARAM" .or "POW" .or "RCP" .or "RSQ" .or "SGE" .or "SLT" .or "SUB" .or "SWZ" .or "TEMP" .or
2567 "XPD" .or "program" .or "result" .or "state" .or "vertex";
2570 The <integer> rule matches an integer constant. The integer consists
2571 of a sequence of one or more digits ("0" through "9").
2574 integer_ne .error INTEGER_EXPECTED;
2583 no_digit_1 .or .true;
2585 digit10 .and .false .error INTEGER_OUT_OF_RANGE;
2588 all_zeroes_1 .or no_digit_1;
2590 '0' .and .loop zero .and no_digit;
2593 integer_0_3_1 .error INTEGER_EXPECTED .and .true .emit 0x00 .emit $;
2595 integer_0_3_2 .or all_zeroes .emit '0';
2596 integer_0_3_2 /* [1, 3] */
2597 leading_zeroes .and '1'-'3' .emit * .and no_digit;
2600 integer_0_63_1 .error INTEGER_EXPECTED .and .true .emit 0x00 .emit $;
2602 integer_0_63_2 .or integer_0_63_3 .or integer_0_63_4 .or integer_0_63_5 .or
2603 all_zeroes .emit '0';
2604 integer_0_63_2 /* [7, 9] */
2605 leading_zeroes .and '7'-'9' .emit * .and no_digit;
2606 integer_0_63_3 /* [10, 59] */
2607 leading_zeroes .and '1'-'5' .emit * .and '0'-'9' .emit * .and no_digit;
2608 integer_0_63_4 /* [60, 63] */
2609 leading_zeroes .and '6' .emit * .and '0'-'3' .emit * .and no_digit;
2610 integer_0_63_5 /* [1, 6] */
2611 leading_zeroes .and '1'-'6' .emit * .and no_digit;
2614 integer_0_64_1 .error INTEGER_EXPECTED .and .true .emit 0x00 .emit $;
2616 integer_0_64_2 .or integer_0_64_3 .or integer_0_64_4 .or integer_0_64_5 .or
2617 all_zeroes .emit '0';
2618 integer_0_64_2 /* [7, 9] */
2619 leading_zeroes .and '7'-'9' .emit * .and no_digit;
2620 integer_0_64_3 /* [10, 59] */
2621 leading_zeroes .and '1'-'5' .emit * .and '0'-'9' .emit * .and no_digit;
2622 integer_0_64_4 /* [60, 64] */
2623 leading_zeroes .and '6' .emit * .and '0'-'4' .emit * .and no_digit;
2624 integer_0_64_5 /* [1, 6] */
2625 leading_zeroes .and '1'-'6' .emit * .and no_digit;
2631 space .error OPERATION_NEEDS_DESTINATION_VARIABLE;
2634 space .error OPERATION_NEEDS_SOURCE_VARIABLE;
2637 single_space .and .loop single_space;
2640 white_char .or comment_block;
2643 ' ' .or '\t' .or '\n' .or '\r';
2646 '#' .and .loop comment_char .and optional_new_line;
2648 /* All ASCII characters except '\r', '\n' and '\0' */
2650 '\x0E'-'\xFF' .or '\x01'-'\x09' .or '\x0B'-'\x0C';
2653 '\n' .or crlf .or .true;
2659 optional_space .and ';' .error MISSING_SEMICOLON .and optional_space;
2662 optional_space .and ',' .error MISSING_COMMA .and optional_space;
2665 optional_space .and ',' .and optional_space;
2668 optional_space .and '[' .error MISSING_LBRACKET .and optional_space;
2671 optional_space .and '[' .and optional_space;
2674 optional_space .and ']' .error MISSING_RBRACKET .and optional_space;
2677 optional_space .and '.' .error MISSING_DOT .and optional_space;
2680 optional_space .and '.' .and optional_space;
2683 optional_space .and '=' .error MISSING_EQUAL .and optional_space;
2686 optional_space .and '{' .error MISSING_LBRACE .and optional_space;
2689 optional_space .and '{' .and optional_space;
2692 optional_space .and '}' .error MISSING_RBRACE .and optional_space;
2695 optional_space .and '.' .and '.' .error MISSING_DOTDOT .and optional_space;
2698 optional_space .and '.' .and '.' .and optional_space;
2701 The definition below accepts the following floating point number formats:
2702 .99 .99e99 99. 99.99 99.99e99 99.e99 99e99
2703 Also 99 format was considered and accepted because of a large number of existing program
2704 strings with such a format.
2707 float_1 .or float_2 .or float_legacy;
2709 '.' .emit 0x00 .and integer_ne .error MISSING_FRACTION_OR_EXPONENT .and optional_exponent;
2711 integer_ne .and float_3;
2713 float_4 .or float_5;
2715 '.' .and optional_integer .and optional_exponent;
2717 exponent .emit 0x00;
2719 integer_ne .and .true .emit 0x00 .emit 0x00;
2722 Below is a correct version of <float> definiton.
2726 float_1 .or float_2;
2728 '.' .emit 0x00 .and integer_ne .error MISSING_FRACTION_OR_EXPONENT .and optional_exponent;
2730 integer_ne .and float_3 .error MISSING_DOT_OR_EXPONENT;
2732 float_4 .or float_5;
2734 '.' .and optional_integer .and optional_exponent;
2736 exponent .emit 0x00;
2740 integer_ne_1 .and .true .emit 0x00 .emit $;
2742 digit10 .emit * .and .loop digit10 .emit *;
2745 integer_ne .or .true .emit 0x00;
2748 NOTE: If exponent part is omited we treat it as if it was "E+1".
2751 exponent .or .true .emit 0x00;
2754 exponent_1 .and optional_sign_ne .and integer_ne .error EXPONENT_VALUE_EXPECTED;
2759 minus_ne .or plus_ne .or .true;
2762 optional_space .and '+' .and optional_space;
2765 optional_space .and '-' .emit '-' .and optional_space;
2768 first_idchar .emit * .and .loop follow_idchar .emit * .and .true .emit 0x00 .emit $;
2771 first_idchar .or digit10;
2774 'a'-'z' .or 'A'-'Z' .or '_' .or '$';
2780 string filtering - if a string is encountered in grammar ("blabla"), the symbol below is
2781 executed to create the string. The symbol must not throw any errors and emit bytes - it should
2782 stop if it encounters invalid character. After this the resulting string (from starting
2783 position up to the invalid character (but without it) is compared with the grammar string.
2785 .string __string_filter;
2788 .loop __identifier_char;
2791 'a'-'z' .or 'A'-'Z' .or '_' .or '$' .or '0'-'9';
2794 error token filtering
2797 e_signature_char .and .loop e_signature_char;
2799 '!' .or '.' .or 'A'-'Z' .or 'a'-'z' .or '0'-'9';
2802 .loop e_statement_not_term;
2803 /* All ASCII characters to one of '\r', '\n', '\0' and ';' */
2804 e_statement_not_term
2805 '\x3C'-'\xFF' .or '\x0E'-'\x3A' .or '\x01'-'\x09' .or '\x0B'-'\x0C';
2808 e_identifier_first .and .loop e_identifier_next;
2810 'a'-'z' .or 'A'-'Z' .or '_' .or '$';
2812 e_identifier_first .or '0'-'9';
2815 e_identifier .or e_token_number .or '[' .or ']' .or '.' .or '{' .or '}' .or '=' .or '+' .or
2816 '-' .or ',' .or ';';
2818 e_token_digit .and .loop e_token_digit;
2823 'A'-'Z' .or 'a'-'z' .or '0'-'9';