xref: /OK3568_Linux_fs/buildroot/package/vkmark/0003-core-Add-off-screen-command-line-option.patch (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1From 1c41ba468681fcee3ebb9b9b0cf68095b7f13f1e Mon Sep 17 00:00:00 2001
2From: Jeffy Chen <jeffy.chen@rock-chips.com>
3Date: Mon, 23 May 2022 13:13:45 +0800
4Subject: [PATCH 3/3] core: Add --off-screen command-line option
5
6Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
7---
8 src/main_loop.cpp | 7 +++++--
9 src/options.cpp   | 5 +++++
10 src/options.h     | 1 +
11 3 files changed, 11 insertions(+), 2 deletions(-)
12
13diff --git a/src/main_loop.cpp b/src/main_loop.cpp
14index 5a6383b..94f4a12 100644
15--- a/src/main_loop.cpp
16+++ b/src/main_loop.cpp
17@@ -123,8 +123,11 @@ void MainLoop::run()
18                !(should_quit = ws.should_quit()) &&
19                !should_stop)
20         {
21-            ws.present_vulkan_image(
22-                scene.draw(ws.next_vulkan_image()));
23+            if (options.off_screen)
24+                scene.draw(ws.next_vulkan_image());
25+            else
26+                ws.present_vulkan_image(
27+                    scene.draw(ws.next_vulkan_image()));
28             scene.update();
29         }
30
31diff --git a/src/options.cpp b/src/options.cpp
32index 0ef58c9..6009949 100644
33--- a/src/options.cpp
34+++ b/src/options.cpp
35@@ -50,6 +50,7 @@ struct option long_options[] = {
36     {"winsys-options", 1, 0, 0},
37     {"list-devices", 0, 0, 0},
38     {"run-forever", 0, 0, 0},
39+    {"off-screen", 0, 0, 0},
40     {"debug", 0, 0, 0},
41     {"help", 0, 0, 0},
42     {0, 0, 0, 0}
43@@ -136,6 +137,7 @@ Options::Options()
44       window_system_dir{VKMARK_WINDOW_SYSTEM_DIR},
45       data_dir{VKMARK_DATA_DIR},
46       run_forever{false},
47+      off_screen{false},
48       show_debug{false},
49       show_help{false},
50       list_devices{false},
51@@ -167,6 +169,7 @@ std::string Options::help_string()
52         "      --winsys-options OPTS   Window system options as 'opt1=val1(:opt2=val2)*'\n"
53         "      --run-forever           Run indefinitely, looping from the last benchmark\n"
54         "                              back to the first\n"
55+        "      --off-screen            Render to an off-screen surface\n"
56         "  -d, --debug                 Display debug messages\n"
57         "  -D  --use-device            Use Vulkan device with specified UUID\n"
58         "  -L  --list-devices          List Vulkan devices\n"
59@@ -223,6 +226,8 @@ bool Options::parse_args(int argc, char **argv)
60             window_system_options = parse_window_system_options(optarg);
61         else if (optname == "run-forever")
62             run_forever = true;
63+        else if (optname == "off-screen")
64+            off_screen = true;
65         else if (c == 'd' || optname == "debug")
66             show_debug = true;
67         else if (c == 'h' || optname == "help")
68diff --git a/src/options.h b/src/options.h
69index eb5b6cf..69b37d4 100644
70--- a/src/options.h
71+++ b/src/options.h
72@@ -55,6 +55,7 @@ struct Options
73     std::string window_system;
74     std::vector<WindowSystemOption> window_system_options;
75     bool run_forever;
76+    bool off_screen;
77     bool show_debug;
78     bool show_help;
79     bool list_devices;
80--
812.20.1
82
83