Commit 6d2d43bb authored by Jan Sikorski's avatar Jan Sikorski Committed by Alexandre Julliard

wined3d: Make wined3d_device_context procedures thread safe.

parent 5abee26b
......@@ -99,6 +99,7 @@ ULONG CDECL wined3d_command_list_decref(struct wined3d_command_list *list)
{
SIZE_T i;
wined3d_mutex_lock();
for (i = 0; i < list->command_list_count; ++i)
wined3d_command_list_decref(list->command_lists[i]);
for (i = 0; i < list->resource_count; ++i)
......@@ -109,6 +110,7 @@ ULONG CDECL wined3d_command_list_decref(struct wined3d_command_list *list)
wined3d_query_decref(list->queries[i].query);
wined3d_cs_destroy_object(device->cs, wined3d_command_list_destroy_object, list);
wined3d_mutex_unlock();
}
return refcount;
......@@ -1010,6 +1012,7 @@ void CDECL wined3d_device_context_dispatch(struct wined3d_device_context *contex
{
struct wined3d_cs_dispatch *op;
wined3d_mutex_lock();
op = wined3d_device_context_require_space(context, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT);
op->opcode = WINED3D_CS_OP_DISPATCH;
op->parameters.indirect = FALSE;
......@@ -1020,6 +1023,7 @@ void CDECL wined3d_device_context_dispatch(struct wined3d_device_context *contex
acquire_compute_pipeline_resources(context);
wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT);
wined3d_mutex_unlock();
}
void CDECL wined3d_device_context_dispatch_indirect(struct wined3d_device_context *context,
......@@ -1027,6 +1031,7 @@ void CDECL wined3d_device_context_dispatch_indirect(struct wined3d_device_contex
{
struct wined3d_cs_dispatch *op;
wined3d_mutex_lock();
op = wined3d_device_context_require_space(context, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT);
op->opcode = WINED3D_CS_OP_DISPATCH;
op->parameters.indirect = TRUE;
......@@ -1037,6 +1042,7 @@ void CDECL wined3d_device_context_dispatch_indirect(struct wined3d_device_contex
wined3d_device_context_acquire_resource(context, &buffer->resource);
wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT);
wined3d_mutex_unlock();
}
static void wined3d_cs_exec_draw(struct wined3d_cs *cs, const void *data)
......@@ -1193,6 +1199,7 @@ void CDECL wined3d_device_context_draw_indirect(struct wined3d_device_context *c
const struct wined3d_state *state = context->state;
struct wined3d_cs_draw *op;
wined3d_mutex_lock();
op = wined3d_device_context_require_space(context, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT);
op->opcode = WINED3D_CS_OP_DRAW;
op->primitive_type = state->primitive_type;
......@@ -1206,6 +1213,7 @@ void CDECL wined3d_device_context_draw_indirect(struct wined3d_device_context *c
wined3d_device_context_acquire_resource(context, &buffer->resource);
wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT);
wined3d_mutex_unlock();
}
static void wined3d_cs_exec_flush(struct wined3d_cs *cs, const void *data)
......@@ -3733,6 +3741,7 @@ HRESULT CDECL wined3d_deferred_context_record_command_list(struct wined3d_device
TRACE("context %p, list %p.\n", context, list);
wined3d_mutex_lock();
memory = heap_alloc(sizeof(*object) + deferred->resource_count * sizeof(*object->resources)
+ deferred->upload_count * sizeof(*object->uploads)
+ deferred->command_list_count * sizeof(*object->command_lists)
......@@ -3740,7 +3749,10 @@ HRESULT CDECL wined3d_deferred_context_record_command_list(struct wined3d_device
+ deferred->data_size);
if (!memory)
{
wined3d_mutex_unlock();
return E_OUTOFMEMORY;
}
object = memory;
memory = &object[1];
......@@ -3791,6 +3803,7 @@ HRESULT CDECL wined3d_deferred_context_record_command_list(struct wined3d_device
TRACE("Created command list %p.\n", object);
*list = object;
wined3d_mutex_unlock();
return S_OK;
}
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