Skip to content

Commit

Permalink
gles.moveClientVBsToVAs: Write VAP cmds on draw thread. (#1220)
Browse files Browse the repository at this point in the history
The calls to glVertexAttribPointer may have come from a thread that has since unbound the context. Just use the thread that is making the draw call.

Issue: #1205
  • Loading branch information
ben-clayton authored Oct 18, 2017
1 parent 15c8162 commit 8f65fb0
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions gapis/api/gles/compat_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,12 +227,16 @@ func moveClientVBsToVAs(
for _, l := range va.VertexAttributeArrays.KeysSorted() {
arr := va.VertexAttributeArrays[l]
if arr.Enabled == GLboolean_GL_TRUE {
if cmd, ok := clientVAs[arr]; ok {
cmd := *cmd // Copy
i := interval.IndexOf(&rngs, cmd.Data.addr)
if glVAP, ok := clientVAs[arr]; ok {
glVAP := *glVAP // Copy
i := interval.IndexOf(&rngs, glVAP.Data.addr)
t.GlBindBuffer_ArrayBuffer(ctx, ids[i])
cmd.Data = VertexPointer{cmd.Data.addr - rngs[i].First, memory.ApplicationPool} // Offset
out.MutateAndWrite(ctx, dID, &cmd)
// The glVertexAttribPointer call may have come from a different thread
// and there's no guarantees that the thread still has the context bound.
// Use the draw call's thread instead.
glVAP.SetThread(cmd.Thread())
glVAP.Data = VertexPointer{glVAP.Data.addr - rngs[i].First, memory.ApplicationPool} // Offset
out.MutateAndWrite(ctx, dID, &glVAP)
}
}
}
Expand Down

0 comments on commit 8f65fb0

Please sign in to comment.