From 26b4142fd0a343616a72ddc01595ec66195fa11a Mon Sep 17 00:00:00 2001
From: Johannes Specht <jojos_band@gmx.net>
Date: Mon, 4 Sep 2017 04:24:37 +0200
Subject: [PATCH] d3d11: Implement SetPredication 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 0f710a4..c83d6a0 100644
--- a/dlls/d3d11/device.c
+++ b/dlls/d3d11/device.c
@@ -91,6 +91,7 @@ enum deferred_cmd
     DEFERRED_MAP,                       /* map_info */
     DEFERRED_DISPATCH,                  /* dispatch_info */
     DEFERRED_DISPATCHINDIRECT,          /* dispatch_indirect_info */
+    DEFERRED_SETPREDICATION,            /* set_predication_info */
 
     DEFERRED_CLEARSTATE,
     DEFERRED_CLEARRENDERTARGETVIEW,     /* clear_rtv_info */
@@ -320,6 +321,11 @@ struct deferred_call
         } dispatch_indirect_info;
         struct
         {
+            ID3D11Predicate *predicate;
+            BOOL value;
+        } set_predication_info;
+        struct
+        {
             ID3D11ShaderResourceView *view;
         } generate_mips_info;
         struct
@@ -716,6 +722,12 @@ static void free_deferred_calls(struct list *commands)
                     ID3D11Buffer_Release(call->dispatch_indirect_info.buffer);
                 break;
             }
+            case DEFERRED_SETPREDICATION:
+            {
+                if (call->set_predication_info.predicate)
+                    ID3D11Predicate_Release(call->set_predication_info.predicate);
+                break;
+            }
             case DEFERRED_CLEARSTATE:
             {
                 break; /* nothing to do */
@@ -1121,6 +1133,13 @@ static void exec_deferred_calls(ID3D11DeviceContext1 *iface, struct list *comman
                         call->dispatch_indirect_info.offset);
                 break;
             }
+            case DEFERRED_SETPREDICATION:
+            {
+                ID3D11DeviceContext1_SetPredication(iface,
+                        call->set_predication_info.predicate,
+                        call->set_predication_info.value);
+                break;
+            }
             case DEFERRED_CLEARSTATE:
             {
                 ID3D11DeviceContext1_ClearState(iface);
@@ -4663,7 +4682,18 @@ static HRESULT STDMETHODCALLTYPE d3d11_deferred_context_GetData(ID3D11DeviceCont
 static void STDMETHODCALLTYPE d3d11_deferred_context_SetPredication(ID3D11DeviceContext *iface,
         ID3D11Predicate *predicate, BOOL value)
 {
-    FIXME("iface %p, predicate %p, value %#x stub!\n", iface, predicate, value);
+    struct d3d11_deferred_context *context = impl_from_deferred_ID3D11DeviceContext(iface);
+    struct deferred_call *call;
+
+    TRACE("iface %p, predicate %p, value %#x.\n", iface, predicate, value);
+
+    if (!(call = add_deferred_call(context, 0)))
+        return;
+
+    call->cmd = DEFERRED_SETPREDICATION;
+    if (predicate) ID3D11Predicate_AddRef(predicate);
+    call->set_predication_info.predicate = predicate;
+    call->set_predication_info.value = value;
 }
 
 static void STDMETHODCALLTYPE d3d11_deferred_context_GSSetShaderResources(ID3D11DeviceContext *iface,
-- 
1.9.1

