summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2003-12-09 01:53:03 +0000
committerBrian Paul <brian.paul@tungstengraphics.com>2003-12-09 01:53:03 +0000
commit853bda3e7c4dfa7d8cc462729f6a3dce89e44963 (patch)
tree9fdbf1812276c8f1f2bb8e56d82d0d163e22eae0 /src
parente8bec8832b50b8c2310e40951bea8bd78f89715c (diff)
Update NEED_SECONDARY_COLOR macro to test if either vertex/fragment
programs are enabled and if they need secondary color input register. Patch by Karl Rasche, with tweaks by Brian.
Diffstat (limited to 'src')
-rw-r--r--src/mesa/main/context.h7
-rw-r--r--src/mesa/main/nvfragprog.h15
-rw-r--r--src/mesa/swrast/s_aatriangle.c1
-rw-r--r--src/mesa/swrast/s_context.c13
-rw-r--r--src/mesa/swrast/s_lines.c1
-rw-r--r--src/mesa/swrast/s_span.c2
-rw-r--r--src/mesa/swrast/s_triangle.c2
-rw-r--r--src/mesa/swrast_setup/ss_vb.c1
-rw-r--r--src/mesa/tnl/t_vb_render.c2
9 files changed, 37 insertions, 7 deletions
diff --git a/src/mesa/main/context.h b/src/mesa/main/context.h
index 2687dc596a9..d6d7920bb4f 100644
--- a/src/mesa/main/context.h
+++ b/src/mesa/main/context.h
@@ -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)) \
+ )
/**
diff --git a/src/mesa/main/nvfragprog.h b/src/mesa/main/nvfragprog.h
index 772edd6be44..7752ddbab47 100644
--- a/src/mesa/main/nvfragprog.h
+++ b/src/mesa/main/nvfragprog.h
@@ -50,6 +50,21 @@
#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
diff --git a/src/mesa/swrast/s_aatriangle.c b/src/mesa/swrast/s_aatriangle.c
index b05a7ea28d2..1bcaa95d330 100644
--- a/src/mesa/swrast/s_aatriangle.c
+++ b/src/mesa/swrast/s_aatriangle.c
@@ -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"
diff --git a/src/mesa/swrast/s_context.c b/src/mesa/swrast/s_context.c
index fb09eb30601..c69d4cfd5d4 100644
--- a/src/mesa/swrast/s_context.c
+++ b/src/mesa/swrast/s_context.c
@@ -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;
}
diff --git a/src/mesa/swrast/s_lines.c b/src/mesa/swrast/s_lines.c
index f003395d428..4d9fe589206 100644
--- a/src/mesa/swrast/s_lines.c
+++ b/src/mesa/swrast/s_lines.c
@@ -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"
diff --git a/src/mesa/swrast/s_span.c b/src/mesa/swrast/s_span.c
index 769b551e712..118cec47e37 100644
--- a/src/mesa/swrast/s_span.c
+++ b/src/mesa/swrast/s_span.c
@@ -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);
diff --git a/src/mesa/swrast/s_triangle.c b/src/mesa/swrast/s_triangle.c
index 5af74ee3ab8..3e429664670 100644
--- a/src/mesa/swrast/s_triangle.c
+++ b/src/mesa/swrast/s_triangle.c
@@ -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;
diff --git a/src/mesa/swrast_setup/ss_vb.c b/src/mesa/swrast_setup/ss_vb.c
index bb9819b5b87..dfa0ea03a2a 100644
--- a/src/mesa/swrast_setup/ss_vb.c
+++ b/src/mesa/swrast_setup/ss_vb.c
@@ -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"
diff --git a/src/mesa/tnl/t_vb_render.c b/src/mesa/tnl/t_vb_render.c
index fb3a8f693c2..24cf0285555 100644
--- a/src/mesa/tnl/t_vb_render.c
+++ b/src/mesa/tnl/t_vb_render.c
@@ -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"