Skip to content

Commit aa90bdb

Browse files
author
Paul Gofman
committed
ddraw: Correctly apply state when multiple devices are used.
CW-Bug-Id: #24604
1 parent 9642756 commit aa90bdb

5 files changed

Lines changed: 19 additions & 0 deletions

File tree

dlls/ddraw/ddraw_private.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ struct ddraw
118118
/* D3D things */
119119
HWND d3d_window;
120120
struct list d3ddevice_list;
121+
struct d3d_device *device_last_applied_state;
121122
int d3dversion;
122123

123124
/* Various HWNDs */

dlls/ddraw/device.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,9 @@ static ULONG WINAPI d3d_device_inner_Release(IUnknown *iface)
325325
if (This->recording)
326326
wined3d_stateblock_decref(This->recording);
327327

328+
if (This->ddraw->device_last_applied_state == This)
329+
This->ddraw->device_last_applied_state = NULL;
330+
328331
/* Releasing the render target below may release the last reference to the ddraw object. Detach
329332
* the device from it before so it doesn't try to save / restore state on the teared down device. */
330333
if (This->ddraw)
@@ -3441,6 +3444,11 @@ void d3d_device_sync_surfaces(struct d3d_device *device)
34413444

34423445
static void d3d_device_apply_state(struct d3d_device *device)
34433446
{
3447+
if (device->ddraw->device_last_applied_state != device)
3448+
{
3449+
wined3d_stateblock_savedstates_set_all(device->wined3d_device, device->state);
3450+
device->ddraw->device_last_applied_state = device;
3451+
}
34443452
wined3d_device_apply_stateblock(device->wined3d_device, device->state);
34453453
d3d_device_sync_surfaces(device);
34463454
}

dlls/wined3d/stateblock.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,13 @@ static void stateblock_savedstates_set_all(struct wined3d_saved_states *states,
286286
memset(states->vs_consts_f, 0xffu, sizeof(states->vs_consts_f));
287287
}
288288

289+
void CDECL wined3d_stateblock_savedstates_set_all(struct wined3d_device *device, struct wined3d_stateblock *stateblock)
290+
{
291+
const struct wined3d_d3d_info *d3d_info = &device->adapter->d3d_info;
292+
293+
stateblock_savedstates_set_all(&stateblock->changed, d3d_info->limits.vs_uniform_count, d3d_info->limits.ps_uniform_count);
294+
}
295+
289296
static void stateblock_savedstates_set_pixel(struct wined3d_saved_states *states, const DWORD num_constants)
290297
{
291298
DWORD texture_mask = 0;

dlls/wined3d/wined3d.spec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@
243243
@ cdecl wined3d_stateblock_init_contained_states(ptr)
244244
@ cdecl wined3d_stateblock_multiply_transform(ptr long ptr)
245245
@ cdecl wined3d_stateblock_reset(ptr)
246+
@ cdecl wined3d_stateblock_savedstates_set_all(ptr ptr)
246247
@ cdecl wined3d_stateblock_set_base_vertex_index(ptr long)
247248
@ cdecl wined3d_stateblock_set_clip_plane(ptr long ptr)
248249
@ cdecl wined3d_stateblock_set_index_buffer(ptr ptr long)

include/wine/wined3d.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2368,6 +2368,8 @@ ULONG __cdecl wined3d_depth_stencil_state_incref(struct wined3d_depth_stencil_st
23682368

23692369
HRESULT __cdecl wined3d_device_acquire_focus_window(struct wined3d_device *device, HWND window);
23702370
void __cdecl wined3d_device_apply_stateblock(struct wined3d_device *device, struct wined3d_stateblock *stateblock);
2371+
void __cdecl wined3d_stateblock_savedstates_set_all(struct wined3d_device *device, struct wined3d_stateblock *stateblock);
2372+
23712373
HRESULT __cdecl wined3d_device_begin_scene(struct wined3d_device *device);
23722374
HRESULT __cdecl wined3d_device_clear(struct wined3d_device *device, unsigned int rect_count, const RECT *rects,
23732375
uint32_t flags, const struct wined3d_color *color, float z, unsigned int stencil);

0 commit comments

Comments
 (0)