internal/graphicscommand: clear uniform variables explicitly

This change is a performance optimization.

(*uint32sBuffer).alloc doesn't clear the uniform values. Without
clearing the values explicitly, CanMergeWithDrawTrianglesCommand
might return false even though two commands can be merged.
This commit is contained in:
Hajime Hoshi 2023-08-19 16:19:11 +09:00
parent a9d9143d90
commit fcec771f34

View File

@ -675,21 +675,33 @@ func (q *commandQueue) prependPreservedUniforms(uniforms []uint32, shader *Shade
w, h := srcs[0].InternalSize() w, h := srcs[0].InternalSize()
uniforms[2] = math.Float32bits(float32(w)) uniforms[2] = math.Float32bits(float32(w))
uniforms[3] = math.Float32bits(float32(h)) uniforms[3] = math.Float32bits(float32(h))
} else {
uniforms[2] = 0
uniforms[3] = 0
} }
if srcs[1] != nil { if srcs[1] != nil {
w, h := srcs[1].InternalSize() w, h := srcs[1].InternalSize()
uniforms[4] = math.Float32bits(float32(w)) uniforms[4] = math.Float32bits(float32(w))
uniforms[5] = math.Float32bits(float32(h)) uniforms[5] = math.Float32bits(float32(h))
} else {
uniforms[4] = 0
uniforms[5] = 0
} }
if srcs[2] != nil { if srcs[2] != nil {
w, h := srcs[2].InternalSize() w, h := srcs[2].InternalSize()
uniforms[6] = math.Float32bits(float32(w)) uniforms[6] = math.Float32bits(float32(w))
uniforms[7] = math.Float32bits(float32(h)) uniforms[7] = math.Float32bits(float32(h))
} else {
uniforms[6] = 0
uniforms[7] = 0
} }
if srcs[3] != nil { if srcs[3] != nil {
w, h := srcs[3].InternalSize() w, h := srcs[3].InternalSize()
uniforms[8] = math.Float32bits(float32(w)) uniforms[8] = math.Float32bits(float32(w))
uniforms[9] = math.Float32bits(float32(h)) uniforms[9] = math.Float32bits(float32(h))
} else {
uniforms[8] = 0
uniforms[9] = 0
} }
if shader.unit() == shaderir.Texels { if shader.unit() == shaderir.Texels {