Henri Verbeet : wined3d: Destroy PBOs in wined3d_texture_gl_destroy_object().

Alexandre Julliard julliard at winehq.org
Tue Dec 3 16:13:12 CST 2019


Module: wine
Branch: master
Commit: b941665b42c95bee72084721aed4d14f349409b4
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=b941665b42c95bee72084721aed4d14f349409b4

Author: Henri Verbeet <hverbeet at codeweavers.com>
Date:   Tue Dec  3 20:23:59 2019 +0330

wined3d: Destroy PBOs in wined3d_texture_gl_destroy_object().

Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/wined3d/adapter_gl.c | 31 +++++++++++++++++++++++++++----
 dlls/wined3d/texture.c    | 24 ------------------------
 2 files changed, 27 insertions(+), 28 deletions(-)

diff --git a/dlls/wined3d/adapter_gl.c b/dlls/wined3d/adapter_gl.c
index 7018c6da1d..eb9965723a 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,9 +4806,10 @@ static void wined3d_texture_gl_destroy_object(void *object)
             gl_info->fbo_ops.glDeleteRenderbuffers(1, &entry->id);
             heap_free(entry);
         }
+    }
 
+    if (context)
         context_release(context);
-    }
 
     wined3d_texture_gl_unload_texture(texture_gl);
 
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index 260a048630..a3bbf2585d 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))
     {




More information about the wine-cvs mailing list