Mesa (master): radeon: share common fog code between radeon and r200

Alex Deucher agd5f at kemper.freedesktop.org
Tue Jan 17 23:11:19 UTC 2012


Module: Mesa
Branch: master
Commit: 94556f359450acebe87d6c9b4f4fd8ccf78589d8
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=94556f359450acebe87d6c9b4f4fd8ccf78589d8

Author: Alex Deucher <alexander.deucher at amd.com>
Date:   Tue Jan 17 18:09:25 2012 -0500

radeon: share common fog code between radeon and r200

Signed-off-by: Alex Deucher <alexander.deucher at amd.com>

---

 src/mesa/drivers/dri/r200/Makefile               |    3 +-
 src/mesa/drivers/dri/r200/r200_context.c         |    3 +-
 src/mesa/drivers/dri/r200/r200_maos_arrays.c     |   40 +------
 src/mesa/drivers/dri/r200/r200_tcl.c             |   84 ---------------
 src/mesa/drivers/dri/r200/r200_tcl.h             |    4 -
 src/mesa/drivers/dri/r200/radeon_fog.c           |    1 +
 src/mesa/drivers/dri/r200/radeon_fog.h           |    1 +
 src/mesa/drivers/dri/radeon/Makefile             |    3 +-
 src/mesa/drivers/dri/radeon/radeon_context.c     |    1 +
 src/mesa/drivers/dri/radeon/radeon_dma.c         |   36 ++++++
 src/mesa/drivers/dri/radeon/radeon_dma.h         |    2 +
 src/mesa/drivers/dri/radeon/radeon_fog.c         |  125 ++++++++++++++++++++++
 src/mesa/drivers/dri/radeon/radeon_fog.h         |   44 ++++++++
 src/mesa/drivers/dri/radeon/radeon_maos_arrays.c |   51 +--------
 src/mesa/drivers/dri/radeon/radeon_maos_verts.c  |    2 +-
 src/mesa/drivers/dri/radeon/radeon_tcl.c         |   83 --------------
 src/mesa/drivers/dri/radeon/radeon_tcl.h         |    3 -
 17 files changed, 227 insertions(+), 259 deletions(-)

diff --git a/src/mesa/drivers/dri/r200/Makefile b/src/mesa/drivers/dri/r200/Makefile
index 3362d04..e53d64b 100644
--- a/src/mesa/drivers/dri/r200/Makefile
+++ b/src/mesa/drivers/dri/r200/Makefile
@@ -20,7 +20,8 @@ RADEON_COMMON_SOURCES = \
 	radeon_span.c \
 	radeon_texture.c \
 	radeon_tex_copy.c \
-	radeon_tile.c
+	radeon_tile.c \
+	radeon_fog.c
 
 DRIVER_SOURCES = r200_context.c \
 		 r200_ioctl.c \
diff --git a/src/mesa/drivers/dri/r200/r200_context.c b/src/mesa/drivers/dri/r200/r200_context.c
index d7a6489..244973e 100644
--- a/src/mesa/drivers/dri/r200/r200_context.c
+++ b/src/mesa/drivers/dri/r200/r200_context.c
@@ -60,6 +60,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "r200_vertprog.h"
 #include "radeon_queryobj.h"
 #include "r200_blit.h"
+#include "radeon_fog.h"
 
 #include "radeon_span.h"
 
