ddraw: Properly flip through the swap chain in ddraw_surface7_Flip().

This commit is contained in:
Henri Verbeet 2013-12-05 10:34:18 +01:00 committed by Alexandre Julliard
parent 7524258aaf
commit ce09d3633a
5 changed files with 52 additions and 35 deletions

View File

@ -1209,26 +1209,43 @@ static HRESULT WINAPI ddraw_surface7_Flip(IDirectDrawSurface7 *iface, IDirectDra
return DDERR_NOTFLIPPABLE; return DDERR_NOTFLIPPABLE;
} }
} }
if (rt == dst_impl->wined3d_surface)
wined3d_device_set_render_target(dst_impl->ddraw->wined3d_device, 0, src_impl->wined3d_surface, FALSE);
wined3d_resource_set_parent(wined3d_surface_get_resource(src_impl->wined3d_surface), dst_impl);
dst_impl->wined3d_surface = src_impl->wined3d_surface;
wined3d_resource_set_parent(wined3d_texture_get_resource(src_impl->wined3d_texture),
wined3d_texture_get_parent(dst_impl->wined3d_texture));
dst_impl->wined3d_texture = src_impl->wined3d_texture;
} }
else else
{ {
if (FAILED(hr = ddraw_surface7_GetAttachedSurface(iface, &caps, &current))) for (current = iface;;)
{ {
ERR("Can't find a flip target\n"); if (FAILED(hr = ddraw_surface7_GetAttachedSurface(current, &caps, &current)))
wined3d_mutex_unlock(); {
return DDERR_NOTFLIPPABLE; /* Unchecked */ ERR("Can't find a flip target\n");
} wined3d_mutex_unlock();
src_impl = impl_from_IDirectDrawSurface7(current); return DDERR_NOTFLIPPABLE; /* Unchecked */
ddraw_surface7_Release(current); }
} ddraw_surface7_Release(current);
if (current == iface)
{
dst_impl = impl_from_IDirectDrawSurface7(iface);
break;
}
if (rt == dst_impl->wined3d_surface) src_impl = impl_from_IDirectDrawSurface7(current);
wined3d_device_set_render_target(dst_impl->ddraw->wined3d_device, 0, src_impl->wined3d_surface, FALSE); if (rt == dst_impl->wined3d_surface)
wined3d_resource_set_parent(wined3d_surface_get_resource(src_impl->wined3d_surface), dst_impl); wined3d_device_set_render_target(dst_impl->ddraw->wined3d_device, 0, src_impl->wined3d_surface, FALSE);
dst_impl->wined3d_surface = src_impl->wined3d_surface; wined3d_resource_set_parent(wined3d_surface_get_resource(src_impl->wined3d_surface), dst_impl);
wined3d_resource_set_parent(wined3d_texture_get_resource(src_impl->wined3d_texture), dst_impl->wined3d_surface = src_impl->wined3d_surface;
wined3d_texture_get_parent(dst_impl->wined3d_texture)); wined3d_resource_set_parent(wined3d_texture_get_resource(src_impl->wined3d_texture),
dst_impl->wined3d_texture = src_impl->wined3d_texture; wined3d_texture_get_parent(dst_impl->wined3d_texture));
dst_impl->wined3d_texture = src_impl->wined3d_texture;
dst_impl = src_impl;
}
}
/* We don't have to worry about potential texture bindings, since /* We don't have to worry about potential texture bindings, since
* flippable surfaces can never be textures. */ * flippable surfaces can never be textures. */

View File

