Signed-off-by: Jan Sikorski jsikorski@codeweavers.com --- dlls/wined3d/cs.c | 13 +++++ dlls/wined3d/device.c | 123 +++++++++++++++++++++++++++++++++++------- 2 files changed, 118 insertions(+), 18 deletions(-)
diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c index 576a3ccd50e..1b4ed519260 100644 --- a/dlls/wined3d/cs.c +++ b/dlls/wined3d/cs.c @@ -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; } diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 71b1e3c3f88..8020f7d0844 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -1649,9 +1649,11 @@ void CDECL wined3d_device_context_reset_state(struct wined3d_device_context *con { TRACE("context %p.\n", context);
+ wined3d_mutex_lock(); state_cleanup(context->state); wined3d_state_reset(context->state, &context->device->adapter->d3d_info); wined3d_device_context_emit_reset_state(context, true); + wined3d_mutex_unlock(); }
void CDECL wined3d_device_context_set_state(struct wined3d_device_context *context, struct wined3d_state *state) @@ -1661,6 +1663,7 @@ void CDECL wined3d_device_context_set_state(struct wined3d_device_context *conte
TRACE("context %p, state %p.\n", context, state);
+ wined3d_mutex_lock(); context->state = state; wined3d_device_context_emit_set_feature_level(context, state->feature_level);
@@ -1757,6 +1760,7 @@ void CDECL wined3d_device_context_set_state(struct wined3d_device_context *conte wined3d_device_context_emit_set_blend_state(context, state->blend_state, &state->blend_factor, state->sample_mask); wined3d_device_context_emit_set_depth_stencil_state(context, state->depth_stencil_state, state->stencil_ref); wined3d_device_context_emit_set_rasterizer_state(context, state->rasterizer_state); + wined3d_mutex_unlock(); }
struct wined3d_state * CDECL wined3d_device_get_state(struct wined3d_device *device) @@ -1789,9 +1793,10 @@ void CDECL wined3d_device_context_set_shader(struct wined3d_device_context *cont
TRACE("context %p, type %#x, shader %p.\n", context, type, shader);
+ wined3d_mutex_lock(); prev = state->shader[type]; if (shader == prev) - return; + goto out;
if (shader) wined3d_shader_incref(shader); @@ -1799,6 +1804,8 @@ void CDECL wined3d_device_context_set_shader(struct wined3d_device_context *cont wined3d_device_context_emit_set_shader(context, type, shader); if (prev) wined3d_shader_decref(prev); +out: + wined3d_mutex_unlock(); }
struct wined3d_shader * CDECL wined3d_device_context_get_shader(const struct wined3d_device_context *context, @@ -1824,8 +1831,9 @@ void CDECL wined3d_device_context_set_constant_buffers(struct wined3d_device_con return; }
+ wined3d_mutex_lock(); if (!memcmp(buffers, &state->cb[type][start_idx], count * sizeof(*buffers))) - return; + goto out;
wined3d_device_context_emit_set_constant_buffers(context, type, start_idx, count, buffers); for (i = 0; i < count; ++i) @@ -1839,6 +1847,8 @@ void CDECL wined3d_device_context_set_constant_buffers(struct wined3d_device_con if (prev) wined3d_buffer_decref(prev); } +out: + wined3d_mutex_unlock(); }
void CDECL wined3d_device_context_set_blend_state(struct wined3d_device_context *context, @@ -1850,10 +1860,11 @@ void CDECL wined3d_device_context_set_blend_state(struct wined3d_device_context TRACE("context %p, blend_state %p, blend_factor %p, sample_mask %#x.\n", context, blend_state, blend_factor, sample_mask);
+ wined3d_mutex_lock(); prev = state->blend_state; if (prev == blend_state && !memcmp(blend_factor, &state->blend_factor, sizeof(*blend_factor)) && sample_mask == state->sample_mask) - return; + goto out;
if (blend_state) wined3d_blend_state_incref(blend_state); @@ -1863,6 +1874,8 @@ void CDECL wined3d_device_context_set_blend_state(struct wined3d_device_context wined3d_device_context_emit_set_blend_state(context, blend_state, blend_factor, sample_mask); if (prev) wined3d_blend_state_decref(prev); +out: + wined3d_mutex_unlock(); }
void CDECL wined3d_device_context_set_depth_stencil_state(struct wined3d_device_context *context, @@ -1873,9 +1886,10 @@ void CDECL wined3d_device_context_set_depth_stencil_state(struct wined3d_device_
TRACE("context %p, depth_stencil_state %p, stencil_ref %u.\n", context, depth_stencil_state, stencil_ref);
+ wined3d_mutex_lock(); prev = state->depth_stencil_state; if (prev == depth_stencil_state && state->stencil_ref == stencil_ref) - return; + goto out;
if (depth_stencil_state) wined3d_depth_stencil_state_incref(depth_stencil_state); @@ -1884,6 +1898,8 @@ void CDECL wined3d_device_context_set_depth_stencil_state(struct wined3d_device_ wined3d_device_context_emit_set_depth_stencil_state(context, depth_stencil_state, stencil_ref); if (prev) wined3d_depth_stencil_state_decref(prev); +out: + wined3d_mutex_unlock(); }
void CDECL wined3d_device_context_set_rasterizer_state(struct wined3d_device_context *context, @@ -1894,9 +1910,10 @@ void CDECL wined3d_device_context_set_rasterizer_state(struct wined3d_device_con
TRACE("context %p, rasterizer_state %p.\n", context, rasterizer_state);
+ wined3d_mutex_lock(); prev = state->rasterizer_state; if (prev == rasterizer_state) - return; + goto out;
if (rasterizer_state) wined3d_rasterizer_state_incref(rasterizer_state); @@ -1904,6 +1921,8 @@ void CDECL wined3d_device_context_set_rasterizer_state(struct wined3d_device_con wined3d_device_context_emit_set_rasterizer_state(context, rasterizer_state); if (prev) wined3d_rasterizer_state_decref(prev); +out: + wined3d_mutex_unlock(); }
void CDECL wined3d_device_context_set_viewports(struct wined3d_device_context *context, unsigned int viewport_count, @@ -1920,6 +1939,7 @@ void CDECL wined3d_device_context_set_viewports(struct wined3d_device_context *c viewports[i].width, viewports[i].height, viewports[i].min_z, viewports[i].max_z); }
+ wined3d_mutex_lock(); if (viewport_count) memcpy(state->viewports, viewports, viewport_count * sizeof(*viewports)); else @@ -1927,6 +1947,7 @@ void CDECL wined3d_device_context_set_viewports(struct wined3d_device_context *c state->viewport_count = viewport_count;
wined3d_device_context_emit_set_viewports(context, viewport_count, viewports); + wined3d_mutex_unlock(); }
void CDECL wined3d_device_context_set_scissor_rects(struct wined3d_device_context *context, unsigned int rect_count, @@ -1942,11 +1963,12 @@ void CDECL wined3d_device_context_set_scissor_rects(struct wined3d_device_contex TRACE("%u: %s\n", i, wine_dbgstr_rect(&rects[i])); }
+ wined3d_mutex_lock(); if (state->scissor_rect_count == rect_count && !memcmp(state->scissor_rects, rects, rect_count * sizeof(*rects))) { TRACE("App is setting the old scissor rectangles over, nothing to do.\n"); - return; + goto out; }
if (rect_count) @@ -1956,6 +1978,8 @@ void CDECL wined3d_device_context_set_scissor_rects(struct wined3d_device_contex state->scissor_rect_count = rect_count;
wined3d_device_context_emit_set_scissor_rects(context, rect_count, rects); +out: + wined3d_mutex_unlock(); }
void CDECL wined3d_device_context_set_shader_resource_views(struct wined3d_device_context *context, @@ -1975,8 +1999,9 @@ void CDECL wined3d_device_context_set_shader_resource_views(struct wined3d_devic return; }
+ wined3d_mutex_lock(); if (!memcmp(views, &state->shader_resource_view[type][start_idx], count * sizeof(*views))) - return; + goto out;
memcpy(real_views, views, count * sizeof(*views));
@@ -2011,6 +2036,8 @@ void CDECL wined3d_device_context_set_shader_resource_views(struct wined3d_devic wined3d_shader_resource_view_decref(prev); } } +out: + wined3d_mutex_unlock(); }
void CDECL wined3d_device_context_set_samplers(struct wined3d_device_context *context, enum wined3d_shader_type type, @@ -2027,8 +2054,9 @@ void CDECL wined3d_device_context_set_samplers(struct wined3d_device_context *co return; }
+ wined3d_mutex_lock(); if (!memcmp(samplers, &state->sampler[type][start_idx], count * sizeof(*samplers))) - return; + goto out;
wined3d_device_context_emit_set_samplers(context, type, start_idx, count, samplers); for (i = 0; i < count; ++i) @@ -2042,6 +2070,8 @@ void CDECL wined3d_device_context_set_samplers(struct wined3d_device_context *co if (prev) wined3d_sampler_decref(prev); } +out: + wined3d_mutex_unlock(); }
void CDECL wined3d_device_context_set_unordered_access_views(struct wined3d_device_context *context, @@ -2060,8 +2090,9 @@ void CDECL wined3d_device_context_set_unordered_access_views(struct wined3d_devi return; }
+ wined3d_mutex_lock(); if (!memcmp(uavs, &state->unordered_access_view[pipeline][start_idx], count * sizeof(*uavs)) && !initial_counts) - return; + goto out;
wined3d_device_context_emit_set_unordered_access_views(context, pipeline, start_idx, count, uavs, initial_counts); for (i = 0; i < count; ++i) @@ -2075,6 +2106,8 @@ void CDECL wined3d_device_context_set_unordered_access_views(struct wined3d_devi if (prev) wined3d_unordered_access_view_decref(prev); } +out: + wined3d_mutex_unlock(); }
static void wined3d_device_context_unbind_srv_for_rtv(struct wined3d_device_context *context, @@ -2136,6 +2169,7 @@ HRESULT CDECL wined3d_device_context_set_rendertarget_views(struct wined3d_devic } }
+ wined3d_mutex_lock(); /* Set the viewport and scissor rectangles, if requested. Tests show that * stateblock recording is ignored, the change goes directly into the * primary stateblock. */ @@ -2156,7 +2190,7 @@ HRESULT CDECL wined3d_device_context_set_rendertarget_views(struct wined3d_devic }
if (!memcmp(views, &state->fb.render_targets[start_idx], count * sizeof(*views))) - return WINED3D_OK; + goto out;
wined3d_device_context_emit_set_rendertarget_views(context, start_idx, count, views); for (i = 0; i < count; ++i) @@ -2180,7 +2214,8 @@ HRESULT CDECL wined3d_device_context_set_rendertarget_views(struct wined3d_devic
wined3d_device_context_unbind_srv_for_rtv(context, view, FALSE); } - +out: + wined3d_mutex_unlock(); return WINED3D_OK; }
@@ -2199,11 +2234,12 @@ HRESULT CDECL wined3d_device_context_set_depth_stencil_view(struct wined3d_devic return WINED3DERR_INVALIDCALL; }
+ wined3d_mutex_lock(); prev = fb->depth_stencil; if (prev == view) { TRACE("Trying to do a NOP SetRenderTarget operation.\n"); - return WINED3D_OK; + goto out; }
if ((fb->depth_stencil = view)) @@ -2212,7 +2248,8 @@ HRESULT CDECL wined3d_device_context_set_depth_stencil_view(struct wined3d_devic if (prev) wined3d_rendertarget_view_decref(prev); wined3d_device_context_unbind_srv_for_rtv(context, view, TRUE); - +out: + wined3d_mutex_unlock(); return WINED3D_OK; }
@@ -2224,6 +2261,7 @@ void CDECL wined3d_device_context_set_predication(struct wined3d_device_context
TRACE("context %p, predicate %p, value %#x.\n", context, predicate, value);
+ wined3d_mutex_lock(); prev = state->predicate; if (predicate) { @@ -2235,6 +2273,7 @@ void CDECL wined3d_device_context_set_predication(struct wined3d_device_context wined3d_device_context_emit_set_predication(context, predicate, value); if (prev) wined3d_query_decref(prev); + wined3d_mutex_unlock(); }
HRESULT CDECL wined3d_device_context_set_stream_sources(struct wined3d_device_context *context, @@ -2262,8 +2301,9 @@ HRESULT CDECL wined3d_device_context_set_stream_sources(struct wined3d_device_co } }
+ wined3d_mutex_lock(); if (!memcmp(streams, &state->streams[start_idx], count * sizeof(*streams))) - return WINED3D_OK; + goto out;
wined3d_device_context_emit_set_stream_sources(context, start_idx, count, streams); for (i = 0; i < count; ++i) @@ -2278,7 +2318,8 @@ HRESULT CDECL wined3d_device_context_set_stream_sources(struct wined3d_device_co if (prev) wined3d_buffer_decref(prev); } - +out: + wined3d_mutex_unlock(); return WINED3D_OK; }
@@ -2293,12 +2334,13 @@ void CDECL wined3d_device_context_set_index_buffer(struct wined3d_device_context TRACE("context %p, buffer %p, format %s, offset %u.\n", context, buffer, debug_d3dformat(format_id), offset);
+ wined3d_mutex_lock(); prev_buffer = state->index_buffer; prev_format = state->index_format; prev_offset = state->index_offset;
if (prev_buffer == buffer && prev_format == format_id && prev_offset == offset) - return; + goto out;
if (buffer) wined3d_buffer_incref(buffer); @@ -2308,6 +2350,8 @@ void CDECL wined3d_device_context_set_index_buffer(struct wined3d_device_context wined3d_device_context_emit_set_index_buffer(context, buffer, format_id, offset); if (prev_buffer) wined3d_buffer_decref(prev_buffer); +out: + wined3d_mutex_unlock(); }
void CDECL wined3d_device_context_set_vertex_declaration(struct wined3d_device_context *context, @@ -2318,9 +2362,10 @@ void CDECL wined3d_device_context_set_vertex_declaration(struct wined3d_device_c
TRACE("context %p, declaration %p.\n", context, declaration);
+ wined3d_mutex_lock(); prev = state->vertex_declaration; if (declaration == prev) - return; + goto out;
if (declaration) wined3d_vertex_declaration_incref(declaration); @@ -2328,6 +2373,8 @@ void CDECL wined3d_device_context_set_vertex_declaration(struct wined3d_device_c wined3d_device_context_emit_set_vertex_declaration(context, declaration); if (prev) wined3d_vertex_declaration_decref(prev); +out: + wined3d_mutex_unlock(); }
void CDECL wined3d_device_context_set_stream_outputs(struct wined3d_device_context *context, @@ -2338,6 +2385,7 @@ void CDECL wined3d_device_context_set_stream_outputs(struct wined3d_device_conte
TRACE("context %p, outputs %p.\n", context, outputs);
+ wined3d_mutex_lock(); wined3d_device_context_emit_set_stream_outputs(context, outputs); for (i = 0; i < WINED3D_MAX_STREAM_OUTPUT_BUFFERS; ++i) { @@ -2350,6 +2398,7 @@ void CDECL wined3d_device_context_set_stream_outputs(struct wined3d_device_conte if (prev_buffer) wined3d_buffer_decref(prev_buffer); } + wined3d_mutex_unlock(); }
void CDECL wined3d_device_context_draw(struct wined3d_device_context *context, unsigned int start_vertex, @@ -2360,8 +2409,10 @@ void CDECL wined3d_device_context_draw(struct wined3d_device_context *context, u TRACE("context %p, start_vertex %u, vertex_count %u, start_instance %u, instance_count %u.\n", context, start_vertex, vertex_count, start_instance, instance_count);
+ wined3d_mutex_lock(); wined3d_device_context_emit_draw(context, state->primitive_type, state->patch_vertex_count, 0, start_vertex, vertex_count, start_instance, instance_count, false); + wined3d_mutex_unlock(); }
void CDECL wined3d_device_context_draw_indexed(struct wined3d_device_context *context, int base_vertex_index, @@ -2372,8 +2423,10 @@ void CDECL wined3d_device_context_draw_indexed(struct wined3d_device_context *co TRACE("context %p, base_vertex_index %d, start_index %u, index_count %u, start_instance %u, instance_count %u.\n", context, base_vertex_index, start_index, index_count, start_instance, instance_count);
+ wined3d_mutex_lock(); wined3d_device_context_emit_draw(context, state->primitive_type, state->patch_vertex_count, base_vertex_index, start_index, index_count, start_instance, instance_count, true); + wined3d_mutex_unlock(); }
void CDECL wined3d_device_context_get_constant_buffer(const struct wined3d_device_context *context, @@ -4066,8 +4119,10 @@ void CDECL wined3d_device_context_set_primitive_type(struct wined3d_device_conte TRACE("context %p, primitive_type %s, patch_vertex_count %u.\n", context, debug_d3dprimitivetype(primitive_type), patch_vertex_count);
+ wined3d_mutex_lock(); state->primitive_type = primitive_type; state->patch_vertex_count = patch_vertex_count; + wined3d_mutex_unlock(); }
void CDECL wined3d_device_context_get_primitive_type(const struct wined3d_device_context *context, @@ -4385,7 +4440,9 @@ void CDECL wined3d_device_context_copy_uav_counter(struct wined3d_device_context TRACE("context %p, dst_buffer %p, offset %u, uav %p.\n", context, dst_buffer, offset, uav);
+ wined3d_mutex_lock(); wined3d_device_context_emit_copy_uav_counter(context, dst_buffer, offset, uav); + wined3d_mutex_unlock(); }
static bool resources_format_compatible(const struct wined3d_resource *src_resource, @@ -4460,8 +4517,10 @@ void CDECL wined3d_device_context_copy_resource(struct wined3d_device_context *c if (dst_resource->type == WINED3D_RTYPE_BUFFER) { wined3d_box_set(&src_box, 0, 0, src_resource->size, 1, 0, 1); + wined3d_mutex_lock(); wined3d_device_context_emit_blt_sub_resource(context, dst_resource, 0, &src_box, src_resource, 0, &src_box, WINED3D_BLT_RAW, NULL, WINED3D_TEXF_POINT); + wined3d_mutex_unlock(); return; }
@@ -4477,6 +4536,7 @@ void CDECL wined3d_device_context_copy_resource(struct wined3d_device_context *c return; }
+ wined3d_mutex_lock(); for (i = 0; i < dst_texture->level_count; ++i) { wined3d_texture_get_level_box(src_texture, i, &src_box); @@ -4489,6 +4549,7 @@ void CDECL wined3d_device_context_copy_resource(struct wined3d_device_context *c src_resource, idx, &src_box, WINED3D_BLT_RAW, NULL, WINED3D_TEXF_POINT); } } + wined3d_mutex_unlock(); }
HRESULT CDECL wined3d_device_context_copy_sub_resource_region(struct wined3d_device_context *context, @@ -4645,8 +4706,10 @@ HRESULT CDECL wined3d_device_context_copy_sub_resource_region(struct wined3d_dev } }
+ wined3d_mutex_lock(); wined3d_device_context_emit_blt_sub_resource(context, dst_resource, dst_sub_resource_idx, &dst_box, src_resource, src_sub_resource_idx, src_box, WINED3D_BLT_RAW, NULL, WINED3D_TEXF_POINT); + wined3d_mutex_unlock();
return WINED3D_OK; } @@ -4686,8 +4749,10 @@ void CDECL wined3d_device_context_update_sub_resource(struct wined3d_device_cont return; }
+ wined3d_mutex_lock(); wined3d_device_context_emit_update_sub_resource(context, resource, sub_resource_idx, box, data, row_pitch, depth_pitch); + wined3d_mutex_unlock(); }
void CDECL wined3d_device_context_resolve_sub_resource(struct wined3d_device_context *context, @@ -4724,6 +4789,7 @@ void CDECL wined3d_device_context_resolve_sub_resource(struct wined3d_device_con return; }
+ wined3d_mutex_lock(); fx.resolve_format_id = format_id;
dst_texture = texture_from_resource(dst_resource); @@ -4737,6 +4803,7 @@ void CDECL wined3d_device_context_resolve_sub_resource(struct wined3d_device_con wined3d_texture_get_level_height(src_texture, src_level)); wined3d_device_context_blt(context, dst_texture, dst_sub_resource_idx, &dst_rect, src_texture, src_sub_resource_idx, &src_rect, 0, &fx, WINED3D_TEXF_POINT); + wined3d_mutex_unlock(); }
HRESULT CDECL wined3d_device_context_clear_rendertarget_view(struct wined3d_device_context *context, @@ -4773,7 +4840,9 @@ HRESULT CDECL wined3d_device_context_clear_rendertarget_view(struct wined3d_devi return hr; }
+ wined3d_mutex_lock(); wined3d_device_context_emit_clear_rendertarget_view(context, view, rect, flags, color, depth, stencil); + wined3d_mutex_unlock();
return WINED3D_OK; } @@ -4789,7 +4858,9 @@ void CDECL wined3d_device_context_clear_uav_float(struct wined3d_device_context return; }
+ wined3d_mutex_lock(); wined3d_device_context_emit_clear_uav(context, view, (const struct wined3d_uvec4 *)clear_value, true); + wined3d_mutex_unlock(); }
void CDECL wined3d_device_context_clear_uav_uint(struct wined3d_device_context *context, @@ -4797,7 +4868,9 @@ void CDECL wined3d_device_context_clear_uav_uint(struct wined3d_device_context * { TRACE("context %p, view %p, clear_value %s.\n", context, view, debug_uvec4(clear_value));
+ wined3d_mutex_lock(); wined3d_device_context_emit_clear_uav(context, view, clear_value, false); + wined3d_mutex_unlock(); }
static unsigned int sanitise_map_flags(const struct wined3d_resource *resource, unsigned int flags) @@ -4885,19 +4958,25 @@ HRESULT CDECL wined3d_device_context_map(struct wined3d_device_context *context, return WINED3DERR_INVALIDCALL; }
+ wined3d_mutex_lock(); if (SUCCEEDED(hr = wined3d_device_context_emit_map(context, resource, sub_resource_idx, &map_desc->data, box, flags))) wined3d_resource_get_sub_resource_map_pitch(resource, sub_resource_idx, &map_desc->row_pitch, &map_desc->slice_pitch); + wined3d_mutex_unlock(); return hr; }
HRESULT CDECL wined3d_device_context_unmap(struct wined3d_device_context *context, struct wined3d_resource *resource, unsigned int sub_resource_idx) { + HRESULT hr; TRACE("context %p, resource %p, sub_resource_idx %u.\n", context, resource, sub_resource_idx);
- return wined3d_device_context_emit_unmap(context, resource, sub_resource_idx); + wined3d_mutex_lock(); + hr = wined3d_device_context_emit_unmap(context, resource, sub_resource_idx); + wined3d_mutex_unlock(); + return hr; }
void CDECL wined3d_device_context_issue_query(struct wined3d_device_context *context, @@ -4905,7 +4984,9 @@ void CDECL wined3d_device_context_issue_query(struct wined3d_device_context *con { TRACE("context %p, query %p, flags %#x.\n", context, query, flags);
+ wined3d_mutex_lock(); context->ops->issue_query(context, query, flags); + wined3d_mutex_unlock(); }
void CDECL wined3d_device_context_execute_command_list(struct wined3d_device_context *context, @@ -4913,7 +4994,9 @@ void CDECL wined3d_device_context_execute_command_list(struct wined3d_device_con { TRACE("context %p, list %p, restore_state %d.\n", context, list, restore_state);
+ wined3d_mutex_lock(); wined3d_device_context_emit_execute_command_list(context, list, restore_state); + wined3d_mutex_unlock(); }
struct wined3d_rendertarget_view * CDECL wined3d_device_context_get_rendertarget_view( @@ -4961,7 +5044,9 @@ void CDECL wined3d_device_context_generate_mipmaps(struct wined3d_device_context return; }
+ wined3d_mutex_lock(); wined3d_device_context_emit_generate_mipmaps(context, view); + wined3d_mutex_unlock(); }
static struct wined3d_texture *wined3d_device_create_cursor_texture(struct wined3d_device *device, @@ -5185,7 +5270,9 @@ void CDECL wined3d_device_context_flush(struct wined3d_device_context *context) { TRACE("context %p.\n", context);
+ wined3d_mutex_lock(); context->ops->flush(context); + wined3d_mutex_unlock(); }
static void update_swapchain_flags(struct wined3d_texture *texture)