From 2b6928fe7faa40ff4e18508cffcea60d5156735f Mon Sep 17 00:00:00 2001
From: Johannes Specht <jojos_band@gmx.net>
Date: Mon, 4 Sep 2017 02:33:19 +0200
Subject: [PATCH] d3d11: Implement CopyStructureCount for deferred contexts.

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

diff --git a/dlls/d3d11/device.c b/dlls/d3d11/device.c
index 5709bf0..4241b5a 100644
--- a/dlls/d3d11/device.c
+++ b/dlls/d3d11/device.c
@@ -44,6 +44,7 @@ enum deferred_cmd
     DEFERRED_SETRESOURCEMINLOD,         /* set_resource_min_lod_info */
     DEFERRED_COPYSUBRESOURCEREGION,     /* copy_subresource_region_info */
     DEFERRED_RESOLVESUBRESOURCE,        /* resolve_subresource_info */
+    DEFERRED_COPYSTRUCTURECOUNT,        /* copy_structure_count_info */
 
     DEFERRED_CSSETSHADER,               /* cs_info */
     DEFERRED_DSSETSHADER,               /* ds_info */
@@ -175,6 +176,12 @@ struct deferred_call
         } resolve_subresource_info;
         struct
         {
+            ID3D11Buffer *dst_buffer;
+            UINT dst_offset;
+            ID3D11UnorderedAccessView *src_view;
+        } copy_structure_count_info;
+        struct
+        {
             ID3D11ComputeShader *shader;
             /* FIXME: add class instances */
         } cs_info;
@@ -480,6 +487,14 @@ static void free_deferred_calls(struct list *commands)
                     ID3D11Resource_Release(call->resolve_subresource_info.src_resource);
                 break;
             }
+            case DEFERRED_COPYSTRUCTURECOUNT:
+            {
+                if (call->copy_structure_count_info.dst_buffer)
+                    ID3D11Buffer_Release(call->copy_structure_count_info.dst_buffer);
+                if (call->copy_structure_count_info.src_view)
+                    ID3D11UnorderedAccessView_Release(call->copy_structure_count_info.src_view);
+                break;
+            }
             case DEFERRED_CSSETSHADER:
             {
                 if (call->cs_info.shader)
@@ -714,6 +729,14 @@ static void exec_deferred_calls(ID3D11DeviceContext1 *iface, struct list *comman
                         call->resolve_subresource_info.format);
                 break;
             }
+            case DEFERRED_COPYSTRUCTURECOUNT:
+            {
+                ID3D11DeviceContext1_CopyStructureCount(iface,
+                        call->copy_structure_count_info.dst_buffer,
+                        call->copy_structure_count_info.dst_offset,
+                        call->copy_structure_count_info.src_view);
+                break;
+            }
             case DEFERRED_CSSETSHADER:
             {
                 ID3D11DeviceContext1_CSSetShader(iface, call->cs_info.shader, NULL, 0);
@@ -4678,8 +4701,22 @@ static void STDMETHODCALLTYPE d3d11_deferred_context_UpdateSubresource(ID3D11Dev
 static void STDMETHODCALLTYPE d3d11_deferred_context_CopyStructureCount(ID3D11DeviceContext *iface,
         ID3D11Buffer *dst_buffer, UINT dst_offset, ID3D11UnorderedAccessView *src_view)
 {
-    FIXME("iface %p, dst_buffer %p, dst_offset %u, src_view %p stub!\n",
-            iface, dst_buffer, dst_offset, src_view);
+    struct d3d11_deferred_context *context = impl_from_deferred_ID3D11DeviceContext(iface);
+    struct deferred_call *call;
+
+    TRACE("iface %p, dst_buffer %p, dst_offset %u, src_view %p.\n",
+          iface, dst_buffer, dst_offset, src_view);
+
+    if (!(call = add_deferred_call(context, 0)))
+        return;
+
+    if (dst_buffer) ID3D11Buffer_AddRef(dst_buffer);
+    if (src_view) ID3D11UnorderedAccessView_AddRef(src_view);
+
+    call->cmd = DEFERRED_COPYSTRUCTURECOUNT;
+    call->copy_structure_count_info.dst_buffer = dst_buffer;
+    call->copy_structure_count_info.dst_offset = dst_offset;
+    call->copy_structure_count_info.src_view = src_view;
 }
 
 static void STDMETHODCALLTYPE d3d11_deferred_context_ClearRenderTargetView(ID3D11DeviceContext *iface,
-- 
1.9.1

