In setMatrix() and setMatrix3(), we previously stored the matrix values in a kha float32array just to then allocate a js float32array* view on the kha array on the fly for each function call, which in my tests in Firefox took about 25-30% of the time of setMatrix().
* required by the GL functions
The same problem still exists in setInts() and setFloats(), however, since the size of the user-provided array isn't known beforehand I didn't implement a pre-allocated "cache" in this case. It might make sense though to implement a dynamically-sizing one in the future. Sadly, it doesn't seem to be possible to replace the buffer of a js.lib.Float32Array (it's read only), so we can't just pre-allocate a view object that we dynamically point to the user-provided kha arrays.
As discussed earlier on Discord.
In
setMatrix()
andsetMatrix3()
, we previously stored the matrix values in a kha float32array just to then allocate a js float32array* view on the kha array on the fly for each function call, which in my tests in Firefox took about 25-30% of the time ofsetMatrix()
.* required by the GL functions
The same problem still exists in
setInts()
andsetFloats()
, however, since the size of the user-provided array isn't known beforehand I didn't implement a pre-allocated "cache" in this case. It might make sense though to implement a dynamically-sizing one in the future. Sadly, it doesn't seem to be possible to replace the buffer of ajs.lib.Float32Array
(it's read only), so we can't just pre-allocate a view object that we dynamically point to the user-provided kha arrays.