Skip to content

Commit

Permalink
Revert the threadId when a command is reverted.
Browse files Browse the repository at this point in the history
The replay builder can revert commands (e.g. due to GL errors).
However, the revert was not reverting the command builder's state
correctly when the thread changed with the reverted command. Thus,
if in BeginCommand it was determined that the thread has changed,
a `SWITCH_THREAD` opcode is prepared, but then reverted, while the
command builder would go on, assuming it has switched threads.
  • Loading branch information
pmuetschard committed May 3, 2018
1 parent 88bbc1b commit 6213739
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion gapis/replay/builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ type Builder struct {
resourceIDToIdx map[id.ID]uint32
threadIDToIdx map[uint64]uint32
currentThreadID uint64
pendingThreadID uint64
resources []protocol.ResourceInfo
reservedMemory memory.RangeList // Reserved memory ranges for regular data.
pointerMemory memory.RangeList // Reserved memory ranges for the pointer table.
Expand Down Expand Up @@ -227,7 +228,7 @@ func (b *Builder) BeginCommand(cmdID, threadID uint64) {
}

if b.currentThreadID != threadID {
b.currentThreadID = threadID
b.pendingThreadID = threadID
index, ok := b.threadIDToIdx[threadID]
if !ok {
index = uint32(len(b.threadIDToIdx)) + 1
Expand All @@ -245,6 +246,7 @@ func (b *Builder) CommitCommand() {
panic("CommitCommand called without a call to BeginCommand")
}
b.lastLabel, b.pendingLabel = b.pendingLabel, 0
b.currentThreadID = b.pendingThreadID
b.inCmd = false
b.temp.reset()
pop := uint32(len(b.stack))
Expand Down Expand Up @@ -286,6 +288,7 @@ func (b *Builder) RevertCommand(err error) {
panic("RevertCommand called without a call to BeginCommand")
}
b.pendingLabel = 0
b.pendingThreadID = b.currentThreadID
b.inCmd = false
// TODO: Revert calls to: AllocateMemory, Buffer, String, ReserveMemory, MapMemory, UnmapMemory, Write.
b.temp.reset()
Expand Down

0 comments on commit 6213739

Please sign in to comment.