@ -3803,10 +3803,10 @@ static void test_flip(void)
color = get_surface_color(backbuffer1, 320, 240); color = get_surface_color(backbuffer1, 320, 240);
/* The testbot seems to just copy the contents of one surface to all the /* The testbot seems to just copy the contents of one surface to all the
* others, instead of properly flipping. */ * others, instead of properly flipping. */
todo_wine ok(compare_color(color, 0x0000ff00, 1) || broken(sysmem_primary && compare_color(color, 0x000000ff, 1)), ok(compare_color(color, 0x0000ff00, 1) || broken(sysmem_primary && compare_color(color, 0x000000ff, 1)),
"Got unexpected color 0x%08x.\n", color); "Got unexpected color 0x%08x.\n", color);
color = get_surface_color(backbuffer2, 320, 240); color = get_surface_color(backbuffer2, 320, 240);
todo_wine ok(compare_color(color, 0x000000ff, 1), "Got unexpected color 0x%08x.\n", color); ok(compare_color(color, 0x000000ff, 1), "Got unexpected color 0x%08x.\n", color);
U5(fx).dwFillColor = 0xffff0000; U5(fx).dwFillColor = 0xffff0000;
hr = IDirectDrawSurface_Blt(backbuffer3, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx); hr = IDirectDrawSurface_Blt(backbuffer3, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
ok(SUCCEEDED(hr), "Failed to fill surface, hr %#x.\n", hr); ok(SUCCEEDED(hr), "Failed to fill surface, hr %#x.\n", hr);
@ -3814,10 +3814,10 @@ static void test_flip(void)
hr = IDirectDrawSurface_Flip(primary, NULL, DDFLIP_WAIT); hr = IDirectDrawSurface_Flip(primary, NULL, DDFLIP_WAIT);
ok(SUCCEEDED(hr), "Failed to flip, hr %#x.\n", hr); ok(SUCCEEDED(hr), "Failed to flip, hr %#x.\n", hr);
color = get_surface_color(backbuffer1, 320, 240); color = get_surface_color(backbuffer1, 320, 240);
todo_wine ok(compare_color(color, 0x000000ff, 1) || broken(sysmem_primary && compare_color(color, 0x00ff0000, 1)), ok(compare_color(color, 0x000000ff, 1) || broken(sysmem_primary && compare_color(color, 0x00ff0000, 1)),
"Got unexpected color 0x%08x.\n", color); "Got unexpected color 0x%08x.\n", color);
color = get_surface_color(backbuffer2, 320, 240); color = get_surface_color(backbuffer2, 320, 240);
todo_wine ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08x.\n", color); ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08x.\n", color);
U5(fx).dwFillColor = 0xff00ff00; U5(fx).dwFillColor = 0xff00ff00;
hr = IDirectDrawSurface_Blt(backbuffer3, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx); hr = IDirectDrawSurface_Blt(backbuffer3, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
ok(SUCCEEDED(hr), "Failed to fill surface, hr %#x.\n", hr); ok(SUCCEEDED(hr), "Failed to fill surface, hr %#x.\n", hr);
@ -3825,7 +3825,7 @@ static void test_flip(void)
hr = IDirectDrawSurface_Flip(primary, NULL, DDFLIP_WAIT); hr = IDirectDrawSurface_Flip(primary, NULL, DDFLIP_WAIT);
ok(SUCCEEDED(hr), "Failed to flip, hr %#x.\n", hr); ok(SUCCEEDED(hr), "Failed to flip, hr %#x.\n", hr);
color = get_surface_color(backbuffer1, 320, 240); color = get_surface_color(backbuffer1, 320, 240);
todo_wine ok(compare_color(color, 0x00ff0000, 1) || broken(sysmem_primary && compare_color(color, 0x0000ff00, 1)), ok(compare_color(color, 0x00ff0000, 1) || broken(sysmem_primary && compare_color(color, 0x0000ff00, 1)),
"Got unexpected color 0x%08x.\n", color); "Got unexpected color 0x%08x.\n", color);
color = get_surface_color(backbuffer2, 320, 240); color = get_surface_color(backbuffer2, 320, 240);
ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08x.\n", color); ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08x.\n", color);

View File

