[PATCH 5/5] wined3d: Determine index buffer location based on vertex buffer locations.

Henri Verbeet hverbeet at codeweavers.com
Wed May 2 14:47:58 CDT 2012


---
 dlls/wined3d/device.c   |   11 +++++++++++
 dlls/wined3d/drawprim.c |    2 +-
 dlls/wined3d/state.c    |    3 ++-
 3 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 0b0b600..c659e47 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -404,6 +404,7 @@ void device_update_stream_info(struct wined3d_device *device, const struct wined
 {
     struct wined3d_stream_info *stream_info = &device->strided_streams;
     const struct wined3d_state *state = &device->stateBlock->state;
+    DWORD prev_all_vbo = stream_info->all_vbo;
 
     if (device->up_strided)
     {
@@ -445,6 +446,16 @@ void device_update_stream_info(struct wined3d_device *device, const struct wined
             device->useDrawStridedSlow = FALSE;
         }
     }
+
+    if (state->index_buffer && !state->user_stream)
+    {
+        if (prev_all_vbo != stream_info->all_vbo)
+            device_invalidate_state(device, STATE_INDEXBUFFER);
+        if (stream_info->all_vbo)
+            wined3d_buffer_preload(state->index_buffer);
+        else
+            buffer_get_sysmem(state->index_buffer, gl_info);
+    }
 }
 
 static void device_preload_texture(const struct wined3d_state *state, unsigned int idx)
diff --git a/dlls/wined3d/drawprim.c b/dlls/wined3d/drawprim.c
index 18b8f3f..2e30175 100644
--- a/dlls/wined3d/drawprim.c
+++ b/dlls/wined3d/drawprim.c
@@ -676,7 +676,7 @@ void drawPrimitive(struct wined3d_device *device, UINT index_count, UINT StartId
             if (!state->user_stream)
             {
                 struct wined3d_buffer *index_buffer = state->index_buffer;
-                if (!index_buffer->buffer_object)
+                if (!index_buffer->buffer_object || !stream_info->all_vbo)
                     idxData = index_buffer->resource.allocatedMemory;
                 else
                     idxData = NULL;
diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c
index 5e6c537..fc6fedc 100644
--- a/dlls/wined3d/state.c
+++ b/dlls/wined3d/state.c
@@ -4817,9 +4817,10 @@ static void scissorrect(struct wined3d_context *context, const struct wined3d_st
 
 static void indexbuffer(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
 {
+    const struct wined3d_stream_info *stream_info = &context->swapchain->device->strided_streams;
     const struct wined3d_gl_info *gl_info = context->gl_info;
 
-    if (state->user_stream || !state->index_buffer)
+    if (state->user_stream || !state->index_buffer || !stream_info->all_vbo)
     {
         GL_EXTCALL(glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0));
     }
-- 
1.7.3.4




More information about the wine-patches mailing list