aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2021-03-18 07:47:40 +0100
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2021-03-18 08:44:48 +0000
commitb30c8ed942f2f32bea067a15e77c4c5a62158404 (patch)
tree60abd36312fbf0fe3b8b28d11acaca2e28fdbca1
parentd17189de25ad29b4b00da735047900df15749b9e (diff)
Fix disabling vsync for frame-count shell
The frame-count shell depends on disabling vsync to be able to render as many frames as it can during 20 seconds. But the logic was inverted in the condition that checked for the --shell parameter, so the frame-count shell would never be detected and the swap interval would never be set to 0. This patch also updates the logic to take into consideration that frame-count is the default now, so it will default to disabling vsync. Change-Id: I9d866a7fddfa46266ba1c8245b84e8389e00b154 Reviewed-by: Daniel Smith <Daniel.Smith@qt.io>
-rw-r--r--src/main.cpp25
1 files changed, 13 insertions, 12 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 7528e34..a57b3e6 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -241,22 +241,23 @@ QStringList processCommandLineArguments(const QCoreApplication &app)
void setupDefaultSurfaceFormat(int argc, char **argv)
{
- bool expectingShell = false;
+ bool frameCountShell = true; // default
for (int i = 0; i < argc; ++i) {
- if (strcmp(argv[i], "--shell")) {
- expectingShell = true;
- } else if (expectingShell && strcmp(argv[i], "frame-count") == 0) {
- QSurfaceFormat format = QSurfaceFormat::defaultFormat();
+ if (strcmp(argv[i], "--shell") == 0 && i < argc - 1) {
+ if (strcmp(argv[i + 1], "frame-count") != 0)
+ frameCountShell = false;
+ }
+ }
+
+ if (frameCountShell) {
+ QSurfaceFormat format = QSurfaceFormat::defaultFormat();
#if QT_VERSION >= 0x050300
- format.setSwapInterval(0);
+ format.setSwapInterval(0);
#else
- fprintf(stderr, "Cannot disable swap interval on this Qt version, frame-count shell won't work properly!\n");
- ::exit(1);
+ fprintf(stderr, "Cannot disable swap interval on this Qt version, frame-count shell won't work properly!\n");
+ ::exit(1);
#endif
- QSurfaceFormat::setDefaultFormat(format);
- } else {
- expectingShell = false;
- }
+ QSurfaceFormat::setDefaultFormat(format);
}
}