@ -4484,10 +4484,10 @@ static void test_flip(void)
color = get_surface_color(backbuffer1, 320, 240); color = get_surface_color(backbuffer1, 320, 240);
/* The testbot seems to just copy the contents of one surface to all the /* The testbot seems to just copy the contents of one surface to all the
* others, instead of properly flipping. */ * others, instead of properly flipping. */
todo_wine ok(compare_color(color, 0x0000ff00, 1) || broken(sysmem_primary && compare_color(color, 0x000000ff, 1)), ok(compare_color(color, 0x0000ff00, 1) || broken(sysmem_primary && compare_color(color, 0x000000ff, 1)),
"Got unexpected color 0x%08x.\n", color); "Got unexpected color 0x%08x.\n", color);
color = get_surface_color(backbuffer2, 320, 240); color = get_surface_color(backbuffer2, 320, 240);
todo_wine ok(compare_color(color, 0x000000ff, 1), "Got unexpected color 0x%08x.\n", color); ok(compare_color(color, 0x000000ff, 1), "Got unexpected color 0x%08x.\n", color);
U5(fx).dwFillColor = 0xffff0000; U5(fx).dwFillColor = 0xffff0000;
hr = IDirectDrawSurface_Blt(backbuffer3, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx); hr = IDirectDrawSurface_Blt(backbuffer3, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
ok(SUCCEEDED(hr), "Failed to fill surface, hr %#x.\n", hr); ok(SUCCEEDED(hr), "Failed to fill surface, hr %#x.\n", hr);
@ -4495,10 +4495,10 @@ static void test_flip(void)
hr = IDirectDrawSurface_Flip(primary, NULL, DDFLIP_WAIT); hr = IDirectDrawSurface_Flip(primary, NULL, DDFLIP_WAIT);
ok(SUCCEEDED(hr), "Failed to flip, hr %#x.\n", hr); ok(SUCCEEDED(hr), "Failed to flip, hr %#x.\n", hr);
color = get_surface_color(backbuffer1, 320, 240); color = get_surface_color(backbuffer1, 320, 240);
todo_wine ok(compare_color(color, 0x000000ff, 1) || broken(sysmem_primary && compare_color(color, 0x00ff0000, 1)), ok(compare_color(color, 0x000000ff, 1) || broken(sysmem_primary && compare_color(color, 0x00ff0000, 1)),
"Got unexpected color 0x%08x.\n", color); "Got unexpected color 0x%08x.\n", color);
color = get_surface_color(backbuffer2, 320, 240); color = get_surface_color(backbuffer2, 320, 240);
todo_wine ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08x.\n", color); ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08x.\n", color);
U5(fx).dwFillColor = 0xff00ff00; U5(fx).dwFillColor = 0xff00ff00;
hr = IDirectDrawSurface_Blt(backbuffer3, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx); hr = IDirectDrawSurface_Blt(backbuffer3, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
ok(SUCCEEDED(hr), "Failed to fill surface, hr %#x.\n", hr); ok(SUCCEEDED(hr), "Failed to fill surface, hr %#x.\n", hr);
@ -4506,7 +4506,7 @@ static void test_flip(void)
hr = IDirectDrawSurface_Flip(primary, NULL, DDFLIP_WAIT); hr = IDirectDrawSurface_Flip(primary, NULL, DDFLIP_WAIT);
ok(SUCCEEDED(hr), "Failed to flip, hr %#x.\n", hr); ok(SUCCEEDED(hr), "Failed to flip, hr %#x.\n", hr);
color = get_surface_color(backbuffer1, 320, 240); color = get_surface_color(backbuffer1, 320, 240);
todo_wine ok(compare_color(color, 0x00ff0000, 1) || broken(sysmem_primary && compare_color(color, 0x0000ff00, 1)), ok(compare_color(color, 0x00ff0000, 1) || broken(sysmem_primary && compare_color(color, 0x0000ff00, 1)),
"Got unexpected color 0x%08x.\n", color); "Got unexpected color 0x%08x.\n", color);
color = get_surface_color(backbuffer2, 320, 240); color = get_surface_color(backbuffer2, 320, 240);
ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08x.\n", color); ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08x.\n", color);

View File

