{
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);
}
}
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
GLuint depth = intelImage->base.Depth;
GLuint l2width, l2height, l2depth;
GLuint i, comp_byte = 0;
+ GLuint texelBytes;
DBG("%s\n", __FUNCTION__);
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,
width,
height,
depth,
- intelImage->base.TexFormat->TexelBytes,
+ texelBytes,
comp_byte,
expect_accelerated_upload);
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.
internalFormat,
level, level,
width, height, depth,
- intelImage->base.TexFormat->TexelBytes,
+ texelBytes,
comp_byte, pixels == NULL);
}
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.
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 ) )
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;
{
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);
}
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 ) )
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;
{
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 );
totalSize = ( baseImage->Height *
baseImage->Width *
- baseImage->TexFormat->TexelBytes );
+ _mesa_get_format_bytes(baseImage->TexFormat->MesaFormat) );
totalSize = (totalSize + 31) & ~31;
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);
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;
/* 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);
}
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;
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) {
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)
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 &&
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));
}
GLuint compressed = image->base.IsCompressed ? image->base.TexFormat->MesaFormat : 0;
GLuint numfaces = 1;
GLuint firstLevel, lastLevel;
+ GLuint texelBytes;
assert(!t->mt);
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
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)) {
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)
}
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 );