Skip to content

Commit

Permalink
graphics: Revive the special allocating method for vertices for Wasm
Browse files Browse the repository at this point in the history
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 hajimehoshi#797
  • Loading branch information
hajimehoshi committed Sep 20, 2020
1 parent 8d17ec8 commit cb73230
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions internal/graphics/vertex.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit cb73230

Please sign in to comment.