[PATCH 3/3] d3d8/tests: Port the depth blit test to d3d8

Stefan Dösinger stefan at codeweavers.com
Fri Dec 9 05:54:30 CST 2011


---
 dlls/d3d8/device.c       |   14 +++++++
 dlls/d3d8/tests/device.c |   88 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 102 insertions(+), 0 deletions(-)

diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c
index 923046d..b6cd613 100644
--- a/dlls/d3d8/device.c
+++ b/dlls/d3d8/device.c
@@ -942,12 +942,26 @@ static HRESULT WINAPI IDirect3DDevice8Impl_CopyRects(IDirect3DDevice8 *iface,
     wined3d_mutex_lock();
     wined3d_resource = wined3d_surface_get_resource(Source->wined3d_surface);
     wined3d_resource_get_desc(wined3d_resource, &wined3d_desc);
+    if (wined3d_desc.usage & WINED3DUSAGE_DEPTHSTENCIL)
+    {
+        WARN("Source %p is a depth stencil surface, returning D3DERR_INVALIDCALL.\n",
+                pSourceSurface);
+        wined3d_mutex_unlock();
+        return D3DERR_INVALIDCALL;
+    }
     srcFormat = wined3d_desc.format;
     src_w = wined3d_desc.width;
     src_h = wined3d_desc.height;
 
     wined3d_resource = wined3d_surface_get_resource(Dest->wined3d_surface);
     wined3d_resource_get_desc(wined3d_resource, &wined3d_desc);
+    if (wined3d_desc.usage & WINED3DUSAGE_DEPTHSTENCIL)
+    {
+        WARN("Dest %p is a depth stencil surface, returning D3DERR_INVALIDCALL.\n",
+                pDestinationSurface);
+        wined3d_mutex_unlock();
+        return D3DERR_INVALIDCALL;
+    }
     destFormat = wined3d_desc.format;
 
     /* Check that the source and destination formats match */
diff --git a/dlls/d3d8/tests/device.c b/dlls/d3d8/tests/device.c
index 6467858..902a600 100644
--- a/dlls/d3d8/tests/device.c
+++ b/dlls/d3d8/tests/device.c
@@ -3004,6 +3004,93 @@ done:
     ok(devmode.dmPelsHeight == screen_height, "Got unexpect height %u.\n", devmode.dmPelsHeight);
 }
 
