Skip to content

Commit 3946108

Browse files
Add --flush-inside-measurement-range option
Add option to flush and wait all current GPU work to finish at the end of every frame inside the measurement range. This allows to take measurements on each frame individually without jobs interleaving between two frames. Change-Id: I5e55fcfc33c4baa344445a963fedbe80e94c925c
1 parent 4fa32d6 commit 3946108

File tree

7 files changed

+33
-13
lines changed

7 files changed

+33
-13
lines changed

framework/decode/replay_options.h

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ struct ReplayOptions
4747
bool omit_null_hardware_buffers{ false };
4848
bool quit_after_measurement_frame_range{ false };
4949
bool flush_measurement_frame_range{ false };
50+
bool flush_inside_measurement_range{ false };
5051
bool force_windowed{ false };
5152
uint32_t windowed_width{ 0 };
5253
uint32_t windowed_height{ 0 };

framework/graphics/fps_info.cpp

+7-4
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,13 @@ FpsInfo::FpsInfo(uint64_t measurement_start_frame,
5858
uint64_t measurement_end_frame,
5959
bool has_measurement_range,
6060
bool quit_after_range,
61-
bool flush_measurement_range) :
61+
bool flush_measurement_range,
62+
bool flush_inside_measurement_range) :
6263
measurement_start_frame_(measurement_start_frame),
6364
measurement_end_frame_(measurement_end_frame), measurement_start_time_(0), measurement_end_time_(0),
6465
quit_after_range_(quit_after_range), flush_measurement_range_(flush_measurement_range),
65-
has_measurement_range_(has_measurement_range), started_measurement_(false), ended_measurement_(false)
66+
flush_inside_measurement_range_(flush_inside_measurement_range), has_measurement_range_(has_measurement_range),
67+
started_measurement_(false), ended_measurement_(false)
6668
{}
6769

6870
void FpsInfo::BeginFile()
@@ -109,8 +111,9 @@ void FpsInfo::EndFrame(uint64_t frame)
109111

110112
bool FpsInfo::ShouldWaitIdleAfterFrame(uint64_t frame)
111113
{
112-
bool range_ended = frame == measurement_end_frame_;
113-
return flush_measurement_range_ && range_ended;
114+
bool range_ended = frame == measurement_end_frame_;
115+
bool inside_range = frame >= measurement_start_frame_ && frame <= measurement_end_frame_;
116+
return (flush_measurement_range_ && range_ended) || (flush_inside_measurement_range_ && inside_range);
114117
}
115118

116119
void FpsInfo::EndFile(uint64_t frame)

framework/graphics/fps_info.h

+7-5
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,12 @@ GFXRECON_BEGIN_NAMESPACE(graphics)
3535
class FpsInfo
3636
{
3737
public:
38-
FpsInfo(uint64_t measurement_start_frame = 1,
39-
uint64_t measurement_end_frame = std::numeric_limits<uint64_t>::max(),
40-
bool has_measurement_range = false,
41-
bool quit_after_range = false,
42-
bool flush_measurement_range = false);
38+
FpsInfo(uint64_t measurement_start_frame = 1,
39+
uint64_t measurement_end_frame = std::numeric_limits<uint64_t>::max(),
40+
bool has_measurement_range = false,
41+
bool quit_after_range = false,
42+
bool flush_measurement_range = false,
43+
bool flush_inside_measurement_range = false);
4344

4445
void LogToConsole();
4546

@@ -67,6 +68,7 @@ class FpsInfo
6768
bool has_measurement_range_;
6869
bool quit_after_range_;
6970
bool flush_measurement_range_;
71+
bool flush_inside_measurement_range_;
7072

7173
bool started_measurement_;
7274
bool ended_measurement_;

tools/replay/android_main.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,8 @@ void android_main(struct android_app* app)
124124
static_cast<uint64_t>(end_frame),
125125
has_mfr,
126126
replay_options.quit_after_measurement_frame_range,
127-
replay_options.flush_measurement_frame_range);
127+
replay_options.flush_measurement_frame_range,
128+
replay_options.flush_inside_measurement_range);
128129

129130
replay_consumer.SetFatalErrorHandler([](const char* message) { throw std::runtime_error(message); });
130131
replay_consumer.SetFpsInfo(&fps_info);

tools/replay/desktop_main.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -146,19 +146,22 @@ int main(int argc, const char** argv)
146146
bool has_mfr = false;
147147
bool quit_after_measurement_frame_range = false;
148148
bool flush_measurement_frame_range = false;
149+
bool flush_inside_measurement_range = false;
149150

