mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 18:58:54 +01:00
internal/graphicsdriver/metal: Refactoring
This commit is contained in:
parent
e98e371bb4
commit
11b9a4b161
@ -70,16 +70,8 @@ func (v *view) setFullscreen(fullscreen bool) {
|
||||
}
|
||||
|
||||
func (v *view) updatePresentsWithTransaction() {
|
||||
pwt := v.usePresentsWithTransaction()
|
||||
v.ml.SetPresentsWithTransaction(pwt)
|
||||
|
||||
// When presentsWithTransaction is YES and triple buffering is enabled, nextDrawing returns immediately once every two times.
|
||||
// This makes FPS doubled. To avoid this, disable the triple buffering.
|
||||
if pwt {
|
||||
v.ml.SetMaximumDrawableCount(2)
|
||||
} else {
|
||||
v.ml.SetMaximumDrawableCount(3)
|
||||
}
|
||||
v.ml.SetPresentsWithTransaction(v.usePresentsWithTransaction())
|
||||
v.ml.SetMaximumDrawableCount(v.maximumDrawableCount())
|
||||
}
|
||||
|
||||
func (v *view) colorPixelFormat() mtl.PixelFormat {
|
||||
|
@ -62,6 +62,10 @@ func (v *view) usePresentsWithTransaction() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (v *view) maximumDrawableCount() int {
|
||||
return 3
|
||||
}
|
||||
|
||||
const (
|
||||
storageMode = mtl.StorageModeShared
|
||||
resourceStorageMode = mtl.ResourceStorageModeShared
|
||||
|
@ -48,6 +48,15 @@ func (v *view) usePresentsWithTransaction() bool {
|
||||
return !v.vsyncDisabled && !v.fullscreen
|
||||
}
|
||||
|
||||
func (v *view) maximumDrawableCount() int {
|
||||
// When presentsWithTransaction is YES and triple buffering is enabled, nextDrawing returns immediately once every two times.
|
||||
// This makes FPS doubled. To avoid this, disable the triple buffering.
|
||||
if v.usePresentsWithTransaction() {
|
||||
return 2
|
||||
}
|
||||
return 3
|
||||
}
|
||||
|
||||
const (
|
||||
storageMode = mtl.StorageModeManaged
|
||||
resourceStorageMode = mtl.ResourceStorageModeManaged
|
||||
|
Loading…
Reference in New Issue
Block a user