From 9a0d564683855e1a01ffcb926c9cb1653a7ff669 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3zef=20Kucia?= Date: Wed, 9 Sep 2015 01:35:45 +0200 Subject: [PATCH] d3d11: Implement d3d11_device_CreateRenderTargetView(). --- dlls/d3d11/d3d11_private.h | 4 ++-- dlls/d3d11/device.c | 31 +++++++++++++++---------------- dlls/d3d11/view.c | 24 +++++++++++++++++++++++- 3 files changed, 40 insertions(+), 19 deletions(-) diff --git a/dlls/d3d11/d3d11_private.h b/dlls/d3d11/d3d11_private.h index e950bcd6a21..cddef4d3960 100644 --- a/dlls/d3d11/d3d11_private.h +++ b/dlls/d3d11/d3d11_private.h @@ -184,8 +184,8 @@ struct d3d_rendertarget_view ID3D10Device1 *device; }; -HRESULT d3d_rendertarget_view_init(struct d3d_rendertarget_view *view, struct d3d_device *device, - ID3D11Resource *resource, const D3D11_RENDER_TARGET_VIEW_DESC *desc) DECLSPEC_HIDDEN; +HRESULT d3d_rendertarget_view_create(struct d3d_device *device, ID3D11Resource *resource, + const D3D11_RENDER_TARGET_VIEW_DESC *desc, struct d3d_rendertarget_view **view) DECLSPEC_HIDDEN; struct d3d_rendertarget_view *unsafe_impl_from_ID3D10RenderTargetView(ID3D10RenderTargetView *iface) DECLSPEC_HIDDEN; /* ID3D10ShaderResourceView */ diff --git a/dlls/d3d11/device.c b/dlls/d3d11/device.c index 5e1f9e00d5e..e866f717930 100644 --- a/dlls/d3d11/device.c +++ b/dlls/d3d11/device.c @@ -135,9 +135,19 @@ static HRESULT STDMETHODCALLTYPE d3d11_device_CreateUnorderedAccessView(ID3D11De static HRESULT STDMETHODCALLTYPE d3d11_device_CreateRenderTargetView(ID3D11Device *iface, ID3D11Resource *resource, const D3D11_RENDER_TARGET_VIEW_DESC *desc, ID3D11RenderTargetView **view) { - FIXME("iface %p, resource %p, desc %p, view %p stub!\n", iface, resource, desc, view); + struct d3d_device *device = impl_from_ID3D11Device(iface); + struct d3d_rendertarget_view *object; + HRESULT hr; + + TRACE("iface %p, resource %p, desc %p, view %p.\n", iface, resource, desc, view); + + if (FAILED(hr = d3d_rendertarget_view_create(device, resource, desc, &object))) + return hr; + + *view = &object->ID3D11RenderTargetView_iface; + + return S_OK; - return E_NOTIMPL; } static HRESULT STDMETHODCALLTYPE d3d11_device_CreateDepthStencilView(ID3D11Device *iface, @@ -2128,28 +2138,17 @@ static HRESULT STDMETHODCALLTYPE d3d10_device_CreateRenderTargetView(ID3D10Devic TRACE("iface %p, resource %p, desc %p, view %p.\n", iface, resource, desc, view); - if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)))) - return E_OUTOFMEMORY; - if (FAILED(hr = ID3D10Resource_QueryInterface(resource, &IID_ID3D11Resource, (void **)&d3d11_resource))) { ERR("Resource does not implement ID3D11Resource.\n"); - HeapFree(GetProcessHeap(), 0, object); return E_FAIL; } - if (FAILED(hr = d3d_rendertarget_view_init(object, device, d3d11_resource, - (const D3D11_RENDER_TARGET_VIEW_DESC *)desc))) - { - WARN("Failed to initialize rendertarget view, hr %#x.\n", hr); - HeapFree(GetProcessHeap(), 0, object); - ID3D11Resource_Release(d3d11_resource); - return hr; - } - + hr = d3d_rendertarget_view_create(device, d3d11_resource, (const D3D11_RENDER_TARGET_VIEW_DESC *)desc, &object); ID3D11Resource_Release(d3d11_resource); + if (FAILED(hr)) + return hr; - TRACE("Created rendertarget view %p.\n", object); *view = &object->ID3D10RenderTargetView_iface; return S_OK; diff --git a/dlls/d3d11/view.c b/dlls/d3d11/view.c index c30e12d6308..195cd73073f 100644 --- a/dlls/d3d11/view.c +++ b/dlls/d3d11/view.c @@ -1095,7 +1095,7 @@ static void wined3d_rendertarget_view_desc_from_d3d11(struct wined3d_rendertarge } } -HRESULT d3d_rendertarget_view_init(struct d3d_rendertarget_view *view, struct d3d_device *device, +static HRESULT d3d_rendertarget_view_init(struct d3d_rendertarget_view *view, struct d3d_device *device, ID3D11Resource *resource, const D3D11_RENDER_TARGET_VIEW_DESC *desc) { struct wined3d_rendertarget_view_desc wined3d_desc; @@ -1143,6 +1143,28 @@ HRESULT d3d_rendertarget_view_init(struct d3d_rendertarget_view *view, struct d3 return S_OK; } +HRESULT d3d_rendertarget_view_create(struct d3d_device *device, ID3D11Resource *resource, + const D3D11_RENDER_TARGET_VIEW_DESC *desc, struct d3d_rendertarget_view **view) +{ + struct d3d_rendertarget_view *object; + HRESULT hr; + + if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)))) + return E_OUTOFMEMORY; + + if (FAILED(hr = d3d_rendertarget_view_init(object, device, resource, desc))) + { + WARN("Failed to initialize rendertarget view, hr %#x.\n", hr); + HeapFree(GetProcessHeap(), 0, object); + return hr; + } + + TRACE("Created rendertarget view %p.\n", object); + *view = object; + + return S_OK; +} + struct d3d_rendertarget_view *unsafe_impl_from_ID3D10RenderTargetView(ID3D10RenderTargetView *iface) { if (!iface)