[PATCH 2/3] d3drm/tests: Add test for IDirect3DRM*::CreateDeviceFromSurface (try 4).
Aaryaman Vasishta
jem456.vasishta at gmail.com
Tue Jun 23 13:19:19 CDT 2015
---
dlls/d3drm/tests/d3drm.c | 158 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 158 insertions(+)
diff --git a/dlls/d3drm/tests/d3drm.c b/dlls/d3drm/tests/d3drm.c
index a822478..acd7aa9 100644
--- a/dlls/d3drm/tests/d3drm.c
+++ b/dlls/d3drm/tests/d3drm.c
@@ -2145,6 +2145,163 @@ cleanup:
DestroyWindow(window);
}
+static void test_create_device_from_surface(void)
+{
+ DDSCAPS caps = { DDSCAPS_ZBUFFER };
+ DDSURFACEDESC desc;
+ IDirectDraw *ddraw = NULL;
+ IDirect3DRM *d3drm1 = NULL;
+ IDirect3DRM2 *d3drm2 = NULL;
+ IDirect3DRMDevice2 *device2 = NULL;
+ IDirect3DDevice2 *d3ddevice2 = NULL;
+ IDirectDrawSurface *surface = NULL, *ds = NULL, *d3drm_surface = NULL, *rds = NULL;
+ DWORD expected_flags;
+ HWND window;
+ HRESULT hr;
+ GUID driver = IID_IDirect3DRGBDevice;
+ ULONG ref1, ref2;
+ RECT rc;
+
+ hr = DirectDrawCreate(NULL, &ddraw, NULL);
+ ok(hr == DD_OK, "Cannot get IDirectDraw interface (hr = %x).\n", hr);
+
+ window = CreateWindowA("static", "d3drm_test", WS_OVERLAPPEDWINDOW, 0, 0, 300, 200, 0, 0, 0, 0);
+ GetClientRect(window, &rc);
+
+ hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
+ ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+
+ hr = Direct3DRMCreate(&d3drm1);
+ ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface (hr = %x).\n", hr);
+
+ hr = IDirect3DRM_QueryInterface(d3drm1, &IID_IDirect3DRM2, (void **)&d3drm2);
+ ok(hr == D3DRM_OK, "Cannot get IDirect3DRM3 interface (hr = %x).\n", hr);
+
+ /* Create a surface and use it to create the retained mode device. */
+ memset(&desc, 0, sizeof(desc));
+ desc.dwSize = sizeof(desc);
+ desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
+ desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
+ desc.dwWidth = rc.right;
+ desc.dwHeight = rc.bottom;
+
+ hr = IDirectDraw_CreateSurface(ddraw, &desc, &surface, NULL);
+ ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+
+ hr = IDirect3DRM2_CreateDeviceFromSurface(d3drm2, &driver, ddraw, surface, &device2);
+ todo_wine ok(hr == DDERR_INVALIDCAPS, "Expected hr == DDERR_INVALIDCAPS, got %x.\n", hr);
+ IDirectDrawSurface_Release(surface);
+
+ desc.ddsCaps.dwCaps |= DDSCAPS_3DDEVICE;
+ hr = IDirectDraw_CreateSurface(ddraw, &desc, &surface, NULL);
+ ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+ ref1 = get_refcount((IUnknown *)surface);
+ hr = IDirect3DRM2_CreateDeviceFromSurface(d3drm2, &driver, ddraw, surface, &device2);
+ ok(SUCCEEDED(hr), "Cannot create IDirect3DRMDevice2 interface (hr = %x).\n", hr);
+ ref2 = get_refcount((IUnknown *)surface);
+ todo_wine ok(ref2 > ref1, "Expected ref2 > ref1, got ref1 = %u, ref2 = %u.\n", ref1, ref2);
+
+ /* Check if CreateDeviceFromSurface creates a primary surface */
+ primary_surface_found = FALSE;
+ hr = IDirectDraw_EnumSurfaces(ddraw, DDENUMSURFACES_ALL | DDENUMSURFACES_DOESEXIST,
+ NULL, NULL, surface_callback);
+ ok(hr == DD_OK, "Failed to enumerate surfaces (hr = %x).\n", hr);
+ ok(!primary_surface_found, "Primary surface shouldn't be created by CreateDeviceFromSurface.\n");
+
+ hr = IDirect3DRMDevice2_GetDirect3DDevice2(device2, &d3ddevice2);
+ todo_wine ok(hr == D3DRM_OK, "Cannot get IDirect3DDevice2 interface (hr = %x).\n", hr);
+ if (FAILED(hr))
+ goto cleanup;
+
+ hr = IDirect3DDevice2_GetRenderTarget(d3ddevice2, &d3drm_surface);
+ ok(hr == DD_OK, "Cannot get surface to the render target (hr = %x).\n", hr);
+ ok(surface == d3drm_surface, "Expected surface returned == %p, got %p.\n", surface, d3drm_surface);
+
+ /* Check properties of attached depth surface */
+ hr = IDirectDrawSurface_GetAttachedSurface(d3drm_surface, &caps, &ds);
+ ok(hr == DD_OK, "Cannot get attached depth surface (hr = %x).\n", hr);
+
+ memset(&desc, 0, sizeof(desc));
+ desc.dwSize = sizeof(desc);
+ hr = IDirectDrawSurface_GetSurfaceDesc(ds, &desc);
+ ok(hr == DD_OK, "Cannot get z surface desc structure (hr = %x).\n", hr);
+
+ ok((desc.dwWidth == rc.right) && (desc.dwHeight == rc.bottom), "Expected surface dimentions = %u, %u, got %u, %u.\n",
+ rc.right, rc.bottom, desc.dwWidth, desc.dwHeight);
+ ok((desc.ddsCaps.dwCaps & DDSCAPS_ZBUFFER) == DDSCAPS_ZBUFFER, "Expected caps containing %x, got %x.\n", DDSCAPS_ZBUFFER, desc.ddsCaps.dwCaps);
+ expected_flags = DDSD_ZBUFFERBITDEPTH | DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PITCH;
+ ok(desc.dwFlags == expected_flags, "Expected %x for flags, got %x.\n", expected_flags, desc.dwFlags);
+
+
+ IDirectDrawSurface_Release(ds);
+ IDirectDrawSurface_Release(surface);
+ IDirectDrawSurface_Release(d3drm_surface);
+ if (device2)
+ {
+ IDirect3DRMDevice2_Release(device2);
+ ref2 = get_refcount((IUnknown *)surface);
+ ok(ref2 == ref1, "Expected ref2 == ref1, got ref1 = %u, ref2 = %u.\n", ref1, ref2);
+ }
+ IDirect3DDevice2_Release(d3ddevice2);
+
+ memset(&desc, 0, sizeof(desc));
+ desc.dwSize = sizeof(desc);
+ desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
+ desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE;
+ desc.dwWidth = rc.right;
+ desc.dwHeight = rc.bottom;
+
+ hr = IDirectDraw_CreateSurface(ddraw, &desc, &surface, NULL);
+ ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+
+ memset(&desc, 0, sizeof(desc));
+ desc.dwSize = sizeof(desc);
+ desc.dwFlags = DDSD_CAPS | DDSD_ZBUFFERBITDEPTH | DDSD_WIDTH | DDSD_HEIGHT;
+ desc.ddsCaps.dwCaps = DDSCAPS_ZBUFFER | DDSCAPS_SYSTEMMEMORY;
+ desc.dwZBufferBitDepth = 16;
+ desc.dwWidth = rc.right;
+ desc.dwHeight = rc.bottom;
+ hr = IDirectDraw_CreateSurface(ddraw, &desc, &ds, NULL);
+ ok(hr == DD_OK, "Cannot create depth surface (hr = %x).\n", hr);
+ hr = IDirectDrawSurface_AddAttachedSurface(surface, ds);
+ ok(SUCCEEDED(hr), "Failed to attach depth buffer, hr %#x.\n", hr);
+
+ hr = IDirect3DRM2_CreateDeviceFromSurface(d3drm2, &driver, ddraw, surface, &device2);
+ ok(SUCCEEDED(hr), "Cannot create IDirect3DRMDevice2 interface (hr = %x).\n", hr);
+
+ hr = IDirect3DRMDevice2_GetDirect3DDevice2(device2, &d3ddevice2);
+ todo_wine ok(hr == D3DRM_OK, "Cannot get IDirect3DDevice2 interface (hr = %x).\n", hr);
+ if (FAILED(hr))
+ goto cleanup;
+
+ hr = IDirect3DDevice2_GetRenderTarget(d3ddevice2, &d3drm_surface);
+ ok(hr == DD_OK, "Cannot get surface to the render target (hr = %x).\n", hr);
+ ok(surface == d3drm_surface, "Expected surface returned == %p, got %p.\n", surface, d3drm_surface);
+
+ /* Check if depth surface matches the one we created */
+ hr = IDirectDrawSurface_GetAttachedSurface(d3drm_surface, &caps, &rds);
+ ok(hr == DD_OK, "Cannot get attached depth surface (hr = %x).\n", hr);
+ ok(ds == rds, "Expected depth surface (%p) == surface created internally (%p).\n", ds, rds);
+
+ IDirectDrawSurface_Release(rds);
+ IDirectDrawSurface_Release(d3drm_surface);
+
+cleanup:
+ if (d3ddevice2)
+ IDirect3DDevice2_Release(d3ddevice2);
+ if (device2)
+ IDirect3DRMDevice2_Release(device2);
+ if (surface)
+ IDirectDrawSurface_Release(surface);
+ if (d3drm2)
+ IDirect3DRM2_Release(d3drm2);
+ if (d3drm1)
+ IDirect3DRM_Release(d3drm1);
+ if (ddraw)
+ IDirectDraw_Release(ddraw);
+ DestroyWindow(window);
+}
+
START_TEST(d3drm)
{
test_MeshBuilder();
@@ -2163,4 +2320,5 @@ START_TEST(d3drm)
test_d3drm_qi();
test_frame_qi();
test_create_device_from_clipper();
+ test_create_device_from_surface();
}
--
1.9.3 (Apple Git-50)
More information about the wine-patches
mailing list