internal/graphicsdriver/metal: bug fix: use 2 as a drawable count for Arm Mac

Closes #2883
This commit is contained in:
Hajime Hoshi 2024-01-17 18:57:50 +09:00
parent 2ec5c788ab
commit 055db234a1
3 changed files with 18 additions and 2 deletions

View File

@ -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
}

View File

@ -64,3 +64,8 @@ const (
storageMode = mtl.StorageModeShared
resourceStorageMode = mtl.ResourceStorageModeShared
)
func (v *view) maximumDrawableCount() int {
// TODO: Is 2 available for iOS?
return 3
}

View File

@ -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
}