Commit 430239b4 authored by Stefan Dösinger's avatar Stefan Dösinger Committed by Alexandre Julliard

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.
parent 0c028511
......@@ -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;
......
......@@ -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
*/
......
......@@ -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.
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment