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

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

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