[PATCH 3/4] wined3d: Pass the context to the main buffer preload function

Stefan Dösinger stefan at codeweavers.com
Mon Sep 9 08:15:37 CDT 2013


---
 dlls/wined3d/buffer.c          | 16 +++++++++-------
 dlls/wined3d/context.c         |  2 +-
 dlls/wined3d/device.c          |  2 +-
 dlls/wined3d/wined3d_private.h |  2 ++
 4 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c
index d198ac4..f811a61 100644
--- a/dlls/wined3d/buffer.c
+++ b/dlls/wined3d/buffer.c
@@ -730,13 +730,13 @@ static void buffer_direct_upload(struct wined3d_buffer *This, const struct wined
     checkGLcall("glUnmapBufferARB");
 }
 
-void CDECL wined3d_buffer_preload(struct wined3d_buffer *buffer)
+/* Context activation is done by the caller. */
+void buffer_internal_preload(struct wined3d_buffer *buffer, struct wined3d_context *context)
 {
     DWORD flags = buffer->flags & (WINED3D_BUFFER_NOSYNC | WINED3D_BUFFER_DISCARD);
     struct wined3d_device *device = buffer->resource.device;
     UINT start = 0, end = 0, len = 0, vertices;
     const struct wined3d_gl_info *gl_info;
-    struct wined3d_context *context;
     BOOL decl_changed = FALSE;
     unsigned int i, j;
     BYTE *data;
@@ -756,9 +756,7 @@ void CDECL wined3d_buffer_preload(struct wined3d_buffer *buffer)
         /* TODO: Make converting independent from VBOs */
         if (buffer->flags & WINED3D_BUFFER_CREATEBO)
         {
-            context = context_acquire(device, NULL);
             buffer_create_buffer_object(buffer, context);
-            context_release(context);
             buffer->flags &= ~WINED3D_BUFFER_CREATEBO;
         }
         else
@@ -867,14 +865,11 @@ void CDECL wined3d_buffer_preload(struct wined3d_buffer *buffer)
             return;
         }
 
-        context = context_acquire(device, NULL);
         buffer_direct_upload(buffer, context->gl_info, flags);
 
-        context_release(context);
         return;
     }
 
-    context = context_acquire(device, NULL);
     gl_info = context->gl_info;
 
     if(!(buffer->flags & WINED3D_BUFFER_DOUBLEBUFFER))
@@ -927,6 +922,13 @@ void CDECL wined3d_buffer_preload(struct wined3d_buffer *buffer)
     }
 
     HeapFree(GetProcessHeap(), 0, data);
+}
+
+void CDECL wined3d_buffer_preload(struct wined3d_buffer *buffer)
+{
+    struct wined3d_context *context;
+    context = context_acquire(buffer->resource.device, NULL);
+    buffer_internal_preload(buffer, context);
     context_release(context);
 }
 
diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c
index da255e8..4a079cf 100644
--- a/dlls/wined3d/context.c
+++ b/dlls/wined3d/context.c
@@ -2372,7 +2372,7 @@ BOOL context_apply_draw_state(struct wined3d_context *context, struct wined3d_de
     if (state->index_buffer)
     {
         if (device->stream_info.all_vbo)
-            wined3d_buffer_preload(state->index_buffer);
+            buffer_internal_preload(state->index_buffer, context);
         else
             buffer_get_sysmem(state->index_buffer, context);
     }
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 3564149..2457771 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -288,7 +288,7 @@ static void device_stream_info_from_declaration(struct wined3d_device *device, s
 
         element = &stream_info->elements[i];
         buffer = state->streams[element->stream_idx].buffer;
-        wined3d_buffer_preload(buffer);
+        buffer_internal_preload(buffer, context);
 
         /* If the preload dropped the buffer object, update the stream info. */
         if (buffer->buffer_object != element->data.buffer_object)
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 3ae9a9e..23d32c2 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2522,6 +2522,8 @@ static inline struct wined3d_buffer *buffer_from_resource(struct wined3d_resourc
 void buffer_get_memory(struct wined3d_buffer *buffer, struct wined3d_context *context,
         struct wined3d_bo_address *data) DECLSPEC_HIDDEN;
 BYTE *buffer_get_sysmem(struct wined3d_buffer *This, struct wined3d_context *context) DECLSPEC_HIDDEN;
+void buffer_internal_preload(struct wined3d_buffer *buffer,
+        struct wined3d_context *context) DECLSPEC_HIDDEN;
 
 struct wined3d_rendertarget_view
 {
-- 
1.8.1.5




More information about the wine-patches mailing list