app: make CPU timings more useful

Record the time for generating a frame and submitting it as well
as the time for issuing the frame to the GPU and swapping buffers.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2019-11-08 13:29:35 +01:00
parent f6cdc62120
commit 1678f922e7
2 changed files with 11 additions and 18 deletions
+3 -1
View File
@@ -291,6 +291,7 @@ func (g *GPU) renderLoop(glctx gl.Context) error {
g.refreshErr <- glctx.MakeCurrent()
case frame := <-g.frames:
glctx.Lock()
frameStart := time.Now()
if frame.collectStats && timers == nil && ctx.caps.EXT_disjoint_timer_query {
timers = newTimers(ctx)
zopsTimer = timers.newTimer()
@@ -348,8 +349,9 @@ func (g *GPU) renderLoop(glctx gl.Context) error {
ft := zt + st + covt + cleant
q := 100 * time.Microsecond
zt, st, covt = zt.Round(q), st.Round(q), covt.Round(q)
frameDur := time.Since(frameStart).Round(q)
ft = ft.Round(q)
res.summary = fmt.Sprintf("f:%7s zt:%7s st:%7s cov:%7s", ft, zt, st, covt)
res.summary = fmt.Sprintf("draw:%7s gpu:%7s zt:%7s st:%7s cov:%7s", frameDur, ft, zt, st, covt)
}
res.err = err
glctx.Unlock()