From 157430a3d2d5adccb5117b71727d86775469e174 Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Fri, 26 Mar 2021 13:44:13 +0100 Subject: [PATCH] gpu: [compute] move timer initialization from Collect to Frame GPU operations logically belong in the Frame method, and it's probably best to keep them inside BeginFrame/EndFrame as well. Signed-off-by: Elias Naur --- gpu/compute.go | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/gpu/compute.go b/gpu/compute.go index 11991b10..c4a6ba3e 100644 --- a/gpu/compute.go +++ b/gpu/compute.go @@ -264,16 +264,6 @@ func (g *compute) Collect(viewport image.Point, ops *op.Ops) { for _, img := range g.drawOps.allImageOps { expandPathOp(img.path, img.clip) } - if g.drawOps.profile && g.timers.t == nil && g.ctx.Caps().Features.Has(driver.FeatureTimers) { - t := &g.timers - t.t = newTimers(g.ctx) - t.elements = g.timers.t.newTimer() - t.tileAlloc = g.timers.t.newTimer() - t.pathCoarse = g.timers.t.newTimer() - t.backdropBinning = g.timers.t.newTimer() - t.coarse = g.timers.t.newTimer() - t.kernel4 = g.timers.t.newTimer() - } } func (g *compute) Clear(col color.NRGBA) { @@ -291,6 +281,17 @@ func (g *compute) Frame() error { defFBO := g.ctx.BeginFrame() defer g.ctx.EndFrame() + if g.drawOps.profile && g.timers.t == nil && g.ctx.Caps().Features.Has(driver.FeatureTimers) { + t := &g.timers + t.t = newTimers(g.ctx) + t.elements = g.timers.t.newTimer() + t.tileAlloc = g.timers.t.newTimer() + t.pathCoarse = g.timers.t.newTimer() + t.backdropBinning = g.timers.t.newTimer() + t.coarse = g.timers.t.newTimer() + t.kernel4 = g.timers.t.newTimer() + } + if err := g.encode(viewport); err != nil { return err }