summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Paul <brianp@vmware.com>2010-01-05 10:01:20 -0700
committerBrian Paul <brianp@vmware.com>2010-01-05 11:44:19 -0700
commit7c6ae4c6c87edd02671a3857d1f774835b923e59 (patch)
tree7231cf18aa3f36e0ea74091c0b3ff90fa5a07cf4
parent37f6929d29c9d3fbec873c0576a343d342ffdedf (diff)
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.
-rw-r--r--src/mesa/shader/program_parse.y22
1 files changed, 14 insertions, 8 deletions
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++;