Module: wine Branch: master Commit: df446ae4fe51f6c38622accc20e97e80ea7a885f URL: http://source.winehq.org/git/wine.git/?a=commit;h=df446ae4fe51f6c38622accc20...
Author: Henri Verbeet hverbeet@codeweavers.com Date: Sun Dec 4 15:50:12 2011 +0100
wined3d: Create the device state block when the device is created.
---
dlls/wined3d/device.c | 61 +++++++++++++++++++++--------------------------- 1 files changed, 27 insertions(+), 34 deletions(-)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 1226390..e96e3c4 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -843,8 +843,19 @@ ULONG CDECL wined3d_device_decref(struct wined3d_device *device)
if (!refcount) { + struct wined3d_stateblock *stateblock; UINT i;
+ if (wined3d_stateblock_decref(device->updateStateBlock) + && device->updateStateBlock != device->stateBlock) + FIXME("Something's still holding the update stateblock.\n"); + device->updateStateBlock = NULL; + + stateblock = device->stateBlock; + device->stateBlock = NULL; + if (wined3d_stateblock_decref(stateblock)) + FIXME("Something's still holding the stateblock.\n"); + for (i = 0; i < sizeof(device->multistate_funcs) / sizeof(device->multistate_funcs[0]); ++i) { HeapFree(GetProcessHeap(), 0, device->multistate_funcs[i]); @@ -1214,18 +1225,6 @@ HRESULT CDECL wined3d_device_init_3d(struct wined3d_device *device, if (!device->adapter->opengl) return WINED3DERR_INVALIDCALL;
- TRACE("Creating stateblock.\n"); - hr = wined3d_stateblock_create(device, WINED3DSBT_INIT, &device->stateBlock); - if (FAILED(hr)) - { - WARN("Failed to create stateblock\n"); - goto err_out; - } - - TRACE("Created stateblock %p.\n", device->stateBlock); - device->updateStateBlock = device->stateBlock; - wined3d_stateblock_incref(device->updateStateBlock); - device->valid_rt_mask = 0; for (i = 0; i < gl_info->limits.buffers; ++i) device->valid_rt_mask |= (1 << i); @@ -1360,11 +1359,6 @@ err_out: device->swapchain_count = 0; if (swapchain) wined3d_swapchain_decref(swapchain); - if (device->stateBlock) - { - wined3d_stateblock_decref(device->stateBlock); - device->stateBlock = NULL; - } if (device->blit_priv) device->blitter->free_private(device); if (device->fragment_priv) @@ -1472,23 +1466,6 @@ HRESULT CDECL wined3d_device_uninit_3d(struct wined3d_device *device) device->depth_blt_texture = 0; }
- /* Release the update stateblock */ - if (wined3d_stateblock_decref(device->updateStateBlock)) - { - if (device->updateStateBlock != device->stateBlock) - FIXME("Something's still holding the update stateblock.\n"); - } - device->updateStateBlock = NULL; - - { - struct wined3d_stateblock *stateblock = device->stateBlock; - device->stateBlock = NULL; - - /* Release the stateblock */ - if (wined3d_stateblock_decref(stateblock)) - FIXME("Something's still holding the stateblock.\n"); - } - /* Destroy the shader backend. Note that this has to happen after all shaders are destroyed. */ device->blitter->free_private(device); device->frag_pipe->free_private(device); @@ -5980,6 +5957,22 @@ HRESULT device_init(struct wined3d_device *device, struct wined3d *wined3d, } device->blitter = adapter->blitter;
+ hr = wined3d_stateblock_create(device, WINED3DSBT_INIT, &device->stateBlock); + if (FAILED(hr)) + { + WARN("Failed to create stateblock.\n"); + for (i = 0; i < sizeof(device->multistate_funcs) / sizeof(device->multistate_funcs[0]); ++i) + { + HeapFree(GetProcessHeap(), 0, device->multistate_funcs[i]); + } + wined3d_decref(device->wined3d); + return hr; + } + + TRACE("Created stateblock %p.\n", device->stateBlock); + device->updateStateBlock = device->stateBlock; + wined3d_stateblock_incref(device->updateStateBlock); + return WINED3D_OK; }