Add a size parameter to _mesa_add_unnamed_constant() and
authorBrian Paul <brian.paul@tungstengraphics.com>
Wed, 15 Nov 2006 23:38:02 +0000 (23:38 +0000)
committerBrian Paul <brian.paul@tungstengraphics.com>
Wed, 15 Nov 2006 23:38:02 +0000 (23:38 +0000)
_mesa_add_named_constant() to indicate vector size (1, 2, 3 or 4).
Always 4 for now...

src/mesa/drivers/dri/i965/brw_vs_tnl.c
src/mesa/drivers/dri/i965/brw_wm_fp.c
src/mesa/main/texenvprogram.c
src/mesa/shader/arbprogparse.c
src/mesa/shader/nvfragparse.c
src/mesa/shader/program.c
src/mesa/shader/program.h
src/mesa/shader/programopt.c
src/mesa/tnl/t_vp_build.c

index 1df111f64577b47cf9ce2ee682f1b9e998466600..52bdb9d7614ace5e52fe64c7e2395b2a3b907a52 100644 (file)
@@ -404,7 +404,7 @@ static struct ureg register_const4f( struct tnl_program *p,
    values[1] = s1;
    values[2] = s2;
    values[3] = s3;
-   idx = _mesa_add_unnamed_constant( p->program->Base.Parameters, values );
+   idx = _mesa_add_unnamed_constant( p->program->Base.Parameters, values, 4 );
    return make_ureg(PROGRAM_STATE_VAR, idx);
 }
 
index 04c7555b9b84af0743549380f081ac06151322e6..bb0aa3561507e73dd64c99b1e2b3852dc72377ee 100644 (file)
@@ -432,7 +432,7 @@ static struct prog_src_register search_or_add_const4f( struct brw_wm_compile *c,
         return src_reg(PROGRAM_STATE_VAR, idx);
    }
    
-   idx = _mesa_add_unnamed_constant( paramList, values );
+   idx = _mesa_add_unnamed_constant( paramList, values, 4 );
 
    return src_reg(PROGRAM_STATE_VAR, idx);
 }
index c99ff5cdc469bf4bc1820b8822ec17895f56ce52..5329719cbbb57a02432bb0988c2dfdaf08eff679 100644 (file)
@@ -575,7 +575,7 @@ static struct ureg register_const4f( struct texenv_fragment_program *p,
    values[1] = s1;
    values[2] = s2;
    values[3] = s3;
-   idx = _mesa_add_unnamed_constant( p->program->Base.Parameters, values );
+   idx = _mesa_add_unnamed_constant( p->program->Base.Parameters, values, 4 );
    return make_ureg(PROGRAM_STATE_VAR, idx);
 }
 
index a423e4ff138e44cdd4682e3e59b4ec65aaed0ed7..5a61f30193b04558d0d306d6d30d405bdab5d3ee 100644 (file)
@@ -1810,7 +1810,7 @@ parse_param_elements (GLcontext * ctx, const GLubyte ** inst,
          parse_constant (inst, const_values, Program, use);
          idx = _mesa_add_named_constant(Program->Base.Parameters,
                                         (char *) param_var->name,
-                                        const_values);
+                                        const_values, 4);
          if (param_var->param_binding_begin == ~0U)
             param_var->param_binding_begin = idx;
          param_var->param_binding_length++;
index 5f3a30b74164d84c097caaa4e487ef9486e41a37..79e6dbd87b75a9ad348095754bf143bc1cc4ad09 100644 (file)
@@ -1041,7 +1041,7 @@ Parse_VectorSrc(struct parse_state *parseState,
       GLuint paramIndex;
       if (!Parse_ScalarConstant(parseState, values))
          RETURN_ERROR;
-      paramIndex = _mesa_add_unnamed_constant(parseState->parameters, values);
+      paramIndex = _mesa_add_unnamed_constant(parseState->parameters, values, 4);
       srcReg->File = PROGRAM_NAMED_PARAM;
       srcReg->Index = paramIndex;
    }
@@ -1052,7 +1052,7 @@ Parse_VectorSrc(struct parse_state *parseState,
       (void) Parse_String(parseState, "{");
       if (!Parse_VectorConstant(parseState, values))
          RETURN_ERROR;
-      paramIndex = _mesa_add_unnamed_constant(parseState->parameters, values);
+      paramIndex = _mesa_add_unnamed_constant(parseState->parameters, values, 4);
       srcReg->File = PROGRAM_NAMED_PARAM;
       srcReg->Index = paramIndex;      
    }
