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

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

diff --git a/dlls/d3d11/device.c b/dlls/d3d11/device.c
index 728a90b..1ed5010 100644
--- a/dlls/d3d11/device.c
+++ b/dlls/d3d11/device.c
@@ -78,6 +78,7 @@ enum deferred_cmd
 
     DEFERRED_CSSETUNORDEREDACCESSVIEWS, /* unordered_view */
     DEFERRED_SOSETTARGETS,              /* so_set_targets_info */
+    DEFERRED_GENERATEMIPS,              /* generate_mips_info */
 
     DEFERRED_DRAW,                      /* draw_info */
     DEFERRED_DRAWINDEXED,               /* draw_indexed_info */
@@ -313,6 +314,10 @@ struct deferred_call
         } dispatch_info;
         struct
         {
+            ID3D11ShaderResourceView *view;
+        } generate_mips_info;
+        struct
+        {
             ID3D11RenderTargetView *rtv;
             float color[4];
         } clear_rtv_info;
@@ -663,6 +668,12 @@ static void free_deferred_calls(struct list *commands)
                 }
                 break;
             }
+            case DEFERRED_GENERATEMIPS:
+            {
+                if (call->generate_mips_info.view)
+                    ID3D11ShaderResourceView_Release(call->generate_mips_info.view);
+                break;
+            }
             case DEFERRED_DRAW:
             case DEFERRED_DRAWINDEXED:
             case DEFERRED_DRAWINDEXEDINSTANCED:
@@ -1016,6 +1027,12 @@ static void exec_deferred_calls(ID3D11DeviceContext1 *iface, struct list *comman
                         call->so_set_targets_info.offsets);
                 break;
             }
+            case DEFERRED_GENERATEMIPS:
+            {
+                ID3D11DeviceContext1_GenerateMips(iface,
+                        call->generate_mips_info.view);
+                break;
+            }
             case DEFERRED_DRAW:
             {
                 ID3D11DeviceContext1_Draw(iface, call->draw_info.count, call->draw_info.start);
@@ -5085,7 +5102,17 @@ static void STDMETHODCALLTYPE d3d11_deferred_context_ClearDepthStencilView(ID3D1
 static void STDMETHODCALLTYPE d3d11_deferred_context_GenerateMips(ID3D11DeviceContext *iface,
         ID3D11ShaderResourceView *view)
 {
-    FIXME("iface %p, view %p stub!\n", iface, view);
+    struct d3d11_deferred_context *context = impl_from_deferred_ID3D11DeviceContext(iface);
+    struct deferred_call *call;
+
+    TRACE("iface %p, view %p.\n", iface, view);
+
+    if (!(call = add_deferred_call(context, 0)))
+        return;
+
+    call->cmd = DEFERRED_GENERATEMIPS;
+    if (view) ID3D11ShaderResourceView_AddRef(view);
+    call->generate_mips_info.view = view;
 }
 
 static void STDMETHODCALLTYPE d3d11_deferred_context_SetResourceMinLOD(ID3D11DeviceContext *iface,
-- 
1.9.1

