From 27ae92005a2782ab4465f1d90cecc8c328a27bc7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Tue, 24 Jan 2017 05:06:12 +0100
Subject: [PATCH] d3d11: Implement ClearRenderTargetView for deferred contexts.

---
 dlls/d3d11/device.c | 33 ++++++++++++++++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)

diff --git a/dlls/d3d11/device.c b/dlls/d3d11/device.c
index 3c475e7..3c41fc3 100644
--- a/dlls/d3d11/device.c
+++ b/dlls/d3d11/device.c
@@ -67,6 +67,7 @@ enum deferred_cmd
     DEFERRED_DISPATCH,                  /* dispatch_info */
 
     DEFERRED_CLEARSTATE,
+    DEFERRED_CLEARRENDERTARGETVIEW,     /* clear_rtv_info */
 };
 
 struct deferred_call
@@ -202,6 +203,11 @@ struct deferred_call
             UINT count_y;
             UINT count_z;
         } dispatch_info;
+        struct
+        {
+            ID3D11RenderTargetView *rtv;
+            float color[4];
+        } clear_rtv_info;
     };
 };
 
@@ -462,6 +468,12 @@ static void free_deferred_calls(struct list *commands)
             {
                 break; /* nothing to do */
             }
+            case DEFERRED_CLEARRENDERTARGETVIEW:
+            {
+                if (call->clear_rtv_info.rtv)
+                    ID3D11RenderTargetView_Release(call->clear_rtv_info.rtv);
+                break;
+            }
             default:
             {
                 FIXME("Unimplemented command type %u\n", call->cmd);
@@ -660,6 +672,12 @@ static void exec_deferred_calls(ID3D11DeviceContext1 *iface, struct list *comman
                 ID3D11DeviceContext1_ClearState(iface);
                 break;
             }
+            case DEFERRED_CLEARRENDERTARGETVIEW:
+            {
+                ID3D11DeviceContext1_ClearRenderTargetView(iface, call->clear_rtv_info.rtv,
+                        call->clear_rtv_info.color);
+                break;
+            }
             default:
             {
                 FIXME("Unimplemented command type %u\n", call->cmd);
@@ -4316,8 +4334,21 @@ static void STDMETHODCALLTYPE d3d11_deferred_context_CopyStructureCount(ID3D11De
 static void STDMETHODCALLTYPE d3d11_deferred_context_ClearRenderTargetView(ID3D11DeviceContext *iface,
         ID3D11RenderTargetView *render_target_view, const float color_rgba[4])
 {
-    FIXME("iface %p, render_target_view %p, color_rgba %s stub!\n",
+    struct d3d11_deferred_context *context = impl_from_deferred_ID3D11DeviceContext(iface);
+    struct deferred_call *call;
+    int i;
+
+    TRACE("iface %p, render_target_view %p, color_rgba %s.\n",
             iface, render_target_view, debug_float4(color_rgba));
+
+    if (!(call = add_deferred_call(context, 0)))
+        return;
+
+    call->cmd = DEFERRED_CLEARRENDERTARGETVIEW;
+    if (render_target_view) ID3D11RenderTargetView_AddRef(render_target_view);
+    call->clear_rtv_info.rtv = render_target_view;
+    for (i = 0; i < 4; i++)
+        call->clear_rtv_info.color[i] = color_rgba[i];
 }
 
 static void STDMETHODCALLTYPE d3d11_deferred_context_ClearUnorderedAccessViewUint(ID3D11DeviceContext *iface,
-- 
1.9.1

