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