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

d3d8: Use a wined3d cs for wined3d locking.

We will need this for d3d10, where both dxgi and d3d10core are making wined3d calls. Right now d3d8/d3d9 also use this to protect their own data, but eventually we should push this down into wined3d itself and use something a bit more fine-grained. There's no good reason that doing e.g. a vertex buffer upload in some thread should block all of wined3d.
parent 4d1379f6
......@@ -57,9 +57,11 @@ static ULONG WINAPI IDirect3DCubeTexture8Impl_Release(LPDIRECT3DCUBETEXTURE8 ifa
if (ref == 0) {
TRACE("Releasing child %p\n", This->wineD3DCubeTexture);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
IWineD3DCubeTexture_Destroy(This->wineD3DCubeTexture, D3D8CB_DestroySurface);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
IUnknown_Release(This->parentDevice);
HeapFree(GetProcessHeap(), 0, This);
}
......@@ -73,14 +75,15 @@ static HRESULT WINAPI IDirect3DCubeTexture8Impl_GetDevice(LPDIRECT3DCUBETEXTURE8
HRESULT hr;
TRACE("(%p) Relay\n" , This);
EnterCriticalSection(&d3d8_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(&d3d8_cs);
wined3d_mutex_lock();
return hr;
}
......@@ -89,9 +92,10 @@ static HRESULT WINAPI IDirect3DCubeTexture8Impl_SetPrivateData(LPDIRECT3DCUBETEX
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DCubeTexture_SetPrivateData(This->wineD3DCubeTexture,refguid,pData,SizeOfData,Flags);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
......@@ -100,9 +104,10 @@ static HRESULT WINAPI IDirect3DCubeTexture8Impl_GetPrivateData(LPDIRECT3DCUBETEX
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DCubeTexture_GetPrivateData(This->wineD3DCubeTexture,refguid,pData,pSizeOfData);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
......@@ -111,9 +116,10 @@ static HRESULT WINAPI IDirect3DCubeTexture8Impl_FreePrivateData(LPDIRECT3DCUBETE
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DCubeTexture_FreePrivateData(This->wineD3DCubeTexture,refguid);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
......@@ -122,9 +128,10 @@ static DWORD WINAPI IDirect3DCubeTexture8Impl_SetPriority(LPDIRECT3DCUBETEXTURE8
DWORD ret;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
ret = IWineD3DCubeTexture_SetPriority(This->wineD3DCubeTexture, PriorityNew);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return ret;
}
......@@ -133,9 +140,10 @@ static DWORD WINAPI IDirect3DCubeTexture8Impl_GetPriority(LPDIRECT3DCUBETEXTURE8
DWORD ret;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
ret = IWineD3DCubeTexture_GetPriority(This->wineD3DCubeTexture);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return ret;
}
......@@ -143,9 +151,9 @@ static void WINAPI IDirect3DCubeTexture8Impl_PreLoad(LPDIRECT3DCUBETEXTURE8 ifac
IDirect3DCubeTexture8Impl *This = (IDirect3DCubeTexture8Impl *)iface;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
IWineD3DCubeTexture_PreLoad(This->wineD3DCubeTexture);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
}
static D3DRESOURCETYPE WINAPI IDirect3DCubeTexture8Impl_GetType(LPDIRECT3DCUBETEXTURE8 iface) {
......@@ -153,9 +161,10 @@ static D3DRESOURCETYPE WINAPI IDirect3DCubeTexture8Impl_GetType(LPDIRECT3DCUBETE
D3DRESOURCETYPE type;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
type = IWineD3DCubeTexture_GetType(This->wineD3DCubeTexture);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return type;
}
......@@ -165,9 +174,10 @@ static DWORD WINAPI IDirect3DCubeTexture8Impl_SetLOD(LPDIRECT3DCUBETEXTURE8 ifac
DWORD lod;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
lod = IWineD3DCubeTexture_SetLOD(This->wineD3DCubeTexture, LODNew);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return lod;
}
......@@ -176,9 +186,10 @@ static DWORD WINAPI IDirect3DCubeTexture8Impl_GetLOD(LPDIRECT3DCUBETEXTURE8 ifac
DWORD lod;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
lod = IWineD3DCubeTexture_GetLOD((LPDIRECT3DBASETEXTURE8) This);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return lod;
}
......@@ -187,9 +198,10 @@ static DWORD WINAPI IDirect3DCubeTexture8Impl_GetLevelCount(LPDIRECT3DCUBETEXTUR
DWORD cnt;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
cnt = IWineD3DCubeTexture_GetLevelCount(This->wineD3DCubeTexture);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return cnt;
}
......@@ -201,9 +213,9 @@ static HRESULT WINAPI IDirect3DCubeTexture8Impl_GetLevelDesc(LPDIRECT3DCUBETEXTU
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DCubeTexture_GetLevelDesc(This->wineD3DCubeTexture, Level, &wined3ddesc);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
if (SUCCEEDED(hr))
{
......@@ -227,13 +239,14 @@ static HRESULT WINAPI IDirect3DCubeTexture8Impl_GetCubeMapSurface(LPDIRECT3DCUBE
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_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(&d3d8_cs);
wined3d_mutex_unlock();
return hrc;
}
......@@ -242,9 +255,10 @@ static HRESULT WINAPI IDirect3DCubeTexture8Impl_LockRect(LPDIRECT3DCUBETEXTURE8
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DCubeTexture_LockRect(This->wineD3DCubeTexture, (WINED3DCUBEMAP_FACES) FaceType, Level, (WINED3DLOCKED_RECT *) pLockedRect, pRect, Flags);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
......@@ -253,9 +267,10 @@ static HRESULT WINAPI IDirect3DCubeTexture8Impl_UnlockRect(LPDIRECT3DCUBETEXTURE
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DCubeTexture_UnlockRect(This->wineD3DCubeTexture, (WINED3DCUBEMAP_FACES) FaceType, Level);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
......@@ -264,9 +279,10 @@ static HRESULT WINAPI IDirect3DCubeTexture8Impl_AddDirtyRect(LPDIRECT3DCUBETEXTU
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DCubeTexture_AddDirtyRect(This->wineD3DCubeTexture, (WINED3DCUBEMAP_FACES) FaceType, pDirtyRect);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
......
......@@ -24,15 +24,6 @@
#include "d3d8_private.h"
#include "wine/debug.h"
static CRITICAL_SECTION_DEBUG d3d8_cs_debug =
{
0, 0, &d3d8_cs,
{ &d3d8_cs_debug.ProcessLocksList,
&d3d8_cs_debug.ProcessLocksList },
0, 0, { (DWORD_PTR)(__FILE__ ": d3d8_cs") }
};
CRITICAL_SECTION d3d8_cs = { &d3d8_cs_debug, -1, 0, 0, 0, 0 };
WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
HRESULT WINAPI D3D8GetSWInfo(void) {
......@@ -48,7 +39,8 @@ IDirect3D8* WINAPI Direct3DCreate8(UINT SDKVersion) {
IDirect3D8Impl* object;
TRACE("SDKVersion = %x\n", SDKVersion);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3D8Impl));
object->lpVtbl = &Direct3D8_Vtbl;
......@@ -56,7 +48,8 @@ IDirect3D8* WINAPI Direct3DCreate8(UINT SDKVersion) {
object->WineD3D = WineDirect3DCreate(8, (IUnknown *)object);
TRACE("Created Direct3D object @ %p, WineObj @ %p\n", object, object->WineD3D);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
if (!object->WineD3D)
{
......
......@@ -122,9 +122,6 @@ typedef struct IDirect3DVertexShaderDeclarationImpl IDirect3DVertexShaderDeclara
/* Advance declaration of structures to satisfy compiler */
typedef struct IDirect3DVertexShader8Impl IDirect3DVertexShader8Impl;
/* Global critical section */
extern CRITICAL_SECTION d3d8_cs;
/* ===========================================================================
The interfaces themselves
=========================================================================== */
......
......@@ -71,9 +71,11 @@ static ULONG WINAPI IDirect3D8Impl_Release(LPDIRECT3D8 iface) {
if (ref == 0) {
TRACE("Releasing wined3d %p\n", This->WineD3D);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
IWineD3D_Release(This->WineD3D);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
HeapFree(GetProcessHeap(), 0, This);
}
......@@ -86,9 +88,10 @@ static HRESULT WINAPI IDirect3D8Impl_RegisterSoftwareDevice (LPDIRECT3D8 iface,
HRESULT hr;
TRACE("(%p)->(%p)\n", This, pInitializeFunction);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3D_RegisterSoftwareDevice(This->WineD3D, pInitializeFunction);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
......@@ -97,9 +100,10 @@ static UINT WINAPI IDirect3D8Impl_GetAdapterCount (LPDIRECT3D8 iface) {
HRESULT hr;
TRACE("(%p)\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3D_GetAdapterCount(This->WineD3D);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
......@@ -119,9 +123,9 @@ static HRESULT WINAPI IDirect3D8Impl_GetAdapterIdentifier(LPDIRECT3D8 iface,
adapter_id.device_name = NULL; /* d3d9 only */
adapter_id.device_name_size = 0; /* d3d9 only */
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3D_GetAdapterIdentifier(This->WineD3D, Adapter, Flags, &adapter_id);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
pIdentifier->DriverVersion = adapter_id.driver_version;
pIdentifier->VendorId = adapter_id.vendor_id;
......@@ -139,9 +143,10 @@ static UINT WINAPI IDirect3D8Impl_GetAdapterModeCount (LPDIRECT3D8 iface,UINT Ad
HRESULT hr;
TRACE("(%p)->(%d)\n", This, Adapter);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3D_GetAdapterModeCount(This->WineD3D, Adapter, 0 /* format */);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
......@@ -150,9 +155,9 @@ static HRESULT WINAPI IDirect3D8Impl_EnumAdapterModes (LPDIRECT3D8 iface, UINT A
HRESULT hr;
TRACE("(%p)->(%d, %d, %p)\n", This, Adapter, Mode, pMode);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3D_EnumAdapterModes(This->WineD3D, Adapter, WINED3DFMT_UNKNOWN, Mode, (WINED3DDISPLAYMODE *) pMode);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
if (SUCCEEDED(hr)) pMode->Format = d3dformat_from_wined3dformat(pMode->Format);
......@@ -164,9 +169,9 @@ static HRESULT WINAPI IDirect3D8Impl_GetAdapterDisplayMode (LPDIRECT3D8 iface, U
HRESULT hr;
TRACE("(%p)->(%d,%p)\n", This, Adapter, pMode);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3D_GetAdapterDisplayMode(This->WineD3D, Adapter, (WINED3DDISPLAYMODE *) pMode);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
if (SUCCEEDED(hr)) pMode->Format = d3dformat_from_wined3dformat(pMode->Format);
......@@ -180,10 +185,11 @@ static HRESULT WINAPI IDirect3D8Impl_CheckDeviceType (LPDIRECT3D8 i
HRESULT hr;
TRACE("(%p)->(%d, %d, %d, %d, %s)\n", This, Adapter, CheckType, DisplayFormat, BackBufferFormat, Windowed ? "true" : "false");
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3D_CheckDeviceType(This->WineD3D, Adapter, CheckType, wined3dformat_from_d3dformat(DisplayFormat),
wined3dformat_from_d3dformat(BackBufferFormat), Windowed);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
......@@ -214,10 +220,11 @@ static HRESULT WINAPI IDirect3D8Impl_CheckDeviceFormat (LPDIRECT3D8 i
break;
}
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3D_CheckDeviceFormat(This->WineD3D, Adapter, DeviceType, wined3dformat_from_d3dformat(AdapterFormat),
Usage, WineD3DRType, wined3dformat_from_d3dformat(CheckFormat), SURFACE_OPENGL);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
......@@ -228,10 +235,11 @@ static HRESULT WINAPI IDirect3D8Impl_CheckDeviceMultiSampleType(IDirect3D8 *ifac
HRESULT hr;
TRACE("(%p)-<(%d, %d, %d, %s, %d)\n", This, Adapter, DeviceType, SurfaceFormat, Windowed ? "true" : "false", MultiSampleType);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3D_CheckDeviceMultiSampleType(This->WineD3D, Adapter, DeviceType,
wined3dformat_from_d3dformat(SurfaceFormat), Windowed, (WINED3DMULTISAMPLE_TYPE) MultiSampleType, NULL);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
......@@ -242,11 +250,12 @@ static HRESULT WINAPI IDirect3D8Impl_CheckDepthStencilMatch(IDirect3D8 *iface, U
HRESULT hr;
TRACE("(%p)-<(%d, %d, %d, %d, %d)\n", This, Adapter, DeviceType, AdapterFormat, RenderTargetFormat, DepthStencilFormat);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3D_CheckDepthStencilMatch(This->WineD3D, Adapter, DeviceType,
wined3dformat_from_d3dformat(AdapterFormat), wined3dformat_from_d3dformat(RenderTargetFormat),
wined3dformat_from_d3dformat(DepthStencilFormat));
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
......@@ -278,9 +287,11 @@ static HRESULT WINAPI IDirect3D8Impl_GetDeviceCaps(LPDIRECT3D8 iface, UINT Ada
if(pWineCaps == NULL){
return D3DERR_INVALIDCALL; /*well this is what MSDN says to return*/
}
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hrc = IWineD3D_GetDeviceCaps(This->WineD3D, Adapter, DeviceType, pWineCaps);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
fixup_caps(pWineCaps);
WINECAPSTOD3D8CAPS(pCaps, pWineCaps)
HeapFree(GetProcessHeap(), 0, pWineCaps);
......@@ -294,9 +305,10 @@ static HMONITOR WINAPI IDirect3D8Impl_GetAdapterMonitor(LPDIRECT3D8 iface, UINT
HMONITOR ret;
TRACE("(%p)->(%d)\n", This, Adapter);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
ret = IWineD3D_GetAdapterMonitor(This->WineD3D, Adapter);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return ret;
}
......@@ -362,14 +374,15 @@ static HRESULT WINAPI IDirect3D8Impl_CreateDevice(LPDIRECT3D8 iface, UINT Adapte
*ppReturnedDeviceInterface = (IDirect3DDevice8 *)object;
/* Allocate an associated WineD3DDevice object */
EnterCriticalSection(&d3d8_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(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
......@@ -396,7 +409,7 @@ static HRESULT WINAPI IDirect3D8Impl_CreateDevice(LPDIRECT3D8 iface, UINT Adapte
}
hr = IWineD3DDevice_Init3D(object->WineD3DDevice, &localParameters);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
pPresentationParameters->BackBufferWidth = localParameters.BackBufferWidth;
pPresentationParameters->BackBufferHeight = localParameters.BackBufferHeight;
......@@ -422,9 +435,11 @@ static HRESULT WINAPI IDirect3D8Impl_CreateDevice(LPDIRECT3D8 iface, UINT Adapte
object->decls = HeapAlloc(GetProcessHeap(), 0, object->declArraySize * sizeof(*object->decls));
if(!object->decls) {
ERR("Out of memory\n");
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
IWineD3DDevice_Release(object->WineD3DDevice);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
HeapFree(GetProcessHeap(), 0, object);
*ppReturnedDeviceInterface = NULL;
hr = E_OUTOFMEMORY;
......
......@@ -56,9 +56,10 @@ static ULONG WINAPI IDirect3DIndexBuffer8Impl_Release(LPDIRECT3DINDEXBUFFER8 ifa
TRACE("(%p) : ReleaseRef to %d\n", This, ref);
if (ref == 0) {
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
IWineD3DBuffer_Release(This->wineD3DIndexBuffer);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
IUnknown_Release(This->parentDevice);
HeapFree(GetProcessHeap(), 0, This);
}
......@@ -72,14 +73,15 @@ static HRESULT WINAPI IDirect3DIndexBuffer8Impl_GetDevice(LPDIRECT3DINDEXBUFFER8
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_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(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
......@@ -88,9 +90,10 @@ static HRESULT WINAPI IDirect3DIndexBuffer8Impl_SetPrivateData(LPDIRECT3DINDEXBU
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DBuffer_SetPrivateData(This->wineD3DIndexBuffer, refguid, pData, SizeOfData, Flags);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
......@@ -99,9 +102,10 @@ static HRESULT WINAPI IDirect3DIndexBuffer8Impl_GetPrivateData(LPDIRECT3DINDEXBU
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DBuffer_GetPrivateData(This->wineD3DIndexBuffer, refguid, pData, pSizeOfData);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
......@@ -110,9 +114,10 @@ static HRESULT WINAPI IDirect3DIndexBuffer8Impl_FreePrivateData(LPDIRECT3DINDEXB
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DBuffer_FreePrivateData(This->wineD3DIndexBuffer, refguid);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
......@@ -121,9 +126,10 @@ static DWORD WINAPI IDirect3DIndexBuffer8Impl_SetPriority(LPDIRECT3DINDEXBUFFER8
DWORD ret;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
ret = IWineD3DBuffer_SetPriority(This->wineD3DIndexBuffer, PriorityNew);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return ret;
}
......@@ -132,9 +138,10 @@ static DWORD WINAPI IDirect3DIndexBuffer8Impl_GetPriority(LPDIRECT3DINDEXBUFFER8
DWORD ret;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
ret = IWineD3DBuffer_GetPriority(This->wineD3DIndexBuffer);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return ret;
}
......@@ -142,9 +149,9 @@ static void WINAPI IDirect3DIndexBuffer8Impl_PreLoad(LPDIRECT3DINDEXBUFFER8 ifac
IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
IWineD3DBuffer_PreLoad(This->wineD3DIndexBuffer);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
}
static D3DRESOURCETYPE WINAPI IDirect3DIndexBuffer8Impl_GetType(LPDIRECT3DINDEXBUFFER8 iface) {
......@@ -160,9 +167,10 @@ static HRESULT WINAPI IDirect3DIndexBuffer8Impl_Lock(LPDIRECT3DINDEXBUFFER8 ifac
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DBuffer_Map(This->wineD3DIndexBuffer, OffsetToLock, SizeToLock, ppbData, Flags);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
......@@ -171,9 +179,10 @@ static HRESULT WINAPI IDirect3DIndexBuffer8Impl_Unlock(LPDIRECT3DINDEXBUFFER8 if
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DBuffer_Unmap(This->wineD3DIndexBuffer);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
......@@ -183,9 +192,9 @@ static HRESULT WINAPI IDirect3DIndexBuffer8Impl_GetDesc(LPDIRECT3DINDEXBUFFER8 i
WINED3DBUFFER_DESC desc;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DBuffer_GetDesc(This->wineD3DIndexBuffer, &desc);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
if (SUCCEEDED(hr)) {
pDesc->Format = d3dformat_from_wined3dformat(This->format);
......
......@@ -56,9 +56,10 @@ static ULONG WINAPI IDirect3DPixelShader8Impl_Release(IDirect3DPixelShader8 * if
TRACE("(%p) : ReleaseRef to %d\n", This, ref);
if (ref == 0) {
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
IWineD3DPixelShader_Release(This->wineD3DPixelShader);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
HeapFree(GetProcessHeap(), 0, This);
}
return ref;
......
......@@ -58,9 +58,10 @@ static ULONG WINAPI IDirect3DStateBlock8Impl_Release(IDirect3DStateBlock8 *iface
TRACE("(%p) : ReleaseRef to %d\n", This, ref);
if (ref == 0) {
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
IWineD3DStateBlock_Release(This->wineD3DStateBlock);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
HeapFree(GetProcessHeap(), 0, This);
}
return ref;
......@@ -74,16 +75,14 @@ static HRESULT WINAPI IDirect3DStateBlock8Impl_GetDevice(IDirect3DStateBlock8 *i
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_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(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
......@@ -94,11 +93,9 @@ static HRESULT WINAPI IDirect3DStateBlock8Impl_Capture(IDirect3DStateBlock8 *ifa
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DStateBlock_Capture(This->wineD3DStateBlock);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
......@@ -109,11 +106,9 @@ static HRESULT WINAPI IDirect3DStateBlock8Impl_Apply(IDirect3DStateBlock8 *iface
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DStateBlock_Apply(This->wineD3DStateBlock);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
......
......@@ -76,9 +76,10 @@ static ULONG WINAPI IDirect3DSurface8Impl_Release(LPDIRECT3DSURFACE8 iface) {
if (This->parentDevice) IUnknown_Release(This->parentDevice);
/* Implicit surfaces are destroyed with the device, not if refcount reaches 0. */
if (!This->isImplicit) {
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
IWineD3DSurface_Release(This->wineD3DSurface);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
HeapFree(GetProcessHeap(), 0, This);
}
}
......@@ -94,14 +95,15 @@ static HRESULT WINAPI IDirect3DSurface8Impl_GetDevice(LPDIRECT3DSURFACE8 iface,
HRESULT hr;
TRACE("(%p)->(%p)\n", This, ppDevice);
EnterCriticalSection(&d3d8_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(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
......@@ -110,9 +112,10 @@ static HRESULT WINAPI IDirect3DSurface8Impl_SetPrivateData(LPDIRECT3DSURFACE8 if
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DSurface_SetPrivateData(This->wineD3DSurface, refguid, pData, SizeOfData, Flags);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
......@@ -121,9 +124,10 @@ static HRESULT WINAPI IDirect3DSurface8Impl_GetPrivateData(LPDIRECT3DSURFACE8 if
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DSurface_GetPrivateData(This->wineD3DSurface, refguid, pData, pSizeOfData);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
......@@ -132,9 +136,10 @@ static HRESULT WINAPI IDirect3DSurface8Impl_FreePrivateData(LPDIRECT3DSURFACE8 i
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DSurface_FreePrivateData(This->wineD3DSurface, refguid);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
......@@ -159,9 +164,9 @@ static HRESULT WINAPI IDirect3DSurface8Impl_GetDesc(LPDIRECT3DSURFACE8 iface, D3
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DSurface_GetDesc(This->wineD3DSurface, &wined3ddesc);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
if (SUCCEEDED(hr))
{
......@@ -184,7 +189,7 @@ static HRESULT WINAPI IDirect3DSurface8Impl_LockRect(LPDIRECT3DSURFACE8 iface, D
TRACE("(%p) Relay\n", This);
TRACE("(%p) calling IWineD3DSurface_LockRect %p %p %p %d\n", This, This->wineD3DSurface, pLockedRect, pRect, Flags);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
if (pRect) {
D3DSURFACE_DESC desc;
IDirect3DSurface8_GetDesc(iface, &desc);
......@@ -196,13 +201,15 @@ static HRESULT WINAPI IDirect3DSurface8Impl_LockRect(LPDIRECT3DSURFACE8 iface, D
|| (pRect->right > desc.Width)
|| (pRect->bottom > desc.Height)) {
WARN("Trying to lock an invalid rectangle, returning D3DERR_INVALIDCALL\n");
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return D3DERR_INVALIDCALL;
}
}
hr = IWineD3DSurface_LockRect(This->wineD3DSurface, (WINED3DLOCKED_RECT *) pLockedRect, pRect, Flags);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
......@@ -211,9 +218,10 @@ static HRESULT WINAPI IDirect3DSurface8Impl_UnlockRect(LPDIRECT3DSURFACE8 iface)
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DSurface_UnlockRect(This->wineD3DSurface);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
switch(hr)
{
case WINEDDERR_NOTLOCKED: return D3DERR_INVALIDCALL;
......
......@@ -56,9 +56,10 @@ static ULONG WINAPI IDirect3DSwapChain8Impl_Release(LPDIRECT3DSWAPCHAIN8 iface)
TRACE("(%p) : ReleaseRef to %d\n", This, ref);
if (ref == 0) {
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
IWineD3DSwapChain_Destroy(This->wineD3DSwapChain, D3D8CB_DestroyRenderTarget);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
if (This->parentDevice) IUnknown_Release(This->parentDevice);
HeapFree(GetProcessHeap(), 0, This);
}
......@@ -71,9 +72,10 @@ static HRESULT WINAPI IDirect3DSwapChain8Impl_Present(LPDIRECT3DSWAPCHAIN8 iface
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DSwapChain_Present(This->wineD3DSwapChain, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion, 0);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
......@@ -84,13 +86,14 @@ static HRESULT WINAPI IDirect3DSwapChain8Impl_GetBackBuffer(LPDIRECT3DSWAPCHAIN8
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_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(&d3d8_cs);
wined3d_mutex_unlock();
return hrc;
}
......
......@@ -57,9 +57,10 @@ static ULONG WINAPI IDirect3DTexture8Impl_Release(LPDIRECT3DTEXTURE8 iface) {
TRACE("(%p) : ReleaseRef to %d\n", This, ref);
if (ref == 0) {
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
IWineD3DTexture_Destroy(This->wineD3DTexture, D3D8CB_DestroySurface);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
IUnknown_Release(This->parentDevice);
HeapFree(GetProcessHeap(), 0, This);
}
......@@ -72,14 +73,16 @@ static HRESULT WINAPI IDirect3DTexture8Impl_GetDevice(LPDIRECT3DTEXTURE8 iface,
IWineD3DDevice *wined3d_device;
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_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(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
......@@ -88,9 +91,10 @@ static HRESULT WINAPI IDirect3DTexture8Impl_SetPrivateData(LPDIRECT3DTEXTURE8 if
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DTexture_SetPrivateData(This->wineD3DTexture, refguid, pData, SizeOfData, Flags);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
......@@ -99,9 +103,10 @@ static HRESULT WINAPI IDirect3DTexture8Impl_GetPrivateData(LPDIRECT3DTEXTURE8 if
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DTexture_GetPrivateData(This->wineD3DTexture, refguid, pData, pSizeOfData);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
......@@ -110,9 +115,10 @@ static HRESULT WINAPI IDirect3DTexture8Impl_FreePrivateData(LPDIRECT3DTEXTURE8 i
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DTexture_FreePrivateData(This->wineD3DTexture, refguid);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
......@@ -121,9 +127,10 @@ static DWORD WINAPI IDirect3DTexture8Impl_SetPriority(LPDIRECT3DTEXTURE8 iface,
DWORD ret;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
ret = IWineD3DTexture_SetPriority(This->wineD3DTexture, PriorityNew);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return ret;
}
......@@ -132,9 +139,10 @@ static DWORD WINAPI IDirect3DTexture8Impl_GetPriority(LPDIRECT3DTEXTURE8 iface)
DWORD ret;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
ret = IWineD3DTexture_GetPriority(This->wineD3DTexture);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return ret;
}
......@@ -142,9 +150,9 @@ static void WINAPI IDirect3DTexture8Impl_PreLoad(LPDIRECT3DTEXTURE8 iface) {
IDirect3DTexture8Impl *This = (IDirect3DTexture8Impl *)iface;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
IWineD3DTexture_PreLoad(This->wineD3DTexture);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
}
static D3DRESOURCETYPE WINAPI IDirect3DTexture8Impl_GetType(LPDIRECT3DTEXTURE8 iface) {
......@@ -152,9 +160,10 @@ static D3DRESOURCETYPE WINAPI IDirect3DTexture8Impl_GetType(LPDIRECT3DTEXTURE8 i
D3DRESOURCETYPE type;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
type = IWineD3DTexture_GetType(This->wineD3DTexture);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return type;
}
......@@ -164,9 +173,10 @@ static DWORD WINAPI IDirect3DTexture8Impl_SetLOD(LPDIRECT3DTEXTURE8 iface, DWORD
DWORD ret;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
ret = IWineD3DTexture_SetLOD(This->wineD3DTexture, LODNew);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return ret;
}
......@@ -175,9 +185,10 @@ static DWORD WINAPI IDirect3DTexture8Impl_GetLOD(LPDIRECT3DTEXTURE8 iface) {
DWORD ret;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
ret = IWineD3DTexture_GetLOD(This->wineD3DTexture);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return ret;
}
......@@ -186,9 +197,10 @@ static DWORD WINAPI IDirect3DTexture8Impl_GetLevelCount(LPDIRECT3DTEXTURE8 iface
DWORD ret;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
ret = IWineD3DTexture_GetLevelCount(This->wineD3DTexture);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return ret;
}
......@@ -200,9 +212,9 @@ static HRESULT WINAPI IDirect3DTexture8Impl_GetLevelDesc(LPDIRECT3DTEXTURE8 ifac
WINED3DSURFACE_DESC wined3ddesc;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DTexture_GetLevelDesc(This->wineD3DTexture, Level, &wined3ddesc);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
if (SUCCEEDED(hr))
{
......@@ -225,13 +237,15 @@ static HRESULT WINAPI IDirect3DTexture8Impl_GetSurfaceLevel(LPDIRECT3DTEXTURE8 i
IWineD3DSurface *mySurface = NULL;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_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(&d3d8_cs);
wined3d_mutex_unlock();
return hrc;
}
......@@ -240,9 +254,10 @@ static HRESULT WINAPI IDirect3DTexture8Impl_LockRect(LPDIRECT3DTEXTURE8 iface, U
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DTexture_LockRect(This->wineD3DTexture, Level, (WINED3DLOCKED_RECT *) pLockedRect, pRect, Flags);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
......@@ -251,9 +266,10 @@ static HRESULT WINAPI IDirect3DTexture8Impl_UnlockRect(LPDIRECT3DTEXTURE8 iface,
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DTexture_UnlockRect(This->wineD3DTexture, Level);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
......@@ -262,9 +278,10 @@ static HRESULT WINAPI IDirect3DTexture8Impl_AddDirtyRect(LPDIRECT3DTEXTURE8 ifac
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DTexture_AddDirtyRect(This->wineD3DTexture, pDirtyRect);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
......
......@@ -57,9 +57,10 @@ static ULONG WINAPI IDirect3DVertexBuffer8Impl_Release(LPDIRECT3DVERTEXBUFFER8 i
TRACE("(%p) : ReleaseRef to %d\n", This, ref);
if (ref == 0) {
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
IWineD3DBuffer_Release(This->wineD3DVertexBuffer);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
IUnknown_Release(This->parentDevice);
HeapFree(GetProcessHeap(), 0, This);
}
......@@ -74,14 +75,15 @@ static HRESULT WINAPI IDirect3DVertexBuffer8Impl_GetDevice(LPDIRECT3DVERTEXBUFFE
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_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(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
......@@ -90,9 +92,10 @@ static HRESULT WINAPI IDirect3DVertexBuffer8Impl_SetPrivateData(LPDIRECT3DVERTEX
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DBuffer_SetPrivateData(This->wineD3DVertexBuffer, refguid, pData, SizeOfData, Flags);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
......@@ -101,9 +104,10 @@ static HRESULT WINAPI IDirect3DVertexBuffer8Impl_GetPrivateData(LPDIRECT3DVERTEX
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DBuffer_GetPrivateData(This->wineD3DVertexBuffer, refguid, pData, pSizeOfData);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
......@@ -112,9 +116,10 @@ static HRESULT WINAPI IDirect3DVertexBuffer8Impl_FreePrivateData(LPDIRECT3DVERTE
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DBuffer_FreePrivateData(This->wineD3DVertexBuffer, refguid);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
......@@ -123,9 +128,10 @@ static DWORD WINAPI IDirect3DVertexBuffer8Impl_SetPriority(LPDIRECT3DVERTEXBUFFE
DWORD ret;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
ret = IWineD3DBuffer_SetPriority(This->wineD3DVertexBuffer, PriorityNew);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return ret;
}
......@@ -134,9 +140,10 @@ static DWORD WINAPI IDirect3DVertexBuffer8Impl_GetPriority(LPDIRECT3DVERTEXBUFFE
DWORD ret;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
ret = IWineD3DBuffer_GetPriority(This->wineD3DVertexBuffer);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return ret;
}
......@@ -144,9 +151,9 @@ static void WINAPI IDirect3DVertexBuffer8Impl_PreLoad(LPDIRECT3DVERTEXBUFFER8 if
IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
IWineD3DBuffer_PreLoad(This->wineD3DVertexBuffer);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
}
static D3DRESOURCETYPE WINAPI IDirect3DVertexBuffer8Impl_GetType(LPDIRECT3DVERTEXBUFFER8 iface) {
......@@ -162,9 +169,10 @@ static HRESULT WINAPI IDirect3DVertexBuffer8Impl_Lock(LPDIRECT3DVERTEXBUFFER8 if
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DBuffer_Map(This->wineD3DVertexBuffer, OffsetToLock, SizeToLock, ppbData, Flags);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
......@@ -173,9 +181,10 @@ static HRESULT WINAPI IDirect3DVertexBuffer8Impl_Unlock(LPDIRECT3DVERTEXBUFFER8
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DBuffer_Unmap(This->wineD3DVertexBuffer);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
......@@ -185,9 +194,9 @@ static HRESULT WINAPI IDirect3DVertexBuffer8Impl_GetDesc(LPDIRECT3DVERTEXBUFFER8
WINED3DBUFFER_DESC desc;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DBuffer_GetDesc(This->wineD3DVertexBuffer, &desc);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
if (SUCCEEDED(hr)) {
pDesc->Type = D3DRTYPE_VERTEXBUFFER;
......
......@@ -61,9 +61,10 @@ static ULONG WINAPI IDirect3DVertexDeclaration8Impl_Release(IDirect3DVertexDecla
TRACE("(%p) : Releasing to %d\n", This, ref_count);
if (!ref_count) {
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
IWineD3DVertexDeclaration_Release(This->wined3d_vertex_declaration);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
HeapFree(GetProcessHeap(), 0, This->elements);
HeapFree(GetProcessHeap(), 0, This);
}
......
......@@ -59,9 +59,9 @@ static ULONG WINAPI IDirect3DVertexShader8Impl_Release(IDirect3DVertexShader8 *i
IDirect3DVertexDeclaration8_Release(This->vertex_declaration);
if (This->wineD3DVertexShader)
{
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
IWineD3DVertexShader_Release(This->wineD3DVertexShader);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
}
HeapFree(GetProcessHeap(), 0, This);
}
......
......@@ -72,9 +72,10 @@ static ULONG WINAPI IDirect3DVolume8Impl_Release(LPDIRECT3DVOLUME8 iface) {
TRACE("(%p) : ReleaseRef to %d\n", This, ref);
if (ref == 0) {
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
IWineD3DVolume_Release(This->wineD3DVolume);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
HeapFree(GetProcessHeap(), 0, This);
}
......@@ -87,11 +88,12 @@ static HRESULT WINAPI IDirect3DVolume8Impl_GetDevice(LPDIRECT3DVOLUME8 iface, ID
IDirect3DVolume8Impl *This = (IDirect3DVolume8Impl *)iface;
IWineD3DDevice *myDevice = NULL;
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
IWineD3DVolume_GetDevice(This->wineD3DVolume, &myDevice);
IWineD3DDevice_GetParent(myDevice, (IUnknown **)ppDevice);
IWineD3DDevice_Release(myDevice);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return D3D_OK;
}
......@@ -100,9 +102,10 @@ static HRESULT WINAPI IDirect3DVolume8Impl_SetPrivateData(LPDIRECT3DVOLUME8 ifac
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DVolume_SetPrivateData(This->wineD3DVolume, refguid, pData, SizeOfData, Flags);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
......@@ -111,9 +114,10 @@ static HRESULT WINAPI IDirect3DVolume8Impl_GetPrivateData(LPDIRECT3DVOLUME8 ifac
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DVolume_GetPrivateData(This->wineD3DVolume, refguid, pData, pSizeOfData);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
......@@ -122,9 +126,10 @@ static HRESULT WINAPI IDirect3DVolume8Impl_FreePrivateData(LPDIRECT3DVOLUME8 ifa
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DVolume_FreePrivateData(This->wineD3DVolume, refguid);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
......@@ -154,9 +159,9 @@ static HRESULT WINAPI IDirect3DVolume8Impl_GetDesc(LPDIRECT3DVOLUME8 iface, D3DV
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DVolume_GetDesc(This->wineD3DVolume, &wined3ddesc);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
if (SUCCEEDED(hr))
{
......@@ -178,9 +183,10 @@ static HRESULT WINAPI IDirect3DVolume8Impl_LockBox(LPDIRECT3DVOLUME8 iface, D3DL
HRESULT hr;
TRACE("(%p) relay %p %p %p %d\n", This, This->wineD3DVolume, pLockedVolume, pBox, Flags);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DVolume_LockBox(This->wineD3DVolume, (WINED3DLOCKED_BOX *) pLockedVolume, (CONST WINED3DBOX *) pBox, Flags);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
......@@ -189,9 +195,10 @@ static HRESULT WINAPI IDirect3DVolume8Impl_UnlockBox(LPDIRECT3DVOLUME8 iface) {
HRESULT hr;
TRACE("(%p) relay %p\n", This, This->wineD3DVolume);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DVolume_UnlockBox(This->wineD3DVolume);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
......
......@@ -57,9 +57,10 @@ static ULONG WINAPI IDirect3DVolumeTexture8Impl_Release(LPDIRECT3DVOLUMETEXTURE8
TRACE("(%p) : ReleaseRef to %d\n", This, ref);
if (ref == 0) {
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
IWineD3DVolumeTexture_Destroy(This->wineD3DVolumeTexture, D3D8CB_DestroyVolume);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
IUnknown_Release(This->parentDevice);
HeapFree(GetProcessHeap(), 0, This);
}
......@@ -73,14 +74,15 @@ static HRESULT WINAPI IDirect3DVolumeTexture8Impl_GetDevice(LPDIRECT3DVOLUMETEXT
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DVolumeTexture_GetDevice(This->wineD3DVolumeTexture, &wined3d_device);
if (SUCCEEDED(hr))
{
IWineD3DDevice_GetParent(wined3d_device, (IUnknown **)ppDevice);
IWineD3DDevice_Release(wined3d_device);
}
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
......@@ -89,9 +91,10 @@ static HRESULT WINAPI IDirect3DVolumeTexture8Impl_SetPrivateData(LPDIRECT3DVOLUM
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DVolumeTexture_SetPrivateData(This->wineD3DVolumeTexture, refguid, pData, SizeOfData, Flags);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
......@@ -100,9 +103,10 @@ static HRESULT WINAPI IDirect3DVolumeTexture8Impl_GetPrivateData(LPDIRECT3DVOLUM
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DVolumeTexture_GetPrivateData(This->wineD3DVolumeTexture, refguid, pData, pSizeOfData);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
......@@ -111,9 +115,10 @@ static HRESULT WINAPI IDirect3DVolumeTexture8Impl_FreePrivateData(LPDIRECT3DVOLU
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DVolumeTexture_FreePrivateData(This->wineD3DVolumeTexture, refguid);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
......@@ -122,9 +127,10 @@ static DWORD WINAPI IDirect3DVolumeTexture8Impl_SetPriority(LPDIRECT3DVOLUMETEXT
DWORD ret;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
ret = IWineD3DVolumeTexture_SetPriority(This->wineD3DVolumeTexture, PriorityNew);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return ret;
}
......@@ -133,9 +139,10 @@ static DWORD WINAPI IDirect3DVolumeTexture8Impl_GetPriority(LPDIRECT3DVOLUMETEXT
DWORD ret;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
ret = IWineD3DVolumeTexture_GetPriority(This->wineD3DVolumeTexture);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return ret;
}
......@@ -143,9 +150,9 @@ static void WINAPI IDirect3DVolumeTexture8Impl_PreLoad(LPDIRECT3DVOLUMETEXTURE8
IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
IWineD3DVolumeTexture_PreLoad(This->wineD3DVolumeTexture);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
}
static D3DRESOURCETYPE WINAPI IDirect3DVolumeTexture8Impl_GetType(LPDIRECT3DVOLUMETEXTURE8 iface) {
......@@ -153,9 +160,10 @@ static D3DRESOURCETYPE WINAPI IDirect3DVolumeTexture8Impl_GetType(LPDIRECT3DVOLU
D3DRESOURCETYPE type;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
type = IWineD3DVolumeTexture_GetType(This->wineD3DVolumeTexture);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return type;
}
......@@ -165,9 +173,10 @@ static DWORD WINAPI IDirect3DVolumeTexture8Impl_SetLOD(LPDIRECT3DVOLUMETEXTURE8
DWORD ret;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
ret = IWineD3DVolumeTexture_SetLOD(This->wineD3DVolumeTexture, LODNew);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return ret;
}
......@@ -176,9 +185,10 @@ static DWORD WINAPI IDirect3DVolumeTexture8Impl_GetLOD(LPDIRECT3DVOLUMETEXTURE8
DWORD ret;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
ret = IWineD3DVolumeTexture_GetLOD(This->wineD3DVolumeTexture);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return ret;
}
......@@ -187,9 +197,10 @@ static DWORD WINAPI IDirect3DVolumeTexture8Impl_GetLevelCount(LPDIRECT3DVOLUMETE
DWORD ret;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
ret = IWineD3DVolumeTexture_GetLevelCount(This->wineD3DVolumeTexture);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return ret;
}
......@@ -201,9 +212,9 @@ static HRESULT WINAPI IDirect3DVolumeTexture8Impl_GetLevelDesc(LPDIRECT3DVOLUMET
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DVolumeTexture_GetLevelDesc(This->wineD3DVolumeTexture, Level, &wined3ddesc);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
if (SUCCEEDED(hr))
{
......@@ -227,13 +238,14 @@ static HRESULT WINAPI IDirect3DVolumeTexture8Impl_GetVolumeLevel(LPDIRECT3DVOLUM
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hrc = IWineD3DVolumeTexture_GetVolumeLevel(This->wineD3DVolumeTexture, Level, &myVolume);
if (hrc == D3D_OK && NULL != ppVolumeLevel) {
IWineD3DVolumeTexture_GetParent(myVolume, (IUnknown **)ppVolumeLevel);
IWineD3DVolumeTexture_Release(myVolume);
}
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hrc;
}
......@@ -242,9 +254,10 @@ static HRESULT WINAPI IDirect3DVolumeTexture8Impl_LockBox(LPDIRECT3DVOLUMETEXTUR
HRESULT hr;
TRACE("(%p) Relay %p %p %p %d\n", This, This->wineD3DVolumeTexture, pLockedVolume, pBox,Flags);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DVolumeTexture_LockBox(This->wineD3DVolumeTexture, Level, (WINED3DLOCKED_BOX *) pLockedVolume, (CONST WINED3DBOX *) pBox, Flags);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
......@@ -253,9 +266,10 @@ static HRESULT WINAPI IDirect3DVolumeTexture8Impl_UnlockBox(LPDIRECT3DVOLUMETEXT
HRESULT hr;
TRACE("(%p) Relay %p %d\n", This, This->wineD3DVolumeTexture, Level);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DVolumeTexture_UnlockBox(This->wineD3DVolumeTexture, Level);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
......@@ -264,9 +278,10 @@ static HRESULT WINAPI IDirect3DVolumeTexture8Impl_AddDirtyBox(LPDIRECT3DVOLUMETE
HRESULT hr;
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
wined3d_mutex_lock();
hr = IWineD3DVolumeTexture_AddDirtyBox(This->wineD3DVolumeTexture, (CONST WINED3DBOX *) pDirtyBox);
LeaveCriticalSection(&d3d8_cs);
wined3d_mutex_unlock();
return hr;
}
......
@ stdcall WineDirect3DCreate(long ptr)
@ stdcall WineDirect3DCreateClipper(ptr)
@ stdcall wined3d_mutex_lock()
@ stdcall wined3d_mutex_unlock()
......@@ -32,6 +32,15 @@ int num_lock = 0;
void (*CDECL wine_tsx11_lock_ptr)(void) = NULL;
void (*CDECL wine_tsx11_unlock_ptr)(void) = NULL;
CRITICAL_SECTION wined3d_cs;
static CRITICAL_SECTION_DEBUG wined3d_cs_debug =
{
0, 0, &wined3d_cs,
{&wined3d_cs_debug.ProcessLocksList,
&wined3d_cs_debug.ProcessLocksList},
0, 0, {(DWORD_PTR)(__FILE__ ": wined3d_cs")}
};
CRITICAL_SECTION wined3d_cs = {&wined3d_cs_debug, -1, 0, 0, 0, 0};
/* When updating default value here, make sure to update winecfg as well,
* where appropriate. */
......@@ -325,6 +334,16 @@ static BOOL wined3d_destroy(HINSTANCE hInstDLL)
return TRUE;
}
void WINAPI wined3d_mutex_lock(void)
{
EnterCriticalSection(&wined3d_cs);
}
void WINAPI wined3d_mutex_unlock(void)
{
LeaveCriticalSection(&wined3d_cs);
}
/* At process attach */
BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
{
......
......@@ -3468,3 +3468,5 @@ interface IWineD3DDevice : IWineD3DBase
IWineD3D *WineDirect3DCreate(UINT dxVersion, IUnknown *parent);
IWineD3DClipper *WineDirect3DCreateClipper(IUnknown *parent);
void wined3d_mutex_lock(void);
void wined3d_mutex_unlock(void);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment