PDA

View Full Version : Texture compression, mipmapping and ATI



abrodersen
12-04-2002, 05:35 AM
Hi.

I am experiencing some odd problems with different ATI cards: The second time I set the image data of a texture (using glTexImage2D) and texture compression is used together with automatic mipmap generation, the texture becomes all white!

It doesn't happen the first time I set it, nor does it happen if either texture compression or automatic mipmapping is disabled, or if the size of the new texture is unchanged.

So far I have tried with 3 different ATI cards (2x mobility and one 9700), and different driver versions, each time with the same result. I've also tried with several different nVidia cards (TNT2, GF1, GF2, GF3, GF4 and GF2Go), without experiencing any problems.

So my question is, am I doing something wrong, which for some reason is accepted on nVidia cards, or is this a bug in ATI's drivers?

The code below shows the problem.




glBindTexture( GL_TEXTURE_2D, TexId);
glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS, true);
glTexImage2D( GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA, 64, 64, 0, GL_RGB, GL_UNSIGNED_BYTE, data );
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, 128, 128, 0, GL_RGB, GL_UNSIGNED_BYTE, data );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
GLenum err = glGetError();
if(err)
{
printf("OpenGl Error: %s\n", gluErrorString(err));
}


Please note that no error is printed!

Any suggestions? Do I really have to delete the texture and recreate it to change it's size?

Thanks.
Anders

P.S. The reason I want to change the texture size is LOD. Most of my textures are huge (1024x1024x32 or 2048x2048x32), but most of the time I only need one or two of them at full resolution (determined at runtime). So initially I only load thumbnails, and then change the size of the textures when I need the higher resolution.

[This message has been edited by abrodersen (edited 12-04-2002).]

PH
12-04-2002, 05:51 AM
Automatic mipmap generation with compressed textures is broken in the 7.78 ATI drivers and fixed in 7.79. I think the ATI driver incorrectly calculates the size of compressed textures as I'm having a texture corruption problem when using copy-to-texture-rectangle ( non-compressed ) when other textures are compressed.

jwatte
12-04-2002, 09:09 PM
Note that your code immediately smashes the compressed texture data by reallocating the texture as uncompressed:




glTexImage2D( GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA, 64, 64, 0, GL_RGB, GL_UNSIGNED_BYTE, data );
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, 128, 128, 0, GL_RGB, GL_UNSIGNED_BYTE, data );

zeckensack
12-04-2002, 10:35 PM
I guess that's the purpose of this excercise ...
Still looks like completely valid code.

abrodersen
12-05-2002, 01:51 AM
Originally posted by jwatte:
Note that your code immediately smashes the compressed texture data by reallocating the texture as uncompressed:




glTexImage2D( GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA, 64, 64, 0, GL_RGB, GL_UNSIGNED_BYTE, data );
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, 128, 128, 0, GL_RGB, GL_UNSIGNED_BYTE, data );



Oops. That's actually a typo. It should have been compressed both times:



glTexImage2D( GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA, 64, 64, 0, GL_RGB, GL_UNSIGNED_BYTE, data );
glTexImage2D( GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA, 128, 128, 0, GL_RGB, GL_UNSIGNED_BYTE, data );

Doesn't change anything though. I've tried different combinations. If both calls to glTexImage2D are asking for non compressed internal format, it works fine. However if one or both calls requests compressed internal format, I get an all white texture.

Anders