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

ddraw: Hold the lock in IDirect3DVertexBuffer methods.

parent 9aab44de
...@@ -165,6 +165,7 @@ IDirect3DVertexBufferImpl_Release(IDirect3DVertexBuffer7 *iface) ...@@ -165,6 +165,7 @@ IDirect3DVertexBufferImpl_Release(IDirect3DVertexBuffer7 *iface)
IWineD3DVertexBuffer *curVB = NULL; IWineD3DVertexBuffer *curVB = NULL;
UINT offset, stride; UINT offset, stride;
EnterCriticalSection(&ddraw_cs);
/* D3D7 Vertex buffers don't stay bound in the device, they are passed as a parameter /* D3D7 Vertex buffers don't stay bound in the device, they are passed as a parameter
* to drawPrimitiveVB. DrawPrimitiveVB sets them as the stream source in wined3d, * to drawPrimitiveVB. DrawPrimitiveVB sets them as the stream source in wined3d,
* and they should get unset there before they are destroyed * and they should get unset there before they are destroyed
...@@ -189,7 +190,9 @@ IDirect3DVertexBufferImpl_Release(IDirect3DVertexBuffer7 *iface) ...@@ -189,7 +190,9 @@ IDirect3DVertexBufferImpl_Release(IDirect3DVertexBuffer7 *iface)
IWineD3DVertexDeclaration_Release(This->wineD3DVertexDeclaration); IWineD3DVertexDeclaration_Release(This->wineD3DVertexDeclaration);
IWineD3DVertexBuffer_Release(This->wineD3DVertexBuffer); IWineD3DVertexBuffer_Release(This->wineD3DVertexBuffer);
LeaveCriticalSection(&ddraw_cs);
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);
return 0; return 0;
} }
return ref; return ref;
...@@ -238,6 +241,7 @@ IDirect3DVertexBufferImpl_Lock(IDirect3DVertexBuffer7 *iface, ...@@ -238,6 +241,7 @@ IDirect3DVertexBufferImpl_Lock(IDirect3DVertexBuffer7 *iface,
HRESULT hr; HRESULT hr;
TRACE("(%p)->(%08x,%p,%p)\n", This, Flags, Data, Size); TRACE("(%p)->(%08x,%p,%p)\n", This, Flags, Data, Size);
EnterCriticalSection(&ddraw_cs);
if(Size) if(Size)
{ {
/* Get the size, for returning it, and for locking */ /* Get the size, for returning it, and for locking */
...@@ -251,11 +255,13 @@ IDirect3DVertexBufferImpl_Lock(IDirect3DVertexBuffer7 *iface, ...@@ -251,11 +255,13 @@ IDirect3DVertexBufferImpl_Lock(IDirect3DVertexBuffer7 *iface,
*Size = Desc.Size; *Size = Desc.Size;
} }
return IWineD3DVertexBuffer_Lock(This->wineD3DVertexBuffer, hr = IWineD3DVertexBuffer_Lock(This->wineD3DVertexBuffer,
0 /* OffsetToLock */, 0 /* OffsetToLock */,
0 /* SizeToLock, 0 == Full lock */, 0 /* SizeToLock, 0 == Full lock */,
(BYTE **) Data, (BYTE **) Data,
Flags); Flags);
LeaveCriticalSection(&ddraw_cs);
return hr;
} }
static HRESULT WINAPI static HRESULT WINAPI
...@@ -286,10 +292,14 @@ static HRESULT WINAPI ...@@ -286,10 +292,14 @@ static HRESULT WINAPI
IDirect3DVertexBufferImpl_Unlock(IDirect3DVertexBuffer7 *iface) IDirect3DVertexBufferImpl_Unlock(IDirect3DVertexBuffer7 *iface)
{ {
ICOM_THIS_FROM(IDirect3DVertexBufferImpl, IDirect3DVertexBuffer7, iface); ICOM_THIS_FROM(IDirect3DVertexBufferImpl, IDirect3DVertexBuffer7, iface);
HRESULT hr;
TRACE("(%p)->()\n", This); TRACE("(%p)->()\n", This);
/* This is easy :) */ EnterCriticalSection(&ddraw_cs);
return IWineD3DVertexBuffer_Unlock(This->wineD3DVertexBuffer); hr = IWineD3DVertexBuffer_Unlock(This->wineD3DVertexBuffer);
LeaveCriticalSection(&ddraw_cs);
return hr;
} }
static HRESULT WINAPI static HRESULT WINAPI
...@@ -355,6 +365,7 @@ IDirect3DVertexBufferImpl_ProcessVertices(IDirect3DVertexBuffer7 *iface, ...@@ -355,6 +365,7 @@ IDirect3DVertexBufferImpl_ProcessVertices(IDirect3DVertexBuffer7 *iface,
*/ */
if( !(VertexOp & D3DVOP_TRANSFORM) ) return DDERR_INVALIDPARAMS; if( !(VertexOp & D3DVOP_TRANSFORM) ) return DDERR_INVALIDPARAMS;
EnterCriticalSection(&ddraw_cs);
/* WineD3D doesn't know d3d7 vertex operation, it uses /* WineD3D doesn't know d3d7 vertex operation, it uses
* render states instead. Set the render states according to * render states instead. Set the render states according to
* the vertex ops * the vertex ops
...@@ -392,6 +403,7 @@ IDirect3DVertexBufferImpl_ProcessVertices(IDirect3DVertexBuffer7 *iface, ...@@ -392,6 +403,7 @@ IDirect3DVertexBufferImpl_ProcessVertices(IDirect3DVertexBuffer7 *iface,
IWineD3DDevice_SetRenderState(D3D->wineD3DDevice, IWineD3DDevice_SetRenderState(D3D->wineD3DDevice,
WINED3DRS_CLIPPING, WINED3DRS_CLIPPING,
oldClip); oldClip);
LeaveCriticalSection(&ddraw_cs);
return hr; return hr;
} }
...@@ -446,11 +458,13 @@ IDirect3DVertexBufferImpl_GetVertexBufferDesc(IDirect3DVertexBuffer7 *iface, ...@@ -446,11 +458,13 @@ IDirect3DVertexBufferImpl_GetVertexBufferDesc(IDirect3DVertexBuffer7 *iface,
if(!Desc) return DDERR_INVALIDPARAMS; if(!Desc) return DDERR_INVALIDPARAMS;
EnterCriticalSection(&ddraw_cs);
hr = IWineD3DVertexBuffer_GetDesc(This->wineD3DVertexBuffer, hr = IWineD3DVertexBuffer_GetDesc(This->wineD3DVertexBuffer,
&WDesc); &WDesc);
if(hr != D3D_OK) if(hr != D3D_OK)
{ {
ERR("(%p) IWineD3DVertexBuffer::GetDesc failed with hr=%08x\n", This, hr); ERR("(%p) IWineD3DVertexBuffer::GetDesc failed with hr=%08x\n", This, hr);
LeaveCriticalSection(&ddraw_cs);
return hr; return hr;
} }
...@@ -463,6 +477,7 @@ IDirect3DVertexBufferImpl_GetVertexBufferDesc(IDirect3DVertexBuffer7 *iface, ...@@ -463,6 +477,7 @@ IDirect3DVertexBufferImpl_GetVertexBufferDesc(IDirect3DVertexBuffer7 *iface,
Desc->dwCaps = This->Caps; Desc->dwCaps = This->Caps;
Desc->dwFVF = WDesc.FVF; Desc->dwFVF = WDesc.FVF;
Desc->dwNumVertices = WDesc.Size / get_flexible_vertex_size(WDesc.FVF); Desc->dwNumVertices = WDesc.Size / get_flexible_vertex_size(WDesc.FVF);
LeaveCriticalSection(&ddraw_cs);
return D3D_OK; return D3D_OK;
} }
...@@ -504,7 +519,9 @@ IDirect3DVertexBufferImpl_Optimize(IDirect3DVertexBuffer7 *iface, ...@@ -504,7 +519,9 @@ IDirect3DVertexBufferImpl_Optimize(IDirect3DVertexBuffer7 *iface,
/* We could forward this call to WineD3D and take advantage /* We could forward this call to WineD3D and take advantage
* of it once we use OpenGL vertex buffers * of it once we use OpenGL vertex buffers
*/ */
EnterCriticalSection(&ddraw_cs);
This->Caps |= D3DVBCAPS_OPTIMIZED; This->Caps |= D3DVBCAPS_OPTIMIZED;
LeaveCriticalSection(&ddraw_cs);
return DD_OK; return DD_OK;
} }
......
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