d3d8: Hold the DLL lock in IDirect3D8 methods.

oldstable
Stefan Dösinger 2007-05-23 00:33:42 +02:00 committed by Alexandre Julliard
parent 193ccecaee
commit 4f14c4700e
1 changed files with 81 additions and 12 deletions

View File

@ -81,19 +81,34 @@ static ULONG WINAPI IDirect3D8Impl_Release(LPDIRECT3D8 iface) {
/* IDirect3D8 Interface follow: */ /* IDirect3D8 Interface follow: */
static HRESULT WINAPI IDirect3D8Impl_RegisterSoftwareDevice (LPDIRECT3D8 iface, void* pInitializeFunction) { static HRESULT WINAPI IDirect3D8Impl_RegisterSoftwareDevice (LPDIRECT3D8 iface, void* pInitializeFunction) {
IDirect3D8Impl *This = (IDirect3D8Impl *)iface; IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
return IWineD3D_RegisterSoftwareDevice(This->WineD3D, pInitializeFunction); HRESULT hr;
TRACE("(%p)->(%p)\n", This, pInitializeFunction);
EnterCriticalSection(&d3d8_cs);
hr = IWineD3D_RegisterSoftwareDevice(This->WineD3D, pInitializeFunction);
LeaveCriticalSection(&d3d8_cs);
return hr;
} }
static UINT WINAPI IDirect3D8Impl_GetAdapterCount (LPDIRECT3D8 iface) { static UINT WINAPI IDirect3D8Impl_GetAdapterCount (LPDIRECT3D8 iface) {
IDirect3D8Impl *This = (IDirect3D8Impl *)iface; IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
return IWineD3D_GetAdapterCount(This->WineD3D); HRESULT hr;
TRACE("(%p)\n", This);
EnterCriticalSection(&d3d8_cs);
hr = IWineD3D_GetAdapterCount(This->WineD3D);
LeaveCriticalSection(&d3d8_cs);
return hr;
} }
static HRESULT WINAPI IDirect3D8Impl_GetAdapterIdentifier (LPDIRECT3D8 iface, static HRESULT WINAPI IDirect3D8Impl_GetAdapterIdentifier (LPDIRECT3D8 iface,
UINT Adapter, DWORD Flags, D3DADAPTER_IDENTIFIER8* pIdentifier) { UINT Adapter, DWORD Flags, D3DADAPTER_IDENTIFIER8* pIdentifier) {
IDirect3D8Impl *This = (IDirect3D8Impl *)iface; IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
WINED3DADAPTER_IDENTIFIER adapter_id; WINED3DADAPTER_IDENTIFIER adapter_id;
HRESULT hr;
TRACE("(%p)->(%d,%08x, %p\n", This, Adapter, Flags, pIdentifier);
EnterCriticalSection(&d3d8_cs);
/* dx8 and dx9 have different structures to be filled in, with incompatible /* dx8 and dx9 have different structures to be filled in, with incompatible
layouts so pass in pointers to the places to be filled via an internal layouts so pass in pointers to the places to be filled via an internal
structure */ structure */
@ -108,55 +123,98 @@ static HRESULT WINAPI IDirect3D8Impl_GetAdapterIdentifier (LPDIRECT3D8 i
adapter_id.DeviceIdentifier = &pIdentifier->DeviceIdentifier; adapter_id.DeviceIdentifier = &pIdentifier->DeviceIdentifier;
adapter_id.WHQLLevel = &pIdentifier->WHQLLevel; adapter_id.WHQLLevel = &pIdentifier->WHQLLevel;
return IWineD3D_GetAdapterIdentifier(This->WineD3D, Adapter, Flags, &adapter_id); hr = IWineD3D_GetAdapterIdentifier(This->WineD3D, Adapter, Flags, &adapter_id);
LeaveCriticalSection(&d3d8_cs);
return hr;
} }
static UINT WINAPI IDirect3D8Impl_GetAdapterModeCount (LPDIRECT3D8 iface,UINT Adapter) { static UINT WINAPI IDirect3D8Impl_GetAdapterModeCount (LPDIRECT3D8 iface,UINT Adapter) {
IDirect3D8Impl *This = (IDirect3D8Impl *)iface; IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
return IWineD3D_GetAdapterModeCount(This->WineD3D, Adapter, 0 /* format */); HRESULT hr;
TRACE("(%p)->(%d)\n", This, Adapter);
EnterCriticalSection(&d3d8_cs);
hr = IWineD3D_GetAdapterModeCount(This->WineD3D, Adapter, 0 /* format */);
LeaveCriticalSection(&d3d8_cs);
return hr;
} }
static HRESULT WINAPI IDirect3D8Impl_EnumAdapterModes (LPDIRECT3D8 iface, UINT Adapter, UINT Mode, D3DDISPLAYMODE* pMode) { static HRESULT WINAPI IDirect3D8Impl_EnumAdapterModes (LPDIRECT3D8 iface, UINT Adapter, UINT Mode, D3DDISPLAYMODE* pMode) {
IDirect3D8Impl *This = (IDirect3D8Impl *)iface; IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
/* FIXME: USe a constant WINED3DFOTMAT_ANY, or something similar */ HRESULT hr;
return IWineD3D_EnumAdapterModes(This->WineD3D, Adapter, 0 /* format */, Mode, (WINED3DDISPLAYMODE *) pMode); TRACE("(%p)->(%d, %d, %p)\n", This, Adapter, Mode, pMode);
EnterCriticalSection(&d3d8_cs);
hr = IWineD3D_EnumAdapterModes(This->WineD3D, Adapter, WINED3DFMT_UNKNOWN, Mode, (WINED3DDISPLAYMODE *) pMode);
LeaveCriticalSection(&d3d8_cs);
return hr;
} }
static HRESULT WINAPI IDirect3D8Impl_GetAdapterDisplayMode (LPDIRECT3D8 iface, UINT Adapter, D3DDISPLAYMODE* pMode) { static HRESULT WINAPI IDirect3D8Impl_GetAdapterDisplayMode (LPDIRECT3D8 iface, UINT Adapter, D3DDISPLAYMODE* pMode) {
IDirect3D8Impl *This = (IDirect3D8Impl *)iface; IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
return IWineD3D_GetAdapterDisplayMode(This->WineD3D, Adapter, (WINED3DDISPLAYMODE *) pMode); HRESULT hr;
TRACE("(%p)->(%d,%p)\n", This, Adapter, pMode);
EnterCriticalSection(&d3d8_cs);
hr = IWineD3D_GetAdapterDisplayMode(This->WineD3D, Adapter, (WINED3DDISPLAYMODE *) pMode);
LeaveCriticalSection(&d3d8_cs);
return hr;
} }
static HRESULT WINAPI IDirect3D8Impl_CheckDeviceType (LPDIRECT3D8 iface, static HRESULT WINAPI IDirect3D8Impl_CheckDeviceType (LPDIRECT3D8 iface,
UINT Adapter, D3DDEVTYPE CheckType, D3DFORMAT DisplayFormat, UINT Adapter, D3DDEVTYPE CheckType, D3DFORMAT DisplayFormat,
D3DFORMAT BackBufferFormat, BOOL Windowed) { D3DFORMAT BackBufferFormat, BOOL Windowed) {
IDirect3D8Impl *This = (IDirect3D8Impl *)iface; IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
return IWineD3D_CheckDeviceType(This->WineD3D, Adapter, CheckType, DisplayFormat, HRESULT hr;
TRACE("(%p)->(%d, %d, %d, %d, %s)\n", This, Adapter, CheckType, DisplayFormat, BackBufferFormat, Windowed ? "true" : "false");
EnterCriticalSection(&d3d8_cs);
hr = IWineD3D_CheckDeviceType(This->WineD3D, Adapter, CheckType, DisplayFormat,
BackBufferFormat, Windowed); BackBufferFormat, Windowed);
LeaveCriticalSection(&d3d8_cs);
return hr;
} }
static HRESULT WINAPI IDirect3D8Impl_CheckDeviceFormat (LPDIRECT3D8 iface, static HRESULT WINAPI IDirect3D8Impl_CheckDeviceFormat (LPDIRECT3D8 iface,
UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat,
DWORD Usage, D3DRESOURCETYPE RType, D3DFORMAT CheckFormat) { DWORD Usage, D3DRESOURCETYPE RType, D3DFORMAT CheckFormat) {
IDirect3D8Impl *This = (IDirect3D8Impl *)iface; IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
return IWineD3D_CheckDeviceFormat(This->WineD3D, Adapter, DeviceType, AdapterFormat, HRESULT hr;
TRACE("(%p)->(%d, %d, %d, %08x, %d, %d)\n", This, Adapter, DeviceType, AdapterFormat, Usage, RType, CheckFormat);
EnterCriticalSection(&d3d8_cs);
hr = IWineD3D_CheckDeviceFormat(This->WineD3D, Adapter, DeviceType, AdapterFormat,
Usage, RType, CheckFormat); Usage, RType, CheckFormat);
LeaveCriticalSection(&d3d8_cs);
return hr;
} }
static HRESULT WINAPI IDirect3D8Impl_CheckDeviceMultiSampleType(LPDIRECT3D8 iface, static HRESULT WINAPI IDirect3D8Impl_CheckDeviceMultiSampleType(LPDIRECT3D8 iface,
UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SurfaceFormat, UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SurfaceFormat,
BOOL Windowed, D3DMULTISAMPLE_TYPE MultiSampleType) { BOOL Windowed, D3DMULTISAMPLE_TYPE MultiSampleType) {
IDirect3D8Impl *This = (IDirect3D8Impl *)iface; IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
return IWineD3D_CheckDeviceMultiSampleType(This->WineD3D, Adapter, DeviceType, SurfaceFormat, HRESULT hr;
TRACE("(%p)-<(%d, %d, %d, %s, %d)\n", This, Adapter, DeviceType, SurfaceFormat, Windowed ? "true" : "false", MultiSampleType);
EnterCriticalSection(&d3d8_cs);
hr = IWineD3D_CheckDeviceMultiSampleType(This->WineD3D, Adapter, DeviceType, SurfaceFormat,
Windowed, (WINED3DMULTISAMPLE_TYPE) MultiSampleType, NULL); Windowed, (WINED3DMULTISAMPLE_TYPE) MultiSampleType, NULL);
LeaveCriticalSection(&d3d8_cs);
return hr;
} }
static HRESULT WINAPI IDirect3D8Impl_CheckDepthStencilMatch(LPDIRECT3D8 iface, static HRESULT WINAPI IDirect3D8Impl_CheckDepthStencilMatch(LPDIRECT3D8 iface,
UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat,
D3DFORMAT RenderTargetFormat, D3DFORMAT DepthStencilFormat) { D3DFORMAT RenderTargetFormat, D3DFORMAT DepthStencilFormat) {
IDirect3D8Impl *This = (IDirect3D8Impl *)iface; IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
return IWineD3D_CheckDepthStencilMatch(This->WineD3D, Adapter, DeviceType, AdapterFormat, HRESULT hr;
TRACE("(%p)-<(%d, %d, %d, %d, %d)\n", This, Adapter, DeviceType, AdapterFormat, RenderTargetFormat, DepthStencilFormat);
EnterCriticalSection(&d3d8_cs);
hr = IWineD3D_CheckDepthStencilMatch(This->WineD3D, Adapter, DeviceType, AdapterFormat,
RenderTargetFormat, DepthStencilFormat); RenderTargetFormat, DepthStencilFormat);
LeaveCriticalSection(&d3d8_cs);
return hr;
} }
static HRESULT WINAPI IDirect3D8Impl_GetDeviceCaps(LPDIRECT3D8 iface, UINT Adapter, D3DDEVTYPE DeviceType, D3DCAPS8* pCaps) { static HRESULT WINAPI IDirect3D8Impl_GetDeviceCaps(LPDIRECT3D8 iface, UINT Adapter, D3DDEVTYPE DeviceType, D3DCAPS8* pCaps) {
@ -174,7 +232,9 @@ static HRESULT WINAPI IDirect3D8Impl_GetDeviceCaps(LPDIRECT3D8 iface, UINT Ada
return D3DERR_INVALIDCALL; /*well this is what MSDN says to return*/ return D3DERR_INVALIDCALL; /*well this is what MSDN says to return*/
} }
D3D8CAPSTOWINECAPS(pCaps, pWineCaps) D3D8CAPSTOWINECAPS(pCaps, pWineCaps)
EnterCriticalSection(&d3d8_cs);
hrc = IWineD3D_GetDeviceCaps(This->WineD3D, Adapter, DeviceType, pWineCaps); hrc = IWineD3D_GetDeviceCaps(This->WineD3D, Adapter, DeviceType, pWineCaps);
LeaveCriticalSection(&d3d8_cs);
HeapFree(GetProcessHeap(), 0, pWineCaps); HeapFree(GetProcessHeap(), 0, pWineCaps);
/* D3D8 doesn't support SM 2.0 or higher, so clamp to 1.x */ /* D3D8 doesn't support SM 2.0 or higher, so clamp to 1.x */
@ -191,7 +251,13 @@ static HRESULT WINAPI IDirect3D8Impl_GetDeviceCaps(LPDIRECT3D8 iface, UINT Ada
static HMONITOR WINAPI IDirect3D8Impl_GetAdapterMonitor(LPDIRECT3D8 iface, UINT Adapter) { static HMONITOR WINAPI IDirect3D8Impl_GetAdapterMonitor(LPDIRECT3D8 iface, UINT Adapter) {
IDirect3D8Impl *This = (IDirect3D8Impl *)iface; IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
return IWineD3D_GetAdapterMonitor(This->WineD3D, Adapter); HMONITOR ret;
TRACE("(%p)->(%d)\n", This, Adapter);
EnterCriticalSection(&d3d8_cs);
ret = IWineD3D_GetAdapterMonitor(This->WineD3D, Adapter);
LeaveCriticalSection(&d3d8_cs);
return ret;
} }
/* Internal function called back during the CreateDevice to create a render target */ /* Internal function called back during the CreateDevice to create a render target */
@ -352,11 +418,13 @@ static HRESULT WINAPI IDirect3D8Impl_CreateDevice(LPDIRECT3D8 iface, UINT Adapte
*ppReturnedDeviceInterface = (IDirect3DDevice8 *)object; *ppReturnedDeviceInterface = (IDirect3DDevice8 *)object;
/* Allocate an associated WineD3DDevice object */ /* Allocate an associated WineD3DDevice object */
EnterCriticalSection(&d3d8_cs);
hr =IWineD3D_CreateDevice(This->WineD3D, Adapter, DeviceType, hFocusWindow, BehaviourFlags, &object->WineD3DDevice, (IUnknown *)object); hr =IWineD3D_CreateDevice(This->WineD3D, Adapter, DeviceType, hFocusWindow, BehaviourFlags, &object->WineD3DDevice, (IUnknown *)object);
if (hr != D3D_OK) { if (hr != D3D_OK) {
HeapFree(GetProcessHeap(), 0, object); HeapFree(GetProcessHeap(), 0, object);
*ppReturnedDeviceInterface = NULL; *ppReturnedDeviceInterface = NULL;
LeaveCriticalSection(&d3d8_cs);
return hr; return hr;
} }
@ -382,6 +450,7 @@ static HRESULT WINAPI IDirect3D8Impl_CreateDevice(LPDIRECT3D8 iface, UINT Adapte
} }
hr = IWineD3DDevice_Init3D(object->WineD3DDevice, &localParameters, D3D8CB_CreateAdditionalSwapChain); hr = IWineD3DDevice_Init3D(object->WineD3DDevice, &localParameters, D3D8CB_CreateAdditionalSwapChain);
LeaveCriticalSection(&d3d8_cs);
pPresentationParameters->BackBufferWidth = localParameters.BackBufferWidth; pPresentationParameters->BackBufferWidth = localParameters.BackBufferWidth;
pPresentationParameters->BackBufferHeight = localParameters.BackBufferHeight; pPresentationParameters->BackBufferHeight = localParameters.BackBufferHeight;