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 for the GPU that Widelands is using. The atlas is 
cached in ~/.widelands/cache for the current build_id() and deleted and rebuild 
if the build_id() does not match. If the atlas is already available on disk, it 
is loaded directly after the graphics system is initialized. This makes startup 
slightly slower.
- Show a text while the graphics are loaded or the atlas is build. This 
required 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 with a texture atlas of 2048x2048 (worst performance): 28% CPU 
load, 3000 OpenGL calls per frame.
This commit with a texture altas of 16384x16384 (best performance): 18% CPU 
load, 209 OpenGL calls.

Worst to best rendering now only takes 20% CPU and 0.5% GL calls of what it 
used to. There is no stutter due to image loading during play anymore, but 
startup is slower and there is a one time cost of building the atlas.

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. 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 requested to review the proposed merge of 
lp:~widelands-dev/widelands/use_image_cache into lp:widelands.

_______________________________________________
Mailing list: https://launchpad.net/~widelands-dev
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~widelands-dev
More help   : https://help.launchpad.net/ListHelp

Reply via email to