We have textures that are dynamically updated. Some of them require us to use BILINEAR_SAMPLINGMODE instead of the default TRILINEAR_SAMPLINGMODE
In order to make sure we have everything looking correct, we loop through all textures and reset to TRILINEAR_SAMPLINGMODE
This appears to have caused a large slowdown when applied to many textures.
Am I right that this is an expensive operation here?
I thought that it would not affect anything to reset the sampling mode but looking at this it appears that there are a lot of potential operations that could be happening. Any advice or best practices?
The slow part is line 3522 which generates mipmaps. This function is mainly only used internally and should probably not be used if your mip chain and so on is already ok. Why not relying on the texture function itself which would be safer as this one assumes the texture has been bound and so on.
Also adding @Evgeni_Popov as I ll be in vacation for a bit
The ThinTexture.updateSamplingMode method is calling Engine.updateTextureSamplingMode with false as the generateMipMaps parameter, so calling the function should not take that long…
Looking at our code, it appeared that the third param in generating textures was set to false. That refers to noMipmaps which throwing us. In that case, I believe that we were in fact generating mipmaps.
On this, we using the texture object to do the updates, but for specific textures which looked off with the default sampling mode, we are calling texture.updateSamplingMode(Texture.TRILINEAR_SAMPLINGMODE)
I believe that if the texture is created with generateMipmaps then any update to the sampling mode will also generate new mipmaps?
No, as you can see in the code above. The fact the mipmaps should be generated is taken care somewhere else, not in updateTextureSamplingMode.
As I understand it, allowing to generate the mipmaps in updateTextureSamplingMode does not make a lot of sense to me: the texture sampling mode of a texture does not impact the way the mipmaps are generated, so regenerating them after changing the sampling mode is a null (identity) operation, the mipmaps will remain the same (if they already exist). I think it’s simply a facility for the HDRFiltering class to request generating the mipmaps after having created a texture.