mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
graphicsdriver/metal: Bug fix: Reading pixels from GPU causes blinking
Metal's Drawable should be obtained only when needed, or reading pixels from GPU causes the blinking screen. Fixes #865
This commit is contained in:
parent
8f62a510ab
commit
de341ca9ac
@ -316,14 +316,6 @@ func (d *Driver) Begin() {
|
|||||||
// NSAutoreleasePool is required to release drawable correctly (#847).
|
// NSAutoreleasePool is required to release drawable correctly (#847).
|
||||||
// https://developer.apple.com/library/archive/documentation/3DDrawing/Conceptual/MTLBestPracticesGuide/Drawables.html
|
// https://developer.apple.com/library/archive/documentation/3DDrawing/Conceptual/MTLBestPracticesGuide/Drawables.html
|
||||||
d.pool = C.allocAutoreleasePool()
|
d.pool = C.allocAutoreleasePool()
|
||||||
|
|
||||||
drawable, err := d.ml.NextDrawable()
|
|
||||||
if err != nil {
|
|
||||||
// Drawable is nil. This can happen at the initial state. Let's wait and see.
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
d.screenDrawable = drawable
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -631,6 +623,14 @@ func (d *Driver) Draw(indexLen int, indexOffset int, mode graphics.CompositeMode
|
|||||||
}
|
}
|
||||||
var t mtl.Texture
|
var t mtl.Texture
|
||||||
if d.dst.screen {
|
if d.dst.screen {
|
||||||
|
if d.screenDrawable == (ca.MetalDrawable{}) {
|
||||||
|
drawable, err := d.ml.NextDrawable()
|
||||||
|
if err != nil {
|
||||||
|
// Drawable is nil. This can happen at the initial state. Let's wait and see.
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
d.screenDrawable = drawable
|
||||||
|
}
|
||||||
t = d.screenDrawable.Texture()
|
t = d.screenDrawable.Texture()
|
||||||
} else {
|
} else {
|
||||||
t = d.dst.texture
|
t = d.dst.texture
|
||||||
|
Loading…
Reference in New Issue
Block a user