Commit 775ea907 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

d3d8: Fix locking.

parent 72b53787
...@@ -820,10 +820,11 @@ static HRESULT IDirect3DDevice8Impl_CreateSurface(LPDIRECT3DDEVICE8 iface, UINT ...@@ -820,10 +820,11 @@ static HRESULT IDirect3DDevice8Impl_CreateSurface(LPDIRECT3DDEVICE8 iface, UINT
TRACE("(%p) : w(%d) h(%d) fmt(%d) surf@%p\n", This, Width, Height, Format, *ppSurface); TRACE("(%p) : w(%d) h(%d) fmt(%d) surf@%p\n", This, Width, Height, Format, *ppSurface);
/* Not called from the VTable, no locking needed */ EnterCriticalSection(&d3d8_cs);
hrc = IWineD3DDevice_CreateSurface(This->WineD3DDevice, Width, Height, wined3dformat_from_d3dformat(Format), hrc = IWineD3DDevice_CreateSurface(This->WineD3DDevice, Width, Height, wined3dformat_from_d3dformat(Format),
Lockable, Discard, Level, &object->wineD3DSurface, Type, Usage & WINED3DUSAGE_MASK, Lockable, Discard, Level, &object->wineD3DSurface, Type, Usage & WINED3DUSAGE_MASK,
(WINED3DPOOL)Pool, MultiSample,MultisampleQuality, NULL, SURFACE_OPENGL, (IUnknown *)object); (WINED3DPOOL)Pool, MultiSample,MultisampleQuality, NULL, SURFACE_OPENGL, (IUnknown *)object);
LeaveCriticalSection(&d3d8_cs);
if (hrc != D3D_OK || NULL == object->wineD3DSurface) { if (hrc != D3D_OK || NULL == object->wineD3DSurface) {
/* free up object */ /* free up object */
FIXME("(%p) call to IWineD3DDevice_CreateSurface failed\n", This); FIXME("(%p) call to IWineD3DDevice_CreateSurface failed\n", This);
...@@ -841,9 +842,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_CreateRenderTarget(LPDIRECT3DDEVICE8 ...@@ -841,9 +842,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_CreateRenderTarget(LPDIRECT3DDEVICE8
HRESULT hr; HRESULT hr;
TRACE("Relay\n"); TRACE("Relay\n");
EnterCriticalSection(&d3d8_cs);
hr = IDirect3DDevice8Impl_CreateSurface(iface, Width, Height, Format, Lockable, FALSE /* Discard */, 0 /* Level */ , ppSurface, D3DRTYPE_SURFACE, D3DUSAGE_RENDERTARGET, D3DPOOL_DEFAULT, MultiSample, 0); hr = IDirect3DDevice8Impl_CreateSurface(iface, Width, Height, Format, Lockable, FALSE /* Discard */, 0 /* Level */ , ppSurface, D3DRTYPE_SURFACE, D3DUSAGE_RENDERTARGET, D3DPOOL_DEFAULT, MultiSample, 0);
LeaveCriticalSection(&d3d8_cs);
return hr; return hr;
} }
...@@ -852,11 +851,9 @@ static HRESULT WINAPI IDirect3DDevice8Impl_CreateDepthStencilSurface(LPDIRECT3DD ...@@ -852,11 +851,9 @@ static HRESULT WINAPI IDirect3DDevice8Impl_CreateDepthStencilSurface(LPDIRECT3DD
TRACE("Relay\n"); TRACE("Relay\n");
/* TODO: Verify that Discard is false */ /* TODO: Verify that Discard is false */
EnterCriticalSection(&d3d8_cs);
hr = IDirect3DDevice8Impl_CreateSurface(iface, Width, Height, Format, TRUE /* Lockable */, FALSE, 0 /* Level */ hr = IDirect3DDevice8Impl_CreateSurface(iface, Width, Height, Format, TRUE /* Lockable */, FALSE, 0 /* Level */
,ppSurface, D3DRTYPE_SURFACE, D3DUSAGE_DEPTHSTENCIL, ,ppSurface, D3DRTYPE_SURFACE, D3DUSAGE_DEPTHSTENCIL,
D3DPOOL_DEFAULT, MultiSample, 0); D3DPOOL_DEFAULT, MultiSample, 0);
LeaveCriticalSection(&d3d8_cs);
return hr; return hr;
} }
...@@ -865,10 +862,8 @@ static HRESULT WINAPI IDirect3DDevice8Impl_CreateImageSurface(LPDIRECT3DDEVICE8 ...@@ -865,10 +862,8 @@ static HRESULT WINAPI IDirect3DDevice8Impl_CreateImageSurface(LPDIRECT3DDEVICE8
HRESULT hr; HRESULT hr;
TRACE("Relay\n"); TRACE("Relay\n");
EnterCriticalSection(&d3d8_cs);
hr = IDirect3DDevice8Impl_CreateSurface(iface, Width, Height, Format, TRUE /* Loackable */ , FALSE /*Discard*/ , 0 /* Level */ , ppSurface, hr = IDirect3DDevice8Impl_CreateSurface(iface, Width, Height, Format, TRUE /* Loackable */ , FALSE /*Discard*/ , 0 /* Level */ , ppSurface,
D3DRTYPE_SURFACE, 0 /* Usage (undefined/none) */ , D3DPOOL_SYSTEMMEM, D3DMULTISAMPLE_NONE, 0 /* MultisampleQuality */); D3DRTYPE_SURFACE, 0 /* Usage (undefined/none) */ , D3DPOOL_SYSTEMMEM, D3DMULTISAMPLE_NONE, 0 /* MultisampleQuality */);
LeaveCriticalSection(&d3d8_cs);
return hr; return hr;
} }
...@@ -894,13 +889,13 @@ static HRESULT WINAPI IDirect3DDevice8Impl_CopyRects(LPDIRECT3DDEVICE8 iface, ID ...@@ -894,13 +889,13 @@ static HRESULT WINAPI IDirect3DDevice8Impl_CopyRects(LPDIRECT3DDEVICE8 iface, ID
winedesc.Width = &srcWidth; winedesc.Width = &srcWidth;
winedesc.Height = &srcHeight; winedesc.Height = &srcHeight;
winedesc.Size = &srcSize; winedesc.Size = &srcSize;
EnterCriticalSection(&d3d8_cs);
IWineD3DSurface_GetDesc(Source->wineD3DSurface, &winedesc); IWineD3DSurface_GetDesc(Source->wineD3DSurface, &winedesc);
winedesc.Format = &destFormat; winedesc.Format = &destFormat;
winedesc.Width = &destWidth; winedesc.Width = &destWidth;
winedesc.Height = &destHeight; winedesc.Height = &destHeight;
winedesc.Size = NULL; winedesc.Size = NULL;
EnterCriticalSection(&d3d8_cs);
IWineD3DSurface_GetDesc(Dest->wineD3DSurface, &winedesc); IWineD3DSurface_GetDesc(Dest->wineD3DSurface, &winedesc);
/* Check that the source and destination formats match */ /* Check that the source and destination formats match */
...@@ -1759,16 +1754,15 @@ static HRESULT WINAPI IDirect3DDevice8Impl_CreateVertexShader(LPDIRECT3DDEVICE8 ...@@ -1759,16 +1754,15 @@ static HRESULT WINAPI IDirect3DDevice8Impl_CreateVertexShader(LPDIRECT3DDEVICE8
object->ref = 1; object->ref = 1;
object->lpVtbl = &Direct3DVertexShader8_Vtbl; object->lpVtbl = &Direct3DVertexShader8_Vtbl;
EnterCriticalSection(&d3d8_cs);
hrc = IDirect3DDevice8Impl_CreateVertexDeclaration(iface, pDeclaration, &object->vertex_declaration); hrc = IDirect3DDevice8Impl_CreateVertexDeclaration(iface, pDeclaration, &object->vertex_declaration);
if (FAILED(hrc)) { if (FAILED(hrc)) {
ERR("(%p) : IDirect3DDeviceImpl_CreateVertexDeclaration call failed\n", This); ERR("(%p) : IDirect3DDeviceImpl_CreateVertexDeclaration call failed\n", This);
LeaveCriticalSection(&d3d8_cs);
HeapFree(GetProcessHeap(), 0, object); HeapFree(GetProcessHeap(), 0, object);
*ppShader = 0; *ppShader = 0;
return D3DERR_INVALIDCALL; return D3DERR_INVALIDCALL;
} }
EnterCriticalSection(&d3d8_cs);
handle = d3d8_allocate_handle(&This->handle_table, object); handle = d3d8_allocate_handle(&This->handle_table, object);
if (handle == D3D8_INVALID_HANDLE) if (handle == D3D8_INVALID_HANDLE)
{ {
...@@ -2023,10 +2017,10 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetVertexShaderDeclaration(LPDIRECT3D ...@@ -2023,10 +2017,10 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetVertexShaderDeclaration(LPDIRECT3D
EnterCriticalSection(&d3d8_cs); EnterCriticalSection(&d3d8_cs);
shader = d3d8_get_object(&This->handle_table, pVertexShader - (VS_HIGHESTFIXEDFXF + 1)); shader = d3d8_get_object(&This->handle_table, pVertexShader - (VS_HIGHESTFIXEDFXF + 1));
LeaveCriticalSection(&d3d8_cs);
if (!shader) if (!shader)
{ {
WARN("Invalid handle (%#x) passed.\n", pVertexShader); WARN("Invalid handle (%#x) passed.\n", pVertexShader);
LeaveCriticalSection(&d3d8_cs);
return D3DERR_INVALIDCALL; return D3DERR_INVALIDCALL;
} }
declaration = (IDirect3DVertexDeclaration8Impl *)shader->vertex_declaration; declaration = (IDirect3DVertexDeclaration8Impl *)shader->vertex_declaration;
...@@ -2034,7 +2028,6 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetVertexShaderDeclaration(LPDIRECT3D ...@@ -2034,7 +2028,6 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetVertexShaderDeclaration(LPDIRECT3D
/* If pData is NULL, we just return the required size of the buffer. */ /* If pData is NULL, we just return the required size of the buffer. */
if (!pData) { if (!pData) {
*pSizeOfData = declaration->elements_size; *pSizeOfData = declaration->elements_size;
LeaveCriticalSection(&d3d8_cs);
return D3D_OK; return D3D_OK;
} }
...@@ -2042,12 +2035,10 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetVertexShaderDeclaration(LPDIRECT3D ...@@ -2042,12 +2035,10 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetVertexShaderDeclaration(LPDIRECT3D
* we should write the required size and return D3DERR_MOREDATA. * we should write the required size and return D3DERR_MOREDATA.
* That's not actually true. */ * That's not actually true. */
if (*pSizeOfData < declaration->elements_size) { if (*pSizeOfData < declaration->elements_size) {
LeaveCriticalSection(&d3d8_cs);
return D3DERR_INVALIDCALL; return D3DERR_INVALIDCALL;
} }
CopyMemory(pData, declaration->elements, declaration->elements_size); CopyMemory(pData, declaration->elements, declaration->elements_size);
LeaveCriticalSection(&d3d8_cs);
return D3D_OK; return D3D_OK;
} }
......
...@@ -71,7 +71,9 @@ static ULONG WINAPI IDirect3D8Impl_Release(LPDIRECT3D8 iface) { ...@@ -71,7 +71,9 @@ static ULONG WINAPI IDirect3D8Impl_Release(LPDIRECT3D8 iface) {
if (ref == 0) { if (ref == 0) {
TRACE("Releasing wined3d %p\n", This->WineD3D); TRACE("Releasing wined3d %p\n", This->WineD3D);
EnterCriticalSection(&d3d8_cs);
IWineD3D_Release(This->WineD3D); IWineD3D_Release(This->WineD3D);
LeaveCriticalSection(&d3d8_cs);
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);
} }
...@@ -389,7 +391,9 @@ static HRESULT WINAPI IDirect3D8Impl_CreateDevice(LPDIRECT3D8 iface, UINT Adapte ...@@ -389,7 +391,9 @@ static HRESULT WINAPI IDirect3D8Impl_CreateDevice(LPDIRECT3D8 iface, UINT Adapte
object->decls = HeapAlloc(GetProcessHeap(), 0, object->declArraySize * sizeof(*object->decls)); object->decls = HeapAlloc(GetProcessHeap(), 0, object->declArraySize * sizeof(*object->decls));
if(!object->decls) { if(!object->decls) {
ERR("Out of memory\n"); ERR("Out of memory\n");
EnterCriticalSection(&d3d8_cs);
IWineD3DDevice_Release(object->WineD3DDevice); IWineD3DDevice_Release(object->WineD3DDevice);
LeaveCriticalSection(&d3d8_cs);
HeapFree(GetProcessHeap(), 0, object); HeapFree(GetProcessHeap(), 0, object);
*ppReturnedDeviceInterface = NULL; *ppReturnedDeviceInterface = NULL;
hr = E_OUTOFMEMORY; hr = E_OUTOFMEMORY;
......
...@@ -56,7 +56,9 @@ static ULONG WINAPI IDirect3DPixelShader8Impl_Release(IDirect3DPixelShader8 * if ...@@ -56,7 +56,9 @@ static ULONG WINAPI IDirect3DPixelShader8Impl_Release(IDirect3DPixelShader8 * if
TRACE("(%p) : ReleaseRef to %d\n", This, ref); TRACE("(%p) : ReleaseRef to %d\n", This, ref);
if (ref == 0) { if (ref == 0) {
EnterCriticalSection(&d3d8_cs);
IWineD3DPixelShader_Release(This->wineD3DPixelShader); IWineD3DPixelShader_Release(This->wineD3DPixelShader);
LeaveCriticalSection(&d3d8_cs);
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);
} }
return ref; return ref;
......
...@@ -58,7 +58,9 @@ static ULONG WINAPI IDirect3DStateBlock8Impl_Release(IDirect3DStateBlock8 *iface ...@@ -58,7 +58,9 @@ static ULONG WINAPI IDirect3DStateBlock8Impl_Release(IDirect3DStateBlock8 *iface
TRACE("(%p) : ReleaseRef to %d\n", This, ref); TRACE("(%p) : ReleaseRef to %d\n", This, ref);
if (ref == 0) { if (ref == 0) {
EnterCriticalSection(&d3d8_cs);
IWineD3DStateBlock_Release(This->wineD3DStateBlock); IWineD3DStateBlock_Release(This->wineD3DStateBlock);
LeaveCriticalSection(&d3d8_cs);
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);
} }
return ref; return ref;
...@@ -88,14 +90,32 @@ static HRESULT WINAPI IDirect3DStateBlock8Impl_GetDevice(IDirect3DStateBlock8 *i ...@@ -88,14 +90,32 @@ static HRESULT WINAPI IDirect3DStateBlock8Impl_GetDevice(IDirect3DStateBlock8 *i
static HRESULT WINAPI IDirect3DStateBlock8Impl_Capture(IDirect3DStateBlock8 *iface) { static HRESULT WINAPI IDirect3DStateBlock8Impl_Capture(IDirect3DStateBlock8 *iface) {
IDirect3DStateBlock8Impl *This = (IDirect3DStateBlock8Impl *)iface; IDirect3DStateBlock8Impl *This = (IDirect3DStateBlock8Impl *)iface;
TRACE("(%p) Relay\n", This); HRESULT hr;
return IWineD3DStateBlock_Capture(This->wineD3DStateBlock);
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
hr = IWineD3DStateBlock_Capture(This->wineD3DStateBlock);
LeaveCriticalSection(&d3d8_cs);
return hr;
} }
static HRESULT WINAPI IDirect3DStateBlock8Impl_Apply(IDirect3DStateBlock8 *iface) { static HRESULT WINAPI IDirect3DStateBlock8Impl_Apply(IDirect3DStateBlock8 *iface) {
IDirect3DStateBlock8Impl *This = (IDirect3DStateBlock8Impl *)iface; IDirect3DStateBlock8Impl *This = (IDirect3DStateBlock8Impl *)iface;
TRACE("(%p) Relay\n", This); HRESULT hr;
return IWineD3DStateBlock_Apply(This->wineD3DStateBlock);
TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs);
hr = IWineD3DStateBlock_Apply(This->wineD3DStateBlock);
LeaveCriticalSection(&d3d8_cs);
return hr;
} }
const IDirect3DStateBlock8Vtbl Direct3DStateBlock8_Vtbl = const IDirect3DStateBlock8Vtbl Direct3DStateBlock8_Vtbl =
......
...@@ -61,7 +61,9 @@ static ULONG WINAPI IDirect3DVertexDeclaration8Impl_Release(IDirect3DVertexDecla ...@@ -61,7 +61,9 @@ static ULONG WINAPI IDirect3DVertexDeclaration8Impl_Release(IDirect3DVertexDecla
TRACE("(%p) : Releasing to %d\n", This, ref_count); TRACE("(%p) : Releasing to %d\n", This, ref_count);
if (!ref_count) { if (!ref_count) {
EnterCriticalSection(&d3d8_cs);
IWineD3DVertexDeclaration_Release(This->wined3d_vertex_declaration); IWineD3DVertexDeclaration_Release(This->wined3d_vertex_declaration);
LeaveCriticalSection(&d3d8_cs);
HeapFree(GetProcessHeap(), 0, This->elements); HeapFree(GetProcessHeap(), 0, This->elements);
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);
} }
......
...@@ -57,7 +57,12 @@ static ULONG WINAPI IDirect3DVertexShader8Impl_Release(IDirect3DVertexShader8 *i ...@@ -57,7 +57,12 @@ static ULONG WINAPI IDirect3DVertexShader8Impl_Release(IDirect3DVertexShader8 *i
if (ref == 0) { if (ref == 0) {
IDirect3DVertexDeclaration8_Release(This->vertex_declaration); IDirect3DVertexDeclaration8_Release(This->vertex_declaration);
if (This->wineD3DVertexShader) IWineD3DVertexShader_Release(This->wineD3DVertexShader); if (This->wineD3DVertexShader)
{
EnterCriticalSection(&d3d8_cs);
IWineD3DVertexShader_Release(This->wineD3DVertexShader);
LeaveCriticalSection(&d3d8_cs);
}
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);
} }
return ref; return ref;
......
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