mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-06 18:05:35 +00:00
app/internal/gpu: extract profile in separate method, Profile
Updates #26 Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -25,6 +25,7 @@ type GPU struct {
|
|||||||
pathCache *opCache
|
pathCache *opCache
|
||||||
cache *resourceCache
|
cache *resourceCache
|
||||||
|
|
||||||
|
profile string
|
||||||
timers *timers
|
timers *timers
|
||||||
frameStart time.Time
|
frameStart time.Time
|
||||||
zopsTimer, stencilTimer, coverTimer, cleanupTimer *timer
|
zopsTimer, stencilTimer, coverTimer, cleanupTimer *timer
|
||||||
@@ -304,12 +305,11 @@ func (g *GPU) Frame(viewport image.Point) {
|
|||||||
g.coverTimer.end()
|
g.coverTimer.end()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GPU) EndFrame() string {
|
func (g *GPU) EndFrame() {
|
||||||
g.cleanupTimer.begin()
|
g.cleanupTimer.begin()
|
||||||
g.cache.frame(g.ctx)
|
g.cache.frame(g.ctx)
|
||||||
g.pathCache.frame(g.ctx)
|
g.pathCache.frame(g.ctx)
|
||||||
g.cleanupTimer.end()
|
g.cleanupTimer.end()
|
||||||
var summary string
|
|
||||||
if g.drawOps.profile && g.timers.ready() {
|
if g.drawOps.profile && g.timers.ready() {
|
||||||
zt, st, covt, cleant := g.zopsTimer.Elapsed, g.stencilTimer.Elapsed, g.coverTimer.Elapsed, g.cleanupTimer.Elapsed
|
zt, st, covt, cleant := g.zopsTimer.Elapsed, g.stencilTimer.Elapsed, g.coverTimer.Elapsed, g.cleanupTimer.Elapsed
|
||||||
ft := zt + st + covt + cleant
|
ft := zt + st + covt + cleant
|
||||||
@@ -317,9 +317,12 @@ func (g *GPU) EndFrame() string {
|
|||||||
zt, st, covt = zt.Round(q), st.Round(q), covt.Round(q)
|
zt, st, covt = zt.Round(q), st.Round(q), covt.Round(q)
|
||||||
frameDur := time.Since(g.frameStart).Round(q)
|
frameDur := time.Since(g.frameStart).Round(q)
|
||||||
ft = ft.Round(q)
|
ft = ft.Round(q)
|
||||||
summary = fmt.Sprintf("draw:%7s gpu:%7s zt:%7s st:%7s cov:%7s", frameDur, ft, zt, st, covt)
|
g.profile = fmt.Sprintf("draw:%7s gpu:%7s zt:%7s st:%7s cov:%7s", frameDur, ft, zt, st, covt)
|
||||||
}
|
}
|
||||||
return summary
|
}
|
||||||
|
|
||||||
|
func (g *GPU) Profile() string {
|
||||||
|
return g.profile
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *renderer) texHandle(t *texture) gl.Texture {
|
func (r *renderer) texHandle(t *texture) gl.Texture {
|
||||||
|
|||||||
+5
-4
@@ -31,7 +31,7 @@ type frame struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type frameResult struct {
|
type frameResult struct {
|
||||||
summary string
|
profile string
|
||||||
err error
|
err error
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,7 +86,8 @@ func (l *renderLoop) renderLoop(glctx window.Context) error {
|
|||||||
g.Frame(frame.viewport)
|
g.Frame(frame.viewport)
|
||||||
var res frameResult
|
var res frameResult
|
||||||
res.err = glctx.Present()
|
res.err = glctx.Present()
|
||||||
res.summary = g.EndFrame()
|
g.EndFrame()
|
||||||
|
res.profile = g.Profile()
|
||||||
glctx.Unlock()
|
glctx.Unlock()
|
||||||
l.results <- res
|
l.results <- res
|
||||||
case <-l.stop:
|
case <-l.stop:
|
||||||
@@ -109,8 +110,8 @@ func (l *renderLoop) Flush() error {
|
|||||||
if l.drawing {
|
if l.drawing {
|
||||||
st := <-l.results
|
st := <-l.results
|
||||||
l.setErr(st.err)
|
l.setErr(st.err)
|
||||||
if st.summary != "" {
|
if st.profile != "" {
|
||||||
l.summary = st.summary
|
l.summary = st.profile
|
||||||
}
|
}
|
||||||
l.drawing = false
|
l.drawing = false
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user