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:
Hajime Hoshi 2020-09-21 04:19:26 +09:00
parent 8d17ec837a
commit cb73230301

View File

@ -83,8 +83,8 @@ func (v *verticesBackend) slice(n int, last bool) []float32 {
} }
func vertexSlice(n int, last bool) []float32 { func vertexSlice(n int, last bool) []float32 {
if web.IsGopherJS() { if web.IsBrowser() {
// In GopherJS, allocating memory by make is expensive. Use the backend instead. // In GopherJS and Wasm, allocating memory by make is expensive. Use the backend instead.
return theVerticesBackend.slice(n, last) return theVerticesBackend.slice(n, last)
} }
return make([]float32, n*VertexFloatNum) return make([]float32, n*VertexFloatNum)