mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
graphics: Revive the special allocating method for vertices for Wasm
It looks like the allocation cost is pretty high even on Wasm. Revive the special method not only on GopherJS but also on Wasm. examples/sprites kept 30FPS without this fix, but keeps 35FPS with this fix, on Hajime's MacBook Pro 2020 (macOS Catalina 10.15.6). Updates #797
This commit is contained in:
parent
8d17ec837a
commit
cb73230301
@ -83,8 +83,8 @@ func (v *verticesBackend) slice(n int, last bool) []float32 {
|
||||
}
|
||||
|
||||
func vertexSlice(n int, last bool) []float32 {
|
||||
if web.IsGopherJS() {
|
||||
// In GopherJS, allocating memory by make is expensive. Use the backend instead.
|
||||
if web.IsBrowser() {
|
||||
// In GopherJS and Wasm, allocating memory by make is expensive. Use the backend instead.
|
||||
return theVerticesBackend.slice(n, last)
|
||||
}
|
||||
return make([]float32, n*VertexFloatNum)
|
||||
|
Loading…
Reference in New Issue
Block a user