Matteo Bruni : wined3d: Introduce wined3d_context_gl_destroy_bo().

Alexandre Julliard julliard at winehq.org
Mon Nov 30 16:13:45 CST 2020


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

Author: Matteo Bruni <mbruni at codeweavers.com>
Date:   Mon Nov 30 18:29:21 2020 +0330

wined3d: Introduce wined3d_context_gl_destroy_bo().

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

---

 dlls/wined3d/adapter_gl.c      |  2 +-
 dlls/wined3d/buffer.c          |  5 +----
 dlls/wined3d/context_gl.c      | 12 ++++++++++++
 dlls/wined3d/texture.c         | 14 +++++---------
 dlls/wined3d/wined3d_private.h |  1 +
 5 files changed, 20 insertions(+), 14 deletions(-)

diff --git a/dlls/wined3d/adapter_gl.c b/dlls/wined3d/adapter_gl.c
index 140948beb6d..cb382cd6734 100644
--- a/dlls/wined3d/adapter_gl.c
+++ b/dlls/wined3d/adapter_gl.c
@@ -4778,7 +4778,7 @@ static void wined3d_view_gl_destroy_object(void *object)
             gl_info->gl_ops.gl.p_glDeleteTextures(1, &ctx->gl_view->name);
         }
         if (counter_id)
-            GL_EXTCALL(glDeleteBuffers(1, &counter_id));
+            wined3d_context_gl_destroy_bo(wined3d_context_gl(context), ctx->counter_bo);
         checkGLcall("delete resources");
         context_release(context);
     }
diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c
index f2817eeee04..2b24e071c05 100644
--- a/dlls/wined3d/buffer.c
+++ b/dlls/wined3d/buffer.c
@@ -142,7 +142,6 @@ static void wined3d_buffer_gl_bind(struct wined3d_buffer_gl *buffer_gl, struct w
 static void wined3d_buffer_gl_destroy_buffer_object(struct wined3d_buffer_gl *buffer_gl,
         struct wined3d_context_gl *context_gl)
 {
-    const struct wined3d_gl_info *gl_info = context_gl->gl_info;
     struct wined3d_resource *resource = &buffer_gl->b.resource;
     struct wined3d_buffer *buffer = &buffer_gl->b;
     struct wined3d_cs *cs = resource->device->cs;
@@ -185,10 +184,8 @@ static void wined3d_buffer_gl_destroy_buffer_object(struct wined3d_buffer_gl *bu
         }
     }
 
-    GL_EXTCALL(glDeleteBuffers(1, &buffer_gl->bo.id));
-    checkGLcall("glDeleteBuffers");
+    wined3d_context_gl_destroy_bo(context_gl, &buffer_gl->bo);
     buffer_gl->b.buffer_object = 0;
-    buffer_gl->bo.id = 0;
 
     if (buffer_gl->b.fence)
     {
diff --git a/dlls/wined3d/context_gl.c b/dlls/wined3d/context_gl.c
index f2b5e8697b6..3a5718e6308 100644
--- a/dlls/wined3d/context_gl.c
+++ b/dlls/wined3d/context_gl.c
@@ -2681,6 +2681,18 @@ void wined3d_context_gl_copy_bo_address(struct wined3d_context_gl *context_gl,
     }
 }
 
+void wined3d_context_gl_destroy_bo(struct wined3d_context_gl *context_gl, struct wined3d_bo_gl *bo)
+{
+    const struct wined3d_gl_info *gl_info = context_gl->gl_info;
+
+    TRACE("context_gl %p, bo %p.\n", context_gl, bo);
+
+    TRACE("Destroying GL buffer %u.\n", bo->id);
+    GL_EXTCALL(glDeleteBuffers(1, &bo->id));
+    checkGLcall("buffer object destruction");
+    bo->id = 0;
+}
+
 static void wined3d_context_gl_set_render_offscreen(struct wined3d_context_gl *context_gl, BOOL offscreen)
 {
     if (context_gl->c.render_offscreen == offscreen)
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index 41e4415f13f..0aef891547a 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -751,18 +751,14 @@ void wined3d_texture_get_memory(struct wined3d_texture *texture, unsigned int su
 
 /* Context activation is done by the caller. */
 static void wined3d_texture_remove_buffer_object(struct wined3d_texture *texture,
-        unsigned int sub_resource_idx, const struct wined3d_gl_info *gl_info)
+        unsigned int sub_resource_idx, struct wined3d_context_gl *context_gl)
 {
     struct wined3d_bo_gl *bo = &texture->sub_resources[sub_resource_idx].bo;
 
-    GL_EXTCALL(glDeleteBuffers(1, &bo->id));
-    checkGLcall("glDeleteBuffers");
-
-    TRACE("Deleted buffer object %u for texture %p, sub-resource %u.\n",
-            bo->id, texture, sub_resource_idx);
+    TRACE("texture %p, sub_resource_idx %u, context_gl %p.\n", texture, sub_resource_idx, context_gl);
 
+    wined3d_context_gl_destroy_bo(context_gl, bo);
     wined3d_texture_invalidate_location(texture, sub_resource_idx, WINED3D_LOCATION_BUFFER);
-    bo->id = 0;
 }
 
 static void wined3d_texture_update_map_binding(struct wined3d_texture *texture)
@@ -781,7 +777,7 @@ static void wined3d_texture_update_map_binding(struct wined3d_texture *texture)
                 && !wined3d_texture_load_location(texture, i, context, map_binding))
             ERR("Failed to load location %s.\n", wined3d_debug_location(map_binding));
         if (texture->resource.map_binding == WINED3D_LOCATION_BUFFER)
-            wined3d_texture_remove_buffer_object(texture, i, wined3d_context_gl(context)->gl_info);
+            wined3d_texture_remove_buffer_object(texture, i, wined3d_context_gl(context));
     }
 
     context_release(context);
@@ -3223,7 +3219,7 @@ static void wined3d_texture_gl_unload_location(struct wined3d_texture *texture,
             for (i = 0; i < sub_count; ++i)
             {
                 if (texture_gl->t.sub_resources[i].bo.id)
-                    wined3d_texture_remove_buffer_object(&texture_gl->t, i, context_gl->gl_info);
+                    wined3d_texture_remove_buffer_object(&texture_gl->t, i, context_gl);
             }
             break;
 
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 15380f5ac81..fa718501e45 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2256,6 +2256,7 @@ void wined3d_context_gl_check_fbo_status(const struct wined3d_context_gl *contex
 void wined3d_context_gl_copy_bo_address(struct wined3d_context_gl *context_gl,
         const struct wined3d_bo_address *dst, const struct wined3d_bo_address *src, size_t size) DECLSPEC_HIDDEN;
 void wined3d_context_gl_destroy(struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
+void wined3d_context_gl_destroy_bo(struct wined3d_context_gl *context_gl, struct wined3d_bo_gl *bo) DECLSPEC_HIDDEN;
 void wined3d_context_gl_draw_shaded_quad(struct wined3d_context_gl *context_gl, struct wined3d_texture_gl *texture_gl,
         unsigned int sub_resource_idx, const RECT *src_rect, const RECT *dst_rect,
         enum wined3d_texture_filter_type filter) DECLSPEC_HIDDEN;




More information about the wine-cvs mailing list