diff options
author | Zhigang Gong <zhigang.gong@linux.intel.com> | 2011-11-16 15:04:36 +0800 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2011-11-17 01:10:21 +0000 |
commit | fbabe60f48006ee664c983082498a863e8beec71 (patch) | |
tree | e0b76a3ee86fcb9b746565a7971ff52c979a0e24 | |
parent | c4c2eb1fae2518578a56a278afeaec66d544439d (diff) |
glamor: Initial commit to introduce glamor acceleration.
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@intel.com>
Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r-- | configure.ac | 14 | ||||
-rw-r--r-- | src/Makefile.am | 7 | ||||
-rw-r--r-- | src/intel.h | 1 | ||||
-rw-r--r-- | src/intel_display.c | 5 | ||||
-rw-r--r-- | src/intel_driver.c | 17 | ||||
-rw-r--r-- | src/intel_glamor.c | 226 | ||||
-rw-r--r-- | src/intel_glamor.h | 63 | ||||
-rw-r--r-- | src/intel_uxa.c | 34 |
8 files changed, 358 insertions, 9 deletions
diff --git a/configure.ac b/configure.ac index 8afe25b0..2b25ee59 100644 --- a/configure.ac +++ b/configure.ac @@ -148,6 +148,20 @@ if test "x$UXA" != "xno"; then fi AC_MSG_RESULT([$UXA]) +AC_MSG_CHECKING([whether to include GLAMOR support]) +AC_ARG_ENABLE(glamor, + AS_HELP_STRING([--enable-glamor], + [Enable glamor, a new GL-based acceleration [default=no]]), + [GLAMOR="$enableval"], + [GLAMOR=no]) +AC_MSG_RESULT([$GLAMOR]) +AM_CONDITIONAL(GLAMOR, test x$GLAMOR != xno) +if test "x$GLAMOR" != "xno"; then + PKG_CHECK_MODULES(LIBGLAMOR, [glamor]) + PKG_CHECK_MODULES(LIBGLAMOR_EGL, [glamor-egl]) + AC_DEFINE(USE_GLAMOR, 1, [Enable glamor acceleration]) +fi + AC_ARG_ENABLE(vmap, AS_HELP_STRING([--enable-vmap], [Enable use of vmap [default=no]]), diff --git a/src/Makefile.am b/src/Makefile.am index e5097daf..e821b94b 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -58,6 +58,7 @@ intel_drv_la_SOURCES += \ intel_display.c \ intel_driver.c \ intel_driver.h \ + intel_glamor.h \ intel_memory.c \ intel_shadow.c \ intel_uxa.c \ @@ -77,6 +78,12 @@ intel_drv_la_SOURCES += \ i965_render.c \ $(NULL) +if GLAMOR +intel_drv_la_SOURCES += \ + intel_glamor.c \ + $(NULL) +endif + if DRI intel_drv_la_SOURCES += \ intel_dri.c \ diff --git a/src/intel.h b/src/intel.h index 1a002e2c..1f004a86 100644 --- a/src/intel.h +++ b/src/intel.h @@ -316,6 +316,7 @@ typedef struct intel_screen_private { void (*batch_commit_notify) (struct intel_screen_private *intel); struct _UxaDriver *uxa_driver; + int uxa_flags; Bool need_sync; int accel_pixmap_offset_alignment; int accel_max_x; diff --git a/src/intel_display.c b/src/intel_display.c index 6fec8b0e..95a9488f 100644 --- a/src/intel_display.c +++ b/src/intel_display.c @@ -45,6 +45,8 @@ #include "X11/extensions/dpmsconst.h" #include "xf86DDC.h" +#include "intel_glamor.h" + struct intel_mode { int fd; uint32_t fb_id; @@ -453,6 +455,7 @@ intel_crtc_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode, crtc->y = y; crtc->rotation = rotation; + intel_glamor_flush(intel); intel_batch_submit(crtc->scrn); mode_to_kmode(crtc->scrn, &intel_crtc->kmode, mode); @@ -1365,6 +1368,7 @@ intel_xf86crtc_resize(ScrnInfoPtr scrn, int width, int height) if (scrn->virtualX == width && scrn->virtualY == height) return TRUE; + intel_glamor_flush(intel); intel_batch_submit(scrn); old_width = scrn->virtualX; @@ -1454,6 +1458,7 @@ intel_do_pageflip(intel_screen_private *intel, new_front->handle, &mode->fb_id)) goto error_out; + intel_glamor_flush(intel); intel_batch_submit(scrn); /* diff --git a/src/intel_driver.c b/src/intel_driver.c index 188c5125..451bebd9 100644 --- a/src/intel_driver.c +++ b/src/intel_driver.c @@ -76,6 +76,8 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "i915_drm.h" #include <xf86drmMode.h> +#include "intel_glamor.h" + /* *INDENT-OFF* */ /* * Note: "ColorKey" is provided for compatibility with the i810 driver. @@ -713,6 +715,13 @@ static Bool I830PreInit(ScrnInfoPtr scrn, int flags) return FALSE; } + if (!intel_glamor_pre_init(scrn)) { + PreInitCleanup(scrn); + xf86DrvMsg(scrn->scrnIndex, X_ERROR, + "Failed to pre init glamor display.\n"); + return FALSE; + } + /* Load the dri2 module if requested. */ if (intel->directRenderingType != DRI_DISABLED) xf86LoadSubModule(scrn, "dri2"); @@ -814,8 +823,10 @@ intel_flush_callback(CallbackListPtr *list, pointer user_data, pointer call_data) { ScrnInfoPtr scrn = user_data; - if (scrn->vtSema) + if (scrn->vtSema) { intel_batch_submit(scrn); + intel_glamor_flush(intel_get_screen_private(scrn)); + } } #if HAVE_UDEV @@ -1111,6 +1122,8 @@ static void I830FreeScreen(int scrnIndex, int flags) ScrnInfoPtr scrn = xf86Screens[scrnIndex]; intel_screen_private *intel = intel_get_screen_private(scrn); + intel_glamor_free_screen(scrnIndex, flags); + if (intel) { intel_mode_fini(intel); intel_close_drm_master(intel); @@ -1187,6 +1200,8 @@ static Bool I830CloseScreen(int scrnIndex, ScreenPtr screen) DeleteCallback(&FlushCallback, intel_flush_callback, scrn); + intel_glamor_close_screen(screen); + if (intel->uxa_driver) { uxa_driver_fini(screen); free(intel->uxa_driver); diff --git a/src/intel_glamor.c b/src/intel_glamor.c new file mode 100644 index 00000000..7b19d5d0 --- /dev/null +++ b/src/intel_glamor.c @@ -0,0 +1,226 @@ +/* + * 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@linux.intel.com> + * + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <xf86.h> +#define GLAMOR_FOR_XORG 1 +#include <glamor.h> + +#include "intel.h" +#include "intel_glamor.h" +#include "uxa.h" + +Bool +intel_glamor_create_screen_resources(ScreenPtr screen) +{ + ScrnInfoPtr scrn = xf86Screens[screen->myNum]; + intel_screen_private *intel = intel_get_screen_private(scrn); + + if (!(intel->uxa_flags & UXA_USE_GLAMOR)) + return TRUE; + + 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); + + /* Load glamor module */ + if (xf86LoadSubModule(scrn, "glamor_egl") && + glamor_egl_init(scrn, intel->drmSubFD)) { + xf86DrvMsg(scrn->scrnIndex, X_INFO, + "glamor detected, initialising\n"); + intel->uxa_flags |= UXA_USE_GLAMOR; + } else { + xf86DrvMsg(scrn->scrnIndex, X_WARNING, + "glamor not available\n"); + intel->uxa_flags &= ~UXA_USE_GLAMOR; + } + + return TRUE; +} + +Bool +intel_glamor_create_textured_pixmap(PixmapPtr pixmap) +{ + ScrnInfoPtr scrn = xf86Screens[pixmap->drawable.pScreen->myNum]; + intel_screen_private *intel = intel_get_screen_private(scrn); + struct intel_pixmap *priv; + + if ((intel->uxa_flags & UXA_USE_GLAMOR) == 0) + return TRUE; + + priv = intel_get_pixmap_private(pixmap); + if (glamor_egl_create_textured_pixmap(pixmap, priv->bo->handle, + priv->stride)) { + priv->pinned = 1; + return TRUE; + } else + return FALSE; +} + +void +intel_glamor_destroy_pixmap(PixmapPtr pixmap) +{ + ScrnInfoPtr scrn = xf86Screens[pixmap->drawable.pScreen->myNum]; + intel_screen_private * intel; + + intel = intel_get_screen_private(scrn); + if (intel->uxa_flags & UXA_USE_GLAMOR) + glamor_egl_destroy_textured_pixmap(pixmap); +} + +static void +intel_glamor_need_flush(DrawablePtr pDrawable) +{ + ScrnInfoPtr scrn = xf86Screens[pDrawable->pScreen->myNum]; + intel_screen_private * intel; + + intel = intel_get_screen_private(scrn); + intel->needs_flush = TRUE; +} + +static void +intel_glamor_finish_access(PixmapPtr pixmap, uxa_access_t access) +{ + switch(access) { + case UXA_ACCESS_RO: + case UXA_ACCESS_RW: + case UXA_GLAMOR_ACCESS_RO: + break; + case UXA_GLAMOR_ACCESS_RW: + intel_glamor_need_flush(&pixmap->drawable); + glamor_block_handler(pixmap->drawable.pScreen); + break; + default: + ErrorF("Invalid access mode %d\n", access); + } + + return; +} + + +Bool +intel_glamor_init(ScreenPtr screen) +{ + ScrnInfoPtr scrn = xf86Screens[screen->myNum]; + intel_screen_private *intel = intel_get_screen_private(scrn); + + if ((intel->uxa_flags & UXA_USE_GLAMOR) == 0) + return TRUE; + + if (!glamor_init(screen, GLAMOR_INVERTED_Y_AXIS)) { + xf86DrvMsg(scrn->scrnIndex, X_ERROR, + "Failed to initialize glamor\n"); + goto fail; + } + + if (!glamor_egl_init_textured_pixmap(screen)) { + xf86DrvMsg(scrn->scrnIndex, X_ERROR, + "Failed to initialize textured pixmap.\n"); + goto fail; + } + + intel->uxa_driver->flags |= UXA_USE_GLAMOR; + intel->uxa_flags = intel->uxa_driver->flags; + + intel->uxa_driver->finish_access = intel_glamor_finish_access; + + xf86DrvMsg(scrn->scrnIndex, X_INFO, + "Use GLAMOR acceleration.\n"); + return TRUE; + + fail: + xf86DrvMsg(scrn->scrnIndex, X_WARNING, + "Use standard UXA acceleration."); + return FALSE; +} + +void +intel_glamor_flush(intel_screen_private * intel) +{ + ScreenPtr screen; + + screen = screenInfo.screens[intel->scrn->scrnIndex]; + if (intel->uxa_flags & UXA_USE_GLAMOR) + glamor_block_handler(screen); +} + +Bool +intel_glamor_create_screen_image(ScreenPtr screen, int handle, int stride) +{ + ScrnInfoPtr scrn = xf86Screens[screen->myNum]; + intel_screen_private *intel; + PixmapPtr pixmap; + + intel = intel_get_screen_private(scrn); + if ((intel->uxa_flags & UXA_USE_GLAMOR) == 0) + return TRUE; + + if (!glamor_egl_create_textured_screen(screen, handle, stride)) + return FALSE; + + pixmap = screen->GetScreenPixmap(screen); + return TRUE; +} + +Bool +intel_glamor_close_screen(ScreenPtr screen) +{ + ScrnInfoPtr scrn = xf86Screens[screen->myNum]; + intel_screen_private * intel; + + intel = intel_get_screen_private(scrn); + if (intel && (intel->uxa_flags & UXA_USE_GLAMOR)) + return glamor_egl_close_screen(screen); + return TRUE; +} + +void +intel_glamor_free_screen(int scrnIndex, int flags) +{ + ScrnInfoPtr scrn = xf86Screens[scrnIndex]; + intel_screen_private * intel; + + intel = intel_get_screen_private(scrn); + if (intel && (intel->uxa_flags & UXA_USE_GLAMOR)) + 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 00000000..1ba17c03 --- /dev/null +++ b/src/intel_glamor.h @@ -0,0 +1,63 @@ +/* + * 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@linux.intel.com> + * + */ + +#ifndef INTEL_GLAMOR_H +#define INTEL_GLAMOR_H + +#ifdef USE_GLAMOR + +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_flush(intel_screen_private * intel); + +Bool intel_glamor_create_textured_pixmap(PixmapPtr pixmap); +void intel_glamor_destroy_pixmap(PixmapPtr pixmap); + +#else + +static inline Bool intel_glamor_pre_init(ScrnInfoPtr scrn) { return TRUE; } +static inline Bool intel_glamor_init(ScreenPtr screen) { return TRUE; } +static inline Bool intel_glamor_create_screen_resources(ScreenPtr screen) { return TRUE; } +static inline Bool intel_glamor_create_screen_image(ScreenPtr screen, int handle, int stride) { return TRUE; } +static inline Bool intel_glamor_close_screen(ScreenPtr screen) { return TRUE; } +static inline void intel_glamor_free_screen(int scrnIndex, int flags) { } + +static inline void intel_glamor_flush(intel_screen_private * intel) { } + +static inline Bool intel_glamor_create_textured_pixmap(PixmapPtr pixmap) { return TRUE; } +static inline void intel_glamor_destroy_pixmap(PixmapPtr pixmap) { } + +#endif + +#endif /* INTEL_GLAMOR_H */ diff --git a/src/intel_uxa.c b/src/intel_uxa.c index 94dfb86f..114a43ed 100644 --- a/src/intel_uxa.c +++ b/src/intel_uxa.c @@ -31,17 +31,19 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "config.h" #endif -#include "xf86.h" -#include "xaarop.h" -#include "intel.h" -#include "i830_reg.h" -#include "i915_drm.h" -#include "brw_defines.h" +#include <xf86.h> +#include <xaarop.h> #include <string.h> #include <errno.h> +#include "intel.h" +#include "intel_glamor.h" #include "uxa.h" +#include "i830_reg.h" +#include "i915_drm.h" +#include "brw_defines.h" + static const int I830CopyROP[16] = { ROP_0, /* GXclear */ ROP_DSa, /* GXand */ @@ -705,9 +707,15 @@ static Bool intel_uxa_prepare_access(PixmapPtr pixmap, uxa_access_t access) int ret; if (!list_is_empty(&priv->batch) && - (access == UXA_ACCESS_RW || priv->batch_write)) + ((access == UXA_ACCESS_RW || access == UXA_GLAMOR_ACCESS_RW) + || priv->batch_write)) intel_batch_submit(scrn); + if (access == UXA_GLAMOR_ACCESS_RW || access == UXA_GLAMOR_ACCESS_RO) + return TRUE; + + intel_glamor_flush(intel); + if (priv->tiling || bo->size <= intel->max_gtt_map_size) ret = drm_intel_gem_bo_map_gtt(bo); else @@ -966,6 +974,7 @@ void intel_uxa_block_handler(intel_screen_private *intel) * and beyond rendering results may not hit the * framebuffer until significantly later. */ + intel_glamor_flush(intel); intel_flush_rendering(intel); } @@ -1097,6 +1106,8 @@ intel_uxa_create_pixmap(ScreenPtr screen, int w, int h, int depth, list_init(&priv->batch); list_init(&priv->flush); intel_set_pixmap_private(pixmap, priv); + + intel_glamor_create_textured_pixmap(pixmap); } return pixmap; @@ -1104,8 +1115,10 @@ intel_uxa_create_pixmap(ScreenPtr screen, int w, int h, int depth, static Bool intel_uxa_destroy_pixmap(PixmapPtr pixmap) { - if (pixmap->refcnt == 1) + if (pixmap->refcnt == 1) { + intel_glamor_destroy_pixmap(pixmap); intel_set_pixmap_bo(pixmap, NULL); + } fbDestroyPixmap(pixmap); return TRUE; } @@ -1136,6 +1149,9 @@ Bool intel_uxa_create_screen_resources(ScreenPtr screen) scrn->displayWidth = intel->front_pitch / intel->cpp; } + if (!intel_glamor_create_screen_resources(screen)) + return FALSE; + return TRUE; } @@ -1298,5 +1314,7 @@ Bool intel_uxa_init(ScreenPtr screen) uxa_set_fallback_debug(screen, intel->fallback_debug); uxa_set_force_fallback(screen, intel->force_fallback); + intel_glamor_init(screen); + return TRUE; } |