Stefan Dösinger : ddraw: Hold the lock in IDirect3DVertexBuffer methods.
Alexandre Julliard
julliard at wine.codeweavers.com
Tue Jun 5 05:48:31 CDT 2007
Module: wine
Branch: master
Commit: f45684d54711d7407015fe1aa4f1b491d1fcd20f
URL: http://source.winehq.org/git/wine.git/?a=commit;h=f45684d54711d7407015fe1aa4f1b491d1fcd20f
Author: Stefan Dösinger <stefan at codeweavers.com>
Date: Wed May 30 16:19:10 2007 +0200
ddraw: Hold the lock in IDirect3DVertexBuffer methods.
---
dlls/ddraw/vertexbuffer.c | 31 ++++++++++++++++++++++++-------
1 files changed, 24 insertions(+), 7 deletions(-)
diff --git a/dlls/ddraw/vertexbuffer.c b/dlls/ddraw/vertexbuffer.c
index fce64a7..10b5fa4 100644
--- a/dlls/ddraw/vertexbuffer.c
+++ b/dlls/ddraw/vertexbuffer.c
@@ -165,6 +165,7 @@ IDirect3DVertexBufferImpl_Release(IDirect3DVertexBuffer7 *iface)
IWineD3DVertexBuffer *curVB = NULL;
UINT offset, stride;
+ EnterCriticalSection(&ddraw_cs);
/* 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,
* and they should get unset there before they are destroyed
@@ -189,7 +190,9 @@ IDirect3DVertexBufferImpl_Release(IDirect3DVertexBuffer7 *iface)
IWineD3DVertexDeclaration_Release(This->wineD3DVertexDeclaration);
IWineD3DVertexBuffer_Release(This->wineD3DVertexBuffer);
+ LeaveCriticalSection(&ddraw_cs);
HeapFree(GetProcessHeap(), 0, This);
+
return 0;
}
return ref;
@@ -238,6 +241,7 @@ IDirect3DVertexBufferImpl_Lock(IDirect3DVertexBuffer7 *iface,
HRESULT hr;
TRACE("(%p)->(%08x,%p,%p)\n", This, Flags, Data, Size);
+ EnterCriticalSection(&ddraw_cs);
if(Size)
{
/* Get the size, for returning it, and for locking */
@@ -251,11 +255,13 @@ IDirect3DVertexBufferImpl_Lock(IDirect3DVertexBuffer7 *iface,
*Size = Desc.Size;
}
- return IWineD3DVertexBuffer_Lock(This->wineD3DVertexBuffer,
- 0 /* OffsetToLock */,
- 0 /* SizeToLock, 0 == Full lock */,
- (BYTE **) Data,
- Flags);
+ hr = IWineD3DVertexBuffer_Lock(This->wineD3DVertexBuffer,
+ 0 /* OffsetToLock */,
+ 0 /* SizeToLock, 0 == Full lock */,
+ (BYTE **) Data,
+ Flags);
+ LeaveCriticalSection(&ddraw_cs);
+ return hr;
}
static HRESULT WINAPI
@@ -286,10 +292,14 @@ static HRESULT WINAPI
IDirect3DVertexBufferImpl_Unlock(IDirect3DVertexBuffer7 *iface)
{
ICOM_THIS_FROM(IDirect3DVertexBufferImpl, IDirect3DVertexBuffer7, iface);
+ HRESULT hr;
TRACE("(%p)->()\n", This);
- /* This is easy :) */
- return IWineD3DVertexBuffer_Unlock(This->wineD3DVertexBuffer);
+ EnterCriticalSection(&ddraw_cs);
+ hr = IWineD3DVertexBuffer_Unlock(This->wineD3DVertexBuffer);
+ LeaveCriticalSection(&ddraw_cs);
+
+ return hr;
}
static HRESULT WINAPI
@@ -355,6 +365,7 @@ IDirect3DVertexBufferImpl_ProcessVertices(IDirect3DVertexBuffer7 *iface,
*/
if( !(VertexOp & D3DVOP_TRANSFORM) ) return DDERR_INVALIDPARAMS;
+ EnterCriticalSection(&ddraw_cs);
/* WineD3D doesn't know d3d7 vertex operation, it uses
* render states instead. Set the render states according to
* the vertex ops
@@ -392,6 +403,7 @@ IDirect3DVertexBufferImpl_ProcessVertices(IDirect3DVertexBuffer7 *iface,
IWineD3DDevice_SetRenderState(D3D->wineD3DDevice,
WINED3DRS_CLIPPING,
oldClip);
+ LeaveCriticalSection(&ddraw_cs);
return hr;
}
@@ -446,11 +458,13 @@ IDirect3DVertexBufferImpl_GetVertexBufferDesc(IDirect3DVertexBuffer7 *iface,
if(!Desc) return DDERR_INVALIDPARAMS;
+ EnterCriticalSection(&ddraw_cs);
hr = IWineD3DVertexBuffer_GetDesc(This->wineD3DVertexBuffer,
&WDesc);
if(hr != D3D_OK)
{
ERR("(%p) IWineD3DVertexBuffer::GetDesc failed with hr=%08x\n", This, hr);
+ LeaveCriticalSection(&ddraw_cs);
return hr;
}
@@ -463,6 +477,7 @@ IDirect3DVertexBufferImpl_GetVertexBufferDesc(IDirect3DVertexBuffer7 *iface,
Desc->dwCaps = This->Caps;
Desc->dwFVF = WDesc.FVF;
Desc->dwNumVertices = WDesc.Size / get_flexible_vertex_size(WDesc.FVF);
+ LeaveCriticalSection(&ddraw_cs);
return D3D_OK;
}
@@ -504,7 +519,9 @@ IDirect3DVertexBufferImpl_Optimize(IDirect3DVertexBuffer7 *iface,
/* We could forward this call to WineD3D and take advantage
* of it once we use OpenGL vertex buffers
*/
+ EnterCriticalSection(&ddraw_cs);
This->Caps |= D3DVBCAPS_OPTIMIZED;
+ LeaveCriticalSection(&ddraw_cs);
return DD_OK;
}
More information about the wine-cvs
mailing list