@ -5088,10 +5088,10 @@ static void test_flip(void)
color = get_surface_color(backbuffer1, 320, 240); color = get_surface_color(backbuffer1, 320, 240);
/* The testbot seems to just copy the contents of one surface to all the /* The testbot seems to just copy the contents of one surface to all the
* others, instead of properly flipping. */ * others, instead of properly flipping. */
todo_wine ok(compare_color(color, 0x0000ff00, 1) || broken(sysmem_primary && compare_color(color, 0x000000ff, 1)), ok(compare_color(color, 0x0000ff00, 1) || broken(sysmem_primary && compare_color(color, 0x000000ff, 1)),
"Got unexpected color 0x%08x.\n", color); "Got unexpected color 0x%08x.\n", color);
color = get_surface_color(backbuffer2, 320, 240); color = get_surface_color(backbuffer2, 320, 240);
todo_wine ok(compare_color(color, 0x000000ff, 1), "Got unexpected color 0x%08x.\n", color); ok(compare_color(color, 0x000000ff, 1), "Got unexpected color 0x%08x.\n", color);
U5(fx).dwFillColor = 0xffff0000; U5(fx).dwFillColor = 0xffff0000;
hr = IDirectDrawSurface4_Blt(backbuffer3, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx); hr = IDirectDrawSurface4_Blt(backbuffer3, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
ok(SUCCEEDED(hr), "Failed to fill surface, hr %#x.\n", hr); ok(SUCCEEDED(hr), "Failed to fill surface, hr %#x.\n", hr);
@ -5099,10 +5099,10 @@ static void test_flip(void)
hr = IDirectDrawSurface4_Flip(primary, NULL, DDFLIP_WAIT); hr = IDirectDrawSurface4_Flip(primary, NULL, DDFLIP_WAIT);
ok(SUCCEEDED(hr), "Failed to flip, hr %#x.\n", hr); ok(SUCCEEDED(hr), "Failed to flip, hr %#x.\n", hr);
color = get_surface_color(backbuffer1, 320, 240); color = get_surface_color(backbuffer1, 320, 240);
todo_wine ok(compare_color(color, 0x000000ff, 1) || broken(sysmem_primary && compare_color(color, 0x00ff0000, 1)), ok(compare_color(color, 0x000000ff, 1) || broken(sysmem_primary && compare_color(color, 0x00ff0000, 1)),
"Got unexpected color 0x%08x.\n", color); "Got unexpected color 0x%08x.\n", color);
color = get_surface_color(backbuffer2, 320, 240); color = get_surface_color(backbuffer2, 320, 240);
todo_wine ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08x.\n", color); ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08x.\n", color);
U5(fx).dwFillColor = 0xff00ff00; U5(fx).dwFillColor = 0xff00ff00;
hr = IDirectDrawSurface4_Blt(backbuffer3, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx); hr = IDirectDrawSurface4_Blt(backbuffer3, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
ok(SUCCEEDED(hr), "Failed to fill surface, hr %#x.\n", hr); ok(SUCCEEDED(hr), "Failed to fill surface, hr %#x.\n", hr);
@ -5110,7 +5110,7 @@ static void test_flip(void)
hr = IDirectDrawSurface4_Flip(primary, NULL, DDFLIP_WAIT); hr = IDirectDrawSurface4_Flip(primary, NULL, DDFLIP_WAIT);
ok(SUCCEEDED(hr), "Failed to flip, hr %#x.\n", hr); ok(SUCCEEDED(hr), "Failed to flip, hr %#x.\n", hr);
color = get_surface_color(backbuffer1, 320, 240); color = get_surface_color(backbuffer1, 320, 240);
todo_wine ok(compare_color(color, 0x00ff0000, 1) || broken(sysmem_primary && compare_color(color, 0x0000ff00, 1)), ok(compare_color(color, 0x00ff0000, 1) || broken(sysmem_primary && compare_color(color, 0x0000ff00, 1)),
"Got unexpected color 0x%08x.\n", color); "Got unexpected color 0x%08x.\n", color);
color = get_surface_color(backbuffer2, 320, 240); color = get_surface_color(backbuffer2, 320, 240);
ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08x.\n", color); ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08x.\n", color);

View File

