Add option to only render a given number of frames.

This is useful on very slow targets, such as GPU emulators.
This commit is contained in:
Per Inge Mathisen 2021-07-29 12:15:58 +02:00
parent 2c8b29b39c
commit 5f72b0faa3
2 changed files with 6 additions and 0 deletions

View file

@ -23,6 +23,7 @@ namespace vks
public:
bool active = false;
bool outputFrameTimes = false;
int outputFrames = -1; // -1 means no frames limit
uint32_t warmup = 1;
uint32_t duration = 10;
std::vector<double> frameTimes;
@ -61,6 +62,7 @@ namespace vks
runtime += tDiff;
frameTimes.push_back(tDiff);
frameCount++;
if (outputFrames != -1 && outputFrames == frameCount) break;
};
std::cout << "Benchmark finished" << "\n";
std::cout << "device : " << deviceProps.deviceName << " (driver version: " << deviceProps.driverVersion << ")" << "\n";

View file

@ -788,6 +788,9 @@ VulkanExampleBase::VulkanExampleBase(bool enableValidation)
if (commandLineParser.isSet("benchmarkresultframes")) {
benchmark.outputFrameTimes = true;
}
if (commandLineParser.isSet("benchmarkframes")) {
benchmark.outputFrames = commandLineParser.getValueAsInt("benchmarkframes", benchmark.outputFrames);
}
#if defined(VK_USE_PLATFORM_ANDROID_KHR)
// Vulkan library is loaded dynamically on Android
@ -2772,6 +2775,7 @@ CommandLineParser::CommandLineParser()
add("benchmarkruntime", { "-br", "--benchruntime" }, 1, "Set duration time for benchmark mode in seconds");
add("benchmarkresultfile", { "-bf", "--benchfilename" }, 1, "Set file name for benchmark results");
add("benchmarkresultframes", { "-bt", "--benchframetimes" }, 0, "Save frame times to benchmark results file");
add("benchmarkframes", { "-bfs", "--benchmarkframes" }, 1, "Only render the given number of frames");
}
void CommandLineParser::add(std::string name, std::vector<std::string> commands, bool hasValue, std::string help)