graphicscommand: Bug fix: Adjusting source regions must be done before checking merging

Fixes #1333
This commit is contained in:
Hajime Hoshi 2020-09-05 00:42:47 +09:00
parent 68c43bb4fb
commit ac30377297

View File

@ -151,16 +151,6 @@ func (q *commandQueue) EnqueueDrawTrianglesCommand(dst *Image, srcs [graphics.Sh
q.nextIndex += len(vertices) / graphics.VertexFloatNum
q.tmpNumIndices += len(indices)
// TODO: If dst is the screen, reorder the command to be the last.
if !split && 0 < len(q.commands) {
// TODO: Pass offsets and uniforms when merging considers the shader.
if last := q.commands[len(q.commands)-1]; last.CanMergeWithDrawTrianglesCommand(dst, srcs, color, mode, filter, address, sourceRegion, shader) {
last.AddNumVertices(len(vertices))
last.AddNumIndices(len(indices))
return
}
}
if srcs[0] != nil {
w, h := srcs[0].InternalSize()
sourceRegion.X /= float32(w)
@ -173,6 +163,16 @@ func (q *commandQueue) EnqueueDrawTrianglesCommand(dst *Image, srcs [graphics.Sh
}
}
// TODO: If dst is the screen, reorder the command to be the last.
if !split && 0 < len(q.commands) {
// TODO: Pass offsets and uniforms when merging considers the shader.
if last := q.commands[len(q.commands)-1]; last.CanMergeWithDrawTrianglesCommand(dst, srcs, color, mode, filter, address, sourceRegion, shader) {
last.AddNumVertices(len(vertices))
last.AddNumIndices(len(indices))
return
}
}
c := &drawTrianglesCommand{
dst: dst,
srcs: srcs,