Module: wine Branch: master Commit: 430239b470cea02cb79e6b6b83784f8e18634909 URL: http://source.winehq.org/git/wine.git/?a=commit;h=430239b470cea02cb79e6b6b83...
Author: Stefan Dösinger stefandoesinger@gmx.at Date: Mon Jul 23 09:57:26 2007 +0200
ddraw: Some d3d-only code fixes.
Vertex declarations are a d3d feature, thus they should be destroyed before d3d is shut down in wined3d. The surface type should be reset afterwards to prevent avoid gl surface afterwards and before a new render target is created.
---
dlls/ddraw/ddraw.c | 22 ++++++++++++++-------- dlls/ddraw/main.c | 7 ------- dlls/ddraw/surface.c | 15 +++++++++++++++ 3 files changed, 29 insertions(+), 15 deletions(-)
diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c index ce591f1..c903ad4 100644 --- a/dlls/ddraw/ddraw.c +++ b/dlls/ddraw/ddraw.c @@ -252,14 +252,6 @@ IDirectDrawImpl_AddRef(IDirectDraw7 *iface) void IDirectDrawImpl_Destroy(IDirectDrawImpl *This) { - int i; - - for(i = 0; i < This->numConvertedDecls; i++) - { - IWineD3DVertexDeclaration_Release(This->decls[i].decl); - } - HeapFree(GetProcessHeap(), 0, This->decls); - /* Clear the cooplevel to restore window and display mode */ IDirectDraw7_SetCooperativeLevel(ICOM_INTERFACE(This, IDirectDraw7), NULL, @@ -3086,6 +3078,20 @@ IDirectDrawImpl_AttachD3DDevice(IDirectDrawImpl *This, return hr; }
+ This->declArraySize = 2; + This->decls = HeapAlloc(GetProcessHeap(), + HEAP_ZERO_MEMORY, + sizeof(*This->decls) * This->declArraySize); + if(!This->decls) + { + ERR("Error allocating an array for the converted vertex decls\n"); + This->declArraySize = 0; + hr = IWineD3DDevice_Uninit3D(This->wineD3DDevice, + D3D7CB_DestroyDepthStencilSurface, + D3D7CB_DestroySwapChain); + return E_OUTOFMEMORY; + } + /* Create an Index Buffer parent */ TRACE("(%p) Successfully initialized 3D\n", This); return DD_OK; diff --git a/dlls/ddraw/main.c b/dlls/ddraw/main.c index 2d28626..54b35dc 100644 --- a/dlls/ddraw/main.c +++ b/dlls/ddraw/main.c @@ -319,13 +319,6 @@ DDRAW_Create(const GUID *guid, list_init(&This->surface_list); list_add_head(&global_ddraw_list, &This->ddraw_list_entry);
- This->decls = HeapAlloc(GetProcessHeap(), 0, 0); - if(!This->decls) - { - ERR("Error allocating an empty array for the converted vertex decls\n"); - goto err_out; - } - /* Call QueryInterface to get the pointer to the requested interface. This also initializes * The required refcount */ diff --git a/dlls/ddraw/surface.c b/dlls/ddraw/surface.c index 1d61530..5dc823e 100644 --- a/dlls/ddraw/surface.c +++ b/dlls/ddraw/surface.c @@ -314,6 +314,13 @@ IDirectDrawSurfaceImpl_Release(IDirectDrawSurface7 *iface) /* Unset any index buffer, just to be sure */ IWineD3DDevice_SetIndices(ddraw->wineD3DDevice, NULL); IWineD3DDevice_SetDepthStencilSurface(ddraw->wineD3DDevice, NULL); + IWineD3DDevice_SetVertexDeclaration(ddraw->wineD3DDevice, NULL); + for(i = 0; i < ddraw->numConvertedDecls; i++) + { + IWineD3DVertexDeclaration_Release(ddraw->decls[i].decl); + } + HeapFree(GetProcessHeap(), 0, ddraw->decls); + ddraw->numConvertedDecls = 0;
if(IWineD3DDevice_Uninit3D(ddraw->wineD3DDevice, D3D7CB_DestroyDepthStencilSurface, D3D7CB_DestroySwapChain) != D3D_OK) { @@ -335,6 +342,14 @@ IDirectDrawSurfaceImpl_Release(IDirectDrawSurface7 *iface) ddraw->d3d_initialized = FALSE; ddraw->d3d_target = NULL;
+ /* Reset to the default surface implementation type. This is needed if apps use + * non render target surfaces and expect blits to work after destroying the render + * target. + * + * TODO: Recreate existing offscreen surfaces + */ + ddraw->ImplType = DefaultSurfaceType; + /* Write a trace because D3D unloading was the reason for many * crashes during development. */