tdfxTexInfo *ti;
tdfxMipMapLevel *mml;
GLint texelBytes, dstRowStride;
+ GLuint mesaFormat;
/*
printf("TexImage id=%d int 0x%x format 0x%x type 0x%x %dx%d\n",
texImage->TexFormat = (*ctx->Driver.ChooseTextureFormat)(ctx,
internalFormat, format, type);
assert(texImage->TexFormat);
- mml->glideFormat = fxGlideFormat(texImage->TexFormat->MesaFormat);
+ mesaFormat = texImage->TexFormat->MesaFormat;
+ mml->glideFormat = fxGlideFormat(mesaFormat);
ti->info.format = mml->glideFormat;
- texImage->FetchTexelc = fxFetchFunction(texImage->TexFormat->MesaFormat);
+ texImage->FetchTexelc = fxFetchFunction(mesaFormat);
texelBytes = texImage->TexFormat->TexelBytes;
if (texImage->IsCompressed) {
mml->width,
mml->height,
1,
- internalFormat);
- dstRowStride = _mesa_compressed_row_stride(internalFormat, mml->width);
+ mesaFormat);
+ dstRowStride = _mesa_compressed_row_stride(texImage->TexFormat->MesaFormat, mml->width);
texImage->Data = _mesa_alloc_texmemory(texImage->CompressedSize);
} else {
dstRowStride = mml->width * texelBytes;
texelBytes = texImage->TexFormat->TexelBytes;
if (texImage->IsCompressed) {
- dstRowStride = _mesa_compressed_row_stride(texImage->InternalFormat, mml->width);
+ dstRowStride = _mesa_compressed_row_stride(texImage->TexFormat->MesaFormat, mml->width);
} else {
dstRowStride = mml->width * texelBytes;
}
tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
tdfxTexInfo *ti;
tdfxMipMapLevel *mml;
+ GLuint mesaFormat;
if (TDFX_DEBUG & DEBUG_VERBOSE_DRI) {
fprintf(stderr, "tdfxCompressedTexImage2D: id=%d int 0x%x %dx%d\n",
/* Determine the appropriate Glide texel format,
* given the user's internal texture format hint.
*/
- mml->glideFormat = fxGlideFormat(texImage->TexFormat->MesaFormat);
+ mesaFormat = texImage->TexFormat->MesaFormat;
+ mml->glideFormat = fxGlideFormat(mesaFormat);
ti->info.format = mml->glideFormat;
- texImage->FetchTexelc = fxFetchFunction(texImage->TexFormat->MesaFormat);
+ texImage->FetchTexelc = fxFetchFunction(mesaFormat);
/* allocate new storage for texture image, if needed */
if (!texImage->Data) {
mml->width,
mml->height,
1,
- internalFormat);
+ mesaFormat);
texImage->Data = _mesa_alloc_texmemory(texImage->CompressedSize);
if (!texImage->Data) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2D");
* we replicate the data over the padded area.
* For now, we take 2) + 3) but texelfetchers will be wrong!
*/
- GLuint srcRowStride = _mesa_compressed_row_stride(internalFormat, width);
+ const GLuint mesaFormat = texImage->TexFormat->MesaFormat;
+ GLuint srcRowStride = _mesa_compressed_row_stride(mesaFormat, width);
- GLuint destRowStride = _mesa_compressed_row_stride(internalFormat,
+ GLuint destRowStride = _mesa_compressed_row_stride(mesaFormat,
mml->width);
_mesa_upscale_teximage2d(srcRowStride, (height+3) / 4,
GLint destRowStride, srcRowStride;
GLint i, rows;
GLubyte *dest;
+ const GLuint mesaFormat = texImage->TexFormat->MesaFormat;
if (TDFX_DEBUG & DEBUG_VERBOSE_DRI) {
fprintf(stderr, "tdfxCompressedTexSubImage2D: id=%d\n", texObj->Name);
mml = TDFX_TEXIMAGE_DATA(texImage);
assert(mml);
- srcRowStride = _mesa_compressed_row_stride(texImage->InternalFormat, width);
+ srcRowStride = _mesa_compressed_row_stride(mesaFormat, width);
- destRowStride = _mesa_compressed_row_stride(texImage->InternalFormat,
- mml->width);
+ destRowStride = _mesa_compressed_row_stride(mesaFormat, mml->width);
dest = _mesa_compressed_image_address(xoffset, yoffset, 0,
- texImage->InternalFormat,
+ mesaFormat,
mml->width,
(GLubyte*) texImage->Data);
* see fxDDCompressedTexImage2D for caveats
*/
if (mml->wScale != 1 || mml->hScale != 1) {
- srcRowStride = _mesa_compressed_row_stride(texImage->InternalFormat, texImage->Width);
+ srcRowStride = _mesa_compressed_row_stride(mesaFormat, texImage->Width);
- destRowStride = _mesa_compressed_row_stride(texImage->InternalFormat,
- mml->width);
+ destRowStride = _mesa_compressed_row_stride(mesaFormat, mml->width);
_mesa_upscale_teximage2d(srcRowStride, texImage->Height / 4,
destRowStride, mml->height / 4,
1, texImage->Data, destRowStride,
}
texelBytes = texImage->TexFormat->TexelBytes;
+ if (texelBytes == 0) {
+ /* compressed format */
+ texImage->IsCompressed = GL_TRUE;
+ texImage->CompressedSize =
+ ctx->Driver.CompressedTextureSize(ctx, texImage->Width,
+ texImage->Height, texImage->Depth,
+ texImage->TexFormat->MesaFormat);
+ }
/* Minimum pitch of 32 bytes */
if (postConvWidth * texelBytes < 32) {
GLint dstRowStride, dstImageStride = 0;
GLboolean success;
if (texImage->IsCompressed) {
- dstRowStride = _mesa_compressed_row_stride(texImage->InternalFormat,width);
+ dstRowStride = _mesa_compressed_row_stride(texImage->TexFormat->MesaFormat, width);
}
else {
dstRowStride = postConvWidth * texImage->TexFormat->TexelBytes;
* \param width texture width in texels.
* \param height texture height in texels.
* \param depth texture depth in texels.
- * \param format - one of the specific compressed texture formats
+ * \param mesaFormat one of the MESA_FORMAT_* compressed formats
*
* \return size in bytes, or zero if bad format
*/
GLuint
_mesa_compressed_texture_size( GLcontext *ctx,
GLsizei width, GLsizei height, GLsizei depth,
- GLenum format )
+ GLuint mesaFormat )
{
GLuint size;
ASSERT(depth == 1);
(void) depth;
- switch (format) {
- case GL_COMPRESSED_RGB_FXT1_3DFX:
- case GL_COMPRESSED_RGBA_FXT1_3DFX:
+ switch (mesaFormat) {
+ case MESA_FORMAT_RGB_FXT1:
+ case MESA_FORMAT_RGBA_FXT1:
/* round up width to next multiple of 8, height to next multiple of 4 */
width = (width + 7) & ~7;
height = (height + 3) & ~3;
if (size < 16)
size = 16;
return size;
- case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
- case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
- case GL_RGB_S3TC:
- case GL_RGB4_S3TC:
+ case MESA_FORMAT_RGB_DXT1:
+ case MESA_FORMAT_RGBA_DXT1:
/* round up width, height to next multiple of 4 */
width = (width + 3) & ~3;
height = (height + 3) & ~3;
if (size < 8)
size = 8;
return size;
- case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
- case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
- case GL_RGBA_S3TC:
- case GL_RGBA4_S3TC:
+ case MESA_FORMAT_RGBA_DXT3:
+ case MESA_FORMAT_RGBA_DXT5:
/* round up width, height to next multiple of 4 */
width = (width + 3) & ~3;
height = (height + 3) & ~3;
size = 16;
return size;
default:
- _mesa_problem(ctx, "bad texformat in compressed_texture_size");
+ _mesa_problem(ctx, "bad mesaFormat in _mesa_compressed_texture_size");
return 0;
}
}
/*
* Compute the bytes per row in a compressed texture image.
* We use this for computing the destination address for sub-texture updates.
- * \param format one of the specific texture compression formats
+ * \param mesaFormat one of the MESA_FORMAT_* compressed formats
* \param width image width in pixels
* \return stride, in bytes, between rows for compressed image
*/
GLint
-_mesa_compressed_row_stride(GLenum format, GLsizei width)
+_mesa_compressed_row_stride(GLuint mesaFormat, GLsizei width)
{
GLint stride;
- switch (format) {
- case GL_COMPRESSED_RGB_FXT1_3DFX:
- case GL_COMPRESSED_RGBA_FXT1_3DFX:
+ switch (mesaFormat) {
+ case MESA_FORMAT_RGB_FXT1:
+ case MESA_FORMAT_RGBA_FXT1:
stride = ((width + 7) / 8) * 16; /* 16 bytes per 8x4 tile */
break;
- case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
- case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
- case GL_RGB_S3TC:
- case GL_RGB4_S3TC:
+ case MESA_FORMAT_RGB_DXT1:
+ case MESA_FORMAT_RGBA_DXT1:
stride = ((width + 3) / 4) * 8; /* 8 bytes per 4x4 tile */
break;
- case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
- case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
- case GL_RGBA_S3TC:
- case GL_RGBA4_S3TC:
+ case MESA_FORMAT_RGBA_DXT3:
+ case MESA_FORMAT_RGBA_DXT5:
stride = ((width + 3) / 4) * 16; /* 16 bytes per 4x4 tile */
break;
default:
+ _mesa_problem(NULL, "bad mesaFormat in _mesa_compressed_row_stride");
return 0;
}
*/
GLubyte *
_mesa_compressed_image_address(GLint col, GLint row, GLint img,
- GLenum format,
+ GLuint mesaFormat,
GLsizei width, const GLubyte *image)
{
GLubyte *addr;
* offset = Z * (((width + X - 1) / X) * (row / Y) + col / X);
*/
- switch (format) {
- case GL_COMPRESSED_RGB_FXT1_3DFX:
- case GL_COMPRESSED_RGBA_FXT1_3DFX:
+ switch (mesaFormat) {
+ case MESA_FORMAT_RGB_FXT1:
+ case MESA_FORMAT_RGBA_FXT1:
addr = (GLubyte *) image + 16 * (((width + 7) / 8) * (row / 4) + col / 8);
break;
- case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
- case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
- case GL_RGB_S3TC:
- case GL_RGB4_S3TC:
+ case MESA_FORMAT_RGB_DXT1:
+ case MESA_FORMAT_RGBA_DXT1:
addr = (GLubyte *) image + 8 * (((width + 3) / 4) * (row / 4) + col / 4);
break;
- case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
- case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
- case GL_RGBA_S3TC:
- case GL_RGBA4_S3TC:
+ case MESA_FORMAT_RGBA_DXT3:
+ case MESA_FORMAT_RGBA_DXT5:
addr = (GLubyte *) image + 16 * (((width + 3) / 4) * (row / 4) + col / 4);
break;
default:
- return NULL;
+ _mesa_problem(NULL, "bad mesaFormat in _mesa_compressed_image_address");
+ addr = NULL;
}
return addr;
extern GLuint
_mesa_compressed_texture_size( GLcontext *ctx,
GLsizei width, GLsizei height, GLsizei depth,
- GLenum format );
+ GLuint mesaFormat );
extern GLint
-_mesa_compressed_row_stride(GLenum format, GLsizei width);
+_mesa_compressed_row_stride(GLuint mesaFormat, GLsizei width);
extern GLubyte *
_mesa_compressed_image_address(GLint col, GLint row, GLint img,
- GLenum format,
+ GLuint mesaFormat,
GLsizei width, const GLubyte *image);
}
dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
- GL_COMPRESSED_RGB_S3TC_DXT1_EXT,
+ dstFormat->MesaFormat,
texWidth, (GLubyte *) dstAddr);
if (ext_tx_compress_dxtn) {
- (*ext_tx_compress_dxtn)(3, srcWidth, srcHeight, pixels, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, dst, dstRowStride);
+ (*ext_tx_compress_dxtn)(3, srcWidth, srcHeight, pixels,
+ GL_COMPRESSED_RGB_S3TC_DXT1_EXT,
+ dst, dstRowStride);
}
else {
_mesa_problem(ctx, "external dxt library not available");
}
dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
- GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,
+ dstFormat->MesaFormat,
texWidth, (GLubyte *) dstAddr);
if (ext_tx_compress_dxtn) {
- (*ext_tx_compress_dxtn)(4, srcWidth, srcHeight, pixels, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, dst, dstRowStride);
+ (*ext_tx_compress_dxtn)(4, srcWidth, srcHeight, pixels,
+ GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,
+ dst, dstRowStride);
}
else {
_mesa_problem(ctx, "external dxt library not available");
}
dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
- GL_COMPRESSED_RGBA_S3TC_DXT3_EXT,
+ dstFormat->MesaFormat,
texWidth, (GLubyte *) dstAddr);
if (ext_tx_compress_dxtn) {
- (*ext_tx_compress_dxtn)(4, srcWidth, srcHeight, pixels, GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, dst, dstRowStride);
+ (*ext_tx_compress_dxtn)(4, srcWidth, srcHeight, pixels,
+ GL_COMPRESSED_RGBA_S3TC_DXT3_EXT,
+ dst, dstRowStride);
}
else {
_mesa_problem(ctx, "external dxt library not available");
}
dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
- GL_COMPRESSED_RGBA_S3TC_DXT5_EXT,
+ dstFormat->MesaFormat,
texWidth, (GLubyte *) dstAddr);
if (ext_tx_compress_dxtn) {
- (*ext_tx_compress_dxtn)(4, srcWidth, srcHeight, pixels, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, dst, dstRowStride);
+ (*ext_tx_compress_dxtn)(4, srcWidth, srcHeight, pixels,
+ GL_COMPRESSED_RGBA_S3TC_DXT5_EXT,
+ dst, dstRowStride);
}
else {
_mesa_problem(ctx, "external dxt library not available");
fetch_texel_2d_rgb_dxt1( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLchan *texel )
{
- (void) k;
- if (fetch_ext_rgb_dxt1) {
- ASSERT (sizeof(GLchan) == sizeof(GLubyte));
- (*fetch_ext_rgb_dxt1)((texImage)->RowStride, (GLubyte *)(texImage)->Data, i, j, texel);
- }
- else _mesa_debug(NULL, "attempted to decode s3tc texture without library available\n");
+ (void) k;
+ if (fetch_ext_rgb_dxt1) {
+ ASSERT (sizeof(GLchan) == sizeof(GLubyte));
+ fetch_ext_rgb_dxt1(texImage->RowStride,
+ (GLubyte *)(texImage)->Data, i, j, texel);
+ }
+ else
+ _mesa_debug(NULL, "attempted to decode s3tc texture without library available\n");
}
{
(void) k;
if (fetch_ext_rgba_dxt1) {
- (*fetch_ext_rgba_dxt1)((texImage)->RowStride, (GLubyte *)(texImage)->Data, i, j, texel);
- }
- else _mesa_debug(NULL, "attempted to decode s3tc texture without library available\n");
+ fetch_ext_rgba_dxt1(texImage->RowStride,
+ (GLubyte *)(texImage)->Data, i, j, texel);
+ }
+ else
+ _mesa_debug(NULL, "attempted to decode s3tc texture without library available\n");
}
{
(void) k;
if (fetch_ext_rgba_dxt3) {
- ASSERT (sizeof(GLchan) == sizeof(GLubyte));
- (*fetch_ext_rgba_dxt3)((texImage)->RowStride, (GLubyte *)(texImage)->Data, i, j, texel);
- }
- else _mesa_debug(NULL, "attempted to decode s3tc texture without library available\n");
+ ASSERT (sizeof(GLchan) == sizeof(GLubyte));
+ fetch_ext_rgba_dxt3(texImage->RowStride, (GLubyte *)(texImage)->Data,
+ i, j, texel);
+ }
+ else
+ _mesa_debug(NULL, "attempted to decode s3tc texture without library available\n");
}
{
(void) k;
if (fetch_ext_rgba_dxt5) {
- (*fetch_ext_rgba_dxt5)((texImage)->RowStride, (GLubyte *)(texImage)->Data, i, j, texel);
- }
- else _mesa_debug(NULL, "attempted to decode s3tc texture without library available\n");
+ fetch_ext_rgba_dxt5(texImage->RowStride, (GLubyte *)(texImage)->Data,
+ i, j, texel);
+ }
+ else
+ _mesa_debug(NULL, "attempted to decode s3tc texture without library available\n");
}
else
img->DepthLog2 = logbase2(img->Depth2);
img->MaxLog2 = MAX2(img->WidthLog2, img->HeightLog2);
- img->IsCompressed = is_compressed_format(ctx, internalFormat);
- if (img->IsCompressed)
- img->CompressedSize = ctx->Driver.CompressedTextureSize(ctx, width,
- height, depth, internalFormat);
- else
- img->CompressedSize = 0;
+ img->IsCompressed = GL_FALSE;
+ img->CompressedSize = 0;
if ((width == 1 || _mesa_bitcount(img->Width2) == 1) &&
(height == 1 || _mesa_bitcount(img->Height2) == 1) &&
GLsizei height, GLsizei depth, GLint border,
GLsizei imageSize)
{
- GLint expectedSize, maxLevels = 0, maxTextureSize;
+ GLint /**expectedSize,**/ maxLevels = 0, maxTextureSize;
if (dimensions == 1) {
/* 1D compressed textures not allowed */
if (level < 0 || level >= maxLevels)
return GL_INVALID_VALUE;
+#if 0
+ /* XXX need to renable this code someday! */
expectedSize = ctx->Driver.CompressedTextureSize(ctx, width, height, depth,
internalFormat);
if (expectedSize != imageSize)
return GL_INVALID_VALUE;
+#endif
return GL_NO_ERROR;
}
}
+/**
+ * Choose the actual storage format for a new texture image.
+ * Mainly, this is a wrapper for the driver's ChooseTextureFormat() function.
+ * Also set some other texImage fields related to texture compression, etc.
+ * \param ctx rendering context
+ * \param texImage the gl_texture_image
+ * \param dims texture dimensions (1, 2 or 3)
+ * \param format the user-specified format parameter
+ * \param type the user-specified type parameter
+ * \param internalFormat the user-specified internal format hint
+ */
+static void
+choose_texture_format(GLcontext *ctx, struct gl_texture_image *texImage,
+ GLuint dims,
+ GLenum format, GLenum type, GLint internalFormat)
+{
+ assert(ctx->Driver.ChooseTextureFormat);
+
+ texImage->TexFormat
+ = ctx->Driver.ChooseTextureFormat(ctx, internalFormat, format, type);
+
+ assert(texImage->TexFormat);
+
+ set_fetch_functions(texImage, dims);
+
+ if (texImage->TexFormat->TexelBytes == 0) {
+ /* must be a compressed format */
+ texImage->IsCompressed = GL_TRUE;
+ texImage->CompressedSize =
+ ctx->Driver.CompressedTextureSize(ctx, texImage->Width,
+ texImage->Height, texImage->Depth,
+ texImage->TexFormat->MesaFormat);
+ }
+ else {
+ /* non-compressed format */
+ texImage->IsCompressed = GL_FALSE;
+ texImage->CompressedSize = 0;
+ }
+}
+
+
+
/*
* This is the software fallback for Driver.TexImage1D()
* and Driver.CopyTexImage1D().
_mesa_adjust_image_for_convolution(ctx, 1, &postConvWidth, NULL);
}
- /* choose the texture format */
- assert(ctx->Driver.ChooseTextureFormat);
- texImage->TexFormat = ctx->Driver.ChooseTextureFormat(ctx, internalFormat,
- format, type);
- assert(texImage->TexFormat);
- set_fetch_functions(texImage, 1);
+ choose_texture_format(ctx, texImage, 1, format, type, internalFormat);
/* allocate memory */
if (texImage->IsCompressed)
&postConvHeight);
}
- /* choose the texture format */
- assert(ctx->Driver.ChooseTextureFormat);
- texImage->TexFormat = (*ctx->Driver.ChooseTextureFormat)(ctx,
- internalFormat, format, type);
- assert(texImage->TexFormat);
- set_fetch_functions(texImage, 2);
+ choose_texture_format(ctx, texImage, 2, format, type, internalFormat);
texelBytes = texImage->TexFormat->TexelBytes;
GLboolean success;
if (texImage->IsCompressed) {
dstRowStride
- = _mesa_compressed_row_stride(texImage->InternalFormat,width);
+ = _mesa_compressed_row_stride(texImage->TexFormat->MesaFormat, width);
}
else {
dstRowStride = postConvWidth * texImage->TexFormat->TexelBytes;
GLint texelBytes, sizeInBytes;
(void) border;
- /* choose the texture format */
- assert(ctx->Driver.ChooseTextureFormat);
- texImage->TexFormat = (*ctx->Driver.ChooseTextureFormat)(ctx,
- internalFormat, format, type);
- assert(texImage->TexFormat);
- set_fetch_functions(texImage, 3);
+ choose_texture_format(ctx, texImage, 3, format, type, internalFormat);
texelBytes = texImage->TexFormat->TexelBytes;
GLboolean success;
if (texImage->IsCompressed) {
dstRowStride
- = _mesa_compressed_row_stride(texImage->InternalFormat,width);
+ = _mesa_compressed_row_stride(texImage->TexFormat->MesaFormat, width);
dstImageStride = 0;
}
else {
GLint dstRowStride = 0, dstImageStride = 0;
GLboolean success;
if (texImage->IsCompressed) {
- dstRowStride = _mesa_compressed_row_stride(texImage->InternalFormat,
+ dstRowStride = _mesa_compressed_row_stride(texImage->TexFormat->MesaFormat,
texImage->Width);
}
else {
GLint dstRowStride, dstImageStride;
GLboolean success;
if (texImage->IsCompressed) {
- dstRowStride = _mesa_compressed_row_stride(texImage->InternalFormat,
+ dstRowStride = _mesa_compressed_row_stride(texImage->TexFormat->MesaFormat,
texImage->Width);
dstImageStride = 0; /* XXX fix */
}
ASSERT(texImage->Depth == 1);
ASSERT(texImage->Data == NULL); /* was freed in glCompressedTexImage2DARB */
- /* choose the texture format */
- assert(ctx->Driver.ChooseTextureFormat);
- texImage->TexFormat = (*ctx->Driver.ChooseTextureFormat)(ctx,
- internalFormat, 0, 0);
- assert(texImage->TexFormat);
- set_fetch_functions(texImage, 2);
+ choose_texture_format(ctx, texImage, 2, 0, 0, internalFormat);
/* allocate storage */
texImage->Data = _mesa_alloc_texmemory(imageSize);
struct gl_texture_object *texObj,
struct gl_texture_image *texImage)
{
- /* this space intentionally left blank */
+ /* there are no compressed 1D texture formats yet */
(void) ctx;
(void) target; (void) level;
(void) xoffset; (void) width;
GLint i, rows;
GLubyte *dest;
const GLubyte *src;
+ const GLuint mesaFormat = texImage->TexFormat->MesaFormat;
+
(void) format;
/* these should have been caught sooner */
if (!data)
return;
- srcRowStride = _mesa_compressed_row_stride(texImage->InternalFormat, width);
+ srcRowStride = _mesa_compressed_row_stride(mesaFormat, width);
src = (const GLubyte *) data;
- destRowStride = _mesa_compressed_row_stride(texImage->InternalFormat,
- texImage->Width);
+ destRowStride = _mesa_compressed_row_stride(mesaFormat, texImage->Width);
dest = _mesa_compressed_image_address(xoffset, yoffset, 0,
texImage->InternalFormat,
texImage->Width,
struct gl_texture_object *texObj,
struct gl_texture_image *texImage)
{
- /* this space intentionally left blank */
+ /* there are no compressed 3D texture formats yet */
(void) ctx;
(void) target; (void) level;
(void) xoffset; (void) yoffset; (void) zoffset;
}
-/*
+/**
* For GL_SGIX_generate_mipmap:
* Generate a complete set of mipmaps from texObj's base-level image.
* Stop at texObj's MaxLevel or when we get to the 1x1 texture.
dstImage->TexFormat = srcImage->TexFormat;
dstImage->FetchTexelc = srcImage->FetchTexelc;
dstImage->FetchTexelf = srcImage->FetchTexelf;
+ dstImage->IsCompressed = srcImage->IsCompressed;
+ if (dstImage->IsCompressed) {
+ dstImage->CompressedSize
+ = ctx->Driver.CompressedTextureSize(ctx, dstImage->Width,
+ dstImage->Height,
+ dstImage->Depth,
+ dstImage->TexFormat->MesaFormat);
+ ASSERT(dstImage->CompressedSize > 0);
+ }
+
ASSERT(dstImage->TexFormat);
ASSERT(dstImage->FetchTexelc);
ASSERT(dstImage->FetchTexelf);
* Setup src and dest data pointers.
*/
if (dstImage->IsCompressed) {
- ASSERT(dstImage->CompressedSize > 0); /* set by init_teximage_fields*/
dstImage->Data = _mesa_alloc_texmemory(dstImage->CompressedSize);
if (!dstImage->Data) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "generating mipmaps");
ASSERT(dstData);
}
else {
- bytesPerTexel = srcImage->TexFormat->TexelBytes;
+ bytesPerTexel = dstImage->TexFormat->TexelBytes;
ASSERT(dstWidth * dstHeight * dstDepth * bytesPerTexel > 0);
dstImage->Data = _mesa_alloc_texmemory(dstWidth * dstHeight
* dstDepth * bytesPerTexel);
/* compress image from dstData into dstImage->Data */
const GLenum srcFormat = convertFormat->BaseFormat;
GLint dstRowStride
- = _mesa_compressed_row_stride(srcImage->InternalFormat, dstWidth);
+ = _mesa_compressed_row_stride(dstImage->TexFormat->MesaFormat, dstWidth);
ASSERT(srcFormat == GL_RGB || srcFormat == GL_RGBA);
dstImage->TexFormat->StoreImage(ctx, 2, dstImage->_BaseFormat,
dstImage->TexFormat,