wined3d: Make reference count decrementing functions thread safe.
Signed-off-by: Jan Sikorski <jsikorski@codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
b905ea81aa
commit
90cd8b0764
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -187,6 +187,7 @@ ULONG CDECL wined3d_decref(struct wined3d *wined3d)
|
|||
{
|
||||
unsigned int i;
|
||||
|
||||
wined3d_mutex_lock();
|
||||
for (i = 0; i < wined3d->adapter_count; ++i)
|
||||
{
|
||||
struct wined3d_adapter *adapter = wined3d->adapters[i];
|
||||
|
@ -194,6 +195,7 @@ ULONG CDECL wined3d_decref(struct wined3d *wined3d)
|
|||
adapter->adapter_ops->adapter_destroy(adapter);
|
||||
}
|
||||
heap_free(wined3d);
|
||||
wined3d_mutex_unlock();
|
||||
}
|
||||
|
||||
return refcount;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -3439,8 +3439,10 @@ ULONG CDECL wined3d_shader_decref(struct wined3d_shader *shader)
|
|||
|
||||
if (!refcount)
|
||||
{
|
||||
wined3d_mutex_lock();
|
||||
shader->parent_ops->wined3d_object_destroyed(shader->parent);
|
||||
wined3d_cs_destroy_object(shader->device->cs, wined3d_shader_destroy_object, shader);
|
||||
wined3d_mutex_unlock();
|
||||
}
|
||||
|
||||
return refcount;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -585,8 +585,10 @@ ULONG CDECL wined3d_stateblock_decref(struct wined3d_stateblock *stateblock)
|
|||
|
||||
if (!refcount)
|
||||
{
|
||||
wined3d_mutex_lock();
|
||||
wined3d_stateblock_state_cleanup(&stateblock->stateblock_state);
|
||||
heap_free(stateblock);
|
||||
wined3d_mutex_unlock();
|
||||
}
|
||||
|
||||
return refcount;
|
||||
|
|
|
@ -1536,6 +1536,11 @@ ULONG CDECL wined3d_texture_decref(struct wined3d_texture *texture)
|
|||
|
||||
if (!refcount)
|
||||
{
|
||||
bool in_cs_thread = GetCurrentThreadId() == texture->resource.device->cs->thread_id;
|
||||
|
||||
/* This is called from the CS thread to destroy temporary textures. */
|
||||
if (!in_cs_thread)
|
||||
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
|
||||
|
@ -1550,6 +1555,8 @@ ULONG CDECL wined3d_texture_decref(struct wined3d_texture *texture)
|
|||
}
|
||||
}
|
||||
texture->resource.device->adapter->adapter_ops->adapter_destroy_texture(texture);
|
||||
if (!in_cs_thread)
|
||||
wined3d_mutex_unlock();
|
||||
}
|
||||
|
||||
return refcount;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue