From 45fa5b6471093db4f97f90b661d1f89d56aa48e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20D=C3=B6singer?= Date: Wed, 2 Mar 2016 19:24:19 +0100 Subject: [PATCH] wined3d: Cleanup sub-resource buffer objects in wined3d_texture_cleanup(). Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- dlls/wined3d/surface.c | 11 +---------- dlls/wined3d/texture.c | 27 +++++++++++++++++++++++++++ dlls/wined3d/volume.c | 3 --- 3 files changed, 28 insertions(+), 13 deletions(-) diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c index 994756dad14..208c254681a 100644 --- a/dlls/wined3d/surface.c +++ b/dlls/wined3d/surface.c @@ -48,13 +48,10 @@ static unsigned int surface_get_sub_resource_idx(const struct wined3d_surface *s void wined3d_surface_cleanup(struct wined3d_surface *surface) { struct wined3d_surface *overlay, *cur; - GLuint buffer_object; TRACE("surface %p.\n", surface); - buffer_object = surface->container->sub_resources[surface_get_sub_resource_idx(surface)].buffer_object; - if (buffer_object || surface->rb_multisample - || surface->rb_resolved || !list_empty(&surface->renderbuffers)) + if (surface->rb_multisample || surface->rb_resolved || !list_empty(&surface->renderbuffers)) { struct wined3d_renderbuffer_entry *entry, *entry2; const struct wined3d_gl_info *gl_info; @@ -64,12 +61,6 @@ void wined3d_surface_cleanup(struct wined3d_surface *surface) context = context_acquire(device, NULL); gl_info = context->gl_info; - if (buffer_object) - { - TRACE("Deleting buffer object %u.\n", buffer_object); - GL_EXTCALL(glDeleteBuffers(1, &buffer_object)); - } - if (surface->rb_multisample) { TRACE("Deleting multisample renderbuffer %u.\n", surface->rb_multisample); diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c index cb2b310fa4a..a8e9194037d 100644 --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c @@ -108,8 +108,35 @@ static void wined3d_texture_unload_gl_texture(struct wined3d_texture *texture) static void wined3d_texture_cleanup(struct wined3d_texture *texture) { + unsigned int sub_count = texture->level_count * texture->layer_count; + struct wined3d_device *device = texture->resource.device; + struct wined3d_context *context = NULL; + const struct wined3d_gl_info *gl_info; + GLuint buffer_object; + unsigned int i; + TRACE("texture %p.\n", texture); + 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_cleanup() in + * general, but if a buffer object was previously created we can. */ + if (!context) + { + context = context_acquire(device, NULL); + gl_info = context->gl_info; + } + + GL_EXTCALL(glDeleteBuffers(1, &buffer_object)); + } + if (context) + context_release(context); + texture->texture_ops->texture_cleanup_sub_resources(texture); wined3d_texture_unload_gl_texture(texture); resource_cleanup(&texture->resource); diff --git a/dlls/wined3d/volume.c b/dlls/wined3d/volume.c index 37826425fb6..ef0d69bef82 100644 --- a/dlls/wined3d/volume.c +++ b/dlls/wined3d/volume.c @@ -397,9 +397,6 @@ void wined3d_volume_cleanup(struct wined3d_volume *volume) { TRACE("volume %p.\n", volume); - if (volume->container->sub_resources[volume->texture_level].buffer_object) - wined3d_volume_free_pbo(volume); - resource_cleanup(&volume->resource); }