[PATCH 1/5] d3d9/tests: Test user memory with D3DPOOL_SCRATCH (try 2).

Stefan Dösinger stefan at codeweavers.com
Tue Dec 10 05:23:17 CST 2013


Try 2: Only try one texture create call, don't repeat all tests with
D3DPOOL_SCRATCH.

@Henri: I'm not sure what kind of control flow you had in mind here. The
best understanding I could come up with was a nested if (first check for
D3DPOOL_DEFAULT, then handle the D3DPOOL_SYSTEMEM special case), which I
think is ugly. I removed the case check for D3DPOOL_SCRATCH, at the cost
of not writing a visible FIXME for pool 0x6.
---
 dlls/d3d9/device.c       | 22 +++++++++++++++++-----
 dlls/d3d9/tests/d3d9ex.c |  7 +++++--
 2 files changed, 22 insertions(+), 7 deletions(-)

diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c
index 5dc207a..0ed094b 100644
--- a/dlls/d3d9/device.c
+++ b/dlls/d3d9/device.c
@@ -740,14 +740,26 @@ static HRESULT WINAPI d3d9_device_CreateTexture(IDirect3DDevice9Ex *iface,
     *texture = NULL;
     if (shared_handle)
     {
-        if (pool == D3DPOOL_SYSTEMMEM)
+        switch (pool)
         {
-            if (levels != 1)
+            case D3DPOOL_DEFAULT:
+                FIXME("Resource sharing not implemented, *shared_handle %p.\n", *shared_handle);
+                break;
+
+            case D3DPOOL_SYSTEMMEM:
+                if (levels != 1)
+                {
+                    WARN("Trying to create a mipmapped user memory texture.\n");
+                    return D3DERR_INVALIDCALL;
+                }
+                set_mem = TRUE;
+                break;
+
+            default:
+                WARN("Trying to create a texture with pool %#x and shared_handle %p.\n",
+                        pool, shared_handle);
                 return D3DERR_INVALIDCALL;
-            set_mem = TRUE;
         }
-        else
-            FIXME("Resource sharing not implemented, *shared_handle %p.\n", *shared_handle);
     }
 
     object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
diff --git a/dlls/d3d9/tests/d3d9ex.c b/dlls/d3d9/tests/d3d9ex.c
index 5825c35..810d2a0 100644
--- a/dlls/d3d9/tests/d3d9ex.c
+++ b/dlls/d3d9/tests/d3d9ex.c
@@ -535,7 +535,7 @@ out:
     IDirect3D9Ex_Release(d3d9ex);
 }
 
-static void test_texture_sysmem_create(void)
+static void test_user_memory(void)
 {
     IDirect3DDevice9Ex *device;
     IDirect3DTexture9 *texture;
@@ -562,6 +562,9 @@ static void test_texture_sysmem_create(void)
     hr = IDirect3DDevice9Ex_CreateTexture(device, 128, 128, 2, 0, D3DFMT_A8R8G8B8,
             D3DPOOL_SYSTEMMEM, &texture, &mem);
     ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+    hr = IDirect3DDevice9Ex_CreateTexture(device, 128, 128, 1, 0, D3DFMT_A8R8G8B8,
+            D3DPOOL_SCRATCH, &texture, &mem);
+    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
 
     hr = IDirect3DDevice9Ex_CreateTexture(device, 128, 128, 1, 0, D3DFMT_A8R8G8B8,
             D3DPOOL_SYSTEMMEM, &texture, &mem);
@@ -1114,7 +1117,7 @@ START_TEST(d3d9ex)
     test_swapchain_get_displaymode_ex();
     test_get_adapter_luid();
     test_get_adapter_displaymode_ex();
-    test_texture_sysmem_create();
+    test_user_memory();
     test_reset();
     test_reset_resources();
     test_vidmem_accounting();
-- 
1.8.3.2




More information about the wine-patches mailing list