[PATCH 08/10] wined3d: Cleanup sub-resource buffer objects in wined3d_texture_cleanup().

Henri Verbeet hverbeet at codeweavers.com
Wed Mar 2 12:24:19 CST 2016


From: Stefan Dösinger <stefan at codeweavers.com>

Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
---
 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 994756d..208c254 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 cb2b310..a8e9194 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 3782642..ef0d69b 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);
 }
 
-- 
2.1.4




More information about the wine-patches mailing list