Don't duplicate computations in gltriangles.go
The computation including a call to Stride() can't be optimized away safely because the compiler can't tell that Stride() is effectively constant, but we know it won't change so we can make a slice pointing at that part of the array. CPU time for updateData goes from 26.35% to 18.65% in my test case.
This commit is contained in:
parent
c6e7a83467
commit
ce8687b80f
|
@ -103,15 +103,17 @@ func (gt *GLTriangles) updateData(t pixel.Triangles) {
|
||||||
tx, ty = (*t)[i].Picture.XY()
|
tx, ty = (*t)[i].Picture.XY()
|
||||||
in = (*t)[i].Intensity
|
in = (*t)[i].Intensity
|
||||||
)
|
)
|
||||||
gt.data[i*gt.vs.Stride()+0] = float32(px)
|
s := gt.vs.Stride()
|
||||||
gt.data[i*gt.vs.Stride()+1] = float32(py)
|
d := gt.data[i*s : i*s+9]
|
||||||
gt.data[i*gt.vs.Stride()+2] = float32(col.R)
|
d[0] = float32(px)
|
||||||
gt.data[i*gt.vs.Stride()+3] = float32(col.G)
|
d[1] = float32(py)
|
||||||
gt.data[i*gt.vs.Stride()+4] = float32(col.B)
|
d[2] = float32(col.R)
|
||||||
gt.data[i*gt.vs.Stride()+5] = float32(col.A)
|
d[3] = float32(col.G)
|
||||||
gt.data[i*gt.vs.Stride()+6] = float32(tx)
|
d[4] = float32(col.B)
|
||||||
gt.data[i*gt.vs.Stride()+7] = float32(ty)
|
d[5] = float32(col.A)
|
||||||
gt.data[i*gt.vs.Stride()+8] = float32(in)
|
d[6] = float32(tx)
|
||||||
|
d[7] = float32(ty)
|
||||||
|
d[8] = float32(in)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue