From dd245016657c599ecf24c4abe999319f9c870c47 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 20 Oct 2009 10:58:14 -0700 Subject: ARB prog parser: Fix parameter array size comparison Array indexes are invalid when >= the maximum, but array sizes are only in valid when > the maximum. This prevented programs from declaring a single maximum size array. See the piglit vp-max-array test. --- src/mesa/shader/program_parse.y | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/mesa/shader/program_parse.y') diff --git a/src/mesa/shader/program_parse.y b/src/mesa/shader/program_parse.y index 06c1915fbe..ae9e15ae5a 100644 --- a/src/mesa/shader/program_parse.y +++ b/src/mesa/shader/program_parse.y @@ -1039,7 +1039,7 @@ optArraySize: } | INTEGER { - if (($1 < 1) || ((unsigned) $1 >= state->limits->MaxParameters)) { + if (($1 < 1) || ((unsigned) $1 > state->limits->MaxParameters)) { yyerror(& @1, state, "invalid parameter array size"); YYERROR; } else { -- cgit v1.2.3 From 8df9587d68752f3369cc1eda1606d3b7c1041ec6 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 27 Oct 2009 11:46:29 -0700 Subject: ARB prog parser: Don't leak program string The program string is kept in the program object. On the second call into glProgramStringARB the previous kept string would be leaked. --- src/mesa/shader/program_parse.y | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/mesa/shader/program_parse.y') diff --git a/src/mesa/shader/program_parse.y b/src/mesa/shader/program_parse.y index ae9e15ae5a..c3152aa2f8 100644 --- a/src/mesa/shader/program_parse.y +++ b/src/mesa/shader/program_parse.y @@ -2278,6 +2278,10 @@ _mesa_parse_arb_program(GLcontext *ctx, GLenum target, const GLubyte *str, _mesa_memcpy (strz, str, len); strz[len] = '\0'; + if (state->prog->String != NULL) { + _mesa_free(state->prog->String); + } + state->prog->String = strz; state->st = _mesa_symbol_table_ctor(); -- cgit v1.2.3 From 93dae6761bc90bbd43b450d2673620ec189b2c7a Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 27 Oct 2009 13:40:18 -0700 Subject: ARB prog parser: Fix epic memory leak in lexer / parser interface Anything that matched IDENTIFIER was strdup'ed and returned to the parser. However, almost every case of IDENTIFIER in the parser just dropped the returned string on the floor. Every swizzle string, every option string, every use of a variable, etc. leaked memory. Create a temporary buffer in the parser state (string_dumpster and dumpster_size). Return strings from the lexer to the parser in the buffer. Grow the buffer as needed. When the parser needs to keep a string (i.e., delcaring a new variable), let it make a copy then. The only leak that valgrind now detects is /occasionally/ the copy of the program string in gl_program::String is leaked. I'm not seeing how. :( --- src/mesa/shader/lex.yy.c | 445 ++++++++++++++++++++---------------- src/mesa/shader/program_lexer.l | 45 +++- src/mesa/shader/program_parse.tab.c | 21 +- src/mesa/shader/program_parse.y | 17 +- src/mesa/shader/program_parser.h | 16 ++ 5 files changed, 337 insertions(+), 207 deletions(-) (limited to 'src/mesa/shader/program_parse.y') diff --git a/src/mesa/shader/lex.yy.c b/src/mesa/shader/lex.yy.c index fefef573ee..728c2dc272 100644 --- a/src/mesa/shader/lex.yy.c +++ b/src/mesa/shader/lex.yy.c @@ -53,7 +53,6 @@ typedef int flex_int32_t; typedef unsigned char flex_uint8_t; typedef unsigned short int flex_uint16_t; typedef unsigned int flex_uint32_t; -#endif /* ! C99 */ /* Limits of integral types. */ #ifndef INT8_MIN @@ -84,6 +83,8 @@ typedef unsigned int flex_uint32_t; #define UINT32_MAX (4294967295U) #endif +#endif /* ! C99 */ + #endif /* ! FLEXINT_H */ #ifdef __cplusplus @@ -157,7 +158,15 @@ typedef void* yyscan_t; /* Size of default input buffer. */ #ifndef YY_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k. + * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. + * Ditto for the __ia64__ case accordingly. + */ +#define YY_BUF_SIZE 32768 +#else #define YY_BUF_SIZE 16384 +#endif /* __ia64__ */ #endif /* The state buf must be large enough to hold one state per character in the main buffer. @@ -918,7 +927,7 @@ static yyconst flex_int16_t yy_chk[1023] = if (condition) { \ return token; \ } else { \ - yylval->string = strdup(yytext); \ + yylval->string = return_string(yyextra, yytext); \ return IDENTIFIER; \ } \ } while (0) @@ -941,7 +950,7 @@ static yyconst flex_int16_t yy_chk[1023] = yylval->temp_inst.SaturateMode = SATURATE_ ## sat; \ return token; \ } else { \ - yylval->string = strdup(yytext); \ + yylval->string = return_string(yyextra, yytext); \ return IDENTIFIER; \ } \ } while (0) @@ -949,6 +958,45 @@ static yyconst flex_int16_t yy_chk[1023] = #define SWIZZLE_INVAL MAKE_SWIZZLE4(SWIZZLE_NIL, SWIZZLE_NIL, \ SWIZZLE_NIL, SWIZZLE_NIL) +/** + * Send a string to the parser using asm_parser_state::string_dumpster + * + * Sends a string to the parser using asm_parser_state::string_dumpster as a + * temporary storage buffer. Data previously stored in + * asm_parser_state::string_dumpster will be lost. If + * asm_parser_state::string_dumpster is not large enough to hold the new + * string, the buffer size will be increased. The buffer size is \b never + * decreased. + * + * \param state Assembler parser state tracking + * \param str String to be passed to the parser + * + * \return + * A pointer to asm_parser_state::string_dumpster on success or \c NULL on + * failure. Currently the only failure case is \c ENOMEM. + */ +static char * +return_string(struct asm_parser_state *state, const char *str) +{ + const size_t len = strlen(str); + + if (len >= state->dumpster_size) { + char *const dumpster = _mesa_realloc(state->string_dumpster, + state->dumpster_size, + len + 1); + if (dumpster == NULL) { + return NULL; + } + + state->string_dumpster = dumpster; + state->dumpster_size = len + 1; + } + + memcpy(state->string_dumpster, str, len + 1); + return state->string_dumpster; +} + + static unsigned mask_from_char(char c) { @@ -1004,7 +1052,7 @@ swiz_from_char(char c) } while(0); #define YY_EXTRA_TYPE struct asm_parser_state * -#line 1008 "lex.yy.c" +#line 1056 "lex.yy.c" #define INITIAL 0 @@ -1141,7 +1189,12 @@ static int input (yyscan_t yyscanner ); /* Amount of stuff to slurp up with each read. */ #ifndef YY_READ_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k */ +#define YY_READ_BUF_SIZE 16384 +#else #define YY_READ_BUF_SIZE 8192 +#endif /* __ia64__ */ #endif /* Copy whatever the last rule matched to the standard output. */ @@ -1149,7 +1202,7 @@ static int input (yyscan_t yyscanner ); /* This used to be an fputs(), but since the string might contain NUL's, * we now use fwrite(). */ -#define ECHO fwrite( yytext, yyleng, 1, yyout ) +#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0) #endif /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, @@ -1160,7 +1213,7 @@ static int input (yyscan_t yyscanner ); if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ { \ int c = '*'; \ - unsigned n; \ + size_t n; \ for ( n = 0; n < max_size && \ (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ buf[n] = (char) c; \ @@ -1245,10 +1298,10 @@ YY_DECL register int yy_act; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; -#line 137 "program_lexer.l" +#line 176 "program_lexer.l" -#line 1252 "lex.yy.c" +#line 1305 "lex.yy.c" yylval = yylval_param; @@ -1337,17 +1390,17 @@ do_action: /* This label is used only to access EOF actions. */ case 1: YY_RULE_SETUP -#line 139 "program_lexer.l" +#line 178 "program_lexer.l" { return ARBvp_10; } YY_BREAK case 2: YY_RULE_SETUP -#line 140 "program_lexer.l" +#line 179 "program_lexer.l" { return ARBfp_10; } YY_BREAK case 3: YY_RULE_SETUP -#line 141 "program_lexer.l" +#line 180 "program_lexer.l" { yylval->integer = at_address; return_token_or_IDENTIFIER(require_ARB_vp, ADDRESS); @@ -1355,760 +1408,760 @@ YY_RULE_SETUP YY_BREAK case 4: YY_RULE_SETUP -#line 145 "program_lexer.l" +#line 184 "program_lexer.l" { return ALIAS; } YY_BREAK case 5: YY_RULE_SETUP -#line 146 "program_lexer.l" +#line 185 "program_lexer.l" { return ATTRIB; } YY_BREAK case 6: YY_RULE_SETUP -#line 147 "program_lexer.l" +#line 186 "program_lexer.l" { return END; } YY_BREAK case 7: YY_RULE_SETUP -#line 148 "program_lexer.l" +#line 187 "program_lexer.l" { return OPTION; } YY_BREAK case 8: YY_RULE_SETUP -#line 149 "program_lexer.l" +#line 188 "program_lexer.l" { return OUTPUT; } YY_BREAK case 9: YY_RULE_SETUP -#line 150 "program_lexer.l" +#line 189 "program_lexer.l" { return PARAM; } YY_BREAK case 10: YY_RULE_SETUP -#line 151 "program_lexer.l" +#line 190 "program_lexer.l" { yylval->integer = at_temp; return TEMP; } YY_BREAK case 11: YY_RULE_SETUP -#line 153 "program_lexer.l" +#line 192 "program_lexer.l" { return_opcode( 1, VECTOR_OP, ABS, OFF); } YY_BREAK case 12: YY_RULE_SETUP -#line 154 "program_lexer.l" +#line 193 "program_lexer.l" { return_opcode(require_ARB_fp, VECTOR_OP, ABS, ZERO_ONE); } YY_BREAK case 13: YY_RULE_SETUP -#line 155 "program_lexer.l" +#line 194 "program_lexer.l" { return_opcode( 1, BIN_OP, ADD, OFF); } YY_BREAK case 14: YY_RULE_SETUP -#line 156 "program_lexer.l" +#line 195 "program_lexer.l" { return_opcode(require_ARB_fp, BIN_OP, ADD, ZERO_ONE); } YY_BREAK case 15: YY_RULE_SETUP -#line 157 "program_lexer.l" +#line 196 "program_lexer.l" { return_opcode(require_ARB_vp, ARL, ARL, OFF); } YY_BREAK case 16: YY_RULE_SETUP -#line 159 "program_lexer.l" +#line 198 "program_lexer.l" { return_opcode(require_ARB_fp, TRI_OP, CMP, OFF); } YY_BREAK case 17: YY_RULE_SETUP -#line 160 "program_lexer.l" +#line 199 "program_lexer.l" { return_opcode(require_ARB_fp, TRI_OP, CMP, ZERO_ONE); } YY_BREAK case 18: YY_RULE_SETUP -#line 161 "program_lexer.l" +#line 200 "program_lexer.l" { return_opcode(require_ARB_fp, SCALAR_OP, COS, OFF); } YY_BREAK case 19: YY_RULE_SETUP -#line 162 "program_lexer.l" +#line 201 "program_lexer.l" { return_opcode(require_ARB_fp, SCALAR_OP, COS, ZERO_ONE); } YY_BREAK case 20: YY_RULE_SETUP -#line 164 "program_lexer.l" +#line 203 "program_lexer.l" { return_opcode( 1, BIN_OP, DP3, OFF); } YY_BREAK case 21: YY_RULE_SETUP -#line 165 "program_lexer.l" +#line 204 "program_lexer.l" { return_opcode(require_ARB_fp, BIN_OP, DP3, ZERO_ONE); } YY_BREAK case 22: YY_RULE_SETUP -#line 166 "program_lexer.l" +#line 205 "program_lexer.l" { return_opcode( 1, BIN_OP, DP4, OFF); } YY_BREAK case 23: YY_RULE_SETUP -#line 167 "program_lexer.l" +#line 206 "program_lexer.l" { return_opcode(require_ARB_fp, BIN_OP, DP4, ZERO_ONE); } YY_BREAK case 24: YY_RULE_SETUP -#line 168 "program_lexer.l" +#line 207 "program_lexer.l" { return_opcode( 1, BIN_OP, DPH, OFF); } YY_BREAK case 25: YY_RULE_SETUP -#line 169 "program_lexer.l" +#line 208 "program_lexer.l" { return_opcode(require_ARB_fp, BIN_OP, DPH, ZERO_ONE); } YY_BREAK case 26: YY_RULE_SETUP -#line 170 "program_lexer.l" +#line 209 "program_lexer.l" { return_opcode( 1, BIN_OP, DST, OFF); } YY_BREAK case 27: YY_RULE_SETUP -#line 171 "program_lexer.l" +#line 210 "program_lexer.l" { return_opcode(require_ARB_fp, BIN_OP, DST, ZERO_ONE); } YY_BREAK case 28: YY_RULE_SETUP -#line 173 "program_lexer.l" +#line 212 "program_lexer.l" { return_opcode( 1, SCALAR_OP, EX2, OFF); } YY_BREAK case 29: YY_RULE_SETUP -#line 174 "program_lexer.l" +#line 213 "program_lexer.l" { return_opcode(require_ARB_fp, SCALAR_OP, EX2, ZERO_ONE); } YY_BREAK case 30: YY_RULE_SETUP -#line 175 "program_lexer.l" +#line 214 "program_lexer.l" { return_opcode(require_ARB_vp, SCALAR_OP, EXP, OFF); } YY_BREAK case 31: YY_RULE_SETUP -#line 177 "program_lexer.l" +#line 216 "program_lexer.l" { return_opcode( 1, VECTOR_OP, FLR, OFF); } YY_BREAK case 32: YY_RULE_SETUP -#line 178 "program_lexer.l" +#line 217 "program_lexer.l" { return_opcode(require_ARB_fp, VECTOR_OP, FLR, ZERO_ONE); } YY_BREAK case 33: YY_RULE_SETUP -#line 179 "program_lexer.l" +#line 218 "program_lexer.l" { return_opcode( 1, VECTOR_OP, FRC, OFF); } YY_BREAK case 34: YY_RULE_SETUP -#line 180 "program_lexer.l" +#line 219 "program_lexer.l" { return_opcode(require_ARB_fp, VECTOR_OP, FRC, ZERO_ONE); } YY_BREAK case 35: YY_RULE_SETUP -#line 182 "program_lexer.l" +#line 221 "program_lexer.l" { return_opcode(require_ARB_fp, KIL, KIL, OFF); } YY_BREAK case 36: YY_RULE_SETUP -#line 184 "program_lexer.l" +#line 223 "program_lexer.l" { return_opcode( 1, VECTOR_OP, LIT, OFF); } YY_BREAK case 37: YY_RULE_SETUP -#line 185 "program_lexer.l" +#line 224 "program_lexer.l" { return_opcode(require_ARB_fp, VECTOR_OP, LIT, ZERO_ONE); } YY_BREAK case 38: YY_RULE_SETUP -#line 186 "program_lexer.l" +#line 225 "program_lexer.l" { return_opcode( 1, SCALAR_OP, LG2, OFF); } YY_BREAK case 39: YY_RULE_SETUP -#line 187 "program_lexer.l" +#line 226 "program_lexer.l" { return_opcode(require_ARB_fp, SCALAR_OP, LG2, ZERO_ONE); } YY_BREAK case 40: YY_RULE_SETUP -#line 188 "program_lexer.l" +#line 227 "program_lexer.l" { return_opcode(require_ARB_vp, SCALAR_OP, LOG, OFF); } YY_BREAK case 41: YY_RULE_SETUP -#line 189 "program_lexer.l" +#line 228 "program_lexer.l" { return_opcode(require_ARB_fp, TRI_OP, LRP, OFF); } YY_BREAK case 42: YY_RULE_SETUP -#line 190 "program_lexer.l" +#line 229 "program_lexer.l" { return_opcode(require_ARB_fp, TRI_OP, LRP, ZERO_ONE); } YY_BREAK case 43: YY_RULE_SETUP -#line 192 "program_lexer.l" +#line 231 "program_lexer.l" { return_opcode( 1, TRI_OP, MAD, OFF); } YY_BREAK case 44: YY_RULE_SETUP -#line 193 "program_lexer.l" +#line 232 "program_lexer.l" { return_opcode(require_ARB_fp, TRI_OP, MAD, ZERO_ONE); } YY_BREAK case 45: YY_RULE_SETUP -#line 194 "program_lexer.l" +#line 233 "program_lexer.l" { return_opcode( 1, BIN_OP, MAX, OFF); } YY_BREAK case 46: YY_RULE_SETUP -#line 195 "program_lexer.l" +#line 234 "program_lexer.l" { return_opcode(require_ARB_fp, BIN_OP, MAX, ZERO_ONE); } YY_BREAK case 47: YY_RULE_SETUP -#line 196 "program_lexer.l" +#line 235 "program_lexer.l" { return_opcode( 1, BIN_OP, MIN, OFF); } YY_BREAK case 48: YY_RULE_SETUP -#line 197 "program_lexer.l" +#line 236 "program_lexer.l" { return_opcode(require_ARB_fp, BIN_OP, MIN, ZERO_ONE); } YY_BREAK case 49: YY_RULE_SETUP -#line 198 "program_lexer.l" +#line 237 "program_lexer.l" { return_opcode( 1, VECTOR_OP, MOV, OFF); } YY_BREAK case 50: YY_RULE_SETUP -#line 199 "program_lexer.l" +#line 238 "program_lexer.l" { return_opcode(require_ARB_fp, VECTOR_OP, MOV, ZERO_ONE); } YY_BREAK case 51: YY_RULE_SETUP -#line 200 "program_lexer.l" +#line 239 "program_lexer.l" { return_opcode( 1, BIN_OP, MUL, OFF); } YY_BREAK case 52: YY_RULE_SETUP -#line 201 "program_lexer.l" +#line 240 "program_lexer.l" { return_opcode(require_ARB_fp, BIN_OP, MUL, ZERO_ONE); } YY_BREAK case 53: YY_RULE_SETUP -#line 203 "program_lexer.l" +#line 242 "program_lexer.l" { return_opcode( 1, BINSC_OP, POW, OFF); } YY_BREAK case 54: YY_RULE_SETUP -#line 204 "program_lexer.l" +#line 243 "program_lexer.l" { return_opcode(require_ARB_fp, BINSC_OP, POW, ZERO_ONE); } YY_BREAK case 55: YY_RULE_SETUP -#line 206 "program_lexer.l" +#line 245 "program_lexer.l" { return_opcode( 1, SCALAR_OP, RCP, OFF); } YY_BREAK case 56: YY_RULE_SETUP -#line 207 "program_lexer.l" +#line 246 "program_lexer.l" { return_opcode(require_ARB_fp, SCALAR_OP, RCP, ZERO_ONE); } YY_BREAK case 57: YY_RULE_SETUP -#line 208 "program_lexer.l" +#line 247 "program_lexer.l" { return_opcode( 1, SCALAR_OP, RSQ, OFF); } YY_BREAK case 58: YY_RULE_SETUP -#line 209 "program_lexer.l" +#line 248 "program_lexer.l" { return_opcode(require_ARB_fp, SCALAR_OP, RSQ, ZERO_ONE); } YY_BREAK case 59: YY_RULE_SETUP -#line 211 "program_lexer.l" +#line 250 "program_lexer.l" { return_opcode(require_ARB_fp, SCALAR_OP, SCS, OFF); } YY_BREAK case 60: YY_RULE_SETUP -#line 212 "program_lexer.l" +#line 251 "program_lexer.l" { return_opcode(require_ARB_fp, SCALAR_OP, SCS, ZERO_ONE); } YY_BREAK case 61: YY_RULE_SETUP -#line 213 "program_lexer.l" +#line 252 "program_lexer.l" { return_opcode( 1, BIN_OP, SGE, OFF); } YY_BREAK case 62: YY_RULE_SETUP -#line 214 "program_lexer.l" +#line 253 "program_lexer.l" { return_opcode(require_ARB_fp, BIN_OP, SGE, ZERO_ONE); } YY_BREAK case 63: YY_RULE_SETUP -#line 215 "program_lexer.l" +#line 254 "program_lexer.l" { return_opcode(require_ARB_fp, SCALAR_OP, SIN, OFF); } YY_BREAK case 64: YY_RULE_SETUP -#line 216 "program_lexer.l" +#line 255 "program_lexer.l" { return_opcode(require_ARB_fp, SCALAR_OP, SIN, ZERO_ONE); } YY_BREAK case 65: YY_RULE_SETUP -#line 217 "program_lexer.l" +#line 256 "program_lexer.l" { return_opcode( 1, BIN_OP, SLT, OFF); } YY_BREAK case 66: YY_RULE_SETUP -#line 218 "program_lexer.l" +#line 257 "program_lexer.l" { return_opcode(require_ARB_fp, BIN_OP, SLT, ZERO_ONE); } YY_BREAK case 67: YY_RULE_SETUP -#line 219 "program_lexer.l" +#line 258 "program_lexer.l" { return_opcode( 1, BIN_OP, SUB, OFF); } YY_BREAK case 68: YY_RULE_SETUP -#line 220 "program_lexer.l" +#line 259 "program_lexer.l" { return_opcode(require_ARB_fp, BIN_OP, SUB, ZERO_ONE); } YY_BREAK case 69: YY_RULE_SETUP -#line 221 "program_lexer.l" +#line 260 "program_lexer.l" { return_opcode( 1, SWZ, SWZ, OFF); } YY_BREAK case 70: YY_RULE_SETUP -#line 222 "program_lexer.l" +#line 261 "program_lexer.l" { return_opcode(require_ARB_fp, SWZ, SWZ, ZERO_ONE); } YY_BREAK case 71: YY_RULE_SETUP -#line 224 "program_lexer.l" +#line 263 "program_lexer.l" { return_opcode(require_ARB_fp, SAMPLE_OP, TEX, OFF); } YY_BREAK case 72: YY_RULE_SETUP -#line 225 "program_lexer.l" +#line 264 "program_lexer.l" { return_opcode(require_ARB_fp, SAMPLE_OP, TEX, ZERO_ONE); } YY_BREAK case 73: YY_RULE_SETUP -#line 226 "program_lexer.l" +#line 265 "program_lexer.l" { return_opcode(require_ARB_fp, SAMPLE_OP, TXB, OFF); } YY_BREAK case 74: YY_RULE_SETUP -#line 227 "program_lexer.l" +#line 266 "program_lexer.l" { return_opcode(require_ARB_fp, SAMPLE_OP, TXB, ZERO_ONE); } YY_BREAK case 75: YY_RULE_SETUP -#line 228 "program_lexer.l" +#line 267 "program_lexer.l" { return_opcode(require_ARB_fp, SAMPLE_OP, TXP, OFF); } YY_BREAK case 76: YY_RULE_SETUP -#line 229 "program_lexer.l" +#line 268 "program_lexer.l" { return_opcode(require_ARB_fp, SAMPLE_OP, TXP, ZERO_ONE); } YY_BREAK case 77: YY_RULE_SETUP -#line 231 "program_lexer.l" +#line 270 "program_lexer.l" { return_opcode( 1, BIN_OP, XPD, OFF); } YY_BREAK case 78: YY_RULE_SETUP -#line 232 "program_lexer.l" +#line 271 "program_lexer.l" { return_opcode(require_ARB_fp, BIN_OP, XPD, ZERO_ONE); } YY_BREAK case 79: YY_RULE_SETUP -#line 234 "program_lexer.l" +#line 273 "program_lexer.l" { return_token_or_IDENTIFIER(require_ARB_vp, VERTEX); } YY_BREAK case 80: YY_RULE_SETUP -#line 235 "program_lexer.l" +#line 274 "program_lexer.l" { return_token_or_IDENTIFIER(require_ARB_fp, FRAGMENT); } YY_BREAK case 81: YY_RULE_SETUP -#line 236 "program_lexer.l" +#line 275 "program_lexer.l" { return PROGRAM; } YY_BREAK case 82: YY_RULE_SETUP -#line 237 "program_lexer.l" +#line 276 "program_lexer.l" { return STATE; } YY_BREAK case 83: YY_RULE_SETUP -#line 238 "program_lexer.l" +#line 277 "program_lexer.l" { return RESULT; } YY_BREAK case 84: YY_RULE_SETUP -#line 240 "program_lexer.l" +#line 279 "program_lexer.l" { return AMBIENT; } YY_BREAK case 85: YY_RULE_SETUP -#line 241 "program_lexer.l" +#line 280 "program_lexer.l" { return ATTENUATION; } YY_BREAK case 86: YY_RULE_SETUP -#line 242 "program_lexer.l" +#line 281 "program_lexer.l" { return BACK; } YY_BREAK case 87: YY_RULE_SETUP -#line 243 "program_lexer.l" +#line 282 "program_lexer.l" { return_token_or_DOT(require_ARB_vp, CLIP); } YY_BREAK case 88: YY_RULE_SETUP -#line 244 "program_lexer.l" +#line 283 "program_lexer.l" { return COLOR; } YY_BREAK case 89: YY_RULE_SETUP -#line 245 "program_lexer.l" +#line 284 "program_lexer.l" { return_token_or_DOT(require_ARB_fp, DEPTH); } YY_BREAK case 90: YY_RULE_SETUP -#line 246 "program_lexer.l" +#line 285 "program_lexer.l" { return DIFFUSE; } YY_BREAK case 91: YY_RULE_SETUP -#line 247 "program_lexer.l" +#line 286 "program_lexer.l" { return DIRECTION; } YY_BREAK case 92: YY_RULE_SETUP -#line 248 "program_lexer.l" +#line 287 "program_lexer.l" { return EMISSION; } YY_BREAK case 93: YY_RULE_SETUP -#line 249 "program_lexer.l" +#line 288 "program_lexer.l" { return ENV; } YY_BREAK case 94: YY_RULE_SETUP -#line 250 "program_lexer.l" +#line 289 "program_lexer.l" { return EYE; } YY_BREAK case 95: YY_RULE_SETUP -#line 251 "program_lexer.l" +#line 290 "program_lexer.l" { return FOGCOORD; } YY_BREAK case 96: YY_RULE_SETUP -#line 252 "program_lexer.l" +#line 291 "program_lexer.l" { return FOG; } YY_BREAK case 97: YY_RULE_SETUP -#line 253 "program_lexer.l" +#line 292 "program_lexer.l" { return FRONT; } YY_BREAK case 98: YY_RULE_SETUP -#line 254 "program_lexer.l" +#line 293 "program_lexer.l" { return HALF; } YY_BREAK case 99: YY_RULE_SETUP -#line 255 "program_lexer.l" +#line 294 "program_lexer.l" { return INVERSE; } YY_BREAK case 100: YY_RULE_SETUP -#line 256 "program_lexer.l" +#line 295 "program_lexer.l" { return INVTRANS; } YY_BREAK case 101: YY_RULE_SETUP -#line 257 "program_lexer.l" +#line 296 "program_lexer.l" { return LIGHT; } YY_BREAK case 102: YY_RULE_SETUP -#line 258 "program_lexer.l" +#line 297 "program_lexer.l" { return LIGHTMODEL; } YY_BREAK case 103: YY_RULE_SETUP -#line 259 "program_lexer.l" +#line 298 "program_lexer.l" { return LIGHTPROD; } YY_BREAK case 104: YY_RULE_SETUP -#line 260 "program_lexer.l" +#line 299 "program_lexer.l" { return LOCAL; } YY_BREAK case 105: YY_RULE_SETUP -#line 261 "program_lexer.l" +#line 300 "program_lexer.l" { return MATERIAL; } YY_BREAK case 106: YY_RULE_SETUP -#line 262 "program_lexer.l" +#line 301 "program_lexer.l" { return MAT_PROGRAM; } YY_BREAK case 107: YY_RULE_SETUP -#line 263 "program_lexer.l" +#line 302 "program_lexer.l" { return MATRIX; } YY_BREAK case 108: YY_RULE_SETUP -#line 264 "program_lexer.l" +#line 303 "program_lexer.l" { return_token_or_DOT(require_ARB_vp, MATRIXINDEX); } YY_BREAK case 109: YY_RULE_SETUP -#line 265 "program_lexer.l" +#line 304 "program_lexer.l" { return MODELVIEW; } YY_BREAK case 110: YY_RULE_SETUP -#line 266 "program_lexer.l" +#line 305 "program_lexer.l" { return MVP; } YY_BREAK case 111: YY_RULE_SETUP -#line 267 "program_lexer.l" +#line 306 "program_lexer.l" { return_token_or_DOT(require_ARB_vp, NORMAL); } YY_BREAK case 112: YY_RULE_SETUP -#line 268 "program_lexer.l" +#line 307 "program_lexer.l" { return OBJECT; } YY_BREAK case 113: YY_RULE_SETUP -#line 269 "program_lexer.l" +#line 308 "program_lexer.l" { return PALETTE; } YY_BREAK case 114: YY_RULE_SETUP -#line 270 "program_lexer.l" +#line 309 "program_lexer.l" { return PARAMS; } YY_BREAK case 115: YY_RULE_SETUP -#line 271 "program_lexer.l" +#line 310 "program_lexer.l" { return PLANE; } YY_BREAK case 116: YY_RULE_SETUP -#line 272 "program_lexer.l" +#line 311 "program_lexer.l" { return_token_or_DOT(require_ARB_vp, POINT_TOK); } YY_BREAK case 117: YY_RULE_SETUP -#line 273 "program_lexer.l" +#line 312 "program_lexer.l" { return_token_or_DOT(require_ARB_vp, POINTSIZE); } YY_BREAK case 118: YY_RULE_SETUP -#line 274 "program_lexer.l" +#line 313 "program_lexer.l" { return POSITION; } YY_BREAK case 119: YY_RULE_SETUP -#line 275 "program_lexer.l" +#line 314 "program_lexer.l" { return PRIMARY; } YY_BREAK case 120: YY_RULE_SETUP -#line 276 "program_lexer.l" +#line 315 "program_lexer.l" { return PROJECTION; } YY_BREAK case 121: YY_RULE_SETUP -#line 277 "program_lexer.l" +#line 316 "program_lexer.l" { return_token_or_DOT(require_ARB_fp, RANGE); } YY_BREAK case 122: YY_RULE_SETUP -#line 278 "program_lexer.l" +#line 317 "program_lexer.l" { return ROW; } YY_BREAK case 123: YY_RULE_SETUP -#line 279 "program_lexer.l" +#line 318 "program_lexer.l" { return SCENECOLOR; } YY_BREAK case 124: YY_RULE_SETUP -#line 280 "program_lexer.l" +#line 319 "program_lexer.l" { return SECONDARY; } YY_BREAK case 125: YY_RULE_SETUP -#line 281 "program_lexer.l" +#line 320 "program_lexer.l" { return SHININESS; } YY_BREAK case 126: YY_RULE_SETUP -#line 282 "program_lexer.l" +#line 321 "program_lexer.l" { return_token_or_DOT(require_ARB_vp, SIZE_TOK); } YY_BREAK case 127: YY_RULE_SETUP -#line 283 "program_lexer.l" +#line 322 "program_lexer.l" { return SPECULAR; } YY_BREAK case 128: YY_RULE_SETUP -#line 284 "program_lexer.l" +#line 323 "program_lexer.l" { return SPOT; } YY_BREAK case 129: YY_RULE_SETUP -#line 285 "program_lexer.l" +#line 324 "program_lexer.l" { return TEXCOORD; } YY_BREAK case 130: YY_RULE_SETUP -#line 286 "program_lexer.l" +#line 325 "program_lexer.l" { return_token_or_DOT(require_ARB_fp, TEXENV); } YY_BREAK case 131: YY_RULE_SETUP -#line 287 "program_lexer.l" +#line 326 "program_lexer.l" { return_token_or_DOT(require_ARB_vp, TEXGEN); } YY_BREAK case 132: YY_RULE_SETUP -#line 288 "program_lexer.l" +#line 327 "program_lexer.l" { return_token_or_DOT(require_ARB_vp, TEXGEN_Q); } YY_BREAK case 133: YY_RULE_SETUP -#line 289 "program_lexer.l" +#line 328 "program_lexer.l" { return_token_or_DOT(require_ARB_vp, TEXGEN_S); } YY_BREAK case 134: YY_RULE_SETUP -#line 290 "program_lexer.l" +#line 329 "program_lexer.l" { return_token_or_DOT(require_ARB_vp, TEXGEN_T); } YY_BREAK case 135: YY_RULE_SETUP -#line 291 "program_lexer.l" +#line 330 "program_lexer.l" { return TEXTURE; } YY_BREAK case 136: YY_RULE_SETUP -#line 292 "program_lexer.l" +#line 331 "program_lexer.l" { return TRANSPOSE; } YY_BREAK case 137: YY_RULE_SETUP -#line 293 "program_lexer.l" +#line 332 "program_lexer.l" { return_token_or_DOT(require_ARB_vp, VTXATTRIB); } YY_BREAK case 138: YY_RULE_SETUP -#line 294 "program_lexer.l" +#line 333 "program_lexer.l" { return_token_or_DOT(require_ARB_vp, WEIGHT); } YY_BREAK case 139: YY_RULE_SETUP -#line 296 "program_lexer.l" +#line 335 "program_lexer.l" { return_token_or_IDENTIFIER(require_ARB_fp, TEXTURE_UNIT); } YY_BREAK case 140: YY_RULE_SETUP -#line 297 "program_lexer.l" +#line 336 "program_lexer.l" { return_token_or_IDENTIFIER(require_ARB_fp, TEX_1D); } YY_BREAK case 141: YY_RULE_SETUP -#line 298 "program_lexer.l" +#line 337 "program_lexer.l" { return_token_or_IDENTIFIER(require_ARB_fp, TEX_2D); } YY_BREAK case 142: YY_RULE_SETUP -#line 299 "program_lexer.l" +#line 338 "program_lexer.l" { return_token_or_IDENTIFIER(require_ARB_fp, TEX_3D); } YY_BREAK case 143: YY_RULE_SETUP -#line 300 "program_lexer.l" +#line 339 "program_lexer.l" { return_token_or_IDENTIFIER(require_ARB_fp, TEX_CUBE); } YY_BREAK case 144: YY_RULE_SETUP -#line 301 "program_lexer.l" +#line 340 "program_lexer.l" { return_token_or_IDENTIFIER(require_ARB_fp && require_rect, TEX_RECT); } YY_BREAK case 145: YY_RULE_SETUP -#line 302 "program_lexer.l" +#line 341 "program_lexer.l" { return_token_or_IDENTIFIER(require_ARB_fp && require_shadow, TEX_SHADOW1D); } YY_BREAK case 146: YY_RULE_SETUP -#line 303 "program_lexer.l" +#line 342 "program_lexer.l" { return_token_or_IDENTIFIER(require_ARB_fp && require_shadow, TEX_SHADOW2D); } YY_BREAK case 147: YY_RULE_SETUP -#line 304 "program_lexer.l" +#line 343 "program_lexer.l" { return_token_or_IDENTIFIER(require_ARB_fp && require_shadow && require_rect, TEX_SHADOWRECT); } YY_BREAK case 148: YY_RULE_SETUP -#line 305 "program_lexer.l" +#line 344 "program_lexer.l" { return_token_or_IDENTIFIER(require_ARB_fp && require_texarray, TEX_ARRAY1D); } YY_BREAK case 149: YY_RULE_SETUP -#line 306 "program_lexer.l" +#line 345 "program_lexer.l" { return_token_or_IDENTIFIER(require_ARB_fp && require_texarray, TEX_ARRAY2D); } YY_BREAK case 150: YY_RULE_SETUP -#line 307 "program_lexer.l" +#line 346 "program_lexer.l" { return_token_or_IDENTIFIER(require_ARB_fp && require_shadow && require_texarray, TEX_ARRAYSHADOW1D); } YY_BREAK case 151: YY_RULE_SETUP -#line 308 "program_lexer.l" +#line 347 "program_lexer.l" { return_token_or_IDENTIFIER(require_ARB_fp && require_shadow && require_texarray, TEX_ARRAYSHADOW2D); } YY_BREAK case 152: YY_RULE_SETUP -#line 310 "program_lexer.l" +#line 349 "program_lexer.l" { - yylval->string = strdup(yytext); + yylval->string = return_string(yyextra, yytext); return IDENTIFIER; } YY_BREAK case 153: YY_RULE_SETUP -#line 315 "program_lexer.l" +#line 354 "program_lexer.l" { return DOT_DOT; } YY_BREAK case 154: YY_RULE_SETUP -#line 317 "program_lexer.l" +#line 356 "program_lexer.l" { yylval->integer = strtol(yytext, NULL, 10); return INTEGER; @@ -2116,7 +2169,7 @@ YY_RULE_SETUP YY_BREAK case 155: YY_RULE_SETUP -#line 321 "program_lexer.l" +#line 360 "program_lexer.l" { yylval->real = _mesa_strtod(yytext, NULL); return REAL; @@ -2128,7 +2181,7 @@ case 156: yyg->yy_c_buf_p = yy_cp -= 1; YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 325 "program_lexer.l" +#line 364 "program_lexer.l" { yylval->real = _mesa_strtod(yytext, NULL); return REAL; @@ -2136,7 +2189,7 @@ YY_RULE_SETUP YY_BREAK case 157: YY_RULE_SETUP -#line 329 "program_lexer.l" +#line 368 "program_lexer.l" { yylval->real = _mesa_strtod(yytext, NULL); return REAL; @@ -2144,7 +2197,7 @@ YY_RULE_SETUP YY_BREAK case 158: YY_RULE_SETUP -#line 333 "program_lexer.l" +#line 372 "program_lexer.l" { yylval->real = _mesa_strtod(yytext, NULL); return REAL; @@ -2152,7 +2205,7 @@ YY_RULE_SETUP YY_BREAK case 159: YY_RULE_SETUP -#line 338 "program_lexer.l" +#line 377 "program_lexer.l" { yylval->swiz_mask.swizzle = SWIZZLE_NOOP; yylval->swiz_mask.mask = WRITEMASK_XYZW; @@ -2161,7 +2214,7 @@ YY_RULE_SETUP YY_BREAK case 160: YY_RULE_SETUP -#line 344 "program_lexer.l" +#line 383 "program_lexer.l" { yylval->swiz_mask.swizzle = SWIZZLE_INVAL; yylval->swiz_mask.mask = WRITEMASK_XY @@ -2171,7 +2224,7 @@ YY_RULE_SETUP YY_BREAK case 161: YY_RULE_SETUP -#line 350 "program_lexer.l" +#line 389 "program_lexer.l" { yylval->swiz_mask.swizzle = SWIZZLE_INVAL; yylval->swiz_mask.mask = WRITEMASK_XZW; @@ -2180,7 +2233,7 @@ YY_RULE_SETUP YY_BREAK case 162: YY_RULE_SETUP -#line 355 "program_lexer.l" +#line 394 "program_lexer.l" { yylval->swiz_mask.swizzle = SWIZZLE_INVAL; yylval->swiz_mask.mask = WRITEMASK_YZW; @@ -2189,7 +2242,7 @@ YY_RULE_SETUP YY_BREAK case 163: YY_RULE_SETUP -#line 361 "program_lexer.l" +#line 400 "program_lexer.l" { yylval->swiz_mask.swizzle = SWIZZLE_INVAL; yylval->swiz_mask.mask = WRITEMASK_X @@ -2199,7 +2252,7 @@ YY_RULE_SETUP YY_BREAK case 164: YY_RULE_SETUP -#line 367 "program_lexer.l" +#line 406 "program_lexer.l" { yylval->swiz_mask.swizzle = SWIZZLE_INVAL; yylval->swiz_mask.mask = WRITEMASK_Y @@ -2209,7 +2262,7 @@ YY_RULE_SETUP YY_BREAK case 165: YY_RULE_SETUP -#line 373 "program_lexer.l" +#line 412 "program_lexer.l" { yylval->swiz_mask.swizzle = SWIZZLE_INVAL; yylval->swiz_mask.mask = WRITEMASK_ZW; @@ -2218,7 +2271,7 @@ YY_RULE_SETUP YY_BREAK case 166: YY_RULE_SETUP -#line 379 "program_lexer.l" +#line 418 "program_lexer.l" { const unsigned s = swiz_from_char(yytext[1]); yylval->swiz_mask.swizzle = MAKE_SWIZZLE4(s, s, s, s); @@ -2228,7 +2281,7 @@ YY_RULE_SETUP YY_BREAK case 167: YY_RULE_SETUP -#line 386 "program_lexer.l" +#line 425 "program_lexer.l" { yylval->swiz_mask.swizzle = MAKE_SWIZZLE4(swiz_from_char(yytext[1]), swiz_from_char(yytext[2]), @@ -2240,7 +2293,7 @@ YY_RULE_SETUP YY_BREAK case 168: YY_RULE_SETUP -#line 395 "program_lexer.l" +#line 434 "program_lexer.l" { yylval->swiz_mask.swizzle = SWIZZLE_NOOP; yylval->swiz_mask.mask = WRITEMASK_XYZW; @@ -2249,7 +2302,7 @@ YY_RULE_SETUP YY_BREAK case 169: YY_RULE_SETUP -#line 401 "program_lexer.l" +#line 440 "program_lexer.l" { yylval->swiz_mask.swizzle = SWIZZLE_INVAL; yylval->swiz_mask.mask = WRITEMASK_XY @@ -2259,7 +2312,7 @@ YY_RULE_SETUP YY_BREAK case 170: YY_RULE_SETUP -#line 407 "program_lexer.l" +#line 446 "program_lexer.l" { yylval->swiz_mask.swizzle = SWIZZLE_INVAL; yylval->swiz_mask.mask = WRITEMASK_XZW; @@ -2268,7 +2321,7 @@ YY_RULE_SETUP YY_BREAK case 171: YY_RULE_SETUP -#line 412 "program_lexer.l" +#line 451 "program_lexer.l" { yylval->swiz_mask.swizzle = SWIZZLE_INVAL; yylval->swiz_mask.mask = WRITEMASK_YZW; @@ -2277,7 +2330,7 @@ YY_RULE_SETUP YY_BREAK case 172: YY_RULE_SETUP -#line 418 "program_lexer.l" +#line 457 "program_lexer.l" { yylval->swiz_mask.swizzle = SWIZZLE_INVAL; yylval->swiz_mask.mask = WRITEMASK_X @@ -2287,7 +2340,7 @@ YY_RULE_SETUP YY_BREAK case 173: YY_RULE_SETUP -#line 424 "program_lexer.l" +#line 463 "program_lexer.l" { yylval->swiz_mask.swizzle = SWIZZLE_INVAL; yylval->swiz_mask.mask = WRITEMASK_Y @@ -2297,7 +2350,7 @@ YY_RULE_SETUP YY_BREAK case 174: YY_RULE_SETUP -#line 430 "program_lexer.l" +#line 469 "program_lexer.l" { yylval->swiz_mask.swizzle = SWIZZLE_INVAL; yylval->swiz_mask.mask = WRITEMASK_ZW; @@ -2306,7 +2359,7 @@ YY_RULE_SETUP YY_BREAK case 175: YY_RULE_SETUP -#line 436 "program_lexer.l" +#line 475 "program_lexer.l" { const unsigned s = swiz_from_char(yytext[1]); yylval->swiz_mask.swizzle = MAKE_SWIZZLE4(s, s, s, s); @@ -2316,7 +2369,7 @@ YY_RULE_SETUP YY_BREAK case 176: YY_RULE_SETUP -#line 444 "program_lexer.l" +#line 483 "program_lexer.l" { if (require_ARB_vp) { return TEXGEN_R; @@ -2330,7 +2383,7 @@ YY_RULE_SETUP YY_BREAK case 177: YY_RULE_SETUP -#line 455 "program_lexer.l" +#line 494 "program_lexer.l" { yylval->swiz_mask.swizzle = MAKE_SWIZZLE4(swiz_from_char(yytext[1]), swiz_from_char(yytext[2]), @@ -2342,13 +2395,13 @@ YY_RULE_SETUP YY_BREAK case 178: YY_RULE_SETUP -#line 464 "program_lexer.l" +#line 503 "program_lexer.l" { return DOT; } YY_BREAK case 179: /* rule 179 can match eol */ YY_RULE_SETUP -#line 466 "program_lexer.l" +#line 505 "program_lexer.l" { yylloc->first_line++; yylloc->first_column = 1; @@ -2359,7 +2412,7 @@ YY_RULE_SETUP YY_BREAK case 180: YY_RULE_SETUP -#line 473 "program_lexer.l" +#line 512 "program_lexer.l" /* eat whitespace */ ; YY_BREAK case 181: @@ -2367,20 +2420,20 @@ case 181: yyg->yy_c_buf_p = yy_cp -= 1; YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 474 "program_lexer.l" +#line 513 "program_lexer.l" /* eat comments */ ; YY_BREAK case 182: YY_RULE_SETUP -#line 475 "program_lexer.l" +#line 514 "program_lexer.l" { return yytext[0]; } YY_BREAK case 183: YY_RULE_SETUP -#line 476 "program_lexer.l" +#line 515 "program_lexer.l" ECHO; YY_BREAK -#line 2384 "lex.yy.c" +#line 2437 "lex.yy.c" case YY_STATE_EOF(INITIAL): yyterminate(); @@ -3148,8 +3201,8 @@ YY_BUFFER_STATE yy_scan_string (yyconst char * yystr , yyscan_t yyscanner) /** Setup the input buffer state to scan the given bytes. The next call to yylex() will * scan from a @e copy of @a bytes. - * @param bytes the byte buffer to scan - * @param len the number of bytes in the buffer pointed to by @a bytes. + * @param yybytes the byte buffer to scan + * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. * @param yyscanner The scanner object. * @return the newly allocated buffer state object. */ @@ -3555,7 +3608,7 @@ void yyfree (void * ptr , yyscan_t yyscanner) #define YYTABLES_NAME "yytables" -#line 476 "program_lexer.l" +#line 515 "program_lexer.l" diff --git a/src/mesa/shader/program_lexer.l b/src/mesa/shader/program_lexer.l index c2803ff707..6c4fad3037 100644 --- a/src/mesa/shader/program_lexer.l +++ b/src/mesa/shader/program_lexer.l @@ -40,7 +40,7 @@ if (condition) { \ return token; \ } else { \ - yylval->string = strdup(yytext); \ + yylval->string = return_string(yyextra, yytext); \ return IDENTIFIER; \ } \ } while (0) @@ -63,7 +63,7 @@ yylval->temp_inst.SaturateMode = SATURATE_ ## sat; \ return token; \ } else { \ - yylval->string = strdup(yytext); \ + yylval->string = return_string(yyextra, yytext); \ return IDENTIFIER; \ } \ } while (0) @@ -71,6 +71,45 @@ #define SWIZZLE_INVAL MAKE_SWIZZLE4(SWIZZLE_NIL, SWIZZLE_NIL, \ SWIZZLE_NIL, SWIZZLE_NIL) +/** + * Send a string to the parser using asm_parser_state::string_dumpster + * + * Sends a string to the parser using asm_parser_state::string_dumpster as a + * temporary storage buffer. Data previously stored in + * asm_parser_state::string_dumpster will be lost. If + * asm_parser_state::string_dumpster is not large enough to hold the new + * string, the buffer size will be increased. The buffer size is \b never + * decreased. + * + * \param state Assembler parser state tracking + * \param str String to be passed to the parser + * + * \return + * A pointer to asm_parser_state::string_dumpster on success or \c NULL on + * failure. Currently the only failure case is \c ENOMEM. + */ +static char * +return_string(struct asm_parser_state *state, const char *str) +{ + const size_t len = strlen(str); + + if (len >= state->dumpster_size) { + char *const dumpster = _mesa_realloc(state->string_dumpster, + state->dumpster_size, + len + 1); + if (dumpster == NULL) { + return NULL; + } + + state->string_dumpster = dumpster; + state->dumpster_size = len + 1; + } + + memcpy(state->string_dumpster, str, len + 1); + return state->string_dumpster; +} + + static unsigned mask_from_char(char c) { @@ -308,7 +347,7 @@ ARRAYSHADOW1D { return_token_or_IDENTIFIER(require_ARB_fp && require ARRAYSHADOW2D { return_token_or_IDENTIFIER(require_ARB_fp && require_shadow && require_texarray, TEX_ARRAYSHADOW2D); } [_a-zA-Z$][_a-zA-Z0-9$]* { - yylval->string = strdup(yytext); + yylval->string = return_string(yyextra, yytext); return IDENTIFIER; } diff --git a/src/mesa/shader/program_parse.tab.c b/src/mesa/shader/program_parse.tab.c index c255e912ed..261b605a2d 100644 --- a/src/mesa/shader/program_parse.tab.c +++ b/src/mesa/shader/program_parse.tab.c @@ -4565,7 +4565,7 @@ yyreduce: "undefined variable binding in ALIAS statement"); YYERROR; } else { - _mesa_symbol_table_add_symbol(state->st, 0, (yyvsp[(2) - (4)].string), target); + _mesa_symbol_table_add_symbol(state->st, 0, strdup((yyvsp[(2) - (4)].string)), target); } ;} break; @@ -4896,10 +4896,14 @@ declare_variable(struct asm_parser_state *state, char *name, enum asm_type t, if (exist != NULL) { yyerror(locp, state, "redeclared identifier"); } else { - s = calloc(1, sizeof(struct asm_symbol)); - s->name = name; + const size_t name_len = strlen(name); + + s = calloc(1, sizeof(struct asm_symbol) + name_len + 1); + s->name = (char *)(s + 1); s->type = t; + memcpy((char *) s->name, name, name_len + 1); + switch (t) { case at_temp: if (state->prog->NumTemporaries >= state->limits->MaxTemps) { @@ -5147,6 +5151,11 @@ _mesa_parse_arb_program(GLcontext *ctx, GLenum target, const GLubyte *str, _mesa_memcpy (strz, str, len); strz[len] = '\0'; + if (state->prog->String != NULL) { + _mesa_free(state->prog->String); + state->prog->String = NULL; + } + state->prog->String = strz; state->st = _mesa_symbol_table_ctor(); @@ -5236,7 +5245,6 @@ error: for (sym = state->sym; sym != NULL; sym = temp) { temp = sym->next; - _mesa_free((void *) sym->name); _mesa_free(sym); } state->sym = NULL; @@ -5244,6 +5252,11 @@ error: _mesa_symbol_table_dtor(state->st); state->st = NULL; + if (state->string_dumpster != NULL) { + _mesa_free(state->string_dumpster); + state->dumpster_size = 0; + } + return result; } diff --git a/src/mesa/shader/program_parse.y b/src/mesa/shader/program_parse.y index c3152aa2f8..a23625d3fb 100644 --- a/src/mesa/shader/program_parse.y +++ b/src/mesa/shader/program_parse.y @@ -1919,7 +1919,7 @@ ALIAS_statement: ALIAS IDENTIFIER '=' IDENTIFIER "undefined variable binding in ALIAS statement"); YYERROR; } else { - _mesa_symbol_table_add_symbol(state->st, 0, $2, target); + _mesa_symbol_table_add_symbol(state->st, 0, strdup($2), target); } } ; @@ -2027,10 +2027,14 @@ declare_variable(struct asm_parser_state *state, char *name, enum asm_type t, if (exist != NULL) { yyerror(locp, state, "redeclared identifier"); } else { - s = calloc(1, sizeof(struct asm_symbol)); - s->name = name; + const size_t name_len = strlen(name); + + s = calloc(1, sizeof(struct asm_symbol) + name_len + 1); + s->name = (char *)(s + 1); s->type = t; + memcpy((char *) s->name, name, name_len + 1); + switch (t) { case at_temp: if (state->prog->NumTemporaries >= state->limits->MaxTemps) { @@ -2280,6 +2284,7 @@ _mesa_parse_arb_program(GLcontext *ctx, GLenum target, const GLubyte *str, if (state->prog->String != NULL) { _mesa_free(state->prog->String); + state->prog->String = NULL; } state->prog->String = strz; @@ -2371,7 +2376,6 @@ error: for (sym = state->sym; sym != NULL; sym = temp) { temp = sym->next; - _mesa_free((void *) sym->name); _mesa_free(sym); } state->sym = NULL; @@ -2379,5 +2383,10 @@ error: _mesa_symbol_table_dtor(state->st); state->st = NULL; + if (state->string_dumpster != NULL) { + _mesa_free(state->string_dumpster); + state->dumpster_size = 0; + } + return result; } diff --git a/src/mesa/shader/program_parser.h b/src/mesa/shader/program_parser.h index fa47d84565..8d8b4d89bc 100644 --- a/src/mesa/shader/program_parser.h +++ b/src/mesa/shader/program_parser.h @@ -38,6 +38,13 @@ enum asm_type { at_output, }; +/** + * \note + * Objects of this type are allocated as the object plus the name of the + * symbol. That is, malloc(sizeof(struct asm_symbol) + strlen(name) + 1). + * Alternately, asm_symbol::name could be moved to the bottom of the structure + * and declared as 'char name[0];'. + */ struct asm_symbol { struct asm_symbol *next; /**< List linkage for freeing. */ const char *name; @@ -157,6 +164,15 @@ struct asm_parser_state { /*@}*/ + /** + * Buffer to hold strings transfered from the lexer to the parser + */ + /*@{*/ + char *string_dumpster; /**< String data transfered. */ + size_t dumpster_size; /**< Total size, in bytes, of the buffer. */ + /*@}*/ + + /** * Selected limits copied from gl_constants * -- cgit v1.2.3 From df5615de1f1bfc68417eb2a6381fe3d8ab9ac035 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 30 Oct 2009 19:05:50 -0600 Subject: ARB prog parser: new set_src_reg(), set_dst_reg() helpers These functions do sanity checks on the register file and index. --- src/mesa/shader/program_parse.y | 83 +++++++++++++++++++++++++++-------------- 1 file changed, 55 insertions(+), 28 deletions(-) (limited to 'src/mesa/shader/program_parse.y') diff --git a/src/mesa/shader/program_parse.y b/src/mesa/shader/program_parse.y index 20bde83af7..32b058400c 100644 --- a/src/mesa/shader/program_parse.y +++ b/src/mesa/shader/program_parse.y @@ -66,8 +66,14 @@ static int validate_inputs(struct YYLTYPE *locp, static void init_dst_reg(struct prog_dst_register *r); +static void set_dst_reg(struct prog_dst_register *r, + gl_register_file file, GLint index); + static void init_src_reg(struct asm_src_register *r); +static void set_src_reg(struct asm_src_register *r, + gl_register_file file, GLint index); + static void asm_instruction_set_operands(struct asm_instruction *inst, const struct prog_dst_register *dst, const struct asm_src_register *src0, const struct asm_src_register *src1, const struct asm_src_register *src2); @@ -580,9 +586,7 @@ scalarUse: srcReg scalarSuffix temp_sym.param_binding_begin = ~0; initialize_symbol_from_const(state->prog, & temp_sym, & $1); - init_src_reg(& $$); - $$.Base.File = PROGRAM_CONSTANT; - $$.Base.Index = temp_sym.param_binding_begin; + set_src_reg(& $$, PROGRAM_CONSTANT, temp_sym.param_binding_begin); } ; @@ -644,9 +648,7 @@ maskedDstReg: dstReg optionalMask optionalCcMask maskedAddrReg: addrReg addrWriteMask { - init_dst_reg(& $$); - $$.File = PROGRAM_ADDRESS; - $$.Index = 0; + set_dst_reg(& $$, PROGRAM_ADDRESS, 0); $$.WriteMask = $2.mask; } ; @@ -776,16 +778,13 @@ srcReg: USED_IDENTIFIER /* temporaryReg | progParamSingle */ init_src_reg(& $$); switch (s->type) { case at_temp: - $$.Base.File = PROGRAM_TEMPORARY; - $$.Base.Index = s->temp_binding; + set_src_reg(& $$, PROGRAM_TEMPORARY, s->temp_binding); break; case at_param: - $$.Base.File = s->param_binding_type; - $$.Base.Index = s->param_binding_begin; + set_src_reg(& $$, s->param_binding_type, s->param_binding_begin); break; case at_attrib: - $$.Base.File = PROGRAM_INPUT; - $$.Base.Index = s->attrib_binding; + set_src_reg(& $$, PROGRAM_INPUT, s->attrib_binding); state->prog->InputsRead |= (1U << $$.Base.Index); if (!validate_inputs(& @1, state)) { @@ -800,9 +799,7 @@ srcReg: USED_IDENTIFIER /* temporaryReg | progParamSingle */ } | attribBinding { - init_src_reg(& $$); - $$.Base.File = PROGRAM_INPUT; - $$.Base.Index = $1; + set_src_reg(& $$, PROGRAM_INPUT, $1); state->prog->InputsRead |= (1U << $$.Base.Index); if (!validate_inputs(& @1, state)) { @@ -832,19 +829,16 @@ srcReg: USED_IDENTIFIER /* temporaryReg | progParamSingle */ } | paramSingleItemUse { - init_src_reg(& $$); - $$.Base.File = ($1.name != NULL) + gl_register_file file = ($1.name != NULL) ? $1.param_binding_type : PROGRAM_CONSTANT; - $$.Base.Index = $1.param_binding_begin; + set_src_reg(& $$, file, $1.param_binding_begin); } ; dstReg: resultBinding { - init_dst_reg(& $$); - $$.File = PROGRAM_OUTPUT; - $$.Index = $1; + set_dst_reg(& $$, PROGRAM_OUTPUT, $1); } | USED_IDENTIFIER /* temporaryReg | vertexResultReg */ { @@ -859,19 +853,15 @@ dstReg: resultBinding YYERROR; } - init_dst_reg(& $$); switch (s->type) { case at_temp: - $$.File = PROGRAM_TEMPORARY; - $$.Index = s->temp_binding; + set_dst_reg(& $$, PROGRAM_TEMPORARY, s->temp_binding); break; case at_output: - $$.File = PROGRAM_OUTPUT; - $$.Index = s->output_binding; + set_dst_reg(& $$, PROGRAM_OUTPUT, s->output_binding); break; default: - $$.File = s->param_binding_type; - $$.Index = s->param_binding_begin; + set_dst_reg(& $$, s->param_binding_type, s->param_binding_begin); break; } } @@ -2263,6 +2253,26 @@ init_dst_reg(struct prog_dst_register *r) } +/** Like init_dst_reg() but set the File and Index fields. */ +void +set_dst_reg(struct prog_dst_register *r, gl_register_file file, GLint index) +{ + const GLint maxIndex = 1 << INST_INDEX_BITS; + const GLint minIndex = 0; + ASSERT(index >= minIndex); + ASSERT(index <= maxIndex); + ASSERT(file == PROGRAM_TEMPORARY || + file == PROGRAM_ADDRESS || + file == PROGRAM_OUTPUT); + memset(r, 0, sizeof(*r)); + r->File = file; + r->Index = index; + r->WriteMask = WRITEMASK_XYZW; + r->CondMask = COND_TR; + r->CondSwizzle = SWIZZLE_NOOP; +} + + void init_src_reg(struct asm_src_register *r) { @@ -2273,6 +2283,23 @@ init_src_reg(struct asm_src_register *r) } +/** Like init_src_reg() but set the File and Index fields. */ +void +set_src_reg(struct asm_src_register *r, gl_register_file file, GLint index) +{ + const GLint maxIndex = (1 << INST_INDEX_BITS) - 1; + const GLint minIndex = -(1 << INST_INDEX_BITS); + ASSERT(index >= minIndex); + ASSERT(index <= maxIndex); + ASSERT(file < PROGRAM_FILE_MAX); + memset(r, 0, sizeof(*r)); + r->Base.File = file; + r->Base.Index = index; + r->Base.Swizzle = SWIZZLE_NOOP; + r->Symbol = NULL; +} + + /** * Validate the set of inputs used by a program * -- cgit v1.2.3 From fe86f8d73268785b31bc8d5a278a233bff42034d Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 4 Nov 2009 17:26:48 -0700 Subject: ARB prog parser: include variable name in error text --- src/mesa/shader/program_parse.tab.c | 1065 ++++++++++++++++++++++++----------- src/mesa/shader/program_parse.tab.h | 151 +---- src/mesa/shader/program_parse.y | 5 +- 3 files changed, 751 insertions(+), 470 deletions(-) (limited to 'src/mesa/shader/program_parse.y') diff --git a/src/mesa/shader/program_parse.tab.c b/src/mesa/shader/program_parse.tab.c index 7f45e0987d..e57c83ea65 100644 --- a/src/mesa/shader/program_parse.tab.c +++ b/src/mesa/shader/program_parse.tab.c @@ -1,24 +1,23 @@ -/* A Bison parser, made by GNU Bison 2.3. */ -/* Skeleton implementation for Bison's Yacc-like parsers in C +/* A Bison parser, made by GNU Bison 2.4.1. */ - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 +/* Skeleton implementation for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify + + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. */ + along with this program. If not, see . */ /* As a special exception, you may create a larger work that contains part or all of the Bison parser skeleton and distribute that work @@ -29,7 +28,7 @@ special exception, which will cause the skeleton and the resulting Bison output files to be licensed under the GNU General Public License without this special exception. - + This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ @@ -47,7 +46,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "2.3" +#define YYBISON_VERSION "2.4.1" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -55,235 +54,20 @@ /* Pure parsers. */ #define YYPURE 1 -/* Using locations. */ -#define YYLSP_NEEDED 1 - +/* Push parsers. */ +#define YYPUSH 0 +/* Pull parsers. */ +#define YYPULL 1 -/* Tokens. */ -#ifndef YYTOKENTYPE -# define YYTOKENTYPE - /* Put the tokens into the symbol table, so that GDB and other debuggers - know about them. */ - enum yytokentype { - ARBvp_10 = 258, - ARBfp_10 = 259, - ADDRESS = 260, - ALIAS = 261, - ATTRIB = 262, - OPTION = 263, - OUTPUT = 264, - PARAM = 265, - TEMP = 266, - END = 267, - BIN_OP = 268, - BINSC_OP = 269, - SAMPLE_OP = 270, - SCALAR_OP = 271, - TRI_OP = 272, - VECTOR_OP = 273, - ARL = 274, - KIL = 275, - SWZ = 276, - TXD_OP = 277, - INTEGER = 278, - REAL = 279, - AMBIENT = 280, - ATTENUATION = 281, - BACK = 282, - CLIP = 283, - COLOR = 284, - DEPTH = 285, - DIFFUSE = 286, - DIRECTION = 287, - EMISSION = 288, - ENV = 289, - EYE = 290, - FOG = 291, - FOGCOORD = 292, - FRAGMENT = 293, - FRONT = 294, - HALF = 295, - INVERSE = 296, - INVTRANS = 297, - LIGHT = 298, - LIGHTMODEL = 299, - LIGHTPROD = 300, - LOCAL = 301, - MATERIAL = 302, - MAT_PROGRAM = 303, - MATRIX = 304, - MATRIXINDEX = 305, - MODELVIEW = 306, - MVP = 307, - NORMAL = 308, - OBJECT = 309, - PALETTE = 310, - PARAMS = 311, - PLANE = 312, - POINT_TOK = 313, - POINTSIZE = 314, - POSITION = 315, - PRIMARY = 316, - PROGRAM = 317, - PROJECTION = 318, - RANGE = 319, - RESULT = 320, - ROW = 321, - SCENECOLOR = 322, - SECONDARY = 323, - SHININESS = 324, - SIZE_TOK = 325, - SPECULAR = 326, - SPOT = 327, - STATE = 328, - TEXCOORD = 329, - TEXENV = 330, - TEXGEN = 331, - TEXGEN_Q = 332, - TEXGEN_R = 333, - TEXGEN_S = 334, - TEXGEN_T = 335, - TEXTURE = 336, - TRANSPOSE = 337, - TEXTURE_UNIT = 338, - TEX_1D = 339, - TEX_2D = 340, - TEX_3D = 341, - TEX_CUBE = 342, - TEX_RECT = 343, - TEX_SHADOW1D = 344, - TEX_SHADOW2D = 345, - TEX_SHADOWRECT = 346, - TEX_ARRAY1D = 347, - TEX_ARRAY2D = 348, - TEX_ARRAYSHADOW1D = 349, - TEX_ARRAYSHADOW2D = 350, - VERTEX = 351, - VTXATTRIB = 352, - WEIGHT = 353, - IDENTIFIER = 354, - USED_IDENTIFIER = 355, - MASK4 = 356, - MASK3 = 357, - MASK2 = 358, - MASK1 = 359, - SWIZZLE = 360, - DOT_DOT = 361, - DOT = 362 - }; -#endif -/* Tokens. */ -#define ARBvp_10 258 -#define ARBfp_10 259 -#define ADDRESS 260 -#define ALIAS 261 -#define ATTRIB 262 -#define OPTION 263 -#define OUTPUT 264 -#define PARAM 265 -#define TEMP 266 -#define END 267 -#define BIN_OP 268 -#define BINSC_OP 269 -#define SAMPLE_OP 270 -#define SCALAR_OP 271 -#define TRI_OP 272 -#define VECTOR_OP 273 -#define ARL 274 -#define KIL 275 -#define SWZ 276 -#define TXD_OP 277 -#define INTEGER 278 -#define REAL 279 -#define AMBIENT 280 -#define ATTENUATION 281 -#define BACK 282 -#define CLIP 283 -#define COLOR 284 -#define DEPTH 285 -#define DIFFUSE 286 -#define DIRECTION 287 -#define EMISSION 288 -#define ENV 289 -#define EYE 290 -#define FOG 291 -#define FOGCOORD 292 -#define FRAGMENT 293 -#define FRONT 294 -#define HALF 295 -#define INVERSE 296 -#define INVTRANS 297 -#define LIGHT 298 -#define LIGHTMODEL 299 -#define LIGHTPROD 300 -#define LOCAL 301 -#define MATERIAL 302 -#define MAT_PROGRAM 303 -#define MATRIX 304 -#define MATRIXINDEX 305 -#define MODELVIEW 306 -#define MVP 307 -#define NORMAL 308 -#define OBJECT 309 -#define PALETTE 310 -#define PARAMS 311 -#define PLANE 312 -#define POINT_TOK 313 -#define POINTSIZE 314 -#define POSITION 315 -#define PRIMARY 316 -#define PROGRAM 317 -#define PROJECTION 318 -#define RANGE 319 -#define RESULT 320 -#define ROW 321 -#define SCENECOLOR 322 -#define SECONDARY 323 -#define SHININESS 324 -#define SIZE_TOK 325 -#define SPECULAR 326 -#define SPOT 327 -#define STATE 328 -#define TEXCOORD 329 -#define TEXENV 330 -#define TEXGEN 331 -#define TEXGEN_Q 332 -#define TEXGEN_R 333 -#define TEXGEN_S 334 -#define TEXGEN_T 335 -#define TEXTURE 336 -#define TRANSPOSE 337 -#define TEXTURE_UNIT 338 -#define TEX_1D 339 -#define TEX_2D 340 -#define TEX_3D 341 -#define TEX_CUBE 342 -#define TEX_RECT 343 -#define TEX_SHADOW1D 344 -#define TEX_SHADOW2D 345 -#define TEX_SHADOWRECT 346 -#define TEX_ARRAY1D 347 -#define TEX_ARRAY2D 348 -#define TEX_ARRAYSHADOW1D 349 -#define TEX_ARRAYSHADOW2D 350 -#define VERTEX 351 -#define VTXATTRIB 352 -#define WEIGHT 353 -#define IDENTIFIER 354 -#define USED_IDENTIFIER 355 -#define MASK4 356 -#define MASK3 357 -#define MASK2 358 -#define MASK1 359 -#define SWIZZLE 360 -#define DOT_DOT 361 -#define DOT 362 - +/* Using locations. */ +#define YYLSP_NEEDED 1 /* Copy the first part of user declarations. */ + +/* Line 189 of yacc.c */ #line 1 "program_parse.y" /* @@ -400,6 +184,9 @@ static struct asm_instruction *asm_instruction_copy_ctor( #define YYLEX_PARAM state->scanner +/* Line 189 of yacc.c */ +#line 189 "program_parse.tab.c" + /* Enabling traces. */ #ifndef YYDEBUG # define YYDEBUG 0 @@ -418,10 +205,130 @@ static struct asm_instruction *asm_instruction_copy_ctor( # define YYTOKEN_TABLE 0 #endif + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + ARBvp_10 = 258, + ARBfp_10 = 259, + ADDRESS = 260, + ALIAS = 261, + ATTRIB = 262, + OPTION = 263, + OUTPUT = 264, + PARAM = 265, + TEMP = 266, + END = 267, + BIN_OP = 268, + BINSC_OP = 269, + SAMPLE_OP = 270, + SCALAR_OP = 271, + TRI_OP = 272, + VECTOR_OP = 273, + ARL = 274, + KIL = 275, + SWZ = 276, + TXD_OP = 277, + INTEGER = 278, + REAL = 279, + AMBIENT = 280, + ATTENUATION = 281, + BACK = 282, + CLIP = 283, + COLOR = 284, + DEPTH = 285, + DIFFUSE = 286, + DIRECTION = 287, + EMISSION = 288, + ENV = 289, + EYE = 290, + FOG = 291, + FOGCOORD = 292, + FRAGMENT = 293, + FRONT = 294, + HALF = 295, + INVERSE = 296, + INVTRANS = 297, + LIGHT = 298, + LIGHTMODEL = 299, + LIGHTPROD = 300, + LOCAL = 301, + MATERIAL = 302, + MAT_PROGRAM = 303, + MATRIX = 304, + MATRIXINDEX = 305, + MODELVIEW = 306, + MVP = 307, + NORMAL = 308, + OBJECT = 309, + PALETTE = 310, + PARAMS = 311, + PLANE = 312, + POINT_TOK = 313, + POINTSIZE = 314, + POSITION = 315, + PRIMARY = 316, + PROGRAM = 317, + PROJECTION = 318, + RANGE = 319, + RESULT = 320, + ROW = 321, + SCENECOLOR = 322, + SECONDARY = 323, + SHININESS = 324, + SIZE_TOK = 325, + SPECULAR = 326, + SPOT = 327, + STATE = 328, + TEXCOORD = 329, + TEXENV = 330, + TEXGEN = 331, + TEXGEN_Q = 332, + TEXGEN_R = 333, + TEXGEN_S = 334, + TEXGEN_T = 335, + TEXTURE = 336, + TRANSPOSE = 337, + TEXTURE_UNIT = 338, + TEX_1D = 339, + TEX_2D = 340, + TEX_3D = 341, + TEX_CUBE = 342, + TEX_RECT = 343, + TEX_SHADOW1D = 344, + TEX_SHADOW2D = 345, + TEX_SHADOWRECT = 346, + TEX_ARRAY1D = 347, + TEX_ARRAY2D = 348, + TEX_ARRAYSHADOW1D = 349, + TEX_ARRAYSHADOW2D = 350, + VERTEX = 351, + VTXATTRIB = 352, + WEIGHT = 353, + IDENTIFIER = 354, + USED_IDENTIFIER = 355, + MASK4 = 356, + MASK3 = 357, + MASK2 = 358, + MASK1 = 359, + SWIZZLE = 360, + DOT_DOT = 361, + DOT = 362 + }; +#endif + + + #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef union YYSTYPE -#line 122 "program_parse.y" { + +/* Line 214 of yacc.c */ +#line 122 "program_parse.y" + struct asm_instruction *inst; struct asm_symbol *sym; struct asm_symbol temp_sym; @@ -445,13 +352,15 @@ typedef union YYSTYPE unsigned xyzw_valid:1; unsigned negate:1; } ext_swizzle; -} -/* Line 187 of yacc.c. */ -#line 451 "program_parse.tab.c" - YYSTYPE; + + + +/* Line 214 of yacc.c */ +#line 360 "program_parse.tab.c" +} YYSTYPE; +# define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 -# define YYSTYPE_IS_TRIVIAL 1 #endif #if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED @@ -469,14 +378,16 @@ typedef struct YYLTYPE /* Copy the second part of user declarations. */ + +/* Line 264 of yacc.c */ #line 267 "program_parse.y" extern int yylex(YYSTYPE *yylval_param, YYLTYPE *yylloc_param, void *yyscanner); -/* Line 216 of yacc.c. */ -#line 480 "program_parse.tab.c" +/* Line 264 of yacc.c */ +#line 391 "program_parse.tab.c" #ifdef short # undef short @@ -551,14 +462,14 @@ typedef short int yytype_int16; #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static int -YYID (int i) +YYID (int yyi) #else static int -YYID (i) - int i; +YYID (yyi) + int yyi; #endif { - return i; + return yyi; } #endif @@ -640,9 +551,9 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */ /* A type that is properly aligned for any stack member. */ union yyalloc { - yytype_int16 yyss; - YYSTYPE yyvs; - YYLTYPE yyls; + yytype_int16 yyss_alloc; + YYSTYPE yyvs_alloc; + YYLTYPE yyls_alloc; }; /* The size of the maximum gap between one aligned stack and the next. */ @@ -677,12 +588,12 @@ union yyalloc elements in the stack, and YYPTR gives the new location of the stack. Advance YYPTR to a properly aligned location for the next stack. */ -# define YYSTACK_RELOCATE(Stack) \ +# define YYSTACK_RELOCATE(Stack_alloc, Stack) \ do \ { \ YYSIZE_T yynewbytes; \ - YYCOPY (&yyptr->Stack, Stack, yysize); \ - Stack = &yyptr->Stack; \ + YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ + Stack = &yyptr->Stack_alloc; \ yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ yyptr += yynewbytes / sizeof (*yyptr); \ } \ @@ -905,7 +816,7 @@ static const yytype_uint16 yyrline[] = 1949, 1957, 1970, 1979, 1988, 1992, 2001, 2010, 2021, 2028, 2033, 2042, 2054, 2057, 2066, 2077, 2078, 2079, 2082, 2083, 2084, 2087, 2088, 2091, 2092, 2095, 2096, 2099, 2110, 2121, - 2132, 2153, 2154 + 2132, 2154, 2155 }; #endif @@ -1553,17 +1464,20 @@ yy_symbol_print (yyoutput, yytype, yyvaluep, yylocationp, state) #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void -yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) +yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) #else static void -yy_stack_print (bottom, top) - yytype_int16 *bottom; - yytype_int16 *top; +yy_stack_print (yybottom, yytop) + yytype_int16 *yybottom; + yytype_int16 *yytop; #endif { YYFPRINTF (stderr, "Stack now"); - for (; bottom <= top; ++bottom) - YYFPRINTF (stderr, " %d", *bottom); + for (; yybottom <= yytop; yybottom++) + { + int yybot = *yybottom; + YYFPRINTF (stderr, " %d", yybot); + } YYFPRINTF (stderr, "\n"); } @@ -1599,11 +1513,11 @@ yy_reduce_print (yyvsp, yylsp, yyrule, state) /* The symbols being reduced. */ for (yyi = 0; yyi < yynrhs; yyi++) { - fprintf (stderr, " $%d = ", yyi + 1); + YYFPRINTF (stderr, " $%d = ", yyi + 1); yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], &(yyvsp[(yyi + 1) - (yynrhs)]) , &(yylsp[(yyi + 1) - (yynrhs)]) , state); - fprintf (stderr, "\n"); + YYFPRINTF (stderr, "\n"); } } @@ -1887,10 +1801,8 @@ yydestruct (yymsg, yytype, yyvaluep, yylocationp, state) break; } } - /* Prevent warnings from -Wmissing-prototypes. */ - #ifdef YYPARSE_PARAM #if defined __STDC__ || defined __cplusplus int yyparse (void *YYPARSE_PARAM); @@ -1909,10 +1821,9 @@ int yyparse (); - -/*----------. -| yyparse. | -`----------*/ +/*-------------------------. +| yyparse or yypush_parse. | +`-------------------------*/ #ifdef YYPARSE_PARAM #if (defined __STDC__ || defined __C99__FUNC__ \ @@ -1936,24 +1847,59 @@ yyparse (state) #endif #endif { - /* The look-ahead symbol. */ +/* The lookahead symbol. */ int yychar; -/* The semantic value of the look-ahead symbol. */ +/* The semantic value of the lookahead symbol. */ YYSTYPE yylval; -/* Number of syntax errors so far. */ -int yynerrs; -/* Location data for the look-ahead symbol. */ +/* Location data for the lookahead symbol. */ YYLTYPE yylloc; - int yystate; + /* Number of syntax errors so far. */ + int yynerrs; + + int yystate; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + + /* The stacks and their tools: + `yyss': related to states. + `yyvs': related to semantic values. + `yyls': related to locations. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss; + yytype_int16 *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs; + YYSTYPE *yyvsp; + + /* The location stack. */ + YYLTYPE yylsa[YYINITDEPTH]; + YYLTYPE *yyls; + YYLTYPE *yylsp; + + /* The locations where the error started and ended. */ + YYLTYPE yyerror_range[2]; + + YYSIZE_T yystacksize; + int yyn; int yyresult; - /* Number of tokens to shift before error messages enabled. */ - int yyerrstatus; - /* Look-ahead token as an internal (translated) token number. */ - int yytoken = 0; + /* Lookahead token as an internal (translated) token number. */ + int yytoken; + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + YYLTYPE yyloc; + #if YYERROR_VERBOSE /* Buffer for error messages, and its allocated size. */ char yymsgbuf[128]; @@ -1961,63 +1907,37 @@ YYLTYPE yylloc; YYSIZE_T yymsg_alloc = sizeof yymsgbuf; #endif - /* Three stacks and their tools: - `yyss': related to states, - `yyvs': related to semantic values, - `yyls': related to locations. - - Refer to the stacks thru separate pointers, to allow yyoverflow - to reallocate them elsewhere. */ - - /* The state stack. */ - yytype_int16 yyssa[YYINITDEPTH]; - yytype_int16 *yyss = yyssa; - yytype_int16 *yyssp; - - /* The semantic value stack. */ - YYSTYPE yyvsa[YYINITDEPTH]; - YYSTYPE *yyvs = yyvsa; - YYSTYPE *yyvsp; - - /* The location stack. */ - YYLTYPE yylsa[YYINITDEPTH]; - YYLTYPE *yyls = yylsa; - YYLTYPE *yylsp; - /* The locations where the error started and ended. */ - YYLTYPE yyerror_range[2]; - #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N), yylsp -= (N)) - YYSIZE_T yystacksize = YYINITDEPTH; - - /* The variables used to return semantic value and location from the - action routines. */ - YYSTYPE yyval; - YYLTYPE yyloc; - /* The number of symbols on the RHS of the reduced rule. Keep to zero when no symbol should be popped. */ int yylen = 0; + yytoken = 0; + yyss = yyssa; + yyvs = yyvsa; + yyls = yylsa; + yystacksize = YYINITDEPTH; + YYDPRINTF ((stderr, "Starting parse\n")); yystate = 0; yyerrstatus = 0; yynerrs = 0; - yychar = YYEMPTY; /* Cause a token to be read. */ + yychar = YYEMPTY; /* Cause a token to be read. */ /* Initialize stack pointers. Waste one element of value and location stack so that they stay on the same level as the state stack. The wasted elements are never initialized. */ - yyssp = yyss; yyvsp = yyvs; yylsp = yyls; + #if YYLTYPE_IS_TRIVIAL /* Initialize the default location before parsing starts. */ yylloc.first_line = yylloc.last_line = 1; - yylloc.first_column = yylloc.last_column = 0; + yylloc.first_column = yylloc.last_column = 1; #endif goto yysetstate; @@ -2056,6 +1976,7 @@ YYLTYPE yylloc; &yyvs1, yysize * sizeof (*yyvsp), &yyls1, yysize * sizeof (*yylsp), &yystacksize); + yyls = yyls1; yyss = yyss1; yyvs = yyvs1; @@ -2077,9 +1998,9 @@ YYLTYPE yylloc; (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); if (! yyptr) goto yyexhaustedlab; - YYSTACK_RELOCATE (yyss); - YYSTACK_RELOCATE (yyvs); - YYSTACK_RELOCATE (yyls); + YYSTACK_RELOCATE (yyss_alloc, yyss); + YYSTACK_RELOCATE (yyvs_alloc, yyvs); + YYSTACK_RELOCATE (yyls_alloc, yyls); # undef YYSTACK_RELOCATE if (yyss1 != yyssa) YYSTACK_FREE (yyss1); @@ -2100,6 +2021,9 @@ YYLTYPE yylloc; YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + if (yystate == YYFINAL) + YYACCEPT; + goto yybackup; /*-----------. @@ -2108,16 +2032,16 @@ YYLTYPE yylloc; yybackup: /* Do appropriate processing given the current state. Read a - look-ahead token if we need one and don't already have one. */ + lookahead token if we need one and don't already have one. */ - /* First try to decide what to do without reference to look-ahead token. */ + /* First try to decide what to do without reference to lookahead token. */ yyn = yypact[yystate]; if (yyn == YYPACT_NINF) goto yydefault; - /* Not known => get a look-ahead token if don't already have one. */ + /* Not known => get a lookahead token if don't already have one. */ - /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ + /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ if (yychar == YYEMPTY) { YYDPRINTF ((stderr, "Reading a token: ")); @@ -2149,20 +2073,16 @@ yybackup: goto yyreduce; } - if (yyn == YYFINAL) - YYACCEPT; - /* Count tokens shifted since error; after three, turn off error status. */ if (yyerrstatus) yyerrstatus--; - /* Shift the look-ahead token. */ + /* Shift the lookahead token. */ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); - /* Discard the shifted token unless it is eof. */ - if (yychar != YYEOF) - yychar = YYEMPTY; + /* Discard the shifted token. */ + yychar = YYEMPTY; yystate = yyn; *++yyvsp = yylval; @@ -2203,6 +2123,8 @@ yyreduce: switch (yyn) { case 3: + +/* Line 1455 of yacc.c */ #line 278 "program_parse.y" { if (state->prog->Target != GL_VERTEX_PROGRAM_ARB) { @@ -2214,6 +2136,8 @@ yyreduce: break; case 4: + +/* Line 1455 of yacc.c */ #line 286 "program_parse.y" { if (state->prog->Target != GL_FRAGMENT_PROGRAM_ARB) { @@ -2227,6 +2151,8 @@ yyreduce: break; case 7: + +/* Line 1455 of yacc.c */ #line 302 "program_parse.y" { int valid = 0; @@ -2250,6 +2176,8 @@ yyreduce: break; case 10: + +/* Line 1455 of yacc.c */ #line 328 "program_parse.y" { if ((yyvsp[(1) - (2)].inst) != NULL) { @@ -2268,6 +2196,8 @@ yyreduce: break; case 12: + +/* Line 1455 of yacc.c */ #line 346 "program_parse.y" { (yyval.inst) = (yyvsp[(1) - (1)].inst); @@ -2276,6 +2206,8 @@ yyreduce: break; case 13: + +/* Line 1455 of yacc.c */ #line 351 "program_parse.y" { (yyval.inst) = (yyvsp[(1) - (1)].inst); @@ -2284,6 +2216,8 @@ yyreduce: break; case 24: + +/* Line 1455 of yacc.c */ #line 372 "program_parse.y" { (yyval.inst) = asm_instruction_ctor(OPCODE_ARL, & (yyvsp[(2) - (4)].dst_reg), & (yyvsp[(4) - (4)].src_reg), NULL, NULL); @@ -2291,6 +2225,8 @@ yyreduce: break; case 25: + +/* Line 1455 of yacc.c */ #line 378 "program_parse.y" { (yyval.inst) = asm_instruction_copy_ctor(& (yyvsp[(1) - (4)].temp_inst), & (yyvsp[(2) - (4)].dst_reg), & (yyvsp[(4) - (4)].src_reg), NULL, NULL); @@ -2298,6 +2234,8 @@ yyreduce: break; case 26: + +/* Line 1455 of yacc.c */ #line 384 "program_parse.y" { (yyval.inst) = asm_instruction_copy_ctor(& (yyvsp[(1) - (4)].temp_inst), & (yyvsp[(2) - (4)].dst_reg), & (yyvsp[(4) - (4)].src_reg), NULL, NULL); @@ -2305,6 +2243,8 @@ yyreduce: break; case 27: + +/* Line 1455 of yacc.c */ #line 390 "program_parse.y" { (yyval.inst) = asm_instruction_copy_ctor(& (yyvsp[(1) - (6)].temp_inst), & (yyvsp[(2) - (6)].dst_reg), & (yyvsp[(4) - (6)].src_reg), & (yyvsp[(6) - (6)].src_reg), NULL); @@ -2312,6 +2252,8 @@ yyreduce: break; case 28: + +/* Line 1455 of yacc.c */ #line 397 "program_parse.y" { (yyval.inst) = asm_instruction_copy_ctor(& (yyvsp[(1) - (6)].temp_inst), & (yyvsp[(2) - (6)].dst_reg), & (yyvsp[(4) - (6)].src_reg), & (yyvsp[(6) - (6)].src_reg), NULL); @@ -2319,6 +2261,8 @@ yyreduce: break; case 29: + +/* Line 1455 of yacc.c */ #line 404 "program_parse.y" { (yyval.inst) = asm_instruction_copy_ctor(& (yyvsp[(1) - (8)].temp_inst), & (yyvsp[(2) - (8)].dst_reg), & (yyvsp[(4) - (8)].src_reg), & (yyvsp[(6) - (8)].src_reg), & (yyvsp[(8) - (8)].src_reg)); @@ -2326,6 +2270,8 @@ yyreduce: break; case 30: + +/* Line 1455 of yacc.c */ #line 410 "program_parse.y" { (yyval.inst) = asm_instruction_copy_ctor(& (yyvsp[(1) - (8)].temp_inst), & (yyvsp[(2) - (8)].dst_reg), & (yyvsp[(4) - (8)].src_reg), NULL, NULL); @@ -2371,6 +2317,8 @@ yyreduce: break; case 31: + +/* Line 1455 of yacc.c */ #line 454 "program_parse.y" { (yyval.inst) = asm_instruction_ctor(OPCODE_KIL, NULL, & (yyvsp[(2) - (2)].src_reg), NULL, NULL); @@ -2379,6 +2327,8 @@ yyreduce: break; case 32: + +/* Line 1455 of yacc.c */ #line 459 "program_parse.y" { (yyval.inst) = asm_instruction_ctor(OPCODE_KIL_NV, NULL, NULL, NULL, NULL); @@ -2390,6 +2340,8 @@ yyreduce: break; case 33: + +/* Line 1455 of yacc.c */ #line 469 "program_parse.y" { (yyval.inst) = asm_instruction_copy_ctor(& (yyvsp[(1) - (12)].temp_inst), & (yyvsp[(2) - (12)].dst_reg), & (yyvsp[(4) - (12)].src_reg), & (yyvsp[(6) - (12)].src_reg), & (yyvsp[(8) - (12)].src_reg)); @@ -2435,6 +2387,8 @@ yyreduce: break; case 34: + +/* Line 1455 of yacc.c */ #line 513 "program_parse.y" { (yyval.integer) = (yyvsp[(2) - (2)].integer); @@ -2442,66 +2396,92 @@ yyreduce: break; case 35: + +/* Line 1455 of yacc.c */ #line 518 "program_parse.y" { (yyval.integer) = TEXTURE_1D_INDEX; ;} break; case 36: + +/* Line 1455 of yacc.c */ #line 519 "program_parse.y" { (yyval.integer) = TEXTURE_2D_INDEX; ;} break; case 37: + +/* Line 1455 of yacc.c */ #line 520 "program_parse.y" { (yyval.integer) = TEXTURE_3D_INDEX; ;} break; case 38: + +/* Line 1455 of yacc.c */ #line 521 "program_parse.y" { (yyval.integer) = TEXTURE_CUBE_INDEX; ;} break; case 39: + +/* Line 1455 of yacc.c */ #line 522 "program_parse.y" { (yyval.integer) = TEXTURE_RECT_INDEX; ;} break; case 40: + +/* Line 1455 of yacc.c */ #line 523 "program_parse.y" { (yyval.integer) = -TEXTURE_1D_INDEX; ;} break; case 41: + +/* Line 1455 of yacc.c */ #line 524 "program_parse.y" { (yyval.integer) = -TEXTURE_2D_INDEX; ;} break; case 42: + +/* Line 1455 of yacc.c */ #line 525 "program_parse.y" { (yyval.integer) = -TEXTURE_RECT_INDEX; ;} break; case 43: + +/* Line 1455 of yacc.c */ #line 526 "program_parse.y" { (yyval.integer) = TEXTURE_1D_ARRAY_INDEX; ;} break; case 44: + +/* Line 1455 of yacc.c */ #line 527 "program_parse.y" { (yyval.integer) = TEXTURE_2D_ARRAY_INDEX; ;} break; case 45: + +/* Line 1455 of yacc.c */ #line 528 "program_parse.y" { (yyval.integer) = -TEXTURE_1D_ARRAY_INDEX; ;} break; case 46: + +/* Line 1455 of yacc.c */ #line 529 "program_parse.y" { (yyval.integer) = -TEXTURE_2D_ARRAY_INDEX; ;} break; case 47: + +/* Line 1455 of yacc.c */ #line 533 "program_parse.y" { /* FIXME: Is this correct? Should the extenedSwizzle be applied @@ -2515,6 +2495,8 @@ yyreduce: break; case 48: + +/* Line 1455 of yacc.c */ #line 545 "program_parse.y" { (yyval.src_reg) = (yyvsp[(2) - (2)].src_reg); @@ -2526,6 +2508,8 @@ yyreduce: break; case 49: + +/* Line 1455 of yacc.c */ #line 553 "program_parse.y" { (yyval.src_reg) = (yyvsp[(3) - (4)].src_reg); @@ -2544,6 +2528,8 @@ yyreduce: break; case 50: + +/* Line 1455 of yacc.c */ #line 570 "program_parse.y" { (yyval.src_reg) = (yyvsp[(1) - (2)].src_reg); @@ -2554,6 +2540,8 @@ yyreduce: break; case 51: + +/* Line 1455 of yacc.c */ #line 577 "program_parse.y" { struct asm_symbol temp_sym; @@ -2572,6 +2560,8 @@ yyreduce: break; case 52: + +/* Line 1455 of yacc.c */ #line 594 "program_parse.y" { (yyval.src_reg) = (yyvsp[(2) - (3)].src_reg); @@ -2586,6 +2576,8 @@ yyreduce: break; case 53: + +/* Line 1455 of yacc.c */ #line 605 "program_parse.y" { (yyval.src_reg) = (yyvsp[(3) - (5)].src_reg); @@ -2606,6 +2598,8 @@ yyreduce: break; case 54: + +/* Line 1455 of yacc.c */ #line 625 "program_parse.y" { (yyval.dst_reg) = (yyvsp[(1) - (3)].dst_reg); @@ -2632,6 +2626,8 @@ yyreduce: break; case 55: + +/* Line 1455 of yacc.c */ #line 650 "program_parse.y" { set_dst_reg(& (yyval.dst_reg), PROGRAM_ADDRESS, 0); @@ -2640,6 +2636,8 @@ yyreduce: break; case 56: + +/* Line 1455 of yacc.c */ #line 657 "program_parse.y" { const unsigned xyzw_valid = @@ -2674,6 +2672,8 @@ yyreduce: break; case 57: + +/* Line 1455 of yacc.c */ #line 690 "program_parse.y" { (yyval.ext_swizzle) = (yyvsp[(2) - (2)].ext_swizzle); @@ -2682,6 +2682,8 @@ yyreduce: break; case 58: + +/* Line 1455 of yacc.c */ #line 697 "program_parse.y" { if (((yyvsp[(1) - (1)].integer) != 0) && ((yyvsp[(1) - (1)].integer) != 1)) { @@ -2700,6 +2702,8 @@ yyreduce: break; case 59: + +/* Line 1455 of yacc.c */ #line 712 "program_parse.y" { if (strlen((yyvsp[(1) - (1)].string)) > 1) { @@ -2751,6 +2755,8 @@ yyreduce: break; case 60: + +/* Line 1455 of yacc.c */ #line 762 "program_parse.y" { struct asm_symbol *const s = (struct asm_symbol *) @@ -2793,6 +2799,8 @@ yyreduce: break; case 61: + +/* Line 1455 of yacc.c */ #line 801 "program_parse.y" { set_src_reg(& (yyval.src_reg), PROGRAM_INPUT, (yyvsp[(1) - (1)].attrib)); @@ -2805,6 +2813,8 @@ yyreduce: break; case 62: + +/* Line 1455 of yacc.c */ #line 810 "program_parse.y" { if (! (yyvsp[(3) - (4)].src_reg).Base.RelAddr @@ -2829,6 +2839,8 @@ yyreduce: break; case 63: + +/* Line 1455 of yacc.c */ #line 831 "program_parse.y" { gl_register_file file = ((yyvsp[(1) - (1)].temp_sym).name != NULL) @@ -2839,6 +2851,8 @@ yyreduce: break; case 64: + +/* Line 1455 of yacc.c */ #line 840 "program_parse.y" { set_dst_reg(& (yyval.dst_reg), PROGRAM_OUTPUT, (yyvsp[(1) - (1)].result)); @@ -2846,6 +2860,8 @@ yyreduce: break; case 65: + +/* Line 1455 of yacc.c */ #line 844 "program_parse.y" { struct asm_symbol *const s = (struct asm_symbol *) @@ -2874,6 +2890,8 @@ yyreduce: break; case 66: + +/* Line 1455 of yacc.c */ #line 871 "program_parse.y" { struct asm_symbol *const s = (struct asm_symbol *) @@ -2892,6 +2910,8 @@ yyreduce: break; case 69: + +/* Line 1455 of yacc.c */ #line 890 "program_parse.y" { init_src_reg(& (yyval.src_reg)); @@ -2900,6 +2920,8 @@ yyreduce: break; case 70: + +/* Line 1455 of yacc.c */ #line 897 "program_parse.y" { /* FINISHME: Add support for multiple address registers. @@ -2913,21 +2935,29 @@ yyreduce: break; case 71: + +/* Line 1455 of yacc.c */ #line 908 "program_parse.y" { (yyval.integer) = 0; ;} break; case 72: + +/* Line 1455 of yacc.c */ #line 909 "program_parse.y" { (yyval.integer) = (yyvsp[(2) - (2)].integer); ;} break; case 73: + +/* Line 1455 of yacc.c */ #line 910 "program_parse.y" { (yyval.integer) = -(yyvsp[(2) - (2)].integer); ;} break; case 74: + +/* Line 1455 of yacc.c */ #line 914 "program_parse.y" { if (((yyvsp[(1) - (1)].integer) < 0) || ((yyvsp[(1) - (1)].integer) > 63)) { @@ -2943,6 +2973,8 @@ yyreduce: break; case 75: + +/* Line 1455 of yacc.c */ #line 928 "program_parse.y" { if (((yyvsp[(1) - (1)].integer) < 0) || ((yyvsp[(1) - (1)].integer) > 64)) { @@ -2958,6 +2990,8 @@ yyreduce: break; case 76: + +/* Line 1455 of yacc.c */ #line 942 "program_parse.y" { struct asm_symbol *const s = (struct asm_symbol *) @@ -2977,6 +3011,8 @@ yyreduce: break; case 77: + +/* Line 1455 of yacc.c */ #line 960 "program_parse.y" { if ((yyvsp[(1) - (1)].swiz_mask).mask != WRITEMASK_X) { @@ -2989,6 +3025,8 @@ yyreduce: break; case 78: + +/* Line 1455 of yacc.c */ #line 971 "program_parse.y" { if ((yyvsp[(1) - (1)].swiz_mask).mask != WRITEMASK_X) { @@ -3002,16 +3040,22 @@ yyreduce: break; case 83: + +/* Line 1455 of yacc.c */ #line 987 "program_parse.y" { (yyval.swiz_mask).swizzle = SWIZZLE_NOOP; (yyval.swiz_mask).mask = WRITEMASK_XYZW; ;} break; case 88: + +/* Line 1455 of yacc.c */ #line 991 "program_parse.y" { (yyval.swiz_mask).swizzle = SWIZZLE_NOOP; (yyval.swiz_mask).mask = WRITEMASK_XYZW; ;} break; case 89: + +/* Line 1455 of yacc.c */ #line 995 "program_parse.y" { (yyval.dst_reg) = (yyvsp[(2) - (3)].dst_reg); @@ -3019,6 +3063,8 @@ yyreduce: break; case 90: + +/* Line 1455 of yacc.c */ #line 999 "program_parse.y" { (yyval.dst_reg) = (yyvsp[(2) - (3)].dst_reg); @@ -3026,6 +3072,8 @@ yyreduce: break; case 91: + +/* Line 1455 of yacc.c */ #line 1003 "program_parse.y" { (yyval.dst_reg).CondMask = COND_TR; @@ -3035,6 +3083,8 @@ yyreduce: break; case 92: + +/* Line 1455 of yacc.c */ #line 1011 "program_parse.y" { (yyval.dst_reg) = (yyvsp[(1) - (2)].dst_reg); @@ -3043,6 +3093,8 @@ yyreduce: break; case 93: + +/* Line 1455 of yacc.c */ #line 1018 "program_parse.y" { (yyval.dst_reg) = (yyvsp[(1) - (2)].dst_reg); @@ -3051,6 +3103,8 @@ yyreduce: break; case 94: + +/* Line 1455 of yacc.c */ #line 1025 "program_parse.y" { const int cond = _mesa_parse_cc((yyvsp[(1) - (1)].string)); @@ -3075,6 +3129,8 @@ yyreduce: break; case 95: + +/* Line 1455 of yacc.c */ #line 1048 "program_parse.y" { const int cond = _mesa_parse_cc((yyvsp[(1) - (1)].string)); @@ -3099,6 +3155,8 @@ yyreduce: break; case 102: + +/* Line 1455 of yacc.c */ #line 1079 "program_parse.y" { struct asm_symbol *const s = @@ -3118,6 +3176,8 @@ yyreduce: break; case 103: + +/* Line 1455 of yacc.c */ #line 1097 "program_parse.y" { (yyval.attrib) = (yyvsp[(2) - (2)].attrib); @@ -3125,6 +3185,8 @@ yyreduce: break; case 104: + +/* Line 1455 of yacc.c */ #line 1101 "program_parse.y" { (yyval.attrib) = (yyvsp[(2) - (2)].attrib); @@ -3132,6 +3194,8 @@ yyreduce: break; case 105: + +/* Line 1455 of yacc.c */ #line 1107 "program_parse.y" { (yyval.attrib) = VERT_ATTRIB_POS; @@ -3139,6 +3203,8 @@ yyreduce: break; case 106: + +/* Line 1455 of yacc.c */ #line 1111 "program_parse.y" { (yyval.attrib) = VERT_ATTRIB_WEIGHT; @@ -3146,6 +3212,8 @@ yyreduce: break; case 107: + +/* Line 1455 of yacc.c */ #line 1115 "program_parse.y" { (yyval.attrib) = VERT_ATTRIB_NORMAL; @@ -3153,6 +3221,8 @@ yyreduce: break; case 108: + +/* Line 1455 of yacc.c */ #line 1119 "program_parse.y" { if (!state->ctx->Extensions.EXT_secondary_color) { @@ -3165,6 +3235,8 @@ yyreduce: break; case 109: + +/* Line 1455 of yacc.c */ #line 1128 "program_parse.y" { if (!state->ctx->Extensions.EXT_fog_coord) { @@ -3177,6 +3249,8 @@ yyreduce: break; case 110: + +/* Line 1455 of yacc.c */ #line 1137 "program_parse.y" { (yyval.attrib) = VERT_ATTRIB_TEX0 + (yyvsp[(2) - (2)].integer); @@ -3184,6 +3258,8 @@ yyreduce: break; case 111: + +/* Line 1455 of yacc.c */ #line 1141 "program_parse.y" { yyerror(& (yylsp[(1) - (4)]), state, "GL_ARB_matrix_palette not supported"); @@ -3192,6 +3268,8 @@ yyreduce: break; case 112: + +/* Line 1455 of yacc.c */ #line 1146 "program_parse.y" { (yyval.attrib) = VERT_ATTRIB_GENERIC0 + (yyvsp[(3) - (4)].integer); @@ -3199,6 +3277,8 @@ yyreduce: break; case 113: + +/* Line 1455 of yacc.c */ #line 1152 "program_parse.y" { if ((unsigned) (yyvsp[(1) - (1)].integer) >= state->limits->MaxAttribs) { @@ -3211,6 +3291,8 @@ yyreduce: break; case 117: + +/* Line 1455 of yacc.c */ #line 1166 "program_parse.y" { (yyval.attrib) = FRAG_ATTRIB_WPOS; @@ -3218,6 +3300,8 @@ yyreduce: break; case 118: + +/* Line 1455 of yacc.c */ #line 1170 "program_parse.y" { (yyval.attrib) = FRAG_ATTRIB_COL0 + (yyvsp[(2) - (2)].integer); @@ -3225,6 +3309,8 @@ yyreduce: break; case 119: + +/* Line 1455 of yacc.c */ #line 1174 "program_parse.y" { (yyval.attrib) = FRAG_ATTRIB_FOGC; @@ -3232,6 +3318,8 @@ yyreduce: break; case 120: + +/* Line 1455 of yacc.c */ #line 1178 "program_parse.y" { (yyval.attrib) = FRAG_ATTRIB_TEX0 + (yyvsp[(2) - (2)].integer); @@ -3239,6 +3327,8 @@ yyreduce: break; case 123: + +/* Line 1455 of yacc.c */ #line 1186 "program_parse.y" { struct asm_symbol *const s = @@ -3256,6 +3346,8 @@ yyreduce: break; case 124: + +/* Line 1455 of yacc.c */ #line 1202 "program_parse.y" { if (((yyvsp[(4) - (6)].integer) != 0) && ((unsigned) (yyvsp[(4) - (6)].integer) != (yyvsp[(6) - (6)].temp_sym).param_binding_length)) { @@ -3279,6 +3371,8 @@ yyreduce: break; case 125: + +/* Line 1455 of yacc.c */ #line 1224 "program_parse.y" { (yyval.integer) = 0; @@ -3286,6 +3380,8 @@ yyreduce: break; case 126: + +/* Line 1455 of yacc.c */ #line 1228 "program_parse.y" { if (((yyvsp[(1) - (1)].integer) < 1) || ((unsigned) (yyvsp[(1) - (1)].integer) > state->limits->MaxParameters)) { @@ -3298,6 +3394,8 @@ yyreduce: break; case 127: + +/* Line 1455 of yacc.c */ #line 1239 "program_parse.y" { (yyval.temp_sym) = (yyvsp[(2) - (2)].temp_sym); @@ -3305,6 +3403,8 @@ yyreduce: break; case 128: + +/* Line 1455 of yacc.c */ #line 1245 "program_parse.y" { (yyval.temp_sym) = (yyvsp[(3) - (4)].temp_sym); @@ -3312,6 +3412,8 @@ yyreduce: break; case 130: + +/* Line 1455 of yacc.c */ #line 1252 "program_parse.y" { (yyvsp[(1) - (3)].temp_sym).param_binding_length += (yyvsp[(3) - (3)].temp_sym).param_binding_length; @@ -3320,6 +3422,8 @@ yyreduce: break; case 131: + +/* Line 1455 of yacc.c */ #line 1259 "program_parse.y" { memset(& (yyval.temp_sym), 0, sizeof((yyval.temp_sym))); @@ -3329,6 +3433,8 @@ yyreduce: break; case 132: + +/* Line 1455 of yacc.c */ #line 1265 "program_parse.y" { memset(& (yyval.temp_sym), 0, sizeof((yyval.temp_sym))); @@ -3338,6 +3444,8 @@ yyreduce: break; case 133: + +/* Line 1455 of yacc.c */ #line 1271 "program_parse.y" { memset(& (yyval.temp_sym), 0, sizeof((yyval.temp_sym))); @@ -3347,6 +3455,8 @@ yyreduce: break; case 134: + +/* Line 1455 of yacc.c */ #line 1279 "program_parse.y" { memset(& (yyval.temp_sym), 0, sizeof((yyval.temp_sym))); @@ -3356,6 +3466,8 @@ yyreduce: break; case 135: + +/* Line 1455 of yacc.c */ #line 1285 "program_parse.y" { memset(& (yyval.temp_sym), 0, sizeof((yyval.temp_sym))); @@ -3365,6 +3477,8 @@ yyreduce: break; case 136: + +/* Line 1455 of yacc.c */ #line 1291 "program_parse.y" { memset(& (yyval.temp_sym), 0, sizeof((yyval.temp_sym))); @@ -3374,6 +3488,8 @@ yyreduce: break; case 137: + +/* Line 1455 of yacc.c */ #line 1299 "program_parse.y" { memset(& (yyval.temp_sym), 0, sizeof((yyval.temp_sym))); @@ -3383,6 +3499,8 @@ yyreduce: break; case 138: + +/* Line 1455 of yacc.c */ #line 1305 "program_parse.y" { memset(& (yyval.temp_sym), 0, sizeof((yyval.temp_sym))); @@ -3392,6 +3510,8 @@ yyreduce: break; case 139: + +/* Line 1455 of yacc.c */ #line 1311 "program_parse.y" { memset(& (yyval.temp_sym), 0, sizeof((yyval.temp_sym))); @@ -3401,71 +3521,99 @@ yyreduce: break; case 140: + +/* Line 1455 of yacc.c */ #line 1318 "program_parse.y" { memcpy((yyval.state), (yyvsp[(1) - (1)].state), sizeof((yyval.state))); ;} break; case 141: + +/* Line 1455 of yacc.c */ #line 1319 "program_parse.y" { memcpy((yyval.state), (yyvsp[(2) - (2)].state), sizeof((yyval.state))); ;} break; case 142: + +/* Line 1455 of yacc.c */ #line 1322 "program_parse.y" { memcpy((yyval.state), (yyvsp[(2) - (2)].state), sizeof((yyval.state))); ;} break; case 143: + +/* Line 1455 of yacc.c */ #line 1323 "program_parse.y" { memcpy((yyval.state), (yyvsp[(2) - (2)].state), sizeof((yyval.state))); ;} break; case 144: + +/* Line 1455 of yacc.c */ #line 1324 "program_parse.y" { memcpy((yyval.state), (yyvsp[(2) - (2)].state), sizeof((yyval.state))); ;} break; case 145: + +/* Line 1455 of yacc.c */ #line 1325 "program_parse.y" { memcpy((yyval.state), (yyvsp[(2) - (2)].state), sizeof((yyval.state))); ;} break; case 146: + +/* Line 1455 of yacc.c */ #line 1326 "program_parse.y" { memcpy((yyval.state), (yyvsp[(2) - (2)].state), sizeof((yyval.state))); ;} break; case 147: + +/* Line 1455 of yacc.c */ #line 1327 "program_parse.y" { memcpy((yyval.state), (yyvsp[(2) - (2)].state), sizeof((yyval.state))); ;} break; case 148: + +/* Line 1455 of yacc.c */ #line 1328 "program_parse.y" { memcpy((yyval.state), (yyvsp[(2) - (2)].state), sizeof((yyval.state))); ;} break; case 149: + +/* Line 1455 of yacc.c */ #line 1329 "program_parse.y" { memcpy((yyval.state), (yyvsp[(2) - (2)].state), sizeof((yyval.state))); ;} break; case 150: + +/* Line 1455 of yacc.c */ #line 1330 "program_parse.y" { memcpy((yyval.state), (yyvsp[(2) - (2)].state), sizeof((yyval.state))); ;} break; case 151: + +/* Line 1455 of yacc.c */ #line 1331 "program_parse.y" { memcpy((yyval.state), (yyvsp[(2) - (2)].state), sizeof((yyval.state))); ;} break; case 152: + +/* Line 1455 of yacc.c */ #line 1332 "program_parse.y" { memcpy((yyval.state), (yyvsp[(2) - (2)].state), sizeof((yyval.state))); ;} break; case 153: + +/* Line 1455 of yacc.c */ #line 1336 "program_parse.y" { memset((yyval.state), 0, sizeof((yyval.state))); @@ -3476,6 +3624,8 @@ yyreduce: break; case 154: + +/* Line 1455 of yacc.c */ #line 1345 "program_parse.y" { (yyval.integer) = (yyvsp[(1) - (1)].integer); @@ -3483,6 +3633,8 @@ yyreduce: break; case 155: + +/* Line 1455 of yacc.c */ #line 1349 "program_parse.y" { (yyval.integer) = STATE_EMISSION; @@ -3490,6 +3642,8 @@ yyreduce: break; case 156: + +/* Line 1455 of yacc.c */ #line 1353 "program_parse.y" { (yyval.integer) = STATE_SHININESS; @@ -3497,6 +3651,8 @@ yyreduce: break; case 157: + +/* Line 1455 of yacc.c */ #line 1359 "program_parse.y" { memset((yyval.state), 0, sizeof((yyval.state))); @@ -3507,6 +3663,8 @@ yyreduce: break; case 158: + +/* Line 1455 of yacc.c */ #line 1368 "program_parse.y" { (yyval.integer) = (yyvsp[(1) - (1)].integer); @@ -3514,6 +3672,8 @@ yyreduce: break; case 159: + +/* Line 1455 of yacc.c */ #line 1372 "program_parse.y" { (yyval.integer) = STATE_POSITION; @@ -3521,6 +3681,8 @@ yyreduce: break; case 160: + +/* Line 1455 of yacc.c */ #line 1376 "program_parse.y" { if (!state->ctx->Extensions.EXT_point_parameters) { @@ -3533,6 +3695,8 @@ yyreduce: break; case 161: + +/* Line 1455 of yacc.c */ #line 1385 "program_parse.y" { (yyval.integer) = (yyvsp[(2) - (2)].integer); @@ -3540,6 +3704,8 @@ yyreduce: break; case 162: + +/* Line 1455 of yacc.c */ #line 1389 "program_parse.y" { (yyval.integer) = STATE_HALF_VECTOR; @@ -3547,6 +3713,8 @@ yyreduce: break; case 163: + +/* Line 1455 of yacc.c */ #line 1395 "program_parse.y" { (yyval.integer) = STATE_SPOT_DIRECTION; @@ -3554,6 +3722,8 @@ yyreduce: break; case 164: + +/* Line 1455 of yacc.c */ #line 1401 "program_parse.y" { (yyval.state)[0] = (yyvsp[(2) - (2)].state)[0]; @@ -3562,6 +3732,8 @@ yyreduce: break; case 165: + +/* Line 1455 of yacc.c */ #line 1408 "program_parse.y" { memset((yyval.state), 0, sizeof((yyval.state))); @@ -3570,6 +3742,8 @@ yyreduce: break; case 166: + +/* Line 1455 of yacc.c */ #line 1413 "program_parse.y" { memset((yyval.state), 0, sizeof((yyval.state))); @@ -3579,6 +3753,8 @@ yyreduce: break; case 167: + +/* Line 1455 of yacc.c */ #line 1421 "program_parse.y" { memset((yyval.state), 0, sizeof((yyval.state))); @@ -3590,6 +3766,8 @@ yyreduce: break; case 169: + +/* Line 1455 of yacc.c */ #line 1433 "program_parse.y" { memset((yyval.state), 0, sizeof((yyval.state))); @@ -3599,6 +3777,8 @@ yyreduce: break; case 170: + +/* Line 1455 of yacc.c */ #line 1441 "program_parse.y" { (yyval.integer) = STATE_TEXENV_COLOR; @@ -3606,6 +3786,8 @@ yyreduce: break; case 171: + +/* Line 1455 of yacc.c */ #line 1447 "program_parse.y" { (yyval.integer) = STATE_AMBIENT; @@ -3613,6 +3795,8 @@ yyreduce: break; case 172: + +/* Line 1455 of yacc.c */ #line 1451 "program_parse.y" { (yyval.integer) = STATE_DIFFUSE; @@ -3620,6 +3804,8 @@ yyreduce: break; case 173: + +/* Line 1455 of yacc.c */ #line 1455 "program_parse.y" { (yyval.integer) = STATE_SPECULAR; @@ -3627,6 +3813,8 @@ yyreduce: break; case 174: + +/* Line 1455 of yacc.c */ #line 1461 "program_parse.y" { if ((unsigned) (yyvsp[(1) - (1)].integer) >= state->MaxLights) { @@ -3639,6 +3827,8 @@ yyreduce: break; case 175: + +/* Line 1455 of yacc.c */ #line 1472 "program_parse.y" { memset((yyval.state), 0, sizeof((yyval.state))); @@ -3649,6 +3839,8 @@ yyreduce: break; case 176: + +/* Line 1455 of yacc.c */ #line 1481 "program_parse.y" { (yyval.integer) = STATE_TEXGEN_EYE_S; @@ -3656,6 +3848,8 @@ yyreduce: break; case 177: + +/* Line 1455 of yacc.c */ #line 1485 "program_parse.y" { (yyval.integer) = STATE_TEXGEN_OBJECT_S; @@ -3663,6 +3857,8 @@ yyreduce: break; case 178: + +/* Line 1455 of yacc.c */ #line 1490 "program_parse.y" { (yyval.integer) = STATE_TEXGEN_EYE_S - STATE_TEXGEN_EYE_S; @@ -3670,6 +3866,8 @@ yyreduce: break; case 179: + +/* Line 1455 of yacc.c */ #line 1494 "program_parse.y" { (yyval.integer) = STATE_TEXGEN_EYE_T - STATE_TEXGEN_EYE_S; @@ -3677,6 +3875,8 @@ yyreduce: break; case 180: + +/* Line 1455 of yacc.c */ #line 1498 "program_parse.y" { (yyval.integer) = STATE_TEXGEN_EYE_R - STATE_TEXGEN_EYE_S; @@ -3684,6 +3884,8 @@ yyreduce: break; case 181: + +/* Line 1455 of yacc.c */ #line 1502 "program_parse.y" { (yyval.integer) = STATE_TEXGEN_EYE_Q - STATE_TEXGEN_EYE_S; @@ -3691,6 +3893,8 @@ yyreduce: break; case 182: + +/* Line 1455 of yacc.c */ #line 1508 "program_parse.y" { memset((yyval.state), 0, sizeof((yyval.state))); @@ -3699,6 +3903,8 @@ yyreduce: break; case 183: + +/* Line 1455 of yacc.c */ #line 1515 "program_parse.y" { (yyval.integer) = STATE_FOG_COLOR; @@ -3706,6 +3912,8 @@ yyreduce: break; case 184: + +/* Line 1455 of yacc.c */ #line 1519 "program_parse.y" { (yyval.integer) = STATE_FOG_PARAMS; @@ -3713,6 +3921,8 @@ yyreduce: break; case 185: + +/* Line 1455 of yacc.c */ #line 1525 "program_parse.y" { memset((yyval.state), 0, sizeof((yyval.state))); @@ -3722,6 +3932,8 @@ yyreduce: break; case 186: + +/* Line 1455 of yacc.c */ #line 1533 "program_parse.y" { if ((unsigned) (yyvsp[(1) - (1)].integer) >= state->MaxClipPlanes) { @@ -3734,6 +3946,8 @@ yyreduce: break; case 187: + +/* Line 1455 of yacc.c */ #line 1544 "program_parse.y" { memset((yyval.state), 0, sizeof((yyval.state))); @@ -3742,6 +3956,8 @@ yyreduce: break; case 188: + +/* Line 1455 of yacc.c */ #line 1551 "program_parse.y" { (yyval.integer) = STATE_POINT_SIZE; @@ -3749,6 +3965,8 @@ yyreduce: break; case 189: + +/* Line 1455 of yacc.c */ #line 1555 "program_parse.y" { (yyval.integer) = STATE_POINT_ATTENUATION; @@ -3756,6 +3974,8 @@ yyreduce: break; case 190: + +/* Line 1455 of yacc.c */ #line 1561 "program_parse.y" { (yyval.state)[0] = (yyvsp[(1) - (5)].state)[0]; @@ -3767,6 +3987,8 @@ yyreduce: break; case 191: + +/* Line 1455 of yacc.c */ #line 1571 "program_parse.y" { (yyval.state)[0] = (yyvsp[(1) - (2)].state)[0]; @@ -3778,6 +4000,8 @@ yyreduce: break; case 192: + +/* Line 1455 of yacc.c */ #line 1581 "program_parse.y" { (yyval.state)[2] = 0; @@ -3786,6 +4010,8 @@ yyreduce: break; case 193: + +/* Line 1455 of yacc.c */ #line 1586 "program_parse.y" { /* It seems logical that the matrix row range specifier would have @@ -3805,6 +4031,8 @@ yyreduce: break; case 194: + +/* Line 1455 of yacc.c */ #line 1604 "program_parse.y" { (yyval.state)[0] = (yyvsp[(2) - (3)].state)[0]; @@ -3814,6 +4042,8 @@ yyreduce: break; case 195: + +/* Line 1455 of yacc.c */ #line 1612 "program_parse.y" { (yyval.integer) = 0; @@ -3821,6 +4051,8 @@ yyreduce: break; case 196: + +/* Line 1455 of yacc.c */ #line 1616 "program_parse.y" { (yyval.integer) = (yyvsp[(1) - (1)].integer); @@ -3828,6 +4060,8 @@ yyreduce: break; case 197: + +/* Line 1455 of yacc.c */ #line 1622 "program_parse.y" { (yyval.integer) = STATE_MATRIX_INVERSE; @@ -3835,6 +4069,8 @@ yyreduce: break; case 198: + +/* Line 1455 of yacc.c */ #line 1626 "program_parse.y" { (yyval.integer) = STATE_MATRIX_TRANSPOSE; @@ -3842,6 +4078,8 @@ yyreduce: break; case 199: + +/* Line 1455 of yacc.c */ #line 1630 "program_parse.y" { (yyval.integer) = STATE_MATRIX_INVTRANS; @@ -3849,6 +4087,8 @@ yyreduce: break; case 200: + +/* Line 1455 of yacc.c */ #line 1636 "program_parse.y" { if ((yyvsp[(1) - (1)].integer) > 3) { @@ -3861,6 +4101,8 @@ yyreduce: break; case 201: + +/* Line 1455 of yacc.c */ #line 1647 "program_parse.y" { (yyval.state)[0] = STATE_MODELVIEW_MATRIX; @@ -3869,6 +4111,8 @@ yyreduce: break; case 202: + +/* Line 1455 of yacc.c */ #line 1652 "program_parse.y" { (yyval.state)[0] = STATE_PROJECTION_MATRIX; @@ -3877,6 +4121,8 @@ yyreduce: break; case 203: + +/* Line 1455 of yacc.c */ #line 1657 "program_parse.y" { (yyval.state)[0] = STATE_MVP_MATRIX; @@ -3885,6 +4131,8 @@ yyreduce: break; case 204: + +/* Line 1455 of yacc.c */ #line 1662 "program_parse.y" { (yyval.state)[0] = STATE_TEXTURE_MATRIX; @@ -3893,6 +4141,8 @@ yyreduce: break; case 205: + +/* Line 1455 of yacc.c */ #line 1667 "program_parse.y" { yyerror(& (yylsp[(1) - (4)]), state, "GL_ARB_matrix_palette not supported"); @@ -3901,6 +4151,8 @@ yyreduce: break; case 206: + +/* Line 1455 of yacc.c */ #line 1672 "program_parse.y" { (yyval.state)[0] = STATE_PROGRAM_MATRIX; @@ -3909,6 +4161,8 @@ yyreduce: break; case 207: + +/* Line 1455 of yacc.c */ #line 1679 "program_parse.y" { (yyval.integer) = 0; @@ -3916,6 +4170,8 @@ yyreduce: break; case 208: + +/* Line 1455 of yacc.c */ #line 1683 "program_parse.y" { (yyval.integer) = (yyvsp[(2) - (3)].integer); @@ -3923,6 +4179,8 @@ yyreduce: break; case 209: + +/* Line 1455 of yacc.c */ #line 1688 "program_parse.y" { /* Since GL_ARB_vertex_blend isn't supported, only modelview matrix @@ -3938,6 +4196,8 @@ yyreduce: break; case 210: + +/* Line 1455 of yacc.c */ #line 1701 "program_parse.y" { /* Since GL_ARB_matrix_palette isn't supported, just let any value @@ -3948,6 +4208,8 @@ yyreduce: break; case 211: + +/* Line 1455 of yacc.c */ #line 1709 "program_parse.y" { if ((unsigned) (yyvsp[(1) - (1)].integer) >= state->MaxProgramMatrices) { @@ -3960,6 +4222,8 @@ yyreduce: break; case 212: + +/* Line 1455 of yacc.c */ #line 1720 "program_parse.y" { memset((yyval.state), 0, sizeof((yyval.state))); @@ -3968,6 +4232,8 @@ yyreduce: break; case 217: + +/* Line 1455 of yacc.c */ #line 1732 "program_parse.y" { memset((yyval.state), 0, sizeof((yyval.state))); @@ -3979,6 +4245,8 @@ yyreduce: break; case 218: + +/* Line 1455 of yacc.c */ #line 1742 "program_parse.y" { (yyval.state)[0] = (yyvsp[(1) - (1)].integer); @@ -3987,6 +4255,8 @@ yyreduce: break; case 219: + +/* Line 1455 of yacc.c */ #line 1747 "program_parse.y" { (yyval.state)[0] = (yyvsp[(1) - (3)].integer); @@ -3995,6 +4265,8 @@ yyreduce: break; case 220: + +/* Line 1455 of yacc.c */ #line 1754 "program_parse.y" { memset((yyval.state), 0, sizeof((yyval.state))); @@ -4006,6 +4278,8 @@ yyreduce: break; case 221: + +/* Line 1455 of yacc.c */ #line 1764 "program_parse.y" { memset((yyval.state), 0, sizeof((yyval.state))); @@ -4017,6 +4291,8 @@ yyreduce: break; case 222: + +/* Line 1455 of yacc.c */ #line 1773 "program_parse.y" { (yyval.state)[0] = (yyvsp[(1) - (1)].integer); @@ -4025,6 +4301,8 @@ yyreduce: break; case 223: + +/* Line 1455 of yacc.c */ #line 1778 "program_parse.y" { (yyval.state)[0] = (yyvsp[(1) - (3)].integer); @@ -4033,6 +4311,8 @@ yyreduce: break; case 224: + +/* Line 1455 of yacc.c */ #line 1785 "program_parse.y" { memset((yyval.state), 0, sizeof((yyval.state))); @@ -4044,6 +4324,8 @@ yyreduce: break; case 225: + +/* Line 1455 of yacc.c */ #line 1795 "program_parse.y" { if ((unsigned) (yyvsp[(1) - (1)].integer) >= state->limits->MaxEnvParams) { @@ -4055,6 +4337,8 @@ yyreduce: break; case 226: + +/* Line 1455 of yacc.c */ #line 1805 "program_parse.y" { if ((unsigned) (yyvsp[(1) - (1)].integer) >= state->limits->MaxLocalParams) { @@ -4066,6 +4350,8 @@ yyreduce: break; case 231: + +/* Line 1455 of yacc.c */ #line 1820 "program_parse.y" { (yyval.vector).count = 4; @@ -4077,6 +4363,8 @@ yyreduce: break; case 232: + +/* Line 1455 of yacc.c */ #line 1830 "program_parse.y" { (yyval.vector).count = 1; @@ -4088,6 +4376,8 @@ yyreduce: break; case 233: + +/* Line 1455 of yacc.c */ #line 1838 "program_parse.y" { (yyval.vector).count = 1; @@ -4099,6 +4389,8 @@ yyreduce: break; case 234: + +/* Line 1455 of yacc.c */ #line 1848 "program_parse.y" { (yyval.vector).count = 4; @@ -4110,6 +4402,8 @@ yyreduce: break; case 235: + +/* Line 1455 of yacc.c */ #line 1856 "program_parse.y" { (yyval.vector).count = 4; @@ -4121,6 +4415,8 @@ yyreduce: break; case 236: + +/* Line 1455 of yacc.c */ #line 1865 "program_parse.y" { (yyval.vector).count = 4; @@ -4132,6 +4428,8 @@ yyreduce: break; case 237: + +/* Line 1455 of yacc.c */ #line 1874 "program_parse.y" { (yyval.vector).count = 4; @@ -4143,6 +4441,8 @@ yyreduce: break; case 238: + +/* Line 1455 of yacc.c */ #line 1884 "program_parse.y" { (yyval.real) = ((yyvsp[(1) - (2)].negate)) ? -(yyvsp[(2) - (2)].real) : (yyvsp[(2) - (2)].real); @@ -4150,6 +4450,8 @@ yyreduce: break; case 239: + +/* Line 1455 of yacc.c */ #line 1888 "program_parse.y" { (yyval.real) = (float)(((yyvsp[(1) - (2)].negate)) ? -(yyvsp[(2) - (2)].integer) : (yyvsp[(2) - (2)].integer)); @@ -4157,26 +4459,36 @@ yyreduce: break; case 240: + +/* Line 1455 of yacc.c */ #line 1893 "program_parse.y" { (yyval.negate) = FALSE; ;} break; case 241: + +/* Line 1455 of yacc.c */ #line 1894 "program_parse.y" { (yyval.negate) = TRUE; ;} break; case 242: + +/* Line 1455 of yacc.c */ #line 1895 "program_parse.y" { (yyval.negate) = FALSE; ;} break; case 243: + +/* Line 1455 of yacc.c */ #line 1898 "program_parse.y" { (yyval.integer) = (yyvsp[(2) - (2)].integer); ;} break; case 245: + +/* Line 1455 of yacc.c */ #line 1902 "program_parse.y" { /* NV_fragment_program_option defines the size qualifiers in a @@ -4214,17 +4526,23 @@ yyreduce: break; case 246: + +/* Line 1455 of yacc.c */ #line 1936 "program_parse.y" { ;} break; case 247: + +/* Line 1455 of yacc.c */ #line 1940 "program_parse.y" { (yyval.integer) = (yyvsp[(1) - (1)].integer); ;} break; case 249: + +/* Line 1455 of yacc.c */ #line 1944 "program_parse.y" { if (!declare_variable(state, (yyvsp[(3) - (3)].string), (yyvsp[(0) - (3)].integer), & (yylsp[(3) - (3)]))) { @@ -4234,6 +4552,8 @@ yyreduce: break; case 250: + +/* Line 1455 of yacc.c */ #line 1950 "program_parse.y" { if (!declare_variable(state, (yyvsp[(1) - (1)].string), (yyvsp[(0) - (1)].integer), & (yylsp[(1) - (1)]))) { @@ -4243,6 +4563,8 @@ yyreduce: break; case 251: + +/* Line 1455 of yacc.c */ #line 1958 "program_parse.y" { struct asm_symbol *const s = @@ -4257,6 +4579,8 @@ yyreduce: break; case 252: + +/* Line 1455 of yacc.c */ #line 1971 "program_parse.y" { if (state->mode == ARB_vertex) { @@ -4269,6 +4593,8 @@ yyreduce: break; case 253: + +/* Line 1455 of yacc.c */ #line 1980 "program_parse.y" { if (state->mode == ARB_vertex) { @@ -4281,6 +4607,8 @@ yyreduce: break; case 254: + +/* Line 1455 of yacc.c */ #line 1989 "program_parse.y" { (yyval.result) = (yyvsp[(2) - (2)].result); @@ -4288,6 +4616,8 @@ yyreduce: break; case 255: + +/* Line 1455 of yacc.c */ #line 1993 "program_parse.y" { if (state->mode == ARB_vertex) { @@ -4300,6 +4630,8 @@ yyreduce: break; case 256: + +/* Line 1455 of yacc.c */ #line 2002 "program_parse.y" { if (state->mode == ARB_vertex) { @@ -4312,6 +4644,8 @@ yyreduce: break; case 257: + +/* Line 1455 of yacc.c */ #line 2011 "program_parse.y" { if (state->mode == ARB_fragment) { @@ -4324,6 +4658,8 @@ yyreduce: break; case 258: + +/* Line 1455 of yacc.c */ #line 2022 "program_parse.y" { (yyval.result) = (yyvsp[(2) - (3)].integer) + (yyvsp[(3) - (3)].integer); @@ -4331,6 +4667,8 @@ yyreduce: break; case 259: + +/* Line 1455 of yacc.c */ #line 2028 "program_parse.y" { (yyval.integer) = (state->mode == ARB_vertex) @@ -4340,6 +4678,8 @@ yyreduce: break; case 260: + +/* Line 1455 of yacc.c */ #line 2034 "program_parse.y" { if (state->mode == ARB_vertex) { @@ -4352,6 +4692,8 @@ yyreduce: break; case 261: + +/* Line 1455 of yacc.c */ #line 2043 "program_parse.y" { if (state->mode == ARB_vertex) { @@ -4364,6 +4706,8 @@ yyreduce: break; case 262: + +/* Line 1455 of yacc.c */ #line 2054 "program_parse.y" { (yyval.integer) = 0; @@ -4371,6 +4715,8 @@ yyreduce: break; case 263: + +/* Line 1455 of yacc.c */ #line 2058 "program_parse.y" { if (state->mode == ARB_vertex) { @@ -4383,6 +4729,8 @@ yyreduce: break; case 264: + +/* Line 1455 of yacc.c */ #line 2067 "program_parse.y" { if (state->mode == ARB_vertex) { @@ -4395,66 +4743,92 @@ yyreduce: break; case 265: + +/* Line 1455 of yacc.c */ #line 2077 "program_parse.y" { (yyval.integer) = 0; ;} break; case 266: + +/* Line 1455 of yacc.c */ #line 2078 "program_parse.y" { (yyval.integer) = 0; ;} break; case 267: + +/* Line 1455 of yacc.c */ #line 2079 "program_parse.y" { (yyval.integer) = 1; ;} break; case 268: + +/* Line 1455 of yacc.c */ #line 2082 "program_parse.y" { (yyval.integer) = 0; ;} break; case 269: + +/* Line 1455 of yacc.c */ #line 2083 "program_parse.y" { (yyval.integer) = 0; ;} break; case 270: + +/* Line 1455 of yacc.c */ #line 2084 "program_parse.y" { (yyval.integer) = 1; ;} break; case 271: + +/* Line 1455 of yacc.c */ #line 2087 "program_parse.y" { (yyval.integer) = 0; ;} break; case 272: + +/* Line 1455 of yacc.c */ #line 2088 "program_parse.y" { (yyval.integer) = (yyvsp[(2) - (3)].integer); ;} break; case 273: + +/* Line 1455 of yacc.c */ #line 2091 "program_parse.y" { (yyval.integer) = 0; ;} break; case 274: + +/* Line 1455 of yacc.c */ #line 2092 "program_parse.y" { (yyval.integer) = (yyvsp[(2) - (3)].integer); ;} break; case 275: + +/* Line 1455 of yacc.c */ #line 2095 "program_parse.y" { (yyval.integer) = 0; ;} break; case 276: + +/* Line 1455 of yacc.c */ #line 2096 "program_parse.y" { (yyval.integer) = (yyvsp[(2) - (3)].integer); ;} break; case 277: + +/* Line 1455 of yacc.c */ #line 2100 "program_parse.y" { if ((unsigned) (yyvsp[(1) - (1)].integer) >= state->MaxTextureCoordUnits) { @@ -4467,6 +4841,8 @@ yyreduce: break; case 278: + +/* Line 1455 of yacc.c */ #line 2111 "program_parse.y" { if ((unsigned) (yyvsp[(1) - (1)].integer) >= state->MaxTextureImageUnits) { @@ -4479,6 +4855,8 @@ yyreduce: break; case 279: + +/* Line 1455 of yacc.c */ #line 2122 "program_parse.y" { if ((unsigned) (yyvsp[(1) - (1)].integer) >= state->MaxTextureUnits) { @@ -4491,6 +4869,8 @@ yyreduce: break; case 280: + +/* Line 1455 of yacc.c */ #line 2133 "program_parse.y" { struct asm_symbol *exist = (struct asm_symbol *) @@ -4498,9 +4878,10 @@ yyreduce: struct asm_symbol *target = (struct asm_symbol *) _mesa_symbol_table_find_symbol(state->st, 0, (yyvsp[(4) - (4)].string)); - if (exist != NULL) { - yyerror(& (yylsp[(2) - (4)]), state, "redeclared identifier"); + char m[1000]; + _mesa_snprintf(m, sizeof(m), "redeclared identifier: %s", (yyvsp[(2) - (4)].string)); + yyerror(& (yylsp[(2) - (4)]), state, m); YYERROR; } else if (target == NULL) { yyerror(& (yylsp[(4) - (4)]), state, @@ -4513,8 +4894,9 @@ yyreduce: break; -/* Line 1267 of yacc.c. */ -#line 4518 "program_parse.tab.c" + +/* Line 1455 of yacc.c */ +#line 4900 "program_parse.tab.c" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); @@ -4590,7 +4972,7 @@ yyerrlab: if (yyerrstatus == 3) { - /* If just tried and failed to reuse look-ahead token after an + /* If just tried and failed to reuse lookahead token after an error, discard it. */ if (yychar <= YYEOF) @@ -4607,7 +4989,7 @@ yyerrlab: } } - /* Else will try to reuse look-ahead token after shifting the error + /* Else will try to reuse lookahead token after shifting the error token. */ goto yyerrlab1; @@ -4665,14 +5047,11 @@ yyerrlab1: YY_STACK_PRINT (yyss, yyssp); } - if (yyn == YYFINAL) - YYACCEPT; - *++yyvsp = yylval; yyerror_range[1] = yylloc; /* Using YYLLOC is tempting, but would change the location of - the look-ahead. YYLOC is available though. */ + the lookahead. YYLOC is available though. */ YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2); *++yylsp = yyloc; @@ -4697,7 +5076,7 @@ yyabortlab: yyresult = 1; goto yyreturn; -#ifndef yyoverflow +#if !defined(yyoverflow) || YYERROR_VERBOSE /*-------------------------------------------------. | yyexhaustedlab -- memory exhaustion comes here. | `-------------------------------------------------*/ @@ -4708,7 +5087,7 @@ yyexhaustedlab: #endif yyreturn: - if (yychar != YYEOF && yychar != YYEMPTY) + if (yychar != YYEMPTY) yydestruct ("Cleanup: discarding lookahead", yytoken, &yylval, &yylloc, state); /* Do not reclaim the symbols of the rule which action triggered @@ -4734,7 +5113,9 @@ yyreturn: } -#line 2157 "program_parse.y" + +/* Line 1675 of yacc.c */ +#line 2158 "program_parse.y" void diff --git a/src/mesa/shader/program_parse.tab.h b/src/mesa/shader/program_parse.tab.h index 25048065c1..406100c859 100644 --- a/src/mesa/shader/program_parse.tab.h +++ b/src/mesa/shader/program_parse.tab.h @@ -1,24 +1,23 @@ -/* A Bison parser, made by GNU Bison 2.3. */ -/* Skeleton interface for Bison's Yacc-like parsers in C +/* A Bison parser, made by GNU Bison 2.4.1. */ - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 +/* Skeleton interface for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify + + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. */ + along with this program. If not, see . */ /* As a special exception, you may create a larger work that contains part or all of the Bison parser skeleton and distribute that work @@ -29,10 +28,11 @@ special exception, which will cause the skeleton and the resulting Bison output files to be licensed under the GNU General Public License without this special exception. - + This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ + /* Tokens. */ #ifndef YYTOKENTYPE # define YYTOKENTYPE @@ -146,120 +146,16 @@ DOT = 362 }; #endif -/* Tokens. */ -#define ARBvp_10 258 -#define ARBfp_10 259 -#define ADDRESS 260 -#define ALIAS 261 -#define ATTRIB 262 -#define OPTION 263 -#define OUTPUT 264 -#define PARAM 265 -#define TEMP 266 -#define END 267 -#define BIN_OP 268 -#define BINSC_OP 269 -#define SAMPLE_OP 270 -#define SCALAR_OP 271 -#define TRI_OP 272 -#define VECTOR_OP 273 -#define ARL 274 -#define KIL 275 -#define SWZ 276 -#define TXD_OP 277 -#define INTEGER 278 -#define REAL 279 -#define AMBIENT 280 -#define ATTENUATION 281 -#define BACK 282 -#define CLIP 283 -#define COLOR 284 -#define DEPTH 285 -#define DIFFUSE 286 -#define DIRECTION 287 -#define EMISSION 288 -#define ENV 289 -#define EYE 290 -#define FOG 291 -#define FOGCOORD 292 -#define FRAGMENT 293 -#define FRONT 294 -#define HALF 295 -#define INVERSE 296 -#define INVTRANS 297 -#define LIGHT 298 -#define LIGHTMODEL 299 -#define LIGHTPROD 300 -#define LOCAL 301 -#define MATERIAL 302 -#define MAT_PROGRAM 303 -#define MATRIX 304 -#define MATRIXINDEX 305 -#define MODELVIEW 306 -#define MVP 307 -#define NORMAL 308 -#define OBJECT 309 -#define PALETTE 310 -#define PARAMS 311 -#define PLANE 312 -#define POINT_TOK 313 -#define POINTSIZE 314 -#define POSITION 315 -#define PRIMARY 316 -#define PROGRAM 317 -#define PROJECTION 318 -#define RANGE 319 -#define RESULT 320 -#define ROW 321 -#define SCENECOLOR 322 -#define SECONDARY 323 -#define SHININESS 324 -#define SIZE_TOK 325 -#define SPECULAR 326 -#define SPOT 327 -#define STATE 328 -#define TEXCOORD 329 -#define TEXENV 330 -#define TEXGEN 331 -#define TEXGEN_Q 332 -#define TEXGEN_R 333 -#define TEXGEN_S 334 -#define TEXGEN_T 335 -#define TEXTURE 336 -#define TRANSPOSE 337 -#define TEXTURE_UNIT 338 -#define TEX_1D 339 -#define TEX_2D 340 -#define TEX_3D 341 -#define TEX_CUBE 342 -#define TEX_RECT 343 -#define TEX_SHADOW1D 344 -#define TEX_SHADOW2D 345 -#define TEX_SHADOWRECT 346 -#define TEX_ARRAY1D 347 -#define TEX_ARRAY2D 348 -#define TEX_ARRAYSHADOW1D 349 -#define TEX_ARRAYSHADOW2D 350 -#define VERTEX 351 -#define VTXATTRIB 352 -#define WEIGHT 353 -#define IDENTIFIER 354 -#define USED_IDENTIFIER 355 -#define MASK4 356 -#define MASK3 357 -#define MASK2 358 -#define MASK1 359 -#define SWIZZLE 360 -#define DOT_DOT 361 -#define DOT 362 - #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef union YYSTYPE -#line 122 "program_parse.y" { + +/* Line 1676 of yacc.c */ +#line 122 "program_parse.y" + struct asm_instruction *inst; struct asm_symbol *sym; struct asm_symbol temp_sym; @@ -283,13 +179,15 @@ typedef union YYSTYPE unsigned xyzw_valid:1; unsigned negate:1; } ext_swizzle; -} -/* Line 1489 of yacc.c. */ -#line 289 "program_parse.tab.h" - YYSTYPE; + + + +/* Line 1676 of yacc.c */ +#line 187 "program_parse.tab.h" +} YYSTYPE; +# define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 -# define YYSTYPE_IS_TRIVIAL 1 #endif @@ -308,3 +206,4 @@ typedef struct YYLTYPE #endif + diff --git a/src/mesa/shader/program_parse.y b/src/mesa/shader/program_parse.y index 32b058400c..5767c51759 100644 --- a/src/mesa/shader/program_parse.y +++ b/src/mesa/shader/program_parse.y @@ -2136,9 +2136,10 @@ ALIAS_statement: ALIAS IDENTIFIER '=' USED_IDENTIFIER struct asm_symbol *target = (struct asm_symbol *) _mesa_symbol_table_find_symbol(state->st, 0, $4); - if (exist != NULL) { - yyerror(& @2, state, "redeclared identifier"); + char m[1000]; + _mesa_snprintf(m, sizeof(m), "redeclared identifier: %s", $2); + yyerror(& @2, state, m); YYERROR; } else if (target == NULL) { yyerror(& @4, state, -- cgit v1.2.3 From 1c7337d46eab0cfd36ebc0ad22c5a66ec9b91d39 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 4 Nov 2009 12:03:44 -0800 Subject: Revert "ARB prog parser: Fix epic memory leak in lexer / parser interface" This reverts commit 93dae6761bc90bbd43b450d2673620ec189b2c7a. This change was completely broken when the parser uses multiple strings in a single production. It would be nice if bug fixes could initially land somewhere other than the stable branch. --- src/mesa/shader/lex.yy.c | 445 ++++++++++++++++-------------------- src/mesa/shader/program_lexer.l | 45 +--- src/mesa/shader/program_parse.tab.c | 21 +- src/mesa/shader/program_parse.y | 17 +- src/mesa/shader/program_parser.h | 16 -- 5 files changed, 207 insertions(+), 337 deletions(-) (limited to 'src/mesa/shader/program_parse.y') diff --git a/src/mesa/shader/lex.yy.c b/src/mesa/shader/lex.yy.c index 728c2dc272..fefef573ee 100644 --- a/src/mesa/shader/lex.yy.c +++ b/src/mesa/shader/lex.yy.c @@ -53,6 +53,7 @@ typedef int flex_int32_t; typedef unsigned char flex_uint8_t; typedef unsigned short int flex_uint16_t; typedef unsigned int flex_uint32_t; +#endif /* ! C99 */ /* Limits of integral types. */ #ifndef INT8_MIN @@ -83,8 +84,6 @@ typedef unsigned int flex_uint32_t; #define UINT32_MAX (4294967295U) #endif -#endif /* ! C99 */ - #endif /* ! FLEXINT_H */ #ifdef __cplusplus @@ -158,15 +157,7 @@ typedef void* yyscan_t; /* Size of default input buffer. */ #ifndef YY_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k. - * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. - * Ditto for the __ia64__ case accordingly. - */ -#define YY_BUF_SIZE 32768 -#else #define YY_BUF_SIZE 16384 -#endif /* __ia64__ */ #endif /* The state buf must be large enough to hold one state per character in the main buffer. @@ -927,7 +918,7 @@ static yyconst flex_int16_t yy_chk[1023] = if (condition) { \ return token; \ } else { \ - yylval->string = return_string(yyextra, yytext); \ + yylval->string = strdup(yytext); \ return IDENTIFIER; \ } \ } while (0) @@ -950,7 +941,7 @@ static yyconst flex_int16_t yy_chk[1023] = yylval->temp_inst.SaturateMode = SATURATE_ ## sat; \ return token; \ } else { \ - yylval->string = return_string(yyextra, yytext); \ + yylval->string = strdup(yytext); \ return IDENTIFIER; \ } \ } while (0) @@ -958,45 +949,6 @@ static yyconst flex_int16_t yy_chk[1023] = #define SWIZZLE_INVAL MAKE_SWIZZLE4(SWIZZLE_NIL, SWIZZLE_NIL, \ SWIZZLE_NIL, SWIZZLE_NIL) -/** - * Send a string to the parser using asm_parser_state::string_dumpster - * - * Sends a string to the parser using asm_parser_state::string_dumpster as a - * temporary storage buffer. Data previously stored in - * asm_parser_state::string_dumpster will be lost. If - * asm_parser_state::string_dumpster is not large enough to hold the new - * string, the buffer size will be increased. The buffer size is \b never - * decreased. - * - * \param state Assembler parser state tracking - * \param str String to be passed to the parser - * - * \return - * A pointer to asm_parser_state::string_dumpster on success or \c NULL on - * failure. Currently the only failure case is \c ENOMEM. - */ -static char * -return_string(struct asm_parser_state *state, const char *str) -{ - const size_t len = strlen(str); - - if (len >= state->dumpster_size) { - char *const dumpster = _mesa_realloc(state->string_dumpster, - state->dumpster_size, - len + 1); - if (dumpster == NULL) { - return NULL; - } - - state->string_dumpster = dumpster; - state->dumpster_size = len + 1; - } - - memcpy(state->string_dumpster, str, len + 1); - return state->string_dumpster; -} - - static unsigned mask_from_char(char c) { @@ -1052,7 +1004,7 @@ swiz_from_char(char c) } while(0); #define YY_EXTRA_TYPE struct asm_parser_state * -#line 1056 "lex.yy.c" +#line 1008 "lex.yy.c" #define INITIAL 0 @@ -1189,12 +1141,7 @@ static int input (yyscan_t yyscanner ); /* Amount of stuff to slurp up with each read. */ #ifndef YY_READ_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k */ -#define YY_READ_BUF_SIZE 16384 -#else #define YY_READ_BUF_SIZE 8192 -#endif /* __ia64__ */ #endif /* Copy whatever the last rule matched to the standard output. */ @@ -1202,7 +1149,7 @@ static int input (yyscan_t yyscanner ); /* This used to be an fputs(), but since the string might contain NUL's, * we now use fwrite(). */ -#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0) +#define ECHO fwrite( yytext, yyleng, 1, yyout ) #endif /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, @@ -1213,7 +1160,7 @@ static int input (yyscan_t yyscanner ); if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ { \ int c = '*'; \ - size_t n; \ + unsigned n; \ for ( n = 0; n < max_size && \ (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ buf[n] = (char) c; \ @@ -1298,10 +1245,10 @@ YY_DECL register int yy_act; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; -#line 176 "program_lexer.l" +#line 137 "program_lexer.l" -#line 1305 "lex.yy.c" +#line 1252 "lex.yy.c" yylval = yylval_param; @@ -1390,17 +1337,17 @@ do_action: /* This label is used only to access EOF actions. */ case 1: YY_RULE_SETUP -#line 178 "program_lexer.l" +#line 139 "program_lexer.l" { return ARBvp_10; } YY_BREAK case 2: YY_RULE_SETUP -#line 179 "program_lexer.l" +#line 140 "program_lexer.l" { return ARBfp_10; } YY_BREAK case 3: YY_RULE_SETUP -#line 180 "program_lexer.l" +#line 141 "program_lexer.l" { yylval->integer = at_address; return_token_or_IDENTIFIER(require_ARB_vp, ADDRESS); @@ -1408,760 +1355,760 @@ YY_RULE_SETUP YY_BREAK case 4: YY_RULE_SETUP -#line 184 "program_lexer.l" +#line 145 "program_lexer.l" { return ALIAS; } YY_BREAK case 5: YY_RULE_SETUP -#line 185 "program_lexer.l" +#line 146 "program_lexer.l" { return ATTRIB; } YY_BREAK case 6: YY_RULE_SETUP -#line 186 "program_lexer.l" +#line 147 "program_lexer.l" { return END; } YY_BREAK case 7: YY_RULE_SETUP -#line 187 "program_lexer.l" +#line 148 "program_lexer.l" { return OPTION; } YY_BREAK case 8: YY_RULE_SETUP -#line 188 "program_lexer.l" +#line 149 "program_lexer.l" { return OUTPUT; } YY_BREAK case 9: YY_RULE_SETUP -#line 189 "program_lexer.l" +#line 150 "program_lexer.l" { return PARAM; } YY_BREAK case 10: YY_RULE_SETUP -#line 190 "program_lexer.l" +#line 151 "program_lexer.l" { yylval->integer = at_temp; return TEMP; } YY_BREAK case 11: YY_RULE_SETUP -#line 192 "program_lexer.l" +#line 153 "program_lexer.l" { return_opcode( 1, VECTOR_OP, ABS, OFF); } YY_BREAK case 12: YY_RULE_SETUP -#line 193 "program_lexer.l" +#line 154 "program_lexer.l" { return_opcode(require_ARB_fp, VECTOR_OP, ABS, ZERO_ONE); } YY_BREAK case 13: YY_RULE_SETUP -#line 194 "program_lexer.l" +#line 155 "program_lexer.l" { return_opcode( 1, BIN_OP, ADD, OFF); } YY_BREAK case 14: YY_RULE_SETUP -#line 195 "program_lexer.l" +#line 156 "program_lexer.l" { return_opcode(require_ARB_fp, BIN_OP, ADD, ZERO_ONE); } YY_BREAK case 15: YY_RULE_SETUP -#line 196 "program_lexer.l" +#line 157 "program_lexer.l" { return_opcode(require_ARB_vp, ARL, ARL, OFF); } YY_BREAK case 16: YY_RULE_SETUP -#line 198 "program_lexer.l" +#line 159 "program_lexer.l" { return_opcode(require_ARB_fp, TRI_OP, CMP, OFF); } YY_BREAK case 17: YY_RULE_SETUP -#line 199 "program_lexer.l" +#line 160 "program_lexer.l" { return_opcode(require_ARB_fp, TRI_OP, CMP, ZERO_ONE); } YY_BREAK case 18: YY_RULE_SETUP -#line 200 "program_lexer.l" +#line 161 "program_lexer.l" { return_opcode(require_ARB_fp, SCALAR_OP, COS, OFF); } YY_BREAK case 19: YY_RULE_SETUP -#line 201 "program_lexer.l" +#line 162 "program_lexer.l" { return_opcode(require_ARB_fp, SCALAR_OP, COS, ZERO_ONE); } YY_BREAK case 20: YY_RULE_SETUP -#line 203 "program_lexer.l" +#line 164 "program_lexer.l" { return_opcode( 1, BIN_OP, DP3, OFF); } YY_BREAK case 21: YY_RULE_SETUP -#line 204 "program_lexer.l" +#line 165 "program_lexer.l" { return_opcode(require_ARB_fp, BIN_OP, DP3, ZERO_ONE); } YY_BREAK case 22: YY_RULE_SETUP -#line 205 "program_lexer.l" +#line 166 "program_lexer.l" { return_opcode( 1, BIN_OP, DP4, OFF); } YY_BREAK case 23: YY_RULE_SETUP -#line 206 "program_lexer.l" +#line 167 "program_lexer.l" { return_opcode(require_ARB_fp, BIN_OP, DP4, ZERO_ONE); } YY_BREAK case 24: YY_RULE_SETUP -#line 207 "program_lexer.l" +#line 168 "program_lexer.l" { return_opcode( 1, BIN_OP, DPH, OFF); } YY_BREAK case 25: YY_RULE_SETUP -#line 208 "program_lexer.l" +#line 169 "program_lexer.l" { return_opcode(require_ARB_fp, BIN_OP, DPH, ZERO_ONE); } YY_BREAK case 26: YY_RULE_SETUP -#line 209 "program_lexer.l" +#line 170 "program_lexer.l" { return_opcode( 1, BIN_OP, DST, OFF); } YY_BREAK case 27: YY_RULE_SETUP -#line 210 "program_lexer.l" +#line 171 "program_lexer.l" { return_opcode(require_ARB_fp, BIN_OP, DST, ZERO_ONE); } YY_BREAK case 28: YY_RULE_SETUP -#line 212 "program_lexer.l" +#line 173 "program_lexer.l" { return_opcode( 1, SCALAR_OP, EX2, OFF); } YY_BREAK case 29: YY_RULE_SETUP -#line 213 "program_lexer.l" +#line 174 "program_lexer.l" { return_opcode(require_ARB_fp, SCALAR_OP, EX2, ZERO_ONE); } YY_BREAK case 30: YY_RULE_SETUP -#line 214 "program_lexer.l" +#line 175 "program_lexer.l" { return_opcode(require_ARB_vp, SCALAR_OP, EXP, OFF); } YY_BREAK case 31: YY_RULE_SETUP -#line 216 "program_lexer.l" +#line 177 "program_lexer.l" { return_opcode( 1, VECTOR_OP, FLR, OFF); } YY_BREAK case 32: YY_RULE_SETUP -#line 217 "program_lexer.l" +#line 178 "program_lexer.l" { return_opcode(require_ARB_fp, VECTOR_OP, FLR, ZERO_ONE); } YY_BREAK case 33: YY_RULE_SETUP -#line 218 "program_lexer.l" +#line 179 "program_lexer.l" { return_opcode( 1, VECTOR_OP, FRC, OFF); } YY_BREAK case 34: YY_RULE_SETUP -#line 219 "program_lexer.l" +#line 180 "program_lexer.l" { return_opcode(require_ARB_fp, VECTOR_OP, FRC, ZERO_ONE); } YY_BREAK case 35: YY_RULE_SETUP -#line 221 "program_lexer.l" +#line 182 "program_lexer.l" { return_opcode(require_ARB_fp, KIL, KIL, OFF); } YY_BREAK case 36: YY_RULE_SETUP -#line 223 "program_lexer.l" +#line 184 "program_lexer.l" { return_opcode( 1, VECTOR_OP, LIT, OFF); } YY_BREAK case 37: YY_RULE_SETUP -#line 224 "program_lexer.l" +#line 185 "program_lexer.l" { return_opcode(require_ARB_fp, VECTOR_OP, LIT, ZERO_ONE); } YY_BREAK case 38: YY_RULE_SETUP -#line 225 "program_lexer.l" +#line 186 "program_lexer.l" { return_opcode( 1, SCALAR_OP, LG2, OFF); } YY_BREAK case 39: YY_RULE_SETUP -#line 226 "program_lexer.l" +#line 187 "program_lexer.l" { return_opcode(require_ARB_fp, SCALAR_OP, LG2, ZERO_ONE); } YY_BREAK case 40: YY_RULE_SETUP -#line 227 "program_lexer.l" +#line 188 "program_lexer.l" { return_opcode(require_ARB_vp, SCALAR_OP, LOG, OFF); } YY_BREAK case 41: YY_RULE_SETUP -#line 228 "program_lexer.l" +#line 189 "program_lexer.l" { return_opcode(require_ARB_fp, TRI_OP, LRP, OFF); } YY_BREAK case 42: YY_RULE_SETUP -#line 229 "program_lexer.l" +#line 190 "program_lexer.l" { return_opcode(require_ARB_fp, TRI_OP, LRP, ZERO_ONE); } YY_BREAK case 43: YY_RULE_SETUP -#line 231 "program_lexer.l" +#line 192 "program_lexer.l" { return_opcode( 1, TRI_OP, MAD, OFF); } YY_BREAK case 44: YY_RULE_SETUP -#line 232 "program_lexer.l" +#line 193 "program_lexer.l" { return_opcode(require_ARB_fp, TRI_OP, MAD, ZERO_ONE); } YY_BREAK case 45: YY_RULE_SETUP -#line 233 "program_lexer.l" +#line 194 "program_lexer.l" { return_opcode( 1, BIN_OP, MAX, OFF); } YY_BREAK case 46: YY_RULE_SETUP -#line 234 "program_lexer.l" +#line 195 "program_lexer.l" { return_opcode(require_ARB_fp, BIN_OP, MAX, ZERO_ONE); } YY_BREAK case 47: YY_RULE_SETUP -#line 235 "program_lexer.l" +#line 196 "program_lexer.l" { return_opcode( 1, BIN_OP, MIN, OFF); } YY_BREAK case 48: YY_RULE_SETUP -#line 236 "program_lexer.l" +#line 197 "program_lexer.l" { return_opcode(require_ARB_fp, BIN_OP, MIN, ZERO_ONE); } YY_BREAK case 49: YY_RULE_SETUP -#line 237 "program_lexer.l" +#line 198 "program_lexer.l" { return_opcode( 1, VECTOR_OP, MOV, OFF); } YY_BREAK case 50: YY_RULE_SETUP -#line 238 "program_lexer.l" +#line 199 "program_lexer.l" { return_opcode(require_ARB_fp, VECTOR_OP, MOV, ZERO_ONE); } YY_BREAK case 51: YY_RULE_SETUP -#line 239 "program_lexer.l" +#line 200 "program_lexer.l" { return_opcode( 1, BIN_OP, MUL, OFF); } YY_BREAK case 52: YY_RULE_SETUP -#line 240 "program_lexer.l" +#line 201 "program_lexer.l" { return_opcode(require_ARB_fp, BIN_OP, MUL, ZERO_ONE); } YY_BREAK case 53: YY_RULE_SETUP -#line 242 "program_lexer.l" +#line 203 "program_lexer.l" { return_opcode( 1, BINSC_OP, POW, OFF); } YY_BREAK case 54: YY_RULE_SETUP -#line 243 "program_lexer.l" +#line 204 "program_lexer.l" { return_opcode(require_ARB_fp, BINSC_OP, POW, ZERO_ONE); } YY_BREAK case 55: YY_RULE_SETUP -#line 245 "program_lexer.l" +#line 206 "program_lexer.l" { return_opcode( 1, SCALAR_OP, RCP, OFF); } YY_BREAK case 56: YY_RULE_SETUP -#line 246 "program_lexer.l" +#line 207 "program_lexer.l" { return_opcode(require_ARB_fp, SCALAR_OP, RCP, ZERO_ONE); } YY_BREAK case 57: YY_RULE_SETUP -#line 247 "program_lexer.l" +#line 208 "program_lexer.l" { return_opcode( 1, SCALAR_OP, RSQ, OFF); } YY_BREAK case 58: YY_RULE_SETUP -#line 248 "program_lexer.l" +#line 209 "program_lexer.l" { return_opcode(require_ARB_fp, SCALAR_OP, RSQ, ZERO_ONE); } YY_BREAK case 59: YY_RULE_SETUP -#line 250 "program_lexer.l" +#line 211 "program_lexer.l" { return_opcode(require_ARB_fp, SCALAR_OP, SCS, OFF); } YY_BREAK case 60: YY_RULE_SETUP -#line 251 "program_lexer.l" +#line 212 "program_lexer.l" { return_opcode(require_ARB_fp, SCALAR_OP, SCS, ZERO_ONE); } YY_BREAK case 61: YY_RULE_SETUP -#line 252 "program_lexer.l" +#line 213 "program_lexer.l" { return_opcode( 1, BIN_OP, SGE, OFF); } YY_BREAK case 62: YY_RULE_SETUP -#line 253 "program_lexer.l" +#line 214 "program_lexer.l" { return_opcode(require_ARB_fp, BIN_OP, SGE, ZERO_ONE); } YY_BREAK case 63: YY_RULE_SETUP -#line 254 "program_lexer.l" +#line 215 "program_lexer.l" { return_opcode(require_ARB_fp, SCALAR_OP, SIN, OFF); } YY_BREAK case 64: YY_RULE_SETUP -#line 255 "program_lexer.l" +#line 216 "program_lexer.l" { return_opcode(require_ARB_fp, SCALAR_OP, SIN, ZERO_ONE); } YY_BREAK case 65: YY_RULE_SETUP -#line 256 "program_lexer.l" +#line 217 "program_lexer.l" { return_opcode( 1, BIN_OP, SLT, OFF); } YY_BREAK case 66: YY_RULE_SETUP -#line 257 "program_lexer.l" +#line 218 "program_lexer.l" { return_opcode(require_ARB_fp, BIN_OP, SLT, ZERO_ONE); } YY_BREAK case 67: YY_RULE_SETUP -#line 258 "program_lexer.l" +#line 219 "program_lexer.l" { return_opcode( 1, BIN_OP, SUB, OFF); } YY_BREAK case 68: YY_RULE_SETUP -#line 259 "program_lexer.l" +#line 220 "program_lexer.l" { return_opcode(require_ARB_fp, BIN_OP, SUB, ZERO_ONE); } YY_BREAK case 69: YY_RULE_SETUP -#line 260 "program_lexer.l" +#line 221 "program_lexer.l" { return_opcode( 1, SWZ, SWZ, OFF); } YY_BREAK case 70: YY_RULE_SETUP -#line 261 "program_lexer.l" +#line 222 "program_lexer.l" { return_opcode(require_ARB_fp, SWZ, SWZ, ZERO_ONE); } YY_BREAK case 71: YY_RULE_SETUP -#line 263 "program_lexer.l" +#line 224 "program_lexer.l" { return_opcode(require_ARB_fp, SAMPLE_OP, TEX, OFF); } YY_BREAK case 72: YY_RULE_SETUP -#line 264 "program_lexer.l" +#line 225 "program_lexer.l" { return_opcode(require_ARB_fp, SAMPLE_OP, TEX, ZERO_ONE); } YY_BREAK case 73: YY_RULE_SETUP -#line 265 "program_lexer.l" +#line 226 "program_lexer.l" { return_opcode(require_ARB_fp, SAMPLE_OP, TXB, OFF); } YY_BREAK case 74: YY_RULE_SETUP -#line 266 "program_lexer.l" +#line 227 "program_lexer.l" { return_opcode(require_ARB_fp, SAMPLE_OP, TXB, ZERO_ONE); } YY_BREAK case 75: YY_RULE_SETUP -#line 267 "program_lexer.l" +#line 228 "program_lexer.l" { return_opcode(require_ARB_fp, SAMPLE_OP, TXP, OFF); } YY_BREAK case 76: YY_RULE_SETUP -#line 268 "program_lexer.l" +#line 229 "program_lexer.l" { return_opcode(require_ARB_fp, SAMPLE_OP, TXP, ZERO_ONE); } YY_BREAK case 77: YY_RULE_SETUP -#line 270 "program_lexer.l" +#line 231 "program_lexer.l" { return_opcode( 1, BIN_OP, XPD, OFF); } YY_BREAK case 78: YY_RULE_SETUP -#line 271 "program_lexer.l" +#line 232 "program_lexer.l" { return_opcode(require_ARB_fp, BIN_OP, XPD, ZERO_ONE); } YY_BREAK case 79: YY_RULE_SETUP -#line 273 "program_lexer.l" +#line 234 "program_lexer.l" { return_token_or_IDENTIFIER(require_ARB_vp, VERTEX); } YY_BREAK case 80: YY_RULE_SETUP -#line 274 "program_lexer.l" +#line 235 "program_lexer.l" { return_token_or_IDENTIFIER(require_ARB_fp, FRAGMENT); } YY_BREAK case 81: YY_RULE_SETUP -#line 275 "program_lexer.l" +#line 236 "program_lexer.l" { return PROGRAM; } YY_BREAK case 82: YY_RULE_SETUP -#line 276 "program_lexer.l" +#line 237 "program_lexer.l" { return STATE; } YY_BREAK case 83: YY_RULE_SETUP -#line 277 "program_lexer.l" +#line 238 "program_lexer.l" { return RESULT; } YY_BREAK case 84: YY_RULE_SETUP -#line 279 "program_lexer.l" +#line 240 "program_lexer.l" { return AMBIENT; } YY_BREAK case 85: YY_RULE_SETUP -#line 280 "program_lexer.l" +#line 241 "program_lexer.l" { return ATTENUATION; } YY_BREAK case 86: YY_RULE_SETUP -#line 281 "program_lexer.l" +#line 242 "program_lexer.l" { return BACK; } YY_BREAK case 87: YY_RULE_SETUP -#line 282 "program_lexer.l" +#line 243 "program_lexer.l" { return_token_or_DOT(require_ARB_vp, CLIP); } YY_BREAK case 88: YY_RULE_SETUP -#line 283 "program_lexer.l" +#line 244 "program_lexer.l" { return COLOR; } YY_BREAK case 89: YY_RULE_SETUP -#line 284 "program_lexer.l" +#line 245 "program_lexer.l" { return_token_or_DOT(require_ARB_fp, DEPTH); } YY_BREAK case 90: YY_RULE_SETUP -#line 285 "program_lexer.l" +#line 246 "program_lexer.l" { return DIFFUSE; } YY_BREAK case 91: YY_RULE_SETUP -#line 286 "program_lexer.l" +#line 247 "program_lexer.l" { return DIRECTION; } YY_BREAK case 92: YY_RULE_SETUP -#line 287 "program_lexer.l" +#line 248 "program_lexer.l" { return EMISSION; } YY_BREAK case 93: YY_RULE_SETUP -#line 288 "program_lexer.l" +#line 249 "program_lexer.l" { return ENV; } YY_BREAK case 94: YY_RULE_SETUP -#line 289 "program_lexer.l" +#line 250 "program_lexer.l" { return EYE; } YY_BREAK case 95: YY_RULE_SETUP -#line 290 "program_lexer.l" +#line 251 "program_lexer.l" { return FOGCOORD; } YY_BREAK case 96: YY_RULE_SETUP -#line 291 "program_lexer.l" +#line 252 "program_lexer.l" { return FOG; } YY_BREAK case 97: YY_RULE_SETUP -#line 292 "program_lexer.l" +#line 253 "program_lexer.l" { return FRONT; } YY_BREAK case 98: YY_RULE_SETUP -#line 293 "program_lexer.l" +#line 254 "program_lexer.l" { return HALF; } YY_BREAK case 99: YY_RULE_SETUP -#line 294 "program_lexer.l" +#line 255 "program_lexer.l" { return INVERSE; } YY_BREAK case 100: YY_RULE_SETUP -#line 295 "program_lexer.l" +#line 256 "program_lexer.l" { return INVTRANS; } YY_BREAK case 101: YY_RULE_SETUP -#line 296 "program_lexer.l" +#line 257 "program_lexer.l" { return LIGHT; } YY_BREAK case 102: YY_RULE_SETUP -#line 297 "program_lexer.l" +#line 258 "program_lexer.l" { return LIGHTMODEL; } YY_BREAK case 103: YY_RULE_SETUP -#line 298 "program_lexer.l" +#line 259 "program_lexer.l" { return LIGHTPROD; } YY_BREAK case 104: YY_RULE_SETUP -#line 299 "program_lexer.l" +#line 260 "program_lexer.l" { return LOCAL; } YY_BREAK case 105: YY_RULE_SETUP -#line 300 "program_lexer.l" +#line 261 "program_lexer.l" { return MATERIAL; } YY_BREAK case 106: YY_RULE_SETUP -#line 301 "program_lexer.l" +#line 262 "program_lexer.l" { return MAT_PROGRAM; } YY_BREAK case 107: YY_RULE_SETUP -#line 302 "program_lexer.l" +#line 263 "program_lexer.l" { return MATRIX; } YY_BREAK case 108: YY_RULE_SETUP -#line 303 "program_lexer.l" +#line 264 "program_lexer.l" { return_token_or_DOT(require_ARB_vp, MATRIXINDEX); } YY_BREAK case 109: YY_RULE_SETUP -#line 304 "program_lexer.l" +#line 265 "program_lexer.l" { return MODELVIEW; } YY_BREAK case 110: YY_RULE_SETUP -#line 305 "program_lexer.l" +#line 266 "program_lexer.l" { return MVP; } YY_BREAK case 111: YY_RULE_SETUP -#line 306 "program_lexer.l" +#line 267 "program_lexer.l" { return_token_or_DOT(require_ARB_vp, NORMAL); } YY_BREAK case 112: YY_RULE_SETUP -#line 307 "program_lexer.l" +#line 268 "program_lexer.l" { return OBJECT; } YY_BREAK case 113: YY_RULE_SETUP -#line 308 "program_lexer.l" +#line 269 "program_lexer.l" { return PALETTE; } YY_BREAK case 114: YY_RULE_SETUP -#line 309 "program_lexer.l" +#line 270 "program_lexer.l" { return PARAMS; } YY_BREAK case 115: YY_RULE_SETUP -#line 310 "program_lexer.l" +#line 271 "program_lexer.l" { return PLANE; } YY_BREAK case 116: YY_RULE_SETUP -#line 311 "program_lexer.l" +#line 272 "program_lexer.l" { return_token_or_DOT(require_ARB_vp, POINT_TOK); } YY_BREAK case 117: YY_RULE_SETUP -#line 312 "program_lexer.l" +#line 273 "program_lexer.l" { return_token_or_DOT(require_ARB_vp, POINTSIZE); } YY_BREAK case 118: YY_RULE_SETUP -#line 313 "program_lexer.l" +#line 274 "program_lexer.l" { return POSITION; } YY_BREAK case 119: YY_RULE_SETUP -#line 314 "program_lexer.l" +#line 275 "program_lexer.l" { return PRIMARY; } YY_BREAK case 120: YY_RULE_SETUP -#line 315 "program_lexer.l" +#line 276 "program_lexer.l" { return PROJECTION; } YY_BREAK case 121: YY_RULE_SETUP -#line 316 "program_lexer.l" +#line 277 "program_lexer.l" { return_token_or_DOT(require_ARB_fp, RANGE); } YY_BREAK case 122: YY_RULE_SETUP -#line 317 "program_lexer.l" +#line 278 "program_lexer.l" { return ROW; } YY_BREAK case 123: YY_RULE_SETUP -#line 318 "program_lexer.l" +#line 279 "program_lexer.l" { return SCENECOLOR; } YY_BREAK case 124: YY_RULE_SETUP -#line 319 "program_lexer.l" +#line 280 "program_lexer.l" { return SECONDARY; } YY_BREAK case 125: YY_RULE_SETUP -#line 320 "program_lexer.l" +#line 281 "program_lexer.l" { return SHININESS; } YY_BREAK case 126: YY_RULE_SETUP -#line 321 "program_lexer.l" +#line 282 "program_lexer.l" { return_token_or_DOT(require_ARB_vp, SIZE_TOK); } YY_BREAK case 127: YY_RULE_SETUP -#line 322 "program_lexer.l" +#line 283 "program_lexer.l" { return SPECULAR; } YY_BREAK case 128: YY_RULE_SETUP -#line 323 "program_lexer.l" +#line 284 "program_lexer.l" { return SPOT; } YY_BREAK case 129: YY_RULE_SETUP -#line 324 "program_lexer.l" +#line 285 "program_lexer.l" { return TEXCOORD; } YY_BREAK case 130: YY_RULE_SETUP -#line 325 "program_lexer.l" +#line 286 "program_lexer.l" { return_token_or_DOT(require_ARB_fp, TEXENV); } YY_BREAK case 131: YY_RULE_SETUP -#line 326 "program_lexer.l" +#line 287 "program_lexer.l" { return_token_or_DOT(require_ARB_vp, TEXGEN); } YY_BREAK case 132: YY_RULE_SETUP -#line 327 "program_lexer.l" +#line 288 "program_lexer.l" { return_token_or_DOT(require_ARB_vp, TEXGEN_Q); } YY_BREAK case 133: YY_RULE_SETUP -#line 328 "program_lexer.l" +#line 289 "program_lexer.l" { return_token_or_DOT(require_ARB_vp, TEXGEN_S); } YY_BREAK case 134: YY_RULE_SETUP -#line 329 "program_lexer.l" +#line 290 "program_lexer.l" { return_token_or_DOT(require_ARB_vp, TEXGEN_T); } YY_BREAK case 135: YY_RULE_SETUP -#line 330 "program_lexer.l" +#line 291 "program_lexer.l" { return TEXTURE; } YY_BREAK case 136: YY_RULE_SETUP -#line 331 "program_lexer.l" +#line 292 "program_lexer.l" { return TRANSPOSE; } YY_BREAK case 137: YY_RULE_SETUP -#line 332 "program_lexer.l" +#line 293 "program_lexer.l" { return_token_or_DOT(require_ARB_vp, VTXATTRIB); } YY_BREAK case 138: YY_RULE_SETUP -#line 333 "program_lexer.l" +#line 294 "program_lexer.l" { return_token_or_DOT(require_ARB_vp, WEIGHT); } YY_BREAK case 139: YY_RULE_SETUP -#line 335 "program_lexer.l" +#line 296 "program_lexer.l" { return_token_or_IDENTIFIER(require_ARB_fp, TEXTURE_UNIT); } YY_BREAK case 140: YY_RULE_SETUP -#line 336 "program_lexer.l" +#line 297 "program_lexer.l" { return_token_or_IDENTIFIER(require_ARB_fp, TEX_1D); } YY_BREAK case 141: YY_RULE_SETUP -#line 337 "program_lexer.l" +#line 298 "program_lexer.l" { return_token_or_IDENTIFIER(require_ARB_fp, TEX_2D); } YY_BREAK case 142: YY_RULE_SETUP -#line 338 "program_lexer.l" +#line 299 "program_lexer.l" { return_token_or_IDENTIFIER(require_ARB_fp, TEX_3D); } YY_BREAK case 143: YY_RULE_SETUP -#line 339 "program_lexer.l" +#line 300 "program_lexer.l" { return_token_or_IDENTIFIER(require_ARB_fp, TEX_CUBE); } YY_BREAK case 144: YY_RULE_SETUP -#line 340 "program_lexer.l" +#line 301 "program_lexer.l" { return_token_or_IDENTIFIER(require_ARB_fp && require_rect, TEX_RECT); } YY_BREAK case 145: YY_RULE_SETUP -#line 341 "program_lexer.l" +#line 302 "program_lexer.l" { return_token_or_IDENTIFIER(require_ARB_fp && require_shadow, TEX_SHADOW1D); } YY_BREAK case 146: YY_RULE_SETUP -#line 342 "program_lexer.l" +#line 303 "program_lexer.l" { return_token_or_IDENTIFIER(require_ARB_fp && require_shadow, TEX_SHADOW2D); } YY_BREAK case 147: YY_RULE_SETUP -#line 343 "program_lexer.l" +#line 304 "program_lexer.l" { return_token_or_IDENTIFIER(require_ARB_fp && require_shadow && require_rect, TEX_SHADOWRECT); } YY_BREAK case 148: YY_RULE_SETUP -#line 344 "program_lexer.l" +#line 305 "program_lexer.l" { return_token_or_IDENTIFIER(require_ARB_fp && require_texarray, TEX_ARRAY1D); } YY_BREAK case 149: YY_RULE_SETUP -#line 345 "program_lexer.l" +#line 306 "program_lexer.l" { return_token_or_IDENTIFIER(require_ARB_fp && require_texarray, TEX_ARRAY2D); } YY_BREAK case 150: YY_RULE_SETUP -#line 346 "program_lexer.l" +#line 307 "program_lexer.l" { return_token_or_IDENTIFIER(require_ARB_fp && require_shadow && require_texarray, TEX_ARRAYSHADOW1D); } YY_BREAK case 151: YY_RULE_SETUP -#line 347 "program_lexer.l" +#line 308 "program_lexer.l" { return_token_or_IDENTIFIER(require_ARB_fp && require_shadow && require_texarray, TEX_ARRAYSHADOW2D); } YY_BREAK case 152: YY_RULE_SETUP -#line 349 "program_lexer.l" +#line 310 "program_lexer.l" { - yylval->string = return_string(yyextra, yytext); + yylval->string = strdup(yytext); return IDENTIFIER; } YY_BREAK case 153: YY_RULE_SETUP -#line 354 "program_lexer.l" +#line 315 "program_lexer.l" { return DOT_DOT; } YY_BREAK case 154: YY_RULE_SETUP -#line 356 "program_lexer.l" +#line 317 "program_lexer.l" { yylval->integer = strtol(yytext, NULL, 10); return INTEGER; @@ -2169,7 +2116,7 @@ YY_RULE_SETUP YY_BREAK case 155: YY_RULE_SETUP -#line 360 "program_lexer.l" +#line 321 "program_lexer.l" { yylval->real = _mesa_strtod(yytext, NULL); return REAL; @@ -2181,7 +2128,7 @@ case 156: yyg->yy_c_buf_p = yy_cp -= 1; YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 364 "program_lexer.l" +#line 325 "program_lexer.l" { yylval->real = _mesa_strtod(yytext, NULL); return REAL; @@ -2189,7 +2136,7 @@ YY_RULE_SETUP YY_BREAK case 157: YY_RULE_SETUP -#line 368 "program_lexer.l" +#line 329 "program_lexer.l" { yylval->real = _mesa_strtod(yytext, NULL); return REAL; @@ -2197,7 +2144,7 @@ YY_RULE_SETUP YY_BREAK case 158: YY_RULE_SETUP -#line 372 "program_lexer.l" +#line 333 "program_lexer.l" { yylval->real = _mesa_strtod(yytext, NULL); return REAL; @@ -2205,7 +2152,7 @@ YY_RULE_SETUP YY_BREAK case 159: YY_RULE_SETUP -#line 377 "program_lexer.l" +#line 338 "program_lexer.l" { yylval->swiz_mask.swizzle = SWIZZLE_NOOP; yylval->swiz_mask.mask = WRITEMASK_XYZW; @@ -2214,7 +2161,7 @@ YY_RULE_SETUP YY_BREAK case 160: YY_RULE_SETUP -#line 383 "program_lexer.l" +#line 344 "program_lexer.l" { yylval->swiz_mask.swizzle = SWIZZLE_INVAL; yylval->swiz_mask.mask = WRITEMASK_XY @@ -2224,7 +2171,7 @@ YY_RULE_SETUP YY_BREAK case 161: YY_RULE_SETUP -#line 389 "program_lexer.l" +#line 350 "program_lexer.l" { yylval->swiz_mask.swizzle = SWIZZLE_INVAL; yylval->swiz_mask.mask = WRITEMASK_XZW; @@ -2233,7 +2180,7 @@ YY_RULE_SETUP YY_BREAK case 162: YY_RULE_SETUP -#line 394 "program_lexer.l" +#line 355 "program_lexer.l" { yylval->swiz_mask.swizzle = SWIZZLE_INVAL; yylval->swiz_mask.mask = WRITEMASK_YZW; @@ -2242,7 +2189,7 @@ YY_RULE_SETUP YY_BREAK case 163: YY_RULE_SETUP -#line 400 "program_lexer.l" +#line 361 "program_lexer.l" { yylval->swiz_mask.swizzle = SWIZZLE_INVAL; yylval->swiz_mask.mask = WRITEMASK_X @@ -2252,7 +2199,7 @@ YY_RULE_SETUP YY_BREAK case 164: YY_RULE_SETUP -#line 406 "program_lexer.l" +#line 367 "program_lexer.l" { yylval->swiz_mask.swizzle = SWIZZLE_INVAL; yylval->swiz_mask.mask = WRITEMASK_Y @@ -2262,7 +2209,7 @@ YY_RULE_SETUP YY_BREAK case 165: YY_RULE_SETUP -#line 412 "program_lexer.l" +#line 373 "program_lexer.l" { yylval->swiz_mask.swizzle = SWIZZLE_INVAL; yylval->swiz_mask.mask = WRITEMASK_ZW; @@ -2271,7 +2218,7 @@ YY_RULE_SETUP YY_BREAK case 166: YY_RULE_SETUP -#line 418 "program_lexer.l" +#line 379 "program_lexer.l" { const unsigned s = swiz_from_char(yytext[1]); yylval->swiz_mask.swizzle = MAKE_SWIZZLE4(s, s, s, s); @@ -2281,7 +2228,7 @@ YY_RULE_SETUP YY_BREAK case 167: YY_RULE_SETUP -#line 425 "program_lexer.l" +#line 386 "program_lexer.l" { yylval->swiz_mask.swizzle = MAKE_SWIZZLE4(swiz_from_char(yytext[1]), swiz_from_char(yytext[2]), @@ -2293,7 +2240,7 @@ YY_RULE_SETUP YY_BREAK case 168: YY_RULE_SETUP -#line 434 "program_lexer.l" +#line 395 "program_lexer.l" { yylval->swiz_mask.swizzle = SWIZZLE_NOOP; yylval->swiz_mask.mask = WRITEMASK_XYZW; @@ -2302,7 +2249,7 @@ YY_RULE_SETUP YY_BREAK case 169: YY_RULE_SETUP -#line 440 "program_lexer.l" +#line 401 "program_lexer.l" { yylval->swiz_mask.swizzle = SWIZZLE_INVAL; yylval->swiz_mask.mask = WRITEMASK_XY @@ -2312,7 +2259,7 @@ YY_RULE_SETUP YY_BREAK case 170: YY_RULE_SETUP -#line 446 "program_lexer.l" +#line 407 "program_lexer.l" { yylval->swiz_mask.swizzle = SWIZZLE_INVAL; yylval->swiz_mask.mask = WRITEMASK_XZW; @@ -2321,7 +2268,7 @@ YY_RULE_SETUP YY_BREAK case 171: YY_RULE_SETUP -#line 451 "program_lexer.l" +#line 412 "program_lexer.l" { yylval->swiz_mask.swizzle = SWIZZLE_INVAL; yylval->swiz_mask.mask = WRITEMASK_YZW; @@ -2330,7 +2277,7 @@ YY_RULE_SETUP YY_BREAK case 172: YY_RULE_SETUP -#line 457 "program_lexer.l" +#line 418 "program_lexer.l" { yylval->swiz_mask.swizzle = SWIZZLE_INVAL; yylval->swiz_mask.mask = WRITEMASK_X @@ -2340,7 +2287,7 @@ YY_RULE_SETUP YY_BREAK case 173: YY_RULE_SETUP -#line 463 "program_lexer.l" +#line 424 "program_lexer.l" { yylval->swiz_mask.swizzle = SWIZZLE_INVAL; yylval->swiz_mask.mask = WRITEMASK_Y @@ -2350,7 +2297,7 @@ YY_RULE_SETUP YY_BREAK case 174: YY_RULE_SETUP -#line 469 "program_lexer.l" +#line 430 "program_lexer.l" { yylval->swiz_mask.swizzle = SWIZZLE_INVAL; yylval->swiz_mask.mask = WRITEMASK_ZW; @@ -2359,7 +2306,7 @@ YY_RULE_SETUP YY_BREAK case 175: YY_RULE_SETUP -#line 475 "program_lexer.l" +#line 436 "program_lexer.l" { const unsigned s = swiz_from_char(yytext[1]); yylval->swiz_mask.swizzle = MAKE_SWIZZLE4(s, s, s, s); @@ -2369,7 +2316,7 @@ YY_RULE_SETUP YY_BREAK case 176: YY_RULE_SETUP -#line 483 "program_lexer.l" +#line 444 "program_lexer.l" { if (require_ARB_vp) { return TEXGEN_R; @@ -2383,7 +2330,7 @@ YY_RULE_SETUP YY_BREAK case 177: YY_RULE_SETUP -#line 494 "program_lexer.l" +#line 455 "program_lexer.l" { yylval->swiz_mask.swizzle = MAKE_SWIZZLE4(swiz_from_char(yytext[1]), swiz_from_char(yytext[2]), @@ -2395,13 +2342,13 @@ YY_RULE_SETUP YY_BREAK case 178: YY_RULE_SETUP -#line 503 "program_lexer.l" +#line 464 "program_lexer.l" { return DOT; } YY_BREAK case 179: /* rule 179 can match eol */ YY_RULE_SETUP -#line 505 "program_lexer.l" +#line 466 "program_lexer.l" { yylloc->first_line++; yylloc->first_column = 1; @@ -2412,7 +2359,7 @@ YY_RULE_SETUP YY_BREAK case 180: YY_RULE_SETUP -#line 512 "program_lexer.l" +#line 473 "program_lexer.l" /* eat whitespace */ ; YY_BREAK case 181: @@ -2420,20 +2367,20 @@ case 181: yyg->yy_c_buf_p = yy_cp -= 1; YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 513 "program_lexer.l" +#line 474 "program_lexer.l" /* eat comments */ ; YY_BREAK case 182: YY_RULE_SETUP -#line 514 "program_lexer.l" +#line 475 "program_lexer.l" { return yytext[0]; } YY_BREAK case 183: YY_RULE_SETUP -#line 515 "program_lexer.l" +#line 476 "program_lexer.l" ECHO; YY_BREAK -#line 2437 "lex.yy.c" +#line 2384 "lex.yy.c" case YY_STATE_EOF(INITIAL): yyterminate(); @@ -3201,8 +3148,8 @@ YY_BUFFER_STATE yy_scan_string (yyconst char * yystr , yyscan_t yyscanner) /** Setup the input buffer state to scan the given bytes. The next call to yylex() will * scan from a @e copy of @a bytes. - * @param yybytes the byte buffer to scan - * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. + * @param bytes the byte buffer to scan + * @param len the number of bytes in the buffer pointed to by @a bytes. * @param yyscanner The scanner object. * @return the newly allocated buffer state object. */ @@ -3608,7 +3555,7 @@ void yyfree (void * ptr , yyscan_t yyscanner) #define YYTABLES_NAME "yytables" -#line 515 "program_lexer.l" +#line 476 "program_lexer.l" diff --git a/src/mesa/shader/program_lexer.l b/src/mesa/shader/program_lexer.l index 6c4fad3037..c2803ff707 100644 --- a/src/mesa/shader/program_lexer.l +++ b/src/mesa/shader/program_lexer.l @@ -40,7 +40,7 @@ if (condition) { \ return token; \ } else { \ - yylval->string = return_string(yyextra, yytext); \ + yylval->string = strdup(yytext); \ return IDENTIFIER; \ } \ } while (0) @@ -63,7 +63,7 @@ yylval->temp_inst.SaturateMode = SATURATE_ ## sat; \ return token; \ } else { \ - yylval->string = return_string(yyextra, yytext); \ + yylval->string = strdup(yytext); \ return IDENTIFIER; \ } \ } while (0) @@ -71,45 +71,6 @@ #define SWIZZLE_INVAL MAKE_SWIZZLE4(SWIZZLE_NIL, SWIZZLE_NIL, \ SWIZZLE_NIL, SWIZZLE_NIL) -/** - * Send a string to the parser using asm_parser_state::string_dumpster - * - * Sends a string to the parser using asm_parser_state::string_dumpster as a - * temporary storage buffer. Data previously stored in - * asm_parser_state::string_dumpster will be lost. If - * asm_parser_state::string_dumpster is not large enough to hold the new - * string, the buffer size will be increased. The buffer size is \b never - * decreased. - * - * \param state Assembler parser state tracking - * \param str String to be passed to the parser - * - * \return - * A pointer to asm_parser_state::string_dumpster on success or \c NULL on - * failure. Currently the only failure case is \c ENOMEM. - */ -static char * -return_string(struct asm_parser_state *state, const char *str) -{ - const size_t len = strlen(str); - - if (len >= state->dumpster_size) { - char *const dumpster = _mesa_realloc(state->string_dumpster, - state->dumpster_size, - len + 1); - if (dumpster == NULL) { - return NULL; - } - - state->string_dumpster = dumpster; - state->dumpster_size = len + 1; - } - - memcpy(state->string_dumpster, str, len + 1); - return state->string_dumpster; -} - - static unsigned mask_from_char(char c) { @@ -347,7 +308,7 @@ ARRAYSHADOW1D { return_token_or_IDENTIFIER(require_ARB_fp && require ARRAYSHADOW2D { return_token_or_IDENTIFIER(require_ARB_fp && require_shadow && require_texarray, TEX_ARRAYSHADOW2D); } [_a-zA-Z$][_a-zA-Z0-9$]* { - yylval->string = return_string(yyextra, yytext); + yylval->string = strdup(yytext); return IDENTIFIER; } diff --git a/src/mesa/shader/program_parse.tab.c b/src/mesa/shader/program_parse.tab.c index 261b605a2d..c255e912ed 100644 --- a/src/mesa/shader/program_parse.tab.c +++ b/src/mesa/shader/program_parse.tab.c @@ -4565,7 +4565,7 @@ yyreduce: "undefined variable binding in ALIAS statement"); YYERROR; } else { - _mesa_symbol_table_add_symbol(state->st, 0, strdup((yyvsp[(2) - (4)].string)), target); + _mesa_symbol_table_add_symbol(state->st, 0, (yyvsp[(2) - (4)].string), target); } ;} break; @@ -4896,14 +4896,10 @@ declare_variable(struct asm_parser_state *state, char *name, enum asm_type t, if (exist != NULL) { yyerror(locp, state, "redeclared identifier"); } else { - const size_t name_len = strlen(name); - - s = calloc(1, sizeof(struct asm_symbol) + name_len + 1); - s->name = (char *)(s + 1); + s = calloc(1, sizeof(struct asm_symbol)); + s->name = name; s->type = t; - memcpy((char *) s->name, name, name_len + 1); - switch (t) { case at_temp: if (state->prog->NumTemporaries >= state->limits->MaxTemps) { @@ -5151,11 +5147,6 @@ _mesa_parse_arb_program(GLcontext *ctx, GLenum target, const GLubyte *str, _mesa_memcpy (strz, str, len); strz[len] = '\0'; - if (state->prog->String != NULL) { - _mesa_free(state->prog->String); - state->prog->String = NULL; - } - state->prog->String = strz; state->st = _mesa_symbol_table_ctor(); @@ -5245,6 +5236,7 @@ error: for (sym = state->sym; sym != NULL; sym = temp) { temp = sym->next; + _mesa_free((void *) sym->name); _mesa_free(sym); } state->sym = NULL; @@ -5252,11 +5244,6 @@ error: _mesa_symbol_table_dtor(state->st); state->st = NULL; - if (state->string_dumpster != NULL) { - _mesa_free(state->string_dumpster); - state->dumpster_size = 0; - } - return result; } diff --git a/src/mesa/shader/program_parse.y b/src/mesa/shader/program_parse.y index a23625d3fb..c3152aa2f8 100644 --- a/src/mesa/shader/program_parse.y +++ b/src/mesa/shader/program_parse.y @@ -1919,7 +1919,7 @@ ALIAS_statement: ALIAS IDENTIFIER '=' IDENTIFIER "undefined variable binding in ALIAS statement"); YYERROR; } else { - _mesa_symbol_table_add_symbol(state->st, 0, strdup($2), target); + _mesa_symbol_table_add_symbol(state->st, 0, $2, target); } } ; @@ -2027,14 +2027,10 @@ declare_variable(struct asm_parser_state *state, char *name, enum asm_type t, if (exist != NULL) { yyerror(locp, state, "redeclared identifier"); } else { - const size_t name_len = strlen(name); - - s = calloc(1, sizeof(struct asm_symbol) + name_len + 1); - s->name = (char *)(s + 1); + s = calloc(1, sizeof(struct asm_symbol)); + s->name = name; s->type = t; - memcpy((char *) s->name, name, name_len + 1); - switch (t) { case at_temp: if (state->prog->NumTemporaries >= state->limits->MaxTemps) { @@ -2284,7 +2280,6 @@ _mesa_parse_arb_program(GLcontext *ctx, GLenum target, const GLubyte *str, if (state->prog->String != NULL) { _mesa_free(state->prog->String); - state->prog->String = NULL; } state->prog->String = strz; @@ -2376,6 +2371,7 @@ error: for (sym = state->sym; sym != NULL; sym = temp) { temp = sym->next; + _mesa_free((void *) sym->name); _mesa_free(sym); } state->sym = NULL; @@ -2383,10 +2379,5 @@ error: _mesa_symbol_table_dtor(state->st); state->st = NULL; - if (state->string_dumpster != NULL) { - _mesa_free(state->string_dumpster); - state->dumpster_size = 0; - } - return result; } diff --git a/src/mesa/shader/program_parser.h b/src/mesa/shader/program_parser.h index 8d8b4d89bc..fa47d84565 100644 --- a/src/mesa/shader/program_parser.h +++ b/src/mesa/shader/program_parser.h @@ -38,13 +38,6 @@ enum asm_type { at_output, }; -/** - * \note - * Objects of this type are allocated as the object plus the name of the - * symbol. That is, malloc(sizeof(struct asm_symbol) + strlen(name) + 1). - * Alternately, asm_symbol::name could be moved to the bottom of the structure - * and declared as 'char name[0];'. - */ struct asm_symbol { struct asm_symbol *next; /**< List linkage for freeing. */ const char *name; @@ -164,15 +157,6 @@ struct asm_parser_state { /*@}*/ - /** - * Buffer to hold strings transfered from the lexer to the parser - */ - /*@{*/ - char *string_dumpster; /**< String data transfered. */ - size_t dumpster_size; /**< Total size, in bytes, of the buffer. */ - /*@}*/ - - /** * Selected limits copied from gl_constants * -- cgit v1.2.3 From 301a9b7e28f7404b8f6d8c34649f0035b49a8249 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 5 Nov 2009 14:15:56 -0800 Subject: ARB prog parser: Release strings returned from the lexer that don't need to be kept --- src/mesa/shader/program_parse.y | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'src/mesa/shader/program_parse.y') diff --git a/src/mesa/shader/program_parse.y b/src/mesa/shader/program_parse.y index c3152aa2f8..b2db2958be 100644 --- a/src/mesa/shader/program_parse.y +++ b/src/mesa/shader/program_parse.y @@ -291,6 +291,8 @@ option: OPTION IDENTIFIER ';' } + free($2); + if (!valid) { const char *const err_str = (state->mode == ARB_vertex) ? "invalid ARB vertex program option" @@ -591,12 +593,17 @@ extSwizSel: INTEGER } | IDENTIFIER { + char s; + if (strlen($1) > 1) { yyerror(& @1, state, "invalid extended swizzle selector"); YYERROR; } - switch ($1[0]) { + s = $1[0]; + free($1); + + switch (s) { case 'x': $$.swz = SWIZZLE_X; $$.xyzw_valid = 1; @@ -644,6 +651,8 @@ srcReg: IDENTIFIER /* temporaryReg | progParamSingle */ struct asm_symbol *const s = (struct asm_symbol *) _mesa_symbol_table_find_symbol(state->st, 0, $1); + free($1); + if (s == NULL) { yyerror(& @1, state, "invalid operand variable"); YYERROR; @@ -734,6 +743,8 @@ dstReg: resultBinding struct asm_symbol *const s = (struct asm_symbol *) _mesa_symbol_table_find_symbol(state->st, 0, $1); + free($1); + if (s == NULL) { yyerror(& @1, state, "invalid operand variable"); YYERROR; @@ -765,6 +776,8 @@ progParamArray: IDENTIFIER struct asm_symbol *const s = (struct asm_symbol *) _mesa_symbol_table_find_symbol(state->st, 0, $1); + free($1); + if (s == NULL) { yyerror(& @1, state, "invalid operand variable"); YYERROR; @@ -832,6 +845,8 @@ addrReg: IDENTIFIER struct asm_symbol *const s = (struct asm_symbol *) _mesa_symbol_table_find_symbol(state->st, 0, $1); + free($1); + if (s == NULL) { yyerror(& @1, state, "invalid array member"); YYERROR; @@ -894,6 +909,7 @@ ATTRIB_statement: ATTRIB IDENTIFIER '=' attribBinding declare_variable(state, $2, at_attrib, & @2); if (s == NULL) { + free($2); YYERROR; } else { s->attrib_binding = $4; @@ -1001,6 +1017,7 @@ PARAM_singleStmt: PARAM IDENTIFIER paramSingleInit declare_variable(state, $2, at_param, & @2); if (s == NULL) { + free($2); YYERROR; } else { s->param_binding_type = $3.param_binding_type; @@ -1014,6 +1031,7 @@ PARAM_singleStmt: PARAM IDENTIFIER paramSingleInit PARAM_multipleStmt: PARAM IDENTIFIER '[' optArraySize ']' paramMultipleInit { if (($4 != 0) && ((unsigned) $4 != $6.param_binding_length)) { + free($2); yyerror(& @4, state, "parameter array size and number of bindings must match"); YYERROR; @@ -1022,6 +1040,7 @@ PARAM_multipleStmt: PARAM IDENTIFIER '[' optArraySize ']' paramMultipleInit declare_variable(state, $2, $6.type, & @2); if (s == NULL) { + free($2); YYERROR; } else { s->param_binding_type = $6.param_binding_type; @@ -1717,12 +1736,14 @@ ADDRESS_statement: ADDRESS { $$ = $1; } varNameList varNameList: varNameList ',' IDENTIFIER { if (!declare_variable(state, $3, $0, & @3)) { + free($3); YYERROR; } } | IDENTIFIER { if (!declare_variable(state, $1, $0, & @1)) { + free($1); YYERROR; } } @@ -1734,6 +1755,7 @@ OUTPUT_statement: OUTPUT IDENTIFIER '=' resultBinding declare_variable(state, $2, at_output, & @2); if (s == NULL) { + free($2); YYERROR; } else { s->output_binding = $4; @@ -1911,10 +1933,14 @@ ALIAS_statement: ALIAS IDENTIFIER '=' IDENTIFIER _mesa_symbol_table_find_symbol(state->st, 0, $4); + free($4); + if (exist != NULL) { + free($2); yyerror(& @2, state, "redeclared identifier"); YYERROR; } else if (target == NULL) { + free($2); yyerror(& @4, state, "undefined variable binding in ALIAS statement"); YYERROR; -- cgit v1.2.3 From d8e256f9236d3e9dfd433c3a59718f0fdf1ca79a Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 5 Nov 2009 14:17:07 -0800 Subject: ARB prog parser: Release old program string in _mesa_parse_arb_{fragment,vertex}_program The program structure passed to _mesa_parse_arb_program is just a place holder. The stings that actually need to be released are only known to the functions calling _mesa_parse_arb_program, so they should be freed there. --- src/mesa/shader/arbprogparse.c | 6 ++++++ src/mesa/shader/program_parse.y | 4 ---- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'src/mesa/shader/program_parse.y') diff --git a/src/mesa/shader/arbprogparse.c b/src/mesa/shader/arbprogparse.c index 05ee4f563e..dd732b6666 100644 --- a/src/mesa/shader/arbprogparse.c +++ b/src/mesa/shader/arbprogparse.c @@ -87,6 +87,9 @@ _mesa_parse_arb_fragment_program(GLcontext* ctx, GLenum target, return; } + if (program->Base.String != NULL) + _mesa_free(program->Base.String); + /* Copy the relevant contents of the arb_program struct into the * fragment_program struct. */ @@ -178,6 +181,9 @@ _mesa_parse_arb_vertex_program(GLcontext *ctx, GLenum target, return; } + if (program->Base.String != NULL) + _mesa_free(program->Base.String); + /* Copy the relevant contents of the arb_program struct into the * vertex_program struct. */ diff --git a/src/mesa/shader/program_parse.y b/src/mesa/shader/program_parse.y index b2db2958be..aad5eeb7da 100644 --- a/src/mesa/shader/program_parse.y +++ b/src/mesa/shader/program_parse.y @@ -2304,10 +2304,6 @@ _mesa_parse_arb_program(GLcontext *ctx, GLenum target, const GLubyte *str, _mesa_memcpy (strz, str, len); strz[len] = '\0'; - if (state->prog->String != NULL) { - _mesa_free(state->prog->String); - } - state->prog->String = strz; state->st = _mesa_symbol_table_ctor(); -- cgit v1.2.3 From 5606dfb572bf4b89b4882265924705bacc8c182b Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 17 Nov 2009 16:10:24 -0800 Subject: Merge branch 'outputswritten64' Add a GLbitfield64 type and several macros to operate on 64-bit fields. The OutputsWritten field of gl_program is changed to use that type. This results in a fair amount of fallout in drivers that use programs. No changes are strictly necessary at this point as all bits used are below the 32-bit boundary. Fairly soon several bits will be added for clip distances written by a vertex shader. This will cause several bits used for varyings to be pushed above the 32-bit boundary. This will affect any drivers that support GLSL. At this point, only the i965 driver has been modified to support this eventuality. I did this as a "squash" merge. There were several places through the outputswritten64 branch where things were broken. I foresee this causing difficulties later for bisecting. The history is still available in the branch. Conflicts: src/mesa/drivers/dri/i965/brw_wm.h --- src/mesa/drivers/dri/i965/brw_clip.c | 2 +- src/mesa/drivers/dri/i965/brw_clip.h | 2 +- src/mesa/drivers/dri/i965/brw_context.h | 6 +----- src/mesa/drivers/dri/i965/brw_gs.h | 2 +- src/mesa/drivers/dri/i965/brw_sf.c | 6 +++--- src/mesa/drivers/dri/i965/brw_sf.h | 2 +- src/mesa/drivers/dri/i965/brw_sf_emit.c | 18 +++++++++--------- src/mesa/drivers/dri/i965/brw_util.c | 2 +- src/mesa/drivers/dri/i965/brw_util.h | 2 +- src/mesa/drivers/dri/i965/brw_vs.c | 2 +- src/mesa/drivers/dri/i965/brw_vs_emit.c | 8 ++++---- src/mesa/drivers/dri/i965/brw_wm.c | 4 ++-- src/mesa/drivers/dri/i965/brw_wm.h | 2 +- src/mesa/drivers/dri/i965/brw_wm_fp.c | 2 +- src/mesa/drivers/dri/i965/brw_wm_glsl.c | 2 +- src/mesa/drivers/dri/i965/brw_wm_pass2.c | 4 ++-- src/mesa/drivers/dri/i965/brw_wm_state.c | 2 +- src/mesa/drivers/dri/r200/r200_tcl.c | 15 ++++++++------- src/mesa/main/config.h | 2 +- src/mesa/main/context.c | 8 +++++--- src/mesa/main/ffvertex_prog.c | 2 +- src/mesa/main/mtypes.h | 27 ++++++++++++++++++++++++++- src/mesa/main/texenvprogram.c | 2 +- src/mesa/shader/prog_print.c | 6 +++--- src/mesa/shader/program_parse.tab.c | 2 +- src/mesa/shader/program_parse.y | 2 +- src/mesa/shader/programopt.c | 8 ++++---- src/mesa/shader/slang/slang_link.c | 25 +++++++++++++++---------- src/mesa/state_tracker/st_atom_shader.c | 2 +- src/mesa/state_tracker/st_program.c | 2 +- src/mesa/swrast/s_fragprog.c | 12 ++++++------ src/mesa/tnl/t_context.c | 2 +- src/mesa/tnl/t_vb_program.c | 8 ++++---- 33 files changed, 111 insertions(+), 82 deletions(-) (limited to 'src/mesa/shader/program_parse.y') diff --git a/src/mesa/drivers/dri/i965/brw_clip.c b/src/mesa/drivers/dri/i965/brw_clip.c index f45dcf8282..dbd10a5297 100644 --- a/src/mesa/drivers/dri/i965/brw_clip.c +++ b/src/mesa/drivers/dri/i965/brw_clip.c @@ -78,7 +78,7 @@ static void compile_clip_prog( struct brw_context *brw, delta = REG_SIZE; for (i = 0; i < VERT_RESULT_MAX; i++) - if (c.key.attrs & (1<= VERT_RESULT_TEX0 && i <= VERT_RESULT_TEX7) { @@ -147,7 +147,7 @@ static void upload_sf_prog(struct brw_context *brw) * edgeflag testing here, it is already done in the clip * program. */ - if (key.attrs & (1<key.attrs & (1<key.attrs & BITFIELD64_BIT(attr)) ? 1 : 0; } /*********************************************************************** @@ -122,8 +122,8 @@ static void do_twoside_color( struct brw_sf_compile *c ) * Flat shading */ -#define VERT_RESULT_COLOR_BITS ((1<nr_setup_regs - 1); - GLuint persp_mask; - GLuint linear_mask; + GLbitfield64 persp_mask; + GLbitfield64 linear_mask; if (c->key.do_flat_shading || c->key.linear_color) persp_mask = c->key.attrs & ~(FRAG_BIT_WPOS | @@ -331,10 +331,10 @@ static GLboolean calculate_masks( struct brw_sf_compile *c, *pc_linear = 0; *pc = 0xf; - if (persp_mask & (1 << c->idx_to_attr[reg*2])) + if (persp_mask & BITFIELD64_BIT(c->idx_to_attr[reg*2])) *pc_persp = 0xf; - if (linear_mask & (1 << c->idx_to_attr[reg*2])) + if (linear_mask & BITFIELD64_BIT(c->idx_to_attr[reg*2])) *pc_linear = 0xf; /* Maybe only processs one attribute on the final round: @@ -342,10 +342,10 @@ static GLboolean calculate_masks( struct brw_sf_compile *c, if (reg*2+1 < c->nr_setup_attrs) { *pc |= 0xf0; - if (persp_mask & (1 << c->idx_to_attr[reg*2+1])) + if (persp_mask & BITFIELD64_BIT(c->idx_to_attr[reg*2+1])) *pc_persp |= 0xf0; - if (linear_mask & (1 << c->idx_to_attr[reg*2+1])) + if (linear_mask & BITFIELD64_BIT(c->idx_to_attr[reg*2+1])) *pc_linear |= 0xf0; } diff --git a/src/mesa/drivers/dri/i965/brw_util.c b/src/mesa/drivers/dri/i965/brw_util.c index ce21aa4869..bba9249d1b 100644 --- a/src/mesa/drivers/dri/i965/brw_util.c +++ b/src/mesa/drivers/dri/i965/brw_util.c @@ -35,7 +35,7 @@ #include "brw_util.h" #include "brw_defines.h" -GLuint brw_count_bits( GLuint val ) +GLuint brw_count_bits(uint64_t val) { GLuint i; for (i = 0; val ; val >>= 1) diff --git a/src/mesa/drivers/dri/i965/brw_util.h b/src/mesa/drivers/dri/i965/brw_util.h index 33e7cd87e4..04f3175d3e 100644 --- a/src/mesa/drivers/dri/i965/brw_util.h +++ b/src/mesa/drivers/dri/i965/brw_util.h @@ -35,7 +35,7 @@ #include "main/mtypes.h" -extern GLuint brw_count_bits( GLuint val ); +extern GLuint brw_count_bits(uint64_t val); extern GLuint brw_parameter_list_state_flags(struct gl_program_parameter_list *paramList); extern GLuint brw_translate_blend_factor( GLenum factor ); extern GLuint brw_translate_blend_equation( GLenum mode ); diff --git a/src/mesa/drivers/dri/i965/brw_vs.c b/src/mesa/drivers/dri/i965/brw_vs.c index f0c79efbd9..fd055e225e 100644 --- a/src/mesa/drivers/dri/i965/brw_vs.c +++ b/src/mesa/drivers/dri/i965/brw_vs.c @@ -56,7 +56,7 @@ static void do_vs_prog( struct brw_context *brw, c.prog_data.inputs_read = vp->program.Base.InputsRead; if (c.key.copy_edgeflag) { - c.prog_data.outputs_written |= 1<prog_data.outputs_written & (1 << i)) { + if (c->prog_data.outputs_written & BITFIELD64_BIT(i)) { c->nr_outputs++; assert(i < Elements(c->regs[PROGRAM_OUTPUT])); if (i == VERT_RESULT_HPOS) { @@ -1124,7 +1124,7 @@ static void emit_vertex_write( struct brw_vs_compile *c) /* Update the header for point size, user clipping flags, and -ve rhw * workaround. */ - if ((c->prog_data.outputs_written & (1<prog_data.outputs_written & BITFIELD64_BIT(VERT_RESULT_PSIZ)) || c->key.nr_userclip || BRW_IS_965(p->brw)) { struct brw_reg header1 = retype(get_tmp(c), BRW_REGISTER_TYPE_UD); @@ -1134,7 +1134,7 @@ static void emit_vertex_write( struct brw_vs_compile *c) brw_set_access_mode(p, BRW_ALIGN_16); - if (c->prog_data.outputs_written & (1<prog_data.outputs_written & BITFIELD64_BIT(VERT_RESULT_PSIZ)) { struct brw_reg psiz = c->regs[PROGRAM_OUTPUT][VERT_RESULT_PSIZ]; brw_MUL(p, brw_writemask(header1, WRITEMASK_W), brw_swizzle1(psiz, 0), brw_imm_f(1<<11)); brw_AND(p, brw_writemask(header1, WRITEMASK_W), header1, brw_imm_ud(0x7ff<<8)); @@ -1224,7 +1224,7 @@ static void emit_vertex_write( struct brw_vs_compile *c) */ GLuint i, mrf = 0; for (i = c->first_overflow_output; i < VERT_RESULT_MAX; i++) { - if (c->prog_data.outputs_written & (1 << i)) { + if (c->prog_data.outputs_written & BITFIELD64_BIT(i)) { /* move from GRF to MRF */ brw_MOV(p, brw_message_reg(4+mrf), c->regs[PROGRAM_OUTPUT][i]); mrf++; diff --git a/src/mesa/drivers/dri/i965/brw_wm.c b/src/mesa/drivers/dri/i965/brw_wm.c index d8971321f3..77e3b2c32a 100644 --- a/src/mesa/drivers/dri/i965/brw_wm.c +++ b/src/mesa/drivers/dri/i965/brw_wm.c @@ -231,7 +231,7 @@ static void brw_wm_populate_key( struct brw_context *brw, ctx->Color.AlphaEnabled) lookup |= IZ_PS_KILL_ALPHATEST_BIT; - if (fp->program.Base.OutputsWritten & (1<program.Base.OutputsWritten & BITFIELD64_BIT(FRAG_RESULT_DEPTH)) lookup |= IZ_PS_COMPUTES_DEPTH_BIT; /* _NEW_DEPTH */ @@ -347,7 +347,7 @@ static void brw_wm_populate_key( struct brw_context *brw, key->nr_color_regions = brw->state.nr_color_regions; /* CACHE_NEW_VS_PROG */ - key->vp_outputs_written = brw->vs.prog_data->outputs_written & DO_SETUP_BITS; + key->vp_outputs_written = brw->vs.prog_data->outputs_written; /* The unique fragment program ID */ key->program_string_id = fp->id; diff --git a/src/mesa/drivers/dri/i965/brw_wm.h b/src/mesa/drivers/dri/i965/brw_wm.h index b3c05eb0ad..9dcb6e14bb 100644 --- a/src/mesa/drivers/dri/i965/brw_wm.h +++ b/src/mesa/drivers/dri/i965/brw_wm.h @@ -79,7 +79,7 @@ struct brw_wm_prog_key { GLuint program_string_id:32; GLushort origin_x, origin_y; GLushort drawable_height; - GLuint vp_outputs_written; + GLbitfield64 vp_outputs_written; }; diff --git a/src/mesa/drivers/dri/i965/brw_wm_fp.c b/src/mesa/drivers/dri/i965/brw_wm_fp.c index 1c4f62ba48..7d03179588 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_fp.c +++ b/src/mesa/drivers/dri/i965/brw_wm_fp.c @@ -986,7 +986,7 @@ static void emit_render_target_writes( struct brw_wm_compile *c ) } else { /* if gl_FragData[0] is written, use it, else use gl_FragColor */ - if (c->fp->program.Base.OutputsWritten & (1 << FRAG_RESULT_DATA0)) + if (c->fp->program.Base.OutputsWritten & BITFIELD64_BIT(FRAG_RESULT_DATA0)) outcolor = src_reg(PROGRAM_OUTPUT, FRAG_RESULT_DATA0); else outcolor = src_reg(PROGRAM_OUTPUT, FRAG_RESULT_COLOR); diff --git a/src/mesa/drivers/dri/i965/brw_wm_glsl.c b/src/mesa/drivers/dri/i965/brw_wm_glsl.c index 3ab446164c..e8c2cb66ec 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_glsl.c +++ b/src/mesa/drivers/dri/i965/brw_wm_glsl.c @@ -371,7 +371,7 @@ static void prealloc_reg(struct brw_wm_compile *c) for (j = 0; j < 4; j++) set_reg(c, PROGRAM_PAYLOAD, fp_input, j, reg); } - if (c->key.vp_outputs_written & (1 << i)) { + if (c->key.vp_outputs_written & BITFIELD64_BIT(i)) { reg_index += 2; } } diff --git a/src/mesa/drivers/dri/i965/brw_wm_pass2.c b/src/mesa/drivers/dri/i965/brw_wm_pass2.c index 6faea018fb..31303febf0 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_pass2.c +++ b/src/mesa/drivers/dri/i965/brw_wm_pass2.c @@ -82,8 +82,8 @@ static void init_registers( struct brw_wm_compile *c ) for (j = 0; j < c->nr_creg; j++) prealloc_reg(c, &c->creg[j], i++); - for (j = 0; j < FRAG_ATTRIB_MAX; j++) { - if (c->key.vp_outputs_written & (1<key.vp_outputs_written & BITFIELD64_BIT(j)) { int fp_index; if (j >= VERT_RESULT_VAR0) diff --git a/src/mesa/drivers/dri/i965/brw_wm_state.c b/src/mesa/drivers/dri/i965/brw_wm_state.c index 361f91292b..f89ed9bce7 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_state.c +++ b/src/mesa/drivers/dri/i965/brw_wm_state.c @@ -106,7 +106,7 @@ wm_unit_populate_key(struct brw_context *brw, struct brw_wm_unit_key *key) /* as far as we can tell */ key->computes_depth = - (fp->Base.OutputsWritten & (1 << FRAG_RESULT_DEPTH)) != 0; + (fp->Base.OutputsWritten & BITFIELD64_BIT(FRAG_RESULT_DEPTH)) != 0; /* BRW_NEW_DEPTH_BUFFER * Override for NULL depthbuffer case, required by the Pixel Shader Computed * Depth field. diff --git a/src/mesa/drivers/dri/r200/r200_tcl.c b/src/mesa/drivers/dri/r200/r200_tcl.c index c702910ef2..e7d48a7f29 100644 --- a/src/mesa/drivers/dri/r200/r200_tcl.c +++ b/src/mesa/drivers/dri/r200/r200_tcl.c @@ -509,25 +509,26 @@ static GLboolean r200_run_tcl_render( GLcontext *ctx, prog to a not enabled output however, so just don't mess with it. We only need to change compsel. */ GLuint out_compsel = 0; - GLuint vp_out = rmesa->curr_vp_hw->mesa_program.Base.OutputsWritten; + const GLbitfield64 vp_out = + rmesa->curr_vp_hw->mesa_program.Base.OutputsWritten; vimap_rev = &rmesa->curr_vp_hw->inputmap_rev[0]; - assert(vp_out & (1 << VERT_RESULT_HPOS)); + assert(vp_out & BITFIELD64_BIT(VERT_RESULT_HPOS)); out_compsel = R200_OUTPUT_XYZW; - if (vp_out & (1 << VERT_RESULT_COL0)) { + if (vp_out & BITFIELD64_BIT(VERT_RESULT_COL0)) { out_compsel |= R200_OUTPUT_COLOR_0; } - if (vp_out & (1 << VERT_RESULT_COL1)) { + if (vp_out & BITFIELD64_BIT(VERT_RESULT_COL1)) { out_compsel |= R200_OUTPUT_COLOR_1; } - if (vp_out & (1 << VERT_RESULT_FOGC)) { + if (vp_out & BITFIELD64_BIT(VERT_RESULT_FOGC)) { out_compsel |= R200_OUTPUT_DISCRETE_FOG; } - if (vp_out & (1 << VERT_RESULT_PSIZ)) { + if (vp_out & BITFIELD64_BIT(VERT_RESULT_PSIZ)) { out_compsel |= R200_OUTPUT_PT_SIZE; } for (i = VERT_RESULT_TEX0; i < VERT_RESULT_TEX6; i++) { - if (vp_out & (1 << i)) { + if (vp_out & BITFIELD64_BIT(i)) { out_compsel |= R200_OUTPUT_TEX_0 << (i - VERT_RESULT_TEX0); } } diff --git a/src/mesa/main/config.h b/src/mesa/main/config.h index 8a09efdb53..c5048970cc 100644 --- a/src/mesa/main/config.h +++ b/src/mesa/main/config.h @@ -205,7 +205,7 @@ #define MAX_VARYING 16 /**< number of float[4] vectors */ #define MAX_SAMPLERS MAX_TEXTURE_IMAGE_UNITS #define MAX_PROGRAM_INPUTS 32 -#define MAX_PROGRAM_OUTPUTS 32 +#define MAX_PROGRAM_OUTPUTS 64 /*@}*/ /** For GL_ARB_vertex_program */ diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 101d3c6b67..b5bf46718f 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -601,9 +601,11 @@ _mesa_init_constants(GLcontext *ctx) ASSERT(MAX_NV_VERTEX_PROGRAM_INPUTS <= VERT_ATTRIB_MAX); ASSERT(MAX_NV_VERTEX_PROGRAM_OUTPUTS <= VERT_RESULT_MAX); - /* check that we don't exceed various 32-bit bitfields */ - ASSERT(VERT_RESULT_MAX <= 32); - ASSERT(FRAG_ATTRIB_MAX <= 32); + /* check that we don't exceed the size of various bitfields */ + ASSERT(VERT_RESULT_MAX <= + (8 * sizeof(ctx->VertexProgram._Current->Base.OutputsWritten))); + ASSERT(FRAG_ATTRIB_MAX <= + (8 * sizeof(ctx->FragmentProgram._Current->Base.InputsRead))); } diff --git a/src/mesa/main/ffvertex_prog.c b/src/mesa/main/ffvertex_prog.c index 356476e35a..fe2416d894 100644 --- a/src/mesa/main/ffvertex_prog.c +++ b/src/mesa/main/ffvertex_prog.c @@ -438,7 +438,7 @@ static struct ureg register_input( struct tnl_program *p, GLuint input ) */ static struct ureg register_output( struct tnl_program *p, GLuint output ) { - p->program->Base.OutputsWritten |= (1<program->Base.OutputsWritten |= BITFIELD64_BIT(output); return make_ureg(PROGRAM_OUTPUT, output); } diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 34c51b5442..881d233ca3 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -78,6 +78,31 @@ #endif +/** + * \name 64-bit extension of GLbitfield. + */ +/*@{*/ +typedef GLuint64 GLbitfield64; + +#define BITFIELD64_ONE 1ULL +#define BITFIELD64_ALLONES ~0ULL + +/** Set a single bit */ +#define BITFIELD64_BIT(b) (BITFIELD64_ONE << (b)) + +/** Set a mask of the least significant \c b bits */ +#define BITFIELD64_MASK(b) (((b) >= 64) ? BITFIELD64_ALLONES : \ + (BITFIELD64_BIT(b) - 1)) + +/** + * Set all bits from l (low bit) to h (high bit), inclusive. + * + * \note \C BITFIELD_64_RANGE(0, 63) return 64 set bits. + */ +#define BITFIELD64_RANGE(l, h) (BITFIELD64_MASK((h) + 1) & ~BITFIELD64_MASK(l)) +/*@}*/ + + /** * \name Some forward type declarations */ @@ -1670,7 +1695,7 @@ struct gl_program struct prog_instruction *Instructions; GLbitfield InputsRead; /**< Bitmask of which input regs are read */ - GLbitfield OutputsWritten; /**< Bitmask of which output regs are written to */ + GLbitfield64 OutputsWritten; /**< Bitmask of which output regs are written */ GLbitfield InputFlags[MAX_PROGRAM_INPUTS]; /**< PROG_PARAM_BIT_x flags */ GLbitfield OutputFlags[MAX_PROGRAM_OUTPUTS]; /**< PROG_PARAM_BIT_x flags */ GLbitfield TexturesUsed[MAX_TEXTURE_UNITS]; /**< TEXTURE_x_BIT bitmask */ diff --git a/src/mesa/main/texenvprogram.c b/src/mesa/main/texenvprogram.c index d7e77e759e..f439d4addb 100644 --- a/src/mesa/main/texenvprogram.c +++ b/src/mesa/main/texenvprogram.c @@ -367,7 +367,7 @@ static GLbitfield get_fp_input_mask( GLcontext *ctx ) else { /* calculate from vp->outputs */ struct gl_vertex_program *vprog; - GLbitfield vp_outputs; + GLbitfield64 vp_outputs; /* Choose GLSL vertex shader over ARB vertex program. Need this * since vertex shader state validation comes after fragment state diff --git a/src/mesa/shader/prog_print.c b/src/mesa/shader/prog_print.c index ba4d39452f..52c102cbaa 100644 --- a/src/mesa/shader/prog_print.c +++ b/src/mesa/shader/prog_print.c @@ -826,11 +826,11 @@ _mesa_print_program(const struct gl_program *prog) * XXX move to imports.[ch] if useful elsewhere. */ static const char * -binary(GLbitfield val) +binary(GLbitfield64 val) { - static char buf[50]; + static char buf[80]; GLint i, len = 0; - for (i = 31; i >= 0; --i) { + for (i = 63; i >= 0; --i) { if (val & (1 << i)) buf[len++] = '1'; else if (len > 0 || i == 0) diff --git a/src/mesa/shader/program_parse.tab.c b/src/mesa/shader/program_parse.tab.c index b9ef88b64b..d4f8429488 100644 --- a/src/mesa/shader/program_parse.tab.c +++ b/src/mesa/shader/program_parse.tab.c @@ -2622,7 +2622,7 @@ yyreduce: YYERROR; } - state->prog->OutputsWritten |= (1U << (yyval.dst_reg).Index); + state->prog->OutputsWritten |= BITFIELD64_BIT((yyval.dst_reg).Index); } ;} break; diff --git a/src/mesa/shader/program_parse.y b/src/mesa/shader/program_parse.y index d07bf85b36..8ca6f9805b 100644 --- a/src/mesa/shader/program_parse.y +++ b/src/mesa/shader/program_parse.y @@ -643,7 +643,7 @@ maskedDstReg: dstReg optionalMask optionalCcMask YYERROR; } - state->prog->OutputsWritten |= (1U << $$.Index); + state->prog->OutputsWritten |= BITFIELD64_BIT($$.Index); } } ; diff --git a/src/mesa/shader/programopt.c b/src/mesa/shader/programopt.c index 3b8529592d..a0daac1b80 100644 --- a/src/mesa/shader/programopt.c +++ b/src/mesa/shader/programopt.c @@ -109,7 +109,7 @@ _mesa_insert_mvp_dp4_code(GLcontext *ctx, struct gl_vertex_program *vprog) vprog->Base.Instructions = newInst; vprog->Base.NumInstructions = newLen; vprog->Base.InputsRead |= VERT_BIT_POS; - vprog->Base.OutputsWritten |= (1 << VERT_RESULT_HPOS); + vprog->Base.OutputsWritten |= BITFIELD64_BIT(VERT_RESULT_HPOS); } @@ -211,7 +211,7 @@ _mesa_insert_mvp_mad_code(GLcontext *ctx, struct gl_vertex_program *vprog) vprog->Base.Instructions = newInst; vprog->Base.NumInstructions = newLen; vprog->Base.InputsRead |= VERT_BIT_POS; - vprog->Base.OutputsWritten |= (1 << VERT_RESULT_HPOS); + vprog->Base.OutputsWritten |= BITFIELD64_BIT(VERT_RESULT_HPOS); } @@ -613,7 +613,7 @@ _mesa_nop_fragment_program(GLcontext *ctx, struct gl_fragment_program *prog) prog->Base.Instructions = inst; prog->Base.NumInstructions = 2; prog->Base.InputsRead = 1 << inputAttr; - prog->Base.OutputsWritten = 1 << FRAG_RESULT_COLOR; + prog->Base.OutputsWritten = BITFIELD64_BIT(FRAG_RESULT_COLOR); } @@ -657,7 +657,7 @@ _mesa_nop_vertex_program(GLcontext *ctx, struct gl_vertex_program *prog) prog->Base.Instructions = inst; prog->Base.NumInstructions = 2; prog->Base.InputsRead = 1 << inputAttr; - prog->Base.OutputsWritten = 1 << VERT_RESULT_COL0; + prog->Base.OutputsWritten = BITFIELD64_BIT(VERT_RESULT_COL0); /* * Now insert code to do standard modelview/projection transformation. diff --git a/src/mesa/shader/slang/slang_link.c b/src/mesa/shader/slang/slang_link.c index 144c126525..0a2bc49780 100644 --- a/src/mesa/shader/slang/slang_link.c +++ b/src/mesa/shader/slang/slang_link.c @@ -515,7 +515,7 @@ _slang_update_inputs_outputs(struct gl_program *prog) } if (inst->DstReg.File == PROGRAM_OUTPUT) { - prog->OutputsWritten |= 1 << inst->DstReg.Index; + prog->OutputsWritten |= BITFIELD64_BIT(inst->DstReg.Index); if (inst->DstReg.RelAddr) { /* If the output attribute is indexed with relative addressing * we know that it must be a varying or texcoord such as @@ -528,14 +528,17 @@ _slang_update_inputs_outputs(struct gl_program *prog) if (prog->Target == GL_VERTEX_PROGRAM_ARB) { if (inst->DstReg.Index == VERT_RESULT_TEX0) { /* mark all texcoord outputs as written */ - const GLbitfield mask = - ((1 << MAX_TEXTURE_COORD_UNITS) - 1) << VERT_RESULT_TEX0; + const GLbitfield64 mask = + BITFIELD64_RANGE(VERT_RESULT_TEX0, + (VERT_RESULT_TEX0 + + MAX_TEXTURE_COORD_UNITS - 1)); prog->OutputsWritten |= mask; } else if (inst->DstReg.Index == VERT_RESULT_VAR0) { /* mark all generic varying outputs as written */ - const GLbitfield mask = - ((1 << MAX_VARYING) - 1) << VERT_RESULT_VAR0; + const GLbitfield64 mask = + BITFIELD64_RANGE(VERT_RESULT_VAR0, + (VERT_RESULT_VAR0 + MAX_VARYING - 1)); prog->OutputsWritten |= mask; } } @@ -807,7 +810,8 @@ _slang_link(GLcontext *ctx, if (shProg->VertexProgram) { _slang_update_inputs_outputs(&shProg->VertexProgram->Base); _slang_count_temporaries(&shProg->VertexProgram->Base); - if (!(shProg->VertexProgram->Base.OutputsWritten & (1 << VERT_RESULT_HPOS))) { + if (!(shProg->VertexProgram->Base.OutputsWritten + & BITFIELD64_BIT(VERT_RESULT_HPOS))) { /* the vertex program did not compute a vertex position */ link_error(shProg, "gl_Position was not written by vertex shader\n"); @@ -825,7 +829,7 @@ _slang_link(GLcontext *ctx, if (shProg->FragmentProgram) { const GLbitfield varyingRead = shProg->FragmentProgram->Base.InputsRead >> FRAG_ATTRIB_VAR0; - const GLbitfield varyingWritten = shProg->VertexProgram ? + const GLbitfield64 varyingWritten = shProg->VertexProgram ? shProg->VertexProgram->Base.OutputsWritten >> VERT_RESULT_VAR0 : 0x0; if ((varyingRead & varyingWritten) != varyingRead) { link_error(shProg, @@ -836,9 +840,10 @@ _slang_link(GLcontext *ctx, /* check that gl_FragColor and gl_FragData are not both written to */ if (shProg->FragmentProgram) { - GLbitfield outputsWritten = shProg->FragmentProgram->Base.OutputsWritten; - if ((outputsWritten & ((1 << FRAG_RESULT_COLOR))) && - (outputsWritten >= (1 << FRAG_RESULT_DATA0))) { + const GLbitfield64 outputsWritten = + shProg->FragmentProgram->Base.OutputsWritten; + if ((outputsWritten & BITFIELD64_BIT(FRAG_RESULT_COLOR)) && + (outputsWritten >= BITFIELD64_BIT(FRAG_RESULT_DATA0))) { link_error(shProg, "Fragment program cannot write both gl_FragColor" " and gl_FragData[].\n"); return; diff --git a/src/mesa/state_tracker/st_atom_shader.c b/src/mesa/state_tracker/st_atom_shader.c index ee649be885..6e311e537e 100644 --- a/src/mesa/state_tracker/st_atom_shader.c +++ b/src/mesa/state_tracker/st_atom_shader.c @@ -176,7 +176,7 @@ find_translated_vp(struct st_context *st, /* See if we need to translate vertex program to TGSI form */ if (xvp->serialNo != stvp->serialNo) { GLuint outAttr; - const GLbitfield outputsWritten = stvp->Base.Base.OutputsWritten; + const GLbitfield64 outputsWritten = stvp->Base.Base.OutputsWritten; GLuint numVpOuts = 0; GLboolean emitPntSize = GL_FALSE, emitBFC0 = GL_FALSE, emitBFC1 = GL_FALSE; GLbitfield usedGenerics = 0x0; diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c index 6d02722c13..190b6a5526 100644 --- a/src/mesa/state_tracker/st_program.c +++ b/src/mesa/state_tracker/st_program.c @@ -469,7 +469,7 @@ st_translate_fragment_program(struct st_context *st, */ { uint numColors = 0; - GLbitfield outputsWritten = stfp->Base.Base.OutputsWritten; + GLbitfield64 outputsWritten = stfp->Base.Base.OutputsWritten; /* if z is written, emit that first */ if (outputsWritten & (1 << FRAG_RESULT_DEPTH)) { diff --git a/src/mesa/swrast/s_fragprog.c b/src/mesa/swrast/s_fragprog.c index 77a77f0bcb..a22d34415d 100644 --- a/src/mesa/swrast/s_fragprog.c +++ b/src/mesa/swrast/s_fragprog.c @@ -190,7 +190,7 @@ run_program(GLcontext *ctx, SWspan *span, GLuint start, GLuint end) { SWcontext *swrast = SWRAST_CONTEXT(ctx); const struct gl_fragment_program *program = ctx->FragmentProgram._Current; - const GLbitfield outputsWritten = program->Base.OutputsWritten; + const GLbitfield64 outputsWritten = program->Base.OutputsWritten; struct gl_program_machine *machine = &swrast->FragProgMachine; GLuint i; @@ -201,7 +201,7 @@ run_program(GLcontext *ctx, SWspan *span, GLuint start, GLuint end) if (_mesa_execute_program(ctx, &program->Base, machine)) { /* Store result color */ - if (outputsWritten & (1 << FRAG_RESULT_COLOR)) { + if (outputsWritten & BITFIELD64_BIT(FRAG_RESULT_COLOR)) { COPY_4V(span->array->attribs[FRAG_ATTRIB_COL0][i], machine->Outputs[FRAG_RESULT_COLOR]); } @@ -212,7 +212,7 @@ run_program(GLcontext *ctx, SWspan *span, GLuint start, GLuint end) */ GLuint buf; for (buf = 0; buf < ctx->DrawBuffer->_NumColorDrawBuffers; buf++) { - if (outputsWritten & (1 << (FRAG_RESULT_DATA0 + buf))) { + if (outputsWritten & BITFIELD64_BIT(FRAG_RESULT_DATA0 + buf)) { COPY_4V(span->array->attribs[FRAG_ATTRIB_COL0 + buf][i], machine->Outputs[FRAG_RESULT_DATA0 + buf]); } @@ -220,7 +220,7 @@ run_program(GLcontext *ctx, SWspan *span, GLuint start, GLuint end) } /* Store result depth/z */ - if (outputsWritten & (1 << FRAG_RESULT_DEPTH)) { + if (outputsWritten & BITFIELD64_BIT(FRAG_RESULT_DEPTH)) { const GLfloat depth = machine->Outputs[FRAG_RESULT_DEPTH][2]; if (depth <= 0.0) span->array->z[i] = 0; @@ -256,12 +256,12 @@ _swrast_exec_fragment_program( GLcontext *ctx, SWspan *span ) run_program(ctx, span, 0, span->end); - if (program->Base.OutputsWritten & (1 << FRAG_RESULT_COLOR)) { + if (program->Base.OutputsWritten & BITFIELD64_BIT(FRAG_RESULT_COLOR)) { span->interpMask &= ~SPAN_RGBA; span->arrayMask |= SPAN_RGBA; } - if (program->Base.OutputsWritten & (1 << FRAG_RESULT_DEPTH)) { + if (program->Base.OutputsWritten & BITFIELD64_BIT(FRAG_RESULT_DEPTH)) { span->interpMask &= ~SPAN_Z; span->arrayMask |= SPAN_Z; } diff --git a/src/mesa/tnl/t_context.c b/src/mesa/tnl/t_context.c index f2771cde09..db21b4589d 100644 --- a/src/mesa/tnl/t_context.c +++ b/src/mesa/tnl/t_context.c @@ -171,7 +171,7 @@ _tnl_InvalidateState( GLcontext *ctx, GLuint new_state ) if (vp) { GLuint i; for (i = 0; i < MAX_VARYING; i++) { - if (vp->Base.OutputsWritten & (1 << (VERT_RESULT_VAR0 + i))) { + if (vp->Base.OutputsWritten & BITFIELD64_BIT(VERT_RESULT_VAR0 + i)) { RENDERINPUTS_SET(tnl->render_inputs_bitset, _TNL_ATTRIB_GENERIC(i)); } diff --git a/src/mesa/tnl/t_vb_program.c b/src/mesa/tnl/t_vb_program.c index c10a27614f..e69f7d5766 100644 --- a/src/mesa/tnl/t_vb_program.c +++ b/src/mesa/tnl/t_vb_program.c @@ -329,7 +329,7 @@ run_vp( GLcontext *ctx, struct tnl_pipeline_stage *stage ) /* make list of outputs to save some time below */ numOutputs = 0; for (i = 0; i < VERT_RESULT_MAX; i++) { - if (program->Base.OutputsWritten & (1 << i)) { + if (program->Base.OutputsWritten & BITFIELD64_BIT(i)) { outputs[numOutputs++] = i; } } @@ -407,14 +407,14 @@ run_vp( GLcontext *ctx, struct tnl_pipeline_stage *stage ) /* Fixup fog and point size results if needed */ if (program->IsNVProgram) { if (ctx->Fog.Enabled && - (program->Base.OutputsWritten & (1 << VERT_RESULT_FOGC)) == 0) { + (program->Base.OutputsWritten & BITFIELD64_BIT(VERT_RESULT_FOGC)) == 0) { for (i = 0; i < VB->Count; i++) { store->results[VERT_RESULT_FOGC].data[i][0] = 1.0; } } if (ctx->VertexProgram.PointSizeEnabled && - (program->Base.OutputsWritten & (1 << VERT_RESULT_PSIZ)) == 0) { + (program->Base.OutputsWritten & BITFIELD64_BIT(VERT_RESULT_PSIZ)) == 0) { for (i = 0; i < VB->Count; i++) { store->results[VERT_RESULT_PSIZ].data[i][0] = ctx->Point.Size; } @@ -472,7 +472,7 @@ run_vp( GLcontext *ctx, struct tnl_pipeline_stage *stage ) } for (i = 0; i < ctx->Const.MaxVarying; i++) { - if (program->Base.OutputsWritten & (1 << (VERT_RESULT_VAR0 + i))) { + if (program->Base.OutputsWritten & BITFIELD64_BIT(VERT_RESULT_VAR0 + i)) { /* Note: varying results get put into the generic attributes */ VB->AttribPtr[VERT_ATTRIB_GENERIC0+i] = &store->results[VERT_RESULT_VAR0 + i]; -- cgit v1.2.3 From 639e7a140e430aa8839c652459eddc9a4b79f9c6 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 29 Dec 2009 09:06:00 -0700 Subject: ARB prog parser: use _mesa_add_unnamed_constant() to use fewer constant slots This function will search the constant parameters in an effort to re-use constant slots. For example, {1,2,3,4} and {4,1,1,2} can be stored in one constant slot and accessed with different swizzles. The swizzle info must be propogated though the parsing code in a few places. Fixes Piglit "vpfp-generic tests/shaders/generic/big-param.vpfp" failure. --- src/mesa/shader/program_parse.tab.c | 598 +++++++++++++++++++----------------- src/mesa/shader/program_parse.tab.h | 2 +- src/mesa/shader/program_parse.y | 66 +++- src/mesa/shader/program_parser.h | 6 + 4 files changed, 377 insertions(+), 295 deletions(-) (limited to 'src/mesa/shader/program_parse.y') diff --git a/src/mesa/shader/program_parse.tab.c b/src/mesa/shader/program_parse.tab.c index d4f8429488..a1e69b8450 100644 --- a/src/mesa/shader/program_parse.tab.c +++ b/src/mesa/shader/program_parse.tab.c @@ -145,6 +145,9 @@ static void init_src_reg(struct asm_src_register *r); static void set_src_reg(struct asm_src_register *r, gl_register_file file, GLint index); +static void set_src_reg_swz(struct asm_src_register *r, + gl_register_file file, GLint index, GLuint swizzle); + static void asm_instruction_set_operands(struct asm_instruction *inst, const struct prog_dst_register *dst, const struct asm_src_register *src0, const struct asm_src_register *src1, const struct asm_src_register *src2); @@ -185,7 +188,7 @@ static struct asm_instruction *asm_instruction_copy_ctor( /* Line 189 of yacc.c */ -#line 189 "program_parse.tab.c" +#line 192 "program_parse.tab.c" /* Enabling traces. */ #ifndef YYDEBUG @@ -327,7 +330,7 @@ typedef union YYSTYPE { /* Line 214 of yacc.c */ -#line 122 "program_parse.y" +#line 125 "program_parse.y" struct asm_instruction *inst; struct asm_symbol *sym; @@ -356,7 +359,7 @@ typedef union YYSTYPE /* Line 214 of yacc.c */ -#line 360 "program_parse.tab.c" +#line 363 "program_parse.tab.c" } YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ @@ -380,14 +383,14 @@ typedef struct YYLTYPE /* Copy the second part of user declarations. */ /* Line 264 of yacc.c */ -#line 267 "program_parse.y" +#line 270 "program_parse.y" extern int yylex(YYSTYPE *yylval_param, YYLTYPE *yylloc_param, void *yyscanner); /* Line 264 of yacc.c */ -#line 391 "program_parse.tab.c" +#line 394 "program_parse.tab.c" #ifdef short # undef short @@ -788,35 +791,35 @@ static const yytype_int16 yyrhs[] = /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { - 0, 274, 274, 277, 285, 297, 298, 301, 325, 326, - 329, 344, 347, 352, 359, 360, 361, 362, 363, 364, - 365, 368, 369, 370, 373, 379, 385, 391, 398, 404, - 411, 455, 460, 470, 514, 520, 521, 522, 523, 524, - 525, 526, 527, 528, 529, 530, 531, 534, 546, 554, - 571, 578, 595, 606, 626, 651, 658, 691, 698, 713, - 768, 809, 818, 839, 848, 852, 881, 900, 900, 902, - 909, 921, 922, 923, 926, 940, 954, 974, 985, 997, - 999, 1000, 1001, 1002, 1005, 1005, 1005, 1005, 1006, 1009, - 1013, 1018, 1025, 1032, 1039, 1062, 1085, 1086, 1087, 1088, - 1089, 1090, 1093, 1112, 1116, 1122, 1126, 1130, 1134, 1143, - 1152, 1156, 1161, 1167, 1178, 1178, 1179, 1181, 1185, 1189, - 1193, 1199, 1199, 1201, 1218, 1243, 1246, 1257, 1263, 1269, - 1270, 1277, 1283, 1289, 1297, 1303, 1309, 1317, 1323, 1329, - 1337, 1338, 1341, 1342, 1343, 1344, 1345, 1346, 1347, 1348, - 1349, 1350, 1351, 1354, 1363, 1367, 1371, 1377, 1386, 1390, - 1394, 1403, 1407, 1413, 1419, 1426, 1431, 1439, 1449, 1451, - 1459, 1465, 1469, 1473, 1479, 1490, 1499, 1503, 1508, 1512, - 1516, 1520, 1526, 1533, 1537, 1543, 1551, 1562, 1569, 1573, - 1579, 1589, 1600, 1604, 1622, 1631, 1634, 1640, 1644, 1648, - 1654, 1665, 1670, 1675, 1680, 1685, 1690, 1698, 1701, 1706, - 1719, 1727, 1738, 1746, 1746, 1748, 1748, 1750, 1760, 1765, - 1772, 1782, 1791, 1796, 1803, 1813, 1823, 1835, 1835, 1836, - 1836, 1838, 1848, 1856, 1866, 1874, 1882, 1891, 1902, 1906, - 1912, 1913, 1914, 1917, 1917, 1920, 1955, 1959, 1959, 1962, - 1969, 1978, 1992, 2001, 2010, 2014, 2023, 2032, 2043, 2050, - 2055, 2064, 2076, 2079, 2088, 2099, 2100, 2101, 2104, 2105, - 2106, 2109, 2110, 2113, 2114, 2117, 2118, 2121, 2132, 2143, - 2154, 2180, 2181 + 0, 277, 277, 280, 288, 300, 301, 304, 328, 329, + 332, 347, 350, 355, 362, 363, 364, 365, 366, 367, + 368, 371, 372, 373, 376, 382, 388, 394, 401, 407, + 414, 458, 463, 473, 517, 523, 524, 525, 526, 527, + 528, 529, 530, 531, 532, 533, 534, 537, 549, 557, + 574, 581, 600, 611, 631, 656, 663, 696, 703, 718, + 773, 816, 825, 846, 856, 860, 889, 908, 908, 910, + 917, 929, 930, 931, 934, 948, 962, 982, 993, 1005, + 1007, 1008, 1009, 1010, 1013, 1013, 1013, 1013, 1014, 1017, + 1021, 1026, 1033, 1040, 1047, 1070, 1093, 1094, 1095, 1096, + 1097, 1098, 1101, 1120, 1124, 1130, 1134, 1138, 1142, 1151, + 1160, 1164, 1169, 1175, 1186, 1186, 1187, 1189, 1193, 1197, + 1201, 1207, 1207, 1209, 1227, 1253, 1256, 1267, 1273, 1279, + 1280, 1287, 1293, 1299, 1307, 1313, 1319, 1327, 1333, 1339, + 1347, 1348, 1351, 1352, 1353, 1354, 1355, 1356, 1357, 1358, + 1359, 1360, 1361, 1364, 1373, 1377, 1381, 1387, 1396, 1400, + 1404, 1413, 1417, 1423, 1429, 1436, 1441, 1449, 1459, 1461, + 1469, 1475, 1479, 1483, 1489, 1500, 1509, 1513, 1518, 1522, + 1526, 1530, 1536, 1543, 1547, 1553, 1561, 1572, 1579, 1583, + 1589, 1599, 1610, 1614, 1632, 1641, 1644, 1650, 1654, 1658, + 1664, 1675, 1680, 1685, 1690, 1695, 1700, 1708, 1711, 1716, + 1729, 1737, 1748, 1756, 1756, 1758, 1758, 1760, 1770, 1775, + 1782, 1792, 1801, 1806, 1813, 1823, 1833, 1845, 1845, 1846, + 1846, 1848, 1858, 1866, 1876, 1884, 1892, 1901, 1912, 1916, + 1922, 1923, 1924, 1927, 1927, 1930, 1965, 1969, 1969, 1972, + 1979, 1988, 2002, 2011, 2020, 2024, 2033, 2042, 2053, 2060, + 2065, 2074, 2086, 2089, 2098, 2109, 2110, 2111, 2114, 2115, + 2116, 2119, 2120, 2123, 2124, 2127, 2128, 2131, 2142, 2153, + 2164, 2190, 2191 }; #endif @@ -2125,7 +2128,7 @@ yyreduce: case 3: /* Line 1455 of yacc.c */ -#line 278 "program_parse.y" +#line 281 "program_parse.y" { if (state->prog->Target != GL_VERTEX_PROGRAM_ARB) { yyerror(& (yylsp[(1) - (1)]), state, "invalid fragment program header"); @@ -2138,7 +2141,7 @@ yyreduce: case 4: /* Line 1455 of yacc.c */ -#line 286 "program_parse.y" +#line 289 "program_parse.y" { if (state->prog->Target != GL_FRAGMENT_PROGRAM_ARB) { yyerror(& (yylsp[(1) - (1)]), state, "invalid vertex program header"); @@ -2153,7 +2156,7 @@ yyreduce: case 7: /* Line 1455 of yacc.c */ -#line 302 "program_parse.y" +#line 305 "program_parse.y" { int valid = 0; @@ -2180,7 +2183,7 @@ yyreduce: case 10: /* Line 1455 of yacc.c */ -#line 330 "program_parse.y" +#line 333 "program_parse.y" { if ((yyvsp[(1) - (2)].inst) != NULL) { if (state->inst_tail == NULL) { @@ -2200,7 +2203,7 @@ yyreduce: case 12: /* Line 1455 of yacc.c */ -#line 348 "program_parse.y" +#line 351 "program_parse.y" { (yyval.inst) = (yyvsp[(1) - (1)].inst); state->prog->NumAluInstructions++; @@ -2210,7 +2213,7 @@ yyreduce: case 13: /* Line 1455 of yacc.c */ -#line 353 "program_parse.y" +#line 356 "program_parse.y" { (yyval.inst) = (yyvsp[(1) - (1)].inst); state->prog->NumTexInstructions++; @@ -2220,7 +2223,7 @@ yyreduce: case 24: /* Line 1455 of yacc.c */ -#line 374 "program_parse.y" +#line 377 "program_parse.y" { (yyval.inst) = asm_instruction_ctor(OPCODE_ARL, & (yyvsp[(2) - (4)].dst_reg), & (yyvsp[(4) - (4)].src_reg), NULL, NULL); ;} @@ -2229,7 +2232,7 @@ yyreduce: case 25: /* Line 1455 of yacc.c */ -#line 380 "program_parse.y" +#line 383 "program_parse.y" { (yyval.inst) = asm_instruction_copy_ctor(& (yyvsp[(1) - (4)].temp_inst), & (yyvsp[(2) - (4)].dst_reg), & (yyvsp[(4) - (4)].src_reg), NULL, NULL); ;} @@ -2238,7 +2241,7 @@ yyreduce: case 26: /* Line 1455 of yacc.c */ -#line 386 "program_parse.y" +#line 389 "program_parse.y" { (yyval.inst) = asm_instruction_copy_ctor(& (yyvsp[(1) - (4)].temp_inst), & (yyvsp[(2) - (4)].dst_reg), & (yyvsp[(4) - (4)].src_reg), NULL, NULL); ;} @@ -2247,7 +2250,7 @@ yyreduce: case 27: /* Line 1455 of yacc.c */ -#line 392 "program_parse.y" +#line 395 "program_parse.y" { (yyval.inst) = asm_instruction_copy_ctor(& (yyvsp[(1) - (6)].temp_inst), & (yyvsp[(2) - (6)].dst_reg), & (yyvsp[(4) - (6)].src_reg), & (yyvsp[(6) - (6)].src_reg), NULL); ;} @@ -2256,7 +2259,7 @@ yyreduce: case 28: /* Line 1455 of yacc.c */ -#line 399 "program_parse.y" +#line 402 "program_parse.y" { (yyval.inst) = asm_instruction_copy_ctor(& (yyvsp[(1) - (6)].temp_inst), & (yyvsp[(2) - (6)].dst_reg), & (yyvsp[(4) - (6)].src_reg), & (yyvsp[(6) - (6)].src_reg), NULL); ;} @@ -2265,7 +2268,7 @@ yyreduce: case 29: /* Line 1455 of yacc.c */ -#line 406 "program_parse.y" +#line 409 "program_parse.y" { (yyval.inst) = asm_instruction_copy_ctor(& (yyvsp[(1) - (8)].temp_inst), & (yyvsp[(2) - (8)].dst_reg), & (yyvsp[(4) - (8)].src_reg), & (yyvsp[(6) - (8)].src_reg), & (yyvsp[(8) - (8)].src_reg)); ;} @@ -2274,7 +2277,7 @@ yyreduce: case 30: /* Line 1455 of yacc.c */ -#line 412 "program_parse.y" +#line 415 "program_parse.y" { (yyval.inst) = asm_instruction_copy_ctor(& (yyvsp[(1) - (8)].temp_inst), & (yyvsp[(2) - (8)].dst_reg), & (yyvsp[(4) - (8)].src_reg), NULL, NULL); if ((yyval.inst) != NULL) { @@ -2321,7 +2324,7 @@ yyreduce: case 31: /* Line 1455 of yacc.c */ -#line 456 "program_parse.y" +#line 459 "program_parse.y" { (yyval.inst) = asm_instruction_ctor(OPCODE_KIL, NULL, & (yyvsp[(2) - (2)].src_reg), NULL, NULL); state->fragment.UsesKill = 1; @@ -2331,7 +2334,7 @@ yyreduce: case 32: /* Line 1455 of yacc.c */ -#line 461 "program_parse.y" +#line 464 "program_parse.y" { (yyval.inst) = asm_instruction_ctor(OPCODE_KIL_NV, NULL, NULL, NULL, NULL); (yyval.inst)->Base.DstReg.CondMask = (yyvsp[(2) - (2)].dst_reg).CondMask; @@ -2344,7 +2347,7 @@ yyreduce: case 33: /* Line 1455 of yacc.c */ -#line 471 "program_parse.y" +#line 474 "program_parse.y" { (yyval.inst) = asm_instruction_copy_ctor(& (yyvsp[(1) - (12)].temp_inst), & (yyvsp[(2) - (12)].dst_reg), & (yyvsp[(4) - (12)].src_reg), & (yyvsp[(6) - (12)].src_reg), & (yyvsp[(8) - (12)].src_reg)); if ((yyval.inst) != NULL) { @@ -2391,7 +2394,7 @@ yyreduce: case 34: /* Line 1455 of yacc.c */ -#line 515 "program_parse.y" +#line 518 "program_parse.y" { (yyval.integer) = (yyvsp[(2) - (2)].integer); ;} @@ -2400,91 +2403,91 @@ yyreduce: case 35: /* Line 1455 of yacc.c */ -#line 520 "program_parse.y" +#line 523 "program_parse.y" { (yyval.integer) = TEXTURE_1D_INDEX; ;} break; case 36: /* Line 1455 of yacc.c */ -#line 521 "program_parse.y" +#line 524 "program_parse.y" { (yyval.integer) = TEXTURE_2D_INDEX; ;} break; case 37: /* Line 1455 of yacc.c */ -#line 522 "program_parse.y" +#line 525 "program_parse.y" { (yyval.integer) = TEXTURE_3D_INDEX; ;} break; case 38: /* Line 1455 of yacc.c */ -#line 523 "program_parse.y" +#line 526 "program_parse.y" { (yyval.integer) = TEXTURE_CUBE_INDEX; ;} break; case 39: /* Line 1455 of yacc.c */ -#line 524 "program_parse.y" +#line 527 "program_parse.y" { (yyval.integer) = TEXTURE_RECT_INDEX; ;} break; case 40: /* Line 1455 of yacc.c */ -#line 525 "program_parse.y" +#line 528 "program_parse.y" { (yyval.integer) = -TEXTURE_1D_INDEX; ;} break; case 41: /* Line 1455 of yacc.c */ -#line 526 "program_parse.y" +#line 529 "program_parse.y" { (yyval.integer) = -TEXTURE_2D_INDEX; ;} break; case 42: /* Line 1455 of yacc.c */ -#line 527 "program_parse.y" +#line 530 "program_parse.y" { (yyval.integer) = -TEXTURE_RECT_INDEX; ;} break; case 43: /* Line 1455 of yacc.c */ -#line 528 "program_parse.y" +#line 531 "program_parse.y" { (yyval.integer) = TEXTURE_1D_ARRAY_INDEX; ;} break; case 44: /* Line 1455 of yacc.c */ -#line 529 "program_parse.y" +#line 532 "program_parse.y" { (yyval.integer) = TEXTURE_2D_ARRAY_INDEX; ;} break; case 45: /* Line 1455 of yacc.c */ -#line 530 "program_parse.y" +#line 533 "program_parse.y" { (yyval.integer) = -TEXTURE_1D_ARRAY_INDEX; ;} break; case 46: /* Line 1455 of yacc.c */ -#line 531 "program_parse.y" +#line 534 "program_parse.y" { (yyval.integer) = -TEXTURE_2D_ARRAY_INDEX; ;} break; case 47: /* Line 1455 of yacc.c */ -#line 535 "program_parse.y" +#line 538 "program_parse.y" { /* FIXME: Is this correct? Should the extenedSwizzle be applied * FIXME: to the existing swizzle? @@ -2499,7 +2502,7 @@ yyreduce: case 48: /* Line 1455 of yacc.c */ -#line 547 "program_parse.y" +#line 550 "program_parse.y" { (yyval.src_reg) = (yyvsp[(2) - (2)].src_reg); @@ -2512,7 +2515,7 @@ yyreduce: case 49: /* Line 1455 of yacc.c */ -#line 555 "program_parse.y" +#line 558 "program_parse.y" { (yyval.src_reg) = (yyvsp[(3) - (4)].src_reg); @@ -2532,7 +2535,7 @@ yyreduce: case 50: /* Line 1455 of yacc.c */ -#line 572 "program_parse.y" +#line 575 "program_parse.y" { (yyval.src_reg) = (yyvsp[(1) - (2)].src_reg); @@ -2544,7 +2547,7 @@ yyreduce: case 51: /* Line 1455 of yacc.c */ -#line 579 "program_parse.y" +#line 582 "program_parse.y" { struct asm_symbol temp_sym; @@ -2557,14 +2560,16 @@ yyreduce: temp_sym.param_binding_begin = ~0; initialize_symbol_from_const(state->prog, & temp_sym, & (yyvsp[(1) - (1)].vector)); - set_src_reg(& (yyval.src_reg), PROGRAM_CONSTANT, temp_sym.param_binding_begin); + set_src_reg_swz(& (yyval.src_reg), PROGRAM_CONSTANT, + temp_sym.param_binding_begin, + temp_sym.param_binding_swizzle); ;} break; case 52: /* Line 1455 of yacc.c */ -#line 596 "program_parse.y" +#line 601 "program_parse.y" { (yyval.src_reg) = (yyvsp[(2) - (3)].src_reg); @@ -2580,7 +2585,7 @@ yyreduce: case 53: /* Line 1455 of yacc.c */ -#line 607 "program_parse.y" +#line 612 "program_parse.y" { (yyval.src_reg) = (yyvsp[(3) - (5)].src_reg); @@ -2602,7 +2607,7 @@ yyreduce: case 54: /* Line 1455 of yacc.c */ -#line 627 "program_parse.y" +#line 632 "program_parse.y" { (yyval.dst_reg) = (yyvsp[(1) - (3)].dst_reg); (yyval.dst_reg).WriteMask = (yyvsp[(2) - (3)].swiz_mask).mask; @@ -2630,7 +2635,7 @@ yyreduce: case 55: /* Line 1455 of yacc.c */ -#line 652 "program_parse.y" +#line 657 "program_parse.y" { set_dst_reg(& (yyval.dst_reg), PROGRAM_ADDRESS, 0); (yyval.dst_reg).WriteMask = (yyvsp[(2) - (2)].swiz_mask).mask; @@ -2640,7 +2645,7 @@ yyreduce: case 56: /* Line 1455 of yacc.c */ -#line 659 "program_parse.y" +#line 664 "program_parse.y" { const unsigned xyzw_valid = ((yyvsp[(1) - (7)].ext_swizzle).xyzw_valid << 0) @@ -2676,7 +2681,7 @@ yyreduce: case 57: /* Line 1455 of yacc.c */ -#line 692 "program_parse.y" +#line 697 "program_parse.y" { (yyval.ext_swizzle) = (yyvsp[(2) - (2)].ext_swizzle); (yyval.ext_swizzle).negate = ((yyvsp[(1) - (2)].negate)) ? 1 : 0; @@ -2686,7 +2691,7 @@ yyreduce: case 58: /* Line 1455 of yacc.c */ -#line 699 "program_parse.y" +#line 704 "program_parse.y" { if (((yyvsp[(1) - (1)].integer) != 0) && ((yyvsp[(1) - (1)].integer) != 1)) { yyerror(& (yylsp[(1) - (1)]), state, "invalid extended swizzle selector"); @@ -2706,7 +2711,7 @@ yyreduce: case 59: /* Line 1455 of yacc.c */ -#line 714 "program_parse.y" +#line 719 "program_parse.y" { char s; @@ -2764,7 +2769,7 @@ yyreduce: case 60: /* Line 1455 of yacc.c */ -#line 769 "program_parse.y" +#line 774 "program_parse.y" { struct asm_symbol *const s = (struct asm_symbol *) _mesa_symbol_table_find_symbol(state->st, 0, (yyvsp[(1) - (1)].string)); @@ -2789,7 +2794,9 @@ yyreduce: set_src_reg(& (yyval.src_reg), PROGRAM_TEMPORARY, s->temp_binding); break; case at_param: - set_src_reg(& (yyval.src_reg), s->param_binding_type, s->param_binding_begin); + set_src_reg_swz(& (yyval.src_reg), s->param_binding_type, + s->param_binding_begin, + s->param_binding_swizzle); break; case at_attrib: set_src_reg(& (yyval.src_reg), PROGRAM_INPUT, s->attrib_binding); @@ -2810,7 +2817,7 @@ yyreduce: case 61: /* Line 1455 of yacc.c */ -#line 810 "program_parse.y" +#line 817 "program_parse.y" { set_src_reg(& (yyval.src_reg), PROGRAM_INPUT, (yyvsp[(1) - (1)].attrib)); state->prog->InputsRead |= (1U << (yyval.src_reg).Base.Index); @@ -2824,7 +2831,7 @@ yyreduce: case 62: /* Line 1455 of yacc.c */ -#line 819 "program_parse.y" +#line 826 "program_parse.y" { if (! (yyvsp[(3) - (4)].src_reg).Base.RelAddr && ((unsigned) (yyvsp[(3) - (4)].src_reg).Base.Index >= (yyvsp[(1) - (4)].sym)->param_binding_length)) { @@ -2850,19 +2857,20 @@ yyreduce: case 63: /* Line 1455 of yacc.c */ -#line 840 "program_parse.y" +#line 847 "program_parse.y" { gl_register_file file = ((yyvsp[(1) - (1)].temp_sym).name != NULL) ? (yyvsp[(1) - (1)].temp_sym).param_binding_type : PROGRAM_CONSTANT; - set_src_reg(& (yyval.src_reg), file, (yyvsp[(1) - (1)].temp_sym).param_binding_begin); + set_src_reg_swz(& (yyval.src_reg), file, (yyvsp[(1) - (1)].temp_sym).param_binding_begin, + (yyvsp[(1) - (1)].temp_sym).param_binding_swizzle); ;} break; case 64: /* Line 1455 of yacc.c */ -#line 849 "program_parse.y" +#line 857 "program_parse.y" { set_dst_reg(& (yyval.dst_reg), PROGRAM_OUTPUT, (yyvsp[(1) - (1)].result)); ;} @@ -2871,7 +2879,7 @@ yyreduce: case 65: /* Line 1455 of yacc.c */ -#line 853 "program_parse.y" +#line 861 "program_parse.y" { struct asm_symbol *const s = (struct asm_symbol *) _mesa_symbol_table_find_symbol(state->st, 0, (yyvsp[(1) - (1)].string)); @@ -2903,7 +2911,7 @@ yyreduce: case 66: /* Line 1455 of yacc.c */ -#line 882 "program_parse.y" +#line 890 "program_parse.y" { struct asm_symbol *const s = (struct asm_symbol *) _mesa_symbol_table_find_symbol(state->st, 0, (yyvsp[(1) - (1)].string)); @@ -2925,7 +2933,7 @@ yyreduce: case 69: /* Line 1455 of yacc.c */ -#line 903 "program_parse.y" +#line 911 "program_parse.y" { init_src_reg(& (yyval.src_reg)); (yyval.src_reg).Base.Index = (yyvsp[(1) - (1)].integer); @@ -2935,7 +2943,7 @@ yyreduce: case 70: /* Line 1455 of yacc.c */ -#line 910 "program_parse.y" +#line 918 "program_parse.y" { /* FINISHME: Add support for multiple address registers. */ @@ -2950,28 +2958,28 @@ yyreduce: case 71: /* Line 1455 of yacc.c */ -#line 921 "program_parse.y" +#line 929 "program_parse.y" { (yyval.integer) = 0; ;} break; case 72: /* Line 1455 of yacc.c */ -#line 922 "program_parse.y" +#line 930 "program_parse.y" { (yyval.integer) = (yyvsp[(2) - (2)].integer); ;} break; case 73: /* Line 1455 of yacc.c */ -#line 923 "program_parse.y" +#line 931 "program_parse.y" { (yyval.integer) = -(yyvsp[(2) - (2)].integer); ;} break; case 74: /* Line 1455 of yacc.c */ -#line 927 "program_parse.y" +#line 935 "program_parse.y" { if (((yyvsp[(1) - (1)].integer) < 0) || ((yyvsp[(1) - (1)].integer) > 63)) { char s[100]; @@ -2988,7 +2996,7 @@ yyreduce: case 75: /* Line 1455 of yacc.c */ -#line 941 "program_parse.y" +#line 949 "program_parse.y" { if (((yyvsp[(1) - (1)].integer) < 0) || ((yyvsp[(1) - (1)].integer) > 64)) { char s[100]; @@ -3005,7 +3013,7 @@ yyreduce: case 76: /* Line 1455 of yacc.c */ -#line 955 "program_parse.y" +#line 963 "program_parse.y" { struct asm_symbol *const s = (struct asm_symbol *) _mesa_symbol_table_find_symbol(state->st, 0, (yyvsp[(1) - (1)].string)); @@ -3028,7 +3036,7 @@ yyreduce: case 77: /* Line 1455 of yacc.c */ -#line 975 "program_parse.y" +#line 983 "program_parse.y" { if ((yyvsp[(1) - (1)].swiz_mask).mask != WRITEMASK_X) { yyerror(& (yylsp[(1) - (1)]), state, "invalid address component selector"); @@ -3042,7 +3050,7 @@ yyreduce: case 78: /* Line 1455 of yacc.c */ -#line 986 "program_parse.y" +#line 994 "program_parse.y" { if ((yyvsp[(1) - (1)].swiz_mask).mask != WRITEMASK_X) { yyerror(& (yylsp[(1) - (1)]), state, @@ -3057,21 +3065,21 @@ yyreduce: case 83: /* Line 1455 of yacc.c */ -#line 1002 "program_parse.y" +#line 1010 "program_parse.y" { (yyval.swiz_mask).swizzle = SWIZZLE_NOOP; (yyval.swiz_mask).mask = WRITEMASK_XYZW; ;} break; case 88: /* Line 1455 of yacc.c */ -#line 1006 "program_parse.y" +#line 1014 "program_parse.y" { (yyval.swiz_mask).swizzle = SWIZZLE_NOOP; (yyval.swiz_mask).mask = WRITEMASK_XYZW; ;} break; case 89: /* Line 1455 of yacc.c */ -#line 1010 "program_parse.y" +#line 1018 "program_parse.y" { (yyval.dst_reg) = (yyvsp[(2) - (3)].dst_reg); ;} @@ -3080,7 +3088,7 @@ yyreduce: case 90: /* Line 1455 of yacc.c */ -#line 1014 "program_parse.y" +#line 1022 "program_parse.y" { (yyval.dst_reg) = (yyvsp[(2) - (3)].dst_reg); ;} @@ -3089,7 +3097,7 @@ yyreduce: case 91: /* Line 1455 of yacc.c */ -#line 1018 "program_parse.y" +#line 1026 "program_parse.y" { (yyval.dst_reg).CondMask = COND_TR; (yyval.dst_reg).CondSwizzle = SWIZZLE_NOOP; @@ -3100,7 +3108,7 @@ yyreduce: case 92: /* Line 1455 of yacc.c */ -#line 1026 "program_parse.y" +#line 1034 "program_parse.y" { (yyval.dst_reg) = (yyvsp[(1) - (2)].dst_reg); (yyval.dst_reg).CondSwizzle = (yyvsp[(2) - (2)].swiz_mask).swizzle; @@ -3110,7 +3118,7 @@ yyreduce: case 93: /* Line 1455 of yacc.c */ -#line 1033 "program_parse.y" +#line 1041 "program_parse.y" { (yyval.dst_reg) = (yyvsp[(1) - (2)].dst_reg); (yyval.dst_reg).CondSwizzle = (yyvsp[(2) - (2)].swiz_mask).swizzle; @@ -3120,7 +3128,7 @@ yyreduce: case 94: /* Line 1455 of yacc.c */ -#line 1040 "program_parse.y" +#line 1048 "program_parse.y" { const int cond = _mesa_parse_cc((yyvsp[(1) - (1)].string)); if ((cond == 0) || ((yyvsp[(1) - (1)].string)[2] != '\0')) { @@ -3146,7 +3154,7 @@ yyreduce: case 95: /* Line 1455 of yacc.c */ -#line 1063 "program_parse.y" +#line 1071 "program_parse.y" { const int cond = _mesa_parse_cc((yyvsp[(1) - (1)].string)); if ((cond == 0) || ((yyvsp[(1) - (1)].string)[2] != '\0')) { @@ -3172,7 +3180,7 @@ yyreduce: case 102: /* Line 1455 of yacc.c */ -#line 1094 "program_parse.y" +#line 1102 "program_parse.y" { struct asm_symbol *const s = declare_variable(state, (yyvsp[(2) - (4)].string), at_attrib, & (yylsp[(2) - (4)])); @@ -3194,7 +3202,7 @@ yyreduce: case 103: /* Line 1455 of yacc.c */ -#line 1113 "program_parse.y" +#line 1121 "program_parse.y" { (yyval.attrib) = (yyvsp[(2) - (2)].attrib); ;} @@ -3203,7 +3211,7 @@ yyreduce: case 104: /* Line 1455 of yacc.c */ -#line 1117 "program_parse.y" +#line 1125 "program_parse.y" { (yyval.attrib) = (yyvsp[(2) - (2)].attrib); ;} @@ -3212,7 +3220,7 @@ yyreduce: case 105: /* Line 1455 of yacc.c */ -#line 1123 "program_parse.y" +#line 1131 "program_parse.y" { (yyval.attrib) = VERT_ATTRIB_POS; ;} @@ -3221,7 +3229,7 @@ yyreduce: case 106: /* Line 1455 of yacc.c */ -#line 1127 "program_parse.y" +#line 1135 "program_parse.y" { (yyval.attrib) = VERT_ATTRIB_WEIGHT; ;} @@ -3230,7 +3238,7 @@ yyreduce: case 107: /* Line 1455 of yacc.c */ -#line 1131 "program_parse.y" +#line 1139 "program_parse.y" { (yyval.attrib) = VERT_ATTRIB_NORMAL; ;} @@ -3239,7 +3247,7 @@ yyreduce: case 108: /* Line 1455 of yacc.c */ -#line 1135 "program_parse.y" +#line 1143 "program_parse.y" { if (!state->ctx->Extensions.EXT_secondary_color) { yyerror(& (yylsp[(2) - (2)]), state, "GL_EXT_secondary_color not supported"); @@ -3253,7 +3261,7 @@ yyreduce: case 109: /* Line 1455 of yacc.c */ -#line 1144 "program_parse.y" +#line 1152 "program_parse.y" { if (!state->ctx->Extensions.EXT_fog_coord) { yyerror(& (yylsp[(1) - (1)]), state, "GL_EXT_fog_coord not supported"); @@ -3267,7 +3275,7 @@ yyreduce: case 110: /* Line 1455 of yacc.c */ -#line 1153 "program_parse.y" +#line 1161 "program_parse.y" { (yyval.attrib) = VERT_ATTRIB_TEX0 + (yyvsp[(2) - (2)].integer); ;} @@ -3276,7 +3284,7 @@ yyreduce: case 111: /* Line 1455 of yacc.c */ -#line 1157 "program_parse.y" +#line 1165 "program_parse.y" { yyerror(& (yylsp[(1) - (4)]), state, "GL_ARB_matrix_palette not supported"); YYERROR; @@ -3286,7 +3294,7 @@ yyreduce: case 112: /* Line 1455 of yacc.c */ -#line 1162 "program_parse.y" +#line 1170 "program_parse.y" { (yyval.attrib) = VERT_ATTRIB_GENERIC0 + (yyvsp[(3) - (4)].integer); ;} @@ -3295,7 +3303,7 @@ yyreduce: case 113: /* Line 1455 of yacc.c */ -#line 1168 "program_parse.y" +#line 1176 "program_parse.y" { if ((unsigned) (yyvsp[(1) - (1)].integer) >= state->limits->MaxAttribs) { yyerror(& (yylsp[(1) - (1)]), state, "invalid vertex attribute reference"); @@ -3309,7 +3317,7 @@ yyreduce: case 117: /* Line 1455 of yacc.c */ -#line 1182 "program_parse.y" +#line 1190 "program_parse.y" { (yyval.attrib) = FRAG_ATTRIB_WPOS; ;} @@ -3318,7 +3326,7 @@ yyreduce: case 118: /* Line 1455 of yacc.c */ -#line 1186 "program_parse.y" +#line 1194 "program_parse.y" { (yyval.attrib) = FRAG_ATTRIB_COL0 + (yyvsp[(2) - (2)].integer); ;} @@ -3327,7 +3335,7 @@ yyreduce: case 119: /* Line 1455 of yacc.c */ -#line 1190 "program_parse.y" +#line 1198 "program_parse.y" { (yyval.attrib) = FRAG_ATTRIB_FOGC; ;} @@ -3336,7 +3344,7 @@ yyreduce: case 120: /* Line 1455 of yacc.c */ -#line 1194 "program_parse.y" +#line 1202 "program_parse.y" { (yyval.attrib) = FRAG_ATTRIB_TEX0 + (yyvsp[(2) - (2)].integer); ;} @@ -3345,7 +3353,7 @@ yyreduce: case 123: /* Line 1455 of yacc.c */ -#line 1202 "program_parse.y" +#line 1210 "program_parse.y" { struct asm_symbol *const s = declare_variable(state, (yyvsp[(2) - (3)].string), at_param, & (yylsp[(2) - (3)])); @@ -3357,6 +3365,7 @@ yyreduce: s->param_binding_type = (yyvsp[(3) - (3)].temp_sym).param_binding_type; s->param_binding_begin = (yyvsp[(3) - (3)].temp_sym).param_binding_begin; s->param_binding_length = (yyvsp[(3) - (3)].temp_sym).param_binding_length; + s->param_binding_swizzle = SWIZZLE_XYZW; s->param_is_array = 0; } ;} @@ -3365,7 +3374,7 @@ yyreduce: case 124: /* Line 1455 of yacc.c */ -#line 1219 "program_parse.y" +#line 1228 "program_parse.y" { if (((yyvsp[(4) - (6)].integer) != 0) && ((unsigned) (yyvsp[(4) - (6)].integer) != (yyvsp[(6) - (6)].temp_sym).param_binding_length)) { free((yyvsp[(2) - (6)].string)); @@ -3383,6 +3392,7 @@ yyreduce: s->param_binding_type = (yyvsp[(6) - (6)].temp_sym).param_binding_type; s->param_binding_begin = (yyvsp[(6) - (6)].temp_sym).param_binding_begin; s->param_binding_length = (yyvsp[(6) - (6)].temp_sym).param_binding_length; + s->param_binding_swizzle = SWIZZLE_XYZW; s->param_is_array = 1; } } @@ -3392,7 +3402,7 @@ yyreduce: case 125: /* Line 1455 of yacc.c */ -#line 1243 "program_parse.y" +#line 1253 "program_parse.y" { (yyval.integer) = 0; ;} @@ -3401,7 +3411,7 @@ yyreduce: case 126: /* Line 1455 of yacc.c */ -#line 1247 "program_parse.y" +#line 1257 "program_parse.y" { if (((yyvsp[(1) - (1)].integer) < 1) || ((unsigned) (yyvsp[(1) - (1)].integer) > state->limits->MaxParameters)) { yyerror(& (yylsp[(1) - (1)]), state, "invalid parameter array size"); @@ -3415,7 +3425,7 @@ yyreduce: case 127: /* Line 1455 of yacc.c */ -#line 1258 "program_parse.y" +#line 1268 "program_parse.y" { (yyval.temp_sym) = (yyvsp[(2) - (2)].temp_sym); ;} @@ -3424,7 +3434,7 @@ yyreduce: case 128: /* Line 1455 of yacc.c */ -#line 1264 "program_parse.y" +#line 1274 "program_parse.y" { (yyval.temp_sym) = (yyvsp[(3) - (4)].temp_sym); ;} @@ -3433,7 +3443,7 @@ yyreduce: case 130: /* Line 1455 of yacc.c */ -#line 1271 "program_parse.y" +#line 1281 "program_parse.y" { (yyvsp[(1) - (3)].temp_sym).param_binding_length += (yyvsp[(3) - (3)].temp_sym).param_binding_length; (yyval.temp_sym) = (yyvsp[(1) - (3)].temp_sym); @@ -3443,7 +3453,7 @@ yyreduce: case 131: /* Line 1455 of yacc.c */ -#line 1278 "program_parse.y" +#line 1288 "program_parse.y" { memset(& (yyval.temp_sym), 0, sizeof((yyval.temp_sym))); (yyval.temp_sym).param_binding_begin = ~0; @@ -3454,7 +3464,7 @@ yyreduce: case 132: /* Line 1455 of yacc.c */ -#line 1284 "program_parse.y" +#line 1294 "program_parse.y" { memset(& (yyval.temp_sym), 0, sizeof((yyval.temp_sym))); (yyval.temp_sym).param_binding_begin = ~0; @@ -3465,7 +3475,7 @@ yyreduce: case 133: /* Line 1455 of yacc.c */ -#line 1290 "program_parse.y" +#line 1300 "program_parse.y" { memset(& (yyval.temp_sym), 0, sizeof((yyval.temp_sym))); (yyval.temp_sym).param_binding_begin = ~0; @@ -3476,7 +3486,7 @@ yyreduce: case 134: /* Line 1455 of yacc.c */ -#line 1298 "program_parse.y" +#line 1308 "program_parse.y" { memset(& (yyval.temp_sym), 0, sizeof((yyval.temp_sym))); (yyval.temp_sym).param_binding_begin = ~0; @@ -3487,7 +3497,7 @@ yyreduce: case 135: /* Line 1455 of yacc.c */ -#line 1304 "program_parse.y" +#line 1314 "program_parse.y" { memset(& (yyval.temp_sym), 0, sizeof((yyval.temp_sym))); (yyval.temp_sym).param_binding_begin = ~0; @@ -3498,7 +3508,7 @@ yyreduce: case 136: /* Line 1455 of yacc.c */ -#line 1310 "program_parse.y" +#line 1320 "program_parse.y" { memset(& (yyval.temp_sym), 0, sizeof((yyval.temp_sym))); (yyval.temp_sym).param_binding_begin = ~0; @@ -3509,7 +3519,7 @@ yyreduce: case 137: /* Line 1455 of yacc.c */ -#line 1318 "program_parse.y" +#line 1328 "program_parse.y" { memset(& (yyval.temp_sym), 0, sizeof((yyval.temp_sym))); (yyval.temp_sym).param_binding_begin = ~0; @@ -3520,7 +3530,7 @@ yyreduce: case 138: /* Line 1455 of yacc.c */ -#line 1324 "program_parse.y" +#line 1334 "program_parse.y" { memset(& (yyval.temp_sym), 0, sizeof((yyval.temp_sym))); (yyval.temp_sym).param_binding_begin = ~0; @@ -3531,7 +3541,7 @@ yyreduce: case 139: /* Line 1455 of yacc.c */ -#line 1330 "program_parse.y" +#line 1340 "program_parse.y" { memset(& (yyval.temp_sym), 0, sizeof((yyval.temp_sym))); (yyval.temp_sym).param_binding_begin = ~0; @@ -3542,98 +3552,98 @@ yyreduce: case 140: /* Line 1455 of yacc.c */ -#line 1337 "program_parse.y" +#line 1347 "program_parse.y" { memcpy((yyval.state), (yyvsp[(1) - (1)].state), sizeof((yyval.state))); ;} break; case 141: /* Line 1455 of yacc.c */ -#line 1338 "program_parse.y" +#line 1348 "program_parse.y" { memcpy((yyval.state), (yyvsp[(2) - (2)].state), sizeof((yyval.state))); ;} break; case 142: /* Line 1455 of yacc.c */ -#line 1341 "program_parse.y" +#line 1351 "program_parse.y" { memcpy((yyval.state), (yyvsp[(2) - (2)].state), sizeof((yyval.state))); ;} break; case 143: /* Line 1455 of yacc.c */ -#line 1342 "program_parse.y" +#line 1352 "program_parse.y" { memcpy((yyval.state), (yyvsp[(2) - (2)].state), sizeof((yyval.state))); ;} break; case 144: /* Line 1455 of yacc.c */ -#line 1343 "program_parse.y" +#line 1353 "program_parse.y" { memcpy((yyval.state), (yyvsp[(2) - (2)].state), sizeof((yyval.state))); ;} break; case 145: /* Line 1455 of yacc.c */ -#line 1344 "program_parse.y" +#line 1354 "program_parse.y" { memcpy((yyval.state), (yyvsp[(2) - (2)].state), sizeof((yyval.state))); ;} break; case 146: /* Line 1455 of yacc.c */ -#line 1345 "program_parse.y" +#line 1355 "program_parse.y" { memcpy((yyval.state), (yyvsp[(2) - (2)].state), sizeof((yyval.state))); ;} break; case 147: /* Line 1455 of yacc.c */ -#line 1346 "program_parse.y" +#line 1356 "program_parse.y" { memcpy((yyval.state), (yyvsp[(2) - (2)].state), sizeof((yyval.state))); ;} break; case 148: /* Line 1455 of yacc.c */ -#line 1347 "program_parse.y" +#line 1357 "program_parse.y" { memcpy((yyval.state), (yyvsp[(2) - (2)].state), sizeof((yyval.state))); ;} break; case 149: /* Line 1455 of yacc.c */ -#line 1348 "program_parse.y" +#line 1358 "program_parse.y" { memcpy((yyval.state), (yyvsp[(2) - (2)].state), sizeof((yyval.state))); ;} break; case 150: /* Line 1455 of yacc.c */ -#line 1349 "program_parse.y" +#line 1359 "program_parse.y" { memcpy((yyval.state), (yyvsp[(2) - (2)].state), sizeof((yyval.state))); ;} break; case 151: /* Line 1455 of yacc.c */ -#line 1350 "program_parse.y" +#line 1360 "program_parse.y" { memcpy((yyval.state), (yyvsp[(2) - (2)].state), sizeof((yyval.state))); ;} break; case 152: /* Line 1455 of yacc.c */ -#line 1351 "program_parse.y" +#line 1361 "program_parse.y" { memcpy((yyval.state), (yyvsp[(2) - (2)].state), sizeof((yyval.state))); ;} break; case 153: /* Line 1455 of yacc.c */ -#line 1355 "program_parse.y" +#line 1365 "program_parse.y" { memset((yyval.state), 0, sizeof((yyval.state))); (yyval.state)[0] = STATE_MATERIAL; @@ -3645,7 +3655,7 @@ yyreduce: case 154: /* Line 1455 of yacc.c */ -#line 1364 "program_parse.y" +#line 1374 "program_parse.y" { (yyval.integer) = (yyvsp[(1) - (1)].integer); ;} @@ -3654,7 +3664,7 @@ yyreduce: case 155: /* Line 1455 of yacc.c */ -#line 1368 "program_parse.y" +#line 1378 "program_parse.y" { (yyval.integer) = STATE_EMISSION; ;} @@ -3663,7 +3673,7 @@ yyreduce: case 156: /* Line 1455 of yacc.c */ -#line 1372 "program_parse.y" +#line 1382 "program_parse.y" { (yyval.integer) = STATE_SHININESS; ;} @@ -3672,7 +3682,7 @@ yyreduce: case 157: /* Line 1455 of yacc.c */ -#line 1378 "program_parse.y" +#line 1388 "program_parse.y" { memset((yyval.state), 0, sizeof((yyval.state))); (yyval.state)[0] = STATE_LIGHT; @@ -3684,7 +3694,7 @@ yyreduce: case 158: /* Line 1455 of yacc.c */ -#line 1387 "program_parse.y" +#line 1397 "program_parse.y" { (yyval.integer) = (yyvsp[(1) - (1)].integer); ;} @@ -3693,7 +3703,7 @@ yyreduce: case 159: /* Line 1455 of yacc.c */ -#line 1391 "program_parse.y" +#line 1401 "program_parse.y" { (yyval.integer) = STATE_POSITION; ;} @@ -3702,7 +3712,7 @@ yyreduce: case 160: /* Line 1455 of yacc.c */ -#line 1395 "program_parse.y" +#line 1405 "program_parse.y" { if (!state->ctx->Extensions.EXT_point_parameters) { yyerror(& (yylsp[(1) - (1)]), state, "GL_ARB_point_parameters not supported"); @@ -3716,7 +3726,7 @@ yyreduce: case 161: /* Line 1455 of yacc.c */ -#line 1404 "program_parse.y" +#line 1414 "program_parse.y" { (yyval.integer) = (yyvsp[(2) - (2)].integer); ;} @@ -3725,7 +3735,7 @@ yyreduce: case 162: /* Line 1455 of yacc.c */ -#line 1408 "program_parse.y" +#line 1418 "program_parse.y" { (yyval.integer) = STATE_HALF_VECTOR; ;} @@ -3734,7 +3744,7 @@ yyreduce: case 163: /* Line 1455 of yacc.c */ -#line 1414 "program_parse.y" +#line 1424 "program_parse.y" { (yyval.integer) = STATE_SPOT_DIRECTION; ;} @@ -3743,7 +3753,7 @@ yyreduce: case 164: /* Line 1455 of yacc.c */ -#line 1420 "program_parse.y" +#line 1430 "program_parse.y" { (yyval.state)[0] = (yyvsp[(2) - (2)].state)[0]; (yyval.state)[1] = (yyvsp[(2) - (2)].state)[1]; @@ -3753,7 +3763,7 @@ yyreduce: case 165: /* Line 1455 of yacc.c */ -#line 1427 "program_parse.y" +#line 1437 "program_parse.y" { memset((yyval.state), 0, sizeof((yyval.state))); (yyval.state)[0] = STATE_LIGHTMODEL_AMBIENT; @@ -3763,7 +3773,7 @@ yyreduce: case 166: /* Line 1455 of yacc.c */ -#line 1432 "program_parse.y" +#line 1442 "program_parse.y" { memset((yyval.state), 0, sizeof((yyval.state))); (yyval.state)[0] = STATE_LIGHTMODEL_SCENECOLOR; @@ -3774,7 +3784,7 @@ yyreduce: case 167: /* Line 1455 of yacc.c */ -#line 1440 "program_parse.y" +#line 1450 "program_parse.y" { memset((yyval.state), 0, sizeof((yyval.state))); (yyval.state)[0] = STATE_LIGHTPROD; @@ -3787,7 +3797,7 @@ yyreduce: case 169: /* Line 1455 of yacc.c */ -#line 1452 "program_parse.y" +#line 1462 "program_parse.y" { memset((yyval.state), 0, sizeof((yyval.state))); (yyval.state)[0] = (yyvsp[(3) - (3)].integer); @@ -3798,7 +3808,7 @@ yyreduce: case 170: /* Line 1455 of yacc.c */ -#line 1460 "program_parse.y" +#line 1470 "program_parse.y" { (yyval.integer) = STATE_TEXENV_COLOR; ;} @@ -3807,7 +3817,7 @@ yyreduce: case 171: /* Line 1455 of yacc.c */ -#line 1466 "program_parse.y" +#line 1476 "program_parse.y" { (yyval.integer) = STATE_AMBIENT; ;} @@ -3816,7 +3826,7 @@ yyreduce: case 172: /* Line 1455 of yacc.c */ -#line 1470 "program_parse.y" +#line 1480 "program_parse.y" { (yyval.integer) = STATE_DIFFUSE; ;} @@ -3825,7 +3835,7 @@ yyreduce: case 173: /* Line 1455 of yacc.c */ -#line 1474 "program_parse.y" +#line 1484 "program_parse.y" { (yyval.integer) = STATE_SPECULAR; ;} @@ -3834,7 +3844,7 @@ yyreduce: case 174: /* Line 1455 of yacc.c */ -#line 1480 "program_parse.y" +#line 1490 "program_parse.y" { if ((unsigned) (yyvsp[(1) - (1)].integer) >= state->MaxLights) { yyerror(& (yylsp[(1) - (1)]), state, "invalid light selector"); @@ -3848,7 +3858,7 @@ yyreduce: case 175: /* Line 1455 of yacc.c */ -#line 1491 "program_parse.y" +#line 1501 "program_parse.y" { memset((yyval.state), 0, sizeof((yyval.state))); (yyval.state)[0] = STATE_TEXGEN; @@ -3860,7 +3870,7 @@ yyreduce: case 176: /* Line 1455 of yacc.c */ -#line 1500 "program_parse.y" +#line 1510 "program_parse.y" { (yyval.integer) = STATE_TEXGEN_EYE_S; ;} @@ -3869,7 +3879,7 @@ yyreduce: case 177: /* Line 1455 of yacc.c */ -#line 1504 "program_parse.y" +#line 1514 "program_parse.y" { (yyval.integer) = STATE_TEXGEN_OBJECT_S; ;} @@ -3878,7 +3888,7 @@ yyreduce: case 178: /* Line 1455 of yacc.c */ -#line 1509 "program_parse.y" +#line 1519 "program_parse.y" { (yyval.integer) = STATE_TEXGEN_EYE_S - STATE_TEXGEN_EYE_S; ;} @@ -3887,7 +3897,7 @@ yyreduce: case 179: /* Line 1455 of yacc.c */ -#line 1513 "program_parse.y" +#line 1523 "program_parse.y" { (yyval.integer) = STATE_TEXGEN_EYE_T - STATE_TEXGEN_EYE_S; ;} @@ -3896,7 +3906,7 @@ yyreduce: case 180: /* Line 1455 of yacc.c */ -#line 1517 "program_parse.y" +#line 1527 "program_parse.y" { (yyval.integer) = STATE_TEXGEN_EYE_R - STATE_TEXGEN_EYE_S; ;} @@ -3905,7 +3915,7 @@ yyreduce: case 181: /* Line 1455 of yacc.c */ -#line 1521 "program_parse.y" +#line 1531 "program_parse.y" { (yyval.integer) = STATE_TEXGEN_EYE_Q - STATE_TEXGEN_EYE_S; ;} @@ -3914,7 +3924,7 @@ yyreduce: case 182: /* Line 1455 of yacc.c */ -#line 1527 "program_parse.y" +#line 1537 "program_parse.y" { memset((yyval.state), 0, sizeof((yyval.state))); (yyval.state)[0] = (yyvsp[(2) - (2)].integer); @@ -3924,7 +3934,7 @@ yyreduce: case 183: /* Line 1455 of yacc.c */ -#line 1534 "program_parse.y" +#line 1544 "program_parse.y" { (yyval.integer) = STATE_FOG_COLOR; ;} @@ -3933,7 +3943,7 @@ yyreduce: case 184: /* Line 1455 of yacc.c */ -#line 1538 "program_parse.y" +#line 1548 "program_parse.y" { (yyval.integer) = STATE_FOG_PARAMS; ;} @@ -3942,7 +3952,7 @@ yyreduce: case 185: /* Line 1455 of yacc.c */ -#line 1544 "program_parse.y" +#line 1554 "program_parse.y" { memset((yyval.state), 0, sizeof((yyval.state))); (yyval.state)[0] = STATE_CLIPPLANE; @@ -3953,7 +3963,7 @@ yyreduce: case 186: /* Line 1455 of yacc.c */ -#line 1552 "program_parse.y" +#line 1562 "program_parse.y" { if ((unsigned) (yyvsp[(1) - (1)].integer) >= state->MaxClipPlanes) { yyerror(& (yylsp[(1) - (1)]), state, "invalid clip plane selector"); @@ -3967,7 +3977,7 @@ yyreduce: case 187: /* Line 1455 of yacc.c */ -#line 1563 "program_parse.y" +#line 1573 "program_parse.y" { memset((yyval.state), 0, sizeof((yyval.state))); (yyval.state)[0] = (yyvsp[(2) - (2)].integer); @@ -3977,7 +3987,7 @@ yyreduce: case 188: /* Line 1455 of yacc.c */ -#line 1570 "program_parse.y" +#line 1580 "program_parse.y" { (yyval.integer) = STATE_POINT_SIZE; ;} @@ -3986,7 +3996,7 @@ yyreduce: case 189: /* Line 1455 of yacc.c */ -#line 1574 "program_parse.y" +#line 1584 "program_parse.y" { (yyval.integer) = STATE_POINT_ATTENUATION; ;} @@ -3995,7 +4005,7 @@ yyreduce: case 190: /* Line 1455 of yacc.c */ -#line 1580 "program_parse.y" +#line 1590 "program_parse.y" { (yyval.state)[0] = (yyvsp[(1) - (5)].state)[0]; (yyval.state)[1] = (yyvsp[(1) - (5)].state)[1]; @@ -4008,7 +4018,7 @@ yyreduce: case 191: /* Line 1455 of yacc.c */ -#line 1590 "program_parse.y" +#line 1600 "program_parse.y" { (yyval.state)[0] = (yyvsp[(1) - (2)].state)[0]; (yyval.state)[1] = (yyvsp[(1) - (2)].state)[1]; @@ -4021,7 +4031,7 @@ yyreduce: case 192: /* Line 1455 of yacc.c */ -#line 1600 "program_parse.y" +#line 1610 "program_parse.y" { (yyval.state)[2] = 0; (yyval.state)[3] = 3; @@ -4031,7 +4041,7 @@ yyreduce: case 193: /* Line 1455 of yacc.c */ -#line 1605 "program_parse.y" +#line 1615 "program_parse.y" { /* It seems logical that the matrix row range specifier would have * to specify a range or more than one row (i.e., $5 > $3). @@ -4052,7 +4062,7 @@ yyreduce: case 194: /* Line 1455 of yacc.c */ -#line 1623 "program_parse.y" +#line 1633 "program_parse.y" { (yyval.state)[0] = (yyvsp[(2) - (3)].state)[0]; (yyval.state)[1] = (yyvsp[(2) - (3)].state)[1]; @@ -4063,7 +4073,7 @@ yyreduce: case 195: /* Line 1455 of yacc.c */ -#line 1631 "program_parse.y" +#line 1641 "program_parse.y" { (yyval.integer) = 0; ;} @@ -4072,7 +4082,7 @@ yyreduce: case 196: /* Line 1455 of yacc.c */ -#line 1635 "program_parse.y" +#line 1645 "program_parse.y" { (yyval.integer) = (yyvsp[(1) - (1)].integer); ;} @@ -4081,7 +4091,7 @@ yyreduce: case 197: /* Line 1455 of yacc.c */ -#line 1641 "program_parse.y" +#line 1651 "program_parse.y" { (yyval.integer) = STATE_MATRIX_INVERSE; ;} @@ -4090,7 +4100,7 @@ yyreduce: case 198: /* Line 1455 of yacc.c */ -#line 1645 "program_parse.y" +#line 1655 "program_parse.y" { (yyval.integer) = STATE_MATRIX_TRANSPOSE; ;} @@ -4099,7 +4109,7 @@ yyreduce: case 199: /* Line 1455 of yacc.c */ -#line 1649 "program_parse.y" +#line 1659 "program_parse.y" { (yyval.integer) = STATE_MATRIX_INVTRANS; ;} @@ -4108,7 +4118,7 @@ yyreduce: case 200: /* Line 1455 of yacc.c */ -#line 1655 "program_parse.y" +#line 1665 "program_parse.y" { if ((yyvsp[(1) - (1)].integer) > 3) { yyerror(& (yylsp[(1) - (1)]), state, "invalid matrix row reference"); @@ -4122,7 +4132,7 @@ yyreduce: case 201: /* Line 1455 of yacc.c */ -#line 1666 "program_parse.y" +#line 1676 "program_parse.y" { (yyval.state)[0] = STATE_MODELVIEW_MATRIX; (yyval.state)[1] = (yyvsp[(2) - (2)].integer); @@ -4132,7 +4142,7 @@ yyreduce: case 202: /* Line 1455 of yacc.c */ -#line 1671 "program_parse.y" +#line 1681 "program_parse.y" { (yyval.state)[0] = STATE_PROJECTION_MATRIX; (yyval.state)[1] = 0; @@ -4142,7 +4152,7 @@ yyreduce: case 203: /* Line 1455 of yacc.c */ -#line 1676 "program_parse.y" +#line 1686 "program_parse.y" { (yyval.state)[0] = STATE_MVP_MATRIX; (yyval.state)[1] = 0; @@ -4152,7 +4162,7 @@ yyreduce: case 204: /* Line 1455 of yacc.c */ -#line 1681 "program_parse.y" +#line 1691 "program_parse.y" { (yyval.state)[0] = STATE_TEXTURE_MATRIX; (yyval.state)[1] = (yyvsp[(2) - (2)].integer); @@ -4162,7 +4172,7 @@ yyreduce: case 205: /* Line 1455 of yacc.c */ -#line 1686 "program_parse.y" +#line 1696 "program_parse.y" { yyerror(& (yylsp[(1) - (4)]), state, "GL_ARB_matrix_palette not supported"); YYERROR; @@ -4172,7 +4182,7 @@ yyreduce: case 206: /* Line 1455 of yacc.c */ -#line 1691 "program_parse.y" +#line 1701 "program_parse.y" { (yyval.state)[0] = STATE_PROGRAM_MATRIX; (yyval.state)[1] = (yyvsp[(3) - (4)].integer); @@ -4182,7 +4192,7 @@ yyreduce: case 207: /* Line 1455 of yacc.c */ -#line 1698 "program_parse.y" +#line 1708 "program_parse.y" { (yyval.integer) = 0; ;} @@ -4191,7 +4201,7 @@ yyreduce: case 208: /* Line 1455 of yacc.c */ -#line 1702 "program_parse.y" +#line 1712 "program_parse.y" { (yyval.integer) = (yyvsp[(2) - (3)].integer); ;} @@ -4200,7 +4210,7 @@ yyreduce: case 209: /* Line 1455 of yacc.c */ -#line 1707 "program_parse.y" +#line 1717 "program_parse.y" { /* Since GL_ARB_vertex_blend isn't supported, only modelview matrix * zero is valid. @@ -4217,7 +4227,7 @@ yyreduce: case 210: /* Line 1455 of yacc.c */ -#line 1720 "program_parse.y" +#line 1730 "program_parse.y" { /* Since GL_ARB_matrix_palette isn't supported, just let any value * through here. The error will be generated later. @@ -4229,7 +4239,7 @@ yyreduce: case 211: /* Line 1455 of yacc.c */ -#line 1728 "program_parse.y" +#line 1738 "program_parse.y" { if ((unsigned) (yyvsp[(1) - (1)].integer) >= state->MaxProgramMatrices) { yyerror(& (yylsp[(1) - (1)]), state, "invalid program matrix selector"); @@ -4243,7 +4253,7 @@ yyreduce: case 212: /* Line 1455 of yacc.c */ -#line 1739 "program_parse.y" +#line 1749 "program_parse.y" { memset((yyval.state), 0, sizeof((yyval.state))); (yyval.state)[0] = STATE_DEPTH_RANGE; @@ -4253,7 +4263,7 @@ yyreduce: case 217: /* Line 1455 of yacc.c */ -#line 1751 "program_parse.y" +#line 1761 "program_parse.y" { memset((yyval.state), 0, sizeof((yyval.state))); (yyval.state)[0] = state->state_param_enum; @@ -4266,7 +4276,7 @@ yyreduce: case 218: /* Line 1455 of yacc.c */ -#line 1761 "program_parse.y" +#line 1771 "program_parse.y" { (yyval.state)[0] = (yyvsp[(1) - (1)].integer); (yyval.state)[1] = (yyvsp[(1) - (1)].integer); @@ -4276,7 +4286,7 @@ yyreduce: case 219: /* Line 1455 of yacc.c */ -#line 1766 "program_parse.y" +#line 1776 "program_parse.y" { (yyval.state)[0] = (yyvsp[(1) - (3)].integer); (yyval.state)[1] = (yyvsp[(3) - (3)].integer); @@ -4286,7 +4296,7 @@ yyreduce: case 220: /* Line 1455 of yacc.c */ -#line 1773 "program_parse.y" +#line 1783 "program_parse.y" { memset((yyval.state), 0, sizeof((yyval.state))); (yyval.state)[0] = state->state_param_enum; @@ -4299,7 +4309,7 @@ yyreduce: case 221: /* Line 1455 of yacc.c */ -#line 1783 "program_parse.y" +#line 1793 "program_parse.y" { memset((yyval.state), 0, sizeof((yyval.state))); (yyval.state)[0] = state->state_param_enum; @@ -4312,7 +4322,7 @@ yyreduce: case 222: /* Line 1455 of yacc.c */ -#line 1792 "program_parse.y" +#line 1802 "program_parse.y" { (yyval.state)[0] = (yyvsp[(1) - (1)].integer); (yyval.state)[1] = (yyvsp[(1) - (1)].integer); @@ -4322,7 +4332,7 @@ yyreduce: case 223: /* Line 1455 of yacc.c */ -#line 1797 "program_parse.y" +#line 1807 "program_parse.y" { (yyval.state)[0] = (yyvsp[(1) - (3)].integer); (yyval.state)[1] = (yyvsp[(3) - (3)].integer); @@ -4332,7 +4342,7 @@ yyreduce: case 224: /* Line 1455 of yacc.c */ -#line 1804 "program_parse.y" +#line 1814 "program_parse.y" { memset((yyval.state), 0, sizeof((yyval.state))); (yyval.state)[0] = state->state_param_enum; @@ -4345,7 +4355,7 @@ yyreduce: case 225: /* Line 1455 of yacc.c */ -#line 1814 "program_parse.y" +#line 1824 "program_parse.y" { if ((unsigned) (yyvsp[(1) - (1)].integer) >= state->limits->MaxEnvParams) { yyerror(& (yylsp[(1) - (1)]), state, "invalid environment parameter reference"); @@ -4358,7 +4368,7 @@ yyreduce: case 226: /* Line 1455 of yacc.c */ -#line 1824 "program_parse.y" +#line 1834 "program_parse.y" { if ((unsigned) (yyvsp[(1) - (1)].integer) >= state->limits->MaxLocalParams) { yyerror(& (yylsp[(1) - (1)]), state, "invalid local parameter reference"); @@ -4371,7 +4381,7 @@ yyreduce: case 231: /* Line 1455 of yacc.c */ -#line 1839 "program_parse.y" +#line 1849 "program_parse.y" { (yyval.vector).count = 4; (yyval.vector).data[0] = (yyvsp[(1) - (1)].real); @@ -4384,7 +4394,7 @@ yyreduce: case 232: /* Line 1455 of yacc.c */ -#line 1849 "program_parse.y" +#line 1859 "program_parse.y" { (yyval.vector).count = 1; (yyval.vector).data[0] = (yyvsp[(1) - (1)].real); @@ -4397,7 +4407,7 @@ yyreduce: case 233: /* Line 1455 of yacc.c */ -#line 1857 "program_parse.y" +#line 1867 "program_parse.y" { (yyval.vector).count = 1; (yyval.vector).data[0] = (float) (yyvsp[(1) - (1)].integer); @@ -4410,7 +4420,7 @@ yyreduce: case 234: /* Line 1455 of yacc.c */ -#line 1867 "program_parse.y" +#line 1877 "program_parse.y" { (yyval.vector).count = 4; (yyval.vector).data[0] = (yyvsp[(2) - (3)].real); @@ -4423,7 +4433,7 @@ yyreduce: case 235: /* Line 1455 of yacc.c */ -#line 1875 "program_parse.y" +#line 1885 "program_parse.y" { (yyval.vector).count = 4; (yyval.vector).data[0] = (yyvsp[(2) - (5)].real); @@ -4436,7 +4446,7 @@ yyreduce: case 236: /* Line 1455 of yacc.c */ -#line 1884 "program_parse.y" +#line 1894 "program_parse.y" { (yyval.vector).count = 4; (yyval.vector).data[0] = (yyvsp[(2) - (7)].real); @@ -4449,7 +4459,7 @@ yyreduce: case 237: /* Line 1455 of yacc.c */ -#line 1893 "program_parse.y" +#line 1903 "program_parse.y" { (yyval.vector).count = 4; (yyval.vector).data[0] = (yyvsp[(2) - (9)].real); @@ -4462,7 +4472,7 @@ yyreduce: case 238: /* Line 1455 of yacc.c */ -#line 1903 "program_parse.y" +#line 1913 "program_parse.y" { (yyval.real) = ((yyvsp[(1) - (2)].negate)) ? -(yyvsp[(2) - (2)].real) : (yyvsp[(2) - (2)].real); ;} @@ -4471,7 +4481,7 @@ yyreduce: case 239: /* Line 1455 of yacc.c */ -#line 1907 "program_parse.y" +#line 1917 "program_parse.y" { (yyval.real) = (float)(((yyvsp[(1) - (2)].negate)) ? -(yyvsp[(2) - (2)].integer) : (yyvsp[(2) - (2)].integer)); ;} @@ -4480,35 +4490,35 @@ yyreduce: case 240: /* Line 1455 of yacc.c */ -#line 1912 "program_parse.y" +#line 1922 "program_parse.y" { (yyval.negate) = FALSE; ;} break; case 241: /* Line 1455 of yacc.c */ -#line 1913 "program_parse.y" +#line 1923 "program_parse.y" { (yyval.negate) = TRUE; ;} break; case 242: /* Line 1455 of yacc.c */ -#line 1914 "program_parse.y" +#line 1924 "program_parse.y" { (yyval.negate) = FALSE; ;} break; case 243: /* Line 1455 of yacc.c */ -#line 1917 "program_parse.y" +#line 1927 "program_parse.y" { (yyval.integer) = (yyvsp[(2) - (2)].integer); ;} break; case 245: /* Line 1455 of yacc.c */ -#line 1921 "program_parse.y" +#line 1931 "program_parse.y" { /* NV_fragment_program_option defines the size qualifiers in a * fairly broken way. "SHORT" or "LONG" can optionally be used @@ -4547,7 +4557,7 @@ yyreduce: case 246: /* Line 1455 of yacc.c */ -#line 1955 "program_parse.y" +#line 1965 "program_parse.y" { ;} break; @@ -4555,14 +4565,14 @@ yyreduce: case 247: /* Line 1455 of yacc.c */ -#line 1959 "program_parse.y" +#line 1969 "program_parse.y" { (yyval.integer) = (yyvsp[(1) - (1)].integer); ;} break; case 249: /* Line 1455 of yacc.c */ -#line 1963 "program_parse.y" +#line 1973 "program_parse.y" { if (!declare_variable(state, (yyvsp[(3) - (3)].string), (yyvsp[(0) - (3)].integer), & (yylsp[(3) - (3)]))) { free((yyvsp[(3) - (3)].string)); @@ -4574,7 +4584,7 @@ yyreduce: case 250: /* Line 1455 of yacc.c */ -#line 1970 "program_parse.y" +#line 1980 "program_parse.y" { if (!declare_variable(state, (yyvsp[(1) - (1)].string), (yyvsp[(0) - (1)].integer), & (yylsp[(1) - (1)]))) { free((yyvsp[(1) - (1)].string)); @@ -4586,7 +4596,7 @@ yyreduce: case 251: /* Line 1455 of yacc.c */ -#line 1979 "program_parse.y" +#line 1989 "program_parse.y" { struct asm_symbol *const s = declare_variable(state, (yyvsp[(3) - (5)].string), at_output, & (yylsp[(3) - (5)])); @@ -4603,7 +4613,7 @@ yyreduce: case 252: /* Line 1455 of yacc.c */ -#line 1993 "program_parse.y" +#line 2003 "program_parse.y" { if (state->mode == ARB_vertex) { (yyval.result) = VERT_RESULT_HPOS; @@ -4617,7 +4627,7 @@ yyreduce: case 253: /* Line 1455 of yacc.c */ -#line 2002 "program_parse.y" +#line 2012 "program_parse.y" { if (state->mode == ARB_vertex) { (yyval.result) = VERT_RESULT_FOGC; @@ -4631,7 +4641,7 @@ yyreduce: case 254: /* Line 1455 of yacc.c */ -#line 2011 "program_parse.y" +#line 2021 "program_parse.y" { (yyval.result) = (yyvsp[(2) - (2)].result); ;} @@ -4640,7 +4650,7 @@ yyreduce: case 255: /* Line 1455 of yacc.c */ -#line 2015 "program_parse.y" +#line 2025 "program_parse.y" { if (state->mode == ARB_vertex) { (yyval.result) = VERT_RESULT_PSIZ; @@ -4654,7 +4664,7 @@ yyreduce: case 256: /* Line 1455 of yacc.c */ -#line 2024 "program_parse.y" +#line 2034 "program_parse.y" { if (state->mode == ARB_vertex) { (yyval.result) = VERT_RESULT_TEX0 + (yyvsp[(3) - (3)].integer); @@ -4668,7 +4678,7 @@ yyreduce: case 257: /* Line 1455 of yacc.c */ -#line 2033 "program_parse.y" +#line 2043 "program_parse.y" { if (state->mode == ARB_fragment) { (yyval.result) = FRAG_RESULT_DEPTH; @@ -4682,7 +4692,7 @@ yyreduce: case 258: /* Line 1455 of yacc.c */ -#line 2044 "program_parse.y" +#line 2054 "program_parse.y" { (yyval.result) = (yyvsp[(2) - (3)].integer) + (yyvsp[(3) - (3)].integer); ;} @@ -4691,7 +4701,7 @@ yyreduce: case 259: /* Line 1455 of yacc.c */ -#line 2050 "program_parse.y" +#line 2060 "program_parse.y" { (yyval.integer) = (state->mode == ARB_vertex) ? VERT_RESULT_COL0 @@ -4702,7 +4712,7 @@ yyreduce: case 260: /* Line 1455 of yacc.c */ -#line 2056 "program_parse.y" +#line 2066 "program_parse.y" { if (state->mode == ARB_vertex) { (yyval.integer) = VERT_RESULT_COL0; @@ -4716,7 +4726,7 @@ yyreduce: case 261: /* Line 1455 of yacc.c */ -#line 2065 "program_parse.y" +#line 2075 "program_parse.y" { if (state->mode == ARB_vertex) { (yyval.integer) = VERT_RESULT_BFC0; @@ -4730,7 +4740,7 @@ yyreduce: case 262: /* Line 1455 of yacc.c */ -#line 2076 "program_parse.y" +#line 2086 "program_parse.y" { (yyval.integer) = 0; ;} @@ -4739,7 +4749,7 @@ yyreduce: case 263: /* Line 1455 of yacc.c */ -#line 2080 "program_parse.y" +#line 2090 "program_parse.y" { if (state->mode == ARB_vertex) { (yyval.integer) = 0; @@ -4753,7 +4763,7 @@ yyreduce: case 264: /* Line 1455 of yacc.c */ -#line 2089 "program_parse.y" +#line 2099 "program_parse.y" { if (state->mode == ARB_vertex) { (yyval.integer) = 1; @@ -4767,91 +4777,91 @@ yyreduce: case 265: /* Line 1455 of yacc.c */ -#line 2099 "program_parse.y" +#line 2109 "program_parse.y" { (yyval.integer) = 0; ;} break; case 266: /* Line 1455 of yacc.c */ -#line 2100 "program_parse.y" +#line 2110 "program_parse.y" { (yyval.integer) = 0; ;} break; case 267: /* Line 1455 of yacc.c */ -#line 2101 "program_parse.y" +#line 2111 "program_parse.y" { (yyval.integer) = 1; ;} break; case 268: /* Line 1455 of yacc.c */ -#line 2104 "program_parse.y" +#line 2114 "program_parse.y" { (yyval.integer) = 0; ;} break; case 269: /* Line 1455 of yacc.c */ -#line 2105 "program_parse.y" +#line 2115 "program_parse.y" { (yyval.integer) = 0; ;} break; case 270: /* Line 1455 of yacc.c */ -#line 2106 "program_parse.y" +#line 2116 "program_parse.y" { (yyval.integer) = 1; ;} break; case 271: /* Line 1455 of yacc.c */ -#line 2109 "program_parse.y" +#line 2119 "program_parse.y" { (yyval.integer) = 0; ;} break; case 272: /* Line 1455 of yacc.c */ -#line 2110 "program_parse.y" +#line 2120 "program_parse.y" { (yyval.integer) = (yyvsp[(2) - (3)].integer); ;} break; case 273: /* Line 1455 of yacc.c */ -#line 2113 "program_parse.y" +#line 2123 "program_parse.y" { (yyval.integer) = 0; ;} break; case 274: /* Line 1455 of yacc.c */ -#line 2114 "program_parse.y" +#line 2124 "program_parse.y" { (yyval.integer) = (yyvsp[(2) - (3)].integer); ;} break; case 275: /* Line 1455 of yacc.c */ -#line 2117 "program_parse.y" +#line 2127 "program_parse.y" { (yyval.integer) = 0; ;} break; case 276: /* Line 1455 of yacc.c */ -#line 2118 "program_parse.y" +#line 2128 "program_parse.y" { (yyval.integer) = (yyvsp[(2) - (3)].integer); ;} break; case 277: /* Line 1455 of yacc.c */ -#line 2122 "program_parse.y" +#line 2132 "program_parse.y" { if ((unsigned) (yyvsp[(1) - (1)].integer) >= state->MaxTextureCoordUnits) { yyerror(& (yylsp[(1) - (1)]), state, "invalid texture coordinate unit selector"); @@ -4865,7 +4875,7 @@ yyreduce: case 278: /* Line 1455 of yacc.c */ -#line 2133 "program_parse.y" +#line 2143 "program_parse.y" { if ((unsigned) (yyvsp[(1) - (1)].integer) >= state->MaxTextureImageUnits) { yyerror(& (yylsp[(1) - (1)]), state, "invalid texture image unit selector"); @@ -4879,7 +4889,7 @@ yyreduce: case 279: /* Line 1455 of yacc.c */ -#line 2144 "program_parse.y" +#line 2154 "program_parse.y" { if ((unsigned) (yyvsp[(1) - (1)].integer) >= state->MaxTextureUnits) { yyerror(& (yylsp[(1) - (1)]), state, "invalid texture unit selector"); @@ -4893,7 +4903,7 @@ yyreduce: case 280: /* Line 1455 of yacc.c */ -#line 2155 "program_parse.y" +#line 2165 "program_parse.y" { struct asm_symbol *exist = (struct asm_symbol *) _mesa_symbol_table_find_symbol(state->st, 0, (yyvsp[(2) - (4)].string)); @@ -4922,7 +4932,7 @@ yyreduce: /* Line 1455 of yacc.c */ -#line 4926 "program_parse.tab.c" +#line 4936 "program_parse.tab.c" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); @@ -5141,7 +5151,7 @@ yyreturn: /* Line 1675 of yacc.c */ -#line 2184 "program_parse.y" +#line 2194 "program_parse.y" void @@ -5271,19 +5281,29 @@ init_src_reg(struct asm_src_register *r) } -/** Like init_src_reg() but set the File and Index fields. */ +/** Like init_src_reg() but set the File and Index fields. + * \return GL_TRUE if a valid src register, GL_FALSE otherwise + */ void set_src_reg(struct asm_src_register *r, gl_register_file file, GLint index) +{ + set_src_reg_swz(r, file, index, SWIZZLE_XYZW); +} + + +void +set_src_reg_swz(struct asm_src_register *r, gl_register_file file, GLint index, + GLuint swizzle) { const GLint maxIndex = (1 << INST_INDEX_BITS) - 1; const GLint minIndex = -(1 << INST_INDEX_BITS); + ASSERT(file < PROGRAM_FILE_MAX); ASSERT(index >= minIndex); ASSERT(index <= maxIndex); - ASSERT(file < PROGRAM_FILE_MAX); memset(r, 0, sizeof(*r)); r->Base.File = file; r->Base.Index = index; - r->Base.Swizzle = SWIZZLE_NOOP; + r->Base.Swizzle = swizzle; r->Symbol = NULL; } @@ -5415,15 +5435,20 @@ initialize_symbol_from_state(struct gl_program *prog, state_tokens[2] = state_tokens[3] = row; idx = add_state_reference(prog->Parameters, state_tokens); - if (param_var->param_binding_begin == ~0U) + if (param_var->param_binding_begin == ~0U) { param_var->param_binding_begin = idx; + param_var->param_binding_swizzle = SWIZZLE_XYZW; + } + param_var->param_binding_length++; } } else { idx = add_state_reference(prog->Parameters, state_tokens); - if (param_var->param_binding_begin == ~0U) + if (param_var->param_binding_begin == ~0U) { param_var->param_binding_begin = idx; + param_var->param_binding_swizzle = SWIZZLE_XYZW; + } param_var->param_binding_length++; } @@ -5463,15 +5488,19 @@ initialize_symbol_from_param(struct gl_program *prog, state_tokens[2] = state_tokens[3] = row; idx = add_state_reference(prog->Parameters, state_tokens); - if (param_var->param_binding_begin == ~0U) + if (param_var->param_binding_begin == ~0U) { param_var->param_binding_begin = idx; + param_var->param_binding_swizzle = SWIZZLE_XYZW; + } param_var->param_binding_length++; } } else { idx = add_state_reference(prog->Parameters, state_tokens); - if (param_var->param_binding_begin == ~0U) + if (param_var->param_binding_begin == ~0U) { param_var->param_binding_begin = idx; + param_var->param_binding_swizzle = SWIZZLE_XYZW; + } param_var->param_binding_length++; } @@ -5479,20 +5508,29 @@ initialize_symbol_from_param(struct gl_program *prog, } +/** + * Put a float/vector constant/literal into the parameter list. + * \param param_var returns info about the parameter/constant's location, + * binding, type, etc. + * \param vec the vector/constant to add + * \return index of the constant in the parameter list. + */ int initialize_symbol_from_const(struct gl_program *prog, struct asm_symbol *param_var, const struct asm_vector *vec) { - const int idx = _mesa_add_parameter(prog->Parameters, PROGRAM_CONSTANT, - NULL, vec->count, GL_NONE, vec->data, - NULL, 0x0); + unsigned swizzle; + const int idx = _mesa_add_unnamed_constant(prog->Parameters, + vec->data, vec->count, &swizzle); param_var->type = at_param; param_var->param_binding_type = PROGRAM_CONSTANT; - if (param_var->param_binding_begin == ~0U) + if (param_var->param_binding_begin == ~0U) { param_var->param_binding_begin = idx; + param_var->param_binding_swizzle = swizzle; + } param_var->param_binding_length++; return idx; diff --git a/src/mesa/shader/program_parse.tab.h b/src/mesa/shader/program_parse.tab.h index 406100c859..d8712b7268 100644 --- a/src/mesa/shader/program_parse.tab.h +++ b/src/mesa/shader/program_parse.tab.h @@ -154,7 +154,7 @@ typedef union YYSTYPE { /* Line 1676 of yacc.c */ -#line 122 "program_parse.y" +#line 125 "program_parse.y" struct asm_instruction *inst; struct asm_symbol *sym; diff --git a/src/mesa/shader/program_parse.y b/src/mesa/shader/program_parse.y index 8ca6f9805b..3f1a350c24 100644 --- a/src/mesa/shader/program_parse.y +++ b/src/mesa/shader/program_parse.y @@ -74,6 +74,9 @@ static void init_src_reg(struct asm_src_register *r); static void set_src_reg(struct asm_src_register *r, gl_register_file file, GLint index); +static void set_src_reg_swz(struct asm_src_register *r, + gl_register_file file, GLint index, GLuint swizzle); + static void asm_instruction_set_operands(struct asm_instruction *inst, const struct prog_dst_register *dst, const struct asm_src_register *src0, const struct asm_src_register *src1, const struct asm_src_register *src2); @@ -588,7 +591,9 @@ scalarUse: srcReg scalarSuffix temp_sym.param_binding_begin = ~0; initialize_symbol_from_const(state->prog, & temp_sym, & $1); - set_src_reg(& $$, PROGRAM_CONSTANT, temp_sym.param_binding_begin); + set_src_reg_swz(& $$, PROGRAM_CONSTANT, + temp_sym.param_binding_begin, + temp_sym.param_binding_swizzle); } ; @@ -790,7 +795,9 @@ srcReg: USED_IDENTIFIER /* temporaryReg | progParamSingle */ set_src_reg(& $$, PROGRAM_TEMPORARY, s->temp_binding); break; case at_param: - set_src_reg(& $$, s->param_binding_type, s->param_binding_begin); + set_src_reg_swz(& $$, s->param_binding_type, + s->param_binding_begin, + s->param_binding_swizzle); break; case at_attrib: set_src_reg(& $$, PROGRAM_INPUT, s->attrib_binding); @@ -841,7 +848,8 @@ srcReg: USED_IDENTIFIER /* temporaryReg | progParamSingle */ gl_register_file file = ($1.name != NULL) ? $1.param_binding_type : PROGRAM_CONSTANT; - set_src_reg(& $$, file, $1.param_binding_begin); + set_src_reg_swz(& $$, file, $1.param_binding_begin, + $1.param_binding_swizzle); } ; @@ -1210,6 +1218,7 @@ PARAM_singleStmt: PARAM IDENTIFIER paramSingleInit s->param_binding_type = $3.param_binding_type; s->param_binding_begin = $3.param_binding_begin; s->param_binding_length = $3.param_binding_length; + s->param_binding_swizzle = SWIZZLE_XYZW; s->param_is_array = 0; } } @@ -1233,6 +1242,7 @@ PARAM_multipleStmt: PARAM IDENTIFIER '[' optArraySize ']' paramMultipleInit s->param_binding_type = $6.param_binding_type; s->param_binding_begin = $6.param_binding_begin; s->param_binding_length = $6.param_binding_length; + s->param_binding_swizzle = SWIZZLE_XYZW; s->param_is_array = 1; } } @@ -2310,19 +2320,29 @@ init_src_reg(struct asm_src_register *r) } -/** Like init_src_reg() but set the File and Index fields. */ +/** Like init_src_reg() but set the File and Index fields. + * \return GL_TRUE if a valid src register, GL_FALSE otherwise + */ void set_src_reg(struct asm_src_register *r, gl_register_file file, GLint index) +{ + set_src_reg_swz(r, file, index, SWIZZLE_XYZW); +} + + +void +set_src_reg_swz(struct asm_src_register *r, gl_register_file file, GLint index, + GLuint swizzle) { const GLint maxIndex = (1 << INST_INDEX_BITS) - 1; const GLint minIndex = -(1 << INST_INDEX_BITS); + ASSERT(file < PROGRAM_FILE_MAX); ASSERT(index >= minIndex); ASSERT(index <= maxIndex); - ASSERT(file < PROGRAM_FILE_MAX); memset(r, 0, sizeof(*r)); r->Base.File = file; r->Base.Index = index; - r->Base.Swizzle = SWIZZLE_NOOP; + r->Base.Swizzle = swizzle; r->Symbol = NULL; } @@ -2454,15 +2474,20 @@ initialize_symbol_from_state(struct gl_program *prog, state_tokens[2] = state_tokens[3] = row; idx = add_state_reference(prog->Parameters, state_tokens); - if (param_var->param_binding_begin == ~0U) + if (param_var->param_binding_begin == ~0U) { param_var->param_binding_begin = idx; + param_var->param_binding_swizzle = SWIZZLE_XYZW; + } + param_var->param_binding_length++; } } else { idx = add_state_reference(prog->Parameters, state_tokens); - if (param_var->param_binding_begin == ~0U) + if (param_var->param_binding_begin == ~0U) { param_var->param_binding_begin = idx; + param_var->param_binding_swizzle = SWIZZLE_XYZW; + } param_var->param_binding_length++; } @@ -2502,15 +2527,19 @@ initialize_symbol_from_param(struct gl_program *prog, state_tokens[2] = state_tokens[3] = row; idx = add_state_reference(prog->Parameters, state_tokens); - if (param_var->param_binding_begin == ~0U) + if (param_var->param_binding_begin == ~0U) { param_var->param_binding_begin = idx; + param_var->param_binding_swizzle = SWIZZLE_XYZW; + } param_var->param_binding_length++; } } else { idx = add_state_reference(prog->Parameters, state_tokens); - if (param_var->param_binding_begin == ~0U) + if (param_var->param_binding_begin == ~0U) { param_var->param_binding_begin = idx; + param_var->param_binding_swizzle = SWIZZLE_XYZW; + } param_var->param_binding_length++; } @@ -2518,20 +2547,29 @@ initialize_symbol_from_param(struct gl_program *prog, } +/** + * Put a float/vector constant/literal into the parameter list. + * \param param_var returns info about the parameter/constant's location, + * binding, type, etc. + * \param vec the vector/constant to add + * \return index of the constant in the parameter list. + */ int initialize_symbol_from_const(struct gl_program *prog, struct asm_symbol *param_var, const struct asm_vector *vec) { - const int idx = _mesa_add_parameter(prog->Parameters, PROGRAM_CONSTANT, - NULL, vec->count, GL_NONE, vec->data, - NULL, 0x0); + unsigned swizzle; + const int idx = _mesa_add_unnamed_constant(prog->Parameters, + vec->data, vec->count, &swizzle); param_var->type = at_param; param_var->param_binding_type = PROGRAM_CONSTANT; - if (param_var->param_binding_begin == ~0U) + if (param_var->param_binding_begin == ~0U) { param_var->param_binding_begin = idx; + param_var->param_binding_swizzle = swizzle; + } param_var->param_binding_length++; return idx; diff --git a/src/mesa/shader/program_parser.h b/src/mesa/shader/program_parser.h index c170948f73..69396ca2c0 100644 --- a/src/mesa/shader/program_parser.h +++ b/src/mesa/shader/program_parser.h @@ -56,6 +56,12 @@ struct asm_symbol { */ unsigned param_binding_begin; + /** + * Constants put into the parameter list may be swizzled. This + * field contain's the symbol's swizzle. (SWIZZLE_X/Y/Z/W) + */ + unsigned param_binding_swizzle; + /* This is how many entries in the the program_parameter_list we take up * with our state tokens or constants. Note that this is _not_ the same as * the number of param registers we eventually use. -- cgit v1.2.3 From 88bd32383a06224c742f6af59fcd95cd11284d5b Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Fri, 1 Jan 2010 15:12:58 -0800 Subject: ARB prog parser: Silence unused variable warnings. --- src/mesa/shader/program_parse.y | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/mesa/shader/program_parse.y') diff --git a/src/mesa/shader/program_parse.y b/src/mesa/shader/program_parse.y index 3f1a350c24..b40b216d65 100644 --- a/src/mesa/shader/program_parse.y +++ b/src/mesa/shader/program_parse.y @@ -2297,7 +2297,9 @@ set_dst_reg(struct prog_dst_register *r, gl_register_file file, GLint index) const GLint maxIndex = 1 << INST_INDEX_BITS; const GLint minIndex = 0; ASSERT(index >= minIndex); + (void) minIndex; ASSERT(index <= maxIndex); + (void) maxIndex; ASSERT(file == PROGRAM_TEMPORARY || file == PROGRAM_ADDRESS || file == PROGRAM_OUTPUT); @@ -2338,7 +2340,9 @@ set_src_reg_swz(struct asm_src_register *r, gl_register_file file, GLint index, const GLint minIndex = -(1 << INST_INDEX_BITS); ASSERT(file < PROGRAM_FILE_MAX); ASSERT(index >= minIndex); + (void) minIndex; ASSERT(index <= maxIndex); + (void) maxIndex; memset(r, 0, sizeof(*r)); r->Base.File = file; r->Base.Index = index; -- cgit v1.2.3 From 7c6ae4c6c87edd02671a3857d1f774835b923e59 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 5 Jan 2010 10:01:20 -0700 Subject: ARB prog parser: add allowSwizzle param to initialize_symbol_from_const() We need to disable constant consolidation when building an array of constants which might be indexed indirectly. Fixes regression in piglit vpfp-generic vp-arl-constant-array.vpfp test caused by earlier constant consolidation patch. --- src/mesa/shader/program_parse.y | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'src/mesa/shader/program_parse.y') diff --git a/src/mesa/shader/program_parse.y b/src/mesa/shader/program_parse.y index b40b216d65..be8c841e3d 100644 --- a/src/mesa/shader/program_parse.y +++ b/src/mesa/shader/program_parse.y @@ -52,7 +52,8 @@ static int initialize_symbol_from_param(struct gl_program *prog, struct asm_symbol *param_var, const gl_state_index tokens[STATE_LENGTH]); static int initialize_symbol_from_const(struct gl_program *prog, - struct asm_symbol *param_var, const struct asm_vector *vec); + struct asm_symbol *param_var, const struct asm_vector *vec, + GLboolean allowSwizzle); static int yyparse(struct asm_parser_state *state); @@ -589,7 +590,7 @@ scalarUse: srcReg scalarSuffix memset(& temp_sym, 0, sizeof(temp_sym)); temp_sym.param_binding_begin = ~0; - initialize_symbol_from_const(state->prog, & temp_sym, & $1); + initialize_symbol_from_const(state->prog, & temp_sym, & $1, GL_TRUE); set_src_reg_swz(& $$, PROGRAM_CONSTANT, temp_sym.param_binding_begin, @@ -1300,7 +1301,7 @@ paramSingleItemDecl: stateSingleItem { memset(& $$, 0, sizeof($$)); $$.param_binding_begin = ~0; - initialize_symbol_from_const(state->prog, & $$, & $1); + initialize_symbol_from_const(state->prog, & $$, & $1, GL_TRUE); } ; @@ -1320,7 +1321,7 @@ paramSingleItemUse: stateSingleItem { memset(& $$, 0, sizeof($$)); $$.param_binding_begin = ~0; - initialize_symbol_from_const(state->prog, & $$, & $1); + initialize_symbol_from_const(state->prog, & $$, & $1, GL_TRUE); } ; @@ -1340,7 +1341,7 @@ paramMultipleItem: stateMultipleItem { memset(& $$, 0, sizeof($$)); $$.param_binding_begin = ~0; - initialize_symbol_from_const(state->prog, & $$, & $1); + initialize_symbol_from_const(state->prog, & $$, & $1, GL_FALSE); } ; @@ -2556,23 +2557,28 @@ initialize_symbol_from_param(struct gl_program *prog, * \param param_var returns info about the parameter/constant's location, * binding, type, etc. * \param vec the vector/constant to add + * \param allowSwizzle if true, try to consolidate constants which only differ + * by a swizzle. We don't want to do this when building + * arrays of constants that may be indexed indirectly. * \return index of the constant in the parameter list. */ int initialize_symbol_from_const(struct gl_program *prog, struct asm_symbol *param_var, - const struct asm_vector *vec) + const struct asm_vector *vec, + GLboolean allowSwizzle) { unsigned swizzle; const int idx = _mesa_add_unnamed_constant(prog->Parameters, - vec->data, vec->count, &swizzle); + vec->data, vec->count, + allowSwizzle ? &swizzle : NULL); param_var->type = at_param; param_var->param_binding_type = PROGRAM_CONSTANT; if (param_var->param_binding_begin == ~0U) { param_var->param_binding_begin = idx; - param_var->param_binding_swizzle = swizzle; + param_var->param_binding_swizzle = allowSwizzle ? swizzle : SWIZZLE_XYZW; } param_var->param_binding_length++; -- cgit v1.2.3 From f0f68b1e4c3d3d23fc9a7d624a465537b2e74d6c Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 5 Jan 2010 10:53:44 -0700 Subject: ARB prog parser: fix parameter binding type References to program local and enviroment parameters are put into the unified program parameters list as PROGRAM_STATE_VAR entries which point into the local or environment arrays. So the param_binding_type field should be PROGRAM_STATE_VAR. This fixes the piglit vpfp-generic vp-arl-env-array.vpfp and vp-arl-local-array.vpfp test failures. --- src/mesa/shader/program_parse.y | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/mesa/shader/program_parse.y') diff --git a/src/mesa/shader/program_parse.y b/src/mesa/shader/program_parse.y index be8c841e3d..5c5d8d7590 100644 --- a/src/mesa/shader/program_parse.y +++ b/src/mesa/shader/program_parse.y @@ -2516,9 +2516,12 @@ initialize_symbol_from_param(struct gl_program *prog, assert((state_tokens[1] == STATE_ENV) || (state_tokens[1] == STATE_LOCAL)); + /* + * The param type is STATE_VAR. The program parameter entry will + * effectively be a pointer into the LOCAL or ENV parameter array. + */ param_var->type = at_param; - param_var->param_binding_type = (state_tokens[1] == STATE_ENV) - ? PROGRAM_ENV_PARAM : PROGRAM_LOCAL_PARAM; + param_var->param_binding_type = PROGRAM_STATE_VAR; /* If we are adding a STATE_ENV or STATE_LOCAL that has multiple elements, * we need to unroll it and call add_state_reference() for each row -- cgit v1.2.3