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"); // Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
@ -14,8 +14,12 @@
// +build ebitendebug // +build ebitendebug
package graphicscommand package debug
func recordLog() bool { import (
return true "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"); // Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
@ -14,8 +14,7 @@
// +build !ebitendebug // +build !ebitendebug
package graphicscommand package debug
func recordLog() bool { func Logf(format string, args ...interface{}) {
return false
} }

View File

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

View File

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