diff --git a/internal/graphicsdriver/opengl/context_desktop.go b/internal/graphicsdriver/opengl/context_desktop.go index 1aee657fe..7e518c2e9 100644 --- a/internal/graphicsdriver/opengl/context_desktop.go +++ b/internal/graphicsdriver/opengl/context_desktop.go @@ -418,7 +418,9 @@ func (c *context) uniformFloats(p program, location string, v []float32, typ sha case shaderir.Mat4: gl.UniformMatrix4fv(l, len, false, (*float32)(gl.Ptr(v))) default: - panic(fmt.Sprintf("opengl: unexpected type: %s", typ.String())) + // Copy shaderir.Type value to avoid heap allocation of typ. + t := typ + panic(fmt.Sprintf("opengl: unexpected type: %s", t.String())) } return true } diff --git a/internal/graphicsdriver/opengl/context_mobile.go b/internal/graphicsdriver/opengl/context_mobile.go index e74aa6fdf..74cbdbfbf 100644 --- a/internal/graphicsdriver/opengl/context_mobile.go +++ b/internal/graphicsdriver/opengl/context_mobile.go @@ -384,7 +384,9 @@ func (c *context) uniformFloats(p program, location string, v []float32, typ sha case shaderir.Mat4: c.ctx.UniformMatrix4fv(int32(l), false, v) default: - panic(fmt.Sprintf("opengl: unexpected type: %s", typ.String())) + // Copy shaderir.Type value to avoid heap allocation of typ. + t := typ + panic(fmt.Sprintf("opengl: unexpected type: %s", t.String())) } return true }