summaryrefslogtreecommitdiffstats
path: root/src/mesa/swrast/s_context.c
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2002-05-02 00:59:20 +0000
committerBrian Paul <[email protected]>2002-05-02 00:59:20 +0000
commitf595212336ae63c981f0f39f4ea1dec67ff7fe25 (patch)
tree9c0762c92e333184234beb5d453462d940da1266 /src/mesa/swrast/s_context.c
parentc450d57991628318696ee7a2bd052f91f480cda3 (diff)
Implemented GL_ARB_texture_env_crossbar.
Simplification of some of the texture application code.
Diffstat (limited to 'src/mesa/swrast/s_context.c')
-rw-r--r--src/mesa/swrast/s_context.c52
1 files changed, 40 insertions, 12 deletions
diff --git a/src/mesa/swrast/s_context.c b/src/mesa/swrast/s_context.c
index 96572aa0634..809ee681223 100644
--- a/src/mesa/swrast/s_context.c
+++ b/src/mesa/swrast/s_context.c
@@ -1,4 +1,4 @@
-/* $Id: s_context.c,v 1.31 2002/04/19 14:05:50 brianp Exp $ */
+/* $Id: s_context.c,v 1.32 2002/05/02 00:59:20 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -40,9 +40,6 @@
#include "s_texture.h"
-
-
-
/*
* Recompute the value of swrast->_RasterMask, etc. according to
* the current context.
@@ -145,6 +142,26 @@ _swrast_update_hint( GLcontext *ctx )
swrast->AllowPixelFog));
}
+
+/*
+ * Update the swrast->_AnyTextureCombine flag.
+ */
+static void
+_swrast_update_texture_env( GLcontext *ctx )
+{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ GLuint i;
+ swrast->_AnyTextureCombine = GL_FALSE;
+ for (i = 0; i < ctx->Const.MaxTextureUnits; i++) {
+ if (ctx->Texture.Unit[i].EnvMode == GL_COMBINE_EXT ||
+ ctx->Texture.Unit[i].EnvMode == GL_COMBINE4_NV) {
+ swrast->_AnyTextureCombine = GL_TRUE;
+ return;
+ }
+ }
+}
+
+
#define _SWRAST_NEW_DERIVED (_SWRAST_NEW_RASTERMASK | \
_NEW_TEXTURE | \
_NEW_HINT | \
@@ -183,6 +200,8 @@ _swrast_update_hint( GLcontext *ctx )
#define _SWRAST_NEW_TEXTURE_SAMPLE_FUNC _NEW_TEXTURE
+#define _SWRAST_NEW_TEXTURE_ENV_MODE _NEW_TEXTURE
+
#define _SWRAST_NEW_BLEND_FUNC _NEW_COLOR
@@ -315,7 +334,6 @@ _swrast_invalidate_state( GLcontext *ctx, GLuint new_state )
for (i = 0 ; i < ctx->Const.MaxTextureUnits ; i++)
swrast->TextureSample[i] = _swrast_validate_texture_sample;
-
if (ctx->Visual.rgbMode) {
ASSERT(swrast->Driver.WriteRGBASpan);
ASSERT(swrast->Driver.WriteRGBSpan);
@@ -334,18 +352,15 @@ _swrast_invalidate_state( GLcontext *ctx, GLuint new_state )
ASSERT(swrast->Driver.ReadCI32Span);
ASSERT(swrast->Driver.ReadCI32Pixels);
}
-
}
-
void
_swrast_validate_derived( GLcontext *ctx )
{
SWcontext *swrast = SWRAST_CONTEXT(ctx);
- if (swrast->NewState)
- {
+ if (swrast->NewState) {
if (swrast->NewState & _SWRAST_NEW_RASTERMASK)
_swrast_update_rasterflags( ctx );
@@ -355,6 +370,9 @@ _swrast_validate_derived( GLcontext *ctx )
if (swrast->NewState & _NEW_HINT)
_swrast_update_hint( ctx );
+ if (swrast->NewState & _SWRAST_NEW_TEXTURE_ENV_MODE)
+ _swrast_update_texture_env( ctx );
+
swrast->NewState = 0;
swrast->StateChanges = 0;
swrast->InvalidateState = _swrast_invalidate_state;
@@ -490,7 +508,6 @@ _swrast_CreateContext( GLcontext *ctx )
swrast->_IntegerAccumMode = GL_TRUE;
swrast->_IntegerAccumScaler = 0.0;
-
for (i = 0 ; i < MAX_TEXTURE_UNITS ; i++)
swrast->TextureSample[i] = _swrast_validate_texture_sample;
@@ -499,7 +516,18 @@ _swrast_CreateContext( GLcontext *ctx )
FREE(swrast);
return GL_FALSE;
}
-
+
+ assert(ctx->Const.MaxTextureUnits > 0);
+ assert(ctx->Const.MaxTextureUnits <= MAX_TEXTURE_UNITS);
+
+ swrast->TexelBuffer = (GLchan *) MALLOC(ctx->Const.MaxTextureUnits *
+ MAX_WIDTH * 4 * sizeof(GLchan));
+ if (!swrast->TexelBuffer) {
+ FREE(swrast->span);
+ FREE(swrast);
+ return GL_FALSE;
+ }
+
ctx->swrast_context = swrast;
return GL_TRUE;
@@ -515,7 +543,7 @@ _swrast_DestroyContext( GLcontext *ctx )
}
FREE( swrast->span );
-
+ FREE( swrast->TexelBuffer );
FREE( swrast );
ctx->swrast_context = 0;