Merge branch 'master' into i915-unification
[mesa.git] / src / mesa / swrast / s_triangle.c
index b17c43546058859238517462e0b94983ca55fb55..fc9d29bbf7f85a9abe0ca34c7296cfb2f500f60a 100644 (file)
@@ -1,8 +1,8 @@
 /*
  * Mesa 3-D graphics library
- * Version:  6.5.2
+ * Version:  6.5.3
  *
- * Copyright (C) 1999-2006  Brian Paul   All Rights Reserved.
+ * Copyright (C) 1999-2007  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"),
@@ -67,24 +67,9 @@ _swrast_culltriangle( GLcontext *ctx,
 
 
 /*
- * Render a flat-shaded color index triangle.
+ * Render a smooth or flat-shaded color index triangle.
  */
-#define NAME flat_ci_triangle
-#define INTERP_Z 1
-#define INTERP_FOG 1
-#define SETUP_CODE                     \
-   span.interpMask |= SPAN_INDEX;      \
-   span.index = FloatToFixed(v2->index);\
-   span.indexStep = 0;
-#define RENDER_SPAN( span )  _swrast_write_index_span(ctx, &span);
-#include "s_tritemp.h"
-
-
-
-/*
- * Render a smooth-shaded color index triangle.
- */
-#define NAME smooth_ci_triangle
+#define NAME ci_triangle
 #define INTERP_Z 1
 #define INTERP_FOG 1
 #define INTERP_INDEX 1
