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.
This commit is contained in:
@@ -151,22 +151,18 @@ _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);
|
||||
if (ctx->Driver.FinishRenderTexture) {
|
||||
/* tell driver we're done rendering to this texobj */
|
||||
ctx->Driver.FinishRenderTexture(ctx, att);
|
||||
}
|
||||
else {
|
||||
/* tell driver that we're done rendering to this texture. */
|
||||
if (ctx->Driver.FinishRenderTexture) {
|
||||
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->Renderbuffer);
|
||||
ASSERT(!att->Texture);
|
||||
_mesa_reference_renderbuffer(&att->Renderbuffer, NULL);
|
||||
_mesa_reference_renderbuffer(&att->Renderbuffer, NULL); /* unbind */
|
||||
ASSERT(!att->Renderbuffer);
|
||||
}
|
||||
att->Type = GL_NONE;
|
||||
att->Complete = GL_TRUE;
|
||||
@@ -192,8 +188,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 */
|
||||
|
Reference in New Issue
Block a user