mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-08 13:28:06 +02:00
added some temporary texobj ref counting debug output
This commit is contained in:
parent
75ebda3ce6
commit
08f7fb45ef
6 changed files with 50 additions and 39 deletions
|
|
@ -561,6 +561,9 @@ delete_texture_cb(GLuint id, void *data, void *userData)
|
|||
{
|
||||
struct gl_texture_object *texObj = (struct gl_texture_object *) data;
|
||||
GLcontext *ctx = (GLcontext *) userData;
|
||||
#ifdef DEBUG
|
||||
printf("MESA TEX DELETE %p (%u) from DestroyContext\n", texObj, texObj->Name);
|
||||
#endif
|
||||
ctx->Driver.DeleteTexture(ctx, texObj);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@ _mesa_remove_attachment(GLcontext *ctx, struct gl_renderbuffer_attachment *att)
|
|||
/* tell driver we're done rendering to this texobj */
|
||||
ctx->Driver.FinishRenderTexture(ctx, att);
|
||||
}
|
||||
_mesa_reference_texobj(&att->Texture, NULL); /* unbind */
|
||||
MESA_REF_TEXOBJ(&att->Texture, NULL); /* unbind */
|
||||
ASSERT(!att->Texture);
|
||||
}
|
||||
if (att->Type == GL_TEXTURE || att->Type == GL_RENDERBUFFER_EXT) {
|
||||
|
|
@ -188,7 +188,7 @@ _mesa_set_texture_attachment(GLcontext *ctx,
|
|||
_mesa_remove_attachment(ctx, att);
|
||||
att->Type = GL_TEXTURE;
|
||||
assert(!att->Texture);
|
||||
_mesa_reference_texobj(&att->Texture, texObj);
|
||||
MESA_REF_TEXOBJ(&att->Texture, texObj);
|
||||
}
|
||||
|
||||
/* always update these fields */
|
||||
|
|
|
|||
|
|
@ -191,7 +191,7 @@ _mesa_free_framebuffer_data(struct gl_framebuffer *fb)
|
|||
_mesa_reference_renderbuffer(&att->Renderbuffer, NULL);
|
||||
}
|
||||
if (att->Texture) {
|
||||
_mesa_reference_texobj(&att->Texture, NULL);
|
||||
MESA_REF_TEXOBJ(&att->Texture, NULL);
|
||||
}
|
||||
ASSERT(!att->Renderbuffer);
|
||||
ASSERT(!att->Texture);
|
||||
|
|
|
|||
|
|
@ -154,10 +154,9 @@ _mesa_delete_texture_object( GLcontext *ctx, struct gl_texture_object *texObj )
|
|||
{
|
||||
GLuint i, face;
|
||||
|
||||
/*
|
||||
printf("TEX DELETE %p (%u)\n", (void*) texObj, texObj->Name);
|
||||
*/
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("MESA TEX DELETE %p (%u)\n", (void*) texObj, texObj->Name);
|
||||
#endif
|
||||
(void) ctx;
|
||||
|
||||
/* Set Target to an invalid value. With some assertions elsewhere
|
||||
|
|
@ -260,7 +259,8 @@ valid_texture_object(const struct gl_texture_object *tex)
|
|||
*/
|
||||
void
|
||||
_mesa_reference_texobj(struct gl_texture_object **ptr,
|
||||
struct gl_texture_object *tex)
|
||||
struct gl_texture_object *tex,
|
||||
const char *where)
|
||||
{
|
||||
assert(ptr);
|
||||
if (*ptr == tex) {
|
||||
|
|
@ -278,10 +278,12 @@ _mesa_reference_texobj(struct gl_texture_object **ptr,
|
|||
_glthread_LOCK_MUTEX(oldTex->Mutex);
|
||||
ASSERT(oldTex->RefCount > 0);
|
||||
oldTex->RefCount--;
|
||||
/*
|
||||
printf("TEX DECR %p (%u) to %d\n",
|
||||
(void*) oldTex, oldTex->Name, oldTex->RefCount);
|
||||
*/
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("MESA TEX REF DECR %p (%u) to %d from %s\n",
|
||||
(void*) oldTex, oldTex->Name, oldTex->RefCount, where);
|
||||
#endif
|
||||
|
||||
deleteFlag = (oldTex->RefCount == 0);
|
||||
_glthread_UNLOCK_MUTEX(oldTex->Mutex);
|
||||
|
||||
|
|
@ -309,10 +311,12 @@ _mesa_reference_texobj(struct gl_texture_object **ptr,
|
|||
}
|
||||
else {
|
||||
tex->RefCount++;
|
||||
/*
|
||||
printf("TEX INCR %p (%u) to %d\n",
|
||||
(void*) tex, tex->Name, tex->RefCount);
|
||||
*/
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("MESA TEX REF INCR %p (%u) to %d from %s\n",
|
||||
(void*) tex, tex->Name, tex->RefCount, where);
|
||||
#endif
|
||||
|
||||
*ptr = tex;
|
||||
}
|
||||
_glthread_UNLOCK_MUTEX(tex->Mutex);
|
||||
|
|
@ -732,19 +736,19 @@ unbind_texobj_from_texunits(GLcontext *ctx, struct gl_texture_object *texObj)
|
|||
for (u = 0; u < MAX_TEXTURE_IMAGE_UNITS; u++) {
|
||||
struct gl_texture_unit *unit = &ctx->Texture.Unit[u];
|
||||
if (texObj == unit->Current1D) {
|
||||
_mesa_reference_texobj(&unit->Current1D, ctx->Shared->Default1D);
|
||||
MESA_REF_TEXOBJ(&unit->Current1D, ctx->Shared->Default1D);
|
||||
}
|
||||
else if (texObj == unit->Current2D) {
|
||||
_mesa_reference_texobj(&unit->Current2D, ctx->Shared->Default2D);
|
||||
MESA_REF_TEXOBJ(&unit->Current2D, ctx->Shared->Default2D);
|
||||
}
|
||||
else if (texObj == unit->Current3D) {
|
||||
_mesa_reference_texobj(&unit->Current3D, ctx->Shared->Default3D);
|
||||
MESA_REF_TEXOBJ(&unit->Current3D, ctx->Shared->Default3D);
|
||||
}
|
||||
else if (texObj == unit->CurrentCubeMap) {
|
||||
_mesa_reference_texobj(&unit->CurrentCubeMap, ctx->Shared->DefaultCubeMap);
|
||||
MESA_REF_TEXOBJ(&unit->CurrentCubeMap, ctx->Shared->DefaultCubeMap);
|
||||
}
|
||||
else if (texObj == unit->CurrentRect) {
|
||||
_mesa_reference_texobj(&unit->CurrentRect, ctx->Shared->DefaultRect);
|
||||
MESA_REF_TEXOBJ(&unit->CurrentRect, ctx->Shared->DefaultRect);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -804,10 +808,10 @@ _mesa_DeleteTextures( GLsizei n, const GLuint *textures)
|
|||
_mesa_HashRemove(ctx->Shared->TexObjects, delObj->Name);
|
||||
_glthread_UNLOCK_MUTEX(ctx->Shared->Mutex);
|
||||
|
||||
/* Unrefernce the texobj. If refcount hits zero, the texture
|
||||
/* Unreference the texobj. If refcount hits zero, the texture
|
||||
* will be deleted.
|
||||
*/
|
||||
_mesa_reference_texobj(&delObj, NULL);
|
||||
MESA_REF_TEXOBJ(&delObj, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -921,19 +925,19 @@ _mesa_BindTexture( GLenum target, GLuint texName )
|
|||
*/
|
||||
switch (target) {
|
||||
case GL_TEXTURE_1D:
|
||||
_mesa_reference_texobj(&texUnit->Current1D, newTexObj);
|
||||
MESA_REF_TEXOBJ(&texUnit->Current1D, newTexObj);
|
||||
break;
|
||||
case GL_TEXTURE_2D:
|
||||
_mesa_reference_texobj(&texUnit->Current2D, newTexObj);
|
||||
MESA_REF_TEXOBJ(&texUnit->Current2D, newTexObj);
|
||||
break;
|
||||
case GL_TEXTURE_3D:
|
||||
_mesa_reference_texobj(&texUnit->Current3D, newTexObj);
|
||||
MESA_REF_TEXOBJ(&texUnit->Current3D, newTexObj);
|
||||
break;
|
||||
case GL_TEXTURE_CUBE_MAP_ARB:
|
||||
_mesa_reference_texobj(&texUnit->CurrentCubeMap, newTexObj);
|
||||
MESA_REF_TEXOBJ(&texUnit->CurrentCubeMap, newTexObj);
|
||||
break;
|
||||
case GL_TEXTURE_RECTANGLE_NV:
|
||||
_mesa_reference_texobj(&texUnit->CurrentRect, newTexObj);
|
||||
MESA_REF_TEXOBJ(&texUnit->CurrentRect, newTexObj);
|
||||
break;
|
||||
default:
|
||||
_mesa_problem(ctx, "bad target in BindTexture");
|
||||
|
|
|
|||
|
|
@ -57,9 +57,13 @@ extern void
|
|||
_mesa_copy_texture_object( struct gl_texture_object *dest,
|
||||
const struct gl_texture_object *src );
|
||||
|
||||
#define MESA_REF_TEXOBJ(PTR, TEX) \
|
||||
_mesa_reference_texobj(PTR, TEX, __FUNCTION__)
|
||||
|
||||
extern void
|
||||
_mesa_reference_texobj(struct gl_texture_object **ptr,
|
||||
struct gl_texture_object *tex);
|
||||
struct gl_texture_object *tex,
|
||||
const char *where);
|
||||
|
||||
extern void
|
||||
_mesa_test_texobj_completeness( const GLcontext *ctx,
|
||||
|
|
|
|||
|
|
@ -119,15 +119,15 @@ _mesa_copy_texture_state( const GLcontext *src, GLcontext *dst )
|
|||
/* copy texture object bindings, not contents of texture objects */
|
||||
_mesa_lock_context_textures(dst);
|
||||
|
||||
_mesa_reference_texobj(&dst->Texture.Unit[i].Current1D,
|
||||
MESA_REF_TEXOBJ(&dst->Texture.Unit[i].Current1D,
|
||||
src->Texture.Unit[i].Current1D);
|
||||
_mesa_reference_texobj(&dst->Texture.Unit[i].Current2D,
|
||||
MESA_REF_TEXOBJ(&dst->Texture.Unit[i].Current2D,
|
||||
src->Texture.Unit[i].Current2D);
|
||||
_mesa_reference_texobj(&dst->Texture.Unit[i].Current3D,
|
||||
MESA_REF_TEXOBJ(&dst->Texture.Unit[i].Current3D,
|
||||
src->Texture.Unit[i].Current3D);
|
||||
_mesa_reference_texobj(&dst->Texture.Unit[i].CurrentCubeMap,
|
||||
MESA_REF_TEXOBJ(&dst->Texture.Unit[i].CurrentCubeMap,
|
||||
src->Texture.Unit[i].CurrentCubeMap);
|
||||
_mesa_reference_texobj(&dst->Texture.Unit[i].CurrentRect,
|
||||
MESA_REF_TEXOBJ(&dst->Texture.Unit[i].CurrentRect,
|
||||
src->Texture.Unit[i].CurrentRect);
|
||||
|
||||
_mesa_unlock_context_textures(dst);
|
||||
|
|
@ -3065,11 +3065,11 @@ init_texture_unit( GLcontext *ctx, GLuint unit )
|
|||
ASSIGN_4V( texUnit->EyePlaneQ, 0.0, 0.0, 0.0, 0.0 );
|
||||
|
||||
/* initialize current texture object ptrs to the shared default objects */
|
||||
_mesa_reference_texobj(&texUnit->Current1D, ctx->Shared->Default1D);
|
||||
_mesa_reference_texobj(&texUnit->Current2D, ctx->Shared->Default2D);
|
||||
_mesa_reference_texobj(&texUnit->Current3D, ctx->Shared->Default3D);
|
||||
_mesa_reference_texobj(&texUnit->CurrentCubeMap, ctx->Shared->DefaultCubeMap);
|
||||
_mesa_reference_texobj(&texUnit->CurrentRect, ctx->Shared->DefaultRect);
|
||||
MESA_REF_TEXOBJ(&texUnit->Current1D, ctx->Shared->Default1D);
|
||||
MESA_REF_TEXOBJ(&texUnit->Current2D, ctx->Shared->Default2D);
|
||||
MESA_REF_TEXOBJ(&texUnit->Current3D, ctx->Shared->Default3D);
|
||||
MESA_REF_TEXOBJ(&texUnit->CurrentCubeMap, ctx->Shared->DefaultCubeMap);
|
||||
MESA_REF_TEXOBJ(&texUnit->CurrentRect, ctx->Shared->DefaultRect);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue