=?UTF-8?Q?Stefan=20D=C3=B6singer=20?=: ddraw: Avoid redundant index buffer discards.

Alexandre Julliard julliard at winehq.org
Tue Nov 15 17:56:15 CST 2016


Module: wine
Branch: master
Commit: 72eab6f214a0f2c24bb9c30e54ac9e034c403713
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=72eab6f214a0f2c24bb9c30e54ac9e034c403713

Author: Stefan Dösinger <stefandoesinger at gmx.at>
Date:   Sun Nov 13 15:12:45 2016 -0600

ddraw: Avoid redundant index buffer discards.

Signed-off-by: Stefan Dösinger <stefandoesinger at gmx.at>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/ddraw/ddraw_private.h |  2 +-
 dlls/ddraw/executebuffer.c | 19 ++++++++++++++-----
 2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/dlls/ddraw/ddraw_private.h b/dlls/ddraw/ddraw_private.h
index 721415c..2f8737b 100644
--- a/dlls/ddraw/ddraw_private.h
+++ b/dlls/ddraw/ddraw_private.h
@@ -523,7 +523,7 @@ struct d3d_execute_buffer
     D3DEXECUTEDATA       data;
 
     /* This buffer will store the transformed vertices */
-    unsigned int         index_size;
+    unsigned int         index_size, index_pos;
     unsigned int         vertex_size;
     struct wined3d_buffer *src_vertex_buffer, *dst_vertex_buffer, *index_buffer;
 
diff --git a/dlls/ddraw/executebuffer.c b/dlls/ddraw/executebuffer.c
index 1603e70..3ed18f1 100644
--- a/dlls/ddraw/executebuffer.c
+++ b/dlls/ddraw/executebuffer.c
@@ -96,6 +96,7 @@ HRESULT d3d_execute_buffer_execute(struct d3d_execute_buffer *buffer,
             case D3DOP_TRIANGLE:
             {
                 WORD *indices;
+                unsigned int index_pos = buffer->index_pos;
                 TRACE("TRIANGLE         (%d)\n", count);
 
                 if (!count)
@@ -116,12 +117,17 @@ HRESULT d3d_execute_buffer_execute(struct d3d_execute_buffer *buffer,
                     if (buffer->index_buffer)
                         wined3d_buffer_decref(buffer->index_buffer);
                     buffer->index_buffer = new_buffer;
+                    index_pos = 0;
+                }
+                else if (buffer->index_size - count * 3 < index_pos)
+                {
+                    index_pos = 0;
                 }
 
-                box.left = 0;
-                box.right = count * 3 * sizeof(*indices);
+                box.left = index_pos * sizeof(*indices);
+                box.right = (index_pos + count * 3) * sizeof(*indices);
                 hr = wined3d_resource_map(wined3d_buffer_get_resource(buffer->index_buffer), 0,
-                        &map_desc, &box, WINED3D_MAP_DISCARD);
+                        &map_desc, &box, index_pos ? WINED3D_MAP_NOOVERWRITE : WINED3D_MAP_DISCARD);
                 if (FAILED(hr))
                     return hr;
                 indices = map_desc.data;
@@ -165,8 +171,11 @@ HRESULT d3d_execute_buffer_execute(struct d3d_execute_buffer *buffer,
                         ddraw_find_decl(device->ddraw, D3DFVF_TLVERTEX));
                 wined3d_device_set_index_buffer(device->wined3d_device, buffer->index_buffer, WINED3DFMT_R16_UINT, 0);
                 wined3d_device_set_primitive_type(device->wined3d_device, WINED3D_PT_TRIANGLELIST);
-                wined3d_device_draw_indexed_primitive(device->wined3d_device, 0, count * 3);
-	    } break;
+                wined3d_device_draw_indexed_primitive(device->wined3d_device, index_pos, count * 3);
+
+                buffer->index_pos = index_pos + count * 3;
+                break;
+            }
 
 	    case D3DOP_MATRIXLOAD:
 	        WARN("MATRIXLOAD-s     (%d)\n", count);




More information about the wine-cvs mailing list