[PATCH 1/4] d3d9/tests: Test user memory with D3DPOOL_SCRATCH.

Stefan Dösinger stefan at codeweavers.com
Mon Dec 9 06:28:13 CST 2013


The undocumented d3d9ex managed pool with enum value 6 does not allow
user memory textures either. I'm not including tests for that yet
until our d3d9 can handle this pool.
---
 dlls/d3d9/device.c       | 24 +++++++++++++----
 dlls/d3d9/tests/d3d9ex.c | 69 +++++++++++++++++++++++++++++++++---------------
 2 files changed, 66 insertions(+), 27 deletions(-)

diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c
index 5dc207a..adda6f9 100644
--- a/dlls/d3d9/device.c
+++ b/dlls/d3d9/device.c
@@ -740,14 +740,28 @@ 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;
+
+            case D3DPOOL_SCRATCH:
+                WARN("Trying to create a user memory D3DPOOL_SCRATCH texture.\n");
                 return D3DERR_INVALIDCALL;
-            set_mem = TRUE;
+
+            default:
+                FIXME("Unhandled pool %#x.\n", pool);
         }
-        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..8ec129d 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;
@@ -544,6 +544,18 @@ static void test_texture_sysmem_create(void)
     HWND window;
     HRESULT hr;
     void *mem;
+    unsigned int i;
+    static const struct
+    {
+        D3DPOOL pool;
+        const char *name;
+        BOOL user_mem_supported;
+    }
+    test_data[] =
+    {
+        {D3DPOOL_SYSTEMMEM, "D3DPOOL_SYSTEMMEM", TRUE},
+        {D3DPOOL_SCRATCH, "D3DPOOL_SCRATCH", FALSE},
+    };
 
     window = create_window();
     if (!(device = create_device(window, window, TRUE)))
@@ -553,28 +565,41 @@ static void test_texture_sysmem_create(void)
     }
 
     mem = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 128 * 128 * 4);
-    hr = IDirect3DDevice9Ex_CreateTexture(device, 128, 128, 0, 0, D3DFMT_A8R8G8B8,
-            D3DPOOL_SYSTEMMEM, &texture, &mem);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
-    hr = IDirect3DDevice9Ex_CreateTexture(device, 1, 1, 0, 0, D3DFMT_A8R8G8B8,
-            D3DPOOL_SYSTEMMEM, &texture, &mem);
-    ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
-    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_SYSTEMMEM, &texture, &mem);
-    ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
-    hr = IDirect3DTexture9_LockRect(texture, 0, &locked_rect, NULL, 0);
-    ok(SUCCEEDED(hr), "Failed to lock texture, hr %#x.\n", hr);
-    ok(locked_rect.Pitch == 128 * 4, "Got unexpected pitch %d.\n", locked_rect.Pitch);
-    ok(locked_rect.pBits == mem, "Got unexpected pBits %p, expected %p.\n", locked_rect.pBits, mem);
-    hr = IDirect3DTexture9_UnlockRect(texture, 0);
-    ok(SUCCEEDED(hr), "Failed to unlock texture, hr %#x.\n", hr);
-    IDirect3DTexture9_Release(texture);
-    HeapFree(GetProcessHeap(), 0, mem);
+    for (i = 0; i < sizeof(test_data) / sizeof(*test_data); i++)
+    {
+        hr = IDirect3DDevice9Ex_CreateTexture(device, 128, 128, 0, 0, D3DFMT_A8R8G8B8,
+                test_data[i].pool, &texture, &mem);
+        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+        hr = IDirect3DDevice9Ex_CreateTexture(device, 1, 1, 0, 0, D3DFMT_A8R8G8B8,
+                test_data[i].pool, &texture, &mem);
+        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+        hr = IDirect3DDevice9Ex_CreateTexture(device, 128, 128, 2, 0, D3DFMT_A8R8G8B8,
+                test_data[i].pool, &texture, &mem);
+        ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
+
+        hr = IDirect3DDevice9Ex_CreateTexture(device, 128, 128, 1, 0, D3DFMT_A8R8G8B8,
+                test_data[i].pool, &texture, &mem);
+        if (test_data[i].user_mem_supported)
+            ok(SUCCEEDED(hr), "Failed to create texture, hr %#x, pool %s.\n",
+                    hr, test_data[i].name);
+        else
+            ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x, pool %s.\n",
+                    hr, test_data[i].name);
+
+        if (SUCCEEDED(hr))
+        {
+            hr = IDirect3DTexture9_LockRect(texture, 0, &locked_rect, NULL, 0);
+            ok(SUCCEEDED(hr), "Failed to lock texture, hr %#x.\n", hr);
+            ok(locked_rect.Pitch == 128 * 4, "Got unexpected pitch %d.\n", locked_rect.Pitch);
+            ok(locked_rect.pBits == mem, "Got unexpected pBits %p, expected %p.\n", locked_rect.pBits, mem);
+            hr = IDirect3DTexture9_UnlockRect(texture, 0);
+            ok(SUCCEEDED(hr), "Failed to unlock texture, hr %#x.\n", hr);
+            IDirect3DTexture9_Release(texture);
+        }
+    }
 
+    HeapFree(GetProcessHeap(), 0, mem);
     refcount = IDirect3DDevice9Ex_Release(device);
     ok(!refcount, "Device has %u references left.\n", refcount);
 
@@ -1114,7 +1139,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