4 ms·
We don't jump a WASM/JS boundry, the entire game is written in C/C++ - we only jump to JS once at the end of each game frame when it comes time to render, so we
by alexvitkov 3y ago
We don't jump a WASM/JS boundry, the entire game is written in C/C++ - we only jump to JS once at the end of each game frame when it comes time to render, so we do all WebGL calls from JS at once.
What I did was rewrite a chunk of our matrix math library, previously written in C, directly into WASM with the shiny new SIMD operations.
Rewriting a naive 4x4 matrix multiplication with SIMD gains you 3x to 4x on on x86 (with the algorithm from the answer in [1]), and a direct translation of that using the WASM SIMD instructions gains you nothing on Chrome.
On Firefox the WASM SIMD is 20-30% faster than naive multiplication, which is not much, but it's something. The issue is that on Chrome the WASM version is dead even with the scalar implementation, and to be honest I care a lot more about performance on Chrome than on Firefox.
[1] https://codereview.stackexchange.com/questions/101144/simd-matrix-multiplication https://codereview.stackexchange.com/questions/101144/simd-m...
- paulgb 3y ago> the entire game is written in C My apologies, that was clear from your original post but I misread it as saying you were porting into C to use SIMD in Wasm. Thanks for the stats, that's good data to know.