Signed-off-by: Stefan Dösinger stefan@codeweavers.com
---
Try 2: Mark AMD ddraw 1 behavior broken. It seems that AMD drivers (tested on r500 and evergreen, both Win7) do not limit the clear to the viewport rectangle in ddraw1 only. Later ddraw versions work fine. The behavior is (unsurprisingly) not influenced by the version of the viewport interface used to do the clear and not related to SetCurrentViewport in ddraw2. It isn't caused by having more than one viewport either. So as far as I can say it's just the driver being broken.
This is merely a port of the existing test back to ddraw. The next patch will address the WARP test failure. --- dlls/ddraw/tests/ddraw1.c | 199 ++++++++++++++++++++++++++++++++++++++++++++++ dlls/ddraw/tests/ddraw2.c | 197 +++++++++++++++++++++++++++++++++++++++++++++ dlls/ddraw/tests/ddraw4.c | 176 ++++++++++++++++++++++++++++++++++++++++ dlls/ddraw/tests/ddraw7.c | 134 +++++++++++++++++++++++++++++++ dlls/ddraw/tests/visual.c | 47 ----------- 5 files changed, 706 insertions(+), 47 deletions(-)
diff --git a/dlls/ddraw/tests/ddraw1.c b/dlls/ddraw/tests/ddraw1.c index d416cf55a3..58703013c1 100644 --- a/dlls/ddraw/tests/ddraw1.c +++ b/dlls/ddraw/tests/ddraw1.c @@ -10913,6 +10913,204 @@ static void test_depth_readback(void) DestroyWindow(window); }
+static void test_clear(void) +{ + IDirectDraw *ddraw; + IDirect3DDevice *device; + IDirectDrawSurface *rt; + ULONG refcount; + HWND window; + HRESULT hr; + D3DRECT rect[2]; + D3DRECT rect_negneg, rect_full = {{0}, {0}, {640}, {480}}; + D3DCOLOR color; + IDirect3DViewport *viewport, *viewport2, *viewport3; + IDirect3DMaterial *white, *red, *green, *blue; + + window = create_window(); + ddraw = create_ddraw(); + ok(!!ddraw, "Failed to create a ddraw object.\n"); + if (!(device = create_device(ddraw, window, DDSCL_NORMAL))) + { + skip("Failed to create a 3D device, skipping test.\n"); + IDirectDraw_Release(ddraw); + DestroyWindow(window); + return; + } + hr = IDirect3DDevice_QueryInterface(device, &IID_IDirectDrawSurface, (void **)&rt); + ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr); + + viewport = create_viewport(device, 0, 0, 640, 480); + + white = create_diffuse_material(device, 1.0f, 1.0f, 1.0f, 1.0f); + red = create_diffuse_material(device, 1.0f, 0.0f, 0.0f, 1.0f); + green = create_diffuse_material(device, 0.0f, 1.0f, 0.0f, 1.0f); + blue = create_diffuse_material(device, 0.0f, 0.0f, 1.0f, 1.0f); + + viewport_set_background(device, viewport, white); + hr = IDirect3DViewport_Clear(viewport, 1, &rect_full, D3DCLEAR_TARGET); + ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr); + + /* Positive x, negative y. */ + U1(rect[0]).x1 = 0; + U2(rect[0]).y1 = 480; + U3(rect[0]).x2 = 320; + U4(rect[0]).y2 = 240; + + /* Positive x, positive y. */ + U1(rect[1]).x1 = 0; + U2(rect[1]).y1 = 0; + U3(rect[1]).x2 = 320; + U4(rect[1]).y2 = 240; + + /* Clear 2 rectangles with one call. Unlike d3d8/9, the refrast does not refuse negative + * rectangles, but it will not clear them either. */ + viewport_set_background(device, viewport, red); + hr = IDirect3DViewport_Clear(viewport, 2, rect, D3DCLEAR_TARGET); + ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr); + + /* negative x, negative y. + * + * FIXME: WARP seems to clear the entire screen here.*/ + rect_negneg.x1 = 640; + rect_negneg.y1 = 240; + rect_negneg.x2 = 320; + rect_negneg.y2 = 0; + viewport_set_background(device, viewport, green); + hr = IDirect3DViewport_Clear(viewport, 1, &rect_negneg, D3DCLEAR_TARGET); + ok(hr == D3D_OK, "Failed to clear, hr %#x.\n", hr); + + color = get_surface_color(rt, 160, 360); + ok(compare_color(color, 0x00ffffff, 0), "Clear rectangle 3(pos, neg) has color %08x.\n", color); + color = get_surface_color(rt, 160, 120); + ok(compare_color(color, 0x00ff0000, 0), "Clear rectangle 1(pos, pos) has color %08x.\n", color); + color = get_surface_color(rt, 480, 360); + ok(compare_color(color, 0x00ffffff, 0), "Clear rectangle 4(NULL) has color %08x.\n", color); + color = get_surface_color(rt, 480, 120); + ok(compare_color(color, 0x00ffffff, 0), "Clear rectangle 4(neg, neg) has color %08x.\n", color); + + /* Test how the viewport affects clears */ + viewport_set_background(device, viewport, white); + hr = IDirect3DViewport_Clear(viewport, 1, &rect_full, D3DCLEAR_TARGET); + ok(hr == D3D_OK, "Failed to clear, hr %#x.\n", hr); + + viewport2 = create_viewport(device, 160, 120, 160, 120); + viewport_set_background(device, viewport2, blue); + hr = IDirect3DViewport_Clear(viewport2, 1, &rect_full, D3DCLEAR_TARGET); + ok(hr == D3D_OK, "Failed to clear, hr %#x.\n", hr); + + viewport3 = create_viewport(device, 320, 240, 320, 240); + viewport_set_background(device, viewport3, green); + + U1(rect[0]).x1 = 160; + U2(rect[0]).y1 = 120; + U3(rect[0]).x2 = 480; + U4(rect[0]).y2 = 360; + hr = IDirect3DViewport_Clear(viewport3, 1, &rect[0], D3DCLEAR_TARGET); + ok(hr == D3D_OK, "Failed to clear, hr %#x.\n", hr); + + /* AMD drivers do not limit the clear area to the viewport rectangle in d3d1. + * It works as intended on other drivers and on d3d2 and newer on AMD cards. */ + color = get_surface_color(rt, 158, 118); + ok(compare_color(color, 0x00ffffff, 0) || broken(compare_color(color, 0x000000ff, 0)), + "(158,118) has color %08x\n", color); + color = get_surface_color(rt, 162, 118); + ok(compare_color(color, 0x00ffffff, 0) || broken(compare_color(color, 0x000000ff, 0)), + "(162,118) has color %08x\n", color); + color = get_surface_color(rt, 158, 122); + ok(compare_color(color, 0x00ffffff, 0) || broken(compare_color(color, 0x000000ff, 0)), + "(158,122) has color %08x\n", color); + color = get_surface_color(rt, 162, 122); + ok(compare_color(color, 0x000000ff, 0) || broken(compare_color(color, 0x0000ff00, 0)), + "(162,122) has color %08x\n", color); + + color = get_surface_color(rt, 318, 238); + ok(compare_color(color, 0x000000ff, 0) || broken(compare_color(color, 0x0000ff00, 0)), + "(318,238) has color %08x\n", color); + color = get_surface_color(rt, 322, 238); + ok(compare_color(color, 0x00ffffff, 0) || broken(compare_color(color, 0x0000ff00, 0)), + "(322,328) has color %08x\n", color); + color = get_surface_color(rt, 318, 242); + ok(compare_color(color, 0x00ffffff, 0) || broken(compare_color(color, 0x0000ff00, 0)), + "(318,242) has color %08x\n", color); + color = get_surface_color(rt, 322, 242); + ok(compare_color(color, 0x0000ff00, 0), "(322,242) has color %08x\n", color); + + color = get_surface_color(rt, 478, 358); + ok(compare_color(color, 0x0000ff00, 0), "(478,358 has color %08x\n", color); + color = get_surface_color(rt, 482, 358); + ok(compare_color(color, 0x00ffffff, 0) || broken(compare_color(color, 0x000000ff, 0)), + "(482,358) has color %08x\n", color); + color = get_surface_color(rt, 478, 362); + ok(compare_color(color, 0x00ffffff, 0) || broken(compare_color(color, 0x000000ff, 0)), + "(478,362) has color %08x\n", color); + color = get_surface_color(rt, 482, 362); + ok(compare_color(color, 0x00ffffff, 0) || broken(compare_color(color, 0x000000ff, 0)), + "(482,362) has color %08x\n", color); + + /* The clear rectangle is rendertarget absolute, not relative to the viewport. */ + hr = IDirect3DViewport_Clear(viewport, 1, &rect_full, D3DCLEAR_TARGET); + ok(hr == D3D_OK, "Failed to clear, hr %#x.\n", hr); + U1(rect[0]).x1 = 330; + U2(rect[0]).y1 = 250; + U3(rect[0]).x2 = 340; + U4(rect[0]).y2 = 260; + hr = IDirect3DViewport_Clear(viewport3, 1, &rect[0], D3DCLEAR_TARGET); + ok(hr == D3D_OK, "Failed to clear, hr %#x.\n", hr); + + color = get_surface_color(rt, 328, 248); + ok(compare_color(color, 0x00ffffff, 0), "(328,248) has color %08x\n", color); + color = get_surface_color(rt, 332, 248); + ok(compare_color(color, 0x00ffffff, 0), "(332,248) has color %08x\n", color); + color = get_surface_color(rt, 328, 252); + ok(compare_color(color, 0x00ffffff, 0), "(328,252) has color %08x\n", color); + color = get_surface_color(rt, 332, 252); + ok(compare_color(color, 0x0000ff00, 0), "(332,252) has color %08x\n", color); + + color = get_surface_color(rt, 338, 248); + ok(compare_color(color, 0x00ffffff, 0), "(338,248) has color %08x\n", color); + color = get_surface_color(rt, 342, 248); + ok(compare_color(color, 0x00ffffff, 0), "(342,248) has color %08x\n", color); + color = get_surface_color(rt, 338, 252); + ok(compare_color(color, 0x0000ff00, 0), "(338,252) has color %08x\n", color); + color = get_surface_color(rt, 342, 252); + ok(compare_color(color, 0x00ffffff, 0), "(342,252) has color %08x\n", color); + + color = get_surface_color(rt, 328, 258); + ok(compare_color(color, 0x00ffffff, 0), "(328,258 has color %08x\n", color); + color = get_surface_color(rt, 332, 258); + ok(compare_color(color, 0x0000ff00, 0), "(332,258) has color %08x\n", color); + color = get_surface_color(rt, 328, 262); + ok(compare_color(color, 0x00ffffff, 0), "(328,262) has color %08x\n", color); + color = get_surface_color(rt, 332, 262); + ok(compare_color(color, 0x00ffffff, 0), "(332,262) has color %08x\n", color); + + color = get_surface_color(rt, 338, 258); + ok(compare_color(color, 0x0000ff00, 0), "(328,258 has color %08x\n", color); + color = get_surface_color(rt, 342, 258); + ok(compare_color(color, 0x00ffffff, 0), "(332,258) has color %08x\n", color); + color = get_surface_color(rt, 338, 262); + ok(compare_color(color, 0x00ffffff, 0), "(328,262) has color %08x\n", color); + color = get_surface_color(rt, 342, 262); + ok(compare_color(color, 0x00ffffff, 0), "(332,262) has color %08x\n", color); + + /* COLORWRITEENABLE, SRGBWRITEENABLE and scissor rectangles do not exist in d3d1. */ + + IDirect3DViewport_Release(viewport3); + IDirect3DViewport_Release(viewport2); + IDirect3DViewport_Release(viewport); + IDirect3DMaterial_Release(white); + IDirect3DMaterial_Release(red); + IDirect3DMaterial_Release(green); + IDirect3DMaterial_Release(blue); + IDirectDrawSurface_Release(rt); + refcount = IDirect3DDevice_Release(device); + ok(!refcount, "Device has %u references left.\n", refcount); + refcount = IDirectDraw_Release(ddraw); + ok(!refcount, "Ddraw object has %u references left.\n", refcount); + DestroyWindow(window); +} + START_TEST(ddraw1) { DDDEVICEIDENTIFIER identifier; @@ -11012,4 +11210,5 @@ START_TEST(ddraw1) test_texture_load(); test_ck_operation(); test_depth_readback(); + test_clear(); } diff --git a/dlls/ddraw/tests/ddraw2.c b/dlls/ddraw/tests/ddraw2.c index 2186c314ac..0b51c99964 100644 --- a/dlls/ddraw/tests/ddraw2.c +++ b/dlls/ddraw/tests/ddraw2.c @@ -12287,6 +12287,202 @@ static void test_depth_readback(void) DestroyWindow(window); }
+static void test_clear(void) +{ + IDirectDraw2 *ddraw; + IDirect3DDevice2 *device; + IDirectDrawSurface *rt; + ULONG refcount; + HWND window; + HRESULT hr; + D3DRECT rect[2]; + D3DRECT rect_negneg, rect_full = {{0}, {0}, {640}, {480}}; + D3DCOLOR color; + IDirect3DViewport2 *viewport, *viewport2, *viewport3; + IDirect3DMaterial2 *white, *red, *green, *blue; + + window = create_window(); + ddraw = create_ddraw(); + ok(!!ddraw, "Failed to create a ddraw object.\n"); + if (!(device = create_device(ddraw, window, DDSCL_NORMAL))) + { + skip("Failed to create a 3D device, skipping test.\n"); + IDirectDraw2_Release(ddraw); + DestroyWindow(window); + return; + } + hr = IDirect3DDevice2_GetRenderTarget(device, &rt); + ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr); + + viewport = create_viewport(device, 0, 0, 640, 480); + hr = IDirect3DDevice2_SetCurrentViewport(device, viewport); + ok(SUCCEEDED(hr), "Failed to set current viewport, hr %#x.\n", hr); + + white = create_diffuse_material(device, 1.0f, 1.0f, 1.0f, 1.0f); + red = create_diffuse_material(device, 1.0f, 0.0f, 0.0f, 1.0f); + green = create_diffuse_material(device, 0.0f, 1.0f, 0.0f, 1.0f); + blue = create_diffuse_material(device, 0.0f, 0.0f, 1.0f, 1.0f); + + viewport_set_background(device, viewport, white); + hr = IDirect3DViewport2_Clear(viewport, 1, &rect_full, D3DCLEAR_TARGET); + ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr); + + /* Positive x, negative y. */ + U1(rect[0]).x1 = 0; + U2(rect[0]).y1 = 480; + U3(rect[0]).x2 = 320; + U4(rect[0]).y2 = 240; + + /* Positive x, positive y. */ + U1(rect[1]).x1 = 0; + U2(rect[1]).y1 = 0; + U3(rect[1]).x2 = 320; + U4(rect[1]).y2 = 240; + + /* Clear 2 rectangles with one call. Unlike d3d8/9, the refrast does not refuse negative + * rectangles, but it will not clear them either. */ + viewport_set_background(device, viewport, red); + hr = IDirect3DViewport2_Clear(viewport, 2, rect, D3DCLEAR_TARGET); + ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr); + + /* negative x, negative y. + * + * FIXME: WARP seems to clear the entire screen here.*/ + rect_negneg.x1 = 640; + rect_negneg.y1 = 240; + rect_negneg.x2 = 320; + rect_negneg.y2 = 0; + viewport_set_background(device, viewport, green); + hr = IDirect3DViewport2_Clear(viewport, 1, &rect_negneg, D3DCLEAR_TARGET); + ok(hr == D3D_OK, "Failed to clear, hr %#x.\n", hr); + + color = get_surface_color(rt, 160, 360); + ok(compare_color(color, 0x00ffffff, 0), "Clear rectangle 3(pos, neg) has color %08x.\n", color); + color = get_surface_color(rt, 160, 120); + ok(compare_color(color, 0x00ff0000, 0), "Clear rectangle 1(pos, pos) has color %08x.\n", color); + color = get_surface_color(rt, 480, 360); + ok(compare_color(color, 0x00ffffff, 0), "Clear rectangle 4(NULL) has color %08x.\n", color); + color = get_surface_color(rt, 480, 120); + ok(compare_color(color, 0x00ffffff, 0), "Clear rectangle 4(neg, neg) has color %08x.\n", color); + + /* Test how the viewport affects clears */ + viewport_set_background(device, viewport, white); + hr = IDirect3DViewport2_Clear(viewport, 1, &rect_full, D3DCLEAR_TARGET); + ok(hr == D3D_OK, "Failed to clear, hr %#x.\n", hr); + + viewport2 = create_viewport(device, 160, 120, 160, 120); + hr = IDirect3DDevice2_SetCurrentViewport(device, viewport2); + ok(SUCCEEDED(hr), "Failed to set current viewport, hr %#x.\n", hr); + + viewport_set_background(device, viewport2, blue); + hr = IDirect3DViewport2_Clear(viewport2, 1, &rect_full, D3DCLEAR_TARGET); + ok(hr == D3D_OK, "Failed to clear, hr %#x.\n", hr); + + viewport3 = create_viewport(device, 320, 240, 320, 240); + hr = IDirect3DDevice2_SetCurrentViewport(device, viewport3); + ok(SUCCEEDED(hr), "Failed to set current viewport, hr %#x.\n", hr); + + U1(rect[0]).x1 = 160; + U2(rect[0]).y1 = 120; + U3(rect[0]).x2 = 480; + U4(rect[0]).y2 = 360; + viewport_set_background(device, viewport3, green); + hr = IDirect3DViewport2_Clear(viewport3, 1, &rect[0], D3DCLEAR_TARGET); + ok(hr == D3D_OK, "Failed to clear, hr %#x.\n", hr); + + hr = IDirect3DDevice2_SetCurrentViewport(device, viewport); + ok(SUCCEEDED(hr), "Failed to set current viewport, hr %#x.\n", hr); + + color = get_surface_color(rt, 158, 118); + ok(compare_color(color, 0x00ffffff, 0), "(158,118) has color %08x\n", color); + color = get_surface_color(rt, 162, 118); + ok(compare_color(color, 0x00ffffff, 0), "(162,118) has color %08x\n", color); + color = get_surface_color(rt, 158, 122); + ok(compare_color(color, 0x00ffffff, 0), "(158,122) has color %08x\n", color); + color = get_surface_color(rt, 162, 122); + ok(compare_color(color, 0x000000ff, 0), "(162,122) has color %08x\n", color); + + color = get_surface_color(rt, 318, 238); + ok(compare_color(color, 0x000000ff, 0), "(318,238) has color %08x\n", color); + color = get_surface_color(rt, 322, 238); + ok(compare_color(color, 0x00ffffff, 0), "(322,328) has color %08x\n", color); + color = get_surface_color(rt, 318, 242); + ok(compare_color(color, 0x00ffffff, 0), "(318,242) has color %08x\n", color); + color = get_surface_color(rt, 322, 242); + ok(compare_color(color, 0x0000ff00, 0), "(322,242) has color %08x\n", color); + + color = get_surface_color(rt, 478, 358); + ok(compare_color(color, 0x0000ff00, 0), "(478,358 has color %08x\n", color); + color = get_surface_color(rt, 482, 358); + ok(compare_color(color, 0x00ffffff, 0), "(482,358) has color %08x\n", color); + color = get_surface_color(rt, 478, 362); + ok(compare_color(color, 0x00ffffff, 0), "(478,362) has color %08x\n", color); + color = get_surface_color(rt, 482, 362); + ok(compare_color(color, 0x00ffffff, 0), "(482,362) has color %08x\n", color); + + /* The clear rectangle is rendertarget absolute, not relative to the viewport. */ + hr = IDirect3DViewport2_Clear(viewport, 1, &rect_full, D3DCLEAR_TARGET); + ok(hr == D3D_OK, "Failed to clear, hr %#x.\n", hr); + U1(rect[0]).x1 = 330; + U2(rect[0]).y1 = 250; + U3(rect[0]).x2 = 340; + U4(rect[0]).y2 = 260; + hr = IDirect3DViewport2_Clear(viewport3, 1, &rect[0], D3DCLEAR_TARGET); + ok(hr == D3D_OK, "Failed to clear, hr %#x.\n", hr); + + color = get_surface_color(rt, 328, 248); + ok(compare_color(color, 0x00ffffff, 0), "(328,248) has color %08x\n", color); + color = get_surface_color(rt, 332, 248); + ok(compare_color(color, 0x00ffffff, 0), "(332,248) has color %08x\n", color); + color = get_surface_color(rt, 328, 252); + ok(compare_color(color, 0x00ffffff, 0), "(328,252) has color %08x\n", color); + color = get_surface_color(rt, 332, 252); + ok(compare_color(color, 0x0000ff00, 0), "(332,252) has color %08x\n", color); + + color = get_surface_color(rt, 338, 248); + ok(compare_color(color, 0x00ffffff, 0), "(338,248) has color %08x\n", color); + color = get_surface_color(rt, 342, 248); + ok(compare_color(color, 0x00ffffff, 0), "(342,248) has color %08x\n", color); + color = get_surface_color(rt, 338, 252); + ok(compare_color(color, 0x0000ff00, 0), "(338,252) has color %08x\n", color); + color = get_surface_color(rt, 342, 252); + ok(compare_color(color, 0x00ffffff, 0), "(342,252) has color %08x\n", color); + + color = get_surface_color(rt, 328, 258); + ok(compare_color(color, 0x00ffffff, 0), "(328,258 has color %08x\n", color); + color = get_surface_color(rt, 332, 258); + ok(compare_color(color, 0x0000ff00, 0), "(332,258) has color %08x\n", color); + color = get_surface_color(rt, 328, 262); + ok(compare_color(color, 0x00ffffff, 0), "(328,262) has color %08x\n", color); + color = get_surface_color(rt, 332, 262); + ok(compare_color(color, 0x00ffffff, 0), "(332,262) has color %08x\n", color); + + color = get_surface_color(rt, 338, 258); + ok(compare_color(color, 0x0000ff00, 0), "(328,258 has color %08x\n", color); + color = get_surface_color(rt, 342, 258); + ok(compare_color(color, 0x00ffffff, 0), "(332,258) has color %08x\n", color); + color = get_surface_color(rt, 338, 262); + ok(compare_color(color, 0x00ffffff, 0), "(328,262) has color %08x\n", color); + color = get_surface_color(rt, 342, 262); + ok(compare_color(color, 0x00ffffff, 0), "(332,262) has color %08x\n", color); + + /* COLORWRITEENABLE, SRGBWRITEENABLE and scissor rectangles do not exist in d3d2. */ + + IDirect3DViewport2_Release(viewport3); + IDirect3DViewport2_Release(viewport2); + IDirect3DViewport2_Release(viewport); + IDirect3DMaterial2_Release(white); + IDirect3DMaterial2_Release(red); + IDirect3DMaterial2_Release(green); + IDirect3DMaterial2_Release(blue); + IDirectDrawSurface_Release(rt); + refcount = IDirect3DDevice2_Release(device); + ok(!refcount, "Device has %u references left.\n", refcount); + refcount = IDirectDraw2_Release(ddraw); + ok(!refcount, "Ddraw object has %u references left.\n", refcount); + DestroyWindow(window); +} + START_TEST(ddraw2) { DDDEVICEIDENTIFIER identifier; @@ -12394,4 +12590,5 @@ START_TEST(ddraw2) test_surface_desc_size(); test_ck_operation(); test_depth_readback(); + test_clear(); } diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c index 4c1bd78eef..dde67d7a33 100644 --- a/dlls/ddraw/tests/ddraw4.c +++ b/dlls/ddraw/tests/ddraw4.c @@ -14355,6 +14355,181 @@ static void test_depth_readback(void) DestroyWindow(window); }
+static void test_clear(void) +{ + IDirect3DDevice3 *device; + IDirectDrawSurface4 *rt; + ULONG refcount; + HWND window; + HRESULT hr; + D3DRECT rect[2]; + D3DRECT rect_negneg, rect_full = {{0}, {0}, {640}, {480}}; + D3DCOLOR color; + IDirect3DViewport3 *viewport, *viewport2, *viewport3; + + window = create_window(); + if (!(device = create_device(window, DDSCL_NORMAL))) + { + skip("Failed to create 3D device.\n"); + DestroyWindow(window); + return; + } + + hr = IDirect3DDevice3_GetRenderTarget(device, &rt); + ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr); + + viewport = create_viewport(device, 0, 0, 640, 480); + hr = IDirect3DDevice3_SetCurrentViewport(device, viewport); + ok(SUCCEEDED(hr), "Failed to set current viewport, hr %#x.\n", hr); + + hr = IDirect3DViewport3_Clear2(viewport, 1, &rect_full, D3DCLEAR_TARGET, 0xffffffff, 0.0, 0); + ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr); + + /* Positive x, negative y. */ + U1(rect[0]).x1 = 0; + U2(rect[0]).y1 = 480; + U3(rect[0]).x2 = 320; + U4(rect[0]).y2 = 240; + + /* Positive x, positive y. */ + U1(rect[1]).x1 = 0; + U2(rect[1]).y1 = 0; + U3(rect[1]).x2 = 320; + U4(rect[1]).y2 = 240; + + /* Clear 2 rectangles with one call. Unlike d3d8/9, the refrast does not refuse negative + * rectangles, but it will not clear them either. */ + hr = IDirect3DViewport3_Clear2(viewport, 2, rect, D3DCLEAR_TARGET, 0xffff0000, 0.0, 0); + ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr); + + /* negative x, negative y. + * + * FIXME: WARP seems to clear the entire screen here.*/ + rect_negneg.x1 = 640; + rect_negneg.y1 = 240; + rect_negneg.x2 = 320; + rect_negneg.y2 = 0; + hr = IDirect3DViewport3_Clear2(viewport, 1, &rect_negneg, D3DCLEAR_TARGET, 0xff00ff00, 0.0, 0); + ok(hr == D3D_OK, "Failed to clear, hr %#x.\n", hr); + + color = get_surface_color(rt, 160, 360); + ok(compare_color(color, 0x00ffffff, 0), "Clear rectangle 3(pos, neg) has color %08x.\n", color); + color = get_surface_color(rt, 160, 120); + ok(compare_color(color, 0x00ff0000, 0), "Clear rectangle 1(pos, pos) has color %08x.\n", color); + color = get_surface_color(rt, 480, 360); + ok(compare_color(color, 0x00ffffff, 0), "Clear rectangle 4(NULL) has color %08x.\n", color); + color = get_surface_color(rt, 480, 120); + ok(compare_color(color, 0x00ffffff, 0), "Clear rectangle 4(neg, neg) has color %08x.\n", color); + + /* Test how the viewport affects clears */ + hr = IDirect3DViewport3_Clear2(viewport, 1, &rect_full, D3DCLEAR_TARGET, 0xffffffff, 0.0, 0); + ok(hr == D3D_OK, "Failed to clear, hr %#x.\n", hr); + + viewport2 = create_viewport(device, 160, 120, 160, 120); + hr = IDirect3DDevice3_SetCurrentViewport(device, viewport2); + ok(SUCCEEDED(hr), "Failed to set current viewport, hr %#x.\n", hr); + + hr = IDirect3DViewport3_Clear2(viewport2, 1, &rect_full, D3DCLEAR_TARGET, 0xff0000ff, 0.0, 0); + ok(hr == D3D_OK, "Failed to clear, hr %#x.\n", hr); + + viewport3 = create_viewport(device, 320, 240, 320, 240); + hr = IDirect3DDevice3_SetCurrentViewport(device, viewport3); + ok(SUCCEEDED(hr), "Failed to set current viewport, hr %#x.\n", hr); + + U1(rect[0]).x1 = 160; + U2(rect[0]).y1 = 120; + U3(rect[0]).x2 = 480; + U4(rect[0]).y2 = 360; + hr = IDirect3DViewport3_Clear2(viewport3, 1, &rect[0], D3DCLEAR_TARGET, 0xff00ff00, 0.0, 0); + ok(hr == D3D_OK, "Failed to clear, hr %#x.\n", hr); + + hr = IDirect3DDevice3_SetCurrentViewport(device, viewport); + ok(SUCCEEDED(hr), "Failed to set current viewport, hr %#x.\n", hr); + + color = get_surface_color(rt, 158, 118); + ok(compare_color(color, 0x00ffffff, 0), "(158,118) has color %08x\n", color); + color = get_surface_color(rt, 162, 118); + ok(compare_color(color, 0x00ffffff, 0), "(162,118) has color %08x\n", color); + color = get_surface_color(rt, 158, 122); + ok(compare_color(color, 0x00ffffff, 0), "(158,122) has color %08x\n", color); + color = get_surface_color(rt, 162, 122); + ok(compare_color(color, 0x000000ff, 0), "(162,122) has color %08x\n", color); + + color = get_surface_color(rt, 318, 238); + ok(compare_color(color, 0x000000ff, 0), "(318,238) has color %08x\n", color); + color = get_surface_color(rt, 322, 238); + ok(compare_color(color, 0x00ffffff, 0), "(322,328) has color %08x\n", color); + color = get_surface_color(rt, 318, 242); + ok(compare_color(color, 0x00ffffff, 0), "(318,242) has color %08x\n", color); + color = get_surface_color(rt, 322, 242); + ok(compare_color(color, 0x0000ff00, 0), "(322,242) has color %08x\n", color); + + color = get_surface_color(rt, 478, 358); + ok(compare_color(color, 0x0000ff00, 0), "(478,358 has color %08x\n", color); + color = get_surface_color(rt, 482, 358); + ok(compare_color(color, 0x00ffffff, 0), "(482,358) has color %08x\n", color); + color = get_surface_color(rt, 478, 362); + ok(compare_color(color, 0x00ffffff, 0), "(478,362) has color %08x\n", color); + color = get_surface_color(rt, 482, 362); + ok(compare_color(color, 0x00ffffff, 0), "(482,362) has color %08x\n", color); + + /* The clear rectangle is rendertarget absolute, not relative to the viewport. */ + hr = IDirect3DViewport3_Clear2(viewport, 1, &rect_full, D3DCLEAR_TARGET, 0xffffffff, 0.0, 0); + ok(hr == D3D_OK, "Failed to clear, hr %#x.\n", hr); + U1(rect[0]).x1 = 330; + U2(rect[0]).y1 = 250; + U3(rect[0]).x2 = 340; + U4(rect[0]).y2 = 260; + hr = IDirect3DViewport3_Clear2(viewport3, 1, &rect[0], D3DCLEAR_TARGET, 0xff00ff00, 0.0, 0); + ok(hr == D3D_OK, "Failed to clear, hr %#x.\n", hr); + + color = get_surface_color(rt, 328, 248); + ok(compare_color(color, 0x00ffffff, 0), "(328,248) has color %08x\n", color); + color = get_surface_color(rt, 332, 248); + ok(compare_color(color, 0x00ffffff, 0), "(332,248) has color %08x\n", color); + color = get_surface_color(rt, 328, 252); + ok(compare_color(color, 0x00ffffff, 0), "(328,252) has color %08x\n", color); + color = get_surface_color(rt, 332, 252); + ok(compare_color(color, 0x0000ff00, 0), "(332,252) has color %08x\n", color); + + color = get_surface_color(rt, 338, 248); + ok(compare_color(color, 0x00ffffff, 0), "(338,248) has color %08x\n", color); + color = get_surface_color(rt, 342, 248); + ok(compare_color(color, 0x00ffffff, 0), "(342,248) has color %08x\n", color); + color = get_surface_color(rt, 338, 252); + ok(compare_color(color, 0x0000ff00, 0), "(338,252) has color %08x\n", color); + color = get_surface_color(rt, 342, 252); + ok(compare_color(color, 0x00ffffff, 0), "(342,252) has color %08x\n", color); + + color = get_surface_color(rt, 328, 258); + ok(compare_color(color, 0x00ffffff, 0), "(328,258 has color %08x\n", color); + color = get_surface_color(rt, 332, 258); + ok(compare_color(color, 0x0000ff00, 0), "(332,258) has color %08x\n", color); + color = get_surface_color(rt, 328, 262); + ok(compare_color(color, 0x00ffffff, 0), "(328,262) has color %08x\n", color); + color = get_surface_color(rt, 332, 262); + ok(compare_color(color, 0x00ffffff, 0), "(332,262) has color %08x\n", color); + + color = get_surface_color(rt, 338, 258); + ok(compare_color(color, 0x0000ff00, 0), "(328,258 has color %08x\n", color); + color = get_surface_color(rt, 342, 258); + ok(compare_color(color, 0x00ffffff, 0), "(332,258) has color %08x\n", color); + color = get_surface_color(rt, 338, 262); + ok(compare_color(color, 0x00ffffff, 0), "(328,262) has color %08x\n", color); + color = get_surface_color(rt, 342, 262); + ok(compare_color(color, 0x00ffffff, 0), "(332,262) has color %08x\n", color); + + /* COLORWRITEENABLE, SRGBWRITEENABLE and scissor rectangles do not exist in d3d3. */ + + IDirect3DViewport3_Release(viewport3); + IDirect3DViewport3_Release(viewport2); + IDirect3DViewport3_Release(viewport); + IDirectDrawSurface4_Release(rt); + refcount = IDirect3DDevice3_Release(device); + ok(!refcount, "Device has %u references left.\n", refcount); + DestroyWindow(window); +} + START_TEST(ddraw4) { DDDEVICEIDENTIFIER identifier; @@ -14475,4 +14650,5 @@ START_TEST(ddraw4) test_compute_sphere_visibility(); test_map_synchronisation(); test_depth_readback(); + test_clear(); } diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c index d7355cf0ea..a9474f2444 100644 --- a/dlls/ddraw/tests/ddraw7.c +++ b/dlls/ddraw/tests/ddraw7.c @@ -13726,6 +13726,139 @@ static void test_depth_readback(void) DestroyWindow(window); }
+static void test_clear(void) +{ + IDirect3DDevice7 *device; + IDirectDrawSurface7 *rt; + ULONG refcount; + HWND window; + HRESULT hr; + D3DRECT rect[2]; + D3DRECT rect_negneg; + D3DCOLOR color; + D3DVIEWPORT7 vp, old_vp; + + window = create_window(); + if (!(device = create_device(window, DDSCL_NORMAL))) + { + skip("Failed to create 3D device.\n"); + DestroyWindow(window); + return; + } + + hr = IDirect3DDevice7_GetRenderTarget(device, &rt); + ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr); + + hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffffff, 0.0, 0); + ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr); + + /* Positive x, negative y. */ + U1(rect[0]).x1 = 0; + U2(rect[0]).y1 = 480; + U3(rect[0]).x2 = 320; + U4(rect[0]).y2 = 240; + + /* Positive x, positive y. */ + U1(rect[1]).x1 = 0; + U2(rect[1]).y1 = 0; + U3(rect[1]).x2 = 320; + U4(rect[1]).y2 = 240; + + /* Clear 2 rectangles with one call. Unlike d3d8/9, the refrast does not refuse negative + * rectangles, but it will not clear them either. */ + hr = IDirect3DDevice7_Clear(device, 2, rect, D3DCLEAR_TARGET, 0xffff0000, 0.0, 0); + ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr); + + /* negative x, negative y. + * + * FIXME: WARP seems to clear the entire screen here.*/ + rect_negneg.x1 = 640; + rect_negneg.y1 = 240; + rect_negneg.x2 = 320; + rect_negneg.y2 = 0; + hr = IDirect3DDevice7_Clear(device, 1, &rect_negneg, D3DCLEAR_TARGET, 0xff00ff00, 0.0, 0); + ok(hr == D3D_OK, "Failed to clear, hr %#x.\n", hr); + + color = get_surface_color(rt, 160, 360); + ok(compare_color(color, 0x00ffffff, 0), "Clear rectangle 3(pos, neg) has color %08x.\n", color); + color = get_surface_color(rt, 160, 120); + ok(compare_color(color, 0x00ff0000, 0), "Clear rectangle 1(pos, pos) has color %08x.\n", color); + color = get_surface_color(rt, 480, 360); + ok(compare_color(color, 0x00ffffff, 0), "Clear rectangle 4(NULL) has color %08x.\n", color); + color = get_surface_color(rt, 480, 120); + ok(compare_color(color, 0x00ffffff, 0), "Clear rectangle 4(neg, neg) has color %08x.\n", color); + + /* Test how the viewport affects clears */ + hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffffff, 0.0, 0); + ok(hr == D3D_OK, "Failed to clear, hr %#x.\n", hr); + hr = IDirect3DDevice7_GetViewport(device, &old_vp); + ok(hr == D3D_OK, "Failed to get viewport, hr %#x.\n", hr); + + vp.dwX = 160; + vp.dwY = 120; + vp.dwWidth = 160; + vp.dwHeight = 120; + vp.dvMinZ = 0.0; + vp.dvMaxZ = 1.0; + hr = IDirect3DDevice7_SetViewport(device, &vp); + ok(hr == D3D_OK, "Failed to set viewport, hr %#x.\n", hr); + hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff0000ff, 0.0, 0); + ok(hr == D3D_OK, "Failed to clear, hr %#x.\n", hr); + + vp.dwX = 320; + vp.dwY = 240; + vp.dwWidth = 320; + vp.dwHeight = 240; + vp.dvMinZ = 0.0; + vp.dvMaxZ = 1.0; + hr = IDirect3DDevice7_SetViewport(device, &vp); + ok(hr == D3D_OK, "Failed to set viewport, hr %#x.\n", hr); + + U1(rect[0]).x1 = 160; + U2(rect[0]).y1 = 120; + U3(rect[0]).x2 = 480; + U4(rect[0]).y2 = 360; + hr = IDirect3DDevice7_Clear(device, 1, &rect[0], D3DCLEAR_TARGET, 0xff00ff00, 0.0, 0); + ok(hr == D3D_OK, "Failed to clear, hr %#x.\n", hr); + + hr = IDirect3DDevice7_SetViewport(device, &old_vp); + ok(hr == D3D_OK, "Failed to set viewport, hr %#x.\n", hr); + + color = get_surface_color(rt, 158, 118); + ok(compare_color(color, 0x00ffffff, 0), "(158,118) has color %08x\n", color); + color = get_surface_color(rt, 162, 118); + ok(compare_color(color, 0x00ffffff, 0), "(162,118) has color %08x\n", color); + color = get_surface_color(rt, 158, 122); + ok(compare_color(color, 0x00ffffff, 0), "(158,122) has color %08x\n", color); + color = get_surface_color(rt, 162, 122); + ok(compare_color(color, 0x000000ff, 0), "(162,122) has color %08x\n", color); + + color = get_surface_color(rt, 318, 238); + ok(compare_color(color, 0x000000ff, 0), "(318,238) has color %08x\n", color); + color = get_surface_color(rt, 322, 238); + ok(compare_color(color, 0x00ffffff, 0), "(322,328) has color %08x\n", color); + color = get_surface_color(rt, 318, 242); + ok(compare_color(color, 0x00ffffff, 0), "(318,242) has color %08x\n", color); + color = get_surface_color(rt, 322, 242); + ok(compare_color(color, 0x0000ff00, 0), "(322,242) has color %08x\n", color); + + color = get_surface_color(rt, 478, 358); + ok(compare_color(color, 0x0000ff00, 0), "(478,358 has color %08x\n", color); + color = get_surface_color(rt, 482, 358); + ok(compare_color(color, 0x00ffffff, 0), "(482,358) has color %08x\n", color); + color = get_surface_color(rt, 478, 362); + ok(compare_color(color, 0x00ffffff, 0), "(478,362) has color %08x\n", color); + color = get_surface_color(rt, 482, 362); + ok(compare_color(color, 0x00ffffff, 0), "(482,362) has color %08x\n", color); + + /* COLORWRITEENABLE, SRGBWRITEENABLE and scissor rectangles do not exist in d3d7. */ + + IDirectDrawSurface7_Release(rt); + refcount = IDirect3DDevice7_Release(device); + ok(!refcount, "Device has %u references left.\n", refcount); + DestroyWindow(window); +} + START_TEST(ddraw7) { DDDEVICEIDENTIFIER2 identifier; @@ -13856,4 +13989,5 @@ START_TEST(ddraw7) test_clip_planes_limits(); test_map_synchronisation(); test_depth_readback(); + test_clear(); } diff --git a/dlls/ddraw/tests/visual.c b/dlls/ddraw/tests/visual.c index 4f6213354d..2cb1c89231 100644 --- a/dlls/ddraw/tests/visual.c +++ b/dlls/ddraw/tests/visual.c @@ -267,52 +267,6 @@ static void set_viewport_size(IDirect3DDevice7 *device) return; }
-static void clear_test(IDirect3DDevice7 *device) -{ - /* Tests the correctness of clearing parameters */ - HRESULT hr; - D3DRECT rect[2]; - D3DRECT rect_negneg; - DWORD color; - - hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffffff, 0.0, 0); - ok(hr == D3D_OK, "IDirect3DDevice7_Clear failed with %08x\n", hr); - - /* Positive x, negative y */ - U1(rect[0]).x1 = 0; - U2(rect[0]).y1 = 480; - U3(rect[0]).x2 = 320; - U4(rect[0]).y2 = 240; - - /* Positive x, positive y */ - U1(rect[1]).x1 = 0; - U2(rect[1]).y1 = 0; - U3(rect[1]).x2 = 320; - U4(rect[1]).y2 = 240; - /* Clear 2 rectangles with one call. Shows that a positive value is returned, but the negative rectangle - * is ignored, the positive is still cleared afterwards - */ - hr = IDirect3DDevice7_Clear(device, 2, rect, D3DCLEAR_TARGET, 0xffff0000, 0.0, 0); - ok(hr == D3D_OK, "IDirect3DDevice7_Clear failed with %08x\n", hr); - - /* negative x, negative y */ - U1(rect_negneg).x1 = 640; - U2(rect_negneg).y1 = 240; - U3(rect_negneg).x2 = 320; - U4(rect_negneg).y2 = 0; - hr = IDirect3DDevice7_Clear(device, 1, &rect_negneg, D3DCLEAR_TARGET, 0xff00ff00, 0.0, 0); - ok(hr == D3D_OK, "IDirect3DDevice7_Clear failed with %08x\n", hr); - - color = getPixelColor(device, 160, 360); /* lower left quad */ - ok(color == 0x00ffffff, "Clear rectangle 3(pos, neg) has color %08x\n", color); - color = getPixelColor(device, 160, 120); /* upper left quad */ - ok(color == 0x00ff0000, "Clear rectangle 1(pos, pos) has color %08x\n", color); - color = getPixelColor(device, 480, 360); /* lower right quad */ - ok(color == 0x00ffffff, "Clear rectangle 4(NULL) has color %08x\n", color); - color = getPixelColor(device, 480, 120); /* upper right quad */ - ok(color == 0x00ffffff, "Clear rectangle 4(neg, neg) has color %08x\n", color); -} - static void fog_test(IDirect3DDevice7 *device) { HRESULT hr; @@ -1681,7 +1635,6 @@ START_TEST(visual)
/* Now run the tests */ depth_clamp_test(Direct3DDevice); - clear_test(Direct3DDevice); fog_test(Direct3DDevice); offscreen_test(Direct3DDevice); test_blend(Direct3DDevice);
Signed-off-by: Stefan Dösinger stefan@codeweavers.com --- dlls/ddraw/tests/ddraw1.c | 28 ++++++++++++++++++++++------ dlls/ddraw/tests/ddraw2.c | 28 ++++++++++++++++++++++------ dlls/ddraw/tests/ddraw4.c | 26 ++++++++++++++++++++------ dlls/ddraw/tests/ddraw7.c | 26 ++++++++++++++++++++------ 4 files changed, 84 insertions(+), 24 deletions(-)
diff --git a/dlls/ddraw/tests/ddraw1.c b/dlls/ddraw/tests/ddraw1.c index 58703013c1..916680fa9c 100644 --- a/dlls/ddraw/tests/ddraw1.c +++ b/dlls/ddraw/tests/ddraw1.c @@ -10969,9 +10969,21 @@ static void test_clear(void) hr = IDirect3DViewport_Clear(viewport, 2, rect, D3DCLEAR_TARGET); ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+ color = get_surface_color(rt, 160, 360); + ok(compare_color(color, 0x00ffffff, 0), "Clear rectangle 3(pos, neg) has color %08x.\n", color); + color = get_surface_color(rt, 160, 120); + ok(compare_color(color, 0x00ff0000, 0), "Clear rectangle 1(pos, pos) has color %08x.\n", color); + color = get_surface_color(rt, 480, 360); + ok(compare_color(color, 0x00ffffff, 0), "Clear rectangle 4(NULL) has color %08x.\n", color); + color = get_surface_color(rt, 480, 120); + ok(compare_color(color, 0x00ffffff, 0), "Clear rectangle 4(neg, neg) has color %08x.\n", color); + + viewport_set_background(device, viewport, white); + hr = IDirect3DViewport_Clear(viewport, 1, &rect_full, D3DCLEAR_TARGET); + ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr); + /* negative x, negative y. - * - * FIXME: WARP seems to clear the entire screen here.*/ + * Also ignored, except on WARP, which clears the entire screen.*/ rect_negneg.x1 = 640; rect_negneg.y1 = 240; rect_negneg.x2 = 320; @@ -10981,13 +10993,17 @@ static void test_clear(void) ok(hr == D3D_OK, "Failed to clear, hr %#x.\n", hr);
color = get_surface_color(rt, 160, 360); - ok(compare_color(color, 0x00ffffff, 0), "Clear rectangle 3(pos, neg) has color %08x.\n", color); + ok(compare_color(color, 0x00ffffff, 0) || broken(compare_color(color, 0x0000ff00, 0)), + "Got unexpected color %08x.\n", color); color = get_surface_color(rt, 160, 120); - ok(compare_color(color, 0x00ff0000, 0), "Clear rectangle 1(pos, pos) has color %08x.\n", color); + ok(compare_color(color, 0x00ffffff, 0) || broken(compare_color(color, 0x0000ff00, 0)), + "Got unexpected color %08x.\n", color); color = get_surface_color(rt, 480, 360); - ok(compare_color(color, 0x00ffffff, 0), "Clear rectangle 4(NULL) has color %08x.\n", color); + ok(compare_color(color, 0x00ffffff, 0) || broken(compare_color(color, 0x0000ff00, 0)), + "Got unexpected color %08x.\n", color); color = get_surface_color(rt, 480, 120); - ok(compare_color(color, 0x00ffffff, 0), "Clear rectangle 4(neg, neg) has color %08x.\n", color); + ok(compare_color(color, 0x00ffffff, 0) || broken(compare_color(color, 0x0000ff00, 0)), + "Got unexpected color %08x.\n", color);
/* Test how the viewport affects clears */ viewport_set_background(device, viewport, white); diff --git a/dlls/ddraw/tests/ddraw2.c b/dlls/ddraw/tests/ddraw2.c index 0b51c99964..e7c81ca81f 100644 --- a/dlls/ddraw/tests/ddraw2.c +++ b/dlls/ddraw/tests/ddraw2.c @@ -12345,9 +12345,21 @@ static void test_clear(void) hr = IDirect3DViewport2_Clear(viewport, 2, rect, D3DCLEAR_TARGET); ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+ color = get_surface_color(rt, 160, 360); + ok(compare_color(color, 0x00ffffff, 0), "Clear rectangle 3(pos, neg) has color %08x.\n", color); + color = get_surface_color(rt, 160, 120); + ok(compare_color(color, 0x00ff0000, 0), "Clear rectangle 1(pos, pos) has color %08x.\n", color); + color = get_surface_color(rt, 480, 360); + ok(compare_color(color, 0x00ffffff, 0), "Clear rectangle 4(NULL) has color %08x.\n", color); + color = get_surface_color(rt, 480, 120); + ok(compare_color(color, 0x00ffffff, 0), "Clear rectangle 4(neg, neg) has color %08x.\n", color); + + viewport_set_background(device, viewport, white); + hr = IDirect3DViewport2_Clear(viewport, 1, &rect_full, D3DCLEAR_TARGET); + ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr); + /* negative x, negative y. - * - * FIXME: WARP seems to clear the entire screen here.*/ + * Also ignored, except on WARP, which clears the entire screen.*/ rect_negneg.x1 = 640; rect_negneg.y1 = 240; rect_negneg.x2 = 320; @@ -12357,13 +12369,17 @@ static void test_clear(void) ok(hr == D3D_OK, "Failed to clear, hr %#x.\n", hr);
color = get_surface_color(rt, 160, 360); - ok(compare_color(color, 0x00ffffff, 0), "Clear rectangle 3(pos, neg) has color %08x.\n", color); + ok(compare_color(color, 0x00ffffff, 0) || broken(compare_color(color, 0x0000ff00, 0)), + "Got unexpected color %08x.\n", color); color = get_surface_color(rt, 160, 120); - ok(compare_color(color, 0x00ff0000, 0), "Clear rectangle 1(pos, pos) has color %08x.\n", color); + ok(compare_color(color, 0x00ffffff, 0) || broken(compare_color(color, 0x0000ff00, 0)), + "Got unexpected color %08x.\n", color); color = get_surface_color(rt, 480, 360); - ok(compare_color(color, 0x00ffffff, 0), "Clear rectangle 4(NULL) has color %08x.\n", color); + ok(compare_color(color, 0x00ffffff, 0) || broken(compare_color(color, 0x0000ff00, 0)), + "Got unexpected color %08x.\n", color); color = get_surface_color(rt, 480, 120); - ok(compare_color(color, 0x00ffffff, 0), "Clear rectangle 4(neg, neg) has color %08x.\n", color); + ok(compare_color(color, 0x00ffffff, 0) || broken(compare_color(color, 0x0000ff00, 0)), + "Got unexpected color %08x.\n", color);
/* Test how the viewport affects clears */ viewport_set_background(device, viewport, white); diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c index dde67d7a33..dac0c0a350 100644 --- a/dlls/ddraw/tests/ddraw4.c +++ b/dlls/ddraw/tests/ddraw4.c @@ -14402,9 +14402,19 @@ static void test_clear(void) hr = IDirect3DViewport3_Clear2(viewport, 2, rect, D3DCLEAR_TARGET, 0xffff0000, 0.0, 0); ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+ color = get_surface_color(rt, 160, 360); + ok(compare_color(color, 0x00ffffff, 0), "Clear rectangle 3(pos, neg) has color %08x.\n", color); + color = get_surface_color(rt, 160, 120); + ok(compare_color(color, 0x00ff0000, 0), "Clear rectangle 1(pos, pos) has color %08x.\n", color); + color = get_surface_color(rt, 480, 360); + ok(compare_color(color, 0x00ffffff, 0), "Clear rectangle 4(NULL) has color %08x.\n", color); + color = get_surface_color(rt, 480, 120); + ok(compare_color(color, 0x00ffffff, 0), "Clear rectangle 4(neg, neg) has color %08x.\n", color); + + hr = IDirect3DViewport3_Clear2(viewport, 1, &rect_full, D3DCLEAR_TARGET, 0xffffffff, 0.0, 0); + ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr); /* negative x, negative y. - * - * FIXME: WARP seems to clear the entire screen here.*/ + * Also ignored, except on WARP, which clears the entire screen.*/ rect_negneg.x1 = 640; rect_negneg.y1 = 240; rect_negneg.x2 = 320; @@ -14413,13 +14423,17 @@ static void test_clear(void) ok(hr == D3D_OK, "Failed to clear, hr %#x.\n", hr);
color = get_surface_color(rt, 160, 360); - ok(compare_color(color, 0x00ffffff, 0), "Clear rectangle 3(pos, neg) has color %08x.\n", color); + ok(compare_color(color, 0x00ffffff, 0) || broken(compare_color(color, 0x0000ff00, 0)), + "Got unexpected color %08x.\n", color); color = get_surface_color(rt, 160, 120); - ok(compare_color(color, 0x00ff0000, 0), "Clear rectangle 1(pos, pos) has color %08x.\n", color); + ok(compare_color(color, 0x00ffffff, 0) || broken(compare_color(color, 0x0000ff00, 0)), + "Got unexpected color %08x.\n", color); color = get_surface_color(rt, 480, 360); - ok(compare_color(color, 0x00ffffff, 0), "Clear rectangle 4(NULL) has color %08x.\n", color); + ok(compare_color(color, 0x00ffffff, 0) || broken(compare_color(color, 0x0000ff00, 0)), + "Got unexpected color %08x.\n", color); color = get_surface_color(rt, 480, 120); - ok(compare_color(color, 0x00ffffff, 0), "Clear rectangle 4(neg, neg) has color %08x.\n", color); + ok(compare_color(color, 0x00ffffff, 0) || broken(compare_color(color, 0x0000ff00, 0)), + "Got unexpected color %08x.\n", color);
/* Test how the viewport affects clears */ hr = IDirect3DViewport3_Clear2(viewport, 1, &rect_full, D3DCLEAR_TARGET, 0xffffffff, 0.0, 0); diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c index a9474f2444..639e099cdd 100644 --- a/dlls/ddraw/tests/ddraw7.c +++ b/dlls/ddraw/tests/ddraw7.c @@ -13769,9 +13769,19 @@ static void test_clear(void) hr = IDirect3DDevice7_Clear(device, 2, rect, D3DCLEAR_TARGET, 0xffff0000, 0.0, 0); ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr);
+ color = get_surface_color(rt, 160, 360); + ok(compare_color(color, 0x00ffffff, 0), "Clear rectangle 3(pos, neg) has color %08x.\n", color); + color = get_surface_color(rt, 160, 120); + ok(compare_color(color, 0x00ff0000, 0), "Clear rectangle 1(pos, pos) has color %08x.\n", color); + color = get_surface_color(rt, 480, 360); + ok(compare_color(color, 0x00ffffff, 0), "Clear rectangle 4(NULL) has color %08x.\n", color); + color = get_surface_color(rt, 480, 120); + ok(compare_color(color, 0x00ffffff, 0), "Clear rectangle 4(neg, neg) has color %08x.\n", color); + + hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffffff, 0.0, 0); + ok(SUCCEEDED(hr), "Failed to clear, hr %#x.\n", hr); /* negative x, negative y. - * - * FIXME: WARP seems to clear the entire screen here.*/ + * Also ignored, except on WARP, which clears the entire screen.*/ rect_negneg.x1 = 640; rect_negneg.y1 = 240; rect_negneg.x2 = 320; @@ -13780,13 +13790,17 @@ static void test_clear(void) ok(hr == D3D_OK, "Failed to clear, hr %#x.\n", hr);
color = get_surface_color(rt, 160, 360); - ok(compare_color(color, 0x00ffffff, 0), "Clear rectangle 3(pos, neg) has color %08x.\n", color); + ok(compare_color(color, 0x00ffffff, 0) || broken(compare_color(color, 0x0000ff00, 0)), + "Got unexpected color %08x.\n", color); color = get_surface_color(rt, 160, 120); - ok(compare_color(color, 0x00ff0000, 0), "Clear rectangle 1(pos, pos) has color %08x.\n", color); + ok(compare_color(color, 0x00ffffff, 0) || broken(compare_color(color, 0x0000ff00, 0)), + "Got unexpected color %08x.\n", color); color = get_surface_color(rt, 480, 360); - ok(compare_color(color, 0x00ffffff, 0), "Clear rectangle 4(NULL) has color %08x.\n", color); + ok(compare_color(color, 0x00ffffff, 0) || broken(compare_color(color, 0x0000ff00, 0)), + "Got unexpected color %08x.\n", color); color = get_surface_color(rt, 480, 120); - ok(compare_color(color, 0x00ffffff, 0), "Clear rectangle 4(neg, neg) has color %08x.\n", color); + ok(compare_color(color, 0x00ffffff, 0) || broken(compare_color(color, 0x0000ff00, 0)), + "Got unexpected color %08x.\n", color);
/* Test how the viewport affects clears */ hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffffff, 0.0, 0);
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=35215
Your paranoid android.
=== w8 (32 bit ddraw4) === ddraw4.c:14416: Test failed: Clear rectangle 3(pos, neg) has color 0000ff00. ddraw4.c:14418: Test failed: Clear rectangle 1(pos, pos) has color 0000ff00. ddraw4.c:14420: Test failed: Clear rectangle 4(NULL) has color 0000ff00. ddraw4.c:14422: Test failed: Clear rectangle 4(neg, neg) has color 0000ff00.
=== w864 (32 bit ddraw4) === ddraw4.c:14416: Test failed: Clear rectangle 3(pos, neg) has color 0000ff00. ddraw4.c:14418: Test failed: Clear rectangle 1(pos, pos) has color 0000ff00. ddraw4.c:14420: Test failed: Clear rectangle 4(NULL) has color 0000ff00. ddraw4.c:14422: Test failed: Clear rectangle 4(neg, neg) has color 0000ff00.
=== w1064 (32 bit ddraw4) === ddraw4.c:14416: Test failed: Clear rectangle 3(pos, neg) has color 0000ff00. ddraw4.c:14418: Test failed: Clear rectangle 1(pos, pos) has color 0000ff00. ddraw4.c:14420: Test failed: Clear rectangle 4(NULL) has color 0000ff00. ddraw4.c:14422: Test failed: Clear rectangle 4(neg, neg) has color 0000ff00.
=== w8 (32 bit ddraw2) === ddraw2.c:12360: Test failed: Clear rectangle 3(pos, neg) has color 0000ff00. ddraw2.c:12362: Test failed: Clear rectangle 1(pos, pos) has color 0000ff00. ddraw2.c:12364: Test failed: Clear rectangle 4(NULL) has color 0000ff00. ddraw2.c:12366: Test failed: Clear rectangle 4(neg, neg) has color 0000ff00.
=== w864 (32 bit ddraw2) === ddraw2.c:12360: Test failed: Clear rectangle 3(pos, neg) has color 0000ff00. ddraw2.c:12362: Test failed: Clear rectangle 1(pos, pos) has color 0000ff00. ddraw2.c:12364: Test failed: Clear rectangle 4(NULL) has color 0000ff00. ddraw2.c:12366: Test failed: Clear rectangle 4(neg, neg) has color 0000ff00.
=== w1064 (32 bit ddraw2) === ddraw2.c:12360: Test failed: Clear rectangle 3(pos, neg) has color 0000ff00. ddraw2.c:12362: Test failed: Clear rectangle 1(pos, pos) has color 0000ff00. ddraw2.c:12364: Test failed: Clear rectangle 4(NULL) has color 0000ff00. ddraw2.c:12366: Test failed: Clear rectangle 4(neg, neg) has color 0000ff00.
=== w8 (32 bit ddraw1) === ddraw1.c:10984: Test failed: Clear rectangle 3(pos, neg) has color 0000ff00. ddraw1.c:10986: Test failed: Clear rectangle 1(pos, pos) has color 0000ff00. ddraw1.c:10988: Test failed: Clear rectangle 4(NULL) has color 0000ff00. ddraw1.c:10990: Test failed: Clear rectangle 4(neg, neg) has color 0000ff00.
=== w864 (32 bit ddraw1) === ddraw1.c:10984: Test failed: Clear rectangle 3(pos, neg) has color 0000ff00. ddraw1.c:10986: Test failed: Clear rectangle 1(pos, pos) has color 0000ff00. ddraw1.c:10988: Test failed: Clear rectangle 4(NULL) has color 0000ff00. ddraw1.c:10990: Test failed: Clear rectangle 4(neg, neg) has color 0000ff00.
=== w1064 (32 bit ddraw1) === ddraw1.c:10984: Test failed: Clear rectangle 3(pos, neg) has color 0000ff00. ddraw1.c:10986: Test failed: Clear rectangle 1(pos, pos) has color 0000ff00. ddraw1.c:10988: Test failed: Clear rectangle 4(NULL) has color 0000ff00. ddraw1.c:10990: Test failed: Clear rectangle 4(neg, neg) has color 0000ff00.
=== w8 (32 bit ddraw7) === ddraw7.c:13783: Test failed: Clear rectangle 3(pos, neg) has color 0000ff00. ddraw7.c:13785: Test failed: Clear rectangle 1(pos, pos) has color 0000ff00. ddraw7.c:13787: Test failed: Clear rectangle 4(NULL) has color 0000ff00. ddraw7.c:13789: Test failed: Clear rectangle 4(neg, neg) has color 0000ff00.
=== w864 (32 bit ddraw7) === ddraw7.c:13783: Test failed: Clear rectangle 3(pos, neg) has color 0000ff00. ddraw7.c:13785: Test failed: Clear rectangle 1(pos, pos) has color 0000ff00. ddraw7.c:13787: Test failed: Clear rectangle 4(NULL) has color 0000ff00. ddraw7.c:13789: Test failed: Clear rectangle 4(neg, neg) has color 0000ff00.
=== w1064 (32 bit ddraw7) === ddraw7.c:13783: Test failed: Clear rectangle 3(pos, neg) has color 0000ff00. ddraw7.c:13785: Test failed: Clear rectangle 1(pos, pos) has color 0000ff00. ddraw7.c:13787: Test failed: Clear rectangle 4(NULL) has color 0000ff00. ddraw7.c:13789: Test failed: Clear rectangle 4(neg, neg) has color 0000ff00.