mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-14 23:17:27 +01:00
internal/graphicscommand: add a first-caller information
This commit is contained in:
parent
e40e699718
commit
39c21bf4a6
@ -69,6 +69,7 @@ type drawTrianglesCommand struct {
|
|||||||
shader *Shader
|
shader *Shader
|
||||||
uniforms []uint32
|
uniforms []uint32
|
||||||
fillRule graphicsdriver.FillRule
|
fillRule graphicsdriver.FillRule
|
||||||
|
firstCaller string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *drawTrianglesCommand) String() string {
|
func (c *drawTrianglesCommand) String() string {
|
||||||
@ -116,7 +117,11 @@ func (c *drawTrianglesCommand) String() string {
|
|||||||
shader += " (" + c.shader.name + ")"
|
shader += " (" + c.shader.name + ")"
|
||||||
}
|
}
|
||||||
|
|
||||||
return fmt.Sprintf("draw-triangles: dst: %s <- src: [%s], num of dst regions: %d, num of indices: %d, blend: %s, fill rule: %s, shader: %s", dst, strings.Join(srcstrs[:], ", "), len(c.dstRegions), c.numIndices(), blend, c.fillRule, shader)
|
str := fmt.Sprintf("draw-triangles: dst: %s <- src: [%s], num of dst regions: %d, num of indices: %d, blend: %s, fill rule: %s, shader: %s", dst, strings.Join(srcstrs[:], ", "), len(c.dstRegions), c.numIndices(), blend, c.fillRule, shader)
|
||||||
|
if c.firstCaller != "" {
|
||||||
|
str += "\n first-caller: " + c.firstCaller
|
||||||
|
}
|
||||||
|
return str
|
||||||
}
|
}
|
||||||
|
|
||||||
// Exec executes the drawTrianglesCommand.
|
// Exec executes the drawTrianglesCommand.
|
||||||
|
@ -18,6 +18,8 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"image"
|
"image"
|
||||||
"math"
|
"math"
|
||||||
|
"runtime"
|
||||||
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
|
|
||||||
@ -162,6 +164,23 @@ func (q *commandQueue) EnqueueDrawTrianglesCommand(dst *Image, srcs [graphics.Sh
|
|||||||
c.shader = shader
|
c.shader = shader
|
||||||
c.uniforms = uniforms
|
c.uniforms = uniforms
|
||||||
c.fillRule = fillRule
|
c.fillRule = fillRule
|
||||||
|
if debug.IsDebug {
|
||||||
|
// Get the root caller of this function.
|
||||||
|
// Relying on a caller stacktrace is very fragile, but this is fine as this is only for debugging.
|
||||||
|
for i := 0; ; i++ {
|
||||||
|
_, file, _, ok := runtime.Caller(i)
|
||||||
|
if !ok {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
if !strings.HasSuffix(file, "/ebiten/image.go") {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if _, file, line, ok := runtime.Caller(i + 1); ok {
|
||||||
|
c.firstCaller = fmt.Sprintf("%s:%d", file, line)
|
||||||
|
}
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
q.commands = append(q.commands, c)
|
q.commands = append(q.commands, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -294,7 +313,15 @@ func (q *commandQueue) flush(graphicsDriver graphicsdriver.Graphics, endFrame bo
|
|||||||
if err := c.Exec(q, graphicsDriver, indexOffset); err != nil {
|
if err := c.Exec(q, graphicsDriver, indexOffset); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
logger.FrameLogf(" %s\n", c)
|
str := c.String()
|
||||||
|
for {
|
||||||
|
head, tail, ok := strings.Cut(str, "\n")
|
||||||
|
logger.FrameLogf(" %s\n", head)
|
||||||
|
if !ok {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
str = tail
|
||||||
|
}
|
||||||
// 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.
|
||||||
|
Loading…
Reference in New Issue
Block a user