mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 18:58:54 +01:00
internal/graphicsdriver/directx: reuse vertices/indices buffers whenever possible
This commit is contained in:
parent
e5525a04d5
commit
90723025cc
@ -840,7 +840,7 @@ func (g *Graphics) End(present bool) error {
|
||||
return err
|
||||
}
|
||||
g.releaseResources(g.frameIndex)
|
||||
g.releaseVerticesAndIndices(g.frameIndex)
|
||||
g.resetVerticesAndIndices(g.frameIndex, true)
|
||||
}
|
||||
|
||||
g.pipelineStates.resetConstantBuffers(g.frameIndex)
|
||||
@ -869,7 +869,7 @@ func (g *Graphics) End(present bool) error {
|
||||
}
|
||||
|
||||
g.releaseResources(g.frameIndex)
|
||||
g.releaseVerticesAndIndices(g.frameIndex)
|
||||
g.resetVerticesAndIndices(g.frameIndex, false)
|
||||
|
||||
g.frameStarted = false
|
||||
}
|
||||
@ -961,17 +961,21 @@ func (g *Graphics) releaseResources(frameIndex int) {
|
||||
g.disposedShaders[frameIndex] = g.disposedShaders[frameIndex][:0]
|
||||
}
|
||||
|
||||
func (g *Graphics) releaseVerticesAndIndices(frameIndex int) {
|
||||
func (g *Graphics) resetVerticesAndIndices(frameIndex int, release bool) {
|
||||
if release {
|
||||
for i := range g.vertices[frameIndex] {
|
||||
g.vertices[frameIndex][i].release()
|
||||
g.vertices[frameIndex][i] = nil
|
||||
}
|
||||
}
|
||||
g.vertices[frameIndex] = g.vertices[frameIndex][:0]
|
||||
|
||||
if release {
|
||||
for i := range g.indices[frameIndex] {
|
||||
g.indices[frameIndex][i].release()
|
||||
g.indices[frameIndex][i] = nil
|
||||
}
|
||||
}
|
||||
g.indices[frameIndex] = g.indices[frameIndex][:0]
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user