Signed-off-by: Jan Sikorski jsikorski@codeweavers.com --- dlls/wined3d/cs.c | 23 +++-- dlls/wined3d/device.c | 148 ++++++++++++++++----------------- dlls/wined3d/wined3d_private.h | 17 ++++ 3 files changed, 105 insertions(+), 83 deletions(-)
diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c index 529ab4fd159..0179d18cf2d 100644 --- a/dlls/wined3d/cs.c +++ b/dlls/wined3d/cs.c @@ -1012,7 +1012,7 @@ void CDECL wined3d_device_context_dispatch(struct wined3d_device_context *contex { struct wined3d_cs_dispatch *op;
- wined3d_mutex_lock(); + wined3d_device_context_lock(context); op = wined3d_device_context_require_space(context, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT); op->opcode = WINED3D_CS_OP_DISPATCH; op->parameters.indirect = FALSE; @@ -1023,7 +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(); + wined3d_device_context_unlock(context); }
void CDECL wined3d_device_context_dispatch_indirect(struct wined3d_device_context *context, @@ -1031,7 +1031,7 @@ void CDECL wined3d_device_context_dispatch_indirect(struct wined3d_device_contex { struct wined3d_cs_dispatch *op;
- wined3d_mutex_lock(); + wined3d_device_context_lock(context); op = wined3d_device_context_require_space(context, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT); op->opcode = WINED3D_CS_OP_DISPATCH; op->parameters.indirect = TRUE; @@ -1042,7 +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(); + wined3d_device_context_unlock(context); }
static void wined3d_cs_exec_draw(struct wined3d_cs *cs, const void *data) @@ -1199,7 +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(); + wined3d_device_context_lock(context); 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; @@ -1213,7 +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(); + wined3d_device_context_unlock(context); }
static void wined3d_cs_exec_flush(struct wined3d_cs *cs, const void *data) @@ -3445,6 +3445,7 @@ void wined3d_cs_destroy(struct wined3d_cs *cs) struct wined3d_deferred_context { struct wined3d_device_context c; + CRITICAL_SECTION lock;
SIZE_T data_size, data_capacity; void *data; @@ -3688,8 +3689,10 @@ HRESULT CDECL wined3d_deferred_context_create(struct wined3d_device *device, str return hr; }
+ InitializeCriticalSection(&object->lock); object->c.ops = &wined3d_deferred_context_ops; object->c.device = device; + object->c.lock = &object->lock;
/* Make sure the first command list gets the state reset when executed. * Resets for subsequent command lists are encoded in wined3d_deferred_context_record_command_list(). */ @@ -3729,6 +3732,8 @@ void CDECL wined3d_deferred_context_destroy(struct wined3d_device_context *conte
wined3d_state_destroy(deferred->c.state); heap_free(deferred->data); + + DeleteCriticalSection(&deferred->lock); heap_free(deferred); }
@@ -3741,7 +3746,7 @@ HRESULT CDECL wined3d_deferred_context_record_command_list(struct wined3d_device
TRACE("context %p, list %p.\n", context, list);
- wined3d_mutex_lock(); + wined3d_device_context_lock(context); 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) @@ -3750,7 +3755,7 @@ HRESULT CDECL wined3d_deferred_context_record_command_list(struct wined3d_device
if (!memory) { - wined3d_mutex_unlock(); + wined3d_device_context_unlock(context); return E_OUTOFMEMORY; }
@@ -3803,7 +3808,7 @@ HRESULT CDECL wined3d_deferred_context_record_command_list(struct wined3d_device
TRACE("Created command list %p.\n", object); *list = object; - wined3d_mutex_unlock(); + wined3d_device_context_unlock(context);
return S_OK; } diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 3d3130777eb..188ecc5707e 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -1649,11 +1649,11 @@ void CDECL wined3d_device_context_reset_state(struct wined3d_device_context *con { TRACE("context %p.\n", context);
- wined3d_mutex_lock(); + wined3d_device_context_lock(context); 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(); + wined3d_device_context_unlock(context); }
void CDECL wined3d_device_context_set_state(struct wined3d_device_context *context, struct wined3d_state *state) @@ -1663,7 +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(); + wined3d_device_context_lock(context); context->state = state; wined3d_device_context_emit_set_feature_level(context, state->feature_level);
@@ -1760,7 +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(); + wined3d_device_context_unlock(context); }
struct wined3d_state * CDECL wined3d_device_get_state(struct wined3d_device *device) @@ -1793,7 +1793,7 @@ 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(); + wined3d_device_context_lock(context); prev = state->shader[type]; if (shader == prev) goto out; @@ -1805,7 +1805,7 @@ void CDECL wined3d_device_context_set_shader(struct wined3d_device_context *cont if (prev) wined3d_shader_decref(prev); out: - wined3d_mutex_unlock(); + wined3d_device_context_unlock(context); }
struct wined3d_shader * CDECL wined3d_device_context_get_shader(const struct wined3d_device_context *context, @@ -1831,7 +1831,7 @@ void CDECL wined3d_device_context_set_constant_buffers(struct wined3d_device_con return; }
- wined3d_mutex_lock(); + wined3d_device_context_lock(context); if (!memcmp(buffers, &state->cb[type][start_idx], count * sizeof(*buffers))) goto out;
@@ -1848,7 +1848,7 @@ void CDECL wined3d_device_context_set_constant_buffers(struct wined3d_device_con wined3d_buffer_decref(prev); } out: - wined3d_mutex_unlock(); + wined3d_device_context_unlock(context); }
void CDECL wined3d_device_context_set_blend_state(struct wined3d_device_context *context, @@ -1860,7 +1860,7 @@ 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(); + wined3d_device_context_lock(context); prev = state->blend_state; if (prev == blend_state && !memcmp(blend_factor, &state->blend_factor, sizeof(*blend_factor)) && sample_mask == state->sample_mask) @@ -1875,7 +1875,7 @@ void CDECL wined3d_device_context_set_blend_state(struct wined3d_device_context if (prev) wined3d_blend_state_decref(prev); out: - wined3d_mutex_unlock(); + wined3d_device_context_unlock(context); }
void CDECL wined3d_device_context_set_depth_stencil_state(struct wined3d_device_context *context, @@ -1886,7 +1886,7 @@ 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(); + wined3d_device_context_lock(context); prev = state->depth_stencil_state; if (prev == depth_stencil_state && state->stencil_ref == stencil_ref) goto out; @@ -1899,7 +1899,7 @@ void CDECL wined3d_device_context_set_depth_stencil_state(struct wined3d_device_ if (prev) wined3d_depth_stencil_state_decref(prev); out: - wined3d_mutex_unlock(); + wined3d_device_context_unlock(context); }
void CDECL wined3d_device_context_set_rasterizer_state(struct wined3d_device_context *context, @@ -1910,7 +1910,7 @@ 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(); + wined3d_device_context_lock(context); prev = state->rasterizer_state; if (prev == rasterizer_state) goto out; @@ -1922,7 +1922,7 @@ void CDECL wined3d_device_context_set_rasterizer_state(struct wined3d_device_con if (prev) wined3d_rasterizer_state_decref(prev); out: - wined3d_mutex_unlock(); + wined3d_device_context_unlock(context); }
void CDECL wined3d_device_context_set_viewports(struct wined3d_device_context *context, unsigned int viewport_count, @@ -1939,7 +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(); + wined3d_device_context_lock(context); if (viewport_count) memcpy(state->viewports, viewports, viewport_count * sizeof(*viewports)); else @@ -1947,7 +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(); + wined3d_device_context_unlock(context); }
void CDECL wined3d_device_context_set_scissor_rects(struct wined3d_device_context *context, unsigned int rect_count, @@ -1963,7 +1963,7 @@ 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(); + wined3d_device_context_lock(context); if (state->scissor_rect_count == rect_count && !memcmp(state->scissor_rects, rects, rect_count * sizeof(*rects))) { @@ -1979,7 +1979,7 @@ void CDECL wined3d_device_context_set_scissor_rects(struct wined3d_device_contex
wined3d_device_context_emit_set_scissor_rects(context, rect_count, rects); out: - wined3d_mutex_unlock(); + wined3d_device_context_unlock(context); }
void CDECL wined3d_device_context_set_shader_resource_views(struct wined3d_device_context *context, @@ -1999,7 +1999,7 @@ void CDECL wined3d_device_context_set_shader_resource_views(struct wined3d_devic return; }
- wined3d_mutex_lock(); + wined3d_device_context_lock(context); if (!memcmp(views, &state->shader_resource_view[type][start_idx], count * sizeof(*views))) goto out;
@@ -2037,7 +2037,7 @@ void CDECL wined3d_device_context_set_shader_resource_views(struct wined3d_devic } } out: - wined3d_mutex_unlock(); + wined3d_device_context_unlock(context); }
void CDECL wined3d_device_context_set_samplers(struct wined3d_device_context *context, enum wined3d_shader_type type, @@ -2054,7 +2054,7 @@ void CDECL wined3d_device_context_set_samplers(struct wined3d_device_context *co return; }
- wined3d_mutex_lock(); + wined3d_device_context_lock(context); if (!memcmp(samplers, &state->sampler[type][start_idx], count * sizeof(*samplers))) goto out;
@@ -2071,7 +2071,7 @@ void CDECL wined3d_device_context_set_samplers(struct wined3d_device_context *co wined3d_sampler_decref(prev); } out: - wined3d_mutex_unlock(); + wined3d_device_context_unlock(context); }
void CDECL wined3d_device_context_set_unordered_access_views(struct wined3d_device_context *context, @@ -2090,7 +2090,7 @@ void CDECL wined3d_device_context_set_unordered_access_views(struct wined3d_devi return; }
- wined3d_mutex_lock(); + wined3d_device_context_lock(context); if (!memcmp(uavs, &state->unordered_access_view[pipeline][start_idx], count * sizeof(*uavs)) && !initial_counts) goto out;
@@ -2107,7 +2107,7 @@ void CDECL wined3d_device_context_set_unordered_access_views(struct wined3d_devi wined3d_unordered_access_view_decref(prev); } out: - wined3d_mutex_unlock(); + wined3d_device_context_unlock(context); }
static void wined3d_device_context_unbind_srv_for_rtv(struct wined3d_device_context *context, @@ -2169,7 +2169,7 @@ HRESULT CDECL wined3d_device_context_set_rendertarget_views(struct wined3d_devic } }
- wined3d_mutex_lock(); + wined3d_device_context_lock(context); /* Set the viewport and scissor rectangles, if requested. Tests show that * stateblock recording is ignored, the change goes directly into the * primary stateblock. */ @@ -2215,7 +2215,7 @@ 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(); + wined3d_device_context_unlock(context); return WINED3D_OK; }
@@ -2234,7 +2234,7 @@ HRESULT CDECL wined3d_device_context_set_depth_stencil_view(struct wined3d_devic return WINED3DERR_INVALIDCALL; }
- wined3d_mutex_lock(); + wined3d_device_context_lock(context); prev = fb->depth_stencil; if (prev == view) { @@ -2249,7 +2249,7 @@ HRESULT CDECL wined3d_device_context_set_depth_stencil_view(struct wined3d_devic wined3d_rendertarget_view_decref(prev); wined3d_device_context_unbind_srv_for_rtv(context, view, TRUE); out: - wined3d_mutex_unlock(); + wined3d_device_context_unlock(context); return WINED3D_OK; }
@@ -2261,7 +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(); + wined3d_device_context_lock(context); prev = state->predicate; if (predicate) { @@ -2273,7 +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(); + wined3d_device_context_unlock(context); }
HRESULT CDECL wined3d_device_context_set_stream_sources(struct wined3d_device_context *context, @@ -2301,7 +2301,7 @@ HRESULT CDECL wined3d_device_context_set_stream_sources(struct wined3d_device_co } }
- wined3d_mutex_lock(); + wined3d_device_context_lock(context); if (!memcmp(streams, &state->streams[start_idx], count * sizeof(*streams))) goto out;
@@ -2319,7 +2319,7 @@ HRESULT CDECL wined3d_device_context_set_stream_sources(struct wined3d_device_co wined3d_buffer_decref(prev); } out: - wined3d_mutex_unlock(); + wined3d_device_context_unlock(context); return WINED3D_OK; }
@@ -2334,7 +2334,7 @@ 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(); + wined3d_device_context_lock(context); prev_buffer = state->index_buffer; prev_format = state->index_format; prev_offset = state->index_offset; @@ -2351,7 +2351,7 @@ void CDECL wined3d_device_context_set_index_buffer(struct wined3d_device_context if (prev_buffer) wined3d_buffer_decref(prev_buffer); out: - wined3d_mutex_unlock(); + wined3d_device_context_unlock(context); }
void CDECL wined3d_device_context_set_vertex_declaration(struct wined3d_device_context *context, @@ -2362,7 +2362,7 @@ void CDECL wined3d_device_context_set_vertex_declaration(struct wined3d_device_c
TRACE("context %p, declaration %p.\n", context, declaration);
- wined3d_mutex_lock(); + wined3d_device_context_lock(context); prev = state->vertex_declaration; if (declaration == prev) goto out; @@ -2374,7 +2374,7 @@ void CDECL wined3d_device_context_set_vertex_declaration(struct wined3d_device_c if (prev) wined3d_vertex_declaration_decref(prev); out: - wined3d_mutex_unlock(); + wined3d_device_context_unlock(context); }
void CDECL wined3d_device_context_set_stream_outputs(struct wined3d_device_context *context, @@ -2385,7 +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_lock(context); wined3d_device_context_emit_set_stream_outputs(context, outputs); for (i = 0; i < WINED3D_MAX_STREAM_OUTPUT_BUFFERS; ++i) { @@ -2398,7 +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(); + wined3d_device_context_unlock(context); }
void CDECL wined3d_device_context_draw(struct wined3d_device_context *context, unsigned int start_vertex, @@ -2409,10 +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_lock(context); 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(); + wined3d_device_context_unlock(context); }
void CDECL wined3d_device_context_draw_indexed(struct wined3d_device_context *context, int base_vertex_index, @@ -2423,10 +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_lock(context); 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(); + wined3d_device_context_unlock(context); }
void CDECL wined3d_device_context_get_constant_buffer(const struct wined3d_device_context *context, @@ -4119,10 +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(); + wined3d_device_context_lock(context); state->primitive_type = primitive_type; state->patch_vertex_count = patch_vertex_count; - wined3d_mutex_unlock(); + wined3d_device_context_unlock(context); }
void CDECL wined3d_device_context_get_primitive_type(const struct wined3d_device_context *context, @@ -4440,9 +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_lock(context); wined3d_device_context_emit_copy_uav_counter(context, dst_buffer, offset, uav); - wined3d_mutex_unlock(); + wined3d_device_context_unlock(context); }
static bool resources_format_compatible(const struct wined3d_resource *src_resource, @@ -4517,10 +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_lock(context); 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(); + wined3d_device_context_unlock(context); return; }
@@ -4536,7 +4536,7 @@ void CDECL wined3d_device_context_copy_resource(struct wined3d_device_context *c return; }
- wined3d_mutex_lock(); + wined3d_device_context_lock(context); for (i = 0; i < dst_texture->level_count; ++i) { wined3d_texture_get_level_box(src_texture, i, &src_box); @@ -4549,7 +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(); + wined3d_device_context_unlock(context); }
HRESULT CDECL wined3d_device_context_copy_sub_resource_region(struct wined3d_device_context *context, @@ -4706,10 +4706,10 @@ HRESULT CDECL wined3d_device_context_copy_sub_resource_region(struct wined3d_dev } }
- wined3d_mutex_lock(); + wined3d_device_context_lock(context); 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(); + wined3d_device_context_unlock(context);
return WINED3D_OK; } @@ -4749,10 +4749,10 @@ void CDECL wined3d_device_context_update_sub_resource(struct wined3d_device_cont return; }
- wined3d_mutex_lock(); + wined3d_device_context_lock(context); wined3d_device_context_emit_update_sub_resource(context, resource, sub_resource_idx, box, data, row_pitch, depth_pitch); - wined3d_mutex_unlock(); + wined3d_device_context_unlock(context); }
void CDECL wined3d_device_context_resolve_sub_resource(struct wined3d_device_context *context, @@ -4789,7 +4789,7 @@ void CDECL wined3d_device_context_resolve_sub_resource(struct wined3d_device_con return; }
- wined3d_mutex_lock(); + wined3d_device_context_lock(context); fx.resolve_format_id = format_id;
dst_texture = texture_from_resource(dst_resource); @@ -4803,7 +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(); + wined3d_device_context_unlock(context); }
HRESULT CDECL wined3d_device_context_clear_rendertarget_view(struct wined3d_device_context *context, @@ -4840,9 +4840,9 @@ HRESULT CDECL wined3d_device_context_clear_rendertarget_view(struct wined3d_devi return hr; }
- wined3d_mutex_lock(); + wined3d_device_context_lock(context); wined3d_device_context_emit_clear_rendertarget_view(context, view, rect, flags, color, depth, stencil); - wined3d_mutex_unlock(); + wined3d_device_context_unlock(context);
return WINED3D_OK; } @@ -4858,9 +4858,9 @@ void CDECL wined3d_device_context_clear_uav_float(struct wined3d_device_context return; }
- wined3d_mutex_lock(); + wined3d_device_context_lock(context); wined3d_device_context_emit_clear_uav(context, view, (const struct wined3d_uvec4 *)clear_value, true); - wined3d_mutex_unlock(); + wined3d_device_context_unlock(context); }
void CDECL wined3d_device_context_clear_uav_uint(struct wined3d_device_context *context, @@ -4868,9 +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_lock(context); wined3d_device_context_emit_clear_uav(context, view, clear_value, false); - wined3d_mutex_unlock(); + wined3d_device_context_unlock(context); }
static unsigned int sanitise_map_flags(const struct wined3d_resource *resource, unsigned int flags) @@ -4958,12 +4958,12 @@ HRESULT CDECL wined3d_device_context_map(struct wined3d_device_context *context, return WINED3DERR_INVALIDCALL; }
- wined3d_mutex_lock(); + wined3d_device_context_lock(context); 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(); + wined3d_device_context_unlock(context); return hr; }
@@ -4973,9 +4973,9 @@ HRESULT CDECL wined3d_device_context_unmap(struct wined3d_device_context *contex HRESULT hr; TRACE("context %p, resource %p, sub_resource_idx %u.\n", context, resource, sub_resource_idx);
- wined3d_mutex_lock(); + wined3d_device_context_lock(context); hr = wined3d_device_context_emit_unmap(context, resource, sub_resource_idx); - wined3d_mutex_unlock(); + wined3d_device_context_unlock(context); return hr; }
@@ -4984,9 +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(); + wined3d_device_context_lock(context); context->ops->issue_query(context, query, flags); - wined3d_mutex_unlock(); + wined3d_device_context_unlock(context); }
void CDECL wined3d_device_context_execute_command_list(struct wined3d_device_context *context, @@ -4994,9 +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_lock(context); wined3d_device_context_emit_execute_command_list(context, list, restore_state); - wined3d_mutex_unlock(); + wined3d_device_context_unlock(context); }
struct wined3d_rendertarget_view * CDECL wined3d_device_context_get_rendertarget_view( @@ -5044,9 +5044,9 @@ void CDECL wined3d_device_context_generate_mipmaps(struct wined3d_device_context return; }
- wined3d_mutex_lock(); + wined3d_device_context_lock(context); wined3d_device_context_emit_generate_mipmaps(context, view); - wined3d_mutex_unlock(); + wined3d_device_context_unlock(context); }
static struct wined3d_texture *wined3d_device_create_cursor_texture(struct wined3d_device *device, @@ -5270,9 +5270,9 @@ void CDECL wined3d_device_context_flush(struct wined3d_device_context *context) { TRACE("context %p.\n", context);
- wined3d_mutex_lock(); + wined3d_device_context_lock(context); context->ops->flush(context); - wined3d_mutex_unlock(); + wined3d_device_context_unlock(context); }
static void update_swapchain_flags(struct wined3d_texture *texture) diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index dbb49f7e104..3b9ff9af4b3 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -4793,8 +4793,25 @@ struct wined3d_device_context const struct wined3d_device_context_ops *ops; struct wined3d_device *device; struct wined3d_state *state; + CRITICAL_SECTION *lock; };
+static inline void wined3d_device_context_lock(struct wined3d_device_context *context) +{ + if (context->lock) + EnterCriticalSection(context->lock); + else + wined3d_mutex_lock(); +} + +static inline void wined3d_device_context_unlock(struct wined3d_device_context *context) +{ + if (context->lock) + LeaveCriticalSection(context->lock); + else + wined3d_mutex_unlock(); +} + struct wined3d_cs { struct wined3d_device_context c;