mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-05 09:25:38 +00:00
gpu: Merge GPU.Collect and GPU.Frame
There's no meaningful reason to have them separate. The intention was to enable rendering concurrent with other processing, but that's gaining framerate at the expense of input latency and complicating ImageOp semantics. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
+7
-2
@@ -559,7 +559,12 @@ func newShaders(ctx driver.Device, vsrc, fsrc shader.Sources) (vert driver.Verte
|
||||
return
|
||||
}
|
||||
|
||||
func (g *compute) Collect(viewport image.Point, ops *op.Ops) {
|
||||
func (g *compute) Frame(frameOps *op.Ops, target RenderTarget, viewport image.Point) error {
|
||||
g.collect(viewport, frameOps)
|
||||
return g.frame(target)
|
||||
}
|
||||
|
||||
func (g *compute) collect(viewport image.Point, ops *op.Ops) {
|
||||
g.viewport = viewport
|
||||
g.collector.reset()
|
||||
for i := range g.output.layerAtlases {
|
||||
@@ -575,7 +580,7 @@ func (g *compute) Clear(col color.NRGBA) {
|
||||
g.collector.clearColor = f32color.LinearFromSRGB(col)
|
||||
}
|
||||
|
||||
func (g *compute) Frame(target RenderTarget) error {
|
||||
func (g *compute) frame(target RenderTarget) error {
|
||||
viewport := g.viewport
|
||||
defFBO := g.ctx.BeginFrame(target, g.collector.clear, viewport)
|
||||
defer g.ctx.EndFrame()
|
||||
|
||||
+10
-7
@@ -43,12 +43,10 @@ type GPU interface {
|
||||
Release()
|
||||
// Clear sets the clear color for the next Frame.
|
||||
Clear(color color.NRGBA)
|
||||
// Collect the graphics operations from frame, given the viewport.
|
||||
Collect(viewport image.Point, frame *op.Ops)
|
||||
// Frame draws the collected operations to target.
|
||||
Frame(target RenderTarget) error
|
||||
// Frame draws the graphics operations from op into a viewport of target.
|
||||
Frame(frame *op.Ops, target RenderTarget, viewport image.Point) error
|
||||
// Profile returns the last available profiling information. Profiling
|
||||
// information is requested when Collect sees an io/profile.Op, and the result
|
||||
// information is requested when Frame sees an io/profile.Op, and the result
|
||||
// is available through Profile at some later time.
|
||||
Profile() string
|
||||
}
|
||||
@@ -399,7 +397,12 @@ func (g *gpu) Release() {
|
||||
g.ctx.Release()
|
||||
}
|
||||
|
||||
func (g *gpu) Collect(viewport image.Point, frameOps *op.Ops) {
|
||||
func (g *gpu) Frame(frameOps *op.Ops, target RenderTarget, viewport image.Point) error {
|
||||
g.collect(viewport, frameOps)
|
||||
return g.frame(target)
|
||||
}
|
||||
|
||||
func (g *gpu) collect(viewport image.Point, frameOps *op.Ops) {
|
||||
g.renderer.blitter.viewport = viewport
|
||||
g.renderer.pather.viewport = viewport
|
||||
g.drawOps.reset(g.cache, viewport)
|
||||
@@ -413,7 +416,7 @@ func (g *gpu) Collect(viewport image.Point, frameOps *op.Ops) {
|
||||
}
|
||||
}
|
||||
|
||||
func (g *gpu) Frame(target RenderTarget) error {
|
||||
func (g *gpu) frame(target RenderTarget) error {
|
||||
viewport := g.renderer.blitter.viewport
|
||||
defFBO := g.ctx.BeginFrame(target, g.drawOps.clear, viewport)
|
||||
defer g.ctx.EndFrame()
|
||||
|
||||
@@ -109,8 +109,7 @@ func (w *Window) Release() {
|
||||
func (w *Window) Frame(frame *op.Ops) error {
|
||||
return contextDo(w.ctx, func() error {
|
||||
w.gpu.Clear(color.NRGBA{})
|
||||
w.gpu.Collect(w.size, frame)
|
||||
return w.gpu.Frame(driver.RenderTarget(w.fbo))
|
||||
return w.gpu.Frame(frame, driver.RenderTarget(w.fbo), w.size)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user