From 01caa2176ef522267e3d187ff15ad5bf0372cebd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20D=C3=B6singer?= <stefan@codeweavers.com>
Date: Thu, 19 Sep 2013 13:09:58 +0200
Subject: wined3d: Discard the backbuffer in discard presents.

---
 dlls/wined3d/swapchain.c | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/dlls/wined3d/swapchain.c b/dlls/wined3d/swapchain.c
index 3214fe5..bb11450 100644
--- a/dlls/wined3d/swapchain.c
+++ b/dlls/wined3d/swapchain.c
@@ -558,14 +558,19 @@ static void swapchain_gl_present(struct wined3d_swapchain *swapchain, const RECT
 
     wined3d_resource_validate_location(&front->resource, WINED3D_LOCATION_DRAWABLE);
     wined3d_resource_invalidate_location(&front->resource, ~WINED3D_LOCATION_DRAWABLE);
-    /* If the swapeffect is DISCARD, the back buffer is undefined. That means the SYSMEM
-     * and INTEXTURE copies can keep their old content if they have any defined content.
-     * If the swapeffect is COPY, the content remains the same. If it is FLIP however,
-     * the texture / sysmem copy needs to be reloaded from the drawable. */
-    if (swapchain->desc.swap_effect == WINED3D_SWAP_EFFECT_FLIP)
+    switch (swapchain->desc.swap_effect)
     {
-        wined3d_resource_validate_location(&back_buffer->resource, back_buffer->container->resource.draw_binding);
-        wined3d_resource_invalidate_location(&back_buffer->resource, ~back_buffer->container->resource.draw_binding);
+        case WINED3D_SWAP_EFFECT_DISCARD:
+            wined3d_resource_validate_location(&back_buffer->resource, WINED3D_LOCATION_DISCARDED);
+            break;
+
+        case WINED3D_SWAP_EFFECT_FLIP:
+            wined3d_resource_validate_location(&back_buffer->resource, back_buffer->container->resource.draw_binding);
+            wined3d_resource_invalidate_location(&back_buffer->resource, ~back_buffer->container->resource.draw_binding);
+            break;
+
+        default:
+            break;
     }
 
     if (fb->depth_stencil)
-- 
2.5.1

