From Fabien Lavignotte, "I use Texture2D::copyTexImage2D to generate some textures at each frame on a PagedLOD databases.
There was some performance problems after a long run, because textures created with copyTexImage2D were not reused. After investigation, there is a problem with the Texture Pool when a texture object is created with an empty profile, and then move after creation to TextureObjectSet with good profile using setAllocated method. I have just changed a little bit the code of Texture2D::copyTexImage2D, to generate the texture object with the good profile at the start."
This commit is contained in:
parent
9c0e56d7a0
commit
78b15f8e17
@ -337,12 +337,6 @@ void Texture2D::copyTexImage2D(State& state, int x, int y, int width, int height
|
|||||||
|
|
||||||
// switch off mip-mapping.
|
// switch off mip-mapping.
|
||||||
//
|
//
|
||||||
_textureObjectBuffer[contextID] = textureObject = generateTextureObject(this, contextID,GL_TEXTURE_2D);
|
|
||||||
|
|
||||||
textureObject->bind();
|
|
||||||
|
|
||||||
applyTexParameters(GL_TEXTURE_2D,state);
|
|
||||||
|
|
||||||
|
|
||||||
bool needHardwareMipMap = (_min_filter != LINEAR && _min_filter != NEAREST);
|
bool needHardwareMipMap = (_min_filter != LINEAR && _min_filter != NEAREST);
|
||||||
bool hardwareMipMapOn = false;
|
bool hardwareMipMapOn = false;
|
||||||
@ -358,12 +352,6 @@ void Texture2D::copyTexImage2D(State& state, int x, int y, int width, int height
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GenerateMipmapMode mipmapResult = mipmapBeforeTexImage(state, hardwareMipMapOn);
|
|
||||||
|
|
||||||
glCopyTexImage2D( GL_TEXTURE_2D, 0, _internalFormat, x, y, width, height, 0 );
|
|
||||||
|
|
||||||
mipmapAfterTexImage(state, mipmapResult);
|
|
||||||
|
|
||||||
_textureWidth = width;
|
_textureWidth = width;
|
||||||
_textureHeight = height;
|
_textureHeight = height;
|
||||||
|
|
||||||
@ -373,7 +361,20 @@ void Texture2D::copyTexImage2D(State& state, int x, int y, int width, int height
|
|||||||
for(int s=1; s<width || s<height; s <<= 1, ++_numMipmapLevels) {}
|
for(int s=1; s<width || s<height; s <<= 1, ++_numMipmapLevels) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
textureObject->setAllocated(_numMipmapLevels,_internalFormat,_textureWidth,_textureHeight,1,0);
|
_textureObjectBuffer[contextID] = textureObject = generateTextureObject(this, contextID,GL_TEXTURE_2D,_numMipmapLevels,_internalFormat,_textureWidth,_textureHeight,1,0);
|
||||||
|
|
||||||
|
textureObject->bind();
|
||||||
|
|
||||||
|
applyTexParameters(GL_TEXTURE_2D,state);
|
||||||
|
|
||||||
|
|
||||||
|
GenerateMipmapMode mipmapResult = mipmapBeforeTexImage(state, hardwareMipMapOn);
|
||||||
|
|
||||||
|
glCopyTexImage2D( GL_TEXTURE_2D, 0, _internalFormat, x, y, width, height, 0 );
|
||||||
|
|
||||||
|
mipmapAfterTexImage(state, mipmapResult);
|
||||||
|
|
||||||
|
textureObject->setAllocated(true);
|
||||||
|
|
||||||
// inform state that this texture is the current one bound.
|
// inform state that this texture is the current one bound.
|
||||||
state.haveAppliedTextureAttribute(state.getActiveTextureUnit(), this);
|
state.haveAppliedTextureAttribute(state.getActiveTextureUnit(), this);
|
||||||
|
Loading…
Reference in New Issue
Block a user