Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- It's not just a performance improvement, it's actually a bugfix for some glitches I was getting with a Unity game (although I imagine it's probably hard-to-impossible to reproduce in practice without the buffer map optimizations).
What happened is that the game DISCARD maps the index buffer, then makes a bunch of non-indexed draws but still with the currently-mapped buffer set as index buffer, then eventually updates and unmaps the buffer and makes use of it in a draw. So it's important not to upload the buffer before it's actually needed. --- dlls/wined3d/context.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c index c6a1d762673..2e363fb1d65 100644 --- a/dlls/wined3d/context.c +++ b/dlls/wined3d/context.c @@ -4225,7 +4225,7 @@ static void context_load_stream_output_buffers(struct wined3d_context *context,
/* Context activation is done by the caller. */ static BOOL context_apply_draw_state(struct wined3d_context *context, - const struct wined3d_device *device, const struct wined3d_state *state) + const struct wined3d_device *device, const struct wined3d_state *state, BOOL indexed) { const struct wined3d_state_entry *state_table = context->state_table; struct wined3d_context_gl *context_gl = wined3d_context_gl(context); @@ -4277,7 +4277,7 @@ static BOOL context_apply_draw_state(struct wined3d_context *context, if (isStateDirty(context, STATE_STREAMSRC)) context_update_stream_info(context, state); } - if (state->index_buffer) + if (indexed && state->index_buffer) { if (context->stream_info.all_vbo) wined3d_buffer_load(state->index_buffer, context, state); @@ -5194,7 +5194,7 @@ void draw_primitive(struct wined3d_device *device, const struct wined3d_state *s if (parameters->indirect) wined3d_buffer_load(parameters->u.indirect.buffer, context, state);
- if (!context_apply_draw_state(context, device, state)) + if (!context_apply_draw_state(context, device, state, parameters->indexed)) { context_release(context); WARN("Unable to apply draw state, skipping draw.\n");