glamor: Use small internal texture format if possible.

Reduce some texture memory requirement and also save
some bandwidth.

Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
This commit is contained in:
Zhigang Gong 2011-07-20 14:33:00 +08:00
parent 01489f9da9
commit 9b667ffd56
2 changed files with 17 additions and 4 deletions

View File

@ -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;

View File

@ -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;