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

wined3d: IWineD3DBuffer_GetDesc() should never fail.

parent ad917d36
......@@ -212,25 +212,21 @@ static HRESULT WINAPI d3d8_vertexbuffer_GetDesc(IDirect3DVertexBuffer8 *iface, D
{
IDirect3DVertexBuffer8Impl *buffer = (IDirect3DVertexBuffer8Impl *)iface;
WINED3DBUFFER_DESC wined3d_desc;
HRESULT hr;
TRACE("iface %p, desc %p.\n", iface, desc);
wined3d_mutex_lock();
hr = IWineD3DBuffer_GetDesc(buffer->wineD3DVertexBuffer, &wined3d_desc);
IWineD3DBuffer_GetDesc(buffer->wineD3DVertexBuffer, &wined3d_desc);
wined3d_mutex_unlock();
if (SUCCEEDED(hr))
{
desc->Type = D3DRTYPE_VERTEXBUFFER;
desc->Usage = wined3d_desc.Usage;
desc->Pool = wined3d_desc.Pool;
desc->Size = wined3d_desc.Size;
desc->FVF = buffer->fvf;
desc->Format = D3DFMT_VERTEXDATA;
}
desc->Type = D3DRTYPE_VERTEXBUFFER;
desc->Usage = wined3d_desc.Usage;
desc->Pool = wined3d_desc.Pool;
desc->Size = wined3d_desc.Size;
desc->FVF = buffer->fvf;
desc->Format = D3DFMT_VERTEXDATA;
return hr;
return D3D_OK;
}
static const IDirect3DVertexBuffer8Vtbl Direct3DVertexBuffer8_Vtbl =
......@@ -479,25 +475,21 @@ static HRESULT WINAPI d3d8_indexbuffer_Unlock(IDirect3DIndexBuffer8 *iface)
static HRESULT WINAPI d3d8_indexbuffer_GetDesc(IDirect3DIndexBuffer8 *iface, D3DINDEXBUFFER_DESC *desc)
{
IDirect3DIndexBuffer8Impl *buffer = (IDirect3DIndexBuffer8Impl *)iface;
HRESULT hr;
WINED3DBUFFER_DESC wined3d_desc;
TRACE("iface %p, desc %p.\n", iface, desc);
wined3d_mutex_lock();
hr = IWineD3DBuffer_GetDesc(buffer->wineD3DIndexBuffer, &wined3d_desc);
IWineD3DBuffer_GetDesc(buffer->wineD3DIndexBuffer, &wined3d_desc);
wined3d_mutex_unlock();
if (SUCCEEDED(hr))
{
desc->Format = d3dformat_from_wined3dformat(buffer->format);
desc->Type = D3DRTYPE_INDEXBUFFER;
desc->Usage = wined3d_desc.Usage;
desc->Pool = wined3d_desc.Pool;
desc->Size = wined3d_desc.Size;
}
desc->Format = d3dformat_from_wined3dformat(buffer->format);
desc->Type = D3DRTYPE_INDEXBUFFER;
desc->Usage = wined3d_desc.Usage;
desc->Pool = wined3d_desc.Pool;
desc->Size = wined3d_desc.Size;
return hr;
return D3D_OK;
}
static const IDirect3DIndexBuffer8Vtbl d3d8_indexbuffer_vtbl =
......
......@@ -214,25 +214,21 @@ static HRESULT WINAPI d3d9_vertexbuffer_GetDesc(IDirect3DVertexBuffer9 *iface, D
{
IDirect3DVertexBuffer9Impl *buffer = (IDirect3DVertexBuffer9Impl *)iface;
WINED3DBUFFER_DESC wined3d_desc;
HRESULT hr;
TRACE("iface %p, desc %p.\n", iface, desc);
wined3d_mutex_lock();
hr = IWineD3DBuffer_GetDesc(buffer->wineD3DVertexBuffer, &wined3d_desc);
IWineD3DBuffer_GetDesc(buffer->wineD3DVertexBuffer, &wined3d_desc);
wined3d_mutex_unlock();
if (SUCCEEDED(hr))
{
desc->Format = D3DFMT_VERTEXDATA;
desc->Usage = wined3d_desc.Usage;
desc->Pool = wined3d_desc.Pool;
desc->Size = wined3d_desc.Size;
desc->Type = D3DRTYPE_VERTEXBUFFER;
desc->FVF = buffer->fvf;
}
desc->Format = D3DFMT_VERTEXDATA;
desc->Usage = wined3d_desc.Usage;
desc->Pool = wined3d_desc.Pool;
desc->Size = wined3d_desc.Size;
desc->Type = D3DRTYPE_VERTEXBUFFER;
desc->FVF = buffer->fvf;
return hr;
return D3D_OK;
}
static const IDirect3DVertexBuffer9Vtbl d3d9_vertexbuffer_vtbl =
......@@ -482,24 +478,20 @@ static HRESULT WINAPI d3d9_indexbuffer_GetDesc(IDirect3DIndexBuffer9 *iface, D3D
{
IDirect3DIndexBuffer9Impl *buffer = (IDirect3DIndexBuffer9Impl *)iface;
WINED3DBUFFER_DESC wined3d_desc;
HRESULT hr;
TRACE("iface %p, desc %p.\n", iface, desc);
wined3d_mutex_lock();
hr = IWineD3DBuffer_GetDesc(buffer->wineD3DIndexBuffer, &wined3d_desc);
IWineD3DBuffer_GetDesc(buffer->wineD3DIndexBuffer, &wined3d_desc);
wined3d_mutex_unlock();
if (SUCCEEDED(hr))
{
desc->Format = d3dformat_from_wined3dformat(buffer->format);
desc->Usage = wined3d_desc.Usage;
desc->Pool = wined3d_desc.Pool;
desc->Size = wined3d_desc.Size;
desc->Type = D3DRTYPE_INDEXBUFFER;
}
desc->Format = d3dformat_from_wined3dformat(buffer->format);
desc->Usage = wined3d_desc.Usage;
desc->Pool = wined3d_desc.Pool;
desc->Size = wined3d_desc.Size;
desc->Type = D3DRTYPE_INDEXBUFFER;
return hr;
return D3D_OK;
}
static const IDirect3DIndexBuffer9Vtbl d3d9_indexbuffer_vtbl =
......
......@@ -4345,10 +4345,9 @@ IDirect3DDeviceImpl_7_DrawIndexedPrimitiveVB(IDirect3DDevice7 *iface,
}
/* check that the buffer is large enough to hold the indices,
* reallocate if necessary.
*/
hr = IWineD3DBuffer_GetDesc(This->indexbuffer, &desc);
if(desc.Size < IndexCount * sizeof(WORD))
* reallocate if necessary. */
IWineD3DBuffer_GetDesc(This->indexbuffer, &desc);
if (desc.Size < IndexCount * sizeof(WORD))
{
UINT size = max(desc.Size * 2, IndexCount * sizeof(WORD));
IWineD3DBuffer *buffer;
......
......@@ -232,13 +232,7 @@ IDirect3DVertexBufferImpl_Lock(IDirect3DVertexBuffer7 *iface,
if(Size)
{
/* Get the size, for returning it, and for locking */
hr = IWineD3DBuffer_GetDesc(This->wineD3DVertexBuffer, &Desc);
if(hr != D3D_OK)
{
ERR("(%p) IWineD3DBuffer::GetDesc failed with hr=%08x\n", This, hr);
LeaveCriticalSection(&ddraw_cs);
return hr;
}
IWineD3DBuffer_GetDesc(This->wineD3DVertexBuffer, &Desc);
*Size = Desc.Size;
}
......@@ -425,26 +419,19 @@ IDirect3DVertexBufferImpl_GetVertexBufferDesc(IDirect3DVertexBuffer7 *iface,
{
IDirect3DVertexBufferImpl *This = (IDirect3DVertexBufferImpl *)iface;
WINED3DBUFFER_DESC WDesc;
HRESULT hr;
TRACE("iface %p, desc %p.\n", iface, Desc);
if(!Desc) return DDERR_INVALIDPARAMS;
EnterCriticalSection(&ddraw_cs);
hr = IWineD3DBuffer_GetDesc(This->wineD3DVertexBuffer, &WDesc);
if(hr != D3D_OK)
{
ERR("(%p) IWineD3DBuffer::GetDesc failed with hr=%08x\n", This, hr);
LeaveCriticalSection(&ddraw_cs);
return hr;
}
IWineD3DBuffer_GetDesc(This->wineD3DVertexBuffer, &WDesc);
LeaveCriticalSection(&ddraw_cs);
/* Now fill the Desc structure */
Desc->dwCaps = This->Caps;
Desc->dwFVF = This->fvf;
Desc->dwNumVertices = WDesc.Size / get_flexible_vertex_size(This->fvf);
LeaveCriticalSection(&ddraw_cs);
return D3D_OK;
}
......
......@@ -1413,7 +1413,7 @@ static HRESULT STDMETHODCALLTYPE buffer_Unmap(IWineD3DBuffer *iface)
return WINED3D_OK;
}
static HRESULT STDMETHODCALLTYPE buffer_GetDesc(IWineD3DBuffer *iface, WINED3DBUFFER_DESC *desc)
static void STDMETHODCALLTYPE buffer_GetDesc(IWineD3DBuffer *iface, WINED3DBUFFER_DESC *desc)
{
struct wined3d_buffer *This = (struct wined3d_buffer *)iface;
......@@ -1423,8 +1423,6 @@ static HRESULT STDMETHODCALLTYPE buffer_GetDesc(IWineD3DBuffer *iface, WINED3DBU
desc->Usage = This->resource.usage;
desc->Pool = This->resource.pool;
desc->Size = This->resource.size;
return WINED3D_OK;
}
static const struct IWineD3DBufferVtbl wined3d_buffer_vtbl =
......
......@@ -2736,7 +2736,7 @@ interface IWineD3DBuffer : IWineD3DResource
);
HRESULT Unmap(
);
HRESULT GetDesc(
void GetDesc(
[out] WINED3DBUFFER_DESC *desc
);
}
......
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