graphicsdriver/metal: Bug fix: Had to set the vsync state again at resetting

Fixes #1364
This commit is contained in:
Hajime Hoshi 2020-10-14 01:55:32 +09:00
parent 249e1c46ba
commit fe6a2daef4
2 changed files with 11 additions and 1 deletions

View File

@ -231,7 +231,12 @@ func (g *game) Update() error {
} else { } else {
ebiten.SetCursorMode(ebiten.CursorModeHidden) ebiten.SetCursorMode(ebiten.CursorModeHidden)
} }
// Set vsync enabled only when this is needed.
// This makes a bug around vsync initialization more explicit (#1364).
if vsyncEnabled != ebiten.IsVsyncEnabled() {
ebiten.SetVsyncEnabled(vsyncEnabled) ebiten.SetVsyncEnabled(vsyncEnabled)
}
ebiten.SetMaxTPS(tps) ebiten.SetMaxTPS(tps)
ebiten.SetWindowDecorated(decorated) ebiten.SetWindowDecorated(decorated)
ebiten.SetWindowPosition(positionX, positionY) ebiten.SetWindowPosition(positionX, positionY)

View File

@ -28,6 +28,7 @@ type view struct {
uiview uintptr uiview uintptr
windowChanged bool windowChanged bool
vsync bool
device mtl.Device device mtl.Device
ml ca.MetalLayer ml ca.MetalLayer
@ -45,6 +46,7 @@ func (v *view) getMTLDevice() mtl.Device {
func (v *view) setDisplaySyncEnabled(enabled bool) { func (v *view) setDisplaySyncEnabled(enabled bool) {
v.ml.SetDisplaySyncEnabled(enabled) v.ml.SetDisplaySyncEnabled(enabled)
v.vsync = enabled
} }
func (v *view) colorPixelFormat() mtl.PixelFormat { func (v *view) colorPixelFormat() mtl.PixelFormat {
@ -67,6 +69,9 @@ func (v *view) reset() error {
// MTLPixelFormatBGRA10_XR_sRGB. // MTLPixelFormatBGRA10_XR_sRGB.
v.ml.SetPixelFormat(mtl.PixelFormatBGRA8UNorm) v.ml.SetPixelFormat(mtl.PixelFormatBGRA8UNorm)
v.ml.SetMaximumDrawableCount(3) v.ml.SetMaximumDrawableCount(3)
// The vsync state might be reset. Set the state again (#1364).
v.ml.SetDisplaySyncEnabled(v.vsync)
return nil return nil
} }