d3d9/tests: Test using a "NULL" texture with a smaller D/S texture.

Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Matteo Bruni 2020-11-25 18:11:28 +01:00 committed by Alexandre Julliard
parent 065d16a766
commit 967227958d

View file

@ -24931,6 +24931,7 @@ done:
static void test_null_format(void)
{
static const D3DVIEWPORT9 vp_part_400 = {0, 100, 400, 200, 0.0f, 1.0f};
static const D3DVIEWPORT9 vp_lower = {0, 60, 640, 420, 0.0f, 1.0f};
static const D3DVIEWPORT9 vp_560 = {0, 180, 560, 300, 0.0f, 1.0f};
static const D3DVIEWPORT9 vp_full = {0, 0, 640, 480, 0.0f, 1.0f};
@ -24984,8 +24985,21 @@ static void test_null_format(void)
{440, 320, 0x000000ff},
{520, 320, 0x00000000},
{600, 320, 0x0000ff00},
},
expected_small[] =
{
{100, 100, 0x00ff0000},
{200, 100, 0x00ff0000},
{300, 100, 0x00ff0000},
{100, 150, 0x00000000},
{200, 150, 0x00000000},
{300, 150, 0x00ff0000},
{100, 200, 0x00000000},
{200, 200, 0x00000000},
{300, 200, 0x00ff0000},
};
IDirect3DSurface9 *original_rt, *small_rt, *null_rt, *small_null_rt;
IDirect3DSurface9 *original_ds, *small_ds;
struct surface_readback rb;
IDirect3DDevice9 *device;
IDirect3D9 *d3d;
@ -25027,6 +25041,12 @@ static void test_null_format(void)
D3DMULTISAMPLE_NONE, 0, FALSE, &small_null_rt, NULL);
ok(SUCCEEDED(hr), "Failed to create render target, hr %#x.\n", hr);
hr = IDirect3DDevice9_GetDepthStencilSurface(device, &original_ds);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice9_CreateDepthStencilSurface(device, 400, 300, D3DFMT_D24S8, 0, 0, FALSE,
&small_ds, NULL);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_DIFFUSE);
ok(SUCCEEDED(hr), "Failed to set FVF, hr %#x.\n", hr);
hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, D3DZB_TRUE);
@ -25112,9 +25132,54 @@ static void test_null_format(void)
}
release_surface_readback(&rb);
/* Clears and draws on a depth buffer smaller than the "NULL" RT work just
* fine. */
hr = IDirect3DDevice9_SetRenderTarget(device, 0, null_rt);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice9_SetDepthStencilSurface(device, small_ds);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice9_SetViewport(device, &vp_full);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_ZBUFFER, 0, 0.6f, 0);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice9_SetViewport(device, &vp_part_400);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice9_BeginScene(device);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad_partial, sizeof(*quad_partial));
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice9_SetRenderTarget(device, 0, small_rt);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0, 0.0f, 0);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice9_EndScene(device);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
get_rt_readback(small_rt, &rb);
for (i = 0; i < ARRAY_SIZE(expected_small); ++i)
{
color = get_readback_color(&rb, expected_small[i].x, expected_small[i].y);
ok(color_match(color, expected_small[i].color, 1),
"Expected color 0x%08x at (%u, %u), got 0x%08x.\n",
expected_small[i].color, expected_small[i].x, expected_small[i].y, color);
}
release_surface_readback(&rb);
hr = IDirect3DDevice9_StretchRect(device, small_rt, NULL, original_rt, NULL, D3DTEXF_POINT);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
IDirect3DSurface9_Release(small_ds);
IDirect3DSurface9_Release(original_ds);
IDirect3DSurface9_Release(small_null_rt);
IDirect3DSurface9_Release(null_rt);
IDirect3DSurface9_Release(small_rt);