@@ -230,7 +231,7 @@ GLboolean r200CreateContext( gl_api api,
    rmesa->radeon.radeonScreen = screen;
    r200_init_vtbl(&rmesa->radeon);
    /* init exp fog table data */
-   r200InitStaticFogData();
+   radeonInitStaticFogData();
 
    /* Parse configuration files.
     * Do this here so that initialMaxAnisotropy is set before we create
diff --git a/src/mesa/drivers/dri/r200/r200_maos_arrays.c b/src/mesa/drivers/dri/r200/r200_maos_arrays.c
index dee7303..973dcaf 100644
--- a/src/mesa/drivers/dri/r200/r200_maos_arrays.c
+++ b/src/mesa/drivers/dri/r200/r200_maos_arrays.c
@@ -70,36 +70,6 @@ do {						\
 } while (0)
 #endif
 
-static void r200_emit_vecfog(struct gl_context *ctx, struct radeon_aos *aos,
-			     GLvoid *data, int stride, int count)
-{
-	radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
-	GLfloat *out;
-	int i;
-	int size = 1;
-
-	if (stride == 0) {
-		radeonAllocDmaRegion(rmesa, &aos->bo, &aos->offset, size * 4, 32);
-		count = 1;
-		aos->stride = 0;
-	} else {
-		radeonAllocDmaRegion(rmesa, &aos->bo, &aos->offset, size * count * 4, 32);
-		aos->stride = size;
-	}
-
-	aos->components = size;
-	aos->count = count;
-
-	radeon_bo_map(aos->bo, 1);
-	out = (GLfloat*)((char*)aos->bo->ptr + aos->offset);
-	for (i = 0; i < count; i++) {
-	  out[0] = r200ComputeFogBlendFactor( ctx, *(GLfloat *)data );
-	  out++;
-	  data += stride;
-	}
-	radeon_bo_unmap(aos->bo);
-}
-
 /* Emit any changed arrays to new GART memory, re-emit a packet to
  * update the arrays.  
  */
@@ -153,11 +123,11 @@ void r200EmitArrays( struct gl_context *ctx, GLubyte *vimap_rev )
 				       VB->AttribPtr[attrib]->stride,
 				       count);
 	       else
-		 r200_emit_vecfog( ctx,
-				   &(rmesa->radeon.tcl.aos[nr]),
-				   (char *)VB->AttribPtr[attrib]->data,
-				   VB->AttribPtr[attrib]->stride,
-				   count);
+		 rcommon_emit_vecfog( ctx,
+				      &(rmesa->radeon.tcl.aos[nr]),
+				      (char *)VB->AttribPtr[attrib]->data,
+				      VB->AttribPtr[attrib]->stride,
+				      count);
 	    }
 	    vfmt0 |= R200_VTX_DISCRETE_FOG;
 	    goto after_emit;
diff --git a/src/mesa/drivers/dri/r200/r200_tcl.c b/src/mesa/drivers/dri/r200/r200_tcl.c
index 3ece7a3..ba8d0db 100644
--- a/src/mesa/drivers/dri/r200/r200_tcl.c
+++ b/src/mesa/drivers/dri/r200/r200_tcl.c
@@ -284,90 +284,6 @@ void r200TclPrimitive( struct gl_context *ctx,
    }
 }
 
