gpu: optimize encodeQuadTo

name             old time/op  new time/op  delta
EncodeQuadTo-32  35.4ns ± 1%  11.9ns ± 3%  -66.34%  (p=0.008 n=5+5)

Signed-off-by: Egon Elbre <egonelbre@gmail.com>
This commit is contained in:
Egon Elbre
2023-01-05 14:22:13 +02:00
committed by Elias Naur
parent c81a1f9671
commit 8bc6737dea
3 changed files with 68 additions and 16 deletions
+10 -8
View File
@@ -113,16 +113,18 @@ type vertex struct {
ToX, ToY float32
}
// encode needs to stay in-sync with the code in clip.go encodeQuadTo.
func (v vertex) encode(d []byte, maxy uint32) {
d = d[0:32]
bo := binary.LittleEndian
bo.PutUint32(d[0:], math.Float32bits(v.Corner))
bo.PutUint32(d[4:], maxy)
bo.PutUint32(d[8:], math.Float32bits(v.FromX))
bo.PutUint32(d[12:], math.Float32bits(v.FromY))
bo.PutUint32(d[16:], math.Float32bits(v.CtrlX))
bo.PutUint32(d[20:], math.Float32bits(v.CtrlY))
bo.PutUint32(d[24:], math.Float32bits(v.ToX))
bo.PutUint32(d[28:], math.Float32bits(v.ToY))
bo.PutUint32(d[0:4], math.Float32bits(v.Corner))
bo.PutUint32(d[4:8], maxy)
bo.PutUint32(d[8:12], math.Float32bits(v.FromX))
bo.PutUint32(d[12:16], math.Float32bits(v.FromY))
bo.PutUint32(d[16:20], math.Float32bits(v.CtrlX))
bo.PutUint32(d[20:24], math.Float32bits(v.CtrlY))
bo.PutUint32(d[24:28], math.Float32bits(v.ToX))
bo.PutUint32(d[28:32], math.Float32bits(v.ToY))
}
const (