diff options
author | Keith Whitwell <keith@tungstengraphics.com> | 2006-10-10 14:46:38 +0000 |
---|---|---|
committer | Keith Whitwell <keith@tungstengraphics.com> | 2006-10-10 14:46:38 +0000 |
commit | 0dab8d51e576730a909fee5f51d7385ca3b0ce3e (patch) | |
tree | cd9f65925e79dafe190f45474cde5750169c1c61 | |
parent | e6bed0e7d1ba705765ca55ad26b6cc5875e9ea0a (diff) |
Also need to lock textures around _mesa_update_state() as values like
texObj->Complete are modified in that routine. Unfortunately we
sometimes need to update state within a region where textures are
locked. Get around this with a new _mesa_update_state_locked() call.
-rw-r--r-- | src/mesa/drivers/dri/i915/intel_tris.c | 2 | ||||
-rw-r--r-- | src/mesa/main/attrib.c | 5 | ||||
-rw-r--r-- | src/mesa/main/state.c | 15 | ||||
-rw-r--r-- | src/mesa/main/state.h | 6 | ||||
-rw-r--r-- | src/mesa/main/teximage.c | 18 | ||||
-rw-r--r-- | src/mesa/main/texstate.c | 4 |
6 files changed, 39 insertions, 11 deletions
diff --git a/src/mesa/drivers/dri/i915/intel_tris.c b/src/mesa/drivers/dri/i915/intel_tris.c index 1a0e32347c..78e9bd160f 100644 --- a/src/mesa/drivers/dri/i915/intel_tris.c +++ b/src/mesa/drivers/dri/i915/intel_tris.c @@ -862,7 +862,7 @@ intelRunPipeline(GLcontext * ctx) _mesa_lock_context_textures(ctx); if (ctx->NewState) - _mesa_update_state(ctx); + _mesa_update_state_locked(ctx); if (intel->NewGLState) { if (intel->NewGLState & _NEW_TEXTURE) { diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c index ef970ad9eb..e22edc1bbc 100644 --- a/src/mesa/main/attrib.c +++ b/src/mesa/main/attrib.c @@ -337,6 +337,8 @@ _mesa_PushAttrib(GLbitfield mask) if (mask & GL_TEXTURE_BIT) { struct gl_texture_attrib *attr; GLuint u; + + _mesa_lock_context_textures(ctx); /* Bump the texture object reference counts so that they don't * inadvertantly get deleted. */ @@ -362,6 +364,9 @@ _mesa_PushAttrib(GLbitfield mask) _mesa_copy_texture_object(&attr->Unit[u].SavedRect, attr->Unit[u].CurrentRect); } + + _mesa_unlock_context_textures(ctx); + newnode = new_attrib_node( GL_TEXTURE_BIT ); newnode->data = attr; newnode->next = head; diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c index 0b7214f9dd..3efe9d9961 100644 --- a/src/mesa/main/state.c +++ b/src/mesa/main/state.c @@ -1014,7 +1014,7 @@ update_color(GLcontext *ctx) * _mesa_update_lighting() and _mesa_update_tnl_spaces(). */ void -_mesa_update_state( GLcontext *ctx ) +_mesa_update_state_locked( GLcontext *ctx ) { GLbitfield new_state = ctx->NewState; @@ -1095,4 +1095,17 @@ _mesa_update_state( GLcontext *ctx ) ctx->Array.NewState = 0; } + +/* This is the usual entrypoint for state updates: + */ +void +_mesa_update_state( GLcontext *ctx ) +{ + _mesa_lock_context_textures(ctx); + _mesa_update_state_locked(ctx); + _mesa_unlock_context_textures(ctx); +} + + + /*@}*/ diff --git a/src/mesa/main/state.h b/src/mesa/main/state.h index 58cfcc4146..5240d4bf93 100644 --- a/src/mesa/main/state.h +++ b/src/mesa/main/state.h @@ -39,5 +39,11 @@ _mesa_init_exec_table(struct _glapi_table *exec); extern void _mesa_update_state( GLcontext *ctx ); +/* As above but can only be called between _mesa_lock_context_textures() and + * _mesa_unlock_context_textures(). + */ +extern void +_mesa_update_state_locked( GLcontext *ctx ); + #endif diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index c4ca4cf9b8..d0ca8c0cf3 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -2246,6 +2246,9 @@ _mesa_TexImage1D( GLenum target, GLint level, GLint internalFormat, return; /* error was recorded */ } + if (ctx->NewState & _IMAGE_NEW_TRANSFER_STATE) + _mesa_update_state(ctx); + texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; texObj = _mesa_select_tex_object(ctx, texUnit, target); _mesa_lock_texture(ctx, texObj); @@ -2267,9 +2270,6 @@ _mesa_TexImage1D( GLenum target, GLint level, GLint internalFormat, postConvWidth, 1, 1, border, internalFormat); - if (ctx->NewState & _IMAGE_NEW_TRANSFER_STATE) - _mesa_update_state(ctx); - ASSERT(ctx->Driver.TexImage1D); /* Give the texture to the driver! <pixels> may be null! */ @@ -2348,6 +2348,9 @@ _mesa_TexImage2D( GLenum target, GLint level, GLint internalFormat, return; /* error was recorded */ } + if (ctx->NewState & _IMAGE_NEW_TRANSFER_STATE) + _mesa_update_state(ctx); + texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; texObj = _mesa_select_tex_object(ctx, texUnit, target); _mesa_lock_texture(ctx, texObj); @@ -2368,9 +2371,6 @@ _mesa_TexImage2D( GLenum target, GLint level, GLint internalFormat, postConvWidth, postConvHeight, 1, border, internalFormat); - if (ctx->NewState & _IMAGE_NEW_TRANSFER_STATE) - _mesa_update_state(ctx); - ASSERT(ctx->Driver.TexImage2D); /* Give the texture to the driver! <pixels> may be null! */ @@ -2445,6 +2445,9 @@ _mesa_TexImage3D( GLenum target, GLint level, GLint internalFormat, return; /* error was recorded */ } + if (ctx->NewState & _IMAGE_NEW_TRANSFER_STATE) + _mesa_update_state(ctx); + texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; texObj = _mesa_select_tex_object(ctx, texUnit, target); _mesa_lock_texture(ctx, texObj); @@ -2465,9 +2468,6 @@ _mesa_TexImage3D( GLenum target, GLint level, GLint internalFormat, width, height, depth, border, internalFormat); - if (ctx->NewState & _IMAGE_NEW_TRANSFER_STATE) - _mesa_update_state(ctx); - ASSERT(ctx->Driver.TexImage3D); /* Give the texture to the driver! <pixels> may be null! */ diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c index 679a21e162..55b0dabcc8 100644 --- a/src/mesa/main/texstate.c +++ b/src/mesa/main/texstate.c @@ -144,6 +144,8 @@ _mesa_copy_texture_state( const GLcontext *src, GLcontext *dst ) dst->Texture.Unit[i].Combine.ScaleShiftA = src->Texture.Unit[i].Combine.ScaleShiftA; /* copy texture object bindings, not contents of texture objects */ + _mesa_lock_context_textures(dst); + copy_texture_binding(src, &dst->Texture.Unit[i].Current1D, src->Texture.Unit[i].Current1D); copy_texture_binding(src, &dst->Texture.Unit[i].Current2D, @@ -154,6 +156,8 @@ _mesa_copy_texture_state( const GLcontext *src, GLcontext *dst ) src->Texture.Unit[i].CurrentCubeMap); copy_texture_binding(src, &dst->Texture.Unit[i].CurrentRect, src->Texture.Unit[i].CurrentRect); + + _mesa_unlock_context_textures(dst); } } |