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 */
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);
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) {
} 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);
}
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);
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",
/* 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;
texImage->Data);
ti->padded = GL_TRUE;
} else {
- MEMCPY(texImage->Data, data, texImage->CompressedSize);
+ MEMCPY(texImage->Data, data, compressedSize);
}
RevalidateTexture(ctx, texObj);
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);
if (texelBytes == 0) {
/* compressed format */
- texImage->CompressedSize =
+ compressedSize =
ctx->Driver.CompressedTextureSize(ctx, texImage->Width,
texImage->Height, texImage->Depth,
texImage->TexFormat);
/* allocate memory */
if (_mesa_is_format_compressed(texImage->TexFormat))
- sizeInBytes = texImage->CompressedSize;
+ sizeInBytes = compressedSize;
else
sizeInBytes = postConvWidth * postConvHeight * texelBytes;
*/
GLuint (*CompressedTextureSize)( GLcontext *ctx, GLsizei width,
GLsizei height, GLsizei depth,
- GLenum format );
+ GLuint mesaFormat );
/*@}*/
/**
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;
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,
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 */
img->TexFormat = MESA_FORMAT_NONE;
img->FetchTexelc = NULL;
img->FetchTexelf = NULL;
- img->CompressedSize = 0;
}
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)))
}
-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;
}
struct gl_texture_object *texObj,
struct gl_texture_image *texImage)
{
- GLint sizeInBytes;
+ GLuint sizeInBytes;
(void) border;
texImage->TexFormat
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");
struct gl_texture_object *texObj,
struct gl_texture_image *texImage)
{
- GLint texelBytes, sizeInBytes;
+ GLuint sizeInBytes;
(void) border;
texImage->TexFormat
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);
struct gl_texture_object *texObj,
struct gl_texture_image *texImage)
{
- GLint texelBytes, sizeInBytes;
+ GLuint sizeInBytes;
(void) border;
texImage->TexFormat
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);
ASSERT(texImage->TexFormat);
_mesa_set_fetch_functions(texImage, 2);
- compute_texture_size(ctx, texImage);
/* allocate storage */
texImage->Data = _mesa_alloc_texmemory(imageSize);
return;
/* copy the data */
- ASSERT(texImage->CompressedSize == (GLuint) imageSize);
MEMCPY(texImage->Data, data, imageSize);
_mesa_unmap_teximage_pbo(ctx, &ctx->Unpack);
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);
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);