forked from joejulian/gio
app: don't delay FrameEvent.Frame by v-sync latency
We should return as soon as possible from FrameEvent.Frame to allow the main goroutine to continue processing other tasks. Whereas GPU.Frame may touch the frame ops, GPU.Present will not, so this change moves Present to after returning from FrameEvent.Frame. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
+4
-4
@@ -248,10 +248,7 @@ func (w *Window) render(frame *op.Ops, viewport image.Point) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := w.gpu.Frame(frame, target, viewport); err != nil {
|
||||
return err
|
||||
}
|
||||
return w.ctx.Present()
|
||||
return w.gpu.Frame(frame, target, viewport)
|
||||
}
|
||||
|
||||
func (w *Window) processFrame(d driver, frameStart time.Time) {
|
||||
@@ -808,6 +805,9 @@ func (w *Window) processEvent(d driver, e event.Event) {
|
||||
// We're done with frame, let the client continue.
|
||||
w.frameAck <- struct{}{}
|
||||
}
|
||||
if err == nil && w.gpu != nil {
|
||||
err = w.ctx.Present()
|
||||
}
|
||||
if err != nil {
|
||||
w.destroyGPU()
|
||||
w.out <- system.DestroyEvent{Err: err}
|
||||
|
||||
Reference in New Issue
Block a user