X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fmain%2Ftexobj.c;h=678845ece068ff0fd694c7ed6f52d555b8b58cd8;hb=d6ee86c77a8e1543557fd64c1f1c354baa0a8ad8;hp=0024efc0e64cab1ce8a5d5685d795a8b4c4e9472;hpb=221b30d595ab2f97fd0518c761615dd28f3ef5ca;p=mesa.git diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c index 0024efc0e64..678845ece06 100644 --- a/src/mesa/main/texobj.c +++ b/src/mesa/main/texobj.c @@ -29,9 +29,7 @@ #include "mfeatures.h" -#if FEATURE_colortable #include "colortab.h" -#endif #include "context.h" #include "enums.h" #include "fbobject.h" @@ -194,9 +192,7 @@ _mesa_delete_texture_object( GLcontext *ctx, struct gl_texture_object *texObj ) */ texObj->Target = 0x99; -#if FEATURE_colortable _mesa_free_colortable_data(&texObj->Palette); -#endif /* free the texture images */ for (face = 0; face < 6; face++) { @@ -260,6 +256,32 @@ _mesa_copy_texture_object( struct gl_texture_object *dest, } +/** + * Clear all texture images of the given texture object. + * + * \param ctx GL context. + * \param t texture object. + * + * \sa _mesa_clear_texture_image(). + */ +void +_mesa_clear_texture_object(GLcontext *ctx, struct gl_texture_object *texObj) +{ + GLuint i, j; + + if (texObj->Target == 0) + return; + + for (i = 0; i < MAX_FACES; i++) { + for (j = 0; j < MAX_TEXTURE_LEVELS; j++) { + struct gl_texture_image *texImage = texObj->Image[i][j]; + if (texImage) + _mesa_clear_texture_image(ctx, texImage); + } + } +} + + /** * Check if the given texture object is valid by examining its Target field. * For debugging only. @@ -281,7 +303,8 @@ valid_texture_object(const struct gl_texture_object *tex) _mesa_problem(NULL, "invalid reference to a deleted texture object"); return GL_FALSE; default: - _mesa_problem(NULL, "invalid texture object Target value"); + _mesa_problem(NULL, "invalid texture object Target 0x%x, Id = %u", + tex->Target, tex->Name); return GL_FALSE; } } @@ -307,7 +330,7 @@ _mesa_reference_texobj(struct gl_texture_object **ptr, GLboolean deleteFlag = GL_FALSE; struct gl_texture_object *oldTex = *ptr; - assert(valid_texture_object(oldTex)); + ASSERT(valid_texture_object(oldTex)); _glthread_LOCK_MUTEX(oldTex->Mutex); ASSERT(oldTex->RefCount > 0); @@ -330,7 +353,7 @@ _mesa_reference_texobj(struct gl_texture_object **ptr, if (tex) { /* reference new texture */ - assert(valid_texture_object(tex)); + ASSERT(valid_texture_object(tex)); _glthread_LOCK_MUTEX(tex->Mutex); if (tex->RefCount == 0) { /* this texture's being deleted (look just above) */ @@ -663,6 +686,24 @@ _mesa_test_texobj_completeness( const GLcontext *ctx, } +/** + * Mark a texture object dirty. It forces the object to be incomplete + * and optionally forces the context to re-validate its state. + * + * \param ctx GL context. + * \param texObj texture object. + * \param invalidate_state also invalidate context state. + */ +void +_mesa_dirty_texobj(GLcontext *ctx, struct gl_texture_object *texObj, + GLboolean invalidate_state) +{ + texObj->_Complete = GL_FALSE; + if (invalidate_state) + ctx->NewState |= _NEW_TEXTURE; +} + + /** * Return pointer to a default/fallback texture. * The texture is a 2D 8x8 RGBA texture with all texels = (0,0,0,1). @@ -714,7 +755,6 @@ _mesa_get_fallback_texture(GLcontext *ctx) } - /*@}*/ @@ -944,6 +984,7 @@ _mesa_BindTexture( GLenum target, GLuint texName ) struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; struct gl_texture_object *newTexObj = NULL, *defaultTexObj = NULL; GLint targetIndex; + GLboolean early_out = GL_FALSE; ASSERT_OUTSIDE_BEGIN_END(ctx); if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE)) @@ -997,6 +1038,17 @@ _mesa_BindTexture( GLenum target, GLuint texName ) assert(valid_texture_object(newTexObj)); + _glthread_LOCK_MUTEX(ctx->Shared->Mutex); + if ((ctx->Shared->RefCount == 1) + && (newTexObj == texUnit->CurrentTex[targetIndex])) { + early_out = GL_TRUE; + } + _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); + + if (early_out) { + return; + } + /* flush before changing binding */ FLUSH_VERTICES(ctx, _NEW_TEXTURE); @@ -1147,10 +1199,9 @@ _mesa_IsTexture( GLuint texture ) /** - * Simplest implementation of texture locking: Grab the a new mutex in - * the shared context. Examine the shared context state timestamp and - * if there has been a change, set the appropriate bits in - * ctx->NewState. + * Simplest implementation of texture locking: grab the shared tex + * mutex. Examine the shared context state timestamp and if there has + * been a change, set the appropriate bits in ctx->NewState. * * This is used to deal with synchronizing things when a texture object * is used/modified by different contexts (or threads) which are sharing