From: Steve Schnepp steve.schnepp@pwkf.org
--- dlls/ddraw/ddraw_private.h | 4 +++- dlls/ddraw/device.c | 15 ++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/dlls/ddraw/ddraw_private.h b/dlls/ddraw/ddraw_private.h index 3bb5b3790ca..b2357cf67c1 100644 --- a/dlls/ddraw/ddraw_private.h +++ b/dlls/ddraw/ddraw_private.h @@ -314,7 +314,8 @@ DWORD ddraw_allocate_handle(struct ddraw_handle_table *t, void *object, enum ddr void *ddraw_free_handle(struct ddraw_handle_table *t, DWORD handle, enum ddraw_handle_type type) DECLSPEC_HIDDEN; void *ddraw_get_object(struct ddraw_handle_table *t, DWORD handle, enum ddraw_handle_type type) DECLSPEC_HIDDEN;
-#define VERTEX_BUFFER_SIZE 4096 +#define VERTEX_BATCH_SIZE_INITIAL 16 +#define VERTEX_BATCH_SIZE_MAX 4096
struct vertex_batch { D3DPRIMITIVETYPE primitive_type; @@ -327,6 +328,7 @@ struct vertex_batch { * it is limited to D3DMAXNUMVERTICES (65,535) */ unsigned int vertex_count; unsigned int vertex_pos; + unsigned int vertex_batch_size; };
struct d3d_device diff --git a/dlls/ddraw/device.c b/dlls/ddraw/device.c index e36a7207ada..d1a3cd2bab5 100644 --- a/dlls/ddraw/device.c +++ b/dlls/ddraw/device.c @@ -1682,13 +1682,18 @@ static HRESULT ddraw_buffer_add(struct d3d_device *device, D3DPRIMITIVETYPE prim } else if (fvf != device->vertex_batch.fvf) { TRACE_(d3d_perf)("Buffering failed due to mismatched fvf %ld != buffer.fvf %ld \n", fvf, device->vertex_batch.fvf); ddraw_buffer_flush(device); - } else if (device->vertex_batch.vertex_count + vertex_count * 2 > VERTEX_BUFFER_SIZE) { + } else if (device->vertex_batch.vertex_count + vertex_count * 2 > device->vertex_batch.vertex_batch_size) { /* We double the number of vertices to add since * - it is a very fast mul * - the number will never more than double * - the precision it offers is good enough */ - FIXME_(d3d_perf)("Buffering failed due to almost full buffer vertex_count %u, adding %lu, max %u \n", device->vertex_batch.vertex_count, vertex_count, VERTEX_BUFFER_SIZE); + FIXME_(d3d_perf)("Full buffer vertex_batch.vertex_count %u, vertex_count %lu, vertex_batch_size %u \n", + device->vertex_batch.vertex_count, vertex_count, device->vertex_batch.vertex_batch_size); ddraw_buffer_flush(device); + + /* Doubling size until quite big */ + if (device->vertex_batch.vertex_batch_size < VERTEX_BATCH_SIZE_MAX) + device->vertex_batch.vertex_batch_size *= 2; } }
@@ -1716,7 +1721,7 @@ static HRESULT ddraw_buffer_add(struct d3d_device *device, D3DPRIMITIVETYPE prim * * We will fill it with following calls */ hr = wined3d_streaming_buffer_map(device->wined3d_device, &device->vertex_buffer, - VERTEX_BUFFER_SIZE * stride, stride, + device->vertex_batch.vertex_batch_size * stride, stride, &device->vertex_batch.vertex_pos, (void**) &device->vertex_batch.vertices); if (FAILED(hr)) goto fail; @@ -1739,8 +1744,6 @@ static HRESULT ddraw_buffer_add(struct d3d_device *device, D3DPRIMITIVETYPE prim ERR("primitive_type %#x not supported\n", primitive_type); }
- assert(device->vertex_batch.vertex_count < VERTEX_BUFFER_SIZE); - /* Buffered ! */ return D3D_OK;
@@ -7096,6 +7099,8 @@ static HRESULT d3d_device_init(struct d3d_device *device, struct ddraw *ddraw, c wined3d_streaming_buffer_init(&device->vertex_buffer, WINED3D_BIND_VERTEX_BUFFER); wined3d_streaming_buffer_init(&device->index_buffer, WINED3D_BIND_INDEX_BUFFER);
+ device->vertex_batch.vertex_batch_size = VERTEX_BATCH_SIZE_INITIAL; + /* Render to the back buffer */ rtv = ddraw_surface_get_rendertarget_view(target); if (FAILED(hr = wined3d_device_context_set_rendertarget_views(device->immediate_context, 0, 1, &rtv, TRUE)))