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