if (fxMesa->type >= GR_SSTTYPE_Voodoo4) {
_mesa_enable_extension(ctx, "GL_3DFX_texture_compression_FXT1");
_mesa_enable_extension(ctx, "GL_EXT_texture_compression_s3tc");
- /*_mesa_enable_extension(ctx, "GL_S3_s3tc");*/
+ _mesa_enable_extension(ctx, "GL_S3_s3tc");
}
if (fxMesa->HaveCmbExt) {
(internalFormat == GL_COMPRESSED_RGB_S3TC_DXT1_EXT) ||
(internalFormat == GL_COMPRESSED_RGBA_S3TC_DXT1_EXT) ||
(internalFormat == GL_COMPRESSED_RGBA_S3TC_DXT3_EXT) ||
- (internalFormat == GL_COMPRESSED_RGBA_S3TC_DXT5_EXT)) {
+ (internalFormat == GL_COMPRESSED_RGBA_S3TC_DXT5_EXT) ||
+ (internalFormat == GL_RGB_S3TC) ||
+ (internalFormat == GL_RGB4_S3TC) ||
+ (internalFormat == GL_RGBA_S3TC) ||
+ (internalFormat == GL_RGBA4_S3TC)) {
return GL_TRUE;
}
switch (format) {
case GL_COMPRESSED_RGB_FXT1_3DFX:
case GL_COMPRESSED_RGBA_FXT1_3DFX:
- /* round up to multiples of 8, 4 */
- size = ((width + 7) / 8) * ((height + 3) / 4) * 16;
+ /* round up width to next multiple of 8, height to next multiple of 4 */
+ width = (width + 7) & ~7;
+ height = (height + 3) & ~3;
+ /* 16 bytes per 8x4 tile of RGB[A] texels */
+ size = width * height / 2;
/* Textures smaller than 8x4 will effectively be made into 8x4 and
* take 16 bytes.
*/
return size;
case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
+ case GL_RGB_S3TC:
+ case GL_RGB4_S3TC:
/* round up width, height to next multiple of 4 */
width = (width + 3) & ~3;
height = (height + 3) & ~3;
/* 8 bytes per 4x4 tile of RGB[A] texels */
- size = (width * height * 8) / 16;
+ size = width * height / 2;
/* Textures smaller than 4x4 will effectively be made into 4x4 and
* take 8 bytes.
*/
return size;
case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
+ case GL_RGBA_S3TC:
+ case GL_RGBA4_S3TC:
/* round up width, height to next multiple of 4 */
width = (width + 3) & ~3;
height = (height + 3) & ~3;
return &_mesa_texformat_argb1555;
/* GL_EXT_texture_compression_s3tc */
case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
+ case GL_RGB_S3TC:
+ case GL_RGB4_S3TC:
return &_mesa_texformat_rgb_dxt1;
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
return &_mesa_texformat_rgba_dxt1;
case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
+ case GL_RGBA_S3TC:
+ case GL_RGBA4_S3TC:
return &_mesa_texformat_rgba_dxt3;
case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
return &_mesa_texformat_rgba_dxt5;
{ OFF, "GL_SGIX_shadow", F(SGIX_shadow) },
{ OFF, "GL_SGIX_shadow_ambient", F(SGIX_shadow_ambient) },
{ OFF, "GL_SUN_multi_draw_arrays", F(EXT_multi_draw_arrays) },
+ { OFF, "GL_S3_s3tc", F(S3_s3tc) },
};
GLboolean SGIX_shadow_ambient; /* or GL_ARB_shadow_ambient */
GLboolean TDFX_texture_compression_FXT1;
GLboolean APPLE_client_storage;
+ GLboolean S3_s3tc;
/*@}*/
/* The extension string */
const GLubyte *String;
n += 3;
}
}
+ if (ctx->Extensions.S3_s3tc) {
+ if (formats) {
+ formats[n++] = GL_RGB_S3TC;
+ formats[n++] = GL_RGB4_S3TC;
+ formats[n++] = GL_RGBA_S3TC;
+ formats[n++] = GL_RGBA4_S3TC;
+ }
+ else {
+ n += 4;
+ }
+ }
}
return n;
}
return ctx->Driver.CompressedTextureSize(ctx, width, height, depth, format);
}
+ ASSERT(depth == 1);
+
switch (format) {
case GL_COMPRESSED_RGB_FXT1_3DFX:
case GL_COMPRESSED_RGBA_FXT1_3DFX:
- /* round up to multiples of 8, 4 */
- size = ((width + 7) / 8) * ((height + 3) / 4) * 16;
+ /* round up width to next multiple of 8, height to next multiple of 4 */
+ width = (width + 7) & ~7;
+ height = (height + 3) & ~3;
+ /* 16 bytes per 8x4 tile of RGB[A] texels */
+ size = width * height / 2;
/* Textures smaller than 8x4 will effectively be made into 8x4 and
* take 16 bytes.
*/
return size;
case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
+ case GL_RGB_S3TC:
+ case GL_RGB4_S3TC:
/* round up width, height to next multiple of 4 */
width = (width + 3) & ~3;
height = (height + 3) & ~3;
- ASSERT(depth == 1);
/* 8 bytes per 4x4 tile of RGB[A] texels */
- size = (width * height * 8) / 16;
+ size = width * height / 2;
/* Textures smaller than 4x4 will effectively be made into 4x4 and
* take 8 bytes.
*/
return size;
case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
+ case GL_RGBA_S3TC:
+ case GL_RGBA4_S3TC:
/* round up width, height to next multiple of 4 */
width = (width + 3) & ~3;
height = (height + 3) & ~3;
- ASSERT(depth == 1);
/* 16 bytes per 4x4 tile of RGBA texels */
size = width * height; /* simple! */
/* Textures smaller than 4x4 will effectively be made into 4x4 and
GLint
_mesa_compressed_row_stride(GLenum format, GLsizei width)
{
- GLint bytesPerTile, stride;
+ GLint stride;
switch (format) {
case GL_COMPRESSED_RGB_FXT1_3DFX:
case GL_COMPRESSED_RGBA_FXT1_3DFX:
- bytesPerTile = 16;
+ 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:
- bytesPerTile = 8;
+ case GL_RGB_S3TC:
+ case GL_RGB4_S3TC:
+ 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:
- bytesPerTile = 16;
+ case GL_RGBA_S3TC:
+ case GL_RGBA4_S3TC:
+ stride = ((width + 3) / 4) * 16; /* 16 bytes per 4x4 tile */
break;
default:
return 0;
}
- stride = ((width + 3) / 4) * bytesPerTile;
return stride;
}
GLenum format,
GLsizei width, const GLubyte *image)
{
- GLint bytesPerTile, stride;
GLubyte *addr;
- ASSERT((row & 3) == 0);
- ASSERT((col & 3) == 0);
(void) img;
+ /* We try to spot a "complete" subtexture "above" ROW, COL;
+ * this texture is given by appropriate rounding of WIDTH x ROW.
+ * Then we just add the amount left (usually on the left).
+ *
+ * Example for X*Y microtiles (Z bytes each)
+ * offset = Z * (((width + X - 1) / X) * (row / Y) + col / X);
+ */
+
switch (format) {
case GL_COMPRESSED_RGB_FXT1_3DFX:
case GL_COMPRESSED_RGBA_FXT1_3DFX:
- bytesPerTile = 16;
+ 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:
- bytesPerTile = 8;
+ case GL_RGB_S3TC:
+ case GL_RGB4_S3TC:
+ 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:
- bytesPerTile = 16;
+ case GL_RGBA_S3TC:
+ case GL_RGBA4_S3TC:
+ addr = (GLubyte *) image + 16 * (((width + 3) / 4) * (row / 4) + col / 4);
break;
default:
return 0;
}
- stride = ((width + 3) / 4) * bytesPerTile;
-
- addr = (GLubyte *) image + (row / 4) * stride + (col / 4) * bytesPerTile;
return addr;
}
_mesa_problem(ctx, "texture compression extension not enabled");
if (ctx->Extensions.TDFX_texture_compression_FXT1)
return &_mesa_texformat_rgb_fxt1;
- else if (ctx->Extensions.EXT_texture_compression_s3tc)
+ else if (ctx->Extensions.EXT_texture_compression_s3tc || ctx->Extensions.S3_s3tc)
return &_mesa_texformat_rgb_dxt1;
return &_mesa_texformat_rgb;
case GL_COMPRESSED_RGBA_ARB:
_mesa_problem(ctx, "texture compression extension not enabled");
if (ctx->Extensions.TDFX_texture_compression_FXT1)
return &_mesa_texformat_rgba_fxt1;
- else if (ctx->Extensions.EXT_texture_compression_s3tc)
+ else if (ctx->Extensions.EXT_texture_compression_s3tc || ctx->Extensions.S3_s3tc)
return &_mesa_texformat_rgba_dxt3; /* Not rgba_dxt1! See the spec */
return &_mesa_texformat_rgba;
else
return NULL;
+ /* GL_S3_s3tc */
+ case GL_RGB_S3TC:
+ case GL_RGB4_S3TC:
+ if (ctx->Extensions.S3_s3tc)
+ return &_mesa_texformat_rgb_dxt1;
+ else
+ return NULL;
+ case GL_RGBA_S3TC:
+ case GL_RGBA4_S3TC:
+ if (ctx->Extensions.S3_s3tc)
+ return &_mesa_texformat_rgba_dxt3;
+ else
+ return NULL;
+
default:
_mesa_problem(ctx, "unexpected format in _mesa_choose_tex_format()");
return NULL;
return GL_RGBA;
else
return -1;
+ case GL_RGB_S3TC:
+ case GL_RGB4_S3TC:
+ if (ctx->Extensions.S3_s3tc)
+ return GL_RGB;
+ else
+ return -1;
+ case GL_RGBA_S3TC:
+ case GL_RGBA4_S3TC:
+ if (ctx->Extensions.S3_s3tc)
+ return GL_RGBA;
+ else
+ return -1;
case GL_YCBCR_MESA:
if (ctx->Extensions.MESA_ycbcr_texture)
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
+ case GL_RGB_S3TC:
+ case GL_RGB4_S3TC:
+ case GL_RGBA_S3TC:
+ case GL_RGBA4_S3TC:
return GL_TRUE;
default:
if (ctx->Driver.IsCompressedFormat) {