From e485302fbcd610c34cf3e664d3d9a588fb7f3a32 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20D=C3=B6singer?= <stefan@codeweavers.com>
Date: Fri, 27 Sep 2013 17:55:35 +0200
Subject: wined3d: Fence present calls.

---
 dlls/wined3d/cs.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c
index bdb9279..45dc5ce 100644
--- a/dlls/wined3d/cs.c
+++ b/dlls/wined3d/cs.c
@@ -485,6 +485,7 @@ static UINT wined3d_cs_exec_present(struct wined3d_cs *cs, const void *data)
     const RECT *src_rect = op->set_data & CS_PRESENT_SRC_RECT ? &op->src_rect : NULL;
     const RECT *dst_rect = op->set_data & CS_PRESENT_DST_RECT ? &op->dst_rect : NULL;
     const RGNDATA *dirty_region = op->set_data & CS_PRESENT_DIRTY_RGN ? &op->dirty_region : NULL;
+    unsigned int i;
 
     swapchain = op->swapchain;
     wined3d_swapchain_set_window(swapchain, op->dst_window_override);
@@ -495,6 +496,10 @@ static UINT wined3d_cs_exec_present(struct wined3d_cs *cs, const void *data)
 
     InterlockedDecrement(&cs->pending_presents);
 
+    wined3d_resource_dec_fence(&swapchain->front_buffer->resource);
+    for (i = 0; i < swapchain->desc.backbuffer_count; i++)
+        wined3d_resource_dec_fence(&swapchain->back_buffers[i]->resource);
+
     return sizeof(*op);
 }
 
@@ -504,6 +509,7 @@ void wined3d_cs_emit_present(struct wined3d_cs *cs, struct wined3d_swapchain *sw
 {
     struct wined3d_cs_present *op;
     LONG pending;
+    unsigned int i;
 
     op = cs->ops->require_space(cs, sizeof(*op));
     op->opcode = WINED3D_CS_OP_PRESENT;
@@ -527,6 +533,10 @@ void wined3d_cs_emit_present(struct wined3d_cs *cs, struct wined3d_swapchain *sw
     }
     op->flags = flags;
 
+    wined3d_resource_inc_fence(&swapchain->front_buffer->resource);
+    for (i = 0; i < swapchain->desc.backbuffer_count; i++)
+        wined3d_resource_inc_fence(&swapchain->back_buffers[i]->resource);
+
     pending = InterlockedIncrement(&cs->pending_presents);
 
     cs->ops->submit(cs, sizeof(*op));
-- 
2.1.3

