Zebediah Figura : wined3d: Prevent buildup of retired OpenGL buffer objects' memory.

Alexandre Julliard julliard at winehq.org
Fri Mar 11 14:49:09 CST 2022


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

Author: Zebediah Figura <zfigura at codeweavers.com>
Date:   Thu Mar 10 17:56:54 2022 -0600

wined3d: Prevent buildup of retired OpenGL buffer objects' memory.

Analogous to d71358f5e9e20f4a99354a0192b67009019b78d3 for the Vulkan backend.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52574
Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/wined3d/context_gl.c      | 12 ++++++++++++
 dlls/wined3d/wined3d_private.h |  1 +
 2 files changed, 13 insertions(+)

diff --git a/dlls/wined3d/context_gl.c b/dlls/wined3d/context_gl.c
index bb186706ad5..8ac5c28c892 100644
--- a/dlls/wined3d/context_gl.c
+++ b/dlls/wined3d/context_gl.c
@@ -2713,6 +2713,7 @@ void wined3d_context_gl_submit_command_fence(struct wined3d_context_gl *context_
         device_gl->completed_fence_id = 0;
         device_gl->current_fence_id = 1;
     }
+    device_gl->retired_bo_size = 0;
     wined3d_context_gl_cleanup_resources(context_gl);
 }
 
@@ -3123,15 +3124,26 @@ 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)
 {
+    struct wined3d_device_gl *device_gl = wined3d_device_gl(context_gl->c.device);
     const struct wined3d_gl_info *gl_info = context_gl->gl_info;
 
     TRACE("context_gl %p, bo %p.\n", context_gl, bo);
 
     if (bo->memory)
     {
+        unsigned int order = bo->memory->order;
+
         if (bo->b.map_ptr)
             wined3d_allocator_chunk_gl_unmap(wined3d_allocator_chunk_gl(bo->memory->chunk), context_gl);
         wined3d_context_gl_destroy_allocator_block(context_gl, bo->memory, bo->command_fence_id);
+
+        if (bo->command_fence_id == device_gl->current_fence_id)
+        {
+            device_gl->retired_bo_size += WINED3D_ALLOCATOR_CHUNK_SIZE >> order;
+            if (device_gl->retired_bo_size > WINED3D_RETIRED_BO_SIZE_THRESHOLD)
+                wined3d_context_gl_submit_command_fence(context_gl);
+        }
+
         bo->id = 0;
         return;
     }
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index e46b6dfb9e0..e0a60a5807d 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -4154,6 +4154,7 @@ struct wined3d_device_gl
     struct wined3d_allocator allocator;
     uint64_t completed_fence_id;
     uint64_t current_fence_id;
+    uint64_t retired_bo_size;
 
     struct wined3d_retired_block_gl
     {




More information about the wine-cvs mailing list