mesa: remove unneeded #include of colormac.h
[mesa.git] / src / mesa / main / ffvertex_prog.c
index 3f08b0984695086ea4a994ba2c3562fdd1e3f239..395b00e15281bbe72217e0c88aa6ede2620cfe49 100644 (file)
@@ -1,6 +1,6 @@
 /**************************************************************************
  *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * Copyright 2007 VMware, Inc.
  * All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
@@ -18,7 +18,7 @@
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -36,7 +36,6 @@
 #include "main/glheader.h"
 #include "main/mtypes.h"
 #include "main/macros.h"
-#include "main/mfeatures.h"
 #include "main/enums.h"
 #include "main/ffvertex_prog.h"
 #include "program/program.h"
@@ -165,7 +164,7 @@ static void make_state_key( struct gl_context *ctx, struct state_key *key )
 
    if (ctx->RenderMode == GL_FEEDBACK) {
       /* make sure the vertprog emits color and tex0 */
-      key->fragprog_inputs_read |= (FRAG_BIT_COL0 | FRAG_BIT_TEX0);
+      key->fragprog_inputs_read |= (VARYING_BIT_COL0 | VARYING_BIT_TEX0);
    }
 
    key->separate_specular = (ctx->Light.Model.ColorControl ==
@@ -229,18 +228,18 @@ static void make_state_key( struct gl_context *ctx, struct state_key *key )
    if (ctx->Point._Attenuated)
       key->point_attenuated = 1;
 
-   if (ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_POINT_SIZE].Enabled)
+   if (ctx->Array.VAO->VertexAttrib[VERT_ATTRIB_POINT_SIZE].Enabled)
       key->point_array = 1;
 
    if (ctx->Texture._TexGenEnabled ||
        ctx->Texture._TexMatEnabled ||
-       ctx->Texture._EnabledUnits)
+       ctx->Texture._MaxEnabledTexImageUnit != -1)
       key->texture_enabled_global = 1;
 
    for (i = 0; i < MAX_TEXTURE_COORD_UNITS; i++) {
       struct gl_texture_unit *texUnit = &ctx->Texture.Unit[i];
 
-      if (texUnit->_ReallyEnabled)
+      if (texUnit->_Current)
         key->unit[i].texunit_really_enabled = 1;
 
       if (ctx->Point.PointSprite)
@@ -303,7 +302,7 @@ struct ureg {
 struct tnl_program {
    const struct state_key *state;
    struct gl_vertex_program *program;
-   GLint max_inst;  /** number of instructions allocated for program */
+   GLuint max_inst;  /** number of instructions allocated for program */
    GLboolean mvp_with_dp4;
 
    GLuint temp_in_use;
@@ -480,7 +479,7 @@ static struct ureg register_const4f( struct tnl_program *p,
    values[3].f = s3;
    idx = _mesa_add_unnamed_constant( p->program->Base.Parameters, values, 4,
                                      &swizzle );
-   ASSERT(swizzle == SWIZZLE_NOOP);
+   assert(swizzle == SWIZZLE_NOOP);
    return make_ureg(PROGRAM_CONSTANT, idx);
 }
 
@@ -531,7 +530,7 @@ static void emit_arg( struct prog_src_register *src,
    src->Abs = 0;
    src->RelAddr = 0;
    /* Check that bitfield sizes aren't exceeded */
-   ASSERT(src->Index == reg.idx);
+   assert(src->Index == reg.idx);
 }
 
 
@@ -545,7 +544,7 @@ static void emit_dst( struct prog_dst_register *dst,
    dst->CondMask = COND_TR;  /* always pass cond test */
    dst->CondSwizzle = SWIZZLE_NOOP;
    /* Check that bitfield sizes aren't exceeded */
-   ASSERT(dst->Index == reg.idx);
+   assert(dst->Index == reg.idx);
 }
 
 
@@ -579,7 +578,7 @@ static void emit_op3fn(struct tnl_program *p,
    GLuint nr;
    struct prog_instruction *inst;
 
-   assert((GLint) p->program->Base.NumInstructions <= p->max_inst);
+   assert(p->program->Base.NumInstructions <= p->max_inst);
 
    if (p->program->Base.NumInstructions == p->max_inst) {
       /* need to extend the program's instruction array */
@@ -608,7 +607,6 @@ static void emit_op3fn(struct tnl_program *p,
 
    inst = &p->program->Base.Instructions[nr];
    inst->Opcode = (enum prog_opcode) op;
-   inst->Data = 0;
 
    emit_arg( &inst->SrcReg[0], src0 );
    emit_arg( &inst->SrcReg[1], src1 );
@@ -700,16 +698,11 @@ static void emit_normalize_vec3( struct tnl_program *p,
                                 struct ureg dest,
                                 struct ureg src )
 {
-#if 0
-   /* XXX use this when drivers are ready for NRM3 */
-   emit_op1(p, OPCODE_NRM3, dest, WRITEMASK_XYZ, src);
-#else
    struct ureg tmp = get_temp(p);
    emit_op2(p, OPCODE_DP3, tmp, WRITEMASK_X, src, src);
    emit_op1(p, OPCODE_RSQ, tmp, WRITEMASK_X, tmp);
    emit_op2(p, OPCODE_MUL, dest, 0, src, swizzle1(tmp, X));
    release_temp(p, tmp);
-#endif
 }
 
 
@@ -1313,20 +1306,22 @@ static void build_fog( struct tnl_program *p )
 
       switch (p->state->fog_distance_mode) {
       case FDM_EYE_RADIAL: /* Z = sqrt(Xe*Xe + Ye*Ye + Ze*Ze) */
-       input = get_eye_position(p);
-       emit_op2(p, OPCODE_DP3, fog, WRITEMASK_X, input, input);
-       emit_op1(p, OPCODE_RSQ, fog, WRITEMASK_X, fog);
-       emit_op1(p, OPCODE_RCP, fog, WRITEMASK_X, fog);
-       break;
+         input = get_eye_position(p);
+         emit_op2(p, OPCODE_DP3, fog, WRITEMASK_X, input, input);
+         emit_op1(p, OPCODE_RSQ, fog, WRITEMASK_X, fog);
+         emit_op1(p, OPCODE_RCP, fog, WRITEMASK_X, fog);
+         break;
       case FDM_EYE_PLANE: /* Z = Ze */
-       input = get_eye_position_z(p);
-       emit_op1(p, OPCODE_MOV, fog, WRITEMASK_X, input);
-       break;
+         input = get_eye_position_z(p);
+         emit_op1(p, OPCODE_MOV, fog, WRITEMASK_X, input);
+         break;
       case FDM_EYE_PLANE_ABS: /* Z = abs(Ze) */
-       input = get_eye_position_z(p);
-       emit_op1(p, OPCODE_ABS, fog, WRITEMASK_X, input);
-       break;
-      default: assert(0); break; /* can't happen */
+         input = get_eye_position_z(p);
+         emit_op1(p, OPCODE_ABS, fog, WRITEMASK_X, input);
+         break;
+      default:
+         assert(!"Bad fog mode in build_fog()");
+         break;
       }
 
    }
@@ -1407,7 +1402,7 @@ static void build_texture_transform( struct tnl_program *p )
 
    for (i = 0; i < MAX_TEXTURE_COORD_UNITS; i++) {
 
-      if (!(p->state->fragprog_inputs_read & FRAG_BIT_TEX(i)))
+      if (!(p->state->fragprog_inputs_read & VARYING_BIT_TEX(i)))
         continue;
 
       if (p->state->unit[i].coord_replace)
@@ -1575,22 +1570,22 @@ static void build_tnl_program( struct tnl_program *p )
 
    /* Lighting calculations:
     */
-   if (p->state->fragprog_inputs_read & (FRAG_BIT_COL0|FRAG_BIT_COL1)) {
+   if (p->state->fragprog_inputs_read & (VARYING_BIT_COL0|VARYING_BIT_COL1)) {
       if (p->state->light_global_enabled)
         build_lighting(p);
       else {
-        if (p->state->fragprog_inputs_read & FRAG_BIT_COL0)
+        if (p->state->fragprog_inputs_read & VARYING_BIT_COL0)
            emit_passthrough(p, VERT_ATTRIB_COLOR0, VARYING_SLOT_COL0);
 
-        if (p->state->fragprog_inputs_read & FRAG_BIT_COL1)
+        if (p->state->fragprog_inputs_read & VARYING_BIT_COL1)
            emit_passthrough(p, VERT_ATTRIB_COLOR1, VARYING_SLOT_COL1);
       }
    }
 
-   if (p->state->fragprog_inputs_read & FRAG_BIT_FOGC)
+   if (p->state->fragprog_inputs_read & VARYING_BIT_FOGC)
       build_fog(p);
 
-   if (p->state->fragprog_inputs_read & FRAG_BITS_TEX_ANY)
+   if (p->state->fragprog_inputs_read & VARYING_BITS_TEX_ANY)
       build_texture_transform(p);
 
    if (p->state->point_attenuated)
@@ -1681,8 +1676,8 @@ _mesa_get_fixed_func_vertex_program(struct gl_context *ctx)
          return NULL;
 
       create_new_program( &key, prog,
-                          ctx->mvp_with_dp4,
-                          ctx->Const.VertexProgram.MaxTemps );
+                          ctx->Const.ShaderCompilerOptions[MESA_SHADER_VERTEX].OptimizeForAOS,
+                          ctx->Const.Program[MESA_SHADER_VERTEX].MaxTemps );
 
 #if 0
       if (ctx->Driver.ProgramStringNotify)