From b941665b42c95bee72084721aed4d14f349409b4 Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Tue, 3 Dec 2019 20:05:59 +0330 Subject: [PATCH] wined3d: Destroy PBOs in wined3d_texture_gl_destroy_object(). Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- dlls/wined3d/adapter_gl.c | 33 ++++++++++++++++++++++++++++----- dlls/wined3d/texture.c | 24 ------------------------ 2 files changed, 28 insertions(+), 29 deletions(-) diff --git a/dlls/wined3d/adapter_gl.c b/dlls/wined3d/adapter_gl.c index 7018c6da1d9..eb9965723a2 100644 --- a/dlls/wined3d/adapter_gl.c +++ b/dlls/wined3d/adapter_gl.c @@ -4765,17 +4765,39 @@ static void wined3d_texture_gl_destroy_object(void *object) { struct wined3d_renderbuffer_entry *entry, *entry2; struct wined3d_texture_gl *texture_gl = object; + struct wined3d_context *context = NULL; const struct wined3d_gl_info *gl_info; - struct wined3d_context *context; struct wined3d_device *device; + unsigned int sub_count, i; + GLuint buffer_object; TRACE("texture_gl %p.\n", texture_gl); + sub_count = texture_gl->t.level_count * texture_gl->t.layer_count; + for (i = 0; i < sub_count; ++i) + { + if (!(buffer_object = texture_gl->t.sub_resources[i].buffer_object)) + continue; + + TRACE("Deleting buffer object %u.\n", buffer_object); + + if (!context) + { + context = context_acquire(texture_gl->t.resource.device, NULL, 0); + gl_info = wined3d_context_gl(context)->gl_info; + } + + GL_EXTCALL(glDeleteBuffers(1, &buffer_object)); + } + if (!list_empty(&texture_gl->renderbuffers)) { device = texture_gl->t.resource.device; - context = context_acquire(device, NULL, 0); - gl_info = wined3d_context_gl(context)->gl_info; + if (!context) + { + context = context_acquire(device, NULL, 0); + gl_info = wined3d_context_gl(context)->gl_info; + } LIST_FOR_EACH_ENTRY_SAFE(entry, entry2, &texture_gl->renderbuffers, struct wined3d_renderbuffer_entry, entry) { @@ -4784,10 +4806,11 @@ static void wined3d_texture_gl_destroy_object(void *object) gl_info->fbo_ops.glDeleteRenderbuffers(1, &entry->id); heap_free(entry); } - - context_release(context); } + if (context) + context_release(context); + wined3d_texture_gl_unload_texture(texture_gl); heap_free(texture_gl); diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c index 260a0486302..a3bbf2585d8 100644 --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c @@ -1118,38 +1118,14 @@ ULONG CDECL wined3d_texture_incref(struct wined3d_texture *texture) static void wined3d_texture_destroy_object(void *object) { - const struct wined3d_gl_info *gl_info = NULL; struct wined3d_texture *texture = object; - struct wined3d_context *context = NULL; struct wined3d_dc_info *dc_info; unsigned int sub_count; - GLuint buffer_object; unsigned int i; TRACE("texture %p.\n", texture); sub_count = texture->level_count * texture->layer_count; - for (i = 0; i < sub_count; ++i) - { - if (!(buffer_object = texture->sub_resources[i].buffer_object)) - continue; - - TRACE("Deleting buffer object %u.\n", buffer_object); - - /* We may not be able to get a context in - * wined3d_texture_destroy_object() in general, but if a buffer object - * was previously created we can. */ - if (!context) - { - context = context_acquire(texture->resource.device, NULL, 0); - gl_info = wined3d_context_gl(context)->gl_info; - } - - GL_EXTCALL(glDeleteBuffers(1, &buffer_object)); - } - - if (context) - context_release(context); if ((dc_info = texture->dc_info)) {