gpu: make GPU an interface to prepare for second implementation

While here, merge BeginFrame and EndFrame; the split was done for
performance reasons, yet never measured.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2020-12-30 18:02:18 +01:00
parent b1ff179aa0
commit 6f2a98c667
3 changed files with 33 additions and 18 deletions
+2 -4
View File
@@ -18,7 +18,7 @@ type Window struct {
size image.Point
ctx context
backend backend.Device
gpu *gpu.GPU
gpu gpu.GPU
fboTex backend.Texture
fbo backend.Framebuffer
}
@@ -109,9 +109,7 @@ func (w *Window) Release() {
func (w *Window) Frame(frame *op.Ops) error {
return contextDo(w.ctx, func() error {
w.gpu.Collect(w.size, frame)
w.gpu.BeginFrame()
w.gpu.EndFrame()
return nil
return w.gpu.Frame()
})
}
+4 -3
View File
@@ -88,10 +88,11 @@ func (l *renderLoop) renderLoop(ctx window.Context) error {
g.Collect(frame.viewport, frame.ops)
// Signal that we're done with the frame ops.
l.ack <- struct{}{}
g.BeginFrame()
var res frameResult
res.err = ctx.Present()
g.EndFrame()
res.err = g.Frame()
if res.err == nil {
res.err = ctx.Present()
}
res.profile = g.Profile()
ctx.Unlock()
l.results <- res