summaryrefslogtreecommitdiff
path: root/src/mesa
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/drivers/dri/intel/intel_tex_image.c13
-rw-r--r--src/mesa/drivers/dri/radeon/radeon_texture.c13
-rw-r--r--src/mesa/drivers/dri/tdfx/tdfx_tex.c29
-rw-r--r--src/mesa/drivers/dri/unichrome/via_tex.c5
-rw-r--r--src/mesa/main/dd.h2
-rw-r--r--src/mesa/main/mipmap.c23
-rw-r--r--src/mesa/main/mtypes.h2
-rw-r--r--src/mesa/main/teximage.c3
-rw-r--r--src/mesa/main/texstore.c42
-rw-r--r--src/mesa/state_tracker/st_cb_texture.c10
10 files changed, 53 insertions, 89 deletions
diff --git a/src/mesa/drivers/dri/intel/intel_tex_image.c b/src/mesa/drivers/dri/intel/intel_tex_image.c
index 9e13ba6871..dd436becab 100644
--- a/src/mesa/drivers/dri/intel/intel_tex_image.c
+++ b/src/mesa/drivers/dri/intel/intel_tex_image.c
@@ -340,11 +340,8 @@ intelTexImage(GLcontext * ctx,
if (_mesa_is_format_compressed(texImage->TexFormat)) {
texelBytes = 0;
- texImage->CompressedSize =
- ctx->Driver.CompressedTextureSize(ctx, texImage->Width,
- texImage->Height, texImage->Depth,
- texImage->TexFormat);
- } else {
+ }
+ else {
texelBytes = _mesa_get_format_bytes(texImage->TexFormat);
/* Minimum pitch of 32 bytes */
@@ -495,7 +492,11 @@ intelTexImage(GLcontext * ctx,
else {
/* Allocate regular memory and store the image there temporarily. */
if (_mesa_is_format_compressed(texImage->TexFormat)) {
- sizeInBytes = texImage->CompressedSize;
+ sizeInBytes = ctx->Driver.CompressedTextureSize(ctx,
+ texImage->Width,
+ texImage->Height,
+ texImage->Depth,
+ texImage->TexFormat);
dstRowStride =
_mesa_compressed_row_stride(texImage->TexFormat, width);
assert(dims != 3);
diff --git a/src/mesa/drivers/dri/radeon/radeon_texture.c b/src/mesa/drivers/dri/radeon/radeon_texture.c
index ce393ffeb6..2c28011057 100644
--- a/src/mesa/drivers/dri/radeon/radeon_texture.c
+++ b/src/mesa/drivers/dri/radeon/radeon_texture.c
@@ -547,13 +547,7 @@ static void radeon_teximage(
if (_mesa_is_format_compressed(texImage->TexFormat)) {
texelBytes = 0;
- texImage->CompressedSize =
- ctx->Driver.CompressedTextureSize(ctx, texImage->Width,
- texImage->Height, texImage->Depth,
- texImage->TexFormat);
} else {
- texImage->CompressedSize = 0;
-
texelBytes = _mesa_get_format_bytes(texImage->TexFormat);
/* Minimum pitch of 32 bytes */
if (postConvWidth * texelBytes < 32) {
@@ -590,7 +584,12 @@ static void radeon_teximage(
} else {
int size;
if (_mesa_is_format_compressed(texImage->TexFormat)) {
- size = texImage->CompressedSize;
+ size = ctx->Driver.CompressedTextureSize(ctx,
+ texImage->Width,
+ texImage->Height,
+ texImage->Depth,
+ texImage->TexFormat);
+
} 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 8b68137eed..5e9421aa2a 100644
--- a/src/mesa/drivers/dri/tdfx/tdfx_tex.c
+++ b/src/mesa/drivers/dri/tdfx/tdfx_tex.c
@@ -1409,13 +1409,13 @@ tdfxTexImage2D(GLcontext *ctx, GLenum target, GLint level,
texelBytes = _mesa_get_format_bytes(texImage->TexFormat);
if (_mesa_is_format_compressed(texImage->TexFormat)) {
- texImage->CompressedSize = _mesa_compressed_texture_size(ctx,
- mml->width,
- mml->height,
- 1,
- mesaFormat);
+ GLuint compressedSize = ctx->Driver.CompressedTextureSize(ctx,
+ mml->width,
+ mml->height,
+ 1,
+ mesaFormat);
dstRowStride = _mesa_compressed_row_stride(texImage->TexFormat, mml->width);
- texImage->Data = _mesa_alloc_texmemory(texImage->CompressedSize);
+ texImage->Data = _mesa_alloc_texmemory(compressedSize);
} else {
dstRowStride = mml->width * texelBytes;
texImage->Data = _mesa_alloc_texmemory(mml->width * mml->height * texelBytes);
@@ -1580,7 +1580,8 @@ tdfxCompressedTexImage2D (GLcontext *ctx, GLenum target,
tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
tdfxTexInfo *ti;
tdfxMipMapLevel *mml;
- GLuint mesaFormat;
+ gl_format mesaFormat;
+ GLuint compressedSize;
if (TDFX_DEBUG & DEBUG_VERBOSE_DRI) {
fprintf(stderr, "tdfxCompressedTexImage2D: id=%d int 0x%x %dx%d\n",
@@ -1637,12 +1638,12 @@ tdfxCompressedTexImage2D (GLcontext *ctx, GLenum target,
/* allocate new storage for texture image, if needed */
if (!texImage->Data) {
- texImage->CompressedSize = _mesa_compressed_texture_size(ctx,
- mml->width,
- mml->height,
- 1,
- mesaFormat);
- texImage->Data = _mesa_alloc_texmemory(texImage->CompressedSize);
+ compressedSize = ctx->Driver.CompressedTextureSize(ctx,
+ mml->width,
+ mml->height,
+ 1,
+ mesaFormat);
+ texImage->Data = _mesa_alloc_texmemory(compressedSize);
if (!texImage->Data) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2D");
return;
@@ -1677,7 +1678,7 @@ tdfxCompressedTexImage2D (GLcontext *ctx, GLenum target,
texImage->Data);
ti->padded = GL_TRUE;
} else {
- MEMCPY(texImage->Data, data, texImage->CompressedSize);
+ MEMCPY(texImage->Data, data, compressedSize);
}
RevalidateTexture(ctx, texObj);
diff --git a/src/mesa/drivers/dri/unichrome/via_tex.c b/src/mesa/drivers/dri/unichrome/via_tex.c
index 13458aba1c..a99aa9debc 100644
--- a/src/mesa/drivers/dri/unichrome/via_tex.c
+++ b/src/mesa/drivers/dri/unichrome/via_tex.c
@@ -674,6 +674,7 @@ static void viaTexImage(GLcontext *ctx,
struct via_texture_object *viaObj = (struct via_texture_object *)texObj;
struct via_texture_image *viaImage = (struct via_texture_image *)texImage;
int heaps[3], nheaps, i;
+ GLuint compressedSize;
if (!is_empty_list(&vmesa->freed_tex_buffers)) {
viaCheckBreadcrumb(vmesa, 0);
@@ -697,7 +698,7 @@ static void viaTexImage(GLcontext *ctx,
if (texelBytes == 0) {
/* compressed format */
- texImage->CompressedSize =
+ compressedSize =
ctx->Driver.CompressedTextureSize(ctx, texImage->Width,
texImage->Height, texImage->Depth,
texImage->TexFormat);
@@ -714,7 +715,7 @@ static void viaTexImage(GLcontext *ctx,
/* allocate memory */
if (_mesa_is_format_compressed(texImage->TexFormat))
- sizeInBytes = texImage->CompressedSize;
+ sizeInBytes = compressedSize;
else
sizeInBytes = postConvWidth * postConvHeight * texelBytes;
diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
index 9131f20f52..64bf9cba19 100644
--- a/src/mesa/main/dd.h
+++ b/src/mesa/main/dd.h
@@ -481,7 +481,7 @@ struct dd_function_table {
*/
GLuint (*CompressedTextureSize)( GLcontext *ctx, GLsizei width,
GLsizei height, GLsizei depth,
- GLenum format );
+ GLuint mesaFormat );
/*@}*/
/**
diff --git a/src/mesa/main/mipmap.c b/src/mesa/main/mipmap.c
index f6d6ce33c8..e24e7285c3 100644
--- a/src/mesa/main/mipmap.c
+++ b/src/mesa/main/mipmap.c
@@ -1614,24 +1614,19 @@ _mesa_generate_mipmap(GLcontext *ctx, GLenum target,
dstImage->TexFormat = srcImage->TexFormat;
dstImage->FetchTexelc = srcImage->FetchTexelc;
dstImage->FetchTexelf = srcImage->FetchTexelf;
+
+ /* Alloc new teximage data buffer.
+ * Setup src and dest data pointers.
+ */
if (_mesa_is_format_compressed(dstImage->TexFormat)) {
- dstImage->CompressedSize
+ GLuint dstCompressedSize
= ctx->Driver.CompressedTextureSize(ctx, dstImage->Width,
dstImage->Height,
dstImage->Depth,
dstImage->TexFormat);
- ASSERT(dstImage->CompressedSize > 0);
- }
-
- ASSERT(dstImage->TexFormat);
- ASSERT(dstImage->FetchTexelc);
- ASSERT(dstImage->FetchTexelf);
+ ASSERT(dstCompressedSize > 0);
- /* Alloc new teximage data buffer.
- * Setup src and dest data pointers.
- */
- if (_mesa_is_format_compressed(dstImage->TexFormat)) {
- dstImage->Data = _mesa_alloc_texmemory(dstImage->CompressedSize);
+ dstImage->Data = _mesa_alloc_texmemory(dstCompressedSize);
if (!dstImage->Data) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "generating mipmaps");
return;
@@ -1653,6 +1648,10 @@ _mesa_generate_mipmap(GLcontext *ctx, GLenum target,
dstData = (GLubyte *) dstImage->Data;
}
+ ASSERT(dstImage->TexFormat);
+ ASSERT(dstImage->FetchTexelc);
+ ASSERT(dstImage->FetchTexelf);
+
_mesa_generate_mipmap_level(target, datatype, comps, border,
srcWidth, srcHeight, srcDepth,
srcData, srcImage->RowStride,
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index f084edb840..8e6e0d09be 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1173,8 +1173,6 @@ struct gl_texture_image
FetchTexelFuncC FetchTexelc; /**< GLchan texel fetch function pointer */
FetchTexelFuncF FetchTexelf; /**< Float texel fetch function pointer */
- GLuint CompressedSize; /**< GL_ARB_texture_compression */
-
GLuint RowStride; /**< Padded width in units of texels */
GLuint *ImageOffsets; /**< if 3D texture: array [Depth] of offsets to
each 2D slice in 'Data', in texels */
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index 86f46b9551..438a316b9c 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->CompressedSize = 0;
}
@@ -966,8 +965,6 @@ _mesa_init_teximage_fields(GLcontext *ctx, GLenum target,
img->MaxLog2 = MAX2(img->WidthLog2, img->HeightLog2);
- img->CompressedSize = 0;
-
if ((width == 1 || _mesa_is_pow_two(img->Width2)) &&
(height == 1 || _mesa_is_pow_two(img->Height2)) &&
(depth == 1 || _mesa_is_pow_two(img->Depth2)))
diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c
index 0fa8c44817..133b0370c8 100644
--- a/src/mesa/main/texstore.c
+++ b/src/mesa/main/texstore.c
@@ -3159,34 +3159,12 @@ _mesa_unmap_teximage_pbo(GLcontext *ctx,
}
-static void
-compute_texture_size(GLcontext *ctx, struct gl_texture_image *texImage)
-{
- if (_mesa_is_format_compressed(texImage->TexFormat)) {
- texImage->CompressedSize =
- ctx->Driver.CompressedTextureSize(ctx, texImage->Width,
- texImage->Height, texImage->Depth,
- texImage->TexFormat);
- }
- else {
- /* non-compressed format */
- texImage->CompressedSize = 0;
- }
-}
-
-
/** 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);
-
+ GLuint sz = _mesa_format_image_size(texImage->TexFormat, texImage->Width,
+ texImage->Height, texImage->Depth);
return sz;
}
@@ -3228,7 +3206,7 @@ _mesa_store_teximage1d(GLcontext *ctx, GLenum target, GLint level,
struct gl_texture_object *texObj,
struct gl_texture_image *texImage)
{
- GLint sizeInBytes;
+ GLuint sizeInBytes;
(void) border;
texImage->TexFormat
@@ -3236,11 +3214,9 @@ _mesa_store_teximage1d(GLcontext *ctx, GLenum target, GLint level,
ASSERT(texImage->TexFormat);
_mesa_set_fetch_functions(texImage, 1);
- compute_texture_size(ctx, texImage);
/* allocate memory */
sizeInBytes = texture_size(texImage);
-
texImage->Data = _mesa_alloc_texmemory(sizeInBytes);
if (!texImage->Data) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage1D");
@@ -3293,7 +3269,7 @@ _mesa_store_teximage2d(GLcontext *ctx, GLenum target, GLint level,
struct gl_texture_object *texObj,
struct gl_texture_image *texImage)
{
- GLint texelBytes, sizeInBytes;
+ GLuint sizeInBytes;
(void) border;
texImage->TexFormat
@@ -3301,9 +3277,6 @@ _mesa_store_teximage2d(GLcontext *ctx, GLenum target, GLint level,
ASSERT(texImage->TexFormat);
_mesa_set_fetch_functions(texImage, 2);
- compute_texture_size(ctx, texImage);
-
- texelBytes = _mesa_get_format_bytes(texImage->TexFormat);
/* allocate memory */
sizeInBytes = texture_size(texImage);
@@ -3355,7 +3328,7 @@ _mesa_store_teximage3d(GLcontext *ctx, GLenum target, GLint level,
struct gl_texture_object *texObj,
struct gl_texture_image *texImage)
{
- GLint texelBytes, sizeInBytes;
+ GLuint sizeInBytes;
(void) border;
texImage->TexFormat
@@ -3363,9 +3336,6 @@ _mesa_store_teximage3d(GLcontext *ctx, GLenum target, GLint level,
ASSERT(texImage->TexFormat);
_mesa_set_fetch_functions(texImage, 3);
- compute_texture_size(ctx, texImage);
-
- texelBytes = _mesa_get_format_bytes(texImage->TexFormat);
/* allocate memory */
sizeInBytes = texture_size(texImage);
@@ -3570,7 +3540,6 @@ _mesa_store_compressed_teximage2d(GLcontext *ctx, GLenum target, GLint level,
ASSERT(texImage->TexFormat);
_mesa_set_fetch_functions(texImage, 2);
- compute_texture_size(ctx, texImage);
/* allocate storage */
texImage->Data = _mesa_alloc_texmemory(imageSize);
@@ -3586,7 +3555,6 @@ _mesa_store_compressed_teximage2d(GLcontext *ctx, GLenum target, GLint level,
return;
/* copy the data */
- ASSERT(texImage->CompressedSize == (GLuint) imageSize);
MEMCPY(texImage->Data, data, imageSize);
_mesa_unmap_teximage_pbo(ctx, &ctx->Unpack);
diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c
index 2574eeb996..dc3ab61425 100644
--- a/src/mesa/state_tracker/st_cb_texture.c
+++ b/src/mesa/state_tracker/st_cb_texture.c
@@ -563,10 +563,6 @@ st_TexImage(GLcontext * ctx,
if (_mesa_is_format_compressed(texImage->TexFormat)) {
/* must be a compressed format */
texelBytes = 0;
- texImage->CompressedSize =
- ctx->Driver.CompressedTextureSize(ctx, texImage->Width,
- texImage->Height, texImage->Depth,
- texImage->TexFormat);
}
else {
texelBytes = _mesa_get_format_bytes(texImage->TexFormat);
@@ -697,7 +693,11 @@ st_TexImage(GLcontext * ctx,
else {
/* Allocate regular memory and store the image there temporarily. */
if (_mesa_is_format_compressed(texImage->TexFormat)) {
- sizeInBytes = texImage->CompressedSize;
+ sizeInBytes = ctx->Driver.CompressedTextureSize(ctx,
+ texImage->Width,
+ texImage->Height,
+ texImage->Depth,
+ texImage->TexFormat);
dstRowStride =
_mesa_compressed_row_stride(texImage->TexFormat, width);
assert(dims != 3);