mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 03:08:54 +01:00
graphicsdriver/metal: Make (*Driver).Flush do nothing
This commit is contained in:
parent
72be1bde24
commit
b99f4c61b5
@ -329,6 +329,7 @@ func (d *Driver) Begin() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (d *Driver) End() {
|
func (d *Driver) End() {
|
||||||
|
d.flush(false, true)
|
||||||
mainthread.Run(func() error {
|
mainthread.Run(func() error {
|
||||||
d.screenDrawable = ca.MetalDrawable{}
|
d.screenDrawable = ca.MetalDrawable{}
|
||||||
C.releaseAutoreleasePool(d.pool)
|
C.releaseAutoreleasePool(d.pool)
|
||||||
@ -361,18 +362,16 @@ func (d *Driver) SetVertices(vertices []float32, indices []uint16) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (d *Driver) Flush() {
|
func (d *Driver) Flush() {
|
||||||
d.flush(false)
|
// On Metal, flushing command buffers only once is enough. Do not call flush.
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Driver) flush(wait bool) {
|
func (d *Driver) flush(wait bool, present bool) {
|
||||||
mainthread.Run(func() error {
|
mainthread.Run(func() error {
|
||||||
if d.cb == (mtl.CommandBuffer{}) {
|
if d.cb == (mtl.CommandBuffer{}) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Calling PresentDrawable here is odd since flush is not related to preseinging.
|
if present && d.screenDrawable != (ca.MetalDrawable{}) {
|
||||||
// Call it at End().
|
|
||||||
if d.screenDrawable != (ca.MetalDrawable{}) {
|
|
||||||
d.cb.PresentDrawable(d.screenDrawable)
|
d.cb.PresentDrawable(d.screenDrawable)
|
||||||
}
|
}
|
||||||
d.cb.Commit()
|
d.cb.Commit()
|
||||||
@ -765,7 +764,7 @@ func (i *Image) syncTexture() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (i *Image) Pixels() ([]byte, error) {
|
func (i *Image) Pixels() ([]byte, error) {
|
||||||
i.driver.flush(true)
|
i.driver.flush(true, false)
|
||||||
i.syncTexture()
|
i.syncTexture()
|
||||||
|
|
||||||
b := make([]byte, 4*i.width*i.height)
|
b := make([]byte, 4*i.width*i.height)
|
||||||
@ -793,7 +792,7 @@ func (i *Image) SetAsSource() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (i *Image) ReplacePixels(pixels []byte, x, y, width, height int) {
|
func (i *Image) ReplacePixels(pixels []byte, x, y, width, height int) {
|
||||||
i.driver.flush(true)
|
i.driver.flush(true, false)
|
||||||
|
|
||||||
mainthread.Run(func() error {
|
mainthread.Run(func() error {
|
||||||
i.texture.ReplaceRegion(mtl.Region{
|
i.texture.ReplaceRegion(mtl.Region{
|
||||||
|
@ -109,11 +109,6 @@ func (c *uiContext) Update(afterFrameUpdate func()) error {
|
|||||||
afterFrameUpdate()
|
afterFrameUpdate()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Before clearing the screen, the offscreen's pixels must be resolved.
|
|
||||||
// After clearing the screen, resolving doesn't work. This is very hacky
|
|
||||||
// but we could not find other way so far (#792).
|
|
||||||
c.offscreen.resolvePendingPixels(true)
|
|
||||||
|
|
||||||
// This clear is needed for fullscreen mode or some mobile platforms (#622).
|
// This clear is needed for fullscreen mode or some mobile platforms (#622).
|
||||||
c.screen.Clear()
|
c.screen.Clear()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user