From d527ab4f6f5a9b027b6693eb1db71aa3390fed20 Mon Sep 17 00:00:00 2001
From: Johannes Specht <jojos_band@gmx.net>
Date: Thu, 31 Aug 2017 20:57:55 +0200
Subject: [PATCH] d3d11: Implement RsSetScissorRects for deferred contexts.

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

diff --git a/dlls/d3d11/device.c b/dlls/d3d11/device.c
index 5753855..b63f344 100644
--- a/dlls/d3d11/device.c
+++ b/dlls/d3d11/device.c
@@ -35,6 +35,7 @@ enum deferred_cmd
 
     DEFERRED_RSSETSTATE,                /* rstate_info */
     DEFERRED_RSSETVIEWPORTS,            /* viewport_info */
+    DEFERRED_RSSETSCISSORRECTS,         /* rs_set_scissor_rects_info */
 
     DEFERRED_OMSETDEPTHSTENCILSTATE,    /* stencil_state_info */
     DEFERRED_OMSETBLENDSTATE,           /* blend_state_info */
@@ -131,6 +132,11 @@ struct deferred_call
         } rstate_info;
         struct
         {
+            UINT rect_count;
+            D3D11_RECT *rects;
+        } rs_set_scissor_rects_info;
+        struct
+        {
             UINT num_viewports;
             D3D11_VIEWPORT *viewports;
         } viewport_info;
@@ -462,6 +468,10 @@ static void free_deferred_calls(struct list *commands)
             {
                 break; /* nothing to do */
             }
+            case DEFERRED_RSSETSCISSORRECTS:
+            {
+                break; /* nothing to do */
+            }
             case DEFERRED_OMSETDEPTHSTENCILSTATE:
             {
                 if (call->stencil_state_info.state)
@@ -729,6 +739,13 @@ static void exec_deferred_calls(ID3D11DeviceContext1 *iface, struct list *comman
                         call->viewport_info.viewports);
                 break;
             }
+            case DEFERRED_RSSETSCISSORRECTS:
+            {
+                ID3D11DeviceContext1_RSSetScissorRects(iface,
+                        call->rs_set_scissor_rects_info.rect_count,
+                        call->rs_set_scissor_rects_info.rects);
+                break;
+            }
             case DEFERRED_OMSETDEPTHSTENCILSTATE:
             {
                 ID3D11DeviceContext1_OMSetDepthStencilState(iface, call->stencil_state_info.state,
@@ -4770,7 +4787,18 @@ static void STDMETHODCALLTYPE d3d11_deferred_context_RSSetViewports(ID3D11Device
 static void STDMETHODCALLTYPE d3d11_deferred_context_RSSetScissorRects(ID3D11DeviceContext *iface,
         UINT rect_count, const D3D11_RECT *rects)
 {
-    FIXME("iface %p, rect_count %u, rects %p stub!\n", iface, rect_count, rects);
+    struct d3d11_deferred_context *context = impl_from_deferred_ID3D11DeviceContext(iface);
+    struct deferred_call *call;
+
+    TRACE("iface %p, rect_count %u, rects %p.\n", iface, rect_count, rects);
+
+    if (!(call = add_deferred_call(context, sizeof(D3D11_RECT) * rect_count)))
+        return;
+
+    call->cmd = DEFERRED_RSSETSCISSORRECTS;
+    call->rs_set_scissor_rects_info.rects = (void *)(call + 1);
+    call->rs_set_scissor_rects_info.rect_count = rect_count;
+    memcpy(call->rs_set_scissor_rects_info.rects, rects, sizeof(D3D11_RECT) * rect_count);
 }
 
 static void STDMETHODCALLTYPE d3d11_deferred_context_CopySubresourceRegion(ID3D11DeviceContext *iface,
-- 
1.9.1

