graphicscommand: Keep the capacity at q.commands

This commit is contained in:
Hajime Hoshi 2019-09-29 03:23:40 +09:00
parent 86b4e9ffeb
commit 907302c440

View File

@ -233,11 +233,12 @@ func (q *commandQueue) Flush() {
} }
theGraphicsDriver.Begin() theGraphicsDriver.Begin()
for len(q.commands) > 0 { cs := q.commands
for len(cs) > 0 {
nv := 0 nv := 0
ne := 0 ne := 0
nc := 0 nc := 0
for _, c := range q.commands { for _, c := range cs {
if c.NumIndices() > graphics.IndicesNum { if c.NumIndices() > graphics.IndicesNum {
panic(fmt.Sprintf("graphicscommand: c.NumIndices() must be <= graphics.IndicesNum but not at Flush: c.NumIndices(): %d, graphics.IndicesNum: %d", c.NumIndices(), graphics.IndicesNum)) panic(fmt.Sprintf("graphicscommand: c.NumIndices() must be <= graphics.IndicesNum but not at Flush: c.NumIndices(): %d, graphics.IndicesNum: %d", c.NumIndices(), graphics.IndicesNum))
} }
@ -254,7 +255,7 @@ func (q *commandQueue) Flush() {
vs = vs[nv:] vs = vs[nv:]
} }
indexOffset := 0 indexOffset := 0
for _, c := range q.commands[:nc] { for _, c := range cs[:nc] {
if err := c.Exec(indexOffset); err != nil { if err := c.Exec(indexOffset); err != nil {
q.err = err q.err = err
return return
@ -271,7 +272,7 @@ func (q *commandQueue) Flush() {
// Call glFlush to prevent black flicking (especially on Android (#226) and iOS). // Call glFlush to prevent black flicking (especially on Android (#226) and iOS).
theGraphicsDriver.Flush() theGraphicsDriver.Flush()
} }
q.commands = q.commands[nc:] cs = cs[nc:]
} }
theGraphicsDriver.End() theGraphicsDriver.End()
q.commands = q.commands[:0] q.commands = q.commands[:0]