ebiten: Add a new log to dump update count

Fixes #1425
This commit is contained in:
Hajime Hoshi 2020-11-24 22:22:45 +09:00
parent 53d7bcda84
commit e7fafb5527
4 changed files with 16 additions and 14 deletions

View File

@ -1,4 +1,4 @@
// Copyright 2018 The Ebiten Authors
// Copyright 2020 The Ebiten Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -14,8 +14,12 @@
// +build ebitendebug
package graphicscommand
package debug
func recordLog() bool {
return true
import (
"fmt"
)
func Logf(format string, args ...interface{}) {
fmt.Printf(format, args...)
}

View File

@ -1,4 +1,4 @@
// Copyright 2018 The Ebiten Authors
// Copyright 2020 The Ebiten Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -14,8 +14,7 @@
// +build !ebitendebug
package graphicscommand
package debug
func recordLog() bool {
return false
func Logf(format string, args ...interface{}) {
}

View File

@ -20,6 +20,7 @@ import (
"strings"
"github.com/hajimehoshi/ebiten/v2/internal/affine"
"github.com/hajimehoshi/ebiten/v2/internal/debug"
"github.com/hajimehoshi/ebiten/v2/internal/driver"
"github.com/hajimehoshi/ebiten/v2/internal/graphics"
"github.com/hajimehoshi/ebiten/v2/internal/shaderir"
@ -214,9 +215,7 @@ func (q *commandQueue) flush() error {
es := q.indices
vs := q.vertices
if recordLog() {
fmt.Println("--")
}
debug.Logf("--\nGraphics commands:\n")
if theGraphicsDriver.HasHighPrecisionFloat() {
n := q.nvertices / graphics.VertexFloatNum
@ -283,9 +282,7 @@ func (q *commandQueue) flush() error {
if err := c.Exec(indexOffset); err != nil {
return err
}
if recordLog() {
fmt.Printf("%s\n", c)
}
debug.Logf(" %s\n", c)
// TODO: indexOffset should be reset if the command type is different
// from the previous one. This fix is needed when another drawing command is
// introduced than drawTrianglesCommand.

View File

@ -22,6 +22,7 @@ import (
"github.com/hajimehoshi/ebiten/v2/internal/buffered"
"github.com/hajimehoshi/ebiten/v2/internal/clock"
"github.com/hajimehoshi/ebiten/v2/internal/debug"
"github.com/hajimehoshi/ebiten/v2/internal/driver"
"github.com/hajimehoshi/ebiten/v2/internal/hooks"
)
@ -161,6 +162,7 @@ func (c *uiContext) update() error {
updateCount = 1
c.updateCalled = true
}
debug.Logf("--\nUpdate count per frame: %d\n", updateCount)
for i := 0; i < updateCount; i++ {
if err := hooks.RunBeforeUpdateHooks(); err != nil {