Added ctx->Texture._EnabledCoordUnits bitfield.
[mesa.git] / src / mesa / tnl / t_vb_texgen.c
index 81751508bfb3737f9e0b14990270ff8a6f9549b5..9a954bf485151ffaa03dbe1d06387931543fbf2b 100644 (file)
@@ -1,10 +1,10 @@
-/* $Id: t_vb_texgen.c,v 1.13 2002/06/29 19:48:17 brianp Exp $ */
+/* $Id: t_vb_texgen.c,v 1.19 2003/03/31 16:48:35 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
- * Version:  3.5
+ * Version:  5.1
  *
- * Copyright (C) 1999-2001  Brian Paul   All Rights Reserved.
+ * Copyright (C) 1999-2003  Brian Paul   All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -24,8 +24,8 @@
  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  *
  * Authors:
- *    Brian Paul <brian@valinux.com>
- *    Keith Whitwell <keithw@valinux.com>
+ *    Brian Paul
+ *    Keith Whitwell <keith@tungstengraphics.com>
  */
 
 
@@ -33,8 +33,7 @@
 #include "colormac.h"
 #include "context.h"
 #include "macros.h"
-#include "mmath.h"
-#include "mem.h"
+#include "imports.h"
 #include "mtypes.h"
 
 #include "math/m_xform.h"
@@ -59,9 +58,9 @@ struct texgen_stage_data {
 
    /* Per-texunit derived state.
     */
-   GLuint TexgenSize[MAX_TEXTURE_UNITS];
-   GLuint TexgenHoles[MAX_TEXTURE_UNITS];
-   texgen_func TexgenFunc[MAX_TEXTURE_UNITS];
+   GLuint TexgenSize[MAX_TEXTURE_COORD_UNITS];
+   GLuint TexgenHoles[MAX_TEXTURE_COORD_UNITS];
+   texgen_func TexgenFunc[MAX_TEXTURE_COORD_UNITS];
 
    /* Temporary values used in texgen.
     */
@@ -70,7 +69,7 @@ struct texgen_stage_data {
 
    /* Buffered outputs of the stage.
     */
-   GLvector4f texcoord[MAX_TEXTURE_UNITS];
+   GLvector4f texcoord[MAX_TEXTURE_COORD_UNITS];
 };
 
 
@@ -114,7 +113,7 @@ static void build_m3( GLfloat f[][3], GLfloat m[],
       fz = f[i][2] = u[2] - norm[2] * two_nu;
       m[i] = fx * fx + fy * fy + (fz + 1.0F) * (fz + 1.0F);
       if (m[i] != 0.0F) {
-        m[i] = 0.5F / (GLfloat) GL_SQRT(m[i]);
+        m[i] = 0.5F * _mesa_inv_sqrtf(m[i]);
       }
    }
 }
@@ -143,7 +142,7 @@ static void build_m2( GLfloat f[][3], GLfloat m[],
       fz = f[i][2] = u[2] - norm[2] * two_nu;
       m[i] = fx * fx + fy * fy + (fz + 1.0F) * (fz + 1.0F);
       if (m[i] != 0.0F) {
-        m[i] = 0.5F / (GLfloat) GL_SQRT(m[i]);
+        m[i] = 0.5F * _mesa_inv_sqrtf(m[i]);
       }
    }
 }
@@ -368,7 +367,7 @@ static void texgen( GLcontext *ctx,
    GLuint count = VB->Count;
    GLfloat (*f)[3] = store->tmp_f;
    GLfloat *m = store->tmp_m;
-        GLuint holes = 0;
+   GLuint holes = 0;
 
 
    if (texUnit->_GenFlags & TEXGEN_NEED_M) {
@@ -400,6 +399,7 @@ static void texgen( GLcontext *ctx,
    }
 
    if (holes) {
+      if (holes & VEC_DIRTY_3) _mesa_vector4f_clean_elem(out, count, 3);
       if (holes & VEC_DIRTY_2) _mesa_vector4f_clean_elem(out, count, 2);
       if (holes & VEC_DIRTY_1) _mesa_vector4f_clean_elem(out, count, 1);
       if (holes & VEC_DIRTY_0) _mesa_vector4f_clean_elem(out, count, 0);
@@ -662,7 +662,7 @@ static void free_texgen_data( struct gl_pipeline_stage *stage )
    GLuint i;
 
    if (store) {
-      for (i = 0 ; i < MAX_TEXTURE_UNITS ; i++)
+      for (i = 0 ; i < MAX_TEXTURE_COORD_UNITS ; i++)
         if (store->texcoord[i].data)
            _mesa_vector4f_free( &store->texcoord[i] );