Module: wine Branch: master Commit: 5813b93185aeb26ff0fca105d320cb92a9c39af7 URL: http://source.winehq.org/git/wine.git/?a=commit;h=5813b93185aeb26ff0fca105d3...
Author: Józef Kucia jkucia@codeweavers.com Date: Wed Apr 26 13:19:55 2017 +0200
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
---
dlls/d3d11/state.c | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-)
diff --git a/dlls/d3d11/state.c b/dlls/d3d11/state.c index c8e443f..b85bd67 100644 --- a/dlls/d3d11/state.c +++ b/dlls/d3d11/state.c @@ -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);