diff options
Diffstat (limited to 'libs/hwui/tests/macrobench/main.cpp')
-rw-r--r-- | libs/hwui/tests/macrobench/main.cpp | 197 |
1 files changed, 111 insertions, 86 deletions
diff --git a/libs/hwui/tests/macrobench/main.cpp b/libs/hwui/tests/macrobench/main.cpp index 616558f29676..0a9a74eccfc9 100644 --- a/libs/hwui/tests/macrobench/main.cpp +++ b/libs/hwui/tests/macrobench/main.cpp @@ -45,7 +45,7 @@ static TestScene::Options gOpts; std::unique_ptr<benchmark::BenchmarkReporter> gBenchmarkReporter; void run(const TestScene::Info& info, const TestScene::Options& opts, - benchmark::BenchmarkReporter* reporter); + benchmark::BenchmarkReporter* reporter); static void printHelp() { printf(R"( @@ -67,6 +67,7 @@ OPTIONS: --onscreen Render tests on device screen. By default tests are offscreen rendered --benchmark_format Set output format. Possible values are tabular, json, csv + --renderer=TYPE Sets the render pipeline to use. May be opengl, skiagl, or skiavk )"); } @@ -81,7 +82,7 @@ static void listTests() { do { int toPrint = dlen; if (toPrint > 50) { - char* found = (char*) memrchr(col2, ' ', 50); + char* found = (char*)memrchr(col2, ' ', 50); if (found) { toPrint = found - col2; } else { @@ -93,7 +94,8 @@ static void listTests() { col2 += toPrint; dlen -= toPrint; while (*col2 == ' ') { - col2++; dlen--; + col2++; + dlen--; } } while (dlen > 0); printf("\n"); @@ -119,7 +121,7 @@ static void moveToCpuSet(const char* cpusetName) { } pid_t pid = getpid(); - int towrite = snprintf(buffer, BUF_SIZE, "%ld", (long) pid); + int towrite = snprintf(buffer, BUF_SIZE, "%ld", (long)pid); if (towrite >= BUF_SIZE) { fprintf(stderr, "Buffer wasn't large enough?\n"); } else { @@ -144,6 +146,20 @@ static bool setBenchmarkFormat(const char* format) { return true; } +static bool setRenderer(const char* renderer) { + if (!strcmp(renderer, "opengl")) { + Properties::overrideRenderPipelineType(RenderPipelineType::OpenGL); + } else if (!strcmp(renderer, "skiagl")) { + Properties::overrideRenderPipelineType(RenderPipelineType::SkiaGL); + } else if (!strcmp(renderer, "skiavk")) { + Properties::overrideRenderPipelineType(RenderPipelineType::SkiaVulkan); + } else { + fprintf(stderr, "Unknown format '%s'", renderer); + return false; + } + return true; +} + // For options that only exist in long-form. Anything in the // 0-255 range is reserved for short options (which just use their ASCII value) namespace LongOpts { @@ -156,22 +172,23 @@ enum { BenchmarkFormat, Onscreen, Offscreen, + Renderer, }; } static const struct option LONG_OPTIONS[] = { - { "frames", required_argument, nullptr, 'f' }, - { "repeat", required_argument, nullptr, 'r' }, - { "help", no_argument, nullptr, 'h' }, - { "list", no_argument, nullptr, LongOpts::List }, - { "wait-for-gpu", no_argument, nullptr, LongOpts::WaitForGpu }, - { "report-frametime", optional_argument, nullptr, LongOpts::ReportFrametime }, - { "cpuset", required_argument, nullptr, LongOpts::CpuSet }, - { "benchmark_format", required_argument, nullptr, LongOpts::BenchmarkFormat }, - { "onscreen", no_argument, nullptr, LongOpts::Onscreen }, - { "offscreen", no_argument, nullptr, LongOpts::Offscreen }, - { 0, 0, 0, 0 } -}; + {"frames", required_argument, nullptr, 'f'}, + {"repeat", required_argument, nullptr, 'r'}, + {"help", no_argument, nullptr, 'h'}, + {"list", no_argument, nullptr, LongOpts::List}, + {"wait-for-gpu", no_argument, nullptr, LongOpts::WaitForGpu}, + {"report-frametime", optional_argument, nullptr, LongOpts::ReportFrametime}, + {"cpuset", required_argument, nullptr, LongOpts::CpuSet}, + {"benchmark_format", required_argument, nullptr, LongOpts::BenchmarkFormat}, + {"onscreen", no_argument, nullptr, LongOpts::Onscreen}, + {"offscreen", no_argument, nullptr, LongOpts::Offscreen}, + {"renderer", required_argument, nullptr, LongOpts::Renderer}, + {0, 0, 0, 0}}; static const char* SHORT_OPTIONS = "c:r:h"; @@ -181,97 +198,105 @@ void parseOptions(int argc, char* argv[]) { opterr = 0; while (true) { - /* getopt_long stores the option index here. */ int option_index = 0; c = getopt_long(argc, argv, SHORT_OPTIONS, LONG_OPTIONS, &option_index); - if (c == -1) - break; + if (c == -1) break; switch (c) { - case 0: - // Option set a flag, don't need to do anything - // (although none of the current LONG_OPTIONS do this...) - break; - - case LongOpts::List: - listTests(); - exit(EXIT_SUCCESS); - break; - - case 'c': - gOpts.count = atoi(optarg); - if (!gOpts.count) { - fprintf(stderr, "Invalid frames argument '%s'\n", optarg); - error = true; - } - break; + case 0: + // Option set a flag, don't need to do anything + // (although none of the current LONG_OPTIONS do this...) + break; - case 'r': - gRepeatCount = atoi(optarg); - if (!gRepeatCount) { - fprintf(stderr, "Invalid repeat argument '%s'\n", optarg); - error = true; - } else { - gRepeatCount = (gRepeatCount > 0 ? gRepeatCount : INT_MAX); - } - break; + case LongOpts::List: + listTests(); + exit(EXIT_SUCCESS); + break; - case LongOpts::ReportFrametime: - if (optarg) { - gOpts.reportFrametimeWeight = atoi(optarg); - if (!gOpts.reportFrametimeWeight) { - fprintf(stderr, "Invalid report frametime weight '%s'\n", optarg); + case 'c': + gOpts.count = atoi(optarg); + if (!gOpts.count) { + fprintf(stderr, "Invalid frames argument '%s'\n", optarg); error = true; } - } else { - gOpts.reportFrametimeWeight = 10; - } - break; + break; - case LongOpts::WaitForGpu: - Properties::waitForGpuCompletion = true; - break; + case 'r': + gRepeatCount = atoi(optarg); + if (!gRepeatCount) { + fprintf(stderr, "Invalid repeat argument '%s'\n", optarg); + error = true; + } else { + gRepeatCount = (gRepeatCount > 0 ? gRepeatCount : INT_MAX); + } + break; - case LongOpts::CpuSet: - if (!optarg) { - error = true; + case LongOpts::ReportFrametime: + if (optarg) { + gOpts.reportFrametimeWeight = atoi(optarg); + if (!gOpts.reportFrametimeWeight) { + fprintf(stderr, "Invalid report frametime weight '%s'\n", optarg); + error = true; + } + } else { + gOpts.reportFrametimeWeight = 10; + } break; - } - moveToCpuSet(optarg); - break; - case LongOpts::BenchmarkFormat: - if (!optarg) { - error = true; + case LongOpts::WaitForGpu: + Properties::waitForGpuCompletion = true; break; - } - if (!setBenchmarkFormat(optarg)) { - error = true; - } - break; - case LongOpts::Onscreen: - gOpts.renderOffscreen = false; - break; + case LongOpts::CpuSet: + if (!optarg) { + error = true; + break; + } + moveToCpuSet(optarg); + break; - case LongOpts::Offscreen: - gOpts.renderOffscreen = true; - break; + case LongOpts::BenchmarkFormat: + if (!optarg) { + error = true; + break; + } + if (!setBenchmarkFormat(optarg)) { + error = true; + } + break; - case 'h': - printHelp(); - exit(EXIT_SUCCESS); - break; + case LongOpts::Renderer: + if (!optarg) { + error = true; + break; + } + if (!setRenderer(optarg)) { + error = true; + } + break; + + case LongOpts::Onscreen: + gOpts.renderOffscreen = false; + break; - case '?': - fprintf(stderr, "Unrecognized option '%s'\n", argv[optind - 1]); + case LongOpts::Offscreen: + gOpts.renderOffscreen = true; + break; + + case 'h': + printHelp(); + exit(EXIT_SUCCESS); + break; + + case '?': + fprintf(stderr, "Unrecognized option '%s'\n", argv[optind - 1]); // fall-through - default: - error = true; - break; + default: + error = true; + break; } } |