PDA

View Full Version : (GL3.2) glGenerateMipmap is super slow on HD4670



somboon
04-18-2010, 11:04 PM
this is the code I use to initialize texture for my OpenGL 3.2 code (Please ignore the DevIL bits)




void OGLTextureLoader::loadTexture(char* filename,GLuint* textureID){

ILuint ImageName;

ilEnable(IL_ORIGIN_SET);
ilOriginFunc(IL_ORIGIN_LOWER_LEFT);
ilGenImages(1, &ImageName);
ilBindImage(ImageName);
ilLoadImage(filename);

glGenTextures(1,textureID);
glBindTexture(GL_TEXTURE_2D,*textureID);

if(ilGetInteger(IL_IMAGE_BITS_PER_PIXEL) == 32){
//glTexImage2D(GL_TEXTURE_2D, 0,GL_COMPRESSED_RGBA_S3TC_DXT5_EXT,ilGetInteger(IL _IMAGE_WIDTH),ilGetInteger(IL_IMAGE_HEIGHT),0, GL_RGBA, GL_UNSIGNED_BYTE,ilGetData());
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,ilGetInteger(IL_IMAGE_WIDTH),ilGetInteger( IL_IMAGE_HEIGHT),0, GL_RGBA, GL_UNSIGNED_BYTE,ilGetData());
}
else if(ilGetInteger(IL_IMAGE_BITS_PER_PIXEL) == 24){
//glTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB_S3TC_DXT1_EXT,ilGetInteger(IL_IM AGE_WIDTH),ilGetInteger(IL_IMAGE_HEIGHT),0, GL_RGB, GL_UNSIGNED_BYTE,ilGetData());
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB,ilGetInteger(IL_IMAGE_WIDTH),ilGetInteger(I L_IMAGE_HEIGHT),0, GL_RGB, GL_UNSIGNED_BYTE,ilGetData());
}

glGenerateMipmap(GL_TEXTURE_2D);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT,16);

ilDeleteImages(1, &ImageName);

glBindTexture(GL_TEXTURE_2D,0);

}



the code run very fast on NVIDIA 9800gt and only take 1.5 ~ 2 second to load 20 of 2048*2048 texture.

but on my ATI4670 card the same code run very slow it took 25 second to load the same set of texture .

It look like the problem are glGenerateMipmap.

if I comment out glGenerateMipmap and change MIN_FILTER to linear/nearest the texture initialization are very fast (less than 2 second) but the texture look very ugly(shimmering when view from distance).

please somebody give me an advice about generating mipmap that work well with both card.

Alfonse Reinheart
04-19-2010, 12:08 AM
You may want to try calling glGenerateMipmap after setting the texture parameters. It might make a difference.

somboon
04-19-2010, 12:35 AM
calling glGenerateMipmap after glTexParameter has the same performance (slow).

and I just noticed that the texture quality when using mipmap on HD4670 is really bad (compare to 9800GT) even when viewing upclose (it look like it use some of the lowres mipmap instead of the hires one).


Are there any parameter I need to supply before calling glGenerateMipmap ?

I also noticed that quality of mipmap in ATI control panel are set to "highest quality" but try to reduced it to "performance" didn't help the loading time.