+static void depth_blit_test(void)
+{
+    HWND hwnd = NULL;
+    IDirect3D8 *d3d = NULL;
+    D3DPRESENT_PARAMETERS d3dpp;
+    D3DDISPLAYMODE d3ddm;
+    IDirect3DDevice8 *device = NULL;
+    IDirect3DSurface8 *backbuffer, *ds1, *ds2, *ds3;
+    RECT src_rect;
+    const POINT dst_point = {0, 0};
+    HRESULT hr;
+
+    d3d = pDirect3DCreate8(D3D_SDK_VERSION);
+    ok(d3d != NULL, "Direct3DCreate8 failed.\n");
+    hwnd = CreateWindow("d3d8_test_wc", "d3d8_test", WS_OVERLAPPEDWINDOW, 100, 100, 160, 160, NULL, NULL, NULL, NULL);
+    ok(hwnd != NULL, "CreateWindow failed.\n");
+    if (!d3d || !hwnd)
+        goto cleanup;
+
+    IDirect3D8_GetAdapterDisplayMode(d3d, D3DADAPTER_DEFAULT, &d3ddm);
+    ZeroMemory(&d3dpp, sizeof(d3dpp));
+    d3dpp.Windowed = TRUE;
+    d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
+    d3dpp.BackBufferWidth = 800;
+    d3dpp.BackBufferHeight = 600;
+    d3dpp.BackBufferFormat = d3ddm.Format;
+    d3dpp.EnableAutoDepthStencil = TRUE;
+    d3dpp.AutoDepthStencilFormat = D3DFMT_D24S8;
+
+    hr = IDirect3D8_CreateDevice(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hwnd,
+            D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &device);
+    ok(hr == D3D_OK || hr == D3DERR_INVALIDCALL || broken(hr == D3DERR_NOTAVAILABLE),
+            "CreateDevice failed, hr %#x.\n", hr);
+    if (!device)
+    {
+        skip("Could not create device, IDirect3D8_CreateDevice returned %#x.\n", hr);
+        goto cleanup;
+    }
+
+    hr = IDirect3DDevice8_GetRenderTarget(device, &backbuffer);
+    ok(SUCCEEDED(hr), "GetRenderTarget failed, hr %#x.\n", hr);
+    hr = IDirect3DDevice8_GetDepthStencilSurface(device, &ds1);
+    ok(SUCCEEDED(hr), "GetDepthStencilSurface failed, hr %#x.\n", hr);
+    hr = IDirect3DDevice8_CreateDepthStencilSurface(device, 640, 480, D3DFMT_D24S8, D3DMULTISAMPLE_NONE, &ds2);
+    ok(SUCCEEDED(hr), "CreateDepthStencilSurface failed, hr %#x.\n", hr);
+    hr = IDirect3DDevice8_CreateDepthStencilSurface(device, 640, 480, D3DFMT_D24S8, D3DMULTISAMPLE_NONE, &ds3);
+    ok(SUCCEEDED(hr), "CreateDepthStencilSurface failed, hr %#x.\n", hr);
+
+    hr = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_ZBUFFER, 0, 0.0f, 0);
+    ok(SUCCEEDED(hr), "Clear failed, hr %#x.\n", hr);
+
+    /* Partial blit. */
+    SetRect(&src_rect, 0, 0, 320, 240);
+    hr = IDirect3DDevice8_CopyRects(device, ds1, &src_rect, 1, ds2, &dst_point);
+    ok(hr == D3DERR_INVALIDCALL, "CopyRects returned %#x, expected %#x.\n", hr, D3DERR_INVALIDCALL);
+    /* Flipped. */
+    SetRect(&src_rect, 0, 480, 640, 0);
+    hr = IDirect3DDevice8_CopyRects(device, ds1, &src_rect, 1, ds2, &dst_point);
+    ok(hr == D3DERR_INVALIDCALL, "CopyRects returned %#x, expected %#x.\n", hr, D3DERR_INVALIDCALL);
+    /* Full, explicit. */
+    SetRect(&src_rect, 0, 0, 640, 480);
+    hr = IDirect3DDevice8_CopyRects(device, ds1, &src_rect, 1, ds2, &dst_point);
+    ok(hr == D3DERR_INVALIDCALL, "CopyRects returned %#x, expected %#x.\n", hr, D3DERR_INVALIDCALL);
+    /* Depth -> color blit.*/
+    hr = IDirect3DDevice8_CopyRects(device, ds1, &src_rect, 1, backbuffer, &dst_point);
+    ok(hr == D3DERR_INVALIDCALL, "CopyRects returned %#x, expected %#x.\n", hr, D3DERR_INVALIDCALL);
+    /* Full, NULL rects, current depth stencil -> unbound depth stencil */
+    hr = IDirect3DDevice8_CopyRects(device, ds1, NULL, 0, ds2, NULL);
+    ok(hr == D3DERR_INVALIDCALL, "CopyRects returned %#x, expected %#x.\n", hr, D3DERR_INVALIDCALL);
+    /* Full, NULL rects, unbound depth stencil -> current depth stencil */
+    hr = IDirect3DDevice8_CopyRects(device, ds2, NULL, 0, ds1, NULL);
+    ok(hr == D3DERR_INVALIDCALL, "CopyRects returned %#x, expected %#x.\n", hr, D3DERR_INVALIDCALL);
+    /* Full, NULL rects, unbound depth stencil -> unbound depth stencil */
+    hr = IDirect3DDevice8_CopyRects(device, ds2, NULL, 0, ds3, NULL);
+    ok(hr == D3DERR_INVALIDCALL, "CopyRects returned %#x, expected %#x.\n", hr, D3DERR_INVALIDCALL);
+
+    IDirect3DSurface8_Release(backbuffer);
+    IDirect3DSurface8_Release(ds3);
+    IDirect3DSurface8_Release(ds2);
+    IDirect3DSurface8_Release(ds1);
+
+cleanup:
+    if (device) IDirect3DDevice8_Release(device);
+    if (d3d) IDirect3D8_Release(d3d);
+    if (hwnd) DestroyWindow(hwnd);
+}
+
 START_TEST(device)
 {
     HMODULE d3d8_handle = LoadLibraryA( "d3d8.dll" );
@@ -3057,6 +3144,7 @@ START_TEST(device)
         test_window_style();
         test_wrong_shader();
         test_mode_change();
+        depth_blit_test();
     }
     UnregisterClassA("d3d8_test_wc", GetModuleHandleA(NULL));
 }
-- 
1.7.3.4




More information about the wine-patches mailing list