From ca36ada041558d1823b12b1a0141e43b9f9ad939 Mon Sep 17 00:00:00 2001 From: Zhigang Gong Date: Wed, 22 Jun 2011 18:15:02 +0800 Subject: [PATCH] glamor: Don't always fallback everything when change window attr. Change the glamor_change_window_attributes's handling. We don't need to fallback every thing to cpu at the beginning. Only when there is a real need to change the pixmap's format, we need to do something. Otherwise, we need do nothing here. Signed-off-by: Zhigang Gong --- glamor/Makefile.am | 1 + glamor/glamor_core.c | 52 +++++------------------------ glamor/glamor_debug.h | 19 +++++++++-- glamor/glamor_render.c | 18 ++++++++-- glamor/glamor_tile.c | 5 ++- glamor/glamor_window.c | 74 ++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 118 insertions(+), 51 deletions(-) create mode 100644 glamor/glamor_window.c diff --git a/glamor/Makefile.am b/glamor/Makefile.am index 53877dcbe..e2678f060 100644 --- a/glamor/Makefile.am +++ b/glamor/Makefile.am @@ -33,6 +33,7 @@ libglamor_la_SOURCES = \ glamor_triangles.c\ glamor_pixmap.c\ glamor_picture.c\ + glamor_window.c\ glamor.h libglamor_la_LIBADD = \ glu3/libglu3.la diff --git a/glamor/glamor_core.c b/glamor/glamor_core.c index a61b8ae53..31734bed0 100644 --- a/glamor/glamor_core.c +++ b/glamor/glamor_core.c @@ -241,10 +241,13 @@ glamor_finish_access(DrawablePtr drawable) Bool glamor_prepare_access_gc(GCPtr gc) { - if (gc->stipple) + if (gc->stipple) { + glamor_fallback("has stipple %p\n", gc->stipple); if (!glamor_prepare_access(&gc->stipple->drawable, GLAMOR_ACCESS_RO)) return FALSE; + } if (gc->fillStyle == FillTiled) { + glamor_fallback("has tile pixmap %p\n", gc->tile.pixmap); if (!glamor_prepare_access (&gc->tile.pixmap->drawable, GLAMOR_ACCESS_RO)) { if (gc->stipple) @@ -332,6 +335,8 @@ glamor_validate_gc(GCPtr gc, unsigned long changes, DrawablePtr drawable) /* fb24_32ReformatTile will do direct access of a newly- * allocated pixmap. */ + glamor_fallback("GC %p tile FB_24_32 transformat %p.\n", gc, old_tile); + if (glamor_prepare_access(&old_tile->drawable, GLAMOR_ACCESS_RO)) { new_tile = fb24_32ReformatTile(old_tile, @@ -351,6 +356,7 @@ glamor_validate_gc(GCPtr gc, unsigned long changes, DrawablePtr drawable) if (!gc->tileIsPixel && FbEvenTile(gc->tile.pixmap->drawable.width * drawable->bitsPerPixel)) { + glamor_fallback("GC %p tile changed %p.\n", gc, gc->tile.pixmap); if (glamor_prepare_access(&gc->tile.pixmap->drawable, GLAMOR_ACCESS_RW)) { fbPadPixmap(gc->tile.pixmap); @@ -367,6 +373,7 @@ glamor_validate_gc(GCPtr gc, unsigned long changes, DrawablePtr drawable) /* We can't inline stipple handling like we do for GCTile because * it sets fbgc privates. */ + glamor_fallback("GC %p stipple changed %p.\n", gc, gc->stipple); if (glamor_prepare_access(&gc->stipple->drawable, GLAMOR_ACCESS_RW)) { fbValidateGC(gc, changes, drawable); glamor_finish_access(&gc->stipple->drawable); @@ -403,52 +410,11 @@ glamor_create_gc(GCPtr gc) return TRUE; } -Bool -glamor_prepare_access_window(WindowPtr window) -{ - if (window->backgroundState == BackgroundPixmap) { - if (!glamor_prepare_access(&window->background.pixmap->drawable, - GLAMOR_ACCESS_RO)) - return FALSE; - } - - if (window->borderIsPixel == FALSE) { - if (!glamor_prepare_access(&window->border.pixmap->drawable, - GLAMOR_ACCESS_RO)) { - if (window->backgroundState == BackgroundPixmap) - glamor_finish_access(&window->background.pixmap->drawable); - return FALSE; - } - } - return TRUE; -} - -void -glamor_finish_access_window(WindowPtr window) -{ - if (window->backgroundState == BackgroundPixmap) - glamor_finish_access(&window->background.pixmap->drawable); - - if (window->borderIsPixel == FALSE) - glamor_finish_access(&window->border.pixmap->drawable); -} - -Bool -glamor_change_window_attributes(WindowPtr window, unsigned long mask) -{ - Bool ret; - - if (!glamor_prepare_access_window(window)) - return FALSE; - ret = fbChangeWindowAttributes(window, mask); - glamor_finish_access_window(window); - return ret; -} - RegionPtr glamor_bitmap_to_region(PixmapPtr pixmap) { RegionPtr ret; + glamor_fallback("pixmap %p \n", pixmap); if (!glamor_prepare_access(&pixmap->drawable, GLAMOR_ACCESS_RO)) return NULL; ret = fbPixmapToRegion(pixmap); diff --git a/glamor/glamor_debug.h b/glamor/glamor_debug.h index aad4b3ca6..48682e802 100644 --- a/glamor/glamor_debug.h +++ b/glamor/glamor_debug.h @@ -5,9 +5,24 @@ #define GLAMOR_DELAYED_STRING_MAX 64 #define GLAMOR_DEBUG_NONE 0 +#define GLAMOR_DEBUG_UNIMPL 0 #define GLAMOR_DEBUG_FALLBACK 1 -#define GLAMOR_DEBUG_TEXTURE_DYNAMIC_UPLOAD 2 -#define GLAMOR_DEBUG_TEXTURE_DOWNLOAD 3 +#define GLAMOR_DEBUG_TEXTURE_DOWNLOAD 2 +#define GLAMOR_DEBUG_TEXTURE_DYNAMIC_UPLOAD 3 + +extern void +AbortServer(void) _X_NORETURN; + +#define GLAMOR_PANIC(_format_, ...) \ + do { \ + LogMessageVerb(X_NONE, 0, "Glamor Fatal Error" \ + " at %32s line %d: " _format_ "\n", \ + __FUNCTION__, __LINE__, \ + ##__VA_ARGS__ ); \ + AbortServer(); \ + } while(0) + + #define __debug_output_message(_format_, _prefix_, ...) \ diff --git a/glamor/glamor_render.c b/glamor/glamor_render.c index f991b0f17..14c3fa8d8 100644 --- a/glamor/glamor_render.c +++ b/glamor/glamor_render.c @@ -748,6 +748,7 @@ glamor_composite_with_shader(CARD8 op, if (source->pSourcePict->type == SourcePictTypeSolidFill) { key.source = SHADER_SOURCE_SOLID; } else { + //key.source = SHADER_SOURCE_SOLID; glamor_fallback("gradient source\n"); goto fail; } @@ -1134,12 +1135,23 @@ glamor_composite(CARD8 op, return; fail: - glamor_fallback("glamor_composite(): " - "from picts %p/%p(%c,%c) to pict %p (%c)\n", - source, mask, + + glamor_fallback( + "from picts %p:%p %dx%d / %p:%p %d x %d (%c,%c) to pict %p:%p %dx%d (%c)\n", + source, + source->pDrawable, + source->pDrawable ? source->pDrawable->width : 0, + source->pDrawable ? source->pDrawable->height : 0, + mask, + (!mask) ? NULL : mask->pDrawable, + (!mask || !mask->pDrawable)? 0 : mask->pDrawable->width, + (!mask || !mask->pDrawable)? 0 : mask->pDrawable->height, glamor_get_picture_location(source), glamor_get_picture_location(mask), dest, + dest->pDrawable, + dest->pDrawable->width, + dest->pDrawable->height, glamor_get_picture_location(dest)); glUseProgramObjectARB(0); diff --git a/glamor/glamor_tile.c b/glamor/glamor_tile.c index 90bf734be..c62392c1b 100644 --- a/glamor/glamor_tile.c +++ b/glamor/glamor_tile.c @@ -94,18 +94,17 @@ glamor_tile(PixmapPtr pixmap, PixmapPtr tile, glamor_pixmap_private *src_pixmap_priv; glamor_pixmap_private *dst_pixmap_priv; + src_pixmap_priv = glamor_get_pixmap_private(tile); dst_pixmap_priv = glamor_get_pixmap_private(pixmap); - if (glamor_priv->tile_prog == 0) { glamor_fallback("Tiling unsupported\n"); goto fail; } - if (GLAMOR_PIXMAP_PRIV_HAS_FBO(dst_pixmap_priv)) { - glamor_fallback("dest has no fbo."); + glamor_fallback("dest has no fbo.\n"); goto fail; } diff --git a/glamor/glamor_window.c b/glamor/glamor_window.c new file mode 100644 index 000000000..05555b204 --- /dev/null +++ b/glamor/glamor_window.c @@ -0,0 +1,74 @@ +/* + * Copyright © 2008 Intel Corporation + * Copyright © 1998 Keith Packard + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Keith Packard not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Keith Packard makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#ifdef HAVE_DIX_CONFIG_H +#include +#endif + +#include "glamor_priv.h" + +/** @file glamor_window.c + * + * Screen Change Window Attribute implementation. + */ + + +static void +glamor_fixup_window_pixmap(DrawablePtr pDrawable, PixmapPtr *ppPixmap) +{ + PixmapPtr pPixmap = *ppPixmap; + glamor_pixmap_private *pixmap_priv; + + if (pPixmap->drawable.bitsPerPixel != pDrawable->bitsPerPixel) + { + pixmap_priv = glamor_get_pixmap_private(pPixmap); + if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv)) { + glamor_fallback("pixmap %p has no fbo\n", pPixmap); + goto fail; + } + glamor_debug_output(GLAMOR_DEBUG_UNIMPL, "To be implemented.\n"); + } + return; + +fail: + GLAMOR_PANIC(" We can't fall back to fbFixupWindowPixmap, as the fb24_32ReformatTile" + " is broken for glamor. \n"); +} + +Bool +glamor_change_window_attributes(WindowPtr pWin, unsigned long mask) +{ + if (mask & CWBackPixmap) { + if (pWin->backgroundState == BackgroundPixmap) + glamor_fixup_window_pixmap(&pWin->drawable, &pWin->background.pixmap); + } + + if (mask & CWBorderPixmap) { + if (pWin->borderIsPixel == FALSE) + glamor_fixup_window_pixmap(&pWin->drawable, &pWin->border.pixmap); + } + return TRUE; +} + + +