Used a faster method for checking for power of 2 on the image dimensions and
did a check on forcing 16bits textures in osg::Texture (which speeds things up on the Umea model which is performance bound by texture memory.), the later check is now commented out.
This commit is contained in:
@@ -309,13 +309,31 @@ void Image::scaleImage(const int s,const int t,const int r)
|
||||
|
||||
void Image::ensureDimensionsArePowerOfTwo()
|
||||
{
|
||||
float sp2 = logf((float)_s)/logf(2.0f);
|
||||
float rounded_sp2 = floorf(sp2+0.5f);
|
||||
int new_s = (int)(powf(2.0f,rounded_sp2));
|
||||
int new_s = _s;
|
||||
int new_t = _t;
|
||||
|
||||
// check if _s is a power of 2 already.
|
||||
if ((_s & (_s-1))!=0)
|
||||
{
|
||||
// it isn't so lets find the closest power of two.
|
||||
// yes, logf and powf are slow, but this code should
|
||||
// only be called during scene graph initilization,
|
||||
// if at all, so not critical in the greater scheme.
|
||||
float p2 = logf((float)_s)/logf(2.0f);
|
||||
float rounded_p2 = floorf(p2+0.5f);
|
||||
new_s = (int)(powf(2.0f,rounded_p2));
|
||||
}
|
||||
|
||||
float tp2 = logf((float)_t)/logf(2.0f);
|
||||
float rounded_tp2 = floorf(tp2+0.5f);
|
||||
int new_t = (int)(powf(2.0f,rounded_tp2));
|
||||
if ((_t & (_t-1))!=0)
|
||||
{
|
||||
// it isn't so lets find the closest power of two.
|
||||
// yes, logf and powf are slow, but this code should
|
||||
// only be called during scene graph initilization,
|
||||
// if at all, so not critical in the greater scheme.
|
||||
float p2 = logf((float)_t)/logf(2.0f);
|
||||
float rounded_p2 = floorf(p2+0.5f);
|
||||
new_t = (int)(powf(2.0f,rounded_p2));
|
||||
}
|
||||
|
||||
static GLint max_size=256;
|
||||
|
||||
|
||||
@@ -416,6 +416,11 @@ void Texture::applyTexImage(GLenum target, Image* image, State& state) const
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
// an experiment to look at the changes in performance
|
||||
// when use 16 bit textures rather than 24/32bit textures.
|
||||
// internalFormat = GL_RGBA4;
|
||||
|
||||
|
||||
if (_subloadMode == OFF) {
|
||||
if( _min_filter == LINEAR || _min_filter == NEAREST )
|
||||
|
||||
Reference in New Issue
Block a user