Zebediah Figura : wined3d: Call wined3d_context_unmap_bo_address() when updating a buffer BO.

Alexandre Julliard julliard at winehq.org
Thu Feb 10 16:10:30 CST 2022


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

Author: Zebediah Figura <zfigura at codeweavers.com>
Date:   Wed Feb  9 20:27:36 2022 -0600

wined3d: Call wined3d_context_unmap_bo_address() when updating a buffer BO.

That is, don't just flush it, but unmap it as well.

As of d8e8ab21c0f9f00d295c035534637115a5d70f9f, we can get here even when
!wined3d_map_persistent(). Thus we currently end up leaving BOs mapped when
performing an accelerated DISCARD map. Try to avoid that.

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/buffer.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c
index a06bfb984ad..50e3e9fe2b4 100644
--- a/dlls/wined3d/buffer.c
+++ b/dlls/wined3d/buffer.c
@@ -1156,9 +1156,27 @@ void wined3d_buffer_update_sub_resource(struct wined3d_buffer *buffer, struct wi
     }
 
     if (upload_bo->addr.buffer_object && upload_bo->addr.buffer_object == buffer->buffer_object)
-        wined3d_context_flush_bo_address(context, &upload_bo->addr, size);
+    {
+        struct wined3d_range range;
+
+        /* We need to flush changes, which is implicitly done by
+         * wined3d_context_unmap_bo_address() even if we aren't actually going
+         * to unmap.
+         *
+         * We would also like to free up virtual address space used by this BO
+         * if it's at a premium—note that this BO was allocated for an
+         * accelerated map. Hence we unmap the BO instead of merely flushing it;
+         * if we don't care about unmapping BOs then
+         * wined3d_context_unmap_bo_address() will flush and return.
+         */
+        range.offset = offset;
+        range.size = size;
+        wined3d_context_unmap_bo_address(context, (const struct wined3d_bo_address *)&upload_bo->addr, 1, &range);
+    }
     else
+    {
         wined3d_buffer_copy_bo_address(buffer, context, offset, &upload_bo->addr, size);
+    }
 }
 
 static void wined3d_buffer_init_data(struct wined3d_buffer *buffer,




More information about the wine-cvs mailing list