Commit 8a3923b3 authored by Józef Kucia's avatar Józef Kucia Committed by Alexandre Julliard

ddraw/tests: Add tests for attaching depth buffers of different sizes.

parent 5afd8030
......@@ -4991,6 +4991,53 @@ static void test_surface_attachment(void)
IDirectDrawSurface_Release(surface2);
IDirectDrawSurface_Release(surface1);
/* Test depth surfaces of different sizes. */
memset(&surface_desc, 0, sizeof(surface_desc));
surface_desc.dwSize = sizeof(surface_desc);
surface_desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE;
surface_desc.dwWidth = 64;
surface_desc.dwHeight = 64;
hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface1, NULL);
ok(hr == D3D_OK, "Failed to create surface, hr %#x.\n", hr);
memset(&surface_desc, 0, sizeof(surface_desc));
surface_desc.dwSize = sizeof(surface_desc);
surface_desc.dwFlags = DDSD_CAPS | DDSD_PIXELFORMAT | DDSD_WIDTH | DDSD_HEIGHT;
surface_desc.ddsCaps.dwCaps = DDSCAPS_ZBUFFER;
surface_desc.ddpfPixelFormat.dwSize = sizeof(surface_desc.ddpfPixelFormat);
surface_desc.ddpfPixelFormat.dwFlags = DDPF_ZBUFFER;
U1(surface_desc.ddpfPixelFormat).dwZBufferBitDepth = 16;
U3(surface_desc.ddpfPixelFormat).dwZBitMask = 0x0000ffff;
surface_desc.dwWidth = 32;
surface_desc.dwHeight = 32;
hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface2, NULL);
ok(hr == D3D_OK, "Failed to create surface, hr %#x.\n", hr);
surface_desc.dwWidth = 64;
surface_desc.dwHeight = 64;
hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface3, NULL);
ok(hr == D3D_OK, "Failed to create surface, hr %#x.\n", hr);
surface_desc.dwWidth = 128;
surface_desc.dwHeight = 128;
hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface4, NULL);
ok(hr == D3D_OK, "Failed to create surface, hr %#x.\n", hr);
hr = IDirectDrawSurface_AddAttachedSurface(surface1, surface2);
todo_wine ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#x.\n", hr);
if (SUCCEEDED(hr))
IDirectDrawSurface_DeleteAttachedSurface(surface1, 0, surface3);
hr = IDirectDrawSurface_AddAttachedSurface(surface1, surface3);
ok(hr == D3D_OK, "Failed to attach depth buffer, hr %#x.\n", hr);
hr = IDirectDrawSurface_DeleteAttachedSurface(surface1, 0, surface3);
ok(hr == D3D_OK, "Failed to detach depth buffer, hr %#x.\n", hr);
hr = IDirectDrawSurface_AddAttachedSurface(surface1, surface4);
todo_wine ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#x.\n", hr);
IDirectDrawSurface_Release(surface4);
IDirectDrawSurface_Release(surface3);
IDirectDrawSurface_Release(surface2);
IDirectDrawSurface_Release(surface1);
/* Test DeleteAttachedSurface() and automatic detachment of attached surfaces on release. */
memset(&surface_desc, 0, sizeof(surface_desc));
surface_desc.dwSize = sizeof(surface_desc);
......
......@@ -6015,6 +6015,53 @@ static void test_surface_attachment(void)
IDirectDrawSurface_Release(surface2);
IDirectDrawSurface_Release(surface1);
/* Test depth surfaces of different sizes. */
memset(&surface_desc, 0, sizeof(surface_desc));
surface_desc.dwSize = sizeof(surface_desc);
surface_desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE;
surface_desc.dwWidth = 64;
surface_desc.dwHeight = 64;
hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface1, NULL);
ok(hr == D3D_OK, "Failed to create surface, hr %#x.\n", hr);
memset(&surface_desc, 0, sizeof(surface_desc));
surface_desc.dwSize = sizeof(surface_desc);
surface_desc.dwFlags = DDSD_CAPS | DDSD_PIXELFORMAT | DDSD_WIDTH | DDSD_HEIGHT;
surface_desc.ddsCaps.dwCaps = DDSCAPS_ZBUFFER;
surface_desc.ddpfPixelFormat.dwSize = sizeof(surface_desc.ddpfPixelFormat);
surface_desc.ddpfPixelFormat.dwFlags = DDPF_ZBUFFER;
U1(surface_desc.ddpfPixelFormat).dwZBufferBitDepth = 16;
U3(surface_desc.ddpfPixelFormat).dwZBitMask = 0x0000ffff;
surface_desc.dwWidth = 32;
surface_desc.dwHeight = 32;
hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface2, NULL);
ok(hr == D3D_OK, "Failed to create surface, hr %#x.\n", hr);
surface_desc.dwWidth = 64;
surface_desc.dwHeight = 64;
hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface3, NULL);
ok(hr == D3D_OK, "Failed to create surface, hr %#x.\n", hr);
surface_desc.dwWidth = 128;
surface_desc.dwHeight = 128;
hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface4, NULL);
ok(hr == D3D_OK, "Failed to create surface, hr %#x.\n", hr);
hr = IDirectDrawSurface_AddAttachedSurface(surface1, surface2);
todo_wine ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#x.\n", hr);
if (SUCCEEDED(hr))
IDirectDrawSurface2_DeleteAttachedSurface(surface1, 0, surface3);
hr = IDirectDrawSurface_AddAttachedSurface(surface1, surface3);
ok(hr == D3D_OK, "Failed to attach depth buffer, hr %#x.\n", hr);
hr = IDirectDrawSurface2_DeleteAttachedSurface(surface1, 0, surface3);
ok(hr == D3D_OK, "Failed to detach depth buffer, hr %#x.\n", hr);
hr = IDirectDrawSurface_AddAttachedSurface(surface1, surface4);
todo_wine ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#x.\n", hr);
IDirectDrawSurface2_Release(surface4);
IDirectDrawSurface2_Release(surface3);
IDirectDrawSurface2_Release(surface2);
IDirectDrawSurface2_Release(surface1);
/* Test DeleteAttachedSurface() and automatic detachment of attached surfaces on release. */
memset(&surface_desc, 0, sizeof(surface_desc));
surface_desc.dwSize = sizeof(surface_desc);
......
......@@ -7327,6 +7327,53 @@ static void test_surface_attachment(void)
IDirectDrawSurface4_Release(surface2);
IDirectDrawSurface4_Release(surface1);
/* Test depth surfaces of different sizes. */
memset(&surface_desc, 0, sizeof(surface_desc));
surface_desc.dwSize = sizeof(surface_desc);
surface_desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE;
surface_desc.dwWidth = 64;
surface_desc.dwHeight = 64;
hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface1, NULL);
ok(hr == D3D_OK, "Failed to create surface, hr %#x.\n", hr);
memset(&surface_desc, 0, sizeof(surface_desc));
surface_desc.dwSize = sizeof(surface_desc);
surface_desc.dwFlags = DDSD_CAPS | DDSD_PIXELFORMAT | DDSD_WIDTH | DDSD_HEIGHT;
surface_desc.ddsCaps.dwCaps = DDSCAPS_ZBUFFER;
U4(surface_desc).ddpfPixelFormat.dwSize = sizeof(U4(surface_desc).ddpfPixelFormat);
U4(surface_desc).ddpfPixelFormat.dwFlags = DDPF_ZBUFFER;
U1(U4(surface_desc).ddpfPixelFormat).dwZBufferBitDepth = 16;
U3(U4(surface_desc).ddpfPixelFormat).dwZBitMask = 0x0000ffff;
surface_desc.dwWidth = 32;
surface_desc.dwHeight = 32;
hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface2, NULL);
ok(hr == D3D_OK, "Failed to create surface, hr %#x.\n", hr);
surface_desc.dwWidth = 64;
surface_desc.dwHeight = 64;
hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface3, NULL);
ok(hr == D3D_OK, "Failed to create surface, hr %#x.\n", hr);
surface_desc.dwWidth = 128;
surface_desc.dwHeight = 128;
hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface4, NULL);
ok(hr == D3D_OK, "Failed to create surface, hr %#x.\n", hr);
hr = IDirectDrawSurface_AddAttachedSurface(surface1, surface2);
todo_wine ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#x.\n", hr);
if (SUCCEEDED(hr))
IDirectDrawSurface4_DeleteAttachedSurface(surface1, 0, surface3);
hr = IDirectDrawSurface_AddAttachedSurface(surface1, surface3);
ok(hr == D3D_OK, "Failed to attach depth buffer, hr %#x.\n", hr);
hr = IDirectDrawSurface4_DeleteAttachedSurface(surface1, 0, surface3);
ok(hr == D3D_OK, "Failed to detach depth buffer, hr %#x.\n", hr);
hr = IDirectDrawSurface_AddAttachedSurface(surface1, surface4);
todo_wine ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#x.\n", hr);
IDirectDrawSurface4_Release(surface4);
IDirectDrawSurface4_Release(surface3);
IDirectDrawSurface4_Release(surface2);
IDirectDrawSurface4_Release(surface1);
/* Test DeleteAttachedSurface() and automatic detachment of attached surfaces on release. */
memset(&surface_desc, 0, sizeof(surface_desc));
surface_desc.dwSize = sizeof(surface_desc);
......
......@@ -7157,6 +7157,53 @@ static void test_surface_attachment(void)
IDirectDrawSurface7_Release(surface2);
IDirectDrawSurface7_Release(surface1);
/* Test depth surfaces of different sizes. */
memset(&surface_desc, 0, sizeof(surface_desc));
surface_desc.dwSize = sizeof(surface_desc);
surface_desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE;
surface_desc.dwWidth = 64;
surface_desc.dwHeight = 64;
hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface1, NULL);
ok(hr == D3D_OK, "Failed to create surface, hr %#x.\n", hr);
memset(&surface_desc, 0, sizeof(surface_desc));
surface_desc.dwSize = sizeof(surface_desc);
surface_desc.dwFlags = DDSD_CAPS | DDSD_PIXELFORMAT | DDSD_WIDTH | DDSD_HEIGHT;
surface_desc.ddsCaps.dwCaps = DDSCAPS_ZBUFFER;
U4(surface_desc).ddpfPixelFormat.dwSize = sizeof(U4(surface_desc).ddpfPixelFormat);
U4(surface_desc).ddpfPixelFormat.dwFlags = DDPF_ZBUFFER;
U1(U4(surface_desc).ddpfPixelFormat).dwZBufferBitDepth = 16;
U3(U4(surface_desc).ddpfPixelFormat).dwZBitMask = 0x0000ffff;
surface_desc.dwWidth = 32;
surface_desc.dwHeight = 32;
hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface2, NULL);
ok(hr == D3D_OK, "Failed to create surface, hr %#x.\n", hr);
surface_desc.dwWidth = 64;
surface_desc.dwHeight = 64;
hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface3, NULL);
ok(hr == D3D_OK, "Failed to create surface, hr %#x.\n", hr);
surface_desc.dwWidth = 128;
surface_desc.dwHeight = 128;
hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface4, NULL);
ok(hr == D3D_OK, "Failed to create surface, hr %#x.\n", hr);
hr = IDirectDrawSurface_AddAttachedSurface(surface1, surface2);
todo_wine ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#x.\n", hr);
if (SUCCEEDED(hr))
IDirectDrawSurface7_DeleteAttachedSurface(surface1, 0, surface3);
hr = IDirectDrawSurface_AddAttachedSurface(surface1, surface3);
ok(hr == D3D_OK, "Failed to attach depth buffer, hr %#x.\n", hr);
hr = IDirectDrawSurface7_DeleteAttachedSurface(surface1, 0, surface3);
ok(hr == D3D_OK, "Failed to detach depth buffer, hr %#x.\n", hr);
hr = IDirectDrawSurface_AddAttachedSurface(surface1, surface4);
todo_wine ok(hr == DDERR_CANNOTATTACHSURFACE, "Got unexpected hr %#x.\n", hr);
IDirectDrawSurface7_Release(surface4);
IDirectDrawSurface7_Release(surface3);
IDirectDrawSurface7_Release(surface2);
IDirectDrawSurface7_Release(surface1);
/* Test DeleteAttachedSurface() and automatic detachment of attached surfaces on release. */
memset(&surface_desc, 0, sizeof(surface_desc));
surface_desc.dwSize = sizeof(surface_desc);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment