Signed-off-by: Jan Sikorski jsikorski@codeweavers.com --- dlls/wined3d/arb_program_shader.c | 2 +- dlls/wined3d/glsl_shader.c | 2 +- dlls/wined3d/surface.c | 2 +- dlls/wined3d/texture.c | 217 ++++++++++++++++-------------- dlls/wined3d/wined3d_private.h | 1 + 5 files changed, 117 insertions(+), 107 deletions(-)
diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c index eeb51448b01..31ca3fca853 100644 --- a/dlls/wined3d/arb_program_shader.c +++ b/dlls/wined3d/arb_program_shader.c @@ -7947,7 +7947,7 @@ static DWORD arbfp_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_bl context_gl->gl_info->gl_ops.gl.p_glFlush();
if (staging_texture) - wined3d_texture_decref(staging_texture); + wined3d_texture_destroy_temporary(staging_texture);
return dst_location; } diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index adfbf60e726..c38aadac39e 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -13276,7 +13276,7 @@ static DWORD glsl_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_bli gl_info->gl_ops.gl.p_glFlush();
if (staging_texture) - wined3d_texture_decref(staging_texture); + wined3d_texture_destroy_temporary(staging_texture);
return dst_location; } diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c index 8a4ca4f5781..68238c7bed3 100644 --- a/dlls/wined3d/surface.c +++ b/dlls/wined3d/surface.c @@ -1219,7 +1219,7 @@ release: dst_texture->swapchain->swapchain_ops->swapchain_frontbuffer_updated(dst_texture->swapchain); } if (converted_texture) - wined3d_texture_decref(converted_texture); + wined3d_texture_destroy_temporary(converted_texture); context_release(context);
return hr; diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c index 339bf4e205a..608348a377a 100644 --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c @@ -332,6 +332,116 @@ static bool fbo_blitter_supported(enum wined3d_blit_op blit_op, const struct win return true; }
+static void wined3d_texture_destroy_dc(void *object) +{ + const struct wined3d_texture_idx *idx = object; + D3DKMT_DESTROYDCFROMMEMORY destroy_desc; + struct wined3d_context *context; + struct wined3d_texture *texture; + struct wined3d_dc_info *dc_info; + struct wined3d_bo_address data; + unsigned int sub_resource_idx; + struct wined3d_device *device; + struct wined3d_range range; + NTSTATUS status; + + TRACE("texture %p, sub_resource_idx %u.\n", idx->texture, idx->sub_resource_idx); + + texture = idx->texture; + sub_resource_idx = idx->sub_resource_idx; + device = texture->resource.device; + dc_info = &texture->dc_info[sub_resource_idx]; + + if (!dc_info->dc) + { + ERR("Sub-resource {%p, %u} has no DC.\n", texture, sub_resource_idx); + return; + } + + TRACE("dc %p, bitmap %p.\n", dc_info->dc, dc_info->bitmap); + + destroy_desc.hDc = dc_info->dc; + destroy_desc.hBitmap = dc_info->bitmap; + if ((status = D3DKMTDestroyDCFromMemory(&destroy_desc))) + ERR("Failed to destroy dc, status %#x.\n", status); + dc_info->dc = NULL; + dc_info->bitmap = NULL; + + wined3d_texture_get_memory(texture, sub_resource_idx, &data, texture->resource.map_binding); + if (data.buffer_object) + { + context = context_acquire(device, NULL, 0); + range.offset = 0; + range.size = texture->sub_resources[sub_resource_idx].size; + wined3d_context_unmap_bo_address(context, &data, 1, &range); + context_release(context); + } +} + +static void wined3d_texture_destroy_object(void *object) +{ + struct wined3d_texture *texture = object; + struct wined3d_resource *resource; + struct wined3d_dc_info *dc_info; + unsigned int sub_count; + unsigned int i; + + TRACE("texture %p.\n", texture); + + resource = &texture->resource; + sub_count = texture->level_count * texture->layer_count; + + if ((dc_info = texture->dc_info)) + { + for (i = 0; i < sub_count; ++i) + { + if (dc_info[i].dc) + { + struct wined3d_texture_idx texture_idx = {texture, i}; + + wined3d_texture_destroy_dc(&texture_idx); + } + } + heap_free(dc_info); + } + + if (texture->overlay_info) + { + for (i = 0; i < sub_count; ++i) + { + struct wined3d_overlay_info *info = &texture->overlay_info[i]; + struct wined3d_overlay_info *overlay, *cur; + + list_remove(&info->entry); + LIST_FOR_EACH_ENTRY_SAFE(overlay, cur, &info->overlays, struct wined3d_overlay_info, entry) + { + list_remove(&overlay->entry); + } + } + heap_free(texture->overlay_info); + } + + if (texture->dirty_regions) + { + for (i = 0; i < texture->layer_count; ++i) + { + heap_free(texture->dirty_regions[i].boxes); + } + heap_free(texture->dirty_regions); + } + + resource->resource_ops->resource_unload(resource); +} + +void wined3d_texture_destroy_temporary(struct wined3d_texture *texture) +{ + assert(texture->resource.ref == 1); + wined3d_texture_destroy_object(texture); + wined3d_resource_free_sysmem(&texture->resource); + context_resource_released(texture->resource.device, &texture->resource); + heap_free(texture); +} + /* Blit between surface locations. Onscreen on different swapchains is not supported. * Depth / stencil is not supported. Context activation is done by the caller. */ static void texture2d_blt_fbo(struct wined3d_device *device, struct wined3d_context *context, @@ -571,10 +681,10 @@ static void texture2d_blt_fbo(struct wined3d_device *device, struct wined3d_cont
done: if (dst_texture != dst_save_texture) - wined3d_texture_decref(dst_texture); + wined3d_texture_destroy_temporary(dst_texture);
if (src_staging_texture) - wined3d_texture_decref(src_staging_texture); + wined3d_texture_destroy_temporary(src_staging_texture);
if (restore_texture) context_restore(context, restore_texture, restore_idx); @@ -1118,52 +1228,6 @@ static void wined3d_texture_create_dc(void *object) TRACE("Created DC %p, bitmap %p for texture %p, %u.\n", dc_info->dc, dc_info->bitmap, texture, sub_resource_idx); }
-static void wined3d_texture_destroy_dc(void *object) -{ - const struct wined3d_texture_idx *idx = object; - D3DKMT_DESTROYDCFROMMEMORY destroy_desc; - struct wined3d_context *context; - struct wined3d_texture *texture; - struct wined3d_dc_info *dc_info; - struct wined3d_bo_address data; - unsigned int sub_resource_idx; - struct wined3d_device *device; - struct wined3d_range range; - NTSTATUS status; - - TRACE("texture %p, sub_resource_idx %u.\n", idx->texture, idx->sub_resource_idx); - - texture = idx->texture; - sub_resource_idx = idx->sub_resource_idx; - device = texture->resource.device; - dc_info = &texture->dc_info[sub_resource_idx]; - - if (!dc_info->dc) - { - ERR("Sub-resource {%p, %u} has no DC.\n", texture, sub_resource_idx); - return; - } - - TRACE("dc %p, bitmap %p.\n", dc_info->dc, dc_info->bitmap); - - destroy_desc.hDc = dc_info->dc; - destroy_desc.hBitmap = dc_info->bitmap; - if ((status = D3DKMTDestroyDCFromMemory(&destroy_desc))) - ERR("Failed to destroy dc, status %#x.\n", status); - dc_info->dc = NULL; - dc_info->bitmap = NULL; - - wined3d_texture_get_memory(texture, sub_resource_idx, &data, texture->resource.map_binding); - if (data.buffer_object) - { - context = context_acquire(device, NULL, 0); - range.offset = 0; - range.size = texture->sub_resources[sub_resource_idx].size; - wined3d_context_unmap_bo_address(context, &data, 1, &range); - context_release(context); - } -} - void wined3d_texture_set_swapchain(struct wined3d_texture *texture, struct wined3d_swapchain *swapchain) { texture->swapchain = swapchain; @@ -1453,61 +1517,6 @@ ULONG CDECL wined3d_texture_incref(struct wined3d_texture *texture) return refcount; }
-static void wined3d_texture_destroy_object(void *object) -{ - struct wined3d_texture *texture = object; - struct wined3d_resource *resource; - struct wined3d_dc_info *dc_info; - unsigned int sub_count; - unsigned int i; - - TRACE("texture %p.\n", texture); - - resource = &texture->resource; - sub_count = texture->level_count * texture->layer_count; - - if ((dc_info = texture->dc_info)) - { - for (i = 0; i < sub_count; ++i) - { - if (dc_info[i].dc) - { - struct wined3d_texture_idx texture_idx = {texture, i}; - - wined3d_texture_destroy_dc(&texture_idx); - } - } - heap_free(dc_info); - } - - if (texture->overlay_info) - { - for (i = 0; i < sub_count; ++i) - { - struct wined3d_overlay_info *info = &texture->overlay_info[i]; - struct wined3d_overlay_info *overlay, *cur; - - list_remove(&info->entry); - LIST_FOR_EACH_ENTRY_SAFE(overlay, cur, &info->overlays, struct wined3d_overlay_info, entry) - { - list_remove(&overlay->entry); - } - } - heap_free(texture->overlay_info); - } - - if (texture->dirty_regions) - { - for (i = 0; i < texture->layer_count; ++i) - { - heap_free(texture->dirty_regions[i].boxes); - } - heap_free(texture->dirty_regions); - } - - resource->resource_ops->resource_unload(resource); -} - void wined3d_texture_cleanup(struct wined3d_texture *texture) { wined3d_cs_destroy_object(texture->resource.device->cs, wined3d_texture_destroy_object, texture); @@ -5961,7 +5970,7 @@ static DWORD ffp_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_blit (old_colour_key_flags & WINED3D_CKEY_SRC_BLT) ? &old_blt_key : NULL);
if (staging_texture) - wined3d_texture_decref(staging_texture); + wined3d_texture_destroy_temporary(staging_texture);
return dst_location; } diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 0c169ec344b..fe7a8dff55e 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -4462,6 +4462,7 @@ void wined3d_texture_upload_from_texture(struct wined3d_texture *dst_texture, un void wined3d_texture_validate_location(struct wined3d_texture *texture, unsigned int sub_resource_idx, DWORD location) DECLSPEC_HIDDEN; void wined3d_texture_clear_dirty_regions(struct wined3d_texture *texture) DECLSPEC_HIDDEN; +void wined3d_texture_destroy_temporary(struct wined3d_texture *texture) DECLSPEC_HIDDEN;
HRESULT wined3d_texture_no3d_init(struct wined3d_texture *texture_no3d, struct wined3d_device *device, const struct wined3d_resource_desc *desc, unsigned int layer_count, unsigned int level_count,
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)
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
On Thu, 7 Oct 2021 at 13:06, Jan Sikorski jsikorski@codeweavers.com wrote:
dlls/wined3d/cs.c | 13 +++++ dlls/wined3d/device.c | 123 +++++++++++++++++++++++++++++++++++------- 2 files changed, 118 insertions(+), 18 deletions(-)
This patch is fine, although the subject line seems slightly misleading. This takes care of setters and draws, etc., but not for example wined3d_device_context_get_index_buffer().
On 11 Oct 2021, at 17:40, Henri Verbeet hverbeet@gmail.com wrote:
On Thu, 7 Oct 2021 at 13:06, Jan Sikorski jsikorski@codeweavers.com wrote:
dlls/wined3d/cs.c | 13 +++++ dlls/wined3d/device.c | 123 +++++++++++++++++++++++++++++++++++------- 2 files changed, 118 insertions(+), 18 deletions(-)
This patch is fine, although the subject line seems slightly misleading. This takes care of setters and draws, etc., but not for example wined3d_device_context_get_index_buffer().
Hm, it is, though I'm not sure how to improve it much. (make _some_ procedures?) Maybe add a second line saying that getters remain externally synchronized for now. That was mostly to avoid exporting per context locks in the last patch, or moving array getter loops into wined3d, in this series.
- Jan
On Mon, 11 Oct 2021 at 17:59, Jan Sikorski jsikorski@codeweavers.com wrote:
On 11 Oct 2021, at 17:40, Henri Verbeet hverbeet@gmail.com wrote: This patch is fine, although the subject line seems slightly misleading. This takes care of setters and draws, etc., but not for example wined3d_device_context_get_index_buffer().
Hm, it is, though I'm not sure how to improve it much. (make _some_ procedures?) Maybe add a second line saying that getters remain externally synchronized for now. That was mostly to avoid exporting per context locks in the last patch, or moving array getter loops into wined3d, in this series.
Personally, I probably would have split the patch and done e.g. just setters in the first one. Adding a short note in the commit message also works. It's probably not worth worrying too much about though.
Signed-off-by: Jan Sikorski jsikorski@codeweavers.com --- dlls/wined3d/adapter_gl.c | 1 + dlls/wined3d/adapter_vk.c | 2 +- dlls/wined3d/device.c | 4 +--- dlls/wined3d/wined3d_private.h | 3 +-- 4 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/dlls/wined3d/adapter_gl.c b/dlls/wined3d/adapter_gl.c index bba728e2fb5..3a6ff54eec2 100644 --- a/dlls/wined3d/adapter_gl.c +++ b/dlls/wined3d/adapter_gl.c @@ -4575,6 +4575,7 @@ static void adapter_gl_uninit_3d(struct wined3d_device *device) { TRACE("device %p.\n", device);
+ wined3d_device_destroy_default_samplers(device); wined3d_cs_destroy_object(device->cs, wined3d_device_delete_opengl_contexts_cs, device); wined3d_cs_finish(device->cs, WINED3D_CS_QUEUE_DEFAULT); } diff --git a/dlls/wined3d/adapter_vk.c b/dlls/wined3d/adapter_vk.c index 91a6b92b4aa..5667cd8d0d3 100644 --- a/dlls/wined3d/adapter_vk.c +++ b/dlls/wined3d/adapter_vk.c @@ -748,7 +748,6 @@ static void adapter_vk_uninit_3d_cs(void *object) device->shader_backend->shader_free_private(device, &context_vk->c); wined3d_device_vk_destroy_null_views(device_vk, context_vk); wined3d_device_vk_destroy_null_resources(device_vk, context_vk); - wined3d_device_destroy_default_samplers(device, &context_vk->c); }
static void adapter_vk_uninit_3d(struct wined3d_device *device) @@ -761,6 +760,7 @@ static void adapter_vk_uninit_3d(struct wined3d_device *device) device_vk = wined3d_device_vk(device); context_vk = &device_vk->context_vk;
+ wined3d_device_destroy_default_samplers(device); wined3d_cs_destroy_object(device->cs, adapter_vk_uninit_3d_cs, device_vk); wined3d_cs_finish(device->cs, WINED3D_CS_QUEUE_DEFAULT);
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 8020f7d0844..436c4dfe854 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -572,8 +572,7 @@ void wined3d_device_create_default_samplers(struct wined3d_device *device, struc } }
-/* Context activation is done by the caller. */ -void wined3d_device_destroy_default_samplers(struct wined3d_device *device, struct wined3d_context *context) +void wined3d_device_destroy_default_samplers(struct wined3d_device *device) { wined3d_sampler_decref(device->default_sampler); device->default_sampler = NULL; @@ -982,7 +981,6 @@ void wined3d_device_delete_opengl_contexts_cs(void *object) device->blitter->ops->blitter_destroy(device->blitter, context); device->shader_backend->shader_free_private(device, context); wined3d_device_gl_destroy_dummy_textures(device_gl, context_gl); - wined3d_device_destroy_default_samplers(device, context); context_release(context);
while (device->context_count) diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index fe7a8dff55e..827ebbec773 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -3889,8 +3889,7 @@ void wined3d_device_create_default_samplers(struct wined3d_device *device, struct wined3d_context *context) DECLSPEC_HIDDEN; void wined3d_device_create_primary_opengl_context_cs(void *object) DECLSPEC_HIDDEN; void wined3d_device_delete_opengl_contexts_cs(void *object) DECLSPEC_HIDDEN; -void wined3d_device_destroy_default_samplers(struct wined3d_device *device, - struct wined3d_context *context) DECLSPEC_HIDDEN; +void wined3d_device_destroy_default_samplers(struct wined3d_device *device) DECLSPEC_HIDDEN; HRESULT wined3d_device_init(struct wined3d_device *device, struct wined3d *wined3d, unsigned int adapter_idx, enum wined3d_device_type device_type, HWND focus_window, unsigned int flags, BYTE surface_alignment, const enum wined3d_feature_level *levels, unsigned int level_count,
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
On Thu, 7 Oct 2021 at 13:06, Jan Sikorski jsikorski@codeweavers.com wrote:
dlls/wined3d/adapter_gl.c | 1 + dlls/wined3d/adapter_vk.c | 2 +- dlls/wined3d/device.c | 4 +--- dlls/wined3d/wined3d_private.h | 3 +-- 4 files changed, 4 insertions(+), 6 deletions(-)
This too could have done with a bit more of an explanation, although in this particular case there's simply no longer a need to call this from the CS thread.
Signed-off-by: Jan Sikorski jsikorski@codeweavers.com --- It looks fishy that these are written to when encoding into deferred contexts; and also that they are read in the cs thread. This patch however is just so that we don't need a mutex for application threads to call these. --- dlls/wined3d/wined3d_private.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 827ebbec773..dbb49f7e104 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -4157,8 +4157,8 @@ struct wined3d_resource
struct list resource_list_entry;
- uint32_t srv_bind_count_device; - uint32_t rtv_bind_count_device; + int32_t srv_bind_count_device; + int32_t rtv_bind_count_device; };
static inline ULONG wined3d_resource_incref(struct wined3d_resource *resource) @@ -6330,22 +6330,22 @@ static inline bool wined3d_rtv_all_subresources(const struct wined3d_rendertarge
static inline void wined3d_srv_bind_count_inc(struct wined3d_shader_resource_view *srv) { - ++srv->resource->srv_bind_count_device; + InterlockedIncrement(&srv->resource->srv_bind_count_device); }
static inline void wined3d_srv_bind_count_dec(struct wined3d_shader_resource_view *srv) { - --srv->resource->srv_bind_count_device; + InterlockedDecrement(&srv->resource->srv_bind_count_device); }
static inline void wined3d_rtv_bind_count_inc(struct wined3d_rendertarget_view *rtv) { - ++rtv->resource->rtv_bind_count_device; + InterlockedIncrement(&rtv->resource->rtv_bind_count_device); }
static inline void wined3d_rtv_bind_count_dec(struct wined3d_rendertarget_view *rtv) { - --rtv->resource->rtv_bind_count_device; + InterlockedDecrement(&rtv->resource->rtv_bind_count_device); }
static inline bool wined3d_rtv_overlaps_srv(const struct wined3d_rendertarget_view *rtv,
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
On Thu, 7 Oct 2021 at 13:06, Jan Sikorski jsikorski@codeweavers.com wrote:
It looks fishy that these are written to when encoding into deferred contexts; and also that they are read in the cs thread. This patch however is just so that we don't need a mutex for application threads to call these.
Yes. That may simply be a case of these predating deferred contexts, and not causing known issues yet...
Signed-off-by: Jan Sikorski jsikorski@codeweavers.com --- dlls/wined3d/buffer.c | 2 ++ dlls/wined3d/cs.c | 2 +- dlls/wined3d/device.c | 2 ++ dlls/wined3d/palette.c | 4 ++++ dlls/wined3d/query.c | 2 ++ dlls/wined3d/sampler.c | 2 ++ dlls/wined3d/state.c | 6 ++++++ dlls/wined3d/texture.c | 2 ++ dlls/wined3d/vertexdeclaration.c | 2 ++ dlls/wined3d/view.c | 12 ++++++++++++ 10 files changed, 35 insertions(+), 1 deletion(-)
diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c index 3ea3bf4b180..6a87393b8c8 100644 --- a/dlls/wined3d/buffer.c +++ b/dlls/wined3d/buffer.c @@ -708,8 +708,10 @@ ULONG CDECL wined3d_buffer_decref(struct wined3d_buffer *buffer)
if (!refcount) { + wined3d_mutex_lock(); buffer->resource.parent_ops->wined3d_object_destroyed(buffer->resource.parent); buffer->resource.device->adapter->adapter_ops->adapter_destroy_buffer(buffer); + wined3d_mutex_unlock(); }
return refcount; diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c index 1b4ed519260..529ab4fd159 100644 --- a/dlls/wined3d/cs.c +++ b/dlls/wined3d/cs.c @@ -99,7 +99,6 @@ 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 +108,7 @@ ULONG CDECL wined3d_command_list_decref(struct wined3d_command_list *list) for (i = 0; i < list->query_count; ++i) wined3d_query_decref(list->queries[i].query);
+ wined3d_mutex_lock(); wined3d_cs_destroy_object(device->cs, wined3d_command_list_destroy_object, list); wined3d_mutex_unlock(); } diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 436c4dfe854..3d3130777eb 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -263,8 +263,10 @@ ULONG CDECL wined3d_device_decref(struct wined3d_device *device)
if (!refcount) { + wined3d_mutex_lock(); device->adapter->adapter_ops->adapter_destroy_device(device); TRACE("Destroyed device %p.\n", device); + wined3d_mutex_unlock(); }
return refcount; diff --git a/dlls/wined3d/palette.c b/dlls/wined3d/palette.c index 85105d1f8de..4bc453bde79 100644 --- a/dlls/wined3d/palette.c +++ b/dlls/wined3d/palette.c @@ -47,7 +47,11 @@ ULONG CDECL wined3d_palette_decref(struct wined3d_palette *palette) TRACE("%p decreasing refcount to %u.\n", palette, refcount);
if (!refcount) + { + wined3d_mutex_lock(); wined3d_cs_destroy_object(palette->device->cs, wined3d_palette_destroy_object, palette); + wined3d_mutex_unlock(); + }
return refcount; } diff --git a/dlls/wined3d/query.c b/dlls/wined3d/query.c index 8ee7ae07886..1b38eb5e311 100644 --- a/dlls/wined3d/query.c +++ b/dlls/wined3d/query.c @@ -444,9 +444,11 @@ ULONG CDECL wined3d_query_decref(struct wined3d_query *query) { struct wined3d_device *device = query->device;
+ wined3d_mutex_lock(); query->parent_ops->wined3d_object_destroyed(query->parent); wined3d_cs_destroy_object(device->cs, wined3d_query_destroy_object, query); device->adapter->adapter_ops->adapter_destroy_query(query); + wined3d_mutex_unlock(); }
return refcount; diff --git a/dlls/wined3d/sampler.c b/dlls/wined3d/sampler.c index 7eb3a2ae0be..bba3165316e 100644 --- a/dlls/wined3d/sampler.c +++ b/dlls/wined3d/sampler.c @@ -41,8 +41,10 @@ ULONG CDECL wined3d_sampler_decref(struct wined3d_sampler *sampler)
if (!refcount) { + wined3d_mutex_lock(); sampler->parent_ops->wined3d_object_destroyed(sampler->parent); sampler->device->adapter->adapter_ops->adapter_destroy_sampler(sampler); + wined3d_mutex_unlock(); }
return refcount; diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c index 8316269afcf..c7f041066d1 100644 --- a/dlls/wined3d/state.c +++ b/dlls/wined3d/state.c @@ -62,8 +62,10 @@ ULONG CDECL wined3d_blend_state_decref(struct wined3d_blend_state *state)
if (!refcount) { + wined3d_mutex_lock(); state->parent_ops->wined3d_object_destroyed(state->parent); wined3d_cs_destroy_object(device->cs, wined3d_blend_state_destroy_object, state); + wined3d_mutex_unlock(); }
return refcount; @@ -136,8 +138,10 @@ ULONG CDECL wined3d_depth_stencil_state_decref(struct wined3d_depth_stencil_stat
if (!refcount) { + wined3d_mutex_lock(); state->parent_ops->wined3d_object_destroyed(state->parent); wined3d_cs_destroy_object(device->cs, wined3d_depth_stencil_state_destroy_object, state); + wined3d_mutex_unlock(); }
return refcount; @@ -199,8 +203,10 @@ ULONG CDECL wined3d_rasterizer_state_decref(struct wined3d_rasterizer_state *sta
if (!refcount) { + wined3d_mutex_lock(); state->parent_ops->wined3d_object_destroyed(state->parent); wined3d_cs_destroy_object(device->cs, wined3d_rasterizer_state_destroy_object, state); + wined3d_mutex_unlock(); }
return refcount; diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c index 608348a377a..e4d27c07126 100644 --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c @@ -1545,6 +1545,7 @@ ULONG CDECL wined3d_texture_decref(struct wined3d_texture *texture)
if (!refcount) { + wined3d_mutex_lock(); /* Wait for the texture to become idle if it's using user memory, * since the application is allowed to free that memory once the * texture is destroyed. Note that this implies that @@ -1559,6 +1560,7 @@ ULONG CDECL wined3d_texture_decref(struct wined3d_texture *texture) } } texture->resource.device->adapter->adapter_ops->adapter_destroy_texture(texture); + wined3d_mutex_unlock(); }
return refcount; diff --git a/dlls/wined3d/vertexdeclaration.c b/dlls/wined3d/vertexdeclaration.c index 45a01f4bdd4..a778352d2cf 100644 --- a/dlls/wined3d/vertexdeclaration.c +++ b/dlls/wined3d/vertexdeclaration.c @@ -68,9 +68,11 @@ ULONG CDECL wined3d_vertex_declaration_decref(struct wined3d_vertex_declaration
if (!refcount) { + wined3d_mutex_lock(); declaration->parent_ops->wined3d_object_destroyed(declaration->parent); wined3d_cs_destroy_object(declaration->device->cs, wined3d_vertex_declaration_destroy_object, declaration); + wined3d_mutex_unlock(); }
return refcount; diff --git a/dlls/wined3d/view.c b/dlls/wined3d/view.c index 565d35d1c5a..03ac1a0d9ff 100644 --- a/dlls/wined3d/view.c +++ b/dlls/wined3d/view.c @@ -376,7 +376,11 @@ ULONG CDECL wined3d_rendertarget_view_decref(struct wined3d_rendertarget_view *v TRACE("%p decreasing refcount to %u.\n", view, refcount);
if (!refcount) + { + wined3d_mutex_lock(); view->resource->device->adapter->adapter_ops->adapter_destroy_rendertarget_view(view); + wined3d_mutex_unlock(); + }
return refcount; } @@ -923,7 +927,11 @@ ULONG CDECL wined3d_shader_resource_view_decref(struct wined3d_shader_resource_v TRACE("%p decreasing refcount to %u.\n", view, refcount);
if (!refcount) + { + wined3d_mutex_lock(); view->resource->device->adapter->adapter_ops->adapter_destroy_shader_resource_view(view); + wined3d_mutex_unlock(); + }
return refcount; } @@ -1441,7 +1449,11 @@ ULONG CDECL wined3d_unordered_access_view_decref(struct wined3d_unordered_access TRACE("%p decreasing refcount to %u.\n", view, refcount);
if (!refcount) + { + wined3d_mutex_lock(); view->resource->device->adapter->adapter_ops->adapter_destroy_unordered_access_view(view); + wined3d_mutex_unlock(); + }
return refcount; }
Signed-off-by: Jan Sikorski jsikorski@codeweavers.com --- dlls/d3d11/async.c | 10 --- dlls/d3d11/buffer.c | 8 -- dlls/d3d11/device.c | 164 --------------------------------------- dlls/d3d11/inputlayout.c | 6 -- dlls/d3d11/shader.c | 33 -------- dlls/d3d11/state.c | 22 ------ dlls/d3d11/view.c | 24 ------ 7 files changed, 267 deletions(-)
diff --git a/dlls/d3d11/async.c b/dlls/d3d11/async.c index fd83871220d..3054c0fca0a 100644 --- a/dlls/d3d11/async.c +++ b/dlls/d3d11/async.c @@ -72,9 +72,7 @@ static ULONG STDMETHODCALLTYPE d3d11_query_AddRef(ID3D11Query *iface) if (refcount == 1) { ID3D11Device2_AddRef(query->device); - wined3d_mutex_lock(); wined3d_query_incref(query->wined3d_query); - wined3d_mutex_unlock(); }
return refcount; @@ -90,11 +88,7 @@ static ULONG STDMETHODCALLTYPE d3d11_query_Release(ID3D11Query *iface) if (!refcount) { ID3D11Device2 *device = query->device; - - wined3d_mutex_lock(); wined3d_query_decref(query->wined3d_query); - wined3d_mutex_unlock(); - ID3D11Device2_Release(device); }
@@ -295,10 +289,8 @@ static void STDMETHODCALLTYPE d3d10_query_Begin(ID3D10Query *iface)
TRACE("iface %p.\n", iface);
- wined3d_mutex_lock(); if (FAILED(hr = wined3d_query_issue(query->wined3d_query, WINED3DISSUE_BEGIN))) ERR("Failed to issue query, hr %#x.\n", hr); - wined3d_mutex_unlock(); }
static void STDMETHODCALLTYPE d3d10_query_End(ID3D10Query *iface) @@ -308,10 +300,8 @@ static void STDMETHODCALLTYPE d3d10_query_End(ID3D10Query *iface)
TRACE("iface %p.\n", iface);
- wined3d_mutex_lock(); if (FAILED(hr = wined3d_query_issue(query->wined3d_query, WINED3DISSUE_END))) ERR("Failed to issue query, hr %#x.\n", hr); - wined3d_mutex_unlock(); }
static HRESULT STDMETHODCALLTYPE d3d10_query_GetData(ID3D10Query *iface, void *data, UINT data_size, UINT flags) diff --git a/dlls/d3d11/buffer.c b/dlls/d3d11/buffer.c index 09d495c3f61..5a6ca81dff4 100644 --- a/dlls/d3d11/buffer.c +++ b/dlls/d3d11/buffer.c @@ -69,9 +69,7 @@ static ULONG STDMETHODCALLTYPE d3d11_buffer_AddRef(ID3D11Buffer *iface) if (refcount == 1) { ID3D11Device2_AddRef(buffer->device); - wined3d_mutex_lock(); wined3d_buffer_incref(buffer->wined3d_buffer); - wined3d_mutex_unlock(); }
return refcount; @@ -88,9 +86,7 @@ static ULONG STDMETHODCALLTYPE d3d11_buffer_Release(ID3D11Buffer *iface) { ID3D11Device2 *device = buffer->device;
- wined3d_mutex_lock(); wined3d_buffer_decref(buffer->wined3d_buffer); - wined3d_mutex_unlock(); /* Release the device last, it may cause the wined3d device to be * destroyed. */ ID3D11Device2_Release(device); @@ -308,11 +304,9 @@ static HRESULT STDMETHODCALLTYPE d3d10_buffer_Map(ID3D10Buffer *iface, D3D10_MAP if (map_flags) FIXME("Ignoring map_flags %#x.\n", map_flags);
- wined3d_mutex_lock(); hr = wined3d_resource_map(wined3d_buffer_get_resource(buffer->wined3d_buffer), 0, &wined3d_map_desc, NULL, wined3d_map_flags_from_d3d10_map_type(map_type)); *data = wined3d_map_desc.data; - wined3d_mutex_unlock();
return hr; } @@ -323,9 +317,7 @@ static void STDMETHODCALLTYPE d3d10_buffer_Unmap(ID3D10Buffer *iface)
TRACE("iface %p.\n", iface);
- wined3d_mutex_lock(); wined3d_resource_unmap(wined3d_buffer_get_resource(buffer->wined3d_buffer), 0); - wined3d_mutex_unlock(); }
static void STDMETHODCALLTYPE d3d10_buffer_GetDesc(ID3D10Buffer *iface, D3D10_BUFFER_DESC *desc) diff --git a/dlls/d3d11/device.c b/dlls/d3d11/device.c index 68b0333604f..60c45c25094 100644 --- a/dlls/d3d11/device.c +++ b/dlls/d3d11/device.c @@ -375,9 +375,7 @@ static ULONG STDMETHODCALLTYPE d3d11_command_list_Release(ID3D11CommandList *ifa
if (!refcount) { - wined3d_mutex_lock(); wined3d_command_list_decref(list->wined3d_list); - wined3d_mutex_unlock(); wined3d_private_store_cleanup(&list->private_store); ID3D11Device2_Release(list->device); heap_free(list); @@ -609,10 +607,8 @@ static void d3d11_device_context_set_constant_buffers(ID3D11DeviceContext1 *ifac wined3d_buffers[i].size = (counts ? counts[i] : WINED3D_MAX_CONSTANT_BUFFER_SIZE) * sizeof(struct wined3d_vec4); }
- wined3d_mutex_lock(); wined3d_device_context_set_constant_buffers(context->wined3d_context, type, start_slot, buffer_count, wined3d_buffers); - wined3d_mutex_unlock(); }
static void d3d11_device_context_set_shader_resource_views(ID3D11DeviceContext1 *iface, enum wined3d_shader_type type, @@ -635,10 +631,8 @@ static void d3d11_device_context_set_shader_resource_views(ID3D11DeviceContext1 wined3d_views[i] = view ? view->wined3d_view : NULL; }
- wined3d_mutex_lock(); wined3d_device_context_set_shader_resource_views(context->wined3d_context, type, start_slot, count, wined3d_views); - wined3d_mutex_unlock(); }
static void d3d11_device_context_set_samplers(ID3D11DeviceContext1 *iface, enum wined3d_shader_type type, @@ -661,9 +655,7 @@ static void d3d11_device_context_set_samplers(ID3D11DeviceContext1 *iface, enum wined3d_samplers[i] = sampler ? sampler->wined3d_sampler : NULL; }
- wined3d_mutex_lock(); wined3d_device_context_set_samplers(context->wined3d_context, type, start_slot, count, wined3d_samplers); - wined3d_mutex_unlock(); }
static void STDMETHODCALLTYPE d3d11_device_context_GetDevice(ID3D11DeviceContext1 *iface, ID3D11Device **device) @@ -737,10 +729,8 @@ static void STDMETHODCALLTYPE d3d11_device_context_PSSetShader(ID3D11DeviceConte if (class_instances) FIXME("Dynamic linking is not implemented yet.\n");
- wined3d_mutex_lock(); wined3d_device_context_set_shader(context->wined3d_context, WINED3D_SHADER_TYPE_PIXEL, ps ? ps->wined3d_shader : NULL); - wined3d_mutex_unlock(); }
static void STDMETHODCALLTYPE d3d11_device_context_PSSetSamplers(ID3D11DeviceContext1 *iface, @@ -764,10 +754,8 @@ static void STDMETHODCALLTYPE d3d11_device_context_VSSetShader(ID3D11DeviceConte if (class_instances) FIXME("Dynamic linking is not implemented yet.\n");
- wined3d_mutex_lock(); wined3d_device_context_set_shader(context->wined3d_context, WINED3D_SHADER_TYPE_VERTEX, vs ? vs->wined3d_shader : NULL); - wined3d_mutex_unlock(); }
static void STDMETHODCALLTYPE d3d11_device_context_DrawIndexed(ID3D11DeviceContext1 *iface, @@ -778,10 +766,8 @@ static void STDMETHODCALLTYPE d3d11_device_context_DrawIndexed(ID3D11DeviceConte TRACE("iface %p, index_count %u, start_index_location %u, base_vertex_location %d.\n", iface, index_count, start_index_location, base_vertex_location);
- wined3d_mutex_lock(); wined3d_device_context_draw_indexed(context->wined3d_context, base_vertex_location, start_index_location, index_count, 0, 0); - wined3d_mutex_unlock(); }
static void STDMETHODCALLTYPE d3d11_device_context_Draw(ID3D11DeviceContext1 *iface, @@ -792,9 +778,7 @@ static void STDMETHODCALLTYPE d3d11_device_context_Draw(ID3D11DeviceContext1 *if TRACE("iface %p, vertex_count %u, start_vertex_location %u.\n", iface, vertex_count, start_vertex_location);
- wined3d_mutex_lock(); wined3d_device_context_draw(context->wined3d_context, start_vertex_location, vertex_count, 0, 0); - wined3d_mutex_unlock(); }
static HRESULT STDMETHODCALLTYPE d3d11_device_context_Map(ID3D11DeviceContext1 *iface, ID3D11Resource *resource, @@ -817,10 +801,8 @@ static HRESULT STDMETHODCALLTYPE d3d11_device_context_Map(ID3D11DeviceContext1 *
wined3d_resource = wined3d_resource_from_d3d11_resource(resource);
- wined3d_mutex_lock(); hr = wined3d_device_context_map(context->wined3d_context, wined3d_resource, subresource_idx, &map_desc, NULL, wined3d_map_flags_from_d3d11_map_type(map_type)); - wined3d_mutex_unlock();
mapped_subresource->pData = map_desc.data; mapped_subresource->RowPitch = map_desc.row_pitch; @@ -839,9 +821,7 @@ static void STDMETHODCALLTYPE d3d11_device_context_Unmap(ID3D11DeviceContext1 *i
wined3d_resource = wined3d_resource_from_d3d11_resource(resource);
- wined3d_mutex_lock(); wined3d_device_context_unmap(context->wined3d_context, wined3d_resource, subresource_idx); - wined3d_mutex_unlock(); }
static void STDMETHODCALLTYPE d3d11_device_context_PSSetConstantBuffers(ID3D11DeviceContext1 *iface, @@ -862,9 +842,7 @@ static void STDMETHODCALLTYPE d3d11_device_context_IASetInputLayout(ID3D11Device
TRACE("iface %p, input_layout %p.\n", iface, input_layout);
- wined3d_mutex_lock(); wined3d_device_context_set_vertex_declaration(context->wined3d_context, layout ? layout->wined3d_decl : NULL); - wined3d_mutex_unlock(); }
static void STDMETHODCALLTYPE d3d11_device_context_IASetVertexBuffers(ID3D11DeviceContext1 *iface, @@ -894,9 +872,7 @@ static void STDMETHODCALLTYPE d3d11_device_context_IASetVertexBuffers(ID3D11Devi streams[i].flags = 0; }
- wined3d_mutex_lock(); wined3d_device_context_set_stream_sources(context->wined3d_context, start_slot, buffer_count, streams); - wined3d_mutex_unlock(); }
static void STDMETHODCALLTYPE d3d11_device_context_IASetIndexBuffer(ID3D11DeviceContext1 *iface, @@ -908,11 +884,9 @@ static void STDMETHODCALLTYPE d3d11_device_context_IASetIndexBuffer(ID3D11Device TRACE("iface %p, buffer %p, format %s, offset %u.\n", iface, buffer, debug_dxgi_format(format), offset);
- wined3d_mutex_lock(); wined3d_device_context_set_index_buffer(context->wined3d_context, buffer_impl ? buffer_impl->wined3d_buffer : NULL, wined3dformat_from_dxgi_format(format), offset); - wined3d_mutex_unlock(); }
static void STDMETHODCALLTYPE d3d11_device_context_DrawIndexedInstanced(ID3D11DeviceContext1 *iface, @@ -926,10 +900,8 @@ static void STDMETHODCALLTYPE d3d11_device_context_DrawIndexedInstanced(ID3D11De iface, instance_index_count, instance_count, start_index_location, base_vertex_location, start_instance_location);
- wined3d_mutex_lock(); wined3d_device_context_draw_indexed(context->wined3d_context, base_vertex_location, start_index_location, instance_index_count, start_instance_location, instance_count); - wined3d_mutex_unlock(); }
static void STDMETHODCALLTYPE d3d11_device_context_DrawInstanced(ID3D11DeviceContext1 *iface, @@ -942,10 +914,8 @@ static void STDMETHODCALLTYPE d3d11_device_context_DrawInstanced(ID3D11DeviceCon iface, instance_vertex_count, instance_count, start_vertex_location, start_instance_location);
- wined3d_mutex_lock(); wined3d_device_context_draw(context->wined3d_context, start_vertex_location, instance_vertex_count, start_instance_location, instance_count); - wined3d_mutex_unlock(); }
static void STDMETHODCALLTYPE d3d11_device_context_GSSetConstantBuffers(ID3D11DeviceContext1 *iface, @@ -970,10 +940,8 @@ static void STDMETHODCALLTYPE d3d11_device_context_GSSetShader(ID3D11DeviceConte if (class_instances) FIXME("Dynamic linking is not implemented yet.\n");
- wined3d_mutex_lock(); wined3d_device_context_set_shader(context->wined3d_context, WINED3D_SHADER_TYPE_GEOMETRY, gs ? gs->wined3d_shader : NULL); - wined3d_mutex_unlock(); }
static void STDMETHODCALLTYPE d3d11_device_context_IASetPrimitiveTopology(ID3D11DeviceContext1 *iface, @@ -987,9 +955,7 @@ static void STDMETHODCALLTYPE d3d11_device_context_IASetPrimitiveTopology(ID3D11
wined3d_primitive_type_from_d3d11_primitive_topology(topology, &primitive_type, &patch_vertex_count);
- wined3d_mutex_lock(); wined3d_device_context_set_primitive_type(context->wined3d_context, primitive_type, patch_vertex_count); - wined3d_mutex_unlock(); }
static void STDMETHODCALLTYPE d3d11_device_context_VSSetShaderResources(ID3D11DeviceContext1 *iface, @@ -1017,9 +983,7 @@ static void STDMETHODCALLTYPE d3d11_device_context_Begin(ID3D11DeviceContext1 *i
TRACE("iface %p, asynchronous %p.\n", iface, asynchronous);
- wined3d_mutex_lock(); wined3d_device_context_issue_query(context->wined3d_context, query->wined3d_query, WINED3DISSUE_BEGIN); - wined3d_mutex_unlock(); }
static void STDMETHODCALLTYPE d3d11_device_context_End(ID3D11DeviceContext1 *iface, @@ -1030,9 +994,7 @@ static void STDMETHODCALLTYPE d3d11_device_context_End(ID3D11DeviceContext1 *ifa
TRACE("iface %p, asynchronous %p.\n", iface, asynchronous);
- wined3d_mutex_lock(); wined3d_device_context_issue_query(context->wined3d_context, query->wined3d_query, WINED3DISSUE_END); - wined3d_mutex_unlock(); }
static HRESULT STDMETHODCALLTYPE d3d11_device_context_GetData(ID3D11DeviceContext1 *iface, @@ -1081,9 +1043,7 @@ static void STDMETHODCALLTYPE d3d11_device_context_SetPredication(ID3D11DeviceCo
query = unsafe_impl_from_ID3D11Query((ID3D11Query *)predicate);
- wined3d_mutex_lock(); wined3d_device_context_set_predication(context->wined3d_context, query ? query->wined3d_query : NULL, value); - wined3d_mutex_unlock(); }
static void STDMETHODCALLTYPE d3d11_device_context_GSSetShaderResources(ID3D11DeviceContext1 *iface, @@ -1128,11 +1088,9 @@ static void STDMETHODCALLTYPE d3d11_device_context_OMSetRenderTargets(ID3D11Devi
dsv = unsafe_impl_from_ID3D11DepthStencilView(depth_stencil_view);
- wined3d_mutex_lock(); wined3d_device_context_set_rendertarget_views(context->wined3d_context, 0, ARRAY_SIZE(wined3d_rtvs), wined3d_rtvs, FALSE); wined3d_device_context_set_depth_stencil_view(context->wined3d_context, dsv ? dsv->wined3d_view : NULL); - wined3d_mutex_unlock(); }
static void STDMETHODCALLTYPE d3d11_device_context_OMSetRenderTargetsAndUnorderedAccessViews( @@ -1176,10 +1134,8 @@ static void STDMETHODCALLTYPE d3d11_device_context_OMSetRenderTargetsAndUnordere wined3d_initial_counts[uav_start_idx + i] = initial_counts ? initial_counts[i] : ~0u; }
- wined3d_mutex_lock(); wined3d_device_context_set_unordered_access_views(context->wined3d_context, WINED3D_PIPELINE_GRAPHICS, 0, ARRAY_SIZE(wined3d_views), wined3d_views, wined3d_initial_counts); - wined3d_mutex_unlock(); } }
@@ -1196,14 +1152,12 @@ static void STDMETHODCALLTYPE d3d11_device_context_OMSetBlendState(ID3D11DeviceC if (!blend_factor) blend_factor = default_blend_factor;
- wined3d_mutex_lock(); if (!(blend_state_impl = unsafe_impl_from_ID3D11BlendState(blend_state))) wined3d_device_context_set_blend_state(context->wined3d_context, NULL, (const struct wined3d_color *)blend_factor, sample_mask); else wined3d_device_context_set_blend_state(context->wined3d_context, blend_state_impl->wined3d_state, (const struct wined3d_color *)blend_factor, sample_mask); - wined3d_mutex_unlock(); }
static void STDMETHODCALLTYPE d3d11_device_context_OMSetDepthStencilState(ID3D11DeviceContext1 *iface, @@ -1215,16 +1169,13 @@ static void STDMETHODCALLTYPE d3d11_device_context_OMSetDepthStencilState(ID3D11 TRACE("iface %p, depth_stencil_state %p, stencil_ref %u.\n", iface, depth_stencil_state, stencil_ref);
- wined3d_mutex_lock(); if (!(state_impl = unsafe_impl_from_ID3D11DepthStencilState(depth_stencil_state))) { wined3d_device_context_set_depth_stencil_state(context->wined3d_context, NULL, stencil_ref); - wined3d_mutex_unlock(); return; }
wined3d_device_context_set_depth_stencil_state(context->wined3d_context, state_impl->wined3d_state, stencil_ref); - wined3d_mutex_unlock(); }
static void STDMETHODCALLTYPE d3d11_device_context_SOSetTargets(ID3D11DeviceContext1 *iface, UINT buffer_count, @@ -1245,9 +1196,7 @@ static void STDMETHODCALLTYPE d3d11_device_context_SOSetTargets(ID3D11DeviceCont outputs[i].offset = offsets ? offsets[i] : 0; }
- wined3d_mutex_lock(); wined3d_device_context_set_stream_outputs(context->wined3d_context, outputs); - wined3d_mutex_unlock(); }
static void STDMETHODCALLTYPE d3d11_device_context_DrawAuto(ID3D11DeviceContext1 *iface) @@ -1265,9 +1214,7 @@ static void STDMETHODCALLTYPE d3d11_device_context_DrawIndexedInstancedIndirect(
d3d_buffer = unsafe_impl_from_ID3D11Buffer(buffer);
- wined3d_mutex_lock(); wined3d_device_context_draw_indirect(context->wined3d_context, d3d_buffer->wined3d_buffer, offset, true); - wined3d_mutex_unlock(); }
static void STDMETHODCALLTYPE d3d11_device_context_DrawInstancedIndirect(ID3D11DeviceContext1 *iface, @@ -1280,9 +1227,7 @@ static void STDMETHODCALLTYPE d3d11_device_context_DrawInstancedIndirect(ID3D11D
d3d_buffer = unsafe_impl_from_ID3D11Buffer(buffer);
- wined3d_mutex_lock(); wined3d_device_context_draw_indirect(context->wined3d_context, d3d_buffer->wined3d_buffer, offset, false); - wined3d_mutex_unlock(); }
static void STDMETHODCALLTYPE d3d11_device_context_Dispatch(ID3D11DeviceContext1 *iface, @@ -1293,10 +1238,8 @@ static void STDMETHODCALLTYPE d3d11_device_context_Dispatch(ID3D11DeviceContext1 TRACE("iface %p, thread_group_count_x %u, thread_group_count_y %u, thread_group_count_z %u.\n", iface, thread_group_count_x, thread_group_count_y, thread_group_count_z);
- wined3d_mutex_lock(); wined3d_device_context_dispatch(context->wined3d_context, thread_group_count_x, thread_group_count_y, thread_group_count_z); - wined3d_mutex_unlock(); }
static void STDMETHODCALLTYPE d3d11_device_context_DispatchIndirect(ID3D11DeviceContext1 *iface, @@ -1309,9 +1252,7 @@ static void STDMETHODCALLTYPE d3d11_device_context_DispatchIndirect(ID3D11Device
buffer_impl = unsafe_impl_from_ID3D11Buffer(buffer);
- wined3d_mutex_lock(); wined3d_device_context_dispatch_indirect(context->wined3d_context, buffer_impl->wined3d_buffer, offset); - wined3d_mutex_unlock(); }
static void STDMETHODCALLTYPE d3d11_device_context_RSSetState(ID3D11DeviceContext1 *iface, @@ -1322,11 +1263,9 @@ static void STDMETHODCALLTYPE d3d11_device_context_RSSetState(ID3D11DeviceContex
TRACE("iface %p, rasterizer_state %p.\n", iface, rasterizer_state);
- wined3d_mutex_lock(); rasterizer_state_impl = unsafe_impl_from_ID3D11RasterizerState(rasterizer_state); wined3d_device_context_set_rasterizer_state(context->wined3d_context, rasterizer_state_impl ? rasterizer_state_impl->wined3d_state : NULL); - wined3d_mutex_unlock(); }
static void STDMETHODCALLTYPE d3d11_device_context_RSSetViewports(ID3D11DeviceContext1 *iface, @@ -1351,9 +1290,7 @@ static void STDMETHODCALLTYPE d3d11_device_context_RSSetViewports(ID3D11DeviceCo wined3d_vp[i].max_z = viewports[i].MaxDepth; }
- wined3d_mutex_lock(); wined3d_device_context_set_viewports(context->wined3d_context, viewport_count, wined3d_vp); - wined3d_mutex_unlock(); }
static void STDMETHODCALLTYPE d3d11_device_context_RSSetScissorRects(ID3D11DeviceContext1 *iface, @@ -1366,9 +1303,7 @@ static void STDMETHODCALLTYPE d3d11_device_context_RSSetScissorRects(ID3D11Devic if (rect_count > WINED3D_MAX_VIEWPORTS) return;
- wined3d_mutex_lock(); wined3d_device_context_set_scissor_rects(context->wined3d_context, rect_count, rects); - wined3d_mutex_unlock(); }
static void STDMETHODCALLTYPE d3d11_device_context_CopySubresourceRegion(ID3D11DeviceContext1 *iface, @@ -1393,10 +1328,8 @@ static void STDMETHODCALLTYPE d3d11_device_context_CopySubresourceRegion(ID3D11D
wined3d_dst_resource = wined3d_resource_from_d3d11_resource(dst_resource); wined3d_src_resource = wined3d_resource_from_d3d11_resource(src_resource); - wined3d_mutex_lock(); wined3d_device_context_copy_sub_resource_region(context->wined3d_context, wined3d_dst_resource, dst_subresource_idx, dst_x, dst_y, dst_z, wined3d_src_resource, src_subresource_idx, src_box ? &wined3d_src_box : NULL, 0); - wined3d_mutex_unlock(); }
static void STDMETHODCALLTYPE d3d11_device_context_CopyResource(ID3D11DeviceContext1 *iface, @@ -1409,9 +1342,7 @@ static void STDMETHODCALLTYPE d3d11_device_context_CopyResource(ID3D11DeviceCont
wined3d_dst_resource = wined3d_resource_from_d3d11_resource(dst_resource); wined3d_src_resource = wined3d_resource_from_d3d11_resource(src_resource); - wined3d_mutex_lock(); wined3d_device_context_copy_resource(context->wined3d_context, wined3d_dst_resource, wined3d_src_resource); - wined3d_mutex_unlock(); }
static void STDMETHODCALLTYPE d3d11_device_context_UpdateSubresource(ID3D11DeviceContext1 *iface, @@ -1429,10 +1360,8 @@ static void STDMETHODCALLTYPE d3d11_device_context_UpdateSubresource(ID3D11Devic wined3d_box_set(&wined3d_box, box->left, box->top, box->right, box->bottom, box->front, box->back);
wined3d_resource = wined3d_resource_from_d3d11_resource(resource); - wined3d_mutex_lock(); wined3d_device_context_update_sub_resource(context->wined3d_context, wined3d_resource, subresource_idx, box ? &wined3d_box : NULL, data, row_pitch, depth_pitch, 0); - wined3d_mutex_unlock(); }
static void STDMETHODCALLTYPE d3d11_device_context_CopyStructureCount(ID3D11DeviceContext1 *iface, @@ -1448,10 +1377,8 @@ static void STDMETHODCALLTYPE d3d11_device_context_CopyStructureCount(ID3D11Devi buffer_impl = unsafe_impl_from_ID3D11Buffer(dst_buffer); uav = unsafe_impl_from_ID3D11UnorderedAccessView(src_view);
- wined3d_mutex_lock(); wined3d_device_context_copy_uav_counter(context->wined3d_context, buffer_impl->wined3d_buffer, dst_offset, uav->wined3d_view); - wined3d_mutex_unlock(); }
static void STDMETHODCALLTYPE d3d11_device_context_ClearRenderTargetView(ID3D11DeviceContext1 *iface, @@ -1468,11 +1395,9 @@ static void STDMETHODCALLTYPE d3d11_device_context_ClearRenderTargetView(ID3D11D if (!view) return;
- wined3d_mutex_lock(); if (FAILED(hr = wined3d_device_context_clear_rendertarget_view(context->wined3d_context, view->wined3d_view, NULL, WINED3DCLEAR_TARGET, &color, 0.0f, 0))) ERR("Failed to clear view, hr %#x.\n", hr); - wined3d_mutex_unlock(); }
static void STDMETHODCALLTYPE d3d11_device_context_ClearUnorderedAccessViewUint(ID3D11DeviceContext1 *iface, @@ -1485,10 +1410,8 @@ static void STDMETHODCALLTYPE d3d11_device_context_ClearUnorderedAccessViewUint( iface, unordered_access_view, values[0], values[1], values[2], values[3]);
view = unsafe_impl_from_ID3D11UnorderedAccessView(unordered_access_view); - wined3d_mutex_lock(); wined3d_device_context_clear_uav_uint(context->wined3d_context, view->wined3d_view, (const struct wined3d_uvec4 *)values); - wined3d_mutex_unlock(); }
static void STDMETHODCALLTYPE d3d11_device_context_ClearUnorderedAccessViewFloat(ID3D11DeviceContext1 *iface, @@ -1501,10 +1424,8 @@ static void STDMETHODCALLTYPE d3d11_device_context_ClearUnorderedAccessViewFloat iface, unordered_access_view, debug_float4(values));
view = unsafe_impl_from_ID3D11UnorderedAccessView(unordered_access_view); - wined3d_mutex_lock(); wined3d_device_context_clear_uav_float(context->wined3d_context, view->wined3d_view, (const struct wined3d_vec4 *)values); - wined3d_mutex_unlock(); }
static void STDMETHODCALLTYPE d3d11_device_context_ClearDepthStencilView(ID3D11DeviceContext1 *iface, @@ -1523,11 +1444,9 @@ static void STDMETHODCALLTYPE d3d11_device_context_ClearDepthStencilView(ID3D11D
wined3d_flags = wined3d_clear_flags_from_d3d11_clear_flags(flags);
- wined3d_mutex_lock(); if (FAILED(hr = wined3d_device_context_clear_rendertarget_view(context->wined3d_context, view->wined3d_view, NULL, wined3d_flags, NULL, depth, stencil))) ERR("Failed to clear view, hr %#x.\n", hr); - wined3d_mutex_unlock(); }
static void STDMETHODCALLTYPE d3d11_device_context_GenerateMips(ID3D11DeviceContext1 *iface, @@ -1538,9 +1457,7 @@ static void STDMETHODCALLTYPE d3d11_device_context_GenerateMips(ID3D11DeviceCont
TRACE("iface %p, view %p.\n", iface, view);
- wined3d_mutex_lock(); wined3d_device_context_generate_mipmaps(context->wined3d_context, srv->wined3d_view); - wined3d_mutex_unlock(); }
static void STDMETHODCALLTYPE d3d11_device_context_SetResourceMinLOD(ID3D11DeviceContext1 *iface, @@ -1574,11 +1491,9 @@ static void STDMETHODCALLTYPE d3d11_device_context_ResolveSubresource(ID3D11Devi wined3d_dst_resource = wined3d_resource_from_d3d11_resource(dst_resource); wined3d_src_resource = wined3d_resource_from_d3d11_resource(src_resource); wined3d_format = wined3dformat_from_dxgi_format(format); - wined3d_mutex_lock(); wined3d_device_context_resolve_sub_resource(context->wined3d_context, wined3d_dst_resource, dst_subresource_idx, wined3d_src_resource, src_subresource_idx, wined3d_format); - wined3d_mutex_unlock(); }
static void STDMETHODCALLTYPE d3d11_device_context_ExecuteCommandList(ID3D11DeviceContext1 *iface, @@ -1589,9 +1504,7 @@ static void STDMETHODCALLTYPE d3d11_device_context_ExecuteCommandList(ID3D11Devi
TRACE("iface %p, command_list %p, restore_state %#x.\n", iface, command_list, restore_state);
- wined3d_mutex_lock(); wined3d_device_context_execute_command_list(context->wined3d_context, list_impl->wined3d_list, !!restore_state); - wined3d_mutex_unlock(); }
static void STDMETHODCALLTYPE d3d11_device_context_HSSetShaderResources(ID3D11DeviceContext1 *iface, @@ -1615,10 +1528,8 @@ static void STDMETHODCALLTYPE d3d11_device_context_HSSetShader(ID3D11DeviceConte if (class_instances) FIXME("Dynamic linking is not implemented yet.\n");
- wined3d_mutex_lock(); wined3d_device_context_set_shader(context->wined3d_context, WINED3D_SHADER_TYPE_HULL, hs ? hs->wined3d_shader : NULL); - wined3d_mutex_unlock(); }
static void STDMETHODCALLTYPE d3d11_device_context_HSSetSamplers(ID3D11DeviceContext1 *iface, @@ -1661,10 +1572,8 @@ static void STDMETHODCALLTYPE d3d11_device_context_DSSetShader(ID3D11DeviceConte if (class_instances) FIXME("Dynamic linking is not implemented yet.\n");
- wined3d_mutex_lock(); wined3d_device_context_set_shader(context->wined3d_context, WINED3D_SHADER_TYPE_DOMAIN, ds ? ds->wined3d_shader : NULL); - wined3d_mutex_unlock(); }
static void STDMETHODCALLTYPE d3d11_device_context_DSSetSamplers(ID3D11DeviceContext1 *iface, @@ -1718,10 +1627,8 @@ static void STDMETHODCALLTYPE d3d11_device_context_CSSetUnorderedAccessViews(ID3 wined3d_views[i] = view ? view->wined3d_view : NULL; }
- wined3d_mutex_lock(); wined3d_device_context_set_unordered_access_views(context->wined3d_context, WINED3D_PIPELINE_COMPUTE, start_slot, view_count, wined3d_views, initial_counts); - wined3d_mutex_unlock(); }
static void STDMETHODCALLTYPE d3d11_device_context_CSSetShader(ID3D11DeviceContext1 *iface, @@ -1736,10 +1643,8 @@ static void STDMETHODCALLTYPE d3d11_device_context_CSSetShader(ID3D11DeviceConte if (class_instances) FIXME("Dynamic linking is not implemented yet.\n");
- wined3d_mutex_lock(); wined3d_device_context_set_shader(context->wined3d_context, WINED3D_SHADER_TYPE_COMPUTE, cs ? cs->wined3d_shader : NULL); - wined3d_mutex_unlock(); }
static void STDMETHODCALLTYPE d3d11_device_context_CSSetSamplers(ID3D11DeviceContext1 *iface, @@ -2732,9 +2637,7 @@ static void STDMETHODCALLTYPE d3d11_device_context_ClearState(ID3D11DeviceContex
TRACE("iface %p.\n", iface);
- wined3d_mutex_lock(); wined3d_device_context_reset_state(context->wined3d_context); - wined3d_mutex_unlock(); }
static void STDMETHODCALLTYPE d3d11_device_context_Flush(ID3D11DeviceContext1 *iface) @@ -2743,9 +2646,7 @@ static void STDMETHODCALLTYPE d3d11_device_context_Flush(ID3D11DeviceContext1 *i
TRACE("iface %p.\n", iface);
- wined3d_mutex_lock(); wined3d_device_context_flush(context->wined3d_context); - wined3d_mutex_unlock(); }
static D3D11_DEVICE_CONTEXT_TYPE STDMETHODCALLTYPE d3d11_device_context_GetType(ID3D11DeviceContext1 *iface) @@ -2782,8 +2683,6 @@ static HRESULT STDMETHODCALLTYPE d3d11_device_context_FinishCommandList(ID3D11De if (!(object = heap_alloc_zero(sizeof(*object)))) return E_OUTOFMEMORY;
- wined3d_mutex_lock(); - if (FAILED(hr = wined3d_deferred_context_record_command_list(context->wined3d_context, !!restore, &object->wined3d_list))) { @@ -2792,8 +2691,6 @@ static HRESULT STDMETHODCALLTYPE d3d11_device_context_FinishCommandList(ID3D11De return hr; }
- wined3d_mutex_unlock(); - object->ID3D11CommandList_iface.lpVtbl = &d3d11_command_list_vtbl; object->refcount = 1; object->device = &context->device->ID3D11Device2_iface; @@ -2829,10 +2726,8 @@ static void STDMETHODCALLTYPE d3d11_device_context_CopySubresourceRegion1(ID3D11
wined3d_dst_resource = wined3d_resource_from_d3d11_resource(dst_resource); wined3d_src_resource = wined3d_resource_from_d3d11_resource(src_resource); - wined3d_mutex_lock(); wined3d_device_context_copy_sub_resource_region(context->wined3d_context, wined3d_dst_resource, dst_subresource_idx, dst_x, dst_y, dst_z, wined3d_src_resource, src_subresource_idx, src_box ? &wined3d_src_box : NULL, flags); - wined3d_mutex_unlock(); }
static void STDMETHODCALLTYPE d3d11_device_context_UpdateSubresource1(ID3D11DeviceContext1 *iface, @@ -2851,10 +2746,8 @@ static void STDMETHODCALLTYPE d3d11_device_context_UpdateSubresource1(ID3D11Devi box->front, box->back);
wined3d_resource = wined3d_resource_from_d3d11_resource(resource); - wined3d_mutex_lock(); wined3d_device_context_update_sub_resource(context->wined3d_context, wined3d_resource, subresource_idx, box ? &wined3d_box : NULL, data, row_pitch, depth_pitch, flags); - wined3d_mutex_unlock(); }
static void STDMETHODCALLTYPE d3d11_device_context_DiscardResource(ID3D11DeviceContext1 *iface, @@ -3769,15 +3662,12 @@ static HRESULT d3d11_deferred_context_create(struct d3d_device *device, return E_OUTOFMEMORY; d3d11_device_context_init(object, device, D3D11_DEVICE_CONTEXT_DEFERRED);
- wined3d_mutex_lock(); if (FAILED(hr = wined3d_deferred_context_create(device->wined3d_device, &object->wined3d_context))) { WARN("Failed to create wined3d deferred context, hr %#x.\n", hr); heap_free(object); - wined3d_mutex_unlock(); return hr; } - wined3d_mutex_unlock();
TRACE("Created deferred context %p.\n", object); *context = object; @@ -4530,9 +4420,7 @@ static ULONG STDMETHODCALLTYPE d3d_device_inner_Release(IUnknown *iface) d3d11_device_context_cleanup(&device->immediate_context); if (device->wined3d_device) { - wined3d_mutex_lock(); wined3d_device_decref(device->wined3d_device); - wined3d_mutex_unlock(); } wine_rb_destroy(&device->sampler_states, NULL, NULL); wine_rb_destroy(&device->rasterizer_states, NULL, NULL); @@ -4616,10 +4504,8 @@ static void d3d10_device_set_constant_buffers(ID3D10Device1 *iface, enum wined3d wined3d_buffers[i].size = WINED3D_MAX_CONSTANT_BUFFER_SIZE * sizeof(struct wined3d_vec4); }
- wined3d_mutex_lock(); wined3d_device_context_set_constant_buffers(device->immediate_context.wined3d_context, type, start_slot, buffer_count, wined3d_buffers); - wined3d_mutex_unlock(); }
static void d3d10_device_set_shader_resource_views(ID3D10Device1 *iface, enum wined3d_shader_type type, @@ -4642,10 +4528,8 @@ static void d3d10_device_set_shader_resource_views(ID3D10Device1 *iface, enum wi wined3d_views[i] = view ? view->wined3d_view : NULL; }
- wined3d_mutex_lock(); wined3d_device_context_set_shader_resource_views(device->immediate_context.wined3d_context, type, start_slot, count, wined3d_views); - wined3d_mutex_unlock(); }
static void d3d10_device_set_samplers(ID3D10Device1 *iface, enum wined3d_shader_type type, @@ -4668,10 +4552,8 @@ static void d3d10_device_set_samplers(ID3D10Device1 *iface, enum wined3d_shader_ wined3d_samplers[i] = sampler ? sampler->wined3d_sampler : NULL; }
- wined3d_mutex_lock(); wined3d_device_context_set_samplers(device->immediate_context.wined3d_context, type, start_slot, count, wined3d_samplers); - wined3d_mutex_unlock(); }
static void STDMETHODCALLTYPE d3d10_device_VSSetConstantBuffers(ID3D10Device1 *iface, @@ -4701,10 +4583,8 @@ static void STDMETHODCALLTYPE d3d10_device_PSSetShader(ID3D10Device1 *iface,
TRACE("iface %p, shader %p\n", iface, shader);
- wined3d_mutex_lock(); wined3d_device_context_set_shader(device->immediate_context.wined3d_context, WINED3D_SHADER_TYPE_PIXEL, ps ? ps->wined3d_shader : NULL); - wined3d_mutex_unlock(); }
static void STDMETHODCALLTYPE d3d10_device_PSSetSamplers(ID3D10Device1 *iface, @@ -4724,10 +4604,8 @@ static void STDMETHODCALLTYPE d3d10_device_VSSetShader(ID3D10Device1 *iface,
TRACE("iface %p, shader %p\n", iface, shader);
- wined3d_mutex_lock(); wined3d_device_context_set_shader(device->immediate_context.wined3d_context, WINED3D_SHADER_TYPE_VERTEX, vs ? vs->wined3d_shader : NULL); - wined3d_mutex_unlock(); }
static void STDMETHODCALLTYPE d3d10_device_DrawIndexed(ID3D10Device1 *iface, UINT index_count, @@ -4738,10 +4616,8 @@ static void STDMETHODCALLTYPE d3d10_device_DrawIndexed(ID3D10Device1 *iface, UIN TRACE("iface %p, index_count %u, start_index_location %u, base_vertex_location %d.\n", iface, index_count, start_index_location, base_vertex_location);
- wined3d_mutex_lock(); wined3d_device_context_draw_indexed(device->immediate_context.wined3d_context, base_vertex_location, start_index_location, index_count, 0, 0); - wined3d_mutex_unlock(); }
static void STDMETHODCALLTYPE d3d10_device_Draw(ID3D10Device1 *iface, UINT vertex_count, @@ -4752,9 +4628,7 @@ static void STDMETHODCALLTYPE d3d10_device_Draw(ID3D10Device1 *iface, UINT verte TRACE("iface %p, vertex_count %u, start_vertex_location %u\n", iface, vertex_count, start_vertex_location);
- wined3d_mutex_lock(); wined3d_device_context_draw(device->immediate_context.wined3d_context, start_vertex_location, vertex_count, 0, 0); - wined3d_mutex_unlock(); }
static void STDMETHODCALLTYPE d3d10_device_PSSetConstantBuffers(ID3D10Device1 *iface, @@ -4775,10 +4649,8 @@ static void STDMETHODCALLTYPE d3d10_device_IASetInputLayout(ID3D10Device1 *iface
TRACE("iface %p, input_layout %p\n", iface, input_layout);
- wined3d_mutex_lock(); wined3d_device_context_set_vertex_declaration(device->immediate_context.wined3d_context, layout ? layout->wined3d_decl : NULL); - wined3d_mutex_unlock(); }
static void STDMETHODCALLTYPE d3d10_device_IASetVertexBuffers(ID3D10Device1 *iface, UINT start_slot, @@ -4808,10 +4680,8 @@ static void STDMETHODCALLTYPE d3d10_device_IASetVertexBuffers(ID3D10Device1 *ifa streams[i].flags = 0; }
- wined3d_mutex_lock(); wined3d_device_context_set_stream_sources(device->immediate_context.wined3d_context, start_slot, buffer_count, streams); - wined3d_mutex_unlock(); }
static void STDMETHODCALLTYPE d3d10_device_IASetIndexBuffer(ID3D10Device1 *iface, @@ -4823,11 +4693,9 @@ static void STDMETHODCALLTYPE d3d10_device_IASetIndexBuffer(ID3D10Device1 *iface TRACE("iface %p, buffer %p, format %s, offset %u.\n", iface, buffer, debug_dxgi_format(format), offset);
- wined3d_mutex_lock(); wined3d_device_context_set_index_buffer(device->immediate_context.wined3d_context, buffer_impl ? buffer_impl->wined3d_buffer : NULL, wined3dformat_from_dxgi_format(format), offset); - wined3d_mutex_unlock(); }
static void STDMETHODCALLTYPE d3d10_device_DrawIndexedInstanced(ID3D10Device1 *iface, @@ -4841,10 +4709,8 @@ static void STDMETHODCALLTYPE d3d10_device_DrawIndexedInstanced(ID3D10Device1 *i iface, instance_index_count, instance_count, start_index_location, base_vertex_location, start_instance_location);
- wined3d_mutex_lock(); wined3d_device_context_draw_indexed(device->immediate_context.wined3d_context, base_vertex_location, start_index_location, instance_index_count, start_instance_location, instance_count); - wined3d_mutex_unlock(); }
static void STDMETHODCALLTYPE d3d10_device_DrawInstanced(ID3D10Device1 *iface, @@ -4857,10 +4723,8 @@ static void STDMETHODCALLTYPE d3d10_device_DrawInstanced(ID3D10Device1 *iface, "start_instance_location %u.\n", iface, instance_vertex_count, instance_count, start_vertex_location, start_instance_location);
- wined3d_mutex_lock(); wined3d_device_context_draw(device->immediate_context.wined3d_context, start_vertex_location, instance_vertex_count, start_instance_location, instance_count); - wined3d_mutex_unlock(); }
static void STDMETHODCALLTYPE d3d10_device_GSSetConstantBuffers(ID3D10Device1 *iface, @@ -4880,10 +4744,8 @@ static void STDMETHODCALLTYPE d3d10_device_GSSetShader(ID3D10Device1 *iface, ID3
TRACE("iface %p, shader %p.\n", iface, shader);
- wined3d_mutex_lock(); wined3d_device_context_set_shader(device->immediate_context.wined3d_context, WINED3D_SHADER_TYPE_GEOMETRY, gs ? gs->wined3d_shader : NULL); - wined3d_mutex_unlock(); }
static void STDMETHODCALLTYPE d3d10_device_IASetPrimitiveTopology(ID3D10Device1 *iface, @@ -4893,10 +4755,8 @@ static void STDMETHODCALLTYPE d3d10_device_IASetPrimitiveTopology(ID3D10Device1
TRACE("iface %p, topology %s.\n", iface, debug_d3d10_primitive_topology(topology));
- wined3d_mutex_lock(); wined3d_device_context_set_primitive_type(device->immediate_context.wined3d_context, (enum wined3d_primitive_type)topology, 0); - wined3d_mutex_unlock(); }
static void STDMETHODCALLTYPE d3d10_device_VSSetShaderResources(ID3D10Device1 *iface, @@ -4925,10 +4785,8 @@ static void STDMETHODCALLTYPE d3d10_device_SetPredication(ID3D10Device1 *iface, TRACE("iface %p, predicate %p, value %#x.\n", iface, predicate, value);
query = unsafe_impl_from_ID3D10Query((ID3D10Query *)predicate); - wined3d_mutex_lock(); wined3d_device_context_set_predication(device->immediate_context.wined3d_context, query ? query->wined3d_query : NULL, value); - wined3d_mutex_unlock(); }
static void STDMETHODCALLTYPE d3d10_device_GSSetShaderResources(ID3D10Device1 *iface, @@ -4974,12 +4832,10 @@ static void STDMETHODCALLTYPE d3d10_device_OMSetRenderTargets(ID3D10Device1 *ifa
dsv = unsafe_impl_from_ID3D10DepthStencilView(depth_stencil_view);
- wined3d_mutex_lock(); wined3d_device_context_set_rendertarget_views(device->immediate_context.wined3d_context, 0, ARRAY_SIZE(wined3d_rtvs), wined3d_rtvs, FALSE); wined3d_device_context_set_depth_stencil_view(device->immediate_context.wined3d_context, dsv ? dsv->wined3d_view : NULL); - wined3d_mutex_unlock(); }
static void STDMETHODCALLTYPE d3d10_device_OMSetBlendState(ID3D10Device1 *iface, @@ -5028,9 +4884,7 @@ static void STDMETHODCALLTYPE d3d10_device_SOSetTargets(ID3D10Device1 *iface, outputs[i].offset = offsets ? offsets[i] : 0; }
- wined3d_mutex_lock(); wined3d_device_context_set_stream_outputs(device->immediate_context.wined3d_context, outputs); - wined3d_mutex_unlock(); }
static void STDMETHODCALLTYPE d3d10_device_DrawAuto(ID3D10Device1 *iface) @@ -5072,9 +4926,7 @@ static void STDMETHODCALLTYPE d3d10_device_RSSetViewports(ID3D10Device1 *iface, wined3d_vp[i].max_z = viewports[i].MaxDepth; }
- wined3d_mutex_lock(); wined3d_device_context_set_viewports(device->immediate_context.wined3d_context, viewport_count, wined3d_vp); - wined3d_mutex_unlock(); }
static void STDMETHODCALLTYPE d3d10_device_RSSetScissorRects(ID3D10Device1 *iface, @@ -5087,9 +4939,7 @@ static void STDMETHODCALLTYPE d3d10_device_RSSetScissorRects(ID3D10Device1 *ifac if (rect_count > WINED3D_MAX_VIEWPORTS) return;
- wined3d_mutex_lock(); wined3d_device_context_set_scissor_rects(device->immediate_context.wined3d_context, rect_count, rects); - wined3d_mutex_unlock(); }
static void STDMETHODCALLTYPE d3d10_device_CopySubresourceRegion(ID3D10Device1 *iface, @@ -5114,11 +4964,9 @@ static void STDMETHODCALLTYPE d3d10_device_CopySubresourceRegion(ID3D10Device1 *
wined3d_dst_resource = wined3d_resource_from_d3d10_resource(dst_resource); wined3d_src_resource = wined3d_resource_from_d3d10_resource(src_resource); - wined3d_mutex_lock(); wined3d_device_context_copy_sub_resource_region(device->immediate_context.wined3d_context, wined3d_dst_resource, dst_subresource_idx, dst_x, dst_y, dst_z, wined3d_src_resource, src_subresource_idx, src_box ? &wined3d_src_box : NULL, 0); - wined3d_mutex_unlock(); }
static void STDMETHODCALLTYPE d3d10_device_CopyResource(ID3D10Device1 *iface, @@ -5131,10 +4979,8 @@ static void STDMETHODCALLTYPE d3d10_device_CopyResource(ID3D10Device1 *iface,
wined3d_dst_resource = wined3d_resource_from_d3d10_resource(dst_resource); wined3d_src_resource = wined3d_resource_from_d3d10_resource(src_resource); - wined3d_mutex_lock(); wined3d_device_context_copy_resource(device->immediate_context.wined3d_context, wined3d_dst_resource, wined3d_src_resource); - wined3d_mutex_unlock(); }
static void STDMETHODCALLTYPE d3d10_device_UpdateSubresource(ID3D10Device1 *iface, @@ -5167,11 +5013,9 @@ static void STDMETHODCALLTYPE d3d10_device_ClearRenderTargetView(ID3D10Device1 * if (!view) return;
- wined3d_mutex_lock(); if (FAILED(hr = wined3d_device_context_clear_rendertarget_view(device->immediate_context.wined3d_context, view->wined3d_view, NULL, WINED3DCLEAR_TARGET, &color, 0.0f, 0))) ERR("Failed to clear view, hr %#x.\n", hr); - wined3d_mutex_unlock(); }
static void STDMETHODCALLTYPE d3d10_device_ClearDepthStencilView(ID3D10Device1 *iface, @@ -5190,11 +5034,9 @@ static void STDMETHODCALLTYPE d3d10_device_ClearDepthStencilView(ID3D10Device1 *
wined3d_flags = wined3d_clear_flags_from_d3d11_clear_flags(flags);
- wined3d_mutex_lock(); if (FAILED(hr = wined3d_device_context_clear_rendertarget_view(device->immediate_context.wined3d_context, view->wined3d_view, NULL, wined3d_flags, NULL, depth, stencil))) ERR("Failed to clear view, hr %#x.\n", hr); - wined3d_mutex_unlock(); }
static void STDMETHODCALLTYPE d3d10_device_GenerateMips(ID3D10Device1 *iface, @@ -5205,9 +5047,7 @@ static void STDMETHODCALLTYPE d3d10_device_GenerateMips(ID3D10Device1 *iface,
TRACE("iface %p, view %p.\n", iface, view);
- wined3d_mutex_lock(); wined3d_device_context_generate_mipmaps(device->immediate_context.wined3d_context, srv->wined3d_view); - wined3d_mutex_unlock(); }
static void STDMETHODCALLTYPE d3d10_device_ResolveSubresource(ID3D10Device1 *iface, @@ -5226,11 +5066,9 @@ static void STDMETHODCALLTYPE d3d10_device_ResolveSubresource(ID3D10Device1 *ifa wined3d_dst_resource = wined3d_resource_from_d3d10_resource(dst_resource); wined3d_src_resource = wined3d_resource_from_d3d10_resource(src_resource); wined3d_format = wined3dformat_from_dxgi_format(format); - wined3d_mutex_lock(); wined3d_device_context_resolve_sub_resource(device->immediate_context.wined3d_context, wined3d_dst_resource, dst_subresource_idx, wined3d_src_resource, src_subresource_idx, wined3d_format); - wined3d_mutex_unlock(); }
static void STDMETHODCALLTYPE d3d10_device_VSGetConstantBuffers(ID3D10Device1 *iface, @@ -5891,9 +5729,7 @@ static void STDMETHODCALLTYPE d3d10_device_Flush(ID3D10Device1 *iface)
TRACE("iface %p.\n", iface);
- wined3d_mutex_lock(); wined3d_device_context_flush(device->immediate_context.wined3d_context); - wined3d_mutex_unlock(); }
static HRESULT STDMETHODCALLTYPE d3d10_device_CreateBuffer(ID3D10Device1 *iface, diff --git a/dlls/d3d11/inputlayout.c b/dlls/d3d11/inputlayout.c index 6b59dd994b3..520fa0ba7b3 100644 --- a/dlls/d3d11/inputlayout.c +++ b/dlls/d3d11/inputlayout.c @@ -138,9 +138,7 @@ static ULONG STDMETHODCALLTYPE d3d11_input_layout_AddRef(ID3D11InputLayout *ifac if (refcount == 1) { ID3D11Device2_AddRef(layout->device); - wined3d_mutex_lock(); wined3d_vertex_declaration_incref(layout->wined3d_decl); - wined3d_mutex_unlock(); }
return refcount; @@ -156,11 +154,7 @@ static ULONG STDMETHODCALLTYPE d3d11_input_layout_Release(ID3D11InputLayout *ifa if (!refcount) { ID3D11Device2 *device = layout->device; - - wined3d_mutex_lock(); wined3d_vertex_declaration_decref(layout->wined3d_decl); - wined3d_mutex_unlock(); - ID3D11Device2_Release(device); }
diff --git a/dlls/d3d11/shader.c b/dlls/d3d11/shader.c index 0d19b74ff0b..eec164a876c 100644 --- a/dlls/d3d11/shader.c +++ b/dlls/d3d11/shader.c @@ -69,9 +69,7 @@ static ULONG STDMETHODCALLTYPE d3d11_vertex_shader_AddRef(ID3D11VertexShader *if if (refcount == 1) { ID3D11Device2_AddRef(shader->device); - wined3d_mutex_lock(); wined3d_shader_incref(shader->wined3d_shader); - wined3d_mutex_unlock(); }
return refcount; @@ -88,9 +86,7 @@ static ULONG STDMETHODCALLTYPE d3d11_vertex_shader_Release(ID3D11VertexShader *i { ID3D11Device2 *device = shader->device;
- wined3d_mutex_lock(); wined3d_shader_decref(shader->wined3d_shader); - wined3d_mutex_unlock(); /* Release the device last, it may cause the wined3d device to be * destroyed. */ ID3D11Device2_Release(device); @@ -365,9 +361,7 @@ static ULONG STDMETHODCALLTYPE d3d11_hull_shader_AddRef(ID3D11HullShader *iface) if (refcount == 1) { ID3D11Device2_AddRef(shader->device); - wined3d_mutex_lock(); wined3d_shader_incref(shader->wined3d_shader); - wined3d_mutex_unlock(); }
return refcount; @@ -383,11 +377,7 @@ static ULONG STDMETHODCALLTYPE d3d11_hull_shader_Release(ID3D11HullShader *iface if (!refcount) { ID3D11Device2 *device = shader->device; - - wined3d_mutex_lock(); wined3d_shader_decref(shader->wined3d_shader); - wined3d_mutex_unlock(); - /* Release the device last, it may cause the wined3d device to be * destroyed. */ ID3D11Device2_Release(device); @@ -558,9 +548,7 @@ static ULONG STDMETHODCALLTYPE d3d11_domain_shader_AddRef(ID3D11DomainShader *if if (refcount == 1) { ID3D11Device2_AddRef(shader->device); - wined3d_mutex_lock(); wined3d_shader_incref(shader->wined3d_shader); - wined3d_mutex_unlock(); }
return refcount; @@ -576,11 +564,7 @@ static ULONG STDMETHODCALLTYPE d3d11_domain_shader_Release(ID3D11DomainShader *i if (!refcount) { ID3D11Device2 *device = shader->device; - - wined3d_mutex_lock(); wined3d_shader_decref(shader->wined3d_shader); - wined3d_mutex_unlock(); - /* Release the device last, it may cause the wined3d device to be * destroyed. */ ID3D11Device2_Release(device); @@ -761,9 +745,7 @@ static ULONG STDMETHODCALLTYPE d3d11_geometry_shader_AddRef(ID3D11GeometryShader if (refcount == 1) { ID3D11Device2_AddRef(shader->device); - wined3d_mutex_lock(); wined3d_shader_incref(shader->wined3d_shader); - wined3d_mutex_unlock(); }
return refcount; @@ -779,11 +761,7 @@ static ULONG STDMETHODCALLTYPE d3d11_geometry_shader_Release(ID3D11GeometryShade if (!refcount) { ID3D11Device2 *device = shader->device; - - wined3d_mutex_lock(); wined3d_shader_decref(shader->wined3d_shader); - wined3d_mutex_unlock(); - /* Release the device last, it may cause the wined3d device to be * destroyed. */ ID3D11Device2_Release(device); @@ -1265,9 +1243,7 @@ static ULONG STDMETHODCALLTYPE d3d11_pixel_shader_AddRef(ID3D11PixelShader *ifac if (refcount == 1) { ID3D11Device2_AddRef(shader->device); - wined3d_mutex_lock(); wined3d_shader_incref(shader->wined3d_shader); - wined3d_mutex_unlock(); }
return refcount; @@ -1283,10 +1259,7 @@ static ULONG STDMETHODCALLTYPE d3d11_pixel_shader_Release(ID3D11PixelShader *ifa if (!refcount) { ID3D11Device2 *device = shader->device; - - wined3d_mutex_lock(); wined3d_shader_decref(shader->wined3d_shader); - wined3d_mutex_unlock(); /* Release the device last, it may cause the wined3d device to be * destroyed. */ ID3D11Device2_Release(device); @@ -1560,9 +1533,7 @@ static ULONG STDMETHODCALLTYPE d3d11_compute_shader_AddRef(ID3D11ComputeShader * if (refcount == 1) { ID3D11Device2_AddRef(shader->device); - wined3d_mutex_lock(); wined3d_shader_incref(shader->wined3d_shader); - wined3d_mutex_unlock(); }
return refcount; @@ -1578,11 +1549,7 @@ static ULONG STDMETHODCALLTYPE d3d11_compute_shader_Release(ID3D11ComputeShader if (!refcount) { ID3D11Device2 *device = shader->device; - - wined3d_mutex_lock(); wined3d_shader_decref(shader->wined3d_shader); - wined3d_mutex_unlock(); - /* Release the device last, it may cause the wined3d device to be * destroyed. */ ID3D11Device2_Release(device); diff --git a/dlls/d3d11/state.c b/dlls/d3d11/state.c index d31ea16bbe8..810217c93b4 100644 --- a/dlls/d3d11/state.c +++ b/dlls/d3d11/state.c @@ -64,9 +64,7 @@ static ULONG STDMETHODCALLTYPE d3d11_blend_state_AddRef(ID3D11BlendState *iface) if (refcount == 1) { ID3D11Device2_AddRef(state->device); - wined3d_mutex_lock(); wined3d_blend_state_incref(state->wined3d_state); - wined3d_mutex_unlock(); }
return refcount; @@ -82,11 +80,7 @@ static ULONG STDMETHODCALLTYPE d3d11_blend_state_Release(ID3D11BlendState *iface if (!refcount) { ID3D11Device2 *device = state->device; - - wined3d_mutex_lock(); wined3d_blend_state_decref(state->wined3d_state); - wined3d_mutex_unlock(); - ID3D11Device2_Release(device); }
@@ -496,9 +490,7 @@ static ULONG STDMETHODCALLTYPE d3d11_depthstencil_state_AddRef(ID3D11DepthStenci if (refcount == 1) { ID3D11Device2_AddRef(state->device); - wined3d_mutex_lock(); wined3d_depth_stencil_state_incref(state->wined3d_state); - wined3d_mutex_unlock(); }
return refcount; @@ -515,9 +507,7 @@ static ULONG STDMETHODCALLTYPE d3d11_depthstencil_state_Release(ID3D11DepthStenc { ID3D11Device2 *device = state->device;
- wined3d_mutex_lock(); wined3d_depth_stencil_state_decref(state->wined3d_state); - wined3d_mutex_unlock(); ID3D11Device2_Release(device); }
@@ -896,9 +886,7 @@ static ULONG STDMETHODCALLTYPE d3d11_rasterizer_state_AddRef(ID3D11RasterizerSta if (refcount == 1) { ID3D11Device2_AddRef(state->device); - wined3d_mutex_lock(); wined3d_rasterizer_state_incref(state->wined3d_state); - wined3d_mutex_unlock(); }
return refcount; @@ -914,11 +902,7 @@ static ULONG STDMETHODCALLTYPE d3d11_rasterizer_state_Release(ID3D11RasterizerSt if (!refcount) { ID3D11Device2 *device = state->device; - - wined3d_mutex_lock(); wined3d_rasterizer_state_decref(state->wined3d_state); - wined3d_mutex_unlock(); - ID3D11Device2_Release(device); }
@@ -1284,9 +1268,7 @@ static ULONG STDMETHODCALLTYPE d3d11_sampler_state_AddRef(ID3D11SamplerState *if if (refcount == 1) { ID3D11Device2_AddRef(state->device); - wined3d_mutex_lock(); wined3d_sampler_incref(state->wined3d_sampler); - wined3d_mutex_unlock(); }
return refcount; @@ -1302,11 +1284,7 @@ static ULONG STDMETHODCALLTYPE d3d11_sampler_state_Release(ID3D11SamplerState *i if (!refcount) { ID3D11Device2 *device = state->device; - - wined3d_mutex_lock(); wined3d_sampler_decref(state->wined3d_sampler); - wined3d_mutex_unlock(); - ID3D11Device2_Release(device); }
diff --git a/dlls/d3d11/view.c b/dlls/d3d11/view.c index 734c9619e5b..89c541fa9ed 100644 --- a/dlls/d3d11/view.c +++ b/dlls/d3d11/view.c @@ -963,9 +963,7 @@ static ULONG STDMETHODCALLTYPE d3d11_depthstencil_view_AddRef(ID3D11DepthStencil if (refcount == 1) { ID3D11Device2_AddRef(view->device); - wined3d_mutex_lock(); wined3d_rendertarget_view_incref(view->wined3d_view); - wined3d_mutex_unlock(); }
return refcount; @@ -981,11 +979,7 @@ static ULONG STDMETHODCALLTYPE d3d11_depthstencil_view_Release(ID3D11DepthStenci if (!refcount) { ID3D11Device2 *device = view->device; - - wined3d_mutex_lock(); wined3d_rendertarget_view_decref(view->wined3d_view); - wined3d_mutex_unlock(); - ID3D11Device2_Release(device); }
@@ -1407,9 +1401,7 @@ static ULONG STDMETHODCALLTYPE d3d11_rendertarget_view_AddRef(ID3D11RenderTarget if (refcount == 1) { ID3D11Device2_AddRef(view->device); - wined3d_mutex_lock(); wined3d_rendertarget_view_incref(view->wined3d_view); - wined3d_mutex_unlock(); }
return refcount; @@ -1425,11 +1417,7 @@ static ULONG STDMETHODCALLTYPE d3d11_rendertarget_view_Release(ID3D11RenderTarge if (!refcount) { ID3D11Device2 *device = view->device; - - wined3d_mutex_lock(); wined3d_rendertarget_view_decref(view->wined3d_view); - wined3d_mutex_unlock(); - ID3D11Device2_Release(device); }
@@ -1855,9 +1843,7 @@ static ULONG STDMETHODCALLTYPE d3d11_shader_resource_view_AddRef(ID3D11ShaderRes if (refcount == 1) { ID3D11Device2_AddRef(view->device); - wined3d_mutex_lock(); wined3d_shader_resource_view_incref(view->wined3d_view); - wined3d_mutex_unlock(); }
return refcount; @@ -1873,11 +1859,7 @@ static ULONG STDMETHODCALLTYPE d3d11_shader_resource_view_Release(ID3D11ShaderRe if (!refcount) { ID3D11Device2 *device = view->device; - - wined3d_mutex_lock(); wined3d_shader_resource_view_decref(view->wined3d_view); - wined3d_mutex_unlock(); - ID3D11Device2_Release(device); }
@@ -2340,9 +2322,7 @@ static ULONG STDMETHODCALLTYPE d3d11_unordered_access_view_AddRef(ID3D11Unordere if (refcount == 1) { ID3D11Device2_AddRef(view->device); - wined3d_mutex_lock(); wined3d_unordered_access_view_incref(view->wined3d_view); - wined3d_mutex_unlock(); }
return refcount; @@ -2358,11 +2338,7 @@ static ULONG STDMETHODCALLTYPE d3d11_unordered_access_view_Release(ID3D11Unorder if (!refcount) { ID3D11Device2 *device = view->device; - - wined3d_mutex_lock(); wined3d_unordered_access_view_decref(view->wined3d_view); - wined3d_mutex_unlock(); - ID3D11Device2_Release(device); }
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=99648
Your paranoid android.
=== debiant2 (32 bit Chinese:China report) ===
d3d11: d3d11.c:9770: Test failed: d3d11.c:15250: Test marked todo: Test 60: Got unexpected color 0xffff0000 at (0, 1). d3d11.c:9770: Test failed: Got hr 0 for WRITE_DISCARD.
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;
On Thu, 7 Oct 2021 at 13:06, Jan Sikorski jsikorski@codeweavers.com wrote:
dlls/wined3d/arb_program_shader.c | 2 +- dlls/wined3d/glsl_shader.c | 2 +- dlls/wined3d/surface.c | 2 +- dlls/wined3d/texture.c | 217 ++++++++++++++++-------------- dlls/wined3d/wined3d_private.h | 1 + 5 files changed, 117 insertions(+), 107 deletions(-)
I'm guessing this is a consequence of patch 5/7, but this could do with a bit more of a commit message; at the very least for the benefit of future git-blame users.
+void wined3d_texture_destroy_temporary(struct wined3d_texture *texture) +{
- assert(texture->resource.ref == 1);
- wined3d_texture_destroy_object(texture);
- wined3d_resource_free_sysmem(&texture->resource);
- context_resource_released(texture->resource.device, &texture->resource);
- heap_free(texture);
+}
This seems fragile. We'd need to keep this in sync with the other cleanup path, and that path is not trivial. If this is purely about avoiding taking the lock on the CS thread, it would seem preferable to just check for that, using something similar to wined3d_from_cs()/wined3d_not_from_cs().
On 11 Oct 2021, at 17:40, Henri Verbeet hverbeet@gmail.com wrote:
On Thu, 7 Oct 2021 at 13:06, Jan Sikorski jsikorski@codeweavers.com wrote:
dlls/wined3d/arb_program_shader.c | 2 +- dlls/wined3d/glsl_shader.c | 2 +- dlls/wined3d/surface.c | 2 +- dlls/wined3d/texture.c | 217 ++++++++++++++++-------------- dlls/wined3d/wined3d_private.h | 1 + 5 files changed, 117 insertions(+), 107 deletions(-)
I'm guessing this is a consequence of patch 5/7, but this could do with a bit more of a commit message; at the very least for the benefit of future git-blame users.
+void wined3d_texture_destroy_temporary(struct wined3d_texture *texture) +{
- assert(texture->resource.ref == 1);
- wined3d_texture_destroy_object(texture);
- wined3d_resource_free_sysmem(&texture->resource);
- context_resource_released(texture->resource.device, &texture->resource);
- heap_free(texture);
+}
This seems fragile. We'd need to keep this in sync with the other cleanup path, and that path is not trivial. If this is purely about avoiding taking the lock on the CS thread, it would seem preferable to just check for that, using something similar to wined3d_from_cs()/wined3d_not_from_cs().
It’s not just that, adapter_destroy_texture calls wined3d_cs_destroy_object, which is wined3d_cs_emit_callback, and that races with the application thread emitting commands into the queue. Maybe that too could be made to behave differently depending on the thread and execute the callback immediately if it’s the CS, but it also seemed error prone and convoluted to me. I’ll see what more could be done to share this code.
- Jan
On Mon, 11 Oct 2021 at 18:17, Jan Sikorski jsikorski@codeweavers.com wrote:
On 11 Oct 2021, at 17:40, Henri Verbeet hverbeet@gmail.com wrote: This seems fragile. We'd need to keep this in sync with the other cleanup path, and that path is not trivial. If this is purely about avoiding taking the lock on the CS thread, it would seem preferable to just check for that, using something similar to wined3d_from_cs()/wined3d_not_from_cs().
It’s not just that, adapter_destroy_texture calls wined3d_cs_destroy_object, which is wined3d_cs_emit_callback, and that races with the application thread emitting commands into the queue. Maybe that too could be made to behave differently depending on the thread and execute the callback immediately if it’s the CS, but it also seemed error prone and convoluted to me. I’ll see what more could be done to share this code.
I don't think that's supposed to race[1], what happens exactly?
[1] In particular, note that wined3d_cs_mt_require_space()/wined3d_cs_mt_finish() will call wined3d_cs_st_require_space()/wined3d_cs_st_finish() when called from the CS thread. It has to work that way to allow calling those from the CS at all; consider what would happen to e.g. wined3d_texture_load_location() calls backed by the blitter otherwise, or e.g. trying to submit an operation while the queue is full.
On 11 Oct 2021, at 20:29, Henri Verbeet hverbeet@gmail.com wrote:
On Mon, 11 Oct 2021 at 18:17, Jan Sikorski jsikorski@codeweavers.com wrote:
On 11 Oct 2021, at 17:40, Henri Verbeet hverbeet@gmail.com wrote: This seems fragile. We'd need to keep this in sync with the other cleanup path, and that path is not trivial. If this is purely about avoiding taking the lock on the CS thread, it would seem preferable to just check for that, using something similar to wined3d_from_cs()/wined3d_not_from_cs().
It’s not just that, adapter_destroy_texture calls wined3d_cs_destroy_object, which is wined3d_cs_emit_callback, and that races with the application thread emitting commands into the queue. Maybe that too could be made to behave differently depending on the thread and execute the callback immediately if it’s the CS, but it also seemed error prone and convoluted to me. I’ll see what more could be done to share this code.
I don't think that's supposed to race[1], what happens exactly?
[1] In particular, note that wined3d_cs_mt_require_space()/wined3d_cs_mt_finish() will call wined3d_cs_st_require_space()/wined3d_cs_st_finish() when called from the CS thread. It has to work that way to allow calling those from the CS at all; consider what would happen to e.g. wined3d_texture_load_location() calls backed by the blitter otherwise, or e.g. trying to submit an operation while the queue is full.
Oh right, no, I didn’t observe any issues at runtime, I forgot that check was there and also didn’t notice there was a separate queue for the _st_ version. I guess conditional locking it is, which is maybe passable with an explanatory comment..
- Jan