Matteo Bruni : d3d9: Fix DrawIndexedPrimitiveUP with non-zero min_vertex_idx.

Alexandre Julliard julliard at winehq.org
Thu Apr 20 12:35:10 CDT 2017


Module: wine
Branch: stable
Commit: 8e442cdf31d6839e49f0075f5180178f1243f5ed
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=8e442cdf31d6839e49f0075f5180178f1243f5ed

Author: Matteo Bruni <mbruni at codeweavers.com>
Date:   Wed Jan 18 21:35:28 2017 +0100

d3d9: Fix DrawIndexedPrimitiveUP with non-zero min_vertex_idx.

Signed-off-by: Matteo Bruni <mbruni at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
(cherry picked from commit bbce5af7d39c54bad156aa0754e7eb4cd03552e4)
Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>

---

 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 e0bc585..e646cb7 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);




More information about the wine-cvs mailing list