[Intel-gfx] [PATCH v2 1/3] glamor: Initial commit to introduce glamor acceleration.

Zhigang Gong zhigang.gong at linux.intel.com
Mon Nov 14 08:04:42 CET 2011


Added one configuration option --enable-glamor to control
whether use glamor. Added one new file intel_glamor.c to
wrap glamor egl API for intel driver's usage.
This commit doesn't really change the driver's control path.
It just adds necessary files for glamor and change some
configuration.

Reviewed-by: Eugeni Dodonov <eugeni.dodonov at intel.com>
Signed-off-by: Zhigang Gong <zhigang.gong at linux.intel.com>
---
 configure.ac       |   17 +++++++
 src/Makefile.am    |    5 ++
 src/intel_glamor.c |  130 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/intel_glamor.h |   45 ++++++++++++++++++
 4 files changed, 197 insertions(+), 0 deletions(-)
 create mode 100644 src/intel_glamor.c
 create mode 100644 src/intel_glamor.h

diff --git a/configure.ac b/configure.ac
index fccab56..dc01c46 100644
--- a/configure.ac
+++ b/configure.ac
@@ -126,6 +126,15 @@ AC_ARG_ENABLE(sna,
 	      [SNA="$enableval"],
 	      [SNA=no])
 AM_CONDITIONAL(SNA, test x$SNA != xno)
+
+AC_ARG_ENABLE(glamor,
+	      AS_HELP_STRING([--enable-glamor],
+			     [Enable glamor, a new GL-based acceleration [default=no]]),
+	      [GLAMOR="$enableval"],
+	      [GLAMOR=no])
+
+AM_CONDITIONAL(GLAMOR, test x$GLAMOR != xno)
+
 AC_MSG_CHECKING([whether to include SNA support])
 
 required_xorg_xserver_version=1.6
@@ -137,6 +146,14 @@ if test "x$SNA" != "xno"; then
 fi
 AC_MSG_RESULT([$SNA])
 
