Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:dreveman:openSUSE:11.1:cr
cr
cr-texture-compression-fix.diff
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File cr-texture-compression-fix.diff of Package cr
commit da2b9fabf3520eec5a4bd478adf5088cfe663a80 Author: David Reveman <davidr@novell.com> Date: Wed Apr 8 17:55:02 2009 -0400 Improve GL_ARB_texture_compression support. diff --git a/crserverlib/server_simpleget.py b/crserverlib/server_simpleget.py index c827e2e..ba582da 100644 --- a/crserverlib/server_simpleget.py +++ b/crserverlib/server_simpleget.py @@ -22,6 +22,39 @@ print """#include "cr_spu.h" from get_sizes import *; +special_num_get_values = { + 'GL_COMPRESSED_TEXTURE_FORMATS_ARB': ('GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB', 'CR_ARB_texture_compression') +} + +get_keys = special_num_get_values.keys() +get_keys.sort() + +print "struct np_struct { GLenum pname; GLenum num_pname; } num_pname_array[] = {" +for key in get_keys: + (np, ifdef) = special_num_get_values[key] + print '#ifdef %s' % ifdef + print '\t{ %s, %s },' % (key, np) + print '#endif /* %s */' % ifdef +print "\t{ 0, 0 }" +print "};" + +print """ +static unsigned int __numValuesServer( GLenum pname ) +{ + struct np_struct *temp; + + for (temp = num_pname_array; temp->num_pname != 0 ; temp++) + { + if (temp->pname == pname) + { + GLint value; + cr_server.head_spu->dispatch_table.GetIntegerv( temp->num_pname, &value ); + return value; + } + } + return __numValues( pname ); +} +""" funcs = [ 'GetIntegerv', 'GetFloatv', 'GetDoublev', 'GetBooleanv' ] types = [ 'GLint', 'GLfloat', 'GLdouble', 'GLboolean' ] @@ -32,7 +65,7 @@ for index in range(len(funcs)): print 'void SERVER_DISPATCH_APIENTRY crServerDispatch%s( %s )' % ( func_name, apiutil.MakeDeclarationString(params)) print '{' print '\t%s *get_values;' % types[index] - print '\tint tablesize = __numValues( pname ) * sizeof(%s);' % types[index] + print '\tint tablesize = __numValuesServer( pname ) * sizeof(%s);' % types[index] print '\t(void) params;' print '\tget_values = (%s *) crAlloc( tablesize );' % types[index] print '\tcr_server.head_spu->dispatch_table.%s( pname, get_values );' % func_name diff --git a/include/cr_extstring.h b/include/cr_extstring.h index dead186..3cc5a5b 100644 --- a/include/cr_extstring.h +++ b/include/cr_extstring.h @@ -53,6 +53,8 @@ static const char *crExtensions = #endif #ifdef CR_ARB_texture_compression "GL_ARB_texture_compression " + "GL_EXT_texture_compression_s3tc " + "GL_3DFX_texture_compression_FXT1 " #endif #ifdef CR_ARB_texture_cube_map "GL_ARB_texture_cube_map " diff --git a/packer/pack_pixels.c b/packer/pack_pixels.c index d4c68b0..494502a 100644 --- a/packer/pack_pixels.c +++ b/packer/pack_pixels.c @@ -222,3 +222,19 @@ crPackGetTexImage( GLenum target, GLint level, GLenum format, GLenum type, WRITE_NETWORK_POINTER( 32, (void *) writeback ); WRITE_OPCODE( pc, CR_EXTEND_OPCODE ); } + +void PACK_APIENTRY +crPackGetCompressedTexImageARB( GLenum target, GLint level, GLvoid *img, int *writeback ) +{ + GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr; + (void) pc; + GET_BUFFERED_POINTER( pc, 32 ); + WRITE_DATA( 0, GLint, 32 ); + WRITE_DATA( 4, GLenum, CR_GETCOMPRESSEDTEXIMAGEARB_EXTEND_OPCODE ); + WRITE_DATA( 8, GLenum, target ); + WRITE_DATA( 12, GLint, level ); + WRITE_NETWORK_POINTER( 16, (void *) img ); + WRITE_NETWORK_POINTER( 24, (void *) writeback ); + WRITE_OPCODE( pc, CR_EXTEND_OPCODE ); +} diff --git a/packer/pack_swap_texture.c b/packer/pack_swap_texture.c index ed16820..466e1ba 100644 --- a/packer/pack_swap_texture.c +++ b/packer/pack_swap_texture.c @@ -959,14 +959,3 @@ void PACK_APIENTRY crPackCompressedTexSubImage3DARBSWAP( GLenum target, GLint le crHugePacket( CR_EXTEND_OPCODE, data_ptr ); crPackFree( data_ptr ); } - -void PACK_APIENTRY crPackGetCompressedTexImageARBSWAP( GLenum target, GLint level, GLvoid *img, int *writeback ) -{ - GET_PACKER_CONTEXT(pc); - crError ( "GetCompressedTexImageARB needs to be special cased!"); - (void) pc; - (void) target; - (void) level; - (void) img; - (void) writeback; -} diff --git a/packer/pack_texture.c b/packer/pack_texture.c index 84df927..5c96b13 100644 --- a/packer/pack_texture.c +++ b/packer/pack_texture.c @@ -952,14 +952,3 @@ void PACK_APIENTRY crPackCompressedTexSubImage3DARB( GLenum target, GLint level, crHugePacket( CR_EXTEND_OPCODE, data_ptr ); crPackFree( data_ptr ); } - -void PACK_APIENTRY crPackGetCompressedTexImageARB( GLenum target, GLint level, GLvoid *img, int *writeback ) -{ - GET_PACKER_CONTEXT(pc); - crError ( "GetCompressedTexImageARB needs to be special cased!"); - (void) pc; - (void) target; - (void) level; - (void) img; - (void) writeback; -} diff --git a/state_tracker/state_extensions_get.txt b/state_tracker/state_extensions_get.txt index 3f99ee1..96d6a24 100644 --- a/state_tracker/state_extensions_get.txt +++ b/state_tracker/state_extensions_get.txt @@ -102,7 +102,7 @@ GLboolean GL_SAMPLE_COVERAGE_INVERT_ARB GL_ARB_multisample g->multisample.sample # GL_ARB_texture_compression GLint GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB GL_ARB_texture_compression g->limits.numCompressedFormats -GLint GL_COMPRESSED_TEXTURE_FORMATS_ARB GL_ARB_texture_compression g->limits.compressedFormats[0] +GLint GL_COMPRESSED_TEXTURE_FORMATS_ARB GL_ARB_texture_compression %if(g->limits.numCompressedFormats>0)// g->limits.compressedFormats[0] %if(g->limits.numCompressedFormats>1)// g->limits.compressedFormats[1] %if(g->limits.numCompressedFormats>2)// g->limits.compressedFormats[2] %if(g->limits.numCompressedFormats>3)// g->limits.compressedFormats[3] %if(g->limits.numCompressedFormats>4)// g->limits.compressedFormats[4] %if(g->limits.numCompressedFormats>5)// g->limits.compressedFormats[5] %if(g->limits.numCompressedFormats>6)// g->limits.compressedFormats[6] %if(g->limits.numCompressedFormats>7)// g->limits.compressedFormats[7] %if(g->limits.numCompressedFormats>8)// g->limits.compressedFormats[8] %if(g->limits.numCompressedFormats>9)// g->limits.compressedFormats[9] GLint GL_TEXTURE_COMPRESSION_HINT_ARB GL_ARB_texture_compression g->hint.textureCompression # GL_EXT_texture_lod_bias diff --git a/state_tracker/state_limits.c b/state_tracker/state_limits.c index 73b70c4..f7c305b 100644 --- a/state_tracker/state_limits.c +++ b/state_tracker/state_limits.c @@ -140,6 +140,15 @@ void crStateLimitsInit (CRLimitsState *l) l->maxVertexProgramAttribs = CR_MAX_VERTEX_PROGRAM_ATTRIBS; l->maxVertexProgramAddressRegs = CR_MAX_VERTEX_PROGRAM_ADDRESS_REGS; #endif +#ifdef CR_ARB_texture_compression + l->numCompressedFormats = 6; + l->compressedFormats[0] = GL_COMPRESSED_RGB_S3TC_DXT1_EXT; + l->compressedFormats[1] = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; + l->compressedFormats[2] = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT; + l->compressedFormats[3] = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; + l->compressedFormats[4] = GL_COMPRESSED_RGB_FXT1_3DFX; + l->compressedFormats[5] = GL_COMPRESSED_RGBA_FXT1_3DFX; +#endif l->extensions = (GLubyte *) crStrdup(crExtensions); @@ -400,6 +409,26 @@ void crStateExtensionsInit( CRLimitsState *limits, CRExtensionState *extensions if (extensions->any_vertex_program || extensions->any_fragment_program) extensions->any_program = GL_TRUE; +#ifdef CR_ARB_texture_compression + if (extensions->ARB_texture_compression) + { + limits->numCompressedFormats = 0; + if (hasExtension((const char*)limits->extensions, "GL_EXT_texture_compression_s3tc")) + { + limits->compressedFormats[limits->numCompressedFormats++] = GL_COMPRESSED_RGB_S3TC_DXT1_EXT; + limits->compressedFormats[limits->numCompressedFormats++] = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; + limits->compressedFormats[limits->numCompressedFormats++] = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT; + limits->compressedFormats[limits->numCompressedFormats++] = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; + } + + if (hasExtension((const char*)limits->extensions, "GL_EXT_texture_compression_s3tc")) + { + limits->compressedFormats[limits->numCompressedFormats++] = GL_COMPRESSED_RGB_FXT1_3DFX; + limits->compressedFormats[limits->numCompressedFormats++] = GL_COMPRESSED_RGBA_FXT1_3DFX; + } + } +#endif + #if 0 /* Now, determine what level of OpenGL we support */ if (extensions->ARB_multisample && diff --git a/state_tracker/state_teximage.c b/state_tracker/state_teximage.c index 581bfa8..14b71bd 100644 --- a/state_tracker/state_teximage.c +++ b/state_tracker/state_teximage.c @@ -977,7 +977,6 @@ crStateTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, } #endif /* CR_OPENGL_VERSION_1_2 || GL_EXT_texture3D */ - void STATE_APIENTRY crStateCompressedTexImage1DARB(GLenum target, GLint level, GLenum internalFormat, GLsizei width, @@ -1213,6 +1212,87 @@ crStateCompressedTexImage3DARB(GLenum target, GLint level, DIRTY(tb->dirty, g->neg_bitid); } +/* + * Compute the bytes per row in a compressed texture image. + * We use this for computing the destination address for sub-texture updates. + * \param internalFormat compressed image format + * \param width image width in pixels + * \return stride, in bytes, between rows for compressed image + */ +static GLint +compressedRowStride(GLuint internalFormat, GLsizei width) +{ + GLint stride; + + switch (internalFormat) { + case GL_COMPRESSED_RGB_FXT1_3DFX: + case GL_COMPRESSED_RGBA_FXT1_3DFX: + 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: + 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: + stride = ((width + 3) / 4) * 16; /* 16 bytes per 4x4 tile */ + break; + default: + crError( "bad internalFormat=0x%x in compressedRowStride", + internalFormat ); + return 0; + } + + return stride; +} + +/* + * Return the address of the pixel at (col, row, img) in a + * compressed texture image. + * \param col, row, img - image position (3D) + * \param internalFormat - compressed image format + * \param width - image width + * \param image - the image address + * \return address of pixel at (row, col) + */ +static GLubyte * +compressedImageAddress(GLint col, GLint row, GLint img, + GLuint internalFormat, + GLsizei width, const GLubyte *image) +{ + GLubyte *addr; + + (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 (internalFormat) { + case GL_COMPRESSED_RGB_FXT1_3DFX: + case GL_COMPRESSED_RGBA_FXT1_3DFX: + 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: + 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: + addr = (GLubyte *) image + 16 * (((width + 3) / 4) * (row / 4) + col / 4); + break; + default: + crError( "bad internalFormat=0x%x in compressedImageAddress", + internalFormat ); + addr = NULL; + } + + return addr; +} void STATE_APIENTRY crStateCompressedTexSubImage1DARB(GLenum target, GLint level, GLint xoffset, @@ -1220,12 +1300,10 @@ crStateCompressedTexSubImage1DARB(GLenum target, GLint level, GLint xoffset, GLsizei imageSize, const GLvoid * data) { CRContext *g = GetCurrentContext(); - CRTextureState *t = &(g->texture); CRStateBits *sb = GetCurrentBits(); CRTextureBits *tb = &(sb->texture); - CRTextureUnit *unit = t->unit + t->curTextureUnit; - CRTextureObj *tobj = unit->currentTexture1D; - CRTextureLevel *tl = tobj->level[0] + level; + CRTextureObj *tobj; + CRTextureLevel *tl; FLUSH(); @@ -1233,6 +1311,10 @@ crStateCompressedTexSubImage1DARB(GLenum target, GLint level, GLint xoffset, return; /* GL error state already set */ } + crStateGetTextureObjectAndImage(g, target, level, &tobj, &tl); + CRASSERT(tobj); + CRASSERT(tl); + xoffset += tl->border; if (xoffset == 0 && width == tl->width) { @@ -1240,7 +1322,21 @@ crStateCompressedTexSubImage1DARB(GLenum target, GLint level, GLint xoffset, crMemcpy(tl->img, data, imageSize); } else { - /* XXX this depends on the exact compression method */ + GLint bytesPerRow, srcRowStride; + GLubyte *dest; + const GLubyte *src; + + srcRowStride = compressedRowStride( tl->internalFormat, + width ); + src = (const GLubyte *) data; + + dest = compressedImageAddress( xoffset, 0, 0, + tl->internalFormat, + tl->width, + (GLubyte *) tl->img ); + + bytesPerRow = srcRowStride; + crMemcpy( dest, src, bytesPerRow ); } #ifdef CR_SGIS_generate_mipmap @@ -1266,12 +1362,10 @@ crStateCompressedTexSubImage2DARB(GLenum target, GLint level, GLint xoffset, GLsizei imageSize, const GLvoid * data) { CRContext *g = GetCurrentContext(); - CRTextureState *t = &(g->texture); CRStateBits *sb = GetCurrentBits(); CRTextureBits *tb = &(sb->texture); - CRTextureUnit *unit = t->unit + t->curTextureUnit; - CRTextureObj *tobj = unit->currentTexture1D; - CRTextureLevel *tl = tobj->level[0] + level; + CRTextureObj *tobj; + CRTextureLevel *tl; FLUSH(); @@ -1280,6 +1374,10 @@ crStateCompressedTexSubImage2DARB(GLenum target, GLint level, GLint xoffset, return; /* GL error state already set */ } + crStateGetTextureObjectAndImage(g, target, level, &tobj, &tl); + CRASSERT(tobj); + CRASSERT(tl); + xoffset += tl->border; yoffset += tl->border; @@ -1289,7 +1387,30 @@ crStateCompressedTexSubImage2DARB(GLenum target, GLint level, GLint xoffset, crMemcpy(tl->img, data, imageSize); } else { - /* XXX this depends on the exact compression method */ + GLint bytesPerRow, destRowStride, srcRowStride; + GLint i, rows; + GLubyte *dest; + const GLubyte *src; + + srcRowStride = compressedRowStride( tl->internalFormat, + width ); + src = (const GLubyte *) data; + + destRowStride = compressedRowStride( tl->internalFormat, + tl->width ); + dest = compressedImageAddress( xoffset, yoffset, 0, + tl->internalFormat, + tl->width, + (GLubyte *) tl->img ); + + bytesPerRow = srcRowStride; + rows = height / 4; + + for (i = 0; i < rows; i++) { + crMemcpy( dest, src, bytesPerRow ); + dest += destRowStride; + src += srcRowStride; + } } #ifdef CR_SGIS_generate_mipmap @@ -1316,12 +1437,10 @@ crStateCompressedTexSubImage3DARB(GLenum target, GLint level, GLint xoffset, const GLvoid * data) { CRContext *g = GetCurrentContext(); - CRTextureState *t = &(g->texture); CRStateBits *sb = GetCurrentBits(); CRTextureBits *tb = &(sb->texture); - CRTextureUnit *unit = t->unit + t->curTextureUnit; - CRTextureObj *tobj = unit->currentTexture1D; - CRTextureLevel *tl = tobj->level[0] + level; + CRTextureObj *tobj; + CRTextureLevel *tl; FLUSH(); @@ -1330,6 +1449,10 @@ crStateCompressedTexSubImage3DARB(GLenum target, GLint level, GLint xoffset, return; /* GL error state already set */ } + crStateGetTextureObjectAndImage(g, target, level, &tobj, &tl); + CRASSERT(tobj); + CRASSERT(tl); + xoffset += tl->border; yoffset += tl->border; zoffset += tl->border; @@ -1341,7 +1464,33 @@ crStateCompressedTexSubImage3DARB(GLenum target, GLint level, GLint xoffset, crMemcpy(tl->img, data, imageSize); } else { - /* XXX this depends on the exact compression method */ + GLint bytesPerRow, destRowStride, srcRowStride; + GLint i, j, rows; + GLubyte *dest; + const GLubyte *src; + + srcRowStride = compressedRowStride( tl->internalFormat, + width ); + src = (const GLubyte *) data; + + destRowStride = compressedRowStride( tl->internalFormat, + tl->width ); + dest = compressedImageAddress( xoffset, yoffset, 0, + tl->internalFormat, + tl->width, + (GLubyte *) tl->img ); + + bytesPerRow = srcRowStride; + rows = height / 4; + + for (j = 0; j < depth; j++) { + GLubyte *d = dest + destRowStride * rows * (zoffset + j); + for (i = 0; i < rows; i++) { + crMemcpy( d, src, bytesPerRow ); + d += destRowStride; + src += srcRowStride; + } + } } #ifdef CR_SGIS_generate_mipmap diff --git a/state_tracker/state_texture.c b/state_tracker/state_texture.c index d4f0597..a52f616 100644 --- a/state_tracker/state_texture.c +++ b/state_tracker/state_texture.c @@ -371,6 +371,67 @@ const CRTextureFormat _texformat_ci8 = { 8, /* IndexBits */ }; +#ifdef CR_ARB_texture_compression +const CRTextureFormat _texformat_rgb_dxt1 = { + 4, /*approx*/ /* RedBits */ + 4, /*approx*/ /* GreenBits */ + 4, /*approx*/ /* BlueBits */ + 0, /* AlphaBits */ + 0, /* LuminanceBits */ + 0, /* IntensityBits */ + 0, /* IndexBits */ +}; + +const CRTextureFormat _texformat_rgba_dxt1 = { + 4, /*approx*/ /* RedBits */ + 4, /*approx*/ /* GreenBits */ + 4, /*approx*/ /* BlueBits */ + 1, /*approx*/ /* AlphaBits */ + 0, /* LuminanceBits */ + 0, /* IntensityBits */ + 0, /* IndexBits */ +}; + +const CRTextureFormat _texformat_rgba_dxt3 = { + 4, /*approx*/ /* RedBits */ + 4, /*approx*/ /* GreenBits */ + 4, /*approx*/ /* BlueBits */ + 4, /*approx*/ /* AlphaBits */ + 0, /* LuminanceBits */ + 0, /* IntensityBits */ + 0, /* IndexBits */ +}; + +const CRTextureFormat _texformat_rgba_dxt5 = { + 4, /*approx*/ /* RedBits */ + 4, /*approx*/ /* GreenBits */ + 4, /*approx*/ /* BlueBits */ + 4, /*approx*/ /* AlphaBits */ + 0, /* LuminanceBits */ + 0, /* IntensityBits */ + 0, /* IndexBits */ +}; + +const CRTextureFormat _texformat_rgb_fxt1 = { + 4, /*approx*/ /* RedBits */ + 4, /*approx*/ /* GreenBits */ + 4, /*approx*/ /* BlueBits */ + 0, /* AlphaBits */ + 0, /* LuminanceBits */ + 0, /* IntensityBits */ + 0, /* IndexBits */ +}; + +const CRTextureFormat _texformat_rgba_fxt1 = { + 4, /*approx*/ /* RedBits */ + 4, /*approx*/ /* GreenBits */ + 4, /*approx*/ /* BlueBits */ + 1, /*approx*/ /* AlphaBits */ + 0, /* LuminanceBits */ + 0, /* IntensityBits */ + 0, /* IndexBits */ +}; +#endif /** * Given an internal texture format enum or 1, 2, 3, 4 initialize the @@ -465,7 +526,26 @@ crStateTextureInitTextureFormat( CRTextureLevel *tl, GLenum internalFormat ) case GL_COLOR_INDEX16_EXT: tl->texFormat = &_texformat_ci8; break; - +#ifdef CR_ARB_texture_compression + case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: + tl->texFormat = &_texformat_rgb_dxt1; + break; + case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: + tl->texFormat = &_texformat_rgba_dxt1; + break; + case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: + tl->texFormat = &_texformat_rgba_dxt3; + break; + case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: + tl->texFormat = &_texformat_rgba_dxt5; + break; + case GL_COMPRESSED_RGB_FXT1_3DFX: + tl->texFormat = &_texformat_rgb_fxt1; + break; + case GL_COMPRESSED_RGBA_FXT1_3DFX: + tl->texFormat = &_texformat_rgba_fxt1; + break; +#endif default: return; } @@ -2577,6 +2657,66 @@ crStateGetTexGeniv(GLenum coord, GLenum pname, GLint *param) } } +/** + * Return number of bytes needed to store a texture of the given size + * using the specified compressed format. + * + * \param width texture width in texels. + * \param height texture height in texels. + * \param depth texture depth in texels. + * \param internalFormat - compressed image format + * + * \return size in bytes, or zero if bad format + */ +static GLuint +compressedTextureSize( GLsizei width, GLsizei height, GLsizei depth, + GLuint internalFormat ) +{ + GLuint size; + + CRASSERT(depth == 1); + (void) depth; + + switch (internalFormat) { + case GL_COMPRESSED_RGB_FXT1_3DFX: + case GL_COMPRESSED_RGBA_FXT1_3DFX: + /* 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: + /* 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 / 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: + /* round up width, height to next multiple of 4 */ + width = (width + 3) & ~3; + height = (height + 3) & ~3; + /* 16 bytes per 4x4 tile of RGBA texels */ + size = width * height; /* simple! */ + /* Textures smaller than 4x4 will effectively be made into + * 4x4 and take 16 bytes. + */ + return size; + default: + return 0; + } +} void STATE_APIENTRY crStateGetTexLevelParameterfv(GLenum target, GLint level, @@ -2649,11 +2789,11 @@ crStateGetTexLevelParameterfv(GLenum target, GLint level, break; #if CR_ARB_texture_compression case GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB: - *params = (GLfloat) timg->bytes; - break; + *params = (GLfloat) compressedTextureSize ( timg->width, timg->height, timg->depth, timg->internalFormat ); + break; case GL_TEXTURE_COMPRESSED_ARB: - *params = (GLfloat) timg->compressed; - break; + *params = (GLfloat) (compressedTextureSize ( timg->width, timg->height, timg->depth, timg->internalFormat ) != 0); + break; #endif default: crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, @@ -2742,10 +2882,10 @@ crStateGetTexLevelParameteriv(GLenum target, GLint level, #endif #if CR_ARB_texture_compression case GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB: - *params = (GLint) timg->bytes; + *params = (GLint) compressedTextureSize ( timg->width, timg->height, timg->depth, timg->internalFormat ); break; case GL_TEXTURE_COMPRESSED_ARB: - *params = (GLint) timg->compressed; + *params = (GLint) (compressedTextureSize ( timg->width, timg->height, timg->depth, timg->internalFormat ) != 0); break; #endif default: diff --git a/glapi_parser/apiutil.py b/glapi_parser/apiutil.py index 5363589..1418df2 100644 --- a/glapi_parser/apiutil.py +++ b/glapi_parser/apiutil.py @@ -434,18 +434,12 @@ def SetsTrackedState(funcName): # tracker for various reasons: # - because the state tracker doesn't manage display lists # (e.g. CallList and CallLists) - # - because the client doesn't have information about what - # the server supports, so the function has to go to the - # server (e.g. CompressedTexImage calls) # - because they require a round-trip to the server (e.g. # the CopyTexImage calls, SetFenceNV, TrackMatrixNV) if funcName in [ 'CopyTexImage1D', 'CopyTexImage2D', 'CopyTexSubImage1D', 'CopyTexSubImage2D', 'CopyTexSubImage3D', 'CallList', 'CallLists', - 'CompressedTexImage1DARB', 'CompressedTexSubImage1DARB', - 'CompressedTexImage2DARB', 'CompressedTexSubImage2DARB', - 'CompressedTexImage3DARB', 'CompressedTexSubImage3DARB', 'SetFenceNV' ]: return 0
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor