From Michael Platings, "On nvidia cards mipmap generation for non-power-of-two textures with

GL_GENERATE_MIPMAP_SGIS is very slow (over half a second for a 720*576
texture). However, glGenerateMipmapEXT() performs well (16ms for the
same texture), so I have modified the attached files to use
Texture::generateMipmap() if glGenerateMipmapEXT is supported, instead
of enabling & disabling GL_GENERATE_MIPMAP_SGIS."

Notes, from Robert Osfield, I've tested the out of the previous path using
GL_GENERATE_MIPMAP_SGIS and non power of two textures on NVidia 7800GT and
Nvidia linux drivers with the image size 720x576 and only get compile times
of 56ms, so the above half second speed looks to be a driver bug.  With
Muchael's changes the cost goes done to less than 5ms, so it's certainly 
an effective change, even given that Michael's poor expereiences with
GL_GENERATE_MIP_SGIS do look to be a driver bug.
This commit is contained in:
Robert Osfield
2008-05-28 11:19:41 +00:00
parent 20f3e74643
commit 8677c4d6d6
4 changed files with 111 additions and 46 deletions

View File

@@ -719,7 +719,25 @@ class OSG_EXPORT Texture : public osg::StateAttribute
/** Helper method. Sets texture parameters. */
void applyTexParameters(GLenum target, State& state) const;
/** Helper method to generate empty mipmap levels by calling of glGenerateMipmapEXT.
/** Returns true if _useHardwareMipMapGeneration is true and either
* glGenerateMipmapEXT() or GL_GENERATE_MIPMAP_SGIS are supported. */
bool isHardwareMipmapGenerationEnabled(const State& state) const;
/** Returned by mipmapBeforeTexImage() to indicate what
* mipmapAfterTexImage() should do */
enum GenerateMipmapMode
{
GENERATE_MIPMAP_NONE,
GENERATE_MIPMAP,
GENERATE_MIPMAP_TEX_PARAMETER
};
/** Helper methods to be called before and after calling
* gl[Compressed][Copy]Tex[Sub]Image2D to handle generating mipmaps. */
GenerateMipmapMode mipmapBeforeTexImage(const State& state, bool hardwareMipmapOn) const;
void mipmapAfterTexImage(State& state, GenerateMipmapMode beforeResult) const;
/** Helper method to generate mipmap levels by calling of glGenerateMipmapEXT.
* If it is not supported, then call the virtual allocateMipmap() method */
void generateMipmap(State& state) const;