wined3d: IWineD3DBuffer_Unmap() can't fail.

This commit is contained in:
Henri Verbeet 2010-10-15 14:35:12 +02:00 committed by Alexandre Julliard
parent 1fa3365832
commit 70f4e66f84
6 changed files with 17 additions and 41 deletions

View File

@ -197,15 +197,13 @@ static HRESULT WINAPI d3d8_vertexbuffer_Lock(IDirect3DVertexBuffer8 *iface,
static HRESULT WINAPI d3d8_vertexbuffer_Unlock(IDirect3DVertexBuffer8 *iface) static HRESULT WINAPI d3d8_vertexbuffer_Unlock(IDirect3DVertexBuffer8 *iface)
{ {
HRESULT hr;
TRACE("iface %p.\n", iface); TRACE("iface %p.\n", iface);
wined3d_mutex_lock(); wined3d_mutex_lock();
hr = IWineD3DBuffer_Unmap(((IDirect3DVertexBuffer8Impl *)iface)->wineD3DVertexBuffer); IWineD3DBuffer_Unmap(((IDirect3DVertexBuffer8Impl *)iface)->wineD3DVertexBuffer);
wined3d_mutex_unlock(); wined3d_mutex_unlock();
return hr; return D3D_OK;
} }
static HRESULT WINAPI d3d8_vertexbuffer_GetDesc(IDirect3DVertexBuffer8 *iface, D3DVERTEXBUFFER_DESC *desc) static HRESULT WINAPI d3d8_vertexbuffer_GetDesc(IDirect3DVertexBuffer8 *iface, D3DVERTEXBUFFER_DESC *desc)
@ -461,15 +459,13 @@ static HRESULT WINAPI d3d8_indexbuffer_Lock(IDirect3DIndexBuffer8 *iface,
static HRESULT WINAPI d3d8_indexbuffer_Unlock(IDirect3DIndexBuffer8 *iface) static HRESULT WINAPI d3d8_indexbuffer_Unlock(IDirect3DIndexBuffer8 *iface)
{ {
HRESULT hr;
TRACE("iface %p.\n", iface); TRACE("iface %p.\n", iface);
wined3d_mutex_lock(); wined3d_mutex_lock();
hr = IWineD3DBuffer_Unmap(((IDirect3DIndexBuffer8Impl *)iface)->wineD3DIndexBuffer); IWineD3DBuffer_Unmap(((IDirect3DIndexBuffer8Impl *)iface)->wineD3DIndexBuffer);
wined3d_mutex_unlock(); wined3d_mutex_unlock();
return hr; return D3D_OK;
} }
static HRESULT WINAPI d3d8_indexbuffer_GetDesc(IDirect3DIndexBuffer8 *iface, D3DINDEXBUFFER_DESC *desc) static HRESULT WINAPI d3d8_indexbuffer_GetDesc(IDirect3DIndexBuffer8 *iface, D3DINDEXBUFFER_DESC *desc)

View File

@ -199,15 +199,13 @@ static HRESULT WINAPI d3d9_vertexbuffer_Lock(IDirect3DVertexBuffer9 *iface,
static HRESULT WINAPI d3d9_vertexbuffer_Unlock(IDirect3DVertexBuffer9 *iface) static HRESULT WINAPI d3d9_vertexbuffer_Unlock(IDirect3DVertexBuffer9 *iface)
{ {
HRESULT hr;
TRACE("iface %p.\n", iface); TRACE("iface %p.\n", iface);
wined3d_mutex_lock(); wined3d_mutex_lock();
hr = IWineD3DBuffer_Unmap(((IDirect3DVertexBuffer9Impl *)iface)->wineD3DVertexBuffer); IWineD3DBuffer_Unmap(((IDirect3DVertexBuffer9Impl *)iface)->wineD3DVertexBuffer);
wined3d_mutex_unlock(); wined3d_mutex_unlock();
return hr; return D3D_OK;
} }
static HRESULT WINAPI d3d9_vertexbuffer_GetDesc(IDirect3DVertexBuffer9 *iface, D3DVERTEXBUFFER_DESC *desc) static HRESULT WINAPI d3d9_vertexbuffer_GetDesc(IDirect3DVertexBuffer9 *iface, D3DVERTEXBUFFER_DESC *desc)
@ -463,15 +461,13 @@ static HRESULT WINAPI d3d9_indexbuffer_Lock(IDirect3DIndexBuffer9 *iface,
static HRESULT WINAPI d3d9_indexbuffer_Unlock(IDirect3DIndexBuffer9 *iface) static HRESULT WINAPI d3d9_indexbuffer_Unlock(IDirect3DIndexBuffer9 *iface)
{ {
HRESULT hr;
TRACE("iface %p.\n", iface); TRACE("iface %p.\n", iface);
wined3d_mutex_lock(); wined3d_mutex_lock();
hr = IWineD3DBuffer_Unmap(((IDirect3DIndexBuffer9Impl *)iface)->wineD3DIndexBuffer); IWineD3DBuffer_Unmap(((IDirect3DIndexBuffer9Impl *)iface)->wineD3DIndexBuffer);
wined3d_mutex_unlock(); wined3d_mutex_unlock();
return hr; return D3D_OK;
} }
static HRESULT WINAPI d3d9_indexbuffer_GetDesc(IDirect3DIndexBuffer9 *iface, D3DINDEXBUFFER_DESC *desc) static HRESULT WINAPI d3d9_indexbuffer_GetDesc(IDirect3DIndexBuffer9 *iface, D3DINDEXBUFFER_DESC *desc)

View File

@ -4364,13 +4364,7 @@ IDirect3DDeviceImpl_7_DrawIndexedPrimitiveVB(IDirect3DDevice7 *iface,
return hr; return hr;
} }
memcpy(LockedIndices, Indices, IndexCount * sizeof(WORD)); memcpy(LockedIndices, Indices, IndexCount * sizeof(WORD));
hr = IWineD3DBuffer_Unmap(This->indexbuffer); IWineD3DBuffer_Unmap(This->indexbuffer);
if(hr != D3D_OK)
{
ERR("(%p) IWineD3DBuffer::Unmap failed with hr = %08x\n", This, hr);
LeaveCriticalSection(&ddraw_cs);
return hr;
}
/* Set the index stream */ /* Set the index stream */
IWineD3DDevice_SetBaseVertexIndex(This->wineD3DDevice, StartVertex); IWineD3DDevice_SetBaseVertexIndex(This->wineD3DDevice, StartVertex);

View File

@ -266,15 +266,14 @@ static HRESULT WINAPI
IDirect3DVertexBufferImpl_Unlock(IDirect3DVertexBuffer7 *iface) IDirect3DVertexBufferImpl_Unlock(IDirect3DVertexBuffer7 *iface)
{ {
IDirect3DVertexBufferImpl *This = (IDirect3DVertexBufferImpl *)iface; IDirect3DVertexBufferImpl *This = (IDirect3DVertexBufferImpl *)iface;
HRESULT hr;
TRACE("iface %p.\n", iface); TRACE("iface %p.\n", iface);
EnterCriticalSection(&ddraw_cs); EnterCriticalSection(&ddraw_cs);
hr = IWineD3DBuffer_Unmap(This->wineD3DVertexBuffer); IWineD3DBuffer_Unmap(This->wineD3DVertexBuffer);
LeaveCriticalSection(&ddraw_cs); LeaveCriticalSection(&ddraw_cs);
return hr; return D3D_OK;
} }
static HRESULT WINAPI static HRESULT WINAPI

View File

@ -1338,7 +1338,7 @@ static HRESULT STDMETHODCALLTYPE buffer_Map(IWineD3DBuffer *iface, UINT offset,
return WINED3D_OK; return WINED3D_OK;
} }
static HRESULT STDMETHODCALLTYPE buffer_Unmap(IWineD3DBuffer *iface) static void STDMETHODCALLTYPE buffer_Unmap(IWineD3DBuffer *iface)
{ {
struct wined3d_buffer *This = (struct wined3d_buffer *)iface; struct wined3d_buffer *This = (struct wined3d_buffer *)iface;
ULONG i; ULONG i;
@ -1351,15 +1351,15 @@ static HRESULT STDMETHODCALLTYPE buffer_Unmap(IWineD3DBuffer *iface)
* the next call (this will happen if the lock_count is < 0). */ * the next call (this will happen if the lock_count is < 0). */
if (!This->lock_count) if (!This->lock_count)
{ {
TRACE("Unmap called without a previous Map call!\n"); WARN("Unmap called without a previous Map call.\n");
return WINED3D_OK; return;
} }
if (InterlockedDecrement(&This->lock_count)) if (InterlockedDecrement(&This->lock_count))
{ {
/* Delay loading the buffer until everything is unlocked */ /* Delay loading the buffer until everything is unlocked */
TRACE("Ignoring unlock\n"); TRACE("Ignoring unlock\n");
return WINED3D_OK; return;
} }
if(!(This->flags & WINED3D_BUFFER_DOUBLEBUFFER) && This->buffer_object) if(!(This->flags & WINED3D_BUFFER_DOUBLEBUFFER) && This->buffer_object)
@ -1410,8 +1410,6 @@ static HRESULT STDMETHODCALLTYPE buffer_Unmap(IWineD3DBuffer *iface)
{ {
buffer_PreLoad(iface); buffer_PreLoad(iface);
} }
return WINED3D_OK;
} }
static void STDMETHODCALLTYPE buffer_GetDesc(IWineD3DBuffer *iface, WINED3DBUFFER_DESC *desc) static void STDMETHODCALLTYPE buffer_GetDesc(IWineD3DBuffer *iface, WINED3DBUFFER_DESC *desc)
@ -1520,14 +1518,7 @@ HRESULT buffer_init(struct wined3d_buffer *buffer, IWineD3DDeviceImpl *device,
memcpy(ptr, data, size); memcpy(ptr, data, size);
hr = IWineD3DBuffer_Unmap((IWineD3DBuffer *)buffer); IWineD3DBuffer_Unmap((IWineD3DBuffer *)buffer);
if (FAILED(hr))
{
ERR("Failed to unmap buffer, hr %#x\n", hr);
buffer_UnLoad((IWineD3DBuffer *)buffer);
resource_cleanup((IWineD3DResource *)buffer);
return hr;
}
} }
buffer->maps = HeapAlloc(GetProcessHeap(), 0, sizeof(*buffer->maps)); buffer->maps = HeapAlloc(GetProcessHeap(), 0, sizeof(*buffer->maps));

View File

@ -2731,7 +2731,7 @@ interface IWineD3DBuffer : IWineD3DResource
[out] BYTE **data, [out] BYTE **data,
[in] DWORD flags [in] DWORD flags
); );
HRESULT Unmap( void Unmap(
); );
void GetDesc( void GetDesc(
[out] WINED3DBUFFER_DESC *desc [out] WINED3DBUFFER_DESC *desc