ZeroK-RTS / Zero-K

Open source RTS game running on the Spring/Recoil engine
https://zero-k.info
GNU General Public License v2.0
690 stars 207 forks source link

Fix chobby chili performance. #3588

Open GoogleFrog opened 5 years ago

GoogleFrog commented 5 years ago

Chobby chili is a lot worse than old ZK chili without RTT.

Licho1 commented 5 years ago

how can it be?

GoogleFrog commented 5 years ago

How how?

Chobby and ZK now use an identical version of chili. ZK has a duplicate chili framework that implements the old ZK version (enabled by default, as the performance of the merge is worse). Everything is unreleased at the moment.

In a standard test (200 selected patrolling Ronin zoomed on in Scorpio Battlefield) I found the following results:

The current hack in RTT chili is to turn RTT off for all scrollbars. This is sort of ok for ingame, because the only scrollbars (should) be found in the menu. Opening a menu with RTT enabled puts Chili at around 16% CPU.

I don't expect RTT to work for everyone so we need a compatibility fallback that has decent performance. It would be very encouraging for this fallback rendering mode to have as good performance as the old ZK chili.

gajop commented 5 years ago

Can you test Chili components separately? We might find the culprit easier that way (it might be component specific, e.g. editbox!).

GoogleFrog commented 5 years ago

The difference seems to draw lists. ZK chili uses draw lists. At some point new chili stopped using draw list and then became very confused as to how to translate properly to make draw lists draw at the right offset. Draw lists are completely broken.

GoogleFrog commented 5 years ago

Rendering to texture appears to be a lot slower than recreating a draw list. You can find a significant performance difference between the two chilies by doing the following:

Old chili has climbing CPU usage in this situation, but new chili has a lot more CPU usage and the game noticeably freezes for a fraction of a second on each key press. The load is caused by adding/removing the hotkey from each button.

I fixed a bug that was causing chili to redraw the entirety of a tree when something in that tree changed, instead of only redrawing down one branch. Render to texture may be faster if it fully uses draw lists (instead of not using them at all).