From 98b443232d7d86ab2eb30182a11ba2c5b660c878 Mon Sep 17 00:00:00 2001
From: Johannes Specht <jojos_band@gmx.net>
Date: Mon, 4 Sep 2017 02:19:00 +0200
Subject: [PATCH] d3d11: Implement SetResourceMinLOD 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 242a758..22e2c8f 100644
--- a/dlls/d3d11/device.c
+++ b/dlls/d3d11/device.c
@@ -41,6 +41,7 @@ enum deferred_cmd
     DEFERRED_OMSETRENDERTARGETS,        /* render_target_info */
 
     DEFERRED_COPYRESOURCE,              /* copy_resource_info */
+    DEFERRED_SETRESOURCEMINLOD,         /* set_resource_min_lod_info */
 
     DEFERRED_CSSETSHADER,               /* cs_info */
     DEFERRED_DSSETSHADER,               /* ds_info */
@@ -148,6 +149,11 @@ struct deferred_call
         } copy_resource_info;
         struct
         {
+            ID3D11Resource *resource;
+            FLOAT min_lod;
+        } set_resource_min_lod_info;
+        struct
+        {
             ID3D11ComputeShader *shader;
             /* FIXME: add class instances */
         } cs_info;
@@ -431,6 +437,12 @@ static void free_deferred_calls(struct list *commands)
                     ID3D11Resource_Release(call->copy_resource_info.src_resource);
                 break;
             }
+            case DEFERRED_SETRESOURCEMINLOD:
+            {
+                if (call->set_resource_min_lod_info.resource)
+                    ID3D11Resource_Release(call->set_resource_min_lod_info.resource);
+                break;
+            }
             case DEFERRED_CSSETSHADER:
             {
                 if (call->cs_info.shader)
@@ -635,6 +647,13 @@ static void exec_deferred_calls(ID3D11DeviceContext1 *iface, struct list *comman
                         call->copy_resource_info.src_resource);
                 break;
             }
+            case DEFERRED_SETRESOURCEMINLOD:
+            {
+                ID3D11DeviceContext1_SetResourceMinLOD(iface,
+                        call->set_resource_min_lod_info.resource,
+                        call->set_resource_min_lod_info.min_lod);
+                break;
+            }
             case DEFERRED_CSSETSHADER:
             {
                 ID3D11DeviceContext1_CSSetShader(iface, call->cs_info.shader, NULL, 0);
@@ -4639,7 +4658,18 @@ static void STDMETHODCALLTYPE d3d11_deferred_context_GenerateMips(ID3D11DeviceCo
 static void STDMETHODCALLTYPE d3d11_deferred_context_SetResourceMinLOD(ID3D11DeviceContext *iface,
         ID3D11Resource *resource, FLOAT min_lod)
 {
-    FIXME("iface %p, resource %p, min_lod %f stub!\n", iface, resource, min_lod);
+    struct d3d11_deferred_context *context = impl_from_deferred_ID3D11DeviceContext(iface);
+    struct deferred_call *call;
+
+    TRACE("iface %p, resource %p, min_lod %f.\n", iface, resource, min_lod);
+
+    if (!(call = add_deferred_call(context, 0)))
+        return;
+
+    call->cmd = DEFERRED_SETRESOURCEMINLOD;
+    if (resource) ID3D11Resource_AddRef(resource);
+    call->set_resource_min_lod_info.resource = resource;
+    call->set_resource_min_lod_info.min_lod = min_lod;
 }
 
 static FLOAT STDMETHODCALLTYPE d3d11_deferred_context_GetResourceMinLOD(ID3D11DeviceContext *iface,
-- 
1.9.1

