aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xautogen.sh2
-rw-r--r--progs/demos/Makefile6
-rw-r--r--src/mesa/drivers/allegro/amesa.c2
-rw-r--r--src/mesa/drivers/dri/intel/intel_clear.c9
-rw-r--r--src/mesa/drivers/dri/intel/intel_swapbuffers.c11
-rw-r--r--src/mesa/drivers/fbdev/glfbdev.c2
-rw-r--r--src/mesa/drivers/glide/fxapi.c4
-rw-r--r--src/mesa/drivers/osmesa/osmesa.c2
-rw-r--r--src/mesa/drivers/x11/xm_api.c2
-rw-r--r--src/mesa/main/context.c8
-rw-r--r--src/mesa/main/fbobject.c2
-rw-r--r--src/mesa/main/mtypes.h8
-rw-r--r--src/mesa/main/pixel.c2
-rw-r--r--src/mesa/main/state.c66
-rw-r--r--src/mesa/main/texenvprogram.c39
-rw-r--r--src/mesa/main/texenvprogram.h2
-rw-r--r--src/mesa/main/teximage.c22
-rw-r--r--src/mesa/main/texparam.c88
-rw-r--r--src/mesa/swrast/s_fragprog.c6
19 files changed, 150 insertions, 133 deletions
diff --git a/autogen.sh b/autogen.sh
index 19e5b55fcfa..c76bf8b07bd 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -11,6 +11,8 @@ if test "x$SRCDIR" != "x$ORIGDIR"; then
exit 1
fi
+MAKEFLAGS=""
+
autoreconf -v --install || exit 1
"$srcdir"/configure "$@"
diff --git a/progs/demos/Makefile b/progs/demos/Makefile
index e636cbd9ad9..32c60721232 100644
--- a/progs/demos/Makefile
+++ b/progs/demos/Makefile
@@ -5,12 +5,6 @@ include $(TOP)/configs/current
INCDIR = $(TOP)/include
-OSMESA_LIBS = -L$(TOP)/$(LIB_DIR) -lglut -lglew -lOSMesa -lGLU -lGL $(APP_LIB_DEPS)
-
-OSMESA16_LIBS = -L$(TOP)/$(LIB_DIR) -lglut -lglew -lOSMesa16 -lGLU -lGL $(APP_LIB_DEPS)
-
-OSMESA32_LIBS = -L$(TOP)/$(LIB_DIR) -lglut -lglew -lOSMesa32 -lGLU -lGL $(APP_LIB_DEPS)
-
LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) \
$(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME)
diff --git a/src/mesa/drivers/allegro/amesa.c b/src/mesa/drivers/allegro/amesa.c
index a9d8f62f92d..0744677d2bd 100644
--- a/src/mesa/drivers/allegro/amesa.c
+++ b/src/mesa/drivers/allegro/amesa.c
@@ -338,7 +338,7 @@ void AMesaDestroyBuffer(AMesaBuffer buffer)
{
if (buffer->Screen) destroy_bitmap(buffer->Screen);
if (buffer->Background) destroy_bitmap(buffer->Background);
- _mesa_unreference_framebuffer(&buffer->GLBuffer);
+ _mesa_reference_framebuffer(&buffer->GLBuffer, NULL);
free(buffer);
}
diff --git a/src/mesa/drivers/dri/intel/intel_clear.c b/src/mesa/drivers/dri/intel/intel_clear.c
index f95d055e621..a47c4d4050e 100644
--- a/src/mesa/drivers/dri/intel/intel_clear.c
+++ b/src/mesa/drivers/dri/intel/intel_clear.c
@@ -39,6 +39,7 @@
#include "main/macros.h"
#include "main/matrix.h"
#include "main/texstate.h"
+#include "main/shaders.h"
#include "main/stencil.h"
#include "main/varray.h"
#include "glapi/dispatch.h"
@@ -71,6 +72,7 @@ intel_clear_tris(GLcontext *ctx, GLbitfield mask)
struct gl_framebuffer *fb = ctx->DrawBuffer;
int i;
GLboolean saved_fp_enable = GL_FALSE, saved_vp_enable = GL_FALSE;
+ GLboolean saved_shader_program = 0;
unsigned int saved_active_texture;
assert((mask & ~(BUFFER_BIT_BACK_LEFT | BUFFER_BIT_FRONT_LEFT |
@@ -109,6 +111,10 @@ intel_clear_tris(GLcontext *ctx, GLbitfield mask)
saved_vp_enable = GL_TRUE;
_mesa_Disable(GL_VERTEX_PROGRAM_ARB);
}
+ if (ctx->Extensions.ARB_shader_objects && ctx->Shader.CurrentProgram) {
+ saved_shader_program = ctx->Shader.CurrentProgram->Name;
+ _mesa_UseProgramObjectARB(0);
+ }
if (ctx->Texture._EnabledUnits != 0) {
int i;
@@ -215,6 +221,9 @@ intel_clear_tris(GLcontext *ctx, GLbitfield mask)
if (saved_vp_enable)
_mesa_Enable(GL_VERTEX_PROGRAM_ARB);
+ if (saved_shader_program)
+ _mesa_UseProgramObjectARB(saved_shader_program);
+
_mesa_PopClientAttrib();
_mesa_PopAttrib();
}
diff --git a/src/mesa/drivers/dri/intel/intel_swapbuffers.c b/src/mesa/drivers/dri/intel/intel_swapbuffers.c
index c1351664359..7d035b9f6e4 100644
--- a/src/mesa/drivers/dri/intel/intel_swapbuffers.c
+++ b/src/mesa/drivers/dri/intel/intel_swapbuffers.c
@@ -43,7 +43,6 @@
GLuint
intelFixupVblank(struct intel_context *intel, __DRIdrawablePrivate *dPriv)
{
-
if (!intel->intelScreen->driScrnPriv->dri2.enabled &&
intel->intelScreen->driScrnPriv->ddx_version.minor >= 7) {
volatile drm_i915_sarea_t *sarea = intel->sarea;
@@ -77,11 +76,14 @@ intelFixupVblank(struct intel_context *intel, __DRIdrawablePrivate *dPriv)
return flags;
} else {
- return dPriv->vblFlags & ~VBLANK_FLAG_SECONDARY;
+ return dPriv->vblFlags & ~VBLANK_FLAG_SECONDARY;
}
}
+/**
+ * Called from driSwapBuffers()
+ */
void
intelSwapBuffers(__DRIdrawablePrivate * dPriv)
{
@@ -130,7 +132,6 @@ intelSwapBuffers(__DRIdrawablePrivate * dPriv)
intel_fb->swap_ust = ust;
}
drmCommandNone(intel->driFd, DRM_I915_GEM_THROTTLE);
-
}
else {
/* XXX this shouldn't be an error but we can't handle it for now */
@@ -138,6 +139,10 @@ intelSwapBuffers(__DRIdrawablePrivate * dPriv)
}
}
+
+/**
+ * Called from driCopySubBuffer()
+ */
void
intelCopySubBuffer(__DRIdrawablePrivate * dPriv, int x, int y, int w, int h)
{
diff --git a/src/mesa/drivers/fbdev/glfbdev.c b/src/mesa/drivers/fbdev/glfbdev.c
index 3c874ba57ab..531558dc4d6 100644
--- a/src/mesa/drivers/fbdev/glfbdev.c
+++ b/src/mesa/drivers/fbdev/glfbdev.c
@@ -685,7 +685,7 @@ glFBDevDestroyBuffer( GLFBDevBufferPtr buffer )
}
{
struct gl_framebuffer *fb = &buffer->glframebuffer;
- _mesa_unreference_framebuffer(&fb);
+ _mesa_reference_framebuffer(&fb, NULL);
}
}
}
diff --git a/src/mesa/drivers/glide/fxapi.c b/src/mesa/drivers/glide/fxapi.c
index b7708fd636a..238f4915995 100644
--- a/src/mesa/drivers/glide/fxapi.c
+++ b/src/mesa/drivers/glide/fxapi.c
@@ -728,7 +728,7 @@ errorhandler:
FREE(fxMesa->fogTable);
}
if (fxMesa->glBuffer) {
- _mesa_unreference_framebuffer(&fxMesa->glBuffer);
+ _mesa_reference_framebuffer(&fxMesa->glBuffer, NULL);
}
if (fxMesa->glVis) {
_mesa_destroy_visual(fxMesa->glVis);
@@ -828,7 +828,7 @@ fxMesaDestroyContext(fxMesaContext fxMesa)
fxDDDestroyFxMesaContext(fxMesa); /* must be before _mesa_destroy_context */
_mesa_destroy_visual(fxMesa->glVis);
_mesa_destroy_context(fxMesa->glCtx);
- _mesa_unreference_framebuffer(&fxMesa->glBuffer);
+ _mesa_reference_framebuffer(&fxMesa->glBuffer, NULL);
fxTMClose(fxMesa); /* must be after _mesa_destroy_context */
FREE(fxMesa);
diff --git a/src/mesa/drivers/osmesa/osmesa.c b/src/mesa/drivers/osmesa/osmesa.c
index f2367bbbb70..904659e3450 100644
--- a/src/mesa/drivers/osmesa/osmesa.c
+++ b/src/mesa/drivers/osmesa/osmesa.c
@@ -1310,7 +1310,7 @@ OSMesaDestroyContext( OSMesaContext osmesa )
_swrast_DestroyContext( &osmesa->mesa );
_mesa_destroy_visual( osmesa->gl_visual );
- _mesa_unreference_framebuffer( &osmesa->gl_buffer );
+ _mesa_reference_framebuffer( &osmesa->gl_buffer, NULL );
_mesa_free_context_data( &osmesa->mesa );
_mesa_free( osmesa );
diff --git a/src/mesa/drivers/x11/xm_api.c b/src/mesa/drivers/x11/xm_api.c
index 00ce3ba7237..2a8c3a4fd36 100644
--- a/src/mesa/drivers/x11/xm_api.c
+++ b/src/mesa/drivers/x11/xm_api.c
@@ -492,7 +492,7 @@ xmesa_free_buffer(XMesaBuffer buffer)
b->frontxrb->drawable = 0;
/* Unreference. If count = zero we'll really delete the buffer */
- _mesa_unreference_framebuffer(&fb);
+ _mesa_reference_framebuffer(&fb, NULL);
return;
}
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index a315091a20d..39c7fa037e0 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -1305,10 +1305,10 @@ _mesa_free_context_data( GLcontext *ctx )
}
/* unreference WinSysDraw/Read buffers */
- _mesa_unreference_framebuffer(&ctx->WinSysDrawBuffer);
- _mesa_unreference_framebuffer(&ctx->WinSysReadBuffer);
- _mesa_unreference_framebuffer(&ctx->DrawBuffer);
- _mesa_unreference_framebuffer(&ctx->ReadBuffer);
+ _mesa_reference_framebuffer(&ctx->WinSysDrawBuffer, NULL);
+ _mesa_reference_framebuffer(&ctx->WinSysReadBuffer, NULL);
+ _mesa_reference_framebuffer(&ctx->DrawBuffer, NULL);
+ _mesa_reference_framebuffer(&ctx->ReadBuffer, NULL);
_mesa_reference_vertprog(ctx, &ctx->VertexProgram.Current, NULL);
_mesa_reference_vertprog(ctx, &ctx->VertexProgram._Current, NULL);
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index ae823262a28..c3cdc110379 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -1268,7 +1268,7 @@ _mesa_DeleteFramebuffersEXT(GLsizei n, const GLuint *framebuffers)
/* But the object will not be freed until it's no longer
* bound in any context.
*/
- _mesa_unreference_framebuffer(&fb);
+ _mesa_reference_framebuffer(&fb, NULL);
}
}
}
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 67f7d463098..be982afe39c 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2846,6 +2846,10 @@ struct gl_matrix_stack
/*@}*/
+/**
+ * Composite state flags
+ */
+/*@{*/
#define _MESA_NEW_NEED_EYE_COORDS (_NEW_LIGHT | \
_NEW_TEXTURE | \
_NEW_POINT | \
@@ -2855,7 +2859,9 @@ struct gl_matrix_stack
#define _MESA_NEW_NEED_NORMALS (_NEW_LIGHT | \
_NEW_TEXTURE)
-#define _IMAGE_NEW_TRANSFER_STATE (_NEW_PIXEL | _NEW_COLOR_MATRIX)
+#define _MESA_NEW_TRANSFER_STATE (_NEW_PIXEL | \
+ _NEW_COLOR_MATRIX)
+/*@}*/
diff --git a/src/mesa/main/pixel.c b/src/mesa/main/pixel.c
index 8d24a201f07..52781e048ec 100644
--- a/src/mesa/main/pixel.c
+++ b/src/mesa/main/pixel.c
@@ -828,7 +828,7 @@ void _mesa_update_pixel( GLcontext *ctx, GLuint new_state )
/* References ColorMatrix.type (derived above).
*/
- if (new_state & _IMAGE_NEW_TRANSFER_STATE)
+ if (new_state & _MESA_NEW_TRANSFER_STATE)
update_image_transfer_state(ctx);
}
diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c
index 718cd998476..0a39279bff3 100644
--- a/src/mesa/main/state.c
+++ b/src/mesa/main/state.c
@@ -173,13 +173,16 @@ update_arrays( GLcontext *ctx )
}
+/**
+ * Update the following fields:
+ * ctx->VertexProgram._Enabled
+ * ctx->FragmentProgram._Enabled
+ * ctx->ATIFragmentShader._Enabled
+ * This needs to be done before texture state validation.
+ */
static void
-update_program(GLcontext *ctx)
+update_program_enables(GLcontext *ctx)
{
- const struct gl_shader_program *shProg = ctx->Shader.CurrentProgram;
- const struct gl_vertex_program *prevVP = ctx->VertexProgram._Current;
- const struct gl_fragment_program *prevFP = ctx->FragmentProgram._Current;
-
/* These _Enabled flags indicate if the program is enabled AND valid. */
ctx->VertexProgram._Enabled = ctx->VertexProgram.Enabled
&& ctx->VertexProgram.Current->Base.Instructions;
@@ -187,6 +190,25 @@ update_program(GLcontext *ctx)
&& ctx->FragmentProgram.Current->Base.Instructions;
ctx->ATIFragmentShader._Enabled = ctx->ATIFragmentShader.Enabled
&& ctx->ATIFragmentShader.Current->Instructions[0];
+}
+
+
+/**
+ * Update vertex/fragment program state. In particular, update these fields:
+ * ctx->VertexProgram._Current
+ * ctx->VertexProgram._TnlProgram,
+ * These point to the highest priority enabled vertex/fragment program or are
+ * NULL if fixed-function processing is to be done.
+ *
+ * This function needs to be called after texture state validation in case
+ * we're generating a fragment program from fixed-function texture state.
+ */
+static void
+update_program(GLcontext *ctx)
+{
+ const struct gl_shader_program *shProg = ctx->Shader.CurrentProgram;
+ const struct gl_vertex_program *prevVP = ctx->VertexProgram._Current;
+ const struct gl_fragment_program *prevFP = ctx->FragmentProgram._Current;
/*
* Set the ctx->VertexProgram._Current and ctx->FragmentProgram._Current
@@ -432,6 +454,24 @@ _mesa_update_state_locked( GLcontext *ctx )
if (MESA_VERBOSE & VERBOSE_STATE)
_mesa_print_state("_mesa_update_state", new_state);
+ /* Determine which state flags effect vertex/fragment program state */
+ if (ctx->FragmentProgram._MaintainTexEnvProgram) {
+ prog_flags |= (_NEW_TEXTURE | _NEW_FOG | _DD_NEW_SEPARATE_SPECULAR);
+ }
+ if (ctx->VertexProgram._MaintainTnlProgram) {
+ prog_flags |= (_NEW_ARRAY | _NEW_TEXTURE | _NEW_TEXTURE_MATRIX |
+ _NEW_TRANSFORM | _NEW_POINT |
+ _NEW_FOG | _NEW_LIGHT |
+ _MESA_NEW_NEED_EYE_COORDS);
+ }
+
+ /*
+ * Now update derived state info
+ */
+
+ if (new_state & prog_flags)
+ update_program_enables( ctx );
+
if (new_state & (_NEW_MODELVIEW|_NEW_PROJECTION))
_mesa_update_modelview_project( ctx, new_state );
@@ -454,7 +494,7 @@ _mesa_update_state_locked( GLcontext *ctx )
_mesa_update_stencil( ctx );
#if FEATURE_pixel_transfer
- if (new_state & _IMAGE_NEW_TRANSFER_STATE)
+ if (new_state & _MESA_NEW_TRANSFER_STATE)
_mesa_update_pixel( ctx, new_state );
#endif
@@ -491,23 +531,9 @@ _mesa_update_state_locked( GLcontext *ctx )
if (new_state & _MESA_NEW_NEED_EYE_COORDS)
_mesa_update_tnl_spaces( ctx, new_state );
- if (ctx->FragmentProgram._MaintainTexEnvProgram) {
- prog_flags |= (_NEW_ARRAY | _NEW_TEXTURE_MATRIX | _NEW_LIGHT |
- _NEW_RENDERMODE |
- _NEW_TEXTURE | _NEW_FOG | _DD_NEW_SEPARATE_SPECULAR);
- }
- if (ctx->VertexProgram._MaintainTnlProgram) {
- prog_flags |= (_NEW_ARRAY | _NEW_TEXTURE | _NEW_TEXTURE_MATRIX |
- _NEW_RENDERMODE |
- _NEW_TRANSFORM | _NEW_POINT |
- _NEW_FOG | _NEW_LIGHT |
- _MESA_NEW_NEED_EYE_COORDS);
- }
if (new_state & prog_flags)
update_program( ctx );
-
-
/*
* Give the driver a chance to act upon the new_state flags.
* The driver might plug in different span functions, for example.
diff --git a/src/mesa/main/texenvprogram.c b/src/mesa/main/texenvprogram.c
index 10edfc8fb80..af51a206a56 100644
--- a/src/mesa/main/texenvprogram.c
+++ b/src/mesa/main/texenvprogram.c
@@ -1405,42 +1405,3 @@ _mesa_get_fixed_func_fragment_program(GLcontext *ctx)
return prog;
}
-
-
-
-/**
- * If _MaintainTexEnvProgram is set we'll generate a fragment program that
- * implements the current texture env/combine mode.
- * This function generates that program and puts it into effect.
- *
- * XXX: remove this function. currently only called by some drivers,
- * not by mesa core. We now handle this properly from inside mesa.
- */
-void
-_mesa_UpdateTexEnvProgram( GLcontext *ctx )
-{
- const struct gl_fragment_program *prev = ctx->FragmentProgram._Current;
-
- ASSERT(ctx->FragmentProgram._MaintainTexEnvProgram);
-
- /* If a conventional fragment program/shader isn't in effect... */
- if (!ctx->FragmentProgram._Enabled &&
- (!ctx->Shader.CurrentProgram ||
- !ctx->Shader.CurrentProgram->FragmentProgram) )
- {
- struct gl_fragment_program *newProg;
-
- newProg = _mesa_get_fixed_func_fragment_program(ctx);
-
- _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current, newProg);
- _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._TexEnvProgram, newProg);
- }
-
- /* Tell the driver about the change. Could define a new target for
- * this?
- */
- if (ctx->FragmentProgram._Current != prev && ctx->Driver.BindProgram) {
- ctx->Driver.BindProgram(ctx, GL_FRAGMENT_PROGRAM_ARB,
- (struct gl_program *) ctx->FragmentProgram._Current);
- }
-}
diff --git a/src/mesa/main/texenvprogram.h b/src/mesa/main/texenvprogram.h
index a7aa60cf374..0a162d2e7a2 100644
--- a/src/mesa/main/texenvprogram.h
+++ b/src/mesa/main/texenvprogram.h
@@ -32,6 +32,4 @@
extern struct gl_fragment_program *
_mesa_get_fixed_func_fragment_program(GLcontext *ctx);
-extern void _mesa_UpdateTexEnvProgram( GLcontext *ctx );
-
#endif
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index fdc72ed8436..8fd69c4f6ac 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -2431,7 +2431,7 @@ _mesa_TexImage1D( GLenum target, GLint level, GLint internalFormat,
return; /* error was recorded */
}
- if (ctx->NewState & _IMAGE_NEW_TRANSFER_STATE)
+ if (ctx->NewState & _MESA_NEW_TRANSFER_STATE)
_mesa_update_state(ctx);
texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
@@ -2537,7 +2537,7 @@ _mesa_TexImage2D( GLenum target, GLint level, GLint internalFormat,
return; /* error was recorded */
}
- if (ctx->NewState & _IMAGE_NEW_TRANSFER_STATE)
+ if (ctx->NewState & _MESA_NEW_TRANSFER_STATE)
_mesa_update_state(ctx);
texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
@@ -2638,7 +2638,7 @@ _mesa_TexImage3D( GLenum target, GLint level, GLint internalFormat,
return; /* error was recorded */
}
- if (ctx->NewState & _IMAGE_NEW_TRANSFER_STATE)
+ if (ctx->NewState & _MESA_NEW_TRANSFER_STATE)
_mesa_update_state(ctx);
texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
@@ -2731,7 +2731,7 @@ _mesa_TexSubImage1D( GLenum target, GLint level,
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
- if (ctx->NewState & _IMAGE_NEW_TRANSFER_STATE)
+ if (ctx->NewState & _MESA_NEW_TRANSFER_STATE)
_mesa_update_state(ctx);
#if FEATURE_convolve
@@ -2791,7 +2791,7 @@ _mesa_TexSubImage2D( GLenum target, GLint level,
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
- if (ctx->NewState & _IMAGE_NEW_TRANSFER_STATE)
+ if (ctx->NewState & _MESA_NEW_TRANSFER_STATE)
_mesa_update_state(ctx);
#if FEATURE_convolve
@@ -2851,7 +2851,7 @@ _mesa_TexSubImage3D( GLenum target, GLint level,
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
- if (ctx->NewState & _IMAGE_NEW_TRANSFER_STATE)
+ if (ctx->NewState & _MESA_NEW_TRANSFER_STATE)
_mesa_update_state(ctx);
if (subtexture_error_check(ctx, 3, target, level, xoffset, yoffset, zoffset,
@@ -2907,7 +2907,7 @@ _mesa_CopyTexImage1D( GLenum target, GLint level,
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
- if (ctx->NewState & _IMAGE_NEW_TRANSFER_STATE)
+ if (ctx->NewState & _MESA_NEW_TRANSFER_STATE)
_mesa_update_state(ctx);
#if FEATURE_convolve
@@ -2972,7 +2972,7 @@ _mesa_CopyTexImage2D( GLenum target, GLint level, GLenum internalFormat,
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
- if (ctx->NewState & _IMAGE_NEW_TRANSFER_STATE)
+ if (ctx->NewState & _MESA_NEW_TRANSFER_STATE)
_mesa_update_state(ctx);
#if FEATURE_convolve
@@ -3040,7 +3040,7 @@ _mesa_CopyTexSubImage1D( GLenum target, GLint level,
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
- if (ctx->NewState & _IMAGE_NEW_TRANSFER_STATE)
+ if (ctx->NewState & _MESA_NEW_TRANSFER_STATE)
_mesa_update_state(ctx);
if (copytexsubimage_error_check1(ctx, 1, target, level))
@@ -3095,7 +3095,7 @@ _mesa_CopyTexSubImage2D( GLenum target, GLint level,
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
- if (ctx->NewState & _IMAGE_NEW_TRANSFER_STATE)
+ if (ctx->NewState & _MESA_NEW_TRANSFER_STATE)
_mesa_update_state(ctx);
if (copytexsubimage_error_check1(ctx, 2, target, level))
@@ -3150,7 +3150,7 @@ _mesa_CopyTexSubImage3D( GLenum target, GLint level,
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
- if (ctx->NewState & _IMAGE_NEW_TRANSFER_STATE)
+ if (ctx->NewState & _MESA_NEW_TRANSFER_STATE)
_mesa_update_state(ctx);
if (copytexsubimage_error_check1(ctx, 3, target, level))
diff --git a/src/mesa/main/texparam.c b/src/mesa/main/texparam.c
index 8df22fe9e2e..865aae86276 100644
--- a/src/mesa/main/texparam.c
+++ b/src/mesa/main/texparam.c
@@ -3,7 +3,7 @@
* Version: 7.5
*
* Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
- * Copyright (C) 1999-2009 VMware, Inc. All Rights Reserved.
+ * Copyright (C) 2009 VMware, Inc. 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"),
@@ -165,6 +165,20 @@ set_swizzle_component(GLuint *swizzle, GLuint comp, GLuint swz)
}
+/**
+ * This is called just prior to changing any texture object state.
+ * Any pending rendering will be flushed out, we'll set the _NEW_TEXTURE
+ * state flag and then mark the texture object as 'incomplete' so that any
+ * per-texture derived state gets recomputed.
+ */
+static INLINE void
+flush(GLcontext *ctx, struct gl_texture_object *texObj)
+{
+ FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ texObj->_Complete = GL_FALSE;
+}
+
+
/** Set an integer-valued texture parameter */
static void
set_tex_parameteri(GLcontext *ctx,
@@ -178,7 +192,7 @@ set_tex_parameteri(GLcontext *ctx,
switch (params[0]) {
case GL_NEAREST:
case GL_LINEAR:
- FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ flush(ctx, texObj);
texObj->MinFilter = params[0];
return;
case GL_NEAREST_MIPMAP_NEAREST:
@@ -186,7 +200,7 @@ set_tex_parameteri(GLcontext *ctx,
case GL_NEAREST_MIPMAP_LINEAR:
case GL_LINEAR_MIPMAP_LINEAR:
if (texObj->Target != GL_TEXTURE_RECTANGLE_NV) {
- FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ flush(ctx, texObj);
texObj->MinFilter = params[0];
return;
}
@@ -202,7 +216,7 @@ set_tex_parameteri(GLcontext *ctx,
switch (params[0]) {
case GL_NEAREST:
case GL_LINEAR:
- FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ flush(ctx, texObj);
texObj->MagFilter = params[0];
return;
default:
@@ -214,7 +228,7 @@ set_tex_parameteri(GLcontext *ctx,
if (texObj->WrapS == params[0])
return;
if (validate_texture_wrap_mode(ctx, texObj->Target, params[0])) {
- FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ flush(ctx, texObj);
texObj->WrapS = params[0];
}
return;
@@ -223,7 +237,7 @@ set_tex_parameteri(GLcontext *ctx,
if (texObj->WrapT == params[0])
return;
if (validate_texture_wrap_mode(ctx, texObj->Target, params[0])) {
- FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ flush(ctx, texObj);
texObj->WrapT = params[0];
}
return;
@@ -232,7 +246,7 @@ set_tex_parameteri(GLcontext *ctx,
if (texObj->WrapR == params[0])
return;
if (validate_texture_wrap_mode(ctx, texObj->Target, params[0])) {
- FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ flush(ctx, texObj);
texObj->WrapR = params[0];
}
return;
@@ -245,7 +259,7 @@ set_tex_parameteri(GLcontext *ctx,
_mesa_error(ctx, GL_INVALID_VALUE, "glTexParameter(param)");
return;
}
- FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ flush(ctx, texObj);
texObj->BaseLevel = params[0];
return;
@@ -256,14 +270,16 @@ set_tex_parameteri(GLcontext *ctx,
_mesa_error(ctx, GL_INVALID_OPERATION, "glTexParameter(param)");
return;
}
- FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ flush(ctx, texObj);
texObj->MaxLevel = params[0];
return;
case GL_GENERATE_MIPMAP_SGIS:
if (ctx->Extensions.SGIS_generate_mipmap) {
- FLUSH_VERTICES(ctx, _NEW_TEXTURE);
- texObj->GenerateMipmap = params[0] ? GL_TRUE : GL_FALSE;
+ if (texObj->GenerateMipmap != params[0]) {
+ flush(ctx, texObj);
+ texObj->GenerateMipmap = params[0] ? GL_TRUE : GL_FALSE;
+ }
}
else {
_mesa_error(ctx, GL_INVALID_ENUM,
@@ -275,8 +291,10 @@ set_tex_parameteri(GLcontext *ctx,
if (ctx->Extensions.ARB_shadow &&
(params[0] == GL_NONE ||
params[0] == GL_COMPARE_R_TO_TEXTURE_ARB)) {
- FLUSH_VERTICES(ctx, _NEW_TEXTURE);
- texObj->CompareMode = params[0];
+ if (texObj->CompareMode != params[0]) {
+ flush(ctx, texObj);
+ texObj->CompareMode = params[0];
+ }
}
else {
_mesa_error(ctx, GL_INVALID_ENUM,
@@ -286,10 +304,12 @@ set_tex_parameteri(GLcontext *ctx,
case GL_TEXTURE_COMPARE_FUNC_ARB:
if (ctx->Extensions.ARB_shadow) {
+ if (texObj->CompareFunc == params[0])
+ return;
switch (params[0]) {
case GL_LEQUAL:
case GL_GEQUAL:
- FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ flush(ctx, texObj);
texObj->CompareFunc = params[0];
return;
case GL_EQUAL:
@@ -299,7 +319,7 @@ set_tex_parameteri(GLcontext *ctx,
case GL_ALWAYS:
case GL_NEVER:
if (ctx->Extensions.EXT_shadow_funcs) {
- FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ flush(ctx, texObj);
texObj->CompareFunc = params[0];
return;
}
@@ -319,8 +339,10 @@ set_tex_parameteri(GLcontext *ctx,
(params[0] == GL_LUMINANCE ||
params[0] == GL_INTENSITY ||
params[0] == GL_ALPHA)) {
- FLUSH_VERTICES(ctx, _NEW_TEXTURE);
- texObj->DepthMode = params[0];
+ if (texObj->DepthMode != params[0]) {
+ flush(ctx, texObj);
+ texObj->DepthMode = params[0];
+ }
}
else {
_mesa_error(ctx, GL_INVALID_ENUM,
@@ -351,7 +373,7 @@ set_tex_parameteri(GLcontext *ctx,
}
ASSERT(comp < 4);
if (swz >= 0) {
- FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ flush(ctx, texObj);
texObj->Swizzle[comp] = params[0];
set_swizzle_component(&texObj->_Swizzle, comp, swz);
return;
@@ -363,7 +385,7 @@ set_tex_parameteri(GLcontext *ctx,
case GL_TEXTURE_SWIZZLE_RGBA_EXT:
if (ctx->Extensions.EXT_texture_swizzle) {
GLuint comp;
- FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ flush(ctx, texObj);
for (comp = 0; comp < 4; comp++) {
const GLint swz = comp_to_swizzle(params[comp]);
if (swz >= 0) {
@@ -397,29 +419,31 @@ set_tex_parameterf(GLcontext *ctx,
case GL_TEXTURE_MIN_LOD:
if (texObj->MinLod == params[0])
return;
- FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ flush(ctx, texObj);
texObj->MinLod = params[0];
return;
case GL_TEXTURE_MAX_LOD:
if (texObj->MaxLod == params[0])
return;
- FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ flush(ctx, texObj);
texObj->MaxLod = params[0];
return;
case GL_TEXTURE_PRIORITY:
- FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ flush(ctx, texObj);
texObj->Priority = CLAMP(params[0], 0.0F, 1.0F);
return;
case GL_TEXTURE_MAX_ANISOTROPY_EXT:
if (ctx->Extensions.EXT_texture_filter_anisotropic) {
+ if (texObj->MaxAnisotropy == params[0])
+ return;
if (params[0] < 1.0) {
_mesa_error(ctx, GL_INVALID_VALUE, "glTexParameter(param)" );
return;
}
- FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ flush(ctx, texObj);
/* clamp to max, that's what NVIDIA does */
texObj->MaxAnisotropy = MIN2(params[0],
ctx->Const.MaxTextureMaxAnisotropy);
@@ -432,8 +456,10 @@ set_tex_parameterf(GLcontext *ctx,
case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB:
if (ctx->Extensions.ARB_shadow_ambient) {
- FLUSH_VERTICES(ctx, _NEW_TEXTURE);
- texObj->CompareFailValue = CLAMP(params[0], 0.0F, 1.0F);
+ if (texObj->CompareFailValue != params[0]) {
+ flush(ctx, texObj);
+ texObj->CompareFailValue = CLAMP(params[0], 0.0F, 1.0F);
+ }
}
else {
_mesa_error(ctx, GL_INVALID_ENUM,
@@ -445,14 +471,14 @@ set_tex_parameterf(GLcontext *ctx,
/* NOTE: this is really part of OpenGL 1.4, not EXT_texture_lod_bias */
if (ctx->Extensions.EXT_texture_lod_bias) {
if (texObj->LodBias != params[0]) {
- FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ flush(ctx, texObj);
texObj->LodBias = params[0];
}
}
break;
case GL_TEXTURE_BORDER_COLOR:
- FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ flush(ctx, texObj);
texObj->BorderColor[RCOMP] = params[0];
texObj->BorderColor[GCOMP] = params[1];
texObj->BorderColor[BCOMP] = params[2];
@@ -503,8 +529,6 @@ _mesa_TexParameterf(GLenum target, GLenum pname, GLfloat param)
set_tex_parameterf(ctx, texObj, pname, &param);
}
- texObj->_Complete = GL_FALSE;
-
if (ctx->Driver.TexParameter && ctx->ErrorValue == GL_NO_ERROR) {
ctx->Driver.TexParameter(ctx, target, texObj, pname, &param);
}
@@ -560,8 +584,6 @@ _mesa_TexParameterfv(GLenum target, GLenum pname, const GLfloat *params)
set_tex_parameterf(ctx, texObj, pname, params);
}
- texObj->_Complete = GL_FALSE;
-
if (ctx->Driver.TexParameter && ctx->ErrorValue == GL_NO_ERROR) {
ctx->Driver.TexParameter(ctx, target, texObj, pname, params);
}
@@ -597,8 +619,6 @@ _mesa_TexParameteri(GLenum target, GLenum pname, GLint param)
set_tex_parameteri(ctx, texObj, pname, &param);
}
- texObj->_Complete = GL_FALSE;
-
if (ctx->Driver.TexParameter && ctx->ErrorValue == GL_NO_ERROR) {
GLfloat fparam = (GLfloat) param;
ctx->Driver.TexParameter(ctx, target, texObj, pname, &fparam);
@@ -646,8 +666,6 @@ _mesa_TexParameteriv(GLenum target, GLenum pname, const GLint *params)
set_tex_parameteri(ctx, texObj, pname, params);
}
- texObj->_Complete = GL_FALSE;
-
if (ctx->Driver.TexParameter && ctx->ErrorValue == GL_NO_ERROR) {
GLfloat fparams[4];
fparams[0] = INT_TO_FLOAT(params[0]);
diff --git a/src/mesa/swrast/s_fragprog.c b/src/mesa/swrast/s_fragprog.c
index bbb784c46e8..c6601f5593d 100644
--- a/src/mesa/swrast/s_fragprog.c
+++ b/src/mesa/swrast/s_fragprog.c
@@ -84,8 +84,7 @@ fetch_texel_lod( GLcontext *ctx, const GLfloat texcoord[4], GLfloat lambda,
swizzle_texel(rgba, color, texObj->_Swizzle);
}
else {
- color[0] = color[1] = color[2] = 0.0F;
- color[3] = 1.0F;
+ ASSIGN_4V(color, 0.0F, 0.0F, 0.0F, 1.0F);
}
}
@@ -127,8 +126,7 @@ fetch_texel_deriv( GLcontext *ctx, const GLfloat texcoord[4],
swizzle_texel(rgba, color, texObj->_Swizzle);
}
else {
- color[0] = color[1] = color[2] = 0.0F;
- color[3] = 1.0F;
+ ASSIGN_4V(color, 0.0F, 0.0F, 0.0F, 1.0F);
}
}