Merge: gamnit: performance improvements for Dawn Arrival
authorJean Privat <jean@pryen.org>
Tue, 27 Jun 2017 13:16:52 +0000 (09:16 -0400)
committerJean Privat <jean@pryen.org>
Tue, 27 Jun 2017 13:16:52 +0000 (09:16 -0400)
This PR applies a few tweaks to optimize performances of the 2D API:

* Each sprite now caches its index in the GPU buffers, replacing the use of `index_of`. This one has the largest performance gain, especially when there is a large number of sprites using the same texture.
* Cache the last sprite on which was called `needs_update` to avoid double or triple adding it to the set of sprites to update on the GPU. This provides a small but notable gain as when a sprite's X and Y coordinates are modified, it was added twice to the set.
* Use a boolean flag instead of the set `sprites_to_update` when all sprite must be updated after a buffer resize.

These changes were tested on [Dawn Arrival](https://gitlab.com/jeremlvt/dawn_arrival) and they cut about 25-50% of the computing time.

Pull-Request: #2513


Trivial merge