ddraw: Properly use the index buffer as a dynamic buffer.
This commit is contained in:
parent
108fcb691c
commit
a61f68fc5a
@ -277,6 +277,7 @@ struct d3d_device
|
|||||||
struct ddraw *ddraw;
|
struct ddraw *ddraw;
|
||||||
struct wined3d_buffer *indexbuffer;
|
struct wined3d_buffer *indexbuffer;
|
||||||
UINT indexbuffer_size;
|
UINT indexbuffer_size;
|
||||||
|
UINT indexbuffer_pos;
|
||||||
struct ddraw_surface *target;
|
struct ddraw_surface *target;
|
||||||
|
|
||||||
/* Viewport management */
|
/* Viewport management */
|
||||||
|
@ -4041,6 +4041,7 @@ static HRESULT d3d_device7_DrawIndexedPrimitiveVB(IDirect3DDevice7 *iface,
|
|||||||
DWORD stride = get_flexible_vertex_size(vb->fvf);
|
DWORD stride = get_flexible_vertex_size(vb->fvf);
|
||||||
WORD *LockedIndices;
|
WORD *LockedIndices;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
UINT ib_pos = This->indexbuffer_pos;
|
||||||
|
|
||||||
TRACE("iface %p, primitive_type %#x, vb %p, start_vertex %u, vertex_count %u, indices %p, index_count %u, flags %#x.\n",
|
TRACE("iface %p, primitive_type %#x, vb %p, start_vertex %u, vertex_count %u, indices %p, index_count %u, flags %#x.\n",
|
||||||
iface, PrimitiveType, D3DVertexBuf, StartVertex, NumVertices, Indices, IndexCount, Flags);
|
iface, PrimitiveType, D3DVertexBuf, StartVertex, NumVertices, Indices, IndexCount, Flags);
|
||||||
@ -4075,14 +4076,18 @@ static HRESULT d3d_device7_DrawIndexedPrimitiveVB(IDirect3DDevice7 *iface,
|
|||||||
if (This->indexbuffer) wined3d_buffer_decref(This->indexbuffer);
|
if (This->indexbuffer) wined3d_buffer_decref(This->indexbuffer);
|
||||||
This->indexbuffer = buffer;
|
This->indexbuffer = buffer;
|
||||||
This->indexbuffer_size = size;
|
This->indexbuffer_size = size;
|
||||||
|
ib_pos = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (This->indexbuffer_size - IndexCount * sizeof(WORD) < ib_pos)
|
||||||
|
ib_pos = 0;
|
||||||
|
|
||||||
/* Copy the index stream into the index buffer. A new IWineD3DDevice
|
/* Copy the index stream into the index buffer. A new IWineD3DDevice
|
||||||
* method could be created which takes an user pointer containing the
|
* method could be created which takes an user pointer containing the
|
||||||
* indices or a SetData-Method for the index buffer, which overrides the
|
* indices or a SetData-Method for the index buffer, which overrides the
|
||||||
* index buffer data with our pointer. */
|
* index buffer data with our pointer. */
|
||||||
hr = wined3d_buffer_map(This->indexbuffer, 0, IndexCount * sizeof(WORD),
|
hr = wined3d_buffer_map(This->indexbuffer, ib_pos, IndexCount * sizeof(WORD),
|
||||||
(BYTE **)&LockedIndices, 0);
|
(BYTE **)&LockedIndices, ib_pos ? WINED3D_MAP_NOOVERWRITE : WINED3D_MAP_DISCARD);
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
ERR("Failed to map buffer, hr %#x.\n", hr);
|
ERR("Failed to map buffer, hr %#x.\n", hr);
|
||||||
@ -4091,6 +4096,7 @@ static HRESULT d3d_device7_DrawIndexedPrimitiveVB(IDirect3DDevice7 *iface,
|
|||||||
}
|
}
|
||||||
memcpy(LockedIndices, Indices, IndexCount * sizeof(WORD));
|
memcpy(LockedIndices, Indices, IndexCount * sizeof(WORD));
|
||||||
wined3d_buffer_unmap(This->indexbuffer);
|
wined3d_buffer_unmap(This->indexbuffer);
|
||||||
|
This->indexbuffer_pos = ib_pos + IndexCount * sizeof(WORD);
|
||||||
|
|
||||||
/* Set the index stream */
|
/* Set the index stream */
|
||||||
wined3d_device_set_base_vertex_index(This->wined3d_device, StartVertex);
|
wined3d_device_set_base_vertex_index(This->wined3d_device, StartVertex);
|
||||||
@ -4107,7 +4113,7 @@ static HRESULT d3d_device7_DrawIndexedPrimitiveVB(IDirect3DDevice7 *iface,
|
|||||||
|
|
||||||
|
|
||||||
wined3d_device_set_primitive_type(This->wined3d_device, PrimitiveType);
|
wined3d_device_set_primitive_type(This->wined3d_device, PrimitiveType);
|
||||||
hr = wined3d_device_draw_indexed_primitive(This->wined3d_device, 0, IndexCount);
|
hr = wined3d_device_draw_indexed_primitive(This->wined3d_device, ib_pos / sizeof(WORD), IndexCount);
|
||||||
|
|
||||||
wined3d_mutex_unlock();
|
wined3d_mutex_unlock();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user