@@ -139,7 +124,7 @@ _swrast_culltriangle( GLcontext *ctx,
  * Render an RGB, GL_DECAL, textured triangle.
  * Interpolate S,T only w/out mipmapping or perspective correction.
  *
- * No fog.
+ * No fog.  No depth testing.
  */
 #define NAME simple_textured_triangle
 #define INTERP_INT_TEX 1
@@ -676,13 +661,13 @@ fast_persp_span(GLcontext *ctx, SWspan *span,
    const GLuint savedTexEnable = ctx->Texture._EnabledUnits;
    ctx->Texture._EnabledUnits = 0;
 
-   tex_coord[0] = span->tex[0][0]  * (info->smask + 1);
-   tex_step[0] = span->texStepX[0][0] * (info->smask + 1);
-   tex_coord[1] = span->tex[0][1] * (info->tmask + 1);
-   tex_step[1] = span->texStepX[0][1] * (info->tmask + 1);
-   /* span->tex[0][2] only if 3D-texturing, here only 2D */
-   tex_coord[2] = span->tex[0][3];
-   tex_step[2] = span->texStepX[0][3];
+   tex_coord[0] = span->attrStart[FRAG_ATTRIB_TEX0][0]  * (info->smask + 1);
+   tex_step[0] = span->attrStepX[FRAG_ATTRIB_TEX0][0] * (info->smask + 1);
+   tex_coord[1] = span->attrStart[FRAG_ATTRIB_TEX0][1] * (info->tmask + 1);
+   tex_step[1] = span->attrStepX[FRAG_ATTRIB_TEX0][1] * (info->tmask + 1);
+   /* span->attrStart[FRAG_ATTRIB_TEX0][2] only if 3D-texturing, here only 2D */
+   tex_coord[2] = span->attrStart[FRAG_ATTRIB_TEX0][3];
+   tex_step[2] = span->attrStepX[FRAG_ATTRIB_TEX0][3];
 
    switch (info->filter) {
    case GL_NEAREST:
@@ -803,7 +788,7 @@ fast_persp_span(GLcontext *ctx, SWspan *span,
 #define INTERP_FOG 1
 #define INTERP_RGB 1
 #define INTERP_ALPHA 1
-#define INTERP_TEX 1
+#define INTERP_ATTRIBS 1
 
 #define SETUP_CODE                                                     \
    struct persp_info info;                                             \
@@ -865,40 +850,21 @@ fast_persp_span(GLcontext *ctx, SWspan *span,
 
 
 /*
- * Render a smooth-shaded, textured, RGBA triangle.
- * Interpolate S,T,R with perspective correction, w/out mipmapping.
+ * Render an RGBA triangle with arbitrary attributes.
  */
-#define NAME general_textured_triangle
+#define NAME general_triangle
 #define INTERP_Z 1
 #define INTERP_W 1
 #define INTERP_FOG 1
 #define INTERP_RGB 1
 #define INTERP_SPEC 1
 #define INTERP_ALPHA 1
-#define INTERP_TEX 1
+#define INTERP_ATTRIBS 1
 #define RENDER_SPAN( span )   _swrast_write_rgba_span(ctx, &span);
 #include "s_tritemp.h"
 
 
 
-/*
- * This is the big one!
- * Interpolate Z, RGB, Alpha, specular, fog, N sets of texture coordinates, and varying floats.
- * Yup, it's slow.
- */
-#define NAME multitextured_triangle
-#define INTERP_Z 1
-#define INTERP_W 1
-#define INTERP_FOG 1
-#define INTERP_RGB 1
-#define INTERP_ALPHA 1
-#define INTERP_SPEC 1
-#define INTERP_MULTITEX 1
-#define INTERP_VARYING 1
-#define RENDER_SPAN( span )   _swrast_write_rgba_span(ctx, &span);
-#include "s_tritemp.h"
-
-
 
 /*
  * Special tri function for occlusion testing
@@ -1073,8 +1039,14 @@ _swrast_choose_triangle( GLcontext *ctx )
          }
       }
 
-      if (ctx->Texture._EnabledCoordUnits || ctx->FragmentProgram._Enabled ||
-          ctx->ATIFragmentShader._Enabled || ctx->ShaderObjects._FragmentShaderPresent) {
+      if (!rgbmode) {
+         USE(ci_triangle);
+         return;
+      }
+
+      if (ctx->Texture._EnabledCoordUnits ||
+          ctx->FragmentProgram._Current ||
+          ctx->ATIFragmentShader._Enabled) {
          /* Ugh, we do a _lot_ of tests to pick the best textured tri func */
          const struct gl_texture_object *texObj2D;
          const struct gl_texture_image *texImg;
@@ -1089,9 +1061,8 @@ _swrast_choose_triangle( GLcontext *ctx )
 
          /* First see if we can use an optimized 2-D texture function */
          if (ctx->Texture._EnabledCoordUnits == 0x1
-             && !ctx->FragmentProgram._Enabled
+             && !ctx->FragmentProgram._Current
              && !ctx->ATIFragmentShader._Enabled
-             && !ctx->ShaderObjects._FragmentShaderPresent
              && ctx->Texture.Unit[0]._ReallyEnabled == TEXTURE_2D_BIT
              && texObj2D->WrapS == GL_REPEAT
              && texObj2D->WrapT == GL_REPEAT
@@ -1121,7 +1092,7 @@ _swrast_choose_triangle( GLcontext *ctx )
               }
               else {
 #if (CHAN_BITS == 16 || CHAN_BITS == 32)
-                  USE(general_textured_triangle);
+                  USE(general_triangle);
 #else
                   USE(affine_textured_triangle);
 #endif
@@ -1129,7 +1100,7 @@ _swrast_choose_triangle( GLcontext *ctx )
            }
            else {
 #if (CHAN_BITS == 16 || CHAN_BITS == 32)
-               USE(general_textured_triangle);
+               USE(general_triangle);
 #else
                USE(persp_textured_triangle);
 #endif
@@ -1137,33 +1108,18 @@ _swrast_choose_triangle( GLcontext *ctx )
         }
          else {
             /* general case textured triangles */
-            if (ctx->Texture._EnabledCoordUnits > 1) {
-               USE(multitextured_triangle);
-            }
-            else {
-               USE(general_textured_triangle);
-            }
+            USE(general_triangle);
          }
       }
       else {
          ASSERT(!ctx->Texture._EnabledCoordUnits);
         if (ctx->Light.ShadeModel==GL_SMOOTH) {
            /* smooth shaded, no texturing, stippled or some raster ops */
-            if (rgbmode) {
-              USE(smooth_rgba_triangle);
-            }
-            else {
-               USE(smooth_ci_triangle);
-            }
+            USE(smooth_rgba_triangle);
         }
         else {
            /* flat shaded, no texturing, stippled or some raster ops */
-            if (rgbmode) {
-              USE(flat_rgba_triangle);
-            }
-            else {
-               USE(flat_ci_triangle);
-            }
+            USE(flat_rgba_triangle);
         }
       }
    }