From bbce5af7d39c54bad156aa0754e7eb4cd03552e4 Mon Sep 17 00:00:00 2001 From: Matteo Bruni Date: Wed, 18 Jan 2017 21:35:28 +0100 Subject: [PATCH] d3d9: Fix DrawIndexedPrimitiveUP with non-zero min_vertex_idx. Signed-off-by: Matteo Bruni Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- dlls/d3d9/device.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c index e0bc5859c61..e646cb76c76 100644 --- a/dlls/d3d9/device.c +++ b/dlls/d3d9/device.c @@ -2485,18 +2485,16 @@ static HRESULT WINAPI d3d9_device_DrawIndexedPrimitiveUP(IDirect3DDevice9Ex *ifa UINT primitive_count, const void *index_data, D3DFORMAT index_format, const void *vertex_data, UINT vertex_stride) { - struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface); - HRESULT hr; UINT idx_count = vertex_count_from_primitive_count(primitive_type, primitive_count); + struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface); UINT idx_fmt_size = index_format == D3DFMT_INDEX16 ? 2 : 4; + UINT vtx_size = vertex_count * vertex_stride; UINT idx_size = idx_count * idx_fmt_size; struct wined3d_map_desc wined3d_map_desc; struct wined3d_box wined3d_box = {0}; struct wined3d_resource *ib, *vb; - UINT ib_pos; - - UINT vtx_size = vertex_count * vertex_stride; - UINT vb_pos, align; + UINT vb_pos, ib_pos, align; + HRESULT hr; TRACE("iface %p, primitive_type %#x, min_vertex_idx %u, vertex_count %u, primitive_count %u, " "index_data %p, index_format %#x, vertex_data %p, vertex_stride %u.\n", @@ -2536,7 +2534,7 @@ static HRESULT WINAPI d3d9_device_DrawIndexedPrimitiveUP(IDirect3DDevice9Ex *ifa if (FAILED(hr = wined3d_resource_map(vb, 0, &wined3d_map_desc, &wined3d_box, vb_pos ? WINED3D_MAP_NOOVERWRITE : WINED3D_MAP_DISCARD))) goto done; - memcpy(wined3d_map_desc.data, vertex_data, vtx_size); + memcpy(wined3d_map_desc.data, (char *)vertex_data + min_vertex_idx * vertex_stride, vtx_size); wined3d_resource_unmap(vb, 0); device->vertex_buffer_pos = vb_pos + vtx_size; @@ -2568,7 +2566,7 @@ static HRESULT WINAPI d3d9_device_DrawIndexedPrimitiveUP(IDirect3DDevice9Ex *ifa wined3d_device_set_index_buffer(device->wined3d_device, device->index_buffer, wined3dformat_from_d3dformat(index_format), 0); - wined3d_device_set_base_vertex_index(device->wined3d_device, vb_pos / vertex_stride); + wined3d_device_set_base_vertex_index(device->wined3d_device, vb_pos / vertex_stride - min_vertex_idx); wined3d_device_set_primitive_type(device->wined3d_device, primitive_type); hr = wined3d_device_draw_indexed_primitive(device->wined3d_device, ib_pos / idx_fmt_size, idx_count); -- 2.11.4.GIT