Update NEED_SECONDARY_COLOR macro to test if either vertex/fragment
authorBrian Paul <brian.paul@tungstengraphics.com>
Tue, 9 Dec 2003 01:53:03 +0000 (01:53 +0000)
committerBrian Paul <brian.paul@tungstengraphics.com>
Tue, 9 Dec 2003 01:53:03 +0000 (01:53 +0000)
programs are enabled and if they need secondary color input register.
Patch by Karl Rasche, with tweaks by Brian.

src/mesa/main/context.h
src/mesa/main/nvfragprog.h
src/mesa/swrast/s_aatriangle.c
src/mesa/swrast/s_context.c
src/mesa/swrast/s_lines.c
src/mesa/swrast/s_span.c
src/mesa/swrast/s_triangle.c
src/mesa/swrast_setup/ss_vb.c
src/mesa/tnl/t_vb_render.c

index 2687dc596a9993f64c90ed9ff854012349e038c9..d6d7920bb4f9cba2de1fe41c51d8128e111b7b84 100644 (file)
@@ -374,7 +374,12 @@ do {                                                                       \
 #define NEED_SECONDARY_COLOR(CTX)                                      \
    (((CTX)->Light.Enabled &&                                           \
      (CTX)->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR)    \
-    || (CTX)->Fog.ColorSumEnabled)
+    || (CTX)->Fog.ColorSumEnabled                                      \
+    || ((CTX)->VertexProgram.Enabled &&                                        \
+        ((CTX)->VertexProgram.Current->InputsRead & VERT_BIT_COLOR1))  \
+    || ((CTX)->FragmentProgram.Enabled &&                              \
+        ((CTX)->FragmentProgram.Current->InputsRead & FRAG_BIT_COL1))  \
+   )
 
 
 /**
index 772edd6be44e6a57ba077e7a71a7d28c8b2c79d5..7752ddbab4703b6120016d982be9204f21f15a64 100644 (file)
 #define FRAG_ATTRIB_TEX6  10
 #define FRAG_ATTRIB_TEX7  11
 
+/* Bitmasks for the above */
+#define FRAG_BIT_WPOS  (1 << FRAG_ATTRIB_WPOS)
+#define FRAG_BIT_COL0  (1 << FRAG_ATTRIB_COL0)
+#define FRAG_BIT_COL1  (1 << FRAG_ATTRIB_COL1)
+#define FRAG_BIT_FOGC  (1 << FRAG_ATTRIB_FOGC)
+#define FRAG_BIT_TEX0  (1 << FRAG_ATTRIB_TEX0)
+#define FRAG_BIT_TEX1  (1 << FRAG_ATTRIB_TEX1)
+#define FRAG_BIT_TEX2  (1 << FRAG_ATTRIB_TEX2)
+#define FRAG_BIT_TEX3  (1 << FRAG_ATTRIB_TEX3)
+#define FRAG_BIT_TEX4  (1 << FRAG_ATTRIB_TEX4)
+#define FRAG_BIT_TEX5  (1 << FRAG_ATTRIB_TEX5)
+#define FRAG_BIT_TEX6  (1 << FRAG_ATTRIB_TEX6)
+#define FRAG_BIT_TEX7  (1 << FRAG_ATTRIB_TEX7)
+
+/* output registers */
 #define FRAG_OUTPUT_COLR  0
 #define FRAG_OUTPUT_COLH  1
 #define FRAG_OUTPUT_DEPR  2
index b05a7ea28d275b1bb9c0cbbd0f8bc08b90ef77d3..1bcaa95d3300b81b211d4e91c012ed721f5550a4 100644 (file)
@@ -34,6 +34,7 @@
 #include "context.h"
 #include "macros.h"
 #include "imports.h"
+#include "nvfragprog.h"
 #include "s_aatriangle.h"
 #include "s_context.h"
 #include "s_span.h"
index fb09eb306010088b1ac1ef61ffe1fb62f2d62cae..c69d4cfd5d400b6a890b98505d91277365323d74 100644 (file)
@@ -30,6 +30,7 @@
 #include "context.h"
 #include "mtypes.h"
 #include "texobj.h"
+#include "nvfragprog.h"
 
 #include "swrast.h"
 #include "s_blend.h"
