From 9b667ffd564910ff7373547ce2f8d4a7c5d71137 Mon Sep 17 00:00:00 2001 From: Zhigang Gong Date: Wed, 20 Jul 2011 14:33:00 +0800 Subject: [PATCH] glamor: Use small internal texture format if possible. Reduce some texture memory requirement and also save some bandwidth. Signed-off-by: Zhigang Gong --- glamor/glamor.c | 6 +++--- glamor/glamor_pixmap.c | 15 ++++++++++++++- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/glamor/glamor.c b/glamor/glamor.c index 695230885..33a33d690 100644 --- a/glamor/glamor.c +++ b/glamor/glamor.c @@ -151,10 +151,10 @@ glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth, if (w == 0 || h == 0 || type == GLAMOR_PIXMAP_MEMORY) return pixmap; - /* We should probably take advantage of ARB_fbo's allowance of GL_ALPHA. - * FBOs, which EXT_fbo forgot to do. - */ switch (depth) { + case 8: + format = GL_ALPHA; + break; case 24: format = GL_RGB; break; diff --git a/glamor/glamor_pixmap.c b/glamor/glamor_pixmap.c index 924a17369..0f85d9687 100644 --- a/glamor/glamor_pixmap.c +++ b/glamor/glamor_pixmap.c @@ -199,7 +199,20 @@ __glamor_upload_pixmap_to_texture(PixmapPtr pixmap, GLenum format, GLenum type, glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap); unsigned int stride, row_length; void *texels; - GLenum iformat = GL_RGBA; + GLenum iformat; + + switch (pixmap->drawable.depth) { + case 8: + iformat = GL_ALPHA; + break; + case 24: + iformat = GL_RGB; + break; + default: + iformat = GL_RGBA; + break; + } + stride = pixmap->devKind; row_length = (stride * 8) / pixmap->drawable.bitsPerPixel;