From 526c4612c8d3a1665a55fcd4bfa8091fb5b2db01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3zef=20Kucia?= Date: Tue, 15 Mar 2016 10:52:50 +0100 Subject: [PATCH] d3d11: Implement d3d11_immediate_context_ClearDepthStencilView(). 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 | 1 + dlls/d3d11/device.c | 17 +++++++++++++++-- dlls/d3d11/utils.c | 18 ++++++++++++++++++ 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/dlls/d3d11/d3d11_private.h b/dlls/d3d11/d3d11_private.h index 072afb4c9ce..a83a754759b 100644 --- a/dlls/d3d11/d3d11_private.h +++ b/dlls/d3d11/d3d11_private.h @@ -67,6 +67,7 @@ DWORD wined3d_usage_from_d3d11(UINT bind_flags, enum D3D11_USAGE usage) DECLSPEC struct wined3d_resource *wined3d_resource_from_d3d11_resource(ID3D11Resource *resource) DECLSPEC_HIDDEN; struct wined3d_resource *wined3d_resource_from_d3d10_resource(ID3D10Resource *resource) DECLSPEC_HIDDEN; DWORD wined3d_map_flags_from_d3d11_map_type(D3D11_MAP map_type) DECLSPEC_HIDDEN; +DWORD wined3d_clear_flags_from_d3d11_clear_flags(UINT clear_flags) DECLSPEC_HIDDEN; enum D3D11_USAGE d3d11_usage_from_d3d10_usage(enum D3D10_USAGE usage) DECLSPEC_HIDDEN; enum D3D10_USAGE d3d10_usage_from_d3d11_usage(enum D3D11_USAGE usage) DECLSPEC_HIDDEN; diff --git a/dlls/d3d11/device.c b/dlls/d3d11/device.c index 0be9331a484..b820383edef 100644 --- a/dlls/d3d11/device.c +++ b/dlls/d3d11/device.c @@ -905,7 +905,7 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_ClearRenderTargetView(ID3D const struct wined3d_color color = {color_rgba[0], color_rgba[1], color_rgba[2], color_rgba[3]}; HRESULT hr; - TRACE("iface %p, render_target_view %p, color_rgba {%.8e %.8e %.8e %.8e}.\n", + TRACE("iface %p, render_target_view %p, color_rgba {%.8e, %.8e, %.8e, %.8e}.\n", iface, render_target_view, color_rgba[0], color_rgba[1], color_rgba[2], color_rgba[3]); wined3d_mutex_lock(); @@ -932,8 +932,21 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_ClearUnorderedAccessViewFl static void STDMETHODCALLTYPE d3d11_immediate_context_ClearDepthStencilView(ID3D11DeviceContext *iface, ID3D11DepthStencilView *depth_stencil_view, UINT flags, FLOAT depth, UINT8 stencil) { - FIXME("iface %p, depth_stencil_view %p, flags %#x, depth %f, stencil %u stub!\n", + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d_depthstencil_view *view = unsafe_impl_from_ID3D11DepthStencilView(depth_stencil_view); + DWORD wined3d_flags; + HRESULT hr; + + TRACE("iface %p, depth_stencil_view %p, flags %#x, depth %.8e, stencil %u.\n", iface, depth_stencil_view, flags, depth, stencil); + + wined3d_flags = wined3d_clear_flags_from_d3d11_clear_flags(flags); + + wined3d_mutex_lock(); + if (FAILED(hr = wined3d_device_clear_rendertarget_view(device->wined3d_device, view->wined3d_view, NULL, + wined3d_flags, NULL, depth, stencil))) + ERR("Failed to clear view, hr %#x.\n", hr); + wined3d_mutex_unlock(); } static void STDMETHODCALLTYPE d3d11_immediate_context_GenerateMips(ID3D11DeviceContext *iface, diff --git a/dlls/d3d11/utils.c b/dlls/d3d11/utils.c index d05ff3dc4dd..6d50de5ae39 100644 --- a/dlls/d3d11/utils.c +++ b/dlls/d3d11/utils.c @@ -593,6 +593,24 @@ DWORD wined3d_map_flags_from_d3d11_map_type(D3D11_MAP map_type) } } +DWORD wined3d_clear_flags_from_d3d11_clear_flags(UINT clear_flags) +{ + DWORD wined3d_clear_flags = 0; + + if (clear_flags & D3D11_CLEAR_DEPTH) + wined3d_clear_flags |= WINED3DCLEAR_ZBUFFER; + if (clear_flags & D3D11_CLEAR_STENCIL) + wined3d_clear_flags |= WINED3DCLEAR_STENCIL; + + if (clear_flags & ~(D3D11_CLEAR_DEPTH | D3D11_CLEAR_STENCIL)) + { + FIXME("Unhandled clear flags %#x.\n", + clear_flags & ~(D3D11_CLEAR_DEPTH | D3D11_CLEAR_STENCIL)); + } + + return wined3d_clear_flags; +} + HRESULT d3d_get_private_data(struct wined3d_private_store *store, REFGUID guid, UINT *data_size, void *data) {