Add disabled support for GL_EXT_fog_coord. While it seems correct to me, it's
authorEric Anholt <anholt@FreeBSD.org>
Wed, 26 Oct 2005 09:37:53 +0000 (09:37 +0000)
committerEric Anholt <anholt@FreeBSD.org>
Wed, 26 Oct 2005 09:37:53 +0000 (09:37 +0000)
not respecting the coords (or perhaps interpreting them differently?) in my
testing.  However, in the process it led to a fix of a secondary color handling
issue where it would be taken from the wrong offset, I believe, based off of
reading the r200 driver.  Also add a minor tweak to save time in the
fog-but-not-specular case.

src/mesa/drivers/dri/sis/sis_context.c
src/mesa/drivers/dri/sis/sis_fog.c
src/mesa/drivers/dri/sis/sis_state.c
src/mesa/drivers/dri/sis/sis_tris.c

index ebfc1f36ef099e3d69039989520b7537b9657450..7e86c1127cb39fb1d295fe6679f95394bb48c847 100644 (file)
@@ -60,6 +60,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #define need_GL_ARB_multisample
 #define need_GL_ARB_texture_compression
+#define need_GL_EXT_fog_coord
 #define need_GL_EXT_secondary_color
 #include "extension_helper.h"
 
@@ -78,6 +79,7 @@ struct dri_extension card_extensions[] =
     { "GL_ARB_texture_border_clamp",       NULL },
     { "GL_ARB_texture_compression",        GL_ARB_texture_compression_functions },
     { "GL_ARB_texture_mirrored_repeat",    NULL },
+    /*{ "GL_EXT_fog_coord",                  GL_EXT_fog_coord_functions },*/
     { "GL_EXT_texture_lod_bias",           NULL },
     { "GL_EXT_secondary_color",            GL_EXT_secondary_color_functions },
     { "GL_EXT_stencil_wrap",               NULL },
index da36b3d795fe0283f87ffdf911298e15b9747a38..fe9a3c95d62dd9054eaa30fb4087d0b7e2eea94e 100644 (file)
@@ -53,6 +53,22 @@ sisDDFogfv( GLcontext *ctx, GLenum pname, const GLfloat *params )
 
    switch (pname)
    {
+   case GL_FOG_COORDINATE_SOURCE_EXT:
+      current->hwFog &= ~MASK_FogMode;
+      switch (ctx->Fog.FogCoordinateSource)
+      {
+      case GL_FOG_COORDINATE_EXT:
+         current->hwFog &= ~MASK_FogZLookup;
+         break;
+      case GL_FRAGMENT_DEPTH_EXT:
+         current->hwFog |= MASK_FogZLookup;
+         break;
+      }
+      if (current->hwFog != prev->hwFog) {
+         prev->hwFog = current->hwFog;
+         smesa->GlobalFlag |= GFLAG_FOGSETTING;
+      }
+      break;
    case GL_FOG_MODE:
       current->hwFog &= ~MASK_FogMode;
       switch (ctx->Fog.Mode)
index f41fb3da04f64f35ca94ede93e0cff0e1792cd9e..1a4c32411533df47f2254a80c6f17cfd86250b1f 100644 (file)
@@ -823,6 +823,7 @@ void sisDDInitState( sisContextPtr smesa )
    /* Set initial fog settings. Start and end are the same case.  */
    sisDDFogfv( ctx, GL_FOG_DENSITY, &ctx->Fog.Density );
    sisDDFogfv( ctx, GL_FOG_END, &ctx->Fog.End );
+   sisDDFogfv( ctx, GL_FOG_COORDINATE_SOURCE_EXT, NULL );
    sisDDFogfv( ctx, GL_FOG_MODE, NULL );
 }
 
index 44cbcd667063d402f00371db78123c8995eb51b5..24f6cb9aa878da4b06dc52340837415b9608411f 100644 (file)
@@ -403,21 +403,24 @@ do {                                                              \
 
 #define VERT_COPY_RGBA( v0, v1 ) v0->ui[coloroffset] = v1->ui[coloroffset]
 
-#define VERT_SET_SPEC( v0, c )                                 \
+#define VERT_SET_SPEC( v, c )                                  \
 do {                                                           \
    if (specoffset != 0) {                                      \
-      UNCLAMPED_FLOAT_TO_UBYTE(v0->v.specular.red, (c)[0]);    \
-      UNCLAMPED_FLOAT_TO_UBYTE(v0->v.specular.green, (c)[1]);  \
-      UNCLAMPED_FLOAT_TO_UBYTE(v0->v.specular.blue, (c)[2]);   \
+      sis_color_t *spec = (sis_color_t *)&((v)->ui[specoffset]); \
+      UNCLAMPED_FLOAT_TO_UBYTE(spec->red, (c)[0]);             \
+      UNCLAMPED_FLOAT_TO_UBYTE(spec->green, (c)[1]);           \
+      UNCLAMPED_FLOAT_TO_UBYTE(spec->blue, (c)[2]);            \
    }                                                           \
 } while (0)
-#define VERT_COPY_SPEC( v0, v1 )                       \
-do {                                                   \
-   if (specoffset != 0) {                              \
-      v0->v.specular.red   = v1->v.specular.red;       \
-      v0->v.specular.green = v1->v.specular.green;     \
-      v0->v.specular.blue  = v1->v.specular.blue;      \
-   }                                                   \
+#define VERT_COPY_SPEC( v0, v1 )                               \
+do {                                                           \
+   if (specoffset != 0) {                                      \
+      sis_color_t *spec0 = (sis_color_t *)&((v0)->ui[specoffset]); \
+      sis_color_t *spec1 = (sis_color_t *)&((v1)->ui[specoffset]); \
+      spec0->red   = spec1->red;                               \
+      spec0->green = spec1->green;                             \
+      spec0->blue  = spec1->blue;                              \
+   }                                                           \
 } while (0)
 
 #define VERT_SAVE_RGBA( idx )    color[idx] = v[idx]->ui[coloroffset]
@@ -833,9 +836,6 @@ do {                                                                        \
    smesa->vertex_attrs[smesa->vertex_attr_count].offset = (N);         \
    smesa->vertex_attr_count++;                                         \
 } while (0)
-
-#define SIS_TCL_STATE_BITS \
-       (_TNL_BITS_TEX_ANY | _TNL_BIT_COLOR1 | _TNL_BIT_FOG)
                                
 static void sisRenderStart( GLcontext *ctx )
 {
@@ -880,12 +880,13 @@ static void sisRenderStart( GLcontext *ctx )
 
    EMIT_ATTR(_TNL_ATTRIB_COLOR0, EMIT_4UB_4F_BGRA);
 
+   smesa->specoffset = 0;
    if (index & (_TNL_BIT_COLOR1|_TNL_BIT_FOG)) {
       AGPParseSet |= SiS_PS_HAS_SPECULAR;
-      smesa->specoffset = smesa->coloroffset + 1;
 
       if (index & _TNL_BIT_COLOR1) {
         EMIT_ATTR(_TNL_ATTRIB_COLOR1, EMIT_3UB_3F_BGR);
+        smesa->specoffset = smesa->coloroffset + 1;
       } else {
         EMIT_PAD(3);
       }
@@ -895,8 +896,6 @@ static void sisRenderStart( GLcontext *ctx )
       } else {
         EMIT_PAD(1);
       }
-   } else {
-      smesa->specoffset = 0;
    }
 
    /* projective textures are not supported by the hardware */