From 300aab481c30eddac58cbf7c9a418d3c0f7bb4e8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Tue, 24 Jan 2017 04:29:10 +0100
Subject: [PATCH] d3d11: Implement Dispatch 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 8fee8cd..b1f148a 100644
--- a/dlls/d3d11/device.c
+++ b/dlls/d3d11/device.c
@@ -62,6 +62,7 @@ enum deferred_cmd
     DEFERRED_DRAWINDEXEDINSTANCED,      /* draw_indexed_inst_info */
 
     DEFERRED_MAP,                       /* map_info */
+    DEFERRED_DISPATCH,                  /* dispatch_info */
 
     DEFERRED_CLEARSTATE,
 };
@@ -186,6 +187,12 @@ struct deferred_call
             void *buffer;
             UINT size;
         } map_info;
+        struct
+        {
+            UINT count_x;
+            UINT count_y;
+            UINT count_z;
+        } dispatch_info;
     };
 };
 
@@ -429,6 +436,10 @@ static void free_deferred_calls(struct list *commands)
                 ID3D11Resource_Release(call->map_info.resource);
                 break;
             }
+            case DEFERRED_DISPATCH:
+            {
+                break; /* nothing to do */
+            }
             case DEFERRED_CLEARSTATE:
             {
                 break; /* nothing to do */
@@ -614,6 +625,12 @@ static void exec_deferred_calls(ID3D11DeviceContext1 *iface, struct list *comman
 
                 break;
             }
+            case DEFERRED_DISPATCH:
+            {
+                ID3D11DeviceContext1_Dispatch(iface, call->dispatch_info.count_x,
+                        call->dispatch_info.count_y, call->dispatch_info.count_z);
+                break;
+            }
             case DEFERRED_CLEARSTATE:
             {
                 ID3D11DeviceContext1_ClearState(iface);
@@ -4181,8 +4198,19 @@ static void STDMETHODCALLTYPE d3d11_deferred_context_DrawInstancedIndirect(ID3D1
 static void STDMETHODCALLTYPE d3d11_deferred_context_Dispatch(ID3D11DeviceContext *iface,
         UINT thread_group_count_x, UINT thread_group_count_y, UINT thread_group_count_z)
 {
-    FIXME("iface %p, thread_group_count_x %u, thread_group_count_y %u, thread_group_count_z %u stub!\n",
+    struct d3d11_deferred_context *context = impl_from_deferred_ID3D11DeviceContext(iface);
+    struct deferred_call *call;
+
+    TRACE("iface %p, thread_group_count_x %u, thread_group_count_y %u, thread_group_count_z %u.\n",
             iface, thread_group_count_x, thread_group_count_y, thread_group_count_z);
+
+    if (!(call = add_deferred_call(context, 0)))
+        return;
+
+    call->cmd = DEFERRED_DISPATCH;
+    call->dispatch_info.count_x = thread_group_count_x;
+    call->dispatch_info.count_y = thread_group_count_y;
+    call->dispatch_info.count_z = thread_group_count_z;
 }
 
 static void STDMETHODCALLTYPE d3d11_deferred_context_DispatchIndirect(ID3D11DeviceContext *iface,
-- 
1.9.1

