Skip to content

Commit

Permalink
Add --flush-inside-measurement-range option
Browse files Browse the repository at this point in the history
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
  • Loading branch information
marius-pelegrin-arm committed Jan 26, 2024
1 parent 118b535 commit 3c701e5
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 13 deletions.
1 change: 1 addition & 0 deletions framework/decode/replay_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ struct ReplayOptions
bool omit_null_hardware_buffers{ false };
bool quit_after_measurement_frame_range{ false };
bool flush_measurement_frame_range{ false };
bool flush_inside_measurement_range{ false };
bool force_windowed{ false };
uint32_t windowed_width{ 0 };
uint32_t windowed_height{ 0 };
Expand Down
11 changes: 7 additions & 4 deletions framework/graphics/fps_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,14 @@ FpsInfo::FpsInfo(uint64_t measurement_start_frame,
bool has_measurement_range,
bool quit_after_range,
bool flush_measurement_range,
bool flush_inside_measurement_range,
const std::string_view measurement_file_name) :
measurement_start_frame_(measurement_start_frame),
measurement_end_frame_(measurement_end_frame), measurement_start_time_(0), measurement_end_time_(0),
quit_after_range_(quit_after_range), flush_measurement_range_(flush_measurement_range),
has_measurement_range_(has_measurement_range), started_measurement_(false), ended_measurement_(false),
frame_start_time_(0), frame_durations_(), measurement_file_name_(measurement_file_name)
flush_inside_measurement_range_(flush_inside_measurement_range), has_measurement_range_(has_measurement_range),
started_measurement_(false), ended_measurement_(false), frame_start_time_(0), frame_durations_(),
measurement_file_name_(measurement_file_name)
{
if (has_measurement_range_)
{
Expand Down Expand Up @@ -177,8 +179,9 @@ void FpsInfo::EndFrame(uint64_t frame)

bool FpsInfo::ShouldWaitIdleAfterFrame(uint64_t frame)
{
bool range_ended = frame == measurement_end_frame_;
return flush_measurement_range_ && range_ended;
bool range_ended = frame == measurement_end_frame_;
bool inside_range = frame >= measurement_start_frame_ && frame <= measurement_end_frame_;
return (flush_measurement_range_ && range_ended) || (flush_inside_measurement_range_ && inside_range);
}

void FpsInfo::EndFile(uint64_t frame)
Expand Down
14 changes: 8 additions & 6 deletions framework/graphics/fps_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,13 @@ GFXRECON_BEGIN_NAMESPACE(graphics)
class FpsInfo
{
public:
FpsInfo(uint64_t measurement_start_frame = 1,
uint64_t measurement_end_frame = std::numeric_limits<uint64_t>::max(),
bool has_measurement_range = false,
bool quit_after_range = false,
bool flush_measurement_range = false,
const std::string_view measurement_file_name = "");
FpsInfo(uint64_t measurement_start_frame = 1,
uint64_t measurement_end_frame = std::numeric_limits<uint64_t>::max(),
bool has_measurement_range = false,
bool quit_after_range = false,
bool flush_measurement_range = false,
bool flush_inside_measurement_range = false,
const std::string_view measurement_file_name = "");

void LogToConsole();

Expand Down Expand Up @@ -69,6 +70,7 @@ class FpsInfo
bool has_measurement_range_;
bool quit_after_range_;
bool flush_measurement_range_;
bool flush_inside_measurement_range_;

bool started_measurement_;
bool ended_measurement_;
Expand Down
1 change: 1 addition & 0 deletions tools/replay/android_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ void android_main(struct android_app* app)
has_mfr,
replay_options.quit_after_measurement_frame_range,
replay_options.flush_measurement_frame_range,
replay_options.flush_inside_measurement_range,
measurement_file_name);

replay_consumer.SetFatalErrorHandler([](const char* message) { throw std::runtime_error(message); });
Expand Down
3 changes: 3 additions & 0 deletions tools/replay/desktop_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,15 @@ int main(int argc, const char** argv)
bool has_mfr = false;
bool quit_after_measurement_frame_range = false;
bool flush_measurement_frame_range = false;
bool flush_inside_measurement_range = false;
std::string measurement_file_name;

if (vulkan_replay_options.enable_vulkan)
{
has_mfr = GetMeasurementFrameRange(arg_parser, start_frame, end_frame);
quit_after_measurement_frame_range = vulkan_replay_options.quit_after_measurement_frame_range;
flush_measurement_frame_range = vulkan_replay_options.flush_measurement_frame_range;
flush_inside_measurement_range = vulkan_replay_options.flush_inside_measurement_range;
}

if (has_mfr)
Expand All @@ -165,6 +167,7 @@ int main(int argc, const char** argv)
has_mfr,
quit_after_measurement_frame_range,
flush_measurement_frame_range,
flush_inside_measurement_range,
measurement_file_name);

gfxrecon::decode::VulkanReplayConsumer vulkan_replay_consumer(application, vulkan_replay_options);
Expand Down
10 changes: 7 additions & 3 deletions tools/replay/replay_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
const char kOptions[] =
"-h|--help,--version,--log-debugview,--no-debug-popup,--paused,--sync,--sfa|--skip-failed-allocations,--"
"opcd|--omit-pipeline-cache-data,--remove-unsupported,--validate,--debug-device-lost,--create-dummy-allocations,--"
"screenshot-all,--onhb|--omit-null-hardware-buffers,--qamr|--quit-after-measurement-"
"range,--fmr|--flush-measurement-range,--use-captured-swapchain-indices,--dcp,--discard-cached-psos,"
"--use-colorspace-fallback,--use-cached-psos,--dx12-override-object-names";
"screenshot-all,--onhb|--omit-null-hardware-buffers,--qamr|--quit-after-measurement-range,--fmr|--flush-"
"measurement-range,--flush-inside-measurement-range,--use-captured-swapchain-indices,--dcp,--"
"discard-cached-psos,--use-colorspace-fallback,--use-cached-psos,--dx12-override-object-names";
const char kArguments[] =
"--log-level,--log-file,--gpu,--gpu-group,--pause-frame,--wsi,--surface-index,-m|--memory-translation,"
"--replace-shaders,--screenshots,--denied-messages,--allowed-messages,--screenshot-format,--"
Expand Down Expand Up @@ -223,6 +223,10 @@ static void PrintUsage(const char* exe_name)
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(" --flush-inside-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\tend of each frame inside the measurement range.");
GFXRECON_WRITE_CONSOLE(" --gpu-group <index>\tUse the specified device group for replay, where index");
GFXRECON_WRITE_CONSOLE(" \t\tis the zero-based index to the array of physical device group");
GFXRECON_WRITE_CONSOLE(" \t\treturned by vkEnumeratePhysicalDeviceGroups. Replay may fail");
Expand Down
6 changes: 6 additions & 0 deletions tools/tool_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ const char kMeasurementRangeArgument[] = "--measurement-frame-range";
const char kMeasurementFileArgument[] = "--measurement-file";
const char kQuitAfterMeasurementRangeOption[] = "--quit-after-measurement-range";
const char kFlushMeasurementRangeOption[] = "--flush-measurement-range";
const char kFlushInsideMeasurementRangeOption[] = "--flush-inside-measurement-range";
const char kSwapchainOption[] = "--swapchain";
const char kEnableUseCapturedSwapchainIndices[] =
"--use-captured-swapchain-indices"; // The same: util::SwapchainOption::kCaptured
Expand Down Expand Up @@ -810,6 +811,11 @@ static void GetReplayOptions(gfxrecon::decode::ReplayOptions& options, const gfx
options.flush_measurement_frame_range = true;
}

if (arg_parser.IsOptionSet(kFlushInsideMeasurementRangeOption))
{
options.flush_inside_measurement_range = true;
}

const auto& override_gpu = arg_parser.GetArgumentValue(kOverrideGpuArgument);
if (!override_gpu.empty())
{
Expand Down

0 comments on commit 3c701e5

Please sign in to comment.