From c040d0aaf9fb1cff798a5c632b4f18f0c12e8282 Mon Sep 17 00:00:00 2001
From: Johannes Specht <jojos_band@gmx.net>
Date: Mon, 4 Sep 2017 02:30:32 +0200
Subject: [PATCH] d3d11: Implement ResolveSubresource for deferred contexts.

---
 dlls/d3d11/device.c | 47 +++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 45 insertions(+), 2 deletions(-)

diff --git a/dlls/d3d11/device.c b/dlls/d3d11/device.c
index 0c5360a..5709bf0 100644
--- a/dlls/d3d11/device.c
+++ b/dlls/d3d11/device.c
@@ -43,6 +43,7 @@ enum deferred_cmd
     DEFERRED_COPYRESOURCE,              /* copy_resource_info */
     DEFERRED_SETRESOURCEMINLOD,         /* set_resource_min_lod_info */
     DEFERRED_COPYSUBRESOURCEREGION,     /* copy_subresource_region_info */
+    DEFERRED_RESOLVESUBRESOURCE,        /* resolve_subresource_info */
 
     DEFERRED_CSSETSHADER,               /* cs_info */
     DEFERRED_DSSETSHADER,               /* ds_info */
@@ -166,6 +167,14 @@ struct deferred_call
         } copy_subresource_region_info;
         struct
         {
+            ID3D11Resource *dst_resource;
+            UINT dst_subresource_idx;
+            ID3D11Resource *src_resource;
+            UINT src_subresource_idx;
+            DXGI_FORMAT format;
+        } resolve_subresource_info;
+        struct
+        {
             ID3D11ComputeShader *shader;
             /* FIXME: add class instances */
         } cs_info;
@@ -463,6 +472,14 @@ static void free_deferred_calls(struct list *commands)
                     ID3D11Resource_Release(call->copy_subresource_region_info.src_resource);
                 break;
             }
+            case DEFERRED_RESOLVESUBRESOURCE:
+            {
+                if (call->resolve_subresource_info.dst_resource)
+                    ID3D11Resource_Release(call->resolve_subresource_info.dst_resource);
+                if (call->resolve_subresource_info.src_resource)
+                    ID3D11Resource_Release(call->resolve_subresource_info.src_resource);
+                break;
+            }
             case DEFERRED_CSSETSHADER:
             {
                 if (call->cs_info.shader)
@@ -687,6 +704,16 @@ static void exec_deferred_calls(ID3D11DeviceContext1 *iface, struct list *comman
                         call->copy_subresource_region_info.src_box);
                 break;
             }
+            case DEFERRED_RESOLVESUBRESOURCE:
+            {
+                ID3D11DeviceContext1_ResolveSubresource(iface,
+                        call->resolve_subresource_info.dst_resource,
+                        call->resolve_subresource_info.dst_subresource_idx,
+                        call->resolve_subresource_info.src_resource,
+                        call->resolve_subresource_info.src_subresource_idx,
+                        call->resolve_subresource_info.format);
+                break;
+            }
             case DEFERRED_CSSETSHADER:
             {
                 ID3D11DeviceContext1_CSSetShader(iface, call->cs_info.shader, NULL, 0);
@@ -4745,10 +4772,26 @@ static void STDMETHODCALLTYPE d3d11_deferred_context_ResolveSubresource(ID3D11De
         ID3D11Resource *src_resource, UINT src_subresource_idx,
         DXGI_FORMAT format)
 {
-    FIXME("iface %p, dst_resource %p, dst_subresource_idx %u, src_resource %p, src_subresource_idx %u, "
-            "format %s stub!\n",
+    struct d3d11_deferred_context *context = impl_from_deferred_ID3D11DeviceContext(iface);
+    struct deferred_call *call;
+
+    TRACE("iface %p, dst_resource %p, dst_subresource_idx %u, src_resource %p, src_subresource_idx %u, "
+            "format %s.\n",
             iface, dst_resource, dst_subresource_idx, src_resource, src_subresource_idx,
             debug_dxgi_format(format));
+
+    if (!(call = add_deferred_call(context, 0)))
+        return;
+
+    if (dst_resource) ID3D11Resource_AddRef(dst_resource);
+    if (src_resource) ID3D11Resource_AddRef(src_resource);
+
+    call->cmd = DEFERRED_RESOLVESUBRESOURCE;
+    call->resolve_subresource_info.dst_resource = dst_resource;
+    call->resolve_subresource_info.dst_subresource_idx = dst_subresource_idx;
+    call->resolve_subresource_info.src_resource = src_resource;
+    call->resolve_subresource_info.src_subresource_idx = src_subresource_idx;
+    call->resolve_subresource_info.format = format;
 }
 
 static void STDMETHODCALLTYPE d3d11_deferred_context_ExecuteCommandList(ID3D11DeviceContext *iface,
-- 
1.9.1