@ -4975,10 +4975,10 @@ static void test_flip(void)
color = get_surface_color(backbuffer1, 320, 240); color = get_surface_color(backbuffer1, 320, 240);
/* The testbot seems to just copy the contents of one surface to all the /* The testbot seems to just copy the contents of one surface to all the
* others, instead of properly flipping. */ * others, instead of properly flipping. */
todo_wine ok(compare_color(color, 0x0000ff00, 1) || broken(sysmem_primary && compare_color(color, 0x000000ff, 1)), ok(compare_color(color, 0x0000ff00, 1) || broken(sysmem_primary && compare_color(color, 0x000000ff, 1)),
"Got unexpected color 0x%08x.\n", color); "Got unexpected color 0x%08x.\n", color);
color = get_surface_color(backbuffer2, 320, 240); color = get_surface_color(backbuffer2, 320, 240);
todo_wine ok(compare_color(color, 0x000000ff, 1), "Got unexpected color 0x%08x.\n", color); ok(compare_color(color, 0x000000ff, 1), "Got unexpected color 0x%08x.\n", color);
U5(fx).dwFillColor = 0xffff0000; U5(fx).dwFillColor = 0xffff0000;
hr = IDirectDrawSurface7_Blt(backbuffer3, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx); hr = IDirectDrawSurface7_Blt(backbuffer3, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
ok(SUCCEEDED(hr), "Failed to fill surface, hr %#x.\n", hr); ok(SUCCEEDED(hr), "Failed to fill surface, hr %#x.\n", hr);
@ -4986,10 +4986,10 @@ static void test_flip(void)
hr = IDirectDrawSurface7_Flip(primary, NULL, DDFLIP_WAIT); hr = IDirectDrawSurface7_Flip(primary, NULL, DDFLIP_WAIT);
ok(SUCCEEDED(hr), "Failed to flip, hr %#x.\n", hr); ok(SUCCEEDED(hr), "Failed to flip, hr %#x.\n", hr);
color = get_surface_color(backbuffer1, 320, 240); color = get_surface_color(backbuffer1, 320, 240);
todo_wine ok(compare_color(color, 0x000000ff, 1) || broken(sysmem_primary && compare_color(color, 0x00ff0000, 1)), ok(compare_color(color, 0x000000ff, 1) || broken(sysmem_primary && compare_color(color, 0x00ff0000, 1)),
"Got unexpected color 0x%08x.\n", color); "Got unexpected color 0x%08x.\n", color);
color = get_surface_color(backbuffer2, 320, 240); color = get_surface_color(backbuffer2, 320, 240);
todo_wine ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08x.\n", color); ok(compare_color(color, 0x00ff0000, 1), "Got unexpected color 0x%08x.\n", color);
U5(fx).dwFillColor = 0xff00ff00; U5(fx).dwFillColor = 0xff00ff00;
hr = IDirectDrawSurface7_Blt(backbuffer3, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx); hr = IDirectDrawSurface7_Blt(backbuffer3, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
ok(SUCCEEDED(hr), "Failed to fill surface, hr %#x.\n", hr); ok(SUCCEEDED(hr), "Failed to fill surface, hr %#x.\n", hr);
@ -4997,7 +4997,7 @@ static void test_flip(void)
hr = IDirectDrawSurface7_Flip(primary, NULL, DDFLIP_WAIT); hr = IDirectDrawSurface7_Flip(primary, NULL, DDFLIP_WAIT);
ok(SUCCEEDED(hr), "Failed to flip, hr %#x.\n", hr); ok(SUCCEEDED(hr), "Failed to flip, hr %#x.\n", hr);
color = get_surface_color(backbuffer1, 320, 240); color = get_surface_color(backbuffer1, 320, 240);
todo_wine ok(compare_color(color, 0x00ff0000, 1) || broken(sysmem_primary && compare_color(color, 0x0000ff00, 1)), ok(compare_color(color, 0x00ff0000, 1) || broken(sysmem_primary && compare_color(color, 0x0000ff00, 1)),
"Got unexpected color 0x%08x.\n", color); "Got unexpected color 0x%08x.\n", color);
color = get_surface_color(backbuffer2, 320, 240); color = get_surface_color(backbuffer2, 320, 240);
ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08x.\n", color); ok(compare_color(color, 0x0000ff00, 1), "Got unexpected color 0x%08x.\n", color);