From 621373914d1af38e1546d2e699c72b6c394b308c Mon Sep 17 00:00:00 2001 From: Pascal Muetschard Date: Wed, 2 May 2018 16:51:13 -0700 Subject: [PATCH] Revert the threadId when a command is reverted. 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. --- gapis/replay/builder/builder.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gapis/replay/builder/builder.go b/gapis/replay/builder/builder.go index 5003c17046..ba63323f74 100644 --- a/gapis/replay/builder/builder.go +++ b/gapis/replay/builder/builder.go @@ -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. @@ -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 @@ -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)) @@ -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()