@@ -226,7 +227,9 @@ _swrast_validate_triangle( GLcontext *ctx,
    _swrast_validate_derived( ctx );
    swrast->choose_triangle( ctx );
 
-   if (ctx->Texture._EnabledUnits == 0 && NEED_SECONDARY_COLOR(ctx)) {
+   if (ctx->Texture._EnabledUnits == 0
+       && NEED_SECONDARY_COLOR(ctx)
+       && !ctx->FragmentProgram.Enabled) {
       /* separate specular color, but no texture */
       swrast->SpecTriangle = swrast->Triangle;
       swrast->Triangle = _swrast_add_spec_terms_triangle;
@@ -243,7 +246,9 @@ _swrast_validate_line( GLcontext *ctx, const SWvertex *v0, const SWvertex *v1 )
    _swrast_validate_derived( ctx );
    swrast->choose_line( ctx );
 
-   if (ctx->Texture._EnabledUnits == 0 && NEED_SECONDARY_COLOR(ctx)) {
+   if (ctx->Texture._EnabledUnits == 0
+       && NEED_SECONDARY_COLOR(ctx)
+       && !ctx->FragmentProgram.Enabled) {
       swrast->SpecLine = swrast->Line;
       swrast->Line = _swrast_add_spec_terms_line;
    }
@@ -260,7 +265,9 @@ _swrast_validate_point( GLcontext *ctx, const SWvertex *v0 )
    _swrast_validate_derived( ctx );
    swrast->choose_point( ctx );
 
-   if (ctx->Texture._EnabledUnits == 0 && NEED_SECONDARY_COLOR(ctx)) {
+   if (ctx->Texture._EnabledUnits == 0
+       && NEED_SECONDARY_COLOR(ctx)
+       && !ctx->FragmentProgram.Enabled) {
       swrast->SpecPoint = swrast->Point;
       swrast->Point = _swrast_add_spec_terms_point;
    }
index f003395d428730469d2da4ef7efb36ee6fce0993..4d9fe5892064acb9243034b5e19bae864646ef1d 100644 (file)
@@ -27,6 +27,7 @@
 #include "context.h"
 #include "colormac.h"
 #include "macros.h"
+#include "nvfragprog.h"
 #include "s_aaline.h"
 #include "s_context.h"
 #include "s_depth.h"
index 769b551e712c11b40199d3a74db3751251d3b747..118cec47e3733e19fecb86e674f466c823e0fe39 100644 (file)
@@ -1207,7 +1207,7 @@ _swrast_write_texture_span( GLcontext *ctx, struct sw_span *span)
          span->primitive == GL_POLYGON  ||  span->primitive == GL_BITMAP);
    ASSERT(span->end <= MAX_WIDTH);
    ASSERT((span->interpMask & span->arrayMask) == 0);
-   ASSERT(ctx->Texture._EnabledCoordUnits);
+   ASSERT(ctx->Texture._EnabledCoordUnits || ctx->FragmentProgram.Enabled);
 
    /*
    printf("%s()  interp 0x%x  array 0x%x\n", __FUNCTION__, span->interpMask, span->arrayMask);
index 5af74ee3ab8d3aaa549a3e4364def4d7cc2f2219..3e429664670090c2c4e913e10c87f6621d20901a 100644 (file)
@@ -1055,7 +1055,7 @@ _swrast_choose_triangle( GLcontext *ctx )
          }
       }
 
-      if (ctx->Texture._EnabledCoordUnits) {
+      if (ctx->Texture._EnabledCoordUnits || ctx->FragmentProgram.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;
index bb9819b5b8704b796186fc60e935ff7e6855711e..dfa0ea03a2ab2bc138cba6a01426f1ca57fc167c 100644 (file)
@@ -30,6 +30,7 @@
 #include "context.h"
 #include "macros.h"
 #include "imports.h"
+#include "nvfragprog.h"
 
 #include "swrast/swrast.h"
 #include "tnl/t_context.h"
index fb3a8f693c23435204ff5b06d1b37f88a19adf2d..24cf0285555c605e635bae3f7183acdc91e48ffb 100644 (file)
@@ -45,7 +45,7 @@
 #include "macros.h"
 #include "imports.h"
 #include "mtypes.h"
-
+#include "nvfragprog.h"
 #include "math/m_matrix.h"
 #include "math/m_xform.h"