[PATCH 3/3] d3d9/tests: Test using a "NULL" texture with a smaller D/S texture.
Matteo Bruni
mbruni at codeweavers.com
Mon Nov 2 12:03:11 CST 2020
Signed-off-by: Matteo Bruni <mbruni at codeweavers.com>
---
dlls/d3d9/tests/visual.c | 63 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 63 insertions(+)
diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c
index 5218d8a2029..7f47a5e6645 100644
--- a/dlls/d3d9/tests/visual.c
+++ b/dlls/d3d9/tests/visual.c
@@ -24934,6 +24934,7 @@ static void test_null_format(void)
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};
+ static const D3DVIEWPORT9 vp_part_400 = {0, 100, 400, 200, 0.0f, 1.0f};
static const DWORD null_fourcc = MAKEFOURCC('N','U','L','L');
static const struct
{
@@ -24984,8 +24985,21 @@ static void test_null_format(void)
{440, 320, 0x000000ff},
{520, 320, 0x00000000},
{600, 320, 0x0000ff00},
+ },
+ expected_2[] =
+ {
+ {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;
IDirect3DDevice9 *device;
IDirect3D9 *d3d;
unsigned int i;
@@ -25026,6 +25040,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);
@@ -25109,9 +25129,52 @@ static void test_null_format(void)
expected_colors[i].color, expected_colors[i].x, expected_colors[i].y, color);
}
+ /* 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.5f, 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);
+
+ for (i = 0; i < ARRAY_SIZE(expected_2); ++i)
+ {
+ color = getPixelColor(device, expected_2[i].x, expected_2[i].y);
+ ok(color_match(color, expected_2[i].color, 1),
+ "Expected color 0x%08x at (%u, %u), got 0x%08x.\n",
+ expected_2[i].color, expected_2[i].x, expected_2[i].y, color);
+ }
+
+ 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);
--
2.26.2
More information about the wine-devel
mailing list