summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/dri
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/drivers/dri')
-rw-r--r--src/mesa/drivers/dri/i810/i810texmem.c59
-rw-r--r--src/mesa/drivers/dri/intel/intel_mipmap_tree.c2
-rw-r--r--src/mesa/drivers/dri/intel/intel_tex_image.c10
-rw-r--r--src/mesa/drivers/dri/intel/intel_tex_validate.c3
-rw-r--r--src/mesa/drivers/dri/mach64/mach64_texmem.c16
-rw-r--r--src/mesa/drivers/dri/mach64/mach64_texstate.c2
-rw-r--r--src/mesa/drivers/dri/mga/mga_texstate.c2
-rw-r--r--src/mesa/drivers/dri/r128/r128_texmem.c8
-rw-r--r--src/mesa/drivers/dri/r128/r128_texstate.c2
-rw-r--r--src/mesa/drivers/dri/r200/r200_texstate.c2
-rw-r--r--src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c9
-rw-r--r--src/mesa/drivers/dri/radeon/radeon_texstate.c2
-rw-r--r--src/mesa/drivers/dri/radeon/radeon_texture.c2
-rw-r--r--src/mesa/drivers/dri/sis/sis_tex.c2
14 files changed, 72 insertions, 49 deletions
diff --git a/src/mesa/drivers/dri/i810/i810texmem.c b/src/mesa/drivers/dri/i810/i810texmem.c
index 5ad66dbf5cb..8cbe38f5fcb 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);
}
}
diff --git a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
index c985da5aa25..188333c75f7 100644
--- a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
+++ b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
@@ -307,7 +307,7 @@ intel_miptree_match_image(struct intel_mipmap_tree *mt,
if (!image->IsCompressed &&
!mt->compressed &&
- image->TexFormat->TexelBytes != mt->cpp)
+ _mesa_get_format_bytes(image->TexFormat->MesaFormat) != mt->cpp)
return GL_FALSE;
/* Test image dimensions against the base level image adjusted for
diff --git a/src/mesa/drivers/dri/intel/intel_tex_image.c b/src/mesa/drivers/dri/intel/intel_tex_image.c
index 5c98860cdad..3bafbba3718 100644
--- a/src/mesa/drivers/dri/intel/intel_tex_image.c
+++ b/src/mesa/drivers/dri/intel/intel_tex_image.c
@@ -70,6 +70,7 @@ guess_and_alloc_mipmap_tree(struct intel_context *intel,
GLuint depth = intelImage->base.Depth;
GLuint l2width, l2height, l2depth;
GLuint i, comp_byte = 0;
+ GLuint texelBytes;
DBG("%s\n", __FUNCTION__);
@@ -126,6 +127,9 @@ guess_and_alloc_mipmap_tree(struct intel_context *intel,
assert(!intelObj->mt);
if (intelImage->base.IsCompressed)
comp_byte = intel_compressed_num_bytes(intelImage->base.TexFormat->MesaFormat);
+
+ texelBytes = _mesa_get_format_bytes(intelImage->base.TexFormat->MesaFormat);
+
intelObj->mt = intel_miptree_create(intel,
intelObj->base.Target,
intelImage->base._BaseFormat,
@@ -135,7 +139,7 @@ guess_and_alloc_mipmap_tree(struct intel_context *intel,
width,
height,
depth,
- intelImage->base.TexFormat->TexelBytes,
+ texelBytes,
comp_byte,
expect_accelerated_upload);
@@ -399,12 +403,14 @@ intelTexImage(GLcontext * ctx,
assert(intelImage->mt);
} else if (intelImage->base.Border == 0) {
int comp_byte = 0;
+ GLuint texelBytes = _mesa_get_format_bytes(intelImage->base.TexFormat->MesaFormat);
if (intelImage->base.IsCompressed) {
comp_byte =
intel_compressed_num_bytes(intelImage->base.TexFormat->MesaFormat);
}
+
/* Didn't fit in the object miptree, but it's suitable for inclusion in
* a miptree, so create one just for our level and store it in the image.
* It'll get moved into the object miptree at validate time.
@@ -414,7 +420,7 @@ intelTexImage(GLcontext * ctx,
internalFormat,
level, level,
width, height, depth,
- intelImage->base.TexFormat->TexelBytes,
+ texelBytes,
comp_byte, pixels == NULL);
}
diff --git a/src/mesa/drivers/dri/intel/intel_tex_validate.c b/src/mesa/drivers/dri/intel/intel_tex_validate.c
index a284d5475f4..0393d7915ab 100644
--- a/src/mesa/drivers/dri/intel/intel_tex_validate.c
+++ b/src/mesa/drivers/dri/intel/intel_tex_validate.c
@@ -169,7 +169,8 @@ intel_finalize_mipmap_tree(struct intel_context *intel, GLuint unit)
comp_byte = intel_compressed_num_bytes(firstImage->base.TexFormat->MesaFormat);
cpp = comp_byte;
}
- else cpp = firstImage->base.TexFormat->TexelBytes;
+ else
+ cpp = _mesa_get_format_bytes(firstImage->base.TexFormat->MesaFormat);
/* Check tree can hold all active levels. Check tree matches
* target, imageFormat, etc.
diff --git a/src/mesa/drivers/dri/mach64/mach64_texmem.c b/src/mesa/drivers/dri/mach64/mach64_texmem.c
index 734e547952e..843b2310517 100644
--- a/src/mesa/drivers/dri/mach64/mach64_texmem.c
+++ b/src/mesa/drivers/dri/mach64/mach64_texmem.c
@@ -76,6 +76,7 @@ static void mach64UploadAGPSubImage( mach64ContextPtr mmesa,
struct gl_texture_image *image;
int texelsPerDword = 0;
int dwords;
+ GLuint texelBytes;
/* Ensure we have a valid texture to upload */
if ( ( level < 0 ) || ( level > mmesa->glCtx->Const.MaxTextureLevels ) )
@@ -85,7 +86,9 @@ static void mach64UploadAGPSubImage( mach64ContextPtr mmesa,
if ( !image )
return;
- switch ( image->TexFormat->TexelBytes ) {
+ texelBytes = _mesa_get_format_bytes(image->TexFormat->MesaFormat);
+
+ switch ( texelBytes ) {
case 1: texelsPerDword = 4; break;
case 2: texelsPerDword = 2; break;
case 4: texelsPerDword = 1; break;
@@ -118,8 +121,8 @@ static void mach64UploadAGPSubImage( mach64ContextPtr mmesa,
{
CARD32 *dst = (CARD32 *)((char *)mach64Screen->agpTextures.map + t->base.memBlock->ofs);
const GLubyte *src = (const GLubyte *) image->Data +
- (y * image->Width + x) * image->TexFormat->TexelBytes;
- const GLuint bytes = width * height * image->TexFormat->TexelBytes;
+ (y * image->Width + x) * texelBytes;
+ const GLuint bytes = width * height * texelBytes;
memcpy(dst, src, bytes);
}
@@ -140,6 +143,7 @@ static void mach64UploadLocalSubImage( mach64ContextPtr mmesa,
const int maxdwords = (MACH64_BUFFER_MAX_DWORDS - (MACH64_HOSTDATA_BLIT_OFFSET / 4));
CARD32 pitch, offset;
int i;
+ GLuint texelBytes;
/* Ensure we have a valid texture to upload */
if ( ( level < 0 ) || ( level > mmesa->glCtx->Const.MaxTextureLevels ) )
@@ -149,7 +153,9 @@ static void mach64UploadLocalSubImage( mach64ContextPtr mmesa,
if ( !image )
return;
- switch ( image->TexFormat->TexelBytes ) {
+ texelBytes = _mesa_get_format_bytes(image->TexFormat->MesaFormat);
+
+ switch ( texelBytes ) {
case 1: texelsPerDword = 4; break;
case 2: texelsPerDword = 2; break;
case 4: texelsPerDword = 1; break;
@@ -259,7 +265,7 @@ static void mach64UploadLocalSubImage( mach64ContextPtr mmesa,
{
const GLubyte *src = (const GLubyte *) image->Data +
- (y * image->Width + x) * image->TexFormat->TexelBytes;
+ (y * image->Width + x) * texelBytes;
mach64FireBlitLocked( mmesa, (void *)src, offset, pitch, format,
x, y, width, height );
diff --git a/src/mesa/drivers/dri/mach64/mach64_texstate.c b/src/mesa/drivers/dri/mach64/mach64_texstate.c
index fd2369dd882..ff03b0c40ab 100644
--- a/src/mesa/drivers/dri/mach64/mach64_texstate.c
+++ b/src/mesa/drivers/dri/mach64/mach64_texstate.c
@@ -89,7 +89,7 @@ static void mach64SetTexImages( mach64ContextPtr mmesa,
totalSize = ( baseImage->Height *
baseImage->Width *
- baseImage->TexFormat->TexelBytes );
+ _mesa_get_format_bytes(baseImage->TexFormat->MesaFormat) );
totalSize = (totalSize + 31) & ~31;
diff --git a/src/mesa/drivers/dri/mga/mga_texstate.c b/src/mesa/drivers/dri/mga/mga_texstate.c
index ad765d1dd76..8f78ab9bd4a 100644
--- a/src/mesa/drivers/dri/mga/mga_texstate.c
+++ b/src/mesa/drivers/dri/mga/mga_texstate.c
@@ -131,7 +131,7 @@ mgaSetTexImages( mgaContextPtr mmesa,
break;
size = texImage->Width * texImage->Height *
- baseImage->TexFormat->TexelBytes;
+ _mesa_get_format_bytes(baseImage->TexFormat->MesaFormat);
t->offsets[i] = totalSize;
t->base.dirty_images[0] |= (1<<i);
diff --git a/src/mesa/drivers/dri/r128/r128_texmem.c b/src/mesa/drivers/dri/r128/r128_texmem.c
index 111fe1fd742..c369e14bd50 100644
--- a/src/mesa/drivers/dri/r128/r128_texmem.c
+++ b/src/mesa/drivers/dri/r128/r128_texmem.c
@@ -95,7 +95,7 @@ static void uploadSubImage( r128ContextPtr rmesa, r128TexObjPtr t,
if ( !image )
return;
- switch ( image->TexFormat->TexelBytes ) {
+ switch ( _mesa_get_format_bytes(image->TexFormat->MesaFormat) ) {
case 1: texelsPerDword = 4; break;
case 2: texelsPerDword = 2; break;
case 4: texelsPerDword = 1; break;
@@ -215,9 +215,11 @@ static void uploadSubImage( r128ContextPtr rmesa, r128TexObjPtr t,
/* Copy the next chunck of the texture image into the blit buffer */
{
+ const GLuint texelBytes =
+ _mesa_get_format_bytes(image->TexFormat->MesaFormat);
const GLubyte *src = (const GLubyte *) image->Data +
- (y * image->Width + x) * image->TexFormat->TexelBytes;
- const GLuint bytes = width * height * image->TexFormat->TexelBytes;
+ (y * image->Width + x) * texelBytes;
+ const GLuint bytes = width * height * texelBytes;
memcpy(dst, src, bytes);
}
diff --git a/src/mesa/drivers/dri/r128/r128_texstate.c b/src/mesa/drivers/dri/r128/r128_texstate.c
index a9c9568003b..9f4f9aea2db 100644
--- a/src/mesa/drivers/dri/r128/r128_texstate.c
+++ b/src/mesa/drivers/dri/r128/r128_texstate.c
@@ -123,7 +123,7 @@ static void r128SetTexImages( r128ContextPtr rmesa,
totalSize += (tObj->Image[0][i]->Height *
tObj->Image[0][i]->Width *
- tObj->Image[0][i]->TexFormat->TexelBytes);
+ _mesa_get_format_bytes(tObj->Image[0][i]->TexFormat->MesaFormat));
/* Offsets must be 32-byte aligned for host data blits and tiling */
totalSize = (totalSize + 31) & ~31;
diff --git a/src/mesa/drivers/dri/r200/r200_texstate.c b/src/mesa/drivers/dri/r200/r200_texstate.c
index c94834752ed..03f0613e7a1 100644
--- a/src/mesa/drivers/dri/r200/r200_texstate.c
+++ b/src/mesa/drivers/dri/r200/r200_texstate.c
@@ -1437,7 +1437,7 @@ static void setup_hardware_state(r200ContextPtr rmesa, radeonTexObj *t)
log2Width = firstImage->WidthLog2;
log2Height = firstImage->HeightLog2;
log2Depth = firstImage->DepthLog2;
- texelBytes = firstImage->TexFormat->TexelBytes;
+ texelBytes = _mesa_get_format_bytes(firstImage->TexFormat->MesaFormat);
if (!t->image_override) {
diff --git a/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c b/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c
index 11c21037c44..851474f8716 100644
--- a/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c
+++ b/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c
@@ -347,6 +347,7 @@ GLboolean radeon_miptree_matches_texture(radeon_mipmap_tree *mt, struct gl_textu
GLuint compressed;
GLuint numfaces = 1;
GLuint firstLevel, lastLevel;
+ GLuint texelBytes;
calculate_first_last_level(texObj, &firstLevel, &lastLevel, 0, texObj->BaseLevel);
if (texObj->Target == GL_TEXTURE_CUBE_MAP)
@@ -354,6 +355,7 @@ GLboolean radeon_miptree_matches_texture(radeon_mipmap_tree *mt, struct gl_textu
firstImage = texObj->Image[0][firstLevel];
compressed = firstImage->IsCompressed ? firstImage->TexFormat->MesaFormat : 0;
+ texelBytes = _mesa_get_format_bytes(firstImage->TexFormat->MesaFormat);
return (mt->firstLevel == firstLevel &&
mt->lastLevel == lastLevel &&
@@ -361,7 +363,7 @@ GLboolean radeon_miptree_matches_texture(radeon_mipmap_tree *mt, struct gl_textu
mt->height0 == firstImage->Height &&
mt->depth0 == firstImage->Depth &&
mt->compressed == compressed &&
- (!mt->compressed ? (mt->bpp == firstImage->TexFormat->TexelBytes) : 1));
+ (!mt->compressed ? (mt->bpp == texelBytes) : 1));
}
@@ -375,6 +377,7 @@ void radeon_try_alloc_miptree(radeonContextPtr rmesa, radeonTexObj *t,
GLuint compressed = image->base.IsCompressed ? image->base.TexFormat->MesaFormat : 0;
GLuint numfaces = 1;
GLuint firstLevel, lastLevel;
+ GLuint texelBytes;
assert(!t->mt);
@@ -385,11 +388,13 @@ void radeon_try_alloc_miptree(radeonContextPtr rmesa, radeonTexObj *t,
if (level != firstLevel || face >= numfaces)
return;
+ texelBytes = _mesa_get_format_bytes(image->base.TexFormat->MesaFormat);
+
t->mt = radeon_miptree_create(rmesa, t, t->base.Target,
image->base.InternalFormat,
firstLevel, lastLevel,
image->base.Width, image->base.Height, image->base.Depth,
- image->base.TexFormat->TexelBytes, t->tile_bits, compressed);
+ texelBytes, t->tile_bits, compressed);
}
/* Although we use the image_offset[] array to store relative offsets
diff --git a/src/mesa/drivers/dri/radeon/radeon_texstate.c b/src/mesa/drivers/dri/radeon/radeon_texstate.c
index ae41b90efe5..a00497a8f94 100644
--- a/src/mesa/drivers/dri/radeon/radeon_texstate.c
+++ b/src/mesa/drivers/dri/radeon/radeon_texstate.c
@@ -1031,7 +1031,7 @@ static GLboolean setup_hardware_state(r100ContextPtr rmesa, radeonTexObj *t, int
log2Width = firstImage->WidthLog2;
log2Height = firstImage->HeightLog2;
log2Depth = firstImage->DepthLog2;
- texelBytes = firstImage->TexFormat->TexelBytes;
+ texelBytes = _mesa_get_format_bytes(firstImage->TexFormat->MesaFormat);
if (!t->image_override) {
if (VALID_FORMAT(firstImage->TexFormat->MesaFormat)) {
diff --git a/src/mesa/drivers/dri/radeon/radeon_texture.c b/src/mesa/drivers/dri/radeon/radeon_texture.c
index a35c783d2ee..416ca1974b1 100644
--- a/src/mesa/drivers/dri/radeon/radeon_texture.c
+++ b/src/mesa/drivers/dri/radeon/radeon_texture.c
@@ -900,7 +900,7 @@ static void migrate_image_to_miptree(radeon_mipmap_tree *mt, radeon_texture_imag
srcrowstride = _mesa_compressed_row_stride(image->base.TexFormat->MesaFormat, image->base.Width);
} else {
height = image->base.Height * image->base.Depth;
- srcrowstride = image->base.Width * image->base.TexFormat->TexelBytes;
+ srcrowstride = image->base.Width * _mesa_get_format_bytes(image->base.TexFormat->MesaFormat);
}
// if (mt->tilebits)
diff --git a/src/mesa/drivers/dri/sis/sis_tex.c b/src/mesa/drivers/dri/sis/sis_tex.c
index f40a8732098..38a309d41fc 100644
--- a/src/mesa/drivers/dri/sis/sis_tex.c
+++ b/src/mesa/drivers/dri/sis/sis_tex.c
@@ -107,7 +107,7 @@ sisAllocTexImage( sisContextPtr smesa, sisTexObjPtr t, int level,
}
assert(t->format == image->_BaseFormat);
- texel_size = image->TexFormat->TexelBytes;
+ texel_size = _mesa_get_format_bytes(image->TexFormat->MesaFormat);
size = image->Width * image->Height * texel_size + TEXTURE_HW_PLUS;
addr = sisAllocFB( smesa, size, &t->image[level].handle );