Commit cd203b38 authored by Stefan Dösinger's avatar Stefan Dösinger Committed by Alexandre Julliard

wined3d: Pass the context to the main buffer preload function.

parent 87f931dc
...@@ -730,13 +730,13 @@ static void buffer_direct_upload(struct wined3d_buffer *This, const struct wined ...@@ -730,13 +730,13 @@ static void buffer_direct_upload(struct wined3d_buffer *This, const struct wined
checkGLcall("glUnmapBufferARB"); 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); DWORD flags = buffer->flags & (WINED3D_BUFFER_NOSYNC | WINED3D_BUFFER_DISCARD);
struct wined3d_device *device = buffer->resource.device; struct wined3d_device *device = buffer->resource.device;
UINT start = 0, end = 0, len = 0, vertices; UINT start = 0, end = 0, len = 0, vertices;
const struct wined3d_gl_info *gl_info; const struct wined3d_gl_info *gl_info;
struct wined3d_context *context;
BOOL decl_changed = FALSE; BOOL decl_changed = FALSE;
unsigned int i, j; unsigned int i, j;
BYTE *data; BYTE *data;
...@@ -756,9 +756,7 @@ void CDECL wined3d_buffer_preload(struct wined3d_buffer *buffer) ...@@ -756,9 +756,7 @@ void CDECL wined3d_buffer_preload(struct wined3d_buffer *buffer)
/* TODO: Make converting independent from VBOs */ /* TODO: Make converting independent from VBOs */
if (buffer->flags & WINED3D_BUFFER_CREATEBO) if (buffer->flags & WINED3D_BUFFER_CREATEBO)
{ {
context = context_acquire(device, NULL);
buffer_create_buffer_object(buffer, context); buffer_create_buffer_object(buffer, context);
context_release(context);
buffer->flags &= ~WINED3D_BUFFER_CREATEBO; buffer->flags &= ~WINED3D_BUFFER_CREATEBO;
} }
else else
...@@ -867,14 +865,11 @@ void CDECL wined3d_buffer_preload(struct wined3d_buffer *buffer) ...@@ -867,14 +865,11 @@ void CDECL wined3d_buffer_preload(struct wined3d_buffer *buffer)
return; return;
} }
context = context_acquire(device, NULL);
buffer_direct_upload(buffer, context->gl_info, flags); buffer_direct_upload(buffer, context->gl_info, flags);
context_release(context);
return; return;
} }
context = context_acquire(device, NULL);
gl_info = context->gl_info; gl_info = context->gl_info;
if(!(buffer->flags & WINED3D_BUFFER_DOUBLEBUFFER)) if(!(buffer->flags & WINED3D_BUFFER_DOUBLEBUFFER))
...@@ -927,6 +922,13 @@ void CDECL wined3d_buffer_preload(struct wined3d_buffer *buffer) ...@@ -927,6 +922,13 @@ void CDECL wined3d_buffer_preload(struct wined3d_buffer *buffer)
} }
HeapFree(GetProcessHeap(), 0, data); 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); context_release(context);
} }
......
...@@ -2372,7 +2372,7 @@ BOOL context_apply_draw_state(struct wined3d_context *context, struct wined3d_de ...@@ -2372,7 +2372,7 @@ BOOL context_apply_draw_state(struct wined3d_context *context, struct wined3d_de
if (state->index_buffer) if (state->index_buffer)
{ {
if (device->stream_info.all_vbo) if (device->stream_info.all_vbo)
wined3d_buffer_preload(state->index_buffer); buffer_internal_preload(state->index_buffer, context);
else else
buffer_get_sysmem(state->index_buffer, context); buffer_get_sysmem(state->index_buffer, context);
} }
......
...@@ -288,7 +288,7 @@ static void device_stream_info_from_declaration(struct wined3d_device *device, s ...@@ -288,7 +288,7 @@ static void device_stream_info_from_declaration(struct wined3d_device *device, s
element = &stream_info->elements[i]; element = &stream_info->elements[i];
buffer = state->streams[element->stream_idx].buffer; 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 the preload dropped the buffer object, update the stream info. */
if (buffer->buffer_object != element->data.buffer_object) if (buffer->buffer_object != element->data.buffer_object)
......
...@@ -2523,6 +2523,8 @@ static inline struct wined3d_buffer *buffer_from_resource(struct wined3d_resourc ...@@ -2523,6 +2523,8 @@ static inline struct wined3d_buffer *buffer_from_resource(struct wined3d_resourc
void buffer_get_memory(struct wined3d_buffer *buffer, struct wined3d_context *context, void buffer_get_memory(struct wined3d_buffer *buffer, struct wined3d_context *context,
struct wined3d_bo_address *data) DECLSPEC_HIDDEN; struct wined3d_bo_address *data) DECLSPEC_HIDDEN;
BYTE *buffer_get_sysmem(struct wined3d_buffer *This, struct wined3d_context *context) 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 struct wined3d_rendertarget_view
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment