3 * Copyright © 2009 Intel Corporation
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
28 #include "main/mtypes.h"
29 #include "prog_parameter.h"
30 #include "prog_parameter_layout.h"
31 #include "prog_statevars.h"
32 #include "prog_instruction.h"
34 #include "symbol_table.h"
35 #include "program_parser.h"
37 extern void *yy_scan_string(char *);
38 extern void yy_delete_buffer(void *);
40 static struct asm_symbol *declare_variable(struct asm_parser_state *state,
41 char *name, enum asm_type t, struct YYLTYPE *locp);
43 static int initialize_symbol_from_state(struct gl_program *prog,
44 struct asm_symbol *param_var, const gl_state_index tokens[STATE_LENGTH]);
46 static int initialize_symbol_from_param(struct gl_program *prog,
47 struct asm_symbol *param_var, const gl_state_index tokens[STATE_LENGTH]);
49 static int initialize_symbol_from_const(struct gl_program *prog,
50 struct asm_symbol *param_var, const struct asm_vector *vec);
52 static int yyparse(struct asm_parser_state *state);
54 static void yyerror(struct YYLTYPE *locp, struct asm_parser_state *state,
57 static int validate_inputs(struct YYLTYPE *locp,
58 struct asm_parser_state *state);
60 static void init_dst_reg(struct prog_dst_register *r);
62 static void init_src_reg(struct asm_src_register *r);
64 static struct asm_instruction *asm_instruction_ctor(gl_inst_opcode op,
65 const struct prog_dst_register *dst, const struct asm_src_register *src0,
66 const struct asm_src_register *src1, const struct asm_src_register *src2);
73 #define YYLLOC_DEFAULT(Current, Rhs, N) \
76 (Current).first_line = YYRHSLOC(Rhs, 1).first_line; \
77 (Current).first_column = YYRHSLOC(Rhs, 1).first_column; \
78 (Current).position = YYRHSLOC(Rhs, 1).position; \
79 (Current).last_line = YYRHSLOC(Rhs, N).last_line; \
80 (Current).last_column = YYRHSLOC(Rhs, N).last_column; \
82 (Current).first_line = YYRHSLOC(Rhs, 0).last_line; \
83 (Current).last_line = (Current).first_line; \
84 (Current).first_column = YYRHSLOC(Rhs, 0).last_column; \
85 (Current).last_column = (Current).first_column; \
86 (Current).position = YYRHSLOC(Rhs, 0).position \
87 + (Current).first_column; \
91 #define YYLEX_PARAM state->scanner
96 %parse-param { struct asm_parser_state *state }
98 %lex-param { void *scanner }
101 struct asm_instruction *inst;
102 struct asm_symbol *sym;
103 struct asm_symbol temp_sym;
104 struct asm_swizzle_mask swiz_mask;
105 struct asm_src_register src_reg;
106 struct prog_dst_register dst_reg;
107 struct prog_instruction temp_inst;
115 struct asm_vector vector;
116 gl_inst_opcode opcode;
119 %token ARBvp_10 ARBfp_10
121 /* Tokens for assembler pseudo-ops */
122 %token <integer> ADDRESS
126 %token <integer> TEMP
129 /* Tokens for instructions */
130 %token <temp_inst> BIN_OP BINSC_OP SAMPLE_OP SCALAR_OP TRI_OP VECTOR_OP
131 %token <temp_inst> ARL KIL SWZ
133 %token <integer> INTEGER
136 %token AMBIENT ATTENUATION
139 %token DEPTH DIFFUSE DIRECTION
140 %token EMISSION ENV EYE
141 %token FOG FOGCOORD FRAGMENT FRONT
143 %token INVERSE INVTRANS
144 %token LIGHT LIGHTMODEL LIGHTPROD LOCAL
145 %token MATERIAL MAT_PROGRAM MATRIX MATRIXINDEX MODELVIEW MVP
148 %token PALETTE PARAMS PLANE POINT POINTSIZE POSITION PRIMARY PROGRAM PROJECTION
149 %token RANGE RESULT ROW
150 %token SCENECOLOR SECONDARY SHININESS SIZE SPECULAR SPOT STATE
151 %token TEXCOORD TEXENV TEXGEN TEXGEN_Q TEXGEN_R TEXGEN_S TEXGEN_T TEXTURE TRANSPOSE
152 %token TEXTURE_UNIT TEX_1D TEX_2D TEX_3D TEX_CUBE TEX_RECT
153 %token VERTEX VTXATTRIB
156 %token <string> IDENTIFIER
157 %token <swiz_mask> MASK4 MASK3 MASK2 MASK1 SWIZZLE
161 %type <inst> instruction ALU_instruction TexInstruction
162 %type <inst> ARL_instruction VECTORop_instruction
163 %type <inst> SCALARop_instruction BINSCop_instruction BINop_instruction
164 %type <inst> TRIop_instruction SWZ_instruction SAMPLE_instruction
165 %type <inst> KIL_instruction
167 %type <dst_reg> dstReg maskedDstReg maskedAddrReg
168 %type <src_reg> srcReg scalarSrcReg swizzleSrcReg
169 %type <swiz_mask> scalarSuffix swizzleSuffix extendedSwizzle extSwizComp
170 %type <swiz_mask> optionalMask
171 %type <integer> extSwizSel
173 %type <sym> progParamArray
174 %type <integer> addrRegRelOffset addrRegPosOffset addrRegNegOffset
175 %type <src_reg> progParamArrayMem progParamArrayAbs progParamArrayRel
177 %type <swiz_mask> addrComponent addrWriteMask
179 %type <result> resultBinding resultColBinding
180 %type <integer> optFaceType optColorType
181 %type <integer> optResultFaceType optResultColorType
183 %type <integer> optTexImageUnitNum texImageUnitNum
184 %type <integer> optTexCoordUnitNum texCoordUnitNum
185 %type <integer> optLegacyTexUnitNum legacyTexUnitNum
186 %type <integer> texImageUnit texTarget
187 %type <integer> vtxAttribNum
189 %type <attrib> attribBinding vtxAttribItem fragAttribItem
191 %type <temp_sym> paramSingleInit paramSingleItemDecl
192 %type <integer> optArraySize
194 %type <state> stateSingleItem stateMultipleItem
195 %type <state> stateMaterialItem
196 %type <state> stateLightItem stateLightModelItem stateLightProdItem
197 %type <state> stateTexGenItem stateFogItem stateClipPlaneItem statePointItem
198 %type <state> stateMatrixItem stateMatrixRow stateMatrixRows
199 %type <state> stateTexEnvItem
201 %type <state> stateLModProperty
202 %type <state> stateMatrixName optMatrixRows
204 %type <integer> stateMatProperty
205 %type <integer> stateLightProperty stateSpotProperty
206 %type <integer> stateLightNumber stateLProdProperty
207 %type <integer> stateTexGenType stateTexGenCoord
208 %type <integer> stateTexEnvProperty
209 %type <integer> stateFogProperty
210 %type <integer> stateClipPlaneNum
211 %type <integer> statePointProperty
213 %type <integer> stateOptMatModifier stateMatModifier stateMatrixRowNum
214 %type <integer> stateOptModMatNum stateModMatNum statePaletteMatNum
215 %type <integer> stateProgramMatNum
217 %type <integer> ambDiffSpecProperty
219 %type <state> programSingleItem progEnvParam progLocalParam
220 %type <state> programMultipleItem progEnvParams progLocalParams
222 %type <temp_sym> paramMultipleInit paramMultInitList paramMultipleItem
223 %type <temp_sym> paramSingleItemUse
225 %type <integer> progEnvParamNum progLocalParamNum
226 %type <state> progEnvParamNums progLocalParamNums
228 %type <vector> paramConstDecl paramConstUse
229 %type <vector> paramConstScalarDecl paramConstScalarUse paramConstVector
230 %type <real> signedFloatConstant
231 %type <negate> optionalSign
234 extern int yylex(YYSTYPE *yylval_param, YYLTYPE *yylloc_param,
240 program: language optionSequence statementSequence END
245 if (state->prog->Target != GL_VERTEX_PROGRAM_ARB) {
246 yyerror(& @1, state, "invalid fragment program header");
249 state->mode = ARB_vertex;
253 if (state->prog->Target != GL_FRAGMENT_PROGRAM_ARB) {
254 yyerror(& @1, state, "invalid vertex program header");
256 state->mode = ARB_fragment;
260 optionSequence: optionSequence option
264 option: OPTION IDENTIFIER ';'
268 if (state->mode == ARB_vertex) {
269 valid = _mesa_ARBvp_parse_option(state, $2);
270 } else if (state->mode == ARB_fragment) {
271 valid = _mesa_ARBfp_parse_option(state, $2);
276 yyerror(& @2, state, "invalid option string");
282 statementSequence: statementSequence statement
286 statement: instruction ';'
289 if (state->inst_tail == NULL) {
290 state->inst_head = $1;
292 state->inst_tail->next = $1;
295 state->inst_tail = $1;
298 state->prog->NumInstructions++;
301 | namingStatement ';'
304 instruction: ALU_instruction
307 state->prog->NumAluInstructions++;
312 state->prog->NumTexInstructions++;
316 ALU_instruction: ARL_instruction
317 | VECTORop_instruction
318 | SCALARop_instruction
319 | BINSCop_instruction
325 TexInstruction: SAMPLE_instruction
329 ARL_instruction: ARL maskedAddrReg ',' scalarSrcReg
331 $$ = asm_instruction_ctor(OPCODE_ARL, & $2, & $4, NULL, NULL);
335 VECTORop_instruction: VECTOR_OP maskedDstReg ',' swizzleSrcReg
337 $$ = asm_instruction_ctor($1.Opcode, & $2, & $4, NULL, NULL);
338 $$->Base.SaturateMode = $1.SaturateMode;
342 SCALARop_instruction: SCALAR_OP maskedDstReg ',' scalarSrcReg
344 $$ = asm_instruction_ctor($1.Opcode, & $2, & $4, NULL, NULL);
345 $$->Base.SaturateMode = $1.SaturateMode;
349 BINSCop_instruction: BINSC_OP maskedDstReg ',' scalarSrcReg ',' scalarSrcReg
351 $$ = asm_instruction_ctor($1.Opcode, & $2, & $4, & $6, NULL);
352 $$->Base.SaturateMode = $1.SaturateMode;
357 BINop_instruction: BIN_OP maskedDstReg ',' swizzleSrcReg ',' swizzleSrcReg
359 $$ = asm_instruction_ctor($1.Opcode, & $2, & $4, & $6, NULL);
360 $$->Base.SaturateMode = $1.SaturateMode;
364 TRIop_instruction: TRI_OP maskedDstReg ','
365 swizzleSrcReg ',' swizzleSrcReg ',' swizzleSrcReg
367 $$ = asm_instruction_ctor($1.Opcode, & $2, & $4, & $6, & $8);
368 $$->Base.SaturateMode = $1.SaturateMode;
372 SAMPLE_instruction: SAMPLE_OP maskedDstReg ',' swizzleSrcReg ',' texImageUnit ',' texTarget
374 $$ = asm_instruction_ctor($1.Opcode, & $2, & $4, NULL, NULL);
376 $$->Base.SaturateMode = $1.SaturateMode;
377 $$->Base.TexSrcUnit = $6;
378 $$->Base.TexSrcTarget = $8;
380 state->prog->TexturesUsed[$6] |= (1U << $8);
385 KIL_instruction: KIL swizzleSrcReg
387 $$ = asm_instruction_ctor(OPCODE_KIL, NULL, & $2, NULL, NULL);
388 state->fragment.UsesKill = 1;
392 texImageUnit: TEXTURE_UNIT optTexImageUnitNum
398 texTarget: TEX_1D { $$ = TEXTURE_1D_INDEX; }
399 | TEX_2D { $$ = TEXTURE_2D_INDEX; }
400 | TEX_3D { $$ = TEXTURE_3D_INDEX; }
401 | TEX_CUBE { $$ = TEXTURE_CUBE_INDEX; }
402 | TEX_RECT { $$ = TEXTURE_RECT_INDEX; }
405 SWZ_instruction: SWZ maskedDstReg ',' srcReg ',' extendedSwizzle
407 /* FIXME: Is this correct? Should the extenedSwizzle be applied
408 * FIXME: to the existing swizzle?
410 $4.Base.Swizzle = $6.swizzle;
412 $$ = asm_instruction_ctor(OPCODE_SWZ, & $2, & $4, NULL, NULL);
413 $$->Base.SaturateMode = $1.SaturateMode;
417 scalarSrcReg: optionalSign srcReg scalarSuffix
422 $$.Base.Negate = ~$$.Base.Negate;
425 $$.Base.Swizzle = _mesa_combine_swizzles($$.Base.Swizzle,
430 swizzleSrcReg: optionalSign srcReg swizzleSuffix
435 $$.Base.Negate = ~$$.Base.Negate;
438 $$.Base.Swizzle = _mesa_combine_swizzles($$.Base.Swizzle,
443 maskedDstReg: dstReg optionalMask
446 $$.WriteMask = $2.mask;
448 if ($$.File == PROGRAM_OUTPUT) {
449 /* Technically speaking, this should check that it is in
450 * vertex program mode. However, PositionInvariant can never be
451 * set in fragment program mode, so it is somewhat irrelevant.
453 if (state->option.PositionInvariant
454 && ($$.Index == VERT_RESULT_HPOS)) {
455 yyerror(& @1, state, "position-invariant programs cannot "
460 state->prog->OutputsWritten |= (1U << $$.Index);
465 maskedAddrReg: addrReg addrWriteMask
468 $$.File = PROGRAM_ADDRESS;
470 $$.WriteMask = $2.mask;
474 extendedSwizzle: extSwizComp ',' extSwizComp ',' extSwizComp ',' extSwizComp
476 $$.swizzle = MAKE_SWIZZLE4($1.swizzle, $3.swizzle,
477 $5.swizzle, $7.swizzle);
478 $$.mask = ($1.mask) | ($3.mask << 1) | ($5.mask << 2)
483 extSwizComp: optionalSign extSwizSel
486 $$.mask = ($1) ? 1 : 0;
492 if (($1 != 0) && ($1 != 1)) {
493 yyerror(& @1, state, "invalid extended swizzle selector");
497 $$ = ($1 == 0) ? SWIZZLE_ZERO : SWIZZLE_ONE;
501 if (strlen($1) > 1) {
502 yyerror(& @1, state, "invalid extended swizzle selector");
520 yyerror(& @1, state, "invalid extended swizzle selector");
527 srcReg: IDENTIFIER /* temporaryReg | progParamSingle */
529 struct asm_symbol *const s = (struct asm_symbol *)
530 _mesa_symbol_table_find_symbol(state->st, 0, $1);
533 yyerror(& @1, state, "invalid operand variable");
535 } else if ((s->type != at_param) && (s->type != at_temp)
536 && (s->type != at_attrib)) {
537 yyerror(& @1, state, "invalid operand variable");
539 } else if ((s->type == at_param) && s->param_is_array) {
540 yyerror(& @1, state, "non-array access to array PARAM");
547 $$.Base.File = PROGRAM_TEMPORARY;
548 $$.Base.Index = s->temp_binding;
551 $$.Base.File = s->param_binding_type;
552 $$.Base.Index = s->param_binding_begin;
555 $$.Base.File = PROGRAM_INPUT;
556 $$.Base.Index = s->attrib_binding;
557 state->prog->InputsRead |= (1U << $$.Base.Index);
559 if (!validate_inputs(& @1, state)) {
572 $$.Base.File = PROGRAM_INPUT;
574 state->prog->InputsRead |= (1U << $$.Base.Index);
576 if (!validate_inputs(& @1, state)) {
580 | progParamArray '[' progParamArrayMem ']'
582 if (! $3.Base.RelAddr
583 && ($3.Base.Index >= $1->param_binding_length)) {
584 yyerror(& @3, state, "out of bounds array access");
589 $$.Base.File = $1->param_binding_type;
591 if ($3.Base.RelAddr) {
592 $1->param_accessed_indirectly = 1;
595 $$.Base.Index = $3.Base.Index;
598 $$.Base.Index = $1->param_binding_begin + $3.Base.Index;
604 $$.Base.File = ($1.name != NULL)
605 ? $1.param_binding_type
607 $$.Base.Index = $1.param_binding_begin;
611 dstReg: resultBinding
614 $$.File = PROGRAM_OUTPUT;
617 | IDENTIFIER /* temporaryReg | vertexResultReg */
619 struct asm_symbol *const s = (struct asm_symbol *)
620 _mesa_symbol_table_find_symbol(state->st, 0, $1);
623 yyerror(& @1, state, "invalid operand variable");
625 } else if ((s->type != at_output) && (s->type != at_temp)) {
626 yyerror(& @1, state, "invalid operand variable");
631 if (s->type == at_temp) {
632 $$.File = PROGRAM_TEMPORARY;
633 $$.Index = s->temp_binding;
635 $$.File = s->param_binding_type;
636 $$.Index = s->param_binding_begin;
641 progParamArray: IDENTIFIER
643 struct asm_symbol *const s = (struct asm_symbol *)
644 _mesa_symbol_table_find_symbol(state->st, 0, $1);
647 yyerror(& @1, state, "invalid operand variable");
649 } else if ((s->type != at_param) || !s->param_is_array) {
650 yyerror(& @1, state, "array access to non-PARAM variable");
658 progParamArrayMem: progParamArrayAbs | progParamArrayRel;
660 progParamArrayAbs: INTEGER
667 progParamArrayRel: addrReg addrComponent addrRegRelOffset
669 /* FINISHME: Add support for multiple address registers.
671 /* FINISHME: Add support for 4-component address registers.
679 addrRegRelOffset: { $$ = 0; }
680 | '+' addrRegPosOffset { $$ = $2; }
681 | '-' addrRegNegOffset { $$ = -$2; }
684 addrRegPosOffset: INTEGER
686 if (($1 < 0) || ($1 > 63)) {
688 "relative address offset too large (positive)");
696 addrRegNegOffset: INTEGER
698 if (($1 < 0) || ($1 > 64)) {
700 "relative address offset too large (negative)");
710 struct asm_symbol *const s = (struct asm_symbol *)
711 _mesa_symbol_table_find_symbol(state->st, 0, $1);
714 yyerror(& @1, state, "invalid array member");
716 } else if (s->type != at_address) {
718 "invalid variable for indexed array access");
728 if ($1.mask != WRITEMASK_X) {
729 yyerror(& @1, state, "invalid address component selector");
739 if ($1.mask != WRITEMASK_X) {
741 "address register write mask must be \".x\"");
754 | { $$.swizzle = SWIZZLE_NOOP; $$.mask = WRITEMASK_XYZW; }
757 optionalMask: MASK4 | MASK3 | MASK2 | MASK1
758 | { $$.swizzle = SWIZZLE_NOOP; $$.mask = WRITEMASK_XYZW; }
761 namingStatement: ATTRIB_statement
769 ATTRIB_statement: ATTRIB IDENTIFIER '=' attribBinding
771 struct asm_symbol *const s =
772 declare_variable(state, $2, at_attrib, & @2);
777 s->attrib_binding = $4;
778 state->InputsBound |= (1U << s->attrib_binding);
780 if (!validate_inputs(& @4, state)) {
787 attribBinding: VERTEX vtxAttribItem
791 | FRAGMENT fragAttribItem
797 vtxAttribItem: POSITION
799 $$ = VERT_ATTRIB_POS;
801 | WEIGHT vtxOptWeightNum
803 $$ = VERT_ATTRIB_WEIGHT;
807 $$ = VERT_ATTRIB_NORMAL;
811 $$ = VERT_ATTRIB_COLOR0 + $2;
815 $$ = VERT_ATTRIB_FOG;
817 | TEXCOORD optTexCoordUnitNum
819 $$ = VERT_ATTRIB_TEX0 + $2;
821 | MATRIXINDEX '[' vtxWeightNum ']'
825 | VTXATTRIB '[' vtxAttribNum ']'
827 $$ = VERT_ATTRIB_GENERIC0 + $3;
831 vtxAttribNum: INTEGER
833 if ($1 >= state->limits->MaxAttribs) {
834 yyerror(& @1, state, "invalid vertex attribute reference");
842 vtxOptWeightNum: | '[' vtxWeightNum ']';
843 vtxWeightNum: INTEGER;
845 fragAttribItem: POSITION
847 $$ = FRAG_ATTRIB_WPOS;
851 $$ = FRAG_ATTRIB_COL0 + $2;
855 $$ = FRAG_ATTRIB_FOGC;
857 | TEXCOORD optTexCoordUnitNum
859 $$ = FRAG_ATTRIB_TEX0 + $2;
863 PARAM_statement: PARAM_singleStmt | PARAM_multipleStmt;
865 PARAM_singleStmt: PARAM IDENTIFIER paramSingleInit
867 struct asm_symbol *const s =
868 declare_variable(state, $2, at_param, & @2);
873 s->param_binding_type = $3.param_binding_type;
874 s->param_binding_begin = $3.param_binding_begin;
875 s->param_binding_length = $3.param_binding_length;
876 s->param_is_array = 0;
881 PARAM_multipleStmt: PARAM IDENTIFIER '[' optArraySize ']' paramMultipleInit
883 if (($4 != 0) && ($4 != $6.param_binding_length)) {
885 "parameter array size and number of bindings must match");
888 struct asm_symbol *const s =
889 declare_variable(state, $2, $6.type, & @2);
894 s->param_binding_type = $6.param_binding_type;
895 s->param_binding_begin = $6.param_binding_begin;
896 s->param_binding_length = $6.param_binding_length;
897 s->param_is_array = 1;
909 if (($1 < 1) || ($1 >= state->limits->MaxParameters)) {
910 yyerror(& @1, state, "invalid parameter array size");
918 paramSingleInit: '=' paramSingleItemDecl
924 paramMultipleInit: '=' '{' paramMultInitList '}'
930 paramMultInitList: paramMultipleItem
931 | paramMultInitList ',' paramMultipleItem
933 $1.param_binding_length += $3.param_binding_length;
938 paramSingleItemDecl: stateSingleItem
940 memset(& $$, 0, sizeof($$));
941 $$.param_binding_begin = ~0;
942 initialize_symbol_from_state(state->prog, & $$, $1);
946 memset(& $$, 0, sizeof($$));
947 $$.param_binding_begin = ~0;
948 initialize_symbol_from_param(state->prog, & $$, $1);
952 memset(& $$, 0, sizeof($$));
953 $$.param_binding_begin = ~0;
954 initialize_symbol_from_const(state->prog, & $$, & $1);
958 paramSingleItemUse: stateSingleItem
960 memset(& $$, 0, sizeof($$));
961 $$.param_binding_begin = ~0;
962 initialize_symbol_from_state(state->prog, & $$, $1);
966 memset(& $$, 0, sizeof($$));
967 $$.param_binding_begin = ~0;
968 initialize_symbol_from_param(state->prog, & $$, $1);
972 memset(& $$, 0, sizeof($$));
973 $$.param_binding_begin = ~0;
974 initialize_symbol_from_const(state->prog, & $$, & $1);
978 paramMultipleItem: stateMultipleItem
980 memset(& $$, 0, sizeof($$));
981 $$.param_binding_begin = ~0;
982 initialize_symbol_from_state(state->prog, & $$, $1);
984 | programMultipleItem
986 memset(& $$, 0, sizeof($$));
987 $$.param_binding_begin = ~0;
988 initialize_symbol_from_param(state->prog, & $$, $1);
992 memset(& $$, 0, sizeof($$));
993 $$.param_binding_begin = ~0;
994 initialize_symbol_from_const(state->prog, & $$, & $1);
998 stateMultipleItem: stateSingleItem { memcpy($$, $1, sizeof($$)); }
999 | STATE stateMatrixRows { memcpy($$, $2, sizeof($$)); }
1002 stateSingleItem: STATE stateMaterialItem { memcpy($$, $2, sizeof($$)); }
1003 | STATE stateLightItem { memcpy($$, $2, sizeof($$)); }
1004 | STATE stateLightModelItem { memcpy($$, $2, sizeof($$)); }
1005 | STATE stateLightProdItem { memcpy($$, $2, sizeof($$)); }
1006 | STATE stateTexGenItem { memcpy($$, $2, sizeof($$)); }
1007 | STATE stateTexEnvItem { memcpy($$, $2, sizeof($$)); }
1008 | STATE stateFogItem { memcpy($$, $2, sizeof($$)); }
1009 | STATE stateClipPlaneItem { memcpy($$, $2, sizeof($$)); }
1010 | STATE statePointItem { memcpy($$, $2, sizeof($$)); }
1011 | STATE stateMatrixRow { memcpy($$, $2, sizeof($$)); }
1014 stateMaterialItem: MATERIAL optFaceType stateMatProperty
1016 memset($$, 0, sizeof($$));
1017 $$[0] = STATE_MATERIAL;
1023 stateMatProperty: ambDiffSpecProperty
1029 $$ = STATE_EMISSION;
1033 $$ = STATE_SHININESS;
1037 stateLightItem: LIGHT '[' stateLightNumber ']' stateLightProperty
1039 memset($$, 0, sizeof($$));
1040 $$[0] = STATE_LIGHT;
1046 stateLightProperty: ambDiffSpecProperty
1052 $$ = STATE_POSITION;
1056 $$ = STATE_ATTENUATION;
1058 | SPOT stateSpotProperty
1064 $$ = STATE_HALF_VECTOR;
1068 stateSpotProperty: DIRECTION
1070 $$ = STATE_SPOT_DIRECTION;
1074 stateLightModelItem: LIGHTMODEL stateLModProperty
1081 stateLModProperty: AMBIENT
1083 memset($$, 0, sizeof($$));
1084 $$[0] = STATE_LIGHTMODEL_AMBIENT;
1086 | optFaceType SCENECOLOR
1088 memset($$, 0, sizeof($$));
1089 $$[0] = STATE_LIGHTMODEL_SCENECOLOR;
1094 stateLightProdItem: LIGHTPROD '[' stateLightNumber ']' optFaceType stateLProdProperty
1096 memset($$, 0, sizeof($$));
1097 $$[0] = STATE_LIGHTPROD;
1104 stateLProdProperty: ambDiffSpecProperty;
1106 stateTexEnvItem: TEXENV optLegacyTexUnitNum stateTexEnvProperty
1108 memset($$, 0, sizeof($$));
1114 stateTexEnvProperty: COLOR
1116 $$ = STATE_TEXENV_COLOR;
1120 ambDiffSpecProperty: AMBIENT
1130 $$ = STATE_SPECULAR;
1134 stateLightNumber: INTEGER
1136 if ($1 >= state->MaxLights) {
1137 yyerror(& @1, state, "invalid light selector");
1145 stateTexGenItem: TEXGEN optTexCoordUnitNum stateTexGenType stateTexGenCoord
1147 memset($$, 0, sizeof($$));
1148 $$[0] = STATE_TEXGEN;
1154 stateTexGenType: EYE
1156 $$ = STATE_TEXGEN_EYE_S;
1160 $$ = STATE_TEXGEN_OBJECT_S;
1163 stateTexGenCoord: TEXGEN_S
1165 $$ = STATE_TEXGEN_EYE_S - STATE_TEXGEN_EYE_S;
1169 $$ = STATE_TEXGEN_EYE_T - STATE_TEXGEN_EYE_S;
1173 $$ = STATE_TEXGEN_EYE_R - STATE_TEXGEN_EYE_S;
1177 $$ = STATE_TEXGEN_EYE_Q - STATE_TEXGEN_EYE_S;
1181 stateFogItem: FOG stateFogProperty
1183 memset($$, 0, sizeof($$));
1188 stateFogProperty: COLOR
1190 $$ = STATE_FOG_COLOR;
1194 $$ = STATE_FOG_PARAMS;
1198 stateClipPlaneItem: CLIP '[' stateClipPlaneNum ']' PLANE
1200 memset($$, 0, sizeof($$));
1201 $$[0] = STATE_CLIPPLANE;
1206 stateClipPlaneNum: INTEGER
1208 if ($1 >= state->MaxClipPlanes) {
1209 yyerror(& @1, state, "invalid clip plane selector");
1217 statePointItem: POINT statePointProperty
1219 memset($$, 0, sizeof($$));
1224 statePointProperty: SIZE
1226 $$ = STATE_POINT_SIZE;
1230 $$ = STATE_POINT_ATTENUATION;
1234 stateMatrixRow: stateMatrixItem ROW '[' stateMatrixRowNum ']'
1244 stateMatrixRows: stateMatrixItem optMatrixRows
1259 | ROW '[' stateMatrixRowNum DOT_DOT stateMatrixRowNum ']'
1261 /* It seems logical that the matrix row range specifier would have
1262 * to specify a range or more than one row (i.e., $5 > $3).
1263 * However, the ARB_vertex_program spec says "a program will fail
1264 * to load if <a> is greater than <b>." This means that $3 == $5
1268 yyerror(& @3, state, "invalid matrix row range");
1277 stateMatrixItem: MATRIX stateMatrixName stateOptMatModifier
1285 stateOptMatModifier:
1295 stateMatModifier: INVERSE
1297 $$ = STATE_MATRIX_INVERSE;
1301 $$ = STATE_MATRIX_TRANSPOSE;
1305 $$ = STATE_MATRIX_INVTRANS;
1309 stateMatrixRowNum: INTEGER
1312 yyerror(& @1, state, "invalid matrix row reference");
1320 stateMatrixName: MODELVIEW stateOptModMatNum
1322 $$[0] = STATE_MODELVIEW_MATRIX;
1327 $$[0] = STATE_PROJECTION_MATRIX;
1332 $$[0] = STATE_MVP_MATRIX;
1335 | TEXTURE optTexCoordUnitNum
1337 $$[0] = STATE_TEXTURE_MATRIX;
1340 | PALETTE '[' statePaletteMatNum ']'
1344 | MAT_PROGRAM '[' stateProgramMatNum ']'
1346 $$[0] = STATE_PROGRAM_MATRIX;
1360 stateModMatNum: INTEGER
1362 /* Since GL_ARB_vertex_blend isn't supported, only modelview matrix
1366 yyerror(& @1, state, "invalid modelview matrix index");
1373 statePaletteMatNum: INTEGER
1375 /* Since GL_ARB_matrix_palette isn't supported, just let any value
1376 * through here. The error will be generated later.
1381 stateProgramMatNum: INTEGER
1383 if ($1 >= state->MaxProgramMatrices) {
1384 yyerror(& @1, state, "invalid program matrix selector");
1394 programSingleItem: progEnvParam | progLocalParam;
1396 programMultipleItem: progEnvParams | progLocalParams;
1398 progEnvParams: PROGRAM ENV '[' progEnvParamNums ']'
1400 memset($$, 0, sizeof($$));
1401 $$[0] = state->state_param_enum;
1408 progEnvParamNums: progEnvParamNum
1413 | progEnvParamNum DOT_DOT progEnvParamNum
1420 progEnvParam: PROGRAM ENV '[' progEnvParamNum ']'
1422 memset($$, 0, sizeof($$));
1423 $$[0] = state->state_param_enum;
1430 progLocalParams: PROGRAM LOCAL '[' progLocalParamNums ']'
1432 memset($$, 0, sizeof($$));
1433 $$[0] = state->state_param_enum;
1434 $$[1] = STATE_LOCAL;
1439 progLocalParamNums: progLocalParamNum
1444 | progLocalParamNum DOT_DOT progLocalParamNum
1451 progLocalParam: PROGRAM LOCAL '[' progLocalParamNum ']'
1453 memset($$, 0, sizeof($$));
1454 $$[0] = state->state_param_enum;
1455 $$[1] = STATE_LOCAL;
1461 progEnvParamNum: INTEGER
1463 if ($1 >= state->limits->MaxEnvParams) {
1464 yyerror(& @1, state, "invalid environment parameter reference");
1471 progLocalParamNum: INTEGER
1473 if ($1 >= state->limits->MaxLocalParams) {
1474 yyerror(& @1, state, "invalid local parameter reference");
1483 paramConstDecl: paramConstScalarDecl | paramConstVector;
1484 paramConstUse: paramConstScalarUse | paramConstVector;
1486 paramConstScalarDecl: signedFloatConstant
1493 paramConstScalarUse: REAL
1501 $$.data[0] = (float) $1;
1505 paramConstVector: '{' signedFloatConstant '}'
1510 | '{' signedFloatConstant ',' signedFloatConstant '}'
1516 | '{' signedFloatConstant ',' signedFloatConstant ','
1517 signedFloatConstant '}'
1524 | '{' signedFloatConstant ',' signedFloatConstant ','
1525 signedFloatConstant ',' signedFloatConstant '}'
1535 signedFloatConstant: optionalSign REAL
1537 $$ = ($1) ? -$2 : $2;
1539 | optionalSign INTEGER
1541 $$ = (float)(($1) ? -$2 : $2);
1545 optionalSign: '+' { $$ = FALSE; }
1546 | '-' { $$ = TRUE; }
1550 TEMP_statement: TEMP { $<integer>$ = $1; } varNameList
1553 ADDRESS_statement: ADDRESS { $<integer>$ = $1; } varNameList
1556 varNameList: varNameList ',' IDENTIFIER
1558 if (!declare_variable(state, $3, $<integer>0, & @3)) {
1564 if (!declare_variable(state, $1, $<integer>0, & @1)) {
1570 OUTPUT_statement: OUTPUT IDENTIFIER '=' resultBinding
1572 struct asm_symbol *const s =
1573 declare_variable(state, $2, at_output, & @2);
1578 s->output_binding = $4;
1583 resultBinding: RESULT POSITION
1585 if (state->mode == ARB_vertex) {
1586 $$ = VERT_RESULT_HPOS;
1588 yyerror(& @2, state, "invalid program result name");
1594 if (state->mode == ARB_vertex) {
1595 $$ = VERT_RESULT_FOGC;
1597 yyerror(& @2, state, "invalid program result name");
1601 | RESULT resultColBinding
1607 if (state->mode == ARB_vertex) {
1608 $$ = VERT_RESULT_PSIZ;
1610 yyerror(& @2, state, "invalid program result name");
1614 | RESULT TEXCOORD optTexCoordUnitNum
1616 if (state->mode == ARB_vertex) {
1617 $$ = VERT_RESULT_TEX0 + $3;
1619 yyerror(& @2, state, "invalid program result name");
1625 if (state->mode == ARB_fragment) {
1626 $$ = FRAG_RESULT_DEPTH;
1628 yyerror(& @2, state, "invalid program result name");
1634 resultColBinding: COLOR optResultFaceType optResultColorType
1642 $$ = (state->mode == ARB_vertex)
1644 : FRAG_RESULT_COLOR;
1648 if (state->mode == ARB_vertex) {
1649 $$ = VERT_RESULT_COL0;
1651 yyerror(& @1, state, "invalid program result name");
1657 if (state->mode == ARB_vertex) {
1658 $$ = VERT_RESULT_BFC0;
1660 yyerror(& @1, state, "invalid program result name");
1672 if (state->mode == ARB_vertex) {
1675 yyerror(& @1, state, "invalid program result name");
1681 if (state->mode == ARB_vertex) {
1684 yyerror(& @1, state, "invalid program result name");
1690 optFaceType: { $$ = 0; }
1695 optColorType: { $$ = 0; }
1696 | PRIMARY { $$ = 0; }
1697 | SECONDARY { $$ = 1; }
1700 optTexCoordUnitNum: { $$ = 0; }
1701 | '[' texCoordUnitNum ']' { $$ = $2; }
1704 optTexImageUnitNum: { $$ = 0; }
1705 | '[' texImageUnitNum ']' { $$ = $2; }
1708 optLegacyTexUnitNum: { $$ = 0; }
1709 | '[' legacyTexUnitNum ']' { $$ = $2; }
1712 texCoordUnitNum: INTEGER
1714 if ($1 >= state->MaxTextureCoordUnits) {
1715 yyerror(& @1, state, "invalid texture coordinate unit selector");
1723 texImageUnitNum: INTEGER
1725 if ($1 >= state->MaxTextureImageUnits) {
1726 yyerror(& @1, state, "invalid texture image unit selector");
1734 legacyTexUnitNum: INTEGER
1736 if ($1 >= state->MaxTextureUnits) {
1737 yyerror(& @1, state, "invalid texture unit selector");
1745 ALIAS_statement: ALIAS IDENTIFIER '=' IDENTIFIER
1747 struct asm_symbol *exist = (struct asm_symbol *)
1748 _mesa_symbol_table_find_symbol(state->st, 0, $2);
1749 struct asm_symbol *target = (struct asm_symbol *)
1750 _mesa_symbol_table_find_symbol(state->st, 0, $4);
1753 if (exist != NULL) {
1754 yyerror(& @2, state, "redeclared identifier");
1756 } else if (target == NULL) {
1757 yyerror(& @4, state,
1758 "undefined variable binding in ALIAS statement");
1761 _mesa_symbol_table_add_symbol(state->st, 0, $2, target);
1768 struct asm_instruction *
1769 asm_instruction_ctor(gl_inst_opcode op,
1770 const struct prog_dst_register *dst,
1771 const struct asm_src_register *src0,
1772 const struct asm_src_register *src1,
1773 const struct asm_src_register *src2)
1775 struct asm_instruction *inst = calloc(1, sizeof(struct asm_instruction));
1778 _mesa_init_instructions(inst, 1);
1779 inst->Base.Opcode = op;
1780 inst->Base.DstReg = *dst;
1782 inst->Base.SrcReg[0] = src0->Base;
1783 inst->SrcReg[0] = *src0;
1786 inst->Base.SrcReg[1] = src1->Base;
1787 inst->SrcReg[1] = *src1;
1789 init_src_reg(& inst->SrcReg[1]);
1793 inst->Base.SrcReg[2] = src2->Base;
1794 inst->SrcReg[2] = *src2;
1796 init_src_reg(& inst->SrcReg[2]);
1805 init_dst_reg(struct prog_dst_register *r)
1807 memset(r, 0, sizeof(*r));
1808 r->File = PROGRAM_UNDEFINED;
1809 r->WriteMask = WRITEMASK_XYZW;
1810 r->CondMask = COND_TR;
1811 r->CondSwizzle = SWIZZLE_NOOP;
1816 init_src_reg(struct asm_src_register *r)
1818 memset(r, 0, sizeof(*r));
1819 r->Base.File = PROGRAM_UNDEFINED;
1820 r->Base.Swizzle = SWIZZLE_NOOP;
1826 * Validate the set of inputs used by a program
1828 * Validates that legal sets of inputs are used by the program. In this case
1829 * "used" included both reading the input or binding the input to a name using
1830 * the \c ATTRIB command.
1833 * \c TRUE if the combination of inputs used is valid, \c FALSE otherwise.
1836 validate_inputs(struct YYLTYPE *locp, struct asm_parser_state *state)
1838 const int inputs = state->prog->InputsRead | state->InputsBound;
1840 if (((inputs & 0x0ffff) & (inputs >> 16)) != 0) {
1841 yyerror(locp, state, "illegal use of generic attribute and name attribute");
1850 declare_variable(struct asm_parser_state *state, char *name, enum asm_type t,
1851 struct YYLTYPE *locp)
1853 struct asm_symbol *s = NULL;
1854 struct asm_symbol *exist = (struct asm_symbol *)
1855 _mesa_symbol_table_find_symbol(state->st, 0, name);
1858 if (exist != NULL) {
1859 yyerror(locp, state, "redeclared identifier");
1861 s = calloc(1, sizeof(struct asm_symbol));
1867 if (state->prog->NumTemporaries >= state->limits->MaxTemps) {
1868 yyerror(locp, state, "too many temporaries declared");
1873 s->temp_binding = state->prog->NumTemporaries;
1874 state->prog->NumTemporaries++;
1878 if (state->prog->NumAddressRegs >= state->limits->MaxAddressRegs) {
1879 yyerror(locp, state, "too many address registers declared");
1884 /* FINISHME: Add support for multiple address registers.
1886 state->prog->NumAddressRegs++;
1893 _mesa_symbol_table_add_symbol(state->st, 0, s->name, s);
1900 int add_state_reference(struct gl_program_parameter_list *param_list,
1901 const gl_state_index tokens[STATE_LENGTH])
1903 const GLuint size = 4; /* XXX fix */
1907 name = _mesa_program_state_string(tokens);
1908 index = _mesa_add_parameter(param_list, PROGRAM_STATE_VAR, name,
1910 NULL, (gl_state_index *) tokens, 0x0);
1911 param_list->StateFlags |= _mesa_program_state_flags(tokens);
1913 /* free name string here since we duplicated it in add_parameter() */
1921 initialize_symbol_from_state(struct gl_program *prog,
1922 struct asm_symbol *param_var,
1923 const gl_state_index tokens[STATE_LENGTH])
1926 gl_state_index state_tokens[STATE_LENGTH];
1929 memcpy(state_tokens, tokens, sizeof(state_tokens));
1931 param_var->type = at_param;
1932 param_var->param_binding_type = PROGRAM_STATE_VAR;
1934 /* If we are adding a STATE_MATRIX that has multiple rows, we need to
1935 * unroll it and call add_state_reference() for each row
1937 if ((state_tokens[0] == STATE_MODELVIEW_MATRIX ||
1938 state_tokens[0] == STATE_PROJECTION_MATRIX ||
1939 state_tokens[0] == STATE_MVP_MATRIX ||
1940 state_tokens[0] == STATE_TEXTURE_MATRIX ||
1941 state_tokens[0] == STATE_PROGRAM_MATRIX)
1942 && (state_tokens[2] != state_tokens[3])) {
1944 const int first_row = state_tokens[2];
1945 const int last_row = state_tokens[3];
1947 for (row = first_row; row <= last_row; row++) {
1948 state_tokens[2] = state_tokens[3] = row;
1950 idx = add_state_reference(prog->Parameters, state_tokens);
1951 if (param_var->param_binding_begin == ~0U)
1952 param_var->param_binding_begin = idx;
1953 param_var->param_binding_length++;
1957 idx = add_state_reference(prog->Parameters, state_tokens);
1958 if (param_var->param_binding_begin == ~0U)
1959 param_var->param_binding_begin = idx;
1960 param_var->param_binding_length++;
1968 initialize_symbol_from_param(struct gl_program *prog,
1969 struct asm_symbol *param_var,
1970 const gl_state_index tokens[STATE_LENGTH])
1973 gl_state_index state_tokens[STATE_LENGTH];
1976 memcpy(state_tokens, tokens, sizeof(state_tokens));
1978 assert((state_tokens[0] == STATE_VERTEX_PROGRAM)
1979 || (state_tokens[0] == STATE_FRAGMENT_PROGRAM));
1980 assert((state_tokens[1] == STATE_ENV)
1981 || (state_tokens[1] == STATE_LOCAL));
1983 param_var->type = at_param;
1984 param_var->param_binding_type = (state_tokens[1] == STATE_ENV)
1985 ? PROGRAM_ENV_PARAM : PROGRAM_LOCAL_PARAM;
1987 /* If we are adding a STATE_ENV or STATE_LOCAL that has multiple elements,
1988 * we need to unroll it and call add_state_reference() for each row
1990 if (state_tokens[2] != state_tokens[3]) {
1992 const int first_row = state_tokens[2];
1993 const int last_row = state_tokens[3];
1995 for (row = first_row; row <= last_row; row++) {
1996 state_tokens[2] = state_tokens[3] = row;
1998 idx = add_state_reference(prog->Parameters, state_tokens);
1999 if (param_var->param_binding_begin == ~0U)
2000 param_var->param_binding_begin = idx;
2001 param_var->param_binding_length++;
2005 idx = add_state_reference(prog->Parameters, state_tokens);
2006 if (param_var->param_binding_begin == ~0U)
2007 param_var->param_binding_begin = idx;
2008 param_var->param_binding_length++;
2016 initialize_symbol_from_const(struct gl_program *prog,
2017 struct asm_symbol *param_var,
2018 const struct asm_vector *vec)
2020 const int idx = _mesa_add_parameter(prog->Parameters, PROGRAM_CONSTANT,
2021 NULL, vec->count, GL_NONE, vec->data,
2024 param_var->type = at_param;
2025 param_var->param_binding_type = PROGRAM_CONSTANT;
2027 if (param_var->param_binding_begin == ~0U)
2028 param_var->param_binding_begin = idx;
2029 param_var->param_binding_length++;
2036 make_error_string(const char *fmt, ...)
2042 va_start(args, fmt);
2044 /* Call vsnprintf once to determine how large the final string is. Call it
2045 * again to do the actual formatting. from the vsnprintf manual page:
2047 * Upon successful return, these functions return the number of
2048 * characters printed (not including the trailing '\0' used to end
2049 * output to strings).
2051 length = 1 + vsnprintf(NULL, 0, fmt, args);
2053 str = _mesa_malloc(length);
2055 vsnprintf(str, length, fmt, args);
2065 yyerror(YYLTYPE *locp, struct asm_parser_state *state, const char *s)
2070 err_str = make_error_string("glProgramStringARB(%s)\n", s);
2072 _mesa_error(state->ctx, GL_INVALID_OPERATION, err_str);
2073 _mesa_free(err_str);
2076 err_str = make_error_string("line %u, char %u: error: %s\n",
2077 locp->first_line, locp->first_column, s);
2078 _mesa_set_program_error(state->ctx, locp->position, err_str);
2081 _mesa_free(err_str);
2087 _mesa_parse_arb_program(GLcontext *ctx, GLenum target, const GLubyte *str,
2088 GLsizei len, struct asm_parser_state *state)
2090 struct gl_program_constants limits;
2091 struct asm_instruction *inst;
2096 state->prog->Target = target;
2097 state->prog->Parameters = _mesa_new_parameter_list();
2099 /* Make a copy of the program string and force it to be NUL-terminated.
2101 strz = (GLubyte *) _mesa_malloc(len + 1);
2103 _mesa_error(ctx, GL_OUT_OF_MEMORY, "glProgramStringARB");
2106 _mesa_memcpy (strz, str, len);
2109 state->prog->String = strz;
2111 state->st = _mesa_symbol_table_ctor();
2113 /* All of these limits should come from ctx.
2115 limits.MaxInstructions = 128;
2116 limits.MaxAluInstructions = 128;
2117 limits.MaxTexInstructions = 128;
2118 limits.MaxTexIndirections = 128;
2119 limits.MaxAttribs = 16;
2120 limits.MaxTemps = 128;
2121 limits.MaxAddressRegs = 1;
2122 limits.MaxParameters = 128;
2123 limits.MaxLocalParams = 256;
2124 limits.MaxEnvParams = 128;
2125 limits.MaxNativeInstructions = 128;
2126 limits.MaxNativeAluInstructions = 128;
2127 limits.MaxNativeTexInstructions = 128;
2128 limits.MaxNativeTexIndirections = 128;
2129 limits.MaxNativeAttribs = 16;
2130 limits.MaxNativeTemps = 128;
2131 limits.MaxNativeAddressRegs = 1;
2132 limits.MaxNativeParameters = 128;
2133 limits.MaxUniformComponents = 0;
2135 state->limits = & limits;
2137 state->MaxTextureImageUnits = 16;
2138 state->MaxTextureCoordUnits = 8;
2139 state->MaxTextureUnits = 8;
2140 state->MaxClipPlanes = 6;
2141 state->MaxLights = 8;
2142 state->MaxProgramMatrices = 8;
2144 state->state_param_enum = (target == GL_VERTEX_PROGRAM_ARB)
2145 ? STATE_VERTEX_PROGRAM : STATE_FRAGMENT_PROGRAM;
2147 _mesa_set_program_error(ctx, -1, NULL);
2149 _mesa_program_lexer_ctor(& state->scanner, state, (const char *) str, len);
2151 _mesa_program_lexer_dtor(state->scanner);
2154 if (ctx->Program.ErrorPos != -1) {
2158 if (! _mesa_layout_parameters(state)) {
2162 loc.first_column = 0;
2165 yyerror(& loc, state, "invalid PARAM usage");
2171 /* Add one instruction to store the "END" instruction.
2173 state->prog->Instructions =
2174 _mesa_alloc_instructions(state->prog->NumInstructions + 1);
2175 inst = state->inst_head;
2176 for (i = 0; i < state->prog->NumInstructions; i++) {
2177 struct asm_instruction *const temp = inst->next;
2179 state->prog->Instructions[i] = inst->Base;
2185 /* Finally, tag on an OPCODE_END instruction */
2187 const GLuint numInst = state->prog->NumInstructions;
2188 _mesa_init_instructions(state->prog->Instructions + numInst, 1);
2189 state->prog->Instructions[numInst].Opcode = OPCODE_END;
2191 state->prog->NumInstructions++;
2193 state->prog->NumParameters = state->prog->Parameters->NumParameters;
2196 * Initialize native counts to logical counts. The device driver may
2197 * change them if program is translated into a hardware program.
2199 state->prog->NumNativeInstructions = state->prog->NumInstructions;
2200 state->prog->NumNativeTemporaries = state->prog->NumTemporaries;
2201 state->prog->NumNativeParameters = state->prog->NumParameters;
2202 state->prog->NumNativeAttributes = state->prog->NumAttributes;
2203 state->prog->NumNativeAddressRegs = state->prog->NumAddressRegs;