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:
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user