internal/graphicsdriver/metal: bug fix: use 3 for drawable count when vsync is off

Updates #2822
This commit is contained in:
Hajime Hoshi 2023-10-28 02:39:35 +09:00
parent 80301eb29e
commit d91f328083

View File

@ -52,6 +52,14 @@ func (v *view) setDisplaySyncEnabled(enabled bool) {
func (v *view) forceSetDisplaySyncEnabled(enabled bool) {
v.ml.SetDisplaySyncEnabled(enabled)
v.vsyncDisabled = !enabled
if v.vsyncDisabled {
// Apparently 2 makes FPS half. Use 3.
v.ml.SetMaximumDrawableCount(3)
} else {
// Use 2 in usual case not to cause rendering delays (#2822).
v.ml.SetMaximumDrawableCount(2)
}
}
func (v *view) colorPixelFormat() mtl.PixelFormat {
@ -82,7 +90,6 @@ func (v *view) initialize(device mtl.Device) error {
// presentsWithTransaction doesn't work with vsync off (#1196).
// nextDrawable took more than one second if the window has other controls like NSTextView (#1029).
v.ml.SetPresentsWithTransaction(false)
v.ml.SetMaximumDrawableCount(2)
return nil
}