mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 02:38:53 +01:00
internal/graphicsdriver/metal: Change the order of GCed buffers
As a big buffer is likely reused, we should remove smaller buffers first. Updates #1196
This commit is contained in:
parent
09bd8b6f4a
commit
bd3f16dbba
@ -425,14 +425,14 @@ func (g *Graphics) availableBuffer(length uintptr) mtl.Buffer {
|
||||
}
|
||||
|
||||
// GC unused buffers.
|
||||
const maxUnusedBuffers = 20
|
||||
const maxUnusedBuffers = 10
|
||||
if len(g.unusedBuffers) > maxUnusedBuffers {
|
||||
bufs := make([]mtl.Buffer, 0, len(g.unusedBuffers))
|
||||
for b := range g.unusedBuffers {
|
||||
bufs = append(bufs, b)
|
||||
}
|
||||
sort.Slice(bufs, func(a, b int) bool {
|
||||
return bufs[a].Length() < bufs[b].Length()
|
||||
return bufs[a].Length() > bufs[b].Length()
|
||||
})
|
||||
for _, b := range bufs[maxUnusedBuffers:] {
|
||||
delete(g.unusedBuffers, b)
|
||||
|
Loading…
Reference in New Issue
Block a user