mesa: removed gl_texture_image::CompressedSize field
Just call ctx->Driver.CompressedTextureSize() when we need to get the compressed image size.
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
+1
-1
@@ -481,7 +481,7 @@ struct dd_function_table {
|
||||
*/
|
||||
GLuint (*CompressedTextureSize)( GLcontext *ctx, GLsizei width,
|
||||
GLsizei height, GLsizei depth,
|
||||
GLenum format );
|
||||
GLuint mesaFormat );
|
||||
/*@}*/
|
||||
|
||||
/**
|
||||
|
||||
+12
-13
@@ -1614,24 +1614,19 @@ _mesa_generate_mipmap(GLcontext *ctx, GLenum target,
|
||||
dstImage->TexFormat = srcImage->TexFormat;
|
||||
dstImage->FetchTexelc = srcImage->FetchTexelc;
|
||||
dstImage->FetchTexelf = srcImage->FetchTexelf;
|
||||
if (_mesa_is_format_compressed(dstImage->TexFormat)) {
|
||||
dstImage->CompressedSize
|
||||
= 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);
|
||||
|
||||
/* 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);
|
||||
GLuint dstCompressedSize
|
||||
= ctx->Driver.CompressedTextureSize(ctx, dstImage->Width,
|
||||
dstImage->Height,
|
||||
dstImage->Depth,
|
||||
dstImage->TexFormat);
|
||||
ASSERT(dstCompressedSize > 0);
|
||||
|
||||
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,
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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)))
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user