150151
if (vulkan_replay_options.enable_vulkan)
151152
{
152153
has_mfr = GetMeasurementFrameRange(arg_parser, start_frame, end_frame);
153154
quit_after_measurement_frame_range = vulkan_replay_options.quit_after_measurement_frame_range;
154155
flush_measurement_frame_range = vulkan_replay_options.flush_measurement_frame_range;
156+
flush_inside_measurement_range = vulkan_replay_options.flush_inside_measurement_range;
155157
}
156158

157159
gfxrecon::graphics::FpsInfo fps_info(static_cast<uint64_t>(start_frame),
158160
static_cast<uint64_t>(end_frame),
159161
has_mfr,
160162
quit_after_measurement_frame_range,
161-
flush_measurement_frame_range);
163+
flush_measurement_frame_range,
164+
flush_inside_measurement_range);
162165

163166
gfxrecon::decode::VulkanReplayConsumer vulkan_replay_consumer(application, vulkan_replay_options);
164167
gfxrecon::decode::VulkanDecoder vulkan_decoder;

tools/replay/replay_settings.h

+6-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ const char kOptions[] =
3030
"-h|--help,--version,--log-debugview,--no-debug-popup,--paused,--sync,--sfa|--skip-failed-allocations,--"
3131
"opcd|--omit-pipeline-cache-data,--remove-unsupported,--validate,--debug-device-lost,--create-dummy-allocations,--"
3232
"screenshot-all,--onhb|--omit-null-hardware-buffers,--qamr|--quit-after-measurement-"
33-
"range,--fmr|--flush-measurement-range,--use-captured-swapchain-indices,--dcp,--discard-cached-psos,"
34-
"--dx12-override-object-names";
33+
"range,--fmr|--flush-measurement-range,--flush-inside-measurement-range,--use-captured-swapchain-indices,--dcp,--"
34+
"discard-cached-psos,--dx12-override-object-names";
3535
const char kArguments[] =
3636
"--log-level,--log-file,--gpu,--gpu-group,--pause-frame,--wsi,--surface-index,-m|--memory-translation,"
3737
"--replace-shaders,--screenshots,--denied-messages,--allowed-messages,--screenshot-format,--"
@@ -191,6 +191,10 @@ static void PrintUsage(const char* exe_name)
191191
GFXRECON_WRITE_CONSOLE(" \t\tIf this is specified the replayer will flush")
192192
GFXRECON_WRITE_CONSOLE(" \t\tand wait for all current GPU work to finish at the");
193193
GFXRECON_WRITE_CONSOLE(" \t\tstart and end of the measurement range.");
194+
GFXRECON_WRITE_CONSOLE(" --flush-inside-measurement-range");
195+
GFXRECON_WRITE_CONSOLE(" \t\tIf this is specified the replayer will flush")
196+
GFXRECON_WRITE_CONSOLE(" \t\tand wait for all current GPU work to finish at the");
197+
GFXRECON_WRITE_CONSOLE(" \t\tend of each frame inside the measurement range.");
194198
GFXRECON_WRITE_CONSOLE(" --gpu-group <index>\t\tUse the specified device group for replay, where index");
195199
GFXRECON_WRITE_CONSOLE(" \t\tis the zero-based index to the array of physical device group");
196200
GFXRECON_WRITE_CONSOLE(" \t\treturned by vkEnumeratePhysicalDeviceGroups. Replay may fail");

tools/tool_settings.h

+6
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ const char kOutput[] = "--output";
9999
const char kMeasurementRangeArgument[] = "--measurement-frame-range";
100100
const char kQuitAfterMeasurementRangeOption[] = "--quit-after-measurement-range";
101101
const char kFlushMeasurementRangeOption[] = "--flush-measurement-range";
102+
const char kFlushInsideMeasurementRangeOption[] = "--flush-inside-measurement-range";
102103
const char kEnableUseCapturedSwapchainIndices[] = "--use-captured-swapchain-indices";
103104
const char kFormatArgument[] = "--format";
104105
const char kIncludeBinariesOption[] = "--include-binaries";
@@ -710,6 +711,11 @@ static void GetReplayOptions(gfxrecon::decode::ReplayOptions& options, const gfx
710711
options.flush_measurement_frame_range = true;
711712
}
712713

714+
if (arg_parser.IsOptionSet(kFlushInsideMeasurementRangeOption))
715+
{
716+
options.flush_inside_measurement_range = true;
717+
}
718+
713719
const auto& override_gpu = arg_parser.GetArgumentValue(kOverrideGpuArgument);
714720
if (!override_gpu.empty())
715721
{

0 commit comments

Comments
 (0)