+if test "x$GLAMOR" != "xno"; then
+	PKG_CHECK_MODULES(LIBGLAMOR, [glamor])
+	PKG_CHECK_MODULES(LIBGLAMOR_EGL, [glamor-egl])
+	AC_DEFINE(GLAMOR, 1, [Enable glamor acceleration])
+fi
+
+AC_MSG_CHECKING([whether to include GLAMOR support])
+AC_MSG_RESULT([$GLAMOR])
 
 AC_ARG_ENABLE(vmap,
 	      AS_HELP_STRING([--enable-vmap],
diff --git a/src/Makefile.am b/src/Makefile.am
index cd1bb36..1a29390 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -40,6 +40,10 @@ SUBDIRS += sna
 intel_drv_la_LIBADD += sna/libsna.la
 endif
 
+if GLAMOR
+GLAMOR_SOURCE = intel_glamor.c
+endif
+
 NULL:=#
 
 intel_drv_la_SOURCES = \
@@ -70,6 +74,7 @@ intel_drv_la_SOURCES = \
 	 i965_3d.c \
 	 i965_video.c \
 	 i965_render.c \
+	 $(GLAMOR_SOURCE) \
 	 $(NULL)
 
 if DRI
diff --git a/src/intel_glamor.c b/src/intel_glamor.c
new file mode 100644
index 0000000..cadfc71
--- /dev/null
+++ b/src/intel_glamor.c
@@ -0,0 +1,130 @@
+/*
+ * Copyright © 2011 Intel Corporation.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including
+ * the next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ *    Zhigang Gong <zhigang.gong at linux.intel.com>
+ *
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <errno.h>
+#include <xf86drm.h>
+
+#define GLAMOR_FOR_XORG  1
+
+#include <glamor.h>
+#include "intel.h"
+#include "intel_glamor.h"
+
+Bool
+intel_glamor_create_screen_resources(ScreenPtr screen)
+{
+	ScrnInfoPtr scrn = xf86Screens[screen->myNum];
+	intel_screen_private *intel = intel_get_screen_private(scrn);
+
+	if (!glamor_glyphs_init(screen))
+		return FALSE;
+	if (!glamor_egl_create_textured_screen(screen,
+					       intel->front_buffer->handle,
+					       intel->front_pitch))
+		return FALSE;
+	return TRUE;
+}
+
+Bool
+intel_glamor_pre_init(ScrnInfoPtr scrn)
+{
+	intel_screen_private *intel;
+	intel = intel_get_screen_private(scrn);
+	return glamor_egl_init(scrn, intel->drmSubFD);
+}
+
+Bool
+intel_glamor_create_textured_pixmap(PixmapPtr pixmap)
+{
+	struct intel_pixmap *priv;
+	priv = intel_get_pixmap_private(pixmap);
+	return glamor_egl_create_textured_pixmap(pixmap, priv->bo->handle,
+						 priv->stride);
+}
+
+void
+intel_glamor_destroy_pixmap(PixmapPtr pixmap)
+{
+	glamor_egl_destroy_textured_pixmap(pixmap);
+}
+
+Bool
+intel_glamor_init(ScreenPtr screen)
+{
+	ScrnInfoPtr scrn = xf86Screens[screen->myNum];
+
+	if (!glamor_init(screen, GLAMOR_INVERTED_Y_AXIS)) {
+		xf86DrvMsg(scrn->scrnIndex, X_ERROR,
+			   "Failed to initialize glamor\n");
+		return FALSE;
+	}
+
+	if (!glamor_egl_init_textured_pixmap(screen)) {
+		xf86DrvMsg(scrn->scrnIndex, X_ERROR,
+			   "Failed to initialize glamor\n");
+		return FALSE;
+	}
+
+	return TRUE;
+}
+
+void
+intel_glamor_block_handler(intel_screen_private * intel)
+{
+	ScreenPtr screen = screenInfo.screens[intel->scrn->scrnIndex];
+	glamor_block_handler(screen);
+}
+
+Bool
+intel_glamor_create_screen_image(ScreenPtr screen, int handle, int stride)
+{
+	PixmapPtr pixmap;
+	if (!glamor_egl_create_textured_screen(screen, handle, stride))
+		return FALSE;
+	pixmap = screen->GetScreenPixmap(screen);
+	return TRUE;
+}
+
+Bool
+intel_glamor_close_screen(ScreenPtr screen)
+{
+	return glamor_egl_close_screen(screen);
+}
+
+void
+intel_glamor_free_screen(int scrnIndex, int flags)
+{
+	glamor_egl_free_screen(scrnIndex, GLAMOR_EGL_EXTERNAL_BUFFER);
+}
diff --git a/src/intel_glamor.h b/src/intel_glamor.h
new file mode 100644
index 0000000..d7c2c86
--- /dev/null
+++ b/src/intel_glamor.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright © 2011 Intel Corporation.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including
+ * the next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ *    Zhigang Gong <zhigang.gong at linux.intel.com>
+ *
+ */
+Bool intel_glamor_pre_init(ScrnInfoPtr scrn);
+
+Bool intel_glamor_init(ScreenPtr screen);
+
+Bool intel_glamor_create_screen_resources(ScreenPtr screen);
+
+Bool intel_glamor_create_screen_image(ScreenPtr screen, int handle, int stride);
+
+Bool intel_glamor_close_screen(ScreenPtr screen);
+
+void intel_glamor_free_screen(int scrnIndex, int flags);
+
+void intel_glamor_block_handler(intel_screen_private * intel);
+
+Bool intel_glamor_create_textured_pixmap(PixmapPtr pixmap);
+
+void intel_glamor_destroy_pixmap(PixmapPtr pixmap);
-- 
1.7.4.4




More information about the Intel-gfx mailing list