Commit a2963b66 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

ddraw: Use wined3d_mutex_lock() / wined3d_mutex_unlock() for locking.

parent 32664381
...@@ -96,10 +96,10 @@ static ULONG WINAPI IDirectDrawClipperImpl_Release(IDirectDrawClipper *iface) ...@@ -96,10 +96,10 @@ static ULONG WINAPI IDirectDrawClipperImpl_Release(IDirectDrawClipper *iface)
if (ref == 0) if (ref == 0)
{ {
EnterCriticalSection(&ddraw_cs); wined3d_mutex_lock();
wined3d_clipper_decref(This->wineD3DClipper); wined3d_clipper_decref(This->wineD3DClipper);
wined3d_mutex_unlock();
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);
LeaveCriticalSection(&ddraw_cs);
return 0; return 0;
} }
else return ref; else return ref;
...@@ -128,9 +128,10 @@ static HRESULT WINAPI IDirectDrawClipperImpl_SetHWnd(IDirectDrawClipper *iface, ...@@ -128,9 +128,10 @@ static HRESULT WINAPI IDirectDrawClipperImpl_SetHWnd(IDirectDrawClipper *iface,
TRACE("iface %p, flags %#x, window %p.\n", iface, dwFlags, hWnd); TRACE("iface %p, flags %#x, window %p.\n", iface, dwFlags, hWnd);
EnterCriticalSection(&ddraw_cs); wined3d_mutex_lock();
hr = wined3d_clipper_set_window(This->wineD3DClipper, dwFlags, hWnd); hr = wined3d_clipper_set_window(This->wineD3DClipper, dwFlags, hWnd);
LeaveCriticalSection(&ddraw_cs); wined3d_mutex_unlock();
switch(hr) switch(hr)
{ {
case WINED3DERR_INVALIDCALL: return DDERR_INVALIDPARAMS; case WINED3DERR_INVALIDCALL: return DDERR_INVALIDPARAMS;
...@@ -165,9 +166,10 @@ static HRESULT WINAPI IDirectDrawClipperImpl_GetClipList(IDirectDrawClipper *ifa ...@@ -165,9 +166,10 @@ static HRESULT WINAPI IDirectDrawClipperImpl_GetClipList(IDirectDrawClipper *ifa
TRACE("iface %p, rect %s, clip_list %p, clip_list_size %p.\n", TRACE("iface %p, rect %s, clip_list %p, clip_list_size %p.\n",
iface, wine_dbgstr_rect(lpRect), lpClipList, lpdwSize); iface, wine_dbgstr_rect(lpRect), lpClipList, lpdwSize);
EnterCriticalSection(&ddraw_cs); wined3d_mutex_lock();
hr = wined3d_clipper_get_clip_list(This->wineD3DClipper, lpRect, lpClipList, lpdwSize); hr = wined3d_clipper_get_clip_list(This->wineD3DClipper, lpRect, lpClipList, lpdwSize);
LeaveCriticalSection(&ddraw_cs); wined3d_mutex_unlock();
return hr; return hr;
} }
...@@ -193,9 +195,10 @@ static HRESULT WINAPI IDirectDrawClipperImpl_SetClipList(IDirectDrawClipper *ifa ...@@ -193,9 +195,10 @@ static HRESULT WINAPI IDirectDrawClipperImpl_SetClipList(IDirectDrawClipper *ifa
TRACE("iface %p, clip_list %p, flags %#x.\n", iface, lprgn, dwFlag); TRACE("iface %p, clip_list %p, flags %#x.\n", iface, lprgn, dwFlag);
EnterCriticalSection(&ddraw_cs); wined3d_mutex_lock();
hr = wined3d_clipper_set_clip_list(This->wineD3DClipper, lprgn, dwFlag); hr = wined3d_clipper_set_clip_list(This->wineD3DClipper, lprgn, dwFlag);
LeaveCriticalSection(&ddraw_cs); wined3d_mutex_unlock();
return hr; return hr;
} }
...@@ -217,9 +220,10 @@ static HRESULT WINAPI IDirectDrawClipperImpl_GetHWnd(IDirectDrawClipper *iface, ...@@ -217,9 +220,10 @@ static HRESULT WINAPI IDirectDrawClipperImpl_GetHWnd(IDirectDrawClipper *iface,
TRACE("iface %p, window %p.\n", iface, hWndPtr); TRACE("iface %p, window %p.\n", iface, hWndPtr);
EnterCriticalSection(&ddraw_cs); wined3d_mutex_lock();
hr = wined3d_clipper_get_window(This->wineD3DClipper, hWndPtr); hr = wined3d_clipper_get_window(This->wineD3DClipper, hWndPtr);
LeaveCriticalSection(&ddraw_cs); wined3d_mutex_unlock();
return hr; return hr;
} }
...@@ -244,16 +248,16 @@ static HRESULT WINAPI IDirectDrawClipperImpl_Initialize(IDirectDrawClipper *ifac ...@@ -244,16 +248,16 @@ static HRESULT WINAPI IDirectDrawClipperImpl_Initialize(IDirectDrawClipper *ifac
TRACE("iface %p, ddraw %p, flags %#x.\n", iface, ddraw, dwFlags); TRACE("iface %p, ddraw %p, flags %#x.\n", iface, ddraw, dwFlags);
EnterCriticalSection(&ddraw_cs); wined3d_mutex_lock();
if (This->initialized) if (This->initialized)
{ {
LeaveCriticalSection(&ddraw_cs); wined3d_mutex_unlock();
return DDERR_ALREADYINITIALIZED; return DDERR_ALREADYINITIALIZED;
} }
This->initialized = TRUE; This->initialized = TRUE;
wined3d_mutex_unlock();
LeaveCriticalSection(&ddraw_cs);
return DD_OK; return DD_OK;
} }
......
...@@ -52,9 +52,6 @@ typedef struct IDirect3DMaterialImpl IDirect3DMaterialImpl; ...@@ -52,9 +52,6 @@ typedef struct IDirect3DMaterialImpl IDirect3DMaterialImpl;
typedef struct IDirect3DExecuteBufferImpl IDirect3DExecuteBufferImpl; typedef struct IDirect3DExecuteBufferImpl IDirect3DExecuteBufferImpl;
typedef struct IDirect3DVertexBufferImpl IDirect3DVertexBufferImpl; typedef struct IDirect3DVertexBufferImpl IDirect3DVertexBufferImpl;
/* Global critical section */
extern CRITICAL_SECTION ddraw_cs DECLSPEC_HIDDEN;
extern DWORD force_refresh_rate DECLSPEC_HIDDEN; extern DWORD force_refresh_rate DECLSPEC_HIDDEN;
/***************************************************************************** /*****************************************************************************
......
...@@ -224,11 +224,12 @@ static HRESULT WINAPI IDirect3DLightImpl_SetLight(IDirect3DLight *iface, D3DLIGH ...@@ -224,11 +224,12 @@ static HRESULT WINAPI IDirect3DLightImpl_SetLight(IDirect3DLight *iface, D3DLIGH
light7->dvTheta = lpLight->dvTheta; light7->dvTheta = lpLight->dvTheta;
light7->dvPhi = lpLight->dvPhi; light7->dvPhi = lpLight->dvPhi;
EnterCriticalSection(&ddraw_cs); wined3d_mutex_lock();
memcpy(&This->light, lpLight, lpLight->dwSize); memcpy(&This->light, lpLight, lpLight->dwSize);
if (This->light.dwFlags & D3DLIGHT_ACTIVE) if (This->light.dwFlags & D3DLIGHT_ACTIVE)
light_update(This); light_update(This);
LeaveCriticalSection(&ddraw_cs); wined3d_mutex_unlock();
return D3D_OK; return D3D_OK;
} }
...@@ -256,9 +257,9 @@ static HRESULT WINAPI IDirect3DLightImpl_GetLight(IDirect3DLight *iface, D3DLIGH ...@@ -256,9 +257,9 @@ static HRESULT WINAPI IDirect3DLightImpl_GetLight(IDirect3DLight *iface, D3DLIGH
dump_light(&This->light); dump_light(&This->light);
} }
EnterCriticalSection(&ddraw_cs); wined3d_mutex_lock();
memcpy(lpLight, &This->light, lpLight->dwSize); memcpy(lpLight, &This->light, lpLight->dwSize);
LeaveCriticalSection(&ddraw_cs); wined3d_mutex_unlock();
return DD_OK; return DD_OK;
} }
......
...@@ -39,18 +39,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(ddraw); ...@@ -39,18 +39,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
/* The configured default surface */ /* The configured default surface */
WINED3DSURFTYPE DefaultSurfaceType = SURFACE_OPENGL; WINED3DSURFTYPE DefaultSurfaceType = SURFACE_OPENGL;
/* DDraw list and critical section */
static struct list global_ddraw_list = LIST_INIT(global_ddraw_list); static struct list global_ddraw_list = LIST_INIT(global_ddraw_list);
static CRITICAL_SECTION_DEBUG ddraw_cs_debug =
{
0, 0, &ddraw_cs,
{ &ddraw_cs_debug.ProcessLocksList,
&ddraw_cs_debug.ProcessLocksList },
0, 0, { (DWORD_PTR)(__FILE__ ": ddraw_cs") }
};
CRITICAL_SECTION ddraw_cs = { &ddraw_cs_debug, -1, 0, 0, 0, 0 };
static HINSTANCE instance; static HINSTANCE instance;
/* value of ForceRefreshRate */ /* value of ForceRefreshRate */
...@@ -272,9 +262,9 @@ DirectDrawCreate(GUID *GUID, ...@@ -272,9 +262,9 @@ DirectDrawCreate(GUID *GUID,
TRACE("driver_guid %s, ddraw %p, outer_unknown %p.\n", TRACE("driver_guid %s, ddraw %p, outer_unknown %p.\n",
debugstr_guid(GUID), DD, UnkOuter); debugstr_guid(GUID), DD, UnkOuter);
EnterCriticalSection(&ddraw_cs); wined3d_mutex_lock();
hr = DDRAW_Create(GUID, (void **) DD, UnkOuter, &IID_IDirectDraw); hr = DDRAW_Create(GUID, (void **) DD, UnkOuter, &IID_IDirectDraw);
LeaveCriticalSection(&ddraw_cs); wined3d_mutex_unlock();
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
{ {
...@@ -309,9 +299,9 @@ DirectDrawCreateEx(GUID *guid, ...@@ -309,9 +299,9 @@ DirectDrawCreateEx(GUID *guid,
if (!IsEqualGUID(iid, &IID_IDirectDraw7)) if (!IsEqualGUID(iid, &IID_IDirectDraw7))
return DDERR_INVALIDPARAMS; return DDERR_INVALIDPARAMS;
EnterCriticalSection(&ddraw_cs); wined3d_mutex_lock();
hr = DDRAW_Create(guid, dd, UnkOuter, iid); hr = DDRAW_Create(guid, dd, UnkOuter, iid);
LeaveCriticalSection(&ddraw_cs); wined3d_mutex_unlock();
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
{ {
...@@ -466,9 +456,10 @@ CF_CreateDirectDraw(IUnknown* UnkOuter, REFIID iid, ...@@ -466,9 +456,10 @@ CF_CreateDirectDraw(IUnknown* UnkOuter, REFIID iid,
TRACE("outer_unknown %p, riid %s, object %p.\n", UnkOuter, debugstr_guid(iid), obj); TRACE("outer_unknown %p, riid %s, object %p.\n", UnkOuter, debugstr_guid(iid), obj);
EnterCriticalSection(&ddraw_cs); wined3d_mutex_lock();
hr = DDRAW_Create(NULL, obj, UnkOuter, iid); hr = DDRAW_Create(NULL, obj, UnkOuter, iid);
LeaveCriticalSection(&ddraw_cs); wined3d_mutex_unlock();
return hr; return hr;
} }
...@@ -495,18 +486,19 @@ CF_CreateDirectDrawClipper(IUnknown* UnkOuter, REFIID riid, ...@@ -495,18 +486,19 @@ CF_CreateDirectDrawClipper(IUnknown* UnkOuter, REFIID riid,
TRACE("outer_unknown %p, riid %s, object %p.\n", UnkOuter, debugstr_guid(riid), obj); TRACE("outer_unknown %p, riid %s, object %p.\n", UnkOuter, debugstr_guid(riid), obj);
EnterCriticalSection(&ddraw_cs); wined3d_mutex_lock();
hr = DirectDrawCreateClipper(0, &Clip, UnkOuter); hr = DirectDrawCreateClipper(0, &Clip, UnkOuter);
if (hr != DD_OK) if (hr != DD_OK)
{ {
LeaveCriticalSection(&ddraw_cs); wined3d_mutex_unlock();
return hr; return hr;
} }
hr = IDirectDrawClipper_QueryInterface(Clip, riid, obj); hr = IDirectDrawClipper_QueryInterface(Clip, riid, obj);
IDirectDrawClipper_Release(Clip); IDirectDrawClipper_Release(Clip);
LeaveCriticalSection(&ddraw_cs); wined3d_mutex_unlock();
return hr; return hr;
} }
......
...@@ -142,9 +142,9 @@ static ULONG WINAPI IDirect3DMaterialImpl_Release(IDirect3DMaterial3 *iface) ...@@ -142,9 +142,9 @@ static ULONG WINAPI IDirect3DMaterialImpl_Release(IDirect3DMaterial3 *iface)
{ {
if(This->Handle) if(This->Handle)
{ {
EnterCriticalSection(&ddraw_cs); wined3d_mutex_lock();
ddraw_free_handle(&This->ddraw->d3ddevice->handle_table, This->Handle - 1, DDRAW_HANDLE_MATERIAL); ddraw_free_handle(&This->ddraw->d3ddevice->handle_table, This->Handle - 1, DDRAW_HANDLE_MATERIAL);
LeaveCriticalSection(&ddraw_cs); wined3d_mutex_unlock();
} }
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);
...@@ -236,10 +236,10 @@ static HRESULT WINAPI IDirect3DMaterialImpl_SetMaterial(IDirect3DMaterial3 *ifac ...@@ -236,10 +236,10 @@ static HRESULT WINAPI IDirect3DMaterialImpl_SetMaterial(IDirect3DMaterial3 *ifac
dump_material(lpMat); dump_material(lpMat);
/* Stores the material */ /* Stores the material */
EnterCriticalSection(&ddraw_cs); wined3d_mutex_lock();
memset(&This->mat, 0, sizeof(This->mat)); memset(&This->mat, 0, sizeof(This->mat));
memcpy(&This->mat, lpMat, lpMat->dwSize); memcpy(&This->mat, lpMat, lpMat->dwSize);
LeaveCriticalSection(&ddraw_cs); wined3d_mutex_unlock();
return DD_OK; return DD_OK;
} }
...@@ -271,10 +271,10 @@ static HRESULT WINAPI IDirect3DMaterialImpl_GetMaterial(IDirect3DMaterial3 *ifac ...@@ -271,10 +271,10 @@ static HRESULT WINAPI IDirect3DMaterialImpl_GetMaterial(IDirect3DMaterial3 *ifac
} }
/* Copies the material structure */ /* Copies the material structure */
EnterCriticalSection(&ddraw_cs); wined3d_mutex_lock();
dwSize = lpMat->dwSize; dwSize = lpMat->dwSize;
memcpy(lpMat, &This->mat, dwSize); memcpy(lpMat, &This->mat, dwSize);
LeaveCriticalSection(&ddraw_cs); wined3d_mutex_unlock();
return DD_OK; return DD_OK;
} }
...@@ -302,7 +302,7 @@ static HRESULT WINAPI IDirect3DMaterialImpl_GetHandle(IDirect3DMaterial3 *iface, ...@@ -302,7 +302,7 @@ static HRESULT WINAPI IDirect3DMaterialImpl_GetHandle(IDirect3DMaterial3 *iface,
TRACE("iface %p, device %p, handle %p.\n", iface, device, handle); TRACE("iface %p, device %p, handle %p.\n", iface, device, handle);
EnterCriticalSection(&ddraw_cs); wined3d_mutex_lock();
This->active_device = device_impl; This->active_device = device_impl;
if(!This->Handle) if(!This->Handle)
{ {
...@@ -310,7 +310,7 @@ static HRESULT WINAPI IDirect3DMaterialImpl_GetHandle(IDirect3DMaterial3 *iface, ...@@ -310,7 +310,7 @@ static HRESULT WINAPI IDirect3DMaterialImpl_GetHandle(IDirect3DMaterial3 *iface,
if (h == DDRAW_INVALID_HANDLE) if (h == DDRAW_INVALID_HANDLE)
{ {
ERR("Failed to allocate a material handle.\n"); ERR("Failed to allocate a material handle.\n");
LeaveCriticalSection(&ddraw_cs); wined3d_mutex_unlock();
return DDERR_INVALIDPARAMS; /* Unchecked */ return DDERR_INVALIDPARAMS; /* Unchecked */
} }
...@@ -318,7 +318,7 @@ static HRESULT WINAPI IDirect3DMaterialImpl_GetHandle(IDirect3DMaterial3 *iface, ...@@ -318,7 +318,7 @@ static HRESULT WINAPI IDirect3DMaterialImpl_GetHandle(IDirect3DMaterial3 *iface,
} }
*handle = This->Handle; *handle = This->Handle;
TRACE(" returning handle %08x.\n", *handle); TRACE(" returning handle %08x.\n", *handle);
LeaveCriticalSection(&ddraw_cs); wined3d_mutex_unlock();
return D3D_OK; return D3D_OK;
} }
......
...@@ -97,13 +97,14 @@ IDirectDrawPaletteImpl_Release(IDirectDrawPalette *iface) ...@@ -97,13 +97,14 @@ IDirectDrawPaletteImpl_Release(IDirectDrawPalette *iface)
if (ref == 0) if (ref == 0)
{ {
EnterCriticalSection(&ddraw_cs); wined3d_mutex_lock();
wined3d_palette_decref(This->wineD3DPalette); wined3d_palette_decref(This->wineD3DPalette);
if(This->ifaceToRelease) if(This->ifaceToRelease)
{ {
IUnknown_Release(This->ifaceToRelease); IUnknown_Release(This->ifaceToRelease);
} }
LeaveCriticalSection(&ddraw_cs); wined3d_mutex_unlock();
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);
} }
...@@ -159,9 +160,9 @@ IDirectDrawPaletteImpl_GetCaps(IDirectDrawPalette *iface, ...@@ -159,9 +160,9 @@ IDirectDrawPaletteImpl_GetCaps(IDirectDrawPalette *iface,
TRACE("iface %p, caps %p.\n", iface, Caps); TRACE("iface %p, caps %p.\n", iface, Caps);
EnterCriticalSection(&ddraw_cs); wined3d_mutex_lock();
*Caps = wined3d_palette_get_flags(This->wineD3DPalette); *Caps = wined3d_palette_get_flags(This->wineD3DPalette);
LeaveCriticalSection(&ddraw_cs); wined3d_mutex_unlock();
return D3D_OK; return D3D_OK;
} }
...@@ -200,9 +201,10 @@ IDirectDrawPaletteImpl_SetEntries(IDirectDrawPalette *iface, ...@@ -200,9 +201,10 @@ IDirectDrawPaletteImpl_SetEntries(IDirectDrawPalette *iface,
if(!PalEnt) if(!PalEnt)
return DDERR_INVALIDPARAMS; return DDERR_INVALIDPARAMS;
EnterCriticalSection(&ddraw_cs); wined3d_mutex_lock();
hr = wined3d_palette_set_entries(This->wineD3DPalette, Flags, Start, Count, PalEnt); hr = wined3d_palette_set_entries(This->wineD3DPalette, Flags, Start, Count, PalEnt);
LeaveCriticalSection(&ddraw_cs); wined3d_mutex_unlock();
return hr; return hr;
} }
...@@ -239,9 +241,10 @@ IDirectDrawPaletteImpl_GetEntries(IDirectDrawPalette *iface, ...@@ -239,9 +241,10 @@ IDirectDrawPaletteImpl_GetEntries(IDirectDrawPalette *iface,
if(!PalEnt) if(!PalEnt)
return DDERR_INVALIDPARAMS; return DDERR_INVALIDPARAMS;
EnterCriticalSection(&ddraw_cs); wined3d_mutex_lock();
hr = wined3d_palette_get_entries(This->wineD3DPalette, Flags, Start, Count, PalEnt); hr = wined3d_palette_get_entries(This->wineD3DPalette, Flags, Start, Count, PalEnt);
LeaveCriticalSection(&ddraw_cs); wined3d_mutex_unlock();
return hr; return hr;
} }
......
...@@ -150,11 +150,11 @@ static ULONG WINAPI IDirect3DVertexBufferImpl_Release(IDirect3DVertexBuffer7 *if ...@@ -150,11 +150,11 @@ static ULONG WINAPI IDirect3DVertexBufferImpl_Release(IDirect3DVertexBuffer7 *if
struct wined3d_buffer *curVB = NULL; struct wined3d_buffer *curVB = NULL;
UINT offset, stride; UINT offset, stride;
EnterCriticalSection(&ddraw_cs);
/* D3D7 Vertex buffers don't stay bound in the device, they are passed /* D3D7 Vertex buffers don't stay bound in the device, they are passed
* as a parameter to drawPrimitiveVB. DrawPrimitiveVB sets them as the * as a parameter to drawPrimitiveVB. DrawPrimitiveVB sets them as the
* stream source in wined3d, and they should get unset there before * stream source in wined3d, and they should get unset there before
* they are destroyed. */ * they are destroyed. */
wined3d_mutex_lock();
wined3d_device_get_stream_source(This->ddraw->wined3d_device, wined3d_device_get_stream_source(This->ddraw->wined3d_device,
0, &curVB, &offset, &stride); 0, &curVB, &offset, &stride);
if (curVB == This->wineD3DVertexBuffer) if (curVB == This->wineD3DVertexBuffer)
...@@ -164,7 +164,8 @@ static ULONG WINAPI IDirect3DVertexBufferImpl_Release(IDirect3DVertexBuffer7 *if ...@@ -164,7 +164,8 @@ static ULONG WINAPI IDirect3DVertexBufferImpl_Release(IDirect3DVertexBuffer7 *if
wined3d_vertex_declaration_decref(This->wineD3DVertexDeclaration); wined3d_vertex_declaration_decref(This->wineD3DVertexDeclaration);
wined3d_buffer_decref(This->wineD3DVertexBuffer); wined3d_buffer_decref(This->wineD3DVertexBuffer);
LeaveCriticalSection(&ddraw_cs); wined3d_mutex_unlock();
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);
return 0; return 0;
...@@ -223,7 +224,7 @@ static HRESULT WINAPI IDirect3DVertexBufferImpl_Lock(IDirect3DVertexBuffer7 *ifa ...@@ -223,7 +224,7 @@ static HRESULT WINAPI IDirect3DVertexBufferImpl_Lock(IDirect3DVertexBuffer7 *ifa
if(Flags & DDLOCK_NOOVERWRITE) wined3d_flags |= WINED3DLOCK_NOOVERWRITE; if(Flags & DDLOCK_NOOVERWRITE) wined3d_flags |= WINED3DLOCK_NOOVERWRITE;
if(Flags & DDLOCK_DISCARDCONTENTS) wined3d_flags |= WINED3DLOCK_DISCARD; if(Flags & DDLOCK_DISCARDCONTENTS) wined3d_flags |= WINED3DLOCK_DISCARD;
EnterCriticalSection(&ddraw_cs); wined3d_mutex_lock();
if(Size) if(Size)
{ {
/* Get the size, for returning it, and for locking */ /* Get the size, for returning it, and for locking */
...@@ -233,7 +234,8 @@ static HRESULT WINAPI IDirect3DVertexBufferImpl_Lock(IDirect3DVertexBuffer7 *ifa ...@@ -233,7 +234,8 @@ static HRESULT WINAPI IDirect3DVertexBufferImpl_Lock(IDirect3DVertexBuffer7 *ifa
} }
hr = wined3d_buffer_map(This->wineD3DVertexBuffer, 0, 0, (BYTE **)Data, wined3d_flags); hr = wined3d_buffer_map(This->wineD3DVertexBuffer, 0, 0, (BYTE **)Data, wined3d_flags);
LeaveCriticalSection(&ddraw_cs); wined3d_mutex_unlock();
return hr; return hr;
} }
...@@ -262,9 +264,9 @@ static HRESULT WINAPI IDirect3DVertexBufferImpl_Unlock(IDirect3DVertexBuffer7 *i ...@@ -262,9 +264,9 @@ static HRESULT WINAPI IDirect3DVertexBufferImpl_Unlock(IDirect3DVertexBuffer7 *i
TRACE("iface %p.\n", iface); TRACE("iface %p.\n", iface);
EnterCriticalSection(&ddraw_cs); wined3d_mutex_lock();
wined3d_buffer_unmap(This->wineD3DVertexBuffer); wined3d_buffer_unmap(This->wineD3DVertexBuffer);
LeaveCriticalSection(&ddraw_cs); wined3d_mutex_unlock();
return D3D_OK; return D3D_OK;
} }
...@@ -326,7 +328,8 @@ static HRESULT WINAPI IDirect3DVertexBufferImpl_ProcessVertices(IDirect3DVertexB ...@@ -326,7 +328,8 @@ static HRESULT WINAPI IDirect3DVertexBufferImpl_ProcessVertices(IDirect3DVertexB
*/ */
if( !(VertexOp & D3DVOP_TRANSFORM) ) return DDERR_INVALIDPARAMS; if( !(VertexOp & D3DVOP_TRANSFORM) ) return DDERR_INVALIDPARAMS;
EnterCriticalSection(&ddraw_cs); wined3d_mutex_lock();
/* 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
...@@ -345,7 +348,9 @@ static HRESULT WINAPI IDirect3DVertexBufferImpl_ProcessVertices(IDirect3DVertexB ...@@ -345,7 +348,9 @@ static HRESULT WINAPI IDirect3DVertexBufferImpl_ProcessVertices(IDirect3DVertexB
/* Restore the states if needed */ /* Restore the states if needed */
if (doClip != oldClip) if (doClip != oldClip)
wined3d_device_set_render_state(device_impl->wined3d_device, WINED3DRS_CLIPPING, oldClip); wined3d_device_set_render_state(device_impl->wined3d_device, WINED3DRS_CLIPPING, oldClip);
LeaveCriticalSection(&ddraw_cs);
wined3d_mutex_unlock();
return hr; return hr;
} }
...@@ -389,10 +394,10 @@ static HRESULT WINAPI IDirect3DVertexBufferImpl_GetVertexBufferDesc(IDirect3DVer ...@@ -389,10 +394,10 @@ static HRESULT WINAPI IDirect3DVertexBufferImpl_GetVertexBufferDesc(IDirect3DVer
if(!Desc) return DDERR_INVALIDPARAMS; if(!Desc) return DDERR_INVALIDPARAMS;
EnterCriticalSection(&ddraw_cs); wined3d_mutex_lock();
wined3d_resource = wined3d_buffer_get_resource(This->wineD3DVertexBuffer); wined3d_resource = wined3d_buffer_get_resource(This->wineD3DVertexBuffer);
wined3d_resource_get_desc(wined3d_resource, &wined3d_desc); wined3d_resource_get_desc(wined3d_resource, &wined3d_desc);
LeaveCriticalSection(&ddraw_cs); wined3d_mutex_unlock();
/* Now fill the Desc structure */ /* Now fill the Desc structure */
Desc->dwCaps = This->Caps; Desc->dwCaps = This->Caps;
...@@ -443,9 +448,9 @@ static HRESULT WINAPI IDirect3DVertexBufferImpl_Optimize(IDirect3DVertexBuffer7 ...@@ -443,9 +448,9 @@ static HRESULT WINAPI IDirect3DVertexBufferImpl_Optimize(IDirect3DVertexBuffer7
/* 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); wined3d_mutex_lock();
This->Caps |= D3DVBCAPS_OPTIMIZED; This->Caps |= D3DVBCAPS_OPTIMIZED;
LeaveCriticalSection(&ddraw_cs); wined3d_mutex_unlock();
return DD_OK; return DD_OK;
} }
...@@ -562,7 +567,7 @@ HRESULT d3d_vertex_buffer_create(IDirect3DVertexBufferImpl **vertex_buf, IDirect ...@@ -562,7 +567,7 @@ HRESULT d3d_vertex_buffer_create(IDirect3DVertexBufferImpl **vertex_buf, IDirect
usage = desc->dwCaps & D3DVBCAPS_WRITEONLY ? WINED3DUSAGE_WRITEONLY : 0; usage = desc->dwCaps & D3DVBCAPS_WRITEONLY ? WINED3DUSAGE_WRITEONLY : 0;
usage |= WINED3DUSAGE_STATICDECL; usage |= WINED3DUSAGE_STATICDECL;
EnterCriticalSection(&ddraw_cs); wined3d_mutex_lock();
hr = wined3d_buffer_create_vb(ddraw->wined3d_device, hr = wined3d_buffer_create_vb(ddraw->wined3d_device,
get_flexible_vertex_size(desc->dwFVF) * desc->dwNumVertices, get_flexible_vertex_size(desc->dwFVF) * desc->dwNumVertices,
...@@ -587,7 +592,7 @@ HRESULT d3d_vertex_buffer_create(IDirect3DVertexBufferImpl **vertex_buf, IDirect ...@@ -587,7 +592,7 @@ HRESULT d3d_vertex_buffer_create(IDirect3DVertexBufferImpl **vertex_buf, IDirect
wined3d_vertex_declaration_incref(buffer->wineD3DVertexDeclaration); wined3d_vertex_declaration_incref(buffer->wineD3DVertexDeclaration);
end: end:
LeaveCriticalSection(&ddraw_cs); wined3d_mutex_unlock();
if (hr == D3D_OK) if (hr == D3D_OK)
*vertex_buf = buffer; *vertex_buf = buffer;
else else
......
...@@ -245,7 +245,8 @@ IDirect3DViewportImpl_GetViewport(IDirect3DViewport3 *iface, ...@@ -245,7 +245,8 @@ IDirect3DViewportImpl_GetViewport(IDirect3DViewport3 *iface,
TRACE("iface %p, data %p.\n", iface, lpData); TRACE("iface %p, data %p.\n", iface, lpData);
EnterCriticalSection(&ddraw_cs); wined3d_mutex_lock();
dwSize = lpData->dwSize; dwSize = lpData->dwSize;
memset(lpData, 0, dwSize); memset(lpData, 0, dwSize);
if (!This->use_vp2) if (!This->use_vp2)
...@@ -271,7 +272,8 @@ IDirect3DViewportImpl_GetViewport(IDirect3DViewport3 *iface, ...@@ -271,7 +272,8 @@ IDirect3DViewportImpl_GetViewport(IDirect3DViewport3 *iface,
TRACE(" returning D3DVIEWPORT :\n"); TRACE(" returning D3DVIEWPORT :\n");
_dump_D3DVIEWPORT(lpData); _dump_D3DVIEWPORT(lpData);
} }
LeaveCriticalSection(&ddraw_cs);
wined3d_mutex_unlock();
return DD_OK; return DD_OK;
} }
...@@ -304,7 +306,8 @@ IDirect3DViewportImpl_SetViewport(IDirect3DViewport3 *iface, ...@@ -304,7 +306,8 @@ IDirect3DViewportImpl_SetViewport(IDirect3DViewport3 *iface,
_dump_D3DVIEWPORT(lpData); _dump_D3DVIEWPORT(lpData);
} }
EnterCriticalSection(&ddraw_cs); wined3d_mutex_lock();
This->use_vp2 = 0; This->use_vp2 = 0;
memset(&(This->viewports.vp1), 0, sizeof(This->viewports.vp1)); memset(&(This->viewports.vp1), 0, sizeof(This->viewports.vp1));
memcpy(&(This->viewports.vp1), lpData, lpData->dwSize); memcpy(&(This->viewports.vp1), lpData, lpData->dwSize);
...@@ -324,7 +327,8 @@ IDirect3DViewportImpl_SetViewport(IDirect3DViewport3 *iface, ...@@ -324,7 +327,8 @@ IDirect3DViewportImpl_SetViewport(IDirect3DViewport3 *iface,
IDirect3DViewport3_Release(current_viewport); IDirect3DViewport3_Release(current_viewport);
} }
} }
LeaveCriticalSection(&ddraw_cs);
wined3d_mutex_unlock();
return DD_OK; return DD_OK;
} }
...@@ -391,7 +395,7 @@ IDirect3DViewportImpl_TransformVertices(IDirect3DViewport3 *iface, ...@@ -391,7 +395,7 @@ IDirect3DViewportImpl_TransformVertices(IDirect3DViewport3 *iface,
} }
EnterCriticalSection(&ddraw_cs); wined3d_mutex_lock();
wined3d_device_get_transform(This->active_device->wined3d_device, wined3d_device_get_transform(This->active_device->wined3d_device,
D3DTRANSFORMSTATE_VIEW, (WINED3DMATRIX *)&view_mat); D3DTRANSFORMSTATE_VIEW, (WINED3DMATRIX *)&view_mat);
wined3d_device_get_transform(This->active_device->wined3d_device, wined3d_device_get_transform(This->active_device->wined3d_device,
...@@ -476,7 +480,7 @@ IDirect3DViewportImpl_TransformVertices(IDirect3DViewport3 *iface, ...@@ -476,7 +480,7 @@ IDirect3DViewportImpl_TransformVertices(IDirect3DViewport3 *iface,
{ {
*lpOffScreen = 0; *lpOffScreen = 0;
} }
LeaveCriticalSection(&ddraw_cs); wined3d_mutex_unlock();
TRACE("All done\n"); TRACE("All done\n");
return DD_OK; return DD_OK;
...@@ -525,13 +529,13 @@ IDirect3DViewportImpl_SetBackground(IDirect3DViewport3 *iface, ...@@ -525,13 +529,13 @@ IDirect3DViewportImpl_SetBackground(IDirect3DViewport3 *iface,
TRACE("iface %p, material %#x.\n", iface, hMat); TRACE("iface %p, material %#x.\n", iface, hMat);
EnterCriticalSection(&ddraw_cs); wined3d_mutex_lock();
if (!hMat) if (!hMat)
{ {
This->background = NULL; This->background = NULL;
TRACE("Setting background to NULL\n"); TRACE("Setting background to NULL\n");
LeaveCriticalSection(&ddraw_cs); wined3d_mutex_unlock();
return D3D_OK; return D3D_OK;
} }
...@@ -539,7 +543,7 @@ IDirect3DViewportImpl_SetBackground(IDirect3DViewport3 *iface, ...@@ -539,7 +543,7 @@ IDirect3DViewportImpl_SetBackground(IDirect3DViewport3 *iface,
if (!m) if (!m)
{ {
WARN("Invalid material handle.\n"); WARN("Invalid material handle.\n");
LeaveCriticalSection(&ddraw_cs); wined3d_mutex_unlock();
return DDERR_INVALIDPARAMS; return DDERR_INVALIDPARAMS;
} }
...@@ -548,7 +552,8 @@ IDirect3DViewportImpl_SetBackground(IDirect3DViewport3 *iface, ...@@ -548,7 +552,8 @@ IDirect3DViewportImpl_SetBackground(IDirect3DViewport3 *iface,
m->mat.u.diffuse.u3.b, m->mat.u.diffuse.u4.a); m->mat.u.diffuse.u3.b, m->mat.u.diffuse.u4.a);
This->background = m; This->background = m;
LeaveCriticalSection(&ddraw_cs); wined3d_mutex_unlock();
return D3D_OK; return D3D_OK;
} }
...@@ -574,7 +579,7 @@ IDirect3DViewportImpl_GetBackground(IDirect3DViewport3 *iface, ...@@ -574,7 +579,7 @@ IDirect3DViewportImpl_GetBackground(IDirect3DViewport3 *iface,
TRACE("iface %p, material %p, valid %p.\n", iface, lphMat, lpValid); TRACE("iface %p, material %p, valid %p.\n", iface, lphMat, lpValid);
EnterCriticalSection(&ddraw_cs); wined3d_mutex_lock();
if(lpValid) if(lpValid)
{ {
*lpValid = This->background != NULL; *lpValid = This->background != NULL;
...@@ -590,7 +595,7 @@ IDirect3DViewportImpl_GetBackground(IDirect3DViewport3 *iface, ...@@ -590,7 +595,7 @@ IDirect3DViewportImpl_GetBackground(IDirect3DViewport3 *iface,
*lphMat = 0; *lphMat = 0;
} }
} }
LeaveCriticalSection(&ddraw_cs); wined3d_mutex_unlock();
return D3D_OK; return D3D_OK;
} }
...@@ -674,7 +679,8 @@ static HRESULT WINAPI IDirect3DViewportImpl_Clear(IDirect3DViewport3 *iface, ...@@ -674,7 +679,8 @@ static HRESULT WINAPI IDirect3DViewportImpl_Clear(IDirect3DViewport3 *iface,
} }
d3d_device3 = &This->active_device->IDirect3DDevice3_iface; d3d_device3 = &This->active_device->IDirect3DDevice3_iface;
EnterCriticalSection(&ddraw_cs); wined3d_mutex_lock();
if (dwFlags & D3DCLEAR_TARGET) { if (dwFlags & D3DCLEAR_TARGET) {
if (This->background == NULL) { if (This->background == NULL) {
ERR(" Trying to clear the color buffer without background material !\n"); ERR(" Trying to clear the color buffer without background material !\n");
...@@ -702,7 +708,8 @@ static HRESULT WINAPI IDirect3DViewportImpl_Clear(IDirect3DViewport3 *iface, ...@@ -702,7 +708,8 @@ static HRESULT WINAPI IDirect3DViewportImpl_Clear(IDirect3DViewport3 *iface,
IDirect3DViewport3_Release(current_viewport); IDirect3DViewport3_Release(current_viewport);
} }
LeaveCriticalSection(&ddraw_cs); wined3d_mutex_unlock();
return hr; return hr;
} }
...@@ -730,10 +737,11 @@ static HRESULT WINAPI IDirect3DViewportImpl_AddLight(IDirect3DViewport3 *iface, ...@@ -730,10 +737,11 @@ static HRESULT WINAPI IDirect3DViewportImpl_AddLight(IDirect3DViewport3 *iface,
TRACE("iface %p, light %p.\n", iface, lpDirect3DLight); TRACE("iface %p, light %p.\n", iface, lpDirect3DLight);
EnterCriticalSection(&ddraw_cs); wined3d_mutex_lock();
if (This->num_lights >= 8) if (This->num_lights >= 8)
{ {
LeaveCriticalSection(&ddraw_cs); wined3d_mutex_unlock();
return DDERR_INVALIDPARAMS; return DDERR_INVALIDPARAMS;
} }
...@@ -758,7 +766,8 @@ static HRESULT WINAPI IDirect3DViewportImpl_AddLight(IDirect3DViewport3 *iface, ...@@ -758,7 +766,8 @@ static HRESULT WINAPI IDirect3DViewportImpl_AddLight(IDirect3DViewport3 *iface,
if (This->active_device) if (This->active_device)
light_activate(lpDirect3DLightImpl); light_activate(lpDirect3DLightImpl);
LeaveCriticalSection(&ddraw_cs); wined3d_mutex_unlock();
return D3D_OK; return D3D_OK;
} }
...@@ -783,12 +792,12 @@ static HRESULT WINAPI IDirect3DViewportImpl_DeleteLight(IDirect3DViewport3 *ifac ...@@ -783,12 +792,12 @@ static HRESULT WINAPI IDirect3DViewportImpl_DeleteLight(IDirect3DViewport3 *ifac
TRACE("iface %p, light %p.\n", iface, lpDirect3DLight); TRACE("iface %p, light %p.\n", iface, lpDirect3DLight);
EnterCriticalSection(&ddraw_cs); wined3d_mutex_lock();
if (l->active_viewport != This) if (l->active_viewport != This)
{ {
WARN("Light %p active viewport is %p.\n", l, l->active_viewport); WARN("Light %p active viewport is %p.\n", l, l->active_viewport);
LeaveCriticalSection(&ddraw_cs); wined3d_mutex_unlock();
return DDERR_INVALIDPARAMS; return DDERR_INVALIDPARAMS;
} }
...@@ -799,7 +808,7 @@ static HRESULT WINAPI IDirect3DViewportImpl_DeleteLight(IDirect3DViewport3 *ifac ...@@ -799,7 +808,7 @@ static HRESULT WINAPI IDirect3DViewportImpl_DeleteLight(IDirect3DViewport3 *ifac
--This->num_lights; --This->num_lights;
This->map_lights &= ~(1 << l->dwLightIndex); This->map_lights &= ~(1 << l->dwLightIndex);
LeaveCriticalSection(&ddraw_cs); wined3d_mutex_unlock();
return D3D_OK; return D3D_OK;
} }
...@@ -831,7 +840,7 @@ static HRESULT WINAPI IDirect3DViewportImpl_NextLight(IDirect3DViewport3 *iface, ...@@ -831,7 +840,7 @@ static HRESULT WINAPI IDirect3DViewportImpl_NextLight(IDirect3DViewport3 *iface,
if (!lplpDirect3DLight) if (!lplpDirect3DLight)
return DDERR_INVALIDPARAMS; return DDERR_INVALIDPARAMS;
EnterCriticalSection(&ddraw_cs); wined3d_mutex_lock();
switch (dwFlags) switch (dwFlags)
{ {
...@@ -872,7 +881,7 @@ static HRESULT WINAPI IDirect3DViewportImpl_NextLight(IDirect3DViewport3 *iface, ...@@ -872,7 +881,7 @@ static HRESULT WINAPI IDirect3DViewportImpl_NextLight(IDirect3DViewport3 *iface,
hr = DDERR_INVALIDPARAMS; hr = DDERR_INVALIDPARAMS;
} }
LeaveCriticalSection(&ddraw_cs); wined3d_mutex_unlock();
return hr; return hr;
} }
...@@ -906,7 +915,7 @@ IDirect3DViewportImpl_GetViewport2(IDirect3DViewport3 *iface, ...@@ -906,7 +915,7 @@ IDirect3DViewportImpl_GetViewport2(IDirect3DViewport3 *iface,
TRACE("iface %p, data %p.\n", iface, lpData); TRACE("iface %p, data %p.\n", iface, lpData);
EnterCriticalSection(&ddraw_cs); wined3d_mutex_lock();
dwSize = lpData->dwSize; dwSize = lpData->dwSize;
memset(lpData, 0, dwSize); memset(lpData, 0, dwSize);
if (This->use_vp2) if (This->use_vp2)
...@@ -933,7 +942,8 @@ IDirect3DViewportImpl_GetViewport2(IDirect3DViewport3 *iface, ...@@ -933,7 +942,8 @@ IDirect3DViewportImpl_GetViewport2(IDirect3DViewport3 *iface,
_dump_D3DVIEWPORT2(lpData); _dump_D3DVIEWPORT2(lpData);
} }
LeaveCriticalSection(&ddraw_cs); wined3d_mutex_unlock();
return D3D_OK; return D3D_OK;
} }
...@@ -964,7 +974,8 @@ IDirect3DViewportImpl_SetViewport2(IDirect3DViewport3 *iface, ...@@ -964,7 +974,8 @@ IDirect3DViewportImpl_SetViewport2(IDirect3DViewport3 *iface,
_dump_D3DVIEWPORT2(lpData); _dump_D3DVIEWPORT2(lpData);
} }
EnterCriticalSection(&ddraw_cs); wined3d_mutex_lock();
This->use_vp2 = 1; This->use_vp2 = 1;
memset(&(This->viewports.vp2), 0, sizeof(This->viewports.vp2)); memset(&(This->viewports.vp2), 0, sizeof(This->viewports.vp2));
memcpy(&(This->viewports.vp2), lpData, lpData->dwSize); memcpy(&(This->viewports.vp2), lpData, lpData->dwSize);
...@@ -978,7 +989,8 @@ IDirect3DViewportImpl_SetViewport2(IDirect3DViewport3 *iface, ...@@ -978,7 +989,8 @@ IDirect3DViewportImpl_SetViewport2(IDirect3DViewport3 *iface,
IDirect3DViewport3_Release(current_viewport); IDirect3DViewport3_Release(current_viewport);
} }
} }
LeaveCriticalSection(&ddraw_cs);
wined3d_mutex_unlock();
return D3D_OK; return D3D_OK;
} }
...@@ -1064,10 +1076,11 @@ IDirect3DViewportImpl_Clear2(IDirect3DViewport3 *iface, ...@@ -1064,10 +1076,11 @@ IDirect3DViewportImpl_Clear2(IDirect3DViewport3 *iface,
TRACE("iface %p, rect_count %u, rects %p, flags %#x, color 0x%08x, depth %.8e, stencil %u.\n", TRACE("iface %p, rect_count %u, rects %p, flags %#x, color 0x%08x, depth %.8e, stencil %u.\n",
iface, dwCount, lpRects, dwFlags, dwColor, dvZ, dwStencil); iface, dwCount, lpRects, dwFlags, dwColor, dvZ, dwStencil);
EnterCriticalSection(&ddraw_cs); wined3d_mutex_lock();
if (This->active_device == NULL) { if (This->active_device == NULL) {
ERR(" Trying to clear a viewport not attached to a device !\n"); ERR(" Trying to clear a viewport not attached to a device !\n");
LeaveCriticalSection(&ddraw_cs); wined3d_mutex_unlock();
return D3DERR_VIEWPORTHASNODEVICE; return D3DERR_VIEWPORTHASNODEVICE;
} }
d3d_device3 = &This->active_device->IDirect3DDevice3_iface; d3d_device3 = &This->active_device->IDirect3DDevice3_iface;
...@@ -1083,7 +1096,9 @@ IDirect3DViewportImpl_Clear2(IDirect3DViewport3 *iface, ...@@ -1083,7 +1096,9 @@ IDirect3DViewportImpl_Clear2(IDirect3DViewport3 *iface,
viewport_activate(vp, TRUE); viewport_activate(vp, TRUE);
IDirect3DViewport3_Release(current_viewport); IDirect3DViewport3_Release(current_viewport);
} }
LeaveCriticalSection(&ddraw_cs);
wined3d_mutex_unlock();
return hr; return hr;
} }
......
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