diff --git a/internal/graphicsdriver/metal/view_darwin.go b/internal/graphicsdriver/metal/view_darwin.go index c4ca4cdd4..b22047fbf 100644 --- a/internal/graphicsdriver/metal/view_darwin.go +++ b/internal/graphicsdriver/metal/view_darwin.go @@ -83,8 +83,7 @@ func (v *view) initialize(device mtl.Device) error { // nextDrawable took more than one second if the window has other controls like NSTextView (#1029). v.ml.SetPresentsWithTransaction(false) - // Always use 3. There are some situations that the FPS becomes half, or the FPS becomes too low (#2880). - v.ml.SetMaximumDrawableCount(3) + v.ml.SetMaximumDrawableCount(v.maximumDrawableCount()) return nil } diff --git a/internal/graphicsdriver/metal/view_ios.go b/internal/graphicsdriver/metal/view_ios.go index dff20eb87..73d19116c 100644 --- a/internal/graphicsdriver/metal/view_ios.go +++ b/internal/graphicsdriver/metal/view_ios.go @@ -64,3 +64,8 @@ const ( storageMode = mtl.StorageModeShared resourceStorageMode = mtl.ResourceStorageModeShared ) + +func (v *view) maximumDrawableCount() int { + // TODO: Is 2 available for iOS? + return 3 +} diff --git a/internal/graphicsdriver/metal/view_macos.go b/internal/graphicsdriver/metal/view_macos.go index cb8fa41fc..c6799a417 100644 --- a/internal/graphicsdriver/metal/view_macos.go +++ b/internal/graphicsdriver/metal/view_macos.go @@ -17,6 +17,8 @@ package metal import ( + "runtime" + "github.com/ebitengine/purego/objc" "github.com/hajimehoshi/ebiten/v2/internal/cocoa" @@ -49,3 +51,13 @@ const ( storageMode = mtl.StorageModeManaged resourceStorageMode = mtl.ResourceStorageModeManaged ) + +func (v *view) maximumDrawableCount() int { + // Use 2 for Arm Mac (#2883). + if runtime.GOARCH == "arm64" { + return 2 + } + + // Use 3 for Intel Mac and iOS. With 2, There are some situations that the FPS becomes half, or the FPS becomes too low (#2880). + return 3 +}