@@ -1142,7 +1142,7 @@ Parse_ScalarSrcReg(struct parse_state *parseState,
       (void) Parse_String(parseState, "{");
       if (!Parse_VectorConstant(parseState, values))
          RETURN_ERROR;
-      paramIndex = _mesa_add_unnamed_constant(parseState->parameters, values);
+      paramIndex = _mesa_add_unnamed_constant(parseState->parameters, values, 4);
       srcReg->File = PROGRAM_NAMED_PARAM;
       srcReg->Index = paramIndex;      
    }
@@ -1166,7 +1166,7 @@ Parse_ScalarSrcReg(struct parse_state *parseState,
       GLuint paramIndex;
       if (!Parse_ScalarConstant(parseState, values))
          RETURN_ERROR;
-      paramIndex = _mesa_add_unnamed_constant(parseState->parameters, values);
+      paramIndex = _mesa_add_unnamed_constant(parseState->parameters, values, 4);
       srcReg->Index = paramIndex;      
       srcReg->File = PROGRAM_NAMED_PARAM;
       needSuffix = GL_FALSE;
index 5c03ad44c2eaebb3fc31b6c5742f792c6912dc99..e903fd030516920d0e6a4e4f64d10b354e19dd73 100644 (file)
@@ -437,9 +437,11 @@ _mesa_add_named_parameter(struct gl_program_parameter_list *paramList,
  */
 GLint
 _mesa_add_named_constant(struct gl_program_parameter_list *paramList,
-                         const char *name, const GLfloat values[4])
+                         const char *name, const GLfloat values[4],
+                         GLuint size)
 {
    GLuint pos, swizzle;
+   ASSERT(size == 4); /* XXX future feature */
    /* check if we already have this constant */
    if (_mesa_lookup_parameter_constant(paramList, values, 4, &pos, &swizzle)) {
       return pos;
@@ -459,9 +461,10 @@ _mesa_add_named_constant(struct gl_program_parameter_list *paramList,
  */
 GLint
 _mesa_add_unnamed_constant(struct gl_program_parameter_list *paramList,
-                           const GLfloat values[4])
+                           const GLfloat values[4], GLuint size)
 {
    GLuint pos, swizzle;
+   ASSERT(size == 4); /* XXX future feature */
    /* check if we already have this constant */
    if (_mesa_lookup_parameter_constant(paramList, values, 4, &pos, &swizzle)) {
       return pos;
index 3f84ea8a4031b96d47e8ed04a317906fab7f67ec..a38a1a63f9cd54ff3e8eee41245c170095c1465b 100644 (file)
@@ -238,11 +238,12 @@ _mesa_add_named_parameter(struct gl_program_parameter_list *paramList,
 
 extern GLint
 _mesa_add_named_constant(struct gl_program_parameter_list *paramList,
-                         const char *name, const GLfloat values[4]);
+                         const char *name, const GLfloat values[4],
+                         GLuint size);
 
 extern GLint
 _mesa_add_unnamed_constant(struct gl_program_parameter_list *paramList,
-                           const GLfloat values[4]);
+                           const GLfloat values[4], GLuint size);
 
 extern GLint
 _mesa_add_state_reference(struct gl_program_parameter_list *paramList,
index 172d373b578ae959a1015913f7ec6bb61a60cb94..783177739d13568ade543933b412da9c5882a676 100644 (file)
@@ -172,7 +172,7 @@ _mesa_append_fog_code(GLcontext *ctx, struct gl_fragment_program *fprog)
    fogVals[1] = 1.0 / SQRTF(log(2.0));
    fogVals[2] = 0.0;
    fogVals[3] = 0.0;
-   fogConsts = _mesa_add_unnamed_constant(fprog->Base.Parameters, fogVals);
+   fogConsts = _mesa_add_unnamed_constant(fprog->Base.Parameters, fogVals, 4);
 
    /* Scan program to find where result.color is written */
    inst = newInst;
index 894a13b7046ee5b63464989ba1e6942e3f20a515..805d05ae7288583616964b6494dc620010c28b9c 100644 (file)
@@ -33,7 +33,7 @@
 #include "glheader.h"
 #include "macros.h"
 #include "enums.h"
-#include "t_context.h"
+#include "t_context.h" /* NOTE: very light dependency on this */
 #include "t_vp_build.h"
 
 #include "shader/program.h"
@@ -386,7 +386,7 @@ static struct ureg register_const4f( struct tnl_program *p,
    values[1] = s1;
    values[2] = s2;
    values[3] = s3;
-   idx = _mesa_add_unnamed_constant( p->program->Base.Parameters, values );
+   idx = _mesa_add_unnamed_constant( p->program->Base.Parameters, values, 4 );
    return make_ureg(PROGRAM_STATE_VAR, idx);
 }