=?UTF-8?Q?J=C3=B3zef=20Kucia=20?=: wined3d: Try to avoid allocating sysmem for GPU buffers with initial data.

Alexandre Julliard julliard at winehq.org
Fri Sep 7 16:49:26 CDT 2018


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

Author: Józef Kucia <jkucia at codeweavers.com>
Date:   Thu Sep  6 22:02:00 2018 +0200

wined3d: Try to avoid allocating sysmem for GPU buffers with initial data.

Signed-off-by: Józef Kucia <jkucia 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 | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c
index 639a145..f381b2e 100644
--- a/dlls/wined3d/buffer.c
+++ b/dlls/wined3d/buffer.c
@@ -1379,9 +1379,6 @@ static HRESULT buffer_init(struct wined3d_buffer *buffer, struct wined3d_device
     buffer->bind_flags = bind_flags;
     buffer->locations = data ? WINED3D_LOCATION_DISCARDED : WINED3D_LOCATION_SYSMEM;
 
-    if (!wined3d_resource_allocate_sysmem(&buffer->resource))
-        return E_OUTOFMEMORY;
-
     TRACE("buffer %p, size %#x, usage %#x, format %s, memory @ %p.\n",
             buffer, buffer->resource.size, buffer->resource.usage,
             debug_d3dformat(buffer->resource.format->id), buffer->resource.heap_memory);
@@ -1394,6 +1391,7 @@ static HRESULT buffer_init(struct wined3d_buffer *buffer, struct wined3d_device
          * the buffer to provide the same behavior to the application. */
         TRACE("Pinning system memory.\n");
         buffer->flags |= WINED3D_BUFFER_PIN_SYSMEM;
+        buffer->locations = WINED3D_LOCATION_SYSMEM;
     }
 
     /* Observations show that draw_primitive_immediate_mode() is faster on
@@ -1418,6 +1416,12 @@ static HRESULT buffer_init(struct wined3d_buffer *buffer, struct wined3d_device
         buffer->flags |= WINED3D_BUFFER_USE_BO;
     }
 
+    if (buffer->locations & WINED3D_LOCATION_SYSMEM || !(buffer->flags & WINED3D_BUFFER_USE_BO))
+    {
+        if (!wined3d_resource_allocate_sysmem(&buffer->resource))
+            return E_OUTOFMEMORY;
+    }
+
     if (!(buffer->maps = heap_alloc(sizeof(*buffer->maps))))
     {
         ERR("Out of memory.\n");




More information about the wine-cvs mailing list