ddraw/tests: Use winetest_push_context() in test_viewport().

Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2022-04-20 20:04:28 -05:00 committed by Alexandre Julliard
parent 738c1c01b6
commit edebe24a07
4 changed files with 116 additions and 90 deletions

View File

@ -386,7 +386,7 @@ static void fill_surface(IDirectDrawSurface *surface, D3DCOLOR color)
ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
}
static void check_rect(IDirectDrawSurface *surface, RECT r, const char *message)
static void check_rect(IDirectDrawSurface *surface, RECT r)
{
LONG x_coords[2][2] =
{
@ -417,8 +417,7 @@ static void check_rect(IDirectDrawSurface *surface, RECT r, const char *message)
if (x < 0 || x >= 640 || y < 0 || y >= 480)
continue;
color = get_surface_color(surface, x, y);
ok(color == expected, "%s: Pixel (%d, %d) has color %08x, expected %08x\n",
message, x, y, color, expected);
ok(color == expected, "Pixel (%d, %d) has color %08x, expected %08x.\n", x, y, color, expected);
}
}
}
@ -13274,11 +13273,13 @@ static void test_viewport(void)
for (j = 0; j < ARRAY_SIZE(tests); ++j)
{
winetest_push_context(tests[j].message);
hr = IDirect3DViewport_Clear(full_viewport, 1, &clear_rect, D3DCLEAR_TARGET);
ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x (j %u).\n", hr, j);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3D_CreateViewport(d3d, &viewport, NULL);
ok(SUCCEEDED(hr), "Failed to create viewport, hr %#x (j %u).\n", hr, j);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
memset(&vp, 0, sizeof(vp));
vp.dwSize = sizeof(vp);
vp.dwX = tests[j].vp.dwX;
@ -13292,26 +13293,27 @@ static void test_viewport(void)
vp.dvMinZ = 0.0f;
vp.dvMaxZ = 1.0f;
hr = IDirect3DViewport_SetViewport(viewport, &vp);
ok(hr == D3DERR_VIEWPORTHASNODEVICE,
"Setting viewport data returned unexpected hr %#x (j %u).\n", hr, j);
ok(hr == D3DERR_VIEWPORTHASNODEVICE, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice_AddViewport(device, viewport);
ok(SUCCEEDED(hr), "Failed to add viewport, hr %#x (j %u).\n", hr, j);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DViewport_SetViewport(viewport, &vp);
ok(SUCCEEDED(hr), "Failed to set viewport data, hr %#x (j %u).\n", hr, j);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice_BeginScene(device);
ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x (j %u).\n", hr, j);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
set_execute_data(execute_buffer, 4, sizeof(quad), inst_length);
hr = IDirect3DDevice_Execute(device, execute_buffer, viewport, D3DEXECUTE_CLIPPED);
ok(SUCCEEDED(hr), "Failed to execute exec buffer, hr %#x (j %u).\n", hr, j);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice_EndScene(device);
ok(SUCCEEDED(hr), "Failed to end scene, hr %#x (j %u).\n", hr, j);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
check_rect(rt, tests[j].expected_rect, tests[j].message);
check_rect(rt, tests[j].expected_rect);
destroy_viewport(device, viewport);
winetest_pop_context();
}
destroy_viewport(device, full_viewport);

View File

@ -388,7 +388,7 @@ static void fill_surface(IDirectDrawSurface *surface, D3DCOLOR color)
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
}
static void check_rect(IDirectDrawSurface *surface, RECT r, const char *message)
static void check_rect(IDirectDrawSurface *surface, RECT r)
{
LONG x_coords[2][2] =
{
@ -419,8 +419,7 @@ static void check_rect(IDirectDrawSurface *surface, RECT r, const char *message)
if (x < 0 || x >= 640 || y < 0 || y >= 480)
continue;
color = get_surface_color(surface, x, y);
ok(color == expected, "%s: Pixel (%d, %d) has color %08x, expected %08x\n",
message, x, y, color, expected);
ok(color == expected, "Pixel (%d, %d) has color %08x, expected %08x.\n", x, y, color, expected);
}
}
}
@ -14149,7 +14148,11 @@ static void test_viewport(void)
{{100, 100, 640, 480}, {100, 220, 579, 459}, "Viewport (100, 100) - (640, 480)"},
{{ 0, 0, 8192, 8192}, {-10, -10, -10, -10}, "Viewport (0, 0) - (8192, 8192)"},
};
static const struct vec2 rt_sizes[] =
static const struct
{
unsigned int x, y;
}
rt_sizes[] =
{
{640, 480}, {1280, 960}, {320, 240}, {800, 600},
};
@ -14220,6 +14223,8 @@ static void test_viewport(void)
for (i = 0; i < ARRAY_SIZE(rt_sizes); ++i)
{
winetest_push_context("Size %ux%u", rt_sizes[i].x, rt_sizes[i].y);
if (i)
{
memset(&surface_desc, 0, sizeof(surface_desc));
@ -14229,23 +14234,23 @@ static void test_viewport(void)
surface_desc.dwHeight = rt_sizes[i].y;
surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE;
hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &rt, NULL);
ok(SUCCEEDED(hr), "Failed to create render target, hr %#x (i %u).\n", hr, i);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
surface_desc.dwFlags = DDSD_CAPS | DDSD_PIXELFORMAT | DDSD_WIDTH | DDSD_HEIGHT;
surface_desc.ddsCaps.dwCaps = DDSCAPS_ZBUFFER;
surface_desc.ddpfPixelFormat = z_fmt;
hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &ds, NULL);
ok(SUCCEEDED(hr), "Failed to create depth buffer, hr %#x (i %u).\n", hr, i);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirectDrawSurface_AddAttachedSurface(rt, ds);
ok(SUCCEEDED(hr), "Failed to attach depth buffer, hr %#x (i %u).\n", hr, i);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice2_SetRenderTarget(device, rt, 0);
ok(SUCCEEDED(hr), "Failed to set render target, hr %#x (i %u).\n", hr, i);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
}
else
{
hr = IDirect3DDevice2_GetRenderTarget(device, &rt);
ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
}
full_viewport = create_viewport(device, 0, 0, rt_sizes[i].x, rt_sizes[i].y);
@ -14257,17 +14262,18 @@ static void test_viewport(void)
for (j = 0; j < ARRAY_SIZE(tests); ++j)
{
winetest_push_context(tests[j].message);
expected_failure = tests[j].vp.dwX + tests[j].vp.dwWidth > rt_sizes[i].x
|| tests[j].vp.dwY + tests[j].vp.dwHeight > rt_sizes[i].y;
hr = IDirect3DViewport2_Clear(full_viewport, 1, &clear_rect, D3DCLEAR_TARGET);
ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x (i %u, j %u).\n", hr, i, j);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3D2_CreateViewport(d3d, &viewport, NULL);
ok(SUCCEEDED(hr), "Failed to create viewport, hr %#x (i %u, j %u).\n", hr, i, j);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DViewport2_SetViewport2(viewport, NULL);
ok(hr == E_INVALIDARG, "Setting NULL viewport data returned unexpected hr %#x (i %u, j %u).\n",
hr, i, j);
ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
memset(&vp, 0, sizeof(vp));
vp.dwSize = sizeof(vp);
vp.dwX = tests[j].vp.dwX;
@ -14279,35 +14285,32 @@ static void test_viewport(void)
vp.dvMinZ = 0.0f;
vp.dvMaxZ = 1.0f;
hr = IDirect3DViewport2_SetViewport(viewport, &vp);
ok(hr == D3DERR_VIEWPORTHASNODEVICE,
"Setting viewport data returned unexpected hr %#x (i %u, j %u).\n", hr, i, j);
ok(hr == D3DERR_VIEWPORTHASNODEVICE, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice2_AddViewport(device, viewport);
ok(SUCCEEDED(hr), "Failed to add viewport, hr %#x (i %u, j %u).\n", hr, i, j);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DViewport2_SetViewport(viewport, &vp);
if (expected_failure)
ok(hr == E_INVALIDARG, "Setting viewport data returned unexpected hr %#x (i %u, j %u).\n",
hr, i, j);
else
ok(SUCCEEDED(hr), "Failed to set viewport data, hr %#x (i %u, j %u).\n", hr, i, j);
ok(hr == (expected_failure ? E_INVALIDARG : DD_OK), "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice2_SetCurrentViewport(device, viewport);
ok(SUCCEEDED(hr), "Failed to set the viewport, hr %#x (i %u, j %u).\n", hr, i, j);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
if (expected_failure)
{
destroy_viewport(device, viewport);
winetest_pop_context();
continue;
}
hr = IDirect3DDevice2_BeginScene(device);
ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x (i %u, j %u).\n", hr, i, j);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice2_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DVT_LVERTEX, quad, 4, 0);
ok(SUCCEEDED(hr), "Got unexpected hr %#x (i %u, j %u).\n", hr, i, j);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice2_EndScene(device);
ok(SUCCEEDED(hr), "Failed to end scene, hr %#x (i %u, j %u).\n", hr, i, j);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
check_rect(rt, tests[j].expected_rect, tests[j].message);
check_rect(rt, tests[j].expected_rect);
destroy_viewport(device, viewport);
winetest_pop_context();
}
destroy_viewport(device, full_viewport);
@ -14317,6 +14320,8 @@ static void test_viewport(void)
IDirectDrawSurface_Release(ds);
IDirectDrawSurface_Release(rt);
winetest_pop_context();
}
destroy_material(black_background);

View File

@ -389,7 +389,7 @@ static void fill_surface(IDirectDrawSurface4 *surface, D3DCOLOR color)
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
}
static void check_rect(IDirectDrawSurface4 *surface, RECT r, const char *message)
static void check_rect(IDirectDrawSurface4 *surface, RECT r)
{
LONG x_coords[2][2] =
{
@ -420,8 +420,7 @@ static void check_rect(IDirectDrawSurface4 *surface, RECT r, const char *message
if (x < 0 || x >= 640 || y < 0 || y >= 480)
continue;
color = get_surface_color(surface, x, y);
ok(color == expected, "%s: Pixel (%d, %d) has color %08x, expected %08x\n",
message, x, y, color, expected);
ok(color == expected, "Pixel (%d, %d) has color %08x, expected %08x.\n", x, y, color, expected);
}
}
}
@ -16748,7 +16747,11 @@ static void test_viewport(void)
{{100, 100, 640, 480}, {100, 220, 579, 459}, "Viewport (100, 100) - (640, 480)"},
{{ 0, 0, 8192, 8192}, {-10, -10, -10, -10}, "Viewport (0, 0) - (8192, 8192)"},
};
static const struct vec2 rt_sizes[] =
static const struct
{
unsigned int x, y;
}
rt_sizes[] =
{
{640, 480}, {1280, 960}, {320, 240}, {800, 600},
};
@ -16815,6 +16818,8 @@ static void test_viewport(void)
for (i = 0; i < ARRAY_SIZE(rt_sizes); ++i)
{
winetest_push_context("Size %ux%u", rt_sizes[i].x, rt_sizes[i].y);
if (i)
{
memset(&surface_desc, 0, sizeof(surface_desc));
@ -16824,23 +16829,23 @@ static void test_viewport(void)
surface_desc.dwHeight = rt_sizes[i].y;
surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE;
hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &rt, NULL);
ok(SUCCEEDED(hr), "Failed to create render target, hr %#x (i %u).\n", hr, i);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
surface_desc.dwFlags = DDSD_CAPS | DDSD_PIXELFORMAT | DDSD_WIDTH | DDSD_HEIGHT;
surface_desc.ddsCaps.dwCaps = DDSCAPS_ZBUFFER;
U4(surface_desc).ddpfPixelFormat = z_fmt;
hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &ds, NULL);
ok(SUCCEEDED(hr), "Failed to create depth buffer, hr %#x (i %u).\n", hr, i);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirectDrawSurface4_AddAttachedSurface(rt, ds);
ok(SUCCEEDED(hr), "Failed to attach depth buffer, hr %#x (i %u).\n", hr, i);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice3_SetRenderTarget(device, rt, 0);
ok(SUCCEEDED(hr), "Failed to set render target, hr %#x.\n", hr);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
}
else
{
hr = IDirect3DDevice3_GetRenderTarget(device, &rt);
ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
}
full_viewport = create_viewport(device, 0, 0, rt_sizes[i].x, rt_sizes[i].y);
@ -16851,16 +16856,18 @@ static void test_viewport(void)
for (j = 0; j < ARRAY_SIZE(tests); ++j)
{
winetest_push_context(tests[j].message);
expected_failure = tests[j].vp.dwX + tests[j].vp.dwWidth > rt_sizes[i].x
|| tests[j].vp.dwY + tests[j].vp.dwHeight > rt_sizes[i].y;
hr = IDirect3DViewport3_Clear2(full_viewport, 1, &clear_rect, D3DCLEAR_TARGET, 0xff000000, 0.0f, 0);
ok(SUCCEEDED(hr), "Failed to clear viewport, hr %#x (i %u, j %u).\n", hr, i, j);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3D3_CreateViewport(d3d, &viewport, NULL);
ok(SUCCEEDED(hr), "Failed to create viewport, hr %#x (i %u, j %u).\n", hr, i, j);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DViewport3_SetViewport2(viewport, NULL);
ok(hr == E_INVALIDARG, "Setting NULL viewport data returned unexpected hr %#x (i %u, j %u).\n", hr, i, j);
ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
memset(&vp, 0, sizeof(vp));
vp.dwSize = sizeof(vp);
vp.dwX = tests[j].vp.dwX;
@ -16874,35 +16881,32 @@ static void test_viewport(void)
vp.dvMinZ = 0.0f;
vp.dvMaxZ = 1.0f;
hr = IDirect3DViewport3_SetViewport2(viewport, &vp);
ok(hr == D3DERR_VIEWPORTHASNODEVICE,
"Setting viewport data returned unexpected hr %#x (i %u, j %u).\n", hr, i, j);
ok(hr == D3DERR_VIEWPORTHASNODEVICE, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice3_AddViewport(device, viewport);
ok(SUCCEEDED(hr), "Failed to add viewport, hr %#x (i %u, j %u).\n", hr, i, j);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DViewport3_SetViewport2(viewport, &vp);
if (expected_failure)
ok(hr == E_INVALIDARG,
"Setting viewport data returned unexpected hr %#x (i %u, j %u).\n", hr, i, j);
else
ok(SUCCEEDED(hr), "Failed to set viewport data, hr %#x (i %u, j %u).\n", hr, i, j);
ok(hr == (expected_failure ? E_INVALIDARG : DD_OK), "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice3_SetCurrentViewport(device, viewport);
ok(SUCCEEDED(hr), "Failed to set the viewport, hr %#x (i %u, j %u).\n", hr, i, j);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
if (expected_failure)
{
destroy_viewport(device, viewport);
winetest_pop_context();
continue;
}
hr = IDirect3DDevice3_BeginScene(device);
ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x (i %u, j %u).\n", hr, i, j);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice3_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZ, quad, 4, 0);
ok(SUCCEEDED(hr), "Got unexpected hr %#x (i %u, j %u).\n", hr, i, j);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice3_EndScene(device);
ok(SUCCEEDED(hr), "Failed to end scene, hr %#x (i %u, j %u).\n", hr, i, j);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
check_rect(rt, tests[j].expected_rect, tests[j].message);
check_rect(rt, tests[j].expected_rect);
destroy_viewport(device, viewport);
winetest_pop_context();
}
destroy_viewport(device, full_viewport);
@ -16912,6 +16916,8 @@ static void test_viewport(void)
IDirectDrawSurface4_Release(ds);
IDirectDrawSurface4_Release(rt);
winetest_pop_context();
}
refcount = IDirect3DDevice3_Release(device);

View File

@ -411,8 +411,8 @@ static void fill_surface(IDirectDrawSurface7 *surface, D3DCOLOR color)
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
}
#define check_rect(a, b, c) check_rect_(__LINE__, a, b, c)
static void check_rect_(unsigned int line, IDirectDrawSurface7 *surface, RECT r, const char *message)
#define check_rect(a, b) check_rect_(__LINE__, a, b)
static void check_rect_(unsigned int line, IDirectDrawSurface7 *surface, RECT r)
{
LONG x_coords[2][2] =
{
@ -443,8 +443,8 @@ static void check_rect_(unsigned int line, IDirectDrawSurface7 *surface, RECT r,
if (x < 0 || x >= 640 || y < 0 || y >= 480)
continue;
color = get_surface_color(surface, x, y);
ok_(__FILE__, line)(color == expected, "%s: Pixel (%d, %d) has color %08x, expected %08x.\n",
message, x, y, color, expected);
ok_(__FILE__, line)(color == expected, "Pixel (%d, %d) has color %08x, expected %08x.\n",
x, y, color, expected);
}
}
}
@ -16191,7 +16191,11 @@ static void test_viewport(void)
{ 0.5f, -0.5f, 1.0f},
{ 0.5f, 0.5f, 1.0f},
};
static const struct vec2 rt_sizes[] =
static const struct
{
unsigned int x, y;
}
rt_sizes[] =
{
{640, 480}, {1280, 960}, {320, 240}, {800, 600},
};
@ -16246,6 +16250,8 @@ static void test_viewport(void)
for (i = 0; i < ARRAY_SIZE(rt_sizes); ++i)
{
winetest_push_context("Size %ux%u", rt_sizes[i].x, rt_sizes[i].y);
if (i)
{
memset(&surface_desc, 0, sizeof(surface_desc));
@ -16255,80 +16261,87 @@ static void test_viewport(void)
surface_desc.dwHeight = rt_sizes[i].y;
surface_desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE;
hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &rt, NULL);
ok(hr == DD_OK, "Got unexpected hr %#x (i %u).\n", hr, i);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
surface_desc.dwFlags = DDSD_CAPS | DDSD_PIXELFORMAT | DDSD_WIDTH | DDSD_HEIGHT;
surface_desc.ddsCaps.dwCaps = DDSCAPS_ZBUFFER;
U4(surface_desc).ddpfPixelFormat = z_fmt;
hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &ds, NULL);
ok(hr == DD_OK, "Got unexpected hr %#x (i %u).\n", hr, i);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirectDrawSurface7_AddAttachedSurface(rt, ds);
ok(hr == DD_OK, "Got unexpected hr %#x (i %u).\n", hr, i);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice7_SetRenderTarget(device, rt, 0);
ok(hr == DD_OK, "Got unexpected hr %#x (i %u).\n", hr, i);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
}
else
{
hr = IDirect3DDevice7_GetRenderTarget(device, &rt);
ok(hr == DD_OK, "Got unexpected hr %#x (i %u).\n", hr, i);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
}
for (j = 0; j < ARRAY_SIZE(tests); ++j)
{
winetest_push_context(tests[j].message);
hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xff000000,
tests[j].expected_z - z_eps, 0);
ok(hr == DD_OK, "Got unexpected hr %#x (i %u, j %u).\n", hr, i, j);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_ZFUNC, D3DCMP_GREATER);
ok(hr == DD_OK, "Got unexpected hr %#x (i %u, j %u).\n", hr, i, j);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_ZENABLE, !i);
ok(hr == DD_OK, "Got unexpected hr %#x (i %u, j %u).\n", hr, i, j);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice7_SetViewport(device, &tests[j].vp);
if (tests[j].vp.dwX + tests[j].vp.dwWidth > rt_sizes[i].x
|| tests[j].vp.dwY + tests[j].vp.dwHeight > rt_sizes[i].y)
{
ok(hr == E_INVALIDARG, "Got unexpected hr %#x (i %u, j %u).\n", hr, i, j);
ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
winetest_pop_context();
continue;
}
else
{
ok(hr == DD_OK, "Got unexpected hr %#x (i %u, j %u).\n", hr, i, j);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
}
hr = IDirect3DDevice7_BeginScene(device);
ok(hr == DD_OK, "Got unexpected hr %#x (i %u, j %u).\n", hr, i, j);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZ, quad, 4, 0);
ok(hr == DD_OK, "Got unexpected hr %#x (i %u, j %u).\n", hr, i, j);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice7_EndScene(device);
ok(hr == DD_OK, "Got unexpected hr %#x (i %u, j %u).\n", hr, i, j);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
check_rect(rt, tests[j].expected_rect, tests[j].message);
check_rect(rt, tests[j].expected_rect);
if (!i)
{
hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xff000000,
tests[j].expected_z + z_eps, 0);
ok(hr == DD_OK, "Got unexpected hr %#x (i %u, j %u).\n", hr, i, j);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_ZFUNC, D3DCMP_LESS);
ok(hr == DD_OK, "Got unexpected hr %#x (i %u, j %u).\n", hr, i, j);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice7_BeginScene(device);
ok(hr == DD_OK, "Got unexpected hr %#x (i %u, j %u).\n", hr, i, j);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, D3DFVF_XYZ, quad, 4, 0);
ok(hr == DD_OK, "Got unexpected hr %#x (i %u, j %u).\n", hr, i, j);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice7_EndScene(device);
ok(hr == DD_OK, "Got unexpected hr %#x (i %u, j %u).\n", hr, i, j);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
check_rect(rt, tests[j].expected_rect, tests[j].message);
check_rect(rt, tests[j].expected_rect);
}
winetest_pop_context();
}
hr = IDirectDrawSurface7_DeleteAttachedSurface(rt, 0, ds);
ok(hr == DD_OK, "Got unexpected hr %#x (i %u).\n", hr, i);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
IDirectDrawSurface7_Release(ds);
IDirectDrawSurface7_Release(rt);
winetest_pop_context();
}
refcount = IDirect3DDevice7_Release(device);