-
-/**********************************************************************/
-/*             Fog blend factor computation for hw tcl                */
-/*             same calculation used as in t_vb_fog.c                 */
-/**********************************************************************/
-
-#define FOG_EXP_TABLE_SIZE 256
-#define FOG_MAX (10.0)
-#define EXP_FOG_MAX .0006595
-#define FOG_INCR (FOG_MAX/FOG_EXP_TABLE_SIZE)
-static GLfloat exp_table[FOG_EXP_TABLE_SIZE];
-
-#if 1
-#define NEG_EXP( result, narg )						\
-do {									\
-   GLfloat f = (GLfloat) (narg * (1.0/FOG_INCR));			\
-   GLint k = (GLint) f;							\
-   if (k > FOG_EXP_TABLE_SIZE-2) 					\
-      result = (GLfloat) EXP_FOG_MAX;					\
-   else									\
-      result = exp_table[k] + (f-k)*(exp_table[k+1]-exp_table[k]);	\
-} while (0)
-#else
-#define NEG_EXP( result, narg )					\
-do {								\
-   result = exp(-narg);						\
-} while (0)
-#endif
-
-
-/**
- * Initialize the exp_table[] lookup table for approximating exp().
- */
-void
-r200InitStaticFogData( void )
-{
-   GLfloat f = 0.0F;
-   GLint i = 0;
-   for ( ; i < FOG_EXP_TABLE_SIZE ; i++, f += FOG_INCR) {
-      exp_table[i] = (GLfloat) exp(-f);
-   }
-}
-
-
-/**
- * Compute per-vertex fog blend factors from fog coordinates by
- * evaluating the GL_LINEAR, GL_EXP or GL_EXP2 fog function.
- * Fog coordinates are distances from the eye (typically between the
- * near and far clip plane distances).
- * Note the fog (eye Z) coords may be negative so we use ABS(z) below.
- * Fog blend factors are in the range [0,1].
- */
-float
-r200ComputeFogBlendFactor( struct gl_context *ctx, GLfloat fogcoord )
-{
-   GLfloat end  = ctx->Fog.End;
-   GLfloat d, temp;
-   const GLfloat z = FABSF(fogcoord);
-
-   switch (ctx->Fog.Mode) {
-   case GL_LINEAR:
-      if (ctx->Fog.Start == ctx->Fog.End)
-         d = 1.0F;
-      else
-         d = 1.0F / (ctx->Fog.End - ctx->Fog.Start);
-      temp = (end - z) * d;
-      return CLAMP(temp, 0.0F, 1.0F);
-      break;
-   case GL_EXP:
-      d = ctx->Fog.Density;
-      NEG_EXP( temp, d * z );
-      return temp;
-      break;
-   case GL_EXP2:
-      d = ctx->Fog.Density*ctx->Fog.Density;
-      NEG_EXP( temp, d * z * z );
-      return temp;
-      break;
-   default:
-      _mesa_problem(ctx, "Bad fog mode in make_fog_coord");
-      return 0;
-   }
-}
-
 /**
  * Predict total emit size for next rendering operation so there is no flush in middle of rendering
  * Prediction has to aim towards the best possible value that is worse than worst case scenario
diff --git a/src/mesa/drivers/dri/r200/r200_tcl.h b/src/mesa/drivers/dri/r200/r200_tcl.h
index 53a1f11..d324d5f 100644
--- a/src/mesa/drivers/dri/r200/r200_tcl.h
+++ b/src/mesa/drivers/dri/r200/r200_tcl.h
@@ -45,10 +45,6 @@ extern void r200EmitPrimitive( struct gl_context *ctx, GLuint first, GLuint last
 
 extern void r200TclFallback( struct gl_context *ctx, GLuint bit, GLboolean mode );
 
-extern void r200InitStaticFogData( void );
-
-extern float r200ComputeFogBlendFactor( struct gl_context *ctx, GLfloat fogcoord );
-					      
 #define R200_TCL_FALLBACK_RASTER            0x1 /* rasterization */
 #define R200_TCL_FALLBACK_UNFILLED          0x2 /* unfilled tris */
 #define R200_TCL_FALLBACK_LIGHT_TWOSIDE     0x4 /* twoside tris */
diff --git a/src/mesa/drivers/dri/r200/radeon_fog.c b/src/mesa/drivers/dri/r200/radeon_fog.c
new file mode 120000
index 0000000..231aa4f
--- /dev/null
+++ b/src/mesa/drivers/dri/r200/radeon_fog.c
@@ -0,0 +1 @@
+../radeon/radeon_fog.c
\ No newline at end of file
diff --git a/src/mesa/drivers/dri/r200/radeon_fog.h b/src/mesa/drivers/dri/r200/radeon_fog.h
new file mode 120000
index 0000000..76c40f6
--- /dev/null
+++ b/src/mesa/drivers/dri/r200/radeon_fog.h
@@ -0,0 +1 @@
+../radeon/radeon_fog.h
\ No newline at end of file
diff --git a/src/mesa/drivers/dri/radeon/Makefile b/src/mesa/drivers/dri/radeon/Makefile
index 3cb1dc5..87af26e 100644
--- a/src/mesa/drivers/dri/radeon/Makefile
+++ b/src/mesa/drivers/dri/radeon/Makefile
@@ -21,7 +21,8 @@ RADEON_COMMON_SOURCES = \
 	radeon_span.c \
 	radeon_texture.c \
 	radeon_tex_copy.c \
-	radeon_tile.c
+	radeon_tile.c \
+	radeon_fog.c
 
 DRIVER_SOURCES = \
 	radeon_context.c \
diff --git a/src/mesa/drivers/dri/radeon/radeon_context.c b/src/mesa/drivers/dri/radeon/radeon_context.c
index 40fd4dc..9881d00 100644
--- a/src/mesa/drivers/dri/radeon/radeon_context.c
+++ b/src/mesa/drivers/dri/radeon/radeon_context.c
@@ -63,6 +63,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "radeon_tcl.h"
 #include "radeon_queryobj.h"
 #include "radeon_blit.h"
