From c9bc5913fd93f40e4d1d51a1b82051df5e68c2ed Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Fri, 6 Dec 2019 08:42:52 +0900 Subject: [PATCH] driver: Refactoring: Remove Graphics.Flush Updates #226 --- internal/driver/graphics.go | 1 - internal/graphicscommand/command.go | 4 ---- internal/graphicsdriver/metal/driver.go | 4 ---- internal/graphicsdriver/opengl/driver.go | 8 +++----- 4 files changed, 3 insertions(+), 14 deletions(-) diff --git a/internal/driver/graphics.go b/internal/driver/graphics.go index dd7288e86..41afbedf3 100644 --- a/internal/driver/graphics.go +++ b/internal/driver/graphics.go @@ -28,7 +28,6 @@ type Graphics interface { SetWindow(window unsafe.Pointer) SetTransparent(transparent bool) SetVertices(vertices []float32, indices []uint16) - Flush() NewImage(width, height int) (Image, error) NewScreenFramebufferImage(width, height int) (Image, error) Reset() error diff --git a/internal/graphicscommand/command.go b/internal/graphicscommand/command.go index 62cd2fc1a..2d03b7a4d 100644 --- a/internal/graphicscommand/command.go +++ b/internal/graphicscommand/command.go @@ -274,10 +274,6 @@ func (q *commandQueue) Flush() { // introduced than drawTrianglesCommand. indexOffset += c.NumIndices() } - if 0 < nc { - // Call glFlush to prevent black flicking (especially on Android (#226) and iOS). - theGraphicsDriver.Flush() - } cs = cs[nc:] } theGraphicsDriver.End() diff --git a/internal/graphicsdriver/metal/driver.go b/internal/graphicsdriver/metal/driver.go index 11553f791..ed0a8ab49 100644 --- a/internal/graphicsdriver/metal/driver.go +++ b/internal/graphicsdriver/metal/driver.go @@ -364,10 +364,6 @@ func (d *Driver) SetVertices(vertices []float32, indices []uint16) { }) } -func (d *Driver) Flush() { - // On Metal, flushing command buffers only once is enough except for manipulating pixels. Do not call flush. -} - func (d *Driver) flush(wait bool, present bool) { d.t.Call(func() error { if d.cb == (mtl.CommandBuffer{}) { diff --git a/internal/graphicsdriver/opengl/driver.go b/internal/graphicsdriver/opengl/driver.go index c80421e0b..76bfa3576 100644 --- a/internal/graphicsdriver/opengl/driver.go +++ b/internal/graphicsdriver/opengl/driver.go @@ -47,7 +47,9 @@ func (d *Driver) Begin() { } func (d *Driver) End() { - // Do nothing. + // Call glFlush to prevent black flicking (especially on Android (#226) and iOS). + // TODO: examples/sprites worked without this. Is this really needed? + d.context.flush() } func (d *Driver) SetWindow(window unsafe.Pointer) { @@ -128,10 +130,6 @@ func (d *Driver) Draw(indexLen int, indexOffset int, mode driver.CompositeMode, return nil } -func (d *Driver) Flush() { - d.context.flush() -} - func (d *Driver) SetVsyncEnabled(enabled bool) { // Do nothing }