Commit 2437e355 authored by Józef Kucia's avatar Józef Kucia Committed by Alexandre Julliard

d3d11: Delay destroying render target view until it is no longer referenced.

parent 02a767cd
......@@ -1442,6 +1442,14 @@ static ULONG STDMETHODCALLTYPE d3d11_rendertarget_view_AddRef(ID3D11RenderTarget
TRACE("%p increasing refcount to %u.\n", view, refcount);
if (refcount == 1)
{
ID3D11Device_AddRef(view->device);
wined3d_mutex_lock();
wined3d_rendertarget_view_incref(view->wined3d_view);
wined3d_mutex_unlock();
}
return refcount;
}
......@@ -1454,12 +1462,13 @@ static ULONG STDMETHODCALLTYPE d3d11_rendertarget_view_Release(ID3D11RenderTarge
if (!refcount)
{
ID3D11Device *device = view->device;
wined3d_mutex_lock();
wined3d_rendertarget_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;
......@@ -1665,6 +1674,19 @@ static const struct ID3D10RenderTargetViewVtbl d3d10_rendertarget_view_vtbl =
d3d10_rendertarget_view_GetDesc,
};
static void STDMETHODCALLTYPE d3d_render_target_view_wined3d_object_destroyed(void *parent)
{
struct d3d_rendertarget_view *view = parent;
wined3d_private_store_cleanup(&view->private_store);
HeapFree(GetProcessHeap(), 0, parent);
}
static const struct wined3d_parent_ops d3d_render_target_view_wined3d_parent_ops =
{
d3d_render_target_view_wined3d_object_destroyed,
};
static void wined3d_rendertarget_view_desc_from_d3d11(struct wined3d_view_desc *wined3d_desc,
const D3D11_RENDER_TARGET_VIEW_DESC *desc)
{
......@@ -1766,7 +1788,7 @@ static HRESULT d3d_rendertarget_view_init(struct d3d_rendertarget_view *view, st
wined3d_rendertarget_view_desc_from_d3d11(&wined3d_desc, &view->desc);
if (FAILED(hr = wined3d_rendertarget_view_create(&wined3d_desc, wined3d_resource,
view, &d3d_null_wined3d_parent_ops, &view->wined3d_view)))
view, &d3d_render_target_view_wined3d_parent_ops, &view->wined3d_view)))
{
wined3d_mutex_unlock();
WARN("Failed to create a wined3d rendertarget view, hr %#x.\n", hr);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment