Permalink
Browse files

directfb: Initial support

Directfb has recently gained support for Mesa/DRM for GLES2.0 acceleration.
This means we can now run without X on supported platforms. This has been
tested on a SandyBridge Macbook Pro.

Limitations:
- Depends on latest DirectFB/Mesa. Oneric should have all that's needed.

Issues:
- Current DirectFB/Mesa has a bug causing the screen to be shown upside-down.
- Current DirectFB/Mesa fails to compile our shaders.
- Current DirectFB does not yet have have mesa hooked up.

Upstream is aware of these issues and is very eager to fix them for us in the
next few days so that they can feature XBMC support with their next release.

TODO:
- Hook up resolution switching in XBMC (currently it's done via a config file)
- Decide whether we need to hook up windowing functions (I say no.)
- Implement ImageProviders for hardware-accelerated image decodes.
- Cleanup the configure logic
  • Loading branch information...
1 parent 471c468 commit fe5788be267f4e641fbd49d708ec5d71e6dfc4fc theuni committed Sep 30, 2011
View
@@ -1210,3 +1210,5 @@ lib/cmyth/Makefile
/xbmc/visualizations/XBMCProjectM/libprojectM/config.inp
/xbmc/win32/git_rev.h
+
+/xbmc/windowing/dfb/Makefile
View
@@ -86,6 +86,9 @@ ifeq (@USE_OPENGLES@,1)
BIN_DIRS += xbmc/rendering/gles
BIN_DIRS += xbmc/windowing/egl
endif
+ifeq (@USE_DIRECTFB@,1)
+BIN_DIRS += xbmc/windowing/dfb
+endif
ifeq ($(findstring osx,@ARCH@),osx)
BIN_DIRS += xbmc/network/osx
@@ -280,6 +283,8 @@ xbmc/windowing/windowing.a: force
$(MAKE) -C xbmc/windowing
xbmc/windowing/egl/windowing_egl.a: force
$(MAKE) -C xbmc/windowing/egl
+xbmc/windowing/dfb/windowing_dfb.a: force
+ $(MAKE) -C xbmc/windowing/dfb
xbmc/windowing/osx/windowing_osx.a: force
$(MAKE) -C xbmc/windowing/osx
xbmc/windowing/X11/windowing_X11.a: force
@@ -507,6 +512,9 @@ ifeq (@USE_OPENGLES@,1)
OBJSXBMC += xbmc/rendering/gles/rendering_gles.a
OBJSXBMC += xbmc/windowing/egl/windowing_egl.a
endif
+ifeq (@USE_DIRECTFB@,1)
+OBJSXBMC += xbmc/windowing/dfb/windowing_dfb.a
+endif
ifeq (@HAVE_XBMC_NONFREE@,1)
OBJSXBMC += lib/UnrarXLib/UnrarXLib.a
View
@@ -83,6 +83,9 @@ projectm_enabled="== ProjectM enabled. =="
projectm_disabled="== ProjectM disabled. =="
x11_enabled="== X11 enabled. =="
x11_disabled="== X11 disabled. =="
+directfb_enabled="== directfb enabled. =="
+directfb_disabled="== directfb disabled. =="
+windowing_error="Could not enable directfb and X11 support simultaneously. Please disable one."
pulse_not_found="== Could not find libpulse. PulseAudio support disabled. =="
pulse_disabled="== PulseAudio support manually disabled. =="
dvdcss_enabled="== DVDCSS support enabled. =="
@@ -269,6 +272,12 @@ AC_ARG_ENABLE([ccache],
[use_ccache=$enableval],
[use_ccache=auto])
+AC_ARG_ENABLE([directfb],
+ [AS_HELP_STRING([--enable-directfb],
+ [enable directfb (default is no) 'Linux Only'])],
+ [use_directfb=$enableval],
+ [use_directfb=no])
+
AC_ARG_ENABLE([pulse],
[AS_HELP_STRING([--enable-pulse],
[enable PulseAudio support (default is auto)])],
@@ -660,6 +669,22 @@ else
fi
fi
+if test "$use_directfb" = "yes" && test "$host_vendor" != "apple"; then
+ if test "x$use_gles" != "xyes"; then
+ AC_MSG_ERROR($directfb_gles)
+ fi
+ AC_MSG_NOTICE($directfb_enabled)
+ PKG_CHECK_MODULES([DIRECTFB], [directfb],
+ [INCLUDES="$INCLUDES $DIRECTFB_CFLAGS"; LIBS="$LIBS $DIRECTFB_LIBS"],
+ AC_MSG_ERROR($missing_library))
+ AC_DEFINE([HAVE_DIRECTFB], [1], [Define to 1 if you have directfb libs installed.])
+ USE_DIRECTFB=1
+ use_sdl=no;use_joystick=no
+else
+ AC_MSG_RESULT($directfb_disabled)
+ USE_DIRECTFB=0
+fi
+
# platform common libraries
AC_CHECK_PROG(MYSQL_CONFIG, mysql_config, "yes", "no")
if test $MYSQL_CONFIG = "yes"; then
@@ -893,6 +918,9 @@ fi
# X11
if test "$use_x11" = "yes" && test "$host_vendor" != "apple"; then
+ if test "$use_directfb" = "yes"; then
+ AC_MSG_ERROR($windowing_error)
+ fi
AC_MSG_NOTICE($x11_enabled)
PKG_CHECK_MODULES([X11], [x11],
[INCLUDES="$INCLUDES $X11_CFLAGS"; LIBS="$LIBS $X11_LIBS"],
@@ -1816,6 +1844,7 @@ OUTPUT_FILES="Makefile \
xbmc/visualizations/OpenGLSpectrum/Makefile \
xbmc/visualizations/WaveForm/Makefile \
xbmc/visualizations/iTunes/Makefile \
+ xbmc/windowing/dfb/Makefile \
tools/Linux/xbmc.sh \
tools/Linux/xbmc-standalone.sh \
tools/TexturePacker/Makefile \
@@ -1869,6 +1898,7 @@ AC_SUBST(USE_OPENMAX)
AC_SUBST(USE_PULSE)
AC_SUBST(USE_XRANDR)
AC_SUBST(USE_ALSA)
+AC_SUBST(USE_DIRECTFB)
AC_SUBST(USE_TEXTUREPACKER)
AC_SUBST(USE_TEXTUREPACKER_NATIVE)
AC_SUBST(USE_TEXTUREPACKER_NATIVE_ROOT)
View
@@ -233,6 +233,10 @@
#ifdef HAVE_LIBGLESV2
#undef HAS_GL
#define HAS_GLES 2
+#if defined(HAVE_DIRECTFB)
+#define HAS_DIRECTFB
+#define HAS_LINUX_EVENTS
+#endif
#endif
// GLES1.0 detected. Dont use GL!
@@ -33,7 +33,8 @@ typedef enum _WindowSystemType
WINDOW_SYSTEM_IOS,
WINDOW_SYSTEM_X11,
WINDOW_SYSTEM_SDL,
- WINDOW_SYSTEM_EGL
+ WINDOW_SYSTEM_EGL,
+ WINDOW_SYSTEM_DFB
} WindowSystemType;
struct RESOLUTION_WHR
@@ -36,6 +36,9 @@
#elif defined(TARGET_LINUX) && defined(HAS_GLES) && defined(HAVE_X11)
#include "X11/WinSystemX11GLES.h"
+#elif defined(TARGET_LINUX) && defined(HAS_GLES) && defined(HAS_DIRECTFB)
+#include "dfb/WinSystemDFB.h"
+
#elif defined(TARGET_LINUX) && defined(HAS_GLES) && defined(HAS_EGL)
#include "egl/WinSystemGLES.h"
@@ -0,0 +1,13 @@
+INCLUDES= -I. \
+ -I@abs_top_srcdir@/xbmc/linux \
+ -I@abs_top_srcdir@/xbmc/windowing
+
+CXXFLAGS+= @DIRECTFB_CFLAGS@
+
+SRCS= \
+ WinSystemDFB.cpp \
+
+LIB=windowing_dfb.a
+
+include @abs_top_srcdir@/Makefile.include
+-include $(patsubst %.cpp,%.P,$(patsubst %.c,%.P,$(SRCS)))
@@ -0,0 +1,184 @@
+/*
+ * Copyright (C) 2005-2011 Team XBMC
+ * http://www.xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, write to
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ */
+#include "system.h"
+
+#ifdef HAS_DIRECTFB
+
+#include "WinSystemDFB.h"
+#include "utils/log.h"
+#include "filesystem/SpecialProtocol.h"
+#include "settings/Settings.h"
+#include "guilib/Texture.h"
+
@theuni

theuni Sep 30, 2011

Owner

Just noticed the funky includes here. Must've been c/p from elsewhere. Will fix.

@theuni

theuni Sep 30, 2011

Owner

Will forward-declare as well, looks like some of my cleanup commits went missing...

+#include <vector>
+#include <directfb/directfb.h>
+#include <directfb/directfbgl2.h>
+
+CWinSystemDFB::CWinSystemDFB() : CWinSystemBase()
+{
+ m_dfb = NULL;
+ m_dfb_layer = NULL;
+ m_dfb_surface = NULL;
+ m_flipflags = DFBSurfaceFlipFlags(DSFLIP_BLIT);
+ m_buffermode = DSCAPS_TRIPLE;
+ m_eWindowSystem = WINDOW_SYSTEM_DFB;
+}
+
+CWinSystemDFB::~CWinSystemDFB()
+{
+ DestroyWindowSystem();
+}
+
+bool CWinSystemDFB::InitWindowSystem()
+{
+ CLog::Log(LOGINFO, "CWinSystemDFB: Creating DirectFB WindowSystem");
+ int ret;
+ DFBSurfaceDescription dsc;
+
+ DirectFBInit(NULL, NULL);
+ DirectFBCreate(&m_dfb);
+
+ ret = m_dfb->GetInterface(m_dfb, "IDirectFBGL2", NULL, m_dfb, (void**) &m_gl2);
+ if (ret)
+ {
+ CLog::Log(LOGERROR, "CWinSystemDFB: Unable to get IDirectFBGL2 interface");
+ return ret;
+ }
+
+ m_dfb->SetCooperativeLevel(m_dfb, DFSCL_FULLSCREEN );
+
+ dsc.flags = DSDESC_CAPS;
+ dsc.caps = (DFBSurfaceCapabilities)(DSCAPS_PRIMARY | m_buffermode);
+
+ m_dfb->CreateSurface( m_dfb, &dsc, &m_dfb_surface );
+
+ m_dfb_surface->Clear(m_dfb_surface, 0, 0, 0, 0);
+ m_dfb_surface->Flip(m_dfb_surface, NULL, DFBSurfaceFlipFlags(m_flipflags));
+
+ ret = m_gl2->CreateContext( m_gl2, NULL, &m_gl2context );
+ if (ret)
+ {
+ CLog::Log(LOGERROR, "CWinSystemDFB: Unable to create DirectFBGL2 context");
+ }
+
+ ret = m_gl2context->Bind( m_gl2context, m_dfb_surface, m_dfb_surface );
+ if (ret)
+ {
+ CLog::Log(LOGERROR, "CWinSystemDFB: Unable to bind DirectFBGL2 context");
+ }
+
+ if (!CWinSystemBase::InitWindowSystem())
+ return false;
+
+ return true;
+}
+
+bool CWinSystemDFB::DestroyWindowSystem()
+{
+ if (m_gl2context)
+ {
+ m_gl2context->Unbind(m_gl2context);
+ m_gl2context->Release(m_gl2context);
+ }
+ m_gl2context = NULL;
+
+ if (m_gl2)
+ m_gl2->Release(m_gl2);
+ m_gl2 = NULL;
+
+ if (m_dfb_surface)
+ m_dfb_surface->Release(m_dfb_surface);
+ m_dfb_surface = NULL;
+
+ if (m_dfb_layer)
+ m_dfb_layer->Release(m_dfb_layer);
+ m_dfb_layer = NULL;
+
+ if (m_dfb)
+ m_dfb->Release(m_dfb);
+ m_dfb = NULL;
+
+ return true;
+}
+
+bool CWinSystemDFB::CreateNewWindow(const CStdString& name, bool fullScreen, RESOLUTION_INFO& res, PHANDLE_EVENT_FUNC userFunction)
+{
+ m_bWindowCreated = true;
+ return true;
+}
+
+bool CWinSystemDFB::DestroyWindow()
+{
+ m_bWindowCreated = false;
+
+ return true;
+}
+
+bool CWinSystemDFB::ResizeWindow(int newWidth, int newHeight, int newLeft, int newTop)
+{
+ CRenderSystemGLES::ResetRenderSystem(newWidth, newHeight, true, 0);
+ return true;
+}
+
+bool CWinSystemDFB::SetFullScreen(bool fullScreen, RESOLUTION_INFO& res, bool blankOtherDisplays)
+{
+ CLog::Log(LOGDEBUG, "CWinSystemDFB::SetFullScreen");
+ m_nWidth = res.iWidth;
+ m_nHeight = res.iHeight;
+ m_bFullScreen = fullScreen;
+
+ CreateNewWindow("", fullScreen, res, NULL);
+
+ CRenderSystemGLES::ResetRenderSystem(res.iWidth, res.iHeight, true, 0);
+
+ return true;
+}
+
+void CWinSystemDFB::UpdateResolutions()
+{
+ int width = 0;
+ int height = 0;
+ CWinSystemBase::UpdateResolutions();
+
+ m_dfb_surface->GetSize(m_dfb_surface, &width, &height);
+ UpdateDesktopResolution(g_settings.m_ResInfo[RES_DESKTOP], 0, width, height, 0.0);
+}
+
+bool CWinSystemDFB::PresentRenderImpl(const CDirtyRegionList &dirty)
+{
+ int ret;
+ m_gl2context->Unbind(m_gl2context);
+ m_dfb_surface->Flip(m_dfb_surface, NULL, (m_flipflags));
+ ret = m_gl2context->Bind(m_gl2context, m_dfb_surface, m_dfb_surface);
+ if (ret)
+ {
+ return false;
+ }
+
+ return true;
+}
+
+void CWinSystemDFB::SetVSyncImpl(bool enable)
+{
+ m_flipflags = enable ? (DFBSurfaceFlipFlags)(m_flipflags | DSFLIP_ONSYNC) : (DFBSurfaceFlipFlags)(m_flipflags & ~DSFLIP_ONSYNC);
+}
+
+#endif
Oops, something went wrong.

0 comments on commit fe5788b

Please sign in to comment.