Signed-off-by: Józef Kucia jkucia@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();
Hi,
While running your changed tests on Windows, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=46167
Your paranoid android.
=== w8 (32 bit report) ===
d3d9: visual.c:1394: Test failed: Failed to clear, hr 0x8876086c. visual.c:1398: Test failed: Got color 0x00000000. visual.c:1407: Test failed: Got color 0x00000000 at 0. visual.c:1407: Test failed: Got color 0x00000000 at 1.
=== w8adm (32 bit report) ===
d3d9: visual.c:1394: Test failed: Failed to clear, hr 0x8876086c. visual.c:1398: Test failed: Got color 0x00000000. visual.c:1407: Test failed: Got color 0x00000000 at 0. visual.c:1407: Test failed: Got color 0x00000000 at 1.
=== w864 (32 bit report) ===
d3d9: visual.c:1394: Test failed: Failed to clear, hr 0x8876086c. visual.c:1398: Test failed: Got color 0x00000000. visual.c:1407: Test failed: Got color 0x00000000 at 0. visual.c:1407: Test failed: Got color 0x00000000 at 1.
=== w1064 (32 bit report) ===
d3d9: visual.c:1394: Test failed: Failed to clear, hr 0x8876086c. visual.c:1398: Test failed: Got color 0x00000000. visual.c:1407: Test failed: Got color 0x00000000 at 0. visual.c:1407: Test failed: Got color 0x00000000 at 1.
=== w864 (64 bit report) ===
d3d9: visual.c:1394: Test failed: Failed to clear, hr 0x8876086c. visual.c:1398: Test failed: Got color 0x00000000. visual.c:1407: Test failed: Got color 0x00000000 at 0. visual.c:1407: Test failed: Got color 0x00000000 at 1.
=== w1064 (64 bit report) ===
d3d9: visual.c:1394: Test failed: Failed to clear, hr 0x8876086c. visual.c:1398: Test failed: Got color 0x00000000. visual.c:1407: Test failed: Got color 0x00000000 at 0. visual.c:1407: Test failed: Got color 0x00000000 at 1.