Skip to content

Commit 9db1be6

Browse files
capture: unleash the chaos (aka 0-based frame numbering)
Heads up, this is the tiny-looking change with giant consequences. We are intentionally touching the capture output path, which means: - golden files will drift, - baselines will scream, - every bot will wake up at once, - and the CI lights are about to turn a festive shade of red. This is not a bug, it’s a feature of progress. Please forgive the noise while the new reality settles in. Refs: #1195, #2483
1 parent c0e2c90 commit 9db1be6

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

framework/decode/file_processor.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,12 @@
3232
GFXRECON_BEGIN_NAMESPACE(gfxrecon)
3333
GFXRECON_BEGIN_NAMESPACE(decode)
3434

35-
// TODO GH #1195: frame numbering should be 1-based.
3635
const uint32_t kFirstFrame = 0;
3736

3837
FileProcessor::FileProcessor() :
3938
current_frame_number_(kFirstFrame), error_state_(kErrorInvalidFileDescriptor), bytes_read_(0),
4039
annotation_handler_(nullptr), compressor_(nullptr), block_index_(0), block_limit_(0),
41-
pending_capture_uses_frame_markers_(false), capture_uses_frame_markers_(false), first_frame_(kFirstFrame + 1),
40+
pending_capture_uses_frame_markers_(false), capture_uses_frame_markers_(false), first_frame_(kFirstFrame),
4241
loading_trimmed_capture_state_(false), pool_(util::HeapBufferPool::Create())
4342
{}
4443

@@ -551,6 +550,18 @@ bool FileProcessor::ProcessFrameDelimiter(const FrameEndMarkerArgs& end_frame)
551550
{
552551
// Validate frame end marker's frame number matches current_frame_number_ when capture_uses_frame_markers_ is
553552
// true.
553+
if (capture_uses_frame_markers_ && current_frame_number_ == end_frame.frame_number - first_frame_ - 1)
554+
{
555+
// Backward compatibility check for first frame end marker:
556+
// Old traces used a 1-based frame numbering scheme, while the current code uses a 0-based scheme.
557+
// Allow the first frame end marker to be off by one in this case, but emit a warning.
558+
GFXRECON_LOG_WARNING("First frame end marker frame number %" PRIu64
559+
" does not match current frame number %" PRIu64
560+
"; assuming 1-based frame numbering from an older capture tool version",
561+
end_frame.frame_number,
562+
current_frame_number_);
563+
first_frame_ += 1;
564+
}
554565
GFXRECON_ASSERT((!capture_uses_frame_markers_) ||
555566
(current_frame_number_ == (end_frame.frame_number - first_frame_)));
556567
if (IsFrameDelimiter(format::BlockType::kFrameMarkerBlock, format::MarkerType::kEndMarker))

framework/encode/capture_manager.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ extern char** environ;
5151
GFXRECON_BEGIN_NAMESPACE(gfxrecon)
5252
GFXRECON_BEGIN_NAMESPACE(encode)
5353

54-
// One based frame count.
55-
const uint32_t kFirstFrame = 1;
54+
const uint32_t kFirstFrame = 0;
5655
const size_t kFileStreamBufferSize = 256 * 1024;
5756

5857
CommonCaptureManager* CommonCaptureManager::singleton_;

0 commit comments

Comments
 (0)