diff --git a/base/benchmark.hpp b/base/benchmark.hpp index 84014171..bae91a6a 100644 --- a/base/benchmark.hpp +++ b/base/benchmark.hpp @@ -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 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"; diff --git a/base/vulkanexamplebase.cpp b/base/vulkanexamplebase.cpp index 7db5a7d2..19c51b28 100644 --- a/base/vulkanexamplebase.cpp +++ b/base/vulkanexamplebase.cpp @@ -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 commands, bool hasValue, std::string help)