segmented render time display

This commit is contained in:
2022-02-22 14:28:35 +08:00
parent e2717aaaa9
commit 3595c32ae5
3 changed files with 63 additions and 3 deletions

View File

@ -12,12 +12,35 @@ import (
"github.com/inkyblackness/imgui-go/v4"
)
const (
timebarN = 700
timebarScale = 160
)
var (
colorset = [...]imgui.PackedColor{4289753676, 4283598045, 4285048917, 4283584196, 4289950337, 4284512403, 4291005402, 4287401100, 4285839820, 4291671396}
timebars [timebarN][]int // height of each bar set
timebari int
)
func (r *WorldRenderer) renderDebugInfo() {
// Render information
if igwrap.Begin("F3", nil, 0) {
igwrap.TextBlank()
igwrap.TextBackground("WorldRender: lastframe %.3fms", float64(io.Diagnostics.Times.Render.Nanoseconds())/float64(time.Millisecond))
igwrap.TextBackground("TimeBars:")
pad := igwrap.Vec2f(imgui.CurrentStyle().ItemSpacing())
imgui.SameLine()
igwrap.TextBackgroundV(colorset[0], pad, "Depthmap")
imgui.SameLine()
igwrap.TextBackgroundV(colorset[1], pad, "Geometry")
imgui.SameLine()
igwrap.TextBackgroundV(colorset[2], pad, "SSAO")
imgui.SameLine()
igwrap.TextBackgroundV(colorset[3], pad, "Lighting")
imgui.SameLine()
igwrap.TextBackgroundV(colorset[4], pad, "Postfx")
isize := asset.WorldTextureAtlas.ImageSize
igwrap.TextBackground("Texture Atlas Size: (%dx%d)", isize[0], isize[1])
@ -36,6 +59,7 @@ func (r *WorldRenderer) renderDebugInfo() {
imgui.End()
}
// Draw Textures
imgui.SetNextWindowPosV(imgui.Vec2{X: float32(r.lastDisplaySize[0]), Y: 0}, imgui.ConditionAlways, imgui.Vec2{X: 1, Y: 0})
if igwrap.Begin("Renderer Textures/Outputs", nil, igwrap.WindowFlagsOverlay) {
imgui.PushStyleVarVec2(imgui.StyleVarItemSpacing, imgui.Vec2{})
@ -53,4 +77,27 @@ func (r *WorldRenderer) renderDebugInfo() {
imgui.End()
}
// Push the next bar
timebars[timebari] = []int{
int(io.Diagnostics.Times.RenderPasses.Depthmap.Nanoseconds() * timebarScale / 1000 / 1000),
int(io.Diagnostics.Times.RenderPasses.Geometry.Nanoseconds() * timebarScale / 1000 / 1000),
int(io.Diagnostics.Times.RenderPasses.SSAO.Nanoseconds() * timebarScale / 1000 / 1000),
int(io.Diagnostics.Times.RenderPasses.Lighting.Nanoseconds() * timebarScale / 1000 / 1000),
int(io.Diagnostics.Times.RenderPasses.Postfx.Nanoseconds() * timebarScale / 1000 / 1000),
}
timebari++
if timebari >= len(timebars) {
timebari = 0
}
// Draw time bars
size := r.lastDisplaySize
dl := imgui.BackgroundDrawList()
for i, l := range timebars {
ex := 0
for j, d := range l {
dl.AddLine(imgui.Vec2{X: float32(i), Y: float32(size[1] - ex - 1)}, imgui.Vec2{X: float32(i), Y: float32(size[1] - ex - d)}, colorset[j])
ex += d
}
}
}