blob: a4e3a20222ed6197785cc268882dc2be9534bb4b [file] [log] [blame]
Michal Krola904b492004-03-04 13:07:52 +00001.syntax program;
2
3/*
4 This value must be incremented every time emit code values or structure of the production
5 array changes. This value is placed at the beginning of the production array. The loader
6 compares the value with its REVISION value. If they do not match, the loader is not up
7 to date.
8*/
Brian Paulbe76b7f2004-10-04 14:40:05 +00009.emtcode REVISION 0x08
Michal Krola904b492004-03-04 13:07:52 +000010
11/* program type */
12.emtcode FRAGMENT_PROGRAM 0x01
13.emtcode VERTEX_PROGRAM 0x02
14
15/* program section */
16.emtcode OPTION 0x01
17.emtcode INSTRUCTION 0x02
18.emtcode DECLARATION 0x03
19.emtcode END 0x04
20
21/* GL_ARB_fragment_program option flags */
22.emtcode ARB_PRECISION_HINT_FASTEST 0x01
23.emtcode ARB_PRECISION_HINT_NICEST 0x02
24.emtcode ARB_FOG_EXP 0x04
25.emtcode ARB_FOG_EXP2 0x08
26.emtcode ARB_FOG_LINEAR 0x10
27
28/* GL_ARB_vertex_program option flags */
29.emtcode ARB_POSITION_INVARIANT 0x20
30
31/* GL_ARB_fragment_program_shadow option flags */
32.emtcode ARB_FRAGMENT_PROGRAM_SHADOW 0x40
33
34/* GL_ARB_fragment_program instruction class */
35.emtcode OP_ALU_INST 0x00
36.emtcode OP_TEX_INST 0x01
37
38/* GL_ARB_vertex_program instruction class */
39/* OP_ALU_INST */
40
41/* GL_ARB_fragment_program instruction type */
42.emtcode OP_ALU_VECTOR 0x00
43.emtcode OP_ALU_SCALAR 0x01
44.emtcode OP_ALU_BINSC 0x02
45.emtcode OP_ALU_BIN 0x03
46.emtcode OP_ALU_TRI 0x04
47.emtcode OP_ALU_SWZ 0x05
48.emtcode OP_TEX_SAMPLE 0x06
49.emtcode OP_TEX_KIL 0x07
50
51/* GL_ARB_vertex_program instruction type */
52.emtcode OP_ALU_ARL 0x08
53/* OP_ALU_VECTOR */
54/* OP_ALU_SCALAR */
55/* OP_ALU_BINSC */
56/* OP_ALU_BIN */
57/* OP_ALU_TRI */
58/* OP_ALU_SWZ */
59
60/* GL_ARB_fragment_program instruction code */
61.emtcode OP_ABS 0x00
62.emtcode OP_ABS_SAT 0x1B
63.emtcode OP_FLR 0x09
64.emtcode OP_FLR_SAT 0x26
65.emtcode OP_FRC 0x0A
66.emtcode OP_FRC_SAT 0x27
67.emtcode OP_LIT 0x0C
68.emtcode OP_LIT_SAT 0x2A
69.emtcode OP_MOV 0x11
70.emtcode OP_MOV_SAT 0x30
71.emtcode OP_COS 0x1F
72.emtcode OP_COS_SAT 0x20
73.emtcode OP_EX2 0x07
74.emtcode OP_EX2_SAT 0x25
75.emtcode OP_LG2 0x0B
76.emtcode OP_LG2_SAT 0x29
77.emtcode OP_RCP 0x14
78.emtcode OP_RCP_SAT 0x33
79.emtcode OP_RSQ 0x15
80.emtcode OP_RSQ_SAT 0x34
81.emtcode OP_SIN 0x38
82.emtcode OP_SIN_SAT 0x39
83.emtcode OP_SCS 0x35
84.emtcode OP_SCS_SAT 0x36
85.emtcode OP_POW 0x13
86.emtcode OP_POW_SAT 0x32
87.emtcode OP_ADD 0x01
88.emtcode OP_ADD_SAT 0x1C
89.emtcode OP_DP3 0x03
90.emtcode OP_DP3_SAT 0x21
91.emtcode OP_DP4 0x04
92.emtcode OP_DP4_SAT 0x22
93.emtcode OP_DPH 0x05
94.emtcode OP_DPH_SAT 0x23
95.emtcode OP_DST 0x06
96.emtcode OP_DST_SAT 0x24
97.emtcode OP_MAX 0x0F
98.emtcode OP_MAX_SAT 0x2E
99.emtcode OP_MIN 0x10
100.emtcode OP_MIN_SAT 0x2F
101.emtcode OP_MUL 0x12
102.emtcode OP_MUL_SAT 0x31
103.emtcode OP_SGE 0x16
104.emtcode OP_SGE_SAT 0x37
105.emtcode OP_SLT 0x17
106.emtcode OP_SLT_SAT 0x3A
107.emtcode OP_SUB 0x18
108.emtcode OP_SUB_SAT 0x3B
109.emtcode OP_XPD 0x1A
110.emtcode OP_XPD_SAT 0x43
111.emtcode OP_CMP 0x1D
112.emtcode OP_CMP_SAT 0x1E
113.emtcode OP_LRP 0x2B
114.emtcode OP_LRP_SAT 0x2C
115.emtcode OP_MAD 0x0E
116.emtcode OP_MAD_SAT 0x2D
117.emtcode OP_SWZ 0x19
118.emtcode OP_SWZ_SAT 0x3C
119.emtcode OP_TEX 0x3D
120.emtcode OP_TEX_SAT 0x3E
121.emtcode OP_TXB 0x3F
122.emtcode OP_TXB_SAT 0x40
123.emtcode OP_TXP 0x41
124.emtcode OP_TXP_SAT 0x42
125.emtcode OP_KIL 0x28
126
127/* GL_ARB_vertex_program instruction code */
128.emtcode OP_ARL 0x02
129/* OP_ABS */
130/* OP_FLR */
131/* OP_FRC */
132/* OP_LIT */
133/* OP_MOV */
134/* OP_EX2 */
135.emtcode OP_EXP 0x08
136/* OP_LG2 */
137.emtcode OP_LOG 0x0D
138/* OP_RCP */
139/* OP_RSQ */
140/* OP_POW */
141/* OP_ADD */
142/* OP_DP3 */
143/* OP_DP4 */
144/* OP_DPH */
145/* OP_DST */
146/* OP_MAX */
147/* OP_MIN */
148/* OP_MUL */
149/* OP_SGE */
150/* OP_SLT */
151/* OP_SUB */
152/* OP_XPD */
153/* OP_MAD */
154/* OP_SWZ */
155
156/* fragment attribute binding */
157.emtcode FRAGMENT_ATTRIB_COLOR 0x01
158.emtcode FRAGMENT_ATTRIB_TEXCOORD 0x02
159.emtcode FRAGMENT_ATTRIB_FOGCOORD 0x03
160.emtcode FRAGMENT_ATTRIB_POSITION 0x04
161
162/* vertex attribute binding */
163.emtcode VERTEX_ATTRIB_POSITION 0x01
164.emtcode VERTEX_ATTRIB_WEIGHT 0x02
165.emtcode VERTEX_ATTRIB_NORMAL 0x03
166.emtcode VERTEX_ATTRIB_COLOR 0x04
167.emtcode VERTEX_ATTRIB_FOGCOORD 0x05
168.emtcode VERTEX_ATTRIB_TEXCOORD 0x06
169.emtcode VERTEX_ATTRIB_MATRIXINDEX 0x07
170.emtcode VERTEX_ATTRIB_GENERIC 0x08
171
172/* fragment result binding */
173.emtcode FRAGMENT_RESULT_COLOR 0x01
174.emtcode FRAGMENT_RESULT_DEPTH 0x02
175
176/* vertex result binding */
177.emtcode VERTEX_RESULT_POSITION 0x01
178.emtcode VERTEX_RESULT_COLOR 0x02
179.emtcode VERTEX_RESULT_FOGCOORD 0x03
180.emtcode VERTEX_RESULT_POINTSIZE 0x04
181.emtcode VERTEX_RESULT_TEXCOORD 0x05
182
183/* texture target */
184.emtcode TEXTARGET_1D 0x01
185.emtcode TEXTARGET_2D 0x02
186.emtcode TEXTARGET_3D 0x03
187.emtcode TEXTARGET_RECT 0x04
188.emtcode TEXTARGET_CUBE 0x05
189/* GL_ARB_fragment_program_shadow */
190.emtcode TEXTARGET_SHADOW1D 0x06
191.emtcode TEXTARGET_SHADOW2D 0x07
192.emtcode TEXTARGET_SHADOWRECT 0x08
193
194/* face type */
195.emtcode FACE_FRONT 0x00
196.emtcode FACE_BACK 0x01
197
198/* color type */
199.emtcode COLOR_PRIMARY 0x00
200.emtcode COLOR_SECONDARY 0x01
201
202/* component */
203.emtcode COMPONENT_X 0x00
204.emtcode COMPONENT_Y 0x01
205.emtcode COMPONENT_Z 0x02
206.emtcode COMPONENT_W 0x03
207.emtcode COMPONENT_0 0x04
208.emtcode COMPONENT_1 0x05
209
210/* array index type */
211.emtcode ARRAY_INDEX_ABSOLUTE 0x00
212.emtcode ARRAY_INDEX_RELATIVE 0x01
213
214/* matrix name */
215.emtcode MATRIX_MODELVIEW 0x01
216.emtcode MATRIX_PROJECTION 0x02
217.emtcode MATRIX_MVP 0x03
218.emtcode MATRIX_TEXTURE 0x04
219.emtcode MATRIX_PALETTE 0x05
220.emtcode MATRIX_PROGRAM 0x06
221
222/* matrix modifier */
223.emtcode MATRIX_MODIFIER_IDENTITY 0x00
224.emtcode MATRIX_MODIFIER_INVERSE 0x01
225.emtcode MATRIX_MODIFIER_TRANSPOSE 0x02
226.emtcode MATRIX_MODIFIER_INVTRANS 0x03
227
228/* constant type */
229.emtcode CONSTANT_SCALAR 0x01
230.emtcode CONSTANT_VECTOR 0x02
231
232/* program param type */
233.emtcode PROGRAM_PARAM_ENV 0x01
234.emtcode PROGRAM_PARAM_LOCAL 0x02
235
236/* register type */
237.emtcode REGISTER_ATTRIB 0x01
238.emtcode REGISTER_PARAM 0x02
239.emtcode REGISTER_RESULT 0x03
240.emtcode REGISTER_ESTABLISHED_NAME 0x04
241
242/* param binding */
243.emtcode PARAM_NULL 0x00
244.emtcode PARAM_ARRAY_ELEMENT 0x01
245.emtcode PARAM_STATE_ELEMENT 0x02
246.emtcode PARAM_PROGRAM_ELEMENT 0x03
247.emtcode PARAM_PROGRAM_ELEMENTS 0x04
248.emtcode PARAM_CONSTANT 0x05
249
250/* param state property */
251.emtcode STATE_MATERIAL 0x01
252.emtcode STATE_LIGHT 0x02
253.emtcode STATE_LIGHT_MODEL 0x03
254.emtcode STATE_LIGHT_PROD 0x04
255.emtcode STATE_FOG 0x05
256.emtcode STATE_MATRIX_ROWS 0x06
257/* GL_ARB_fragment_program */
258.emtcode STATE_TEX_ENV 0x07
259.emtcode STATE_DEPTH 0x08
260/* GL_ARB_vertex_program */
261.emtcode STATE_TEX_GEN 0x09
262.emtcode STATE_CLIP_PLANE 0x0A
263.emtcode STATE_POINT 0x0B
264
265/* state material property */
266.emtcode MATERIAL_AMBIENT 0x01
267.emtcode MATERIAL_DIFFUSE 0x02
268.emtcode MATERIAL_SPECULAR 0x03
269.emtcode MATERIAL_EMISSION 0x04
270.emtcode MATERIAL_SHININESS 0x05
271
272/* state light property */
273.emtcode LIGHT_AMBIENT 0x01
274.emtcode LIGHT_DIFFUSE 0x02
275.emtcode LIGHT_SPECULAR 0x03
276.emtcode LIGHT_POSITION 0x04
277.emtcode LIGHT_ATTENUATION 0x05
278.emtcode LIGHT_HALF 0x06
279.emtcode LIGHT_SPOT_DIRECTION 0x07
280
281/* state light model property */
282.emtcode LIGHT_MODEL_AMBIENT 0x01
283.emtcode LIGHT_MODEL_SCENECOLOR 0x02
284
285/* state light product property */
286.emtcode LIGHT_PROD_AMBIENT 0x01
287.emtcode LIGHT_PROD_DIFFUSE 0x02
288.emtcode LIGHT_PROD_SPECULAR 0x03
289
290/* state texture environment property */
291.emtcode TEX_ENV_COLOR 0x01
292
293/* state texture generation coord property */
294.emtcode TEX_GEN_EYE 0x01
295.emtcode TEX_GEN_OBJECT 0x02
296
297/* state fog property */
298.emtcode FOG_COLOR 0x01
299.emtcode FOG_PARAMS 0x02
300
301/* state depth property */
302.emtcode DEPTH_RANGE 0x01
303
304/* state point parameters property */
305.emtcode POINT_SIZE 0x01
306.emtcode POINT_ATTENUATION 0x02
307
308/* declaration */
309.emtcode ATTRIB 0x01
310.emtcode PARAM 0x02
311.emtcode TEMP 0x03
312.emtcode OUTPUT 0x04
313.emtcode ALIAS 0x05
314/* GL_ARB_vertex_program */
315.emtcode ADDRESS 0x06
316
317/* error messages */
318.errtext UNKNOWN_PROGRAM_SIGNATURE "1001: '$e_signature$': unknown program signature"
319.errtext MISSING_END_OR_INVALID_STATEMENT "1002: '$e_statement$': invalid statement"
320.errtext CODE_AFTER_END "1003: '$e_statement$': code after 'END' keyword"
321.errtext INVALID_PROGRAM_OPTION "1004: '$e_identifier$': invalid program option"
322.errtext EXT_SWIZ_COMP_EXPECTED "1005: extended swizzle component expected but '$e_token$' found"
323.errtext TEX_TARGET_EXPECTED "1006: texture target expected but '$e_token$' found"
324.errtext TEXTURE_EXPECTED "1007: 'texture' expected but '$e_identifier$' found"
325.errtext SOURCE_REGISTER_EXPECTED "1008: source register expected but '$e_token$' found"
326.errtext DESTINATION_REGISTER_EXPECTED "1009: destination register expected but '$e_token$' found"
327.errtext INVALID_ADDRESS_COMPONENT "1010: '$e_identifier$': invalid address component"
328.errtext INVALID_ADDRESS_WRITEMASK "1011: '$e_identifier$': invalid address writemask"
329.errtext INVALID_COMPONENT "1012: '$e_charordigit$': invalid component"
330.errtext INVALID_SUFFIX "1013: '$e_identifier$': invalid suffix"
331.errtext INVALID_WRITEMASK "1014: '$e_identifier$': invalid writemask"
332.errtext FRAGMENT_EXPECTED "1015: 'fragment' expected but '$e_identifier$' found"
333.errtext VERTEX_EXPECTED "1016: 'vertex' expected but '$e_identifier$' found"
334.errtext INVALID_FRAGMENT_PROPERTY "1017: '$e_identifier$': invalid fragment property"
335.errtext INVALID_VERTEX_PROPERTY "1018: '$e_identifier$': invalid vertex property"
336.errtext INVALID_STATE_PROPERTY "1019: '$e_identifier$': invalid state property"
337.errtext INVALID_MATERIAL_PROPERTY "1020: '$e_identifier$': invalid material property"
338.errtext INVALID_LIGHT_PROPERTY "1021: '$e_identifier$': invalid light property"
339.errtext INVALID_SPOT_PROPERTY "1022: '$e_identifier$': invalid spot property"
340.errtext INVALID_LIGHTMODEL_PROPERTY "1023: '$e_identifier$': invalid light model property"
341.errtext INVALID_LIGHTPROD_PROPERTY "1024: '$e_identifier$': invalid light product property"
342.errtext INVALID_TEXENV_PROPERTY "1025: '$e_identifier$': invalid texture environment property"
343.errtext INVALID_TEXGEN_PROPERTY "1026: '$e_identifier$': invalid texture generating property"
344.errtext INVALID_TEXGEN_COORD "1027: '$e_identifier$': invalid texture generating coord"
345.errtext INVALID_FOG_PROPERTY "1028: '$e_identifier$': invalid fog property"
346.errtext INVALID_DEPTH_PROPERTY "1029: '$e_identifier$': invalid depth property"
347.errtext INVALID_CLIPPLANE_PROPERTY "1030: '$e_identifier$': invalid clip plane property"
348.errtext INVALID_POINT_PROPERTY "1031: '$e_identifier$': invalid point property"
349.errtext MATRIX_ROW_SELECTOR_OR_MODIFIER_EXPECTED "1032: matrix row selector or modifier expected but '$e_token$' found"
350.errtext INVALID_MATRIX_NAME "1033: '$e_identifier$': invalid matrix name"
351.errtext INVALID_PROGRAM_PROPERTY "1034: '$e_identifier$': invalid program property"
352.errtext RESULT_EXPECTED "1035: 'result' expected but '$e_token$' found"
353.errtext INVALID_RESULT_PROPERTY "1036: '$e_identifier$': invalid result property"
354.errtext INVALID_FACE_PROPERTY "1037: '$e_identifier$': invalid face property"
355.errtext INVALID_COLOR_PROPERTY "1038: '$e_identifier$': invalid color property"
356.errtext IDENTIFIER_EXPECTED "1039: identifier expected but '$e_token$' found"
357.errtext RESERVED_KEYWORD "1040: use of reserved keyword as an identifier"
358.errtext INTEGER_EXPECTED "1041: integer value expected but '$e_token$' found"
359.errtext MISSING_SEMICOLON "1042: ';' expected but '$e_token$' found"
360.errtext MISSING_COMMA "1043: ',' expected but '$e_token$' found"
361.errtext MISSING_LBRACKET "1044: '[' expected but '$e_token$' found"
362.errtext MISSING_RBRACKET "1045: ']' expected but '$e_token$' found"
363.errtext MISSING_DOT "1046: '.' expected but '$e_token$' found"
364.errtext MISSING_EQUAL "1047: '=' expected but '$e_token$' found"
365.errtext MISSING_LBRACE "1048: '{' expected but '$e_token$' found"
366.errtext MISSING_RBRACE "1049: '}' expected but '$e_token$' found"
367.errtext MISSING_DOTDOT "1050: '..' expected but '$e_token$' found"
368.errtext MISSING_FRACTION_OR_EXPONENT "1051: missing fraction part or exponent"
369.errtext MISSING_DOT_OR_EXPONENT "1052: missing '.' or exponent"
370.errtext EXPONENT_VALUE_EXPECTED "1053: exponent value expected"
371.errtext INTEGER_OUT_OF_RANGE "1054: integer value out of range"
372.errtext OPERATION_NEEDS_DESTINATION_VARIABLE "1055: operation needs destination variable"
373.errtext OPERATION_NEEDS_SOURCE_VARIABLE "1056: operation needs source variable"
374.errtext ADDRESS_REGISTER_EXPECTED "1057: address register expected but '$e_token$' found"
375.errtext ADDRESS_REGISTER_OR_INTEGER_EXPECTED "1058: address register or integer literal expected but '$e_token$' found"
376
377/* extension presence condition registers */
378
379/* GL_ARB_vertex_blend */
380/* GL_EXT_vertex_weighting */
381.regbyte vertex_blend 0x00
382
383/* GL_ARB_matrix_palette */
384.regbyte matrix_palette 0x00
385
386/* GL_ARB_point_parameters */
387/* GL_EXT_point_parameters */
388.regbyte point_parameters 0x00
389
390/* GL_EXT_secondary_color */
391.regbyte secondary_color 0x00
392
393/* GL_EXT_fog_coord */
394.regbyte fog_coord 0x00
395
396/* GL_EXT_texture_rectangle */
397/* GL_NV_texture_rectangle */
398.regbyte texture_rectangle 0x00
399
400/* GL_ARB_fragment_program_shadow */
401.regbyte fragment_program_shadow 0x00
402
403/* option presence condition registers */
404/* they are all initially set to zero - when a particular OPTION is encountered, the appropriate */
405/* register is set to 1 to indicate that the OPTION was specified. */
406
407/* GL_ARB_fragment_program */
408.regbyte ARB_precision_hint_fastest 0x00
409.regbyte ARB_precision_hint_nicest 0x00
410.regbyte ARB_fog_exp 0x00
411.regbyte ARB_fog_exp2 0x00
412.regbyte ARB_fog_linear 0x00
413
414/* GL_ARB_vertex_program */
415.regbyte ARB_position_invariant 0x00
416
417/* GL_ARB_fragment_program_shadow */
418.regbyte ARB_fragment_program_shadow 0x00
419
420/* program target condition register */
421/* this syntax script deals with two program targets - VERTEX_PROGRAM and FRAGMENT_PROGRAM. */
422/* to distinguish between them we need a register that will store for us the current target. */
423/* the client will typically set the register to apropriate value before parsing a particular */
424/* program. the mapping between program targets and their values is listed below. */
425/* */
426/* program target register value */
427/* ---------------------------------------------- */
428/* FRAGMENT_PROGRAM 0x10 */
429/* VERTEX_PROGRAM 0x20 */
430/* */
431/* the initial value of the register is 0 to catch potential errors with not setting the register */
432/* with the proper value. */
433.regbyte program_target 0x00
434
435/*
436 <program> ::= <optionSequence> <statementSequence> "END"
437*/
438program
439 programs .error UNKNOWN_PROGRAM_SIGNATURE .emit REVISION;
440programs
441 .if (program_target == 0x10) frag_program_1_0 .emit FRAGMENT_PROGRAM .emit 0x01 .emit 0x00 .or
442 .if (program_target == 0x20) vert_program_1_0 .emit VERTEX_PROGRAM .emit 0x01 .emit 0x00;
443frag_program_1_0
444 '!' .and '!' .and 'A' .and 'R' .and 'B' .and 'f' .and 'p' .and '1' .and '.' .and '0' .and
445 optional_space .and fp_optionSequence .and fp_statementSequence .and
446 "END" .error MISSING_END_OR_INVALID_STATEMENT .emit END .and optional_space .and
447 '\0' .error CODE_AFTER_END;
448vert_program_1_0
449 '!' .and '!' .and 'A' .and 'R' .and 'B' .and 'v' .and 'p' .and '1' .and '.' .and '0' .and
450 optional_space .and vp_optionSequence .and vp_statementSequence .and
451 "END" .error MISSING_END_OR_INVALID_STATEMENT .emit END .and optional_space .and
452 '\0' .error CODE_AFTER_END;
453
454/*
455 <optionSequence> ::= <optionSequence> <option>
456 | ""
457*/
458fp_optionSequence
459 .loop fp_option;
460vp_optionSequence
461 .loop vp_option;
462
463/*
464 <option> ::= "OPTION" <identifier> ";"
465
466NOTE: options ARB_precision_hint_nicest and ARB_precision_hint_fastest are exclusive. When one of
467 these options is encountered, the other one is automatically disabled.
468 the same applies to options ARB_fog_exp, ARB_fog_exp2 and ARB_fog_linear.
469*/
470fp_option
471 "OPTION" .emit OPTION .and space .error IDENTIFIER_EXPECTED .and
472 fp_optionString .error INVALID_PROGRAM_OPTION .and semicolon;
473vp_option
474 "OPTION" .emit OPTION .and space .error IDENTIFIER_EXPECTED .and
475 vp_optionString .error INVALID_PROGRAM_OPTION .and semicolon;
476fp_optionString
477 .if (ARB_precision_hint_nicest == 0x00) "ARB_precision_hint_fastest"
478 .emit ARB_PRECISION_HINT_FASTEST .load ARB_precision_hint_fastest 0x01 .or
479 .if (ARB_precision_hint_fastest == 0x00) "ARB_precision_hint_nicest"
480 .emit ARB_PRECISION_HINT_NICEST .load ARB_precision_hint_nicest 0x01 .or
481 fp_ARB_fog_exp .emit ARB_FOG_EXP .load ARB_fog_exp 0x01 .or
482 fp_ARB_fog_exp2 .emit ARB_FOG_EXP2 .load ARB_fog_exp2 0x01 .or
483 fp_ARB_fog_linear .emit ARB_FOG_LINEAR .load ARB_fog_linear 0x01 .or
484 .if (fragment_program_shadow != 0x00) "ARB_fragment_program_shadow"
485 .emit ARB_FRAGMENT_PROGRAM_SHADOW .load ARB_fragment_program_shadow 0x01;
486vp_optionString
487 "ARB_position_invariant" .emit ARB_POSITION_INVARIANT .load ARB_position_invariant 0x01;
488fp_ARB_fog_exp
489 .if (ARB_fog_exp2 == 0x00) .true .and .if (ARB_fog_linear == 0x00) "ARB_fog_exp";
490fp_ARB_fog_exp2
491 .if (ARB_fog_exp == 0x00) .true .and .if (ARB_fog_linear == 0x00) "ARB_fog_exp2";
492fp_ARB_fog_linear
493 .if (ARB_fog_exp == 0x00) .true .and .if (ARB_fog_exp2 == 0x00) "ARB_fog_linear";
494
495/*
496 <statementSequence> ::= <statementSequence> <statement>
497 | ""
498*/
499fp_statementSequence
500 .loop fp_statement;
501vp_statementSequence
502 .loop vp_statement;
503
504/*
505 <statement> ::= <instruction> ";"
506 | <namingStatement> ";"
507
508NOTE: ".emit $" in the definitions below means that we output instruction position (offset of
509 the first character of instruction) for program debugging purposes.
510*/
511fp_statement
512 fp_statement_1 .or fp_statement_2;
513vp_statement
514 vp_statement_1 .or vp_statement_2;
515fp_statement_1
516 fp_instruction .emit INSTRUCTION .emit $ .and semicolon;
517fp_statement_2
518 fp_namingStatement .emit DECLARATION .and semicolon;
519vp_statement_1
520 vp_instruction .emit INSTRUCTION .emit $ .and semicolon;
521vp_statement_2
522 vp_namingStatement .emit DECLARATION .and semicolon;
523
524/*
525fragment program
526 <instruction> ::= <ALUInstruction>
527 | <TexInstruction>
528
529vertex program
530 <instruction> ::= <ARL_instruction>
531 | <VECTORop_instruction>
532 | <SCALARop_instruction>
533 | <BINSCop_instruction>
534 | <BINop_instruction>
535 | <TRIop_instruction>
536 | <SWZ_instruction>
537*/
538fp_instruction
539 ALUInstruction .emit OP_ALU_INST .or
540 TexInstruction .emit OP_TEX_INST;
541vp_instruction
542 ARL_instruction .emit OP_ALU_ARL .or
543 vp_VECTORop_instruction .emit OP_ALU_VECTOR .or
544 vp_SCALARop_instruction .emit OP_ALU_SCALAR .or
545 vp_BINSCop_instruction .emit OP_ALU_BINSC .or
546 vp_BINop_instruction .emit OP_ALU_BIN .or
547 vp_TRIop_instruction .emit OP_ALU_TRI .or
548 vp_SWZ_instruction .emit OP_ALU_SWZ;
549
550/*
551fragment program
552 <ALUInstruction> ::= <VECTORop_instruction>
553 | <SCALARop_instruction>
554 | <BINSCop_instruction>
555 | <BINop_instruction>
556 | <TRIop_instruction>
557 | <SWZ_instruction>
558*/
559ALUInstruction
560 fp_VECTORop_instruction .emit OP_ALU_VECTOR .or
561 fp_SCALARop_instruction .emit OP_ALU_SCALAR .or
562 fp_BINSCop_instruction .emit OP_ALU_BINSC .or
563 fp_BINop_instruction .emit OP_ALU_BIN .or
564 fp_TRIop_instruction .emit OP_ALU_TRI .or
565 fp_SWZ_instruction .emit OP_ALU_SWZ;
566
567/*
568fragment program
569 <TexInstruction> ::= <SAMPLE_instruction>
570 | <KIL_instruction>
571*/
572TexInstruction
573 SAMPLE_instruction .emit OP_TEX_SAMPLE .or
574 KIL_instruction .emit OP_TEX_KIL;
575
576/*
577vertex program
578 <ARL_instruction> ::= "ARL" <maskedAddrReg> "," <scalarSrcReg>
579*/
580ARL_instruction
581 "ARL" .emit OP_ARL .and space_dst .and maskedAddrReg .and comma .and vp_scalarSrcReg;
582
583/*
584fragment program
585 <VECTORop_instruction> ::= <VECTORop> <maskedDstReg> ","
586 <vectorSrcReg>
587
588vertex program
589 <VECTORop_instruction> ::= <VECTORop> <maskedDstReg> "," <swizzleSrcReg>
590*/
591fp_VECTORop_instruction
592 fp_VECTORop .and space_dst .and fp_maskedDstReg .and comma .and vectorSrcReg;
593vp_VECTORop_instruction
594 vp_VECTORop .and space_dst .and vp_maskedDstReg .and comma .and swizzleSrcReg;
595
596/*
597fragment program
598 <VECTORop> ::= "ABS" | "ABS_SAT"
599 | "FLR" | "FLR_SAT"
600 | "FRC" | "FRC_SAT"
601 | "LIT" | "LIT_SAT"
602 | "MOV" | "MOV_SAT"
603
604vertex program
605 <VECTORop> ::= "ABS"
606 | "FLR"
607 | "FRC"
608 | "LIT"
609 | "MOV"
610*/
611fp_VECTORop
612 "ABS" .emit OP_ABS .or "ABS_SAT" .emit OP_ABS_SAT .or
613 "FLR" .emit OP_FLR .or "FLR_SAT" .emit OP_FLR_SAT .or
614 "FRC" .emit OP_FRC .or "FRC_SAT" .emit OP_FRC_SAT .or
615 "LIT" .emit OP_LIT .or "LIT_SAT" .emit OP_LIT_SAT .or
616 "MOV" .emit OP_MOV .or "MOV_SAT" .emit OP_MOV_SAT;
617vp_VECTORop
618 "ABS" .emit OP_ABS .or
619 "FLR" .emit OP_FLR .or
620 "FRC" .emit OP_FRC .or
621 "LIT" .emit OP_LIT .or
622 "MOV" .emit OP_MOV;
623
624/*
625 <SCALARop_instruction> ::= <SCALARop> <maskedDstReg> "," <scalarSrcReg>
626*/
627fp_SCALARop_instruction
628 fp_SCALARop .and space_dst .and fp_maskedDstReg .and comma .and fp_scalarSrcReg;
629vp_SCALARop_instruction
630 vp_SCALARop .and space_dst .and vp_maskedDstReg .and comma .and vp_scalarSrcReg;
631
632/*
633fragment program
634 <SCALARop> ::= "COS" | "COS_SAT"
635 | "EX2" | "EX2_SAT"
636 | "LG2" | "LG2_SAT"
637 | "RCP" | "RCP_SAT"
638 | "RSQ" | "RSQ_SAT"
639 | "SIN" | "SIN_SAT"
640 | "SCS" | "SCS_SAT"
641
642vertex program
643 <SCALARop> ::= "EX2"
644 | "EXP"
645 | "LG2"
646 | "LOG"
647 | "RCP"
648 | "RSQ"
649*/
650fp_SCALARop
651 "COS" .emit OP_COS .or "COS_SAT" .emit OP_COS_SAT .or
652 "EX2" .emit OP_EX2 .or "EX2_SAT" .emit OP_EX2_SAT .or
653 "LG2" .emit OP_LG2 .or "LG2_SAT" .emit OP_LG2_SAT .or
654 "RCP" .emit OP_RCP .or "RCP_SAT" .emit OP_RCP_SAT .or
655 "RSQ" .emit OP_RSQ .or "RSQ_SAT" .emit OP_RSQ_SAT .or
656 "SIN" .emit OP_SIN .or "SIN_SAT" .emit OP_SIN_SAT .or
657 "SCS" .emit OP_SCS .or "SCS_SAT" .emit OP_SCS_SAT;
658vp_SCALARop
659 "EX2" .emit OP_EX2 .or
660 "EXP" .emit OP_EXP .or
661 "LG2" .emit OP_LG2 .or
662 "LOG" .emit OP_LOG .or
663 "RCP" .emit OP_RCP .or
664 "RSQ" .emit OP_RSQ;
665
666/*
667 <BINSCop_instruction> ::= <BINSCop> <maskedDstReg> "," <scalarSrcReg> ","
668 <scalarSrcReg>
669*/
670fp_BINSCop_instruction
671 fp_BINSCop .and space_dst .and fp_maskedDstReg .and comma .and fp_scalarSrcReg .and comma .and
672 fp_scalarSrcReg;
673vp_BINSCop_instruction
674 vp_BINSCop .and space_dst .and vp_maskedDstReg .and comma .and vp_scalarSrcReg .and comma .and
675 vp_scalarSrcReg;
676
677/*
678fragment program
679 <BINSCop> ::= "POW" | "POW_SAT"
680
681vertex program
682 <BINSCop> ::= "POW"
683*/
684fp_BINSCop
685 "POW" .emit OP_POW .or "POW_SAT" .emit OP_POW_SAT;
686vp_BINSCop
687 "POW" .emit OP_POW;
688
689/*
690fragment program
691 <BINop_instruction> ::= <BINop> <maskedDstReg> ","
692 <vectorSrcReg> "," <vectorSrcReg>
693
694vertex program
695 <BINop_instruction> ::= <BINop> <maskedDstReg> ","
696 <swizzleSrcReg> "," <swizzleSrcReg>
697*/
698fp_BINop_instruction
699 fp_BINop .and space_dst .and fp_maskedDstReg .and comma .and vectorSrcReg .and comma .and
700 vectorSrcReg;
701vp_BINop_instruction
702 vp_BINop .and space_dst .and vp_maskedDstReg .and comma .and swizzleSrcReg .and comma .and
703 swizzleSrcReg;
704
705/*
706fragment program
707 <BINop> ::= "ADD" | "ADD_SAT"
708 | "DP3" | "DP3_SAT"
709 | "DP4" | "DP4_SAT"
710 | "DPH" | "DPH_SAT"
711 | "DST" | "DST_SAT"
712 | "MAX" | "MAX_SAT"
713 | "MIN" | "MIN_SAT"
714 | "MUL" | "MUL_SAT"
715 | "SGE" | "SGE_SAT"
716 | "SLT" | "SLT_SAT"
717 | "SUB" | "SUB_SAT"
718 | "XPD" | "XPD_SAT"
719
720vertex program
721 <BINop> ::= "ADD"
722 | "DP3"
723 | "DP4"
724 | "DPH"
725 | "DST"
726 | "MAX"
727 | "MIN"
728 | "MUL"
729 | "SGE"
730 | "SLT"
731 | "SUB"
732 | "XPD"
733*/
734fp_BINop
735 "ADD" .emit OP_ADD .or "ADD_SAT" .emit OP_ADD_SAT .or
736 "DP3" .emit OP_DP3 .or "DP3_SAT" .emit OP_DP3_SAT .or
737 "DP4" .emit OP_DP4 .or "DP4_SAT" .emit OP_DP4_SAT .or
738 "DPH" .emit OP_DPH .or "DPH_SAT" .emit OP_DPH_SAT .or
739 "DST" .emit OP_DST .or "DST_SAT" .emit OP_DST_SAT .or
740 "MAX" .emit OP_MAX .or "MAX_SAT" .emit OP_MAX_SAT .or
741 "MIN" .emit OP_MIN .or "MIN_SAT" .emit OP_MIN_SAT .or
742 "MUL" .emit OP_MUL .or "MUL_SAT" .emit OP_MUL_SAT .or
743 "SGE" .emit OP_SGE .or "SGE_SAT" .emit OP_SGE_SAT .or
744 "SLT" .emit OP_SLT .or "SLT_SAT" .emit OP_SLT_SAT .or
745 "SUB" .emit OP_SUB .or "SUB_SAT" .emit OP_SUB_SAT .or
746 "XPD" .emit OP_XPD .or "XPD_SAT" .emit OP_XPD_SAT;
747vp_BINop
748 "ADD" .emit OP_ADD .or
749 "DP3" .emit OP_DP3 .or
750 "DP4" .emit OP_DP4 .or
751 "DPH" .emit OP_DPH .or
752 "DST" .emit OP_DST .or
753 "MAX" .emit OP_MAX .or
754 "MIN" .emit OP_MIN .or
755 "MUL" .emit OP_MUL .or
756 "SGE" .emit OP_SGE .or
757 "SLT" .emit OP_SLT .or
758 "SUB" .emit OP_SUB .or
759 "XPD" .emit OP_XPD;
760
761/*
762fragment program
763 <TRIop_instruction> ::= <TRIop> <maskedDstReg> ","
764 <vectorSrcReg> "," <vectorSrcReg> ","
765 <vectorSrcReg>
766
767vertex program
768 <TRIop_instruction> ::= <TRIop> <maskedDstReg> ","
769 <swizzleSrcReg> "," <swizzleSrcReg> ","
770 <swizzleSrcReg>
771*/
772fp_TRIop_instruction
773 fp_TRIop .and space_dst .and fp_maskedDstReg .and comma .and vectorSrcReg .and comma .and
774 vectorSrcReg .and comma .and vectorSrcReg;
775vp_TRIop_instruction
776 vp_TRIop .and space_dst .and vp_maskedDstReg .and comma .and swizzleSrcReg .and comma .and
777 swizzleSrcReg .and comma .and swizzleSrcReg;
778
779/*
780fragment program
781 <TRIop> ::= "CMP" | "CMP_SAT"
782 | "LRP" | "LRP_SAT"
783 | "MAD" | "MAD_SAT"
784
785vertex program
786 <TRIop> ::= "MAD"
787*/
788fp_TRIop
789 "CMP" .emit OP_CMP .or "CMP_SAT" .emit OP_CMP_SAT .or
790 "LRP" .emit OP_LRP .or "LRP_SAT" .emit OP_LRP_SAT .or
791 "MAD" .emit OP_MAD .or "MAD_SAT" .emit OP_MAD_SAT;
792vp_TRIop
793 "MAD" .emit OP_MAD;
794
795/*
796fragment program
797 <SWZ_instruction> ::= <SWZop> <maskedDstReg> ","
798 <srcReg> "," <extendedSwizzle>
799
800vertex program
801 <SWZ_instruction> ::= "SWZ" <maskedDstReg> "," <srcReg> ","
802 <extendedSwizzle>
803*/
804fp_SWZ_instruction
805 SWZop .and space_dst .and fp_maskedDstReg .and comma .and fp_srcReg .and comma .and
806 fp_extendedSwizzle .error EXT_SWIZ_COMP_EXPECTED;
807vp_SWZ_instruction
808 "SWZ" .emit OP_SWZ .and space_dst .and vp_maskedDstReg .and comma .and vp_srcReg .and comma .and
809 vp_extendedSwizzle .error EXT_SWIZ_COMP_EXPECTED;
810
811/*
812fragment program
813 <SWZop> ::= "SWZ" | "SWZ_SAT"
814*/
815SWZop
816 "SWZ" .emit OP_SWZ .or "SWZ_SAT" .emit OP_SWZ_SAT;
817
818/*
819fragment program
820 <SAMPLE_instruction> ::= <SAMPLEop> <maskedDstReg> ","
821 <vectorSrcReg> "," <texImageUnit> ","
822 <texTarget>
823*/
824SAMPLE_instruction
825 SAMPLEop .and space_dst .and fp_maskedDstReg .and comma .and vectorSrcReg .and comma .and
826 texImageUnit .and comma .and texTarget .error TEX_TARGET_EXPECTED;
827
828/*
829fragment program
830 <SAMPLEop> ::= "TEX" | "TEX_SAT"
831 | "TXP" | "TXP_SAT"
832 | "TXB" | "TXB_SAT"
833*/
834SAMPLEop
835 "TEX" .emit OP_TEX .or "TEX_SAT" .emit OP_TEX_SAT .or
836 "TXB" .emit OP_TXB .or "TXB_SAT" .emit OP_TXB_SAT .or
837 "TXP" .emit OP_TXP .or "TXP_SAT" .emit OP_TXP_SAT;
838
839/*
840fragment program
841 <KIL_instruction> ::= "KIL" <vectorSrcReg>
842*/
843KIL_instruction
844 "KIL" .emit OP_KIL .and space_src .and vectorSrcReg;
845
846/*
847fragment program
848 <texImageUnit> ::= "texture" <optTexImageUnitNum>
849*/
850texImageUnit
851 "texture" .error TEXTURE_EXPECTED .and optTexImageUnitNum;
852
853/*
854fragment program
855 <texTarget> ::= "1D"
856 | "2D"
857 | "3D"
858 | "CUBE"
859 | "RECT"
860 | <shadowTarget> (if option ARB_fragment_program_shadow present)
861*/
862texTarget
863 "1D" .emit TEXTARGET_1D .or
864 "2D" .emit TEXTARGET_2D .or
865 "3D" .emit TEXTARGET_3D .or
866 .if (texture_rectangle != 0x00) "RECT" .emit TEXTARGET_RECT .or
867 "CUBE" .emit TEXTARGET_CUBE .or
868 .if (ARB_fragment_program_shadow != 0x00) shadowTarget;
869
870/*
871GL_ARB_fragment_program_shadow
872 <shadowTarget> ::= "SHADOW1D"
873 | "SHADOW2D"
874 | "SHADOWRECT"
875*/
876shadowTarget
877 "SHADOW1D" .emit TEXTARGET_SHADOW1D .or
878 "SHADOW2D" .emit TEXTARGET_SHADOW2D .or
879 .if (texture_rectangle != 0x00) "SHADOWRECT" .emit TEXTARGET_SHADOWRECT;
880
881/*
882fragment program
883 <optTexImageUnitNum> ::= ""
884 | "[" <texImageUnitNum> "]"
885*/
886optTexImageUnitNum
887 optTexImageUnitNum_1 .or .true .emit 0x00;
888optTexImageUnitNum_1
889 lbracket_ne .and texImageUnitNum .and rbracket;
890
891/*
892fragment program
893 <texImageUnitNum> ::= <integer> from 0 to
894 MAX_TEXTURE_IMAGE_UNITS_ARB-1
895*/
896texImageUnitNum
897 integer;
898
899/*
900 <scalarSrcReg> ::= <optionalSign> <srcReg> <scalarSuffix>
901*/
902fp_scalarSrcReg
903 optionalSign .and fp_srcReg .and fp_scalarSuffix;
904vp_scalarSrcReg
905 optionalSign .and vp_srcReg .and vp_scalarSuffix;
906
907/*
908vertex program
909 <swizzleSrcReg> ::= <optionalSign> <srcReg> <swizzleSuffix>
910*/
911swizzleSrcReg
912 optionalSign .and vp_srcReg .and swizzleSuffix;
913
914/*
915fragment program
916 <vectorSrcReg> ::= <optionalSign> <srcReg> <optionalSuffix>
917*/
918vectorSrcReg
919 optionalSign .and fp_srcReg .and optionalSuffix;
920
921/*
922 <maskedDstReg> ::= <dstReg> <optionalMask>
923*/
924fp_maskedDstReg
925 fp_dstReg .and fp_optionalMask;
926vp_maskedDstReg
927 vp_dstReg .and vp_optionalMask;
928
929/*
930vertex program
931 <maskedAddrReg> ::= <addrReg> <addrWriteMask>
932*/
933maskedAddrReg
934 addrReg .error ADDRESS_REGISTER_EXPECTED .and addrWriteMask;
935
936/*
937fragment program
938 <extendedSwizzle> ::= <xyzwExtendedSwizzle>
939 | <rgbaExtendedSwizzle>
940
941vertex program
942 <extendedSwizzle> ::= <extSwizComp> "," <extSwizComp> ","
943 <extSwizComp> "," <extSwizComp>
944
945NOTE: do NOT change the order of <rgbaExtendedSwizzle> and <xyzwExtendedSwizzle> rulez
946*/
947fp_extendedSwizzle
948 rgbaExtendedSwizzle .or xyzwExtendedSwizzle;
949vp_extendedSwizzle
950 extSwizComp .and comma .and
951 extSwizComp .error EXT_SWIZ_COMP_EXPECTED .and comma .and
952 extSwizComp .error EXT_SWIZ_COMP_EXPECTED .and comma .and
953 extSwizComp .error EXT_SWIZ_COMP_EXPECTED;
954
955/*
956fragment program
957 <xyzwExtendedSwizzle> ::= <xyzwExtSwizComp> "," <xyzwExtSwizComp> ","
958 <xyzwExtSwizComp> "," <xyzwExtSwizComp>
959*/
960xyzwExtendedSwizzle
961 xyzwExtSwizComp .and comma .and
962 xyzwExtSwizComp .error EXT_SWIZ_COMP_EXPECTED .and comma .and
963 xyzwExtSwizComp .error EXT_SWIZ_COMP_EXPECTED .and comma .and
964 xyzwExtSwizComp .error EXT_SWIZ_COMP_EXPECTED;
965
966/*
967fragment program
968 <rgbaExtendedSwizzle> ::= <rgbaExtSwizComp> "," <rgbaExtSwizComp> ","
969 <rgbaExtSwizComp> "," <rgbaExtSwizComp>
970*/
971rgbaExtendedSwizzle
972 rgbaExtendedSwizzle_1 .or rgbaExtendedSwizzle_2 .or rgbaExtendedSwizzle_3 .or
973 rgbaExtendedSwizzle_4;
974rgbaExtendedSwizzle_1
975 rgbaExtSwizComp_digit .and comma .and rgbaExtSwizComp_digit .and comma .and
976 rgbaExtSwizComp_digit .and comma .and rgbaExtSwizComp;
977rgbaExtendedSwizzle_2
978 rgbaExtSwizComp_digit .and comma .and rgbaExtSwizComp_digit .and comma .and
979 rgbaExtSwizComp_alpha .and comma .and rgbaExtSwizComp .error EXT_SWIZ_COMP_EXPECTED;
980rgbaExtendedSwizzle_3
981 rgbaExtSwizComp_digit .and comma .and rgbaExtSwizComp_alpha .and comma .and
982 rgbaExtSwizComp .error EXT_SWIZ_COMP_EXPECTED .and comma .and
983 rgbaExtSwizComp .error EXT_SWIZ_COMP_EXPECTED;
984rgbaExtendedSwizzle_4
985 rgbaExtSwizComp_alpha .and comma .and
986 rgbaExtSwizComp .error EXT_SWIZ_COMP_EXPECTED .and comma .and
987 rgbaExtSwizComp .error EXT_SWIZ_COMP_EXPECTED .and comma .and
988 rgbaExtSwizComp .error EXT_SWIZ_COMP_EXPECTED;
989
990/*
991fragment program
992 <xyzwExtSwizComp> ::= <optionalSign> <xyzwExtSwizSel>
993*/
994xyzwExtSwizComp
995 optionalSign .and xyzwExtSwizSel;
996
997/*
998fragment program
999 <rgbaExtSwizComp> ::= <optionalSign> <rgbaExtSwizSel>
1000*/
1001rgbaExtSwizComp
1002 optionalSign .and rgbaExtSwizSel;
1003rgbaExtSwizComp_digit
1004 optionalSign .and rgbaExtSwizSel_digit;
1005rgbaExtSwizComp_alpha
1006 optionalSign .and rgbaExtSwizSel_alpha;
1007
1008/*
1009vertex program
1010 <extSwizComp> ::= <optionalSign> <extSwizSel>
1011*/
1012extSwizComp
1013 optionalSign .and extSwizSel;
1014
1015/*
1016fragment program
1017 <xyzwExtSwizSel> ::= "0"
1018 | "1"
1019 | <xyzwComponent>
1020*/
1021xyzwExtSwizSel
1022 "0" .emit COMPONENT_0 .or "1" .emit COMPONENT_1 .or xyzwComponent_single;
1023
1024/*
1025fragment program
1026 <rgbaExtSwizSel> ::= "0"
1027 | "1"
1028 | <rgbaComponent>
1029*/
1030rgbaExtSwizSel
1031 rgbaExtSwizSel_digit .or rgbaExtSwizSel_alpha;
1032rgbaExtSwizSel_digit
1033 "0" .emit COMPONENT_0 .or "1" .emit COMPONENT_1;
1034rgbaExtSwizSel_alpha
1035 rgbaComponent_single;
1036
1037/*
1038vertex program
1039 <extSwizSel> ::= "0"
1040 | "1"
1041 | <component>
1042*/
1043extSwizSel
1044 "0" .emit COMPONENT_0 .or "1" .emit COMPONENT_1 .or vp_component_single;
1045
1046/*
1047fragment program
1048 <srcReg> ::= <fragmentAttribReg>
1049 | <temporaryReg>
1050 | <progParamReg>
1051
1052vertex program
1053 <srcReg> ::= <vertexAttribReg>
1054 | <temporaryReg>
1055 | <progParamReg>
1056*/
1057fp_srcReg
1058 fp_srcReg_1 .error SOURCE_REGISTER_EXPECTED;
1059vp_srcReg
1060 vp_srcReg_1 .error SOURCE_REGISTER_EXPECTED;
1061fp_srcReg_1
1062 fragmentAttribReg .emit REGISTER_ATTRIB .or
1063 fp_progParamReg .emit REGISTER_PARAM .or
1064 fp_temporaryReg .emit REGISTER_ESTABLISHED_NAME;
1065vp_srcReg_1
1066 vertexAttribReg .emit REGISTER_ATTRIB .or
1067 vp_progParamReg .emit REGISTER_PARAM .or
1068 vp_temporaryReg .emit REGISTER_ESTABLISHED_NAME;
1069
1070/*
1071fragment program
1072 <dstReg> ::= <temporaryReg>
1073 | <fragmentResultReg>
1074
1075vertex program
1076 <dstReg> ::= <temporaryReg>
1077 | <vertexResultReg>
1078*/
1079fp_dstReg
1080 fp_dstReg_1 .error DESTINATION_REGISTER_EXPECTED;
1081vp_dstReg
1082 vp_dstReg_1 .error DESTINATION_REGISTER_EXPECTED;
1083fp_dstReg_1
1084 fragmentResultReg .emit REGISTER_RESULT .or
1085 fp_temporaryReg .emit REGISTER_ESTABLISHED_NAME;
1086vp_dstReg_1
1087 vertexResultReg .emit REGISTER_RESULT .or
1088 vp_temporaryReg .emit REGISTER_ESTABLISHED_NAME;
1089
1090/*
1091fragment program
1092 <fragmentAttribReg> ::= <establishedName>
1093 | <fragAttribBinding>
1094
1095NOTE: <establishedName> is driven by <temporaryReg> rule at the end of <srcReg>
1096*/
1097fragmentAttribReg
1098 /*fp_establishedName .or */fragAttribBinding;
1099
1100/*
1101vertex program
1102 <vertexAttribReg> ::= <establishedName>
1103 | <vtxAttribBinding>
1104
1105NOTE: <establishedName> is driven by <temporaryReg> rule at the end of <srcReg>
1106*/
1107vertexAttribReg
1108 vtxAttribBinding;
1109
1110/*
1111 <temporaryReg> ::= <establishedName>
1112*/
1113fp_temporaryReg
1114 fp_establishedName_no_error_on_identifier;
1115vp_temporaryReg
1116 vp_establishedName_no_error_on_identifier;
1117
1118/*
1119fragment program
1120 <progParamReg> ::= <progParamSingle>
1121 | <progParamArray> "[" <progParamArrayAbs> "]"
1122 | <paramSingleItemUse>
1123
1124vertex program
1125 <progParamReg> ::= <progParamSingle>
1126 | <progParamArray> "[" <progParamArrayMem> "]"
1127 | <paramSingleItemUse>
1128*/
1129fp_progParamReg
1130 fp_paramSingleItemUse .or fp_progParamReg_1 .or fp_progParamSingle;
1131vp_progParamReg
1132 vp_paramSingleItemUse .or vp_progParamReg_1 .or vp_progParamSingle;
1133fp_progParamReg_1
1134 fp_progParamArray .emit PARAM_ARRAY_ELEMENT .and lbracket_ne .and progParamArrayAbs .and
1135 rbracket;
1136vp_progParamReg_1
1137 vp_progParamArray .emit PARAM_ARRAY_ELEMENT .and lbracket_ne .and progParamArrayMem .and
1138 rbracket;
1139
1140/*
1141 <progParamSingle> ::= <establishedName>
1142
1143NOTE: <establishedName> is driven by <temporaryReg> rule at the end of <srcReg>
1144*/
1145fp_progParamSingle
1146 .false;
1147vp_progParamSingle
1148 .false;
1149
1150/*
1151 <progParamArray> ::= <establishedName>
1152*/
1153fp_progParamArray
1154 fp_establishedName_no_error_on_identifier;
1155vp_progParamArray
1156 vp_establishedName_no_error_on_identifier;
1157
1158/*
1159vertex program
1160 <progParamArrayMem> ::= <progParamArrayAbs>
1161 | <progParamArrayRel>
1162*/
1163progParamArrayMem
1164 progParamArrayAbs .or progParamArrayRel;
1165
1166/*
1167 <progParamArrayAbs> ::= <integer>
1168*/
1169progParamArrayAbs
1170 integer_ne .emit ARRAY_INDEX_ABSOLUTE;
1171
1172/*
1173vertex program
1174 <progParamArrayRel> ::= <addrReg> <addrComponent> <addrRegRelOffset>
1175*/
1176progParamArrayRel
1177 addrReg .error ADDRESS_REGISTER_OR_INTEGER_EXPECTED .emit ARRAY_INDEX_RELATIVE .and
1178 addrComponent .and addrRegRelOffset;
1179
1180/*
1181vertex program
1182 <addrRegRelOffset> ::= ""
1183 | "+" <addrRegPosOffset>
1184 | "-" <addrRegNegOffset>
1185*/
1186addrRegRelOffset
1187 addrRegRelOffset_1 .or addrRegRelOffset_2 .or .true .emit 0x00;
1188addrRegRelOffset_1
1189 plus_ne .and addrRegPosOffset;
1190addrRegRelOffset_2
1191 minus_ne .and addrRegNegOffset;
1192
1193/*
1194vertex program
1195 <addrRegPosOffset> ::= <integer> from 0 to 63
1196*/
1197addrRegPosOffset
1198 integer_0_63;
1199
1200/*
1201vertex program
1202 <addrRegNegOffset> ::= <integer> from 0 to 64
1203*/
1204addrRegNegOffset
1205 integer_0_64;
1206
1207/*
1208fragment program
1209 <fragmentResultReg> ::= <establishedName>
1210 | <resultBinding>
1211
1212NOTE: <establishedName> is driven by <temporaryReg> rule at the end of <dstReg>
1213*/
1214fragmentResultReg
1215 fp_resultBinding;
1216
1217/*
1218vertex program
1219 <vertexResultReg> ::= <establishedName>
1220 | <resultBinding>
1221
1222NOTE: <establishedName> is driven by <temporaryReg> rule at the end of <dstReg>
1223*/
1224vertexResultReg
1225 vp_resultBinding;
1226
1227/*
1228vertex program
1229 <addrReg> ::= <establishedName>
1230*/
1231addrReg
1232 vp_establishedName_no_error_on_identifier;
1233
1234/*
1235vertex program
1236 <addrComponent> ::= "." "x"
1237*/
1238addrComponent
1239 dot .and "x" .error INVALID_ADDRESS_COMPONENT .emit COMPONENT_X .emit COMPONENT_X
1240 .emit COMPONENT_X .emit COMPONENT_X;
1241
1242/*
1243vertex program
1244 <addrWriteMask> ::= "." "x"
1245*/
1246addrWriteMask
1247 dot .and "x" .error INVALID_ADDRESS_WRITEMASK .emit 0x08;
1248
1249/*
1250 <scalarSuffix> ::= "." <component>
1251*/
1252fp_scalarSuffix
1253 dot .and fp_component_single .error INVALID_COMPONENT;
1254vp_scalarSuffix
1255 dot .and vp_component_single .error INVALID_COMPONENT;
1256
1257/*
1258vertex program
1259 <swizzleSuffix> ::= ""
1260 | "." <component>
1261 | "." <component> <component>
1262 <component> <component>
1263*/
1264swizzleSuffix
1265 swizzleSuffix_1 .or
1266 .true .emit COMPONENT_X .emit COMPONENT_Y .emit COMPONENT_Z .emit COMPONENT_W;
1267swizzleSuffix_1
1268 dot_ne .and swizzleSuffix_2 .error INVALID_SUFFIX;
1269swizzleSuffix_2
1270 swizzleSuffix_3 .or swizzleSuffix_4;
1271swizzleSuffix_3
1272 vp_component_multi .and vp_component_multi .and vp_component_multi .error INVALID_COMPONENT .and
1273 vp_component_multi .error INVALID_COMPONENT;
1274swizzleSuffix_4
1275 "x" .emit COMPONENT_X .emit COMPONENT_X .emit COMPONENT_X .emit COMPONENT_X .or
1276 "y" .emit COMPONENT_Y .emit COMPONENT_Y .emit COMPONENT_Y .emit COMPONENT_Y .or
1277 "z" .emit COMPONENT_Z .emit COMPONENT_Z .emit COMPONENT_Z .emit COMPONENT_Z .or
1278 "w" .emit COMPONENT_W .emit COMPONENT_W .emit COMPONENT_W .emit COMPONENT_W;
1279
1280/*
1281fragment program
1282 <optionalSuffix> ::= ""
1283 | "." <component>
1284 | "." <xyzwComponent> <xyzwComponent>
1285 <xyzwComponent> <xyzwComponent>
1286 | "." <rgbaComponent> <rgbaComponent>
1287 <rgbaComponent> <rgbaComponent>
1288*/
1289optionalSuffix
1290 optionalSuffix_1 .or
1291 .true .emit COMPONENT_X .emit COMPONENT_Y .emit COMPONENT_Z .emit COMPONENT_W;
1292optionalSuffix_1
1293 dot_ne .and optionalSuffix_2 .error INVALID_SUFFIX;
1294optionalSuffix_2
1295 optionalSuffix_3 .or optionalSuffix_4 .or optionalSuffix_5;
1296optionalSuffix_3
1297 xyzwComponent_multi .and xyzwComponent_multi .and
1298 xyzwComponent_multi .error INVALID_COMPONENT .and xyzwComponent_multi .error INVALID_COMPONENT;
1299optionalSuffix_4
1300 rgbaComponent_multi .and rgbaComponent_multi .and
1301 rgbaComponent_multi .error INVALID_COMPONENT .and rgbaComponent_multi .error INVALID_COMPONENT;
1302optionalSuffix_5
1303 "x" .emit COMPONENT_X .emit COMPONENT_X .emit COMPONENT_X .emit COMPONENT_X .or
1304 "y" .emit COMPONENT_Y .emit COMPONENT_Y .emit COMPONENT_Y .emit COMPONENT_Y .or
1305 "z" .emit COMPONENT_Z .emit COMPONENT_Z .emit COMPONENT_Z .emit COMPONENT_Z .or
1306 "w" .emit COMPONENT_W .emit COMPONENT_W .emit COMPONENT_W .emit COMPONENT_W .or
1307 "r" .emit COMPONENT_X .emit COMPONENT_X .emit COMPONENT_X .emit COMPONENT_X .or
1308 "g" .emit COMPONENT_Y .emit COMPONENT_Y .emit COMPONENT_Y .emit COMPONENT_Y .or
1309 "b" .emit COMPONENT_Z .emit COMPONENT_Z .emit COMPONENT_Z .emit COMPONENT_Z .or
1310 "a" .emit COMPONENT_W .emit COMPONENT_W .emit COMPONENT_W .emit COMPONENT_W;
1311
1312/*
1313fragment program
1314 <component> ::= <xyzwComponent>
1315 | <rgbaComponent>
1316
1317vertex program
1318 <component> ::= "x"
1319 | "y"
1320 | "z"
1321 | "w"
1322*/
1323fp_component_single
1324 xyzwComponent_single .or rgbaComponent_single;
1325vp_component_multi
1326 'x' .emit COMPONENT_X .or 'y' .emit COMPONENT_Y .or 'z' .emit COMPONENT_Z .or
1327 'w' .emit COMPONENT_W;
1328vp_component_single
1329 "x" .emit COMPONENT_X .or "y" .emit COMPONENT_Y .or "z" .emit COMPONENT_Z .or
1330 "w" .emit COMPONENT_W;
1331
1332/*
1333fragment program
1334 <xyzwComponent> ::= "x" | "y" | "z" | "w"
1335*/
1336xyzwComponent_multi
1337 'x' .emit COMPONENT_X .or 'y' .emit COMPONENT_Y .or 'z' .emit COMPONENT_Z .or
1338 'w' .emit COMPONENT_W;
1339xyzwComponent_single
1340 "x" .emit COMPONENT_X .or "y" .emit COMPONENT_Y .or "z" .emit COMPONENT_Z .or
1341 "w" .emit COMPONENT_W;
1342
1343/*
1344fragment program
1345 <rgbaComponent> ::= "r" | "g" | "b" | "a"
1346*/
1347rgbaComponent_multi
1348 'r' .emit COMPONENT_X .or 'g' .emit COMPONENT_Y .or 'b' .emit COMPONENT_Z .or
1349 'a' .emit COMPONENT_W;
1350rgbaComponent_single
1351 "r" .emit COMPONENT_X .or "g" .emit COMPONENT_Y .or "b" .emit COMPONENT_Z .or
1352 "a" .emit COMPONENT_W;
1353
1354/*
1355fragment program
1356 <optionalMask> ::= ""
1357 | <xyzwMask>
1358 | <rgbaMask>
1359
1360vertex program
1361 <optionalMask> ::= ""
1362 | "." "x"
1363 | "." "y"
1364 | "." "xy"
1365 | "." "z"
1366 | "." "xz"
1367 | "." "yz"
1368 | "." "xyz"
1369 | "." "w"
1370 | "." "xw"
1371 | "." "yw"
1372 | "." "xyw"
1373 | "." "zw"
1374 | "." "xzw"
1375 | "." "yzw"
1376 | "." "xyzw"
1377
1378NOTE: do NOT change the order of <rgbaMask> and <xyzwMask> rulez
1379*/
1380fp_optionalMask
1381 rgbaMask .or xyzwMask .or .true .emit 0x0F;
1382vp_optionalMask
1383 xyzwMask .or .true .emit 0x0F;
1384
1385/*
1386fragment program
1387 <xyzwMask> ::= "." "x"
1388 | "." "y"
1389 | "." "xy"
1390 | "." "z"
1391 | "." "xz"
1392 | "." "yz"
1393 | "." "xyz"
1394 | "." "w"
1395 | "." "xw"
1396 | "." "yw"
1397 | "." "xyw"
1398 | "." "zw"
1399 | "." "xzw"
1400 | "." "yzw"
1401 | "." "xyzw"
1402
1403NOTE: <xyzwMask> is also referenced by the vertex program symbol <optionalMask>.
1404*/
1405xyzwMask
1406 dot_ne .and xyzwMask_1 .error INVALID_WRITEMASK;
1407xyzwMask_1
1408 "xyzw" .emit 0x0F .or "xyz" .emit 0x0E .or "xyw" .emit 0x0D .or "xy" .emit 0x0C .or
1409 "xzw" .emit 0x0B .or "xz" .emit 0x0A .or "xw" .emit 0x09 .or "x" .emit 0x08 .or
1410 "yzw" .emit 0x07 .or "yz" .emit 0x06 .or "yw" .emit 0x05 .or "y" .emit 0x04 .or
1411 "zw" .emit 0x03 .or "z" .emit 0x02 .or "w" .emit 0x01;
1412
1413/*
1414fragment program
1415 <rgbaMask> ::= "." "r"
1416 | "." "g"
1417 | "." "rg"
1418 | "." "b"
1419 | "." "rb"
1420 | "." "gb"
1421 | "." "rgb"
1422 | "." "a"
1423 | "." "ra"
1424 | "." "ga"
1425 | "." "rga"
1426 | "." "ba"
1427 | "." "rba"
1428 | "." "gba"
1429 | "." "rgba"
1430*/
1431rgbaMask
1432 dot_ne .and rgbaMask_1;
1433rgbaMask_1
1434 "rgba" .emit 0x0F .or "rgb" .emit 0x0E .or "rga" .emit 0x0D .or "rg" .emit 0x0C .or
1435 "rba" .emit 0x0B .or "rb" .emit 0x0A .or "ra" .emit 0x09 .or "r" .emit 0x08 .or
1436 "gba" .emit 0x07 .or "gb" .emit 0x06 .or "ga" .emit 0x05 .or "g" .emit 0x04 .or
1437 "ba" .emit 0x03 .or "b" .emit 0x02 .or "a" .emit 0x01;
1438
1439/*
1440fragment program
1441 <namingStatement> ::= <ATTRIB_statement>
1442 | <PARAM_statement>
1443 | <TEMP_statement>
1444 | <OUTPUT_statement>
1445 | <ALIAS_statement>
1446
1447vertex program
1448 <namingStatement> ::= <ATTRIB_statement>
1449 | <PARAM_statement>
1450 | <TEMP_statement>
1451 | <ADDRESS_statement>
1452 | <OUTPUT_statement>
1453 | <ALIAS_statement>
1454*/
1455fp_namingStatement
1456 fp_ATTRIB_statement .emit ATTRIB .or
1457 fp_PARAM_statement .emit PARAM .or
1458 fp_TEMP_statement .emit TEMP .or
1459 fp_OUTPUT_statement .emit OUTPUT .or
1460 fp_ALIAS_statement .emit ALIAS;
1461vp_namingStatement
1462 vp_ATTRIB_statement .emit ATTRIB .or
1463 vp_PARAM_statement .emit PARAM .or
1464 vp_TEMP_statement .emit TEMP .or
1465 ADDRESS_statement .emit ADDRESS .or
1466 vp_OUTPUT_statement .emit OUTPUT .or
1467 vp_ALIAS_statement .emit ALIAS;
1468
1469/*
1470fragment program
1471 <ATTRIB_statement> ::= "ATTRIB" <establishName> "="
1472 <fragAttribBinding>
1473
1474vertex program
1475 <ATTRIB_statement> ::= "ATTRIB" <establishName> "="
1476 <vtxAttribBinding>
1477*/
1478fp_ATTRIB_statement
1479 "ATTRIB" .and space .and fp_establishName .and equal .and
1480 fragAttribBinding .error FRAGMENT_EXPECTED;
1481vp_ATTRIB_statement
1482 "ATTRIB" .and space .and vp_establishName .and equal .and
1483 vtxAttribBinding .error VERTEX_EXPECTED;
1484
1485/*
1486fragment program
1487 <fragAttribBinding> ::= "fragment" "." <fragAttribItem>
1488*/
1489fragAttribBinding
1490 "fragment" .and dot .and fragAttribItem .error INVALID_FRAGMENT_PROPERTY;
1491
1492/*
1493vertex program
1494 <vtxAttribBinding> ::= "vertex" "." <vtxAttribItem>
1495*/
1496vtxAttribBinding
1497 "vertex" .and dot .and vtxAttribItem .error INVALID_VERTEX_PROPERTY;
1498
1499/*
1500fragment program
1501 <fragAttribItem> ::= "color" <optColorType>
1502 | "texcoord" <optTexCoordNum>
1503 | "fogcoord"
1504 | "position"
1505*/
1506fragAttribItem
1507 fragAttribItem_1 .emit FRAGMENT_ATTRIB_COLOR .or
1508 fragAttribItem_2 .emit FRAGMENT_ATTRIB_TEXCOORD .or
1509 .if (fog_coord != 0x00) "fogcoord" .emit FRAGMENT_ATTRIB_FOGCOORD .or
1510 "position" .emit FRAGMENT_ATTRIB_POSITION;
1511fragAttribItem_1
1512 "color" .and optColorType;
1513fragAttribItem_2
1514 "texcoord" .and optTexCoordNum;
1515
1516/*
1517vertex program
1518 <vtxAttribItem> ::= "position"
1519 | "weight" <vtxOptWeightNum>
1520 | "normal"
1521 | "color" <optColorType>
1522 | "fogcoord"
1523 | "texcoord" <optTexCoordNum>
1524 | "matrixindex" "[" <vtxWeightNum> "]"
1525 | "attrib" "[" <vtxAttribNum> "]"
1526*/
1527vtxAttribItem
1528 "position" .emit VERTEX_ATTRIB_POSITION .or
1529 .if (vertex_blend != 0x00) vtxAttribItem_1 .emit VERTEX_ATTRIB_WEIGHT .or
1530 "normal" .emit VERTEX_ATTRIB_NORMAL .or
1531 vtxAttribItem_2 .emit VERTEX_ATTRIB_COLOR .or
1532 "fogcoord" .emit VERTEX_ATTRIB_FOGCOORD .or
1533 vtxAttribItem_3 .emit VERTEX_ATTRIB_TEXCOORD .or
1534 .if (matrix_palette != 0x00) vtxAttribItem_4 .emit VERTEX_ATTRIB_MATRIXINDEX .or
1535 vtxAttribItem_5 .emit VERTEX_ATTRIB_GENERIC;
1536vtxAttribItem_1
1537 "weight" .and vtxOptWeightNum;
1538vtxAttribItem_2
1539 "color" .and optColorType;
1540vtxAttribItem_3
1541 "texcoord" .and optTexCoordNum;
1542vtxAttribItem_4
1543 "matrixindex" .and lbracket .and vtxWeightNum .and rbracket;
1544vtxAttribItem_5
1545 "attrib" .and lbracket .and vtxAttribNum .and rbracket;
1546
1547/*
1548vertex program
1549 <vtxAttribNum> ::= <integer> from 0 to MAX_VERTEX_ATTRIBS_ARB-1
1550*/
1551vtxAttribNum
1552 integer;
1553
1554/*
1555vertex program
1556 <vtxOptWeightNum> ::= ""
1557 | "[" <vtxWeightNum> "]"
1558*/
1559vtxOptWeightNum
1560 vtxOptWeightNum_1 .or .true .emit 0x00;
1561vtxOptWeightNum_1
1562 lbracket_ne .and vtxWeightNum .and rbracket;
1563
1564/*
1565vertex program
1566 <vtxWeightNum> ::= <integer> from 0 to MAX_VERTEX_UNITS_ARB-1,
1567 must be divisible by four
1568*/
1569vtxWeightNum
1570 integer;
1571
1572/*
1573 <PARAM_statement> ::= <PARAM_singleStmt>
1574 | <PARAM_multipleStmt>
1575*/
1576fp_PARAM_statement
1577 fp_PARAM_multipleStmt .or fp_PARAM_singleStmt;
1578vp_PARAM_statement
1579 vp_PARAM_multipleStmt .or vp_PARAM_singleStmt;
1580
1581/*
1582 <PARAM_singleStmt> ::= "PARAM" <establishName> <paramSingleInit>
1583*/
1584fp_PARAM_singleStmt
1585 "PARAM" .and space .and fp_establishName .and .true .emit 0x00 .and fp_paramSingleInit .and
1586 .true .emit PARAM_NULL;
1587vp_PARAM_singleStmt
1588 "PARAM" .and space .and vp_establishName .and .true .emit 0x00 .and vp_paramSingleInit .and
1589 .true .emit PARAM_NULL;
1590
1591/*
1592 <PARAM_multipleStmt> ::= "PARAM" <establishName> "[" <optArraySize> "]"
1593 <paramMultipleInit>
1594*/
1595fp_PARAM_multipleStmt
1596 "PARAM" .and space .and fp_establishName .and lbracket_ne .and optArraySize .and rbracket .and
1597 fp_paramMultipleInit .and .true .emit PARAM_NULL;
1598vp_PARAM_multipleStmt
1599 "PARAM" .and space .and vp_establishName .and lbracket_ne .and optArraySize .and rbracket .and
1600 vp_paramMultipleInit .and .true .emit PARAM_NULL;
1601
1602/*
1603 <optArraySize> ::= ""
1604 | <integer> from 1 to MAX_PROGRAM_PARAMETERS_ARB
1605 (maximum number of allowed program
1606 parameter bindings)
1607*/
1608optArraySize
1609 optional_integer;
1610
1611/*
1612 <paramSingleInit> ::= "=" <paramSingleItemDecl>
1613*/
1614fp_paramSingleInit
1615 equal .and fp_paramSingleItemDecl;
1616vp_paramSingleInit
1617 equal .and vp_paramSingleItemDecl;
1618
1619/*
1620 <paramMultipleInit> ::= "=" "{" <paramMultInitList> "}"
1621*/
1622fp_paramMultipleInit
1623 equal .and lbrace .and fp_paramMultInitList .and rbrace;
1624vp_paramMultipleInit
1625 equal .and lbrace .and vp_paramMultInitList .and rbrace;
1626
1627/*
1628 <paramMultInitList> ::= <paramMultipleItem>
1629 | <paramMultipleItem> "," <paramMultiInitList>
1630*/
1631fp_paramMultInitList
1632 fp_paramMultInitList_1 .or fp_paramMultipleItem;
1633vp_paramMultInitList
1634 vp_paramMultInitList_1 .or vp_paramMultipleItem;
1635fp_paramMultInitList_1
1636 fp_paramMultipleItem .and comma_ne .and fp_paramMultInitList;
1637vp_paramMultInitList_1
1638 vp_paramMultipleItem .and comma_ne .and vp_paramMultInitList;
1639
1640/*
1641 <paramSingleItemDecl> ::= <stateSingleItem>
1642 | <programSingleItem>
1643 | <paramConstDecl>
1644*/
1645fp_paramSingleItemDecl
1646 fp_stateSingleItem .emit PARAM_STATE_ELEMENT .or
1647 programSingleItem .emit PARAM_PROGRAM_ELEMENT .or
1648 paramConstDecl .emit PARAM_CONSTANT;
1649vp_paramSingleItemDecl
1650 vp_stateSingleItem .emit PARAM_STATE_ELEMENT .or
1651 programSingleItem .emit PARAM_PROGRAM_ELEMENT .or
1652 paramConstDecl .emit PARAM_CONSTANT;
1653
1654/*
1655 <paramSingleItemUse> ::= <stateSingleItem>
1656 | <programSingleItem>
1657 | <paramConstUse>
1658*/
1659fp_paramSingleItemUse
1660 fp_stateSingleItem .emit PARAM_STATE_ELEMENT .or
1661 programSingleItem .emit PARAM_PROGRAM_ELEMENT .or
1662 paramConstUse .emit PARAM_CONSTANT;
1663vp_paramSingleItemUse
1664 vp_stateSingleItem .emit PARAM_STATE_ELEMENT .or
1665 programSingleItem .emit PARAM_PROGRAM_ELEMENT .or
1666 paramConstUse .emit PARAM_CONSTANT;
1667
1668/*
1669 <paramMultipleItem> ::= <stateMultipleItem>
1670 | <programMultipleItem>
1671 | <paramConstDecl>
1672*/
1673fp_paramMultipleItem
1674 fp_stateMultipleItem .emit PARAM_STATE_ELEMENT .or
1675 programMultipleItem .emit PARAM_PROGRAM_ELEMENT .or
1676 paramConstDecl .emit PARAM_CONSTANT;
1677vp_paramMultipleItem
1678 vp_stateMultipleItem .emit PARAM_STATE_ELEMENT .or
1679 programMultipleItem .emit PARAM_PROGRAM_ELEMENT .or
1680 paramConstDecl .emit PARAM_CONSTANT;
1681
1682/*
1683 <stateMultipleItem> ::= <stateSingleItem>
1684 | "state" "." <stateMatrixRows>
1685*/
1686fp_stateMultipleItem
1687 stateMultipleItem_1 .or fp_stateSingleItem;
1688vp_stateMultipleItem
1689 stateMultipleItem_1 .or vp_stateSingleItem;
1690stateMultipleItem_1
1691 "state" .and dot .and stateMatrixRows .emit STATE_MATRIX_ROWS;
1692
1693/*
1694fragment program
1695 <stateSingleItem> ::= "state" "." <stateMaterialItem>
1696 | "state" "." <stateLightItem>
1697 | "state" "." <stateLightModelItem>
1698 | "state" "." <stateLightProdItem>
1699 | "state" "." <stateTexEnvItem>
1700 | "state" "." <stateFogItem>
1701 | "state" "." <stateDepthItem>
1702 | "state" "." <stateMatrixRow>
1703
1704vertex program
1705 <stateSingleItem> ::= "state" "." <stateMaterialItem>
1706 | "state" "." <stateLightItem>
1707 | "state" "." <stateLightModelItem>
1708 | "state" "." <stateLightProdItem>
1709 | "state" "." <stateTexGenItem>
1710 | "state" "." <stateFogItem>
1711 | "state" "." <stateClipPlaneItem>
1712 | "state" "." <statePointItem>
1713 | "state" "." <stateMatrixRow>
1714*/
1715fp_stateSingleItem
1716 "state" .and dot .and fp_stateSingleItem_1 .error INVALID_STATE_PROPERTY;
1717vp_stateSingleItem
1718 "state" .and dot .and vp_stateSingleItem_1 .error INVALID_STATE_PROPERTY;
1719fp_stateSingleItem_1
1720 stateSingleItem_1 .or stateSingleItem_2 .or stateSingleItem_3 .or stateSingleItem_4 .or
1721 stateSingleItem_5 .or stateSingleItem_7 .or stateSingleItem_8 .or stateSingleItem_11;
1722vp_stateSingleItem_1
1723 stateSingleItem_1 .or stateSingleItem_2 .or stateSingleItem_3 .or stateSingleItem_4 .or
1724 stateSingleItem_6 .or stateSingleItem_7 .or stateSingleItem_9 .or stateSingleItem_10 .or
1725 stateSingleItem_11;
1726stateSingleItem_1
1727 stateMaterialItem .emit STATE_MATERIAL;
1728stateSingleItem_2
1729 stateLightItem .emit STATE_LIGHT;
1730stateSingleItem_3
1731 stateLightModelItem .emit STATE_LIGHT_MODEL;
1732stateSingleItem_4
1733 stateLightProdItem .emit STATE_LIGHT_PROD;
1734stateSingleItem_5
1735 stateTexEnvItem .emit STATE_TEX_ENV;
1736stateSingleItem_6
1737 stateTexGenItem .emit STATE_TEX_GEN;
1738stateSingleItem_7
1739 stateFogItem .emit STATE_FOG;
1740stateSingleItem_8
1741 stateDepthItem .emit STATE_DEPTH;
1742stateSingleItem_9
1743 stateClipPlaneItem .emit STATE_CLIP_PLANE;
1744stateSingleItem_10
1745 statePointItem .emit STATE_POINT;
1746stateSingleItem_11
1747 stateMatrixRow .emit STATE_MATRIX_ROWS;
1748
1749/*
1750 <stateMaterialItem> ::= "material" <optFaceType> "." <stateMatProperty>
1751*/
1752stateMaterialItem
1753 "material" .and optFaceType .and dot .and stateMatProperty .error INVALID_MATERIAL_PROPERTY;
1754
1755/*
1756 <stateMatProperty> ::= "ambient"
1757 | "diffuse"
1758 | "specular"
1759 | "emission"
1760 | "shininess"
1761*/
1762stateMatProperty
1763 "ambient" .emit MATERIAL_AMBIENT .or
1764 "diffuse" .emit MATERIAL_DIFFUSE .or
1765 "specular" .emit MATERIAL_SPECULAR .or
1766 "emission" .emit MATERIAL_EMISSION .or
1767 "shininess" .emit MATERIAL_SHININESS;
1768
1769/*
1770 <stateLightItem> ::= "light" "[" <stateLightNumber> "]" "."
1771 <stateLightProperty>
1772*/
1773stateLightItem
1774 "light" .and lbracket .and stateLightNumber .and rbracket .and dot .and
1775 stateLightProperty .error INVALID_LIGHT_PROPERTY;
1776
1777/*
1778 <stateLightProperty> ::= "ambient"
1779 | "diffuse"
1780 | "specular"
1781 | "position"
1782 | "attenuation"
1783 | "spot" "." <stateSpotProperty>
1784 | "half"
1785*/
1786stateLightProperty
1787 "ambient" .emit LIGHT_AMBIENT .or
1788 "diffuse" .emit LIGHT_DIFFUSE .or
1789 "specular" .emit LIGHT_SPECULAR .or
1790 "position" .emit LIGHT_POSITION .or
1791 "attenuation" .emit LIGHT_ATTENUATION .or
1792 stateLightProperty_1 .emit LIGHT_SPOT_DIRECTION .or
1793 "half" .emit LIGHT_HALF;
1794stateLightProperty_1
1795 "spot" .and dot .and stateSpotProperty .error INVALID_SPOT_PROPERTY;
1796
1797/*
1798 <stateSpotProperty> ::= "direction"
1799*/
1800stateSpotProperty
1801 "direction";
1802
1803/*
1804 <stateLightModelItem> ::= "lightmodel" <stateLModProperty>
1805*/
1806stateLightModelItem
1807 "lightmodel" .and stateLModProperty .error INVALID_LIGHTMODEL_PROPERTY;
1808
1809/*
1810 <stateLModProperty> ::= "." "ambient"
1811 | <optFaceType> "." "scenecolor"
1812*/
1813stateLModProperty
1814 stateLModProperty_1 .or stateLModProperty_2;
1815stateLModProperty_1
1816 dot .and "ambient" .emit LIGHT_MODEL_AMBIENT;
1817stateLModProperty_2
1818 stateLModProperty_3 .emit LIGHT_MODEL_SCENECOLOR;
1819stateLModProperty_3
1820 optFaceType .and dot .and "scenecolor";
1821
1822/*
1823 <stateLightProdItem> ::= "lightprod" "[" <stateLightNumber> "]"
1824 <optFaceType> "." <stateLProdProperty>
1825*/
1826stateLightProdItem
1827 "lightprod" .and lbracket .and stateLightNumber .and rbracket .and optFaceType .and dot .and
1828 stateLProdProperty .error INVALID_LIGHTPROD_PROPERTY;
1829
1830/*
1831 <stateLProdProperty> ::= "ambient"
1832 | "diffuse"
1833 | "specular"
1834*/
1835stateLProdProperty
1836 "ambient" .emit LIGHT_PROD_AMBIENT .or
1837 "diffuse" .emit LIGHT_PROD_DIFFUSE .or
1838 "specular" .emit LIGHT_PROD_SPECULAR;
1839
1840/*
1841 <stateLightNumber> ::= <integer> from 0 to MAX_LIGHTS-1
1842*/
1843stateLightNumber
1844 integer;
1845
1846/*
1847fragment program
1848 <stateTexEnvItem> ::= "texenv" <optLegacyTexUnitNum> "."
1849 <stateTexEnvProperty>
1850*/
1851stateTexEnvItem
1852 "texenv" .and optLegacyTexUnitNum .and dot .and
1853 stateTexEnvProperty .error INVALID_TEXENV_PROPERTY;
1854
1855/*
1856fragment program
1857 <stateTexEnvProperty> ::= "color"
1858*/
1859stateTexEnvProperty
1860 "color" .emit TEX_ENV_COLOR;
1861
1862/*
1863fragment program
1864 <optLegacyTexUnitNum> ::= ""
1865 | "[" <legacyTexUnitNum> "]"
1866
1867NOTE: <optLegaceTexUnitNum> is not optional.
1868*/
1869optLegacyTexUnitNum
1870 lbracket_ne .and legacyTexUnitNum .and rbracket;
1871
1872/*
1873fragment program
1874 <legacyTexUnitNum> ::= <integer> from 0 to MAX_TEXTURE_UNITS-1
1875*/
1876legacyTexUnitNum
1877 integer;
1878
1879/*
1880vertex program
1881 <stateTexGenItem> ::= "texgen" <optTexCoordNum> "."
1882 <stateTexGenType> "." <stateTexGenCoord>
1883*/
1884stateTexGenItem
1885 "texgen" .and optTexCoordNum .and dot .and stateTexGenType .error INVALID_TEXGEN_PROPERTY .and
1886 dot .and stateTexGenCoord .error INVALID_TEXGEN_COORD;
1887
1888/*
1889vertex program
1890 <stateTexGenType> ::= "eye"
1891 | "object"
1892*/
1893stateTexGenType
1894 "eye" .emit TEX_GEN_EYE .or
1895 "object" .emit TEX_GEN_OBJECT;
1896
1897/*
1898vertex program
1899 <stateTexGenCoord> ::= "s"
1900 | "t"
1901 | "r"
1902 | "q"
1903*/
1904stateTexGenCoord
1905 "s" .emit COMPONENT_X .or
1906 "t" .emit COMPONENT_Y .or
1907 "r" .emit COMPONENT_Z .or
1908 "q" .emit COMPONENT_W;
1909
1910/*
1911 <stateFogItem> ::= "fog" "." <stateFogProperty>
1912*/
1913stateFogItem
1914 "fog" .and dot .and stateFogProperty .error INVALID_FOG_PROPERTY;
1915
1916/*
1917 <stateFogProperty> ::= "color"
1918 | "params"
1919*/
1920stateFogProperty
1921 "color" .emit FOG_COLOR .or
1922 "params" .emit FOG_PARAMS;
1923
1924/*
1925fragment program
1926 <stateDepthItem> ::= "depth" "." <stateDepthProperty>
1927*/
1928stateDepthItem
1929 "depth" .and dot .and stateDepthProperty .error INVALID_DEPTH_PROPERTY;
1930
1931/*
1932fragment program
1933 <stateDepthProperty> ::= "range"
1934*/
1935stateDepthProperty
1936 "range" .emit DEPTH_RANGE;
1937
1938/*
1939vertex program
1940 <stateClipPlaneItem> ::= "clip" "[" <stateClipPlaneNum> "]" "." "plane"
1941*/
1942stateClipPlaneItem
1943 "clip" .and lbracket .and stateClipPlaneNum .and rbracket .and dot .and
1944 "plane" .error INVALID_CLIPPLANE_PROPERTY;
1945
1946/*
1947vertex program
1948 <stateClipPlaneNum> ::= <integer> from 0 to MAX_CLIP_PLANES-1
1949*/
1950stateClipPlaneNum
1951 integer;
1952
1953/*
1954vertex program
1955 <statePointItem> ::= "point" . <statePointProperty>
1956*/
1957statePointItem
1958 "point" .and dot .and statePointProperty .error INVALID_POINT_PROPERTY;
1959
1960/*
1961vertex program
1962 <statePointProperty> ::= "size"
1963 | "attenuation"
1964*/
1965statePointProperty
1966 "size" .emit POINT_SIZE .or
1967 .if (point_parameters != 0x00) "attenuation" .emit POINT_ATTENUATION;
1968
1969/*
1970 <stateMatrixRow> ::= <stateMatrixItem> "." "row" "["
1971 <stateMatrixRowNum> "]"
1972*/
1973stateMatrixRow
1974 stateMatrixItem .and dot .and "row" .error MATRIX_ROW_SELECTOR_OR_MODIFIER_EXPECTED .and
1975 lbracket .and stateMatrixRowNum .and rbracket .emit 0x0;
1976
1977/*
1978 <stateMatrixRows> ::= <stateMatrixItem> <optMatrixRows>
1979*/
1980stateMatrixRows
1981 stateMatrixItem .and optMatrixRows;
1982
1983/*
1984 <optMatrixRows> ::= ""
1985 | "." "row" "[" <stateMatrixRowNum> ".."
1986 <stateMatrixRowNum> "]"
1987*/
1988optMatrixRows
1989 optMatrixRows_1 .or .true .emit 0x0 .emit '3' .emit 0x0 .emit $;
1990optMatrixRows_1
1991 dot_ne .and "row" .error MATRIX_ROW_SELECTOR_OR_MODIFIER_EXPECTED .and lbracket .and
1992 stateMatrixRowNum .and dotdot .and stateMatrixRowNum .and rbracket;
1993
1994/*
1995 <stateMatrixItem> ::= "matrix" . <stateMatrixName>
1996 <stateOptMatModifier>
1997*/
1998stateMatrixItem
1999 "matrix" .and dot .and stateMatrixName .error INVALID_MATRIX_NAME .and stateOptMatModifier;
2000
2001/*
2002 <stateOptMatModifier> ::= ""
2003 | "." <stateMatModifier>
2004*/
2005stateOptMatModifier
2006 stateOptMatModifier_1 .or .true .emit MATRIX_MODIFIER_IDENTITY;
2007stateOptMatModifier_1
2008 dot_ne .and stateMatModifier;
2009
2010/*
2011 <stateMatModifier> ::= "inverse"
2012 | "transpose"
2013 | "invtrans"
2014*/
2015stateMatModifier
2016 "inverse" .emit MATRIX_MODIFIER_INVERSE .or
2017 "transpose" .emit MATRIX_MODIFIER_TRANSPOSE .or
2018 "invtrans" .emit MATRIX_MODIFIER_INVTRANS;
2019
2020/*
2021 <stateMatrixRowNum> ::= <integer> from 0 to 3
2022*/
2023stateMatrixRowNum
2024 integer_0_3;
2025
2026/*
2027 <stateMatrixName> ::= "modelview" <stateOptModMatNum>
2028 | "projection"
2029 | "mvp"
2030 | "texture" <optTexCoordNum>
2031 | "palette" "[" <statePaletteMatNum> "]"
2032 | "program" "[" <stateProgramMatNum> "]"
2033*/
2034stateMatrixName
2035 stateMatrixName_1_1 .emit MATRIX_MODELVIEW .or
2036 "projection" .emit MATRIX_PROJECTION .or
2037 "mvp" .emit MATRIX_MVP .or
2038 stateMatrixName_1_2 .emit MATRIX_TEXTURE .or
2039 .if (matrix_palette != 0x00) stateMatrixName_1_3 .emit MATRIX_PALETTE .or
2040 stateMatrixName_1_4 .emit MATRIX_PROGRAM;
2041stateMatrixName_1_1
2042 "modelview" .and stateOptModMatNum;
2043stateMatrixName_1_2
2044 "texture" .and optTexCoordNum;
2045stateMatrixName_1_3
2046 "palette" .and lbracket .and statePaletteMatNum .and rbracket;
2047stateMatrixName_1_4
2048 "program" .and lbracket .and stateProgramMatNum .and rbracket;
2049
2050/*
2051 <stateOptModMatNum> ::= ""
2052 | "[" <stateModMatNum> "]"
2053*/
2054stateOptModMatNum
2055 .if (vertex_blend != 0x00) stateOptModMatNum_1 .or
2056 .true .emit 0x00;
2057stateOptModMatNum_1
2058 lbracket_ne .and stateModMatNum .and rbracket;
2059
2060/*
2061 <stateModMatNum> ::= <integer> from 0 to MAX_VERTEX_UNITS_ARB-1
2062*/
2063stateModMatNum
2064 integer;
2065
2066/*
Brian Paulbe76b7f2004-10-04 14:40:05 +00002067 From ARB_draw_buffers:
2068 <optOutputColorNum> ::= ""
2069 | "[" <OutputColorNum> "]"
2070*/
2071optOutputColorNum
2072 optOutputColorNum_1 .or .true .emit 0x00;
2073optOutputColorNum_1
2074 lbracket_ne .and outputColorNum .and rbracket;
2075
2076/*
2077 From ARB_draw_buffers:
2078 <outputColorNum> ::= <integer> from 0 to MAX_DRAW_BUFFERS_ARB-1
2079*/
2080outputColorNum
2081 integer;
2082
2083/*
Michal Krola904b492004-03-04 13:07:52 +00002084 <optTexCoordNum> ::= ""
2085 | "[" <texCoordNum> "]"
2086*/
2087optTexCoordNum
2088 optTexCoordNum_1 .or .true .emit 0x00;
2089optTexCoordNum_1
2090 lbracket_ne .and texCoordNum .and rbracket;
2091
2092/*
2093 <texCoordNum> ::= <integer> from 0 to MAX_TEXTURE_COORDS_ARB-1
2094*/
2095texCoordNum
2096 integer;
2097
2098/*
2099 <statePaletteMatNum> ::= <integer> from 0 to MAX_PALETTE_MATRICES_ARB-1
2100*/
2101statePaletteMatNum
2102 integer;
2103
2104/*
2105 <stateProgramMatNum> ::= <integer> from 0 to MAX_PROGRAM_MATRICES_ARB-1
2106*/
2107stateProgramMatNum
2108 integer;
2109
2110/*
2111 <programSingleItem> ::= <progEnvParam>
2112 | <progLocalParam>
2113
2114NOTE: <programSingleItem> has been modified for correct error handling. If program property
2115 is neither "env" nor "local" INVALID_PROGRAM_PROPERTY is generated.
2116*/
2117programSingleItem
2118 "program" .and dot .and programSingleItem_1 .error INVALID_PROGRAM_PROPERTY;
2119programSingleItem_1
2120 progEnvParam .or progLocalParam;
2121
2122/*
2123 <programMultipleItem> ::= <progEnvParams>
2124 | <progLocalParams>
2125
2126NOTE: <programMultipleItem> has been modified for correct error handling. If program property
2127 is neither "env" nor "local" INVALID_PROGRAM_PROPERTY is generated.
2128*/
2129programMultipleItem
2130 "program" .and dot .and programMultipleItem_1 .error INVALID_PROGRAM_PROPERTY;
2131programMultipleItem_1
2132 progEnvParams .or progLocalParams;
2133
2134/*
2135 <progEnvParams> ::= "program" "." "env"
2136 "[" <progEnvParamNums> "]"
2137
2138NOTE: "program" "." has been moved to <programMultipleItem>.
2139*/
2140progEnvParams
2141 "env" .emit PROGRAM_PARAM_ENV .and lbracket .and progEnvParamNums .and rbracket;
2142
2143/*
2144 <progEnvParamNums> ::= <progEnvParamNum>
2145 | <progEnvParamNum> ".." <progEnvParamNum>
2146*/
2147progEnvParamNums
2148 progEnvParamNums_1 .or progEnvParamNums_2;
2149progEnvParamNums_1
2150 progEnvParamNum .and dotdot_ne .and progEnvParamNum;
2151progEnvParamNums_2
2152 progEnvParamNum .and .true .emit 0x00;
2153
2154/*
2155 <progEnvParam> ::= "program" "." "env"
2156 "[" <progEnvParamNum> "]"
2157
2158NOTE: "program" "." has been moved to <programSingleItem>.
2159*/
2160progEnvParam
2161 "env" .emit PROGRAM_PARAM_ENV .and lbracket .and progEnvParamNum .and rbracket .emit 0x00;
2162
2163/*
2164 <progLocalParams> ::= "program" "." "local"
2165 "[" <progLocalParamNums> "]"
2166
2167NOTE: "program" "." has been moved to <programMultipleItem>.
2168*/
2169progLocalParams
2170 "local" .emit PROGRAM_PARAM_LOCAL .and lbracket .and progLocalParamNums .and rbracket;
2171
2172/*
2173 <progLocalParamNums> ::= <progLocalParamNum>
2174 | <progLocalParamNum> ".." <progLocalParamNum>
2175*/
2176progLocalParamNums
2177 progLocalParamNums_1 .or progLocalParamNums_2;
2178progLocalParamNums_1
2179 progLocalParamNum .and dotdot_ne .and progLocalParamNum;
2180progLocalParamNums_2
2181 progLocalParamNum .and .true .emit 0x00;
2182
2183/*
2184 <progLocalParam> ::= "program" "." "local"
2185 "[" <progLocalParamNum> "]"
2186
2187NOTE: "program" "." has been moved to <programSingleItem>.
2188*/
2189progLocalParam
2190 "local" .emit PROGRAM_PARAM_LOCAL .and lbracket .and progLocalParamNum .and rbracket .emit 0x00;
2191
2192/*
2193 <progEnvParamNum> ::= <integer> from 0 to
2194 MAX_PROGRAM_ENV_PARAMETERS_ARB - 1
2195*/
2196progEnvParamNum
2197 integer;
2198
2199/*
2200 <progLocalParamNum> ::= <integer> from 0 to
2201 MAX_PROGRAM_LOCAL_PARAMETERS_ARB - 1
2202*/
2203progLocalParamNum
2204 integer;
2205
2206/*
2207 <paramConstDecl> ::= <paramConstScalarDecl>
2208 | <paramConstVector>
2209*/
2210paramConstDecl
2211 paramConstScalarDecl .emit CONSTANT_SCALAR .or paramConstVector .emit CONSTANT_VECTOR;
2212
2213/*
2214 <paramConstUse> ::= <paramConstScalarUse>
2215 | <paramConstVector>
2216*/
2217paramConstUse
2218 paramConstScalarUse .emit CONSTANT_SCALAR .or paramConstVector .emit CONSTANT_VECTOR;
2219
2220/*
2221 <paramConstScalarDecl> ::= <signedFloatConstant>
2222*/
2223paramConstScalarDecl
2224 signedFloatConstant;
2225
2226/*
2227 <paramConstScalarUse> ::= <floatConstant>
2228*/
2229paramConstScalarUse
2230 floatConstant;
2231
2232/*
2233 <paramConstVector> ::= "{" <signedFloatConstant> "}"
2234 | "{" <signedFloatConstant> ","
2235 <signedFloatConstant> "}"
2236 | "{" <signedFloatConstant> ","
2237 <signedFloatConstant> ","
2238 <signedFloatConstant> "}"
2239 | "{" <signedFloatConstant> ","
2240 <signedFloatConstant> ","
2241 <signedFloatConstant> ","
2242 <signedFloatConstant> "}"
2243*/
2244paramConstVector
2245 paramConstVector_4 .emit 0x04 .or paramConstVector_3 .emit 0x03 .or
2246 paramConstVector_2 .emit 0x02 .or paramConstVector_1 .emit 0x01;
2247paramConstVector_1
2248 lbrace_ne .and signedFloatConstant .and rbrace;
2249paramConstVector_2
2250 lbrace_ne .and signedFloatConstant .and comma_ne .and signedFloatConstant .and rbrace;
2251paramConstVector_3
2252 lbrace_ne .and signedFloatConstant .and comma_ne .and signedFloatConstant .and comma_ne .and
2253 signedFloatConstant .and rbrace;
2254paramConstVector_4
2255 lbrace_ne .and signedFloatConstant .and comma_ne .and signedFloatConstant .and comma_ne .and
2256 signedFloatConstant .and comma_ne .and signedFloatConstant .and rbrace;
2257
2258/*
2259 <signedFloatConstant> ::= <optionalSign> <floatConstant>
2260*/
2261signedFloatConstant
2262 optionalSign .and floatConstant;
2263
2264/*
2265 <floatConstant> ::= see text
2266 The <floatConstant> rule matches a floating-point constant consisting
2267 of an integer part, a decimal point, a fraction part, an "e" or
2268 "E", and an optionally signed integer exponent. The integer and
2269 fraction parts both consist of a sequence of one or more digits ("0"
2270 through "9"). Either the integer part or the fraction parts (not
2271 both) may be missing; either the decimal point or the "e" (or "E")
2272 and the exponent (not both) may be missing.
2273*/
2274floatConstant
2275 float;
2276
2277/*
2278 <optionalSign> ::= ""
2279 | "-"
2280 | "+"
2281*/
2282optionalSign
2283 optional_sign_ne;
2284
2285/*
2286 <TEMP_statement> ::= "TEMP" <varNameList>
2287*/
2288fp_TEMP_statement
2289 "TEMP" .and space .and fp_varNameList .and .true .emit 0x00;
2290vp_TEMP_statement
2291 "TEMP" .and space .and vp_varNameList .and .true .emit 0x00;
2292
2293/*
2294vertex program
2295 <ADDRESS_statement> ::= "ADDRESS" <varNameList>
2296*/
2297ADDRESS_statement
2298 "ADDRESS" .and space .and vp_varNameList .and .true .emit 0x00;
2299
2300/*
2301 <varNameList> ::= <establishName>
2302 | <establishName> "," <varNameList>
2303*/
2304fp_varNameList
2305 fp_varNameList_1 .or fp_establishName;
2306vp_varNameList
2307 vp_varNameList_1 .or vp_establishName;
2308fp_varNameList_1
2309 fp_establishName .and comma_ne .and fp_varNameList;
2310vp_varNameList_1
2311 vp_establishName .and comma_ne .and vp_varNameList;
2312
2313/*
2314 <OUTPUT_statement> ::= "OUTPUT" <establishName> "="
2315 <resultBinding>
2316*/
2317fp_OUTPUT_statement
2318 "OUTPUT" .and space .and fp_establishName .and equal .and
2319 fp_resultBinding .error RESULT_EXPECTED;
2320vp_OUTPUT_statement
2321 "OUTPUT" .and space .and vp_establishName .and equal .and
2322 vp_resultBinding .error RESULT_EXPECTED;
2323
2324/*
Brian Paulbe76b7f2004-10-04 14:40:05 +00002325 From ARB_draw_buffers:
Michal Krola904b492004-03-04 13:07:52 +00002326fragment program
Brian Paulbe76b7f2004-10-04 14:40:05 +00002327 <resultBinding> ::= "result" "." "color" <optOutputColorNum>
Michal Krola904b492004-03-04 13:07:52 +00002328 | "result" "." "depth"
2329
2330vertex program
2331 <resultBinding> ::= "result" "." "position"
2332 | "result" "." <resultColBinding>
2333 | "result" "." "fogcoord"
2334 | "result" "." "pointsize"
2335 | "result" "." "texcoord" <optTexCoordNum>
2336*/
2337fp_resultBinding
2338 "result" .and dot .and fp_resultBinding_1 .error INVALID_RESULT_PROPERTY;
2339vp_resultBinding
2340 "result" .and dot .and vp_resultBinding_1 .error INVALID_RESULT_PROPERTY;
2341fp_resultBinding_1
Brian Paulbe76b7f2004-10-04 14:40:05 +00002342 fp_resultBinding_2 .emit FRAGMENT_RESULT_COLOR .or
Michal Krola904b492004-03-04 13:07:52 +00002343 "depth" .emit FRAGMENT_RESULT_DEPTH;
Brian Paulbe76b7f2004-10-04 14:40:05 +00002344fp_resultBinding_2
2345 "color" .and optOutputColorNum;
Michal Krola904b492004-03-04 13:07:52 +00002346vp_resultBinding_1
2347 .if (ARB_position_invariant == 0x00) "position" .emit VERTEX_RESULT_POSITION .or
2348 resultColBinding .emit VERTEX_RESULT_COLOR .or
2349 "fogcoord" .emit VERTEX_RESULT_FOGCOORD .or
2350 "pointsize" .emit VERTEX_RESULT_POINTSIZE .or
2351 vp_resultBinding_2 .emit VERTEX_RESULT_TEXCOORD;
2352vp_resultBinding_2
2353 "texcoord" .and optTexCoordNum;
2354
2355/*
2356vertex program
2357 <resultColBinding> ::= "color" <optFaceType> <optColorType>
2358*/
2359resultColBinding
2360 "color" .and optFaceType .and optColorType;
2361
2362/*
2363 <optFaceType> ::= ""
2364 | "." "front"
2365 | "." "back"
2366*/
2367optFaceType
2368 FaceType .or .true .emit FACE_FRONT;
2369FaceType
2370 dot_ne .and FaceProperty;
2371FaceProperty
2372 "front" .emit FACE_FRONT .or "back" .emit FACE_BACK;
2373
2374/*
2375 <optColorType> ::= ""
2376 | "." "primary"
2377 | "." "secondary"
2378*/
2379optColorType
2380 ColorType .or .true .emit COLOR_PRIMARY;
2381ColorType
2382 dot_ne .and ColorProperty;
2383ColorProperty
2384 "primary" .emit COLOR_PRIMARY .or
2385 .if (secondary_color != 0x00) "secondary" .emit COLOR_SECONDARY;
2386
2387/*
2388 <ALIAS_statement> ::= "ALIAS" <establishName> "="
2389 <establishedName>
2390*/
2391fp_ALIAS_statement
2392 "ALIAS" .and fp_ALIAS_statement_1 .error IDENTIFIER_EXPECTED .and equal .and fp_establishedName;
2393vp_ALIAS_statement
2394 "ALIAS" .and vp_ALIAS_statement_1 .error IDENTIFIER_EXPECTED .and equal .and vp_establishedName;
2395fp_ALIAS_statement_1
2396 space .and fp_establishName;
2397vp_ALIAS_statement_1
2398 space .and vp_establishName;
2399
2400/*
2401 <establishName> ::= <identifier>
2402*/
2403fp_establishName
2404 fp_identifier;
2405vp_establishName
2406 vp_identifier;
2407
2408/*
2409 <establishedName> ::= <identifier>
2410*/
2411fp_establishedName
2412 fp_identifier;
2413vp_establishedName
2414 vp_identifier;
2415fp_establishedName_no_error_on_identifier
2416 fp_identifier_ne;
2417vp_establishedName_no_error_on_identifier
2418 vp_identifier_ne;
2419
2420/*
2421fragment program
2422 <identifier> ::= see text
2423 The <identifier> rule matches a sequence of one or more letters ("A"
2424 through "Z", "a" through "z"), digits ("0" through "9), underscores
2425 ("_"), or dollar signs ("$"); the first character must not be a
2426 number. Upper and lower case letters are considered different
2427 (names are case-sensitive). The following strings are reserved
2428 keywords and may not be used as identifiers:
2429
2430 ABS, ABS_SAT, ADD, ADD_SAT, ALIAS, ATTRIB, CMP, CMP_SAT, COS,
2431 COS_SAT, DP3, DP3_SAT, DP4, DP4_SAT, DPH, DPH_SAT, DST, DST_SAT,
2432 END, EX2, EX2_SAT, FLR, FLR_SAT, FRC, FRC_SAT, KIL, LG2,
2433 LG2_SAT, LIT, LIT_SAT, LRP, LRP_SAT, MAD, MAD_SAT, MAX, MAX_SAT,
2434 MIN, MIN_SAT, MOV, MOV_SAT, MUL, MUL_SAT, OPTION, OUTPUT, PARAM,
2435 POW, POW_SAT, RCP, RCP_SAT, RSQ, RSQ_SAT, SIN, SIN_SAT, SCS,
2436 SCS_SAT, SGE, SGE_SAT, SLT, SLT_SAT, SUB, SUB_SAT, SWZ, SWZ_SAT,
2437 TEMP, TEX, TEX_SAT, TXB, TXB_SAT, TXP, TXP_SAT, XPD, XPD_SAT,
2438 fragment, program, result, state, and texture.
2439
2440vertex program
2441 <identifier> ::= see text
2442 The <identifier> rule matches a sequence of one or more letters ("A"
2443 through "Z", "a" through "z"), digits ("0" through "9), underscores ("_"),
2444 or dollar signs ("$"); the first character must not be a number. Upper
2445 and lower case letters are considered different (names are
2446 case-sensitive). The following strings are reserved keywords and may not
2447 be used as identifiers:
2448
2449 ABS, ADD, ADDRESS, ALIAS, ARL, ATTRIB, DP3, DP4, DPH, DST, END, EX2,
2450 EXP, FLR, FRC, LG2, LIT, LOG, MAD, MAX, MIN, MOV, MUL, OPTION, OUTPUT,
2451 PARAM, POW, RCP, RSQ, SGE, SLT, SUB, SWZ, TEMP, XPD, program, result,
2452 state, and vertex.
2453*/
2454fp_identifier
2455 fp_identifier_ne .error IDENTIFIER_EXPECTED;
2456vp_identifier
2457 vp_identifier_ne .error IDENTIFIER_EXPECTED;
2458fp_identifier_ne
2459 fp_not_reserved_identifier .and identifier_ne;
2460vp_identifier_ne
2461 vp_not_reserved_identifier .and identifier_ne;
2462
2463fp_not_reserved_identifier
2464 fp_not_reserved_identifier_1 .or .true;
2465fp_not_reserved_identifier_1
2466 fp_reserved_identifier .and .false .error RESERVED_KEYWORD;
2467vp_not_reserved_identifier
2468 vp_not_reserved_identifier_1 .or .true;
2469vp_not_reserved_identifier_1
2470 vp_reserved_identifier .and .false .error RESERVED_KEYWORD;
2471
2472fp_reserved_identifier
2473 "ABS" .or "ABS_SAT" .or "ADD" .or "ADD_SAT" .or "ALIAS" .or "ATTRIB" .or "CMP" .or "CMP_SAT" .or
2474 "COS" .or "COS_SAT" .or "DP3" .or "DP3_SAT" .or "DP4" .or "DP4_SAT" .or "DPH" .or "DPH_SAT" .or
2475 "DST" .or "DST_SAT" .or "END" .or "EX2" .or "EX2_SAT" .or "FLR" .or "FLR_SAT" .or "FRC" .or
2476 "FRC_SAT" .or "KIL" .or "LG2" .or "LG2_SAT" .or "LIT" .or "LIT_SAT" .or "LRP" .or "LRP_SAT" .or
2477 "MAD" .or "MAD_SAT" .or "MAX" .or "MAX_SAT" .or "MIN" .or "MIN_SAT" .or "MOV" .or "MOV_SAT" .or
2478 "MUL" .or "MUL_SAT" .or "OPTION" .or "OUTPUT" .or "PARAM" .or "POW" .or "POW_SAT" .or "RCP" .or
2479 "RCP_SAT" .or "RSQ" .or "RSQ_SAT" .or "SIN" .or "SIN_SAT" .or "SCS" .or "SCS_SAT" .or "SGE" .or
2480 "SGE_SAT" .or "SLT" .or "SLT_SAT" .or "SUB" .or "SUB_SAT" .or "SWZ" .or "SWZ_SAT" .or "TEMP" .or
2481 "TEX" .or "TEX_SAT" .or "TXB" .or "TXB_SAT" .or "TXP" .or "TXP_SAT" .or "XPD" .or "XPD_SAT" .or
2482 "fragment" .or "program" .or "result" .or "state" .or "texture";
2483vp_reserved_identifier
2484 "ABS" .or "ADD" .or "ADDRESS" .or "ALIAS" .or "ARL" .or "ATTRIB" .or "DP3" .or "DP4" .or
2485 "DPH" .or "DST" .or "END" .or "EX2" .or "EXP" .or "FLR" .or "FRC" .or "LG2" .or "LIT" .or
2486 "LOG" .or "MAD" .or "MAX" .or "MIN" .or "MOV" .or "MUL" .or "OPTION" .or "OUTPUT" .or
2487 "PARAM" .or "POW" .or "RCP" .or "RSQ" .or "SGE" .or "SLT" .or "SUB" .or "SWZ" .or "TEMP" .or
2488 "XPD" .or "program" .or "result" .or "state" .or "vertex";
2489
2490/*
2491 The <integer> rule matches an integer constant. The integer consists
2492 of a sequence of one or more digits ("0" through "9").
2493*/
2494integer
2495 integer_ne .error INTEGER_EXPECTED;
2496
2497zero
2498 '0';
2499
2500leading_zeroes
2501 .loop zero;
2502
2503no_digit
2504 no_digit_1 .or .true;
2505no_digit_1
2506 digit10 .and .false .error INTEGER_OUT_OF_RANGE;
2507
2508all_zeroes
2509 all_zeroes_1 .or no_digit_1;
2510all_zeroes_1
2511 '0' .and .loop zero .and no_digit;
2512
2513integer_0_3
2514 integer_0_3_1 .error INTEGER_EXPECTED .and .true .emit 0x00 .emit $;
2515integer_0_3_1
2516 integer_0_3_2 .or all_zeroes .emit '0';
2517integer_0_3_2 /* [1, 3] */
2518 leading_zeroes .and '1'-'3' .emit * .and no_digit;
2519
2520integer_0_63
2521 integer_0_63_1 .error INTEGER_EXPECTED .and .true .emit 0x00 .emit $;
2522integer_0_63_1
2523 integer_0_63_2 .or integer_0_63_3 .or integer_0_63_4 .or integer_0_63_5 .or
2524 all_zeroes .emit '0';
2525integer_0_63_2 /* [7, 9] */
2526 leading_zeroes .and '7'-'9' .emit * .and no_digit;
2527integer_0_63_3 /* [10, 59] */
2528 leading_zeroes .and '1'-'5' .emit * .and '0'-'9' .emit * .and no_digit;
2529integer_0_63_4 /* [60, 63] */
2530 leading_zeroes .and '6' .emit * .and '0'-'3' .emit * .and no_digit;
2531integer_0_63_5 /* [1, 6] */
2532 leading_zeroes .and '1'-'6' .emit * .and no_digit;
2533
2534integer_0_64
2535 integer_0_64_1 .error INTEGER_EXPECTED .and .true .emit 0x00 .emit $;
2536integer_0_64_1
2537 integer_0_64_2 .or integer_0_64_3 .or integer_0_64_4 .or integer_0_64_5 .or
2538 all_zeroes .emit '0';
2539integer_0_64_2 /* [7, 9] */
2540 leading_zeroes .and '7'-'9' .emit * .and no_digit;
2541integer_0_64_3 /* [10, 59] */
2542 leading_zeroes .and '1'-'5' .emit * .and '0'-'9' .emit * .and no_digit;
2543integer_0_64_4 /* [60, 64] */
2544 leading_zeroes .and '6' .emit * .and '0'-'4' .emit * .and no_digit;
2545integer_0_64_5 /* [1, 6] */
2546 leading_zeroes .and '1'-'6' .emit * .and no_digit;
2547
2548optional_space
2549 space .or .true;
2550
2551space_dst
2552 space .error OPERATION_NEEDS_DESTINATION_VARIABLE;
2553
2554space_src
2555 space .error OPERATION_NEEDS_SOURCE_VARIABLE;
2556
2557space
2558 single_space .and .loop single_space;
2559
2560single_space
2561 white_char .or comment_block;
2562
2563white_char
2564 ' ' .or '\t' .or '\n' .or '\r';
2565
2566comment_block
2567 '#' .and .loop comment_char .and new_line;
2568
2569/* All ASCII characters except '\r', '\n' and '\0' */
2570comment_char
2571 '\x0E'-'\xFF' .or '\x01'-'\x09' .or '\x0B'-'\x0C';
2572
2573new_line
2574 '\n' .or crlf .or '\0';
2575
2576crlf
2577 '\r' .and '\n';
2578
2579semicolon
2580 optional_space .and ';' .error MISSING_SEMICOLON .and optional_space;
2581
2582comma
2583 optional_space .and ',' .error MISSING_COMMA .and optional_space;
2584
2585comma_ne
2586 optional_space .and ',' .and optional_space;
2587
2588lbracket
2589 optional_space .and '[' .error MISSING_LBRACKET .and optional_space;
2590
2591lbracket_ne
2592 optional_space .and '[' .and optional_space;
2593
2594rbracket
2595 optional_space .and ']' .error MISSING_RBRACKET .and optional_space;
2596
2597dot
2598 optional_space .and '.' .error MISSING_DOT .and optional_space;
2599
2600dot_ne
2601 optional_space .and '.' .and optional_space;
2602
2603equal
2604 optional_space .and '=' .error MISSING_EQUAL .and optional_space;
2605
2606lbrace
2607 optional_space .and '{' .error MISSING_LBRACE .and optional_space;
2608
2609lbrace_ne
2610 optional_space .and '{' .and optional_space;
2611
2612rbrace
2613 optional_space .and '}' .error MISSING_RBRACE .and optional_space;
2614
2615dotdot
2616 optional_space .and '.' .and '.' .error MISSING_DOTDOT .and optional_space;
2617
2618dotdot_ne
2619 optional_space .and '.' .and '.' .and optional_space;
2620
2621/*
2622 The definition below accepts the following floating point number formats:
2623 .99 .99e99 99. 99.99 99.99e99 99.e99 99e99
2624 Also 99 format was considered and accepted because of a large number of existing program
2625 strings with such a format.
2626*/
2627float
2628 float_1 .or float_2 .or float_legacy;
2629float_1
2630 '.' .emit 0x00 .and integer_ne .error MISSING_FRACTION_OR_EXPONENT .and optional_exponent;
2631float_2
2632 integer_ne .and float_3;
2633float_3
2634 float_4 .or float_5;
2635float_4
2636 '.' .and optional_integer .and optional_exponent;
2637float_5
2638 exponent .emit 0x00;
2639float_legacy
2640 integer_ne .and .true .emit 0x00 .emit 0x00;
2641
2642/*
2643 Below is a correct version of <float> definiton.
2644*/
2645/*
2646float
2647 float_1 .or float_2;
2648float_1
2649 '.' .emit 0x00 .and integer_ne .error MISSING_FRACTION_OR_EXPONENT .and optional_exponent;
2650float_2
2651 integer_ne .and float_3 .error MISSING_DOT_OR_EXPONENT;
2652float_3
2653 float_4 .or float_5;
2654float_4
2655 '.' .and optional_integer .and optional_exponent;
2656float_5
2657 exponent .emit 0x00;
2658*/
2659
2660integer_ne
2661 integer_ne_1 .and .true .emit 0x00 .emit $;
2662integer_ne_1
2663 digit10 .emit * .and .loop digit10 .emit *;
2664
2665optional_integer
2666 integer_ne .or .true .emit 0x00;
2667
2668/*
2669NOTE: If exponent part is omited we treat it as if it was "E+1".
2670*/
2671optional_exponent
2672 exponent .or .true .emit 0x00;
2673
2674exponent
2675 exponent_1 .and optional_sign_ne .and integer_ne .error EXPONENT_VALUE_EXPECTED;
2676exponent_1
2677 'e' .or 'E';
2678
2679optional_sign_ne
2680 minus_ne .or plus_ne .or .true;
2681
2682plus_ne
2683 optional_space .and '+' .and optional_space;
2684
2685minus_ne
2686 optional_space .and '-' .emit '-' .and optional_space;
2687
2688identifier_ne
2689 first_idchar .emit * .and .loop follow_idchar .emit * .and .true .emit 0x00 .emit $;
2690
2691follow_idchar
2692 first_idchar .or digit10;
2693
2694first_idchar
2695 'a'-'z' .or 'A'-'Z' .or '_' .or '$';
2696
2697digit10
2698 '0'-'9';
2699
2700/*
2701 string filtering - if a string is encountered in grammar ("blabla"), the symbol below is
2702 executed to create the string. The symbol must not throw any errors and emit bytes - it should
2703 stop if it encounters invalid character. After this the resulting string (from starting
2704 position up to the invalid character (but without it) is compared with the grammar string.
2705*/
2706.string __string_filter;
2707
2708__string_filter
2709 .loop __identifier_char;
2710
2711__identifier_char
2712 'a'-'z' .or 'A'-'Z' .or '_' .or '$' .or '0'-'9';
2713
2714/*
2715 error token filtering
2716*/
2717e_signature
2718 e_signature_char .and .loop e_signature_char;
2719e_signature_char
2720 '!' .or '.' .or 'A'-'Z' .or 'a'-'z' .or '0'-'9';
2721
2722e_statement
2723 .loop e_statement_not_term;
2724/* All ASCII characters to one of '\r', '\n', '\0' and ';' */
2725e_statement_not_term
2726 '\x3C'-'\xFF' .or '\x0E'-'\x3A' .or '\x01'-'\x09' .or '\x0B'-'\x0C';
2727
2728e_identifier
2729 e_identifier_first .and .loop e_identifier_next;
2730e_identifier_first
2731 'a'-'z' .or 'A'-'Z' .or '_' .or '$';
2732e_identifier_next
2733 e_identifier_first .or '0'-'9';
2734
2735e_token
2736 e_identifier .or e_token_number .or '[' .or ']' .or '.' .or '{' .or '}' .or '=' .or '+' .or
2737 '-' .or ',' .or ';';
2738e_token_number
2739 e_token_digit .and .loop e_token_digit;
2740e_token_digit
2741 '0'-'9';
2742
2743e_charordigit
2744 'A'-'Z' .or 'a'-'z' .or '0'-'9';
2745