From 5b305503112613c952b39e00003da1a1bfd30d3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3zef=20Kucia?= Date: Thu, 27 Apr 2017 12:02:50 +0200 Subject: [PATCH] d3d11: Delay destroying unordered access view until it is no longer referenced. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Józef Kucia Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- dlls/d3d11/d3d11_private.h | 2 -- dlls/d3d11/device.c | 2 +- dlls/d3d11/view.c | 30 ++++++++++++++++++++++++++---- 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/dlls/d3d11/d3d11_private.h b/dlls/d3d11/d3d11_private.h index a8987cbd7aa..cbc8d7c66d0 100644 --- a/dlls/d3d11/d3d11_private.h +++ b/dlls/d3d11/d3d11_private.h @@ -54,8 +54,6 @@ struct d3d_device; -extern const struct wined3d_parent_ops d3d_null_wined3d_parent_ops DECLSPEC_HIDDEN; - /* TRACE helper functions */ const char *debug_d3d10_primitive_topology(D3D10_PRIMITIVE_TOPOLOGY topology) DECLSPEC_HIDDEN; const char *debug_dxgi_format(DXGI_FORMAT format) DECLSPEC_HIDDEN; diff --git a/dlls/d3d11/device.c b/dlls/d3d11/device.c index c5ead363c42..259f189f8af 100644 --- a/dlls/d3d11/device.c +++ b/dlls/d3d11/device.c @@ -27,7 +27,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d11); static void STDMETHODCALLTYPE d3d_null_wined3d_object_destroyed(void *parent) {} -const struct wined3d_parent_ops d3d_null_wined3d_parent_ops = +static const struct wined3d_parent_ops d3d_null_wined3d_parent_ops = { d3d_null_wined3d_object_destroyed, }; diff --git a/dlls/d3d11/view.c b/dlls/d3d11/view.c index f1478ba0de0..f747c4bfdea 100644 --- a/dlls/d3d11/view.c +++ b/dlls/d3d11/view.c @@ -2377,6 +2377,14 @@ static ULONG STDMETHODCALLTYPE d3d11_unordered_access_view_AddRef(ID3D11Unordere TRACE("%p increasing refcount to %u.\n", view, refcount); + if (refcount == 1) + { + ID3D11Device_AddRef(view->device); + wined3d_mutex_lock(); + wined3d_unordered_access_view_incref(view->wined3d_view); + wined3d_mutex_unlock(); + } + return refcount; } @@ -2389,12 +2397,13 @@ static ULONG STDMETHODCALLTYPE d3d11_unordered_access_view_Release(ID3D11Unorder if (!refcount) { + ID3D11Device *device = view->device; + wined3d_mutex_lock(); wined3d_unordered_access_view_decref(view->wined3d_view); - ID3D11Device_Release(view->device); - wined3d_private_store_cleanup(&view->private_store); wined3d_mutex_unlock(); - HeapFree(GetProcessHeap(), 0, view); + + ID3D11Device_Release(device); } return refcount; @@ -2477,6 +2486,19 @@ static const struct ID3D11UnorderedAccessViewVtbl d3d11_unordered_access_view_vt d3d11_unordered_access_view_GetDesc, }; +static void STDMETHODCALLTYPE d3d11_unordered_access_view_wined3d_object_destroyed(void *parent) +{ + struct d3d11_unordered_access_view *view = parent; + + wined3d_private_store_cleanup(&view->private_store); + HeapFree(GetProcessHeap(), 0, parent); +} + +static const struct wined3d_parent_ops d3d11_unordered_access_view_wined3d_parent_ops = +{ + d3d11_unordered_access_view_wined3d_object_destroyed, +}; + static unsigned int wined3d_view_flags_from_d3d11_buffer_uav_flags(unsigned int d3d11_flags) { unsigned int wined3d_flags = d3d11_flags & (WINED3D_VIEW_BUFFER_RAW @@ -2577,7 +2599,7 @@ static HRESULT d3d11_unordered_access_view_init(struct d3d11_unordered_access_vi } if (FAILED(hr = wined3d_unordered_access_view_create(&wined3d_desc, wined3d_resource, - view, &d3d_null_wined3d_parent_ops, &view->wined3d_view))) + view, &d3d11_unordered_access_view_wined3d_parent_ops, &view->wined3d_view))) { wined3d_mutex_unlock(); WARN("Failed to create wined3d unordered access view, hr %#x.\n", hr);