widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #05297
[Merge] lp:~widelands-dev/widelands/use_image_cache into lp:widelands
The proposal to merge lp:~widelands-dev/widelands/use_image_cache into lp:widelands has been updated.
Commit Message changed to:
- Build a texture atlas with the most commonly used images on startup.
- Mild refactorings in the graphic initialization.
- Add a caching mechanism to remember OpenGL state like bound textures, framebuffers, and so on. Use this to avoid unneeded calls into the driver.
- Combine all different blit programs into one and use a if in the fragment shader. This allows for more batching, taking load from the CPU and transferring it to the GPU.
- Apply suggestion by nha: Recreate buffers on the GPU on each frame instead of trying to reuse the memory.
These are the improvements that this buys: All benchmarks where run at 60 FPS, 3440x1440 resolution & fullscreen, on a map with lots of buildings, lots of textures on the screen, lots of different map objects. The game was paused, so that no logic code ate CPU. Census & statistics were disabled since they do not benefit from the texture atlas at all.
pre renderqueue (revision 7691): ~90% CPU load, 41000 OpenGL calls per frame.
post renderqueue (revision 7695): ~65% CPU load, 18300 OpenGL calls per frame.
This commit: 28% CPU load, 3000 OpenGL calls per frame.
An experimental version that loaded every image in Widelands into one 16kx16k texture atlas (1 GB of GPU RAMs was needed): 18% CPU load, 209 OpenGL calls. This proved unsustainable for most GPUs so it was dropped again.
Worst to best rendering now only takes 32% CPU and 8% GL calls of what it used to.
Possible improvements: The atlas creating could also compress the images by finding unchanging areas in animation. This would drastically reduce the size of the atlas and the use of GPU memory. This is described in bug 1121982. I am not motivated to work on this now though and I only consider it a nice to have.
For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/use_image_cache/+merge/282106
--
Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/full_texture_atlas.
References