[PATCH 07/10] wined3d: Disallow dynamic rendertarget and depth/stencil resources.

Henri Verbeet hverbeet at codeweavers.com
Sun Nov 18 12:39:18 CST 2018


Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
---
 dlls/d3d8/tests/device.c |  7 ++++---
 dlls/d3d9/tests/device.c |  7 ++++---
 dlls/ddraw/surface.c     |  4 +++-
 dlls/wined3d/resource.c  | 20 +++++++++++++++-----
 4 files changed, 26 insertions(+), 12 deletions(-)

diff --git a/dlls/d3d8/tests/device.c b/dlls/d3d8/tests/device.c
index 59eec656cdc..c07e98192dd 100644
--- a/dlls/d3d8/tests/device.c
+++ b/dlls/d3d8/tests/device.c
@@ -8944,7 +8944,7 @@ static void test_resource_access(void)
                 case SURFACE_2D:
                     hr = IDirect3DDevice8_CreateTexture(device, 16, 16, 1,
                             tests[j].usage, format, tests[j].pool, &texture_2d);
-                    todo_wine_if(j == 10 || j == 13 || j == 16 || j == 23 || j == 30)
+                    todo_wine_if(!tests[j].valid && tests[j].format == FORMAT_DEPTH && !tests[j].usage)
                         ok(hr == (tests[j].valid && (tests[j].format != FORMAT_DEPTH || depth_2d)
                                 ? D3D_OK : D3DERR_INVALIDCALL),
                                 "Test %s %u: Got unexpected hr %#x.\n", surface_types[i].name, j, hr);
@@ -8959,7 +8959,7 @@ static void test_resource_access(void)
                 case SURFACE_CUBE:
                     hr = IDirect3DDevice8_CreateCubeTexture(device, 16, 1,
                             tests[j].usage, format, tests[j].pool, &texture_cube);
-                    todo_wine_if(j == 10 || j == 13 || j == 16 || j == 23 || j == 30)
+                    todo_wine_if(!tests[j].valid && tests[j].format == FORMAT_DEPTH && !tests[j].usage)
                         ok(hr == (tests[j].valid && (tests[j].format != FORMAT_DEPTH || depth_cube)
                                 ? D3D_OK : D3DERR_INVALIDCALL),
                                 "Test %s %u: Got unexpected hr %#x.\n", surface_types[i].name, j, hr);
@@ -9091,7 +9091,8 @@ static void test_resource_access(void)
 
         hr = IDirect3DDevice8_CreateVolumeTexture(device, 16, 16, 1, 1,
                 tests[i].usage, format, tests[i].pool, &texture);
-        todo_wine_if(tests[i].usage & D3DUSAGE_RENDERTARGET && tests[i].pool == D3DPOOL_DEFAULT)
+        todo_wine_if(tests[i].usage & D3DUSAGE_RENDERTARGET
+                && !(tests[i].usage & D3DUSAGE_DYNAMIC) && tests[i].pool == D3DPOOL_DEFAULT)
             ok(hr == (!(tests[i].usage & ~D3DUSAGE_DYNAMIC) ? D3D_OK : D3DERR_INVALIDCALL),
                     "Test %u: Got unexpected hr %#x.\n", i, hr);
         if (FAILED(hr))
diff --git a/dlls/d3d9/tests/device.c b/dlls/d3d9/tests/device.c
index f3b9a0ae26e..9f293a81802 100644
--- a/dlls/d3d9/tests/device.c
+++ b/dlls/d3d9/tests/device.c
@@ -12774,7 +12774,7 @@ static void test_resource_access(void)
                 case SURFACE_2D:
                     hr = IDirect3DDevice9_CreateTexture(device, 16, 16, 1,
                             tests[j].usage, format, tests[j].pool, &texture_2d, NULL);
-                    todo_wine_if(j == 10 || j == 13 || j == 16 || j == 23 || j == 30)
+                    todo_wine_if(!tests[j].valid && tests[j].format == FORMAT_DEPTH && !tests[j].usage)
                         ok(hr == (tests[j].valid && (tests[j].format != FORMAT_DEPTH || depth_2d)
                                 ? D3D_OK : D3DERR_INVALIDCALL),
                                 "Test %s %u: Got unexpected hr %#x.\n", surface_types[i].name, j, hr);
@@ -12789,7 +12789,7 @@ static void test_resource_access(void)
                 case SURFACE_CUBE:
                     hr = IDirect3DDevice9_CreateCubeTexture(device, 16, 1,
                             tests[j].usage, format, tests[j].pool, &texture_cube, NULL);
