From: Paul Gofman pgofman@codeweavers.com
--- dlls/ddraw/ddraw_private.h | 1 + dlls/ddraw/device.c | 8 ++++++++ dlls/ddraw/tests/ddraw2.c | 2 +- dlls/ddraw/tests/ddraw4.c | 2 +- dlls/ddraw/tests/ddraw7.c | 2 +- dlls/wined3d/stateblock.c | 7 +++++++ dlls/wined3d/wined3d.spec | 1 + include/wine/wined3d.h | 2 ++ 8 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/dlls/ddraw/ddraw_private.h b/dlls/ddraw/ddraw_private.h index 882ff4c0708..bd1df8e1b82 100644 --- a/dlls/ddraw/ddraw_private.h +++ b/dlls/ddraw/ddraw_private.h @@ -114,6 +114,7 @@ struct ddraw /* D3D things */ HWND d3d_window; struct list d3ddevice_list; + struct d3d_device *device_last_applied_state; int d3dversion;
/* Various HWNDs */ diff --git a/dlls/ddraw/device.c b/dlls/ddraw/device.c index 067dbf63485..e3c3f7197ea 100644 --- a/dlls/ddraw/device.c +++ b/dlls/ddraw/device.c @@ -325,6 +325,9 @@ static ULONG WINAPI d3d_device_inner_Release(IUnknown *iface) if (This->recording) wined3d_stateblock_decref(This->recording);
+ if (This->ddraw->device_last_applied_state == This) + This->ddraw->device_last_applied_state = NULL; + /* Releasing the render target below may release the last reference to the ddraw object. Detach * the device from it before so it doesn't try to save / restore state on the teared down device. */ if (This->ddraw) @@ -3451,6 +3454,11 @@ void d3d_device_sync_surfaces(struct d3d_device *device)
void d3d_device_apply_state(struct d3d_device *device, BOOL clear_state) { + if (device->ddraw->device_last_applied_state != device) + { + wined3d_stateblock_savedstates_set_all(device->wined3d_device, device->state); + device->ddraw->device_last_applied_state = device; + } if (clear_state) wined3d_stateblock_apply_clear_state(device->state, device->wined3d_device); else diff --git a/dlls/ddraw/tests/ddraw2.c b/dlls/ddraw/tests/ddraw2.c index e0818c5f62b..2336f09032d 100644 --- a/dlls/ddraw/tests/ddraw2.c +++ b/dlls/ddraw/tests/ddraw2.c @@ -16709,7 +16709,7 @@ static void test_multiple_devices(void) ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr); hr = IDirect3DDevice2_EndScene(device); colour = get_surface_color(surface, 320, 240); - todo_wine ok(colour == 0x0000ff, "got %#lx.\n", colour); + ok(colour == 0x0000ff, "got %#lx.\n", colour);
IDirect3DTexture2_Release(texture2); IDirect3DTexture2_Release(texture); diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c index 605d70d4b6d..88fe35e5ebc 100644 --- a/dlls/ddraw/tests/ddraw4.c +++ b/dlls/ddraw/tests/ddraw4.c @@ -19715,7 +19715,7 @@ static void test_multiple_devices(void) ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr); hr = IDirect3DDevice3_EndScene(device); colour = get_surface_color(surface, 320, 240); - todo_wine ok(colour == 0x0000ff, "got %#lx.\n", colour); + ok(colour == 0x0000ff, "got %#lx.\n", colour);
IDirect3DMaterial3_Release(material); IDirect3DViewport3_Release(viewport); diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c index f10c39f40ff..6a173f64f67 100644 --- a/dlls/ddraw/tests/ddraw7.c +++ b/dlls/ddraw/tests/ddraw7.c @@ -20176,7 +20176,7 @@ static void test_multiple_devices(void) ok(hr == DD_OK, "Got unexpected hr %#lx.\n", hr); hr = IDirect3DDevice7_EndScene(device); colour = get_surface_color(surface, 320, 240); - todo_wine ok(colour == 0x0000ff, "got %#lx.\n", colour); + ok(colour == 0x0000ff, "got %#lx.\n", colour);
refcount = IDirect3DDevice3_Release(device); ok(!refcount, "Device has %lu references left.\n", refcount); diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c index 80c1a6ea5b7..954b0f76547 100644 --- a/dlls/wined3d/stateblock.c +++ b/dlls/wined3d/stateblock.c @@ -309,6 +309,13 @@ static void stateblock_savedstates_set_all(struct wined3d_saved_states *states, memset(states->vs_consts_f, 0xffu, sizeof(states->vs_consts_f)); }
+void CDECL wined3d_stateblock_savedstates_set_all(struct wined3d_device *device, struct wined3d_stateblock *stateblock) +{ + const struct wined3d_d3d_info *d3d_info = &device->adapter->d3d_info; + + stateblock_savedstates_set_all(&stateblock->changed, d3d_info->limits.vs_uniform_count, d3d_info->limits.ps_uniform_count); +} + static void stateblock_savedstates_set_pixel(struct wined3d_saved_states *states, const DWORD num_constants) { DWORD texture_mask = 0; diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec index 16c7624eb9c..846317a824c 100644 --- a/dlls/wined3d/wined3d.spec +++ b/dlls/wined3d/wined3d.spec @@ -245,6 +245,7 @@ @ cdecl wined3d_stateblock_init_contained_states(ptr) @ cdecl wined3d_stateblock_multiply_transform(ptr long ptr) @ cdecl wined3d_stateblock_reset(ptr) +@ cdecl wined3d_stateblock_savedstates_set_all(ptr ptr) @ cdecl wined3d_stateblock_set_base_vertex_index(ptr long) @ cdecl wined3d_stateblock_set_clip_plane(ptr long ptr) @ cdecl wined3d_stateblock_set_index_buffer(ptr ptr long) diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h index b9ae23bac16..36163d50af5 100644 --- a/include/wine/wined3d.h +++ b/include/wine/wined3d.h @@ -2369,6 +2369,8 @@ ULONG __cdecl wined3d_depth_stencil_state_incref(struct wined3d_depth_stencil_st
HRESULT __cdecl wined3d_device_acquire_focus_window(struct wined3d_device *device, HWND window); void __cdecl wined3d_device_apply_stateblock(struct wined3d_device *device, struct wined3d_stateblock *stateblock); +void __cdecl wined3d_stateblock_savedstates_set_all(struct wined3d_device *device, struct wined3d_stateblock *stateblock); + HRESULT __cdecl wined3d_device_begin_scene(struct wined3d_device *device); HRESULT __cdecl wined3d_device_clear(struct wined3d_device *device, unsigned int rect_count, const RECT *rects, uint32_t flags, const struct wined3d_color *color, float z, unsigned int stencil);