Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/ddraw/ddraw.c | 9 +++++++++ dlls/ddraw/ddraw_private.h | 4 +++- dlls/ddraw/device.c | 6 +++++- dlls/ddraw/surface.c | 1 + 4 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c index 2c7619016e..69ef612cd4 100644 --- a/dlls/ddraw/ddraw.c +++ b/dlls/ddraw/ddraw.c @@ -422,6 +422,7 @@ static void ddraw_destroy(struct ddraw *This)
if (This->wined3d_swapchain) ddraw_destroy_swapchain(This); + wined3d_stateblock_decref(This->state); wined3d_device_decref(This->wined3d_device); wined3d_decref(This->wined3d);
@@ -5025,5 +5026,13 @@ HRESULT ddraw_init(struct ddraw *ddraw, DWORD flags, enum wined3d_device_type de
list_init(&ddraw->surface_list);
+ if (FAILED(hr = wined3d_stateblock_create(ddraw->wined3d_device, WINED3D_SBT_PRIMARY, &ddraw->state))) + { + ERR("Failed to create the primary stateblock, hr %#x.\n", hr); + wined3d_device_decref(ddraw->wined3d_device); + wined3d_decref(ddraw->wined3d); + return hr; + } + return DD_OK; } diff --git a/dlls/ddraw/ddraw_private.h b/dlls/ddraw/ddraw_private.h index 771b2a44d1..4ecd83d006 100644 --- a/dlls/ddraw/ddraw_private.h +++ b/dlls/ddraw/ddraw_private.h @@ -127,6 +127,8 @@ struct ddraw /* FVF management */ struct FvfToDecl *decls; UINT numConvertedDecls, declArraySize; + + struct wined3d_stateblock *state; };
#define DDRAW_WINDOW_CLASS_NAME "DirectDrawDeviceWnd" @@ -351,7 +353,7 @@ struct d3d_device
struct wined3d_vec4 user_clip_planes[D3DMAXUSERCLIPPLANES];
- struct wined3d_stateblock *recording; + struct wined3d_stateblock *recording, *state, *update_state; };
HRESULT d3d_device_create(struct ddraw *ddraw, struct ddraw_surface *target, IUnknown *rt_iface, diff --git a/dlls/ddraw/device.c b/dlls/ddraw/device.c index 43e5d0aa92..9ea7cd7caf 100644 --- a/dlls/ddraw/device.c +++ b/dlls/ddraw/device.c @@ -5620,7 +5620,7 @@ static HRESULT d3d_device7_BeginStateBlock(IDirect3DDevice7 *iface) return D3DERR_INBEGINSTATEBLOCK; } if (SUCCEEDED(hr = wined3d_device_begin_stateblock(device->wined3d_device, &stateblock))) - device->recording = stateblock; + device->update_state = device->recording = stateblock; wined3d_mutex_unlock();
return hr_ddraw_from_wined3d(hr); @@ -5688,6 +5688,7 @@ static HRESULT d3d_device7_EndStateBlock(IDirect3DDevice7 *iface, DWORD *statebl } wined3d_sb = device->recording; device->recording = NULL; + device->update_state = device->state;
h = ddraw_allocate_handle(&device->handle_table, wined3d_sb, DDRAW_HANDLE_STATEBLOCK); if (h == DDRAW_INVALID_HANDLE) @@ -6978,12 +6979,15 @@ static HRESULT d3d_device_init(struct d3d_device *device, struct ddraw *ddraw, /* This is for convenience. */ device->wined3d_device = ddraw->wined3d_device; wined3d_device_incref(ddraw->wined3d_device); + device->update_state = device->state = ddraw->state; + wined3d_stateblock_incref(ddraw->state);
/* Render to the back buffer */ if (FAILED(hr = wined3d_device_set_rendertarget_view(ddraw->wined3d_device, 0, ddraw_surface_get_rendertarget_view(target), TRUE))) { ERR("Failed to set render target, hr %#x.\n", hr); + wined3d_stateblock_decref(device->state); ddraw_handle_table_destroy(&device->handle_table); return hr; } diff --git a/dlls/ddraw/surface.c b/dlls/ddraw/surface.c index 6c27d8c26c..769b5a7576 100644 --- a/dlls/ddraw/surface.c +++ b/dlls/ddraw/surface.c @@ -6081,6 +6081,7 @@ HRESULT ddraw_surface_create(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_ if (ddraw->d3ddevice->recording) wined3d_stateblock_decref(ddraw->d3ddevice->recording); ddraw->d3ddevice->recording = NULL; + ddraw->d3ddevice->update_state = ddraw->d3ddevice->state; }
wined3d_device_set_render_state(ddraw->wined3d_device, WINED3D_RS_ZENABLE,