forked from LunarG/gfxreconstruct
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path0001-Add-measurement-framerange-support.patch
More file actions
674 lines (619 loc) · 29.4 KB
/
0001-Add-measurement-framerange-support.patch
File metadata and controls
674 lines (619 loc) · 29.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
From 6ff41c611bbf19b4bc5611766d62f732583c51a7 Mon Sep 17 00:00:00 2001
From: tomped01 <tom.pedersen@arm.com>
Date: Mon, 12 Jul 2021 20:25:25 +0200
Subject: [PATCH] Add measurement framerange support
This patch adds the option to specify start and stop frames for
secondary FPS measurements. In addition, options for aborting replay
after the end of the measurement range is reached and for flushing all
work at range boundaries have been added.
The framerange support is very useful when investigating performance for
large traces as creating new trimmed variants for every scene in the
trace can be very time consuming (and quickly becomes unmaintainable for
large sets of traces).
The abort option is very handy on slower development platforms where
replay of relatively small traces can take hours, this allows for
skipping work one might not be interested in for a particular run.
Change-Id: Ic3e81a53974d7955732e65337c2b8669f14ff887
---
framework/application/application.cpp | 106 ++++++++++++++-
framework/application/application.h | 36 ++++--
framework/decode/api_decoder.h | 2 +
framework/decode/file_processor.cpp | 8 ++
framework/decode/file_processor.h | 2 +
framework/decode/vulkan_consumer_base.h | 2 +
framework/decode/vulkan_decoder_base.cpp | 8 ++
framework/decode/vulkan_decoder_base.h | 2 +
.../decode/vulkan_replay_consumer_base.cpp | 26 +++-
.../decode/vulkan_replay_consumer_base.h | 2 +
framework/decode/vulkan_replay_options.h | 2 +
tools/replay/android_main.cpp | 15 ++-
tools/replay/desktop_main.cpp | 15 ++-
tools/replay/replay_settings.h | 121 +++++++++++++++++-
14 files changed, 317 insertions(+), 30 deletions(-)
diff --git a/framework/application/application.cpp b/framework/application/application.cpp
index 1ecff6a..19e3a58 100644
--- a/framework/application/application.cpp
+++ b/framework/application/application.cpp
@@ -54,9 +54,14 @@ void Application::SetFileProcessor(decode::FileProcessor* file_processor)
file_processor_ = file_processor;
}
-void Application::Run()
+void Application::Run(uint32_t measurement_start_frame,
+ uint32_t measurement_end_frame,
+ bool quit_after_range,
+ bool flush_measurement_range)
{
- running_ = true;
+ running_ = true;
+ measurement_start_time = 0;
+ measurement_end_time = 0;
while (running_)
{
@@ -65,9 +70,17 @@ void Application::Run()
// Only process the next frame if a quit event was not processed or not paused.
if (running_ && !paused_)
{
- PlaySingleFrame();
+ HandleMeasurementRange(
+ measurement_start_frame, measurement_end_frame, quit_after_range, flush_measurement_range);
+
+ if (running_)
+ {
+ PlaySingleFrame();
+ }
}
}
+
+ WriteMeasurementRangeFpsToConsole(measurement_start_frame, measurement_end_frame);
}
void Application::SetPaused(bool paused)
@@ -150,5 +163,92 @@ bool Application::UnregisterWindow(decode::Window* window)
return true;
}
+void Application::HandleMeasurementRange(uint32_t measurement_start_frame,
+ uint32_t measurement_end_frame,
+ bool quit_after_range,
+ bool flush_measurement_range)
+{
+ if (file_processor_->GetCurrentFrameNumber() == measurement_start_frame)
+ {
+ if (flush_measurement_range)
+ {
+ file_processor_->WaitDecodersIdle();
+ }
+
+ measurement_start_time = gfxrecon::util::datetime::GetTimestamp();
+ }
+ else if (file_processor_->GetCurrentFrameNumber() == measurement_end_frame)
+ {
+ // End before replay -> non inclusive range
+ if (flush_measurement_range)
+ {
+ file_processor_->WaitDecodersIdle();
+ }
+
+ measurement_end_time = gfxrecon::util::datetime::GetTimestamp();
+
+ if (quit_after_range)
+ {
+ running_ = false;
+ }
+ }
+}
+
+void Application::WriteMeasurementRangeFpsToConsole(uint32_t measurement_start_frame, uint32_t measurement_end_frame)
+{
+ if (file_processor_->GetErrorState() != gfxrecon::decode::FileProcessor::kErrorNone)
+ {
+ GFXRECON_LOG_ERROR("A failure has occurred during replay, cannot calculate measurement range FPS.");
+ return;
+ }
+
+ if (running_ && (file_processor_->GetCurrentFrameNumber() < measurement_end_frame))
+ {
+ GFXRECON_LOG_WARNING("Application is still running and has not yet reached the measurement "
+ "range end frame. Cannot calculate measurement range FPS.")
+ return;
+ }
+
+ if (measurement_start_frame >= measurement_end_frame)
+ {
+ GFXRECON_LOG_WARNING("Measurement start frame (%u) is greater than or equal to the end frame (%u). "
+ "Cannot calculate measurement range FPS.",
+ measurement_start_frame,
+ measurement_end_frame);
+
+ return;
+ }
+
+ if (file_processor_->GetCurrentFrameNumber() < measurement_start_frame)
+ {
+ GFXRECON_LOG_WARNING("Measurement range start frame (%u) is greater than the last replayed frame (%u). "
+ "Measurements were never started, cannot calculate measurement range FPS.",
+ measurement_start_frame,
+ file_processor_->GetCurrentFrameNumber());
+ return;
+ }
+
+ // Here we clip the range for convenience.
+ if (file_processor_->GetCurrentFrameNumber() < measurement_end_frame)
+ {
+ file_processor_->WaitDecodersIdle();
+ measurement_end_time = gfxrecon::util::datetime::GetTimestamp();
+ measurement_end_frame = file_processor_->GetCurrentFrameNumber();
+ }
+
+ double diff_time_sec = gfxrecon::util::datetime::ConvertTimestampToSeconds(
+ gfxrecon::util::datetime::DiffTimestamps(measurement_start_time, measurement_end_time));
+
+ uint32_t total_frames = measurement_end_frame - measurement_start_frame;
+ double fps = static_cast<double>(total_frames) / diff_time_sec;
+ GFXRECON_WRITE_CONSOLE("Measurement range FPS: %f fps, %f seconds, %u frame%s, 1 loop, framerange [%u-%u)",
+ fps,
+ diff_time_sec,
+ total_frames,
+ total_frames > 1 ? "s" : "",
+ measurement_start_frame,
+ measurement_end_frame);
+}
+
GFXRECON_END_NAMESPACE(application)
GFXRECON_END_NAMESPACE(gfxrecon)
diff --git a/framework/application/application.h b/framework/application/application.h
index 6f19414..5603a3c 100644
--- a/framework/application/application.h
+++ b/framework/application/application.h
@@ -27,9 +27,11 @@
#include "decode/file_processor.h"
#include "decode/window.h"
#include "util/defines.h"
+#include "util/date_time.h"
#include <string>
#include <vector>
+#include <limits>
GFXRECON_BEGIN_NAMESPACE(gfxrecon)
GFXRECON_BEGIN_NAMESPACE(application)
@@ -47,7 +49,10 @@ class Application
bool IsRunning() const { return running_; }
- void Run();
+ void Run(uint32_t measurement_start_frame = 0,
+ uint32_t measurement_end_frame = std::numeric_limits<uint32_t>::max(),
+ bool quit_after_range = false,
+ bool flush_measurement_range = false);
bool GetPaused() const { return paused_; }
@@ -68,18 +73,27 @@ class Application
void SetFileProcessor(decode::FileProcessor* file_processor);
+ void HandleMeasurementRange(uint32_t measurement_start_frame,
+ uint32_t measurement_end_frame,
+ bool quit_after_range,
+ bool flush_measurement_range);
+
+ void WriteMeasurementRangeFpsToConsole(uint32_t measurement_start_frame, uint32_t measurement_end_frame);
+
private:
// clang-format off
- std::vector<decode::Window*> windows_; ///< List of windows that have been registered with the application.
- decode::FileProcessor* file_processor_; ///< The FileProcessor object responsible for decoding and processing
- ///< capture file data.
- bool running_; ///< Indicates that the application is actively processing system
- ///< events for playback.
- bool paused_; ///< Indicates that the playback has been paused. When paused the
- ///< application will stop rendering, but will continue processing
- ///< system events.
- std::string name_; ///< Application name to display in window title bar.
- uint32_t pause_frame_; ///< The number for a frame that replay should pause after.
+ std::vector<decode::Window*> windows_; ///< List of windows that have been registered with the application.
+ decode::FileProcessor* file_processor_; ///< The FileProcessor object responsible for decoding and processing
+ ///< capture file data.
+ bool running_; ///< Indicates that the application is actively processing system
+ ///< events for playback.
+ bool paused_; ///< Indicates that the playback has been paused. When paused the
+ ///< application will stop rendering, but will continue processing
+ ///< system events.
+ std::string name_; ///< Application name to display in window title bar.
+ uint32_t pause_frame_; ///< The number for a frame that replay should pause after.
+ int64_t measurement_start_time; ///< The time when the measurement range started
+ int64_t measurement_end_time; ///< The time when the measurement range ended
// clang-format on
};
diff --git a/framework/decode/api_decoder.h b/framework/decode/api_decoder.h
index 29ab791..84a03cd 100644
--- a/framework/decode/api_decoder.h
+++ b/framework/decode/api_decoder.h
@@ -45,6 +45,8 @@ class ApiDecoder
public:
virtual ~ApiDecoder() {}
+ virtual void WaitIdle() = 0;
+
virtual bool SupportsApiCall(format::ApiCallId id) = 0;
virtual void DecodeFunctionCall(format::ApiCallId id,
diff --git a/framework/decode/file_processor.cpp b/framework/decode/file_processor.cpp
index 29f79fe..ba67f35 100644
--- a/framework/decode/file_processor.cpp
+++ b/framework/decode/file_processor.cpp
@@ -56,6 +56,14 @@ FileProcessor::~FileProcessor()
DecodeAllocator::DestroyInstance();
}
+void FileProcessor::WaitDecodersIdle()
+{
+ for (auto decoder : decoders_)
+ {
+ decoder->WaitIdle();
+ }
+};
+
bool FileProcessor::Initialize(const std::string& filename)
{
bool success = false;
diff --git a/framework/decode/file_processor.h b/framework/decode/file_processor.h
index 90673b3..05cc3bb 100644
--- a/framework/decode/file_processor.h
+++ b/framework/decode/file_processor.h
@@ -62,6 +62,8 @@ class FileProcessor
~FileProcessor();
+ void WaitDecodersIdle();
+
void SetAnnotationProcessor(AnnotationHandler* handler) { annotation_handler_ = handler; }
void AddDecoder(ApiDecoder* decoder) { decoders_.push_back(decoder); }
diff --git a/framework/decode/vulkan_consumer_base.h b/framework/decode/vulkan_consumer_base.h
index c0e17cb..1e45d3f 100644
--- a/framework/decode/vulkan_consumer_base.h
+++ b/framework/decode/vulkan_consumer_base.h
@@ -46,6 +46,8 @@ class VulkanConsumerBase
virtual ~VulkanConsumerBase() {}
+ virtual void WaitDevicesIdle() {}
+
virtual void ProcessStateBeginMarker(uint64_t frame_number) {}
virtual void ProcessStateEndMarker(uint64_t frame_number) {}
diff --git a/framework/decode/vulkan_decoder_base.cpp b/framework/decode/vulkan_decoder_base.cpp
index 7dc25ec..7ade7ac 100644
--- a/framework/decode/vulkan_decoder_base.cpp
+++ b/framework/decode/vulkan_decoder_base.cpp
@@ -30,6 +30,14 @@
GFXRECON_BEGIN_NAMESPACE(gfxrecon)
GFXRECON_BEGIN_NAMESPACE(decode)
+void VulkanDecoderBase::WaitIdle()
+{
+ for (auto consumer : consumers_)
+ {
+ consumer->WaitDevicesIdle();
+ }
+}
+
void VulkanDecoderBase::DispatchStateBeginMarker(uint64_t frame_number)
{
for (auto consumer : consumers_)
diff --git a/framework/decode/vulkan_decoder_base.h b/framework/decode/vulkan_decoder_base.h
index ea1ccee..645b9c1 100644
--- a/framework/decode/vulkan_decoder_base.h
+++ b/framework/decode/vulkan_decoder_base.h
@@ -53,6 +53,8 @@ class VulkanDecoderBase : public ApiDecoder
consumers_.erase(std::remove(consumers_.begin(), consumers_.end(), consumer));
}
+ virtual void WaitIdle() override;
+
virtual bool SupportsApiCall(format::ApiCallId call_id) override
{
return ((call_id >= format::ApiCallId::ApiCall_vkCreateInstance) &&
diff --git a/framework/decode/vulkan_replay_consumer_base.cpp b/framework/decode/vulkan_replay_consumer_base.cpp
index 4f354a9..95c3b34 100644
--- a/framework/decode/vulkan_replay_consumer_base.cpp
+++ b/framework/decode/vulkan_replay_consumer_base.cpp
@@ -44,7 +44,7 @@
GFXRECON_BEGIN_NAMESPACE(gfxrecon)
GFXRECON_BEGIN_NAMESPACE(decode)
-const size_t kMaxEventStatusRetries = 16;
+const size_t kMaxEventStatusRetries = 16;
const size_t kMaxQueryPoolResultsRetries = 16;
const int32_t kDefaultWindowPositionX = 0;
@@ -162,7 +162,10 @@ VulkanReplayConsumerBase::~VulkanReplayConsumerBase()
create_surface_count_);
}
- // Idle all devices before destroying other resources, and cleanup screenshot resources before destroying device.
+ // Idle all devices before destroying other resources.
+ WaitDevicesIdle();
+
+ // Cleanup screenshot resources before destroying device.
object_info_table_.VisitDeviceInfo([this](const DeviceInfo* info) {
assert(info != nullptr);
VkDevice device = info->handle;
@@ -170,8 +173,6 @@ VulkanReplayConsumerBase::~VulkanReplayConsumerBase()
auto device_table = GetDeviceTable(device);
assert(device_table != nullptr);
- device_table->DeviceWaitIdle(device);
-
if (screenshot_handler_ != nullptr)
{
screenshot_handler_->DestroyDeviceResources(device, device_table);
@@ -197,6 +198,19 @@ VulkanReplayConsumerBase::~VulkanReplayConsumerBase()
}
}
+void VulkanReplayConsumerBase::WaitDevicesIdle()
+{
+ object_info_table_.VisitDeviceInfo([this](const DeviceInfo* info) {
+ assert(info != nullptr);
+ VkDevice device = info->handle;
+
+ auto device_table = GetDeviceTable(device);
+ assert(device_table != nullptr);
+
+ device_table->DeviceWaitIdle(device);
+ });
+}
+
void VulkanReplayConsumerBase::ProcessStateBeginMarker(uint64_t frame_number)
{
GFXRECON_LOG_INFO("Loading state for captured frame %" PRId64, frame_number);
@@ -2991,8 +3005,8 @@ VkResult VulkanReplayConsumerBase::OverrideGetEventStatus(PFN_vkGetEventStatus f
assert((device_info != nullptr) && (event_info != nullptr));
VkResult result;
- VkDevice device = device_info->handle;
- VkEvent event = event_info->handle;
+ VkDevice device = device_info->handle;
+ VkEvent event = event_info->handle;
size_t retries = 0;
do
diff --git a/framework/decode/vulkan_replay_consumer_base.h b/framework/decode/vulkan_replay_consumer_base.h
index 0cc0aef..dc8fda0 100644
--- a/framework/decode/vulkan_replay_consumer_base.h
+++ b/framework/decode/vulkan_replay_consumer_base.h
@@ -74,6 +74,8 @@ class VulkanReplayConsumerBase : public VulkanConsumer
void SetFpsInfo(graphics::FpsInfo* fps_info) { fps_info_ = fps_info; }
+ virtual void WaitDevicesIdle() override;
+
virtual void ProcessStateBeginMarker(uint64_t frame_number) override;
virtual void ProcessStateEndMarker(uint64_t frame_number) override;
diff --git a/framework/decode/vulkan_replay_options.h b/framework/decode/vulkan_replay_options.h
index e74a3b0..12f764e 100644
--- a/framework/decode/vulkan_replay_options.h
+++ b/framework/decode/vulkan_replay_options.h
@@ -58,6 +58,8 @@ struct ReplayOptions
bool skip_failed_allocations{ false };
bool omit_pipeline_cache_data{ false };
bool remove_unsupported_features{ false };
+ bool quit_after_measurement_frame_range{ false };
+ bool flush_measurement_frame_range{ false };
int32_t override_gpu_index{ -1 };
int32_t surface_index{ -1 };
CreateResourceAllocator create_resource_allocator;
diff --git a/tools/replay/android_main.cpp b/tools/replay/android_main.cpp
index 154aa41..cbc00d8 100644
--- a/tools/replay/android_main.cpp
+++ b/tools/replay/android_main.cpp
@@ -44,6 +44,7 @@
#include <memory>
#include <string>
#include <vector>
+#include <utility>
const char kArgsExtentKey[] = "args";
const char kDefaultCaptureFile[] = "/sdcard/gfxrecon_capture" GFXRECON_FILE_EXTENSION;
@@ -116,9 +117,10 @@ void android_main(struct android_app* app)
else
{
gfxrecon::decode::VulkanTrackedObjectInfoTable tracked_object_info_table;
- gfxrecon::decode::VulkanReplayConsumer replay_consumer(
- window_factory.get(), GetReplayOptions(arg_parser, filename, &tracked_object_info_table));
- gfxrecon::decode::VulkanDecoder decoder;
+ gfxrecon::decode::ReplayOptions replay_options =
+ GetReplayOptions(arg_parser, filename, &tracked_object_info_table);
+ gfxrecon::decode::VulkanReplayConsumer replay_consumer(window_factory.get(), replay_options);
+ gfxrecon::decode::VulkanDecoder decoder;
replay_consumer.SetFatalErrorHandler(
[](const char* message) { throw std::runtime_error(message); });
@@ -127,6 +129,8 @@ void android_main(struct android_app* app)
file_processor.AddDecoder(&decoder);
application->SetPauseFrame(GetPauseFrame(arg_parser));
+ std::pair<uint32_t, uint32_t> measurement_frame_range = GetMeasurementFrameRange(arg_parser);
+
// Warn if the capture layer is active.
CheckActiveLayers(kLayerProperty);
@@ -135,7 +139,10 @@ void android_main(struct android_app* app)
application->SetPaused(true);
app->userData = application.get();
- application->Run();
+ application->Run(measurement_frame_range.first,
+ measurement_frame_range.second,
+ replay_options.quit_after_measurement_frame_range,
+ replay_options.flush_measurement_frame_range);
}
}
}
diff --git a/tools/replay/desktop_main.cpp b/tools/replay/desktop_main.cpp
index e2afa36..252863e 100644
--- a/tools/replay/desktop_main.cpp
+++ b/tools/replay/desktop_main.cpp
@@ -38,6 +38,7 @@
#include <stdexcept>
#include <string>
#include <vector>
+#include <utility>
#if defined(WIN32)
#if defined(VK_USE_PLATFORM_WIN32_KHR)
@@ -213,9 +214,10 @@ int main(int argc, const char** argv)
{
gfxrecon::graphics::FpsInfo fps_info;
gfxrecon::decode::VulkanTrackedObjectInfoTable tracked_object_info_table;
- gfxrecon::decode::VulkanReplayConsumer replay_consumer(
- window_factory.get(), GetReplayOptions(arg_parser, filename, &tracked_object_info_table));
- gfxrecon::decode::VulkanDecoder decoder;
+ gfxrecon::decode::ReplayOptions replay_options =
+ GetReplayOptions(arg_parser, filename, &tracked_object_info_table);
+ gfxrecon::decode::VulkanReplayConsumer replay_consumer(window_factory.get(), replay_options);
+ gfxrecon::decode::VulkanDecoder decoder;
replay_consumer.SetFatalErrorHandler([](const char* message) { throw std::runtime_error(message); });
replay_consumer.SetFpsInfo(&fps_info);
@@ -224,12 +226,17 @@ int main(int argc, const char** argv)
file_processor.AddDecoder(&decoder);
application->SetPauseFrame(GetPauseFrame(arg_parser));
+ std::pair<uint32_t, uint32_t> measurement_frame_range = GetMeasurementFrameRange(arg_parser);
+
// Warn if the capture layer is active.
CheckActiveLayers(gfxrecon::util::platform::GetEnv(kLayerEnvVar));
fps_info.Begin();
- application->Run();
+ application->Run(measurement_frame_range.first,
+ measurement_frame_range.second,
+ replay_options.quit_after_measurement_frame_range,
+ replay_options.flush_measurement_frame_range);
if ((file_processor.GetCurrentFrameNumber() > 0) &&
(file_processor.GetErrorState() == gfxrecon::decode::FileProcessor::kErrorNone))
diff --git a/tools/replay/replay_settings.h b/tools/replay/replay_settings.h
index fb13d4a..8798c9f 100644
--- a/tools/replay/replay_settings.h
+++ b/tools/replay/replay_settings.h
@@ -42,6 +42,7 @@
#include <sstream>
#include <string>
#include <vector>
+#include <utility>
#ifndef GFXRECON_REPLAY_SETTINGS_H
#define GFXRECON_REPLAY_SETTINGS_H
@@ -75,11 +76,16 @@ const char kScreenshotRangeArgument[] = "--screenshots";
const char kScreenshotFormatArgument[] = "--screenshot-format";
const char kScreenshotDirArgument[] = "--screenshot-dir";
const char kScreenshotFilePrefixArgument[] = "--screenshot-prefix";
+const char kMeasurementRangeArgument[] = "--measurement-frame-range";
+const char kQuitAfterMeasurementRangeOption[] = "--quit-after-measurement-range";
+const char kFlushMeasurementRangeOption[] = "--flush-measurement-range";
const char kOptions[] = "-h|--help,--version,--log-debugview,--no-debug-popup,--paused,--sync,--sfa|--skip-failed-"
- "allocations,--opcd|--omit-pipeline-cache-data,--remove-unsupported,--screenshot-all";
+ "allocations,--opcd|--omit-pipeline-cache-data,--remove-unsupported,--screenshot-all"
+ "--qamr|--quit-after-measurement-range,--fmr|--flush-measurement-range";
const char kArguments[] = "--log-level,--log-file,--gpu,--pause-frame,--wsi,--surface-index,-m|--memory-translation,--"
- "replace-shaders,--screenshots,--screenshot-format,--screenshot-dir,--screenshot-prefix";
+ "replace-shaders,--screenshots,--screenshot-format,--screenshot-dir,--screenshot-prefix"
+ "--mfr|--measurement-frame-range";
enum class WsiPlatform
{
@@ -502,6 +508,89 @@ GetScreenshotRanges(const gfxrecon::util::ArgumentParser& arg_parser)
return ranges;
}
+static std::pair<uint32_t, uint32_t> GetMeasurementFrameRange(const gfxrecon::util::ArgumentParser& arg_parser)
+{
+ std::pair<uint32_t, uint32_t> measurement_frame_range(0, std::numeric_limits<uint32_t>::max());
+
+ const auto& value = arg_parser.GetArgumentValue(kMeasurementRangeArgument);
+ if (!value.empty())
+ {
+ std::string range = value;
+
+ if (std::count(range.begin(), range.end(), '-') != 1)
+ {
+ GFXRECON_LOG_WARNING(
+ "Ignoring invalid measurement frame range \"%s\". Must have format: <start_frame>-<end_frame>",
+ range.c_str());
+ return measurement_frame_range;
+ }
+
+ // Remove whitespace.
+ range.erase(std::remove_if(range.begin(), range.end(), ::isspace), range.end());
+
+ // Split string on '-' delimiter.
+ bool invalid = false;
+ std::vector<std::string> values;
+ std::istringstream range_input;
+ range_input.str(range);
+
+ for (std::string token; std::getline(range_input, token, '-');)
+ {
+ if (token.empty())
+ {
+ break;
+ }
+
+ // Check that the range string only contains numbers.
+ size_t count = std::count_if(token.begin(), token.end(), ::isdigit);
+ if (count == token.length())
+ {
+ values.push_back(token);
+ }
+ else
+ {
+ GFXRECON_LOG_WARNING(
+ "Ignoring invalid measurement frame range \"%s\", which contains non-numeric values",
+ range.c_str());
+ invalid = true;
+ break;
+ }
+ }
+
+ if (values.size() < 2)
+ {
+ GFXRECON_LOG_WARNING("Ignoring invalid measurement frame range \"%s\", does not have two values.",
+ range.c_str());
+
+ invalid = true;
+ }
+
+ if (!invalid)
+ {
+ uint32_t start_frame = std::stoi(values[0]);
+ uint32_t end_frame = std::stoi(values[1]);
+
+ if (start_frame >= end_frame)
+ {
+ GFXRECON_LOG_WARNING("Ignoring invalid measurement frame range \"%s\", where first frame is "
+ "greater than or equal to the last frame",
+ range.c_str());
+
+ return measurement_frame_range;
+ }
+
+ measurement_frame_range.first = start_frame;
+ measurement_frame_range.second = end_frame;
+ }
+ else
+ {
+ GFXRECON_LOG_WARNING("Ignoring invalid measurement frame range \"%s\".", range.c_str());
+ }
+ }
+
+ return measurement_frame_range;
+}
+
static gfxrecon::decode::CreateResourceAllocator
GetCreateResourceAllocatorFunc(const gfxrecon::util::ArgumentParser& arg_parser,
const std::string& filename,
@@ -557,6 +646,16 @@ GetReplayOptions(const gfxrecon::util::ArgumentParser& arg_parser,
replay_options.remove_unsupported_features = true;
}
+ if (arg_parser.IsOptionSet(kQuitAfterMeasurementRangeOption))
+ {
+ replay_options.quit_after_measurement_frame_range = true;
+ }
+
+ if (arg_parser.IsOptionSet(kFlushMeasurementRangeOption))
+ {
+ replay_options.flush_measurement_frame_range = true;
+ }
+
if (arg_parser.IsOptionSet(kSkipFailedAllocationLongOption) ||
arg_parser.IsOptionSet(kSkipFailedAllocationShortOption))
{
@@ -654,6 +753,24 @@ static void PrintUsage(const char* exe_name)
#if defined(WIN32)
GFXRECON_WRITE_CONSOLE(" --log-debugview\tLog messages with OutputDebugStringA.");
#endif
+ GFXRECON_WRITE_CONSOLE(" --measurement-frame-range <start_frame>-<end_frame>");
+ GFXRECON_WRITE_CONSOLE(" \t\tCustom framerange to measure FPS for.");
+ GFXRECON_WRITE_CONSOLE(" \t\tThis range will include the start frame but not the end frame.");
+ GFXRECON_WRITE_CONSOLE(" \t\tThe result will be in addition to the replay FPS,");
+ GFXRECON_WRITE_CONSOLE(" \t\twhich is a separate FPS result for the whole trace excluding");
+ GFXRECON_WRITE_CONSOLE(" \t\tthe loading frames. The measurement frame range defaults to all frames");
+ GFXRECON_WRITE_CONSOLE(" \t\tin the trace (including the loading frames) but can be");
+ GFXRECON_WRITE_CONSOLE(" \t\tconfigured for any range. If the end frame is past the");
+ GFXRECON_WRITE_CONSOLE(" \t\tlast frame in the trace it will be clamped to the frame after the last");
+ GFXRECON_WRITE_CONSOLE(" \t\t(so in that case the results would include the last frame).");
+ GFXRECON_WRITE_CONSOLE(" --quit-after-measurement-range");
+ GFXRECON_WRITE_CONSOLE(" \t\tIf this is specified the replayer will abort");
+ GFXRECON_WRITE_CONSOLE(" \t\twhen it reaches the <end_frame> specified in");
+ GFXRECON_WRITE_CONSOLE(" \t\tthe --measurement-frame-range argument.");
+ GFXRECON_WRITE_CONSOLE(" --flush-measurement-range");
+ GFXRECON_WRITE_CONSOLE(" \t\tIf this is specified the replayer will flush")
+ GFXRECON_WRITE_CONSOLE(" \t\tand wait for all current GPU work to finish at the");
+ GFXRECON_WRITE_CONSOLE(" \t\tstart and end of the measurement range.");
GFXRECON_WRITE_CONSOLE(" --gpu <index>\t\tUse the specified device for replay, where index");
GFXRECON_WRITE_CONSOLE(" \t\tis the zero-based index to the array of physical devices");
GFXRECON_WRITE_CONSOLE(" \t\treturned by vkEnumeratePhysicalDevices. Replay may fail");
--
2.17.1