Merge branch 'master' of git+ssh://keithw@git.freedesktop.org/git/mesa/mesa into...
[mesa.git] / src / mesa / drivers / dri / i965 / brw_vs_tnl.c
index cf3b904793dad5c8b47084aeff0b86e17b99c59b..0d61092247ab0b61ef992a8f7de6c85a421c40bf 100644 (file)
@@ -114,7 +114,7 @@ static GLuint translate_texgen( GLboolean enabled, GLenum mode )
 static void make_state_key( GLcontext *ctx, struct state_key *key )
 {
    struct brw_context *brw = brw_context(ctx);
-   struct gl_fragment_program *fp = brw->fragment_program;
+   const struct gl_fragment_program *fp = brw->fragment_program;
    GLuint i;
 
    /* This now relies on texenvprogram.c being active:
@@ -146,9 +146,13 @@ static void make_state_key( GLcontext *ctx, struct state_key *key )
       }
 
       /* BRW_NEW_INPUT_VARYING */
-      for (i = BRW_ATTRIB_MAT_FRONT_AMBIENT ; i < BRW_ATTRIB_INDEX ; i++) 
-        if (brw->vb.info.varying[0] & (1<<i)) 
-           key->light_material_mask |= 1<<(i-BRW_ATTRIB_MAT_FRONT_AMBIENT);
+
+      /* For these programs, material values are stuffed into the
+       * generic slots:
+       */
+      for (i = 0 ; i < MAT_ATTRIB_MAX ; i++) 
+        if (brw->vb.info.varying & (1<<(VERT_ATTRIB_GENERIC0 + i))) 
+           key->light_material_mask |= 1<<i;
 
       for (i = 0; i < MAX_LIGHTS; i++) {
         struct gl_light *light = &brw->attribs.Light->Light[i];
@@ -340,7 +344,7 @@ static struct ureg get_temp( struct tnl_program *p )
    int bit = ffs( ~p->temp_in_use );
    if (!bit) {
       fprintf(stderr, "%s: out of temporaries\n", __FILE__);
-      abort();
+      assert(0);
    }
 
    if (bit > p->program->Base.NumTemporaries)
@@ -374,6 +378,8 @@ static void release_temps( struct tnl_program *p )
 
 static struct ureg register_input( struct tnl_program *p, GLuint input )
 {
+   assert(input < 32);
+
    p->program->Base.InputsRead |= (1<<input);
    return make_ureg(PROGRAM_INPUT, input);
 }
@@ -396,7 +402,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);
 }
 
@@ -527,6 +533,7 @@ static void emit_op3fn(struct tnl_program *p,
 
    {      
       struct prog_instruction *inst = &p->program->Base.Instructions[nr];
+      memset(inst, 0, sizeof(*inst));
       inst->Opcode = op; 
       inst->StringPos = 0;
       inst->Data = 0;
@@ -667,7 +674,7 @@ static struct ureg get_eye_z( struct tnl_program *p )
       return swizzle1(p->eye_position, Z);
    }
    else if (!is_undef(p->eye_z)) {
-      struct ureg pos = register_input( p, VERT_ATTRIB_POS ); 
+      struct ureg pos = register_input( p, BRW_ATTRIB_POS ); 
       struct ureg modelview2;
 
       p->eye_z = reserve_temp(p);
@@ -779,7 +786,7 @@ static struct ureg get_material( struct tnl_program *p, GLuint side,
    if (p->color_materials & (1<<attrib))
       return register_input(p, VERT_ATTRIB_COLOR0);
    else if (p->materials & (1<<attrib)) 
-      return register_input( p, attrib + BRW_ATTRIB_MAT_FRONT_AMBIENT );
+      return register_input( p, attrib + _TNL_ATTRIB_MAT_FRONT_AMBIENT );
    else
       return register_param3( p, STATE_MATERIAL, side, property );
 }
@@ -1618,7 +1625,7 @@ const struct brw_tracked_state brw_tnl_vertprog = {
 
 static void update_active_vertprog( struct brw_context *brw )
 {
-   struct gl_vertex_program *prev = brw->vertex_program;
+   const struct gl_vertex_program *prev = brw->vertex_program;
 
    /* NEW_PROGRAM */
    if (brw->attribs.VertexProgram->_Enabled) {