Henri Verbeet : wined3d: Do not add wined3d internal resources to the device resource list.

Alexandre Julliard julliard at winehq.org
Thu Apr 13 13:06:08 CDT 2017


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

Author: Henri Verbeet <hverbeet at codeweavers.com>
Date:   Thu Apr 13 00:10:59 2017 +0200

wined3d: Do not add wined3d internal resources to the device resource list.

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

---

 dlls/wined3d/resource.c | 35 +++++++++++++++++++++--------------
 dlls/wined3d/surface.c  |  2 +-
 include/wine/wined3d.h  |  1 +
 3 files changed, 23 insertions(+), 15 deletions(-)

diff --git a/dlls/wined3d/resource.c b/dlls/wined3d/resource.c
index 4e0f6a6..5f75b93 100644
--- a/dlls/wined3d/resource.c
+++ b/dlls/wined3d/resource.c
@@ -57,6 +57,7 @@ static void resource_check_usage(DWORD usage)
             | WINED3DUSAGE_AUTOGENMIPMAP
             | WINED3DUSAGE_STATICDECL
             | WINED3DUSAGE_OVERLAY
+            | WINED3DUSAGE_PRIVATE
             | WINED3DUSAGE_LEGACY_CUBEMAP
             | WINED3DUSAGE_TEXTURE;
 
@@ -216,19 +217,22 @@ HRESULT resource_init(struct wined3d_resource *resource, struct wined3d_device *
         resource->heap_memory = NULL;
     }
 
-    /* Check that we have enough video ram left */
-    if (pool == WINED3D_POOL_DEFAULT && device->wined3d->flags & WINED3D_VIDMEM_ACCOUNTING)
+    if (!(usage & WINED3DUSAGE_PRIVATE))
     {
-        if (size > wined3d_device_get_available_texture_mem(device))
+        /* Check that we have enough video ram left */
+        if (pool == WINED3D_POOL_DEFAULT && device->wined3d->flags & WINED3D_VIDMEM_ACCOUNTING)
         {
-            ERR("Out of adapter memory\n");
-            wined3d_resource_free_sysmem(resource);
-            return WINED3DERR_OUTOFVIDEOMEMORY;
+            if (size > wined3d_device_get_available_texture_mem(device))
+            {
+                ERR("Out of adapter memory\n");
+                wined3d_resource_free_sysmem(resource);
+                return WINED3DERR_OUTOFVIDEOMEMORY;
+            }
+            adapter_adjust_memory(device->adapter, size);
         }
-        adapter_adjust_memory(device->adapter, size);
-    }
 
-    device_resource_add(device, resource);
+        device_resource_add(device, resource);
+    }
 
     return WINED3D_OK;
 }
@@ -248,13 +252,16 @@ void resource_cleanup(struct wined3d_resource *resource)
 
     TRACE("Cleaning up resource %p.\n", resource);
 
-    if (resource->pool == WINED3D_POOL_DEFAULT && d3d->flags & WINED3D_VIDMEM_ACCOUNTING)
+    if (!(resource->usage & WINED3DUSAGE_PRIVATE))
     {
-        TRACE("Decrementing device memory pool by %u.\n", resource->size);
-        adapter_adjust_memory(resource->device->adapter, (INT64)0 - resource->size);
-    }
+        if (resource->pool == WINED3D_POOL_DEFAULT && d3d->flags & WINED3D_VIDMEM_ACCOUNTING)
+        {
+            TRACE("Decrementing device memory pool by %u.\n", resource->size);
+            adapter_adjust_memory(resource->device->adapter, (INT64)0 - resource->size);
+        }
 
-    device_resource_released(resource->device, resource);
+        device_resource_released(resource->device, resource);
+    }
     wined3d_resource_acquire(resource);
     wined3d_cs_destroy_object(resource->device->cs, wined3d_resource_destroy_object, resource);
 }
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index fdf9e27..625e4f3 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -1271,7 +1271,7 @@ static struct wined3d_texture *surface_convert_format(struct wined3d_texture *sr
     desc.format = dst_format->id;
     desc.multisample_type = WINED3D_MULTISAMPLE_NONE;
     desc.multisample_quality = 0;
-    desc.usage = 0;
+    desc.usage = WINED3DUSAGE_PRIVATE;
     desc.pool = WINED3D_POOL_SCRATCH;
     desc.width = wined3d_texture_get_level_width(src_texture, texture_level);
     desc.height = wined3d_texture_get_level_height(src_texture, texture_level);
diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h
index e598f80..1bf5a6c 100644
--- a/include/wine/wined3d.h
+++ b/include/wine/wined3d.h
@@ -870,6 +870,7 @@ enum wined3d_shader_byte_code_format
 #define WINED3DUSAGE_TEXTAPI                                    0x10000000
 #define WINED3DUSAGE_MASK                                       0x10007fff
 
+#define WINED3DUSAGE_PRIVATE                                    0x00400000
 #define WINED3DUSAGE_LEGACY_CUBEMAP                             0x00800000
 #define WINED3DUSAGE_TEXTURE                                    0x01000000
 #define WINED3DUSAGE_OWNDC                                      0x02000000




More information about the wine-cvs mailing list