[PATCH 5/5] d3d9: Use the wined3d cs for wined3d locking.
Henri Verbeet
hverbeet at codeweavers.com
Wed Aug 26 03:18:09 CDT 2009
---
dlls/d3d9/cubetexture.c | 101 ++++++-----
dlls/d3d9/d3d9_main.c | 14 +-
dlls/d3d9/d3d9_private.h | 1 -
dlls/d3d9/device.c | 405 ++++++++++++++++++++++++-----------------
dlls/d3d9/directx.c | 75 +++++---
dlls/d3d9/indexbuffer.c | 59 ++++---
dlls/d3d9/pixelshader.c | 61 ++++---
dlls/d3d9/query.c | 40 +++--
dlls/d3d9/stateblock.c | 41 +++--
dlls/d3d9/surface.c | 69 ++++---
dlls/d3d9/swapchain.c | 51 +++---
dlls/d3d9/texture.c | 106 +++++++-----
dlls/d3d9/vertexbuffer.c | 60 ++++---
dlls/d3d9/vertexdeclaration.c | 26 ++-
dlls/d3d9/vertexshader.c | 62 ++++---
dlls/d3d9/volume.c | 33 ++--
dlls/d3d9/volumetexture.c | 85 +++++-----
17 files changed, 746 insertions(+), 543 deletions(-)
diff --git a/dlls/d3d9/cubetexture.c b/dlls/d3d9/cubetexture.c
index 90c174c..8209d0b 100644
--- a/dlls/d3d9/cubetexture.c
+++ b/dlls/d3d9/cubetexture.c
@@ -61,10 +61,10 @@ static ULONG WINAPI IDirect3DCubeTexture9Impl_Release(LPDIRECT3DCUBETEXTURE9 ifa
if (ref == 0) {
TRACE("Releasing child %p\n", This->wineD3DCubeTexture);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
IWineD3DCubeTexture_Destroy(This->wineD3DCubeTexture, D3D9CB_DestroySurface);
IDirect3DDevice9Ex_Release(This->parentDevice);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
HeapFree(GetProcessHeap(), 0, This);
}
@@ -78,14 +78,15 @@ static HRESULT WINAPI IDirect3DCubeTexture9Impl_GetDevice(LPDIRECT3DCUBETEXTURE9
HRESULT hr;
TRACE("(%p) Relay\n" , This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DCubeTexture_GetDevice(This->wineD3DCubeTexture, &wined3d_device);
if (SUCCEEDED(hr))
{
IWineD3DDevice_GetParent(wined3d_device, (IUnknown **)ppDevice);
IWineD3DDevice_Release(wined3d_device);
}
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -94,9 +95,10 @@ static HRESULT WINAPI IDirect3DCubeTexture9Impl_SetPrivateData(LPDIRECT3DCUBETEX
HRESULT hr;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DCubeTexture_SetPrivateData(This->wineD3DCubeTexture,refguid,pData,SizeOfData,Flags);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -105,9 +107,10 @@ static HRESULT WINAPI IDirect3DCubeTexture9Impl_GetPrivateData(LPDIRECT3DCUBETEX
HRESULT hr;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DCubeTexture_GetPrivateData(This->wineD3DCubeTexture,refguid,pData,pSizeOfData);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -116,9 +119,10 @@ static HRESULT WINAPI IDirect3DCubeTexture9Impl_FreePrivateData(LPDIRECT3DCUBETE
HRESULT hr;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DCubeTexture_FreePrivateData(This->wineD3DCubeTexture,refguid);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -127,9 +131,10 @@ static DWORD WINAPI IDirect3DCubeTexture9Impl_SetPriority(LPDIRECT3DCUBETEXTURE9
DWORD ret;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
ret = IWineD3DCubeTexture_SetPriority(This->wineD3DCubeTexture, PriorityNew);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return ret;
}
@@ -138,9 +143,10 @@ static DWORD WINAPI IDirect3DCubeTexture9Impl_GetPriority(LPDIRECT3DCUBETEXTURE9
DWORD ret;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
ret = IWineD3DCubeTexture_GetPriority(This->wineD3DCubeTexture);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return ret;
}
@@ -148,9 +154,9 @@ static void WINAPI IDirect3DCubeTexture9Impl_PreLoad(LPDIRECT3DCUBETEXTURE9 ifac
IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
IWineD3DCubeTexture_PreLoad(This->wineD3DCubeTexture);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
}
static D3DRESOURCETYPE WINAPI IDirect3DCubeTexture9Impl_GetType(LPDIRECT3DCUBETEXTURE9 iface) {
@@ -158,9 +164,10 @@ static D3DRESOURCETYPE WINAPI IDirect3DCubeTexture9Impl_GetType(LPDIRECT3DCUBETE
D3DRESOURCETYPE ret;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
ret = IWineD3DCubeTexture_GetType(This->wineD3DCubeTexture);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return ret;
}
@@ -170,9 +177,10 @@ static DWORD WINAPI IDirect3DCubeTexture9Impl_SetLOD(LPDIRECT3DCUBETEXTURE9 ifac
DWORD ret;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
ret = IWineD3DCubeTexture_SetLOD(This->wineD3DCubeTexture, LODNew);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return ret;
}
@@ -181,9 +189,10 @@ static DWORD WINAPI IDirect3DCubeTexture9Impl_GetLOD(LPDIRECT3DCUBETEXTURE9 ifac
DWORD ret;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
ret = IWineD3DCubeTexture_GetLOD(This->wineD3DCubeTexture);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return ret;
}
@@ -192,9 +201,10 @@ static DWORD WINAPI IDirect3DCubeTexture9Impl_GetLevelCount(LPDIRECT3DCUBETEXTUR
DWORD ret;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
ret = IWineD3DCubeTexture_GetLevelCount(This->wineD3DCubeTexture);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return ret;
}
@@ -203,9 +213,10 @@ static HRESULT WINAPI IDirect3DCubeTexture9Impl_SetAutoGenFilterType(LPDIRECT3DC
HRESULT hr;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DCubeTexture_SetAutoGenFilterType(This->wineD3DCubeTexture, (WINED3DTEXTUREFILTERTYPE) FilterType);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -214,9 +225,10 @@ static D3DTEXTUREFILTERTYPE WINAPI IDirect3DCubeTexture9Impl_GetAutoGenFilterTyp
D3DTEXTUREFILTERTYPE ret;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
ret = (D3DTEXTUREFILTERTYPE) IWineD3DCubeTexture_GetAutoGenFilterType(This->wineD3DCubeTexture);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return ret;
}
@@ -224,9 +236,9 @@ static void WINAPI IDirect3DCubeTexture9Impl_GenerateMipSubLevels(LPDIRECT3DCUBE
IDirect3DCubeTexture9Impl *This = (IDirect3DCubeTexture9Impl *)iface;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
IWineD3DCubeTexture_GenerateMipSubLevels(This->wineD3DCubeTexture);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
}
/* IDirect3DCubeTexture9 Interface follow: */
@@ -237,9 +249,9 @@ static HRESULT WINAPI IDirect3DCubeTexture9Impl_GetLevelDesc(LPDIRECT3DCUBETEXTU
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DCubeTexture_GetLevelDesc(This->wineD3DCubeTexture, Level, &wined3ddesc);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
if (SUCCEEDED(hr))
{
@@ -263,13 +275,14 @@ static HRESULT WINAPI IDirect3DCubeTexture9Impl_GetCubeMapSurface(LPDIRECT3DCUBE
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hrc = IWineD3DCubeTexture_GetCubeMapSurface(This->wineD3DCubeTexture, (WINED3DCUBEMAP_FACES) FaceType, Level, &mySurface);
if (hrc == D3D_OK && NULL != ppCubeMapSurface) {
IWineD3DCubeTexture_GetParent(mySurface, (IUnknown **)ppCubeMapSurface);
IWineD3DCubeTexture_Release(mySurface);
}
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hrc;
}
@@ -278,9 +291,10 @@ static HRESULT WINAPI IDirect3DCubeTexture9Impl_LockRect(LPDIRECT3DCUBETEXTURE9
HRESULT hr;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DCubeTexture_LockRect(This->wineD3DCubeTexture, (WINED3DCUBEMAP_FACES) FaceType, Level, (WINED3DLOCKED_RECT *) pLockedRect, pRect, Flags);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -289,9 +303,10 @@ static HRESULT WINAPI IDirect3DCubeTexture9Impl_UnlockRect(LPDIRECT3DCUBETEXTURE
HRESULT hr;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DCubeTexture_UnlockRect(This->wineD3DCubeTexture, (WINED3DCUBEMAP_FACES) FaceType, Level);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -300,9 +315,10 @@ static HRESULT WINAPI IDirect3DCubeTexture9Impl_AddDirtyRect(LPDIRECT3DCUBETEXT
HRESULT hr;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DCubeTexture_AddDirtyRect(This->wineD3DCubeTexture, (WINED3DCUBEMAP_FACES) FaceType, pDirtyRect);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -360,10 +376,11 @@ HRESULT WINAPI IDirect3DDevice9Impl_CreateCubeTexture(LPDIRECT3DDEVICE9EX ifac
}
object->lpVtbl = &Direct3DCubeTexture9_Vtbl;
object->ref = 1;
- EnterCriticalSection(&d3d9_cs);
+
+ wined3d_mutex_lock();
hr = IWineD3DDevice_CreateCubeTexture(This->WineD3DDevice, EdgeLength, Levels, Usage,
wined3dformat_from_d3dformat(Format), Pool, &object->wineD3DCubeTexture, (IUnknown *)object);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
if (hr != D3D_OK){
diff --git a/dlls/d3d9/d3d9_main.c b/dlls/d3d9/d3d9_main.c
index 40d73a5..f59fc46 100644
--- a/dlls/d3d9/d3d9_main.c
+++ b/dlls/d3d9/d3d9_main.c
@@ -25,15 +25,6 @@
#include "initguid.h"
#include "d3d9_private.h"
-static CRITICAL_SECTION_DEBUG d3d9_cs_debug =
-{
- 0, 0, &d3d9_cs,
- { &d3d9_cs_debug.ProcessLocksList,
- &d3d9_cs_debug.ProcessLocksList },
- 0, 0, { (DWORD_PTR)(__FILE__ ": d3d9_cs") }
-};
-CRITICAL_SECTION d3d9_cs = { &d3d9_cs_debug, -1, 0, 0, 0, 0 };
-
WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
static int D3DPERF_event_level = 0;
@@ -47,9 +38,10 @@ IDirect3D9* WINAPI Direct3DCreate9(UINT SDKVersion) {
object->lpVtbl = &Direct3D9_Vtbl;
object->ref = 1;
- EnterCriticalSection(&d3d9_cs);
+
+ wined3d_mutex_lock();
object->WineD3D = WineDirect3DCreate(9, (IUnknown *)object);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
TRACE("SDKVersion = %x, Created Direct3D object @ %p, WineObj @ %p\n", SDKVersion, object, object->WineD3D);
diff --git a/dlls/d3d9/d3d9_private.h b/dlls/d3d9/d3d9_private.h
index 7e43974..4983f13 100644
--- a/dlls/d3d9/d3d9_private.h
+++ b/dlls/d3d9/d3d9_private.h
@@ -44,7 +44,6 @@
extern HRESULT vdecl_convert_fvf(
DWORD FVF,
D3DVERTEXELEMENT9** ppVertexElements);
-extern CRITICAL_SECTION d3d9_cs;
D3DFORMAT d3dformat_from_wined3dformat(WINED3DFORMAT format);
WINED3DFORMAT wined3dformat_from_d3dformat(D3DFORMAT format);
diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c
index 14885de..61bfc58 100644
--- a/dlls/d3d9/device.c
+++ b/dlls/d3d9/device.c
@@ -248,7 +248,7 @@ static ULONG WINAPI IDirect3DDevice9Impl_Release(LPDIRECT3DDEVICE9EX iface) {
unsigned i;
This->inDestruction = TRUE;
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
for(i = 0; i < This->numConvertedDecls; i++) {
/* Unless Wine is buggy or the app has a bug the refcount will be 0, because decls hold a reference to the
* device
@@ -259,7 +259,8 @@ static ULONG WINAPI IDirect3DDevice9Impl_Release(LPDIRECT3DDEVICE9EX iface) {
IWineD3DDevice_Uninit3D(This->WineD3DDevice, D3D9CB_DestroyDepthStencilSurface, D3D9CB_DestroySwapChain);
IWineD3DDevice_Release(This->WineD3DDevice);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
HeapFree(GetProcessHeap(), 0, This);
}
return ref;
@@ -271,9 +272,10 @@ static HRESULT WINAPI IDirect3DDevice9Impl_TestCooperativeLevel(LPDIRECT3DDEVI
HRESULT hr;
TRACE("(%p)\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DDevice_TestCooperativeLevel(This->WineD3DDevice);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
if(hr == WINED3D_OK && This->notreset) {
TRACE("D3D9 Device is marked not reset\n");
hr = D3DERR_DEVICENOTRESET;
@@ -287,9 +289,10 @@ static UINT WINAPI IDirect3DDevice9Impl_GetAvailableTextureMem(LPDIRECT3DDE
HRESULT hr;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DDevice_GetAvailableTextureMem(This->WineD3DDevice);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -298,9 +301,10 @@ static HRESULT WINAPI IDirect3DDevice9Impl_EvictManagedResources(LPDIRECT3DDEV
HRESULT hr;
TRACE("(%p) : Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DDevice_EvictManagedResources(This->WineD3DDevice);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -315,7 +319,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetDirect3D(LPDIRECT3DDEVICE9EX iface
return D3DERR_INVALIDCALL;
}
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DDevice_GetDirect3D(This->WineD3DDevice, &pWineD3D);
if (hr == D3D_OK && pWineD3D != NULL)
{
@@ -326,7 +330,8 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetDirect3D(LPDIRECT3DDEVICE9EX iface
*ppD3D9 = NULL;
}
TRACE("(%p) returning %p\n", This, *ppD3D9);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -345,9 +350,11 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetDeviceCaps(LPDIRECT3DDEVICE9EX i
}
memset(pCaps, 0, sizeof(*pCaps));
- EnterCriticalSection(&d3d9_cs);
+
+ wined3d_mutex_lock();
hrc = IWineD3DDevice_GetDeviceCaps(This->WineD3DDevice, pWineCaps);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
WINECAPSTOD3D9CAPS(pCaps, pWineCaps)
HeapFree(GetProcessHeap(), 0, pWineCaps);
@@ -365,9 +372,9 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetDisplayMode(LPDIRECT3DDEVICE9EX
HRESULT hr;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DDevice_GetDisplayMode(This->WineD3DDevice, iSwapChain, (WINED3DDISPLAYMODE *) pMode);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
if (SUCCEEDED(hr)) pMode->Format = d3dformat_from_wined3dformat(pMode->Format);
@@ -379,9 +386,10 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetCreationParameters(LPDIRECT3DDEV
HRESULT hr;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DDevice_GetCreationParameters(This->WineD3DDevice, (WINED3DDEVICE_CREATION_PARAMETERS *) pParameters);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -396,9 +404,10 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetCursorProperties(LPDIRECT3DDEVIC
return WINED3DERR_INVALIDCALL;
}
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DDevice_SetCursorProperties(This->WineD3DDevice, XHotSpot, YHotSpot, pSurface->wineD3DSurface);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -406,9 +415,9 @@ static void WINAPI IDirect3DDevice9Impl_SetCursorPosition(LPDIRECT3DDEVICE9
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
IWineD3DDevice_SetCursorPosition(This->WineD3DDevice, XScreenSpace, YScreenSpace, Flags);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
}
static BOOL WINAPI IDirect3DDevice9Impl_ShowCursor(LPDIRECT3DDEVICE9EX iface, BOOL bShow) {
@@ -416,9 +425,10 @@ static BOOL WINAPI IDirect3DDevice9Impl_ShowCursor(LPDIRECT3DDEVICE9EX ifac
BOOL ret;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
ret = IWineD3DDevice_ShowCursor(This->WineD3DDevice, bShow);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return ret;
}
@@ -497,7 +507,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_Reset(LPDIRECT3DDEVICE9EX iface, D3
* Unsetting them is no problem, because the states are supposed to be reset anyway. If the validation
* below fails, the device is considered "lost", and _Reset and _Release are the only allowed calls
*/
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
IWineD3DDevice_SetIndices(This->WineD3DDevice, NULL, WINED3DFMT_UNKNOWN);
for(i = 0; i < 16; i++) {
IWineD3DDevice_SetStreamSource(This->WineD3DDevice, i, NULL, 0, 0);
@@ -510,7 +520,8 @@ static HRESULT WINAPI IDirect3DDevice9Impl_Reset(LPDIRECT3DDEVICE9EX iface, D3
if(!resources_ok) {
WARN("The application is holding D3DPOOL_DEFAULT resources, rejecting reset\n");
This->notreset = TRUE;
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return WINED3DERR_INVALIDCALL;
}
@@ -552,7 +563,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_Reset(LPDIRECT3DDEVICE9EX iface, D3
This->notreset = FALSE;
}
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
return hr;
}
@@ -563,9 +574,10 @@ static HRESULT WINAPI IDirect3DDevice9Impl_Present(LPDIRECT3DDEVICE9EX iface,
HRESULT hr;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DDevice_Present(This->WineD3DDevice, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -576,13 +588,14 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetBackBuffer(LPDIRECT3DDEVICE9EX i
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
rc = IWineD3DDevice_GetBackBuffer(This->WineD3DDevice, iSwapChain, BackBuffer, (WINED3DBACKBUFFER_TYPE) Type, &retSurface);
if (rc == D3D_OK && NULL != retSurface && NULL != ppBackBuffer) {
IWineD3DSurface_GetParent(retSurface, (IUnknown **)ppBackBuffer);
IWineD3DSurface_Release(retSurface);
}
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return rc;
}
static HRESULT WINAPI IDirect3DDevice9Impl_GetRasterStatus(LPDIRECT3DDEVICE9EX iface, UINT iSwapChain, D3DRASTER_STATUS* pRasterStatus) {
@@ -590,9 +603,10 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetRasterStatus(LPDIRECT3DDEVICE9EX
HRESULT hr;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DDevice_GetRasterStatus(This->WineD3DDevice, iSwapChain, (WINED3DRASTER_STATUS *) pRasterStatus);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -601,9 +615,10 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetDialogBoxMode(LPDIRECT3DDEVICE9EX
HRESULT hr;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DDevice_SetDialogBoxMode(This->WineD3DDevice, bEnableDialogs);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -612,20 +627,20 @@ static void WINAPI IDirect3DDevice9Impl_SetGammaRamp(LPDIRECT3DDEVICE9EX iface,
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
/* Note: D3DGAMMARAMP is compatible with WINED3DGAMMARAMP */
+ wined3d_mutex_lock();
IWineD3DDevice_SetGammaRamp(This->WineD3DDevice, iSwapChain, Flags, (CONST WINED3DGAMMARAMP *)pRamp);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
}
static void WINAPI IDirect3DDevice9Impl_GetGammaRamp(LPDIRECT3DDEVICE9EX iface, UINT iSwapChain, D3DGAMMARAMP* pRamp) {
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
/* Note: D3DGAMMARAMP is compatible with WINED3DGAMMARAMP */
+ wined3d_mutex_lock();
IWineD3DDevice_GetGammaRamp(This->WineD3DDevice, iSwapChain, (WINED3DGAMMARAMP *) pRamp);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
}
@@ -661,11 +676,11 @@ static HRESULT IDirect3DDevice9Impl_CreateSurface(LPDIRECT3DDEVICE9EX iface, UIN
TRACE("(%p) : w(%d) h(%d) fmt(%d) surf@%p\n", This, Width, Height, Format, *ppSurface);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hrc = IWineD3DDevice_CreateSurface(This->WineD3DDevice, Width, Height, wined3dformat_from_d3dformat(Format),
Lockable, Discard, Level, &object->wineD3DSurface, Usage & WINED3DUSAGE_MASK, (WINED3DPOOL)Pool,
MultiSample, MultisampleQuality, SURFACE_OPENGL, (IUnknown *)object);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
if (hrc != D3D_OK || NULL == object->wineD3DSurface) {
@@ -715,9 +730,10 @@ static HRESULT WINAPI IDirect3DDevice9Impl_UpdateSurface(LPDIRECT3DDEVICE9EX i
HRESULT hr;
TRACE("(%p) Relay\n" , This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DDevice_UpdateSurface(This->WineD3DDevice, ((IDirect3DSurface9Impl *)pSourceSurface)->wineD3DSurface, pSourceRect, ((IDirect3DSurface9Impl *)pDestinationSurface)->wineD3DSurface, pDestPoint);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -726,9 +742,10 @@ static HRESULT WINAPI IDirect3DDevice9Impl_UpdateTexture(LPDIRECT3DDEVICE9EX i
HRESULT hr;
TRACE("(%p) Relay\n" , This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DDevice_UpdateTexture(This->WineD3DDevice, ((IDirect3DBaseTexture9Impl *)pSourceTexture)->wineD3DBaseTexture, ((IDirect3DBaseTexture9Impl *)pDestinationTexture)->wineD3DBaseTexture);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -739,9 +756,10 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetRenderTargetData(LPDIRECT3DDEVIC
HRESULT hr;
TRACE("(%p)->(%p,%p)\n" , This, renderTarget, destSurface);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DSurface_BltFast(destSurface->wineD3DSurface, 0, 0, renderTarget->wineD3DSurface, NULL, WINEDDBLTFAST_NOCOLORKEY);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -751,9 +769,10 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetFrontBufferData(LPDIRECT3DDEVICE
HRESULT hr;
TRACE("(%p) Relay\n" , This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DDevice_GetFrontBufferData(This->WineD3DDevice, iSwapChain, destSurface->wineD3DSurface);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -764,9 +783,11 @@ static HRESULT WINAPI IDirect3DDevice9Impl_StretchRect(LPDIRECT3DDEVICE9EX ifa
HRESULT hr;
TRACE("(%p)->(%p,%p,%p,%p,%d)\n" , This, src, pSourceRect, dst, pDestRect, Filter);
- EnterCriticalSection(&d3d9_cs);
+
+ wined3d_mutex_lock();
hr = IWineD3DSurface_Blt(dst->wineD3DSurface, pDestRect, src->wineD3DSurface, pSourceRect, 0, NULL, Filter);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -780,7 +801,8 @@ static HRESULT WINAPI IDirect3DDevice9Impl_ColorFill(LPDIRECT3DDEVICE9EX iface
HRESULT hr;
TRACE("(%p) Relay\n" , This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
+
IWineD3DSurface_GetDesc(surface->wineD3DSurface, &desc);
usage = desc.usage;
pool = desc.pool;
@@ -790,7 +812,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_ColorFill(LPDIRECT3DDEVICE9EX iface
* in D3DPOOL_DEFAULT
*/
if(!(usage & WINED3DUSAGE_RENDERTARGET) && (pool != WINED3DPOOL_DEFAULT || restype != WINED3DRTYPE_SURFACE)) {
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
WARN("Surface is not a render target, or not a stand-alone D3DPOOL_DEFAULT surface\n");
return D3DERR_INVALIDCALL;
}
@@ -798,7 +820,9 @@ static HRESULT WINAPI IDirect3DDevice9Impl_ColorFill(LPDIRECT3DDEVICE9EX iface
/* Colorfill can only be used on rendertarget surfaces, or offscreen plain surfaces in D3DPOOL_DEFAULT */
/* Note: D3DRECT is compatible with WINED3DRECT */
hr = IWineD3DDevice_ColorFill(This->WineD3DDevice, surface->wineD3DSurface, (CONST WINED3DRECT*)pRect, color);
- LeaveCriticalSection(&d3d9_cs);
+
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -830,9 +854,10 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetRenderTarget(LPDIRECT3DDEVICE9EX
HRESULT hr;
TRACE("(%p) Relay\n" , This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DDevice_SetRenderTarget(This->WineD3DDevice, RenderTargetIndex, pSurface ? pSurface->wineD3DSurface : NULL);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -847,7 +872,8 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetRenderTarget(LPDIRECT3DDEVICE9EX
return D3DERR_INVALIDCALL;
}
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
+
hr=IWineD3DDevice_GetRenderTarget(This->WineD3DDevice,RenderTargetIndex,&pRenderTarget);
if (FAILED(hr))
@@ -864,7 +890,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetRenderTarget(LPDIRECT3DDEVICE9EX
IWineD3DSurface_Release(pRenderTarget);
}
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
return hr;
}
@@ -876,9 +902,11 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetDepthStencilSurface(LPDIRECT3DDE
TRACE("(%p) Relay\n" , This);
pSurface = (IDirect3DSurface9Impl*)pZStencilSurface;
- EnterCriticalSection(&d3d9_cs);
+
+ wined3d_mutex_lock();
hr = IWineD3DDevice_SetDepthStencilSurface(This->WineD3DDevice, NULL==pSurface ? NULL : pSurface->wineD3DSurface);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -892,7 +920,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetDepthStencilSurface(LPDIRECT3DDE
return D3DERR_INVALIDCALL;
}
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DDevice_GetDepthStencilSurface(This->WineD3DDevice,&pZStencilSurface);
if (hr == WINED3D_OK) {
IWineD3DSurface_GetParent(pZStencilSurface,(IUnknown**)ppZStencilSurface);
@@ -902,7 +930,8 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetDepthStencilSurface(LPDIRECT3DDE
WARN("Call to IWineD3DDevice_GetDepthStencilSurface failed with 0x%08x\n", hr);
*ppZStencilSurface = NULL;
}
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -911,9 +940,10 @@ static HRESULT WINAPI IDirect3DDevice9Impl_BeginScene(LPDIRECT3DDEVICE9EX ifac
HRESULT hr;
TRACE("(%p) Relay\n" , This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DDevice_BeginScene(This->WineD3DDevice);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -922,9 +952,10 @@ static HRESULT WINAPI IDirect3DDevice9Impl_EndScene(LPDIRECT3DDEVICE9EX iface)
HRESULT hr;
TRACE("(%p) Relay\n" , This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DDevice_EndScene(This->WineD3DDevice);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -934,9 +965,10 @@ static HRESULT WINAPI IDirect3DDevice9Impl_Clear(LPDIRECT3DDEVICE9EX iface, DW
TRACE("(%p) Relay\n" , This);
/* Note: D3DRECT is compatible with WINED3DRECT */
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DDevice_Clear(This->WineD3DDevice, Count, (CONST WINED3DRECT*) pRects, Flags, Color, Z, Stencil);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -946,9 +978,10 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetTransform(LPDIRECT3DDEVICE9EX if
TRACE("(%p) Relay\n" , This);
/* Note: D3DMATRIX is compatible with WINED3DMATRIX */
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DDevice_SetTransform(This->WineD3DDevice, State, (CONST WINED3DMATRIX*) lpMatrix);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -958,10 +991,10 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetTransform(LPDIRECT3DDEVICE9EX if
TRACE("(%p) Relay\n" , This);
- EnterCriticalSection(&d3d9_cs);
/* Note: D3DMATRIX is compatible with WINED3DMATRIX */
+ wined3d_mutex_lock();
hr = IWineD3DDevice_GetTransform(This->WineD3DDevice, State, (WINED3DMATRIX*) pMatrix);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
return hr;
}
@@ -972,9 +1005,10 @@ static HRESULT WINAPI IDirect3DDevice9Impl_MultiplyTransform(LPDIRECT3DDEVICE9
TRACE("(%p) Relay\n" , This);
/* Note: D3DMATRIX is compatible with WINED3DMATRIX */
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DDevice_MultiplyTransform(This->WineD3DDevice, State, (CONST WINED3DMATRIX*) pMatrix);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -984,9 +1018,10 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetViewport(LPDIRECT3DDEVICE9EX ifa
TRACE("(%p) Relay\n" , This);
/* Note: D3DVIEWPORT9 is compatible with WINED3DVIEWPORT */
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DDevice_SetViewport(This->WineD3DDevice, (const WINED3DVIEWPORT *)pViewport);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -996,9 +1031,10 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetViewport(LPDIRECT3DDEVICE9EX ifa
TRACE("(%p) Relay\n" , This);
/* Note: D3DVIEWPORT9 is compatible with WINED3DVIEWPORT */
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DDevice_GetViewport(This->WineD3DDevice, (WINED3DVIEWPORT *)pViewport);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -1008,9 +1044,10 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetMaterial(LPDIRECT3DDEVICE9EX ifa
TRACE("(%p) Relay\n" , This);
/* Note: D3DMATERIAL9 is compatible with WINED3DMATERIAL */
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DDevice_SetMaterial(This->WineD3DDevice, (const WINED3DMATERIAL *)pMaterial);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -1020,9 +1057,10 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetMaterial(LPDIRECT3DDEVICE9EX ifa
TRACE("(%p) Relay\n" , This);
/* Note: D3DMATERIAL9 is compatible with WINED3DMATERIAL */
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DDevice_GetMaterial(This->WineD3DDevice, (WINED3DMATERIAL *)pMaterial);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -1032,9 +1070,10 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetLight(LPDIRECT3DDEVICE9EX iface,
TRACE("(%p) Relay\n" , This);
/* Note: D3DLIGHT9 is compatible with WINED3DLIGHT */
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DDevice_SetLight(This->WineD3DDevice, Index, (const WINED3DLIGHT *)pLight);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -1044,9 +1083,10 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetLight(LPDIRECT3DDEVICE9EX iface,
TRACE("(%p) Relay\n" , This);
/* Note: D3DLIGHT9 is compatible with WINED3DLIGHT */
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DDevice_GetLight(This->WineD3DDevice, Index, (WINED3DLIGHT *)pLight);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -1055,9 +1095,10 @@ static HRESULT WINAPI IDirect3DDevice9Impl_LightEnable(LPDIRECT3DDEVICE9EX ifa
HRESULT hr;
TRACE("(%p) Relay\n" , This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DDevice_SetLightEnable(This->WineD3DDevice, Index, Enable);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -1066,9 +1107,10 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetLightEnable(LPDIRECT3DDEVICE9EX
HRESULT hr;
TRACE("(%p) Relay\n" , This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DDevice_GetLightEnable(This->WineD3DDevice, Index, pEnable);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -1077,9 +1119,10 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetClipPlane(LPDIRECT3DDEVICE9EX if
HRESULT hr;
TRACE("(%p) Relay\n" , This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DDevice_SetClipPlane(This->WineD3DDevice, Index, pPlane);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -1088,9 +1131,10 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetClipPlane(LPDIRECT3DDEVICE9EX if
HRESULT hr;
TRACE("(%p) Relay\n" , This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DDevice_GetClipPlane(This->WineD3DDevice, Index, pPlane);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -1099,9 +1143,10 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetRenderState(LPDIRECT3DDEVICE9EX
HRESULT hr;
TRACE("(%p) Relay\n" , This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DDevice_SetRenderState(This->WineD3DDevice, State, Value);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -1110,9 +1155,10 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetRenderState(LPDIRECT3DDEVICE9EX
HRESULT hr;
TRACE("(%p) Relay\n" , This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DDevice_GetRenderState(This->WineD3DDevice, State, pValue);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -1121,9 +1167,10 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetClipStatus(LPDIRECT3DDEVICE9EX i
HRESULT hr;
TRACE("(%p) Relay\n" , This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DDevice_SetClipStatus(This->WineD3DDevice, (const WINED3DCLIPSTATUS *)pClipStatus);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -1132,9 +1179,10 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetClipStatus(LPDIRECT3DDEVICE9EX i
HRESULT hr;
TRACE("(%p) Relay\n" , This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DDevice_GetClipStatus(This->WineD3DDevice, (WINED3DCLIPSTATUS *)pClipStatus);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -1149,7 +1197,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetTexture(LPDIRECT3DDEVICE9EX ifac
return D3DERR_INVALIDCALL;
}
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
rc = IWineD3DDevice_GetTexture(This->WineD3DDevice, Stage, &retTexture);
if (SUCCEEDED(rc) && NULL != retTexture) {
IWineD3DBaseTexture_GetParent(retTexture, (IUnknown **)ppTexture);
@@ -1160,7 +1208,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetTexture(LPDIRECT3DDEVICE9EX ifac
}
*ppTexture = NULL;
}
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
return rc;
}
@@ -1170,10 +1218,11 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetTexture(LPDIRECT3DDEVICE9EX ifac
HRESULT hr;
TRACE("(%p) Relay %d %p\n" , This, Stage, pTexture);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DDevice_SetTexture(This->WineD3DDevice, Stage,
pTexture==NULL ? NULL:((IDirect3DBaseTexture9Impl *)pTexture)->wineD3DBaseTexture);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -1219,9 +1268,10 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetTextureStageState(LPDIRECT3DDEVI
HRESULT hr;
TRACE("(%p) Relay\n" , This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DDevice_GetTextureStageState(This->WineD3DDevice, Stage, tss_lookup[Type], pValue);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -1230,9 +1280,10 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetTextureStageState(LPDIRECT3DDEVI
HRESULT hr;
TRACE("(%p) Relay\n" , This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DDevice_SetTextureStageState(This->WineD3DDevice, Stage, tss_lookup[Type], Value);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -1241,9 +1292,10 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetSamplerState(LPDIRECT3DDEVICE9EX
HRESULT hr;
TRACE("(%p) Relay\n" , This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DDevice_GetSamplerState(This->WineD3DDevice, Sampler, Type, pValue);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -1252,9 +1304,10 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetSamplerState(LPDIRECT3DDEVICE9EX
HRESULT hr;
TRACE("(%p) Relay\n" , This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DDevice_SetSamplerState(This->WineD3DDevice, Sampler, Type, Value);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -1263,9 +1316,10 @@ static HRESULT WINAPI IDirect3DDevice9Impl_ValidateDevice(LPDIRECT3DDEVICE9EX
HRESULT hr;
TRACE("(%p) Relay\n" , This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DDevice_ValidateDevice(This->WineD3DDevice, pNumPasses);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -1274,9 +1328,10 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetPaletteEntries(LPDIRECT3DDEVICE9
HRESULT hr;
TRACE("(%p) Relay\n" , This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DDevice_SetPaletteEntries(This->WineD3DDevice, PaletteNumber, pEntries);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -1285,9 +1340,10 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetPaletteEntries(LPDIRECT3DDEVICE9
HRESULT hr;
TRACE("(%p) Relay\n" , This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DDevice_GetPaletteEntries(This->WineD3DDevice, PaletteNumber, pEntries);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -1296,9 +1352,10 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetCurrentTexturePalette(LPDIRECT3D
HRESULT hr;
TRACE("(%p) Relay\n" , This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DDevice_SetCurrentTexturePalette(This->WineD3DDevice, PaletteNumber);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -1307,9 +1364,10 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetCurrentTexturePalette(LPDIRECT3D
HRESULT hr;
TRACE("(%p) Relay\n" , This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DDevice_GetCurrentTexturePalette(This->WineD3DDevice, PaletteNumber);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -1318,9 +1376,10 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetScissorRect(LPDIRECT3DDEVICE9EX
HRESULT hr;
TRACE("(%p) Relay\n" , This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DDevice_SetScissorRect(This->WineD3DDevice, pRect);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -1329,9 +1388,10 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetScissorRect(LPDIRECT3DDEVICE9EX
HRESULT hr;
TRACE("(%p) Relay\n" , This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DDevice_GetScissorRect(This->WineD3DDevice, pRect);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -1340,9 +1400,10 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetSoftwareVertexProcessing(LPDIREC
HRESULT hr;
TRACE("(%p) Relay\n" , This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DDevice_SetSoftwareVertexProcessing(This->WineD3DDevice, bSoftware);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -1351,9 +1412,10 @@ static BOOL WINAPI IDirect3DDevice9Impl_GetSoftwareVertexProcessing(LPDIREC
BOOL ret;
TRACE("(%p) Relay\n" , This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
ret = IWineD3DDevice_GetSoftwareVertexProcessing(This->WineD3DDevice);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return ret;
}
@@ -1362,9 +1424,10 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetNPatchMode(LPDIRECT3DDEVICE9EX i
HRESULT hr;
TRACE("(%p) Relay\n" , This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DDevice_SetNPatchMode(This->WineD3DDevice, nSegments);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -1373,9 +1436,10 @@ static float WINAPI IDirect3DDevice9Impl_GetNPatchMode(LPDIRECT3DDEVICE9EX i
float ret;
TRACE("(%p) Relay\n" , This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
ret = IWineD3DDevice_GetNPatchMode(This->WineD3DDevice);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return ret;
}
@@ -1384,11 +1448,12 @@ static HRESULT WINAPI IDirect3DDevice9Impl_DrawPrimitive(LPDIRECT3DDEVICE9EX ifa
HRESULT hr;
TRACE("(%p) Relay\n" , This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
IWineD3DDevice_SetPrimitiveType(This->WineD3DDevice, PrimitiveType);
hr = IWineD3DDevice_DrawPrimitive(This->WineD3DDevice, StartVertex,
vertex_count_from_primitive_count(PrimitiveType, PrimitiveCount));
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -1399,12 +1464,13 @@ static HRESULT WINAPI IDirect3DDevice9Impl_DrawIndexedPrimitive(LPDIRECT3DDEVI
TRACE("(%p) Relay\n" , This);
/* D3D8 passes the baseVertexIndex in SetIndices, and due to the stateblock functions wined3d has to work that way */
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
IWineD3DDevice_SetBaseVertexIndex(This->WineD3DDevice, BaseVertexIndex);
IWineD3DDevice_SetPrimitiveType(This->WineD3DDevice, PrimitiveType);
hr = IWineD3DDevice_DrawIndexedPrimitive(This->WineD3DDevice, MinVertexIndex, NumVertices,
startIndex, vertex_count_from_primitive_count(PrimitiveType, primCount));
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -1413,12 +1479,13 @@ static HRESULT WINAPI IDirect3DDevice9Impl_DrawPrimitiveUP(LPDIRECT3DDEVICE9EX
HRESULT hr;
TRACE("(%p) Relay\n" , This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
IWineD3DDevice_SetPrimitiveType(This->WineD3DDevice, PrimitiveType);
hr = IWineD3DDevice_DrawPrimitiveUP(This->WineD3DDevice,
vertex_count_from_primitive_count(PrimitiveType, PrimitiveCount),
pVertexStreamZeroData, VertexStreamZeroStride);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -1429,12 +1496,13 @@ static HRESULT WINAPI IDirect3DDevice9Impl_DrawIndexedPrimitiveUP(LPDIRECT3DDE
HRESULT hr;
TRACE("(%p) Relay\n" , This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
IWineD3DDevice_SetPrimitiveType(This->WineD3DDevice, PrimitiveType);
hr = IWineD3DDevice_DrawIndexedPrimitiveUP(This->WineD3DDevice, MinVertexIndex, NumVertexIndices,
vertex_count_from_primitive_count(PrimitiveType, PrimitiveCount), pIndexData,
wined3dformat_from_d3dformat(IndexDataFormat), pVertexStreamZeroData, VertexStreamZeroStride);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -1445,9 +1513,10 @@ static HRESULT WINAPI IDirect3DDevice9Impl_ProcessVertices(LPDIRECT3DDEVICE9EX
IDirect3DVertexBuffer9Impl *dest = (IDirect3DVertexBuffer9Impl *) pDestBuffer;
TRACE("(%p) Relay\n" , This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DDevice_ProcessVertices(This->WineD3DDevice,SrcStartIndex, DestIndex, VertexCount, dest->wineD3DVertexBuffer, Decl ? Decl->wineD3DVertexDeclaration : NULL, Flags, dest->fvf);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -1521,9 +1590,9 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetFVF(LPDIRECT3DDEVICE9EX iface, DWO
return D3D_OK;
}
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
decl = getConvertedDecl(This, FVF);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
if (!decl)
{
@@ -1572,11 +1641,12 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetStreamSource(LPDIRECT3DDEVICE9EX i
HRESULT hr;
TRACE("(%p) Relay\n" , This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DDevice_SetStreamSource(This->WineD3DDevice, StreamNumber,
pStreamData==NULL ? NULL:((IDirect3DVertexBuffer9Impl *)pStreamData)->wineD3DVertexBuffer,
OffsetInBytes, Stride);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -1591,7 +1661,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetStreamSource(LPDIRECT3DDEVICE9EX i
return D3DERR_INVALIDCALL;
}
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
rc = IWineD3DDevice_GetStreamSource(This->WineD3DDevice, StreamNumber, &retStream, OffsetInBytes, pStride);
if (rc == D3D_OK && NULL != retStream) {
IWineD3DBuffer_GetParent(retStream, (IUnknown **)pStream);
@@ -1602,7 +1672,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetStreamSource(LPDIRECT3DDEVICE9EX i
}
*pStream = NULL;
}
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
return rc;
}
@@ -1612,9 +1682,10 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetStreamSourceFreq(LPDIRECT3DDEVIC
HRESULT hr;
TRACE("(%p) Relay\n" , This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DDevice_SetStreamSourceFreq(This->WineD3DDevice, StreamNumber, Divider);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -1623,9 +1694,10 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetStreamSourceFreq(LPDIRECT3DDEVIC
HRESULT hr;
TRACE("(%p) Relay\n" , This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DDevice_GetStreamSourceFreq(This->WineD3DDevice, StreamNumber, Divider);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -1635,11 +1707,12 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetIndices(LPDIRECT3DDEVICE9EX ifac
IDirect3DIndexBuffer9Impl *ib = (IDirect3DIndexBuffer9Impl *) pIndexData;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DDevice_SetIndices(This->WineD3DDevice,
ib ? ib->wineD3DIndexBuffer : NULL,
ib ? ib->format : WINED3DFMT_UNKNOWN);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -1654,7 +1727,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetIndices(LPDIRECT3DDEVICE9EX ifac
return D3DERR_INVALIDCALL;
}
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
rc = IWineD3DDevice_GetIndices(This->WineD3DDevice, &retIndexData);
if (SUCCEEDED(rc) && retIndexData) {
IWineD3DBuffer_GetParent(retIndexData, (IUnknown **)ppIndexData);
@@ -1663,7 +1736,8 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetIndices(LPDIRECT3DDEVICE9EX ifac
if (FAILED(rc)) FIXME("Call to GetIndices failed\n");
*ppIndexData = NULL;
}
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return rc;
}
@@ -1672,9 +1746,10 @@ static HRESULT WINAPI IDirect3DDevice9Impl_DrawRectPatch(LPDIRECT3DDEVICE9EX i
HRESULT hr;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DDevice_DrawRectPatch(This->WineD3DDevice, Handle, pNumSegs, (CONST WINED3DRECTPATCH_INFO *)pRectPatchInfo);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -1683,9 +1758,10 @@ static HRESULT WINAPI IDirect3DDevice9Impl_DrawTriPatch(LPDIRECT3DDEVICE9EX if
HRESULT hr;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DDevice_DrawTriPatch(This->WineD3DDevice, Handle, pNumSegs, (CONST WINED3DTRIPATCH_INFO *)pTriPatchInfo);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -1694,9 +1770,10 @@ static HRESULT WINAPI IDirect3DDevice9Impl_DeletePatch(LPDIRECT3DDEVICE9EX ifa
HRESULT hr;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DDevice_DeletePatch(This->WineD3DDevice, Handle);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
diff --git a/dlls/d3d9/directx.c b/dlls/d3d9/directx.c
index 166bfc2..fe22916 100644
--- a/dlls/d3d9/directx.c
+++ b/dlls/d3d9/directx.c
@@ -69,9 +69,10 @@ static ULONG WINAPI IDirect3D9Impl_Release(LPDIRECT3D9EX iface) {
TRACE("(%p) : ReleaseRef to %d\n", This, ref);
if (ref == 0) {
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
IWineD3D_Release(This->WineD3D);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
HeapFree(GetProcessHeap(), 0, This);
}
@@ -84,9 +85,10 @@ static HRESULT WINAPI IDirect3D9Impl_RegisterSoftwareDevice(LPDIRECT3D9EX ifac
HRESULT hr;
TRACE("(%p)->(%p)\n", This, pInitializeFunction);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3D_RegisterSoftwareDevice(This->WineD3D, pInitializeFunction);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -95,9 +97,10 @@ static UINT WINAPI IDirect3D9Impl_GetAdapterCount(LPDIRECT3D9EX iface) {
HRESULT hr;
TRACE("%p\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3D_GetAdapterCount(This->WineD3D);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -113,9 +116,9 @@ static HRESULT WINAPI IDirect3D9Impl_GetAdapterIdentifier(LPDIRECT3D9EX iface, U
adapter_id.device_name = pIdentifier->DeviceName;
adapter_id.device_name_size = sizeof(pIdentifier->DeviceName);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3D_GetAdapterIdentifier(This->WineD3D, Adapter, Flags, &adapter_id);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
pIdentifier->DriverVersion = adapter_id.driver_version;
pIdentifier->VendorId = adapter_id.vendor_id;
@@ -138,9 +141,10 @@ static UINT WINAPI IDirect3D9Impl_GetAdapterModeCount(LPDIRECT3D9EX iface, UINT
return 0;
}
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3D_GetAdapterModeCount(This->WineD3D, Adapter, wined3dformat_from_d3dformat(Format));
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -153,10 +157,10 @@ static HRESULT WINAPI IDirect3D9Impl_EnumAdapterModes(LPDIRECT3D9EX iface, UINT
if(Format != D3DFMT_X8R8G8B8 && Format != D3DFMT_R5G6B5)
return D3DERR_INVALIDCALL;
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3D_EnumAdapterModes(This->WineD3D, Adapter, wined3dformat_from_d3dformat(Format),
Mode, (WINED3DDISPLAYMODE *) pMode);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
if (SUCCEEDED(hr)) pMode->Format = d3dformat_from_wined3dformat(pMode->Format);
@@ -167,9 +171,9 @@ static HRESULT WINAPI IDirect3D9Impl_GetAdapterDisplayMode(LPDIRECT3D9EX iface,
IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
HRESULT hr;
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3D_GetAdapterDisplayMode(This->WineD3D, Adapter, (WINED3DDISPLAYMODE *) pMode);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
if (SUCCEEDED(hr)) pMode->Format = d3dformat_from_wined3dformat(pMode->Format);
@@ -184,10 +188,11 @@ static HRESULT WINAPI IDirect3D9Impl_CheckDeviceType(IDirect3D9Ex *iface, UINT A
TRACE("(%p)->(%d, %d, %d, %d, %s\n", This, Adapter, CheckType, DisplayFormat,
BackBufferFormat, Windowed ? "true" : "false");
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3D_CheckDeviceType(This->WineD3D, Adapter, CheckType, wined3dformat_from_d3dformat(DisplayFormat),
wined3dformat_from_d3dformat(BackBufferFormat), Windowed);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -222,10 +227,11 @@ static HRESULT WINAPI IDirect3D9Impl_CheckDeviceFormat(IDirect3D9Ex *iface, UINT
break;
}
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3D_CheckDeviceFormat(This->WineD3D, Adapter, DeviceType, wined3dformat_from_d3dformat(AdapterFormat),
Usage, WineD3DRType, wined3dformat_from_d3dformat(CheckFormat), SURFACE_OPENGL);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -237,10 +243,11 @@ static HRESULT WINAPI IDirect3D9Impl_CheckDeviceMultiSampleType(IDirect3D9Ex *if
HRESULT hr;
TRACE("%p\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3D_CheckDeviceMultiSampleType(This->WineD3D, Adapter, DeviceType,
wined3dformat_from_d3dformat(SurfaceFormat), Windowed, MultiSampleType, pQualityLevels);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -251,11 +258,12 @@ static HRESULT WINAPI IDirect3D9Impl_CheckDepthStencilMatch(IDirect3D9Ex *iface,
HRESULT hr;
TRACE("%p\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3D_CheckDepthStencilMatch(This->WineD3D, Adapter, DeviceType,
wined3dformat_from_d3dformat(AdapterFormat), wined3dformat_from_d3dformat(RenderTargetFormat),
wined3dformat_from_d3dformat(DepthStencilFormat));
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -264,10 +272,11 @@ static HRESULT WINAPI IDirect3D9Impl_CheckDeviceFormatConversion(LPDIRECT3D9EX i
HRESULT hr;
TRACE("%p\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3D_CheckDeviceFormatConversion(This->WineD3D, Adapter, DeviceType,
wined3dformat_from_d3dformat(SourceFormat), wined3dformat_from_d3dformat(TargetFormat));
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -345,9 +354,11 @@ static HRESULT WINAPI IDirect3D9Impl_GetDeviceCaps(LPDIRECT3D9EX iface, UINT Ada
return D3DERR_INVALIDCALL; /*well this is what MSDN says to return*/
}
memset(pCaps, 0, sizeof(*pCaps));
- EnterCriticalSection(&d3d9_cs);
+
+ wined3d_mutex_lock();
hrc = IWineD3D_GetDeviceCaps(This->WineD3D, Adapter, DeviceType, pWineCaps);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
WINECAPSTOD3D9CAPS(pCaps, pWineCaps)
HeapFree(GetProcessHeap(), 0, pWineCaps);
@@ -365,9 +376,10 @@ static HMONITOR WINAPI IDirect3D9Impl_GetAdapterMonitor(LPDIRECT3D9EX iface, UIN
HMONITOR ret;
TRACE("%p\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
ret = IWineD3D_GetAdapterMonitor(This->WineD3D, Adapter);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return ret;
}
@@ -433,13 +445,14 @@ static HRESULT WINAPI IDirect3D9Impl_CreateDevice(LPDIRECT3D9EX iface, UINT Adap
*ppReturnedDeviceInterface = (IDirect3DDevice9 *)object;
/* Allocate an associated WineD3DDevice object */
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3D_CreateDevice(This->WineD3D, Adapter, DeviceType, hFocusWindow, BehaviourFlags,
(IUnknown *)object, (IWineD3DDeviceParent *)&object->device_parent_vtbl, &object->WineD3DDevice);
if (hr != D3D_OK) {
HeapFree(GetProcessHeap(), 0, object);
*ppReturnedDeviceInterface = NULL;
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -507,7 +520,7 @@ static HRESULT WINAPI IDirect3D9Impl_CreateDevice(LPDIRECT3D9EX iface, UINT Adap
* can be used without further checking
*/
object->convertedDecls = HeapAlloc(GetProcessHeap(), 0, 0);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
return hr;
}
diff --git a/dlls/d3d9/indexbuffer.c b/dlls/d3d9/indexbuffer.c
index 8802bd1..8382135 100644
--- a/dlls/d3d9/indexbuffer.c
+++ b/dlls/d3d9/indexbuffer.c
@@ -57,9 +57,10 @@ static ULONG WINAPI IDirect3DIndexBuffer9Impl_Release(LPDIRECT3DINDEXBUFFER9 ifa
TRACE("(%p) : ReleaseRef to %d\n", This, ref);
if (ref == 0) {
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
IWineD3DBuffer_Release(This->wineD3DIndexBuffer);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
IDirect3DDevice9Ex_Release(This->parentDevice);
HeapFree(GetProcessHeap(), 0, This);
}
@@ -73,14 +74,15 @@ static HRESULT WINAPI IDirect3DIndexBuffer9Impl_GetDevice(LPDIRECT3DINDEXBUFFER9
HRESULT hr;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DBuffer_GetDevice(This->wineD3DIndexBuffer, &wined3d_device);
if (SUCCEEDED(hr))
{
IWineD3DDevice_GetParent(wined3d_device, (IUnknown **)ppDevice);
IWineD3DDevice_Release(wined3d_device);
}
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -89,9 +91,10 @@ static HRESULT WINAPI IDirect3DIndexBuffer9Impl_SetPrivateData(LPDIRECT3DINDEXBU
HRESULT hr;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DBuffer_SetPrivateData(This->wineD3DIndexBuffer, refguid, pData, SizeOfData, Flags);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -100,9 +103,10 @@ static HRESULT WINAPI IDirect3DIndexBuffer9Impl_GetPrivateData(LPDIRECT3DINDEXBU
HRESULT hr;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DBuffer_GetPrivateData(This->wineD3DIndexBuffer, refguid, pData, pSizeOfData);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -111,9 +115,10 @@ static HRESULT WINAPI IDirect3DIndexBuffer9Impl_FreePrivateData(LPDIRECT3DINDEXB
HRESULT hr;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DBuffer_FreePrivateData(This->wineD3DIndexBuffer, refguid);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -122,9 +127,10 @@ static DWORD WINAPI IDirect3DIndexBuffer9Impl_SetPriority(LPDIRECT3DINDEXBUFFER9
DWORD ret;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
ret = IWineD3DBuffer_SetPriority(This->wineD3DIndexBuffer, PriorityNew);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return ret;
}
@@ -133,9 +139,10 @@ static DWORD WINAPI IDirect3DIndexBuffer9Impl_GetPriority(LPDIRECT3DINDEXBUFFER9
DWORD ret;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
ret = IWineD3DBuffer_GetPriority(This->wineD3DIndexBuffer);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return ret;
}
@@ -143,9 +150,9 @@ static void WINAPI IDirect3DIndexBuffer9Impl_PreLoad(LPDIRECT3DINDEXBUFFER9 ifac
IDirect3DIndexBuffer9Impl *This = (IDirect3DIndexBuffer9Impl *)iface;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
IWineD3DBuffer_PreLoad(This->wineD3DIndexBuffer);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
}
static D3DRESOURCETYPE WINAPI IDirect3DIndexBuffer9Impl_GetType(LPDIRECT3DINDEXBUFFER9 iface) {
@@ -161,9 +168,10 @@ static HRESULT WINAPI IDirect3DIndexBuffer9Impl_Lock(LPDIRECT3DINDEXBUFFER9 ifac
HRESULT hr;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DBuffer_Map(This->wineD3DIndexBuffer, OffsetToLock, SizeToLock, (BYTE **)ppbData, Flags);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -172,9 +180,10 @@ static HRESULT WINAPI IDirect3DIndexBuffer9Impl_Unlock(LPDIRECT3DINDEXBUFFER9 if
HRESULT hr;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DBuffer_Unmap(This->wineD3DIndexBuffer);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -184,9 +193,9 @@ static HRESULT WINAPI IDirect3DIndexBuffer9Impl_GetDesc(LPDIRECT3DINDEXB
WINED3DBUFFER_DESC desc;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DBuffer_GetDesc(This->wineD3DIndexBuffer, &desc);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
if (SUCCEEDED(hr)) {
pDesc->Format = d3dformat_from_wined3dformat(This->format);
@@ -243,10 +252,12 @@ HRESULT WINAPI IDirect3DDevice9Impl_CreateIndexBuffer(LPDIRECT3DDEVICE9EX iface,
object->ref = 1;
object->format = wined3dformat_from_d3dformat(Format);
TRACE("Calling wined3d create index buffer\n");
- EnterCriticalSection(&d3d9_cs);
+
+ wined3d_mutex_lock();
hrc = IWineD3DDevice_CreateIndexBuffer(This->WineD3DDevice, Length, Usage & WINED3DUSAGE_MASK,
(WINED3DPOOL)Pool, &object->wineD3DIndexBuffer, (IUnknown *)object);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
if (hrc != D3D_OK) {
/* free up object */
diff --git a/dlls/d3d9/pixelshader.c b/dlls/d3d9/pixelshader.c
index 3939f59..0cec589 100644
--- a/dlls/d3d9/pixelshader.c
+++ b/dlls/d3d9/pixelshader.c
@@ -56,9 +56,10 @@ static ULONG WINAPI IDirect3DPixelShader9Impl_Release(LPDIRECT3DPIXELSHADER9 ifa
TRACE("(%p) : ReleaseRef to %d\n", This, ref);
if (ref == 0) {
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
IWineD3DPixelShader_Release(This->wineD3DPixelShader);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
IDirect3DDevice9Ex_Release(This->parentDevice);
HeapFree(GetProcessHeap(), 0, This);
}
@@ -72,11 +73,12 @@ static HRESULT WINAPI IDirect3DPixelShader9Impl_GetDevice(LPDIRECT3DPIXELSHADER9
TRACE("(%p) : Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
IWineD3DPixelShader_GetDevice(This->wineD3DPixelShader, &myDevice);
IWineD3DDevice_GetParent(myDevice, (IUnknown **)ppDevice);
IWineD3DDevice_Release(myDevice);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
TRACE("(%p) returning (%p)\n", This, *ppDevice);
return D3D_OK;
}
@@ -86,9 +88,10 @@ static HRESULT WINAPI IDirect3DPixelShader9Impl_GetFunction(LPDIRECT3DPIXELSHADE
HRESULT hr;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DPixelShader_GetFunction(This->wineD3DPixelShader, pData, pSizeOfData);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -127,12 +130,14 @@ HRESULT WINAPI IDirect3DDevice9Impl_CreatePixelShader(LPDIRECT3DDEVICE9EX iface,
object->ref = 1;
object->lpVtbl = &Direct3DPixelShader9_Vtbl;
- EnterCriticalSection(&d3d9_cs);
+
+ wined3d_mutex_lock();
hrc = IWineD3DDevice_CreatePixelShader(This->WineD3DDevice, pFunction, NULL,
&object->wineD3DPixelShader, (IUnknown *)object);
- LeaveCriticalSection(&d3d9_cs);
- if (hrc != D3D_OK) {
+ wined3d_mutex_unlock();
+ if (hrc != D3D_OK)
+ {
/* free up object */
FIXME("(%p) call to IWineD3DDevice_CreatePixelShader failed\n", This);
HeapFree(GetProcessHeap(), 0 , object);
@@ -152,9 +157,10 @@ HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShader(LPDIRECT3DDEVICE9EX iface, ID
IDirect3DPixelShader9Impl *shader = (IDirect3DPixelShader9Impl *)pShader;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
IWineD3DDevice_SetPixelShader(This->WineD3DDevice, shader == NULL ? NULL :shader->wineD3DPixelShader);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return D3D_OK;
}
@@ -169,7 +175,7 @@ HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShader(LPDIRECT3DDEVICE9EX iface, ID
return D3DERR_INVALIDCALL;
}
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hrc = IWineD3DDevice_GetPixelShader(This->WineD3DDevice, &object);
if (SUCCEEDED(hrc))
{
@@ -187,7 +193,7 @@ HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShader(LPDIRECT3DDEVICE9EX iface, ID
{
WARN("(%p) : Call to IWineD3DDevice_GetPixelShader failed %u (device %p)\n", This, hrc, This->WineD3DDevice);
}
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
TRACE("(%p) : returning %p\n", This, *ppShader);
return hrc;
@@ -198,9 +204,10 @@ HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShaderConstantF(LPDIRECT3DDEVICE9EX
HRESULT hr;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DDevice_SetPixelShaderConstantF(This->WineD3DDevice, Register, pConstantData, Vector4fCount);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -210,9 +217,9 @@ HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShaderConstantF(LPDIRECT3DDEVICE9EX
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DDevice_GetPixelShaderConstantF(This->WineD3DDevice, Register, pConstantData, Vector4fCount);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
return hr;
}
@@ -222,9 +229,10 @@ HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShaderConstantI(LPDIRECT3DDEVICE9EX
HRESULT hr;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DDevice_SetPixelShaderConstantI(This->WineD3DDevice, Register, pConstantData, Vector4iCount);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -233,9 +241,10 @@ HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShaderConstantI(LPDIRECT3DDEVICE9EX
HRESULT hr;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DDevice_GetPixelShaderConstantI(This->WineD3DDevice, Register, pConstantData, Vector4iCount);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -244,9 +253,10 @@ HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShaderConstantB(LPDIRECT3DDEVICE9EX
HRESULT hr;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DDevice_SetPixelShaderConstantB(This->WineD3DDevice, Register, pConstantData, BoolCount);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -255,8 +265,9 @@ HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShaderConstantB(LPDIRECT3DDEVICE9EX
HRESULT hr;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DDevice_GetPixelShaderConstantB(This->WineD3DDevice, Register, pConstantData, BoolCount);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
diff --git a/dlls/d3d9/query.c b/dlls/d3d9/query.c
index 6e4b20a..a17d2e8 100644
--- a/dlls/d3d9/query.c
+++ b/dlls/d3d9/query.c
@@ -57,9 +57,10 @@ static ULONG WINAPI IDirect3DQuery9Impl_Release(LPDIRECT3DQUERY9 iface) {
TRACE("(%p) : ReleaseRef to %d\n", This, ref);
if (ref == 0) {
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
IWineD3DQuery_Release(This->wineD3DQuery);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
IDirect3DDevice9Ex_Release(This->parentDevice);
HeapFree(GetProcessHeap(), 0, This);
}
@@ -74,7 +75,7 @@ static HRESULT WINAPI IDirect3DQuery9Impl_GetDevice(LPDIRECT3DQUERY9 iface, IDir
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DQuery_GetDevice(This->wineD3DQuery, &pDevice);
if(hr != D3D_OK){
*ppDevice = NULL;
@@ -82,7 +83,8 @@ static HRESULT WINAPI IDirect3DQuery9Impl_GetDevice(LPDIRECT3DQUERY9 iface, IDir
hr = IWineD3DDevice_GetParent(pDevice, (IUnknown **)ppDevice);
IWineD3DDevice_Release(pDevice);
}
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -91,9 +93,10 @@ static D3DQUERYTYPE WINAPI IDirect3DQuery9Impl_GetType(LPDIRECT3DQUERY9 iface) {
HRESULT hr;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DQuery_GetType(This->wineD3DQuery);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -102,9 +105,10 @@ static DWORD WINAPI IDirect3DQuery9Impl_GetDataSize(LPDIRECT3DQUERY9 iface) {
DWORD ret;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
ret = IWineD3DQuery_GetDataSize(This->wineD3DQuery);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return ret;
}
@@ -113,9 +117,10 @@ static HRESULT WINAPI IDirect3DQuery9Impl_Issue(LPDIRECT3DQUERY9 iface, DWORD dw
HRESULT hr;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DQuery_Issue(This->wineD3DQuery, dwIssueFlags);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -124,9 +129,10 @@ static HRESULT WINAPI IDirect3DQuery9Impl_GetData(LPDIRECT3DQUERY9 iface, void*
HRESULT hr;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DQuery_GetData(This->wineD3DQuery, pData, dwSize, dwGetDataFlags);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -154,9 +160,10 @@ HRESULT WINAPI IDirect3DDevice9Impl_CreateQuery(LPDIRECT3DDEVICE9EX iface, D3DQU
if (!ppQuery)
{
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DDevice_CreateQuery(This->WineD3DDevice, Type, NULL, NULL);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -169,9 +176,10 @@ HRESULT WINAPI IDirect3DDevice9Impl_CreateQuery(LPDIRECT3DDEVICE9EX iface, D3DQU
object->lpVtbl = &Direct3DQuery9_Vtbl;
object->ref = 1;
- EnterCriticalSection(&d3d9_cs);
+
+ wined3d_mutex_lock();
hr = IWineD3DDevice_CreateQuery(This->WineD3DDevice, Type, &object->wineD3DQuery, (IUnknown *)object);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
if (FAILED(hr)) {
diff --git a/dlls/d3d9/stateblock.c b/dlls/d3d9/stateblock.c
index d17233f..e91eec3 100644
--- a/dlls/d3d9/stateblock.c
+++ b/dlls/d3d9/stateblock.c
@@ -57,9 +57,10 @@ static ULONG WINAPI IDirect3DStateBlock9Impl_Release(LPDIRECT3DSTATEBLOCK9 iface
TRACE("(%p) : ReleaseRef to %d\n", This, ref);
if (ref == 0) {
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
IWineD3DStateBlock_Release(This->wineD3DStateBlock);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
IDirect3DDevice9Ex_Release(This->parentDevice);
HeapFree(GetProcessHeap(), 0, This);
}
@@ -73,14 +74,15 @@ static HRESULT WINAPI IDirect3DStateBlock9Impl_GetDevice(LPDIRECT3DSTATEBLOCK9 i
HRESULT hr;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DStateBlock_GetDevice(This->wineD3DStateBlock, &wined3d_device);
if (SUCCEEDED(hr))
{
IWineD3DDevice_GetParent(wined3d_device, (IUnknown **)ppDevice);
IWineD3DDevice_Release(wined3d_device);
}
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -89,9 +91,10 @@ static HRESULT WINAPI IDirect3DStateBlock9Impl_Capture(LPDIRECT3DSTATEBLOCK9 ifa
HRESULT hr;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DStateBlock_Capture(This->wineD3DStateBlock);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -100,9 +103,10 @@ static HRESULT WINAPI IDirect3DStateBlock9Impl_Apply(LPDIRECT3DSTATEBLOCK9 iface
HRESULT hr;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DStateBlock_Apply(This->wineD3DStateBlock);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -139,9 +143,10 @@ HRESULT WINAPI IDirect3DDevice9Impl_CreateStateBlock(LPDIRECT3DDEVICE9EX iface,
object->lpVtbl = &Direct3DStateBlock9_Vtbl;
object->ref = 1;
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hrc = IWineD3DDevice_CreateStateBlock(This->WineD3DDevice, (WINED3DSTATEBLOCKTYPE)Type, &object->wineD3DStateBlock, (IUnknown*)object);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
if(hrc != D3D_OK){
FIXME("(%p) Call to IWineD3DDevice_CreateStateBlock failed.\n", This);
HeapFree(GetProcessHeap(), 0, object);
@@ -160,9 +165,10 @@ HRESULT WINAPI IDirect3DDevice9Impl_BeginStateBlock(LPDIRECT3DDEVICE9EX iface)
HRESULT hr;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DDevice_BeginStateBlock(This->WineD3DDevice);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -175,12 +181,13 @@ HRESULT WINAPI IDirect3DDevice9Impl_EndStateBlock(LPDIRECT3DDEVICE9EX iface, I
TRACE("(%p) Relay\n", This);
/* Tell wineD3D to endstateblock before anything else (in case we run out
- * of memory later and cause locking problems)
- */
- EnterCriticalSection(&d3d9_cs);
+ * of memory later and cause locking problems) */
+ wined3d_mutex_lock();
hr=IWineD3DDevice_EndStateBlock(This->WineD3DDevice,&wineD3DStateBlock);
- LeaveCriticalSection(&d3d9_cs);
- if(hr!= D3D_OK){
+ wined3d_mutex_unlock();
+
+ if (hr!= D3D_OK)
+ {
WARN("IWineD3DDevice_EndStateBlock returned an error\n");
return hr;
}
diff --git a/dlls/d3d9/surface.c b/dlls/d3d9/surface.c
index 70444b2..b4defaf 100644
--- a/dlls/d3d9/surface.c
+++ b/dlls/d3d9/surface.c
@@ -78,9 +78,10 @@ static ULONG WINAPI IDirect3DSurface9Impl_Release(LPDIRECT3DSURFACE9 iface) {
if (ref == 0) {
if (This->parentDevice) IDirect3DDevice9Ex_Release(This->parentDevice);
if (!This->isImplicit) {
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
IWineD3DSurface_Release(This->wineD3DSurface);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
HeapFree(GetProcessHeap(), 0, This);
}
}
@@ -96,14 +97,15 @@ static HRESULT WINAPI IDirect3DSurface9Impl_GetDevice(LPDIRECT3DSURFACE9 iface,
HRESULT hr;
TRACE("(%p)->(%p)\n", This, ppDevice);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DSurface_GetDevice(This->wineD3DSurface, &wined3d_device);
if (SUCCEEDED(hr))
{
IWineD3DDevice_GetParent(wined3d_device, (IUnknown **)ppDevice);
IWineD3DDevice_Release(wined3d_device);
}
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -112,9 +114,10 @@ static HRESULT WINAPI IDirect3DSurface9Impl_SetPrivateData(LPDIRECT3DSURFACE9 if
HRESULT hr;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DSurface_SetPrivateData(This->wineD3DSurface, refguid, pData, SizeOfData, Flags);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -123,9 +126,10 @@ static HRESULT WINAPI IDirect3DSurface9Impl_GetPrivateData(LPDIRECT3DSURFACE9 if
HRESULT hr;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DSurface_GetPrivateData(This->wineD3DSurface, refguid, pData, pSizeOfData);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -134,9 +138,10 @@ static HRESULT WINAPI IDirect3DSurface9Impl_FreePrivateData(LPDIRECT3DSURFACE9 i
HRESULT hr;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DSurface_FreePrivateData(This->wineD3DSurface, refguid);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -145,9 +150,10 @@ static DWORD WINAPI IDirect3DSurface9Impl_SetPriority(LPDIRECT3DSURFACE9 iface,
HRESULT hr;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DSurface_SetPriority(This->wineD3DSurface, PriorityNew);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -156,9 +162,10 @@ static DWORD WINAPI IDirect3DSurface9Impl_GetPriority(LPDIRECT3DSURFACE9 iface)
HRESULT hr;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DSurface_GetPriority(This->wineD3DSurface);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -166,10 +173,9 @@ static void WINAPI IDirect3DSurface9Impl_PreLoad(LPDIRECT3DSURFACE9 iface) {
IDirect3DSurface9Impl *This = (IDirect3DSurface9Impl *)iface;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
IWineD3DSurface_PreLoad(This->wineD3DSurface);
- LeaveCriticalSection(&d3d9_cs);
- return ;
+ wined3d_mutex_unlock();
}
static D3DRESOURCETYPE WINAPI IDirect3DSurface9Impl_GetType(LPDIRECT3DSURFACE9 iface) {
@@ -177,9 +183,10 @@ static D3DRESOURCETYPE WINAPI IDirect3DSurface9Impl_GetType(LPDIRECT3DSURFACE9 i
D3DRESOURCETYPE ret;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
ret = IWineD3DSurface_GetType(This->wineD3DSurface);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return ret;
}
@@ -209,9 +216,9 @@ static HRESULT WINAPI IDirect3DSurface9Impl_GetDesc(LPDIRECT3DSURFACE9 iface, D3
HRESULT hr;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DSurface_GetDesc(This->wineD3DSurface, &wined3ddesc);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
if (SUCCEEDED(hr))
{
@@ -233,10 +240,11 @@ static HRESULT WINAPI IDirect3DSurface9Impl_LockRect(LPDIRECT3DSURFACE9 iface, D
HRESULT hr;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
TRACE("(%p) calling IWineD3DSurface_LockRect %p %p %p %d\n", This, This->wineD3DSurface, pLockedRect, pRect, Flags);
hr = IWineD3DSurface_LockRect(This->wineD3DSurface, (WINED3DLOCKED_RECT *) pLockedRect, pRect, Flags);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -245,9 +253,10 @@ static HRESULT WINAPI IDirect3DSurface9Impl_UnlockRect(LPDIRECT3DSURFACE9 iface)
HRESULT hr;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DSurface_UnlockRect(This->wineD3DSurface);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
switch(hr)
{
case WINEDDERR_NOTLOCKED: return D3DERR_INVALIDCALL;
@@ -260,9 +269,10 @@ static HRESULT WINAPI IDirect3DSurface9Impl_GetDC(LPDIRECT3DSURFACE9 iface, HDC*
HRESULT hr;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DSurface_GetDC(This->wineD3DSurface, phdc);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -271,9 +281,10 @@ static HRESULT WINAPI IDirect3DSurface9Impl_ReleaseDC(LPDIRECT3DSURFACE9 iface,
HRESULT hr;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DSurface_ReleaseDC(This->wineD3DSurface, hdc);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
switch(hr) {
case WINEDDERR_NODC: return WINED3DERR_INVALIDCALL;
default: return hr;
diff --git a/dlls/d3d9/swapchain.c b/dlls/d3d9/swapchain.c
index 4f639b1..fb66807 100644
--- a/dlls/d3d9/swapchain.c
+++ b/dlls/d3d9/swapchain.c
@@ -62,9 +62,10 @@ static ULONG WINAPI IDirect3DSwapChain9Impl_Release(LPDIRECT3DSWAPCHAIN9 iface)
if (ref == 0) {
if (This->parentDevice) IDirect3DDevice9Ex_Release(This->parentDevice);
if (!This->isImplicit) {
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
IWineD3DSwapChain_Destroy(This->wineD3DSwapChain, D3D9CB_DestroyRenderTarget);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
HeapFree(GetProcessHeap(), 0, This);
}
}
@@ -78,9 +79,9 @@ static HRESULT WINAPI IDirect3DSwapChain9Impl_Present(LPDIRECT3DSWAPCHAIN9 iface
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DSwapChain_Present(This->wineD3DSwapChain, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion, dwFlags);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
return hr;
}
@@ -90,9 +91,10 @@ static HRESULT WINAPI IDirect3DSwapChain9Impl_GetFrontBufferData(LPDIRECT3DSWAPC
HRESULT hr;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DSwapChain_GetFrontBufferData(This->wineD3DSwapChain, ((IDirect3DSurface9Impl *)pDestSurface)->wineD3DSurface);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -103,13 +105,14 @@ static HRESULT WINAPI IDirect3DSwapChain9Impl_GetBackBuffer(LPDIRECT3DSWAPCHAIN9
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hrc = IWineD3DSwapChain_GetBackBuffer(This->wineD3DSwapChain, iBackBuffer, (WINED3DBACKBUFFER_TYPE) Type, &mySurface);
if (hrc == D3D_OK && NULL != mySurface) {
IWineD3DSurface_GetParent(mySurface, (IUnknown **)ppBackBuffer);
IWineD3DSurface_Release(mySurface);
}
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
/* Do not touch the **ppBackBuffer pointer otherwise! (see device test) */
return hrc;
}
@@ -119,9 +122,10 @@ static HRESULT WINAPI IDirect3DSwapChain9Impl_GetRasterStatus(LPDIRECT3DSWAPCHAI
HRESULT hr;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DSwapChain_GetRasterStatus(This->wineD3DSwapChain, (WINED3DRASTER_STATUS *) pRasterStatus);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -130,9 +134,9 @@ static HRESULT WINAPI IDirect3DSwapChain9Impl_GetDisplayMode(LPDIRECT3DSWAPCHAIN
HRESULT hr;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DSwapChain_GetDisplayMode(This->wineD3DSwapChain, (WINED3DDISPLAYMODE *) pMode);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
if (SUCCEEDED(hr)) pMode->Format = d3dformat_from_wined3dformat(pMode->Format);
@@ -146,13 +150,14 @@ static HRESULT WINAPI IDirect3DSwapChain9Impl_GetDevice(LPDIRECT3DSWAPCHAIN9 ifa
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hrc = IWineD3DSwapChain_GetDevice(This->wineD3DSwapChain, &device);
if (hrc == D3D_OK && NULL != device) {
IWineD3DDevice_GetParent(device, (IUnknown **)ppDevice);
IWineD3DDevice_Release(device);
}
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hrc;
}
@@ -163,9 +168,9 @@ static HRESULT WINAPI IDirect3DSwapChain9Impl_GetPresentParameters(LPDIRECT3DSWA
TRACE("(%p)->(%p): Relay\n", This, pPresentationParameters);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DSwapChain_GetPresentParameters(This->wineD3DSwapChain, &winePresentParameters);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
pPresentationParameters->BackBufferWidth = winePresentParameters.BackBufferWidth;
pPresentationParameters->BackBufferHeight = winePresentParameters.BackBufferHeight;
@@ -240,10 +245,10 @@ HRESULT WINAPI IDirect3DDevice9Impl_CreateAdditionalSwapChain(LPDIRECT3DDEVICE
localParameters.PresentationInterval = pPresentationParameters->PresentationInterval;
localParameters.AutoRestoreDisplayMode = TRUE;
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hrc = IWineD3DDevice_CreateSwapChain(This->WineD3DDevice, &localParameters,
&object->wineD3DSwapChain, (IUnknown*)object, SURFACE_OPENGL);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
pPresentationParameters->BackBufferWidth = localParameters.BackBufferWidth;
pPresentationParameters->BackBufferHeight = localParameters.BackBufferHeight;
@@ -280,7 +285,7 @@ HRESULT WINAPI IDirect3DDevice9Impl_GetSwapChain(LPDIRECT3DDEVICE9EX iface, UI
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hrc = IWineD3DDevice_GetSwapChain(This->WineD3DDevice, iSwapChain, &swapchain);
if (hrc == D3D_OK && NULL != swapchain) {
IWineD3DSwapChain_GetParent(swapchain, (IUnknown **)pSwapChain);
@@ -288,7 +293,8 @@ HRESULT WINAPI IDirect3DDevice9Impl_GetSwapChain(LPDIRECT3DDEVICE9EX iface, UI
} else {
*pSwapChain = NULL;
}
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hrc;
}
@@ -297,8 +303,9 @@ UINT WINAPI IDirect3DDevice9Impl_GetNumberOfSwapChains(LPDIRECT3DDEVICE9EX
UINT ret;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
ret = IWineD3DDevice_GetNumberOfSwapChains(This->WineD3DDevice);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return ret;
}
diff --git a/dlls/d3d9/texture.c b/dlls/d3d9/texture.c
index 10dd498..2749975 100644
--- a/dlls/d3d9/texture.c
+++ b/dlls/d3d9/texture.c
@@ -59,9 +59,10 @@ static ULONG WINAPI IDirect3DTexture9Impl_Release(LPDIRECT3DTEXTURE9 iface) {
TRACE("(%p) : ReleaseRef to %d\n", This, ref);
if (ref == 0) {
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
IWineD3DTexture_Destroy(This->wineD3DTexture, D3D9CB_DestroySurface);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
IDirect3DDevice9Ex_Release(This->parentDevice);
HeapFree(GetProcessHeap(), 0, This);
}
@@ -75,14 +76,15 @@ static HRESULT WINAPI IDirect3DTexture9Impl_GetDevice(LPDIRECT3DTEXTURE9 iface,
HRESULT hr;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DTexture_GetDevice(This->wineD3DTexture, &wined3d_device);
if (SUCCEEDED(hr))
{
IWineD3DDevice_GetParent(wined3d_device, (IUnknown **)ppDevice);
IWineD3DDevice_Release(wined3d_device);
}
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -91,9 +93,10 @@ static HRESULT WINAPI IDirect3DTexture9Impl_SetPrivateData(LPDIRECT3DTEXTURE9 if
HRESULT hr;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DTexture_SetPrivateData(This->wineD3DTexture, refguid, pData, SizeOfData, Flags);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -102,9 +105,10 @@ static HRESULT WINAPI IDirect3DTexture9Impl_GetPrivateData(LPDIRECT3DTEXTURE9 if
HRESULT hr;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DTexture_GetPrivateData(This->wineD3DTexture, refguid, pData, pSizeOfData);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -113,9 +117,10 @@ static HRESULT WINAPI IDirect3DTexture9Impl_FreePrivateData(LPDIRECT3DTEXTURE9 i
HRESULT hr;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DTexture_FreePrivateData(This->wineD3DTexture, refguid);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -124,9 +129,10 @@ static DWORD WINAPI IDirect3DTexture9Impl_SetPriority(LPDIRECT3DTEXTURE9 iface,
DWORD ret;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
ret = IWineD3DTexture_SetPriority(This->wineD3DTexture, PriorityNew);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return ret;
}
@@ -135,9 +141,10 @@ static DWORD WINAPI IDirect3DTexture9Impl_GetPriority(LPDIRECT3DTEXTURE9 iface)
DWORD ret;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
ret = IWineD3DTexture_GetPriority(This->wineD3DTexture);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return ret;
}
@@ -145,9 +152,9 @@ static void WINAPI IDirect3DTexture9Impl_PreLoad(LPDIRECT3DTEXTURE9 iface) {
IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
IWineD3DTexture_PreLoad(This->wineD3DTexture);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
}
static D3DRESOURCETYPE WINAPI IDirect3DTexture9Impl_GetType(LPDIRECT3DTEXTURE9 iface) {
@@ -155,9 +162,10 @@ static D3DRESOURCETYPE WINAPI IDirect3DTexture9Impl_GetType(LPDIRECT3DTEXTURE9 i
HRESULT ret;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
ret = IWineD3DTexture_GetType(This->wineD3DTexture);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return ret;
}
@@ -167,9 +175,10 @@ static DWORD WINAPI IDirect3DTexture9Impl_SetLOD(LPDIRECT3DTEXTURE9 iface, DWORD
DWORD ret;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
ret = IWineD3DTexture_SetLOD(This->wineD3DTexture, LODNew);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return ret;
}
@@ -178,9 +187,10 @@ static DWORD WINAPI IDirect3DTexture9Impl_GetLOD(LPDIRECT3DTEXTURE9 iface) {
DWORD ret;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
ret = IWineD3DTexture_GetLOD(This->wineD3DTexture);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return ret;
}
@@ -189,9 +199,10 @@ static DWORD WINAPI IDirect3DTexture9Impl_GetLevelCount(LPDIRECT3DTEXTURE9 iface
DWORD ret;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
ret = IWineD3DTexture_GetLevelCount(This->wineD3DTexture);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return ret;
}
@@ -200,9 +211,10 @@ static HRESULT WINAPI IDirect3DTexture9Impl_SetAutoGenFilterType(LPDIRECT3DTEXTU
HRESULT hr;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DTexture_SetAutoGenFilterType(This->wineD3DTexture, (WINED3DTEXTUREFILTERTYPE) FilterType);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -211,9 +223,10 @@ static D3DTEXTUREFILTERTYPE WINAPI IDirect3DTexture9Impl_GetAutoGenFilterType(LP
D3DTEXTUREFILTERTYPE ret;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
ret = (D3DTEXTUREFILTERTYPE) IWineD3DTexture_GetAutoGenFilterType(This->wineD3DTexture);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return ret;
}
@@ -221,9 +234,9 @@ static void WINAPI IDirect3DTexture9Impl_GenerateMipSubLevels(LPDIRECT3DTEXTURE9
IDirect3DTexture9Impl *This = (IDirect3DTexture9Impl *)iface;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
IWineD3DTexture_GenerateMipSubLevels(This->wineD3DTexture);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
}
/* IDirect3DTexture9 Interface follow: */
@@ -234,9 +247,9 @@ static HRESULT WINAPI IDirect3DTexture9Impl_GetLevelDesc(LPDIRECT3DTEXTURE9 ifac
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DTexture_GetLevelDesc(This->wineD3DTexture, Level, &wined3ddesc);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
if (SUCCEEDED(hr))
{
@@ -259,13 +272,15 @@ static HRESULT WINAPI IDirect3DTexture9Impl_GetSurfaceLevel(LPDIRECT3DTEXTURE9 i
IWineD3DSurface *mySurface = NULL;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+
+ wined3d_mutex_lock();
hrc = IWineD3DTexture_GetSurfaceLevel(This->wineD3DTexture, Level, &mySurface);
if (hrc == D3D_OK && NULL != ppSurfaceLevel) {
IWineD3DSurface_GetParent(mySurface, (IUnknown **)ppSurfaceLevel);
IWineD3DSurface_Release(mySurface);
}
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hrc;
}
@@ -274,9 +289,10 @@ static HRESULT WINAPI IDirect3DTexture9Impl_LockRect(LPDIRECT3DTEXTURE9 iface, U
HRESULT hr;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DTexture_LockRect(This->wineD3DTexture, Level, (WINED3DLOCKED_RECT *) pLockedRect, pRect, Flags);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -285,9 +301,10 @@ static HRESULT WINAPI IDirect3DTexture9Impl_UnlockRect(LPDIRECT3DTEXTURE9 iface,
HRESULT hr;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DTexture_UnlockRect(This->wineD3DTexture, Level);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -296,9 +313,10 @@ static HRESULT WINAPI IDirect3DTexture9Impl_AddDirtyRect(LPDIRECT3DTEXTURE9 ifac
HRESULT hr;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DTexture_AddDirtyRect(This->wineD3DTexture, pDirtyRect);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -352,12 +370,14 @@ HRESULT WINAPI IDirect3DDevice9Impl_CreateTexture(LPDIRECT3DDEVICE9EX iface, U
object->lpVtbl = &Direct3DTexture9_Vtbl;
object->ref = 1;
- EnterCriticalSection(&d3d9_cs);
+
+ wined3d_mutex_lock();
hrc = IWineD3DDevice_CreateTexture(This->WineD3DDevice, Width, Height, Levels, Usage & WINED3DUSAGE_MASK,
wined3dformat_from_d3dformat(Format), Pool, &object->wineD3DTexture, (IUnknown *)object);
- LeaveCriticalSection(&d3d9_cs);
- if (FAILED(hrc)) {
+ wined3d_mutex_unlock();
+ if (FAILED(hrc))
+ {
/* free up object */
WARN("(%p) call to IWineD3DDevice_CreateTexture failed\n", This);
HeapFree(GetProcessHeap(), 0, object);
diff --git a/dlls/d3d9/vertexbuffer.c b/dlls/d3d9/vertexbuffer.c
index 501db41..26264b8 100644
--- a/dlls/d3d9/vertexbuffer.c
+++ b/dlls/d3d9/vertexbuffer.c
@@ -58,9 +58,10 @@ static ULONG WINAPI IDirect3DVertexBuffer9Impl_Release(LPDIRECT3DVERTEXBUFFER9 i
TRACE("(%p) : ReleaseRef to %d\n", This, ref);
if (ref == 0) {
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
IWineD3DBuffer_Release(This->wineD3DVertexBuffer);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
IDirect3DDevice9Ex_Release(This->parentDevice);
HeapFree(GetProcessHeap(), 0, This);
}
@@ -74,14 +75,15 @@ static HRESULT WINAPI IDirect3DVertexBuffer9Impl_GetDevice(LPDIRECT3DVERTEXBUFFE
HRESULT hr;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DBuffer_GetDevice(This->wineD3DVertexBuffer, &wined3d_device);
if (SUCCEEDED(hr))
{
IWineD3DDevice_GetParent(wined3d_device, (IUnknown **)ppDevice);
IWineD3DDevice_Release(wined3d_device);
}
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -91,9 +93,9 @@ static HRESULT WINAPI IDirect3DVertexBuffer9Impl_SetPrivateData(LPDIRECT3DVERTEX
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DBuffer_SetPrivateData(This->wineD3DVertexBuffer, refguid, pData, SizeOfData, Flags);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
return hr;
}
@@ -103,9 +105,10 @@ static HRESULT WINAPI IDirect3DVertexBuffer9Impl_GetPrivateData(LPDIRECT3DVERTEX
HRESULT hr;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DBuffer_GetPrivateData(This->wineD3DVertexBuffer, refguid, pData, pSizeOfData);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -114,9 +117,10 @@ static HRESULT WINAPI IDirect3DVertexBuffer9Impl_FreePrivateData(LPDIRECT3DVERTE
HRESULT hr;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DBuffer_FreePrivateData(This->wineD3DVertexBuffer, refguid);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -125,9 +129,10 @@ static DWORD WINAPI IDirect3DVertexBuffer9Impl_SetPriority(LPDIRECT3DVERTEXBUFFE
HRESULT hr;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DBuffer_SetPriority(This->wineD3DVertexBuffer, PriorityNew);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -136,9 +141,10 @@ static DWORD WINAPI IDirect3DVertexBuffer9Impl_GetPriority(LPDIRECT3DVERTEXBUFFE
HRESULT hr;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DBuffer_GetPriority(This->wineD3DVertexBuffer);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -146,10 +152,9 @@ static void WINAPI IDirect3DVertexBuffer9Impl_PreLoad(LPDIRECT3DVERTEXBUFFER9 if
IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
IWineD3DBuffer_PreLoad(This->wineD3DVertexBuffer);
- LeaveCriticalSection(&d3d9_cs);
- return ;
+ wined3d_mutex_unlock();
}
static D3DRESOURCETYPE WINAPI IDirect3DVertexBuffer9Impl_GetType(LPDIRECT3DVERTEXBUFFER9 iface) {
@@ -165,9 +170,10 @@ static HRESULT WINAPI IDirect3DVertexBuffer9Impl_Lock(LPDIRECT3DVERTEXBUFFER9 if
HRESULT hr;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DBuffer_Map(This->wineD3DVertexBuffer, OffsetToLock, SizeToLock, (BYTE **)ppbData, Flags);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -176,9 +182,10 @@ static HRESULT WINAPI IDirect3DVertexBuffer9Impl_Unlock(LPDIRECT3DVERTEXBUFFER9
HRESULT hr;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DBuffer_Unmap(This->wineD3DVertexBuffer);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -188,9 +195,9 @@ static HRESULT WINAPI IDirect3DVertexBuffer9Impl_GetDesc(LPDIRECT3DVERTEXBUFFER9
WINED3DBUFFER_DESC desc;
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DBuffer_GetDesc(This->wineD3DVertexBuffer, &desc);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
if (SUCCEEDED(hr)) {
pDesc->Format = D3DFMT_VERTEXDATA;
@@ -246,11 +253,12 @@ HRESULT WINAPI IDirect3DDevice9Impl_CreateVertexBuffer(LPDIRECT3DDEVICE9EX iface
object->lpVtbl = &Direct3DVertexBuffer9_Vtbl;
object->ref = 1;
object->fvf = FVF;
- EnterCriticalSection(&d3d9_cs);
+
+ wined3d_mutex_lock();
hrc = IWineD3DDevice_CreateVertexBuffer(This->WineD3DDevice, Size, Usage & WINED3DUSAGE_MASK,
0 /* fvf for ddraw only */, (WINED3DPOOL) Pool, &(object->wineD3DVertexBuffer), (IUnknown *)object);
- LeaveCriticalSection(&d3d9_cs);
-
+ wined3d_mutex_unlock();
+
if (hrc != D3D_OK) {
/* free up object */
diff --git a/dlls/d3d9/vertexdeclaration.c b/dlls/d3d9/vertexdeclaration.c
index 38f0751..58f61b7 100644
--- a/dlls/d3d9/vertexdeclaration.c
+++ b/dlls/d3d9/vertexdeclaration.c
@@ -230,9 +230,11 @@ void IDirect3DVertexDeclaration9Impl_Destroy(LPDIRECT3DVERTEXDECLARATION9 iface)
/* Should not happen unless wine has a bug or the application releases references it does not own */
ERR("Destroying vdecl with ref != 0\n");
}
- EnterCriticalSection(&d3d9_cs);
+
+ wined3d_mutex_lock();
IWineD3DVertexDeclaration_Release(This->wineD3DVertexDeclaration);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
HeapFree(GetProcessHeap(), 0, This->elements);
HeapFree(GetProcessHeap(), 0, This);
}
@@ -262,13 +264,14 @@ static HRESULT WINAPI IDirect3DVertexDeclaration9Impl_GetDevice(LPDIRECT3DVERTEX
TRACE("(%p) : Relay\n", iface);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DVertexDeclaration_GetDevice(This->wineD3DVertexDeclaration, &myDevice);
if (hr == D3D_OK && myDevice != NULL) {
hr = IWineD3DDevice_GetParent(myDevice, (IUnknown **)ppDevice);
IWineD3DDevice_Release(myDevice);
}
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -392,10 +395,10 @@ HRESULT WINAPI IDirect3DDevice9Impl_CreateVertexDeclaration(LPDIRECT3DDEVICE9E
CopyMemory(object->elements, pVertexElements, element_count * sizeof(D3DVERTEXELEMENT9));
object->element_count = element_count;
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DDevice_CreateVertexDeclaration(This->WineD3DDevice, &object->wineD3DVertexDeclaration,
(IUnknown *)object, wined3d_elements, wined3d_element_count);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
HeapFree(GetProcessHeap(), 0, wined3d_elements);
@@ -421,9 +424,10 @@ HRESULT WINAPI IDirect3DDevice9Impl_SetVertexDeclaration(LPDIRECT3DDEVICE9EX i
TRACE("(%p) : Relay\n", iface);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DDevice_SetVertexDeclaration(This->WineD3DDevice, pDeclImpl == NULL ? NULL : pDeclImpl->wineD3DVertexDeclaration);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -439,7 +443,8 @@ HRESULT WINAPI IDirect3DDevice9Impl_GetVertexDeclaration(LPDIRECT3DDEVICE9EX i
}
*ppDecl = NULL;
- EnterCriticalSection(&d3d9_cs);
+
+ wined3d_mutex_lock();
hr = IWineD3DDevice_GetVertexDeclaration(This->WineD3DDevice, &pTest);
if (hr == D3D_OK && NULL != pTest) {
IWineD3DVertexDeclaration_GetParent(pTest, (IUnknown **)ppDecl);
@@ -447,7 +452,8 @@ HRESULT WINAPI IDirect3DDevice9Impl_GetVertexDeclaration(LPDIRECT3DDEVICE9EX i
} else {
*ppDecl = NULL;
}
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
TRACE("(%p) : returning %p\n", This, *ppDecl);
return hr;
}
diff --git a/dlls/d3d9/vertexshader.c b/dlls/d3d9/vertexshader.c
index d7b680e..8a5d5bc 100644
--- a/dlls/d3d9/vertexshader.c
+++ b/dlls/d3d9/vertexshader.c
@@ -56,9 +56,10 @@ static ULONG WINAPI IDirect3DVertexShader9Impl_Release(LPDIRECT3DVERTEXSHADER9 i
TRACE("(%p) : ReleaseRef to %d\n", This, ref);
if (ref == 0) {
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
IWineD3DVertexShader_Release(This->wineD3DVertexShader);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
IDirect3DDevice9Ex_Release(This->parentDevice);
HeapFree(GetProcessHeap(), 0, This);
}
@@ -72,7 +73,7 @@ static HRESULT WINAPI IDirect3DVertexShader9Impl_GetDevice(LPDIRECT3DVERTEXSHADE
HRESULT hr;
TRACE("(%p) : Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DVertexShader_GetDevice(This->wineD3DVertexShader, &myDevice);
if (WINED3D_OK == hr && myDevice != NULL) {
hr = IWineD3DDevice_GetParent(myDevice, (IUnknown **)ppDevice);
@@ -80,7 +81,8 @@ static HRESULT WINAPI IDirect3DVertexShader9Impl_GetDevice(LPDIRECT3DVERTEXSHADE
} else {
*ppDevice = NULL;
}
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
TRACE("(%p) returning (%p)\n", This, *ppDevice);
return hr;
}
@@ -90,9 +92,10 @@ static HRESULT WINAPI IDirect3DVertexShader9Impl_GetFunction(LPDIRECT3DVERTEXSHA
HRESULT hr;
TRACE("(%p) : Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DVertexShader_GetFunction(This->wineD3DVertexShader, pData, pSizeOfData);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -125,10 +128,11 @@ HRESULT WINAPI IDirect3DDevice9Impl_CreateVertexShader(LPDIRECT3DDEVICE9EX iface
object->ref = 1;
object->lpVtbl = &Direct3DVertexShader9_Vtbl;
- EnterCriticalSection(&d3d9_cs);
+
+ wined3d_mutex_lock();
hrc= IWineD3DDevice_CreateVertexShader(This->WineD3DDevice, pFunction,
NULL /* output signature */, &object->wineD3DVertexShader, (IUnknown *)object);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
if (FAILED(hrc)) {
@@ -151,9 +155,10 @@ HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShader(LPDIRECT3DDEVICE9EX iface, I
HRESULT hrc = D3D_OK;
TRACE("(%p) : Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+
+ wined3d_mutex_lock();
hrc = IWineD3DDevice_SetVertexShader(This->WineD3DDevice, pShader==NULL?NULL:((IDirect3DVertexShader9Impl *)pShader)->wineD3DVertexShader);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
TRACE("(%p) : returning hr(%u)\n", This, hrc);
return hrc;
@@ -165,7 +170,8 @@ HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShader(LPDIRECT3DDEVICE9EX iface, I
HRESULT hrc = D3D_OK;
TRACE("(%p) : Relay device@%p\n", This, This->WineD3DDevice);
- EnterCriticalSection(&d3d9_cs);
+
+ wined3d_mutex_lock();
hrc = IWineD3DDevice_GetVertexShader(This->WineD3DDevice, &pShader);
if (SUCCEEDED(hrc))
{
@@ -183,7 +189,8 @@ HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShader(LPDIRECT3DDEVICE9EX iface, I
{
WARN("(%p) : Call to IWineD3DDevice_GetVertexShader failed %u (device %p)\n", This, hrc, This->WineD3DDevice);
}
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
TRACE("(%p) : returning %p\n", This, *ppShader);
return hrc;
}
@@ -199,9 +206,10 @@ HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShaderConstantF(LPDIRECT3DDEVICE9EX
return D3DERR_INVALIDCALL;
}
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DDevice_SetVertexShaderConstantF(This->WineD3DDevice, Register, pConstantData, Vector4fCount);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -216,9 +224,11 @@ HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShaderConstantF(LPDIRECT3DDEVICE9EX
}
TRACE("(%p) : Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+
+ wined3d_mutex_lock();
hr = IWineD3DDevice_GetVertexShaderConstantF(This->WineD3DDevice, Register, pConstantData, Vector4fCount);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -227,9 +237,10 @@ HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShaderConstantI(LPDIRECT3DDEVICE9EX
HRESULT hr;
TRACE("(%p) : Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DDevice_SetVertexShaderConstantI(This->WineD3DDevice, Register, pConstantData, Vector4iCount);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -238,9 +249,10 @@ HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShaderConstantI(LPDIRECT3DDEVICE9EX
HRESULT hr;
TRACE("(%p) : Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DDevice_GetVertexShaderConstantI(This->WineD3DDevice, Register, pConstantData, Vector4iCount);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -249,9 +261,10 @@ HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShaderConstantB(LPDIRECT3DDEVICE9EX
HRESULT hr;
TRACE("(%p) : Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DDevice_SetVertexShaderConstantB(This->WineD3DDevice, Register, pConstantData, BoolCount);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
@@ -260,8 +273,9 @@ HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShaderConstantB(LPDIRECT3DDEVICE9EX
HRESULT hr;
TRACE("(%p) : Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DDevice_GetVertexShaderConstantB(This->WineD3DDevice, Register, pConstantData, BoolCount);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
return hr;
}
diff --git a/dlls/d3d9/volume.c b/dlls/d3d9/volume.c
index 7c49a9a..9f1252a 100644
--- a/dlls/d3d9/volume.c
+++ b/dlls/d3d9/volume.c
@@ -72,9 +72,10 @@ static ULONG WINAPI IDirect3DVolume9Impl_Release(LPDIRECT3DVOLUME9 iface) {
TRACE("(%p) : ReleaseRef to %d\n", This, ref);
if (ref == 0) {
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
IWineD3DVolume_Release(This->wineD3DVolume);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
HeapFree(GetProcessHeap(), 0, This);
}
@@ -89,13 +90,13 @@ static HRESULT WINAPI IDirect3DVolume9Impl_GetDevice(LPDIRECT3DVOLUME9 iface, ID
TRACE("iface %p, ppDevice %p\n", iface, ppDevice);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
IWineD3DVolume_GetDevice(This->wineD3DVolume, &myDevice);
IWineD3DDevice_GetParent(myDevice, (IUnknown **)ppDevice);
IWineD3DDevice_Release(myDevice);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
return D3D_OK;
}
@@ -106,11 +107,11 @@ static HRESULT WINAPI IDirect3DVolume9Impl_SetPrivateData(LPDIRECT3DVOLUME9 ifac
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DVolume_SetPrivateData(This->wineD3DVolume, refguid, pData, SizeOfData, Flags);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
return hr;
}
@@ -121,11 +122,11 @@ static HRESULT WINAPI IDirect3DVolume9Impl_GetPrivateData(LPDIRECT3DVOLUME9 ifac
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DVolume_GetPrivateData(This->wineD3DVolume, refguid, pData, pSizeOfData);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
return hr;
}
@@ -136,11 +137,11 @@ static HRESULT WINAPI IDirect3DVolume9Impl_FreePrivateData(LPDIRECT3DVOLUME9 ifa
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DVolume_FreePrivateData(This->wineD3DVolume, refguid);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
return hr;
}
@@ -171,11 +172,11 @@ static HRESULT WINAPI IDirect3DVolume9Impl_GetDesc(LPDIRECT3DVOLUME9 iface, D3DV
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DVolume_GetDesc(This->wineD3DVolume, &wined3ddesc);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
if (SUCCEEDED(hr))
{
@@ -197,12 +198,12 @@ static HRESULT WINAPI IDirect3DVolume9Impl_LockBox(LPDIRECT3DVOLUME9 iface, D3DL
TRACE("(%p) relay %p %p %p %d\n", This, This->wineD3DVolume, pLockedVolume, pBox, Flags);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DVolume_LockBox(This->wineD3DVolume, (WINED3DLOCKED_BOX *)pLockedVolume,
(const WINED3DBOX *)pBox, Flags);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
return hr;
}
@@ -213,11 +214,11 @@ static HRESULT WINAPI IDirect3DVolume9Impl_UnlockBox(LPDIRECT3DVOLUME9 iface) {
TRACE("(%p) relay %p\n", This, This->wineD3DVolume);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DVolume_UnlockBox(This->wineD3DVolume);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
return hr;
}
diff --git a/dlls/d3d9/volumetexture.c b/dlls/d3d9/volumetexture.c
index efeb919..aefab62 100644
--- a/dlls/d3d9/volumetexture.c
+++ b/dlls/d3d9/volumetexture.c
@@ -58,9 +58,10 @@ static ULONG WINAPI IDirect3DVolumeTexture9Impl_Release(LPDIRECT3DVOLUMETEXTURE9
TRACE("(%p) : ReleaseRef to %d\n", This, ref);
if (ref == 0) {
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
IWineD3DVolumeTexture_Destroy(This->wineD3DVolumeTexture, D3D9CB_DestroyVolume);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
+
IDirect3DDevice9Ex_Release(This->parentDevice);
HeapFree(GetProcessHeap(), 0, This);
}
@@ -75,14 +76,14 @@ static HRESULT WINAPI IDirect3DVolumeTexture9Impl_GetDevice(LPDIRECT3DVOLUMETEXT
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DStateBlock_GetDevice(This->wineD3DVolumeTexture, &wined3d_device);
if (SUCCEEDED(hr))
{
IWineD3DDevice_GetParent(wined3d_device, (IUnknown **)ppDevice);
IWineD3DDevice_Release(wined3d_device);
}
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
return hr;
}
@@ -93,11 +94,11 @@ static HRESULT WINAPI IDirect3DVolumeTexture9Impl_SetPrivateData(LPDIRECT3DVOLUM
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DVolumeTexture_SetPrivateData(This->wineD3DVolumeTexture, refguid, pData, SizeOfData, Flags);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
return hr;
}
@@ -108,11 +109,11 @@ static HRESULT WINAPI IDirect3DVolumeTexture9Impl_GetPrivateData(LPDIRECT3DVOLUM
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DVolumeTexture_GetPrivateData(This->wineD3DVolumeTexture, refguid, pData, pSizeOfData);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
return hr;
}
@@ -123,11 +124,11 @@ static HRESULT WINAPI IDirect3DVolumeTexture9Impl_FreePrivateData(LPDIRECT3DVOLU
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DVolumeTexture_FreePrivateData(This->wineD3DVolumeTexture, refguid);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
return hr;
}
@@ -138,11 +139,11 @@ static DWORD WINAPI IDirect3DVolumeTexture9Impl_SetPriority(LPDIRECT3DVOLUMETEXT
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
priority = IWineD3DVolumeTexture_SetPriority(This->wineD3DVolumeTexture, PriorityNew);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
return priority;
}
@@ -153,11 +154,11 @@ static DWORD WINAPI IDirect3DVolumeTexture9Impl_GetPriority(LPDIRECT3DVOLUMETEXT
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
priority = IWineD3DVolumeTexture_GetPriority(This->wineD3DVolumeTexture);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
return priority;
}
@@ -167,11 +168,11 @@ static void WINAPI IDirect3DVolumeTexture9Impl_PreLoad(LPDIRECT3DVOLUMETEXTURE9
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
IWineD3DVolumeTexture_PreLoad(This->wineD3DVolumeTexture);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
}
static D3DRESOURCETYPE WINAPI IDirect3DVolumeTexture9Impl_GetType(LPDIRECT3DVOLUMETEXTURE9 iface) {
@@ -180,11 +181,11 @@ static D3DRESOURCETYPE WINAPI IDirect3DVolumeTexture9Impl_GetType(LPDIRECT3DVOLU
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
type = IWineD3DVolumeTexture_GetType(This->wineD3DVolumeTexture);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
return type;
}
@@ -196,11 +197,11 @@ static DWORD WINAPI IDirect3DVolumeTexture9Impl_SetLOD(LPDIRECT3DVOLUMETEXTURE9
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
lod = IWineD3DVolumeTexture_SetLOD(This->wineD3DVolumeTexture, LODNew);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
return lod;
}
@@ -211,11 +212,11 @@ static DWORD WINAPI IDirect3DVolumeTexture9Impl_GetLOD(LPDIRECT3DVOLUMETEXTURE9
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
lod = IWineD3DVolumeTexture_GetLOD(This->wineD3DVolumeTexture);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
return lod;
}
@@ -226,11 +227,11 @@ static DWORD WINAPI IDirect3DVolumeTexture9Impl_GetLevelCount(LPDIRECT3DVOLUMETE
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
level_count = IWineD3DVolumeTexture_GetLevelCount(This->wineD3DVolumeTexture);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
return level_count;
}
@@ -241,11 +242,11 @@ static HRESULT WINAPI IDirect3DVolumeTexture9Impl_SetAutoGenFilterType(LPDIRECT3
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DVolumeTexture_SetAutoGenFilterType(This->wineD3DVolumeTexture, (WINED3DTEXTUREFILTERTYPE) FilterType);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
return hr;
}
@@ -256,11 +257,11 @@ static D3DTEXTUREFILTERTYPE WINAPI IDirect3DVolumeTexture9Impl_GetAutoGenFilterT
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
filter_type = (D3DTEXTUREFILTERTYPE)IWineD3DVolumeTexture_GetAutoGenFilterType(This->wineD3DVolumeTexture);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
return filter_type;
}
@@ -270,11 +271,11 @@ static void WINAPI IDirect3DVolumeTexture9Impl_GenerateMipSubLevels(LPDIRECT3DVO
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
IWineD3DVolumeTexture_GenerateMipSubLevels(This->wineD3DVolumeTexture);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
}
/* IDirect3DVolumeTexture9 Interface follow: */
@@ -285,11 +286,11 @@ static HRESULT WINAPI IDirect3DVolumeTexture9Impl_GetLevelDesc(LPDIRECT3DVOLUMET
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DVolumeTexture_GetLevelDesc(This->wineD3DVolumeTexture, Level, &wined3ddesc);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
if (SUCCEEDED(hr))
{
@@ -312,7 +313,7 @@ static HRESULT WINAPI IDirect3DVolumeTexture9Impl_GetVolumeLevel(LPDIRECT3DVOLUM
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hrc = IWineD3DVolumeTexture_GetVolumeLevel(This->wineD3DVolumeTexture, Level, &myVolume);
if (hrc == D3D_OK && NULL != ppVolumeLevel) {
@@ -320,7 +321,7 @@ static HRESULT WINAPI IDirect3DVolumeTexture9Impl_GetVolumeLevel(LPDIRECT3DVOLUM
IWineD3DVolumeTexture_Release(myVolume);
}
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
return hrc;
}
@@ -331,12 +332,12 @@ static HRESULT WINAPI IDirect3DVolumeTexture9Impl_LockBox(LPDIRECT3DVOLUMETEXTUR
TRACE("(%p) Relay %p %p %p %d\n", This, This->wineD3DVolumeTexture, pLockedVolume, pBox,Flags);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DVolumeTexture_LockBox(This->wineD3DVolumeTexture, Level, (WINED3DLOCKED_BOX *)pLockedVolume,
(const WINED3DBOX *)pBox, Flags);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
return hr;
}
@@ -347,11 +348,11 @@ static HRESULT WINAPI IDirect3DVolumeTexture9Impl_UnlockBox(LPDIRECT3DVOLUMETEXT
TRACE("(%p) Relay %p %d\n", This, This->wineD3DVolumeTexture, Level);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DVolumeTexture_UnlockBox(This->wineD3DVolumeTexture, Level);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
return hr;
}
@@ -362,11 +363,11 @@ static HRESULT WINAPI IDirect3DVolumeTexture9Impl_AddDirtyBox(LPDIRECT3DVOLUMETE
TRACE("(%p) Relay\n", This);
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hr = IWineD3DVolumeTexture_AddDirtyBox(This->wineD3DVolumeTexture, (CONST WINED3DBOX *)pDirtyBox);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
return hr;
}
@@ -425,13 +426,13 @@ HRESULT WINAPI IDirect3DDevice9Impl_CreateVolumeTexture(LPDIRECT3DDEVICE9EX if
object->lpVtbl = &Direct3DVolumeTexture9_Vtbl;
object->ref = 1;
- EnterCriticalSection(&d3d9_cs);
+ wined3d_mutex_lock();
hrc = IWineD3DDevice_CreateVolumeTexture(This->WineD3DDevice, Width, Height, Depth, Levels,
Usage & WINED3DUSAGE_MASK, wined3dformat_from_d3dformat(Format),
Pool, &object->wineD3DVolumeTexture, (IUnknown *)object);
- LeaveCriticalSection(&d3d9_cs);
+ wined3d_mutex_unlock();
if (hrc != D3D_OK) {
--
1.6.0.6
More information about the wine-patches
mailing list