From: Brian Paul Date: Tue, 5 Jan 2010 17:01:20 +0000 (-0700) Subject: ARB prog parser: add allowSwizzle param to initialize_symbol_from_const() X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7c6ae4c6c87edd02671a3857d1f774835b923e59;p=mesa.git 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. --- diff --git a/src/mesa/shader/program_parse.y b/src/mesa/shader/program_parse.y index b40b216d658..be8c841e3da 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++;