d3d11: Delay destroying sampler state until it is no longer referenced.
Implements D3D11 behavior. Signed-off-by: Józef Kucia <jkucia@codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
5b0fe9cee5
commit
5813b93185
|
@ -947,6 +947,14 @@ static ULONG STDMETHODCALLTYPE d3d11_sampler_state_AddRef(ID3D11SamplerState *if
|
|||
|
||||
TRACE("%p increasing refcount to %u.\n", state, refcount);
|
||||
|
||||
if (refcount == 1)
|
||||
{
|
||||
ID3D11Device_AddRef(state->device);
|
||||
wined3d_mutex_lock();
|
||||
wined3d_sampler_incref(state->wined3d_sampler);
|
||||
wined3d_mutex_unlock();
|
||||
}
|
||||
|
||||
return refcount;
|
||||
}
|
||||
|
||||
|
@ -959,15 +967,13 @@ static ULONG STDMETHODCALLTYPE d3d11_sampler_state_Release(ID3D11SamplerState *i
|
|||
|
||||
if (!refcount)
|
||||
{
|
||||
struct d3d_device *device = impl_from_ID3D11Device(state->device);
|
||||
ID3D11Device *device = state->device;
|
||||
|
||||
wined3d_mutex_lock();
|
||||
wined3d_sampler_decref(state->wined3d_sampler);
|
||||
wine_rb_remove(&device->sampler_states, &state->entry);
|
||||
ID3D11Device_Release(state->device);
|
||||
wined3d_private_store_cleanup(&state->private_store);
|
||||
wined3d_mutex_unlock();
|
||||
HeapFree(GetProcessHeap(), 0, state);
|
||||
|
||||
ID3D11Device_Release(device);
|
||||
}
|
||||
|
||||
return refcount;
|
||||
|
@ -1146,6 +1152,21 @@ static const struct ID3D10SamplerStateVtbl d3d10_sampler_state_vtbl =
|
|||
d3d10_sampler_state_GetDesc,
|
||||
};
|
||||
|
||||
static void STDMETHODCALLTYPE d3d_sampler_wined3d_object_destroyed(void *parent)
|
||||
{
|
||||
struct d3d_sampler_state *state = parent;
|
||||
struct d3d_device *device = impl_from_ID3D11Device(state->device);
|
||||
|
||||
wine_rb_remove(&device->sampler_states, &state->entry);
|
||||
wined3d_private_store_cleanup(&state->private_store);
|
||||
HeapFree(GetProcessHeap(), 0, parent);
|
||||
}
|
||||
|
||||
static const struct wined3d_parent_ops d3d_sampler_wined3d_parent_ops =
|
||||
{
|
||||
d3d_sampler_wined3d_object_destroyed,
|
||||
};
|
||||
|
||||
static enum wined3d_texture_address wined3d_texture_address_from_d3d11(enum D3D11_TEXTURE_ADDRESS_MODE t)
|
||||
{
|
||||
return (enum wined3d_texture_address)t;
|
||||
|
@ -1212,7 +1233,7 @@ HRESULT d3d_sampler_state_init(struct d3d_sampler_state *state, struct d3d_devic
|
|||
wined3d_desc.srgb_decode = TRUE;
|
||||
|
||||
if (FAILED(hr = wined3d_sampler_create(device->wined3d_device, &wined3d_desc,
|
||||
state, &d3d_null_wined3d_parent_ops, &state->wined3d_sampler)))
|
||||
state, &d3d_sampler_wined3d_parent_ops, &state->wined3d_sampler)))
|
||||
{
|
||||
WARN("Failed to create wined3d sampler, hr %#x.\n", hr);
|
||||
wined3d_private_store_cleanup(&state->private_store);
|
||||
|
|
Loading…
Reference in New Issue