Henri Verbeet : wined3d: Only use stretch_rect_fbo() on surfaces that are FBO attachable.

Alexandre Julliard julliard at winehq.org
Fri Jun 5 08:56:54 CDT 2009


Module: wine
Branch: master
Commit: fb7531599f76f7af7be11798bf12f83f61428d43
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=fb7531599f76f7af7be11798bf12f83f61428d43

Author: Henri Verbeet <hverbeet at codeweavers.com>
Date:   Fri Jun  5 14:39:20 2009 +0200

wined3d: Only use stretch_rect_fbo() on surfaces that are FBO attachable.

---

 dlls/wined3d/surface.c         |   21 ++++++++++++++++++---
 dlls/wined3d/utils.c           |    1 +
 dlls/wined3d/wined3d_private.h |    1 +
 3 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index d65105d..2f5554f 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -523,6 +523,17 @@ void surface_add_dirty_rect(IWineD3DSurface *iface, const RECT *dirty_rect)
     }
 }
 
+static inline BOOL surface_can_stretch_rect(IWineD3DSurfaceImpl *src, IWineD3DSurfaceImpl *dst)
+{
+    return ((src->resource.format_desc->Flags & WINED3DFMT_FLAG_FBO_ATTACHABLE)
+            || (src->resource.usage & WINED3DUSAGE_RENDERTARGET))
+            && ((dst->resource.format_desc->Flags & WINED3DFMT_FLAG_FBO_ATTACHABLE)
+            || (dst->resource.usage & WINED3DUSAGE_RENDERTARGET))
+            && (src->resource.format_desc->format == dst->resource.format_desc->format
+            || (is_identity_fixup(src->resource.format_desc->color_fixup)
+            && is_identity_fixup(dst->resource.format_desc->color_fixup)));
+}
+
 static ULONG WINAPI IWineD3DSurfaceImpl_Release(IWineD3DSurface *iface)
 {
     IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
@@ -3408,7 +3419,9 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *This, const
          * FBO support, so it doesn't really make sense to try and make it work with different offscreen rendering
          * backends.
          */
-        if (wined3d_settings.offscreen_rendering_mode == ORM_FBO && GL_SUPPORT(EXT_FRAMEBUFFER_BLIT)) {
+        if (wined3d_settings.offscreen_rendering_mode == ORM_FBO && GL_SUPPORT(EXT_FRAMEBUFFER_BLIT)
+                && surface_can_stretch_rect(Src, This))
+        {
             stretch_rect_fbo((IWineD3DDevice *)myDevice, SrcSurface, &srect,
                     (IWineD3DSurface *)This, &rect, Filter, upsideDown);
         } else if((!stretchx) || rect.x2 - rect.x1 > Src->currentDesc.Width ||
@@ -3470,8 +3483,10 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *This, const
             Src->palette = This->palette;
         }
 
-        if (wined3d_settings.offscreen_rendering_mode == ORM_FBO && GL_SUPPORT(EXT_FRAMEBUFFER_BLIT) &&
-            (Flags & (WINEDDBLT_KEYSRC | WINEDDBLT_KEYSRCOVERRIDE)) == 0) {
+        if (wined3d_settings.offscreen_rendering_mode == ORM_FBO && GL_SUPPORT(EXT_FRAMEBUFFER_BLIT)
+                && !(Flags & (WINEDDBLT_KEYSRC | WINEDDBLT_KEYSRCOVERRIDE))
+                && surface_can_stretch_rect(Src, This))
+        {
             TRACE("Using stretch_rect_fbo\n");
             /* The source is always a texture, but never the currently active render target, and the texture
              * contents are never upside down
diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c
index ef55419..e95bd4c 100644
--- a/dlls/wined3d/utils.c
+++ b/dlls/wined3d/utils.c
@@ -549,6 +549,7 @@ static void init_format_fbo_compat_info(WineD3D_GL_Info *gl_info)
             if (check_fbo_compat(gl_info, desc->glInternal, desc->glFormat, desc->glType))
             {
                 TRACE("Format %s is supported as fbo target\n", debug_d3dformat(desc->format));
+                desc->Flags |= WINED3DFMT_FLAG_FBO_ATTACHABLE;
                 desc->rtInternal = desc->glInternal;
             }
             else
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index a610b7a..adf6235 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2749,6 +2749,7 @@ extern WINED3DFORMAT pixelformat_for_depth(DWORD depth);
 #define WINED3DFMT_FLAG_STENCIL                  0x8
 #define WINED3DFMT_FLAG_RENDERTARGET             0x10
 #define WINED3DFMT_FLAG_FOURCC                   0x20
+#define WINED3DFMT_FLAG_FBO_ATTACHABLE           0x40
 
 struct GlPixelFormatDesc
 {




More information about the wine-cvs mailing list