[PATCH 4/4] wined3d: Add an initial fbo_blit implementation.

Roderick Colenbrander thunderbird2k at gmail.com
Wed Apr 7 16:12:26 CDT 2010


---
 dlls/wined3d/surface.c         |   96 ++++++++++++++++++++++++++++++++-------
 dlls/wined3d/wined3d_private.h |    1 +
 2 files changed, 79 insertions(+), 18 deletions(-)

diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index 03f6245..e39580e 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -989,17 +989,6 @@ 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 BOOL surface_convert_color_to_argb(IWineD3DSurfaceImpl *This, DWORD color, DWORD *argb_color)
 {
     IWineD3DDeviceImpl *device = This->resource.device;
@@ -3883,9 +3872,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
-                && myDevice->adapter->gl_info.fbo_ops.glBlitFramebuffer
-                && surface_can_stretch_rect(Src, This))
+        if (fbo_blit.blit_supported(&myDevice->adapter->gl_info, BLIT_OP_BLIT,
+                                    &src_rect, Src->resource.usage, Src->resource.pool, Src->resource.format_desc,
+                                    &dst_rect, This->resource.usage, This->resource.pool, This->resource.format_desc))
         {
             stretch_rect_fbo((IWineD3DDevice *)myDevice, SrcSurface, &src_rect,
                     (IWineD3DSurface *)This, &dst_rect, Filter);
@@ -3927,10 +3916,10 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *This, const
             Src->palette = This->palette;
         }
 
-        if (wined3d_settings.offscreen_rendering_mode == ORM_FBO
-                && myDevice->adapter->gl_info.fbo_ops.glBlitFramebuffer
-                && !(Flags & (WINEDDBLT_KEYSRC | WINEDDBLT_KEYSRCOVERRIDE))
-                && surface_can_stretch_rect(Src, This))
+        if (!(Flags & (WINEDDBLT_KEYSRC | WINEDDBLT_KEYSRCOVERRIDE))
+            && fbo_blit.blit_supported(&myDevice->adapter->gl_info, BLIT_OP_BLIT,
+                                       &src_rect, Src->resource.usage, Src->resource.pool, Src->resource.format_desc,
+                                       &dst_rect, This->resource.usage, This->resource.pool, This->resource.format_desc))
         {
             TRACE("Using stretch_rect_fbo\n");
             /* The source is always a texture, but never the currently active render target, and the texture
@@ -5208,3 +5197,74 @@ const struct blit_shader cpu_blit =  {
     cpu_blit_supported,
     cpu_blit_color_fill
 };
+
+static HRESULT fbo_blit_alloc(IWineD3DDevice *iface)
+{
+    return WINED3D_OK;
+}
+
+/* Context activation is done by the caller. */
+static void fbo_blit_free(IWineD3DDevice *iface)
+{
+}
+
+/* Context activation is done by the caller. */
+static HRESULT fbo_blit_set(IWineD3DDevice *iface, IWineD3DSurfaceImpl *surface)
+{
+    return WINED3D_OK;
+}
+
+/* Context activation is done by the caller. */
+static void fbo_blit_unset(IWineD3DDevice *iface)
+{
+}
+
+static BOOL fbo_blit_supported(const struct wined3d_gl_info *gl_info, enum blit_operation blit_op,
+                               const RECT *src_rect, DWORD src_usage, WINED3DPOOL src_pool,
+                               const struct wined3d_format_desc *src_format_desc,
+                               const RECT *dst_rect, DWORD dst_usage, WINED3DPOOL dst_pool,
+                               const struct wined3d_format_desc *dst_format_desc)
+{
+    if ((wined3d_settings.offscreen_rendering_mode != ORM_FBO) || !gl_info->fbo_ops.glBlitFramebuffer)
+        return FALSE;
+
+    /* We only support blitting. Things like color keying / color fill should
+     * be handled by other blitters.
+     */
+    if (blit_op != BLIT_OP_BLIT)
+        return FALSE;
+
+    /* Source and/or destination need to be on the GL side */
+    if (src_pool == WINED3DPOOL_SYSTEMMEM || dst_pool == WINED3DPOOL_SYSTEMMEM)
+        return FALSE;
+
+    if(!((src_format_desc->Flags & WINED3DFMT_FLAG_FBO_ATTACHABLE) || (src_usage & WINED3DUSAGE_RENDERTARGET))
+        && ((dst_format_desc->Flags & WINED3DFMT_FLAG_FBO_ATTACHABLE) || (dst_usage & WINED3DUSAGE_RENDERTARGET)))
+        return FALSE;
+
+    if (!is_identity_fixup(src_format_desc->color_fixup) ||
+        !is_identity_fixup(dst_format_desc->color_fixup))
+        return FALSE;
+
+    if (!(src_format_desc->format == dst_format_desc->format
+        || (is_identity_fixup(src_format_desc->color_fixup)
+        && is_identity_fixup(dst_format_desc->color_fixup))))
+        return FALSE;
+
+    return TRUE;
+}
+
+static HRESULT fbo_blit_color_fill(IWineD3DDeviceImpl *device, IWineD3DSurfaceImpl *dst_surface, const RECT *dst_rect, DWORD fill_color)
+{
+    FIXME("Color filling not implemented by fbo_blit\n");
+    return WINED3DERR_INVALIDCALL;
+}
+
+const struct blit_shader fbo_blit =  {
+    fbo_blit_alloc,
+    fbo_blit_free,
+    fbo_blit_set,
+    fbo_blit_unset,
+    fbo_blit_supported,
+    fbo_blit_color_fill
+};
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 0381890..cafa88b 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -1189,6 +1189,7 @@ struct blit_shader
 extern const struct blit_shader ffp_blit DECLSPEC_HIDDEN;
 extern const struct blit_shader arbfp_blit DECLSPEC_HIDDEN;
 extern const struct blit_shader cpu_blit DECLSPEC_HIDDEN;
+extern const struct blit_shader fbo_blit DECLSPEC_HIDDEN;
 
 typedef enum ContextUsage {
     CTXUSAGE_RESOURCELOAD       = 1,    /* Only loads textures: No State is applied */
-- 
1.6.3.3




More information about the wine-patches mailing list