From e9e4f687334712d9e63ffbd1727b485d6ed6059b Mon Sep 17 00:00:00 2001
From: Johannes Specht <jojos_band@gmx.net>
Date: Thu, 31 Aug 2017 20:24:35 +0200
Subject: [PATCH] d3d11: Implement CopyResource for deferred contexts.

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

diff --git a/dlls/d3d11/device.c b/dlls/d3d11/device.c
index 67feab6..242a758 100644
--- a/dlls/d3d11/device.c
+++ b/dlls/d3d11/device.c
@@ -40,6 +40,8 @@ enum deferred_cmd
     DEFERRED_OMSETBLENDSTATE,           /* blend_state_info */
     DEFERRED_OMSETRENDERTARGETS,        /* render_target_info */
 
+    DEFERRED_COPYRESOURCE,              /* copy_resource_info */
+
     DEFERRED_CSSETSHADER,               /* cs_info */
     DEFERRED_DSSETSHADER,               /* ds_info */
     DEFERRED_GSSETSHADER,               /* gs_info */
@@ -141,6 +143,11 @@ struct deferred_call
         } render_target_info;
         struct
         {
+            ID3D11Resource *dst_resource;
+            ID3D11Resource *src_resource;
+        } copy_resource_info;
+        struct
+        {
             ID3D11ComputeShader *shader;
             /* FIXME: add class instances */
         } cs_info;
@@ -416,6 +423,14 @@ static void free_deferred_calls(struct list *commands)
                     ID3D11DepthStencilView_Release(call->render_target_info.depth_stencil);
                 break;
             }
+            case DEFERRED_COPYRESOURCE:
+            {
+                if (call->copy_resource_info.dst_resource)
+                    ID3D11Resource_Release(call->copy_resource_info.dst_resource);
+                if (call->copy_resource_info.src_resource)
+                    ID3D11Resource_Release(call->copy_resource_info.src_resource);
+                break;
+            }
             case DEFERRED_CSSETSHADER:
             {
                 if (call->cs_info.shader)
@@ -613,6 +628,13 @@ static void exec_deferred_calls(ID3D11DeviceContext1 *iface, struct list *comman
                         call->render_target_info.render_targets, call->render_target_info.depth_stencil);
                 break;
             }
+            case DEFERRED_COPYRESOURCE:
+            {
+                ID3D11DeviceContext1_CopyResource(iface,
+                        call->copy_resource_info.dst_resource,
+                        call->copy_resource_info.src_resource);
+                break;
+            }
             case DEFERRED_CSSETSHADER:
             {
                 ID3D11DeviceContext1_CSSetShader(iface, call->cs_info.shader, NULL, 0);
@@ -4523,7 +4545,20 @@ static void STDMETHODCALLTYPE d3d11_deferred_context_CopySubresourceRegion(ID3D1
 static void STDMETHODCALLTYPE d3d11_deferred_context_CopyResource(ID3D11DeviceContext *iface,
         ID3D11Resource *dst_resource, ID3D11Resource *src_resource)
 {
-    FIXME("iface %p, dst_resource %p, src_resource %p stub!\n", iface, dst_resource, src_resource);
+    struct d3d11_deferred_context *context = impl_from_deferred_ID3D11DeviceContext(iface);
+    struct deferred_call *call;
+
+    TRACE("iface %p, dst_resource %p, src_resource %p.\n", iface, dst_resource, src_resource);
+
+    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_COPYRESOURCE;
+    call->copy_resource_info.dst_resource = dst_resource;
+    call->copy_resource_info.src_resource = src_resource;
 }
 
 static void STDMETHODCALLTYPE d3d11_deferred_context_UpdateSubresource(ID3D11DeviceContext *iface,
-- 
1.9.1

