DDS/Mipmap texture performance problem/bug found + ev. patch

Hi all,



While trying to optimize my animated multi mesh part models I stumbled over a bug concerning mipmaps. I loaded a model with one of my dds textures and it showed a framerate of 45 fps. Loading the same model and using a png file gve me 750 fps. So after profiling I found that 95% of the time went into TextureUtil.uploadTexture(). It is caused by the Image class which when on construction is passed mipmaps it does not reset the flags for mipmap generation.

needGeneratedMips = false;

mipsWereGenerated = true;

You should be able to see some decent performance degration when using just one big texture with many mipmap levels (I had a 1024x1024 with all 11 mips).



this was the patch used on my side:



Index: src/core/com/jme3/texture/Image.java

===================================================================

— src/core/com/jme3/texture/Image.java (revision 9654)

+++ src/core/com/jme3/texture/Image.java (working copy)

@@ -433,6 +433,9 @@



if (mipMapSizes != null && mipMapSizes.length <= 1) {

mipMapSizes = null;

  •    } else {<br />
    
  •    	needGeneratedMips = false;<br />
    
  •    	mipsWereGenerated = true;<br />
    

}



setFormat(format);

@@ -465,6 +468,9 @@



if (mipMapSizes != null && mipMapSizes.length <= 1) {

mipMapSizes = null;

  •    } else {<br />
    
  •    	needGeneratedMips = false;<br />
    
  •    	mipsWereGenerated = true;<br />
    

}



setFormat(format);

3 Likes

Thanks, the patch was applied. I also added the fix to the setMipMapSizes() and read() methods.