diff options
author | Brian Paul <[email protected]> | 2008-07-04 10:29:15 -0600 |
---|---|---|
committer | Brian Paul <[email protected]> | 2008-07-04 10:29:15 -0600 |
commit | 2fa7b3f78639114aec42fcbbfc29d3645832708b (patch) | |
tree | a0dc1ff3b4181e61f5bdf16ffbc3238f22c5c8f8 /src/mesa/main/fbobject.c | |
parent | 9ca1c62a963ca7024c4bccf83af3f90955cd5068 (diff) |
mesa: Implement mutex/locking around texture object reference counting.
Use new _mesa_reference_texobj() function for referencing/unreferencing
textures. Add new assertions/tests to try to detect invalid usage of
deleted textures.
cherry-picked from master (9e01b915f1243a3f551cb795b7124bd1e52ca15f)
Diffstat (limited to 'src/mesa/main/fbobject.c')
-rw-r--r-- | src/mesa/main/fbobject.c | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c index 56a3131016f..0ae69bdce7a 100644 --- a/src/mesa/main/fbobject.c +++ b/src/mesa/main/fbobject.c @@ -172,17 +172,12 @@ _mesa_remove_attachment(GLcontext *ctx, struct gl_renderbuffer_attachment *att) { if (att->Type == GL_TEXTURE) { ASSERT(att->Texture); - att->Texture->RefCount--; - if (att->Texture->RefCount == 0) { - ctx->Driver.DeleteTexture(ctx, att->Texture); - } - else { + if (ctx->Driver.FinishRenderTexture) { /* tell driver that we're done rendering to this texture. */ - if (ctx->Driver.FinishRenderTexture) { - ctx->Driver.FinishRenderTexture(ctx, att); - } + ctx->Driver.FinishRenderTexture(ctx, att); } - att->Texture = NULL; + _mesa_reference_texobj(&att->Texture, NULL); /* unbind */ + ASSERT(!att->Texture); } if (att->Type == GL_TEXTURE || att->Type == GL_RENDERBUFFER_EXT) { ASSERT(!att->Texture); @@ -213,8 +208,8 @@ _mesa_set_texture_attachment(GLcontext *ctx, /* new attachment */ _mesa_remove_attachment(ctx, att); att->Type = GL_TEXTURE; - att->Texture = texObj; - texObj->RefCount++; + assert(!att->Texture); + _mesa_reference_texobj(&att->Texture, texObj); } /* always update these fields */ |