[PATCH 4/4] wined3d: Avoid loading the destination surface in stretch_rect_fbo() if it will be completely overwritten.

Henri Verbeet hverbeet at codeweavers.com
Fri Jul 23 04:31:05 CDT 2010


---
 dlls/wined3d/device.c |   19 +++++++++++++++----
 1 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 17a4b83..df9e1d6 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -5743,6 +5743,15 @@ static HRESULT  WINAPI  IWineD3DDeviceImpl_GetDepthStencilSurface(IWineD3DDevice
     }
 }
 
+static BOOL surface_is_full_rect(IWineD3DSurfaceImpl *surface, const RECT *r)
+{
+    if ((r->left && r->right) || abs(r->right - r->left) != surface->currentDesc.Width)
+        return FALSE;
+    if ((r->top && r->bottom) || abs(r->bottom - r->top) != surface->currentDesc.Height)
+        return FALSE;
+    return TRUE;
+}
+
 void stretch_rect_fbo(IWineD3DDeviceImpl *device, IWineD3DSurfaceImpl *src_surface, const RECT *src_rect_in,
         IWineD3DSurfaceImpl *dst_surface, const RECT *dst_rect_in, const WINED3DTEXTUREFILTERTYPE filter)
 {
@@ -5772,11 +5781,13 @@ void stretch_rect_fbo(IWineD3DDeviceImpl *device, IWineD3DSurfaceImpl *src_surfa
             break;
     }
 
-    /* Make sure the drawables are up-to-date. Note that loading the
-     * destination surface isn't strictly required if we overwrite the
-     * entire surface. */
+    /* Make sure the drawables are up-to-date. Loading the destination
+     * surface isn't required if the entire surface is overwritten. (And is
+     * in fact harmful if we're being called by surface_load_location() with
+     * the purpose of loading the destination surface.) */
     surface_load_location(src_surface, SFLAG_INDRAWABLE, NULL);
-    surface_load_location(dst_surface, SFLAG_INDRAWABLE, NULL);
+    if (!surface_is_full_rect(dst_surface, &dst_rect))
+        surface_load_location(dst_surface, SFLAG_INDRAWABLE, NULL);
 
     if (!surface_is_offscreen(src_surface)) context = context_acquire(device, src_surface);
     else if (!surface_is_offscreen(dst_surface)) context = context_acquire(device, dst_surface);
-- 
1.7.1




More information about the wine-patches mailing list