From ac0589c91699433bc9dbc25b7edff456dff742a4 Mon Sep 17 00:00:00 2001 From: Zhigang Gong Date: Fri, 10 Jun 2011 14:02:19 +0800 Subject: [PATCH] glamor: Use software fb for 1bpp pixmap. For 1bpp pixmap, software fb get better performance than GL surface. The main reason is that fbo doesn't support 1bpp texture as internal format, so we have to translate a 1bpp bitmap to a 8bit alpha format each time which is very inefficient. And the previous implementation is not supported by the latest OpenGL 4.0, the GL_BITMAP was deprecated. Signed-off-by: Zhigang Gong --- glamor/glamor.c | 5 +++-- glamor/glamor_core.c | 13 ++----------- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/glamor/glamor.c b/glamor/glamor.c index 42e398646..be5999a0c 100644 --- a/glamor/glamor.c +++ b/glamor/glamor.c @@ -108,7 +108,7 @@ glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth, if (w > 32767 || h > 32767) return NullPixmap; - if (w > MAX_WIDTH || h > MAX_HEIGHT) { + if (w > MAX_WIDTH || h > MAX_HEIGHT || ( depth == 1 && w != 0 && h != 0)) { /* MESA can only support upto MAX_WIDTH*MAX_HEIGHT fbo. If we exceed such limitation, we have to use framebuffer.*/ type = GLAMOR_FB; @@ -117,7 +117,8 @@ glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth, (((w * pixmap->drawable.bitsPerPixel + 7) / 8) + 3) & ~3, NULL); - ErrorF("fallback to software fb for pixmap %p , %d x %d \n", pixmap, w, h); + + glamor_fallback("fallback to software fb for pixmap %p , %d x %d depth %d\n", pixmap, w, h, depth); } else pixmap = fbCreatePixmap (screen, 0, 0, depth, usage); diff --git a/glamor/glamor_core.c b/glamor/glamor_core.c index 0bfa7600a..14031d276 100644 --- a/glamor/glamor_core.c +++ b/glamor/glamor_core.c @@ -309,13 +309,8 @@ glamor_prepare_access(DrawablePtr drawable, glamor_access_t access) stride = pixmap->devKind; row_length = (stride * 8) / pixmap->drawable.bitsPerPixel; - + assert(drawable->depth != 1); switch (drawable->depth) { - case 1: - format = GL_ALPHA; - type = GL_UNSIGNED_BYTE; - row_length = stride; - break; case 8: format = GL_ALPHA; type = GL_UNSIGNED_BYTE; @@ -485,14 +480,10 @@ glamor_load_texture_pixmap(PixmapPtr pixmap) else ptexcoords = texcoords; + assert(pixmap->drawable.depth != 1); stride = pixmap->devKind; row_length = (stride * 8) / pixmap->drawable.bitsPerPixel; switch (pixmap->drawable.depth) { - case 1: - format = GL_COLOR_INDEX; - type = GL_BITMAP; - row_length = stride; - break; case 8: format = GL_ALPHA; type = GL_UNSIGNED_BYTE;