diff --git a/src/xenia/gpu/gl4/command_processor.cc b/src/xenia/gpu/gl4/command_processor.cc index bf1e20fad..5734732ad 100644 --- a/src/xenia/gpu/gl4/command_processor.cc +++ b/src/xenia/gpu/gl4/command_processor.cc @@ -775,7 +775,12 @@ bool CommandProcessor::ExecutePacketType3(RingbufferReader* reader, uint32_t count = ((packet >> 16) & 0x3FFF) + 1; auto data_start_offset = reader->offset(); - trace_writer_.WritePacketStart(reader->ptr() - 4, 1 + count); + // To handle nesting behavior when tracing we special case indirect buffers. + if (opcode == PM4_INDIRECT_BUFFER) { + trace_writer_.WritePacketStart(reader->ptr() - 4, 2); + } else { + trace_writer_.WritePacketStart(reader->ptr() - 4, 1 + count); + } // & 1 == predicate - when set, we do bin check to see if we should execute // the packet. Only type 3 packets are affected. diff --git a/src/xenia/gpu/trace_viewer_main.cc b/src/xenia/gpu/trace_viewer_main.cc index 2573749d9..58a9ea480 100644 --- a/src/xenia/gpu/trace_viewer_main.cc +++ b/src/xenia/gpu/trace_viewer_main.cc @@ -665,7 +665,7 @@ class TraceReader { break; } } - if (pending_break) { + if (pending_break || current_frame.command_count) { current_frame.end_ptr = trace_ptr; frames_.push_back(std::move(current_frame)); } diff --git a/src/xenia/gpu/tracing.h b/src/xenia/gpu/tracing.h index 2fdc6998c..cd7c53f68 100644 --- a/src/xenia/gpu/tracing.h +++ b/src/xenia/gpu/tracing.h @@ -112,10 +112,9 @@ class TraceWriter { return; } auto cmd = PrimaryBufferStartCommand({ - TraceCommandType::kPrimaryBufferStart, base_ptr, count, + TraceCommandType::kPrimaryBufferStart, base_ptr, 0, }); fwrite(&cmd, 1, sizeof(cmd), file_); - fwrite(membase_ + base_ptr, 4, count, file_); } void WritePrimaryBufferEnd() { @@ -133,10 +132,9 @@ class TraceWriter { return; } auto cmd = IndirectBufferStartCommand({ - TraceCommandType::kIndirectBufferStart, base_ptr, count, + TraceCommandType::kIndirectBufferStart, base_ptr, 0, }); fwrite(&cmd, 1, sizeof(cmd), file_); - fwrite(membase_ + base_ptr, 4, count, file_); } void WriteIndirectBufferEnd() {