[PATCH 1/6] wined3d: Use the resource access flags in resource_init().

Henri Verbeet hverbeet at codeweavers.com
Wed Jan 31 09:19:36 CST 2018


Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
---
 dlls/wined3d/resource.c        | 12 +++++++-----
 dlls/wined3d/utils.c           | 16 ++++++++++++++++
 dlls/wined3d/wined3d_private.h |  2 ++
 3 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/dlls/wined3d/resource.c b/dlls/wined3d/resource.c
index cf01f93..172a054 100644
--- a/dlls/wined3d/resource.c
+++ b/dlls/wined3d/resource.c
@@ -83,6 +83,7 @@ HRESULT resource_init(struct wined3d_resource *resource, struct wined3d_device *
     enum wined3d_gl_resource_type base_type = WINED3D_GL_RES_TYPE_COUNT;
     enum wined3d_gl_resource_type gl_type = WINED3D_GL_RES_TYPE_COUNT;
     const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
+    DWORD access = resource_access_from_pool(pool);
     BOOL tex_2d_ok = FALSE;
     unsigned int i;
 
@@ -104,9 +105,10 @@ HRESULT resource_init(struct wined3d_resource *resource, struct wined3d_device *
 
     resource_check_usage(usage);
 
-    if (usage & WINED3DUSAGE_SCRATCH && pool != WINED3D_POOL_SYSTEM_MEM)
+    if (usage & WINED3DUSAGE_SCRATCH && access & WINED3D_RESOURCE_ACCESS_GPU)
     {
-        ERR("WINED3DUSAGE_SCRATCH used with pool %s.\n", debug_d3dpool(pool));
+        ERR("Trying to create a scratch resource with access flags %s.\n",
+                wined3d_debug_resource_access(access));
         return WINED3DERR_INVALIDCALL;
     }
 
@@ -197,9 +199,9 @@ HRESULT resource_init(struct wined3d_resource *resource, struct wined3d_device *
     resource->multisample_quality = multisample_quality;
     resource->usage = usage;
     resource->pool = pool;
-    resource->access = resource_access_from_pool(pool);
     if (usage & WINED3DUSAGE_DYNAMIC)
-        resource->access |= WINED3D_RESOURCE_ACCESS_MAP;
+        access |= WINED3D_RESOURCE_ACCESS_MAP;
+    resource->access = access;
     resource->width = width;
     resource->height = height;
     resource->depth = depth;
@@ -226,7 +228,7 @@ HRESULT resource_init(struct wined3d_resource *resource, struct wined3d_device *
     if (!(usage & WINED3DUSAGE_PRIVATE))
     {
         /* Check that we have enough video ram left */
-        if (pool == WINED3D_POOL_DEFAULT && device->wined3d->flags & WINED3D_VIDMEM_ACCOUNTING)
+        if (!(access & WINED3D_RESOURCE_ACCESS_CPU) && device->wined3d->flags & WINED3D_VIDMEM_ACCOUNTING)
         {
             if (size > wined3d_device_get_available_texture_mem(device))
             {
diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c
index bd8aa06..a79c3af 100644
--- a/dlls/wined3d/utils.c
+++ b/dlls/wined3d/utils.c
@@ -4129,6 +4129,22 @@ const char *debug_d3ddevicetype(enum wined3d_device_type device_type)
     }
 }
 
+const char *wined3d_debug_resource_access(DWORD access)
+{
+    char buf[91];
+
+    buf[0] = '\0';
+#define ACCESS_TO_STR(x) if (access & x) { strcat(buf, " | "#x); access &= ~x; }
+    ACCESS_TO_STR(WINED3D_RESOURCE_ACCESS_GPU);
+    ACCESS_TO_STR(WINED3D_RESOURCE_ACCESS_CPU);
+    ACCESS_TO_STR(WINED3D_RESOURCE_ACCESS_MAP);
+#undef ACCESS_TO_STR
+    if (access)
+        FIXME("Unrecognised access flag(s) %#x.\n", access);
+
+    return buf[0] ? wine_dbg_sprintf("%s", &buf[3]) : "0";
+}
+
 const char *debug_d3dusage(DWORD usage)
 {
     char buf[552];
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index f95330f..8006f3a 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2965,6 +2965,8 @@ static inline BOOL isStateDirty(const struct wined3d_context *context, DWORD sta
 #define WINED3D_RESOURCE_ACCESS_CPU     0x2u
 #define WINED3D_RESOURCE_ACCESS_MAP     0x4u
 
+const char *wined3d_debug_resource_access(DWORD access) DECLSPEC_HIDDEN;
+
 static inline BOOL wined3d_resource_access_is_managed(unsigned int access)
 {
     return !(~access & (WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_CPU));
-- 
2.1.4




More information about the wine-devel mailing list