mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
internal/graphicsdriver/metal: call PresentDrawable only when necessary
This commit is contained in:
parent
ee911fd892
commit
8b7273b74a
@ -293,6 +293,7 @@ func (q *commandQueue) flush() error {
|
||||
}
|
||||
|
||||
theGraphicsDriver.Begin()
|
||||
var present bool
|
||||
cs := q.commands
|
||||
for len(cs) > 0 {
|
||||
nv := 0
|
||||
@ -308,6 +309,9 @@ func (q *commandQueue) flush() error {
|
||||
}
|
||||
nv += dtc.numVertices()
|
||||
ne += dtc.numIndices()
|
||||
if dtc.dst.screen {
|
||||
present = true
|
||||
}
|
||||
}
|
||||
nc++
|
||||
}
|
||||
@ -331,7 +335,7 @@ func (q *commandQueue) flush() error {
|
||||
}
|
||||
cs = cs[nc:]
|
||||
}
|
||||
theGraphicsDriver.End()
|
||||
theGraphicsDriver.End(present)
|
||||
|
||||
// Release the commands explicitly (#1803).
|
||||
// Apparently, the part of a slice between len and cap-1 still holds references.
|
||||
|
@ -46,7 +46,7 @@ type Uniform struct {
|
||||
|
||||
type Graphics interface {
|
||||
Begin()
|
||||
End()
|
||||
End(present bool)
|
||||
SetTransparent(transparent bool)
|
||||
SetVertices(vertices []float32, indices []uint16)
|
||||
NewImage(width, height int) (Image, error)
|
||||
|
@ -369,8 +369,8 @@ func (g *Graphics) Begin() {
|
||||
g.pool = C.allocAutoreleasePool()
|
||||
}
|
||||
|
||||
func (g *Graphics) End() {
|
||||
g.flushIfNeeded(true)
|
||||
func (g *Graphics) End(present bool) {
|
||||
g.flushIfNeeded(present)
|
||||
g.screenDrawable = ca.MetalDrawable{}
|
||||
C.releaseAutoreleasePool(g.pool)
|
||||
g.pool = nil
|
||||
|
@ -60,7 +60,7 @@ func (g *Graphics) Begin() {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
func (g *Graphics) End() {
|
||||
func (g *Graphics) End(present bool) {
|
||||
// Call glFlush to prevent black flicking (especially on Android (#226) and iOS).
|
||||
// TODO: examples/sprites worked without this. Is this really needed?
|
||||
g.context.flush()
|
||||
|
Loading…
Reference in New Issue
Block a user