mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 03:08: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
|
return err
|
||||||
}
|
}
|
||||||
g.releaseResources(g.frameIndex)
|
g.releaseResources(g.frameIndex)
|
||||||
g.releaseVerticesAndIndices(g.frameIndex)
|
g.resetVerticesAndIndices(g.frameIndex, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
g.pipelineStates.resetConstantBuffers(g.frameIndex)
|
g.pipelineStates.resetConstantBuffers(g.frameIndex)
|
||||||
@ -869,7 +869,7 @@ func (g *Graphics) End(present bool) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
g.releaseResources(g.frameIndex)
|
g.releaseResources(g.frameIndex)
|
||||||
g.releaseVerticesAndIndices(g.frameIndex)
|
g.resetVerticesAndIndices(g.frameIndex, false)
|
||||||
|
|
||||||
g.frameStarted = false
|
g.frameStarted = false
|
||||||
}
|
}
|
||||||
@ -961,16 +961,20 @@ func (g *Graphics) releaseResources(frameIndex int) {
|
|||||||
g.disposedShaders[frameIndex] = g.disposedShaders[frameIndex][:0]
|
g.disposedShaders[frameIndex] = g.disposedShaders[frameIndex][:0]
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Graphics) releaseVerticesAndIndices(frameIndex int) {
|
func (g *Graphics) resetVerticesAndIndices(frameIndex int, release bool) {
|
||||||
for i := range g.vertices[frameIndex] {
|
if release {
|
||||||
g.vertices[frameIndex][i].release()
|
for i := range g.vertices[frameIndex] {
|
||||||
g.vertices[frameIndex][i] = nil
|
g.vertices[frameIndex][i].release()
|
||||||
|
g.vertices[frameIndex][i] = nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
g.vertices[frameIndex] = g.vertices[frameIndex][:0]
|
g.vertices[frameIndex] = g.vertices[frameIndex][:0]
|
||||||
|
|
||||||
for i := range g.indices[frameIndex] {
|
if release {
|
||||||
g.indices[frameIndex][i].release()
|
for i := range g.indices[frameIndex] {
|
||||||
g.indices[frameIndex][i] = nil
|
g.indices[frameIndex][i].release()
|
||||||
|
g.indices[frameIndex][i] = nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
g.indices[frameIndex] = g.indices[frameIndex][:0]
|
g.indices[frameIndex] = g.indices[frameIndex][:0]
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user