From fc3937794343611ef4bedefc4829ed06ceee8f64 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Tue, 24 Jan 2017 04:10:12 +0100
Subject: [PATCH] d3d11: Implement CSSetShader 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 2f13e85..e54ccaf 100644
--- a/dlls/d3d11/device.c
+++ b/dlls/d3d11/device.c
@@ -40,6 +40,7 @@ enum deferred_cmd
     DEFERRED_OMSETBLENDSTATE,           /* blend_state_info */
     DEFERRED_OMSETRENDERTARGETS,        /* render_target_info */
 
+    DEFERRED_CSSETSHADER,               /* cs_info */
     DEFERRED_DSSETSHADER,               /* ds_info */
     DEFERRED_HSSETSHADER,               /* hs_info */
     DEFERRED_PSSETSHADER,               /* ps_info */
@@ -120,6 +121,11 @@ struct deferred_call
         } render_target_info;
         struct
         {
+            ID3D11ComputeShader *shader;
+            /* FIXME: add class instances */
+        } cs_info;
+        struct
+        {
             ID3D11DomainShader *shader;
             /* FIXME: add class instances */
         } ds_info;
@@ -349,6 +355,12 @@ static void free_deferred_calls(struct list *commands)
                     ID3D11DepthStencilView_Release(call->render_target_info.depth_stencil);
                 break;
             }
+            case DEFERRED_CSSETSHADER:
+            {
+                if (call->cs_info.shader)
+                    ID3D11ComputeShader_Release(call->cs_info.shader);
+                break;
+            }
             case DEFERRED_DSSETSHADER:
             {
                 if (call->ds_info.shader)
@@ -491,6 +503,11 @@ 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_CSSETSHADER:
+            {
+                ID3D11DeviceContext1_CSSetShader(iface, call->cs_info.shader, NULL, 0);
+                break;
+            }
             case DEFERRED_DSSETSHADER:
             {
                 ID3D11DeviceContext1_DSSetShader(iface, call->ds_info.shader, NULL, 0);
@@ -4410,8 +4427,18 @@ static void STDMETHODCALLTYPE d3d11_deferred_context_CSSetUnorderedAccessViews(I
 static void STDMETHODCALLTYPE d3d11_deferred_context_CSSetShader(ID3D11DeviceContext *iface,
         ID3D11ComputeShader *shader, ID3D11ClassInstance *const *class_instances, UINT class_instance_count)
 {
-    FIXME("iface %p, shader %p, class_instances %p, class_instance_count %u stub!\n",
+    struct d3d11_deferred_context *context = impl_from_deferred_ID3D11DeviceContext(iface);
+    struct deferred_call *call;
+
+    TRACE("iface %p, shader %p, class_instances %p, class_instance_count %u.\n",
             iface, shader, class_instances, class_instance_count);
+
+    if (!(call = add_deferred_call(context, 0)))
+        return;
+
+    call->cmd = DEFERRED_CSSETSHADER;
+    if (shader) ID3D11ComputeShader_AddRef(shader);
+    call->cs_info.shader = shader;
 }
 
 static void STDMETHODCALLTYPE d3d11_deferred_context_CSSetSamplers(ID3D11DeviceContext *iface,
-- 
1.9.1

