summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBrian Paul <brianp@vmware.com>2009-10-01 16:29:44 -0600
committerBrian Paul <brianp@vmware.com>2009-10-01 16:29:44 -0600
commitb6bdafdf2cf1110b4a5ca7cf9e1c3dcb124b800f (patch)
treeaf668a98fe8ec899b8da9c25533f299c5c3f90d1 /src
parent040fd7ed44c21a1faaa6475888e9365e8f0de42b (diff)
mesa: remove gl_texture_image::IsCompressed field
Use _mesa_is_format_compressed() instead.
Diffstat (limited to 'src')
-rw-r--r--src/mesa/drivers/dri/intel/intel_mipmap_tree.c6
-rw-r--r--src/mesa/drivers/dri/intel/intel_tex_image.c7
-rw-r--r--src/mesa/drivers/dri/intel/intel_tex_subimage.c2
-rw-r--r--src/mesa/drivers/dri/intel/intel_tex_validate.c4
-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.c4
-rw-r--r--src/mesa/drivers/dri/radeon/radeon_texture.c4
-rw-r--r--src/mesa/drivers/dri/tdfx/tdfx_tex.c13
-rw-r--r--src/mesa/drivers/dri/unichrome/via_tex.c5
-rw-r--r--src/mesa/drivers/glide/fxddtex.c19
-rw-r--r--src/mesa/main/mipmap.c11
-rw-r--r--src/mesa/main/mtypes.h1
-rw-r--r--src/mesa/main/texgetimage.c2
-rw-r--r--src/mesa/main/teximage.c6
-rw-r--r--src/mesa/main/texparam.c4
-rw-r--r--src/mesa/main/texstore.c207
-rw-r--r--src/mesa/state_tracker/st_cb_texture.c5
18 files changed, 140 insertions, 171 deletions
diff --git a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
index 6bb7481ae4..a11869e7e8 100644
--- a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
+++ b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
@@ -293,6 +293,8 @@ intel_miptree_match_image(struct intel_mipmap_tree *mt,
struct gl_texture_image *image,
GLuint face, GLuint level)
{
+ GLboolean isCompressed = _mesa_is_format_compressed(image->TexFormat);
+
/* Images with borders are never pulled into mipmap trees.
*/
if (image->Border ||
@@ -302,10 +304,10 @@ intel_miptree_match_image(struct intel_mipmap_tree *mt,
return GL_FALSE;
if (image->InternalFormat != mt->internal_format ||
- image->IsCompressed != mt->compressed)
+ isCompressed != mt->compressed)
return GL_FALSE;
- if (!image->IsCompressed &&
+ if (!isCompressed &&
!mt->compressed &&
_mesa_get_format_bytes(image->TexFormat) != mt->cpp)
return GL_FALSE;
diff --git a/src/mesa/drivers/dri/intel/intel_tex_image.c b/src/mesa/drivers/dri/intel/intel_tex_image.c
index bbbeac8f7f..29cca45148 100644
--- a/src/mesa/drivers/dri/intel/intel_tex_image.c
+++ b/src/mesa/drivers/dri/intel/intel_tex_image.c
@@ -125,7 +125,7 @@ guess_and_alloc_mipmap_tree(struct intel_context *intel,
}
assert(!intelObj->mt);
- if (intelImage->base.IsCompressed)
+ if (_mesa_is_format_compressed(intelImage->base.TexFormat))
comp_byte = intel_compressed_num_bytes(intelImage->base.TexFormat);
texelBytes = _mesa_get_format_bytes(intelImage->base.TexFormat);
@@ -339,7 +339,6 @@ intelTexImage(GLcontext * ctx,
if (_mesa_is_format_compressed(texImage->TexFormat)) {
texelBytes = 0;
- texImage->IsCompressed = GL_TRUE;
texImage->CompressedSize =
ctx->Driver.CompressedTextureSize(ctx, texImage->Width,
texImage->Height, texImage->Depth,
@@ -405,7 +404,7 @@ intelTexImage(GLcontext * ctx,
int comp_byte = 0;
GLuint texelBytes = _mesa_get_format_bytes(intelImage->base.TexFormat);
GLenum baseFormat = _mesa_get_format_base_format(intelImage->base.TexFormat);
- if (intelImage->base.IsCompressed) {
+ if (_mesa_is_format_compressed(intelImage->base.TexFormat)) {
comp_byte =
intel_compressed_num_bytes(intelImage->base.TexFormat);
}
@@ -494,7 +493,7 @@ intelTexImage(GLcontext * ctx,
}
else {
/* Allocate regular memory and store the image there temporarily. */
- if (texImage->IsCompressed) {
+ if (_mesa_is_format_compressed(texImage->TexFormat)) {
sizeInBytes = texImage->CompressedSize;
dstRowStride =
_mesa_compressed_row_stride(texImage->TexFormat, width);
diff --git a/src/mesa/drivers/dri/intel/intel_tex_subimage.c b/src/mesa/drivers/dri/intel/intel_tex_subimage.c
index bba1b53009..cc329dae58 100644
--- a/src/mesa/drivers/dri/intel/intel_tex_subimage.c
+++ b/src/mesa/drivers/dri/intel/intel_tex_subimage.c
@@ -85,7 +85,7 @@ intelTexSubimage(GLcontext * ctx,
&dstRowStride,
texImage->ImageOffsets);
else {
- if (texImage->IsCompressed) {
+ if (_mesa_is_format_compressed(texImage->TexFormat)) {
dstRowStride =
_mesa_compressed_row_stride(texImage->TexFormat, width);
assert(dims != 3);
diff --git a/src/mesa/drivers/dri/intel/intel_tex_validate.c b/src/mesa/drivers/dri/intel/intel_tex_validate.c
index 0296c92523..d5b562f5e5 100644
--- a/src/mesa/drivers/dri/intel/intel_tex_validate.c
+++ b/src/mesa/drivers/dri/intel/intel_tex_validate.c
@@ -165,7 +165,7 @@ intel_finalize_mipmap_tree(struct intel_context *intel, GLuint unit)
intel_miptree_reference(&intelObj->mt, firstImage->mt);
}
- if (firstImage->base.IsCompressed) {
+ if (_mesa_is_format_compressed(firstImage->base.TexFormat)) {
comp_byte = intel_compressed_num_bytes(firstImage->base.TexFormat);
cpp = comp_byte;
}
@@ -190,7 +190,7 @@ intel_finalize_mipmap_tree(struct intel_context *intel, GLuint unit)
intelObj->mt->height0 != firstImage->base.Height ||
intelObj->mt->depth0 != firstImage->base.Depth ||
intelObj->mt->cpp != cpp ||
- intelObj->mt->compressed != firstImage->base.IsCompressed)) {
+ intelObj->mt->compressed != _mesa_is_format_compressed(firstImage->base.TexFormat))) {
intel_miptree_release(intel, &intelObj->mt);
}
diff --git a/src/mesa/drivers/dri/r200/r200_texstate.c b/src/mesa/drivers/dri/r200/r200_texstate.c
index daca318684..1a6fa9f548 100644
--- a/src/mesa/drivers/dri/r200/r200_texstate.c
+++ b/src/mesa/drivers/dri/r200/r200_texstate.c
@@ -1504,7 +1504,7 @@ static void setup_hardware_state(r200ContextPtr rmesa, radeonTexObj *t)
| ((firstImage->Height - 1) << R200_PP_TX_HEIGHTMASK_SHIFT));
if ( !t->image_override ) {
- if (firstImage->IsCompressed)
+ if (_mesa_is_format_compressed(firstImage->TexFormat))
t->pp_txpitch = (firstImage->Width + 63) & ~(63);
else
t->pp_txpitch = ((firstImage->Width * texelBytes) + 63) & ~(63);
diff --git a/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c b/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c
index b602bfb4b0..5429525587 100644
--- a/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c
+++ b/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c
@@ -314,16 +314,17 @@ static void calculate_first_last_level(struct gl_texture_object *tObj,
GLboolean radeon_miptree_matches_image(radeon_mipmap_tree *mt,
struct gl_texture_image *texImage, GLuint face, GLuint level)
{
+ GLboolean isCompressed = _mesa_is_format_compressed(texImage->TexFormat);
radeon_mipmap_level *lvl;
if (face >= mt->faces || level < mt->firstLevel || level > mt->lastLevel)
return GL_FALSE;
if (texImage->InternalFormat != mt->internal_format ||
- texImage->IsCompressed != mt->compressed)
+ isCompressed != mt->compressed)
return GL_FALSE;
- if (!texImage->IsCompressed &&
+ if (!isCompressed &&
!mt->compressed &&
_mesa_get_format_bytes(texImage->TexFormat) != mt->bpp)
return GL_FALSE;
@@ -354,7 +355,7 @@ GLboolean radeon_miptree_matches_texture(radeon_mipmap_tree *mt, struct gl_textu
numfaces = 6;
firstImage = texObj->Image[0][firstLevel];
- compressed = firstImage->IsCompressed ? firstImage->TexFormat : 0;
+ compressed = _mesa_is_format_compressed(firstImage->TexFormat) ? firstImage->TexFormat : 0;
texelBytes = _mesa_get_format_bytes(firstImage->TexFormat);
return (mt->firstLevel == firstLevel &&
@@ -374,7 +375,7 @@ GLboolean radeon_miptree_matches_texture(radeon_mipmap_tree *mt, struct gl_textu
void radeon_try_alloc_miptree(radeonContextPtr rmesa, radeonTexObj *t,
radeon_texture_image *image, GLuint face, GLuint level)
{
- GLuint compressed = image->base.IsCompressed ? image->base.TexFormat : 0;
+ GLuint compressed = _mesa_is_format_compressed(image->base.TexFormat) ? image->base.TexFormat : 0;
GLuint numfaces = 1;
GLuint firstLevel, lastLevel;
GLuint texelBytes;
diff --git a/src/mesa/drivers/dri/radeon/radeon_texstate.c b/src/mesa/drivers/dri/radeon/radeon_texstate.c
index 1064602504..5d22a11859 100644
--- a/src/mesa/drivers/dri/radeon/radeon_texstate.c
+++ b/src/mesa/drivers/dri/radeon/radeon_texstate.c
@@ -81,8 +81,10 @@ struct tx_table {
GLuint format, filter;
};
+/* XXX verify this table against MESA_FORMAT_x values */
static const struct tx_table tx_table[] =
{
+ 0, /* MESA_FORMAT_NONE */
_ALPHA(RGBA8888),
_ALPHA_REV(RGBA8888),
_ALPHA(ARGB8888),
@@ -1083,7 +1085,7 @@ static GLboolean setup_hardware_state(r100ContextPtr rmesa, radeonTexObj *t, int
| ((firstImage->Height - 1) << RADEON_TEX_VSIZE_SHIFT));
if ( !t->image_override ) {
- if (firstImage->IsCompressed)
+ if (_mesa_is_format_compressed(firstImage->TexFormat))
t->pp_txpitch = (firstImage->Width + 63) & ~(63);
else
t->pp_txpitch = ((firstImage->Width * texelBytes) + 63) & ~(63);
diff --git a/src/mesa/drivers/dri/radeon/radeon_texture.c b/src/mesa/drivers/dri/radeon/radeon_texture.c
index 0378b3c9fc..442116a2dd 100644
--- a/src/mesa/drivers/dri/radeon/radeon_texture.c
+++ b/src/mesa/drivers/dri/radeon/radeon_texture.c
@@ -546,13 +546,11 @@ static void radeon_teximage(
if (_mesa_is_format_compressed(texImage->TexFormat)) {
texelBytes = 0;
- texImage->IsCompressed = GL_TRUE;
texImage->CompressedSize =
ctx->Driver.CompressedTextureSize(ctx, texImage->Width,
texImage->Height, texImage->Depth,
texImage->TexFormat);
} else {
- texImage->IsCompressed = GL_FALSE;
texImage->CompressedSize = 0;
texelBytes = _mesa_get_format_bytes(texImage->TexFormat);
@@ -590,7 +588,7 @@ static void radeon_teximage(
dstRowStride = lvl->rowstride;
} else {
int size;
- if (texImage->IsCompressed) {
+ if (_mesa_is_format_compressed(texImage->TexFormat)) {
size = texImage->CompressedSize;
} else {
size = texImage->Width * texImage->Height * texImage->Depth * _mesa_get_format_bytes(texImage->TexFormat);
diff --git a/src/mesa/drivers/dri/tdfx/tdfx_tex.c b/src/mesa/drivers/dri/tdfx/tdfx_tex.c
index 427d315a01..8b68137eed 100644
--- a/src/mesa/drivers/dri/tdfx/tdfx_tex.c
+++ b/src/mesa/drivers/dri/tdfx/tdfx_tex.c
@@ -191,7 +191,6 @@ tdfxGenerateMipmap(GLcontext *ctx, GLenum target,
texImage = _mesa_get_tex_image(ctx, texObj, target, level);
texelBytes = _mesa_get_format_bytes(texImage->TexFormat);
- assert(!texImage->IsCompressed);
mml = TDFX_TEXIMAGE_DATA(texImage);
@@ -1233,7 +1232,7 @@ adjust2DRatio (GLcontext *ctx,
GLvoid *tempImage;
GLuint dstImageOffsets = 0;
- if (!texImage->IsCompressed) {
+ if (!_mesa_is_format_compressed(texImage->TexFormat)) {
GLubyte *destAddr;
tempImage = MALLOC(width * height * texelBytes);
@@ -1366,7 +1365,7 @@ tdfxTexImage2D(GLcontext *ctx, GLenum target, GLint level,
* be correct, since it would mess with "compressedSize".
* Ditto for GL_RGBA[4]_S3TC, which is always mapped to DXT3.
*/
- if (texImage->IsCompressed) {
+ if (_mesa_is_format_compressed(texImage->TexFormat)) {
switch (internalFormat) {
case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
case GL_RGB_S3TC:
@@ -1393,7 +1392,7 @@ tdfxTexImage2D(GLcontext *ctx, GLenum target, GLint level,
}
if (texNapalm) {
texImage->InternalFormat = internalFormat = texNapalm;
- texImage->IsCompressed = GL_TRUE;
+ _mesa_is_format_compressed(texImage->TexFormat) = GL_TRUE;
}
}
#endif
@@ -1409,7 +1408,7 @@ tdfxTexImage2D(GLcontext *ctx, GLenum target, GLint level,
texImage->FetchTexelc = fxFetchFunction(mesaFormat);
texelBytes = _mesa_get_format_bytes(texImage->TexFormat);
- if (texImage->IsCompressed) {
+ if (_mesa_is_format_compressed(texImage->TexFormat)) {
texImage->CompressedSize = _mesa_compressed_texture_size(ctx,
mml->width,
mml->height,
@@ -1492,7 +1491,7 @@ tdfxTexSubImage2D(GLcontext *ctx, GLenum target, GLint level,
assert(texImage->_BaseFormat);
texelBytes = _mesa_get_format_bytes(texImage->TexFormat);
- if (texImage->IsCompressed) {
+ if (_mesa_is_format_compressed(texImage->TexFormat)) {
dstRowStride = _mesa_compressed_row_stride(texImage->TexFormat, mml->width);
} else {
dstRowStride = mml->width * texelBytes;
@@ -1594,8 +1593,6 @@ tdfxCompressedTexImage2D (GLcontext *ctx, GLenum target,
return;
}
- assert(texImage->IsCompressed);
-
ti = TDFX_TEXTURE_DATA(texObj);
if (!ti) {
texObj->DriverData = fxAllocTexObjData(fxMesa);
diff --git a/src/mesa/drivers/dri/unichrome/via_tex.c b/src/mesa/drivers/dri/unichrome/via_tex.c
index b6be06d1ee..a4cf5466fd 100644
--- a/src/mesa/drivers/dri/unichrome/via_tex.c
+++ b/src/mesa/drivers/dri/unichrome/via_tex.c
@@ -696,7 +696,6 @@ static void viaTexImage(GLcontext *ctx,
if (texelBytes == 0) {
/* compressed format */
- texImage->IsCompressed = GL_TRUE;
texImage->CompressedSize =
ctx->Driver.CompressedTextureSize(ctx, texImage->Width,
texImage->Height, texImage->Depth,
@@ -713,7 +712,7 @@ static void viaTexImage(GLcontext *ctx,
viaImage->pitchLog2 = logbase2(postConvWidth * texelBytes);
/* allocate memory */
- if (texImage->IsCompressed)
+ if (_mesa_is_format_compressed(texImage->TexFormat))
sizeInBytes = texImage->CompressedSize;
else
sizeInBytes = postConvWidth * postConvHeight * texelBytes;
@@ -793,7 +792,7 @@ static void viaTexImage(GLcontext *ctx,
GLint dstRowStride;
GLboolean success;
- if (texImage->IsCompressed) {
+ if (_mesa_is_format_compressed(texImage->TexFormat)) {
dstRowStride = _mesa_compressed_row_stride(texImage->TexFormat, width);
}
else {
diff --git a/src/mesa/drivers/glide/fxddtex.c b/src/mesa/drivers/glide/fxddtex.c
index a64b6a5553..a820cb818e 100644
--- a/src/mesa/drivers/glide/fxddtex.c
+++ b/src/mesa/drivers/glide/fxddtex.c
@@ -1234,7 +1234,7 @@ adjust2DRatio (GLcontext *ctx,
const GLint newHeight = height * mml->hScale;
GLvoid *tempImage;
- if (!texImage->IsCompressed) {
+ if (!_mesa_is_format_compressed(texImage->TexFormat)) {
GLubyte *destAddr;
tempImage = MALLOC(width * height * texelBytes);
@@ -1353,7 +1353,7 @@ fxDDTexImage2D(GLcontext * ctx, GLenum target, GLint level,
#if FX_COMPRESS_S3TC_AS_FXT1_HACK
/* [koolsmoky] substitute FXT1 for DXTn and Legacy S3TC */
- if (!ctx->Mesa_DXTn && texImage->IsCompressed) {
+ if (!ctx->Mesa_DXTn && _mesa_is_format_compressed(texImage->TexFormat)) {
switch (internalFormat) {
case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
case GL_RGB_S3TC:
@@ -1380,7 +1380,6 @@ fxDDTexImage2D(GLcontext * ctx, GLenum target, GLint level,
}
if (texNapalm) {
texImage->InternalFormat = internalFormat = texNapalm;
- texImage->IsCompressed = GL_TRUE;
}
}
#endif
@@ -1397,7 +1396,7 @@ fxDDTexImage2D(GLcontext * ctx, GLenum target, GLint level,
/* allocate mipmap buffer */
assert(!texImage->Data);
- if (texImage->IsCompressed) {
+ if (_mesa_is_format_compressed(texImage->TexFormat)) {
texImage->CompressedSize = _mesa_compressed_texture_size(ctx,
mml->width,
mml->height,
@@ -1451,7 +1450,7 @@ fxDDTexImage2D(GLcontext * ctx, GLenum target, GLint level,
const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
const GLint maxLevels = _mesa_max_texture_levels(ctx, texObj->Target);
- assert(!texImage->IsCompressed);
+ assert(!_mesa_is_format_compressed(texImage->TexFormat));
while (level < texObj->MaxLevel && level < maxLevels - 1) {
mipWidth = width / 2;
@@ -1523,7 +1522,7 @@ fxDDTexSubImage2D(GLcontext * ctx, GLenum target, GLint level,
assert(texImage->_BaseFormat);
texelBytes = _mesa_get_format_bytes(texImage->TexFormat->MesaFormat);
- if (texImage->IsCompressed) {
+ if (_mesa_is_format_compressed(texImage->TexFormat)) {
dstRowStride = _mesa_compressed_row_stride(texImage->InternalFormat, mml->width);
} else {
dstRowStride = mml->width * texelBytes;
@@ -1564,7 +1563,7 @@ fxDDTexSubImage2D(GLcontext * ctx, GLenum target, GLint level,
const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
const GLint maxLevels = _mesa_max_texture_levels(ctx, texObj->Target);
- assert(!texImage->IsCompressed);
+ assert(!_mesa_is_format_compressed(texImage->TexFormat));
width = texImage->Width;
height = texImage->Height;
@@ -1620,7 +1619,7 @@ fxDDCompressedTexImage2D (GLcontext *ctx, GLenum target,
width, height);
}
- assert(texImage->IsCompressed);
+ assert(_mesa_is_format_compressed(texImage->TexFormat));
if (!fxIsTexSupported(target, internalFormat, texImage)) {
_mesa_problem(NULL, "fx Driver: unsupported texture in fxDDCompressedTexImg()\n");
@@ -1712,7 +1711,7 @@ fxDDCompressedTexImage2D (GLcontext *ctx, GLenum target,
/* GL_SGIS_generate_mipmap */
if (level == texObj->BaseLevel && texObj->GenerateMipmap) {
- assert(!texImage->IsCompressed);
+ assert(!_mesa_is_format_compressed(texImage->TexFormat));
}
fxTexInvalidate(ctx, texObj);
@@ -1777,7 +1776,7 @@ fxDDCompressedTexSubImage2D( GLcontext *ctx, GLenum target,
/* GL_SGIS_generate_mipmap */
if (level == texObj->BaseLevel && texObj->GenerateMipmap) {
- assert(!texImage->IsCompressed);
+ assert(!_mesa_is_format_compressed(texImage->TexFormat));
}
if (ti->validated && ti->isInTM)
diff --git a/src/mesa/main/mipmap.c b/src/mesa/main/mipmap.c
index ccd153303d..f6d6ce33c8 100644
--- a/src/mesa/main/mipmap.c
+++ b/src/mesa/main/mipmap.c
@@ -1511,7 +1511,7 @@ _mesa_generate_mipmap(GLcontext *ctx, GLenum target,
ASSERT(maxLevels > 0); /* bad target */
/* Find convertFormat - the format that do_row() will process */
- if (srcImage->IsCompressed) {
+ if (_mesa_is_format_compressed(srcImage->TexFormat)) {
/* setup for compressed textures */
GLuint row;
GLint components, size;
@@ -1589,7 +1589,7 @@ _mesa_generate_mipmap(GLcontext *ctx, GLenum target,
&dstWidth, &dstHeight, &dstDepth);
if (!nextLevel) {
/* all done */
- if (srcImage->IsCompressed) {
+ if (_mesa_is_format_compressed(srcImage->TexFormat)) {
_mesa_free((void *) srcData);
_mesa_free(dstData);
}
@@ -1614,8 +1614,7 @@ _mesa_generate_mipmap(GLcontext *ctx, GLenum target,
dstImage->TexFormat = srcImage->TexFormat;
dstImage->FetchTexelc = srcImage->FetchTexelc;
dstImage->FetchTexelf = srcImage->FetchTexelf;
- dstImage->IsCompressed = srcImage->IsCompressed;
- if (dstImage->IsCompressed) {
+ if (_mesa_is_format_compressed(dstImage->TexFormat)) {
dstImage->CompressedSize
= ctx->Driver.CompressedTextureSize(ctx, dstImage->Width,
dstImage->Height,
@@ -1631,7 +1630,7 @@ _mesa_generate_mipmap(GLcontext *ctx, GLenum target,
/* Alloc new teximage data buffer.
* Setup src and dest data pointers.
*/
- if (dstImage->IsCompressed) {
+ if (_mesa_is_format_compressed(dstImage->TexFormat)) {
dstImage->Data = _mesa_alloc_texmemory(dstImage->CompressedSize);
if (!dstImage->Data) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "generating mipmaps");
@@ -1661,7 +1660,7 @@ _mesa_generate_mipmap(GLcontext *ctx, GLenum target,
dstData, dstImage->RowStride);
- if (dstImage->IsCompressed) {
+ if (_mesa_is_format_compressed(dstImage->TexFormat)) {
GLubyte *temp;
/* compress image from dstData into dstImage->Data */
const GLenum srcFormat = _mesa_get_format_base_format(convertFormat);
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 1599a6f13f..f084edb840 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1173,7 +1173,6 @@ struct gl_texture_image
FetchTexelFuncC FetchTexelc; /**< GLchan texel fetch function pointer */
FetchTexelFuncF FetchTexelf; /**< Float texel fetch function pointer */
- GLboolean IsCompressed; /**< GL_ARB_texture_compression */
GLuint CompressedSize; /**< GL_ARB_texture_compression */
GLuint RowStride; /**< Padded width in units of texels */
diff --git a/src/mesa/main/texgetimage.c b/src/mesa/main/texgetimage.c
index e9e408d8c5..3e3951b1c4 100644
--- a/src/mesa/main/texgetimage.c
+++ b/src/mesa/main/texgetimage.c
@@ -567,7 +567,7 @@ _mesa_GetCompressedTexImageARB(GLenum target, GLint level, GLvoid *img)
{
texImage = _mesa_select_tex_image(ctx, texObj, target, level);
if (texImage) {
- if (texImage->IsCompressed) {
+ if (_mesa_is_format_compressed(texImage->TexFormat)) {
/* this typically calls _mesa_get_compressed_teximage() */
ctx->Driver.GetCompressedTexImage(ctx, target, level, img,
texObj, texImage);
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index c4e5ce2682..86f46b9551 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -903,7 +903,6 @@ clear_teximage_fields(struct gl_texture_image *img)
img->TexFormat = MESA_FORMAT_NONE;
img->FetchTexelc = NULL;
img->FetchTexelf = NULL;
- img->IsCompressed = 0;
img->CompressedSize = 0;
}
@@ -967,7 +966,6 @@ _mesa_init_teximage_fields(GLcontext *ctx, GLenum target,
img->MaxLog2 = MAX2(img->WidthLog2, img->HeightLog2);
- img->IsCompressed = GL_FALSE;
img->CompressedSize = 0;
if ((width == 1 || _mesa_is_pow_two(img->Width2)) &&
@@ -1589,7 +1587,7 @@ subtexture_error_check2( GLcontext *ctx, GLuint dimensions,
}
#endif
- if (destTex->IsCompressed) {
+ if (_mesa_is_format_compressed(destTex->TexFormat)) {
if (!target_can_be_compressed(ctx, target)) {
_mesa_error(ctx, GL_INVALID_ENUM,
"glTexSubImage%D(target)", dimensions);
@@ -1951,7 +1949,7 @@ copytexsubimage_error_check2( GLcontext *ctx, GLuint dimensions,
}
}
- if (teximage->IsCompressed) {
+ if (_mesa_is_format_compressed(teximage->TexFormat)) {
if (!target_can_be_compressed(ctx, target)) {
_mesa_error(ctx, GL_INVALID_ENUM,
"glCopyTexSubImage%d(target)", dimensions);
diff --git a/src/mesa/main/texparam.c b/src/mesa/main/texparam.c
index a9df1dac15..a6b611dffb 100644
--- a/src/mesa/main/texparam.c
+++ b/src/mesa/main/texparam.c
@@ -852,7 +852,7 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level,
/* GL_ARB_texture_compression */
case GL_TEXTURE_COMPRESSED_IMAGE_SIZE:
- if (img->IsCompressed && !isProxy) {
+ if (_mesa_is_format_compressed(img->TexFormat) && !isProxy) {
/* Don't use ctx->Driver.CompressedTextureSize() since that
* may returned a padded hardware size.
*/
@@ -866,7 +866,7 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level,
}
break;
case GL_TEXTURE_COMPRESSED:
- *params = (GLint) img->IsCompressed;
+ *params = (GLint) _mesa_is_format_compressed(img->TexFormat);
break;
/* GL_ARB_texture_float */
diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c
index 48bee88e0f..3e87e47cb1 100644
--- a/src/mesa/main/texstore.c
+++ b/src/mesa/main/texstore.c
@@ -3244,10 +3244,7 @@ _mesa_set_fetch_functions(struct gl_texture_image *texImage, GLuint dims)
static void
compute_texture_size(GLcontext *ctx, struct gl_texture_image *texImage)
{
- texImage->IsCompressed =
- _mesa_is_format_compressed(texImage->TexFormat);
-
- if (texImage->IsCompressed) {
+ if (_mesa_is_format_compressed(texImage->TexFormat)) {
texImage->CompressedSize =
ctx->Driver.CompressedTextureSize(ctx, texImage->Width,
texImage->Height, texImage->Depth,
@@ -3260,6 +3257,41 @@ compute_texture_size(GLcontext *ctx, struct gl_texture_image *texImage)
}
+/** Return texture size in bytes */
+static GLuint
+texture_size(const struct gl_texture_image *texImage)
+{
+ GLuint sz;
+
+ if (_mesa_is_format_compressed(texImage->TexFormat))
+ sz = texImage->CompressedSize;
+ else
+ sz = texImage->Width * texImage->Height * texImage->Depth *
+ _mesa_get_format_bytes(texImage->TexFormat);
+
+ return sz;
+}
+
+
+/** Return row stride in bytes */
+static GLuint
+texture_row_stride(const struct gl_texture_image *texImage)
+{
+ GLuint stride;
+
+ if (_mesa_is_format_compressed(texImage->TexFormat)) {
+ stride = _mesa_compressed_row_stride(texImage->TexFormat,
+ texImage->Width);
+ }
+ else {
+ GLuint texelBytes = _mesa_get_format_bytes(texImage->TexFormat);
+ stride = texImage->RowStride * texelBytes;
+ }
+
+ return stride;
+}
+
+
/**
* This is the software fallback for Driver.TexImage1D()
@@ -3289,10 +3321,8 @@ _mesa_store_teximage1d(GLcontext *ctx, GLenum target, GLint level,
compute_texture_size(ctx, texImage);
/* allocate memory */
- if (texImage->IsCompressed)
- sizeInBytes = texImage->CompressedSize;
- else
- sizeInBytes = texImage->Width * _mesa_get_format_bytes(texImage->TexFormat);
+ sizeInBytes = texture_size(texImage);
+
texImage->Data = _mesa_alloc_texmemory(sizeInBytes);
if (!texImage->Data) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage1D");
@@ -3309,16 +3339,14 @@ _mesa_store_teximage1d(GLcontext *ctx, GLenum target, GLint level,
}
else {
const GLint dstRowStride = 0;
- GLboolean success;
-
- success = _mesa_texstore(ctx, 1, texImage->_BaseFormat,
- texImage->TexFormat,
- texImage->Data,
- 0, 0, 0, /* dstX/Y/Zoffset */
- dstRowStride,
- texImage->ImageOffsets,
- width, 1, 1,
- format, type, pixels, packing);
+ GLboolean success = _mesa_texstore(ctx, 1, texImage->_BaseFormat,
+ texImage->TexFormat,
+ texImage->Data,
+ 0, 0, 0, /* dstX/Y/Zoffset */
+ dstRowStride,
+ texImage->ImageOffsets,
+ width, 1, 1,
+ format, type, pixels, packing);
if (!success) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage1D");
}
@@ -3360,10 +3388,7 @@ _mesa_store_teximage2d(GLcontext *ctx, GLenum target, GLint level,
texelBytes = _mesa_get_format_bytes(texImage->TexFormat);
/* allocate memory */
- if (texImage->IsCompressed)
- sizeInBytes = texImage->CompressedSize;
- else
- sizeInBytes = texImage->Width * texImage->Height * texelBytes;
+ sizeInBytes = texture_size(texImage);
texImage->Data = _mesa_alloc_texmemory(sizeInBytes);
if (!texImage->Data) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D");
@@ -3379,26 +3404,15 @@ _mesa_store_teximage2d(GLcontext *ctx, GLenum target, GLint level,
return;
}
else {
- GLint dstRowStride;
- GLboolean success;
-
- if (texImage->IsCompressed) {
- dstRowStride
- = _mesa_compressed_row_stride(texImage->TexFormat, width);
- }
- else {
- dstRowStride = texImage->RowStride * texelBytes;
- }
-
- success = _mesa_texstore(ctx, 2, texImage->_BaseFormat,
- texImage->TexFormat,
- texImage->Data,
- 0, 0, 0, /* dstX/Y/Zoffset */
- dstRowStride,
- texImage->ImageOffsets,
- width, height, 1,
- format, type, pixels, packing);
-
+ GLint dstRowStride = texture_row_stride(texImage);
+ GLboolean success = _mesa_texstore(ctx, 2, texImage->_BaseFormat,
+ texImage->TexFormat,
+ texImage->Data,
+ 0, 0, 0, /* dstX/Y/Zoffset */
+ dstRowStride,
+ texImage->ImageOffsets,
+ width, height, 1,
+ format, type, pixels, packing);
if (!success) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D");
}
@@ -3436,10 +3450,7 @@ _mesa_store_teximage3d(GLcontext *ctx, GLenum target, GLint level,
texelBytes = _mesa_get_format_bytes(texImage->TexFormat);
/* allocate memory */
- if (texImage->IsCompressed)
- sizeInBytes = texImage->CompressedSize;
- else
- sizeInBytes = width * height * depth * texelBytes;
+ sizeInBytes = texture_size(texImage);
texImage->Data = _mesa_alloc_texmemory(sizeInBytes);
if (!texImage->Data) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage3D");
@@ -3455,25 +3466,15 @@ _mesa_store_teximage3d(GLcontext *ctx, GLenum target, GLint level,
return;
}
else {
- GLint dstRowStride;
- GLboolean success;
-
- if (texImage->IsCompressed) {
- dstRowStride
- = _mesa_compressed_row_stride(texImage->TexFormat, width);
- }
- else {
- dstRowStride = texImage->RowStride * texelBytes;
- }
-
- success = _mesa_texstore(ctx, 3, texImage->_BaseFormat,
- texImage->TexFormat,
- texImage->Data,
- 0, 0, 0, /* dstX/Y/Zoffset */
- dstRowStride,
- texImage->ImageOffsets,
- width, height, depth,
- format, type, pixels, packing);
+ GLint dstRowStride = texture_row_stride(texImage);
+ GLboolean success = _mesa_texstore(ctx, 3, texImage->_BaseFormat,
+ texImage->TexFormat,
+ texImage->Data,
+ 0, 0, 0, /* dstX/Y/Zoffset */
+ dstRowStride,
+ texImage->ImageOffsets,
+ width, height, depth,
+ format, type, pixels, packing);
if (!success) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage3D");
}
@@ -3505,16 +3506,14 @@ _mesa_store_texsubimage1d(GLcontext *ctx, GLenum target, GLint level,
{
const GLint dstRowStride = 0;
- GLboolean success;
-
- success = _mesa_texstore(ctx, 1, texImage->_BaseFormat,
- texImage->TexFormat,
- texImage->Data,
- xoffset, 0, 0, /* offsets */
- dstRowStride,
- texImage->ImageOffsets,
- width, 1, 1,
- format, type, pixels, packing);
+ GLboolean success = _mesa_texstore(ctx, 1, texImage->_BaseFormat,
+ texImage->TexFormat,
+ texImage->Data,
+ xoffset, 0, 0, /* offsets */
+ dstRowStride,
+ texImage->ImageOffsets,
+ width, 1, 1,
+ format, type, pixels, packing);
if (!success) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage1D");
}
@@ -3545,26 +3544,15 @@ _mesa_store_texsubimage2d(GLcontext *ctx, GLenum target, GLint level,
return;
{
- GLint dstRowStride = 0;
- GLboolean success;
-
- if (texImage->IsCompressed) {
- dstRowStride = _mesa_compressed_row_stride(texImage->TexFormat,
- texImage->Width);
- }
- else {
- dstRowStride = texImage->RowStride *
- _mesa_get_format_bytes(texImage->TexFormat);
- }
-
- success = _mesa_texstore(ctx, 2, texImage->_BaseFormat,
- texImage->TexFormat,
- texImage->Data,
- xoffset, yoffset, 0,
- dstRowStride,
- texImage->ImageOffsets,
- width, height, 1,
- format, type, pixels, packing);
+ GLint dstRowStride = texture_row_stride(texImage);
+ GLboolean success = _mesa_texstore(ctx, 2, texImage->_BaseFormat,
+ texImage->TexFormat,
+ texImage->Data,
+ xoffset, yoffset, 0,
+ dstRowStride,
+ texImage->ImageOffsets,
+ width, height, 1,
+ format, type, pixels, packing);
if (!success) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage2D");
}
@@ -3595,26 +3583,15 @@ _mesa_store_texsubimage3d(GLcontext *ctx, GLenum target, GLint level,
return;
{
- GLint dstRowStride;
- GLboolean success;
-
- if (texImage->IsCompressed) {
- dstRowStride = _mesa_compressed_row_stride(texImage->TexFormat,
- texImage->Width);
- }
- else {
- dstRowStride = texImage->RowStride *
- _mesa_get_format_bytes(texImage->TexFormat);
- }
-
- success = _mesa_texstore(ctx, 3, texImage->_BaseFormat,
- texImage->TexFormat,
- texImage->Data,
- xoffset, yoffset, zoffset,
- dstRowStride,
- texImage->ImageOffsets,
- width, height, depth,
- format, type, pixels, packing);
+ GLint dstRowStride = texture_row_stride(texImage);
+ GLboolean success = _mesa_texstore(ctx, 3, texImage->_BaseFormat,
+ texImage->TexFormat,
+ texImage->Data,
+ xoffset, yoffset, zoffset,
+ dstRowStride,
+ texImage->ImageOffsets,
+ width, height, depth,
+ format, type, pixels, packing);
if (!success) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage3D");
}
diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c
index 716fbc8b29..b457a8dc6e 100644
--- a/src/mesa/state_tracker/st_cb_texture.c
+++ b/src/mesa/state_tracker/st_cb_texture.c
@@ -562,7 +562,6 @@ st_TexImage(GLcontext * ctx,
if (_mesa_is_format_compressed(texImage->TexFormat)) {
/* must be a compressed format */
texelBytes = 0;
- texImage->IsCompressed = GL_TRUE;
texImage->CompressedSize =
ctx->Driver.CompressedTextureSize(ctx, texImage->Width,
texImage->Height, texImage->Depth,
@@ -696,7 +695,7 @@ st_TexImage(GLcontext * ctx,
}
else {
/* Allocate regular memory and store the image there temporarily. */
- if (texImage->IsCompressed) {
+ if (_mesa_is_format_compressed(texImage->TexFormat)) {
sizeInBytes = texImage->CompressedSize;
dstRowStride =
_mesa_compressed_row_stride(texImage->TexFormat, width);
@@ -1823,7 +1822,7 @@ st_finalize_texture(GLcontext *ctx,
}
/* FIXME: determine format block instead of cpp */
- if (firstImage->base.IsCompressed) {
+ if (_mesa_is_format_compressed(firstImage->base.TexFormat)) {
cpp = compressed_num_bytes(firstImage->base.TexFormat);
}
else {