[PATCH 5/5] d3d9/tests: Add test for clearing surfaces with different sizes.
Józef Kucia
jkucia at codeweavers.com
Tue Jan 8 10:12:53 CST 2019
Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
---
dlls/d3d9/tests/visual.c | 110 +++++++++++++++++++++++++++++++++++++++
1 file changed, 110 insertions(+)
diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c
index 51229f2b8268..3db61db12c7e 100644
--- a/dlls/d3d9/tests/visual.c
+++ b/dlls/d3d9/tests/visual.c
@@ -1324,6 +1324,115 @@ done:
DestroyWindow(window);
}
+static void test_clear_different_size_surfaces(void)
+{
+ IDirect3DSurface9 *ds, *rt, *rt2;
+ struct surface_readback rb;
+ IDirect3DDevice9 *device;
+ D3DLOCKED_RECT lr;
+ unsigned int x, y;
+ D3DVIEWPORT9 vp;
+ IDirect3D9 *d3d;
+ D3DCAPS9 caps;
+ WORD *depth;
+ HWND window;
+ DWORD color;
+ HRESULT hr;
+
+ window = create_window();
+ d3d = Direct3DCreate9(D3D_SDK_VERSION);
+ ok(!!d3d, "Failed to create D3D object.\n");
+ if (!(device = create_device(d3d, window, window, TRUE)))
+ {
+ skip("Failed to create D3D device.\n");
+ goto done;
+ }
+
+ hr = IDirect3DDevice9_GetDeviceCaps(device, &caps);
+ ok(hr == D3D_OK, "Failed to get device caps, hr %#x.\n", hr);
+
+ hr = IDirect3DDevice9_CreateRenderTarget(device, 1, 1, D3DFMT_A8R8G8B8,
+ D3DMULTISAMPLE_NONE, 0, TRUE, &rt, NULL);
+ ok(hr == D3D_OK, "Failed to create render target surface, hr %#x.\n", hr);
+ hr = IDirect3DDevice9_CreateRenderTarget(device, 1, 2, D3DFMT_A8R8G8B8,
+ D3DMULTISAMPLE_NONE, 0, TRUE, &rt2, NULL);
+ ok(hr == D3D_OK, "Failed to create render target surface, hr %#x.\n", hr);
+
+ if (SUCCEEDED(IDirect3D9_CheckDeviceFormat(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
+ D3DFMT_A8R8G8B8, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_SURFACE, D3DFMT_D16_LOCKABLE)))
+ {
+ hr = IDirect3DDevice9_CreateDepthStencilSurface(device, 4, 4, D3DFMT_D16_LOCKABLE,
+ D3DMULTISAMPLE_NONE, 0, FALSE, &ds, NULL);
+ ok(hr == D3D_OK, "Failed to create depth surface, hr %#x.\n", hr);
+ }
+ else
+ {
+ skip("D3DFMT_D16_LOCKABLE is not supported.\n");
+ ds = NULL;
+ }
+
+ hr = IDirect3DDevice9_SetDepthStencilSurface(device, ds);
+ ok(hr == D3D_OK, "Failed to set depth stencil surface, hr %#x.\n", hr);
+ hr = IDirect3DDevice9_SetRenderTarget(device, 0, rt);
+ ok(hr == D3D_OK, "Failed to set render target, hr %#x.\n", hr);
+ if (caps.NumSimultaneousRTs >= 2)
+ {
+ hr = IDirect3DDevice9_SetRenderTarget(device, 1, rt2);
+ ok(hr == D3D_OK, "Failed to set render target, hr %#x.\n", hr);
+ }
+
+ vp.X = 0;
+ vp.Y = 0;
+ vp.Width = 640;
+ vp.Height = 640;
+ vp.MinZ = 0.0f;
+ vp.MaxZ = 1.0f;
+ hr = IDirect3DDevice9_SetViewport(device, &vp);
+ ok(hr == D3D_OK, "Failed to set viewport, hr %#x.\n", hr);
+
+ hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xffff0000, 0.5f, 0);
+ ok(hr == D3D_OK, "Failed to clear, hr %#x.\n", hr);
+
+ get_rt_readback(rt, &rb);
+ color = get_readback_color(&rb, 0, 0);
+ ok(color == 0xffff0000, "Got color 0x%08x.\n", color);
+ release_surface_readback(&rb);
+
+ if (caps.NumSimultaneousRTs >= 2)
+ {
+ get_rt_readback(rt2, &rb);
+ for (y = 0; y < 2; ++y)
+ {
+ color = get_readback_color(&rb, 0, y);
+ ok(color == 0xffff0000, "Got color 0x%08x at %u.\n", color, y);
+ }
+ release_surface_readback(&rb);
+ }
+
+ if (ds)
+ {
+ hr = IDirect3DSurface9_LockRect(ds, &lr, NULL, D3DLOCK_READONLY);
+ ok(hr == D3D_OK, "Failed to lock rect, hr %#x.\n", hr);
+ for (y = 0; y < 4; ++y)
+ {
+ depth = (WORD *)((BYTE *)lr.pBits + y * lr.Pitch);
+ for (x = 0; x < 4; ++x)
+ {
+ ok(abs(depth[x] - 0x7fff) <= 2, "Got depth 0x%04x at %u, %u.\n", depth[x], x, y);
+ }
+ }
+ hr = IDirect3DSurface9_UnlockRect(ds);
+ ok(hr == D3D_OK, "Failed to unlock rect, hr %#x.\n", hr);
+ IDirect3DSurface9_Release(ds);
+ }
+
+ IDirect3DSurface9_Release(rt);
+ IDirect3DSurface9_Release(rt2);
+done:
+ IDirect3D9_Release(d3d);
+ DestroyWindow(window);
+}
+
static void color_fill_test(void)
{
IDirect3DSurface9 *surface;
@@ -24420,6 +24529,7 @@ START_TEST(visual)
lighting_test();
test_specular_lighting();
clear_test();
+ test_clear_different_size_surfaces();
color_fill_test();
fog_test();
test_cube_wrap();
--
2.19.2
More information about the wine-devel
mailing list