+#include "radeon_fog.h"
 
 #include "utils.h"
 #include "xmlpool.h" /* for symbolic values of enum-type options */
diff --git a/src/mesa/drivers/dri/radeon/radeon_dma.c b/src/mesa/drivers/dri/radeon/radeon_dma.c
index b49486f..61cddda 100644
--- a/src/mesa/drivers/dri/radeon/radeon_dma.c
+++ b/src/mesa/drivers/dri/radeon/radeon_dma.c
@@ -32,6 +32,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #include <errno.h>
 #include "radeon_common.h"
+#include "radeon_fog.h"
 #include "main/simple_list.h"
 
 #if defined(USE_X86_ASM)
@@ -165,6 +166,41 @@ void rcommon_emit_vector(struct gl_context * ctx, struct radeon_aos *aos,
 	radeon_bo_unmap(aos->bo);
 }
 
+void rcommon_emit_vecfog(struct gl_context *ctx, struct radeon_aos *aos,
+			 GLvoid *data, int stride, int count)
+{
+	int i;
+	float *out;
+	int size = 1;
+	radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+
+	if (RADEON_DEBUG & RADEON_VERTS)
+		fprintf(stderr, "%s count %d stride %d\n",
+			__FUNCTION__, count, stride);
+
+	if (stride == 0) {
+		radeonAllocDmaRegion( rmesa, &aos->bo, &aos->offset, size * 4, 32 );
+		count = 1;
+		aos->stride = 0;
+	} else {
+		radeonAllocDmaRegion(rmesa, &aos->bo, &aos->offset, size * count * 4, 32);
+		aos->stride = size;
+	}
+
+	aos->components = size;
+	aos->count = count;
+
+	/* Emit the data */
+	radeon_bo_map(aos->bo, 1);
+	out = (float*)((char*)aos->bo->ptr + aos->offset);
+	for (i = 0; i < count; i++) {
+		out[0] = radeonComputeFogBlendFactor( ctx, *(GLfloat *)data );
+		out++;
+		data += stride;
+	}
+	radeon_bo_unmap(aos->bo);
+}
+
 void radeon_init_dma(radeonContextPtr rmesa)
 {
 	make_empty_list(&rmesa->dma.free);
diff --git a/src/mesa/drivers/dri/radeon/radeon_dma.h b/src/mesa/drivers/dri/radeon/radeon_dma.h
index ad6a3b8..db7b84e 100644
--- a/src/mesa/drivers/dri/radeon/radeon_dma.h
+++ b/src/mesa/drivers/dri/radeon/radeon_dma.h
@@ -40,6 +40,8 @@ void radeonEmitVec16(uint32_t *out, const GLvoid * data, int stride, int count);
 
 void rcommon_emit_vector(struct gl_context * ctx, struct radeon_aos *aos,
 			 const GLvoid * data, int size, int stride, int count);
+void rcommon_emit_vecfog(struct gl_context *ctx, struct radeon_aos *aos,
+			 GLvoid *data, int stride, int count);
 
 void radeonReturnDmaRegion(radeonContextPtr rmesa, int return_bytes);
 void radeonRefillCurrentDmaRegion(radeonContextPtr rmesa, int size);
diff --git a/src/mesa/drivers/dri/radeon/radeon_fog.c b/src/mesa/drivers/dri/radeon/radeon_fog.c
new file mode 100644
index 0000000..bd2642b
--- /dev/null
+++ b/src/mesa/drivers/dri/radeon/radeon_fog.c
@@ -0,0 +1,125 @@
+/**************************************************************************
+
+Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
+                     Tungsten Graphics Inc., Austin, Texas.
+
+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"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial
+portions of the Software.
+
+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 NONINFRINGEMENT.
+IN NO EVENT SHALL THE COPYRIGHT OWNER(S) 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.
+
+**************************************************************************/
+
+/*
+ * Authors:
+ *   Keith Whitwell <keith at tungstengraphics.com>
+ */
+
+#include "main/glheader.h"
+#include "main/imports.h"
+#include "main/context.h"
+#include "main/mtypes.h"
+#include "main/enums.h"
+#include "main/macros.h"
+
+#include "radeon_fog.h"
+
+/**********************************************************************/
+/*             Fog blend factor computation for hw tcl                */
+/*             same calculation used as in t_vb_fog.c                 */
+/**********************************************************************/
+
+#define FOG_EXP_TABLE_SIZE 256
+#define FOG_MAX (10.0)
+#define EXP_FOG_MAX .0006595
+#define FOG_INCR (FOG_MAX/FOG_EXP_TABLE_SIZE)
+static GLfloat exp_table[FOG_EXP_TABLE_SIZE];
+
+#if 1
+#define NEG_EXP( result, narg )						\
+do {									\
+   GLfloat f = (GLfloat) (narg * (1.0/FOG_INCR));			\
+   GLint k = (GLint) f;							\
+   if (k > FOG_EXP_TABLE_SIZE-2) 					\
+      result = (GLfloat) EXP_FOG_MAX;					\
+   else									\
+      result = exp_table[k] + (f-k)*(exp_table[k+1]-exp_table[k]);	\
+} while (0)
+#else
+#define NEG_EXP( result, narg )					\
+do {								\
+   result = exp(-narg);						\
+} while (0)
+#endif
+
+
+/**
+ * Initialize the exp_table[] lookup table for approximating exp().
+ */
+void
+radeonInitStaticFogData( void )
+{
+   GLfloat f = 0.0F;
+   GLint i = 0;
+   for ( ; i < FOG_EXP_TABLE_SIZE ; i++, f += FOG_INCR) {
+      exp_table[i] = (GLfloat) exp(-f);
+   }
+}
+
+/**
+ * Compute per-vertex fog blend factors from fog coordinates by
+ * evaluating the GL_LINEAR, GL_EXP or GL_EXP2 fog function.
+ * Fog coordinates are distances from the eye (typically between the
+ * near and far clip plane distances).
+ * Note the fog (eye Z) coords may be negative so we use ABS(z) below.
+ * Fog blend factors are in the range [0,1].
+ */
+float
+radeonComputeFogBlendFactor( struct gl_context *ctx, GLfloat fogcoord )
+{
+	GLfloat end  = ctx->Fog.End;
+	GLfloat d, temp;
+	const GLfloat z = FABSF(fogcoord);
+
+	switch (ctx->Fog.Mode) {
+	case GL_LINEAR:
+		if (ctx->Fog.Start == ctx->Fog.End)
+			d = 1.0F;
+		else
+			d = 1.0F / (ctx->Fog.End - ctx->Fog.Start);
+		temp = (end - z) * d;
+		return CLAMP(temp, 0.0F, 1.0F);
+		break;
+	case GL_EXP:
+		d = ctx->Fog.Density;
+		NEG_EXP( temp, d * z );
+		return temp;
+		break;
+	case GL_EXP2:
+		d = ctx->Fog.Density*ctx->Fog.Density;
+		NEG_EXP( temp, d * z * z );
+		return temp;
+		break;
+	default:
+		_mesa_problem(ctx, "Bad fog mode in make_fog_coord");
+		return 0;
+	}
+}
+
diff --git a/src/mesa/drivers/dri/radeon/radeon_fog.h b/src/mesa/drivers/dri/radeon/radeon_fog.h
new file mode 100644
index 0000000..0c3b8d5
--- /dev/null
+++ b/src/mesa/drivers/dri/radeon/radeon_fog.h
@@ -0,0 +1,44 @@
+/**************************************************************************
+
+Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
+                     Tungsten Graphics Inc., Austin, Texas.
+
+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"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial
+portions of the Software.
+
+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 NONINFRINGEMENT.
+IN NO EVENT SHALL THE COPYRIGHT OWNER(S) 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.
+
+**************************************************************************/
+
+/*
+ * Authors:
+ *   Keith Whitwell <keith at tungstengraphics.com>
+ */
+
+#ifndef RADEON_FOG_H
+#define RADEON_FOG_H
+
+void
+radeonInitStaticFogData( void );
+
+float
+radeonComputeFogBlendFactor( struct gl_context *ctx, GLfloat fogcoord );
+
+#endif
diff --git a/src/mesa/drivers/dri/radeon/radeon_maos_arrays.c b/src/mesa/drivers/dri/radeon/radeon_maos_arrays.c
index 05aa2cb..3f69105 100644
--- a/src/mesa/drivers/dri/radeon/radeon_maos_arrays.c
+++ b/src/mesa/drivers/dri/radeon/radeon_maos_arrays.c
@@ -48,44 +48,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "radeon_maos.h"
 #include "radeon_tcl.h"
 
-static void emit_vecfog(struct gl_context *ctx, struct radeon_aos *aos,
-			GLvoid *data, int stride, int count)
-{
-   int i;
-   uint32_t *out;
-   int size = 1;
-   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
-
-   if (RADEON_DEBUG & RADEON_VERTS)
-      fprintf(stderr, "%s count %d stride %d\n",
-	      __FUNCTION__, count, stride);
-
-   if (stride == 0) {
-      radeonAllocDmaRegion( rmesa, &aos->bo, &aos->offset, size * 4, 32 );
-      count = 1;
-      aos->stride = 0;
-   }
-   else {
-      radeonAllocDmaRegion(rmesa, &aos->bo, &aos->offset, size * count * 4, 32);
-      aos->stride = size;
-   }
-
-   aos->components = size;
-   aos->count = count;
-
-
-   /* Emit the data
-    */
-   radeon_bo_map(aos->bo, 1);
-   out = (uint32_t*)((char*)aos->bo->ptr + aos->offset);
-   for (i = 0; i < count; i++) {
-      out[0] = radeonComputeFogBlendFactor( ctx, *(GLfloat *)data );
-      out++;
-      data += stride;
-   }
-   radeon_bo_unmap(aos->bo);
-}
-
 static void emit_s0_vec(uint32_t *out, GLvoid *data, int stride, int count)
 {
    int i;
@@ -118,9 +80,6 @@ static void emit_stq_vec(uint32_t *out, GLvoid *data, int stride, int count)
    }
 }
 
