From 9fbb8884f034e0d691fed0e099d4d796f3b42848 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Sun, 27 Sep 2009 20:24:59 -0600 Subject: mesa/drivers: use _mesa_get_format_bytes() --- src/mesa/drivers/dri/i810/i810texmem.c | 59 ++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 28 deletions(-) (limited to 'src/mesa/drivers/dri/i810') diff --git a/src/mesa/drivers/dri/i810/i810texmem.c b/src/mesa/drivers/dri/i810/i810texmem.c index 5ad66dbf5c..8cbe38f5fc 100644 --- a/src/mesa/drivers/dri/i810/i810texmem.c +++ b/src/mesa/drivers/dri/i810/i810texmem.c @@ -92,44 +92,47 @@ static void i810UploadTexLevel( i810ContextPtr imesa, { const struct gl_texture_image *image = t->image[hwlevel].image; int j; + GLuint texelBytes; if (!image || !image->Data) return; - if (image->Width * image->TexFormat->TexelBytes == t->Pitch) { + texelBytes = _mesa_get_format_bytes(image->TexFormat->MesaFormat); + + if (image->Width * texelBytes == t->Pitch) { GLubyte *dst = (GLubyte *)(t->BufAddr + t->image[hwlevel].offset); GLubyte *src = (GLubyte *)image->Data; memcpy( dst, src, t->Pitch * image->Height ); } - else switch (image->TexFormat->TexelBytes) { - case 1: - { - GLubyte *dst = (GLubyte *)(t->BufAddr + t->image[hwlevel].offset); - GLubyte *src = (GLubyte *)image->Data; - - for (j = 0 ; j < image->Height ; j++, dst += t->Pitch) { - __memcpy(dst, src, image->Width ); - src += image->Width; - } + else { + switch (texelBytes) { + case 1: + { + GLubyte *dst = (GLubyte *)(t->BufAddr + t->image[hwlevel].offset); + GLubyte *src = (GLubyte *)image->Data; + + for (j = 0 ; j < image->Height ; j++, dst += t->Pitch) { + __memcpy(dst, src, image->Width ); + src += image->Width; + } + } + break; + case 2: + { + GLushort *dst = (GLushort *)(t->BufAddr + t->image[hwlevel].offset); + GLushort *src = (GLushort *)image->Data; + + for (j = 0 ; j < image->Height ; j++, dst += (t->Pitch/2)) { + __memcpy(dst, src, image->Width * 2 ); + src += image->Width; + } + } + break; + default: + fprintf(stderr, "%s: Not supported texel size %d\n", + __FUNCTION__, texelBytes); } - break; - - case 2: - { - GLushort *dst = (GLushort *)(t->BufAddr + t->image[hwlevel].offset); - GLushort *src = (GLushort *)image->Data; - - for (j = 0 ; j < image->Height ; j++, dst += (t->Pitch/2)) { - __memcpy(dst, src, image->Width * 2 ); - src += image->Width; - } - } - break; - - default: - fprintf(stderr, "%s: Not supported texel size %d\n", - __FUNCTION__, image->TexFormat->TexelBytes); } } -- cgit v1.2.3