Mesa (mesa_7_7_branch): ARB prog parser: add allowSwizzle param to initialize_symbol_from_const()

Brian Paul brianp at kemper.freedesktop.org
Tue Jan 5 10:45:49 PST 2010


Module: Mesa
Branch: mesa_7_7_branch
Commit: 7c6ae4c6c87edd02671a3857d1f774835b923e59
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=7c6ae4c6c87edd02671a3857d1f774835b923e59

Author: Brian Paul <brianp at vmware.com>
Date:   Tue Jan  5 10:01:20 2010 -0700

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 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/src/mesa/shader/program_parse.y b/src/mesa/shader/program_parse.y
index b40b216..be8c841 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++;
 



More information about the mesa-commit mailing list