-
-
-
 static void emit_tex_vector(struct gl_context *ctx, struct radeon_aos *aos,
 			    GLvoid *data, int size, int stride, int count)
 {
@@ -275,11 +234,11 @@ void radeonEmitArrays( struct gl_context *ctx, GLuint inputs )
    are emitted together but for secondary color not. */
    if (inputs & VERT_BIT_FOG) {
       if (!rmesa->tcl.fog.buf)
-	 emit_vecfog( ctx,
-		      &(rmesa->tcl.aos[nr]),
-		      (char *)VB->AttribPtr[_TNL_ATTRIB_FOG]->data,
-		      VB->AttribPtr[_TNL_ATTRIB_FOG]->stride,
-		      count);
+	 rcommon_emit_vecfog( ctx,
+			      &(rmesa->tcl.aos[nr]),
+			      (char *)VB->AttribPtr[_TNL_ATTRIB_FOG]->data,
+			      VB->AttribPtr[_TNL_ATTRIB_FOG]->stride,
+			      count);
 
       vfmt |= RADEON_CP_VC_FRMT_FPFOG;
       nr++;
diff --git a/src/mesa/drivers/dri/radeon/radeon_maos_verts.c b/src/mesa/drivers/dri/radeon/radeon_maos_verts.c
index 5dac2a3..985ad66 100644
--- a/src/mesa/drivers/dri/radeon/radeon_maos_verts.c
+++ b/src/mesa/drivers/dri/radeon/radeon_maos_verts.c
@@ -47,7 +47,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "radeon_tcl.h"
 #include "radeon_swtcl.h"
 #include "radeon_maos.h"
-
+#include "radeon_fog.h"
 
 #define RADEON_TCL_MAX_SETUP 19
 
diff --git a/src/mesa/drivers/dri/radeon/radeon_tcl.c b/src/mesa/drivers/dri/radeon/radeon_tcl.c
index 06cb807..dee25ae 100644
--- a/src/mesa/drivers/dri/radeon/radeon_tcl.c
+++ b/src/mesa/drivers/dri/radeon/radeon_tcl.c
@@ -276,89 +276,6 @@ void radeonTclPrimitive( struct gl_context *ctx,
    }
 }
 
-/**********************************************************************/
-/*             Fog blend factor computation for hw tcl                */
-/*             same calculation used as in t_vb_fog.c                 */
-/**********************************************************************/
-
-#define FOG_EXP_TABLE_SIZE 256
-#define FOG_MAX (10.0)
-#define EXP_FOG_MAX .0006595
-#define FOG_INCR (FOG_MAX/FOG_EXP_TABLE_SIZE)
-static GLfloat exp_table[FOG_EXP_TABLE_SIZE];
-
-#if 1
-#define NEG_EXP( result, narg )						\
-do {									\
-   GLfloat f = (GLfloat) (narg * (1.0/FOG_INCR));			\
-   GLint k = (GLint) f;							\
-   if (k > FOG_EXP_TABLE_SIZE-2) 					\
-      result = (GLfloat) EXP_FOG_MAX;					\
-   else									\
-      result = exp_table[k] + (f-k)*(exp_table[k+1]-exp_table[k]);	\
-} while (0)
-#else
-#define NEG_EXP( result, narg )					\
-do {								\
-   result = exp(-narg);						\
-} while (0)
-#endif
-
-
-/**
- * Initialize the exp_table[] lookup table for approximating exp().
- */
-void
-radeonInitStaticFogData( void )
-{
-   GLfloat f = 0.0F;
-   GLint i = 0;
-   for ( ; i < FOG_EXP_TABLE_SIZE ; i++, f += FOG_INCR) {
-      exp_table[i] = (GLfloat) exp(-f);
-   }
-}
-
-
-/**
- * Compute per-vertex fog blend factors from fog coordinates by
- * evaluating the GL_LINEAR, GL_EXP or GL_EXP2 fog function.
- * Fog coordinates are distances from the eye (typically between the
- * near and far clip plane distances).
- * Note the fog (eye Z) coords may be negative so we use ABS(z) below.
- * Fog blend factors are in the range [0,1].
- */
-float
-radeonComputeFogBlendFactor( struct gl_context *ctx, GLfloat fogcoord )
-{
-   GLfloat end  = ctx->Fog.End;
-   GLfloat d, temp;
-   const GLfloat z = FABSF(fogcoord);
-
-   switch (ctx->Fog.Mode) {
-   case GL_LINEAR:
-      if (ctx->Fog.Start == ctx->Fog.End)
-         d = 1.0F;
-      else
-         d = 1.0F / (ctx->Fog.End - ctx->Fog.Start);
-      temp = (end - z) * d;
-      return CLAMP(temp, 0.0F, 1.0F);
-      break;
-   case GL_EXP:
-      d = ctx->Fog.Density;
-      NEG_EXP( temp, d * z );
-      return temp;
-      break;
-   case GL_EXP2:
-      d = ctx->Fog.Density*ctx->Fog.Density;
-      NEG_EXP( temp, d * z * z );
-      return temp;
-      break;
-   default:
-      _mesa_problem(ctx, "Bad fog mode in make_fog_coord");
-      return 0;
-   }
-}
-
 /**
  * Predict total emit size for next rendering operation so there is no flush in middle of rendering
  * Prediction has to aim towards the best possible value that is worse than worst case scenario
diff --git a/src/mesa/drivers/dri/radeon/radeon_tcl.h b/src/mesa/drivers/dri/radeon/radeon_tcl.h
index cf19766..7f38fe6 100644
--- a/src/mesa/drivers/dri/radeon/radeon_tcl.h
+++ b/src/mesa/drivers/dri/radeon/radeon_tcl.h
@@ -46,9 +46,6 @@ extern void radeonEmitPrimitive( struct gl_context *ctx, GLuint first, GLuint la
 
 extern void radeonTclFallback( struct gl_context *ctx, GLuint bit, GLboolean mode );
 
-extern void radeonInitStaticFogData( void );
-extern float radeonComputeFogBlendFactor( struct gl_context *ctx, GLfloat fogcoord );
-
 #define RADEON_TCL_FALLBACK_RASTER            0x1 /* rasterization */
 #define RADEON_TCL_FALLBACK_UNFILLED          0x2 /* unfilled tris */
 #define RADEON_TCL_FALLBACK_LIGHT_TWOSIDE     0x4 /* twoside tris */




More information about the mesa-commit mailing list