Skip to content

Commit 227b79c

Browse files
committed
[Prototype] Add frame looping and profiling capabilities to gfxr replay
1 parent 2ef5400 commit 227b79c

File tree

7 files changed

+85
-53
lines changed

7 files changed

+85
-53
lines changed

android/layer/build.gradle

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ android {
4040
minifyEnabled false
4141
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
4242
}
43+
debug {
44+
externalNativeBuild {
45+
cmake {
46+
arguments "-DCMAKE_BUILD_TYPE=RelWithDebInfo"
47+
}
48+
}
49+
}
4350
}
4451
externalNativeBuild {
4552
cmake {

android/tools/replay/build.gradle

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ android {
3535
minifyEnabled false
3636
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
3737
}
38+
debug {
39+
externalNativeBuild {
40+
cmake {
41+
arguments "-DCMAKE_BUILD_TYPE=RelWithDebInfo"
42+
}
43+
}
44+
}
3845
}
3946
externalNativeBuild {
4047
cmake {

framework/decode/file_processor.cpp

Lines changed: 61 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,6 @@ bool FileProcessor::ProcessBlocks()
266266
BlockBuffer block_buffer;
267267
bool success = true;
268268

269-
int64_t frame_begin_offset = util::platform::FileTell(active_files_.find(file_stack_.back().filename)->second.fd);
270-
int64_t frame_begin_block_index = block_index_;
271269

272270
auto err_handler = [this](BlockIOError err, const char* message) { HandleBlockReadError(err, message); };
273271
BlockParser block_parser(BlockParser::ErrorHandler{ err_handler }, pool_, compressor_.get());
@@ -277,80 +275,94 @@ bool FileProcessor::ProcessBlocks()
277275
ProcessVisitor process_visitor(*this);
278276
DispatchVisitor dispatch_visitor(decoders_, annotation_handler_);
279277

280-
// while (success)
281-
// {
282-
// PrintBlockInfo();
283-
// success = ContinueDecoding();
284-
// }
278+
int64_t frame_begin_offset = -1;
279+
if (!file_stack_.empty() && file_stack_.back().active_file) {
280+
frame_begin_offset = file_stack_.back().active_file->GetCurrentPos();
281+
}
282+
int64_t frame_begin_block_index = block_index_;
285283

286-
for(int frame_repeat_n = 0; frame_repeat_n < repeat_frame_n_times_ + 1; ++frame_repeat_n) {
287-
if(frame_repeat_n > 0) {
284+
for (uint32_t frame_repeat_n = 0; frame_repeat_n < repeat_frame_n_times_ + 1; ++frame_repeat_n)
285+
{
286+
if (frame_repeat_n > 0)
287+
{
288288
SeekActiveFile(frame_begin_offset, util::platform::FileSeekSet);
289289
block_index_ = frame_begin_block_index;
290-
success = true;
290+
success = true;
291291
}
292+
292293
while (success)
293294
{
294-
success = GetBlockBuffer(block_parser, block_buffer);
295-
296-
for (auto decoder : decoders_)
297-
{
298-
decoder->SetCurrentBlockIndex(block_index_);
299-
}
295+
PrintBlockInfo();
296+
success = ContinueDecoding();
300297

301298
if (success)
302299
{
303-
if (SkipBlockProcessing())
300+
success = GetBlockBuffer(block_parser, block_buffer);
301+
302+
for (auto decoder : decoders_)
304303
{
305-
GFXRECON_CHECK_CONVERSION_DATA_LOSS(size_t, block_buffer.Header().size);
304+
decoder->SetCurrentBlockIndex(block_index_);
306305
}
307306

308-
else
307+
if (success)
309308
{
310-
block_parser.SetBlockIndex(block_index_);
311-
block_parser.SetFrameNumber(current_frame_number_);
312-
// NOTE: upon successful parsing, the block_buffer block data has been moved to the
313-
// parsed_block, though the block header is still valid.
314-
ParsedBlock parsed_block = block_parser.ParseBlock(block_buffer);
315-
316-
// NOTE: Visitable is either Ready or DeferredDecompression,
317-
// Invalid, Unknown, and Skip are not Visitable
318-
if (parsed_block.IsVisitable())
309+
if (SkipBlockProcessing())
319310
{
320-
// Deferred decompress failure implies a late uncovering of an invalid block.
321-
success = parsed_block.Decompress(block_parser); // Safe without testing block state.
322-
if (success)
311+
GFXRECON_CHECK_CONVERSION_DATA_LOSS(size_t, block_buffer.Header().size);
312+
}
313+
else
314+
{
315+
block_parser.SetBlockIndex(block_index_);
316+
block_parser.SetFrameNumber(current_frame_number_);
317+
// NOTE: upon successful parsing, the block_buffer block data has been moved to the
318+
// parsed_block, though the block header is still valid.
319+
ParsedBlock parsed_block = block_parser.ParseBlock(block_buffer);
320+
321+
if (parsed_block.Holds<FrameEndMarkerArgs>())
323322
{
324-
std::visit(process_visitor, parsed_block.GetArgs());
325-
success = process_visitor.IsSuccess();
323+
frame_begin_offset = file_stack_.back().active_file->GetCurrentPos();
324+
frame_begin_block_index = block_index_ + 1;
325+
}
326+
327+
// NOTE: Visitable is either Ready or DeferredDecompression,
328+
// Invalid, Unknown, and Skip are not Visitable
329+
if (parsed_block.IsVisitable())
330+
{
331+
// Deferred decompress failure implies a late uncovering of an invalid block.
332+
success = parsed_block.Decompress(block_parser); // Safe without testing block state.
326333
if (success)
327334
{
328-
std::visit(dispatch_visitor, parsed_block.GetArgs());
335+
std::visit(process_visitor, parsed_block.GetArgs());
336+
success = process_visitor.IsSuccess();
337+
if (success)
338+
{
339+
std::visit(dispatch_visitor, parsed_block.GetArgs());
340+
}
329341
}
330342
}
331-
}
332343

333-
// NOTE: Warnings for unknown/invalid blocks are handled in the BlockParser
344+
// NOTE: Warnings for unknown/invalid blocks are handled in the BlockParser
334345

335-
if (process_visitor.IsFrameDelimiter())
336-
{
337-
// The ProcessVisitor (pre-dispatch) is not the right place to update the frame state, so do it
338-
// here
339-
UpdateEndFrameState();
340-
break;
346+
if (process_visitor.IsFrameDelimiter())
347+
{
348+
// The ProcessVisitor (pre-dispatch) is not the right place to update the frame state, so do
349+
// it here
350+
UpdateEndFrameState();
351+
break;
352+
}
341353
}
342354
}
343-
}
344-
else
345-
{
346355

347-
success = HandleBlockEof("read", true);
356+
else
357+
{
358+
success = HandleBlockEof("read", true);
359+
}
348360
}
349361
++block_index_;
350-
DecrementRemainingCommands();
362+
if (frame_repeat_n == repeat_frame_n_times_) {
363+
DecrementRemainingCommands();
364+
}
351365
}
352-
353-
DecrementRemainingCommands();
354366
}
355367
return success;
356368
}

framework/decode/vulkan_replay_consumer_base.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ bool frame_first_queue_submit = false;
8080

8181
const size_t kMaxEventStatusRetries = 16;
8282

83+
8384
const char kUnknownDeviceLabel[] = "<Unknown>";
8485
const char kValidationLayerName[] = "VK_LAYER_KHRONOS_validation";
8586

framework/util/file_input_stream.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ class FStreamFileInputStream
5959
bool PeekBytes(void* buffer, size_t bytes);
6060
DataSpan ReadSpan(const size_t bytes);
6161

62+
int64_t GetCurrentPos() const { return util::platform::FileTell(fd_); }
63+
6264
explicit operator bool() const { return IsOpen(); }
6365

6466
protected:

tools/replay/replay_settings.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,12 @@ const char kOptions[] =
3232
"screenshot-all,--onhb|--omit-null-hardware-buffers,--qamr|--quit-after-measurement-range,--fmr|--flush-"
3333
"measurement-range,--flush-inside-measurement-range,--vssb|--virtual-swapchain-skip-blit,--use-captured-swapchain-"
3434
"indices,--dcp,--discard-cached-psos,--use-colorspace-fallback,--use-cached-psos,--dx12-override-object-names,--"
35-
"dx12-ags-inject-markers,--offscreen-swapchain-frame-boundary,--wait-before-present,--dump-resources-before-draw,"
36-
"--dump-resources-modifiable-state-only,--pbi-all,--preload-measurement-range,--add-new-pipeline-caches,--"
37-
"screenshot-ignore-FrameBoundaryANDROID,--deduplicate-device,--log-timestamps,--capture";
35+
"dx12-ags-inject-markers,--offscreen-swapchain-frame-boundary,--wait-before-present,--render-pass-barrier,--dump-resources-before-draw,"
36+
"--dump-resources-dump-depth-attachment,--dump-resources-dump-vertex-index-buffers,"
37+
"--dump-resources-json-output-per-command,--dump-resources-dump-immutable-resources,"
38+
"--dump-resources-dump-all-image-subresources,--dump-resources-dump-raw-images,--dump-resources-dump-"
39+
"separate-alpha,--dump-resources-modifiable-state-only,--pbi-all,--preload-measurement-range,"
40+
"--add-new-pipeline-caches,--screenshot-ignore-FrameBoundaryANDROID,--deduplicate-device,--log-timestamps,--capture";
3841
const char kArguments[] =
3942
"--log-level,--log-file,--cpu-mask,--gpu,--gpu-group,--pause-frame,--frame-repeats,--wsi,--surface-index,-m|--memory-translation,"
4043
"--replace-shaders,--screenshots,--screenshot-interval,--denied-messages,--allowed-messages,--screenshot-format,--"

tools/tool_settings.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ const char kOverrideGpuArgument[] = "--gpu";
8282
const char kOverrideGpuGroupArgument[] = "--gpu-group";
8383
const char kPausedOption[] = "--paused";
8484
const char kPauseFrameArgument[] = "--pause-frame";
85-
const char kRepeatFrameNTimesArgument[] = "--frame-repeats";
8685
const char kCaptureOption[] = "--capture";
86+
const char kRepeatFrameNTimesArgument[] = "--frame-repeats";
8787
const char kSkipFailedAllocationShortOption[] = "--sfa";
8888
const char kSkipFailedAllocationLongOption[] = "--skip-failed-allocations";
8989
const char kDiscardCachedPsosShortOption[] = "--dcp";

0 commit comments

Comments
 (0)