- [AI] some fine tuning in the colony management.
- [Render] Added textCacheSize option to the open-ig-config.xml which enables the text rendering cache if not zero. Suggested value is between 1024 and 2048, but requires at least 1GB of memory (set via Xmx or in the launcher). When set, rendering the starmap screen when lots of planets are visible is more efficient.
- Added CTRL+F shortcut to display the times between frames (BF) and in-frames (IF) in milliseconds. The BF indicates the general refresh rate and the IF indicates how much time is spent computing/rendering a particular frame.
Why is the game barely making 30/60 frames per second? It depends on how many rendering instruction is sent to the underlying DirectX/OpenGL adaptor inside Java. There is so much overhead to cross the Java-native boundary that rendering lots of small images (i.e., each letter of a colored text) takes noticeable amount of time. The text rendering cache mentioned above helps by caching the text rendered into one image and reusing it when possible. Even though this takes more data to be trasferred to the GPU, it is far faster because now it uses only 1 instruction to do it instead of 20 or so. With the text rendering cache, the IF value on my machine fell from 12ms to 6ms,
The second pain point is the colony screen. Although you don't see the entire surface, rendering speed is barely 30 frames per second, even lower at sunrise or sunset. One half of the cause is the radar panel. The radar needs to render the entire surface, scaled down, not just the visible part: it practically multiplies the number of rendering instructions. You can see the dramatic effect if you watch the times above (CTRL+F) and toggle the panel. The second cause is the way day-night rendering is implemented. Since Java2D doesn't offer pixel shaders, the rendering needs to create a darkened image of each building and surface tile, then upload it to the GPU. The image generation is super fast, but the upload is really slow: about 200MB image data in the worst case needs to be transferred to the GPU, but since PCIe speed is limited (250/500/1000 MB/s), it can take several hundred milliseconds to do it, which translates to 5-10 frames per second. To help this case, the game offers tile caching for some time now which can be setup outside the game in the Settings / Other... dialog.