Merge: gamnit: cache each camera matrix and avoid boxing floats in matrix operations
authorJean Privat <jean@pryen.org>
Wed, 10 May 2017 13:20:47 +0000 (09:20 -0400)
committerJean Privat <jean@pryen.org>
Wed, 10 May 2017 13:20:47 +0000 (09:20 -0400)
Optimize the gamnit framework to avoid excessive garbage collection and a general speedup.

Replace the use of a generic `Array[E]` to implement matrices of floats, as it caused the boxing of each floats at each access. The new custom extern class does not suffer from the boxing and allow for some optimization in C code. This structure is allocated in the Nit GC (hackishly), and doesn't need an explicit liberation. A limitation of the current solution is about the size of the floating points in C, `matrix` uses doubles and `glesv2` floats, the data is copied and cast in C code, this could be optimized further as needed.

Caching each camera matrix avoids recreating them at each frame, which was quite costly, especially for the UI camera that rarely moves. The caching logic is implemented as a distinct class allowing easy debugging.

Pull-Request: #2428
Reviewed-by: Jean Privat <jean@pryen.org>

1  2 
lib/gamnit/flat.nit

Simple merge