-                    todo_wine_if(j == 10 || j == 13 || j == 16 || j == 23 || j == 30)
+                    todo_wine_if(!tests[j].valid && tests[j].format == FORMAT_DEPTH && !tests[j].usage)
                         ok(hr == (tests[j].valid && (tests[j].format != FORMAT_DEPTH || depth_cube)
                                 ? D3D_OK : D3DERR_INVALIDCALL),
                                 "Test %s %u: Got unexpected hr %#x.\n", surface_types[i].name, j, hr);
@@ -12926,7 +12926,8 @@ static void test_resource_access(void)
 
         hr = IDirect3DDevice9_CreateVolumeTexture(device, 16, 16, 1, 1,
                 tests[i].usage, format, tests[i].pool, &texture, NULL);
-        todo_wine_if(tests[i].usage & D3DUSAGE_RENDERTARGET && tests[i].pool == D3DPOOL_DEFAULT)
+        todo_wine_if(tests[i].usage & D3DUSAGE_RENDERTARGET
+                && !(tests[i].usage & D3DUSAGE_DYNAMIC) && tests[i].pool == D3DPOOL_DEFAULT)
             ok(hr == (!(tests[i].usage & ~D3DUSAGE_DYNAMIC) ? D3D_OK : D3DERR_INVALIDCALL),
                     "Test %u: Got unexpected hr %#x.\n", i, hr);
         if (FAILED(hr))
diff --git a/dlls/ddraw/surface.c b/dlls/ddraw/surface.c
index 7c13cbfa39c..819044214d5 100644
--- a/dlls/ddraw/surface.c
+++ b/dlls/ddraw/surface.c
@@ -6189,7 +6189,9 @@ HRESULT ddraw_surface_create(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_
             /* Videomemory adds localvidmem. This is mutually exclusive with
              * systemmemory and texturemanage. */
             desc->ddsCaps.dwCaps |= DDSCAPS_LOCALVIDMEM;
-            wined3d_desc.usage |= WINED3DUSAGE_DYNAMIC;
+            /* Dynamic resources can't be written by the GPU. */
+            if (!(wined3d_desc.bind_flags & (WINED3D_BIND_RENDER_TARGET | WINED3D_BIND_DEPTH_STENCIL)))
+                wined3d_desc.usage |= WINED3DUSAGE_DYNAMIC;
         }
     }
 
diff --git a/dlls/wined3d/resource.c b/dlls/wined3d/resource.c
index e5016e42e08..82e9019a0ed 100644
--- a/dlls/wined3d/resource.c
+++ b/dlls/wined3d/resource.c
@@ -91,12 +91,22 @@ HRESULT resource_init(struct wined3d_resource *resource, struct wined3d_device *
         return WINED3DERR_INVALIDCALL;
     }
 
-    if ((access & (WINED3D_RESOURCE_ACCESS_CPU | WINED3D_RESOURCE_ACCESS_GPU)) != WINED3D_RESOURCE_ACCESS_GPU
-            && bind_flags & (WINED3D_BIND_RENDER_TARGET | WINED3D_BIND_DEPTH_STENCIL))
+    if (bind_flags & (WINED3D_BIND_RENDER_TARGET | WINED3D_BIND_DEPTH_STENCIL))
     {
-        WARN("Bind flags %s are incompatible with resource access %s.\n",
-                wined3d_debug_bind_flags(bind_flags), wined3d_debug_resource_access(access));
-        return WINED3DERR_INVALIDCALL;
+        if ((access & (WINED3D_RESOURCE_ACCESS_CPU | WINED3D_RESOURCE_ACCESS_GPU)) != WINED3D_RESOURCE_ACCESS_GPU)
+        {
+            WARN("Bind flags %s are incompatible with resource access %s.\n",
+                    wined3d_debug_bind_flags(bind_flags), wined3d_debug_resource_access(access));
+            return WINED3DERR_INVALIDCALL;
+        }
+
+        /* Dynamic usage is incompatible with GPU writes. */
+        if (usage & WINED3DUSAGE_DYNAMIC)
+        {
+            WARN("Bind flags %s are incompatible with resource usage %s.\n",
+                    wined3d_debug_bind_flags(bind_flags), debug_d3dusage(usage));
+            return WINED3DERR_INVALIDCALL;
+        }
     }
 
     if (!size)
-- 
2.11.0




More information about the wine-devel mailing list