From bcf5cc6f8d056a6406dccc301ce301ab8e063f56 Mon Sep 17 00:00:00 2001
From: Johannes Specht <jojos_band@gmx.net>
Date: Mon, 4 Sep 2017 04:22:04 +0200
Subject: [PATCH] d3d11: Implement DispatchIndirect for deferred contexts.

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

diff --git a/dlls/d3d11/device.c b/dlls/d3d11/device.c
index 1ed5010..0f710a4 100644
--- a/dlls/d3d11/device.c
+++ b/dlls/d3d11/device.c
@@ -90,6 +90,7 @@ enum deferred_cmd
 
     DEFERRED_MAP,                       /* map_info */
     DEFERRED_DISPATCH,                  /* dispatch_info */
+    DEFERRED_DISPATCHINDIRECT,          /* dispatch_indirect_info */
 
     DEFERRED_CLEARSTATE,
     DEFERRED_CLEARRENDERTARGETVIEW,     /* clear_rtv_info */
@@ -314,6 +315,11 @@ struct deferred_call
         } dispatch_info;
         struct
         {
+            ID3D11Buffer *buffer;
+            UINT offset;
+        } dispatch_indirect_info;
+        struct
+        {
             ID3D11ShaderResourceView *view;
         } generate_mips_info;
         struct
@@ -704,6 +710,12 @@ static void free_deferred_calls(struct list *commands)
             {
                 break; /* nothing to do */
             }
+            case DEFERRED_DISPATCHINDIRECT:
+            {
+                if (call->dispatch_indirect_info.buffer)
+                    ID3D11Buffer_Release(call->dispatch_indirect_info.buffer);
+                break;
+            }
             case DEFERRED_CLEARSTATE:
             {
                 break; /* nothing to do */
@@ -1102,6 +1114,13 @@ static void exec_deferred_calls(ID3D11DeviceContext1 *iface, struct list *comman
                         call->dispatch_info.count_y, call->dispatch_info.count_z);
                 break;
             }
+            case DEFERRED_DISPATCHINDIRECT:
+            {
+                ID3D11DeviceContext1_DispatchIndirect(iface,
+                        call->dispatch_indirect_info.buffer,
+                        call->dispatch_indirect_info.offset);
+                break;
+            }
             case DEFERRED_CLEARSTATE:
             {
                 ID3D11DeviceContext1_ClearState(iface);
@@ -4881,7 +4900,18 @@ static void STDMETHODCALLTYPE d3d11_deferred_context_Dispatch(ID3D11DeviceContex
 static void STDMETHODCALLTYPE d3d11_deferred_context_DispatchIndirect(ID3D11DeviceContext *iface,
         ID3D11Buffer *buffer, UINT offset)
 {
-    FIXME("iface %p, buffer %p, offset %u stub!\n", iface, buffer, offset);
+    struct d3d11_deferred_context *context = impl_from_deferred_ID3D11DeviceContext(iface);
+    struct deferred_call *call;
+
+    TRACE("iface %p, buffer %p, offset %u.\n", iface, buffer, offset);
+
+    if (!(call = add_deferred_call(context, 0)))
+        return;
+
+    call->cmd = DEFERRED_DISPATCHINDIRECT;
+    if (buffer) ID3D11Buffer_AddRef(buffer);
+    call->dispatch_indirect_info.buffer = buffer;
+    call->dispatch_indirect_info.offset = offset;
 }
 
 static void STDMETHODCALLTYPE d3d11_deferred_context_RSSetState(ID3D11DeviceContext *iface,
-- 
1.9.1

