wined3d: Only use stretch_rect_fbo() on surfaces that are FBO attachable.
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 @@
}
}
+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 @@
* 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 @@
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 @@
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 @@
#define WINED3DFMT_FLAG_STENCIL 0x8
#define WINED3DFMT_FLAG_RENDERTARGET 0x10
#define WINED3DFMT_FLAG_FOURCC 0x20
+#define WINED3DFMT_FLAG_FBO_ATTACHABLE 0x40
struct GlPixelFormatDesc
{