Mir

Merge lp:~robertcarr/mir/multiwin-egl-example into lp:mir

Proposed by Robert Carr
Status: Merged
Approved by: Alan Griffiths
Approved revision: no longer in the source branch.
Merged at revision: 1441
Proposed branch: lp:~robertcarr/mir/multiwin-egl-example
Merge into: lp:mir
Diff against target: 150 lines (+62/-41)
1 file modified
examples/scroll.cpp (+62/-41)
To merge this branch: bzr merge lp:~robertcarr/mir/multiwin-egl-example
Reviewer Review Type Date Requested Status
Chris Halse Rogers Needs Fixing
Alexandros Frantzis (community) Approve
Kevin DuBois (community) Abstain
Alan Griffiths Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+208534@code.launchpad.net

Commit message

Add support for multiple windows to mir_demo_client_scroll to demonstrate multiple EGL windows from one connection is failing!

Description of the change

While investigating some nested multi-monitor issues on Mesa, I wondered if there was something to demonstrate rendering to multiple EGL surfaces created from the same connection from multiple threads (as nested behaves in the case of multiple nested outputs!). I found that there was not so I added support to mir_demo_client_scroll.

Unfortunately it does not work as I will shortly document in a bug.

To post a comment you must log in.
Revision history for this message
Robert Carr (robertcarr) wrote :
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

I guess it is pre-existing, but why can't we do as the other examples do and exit cleanly?

review: Approve
Revision history for this message
Kevin DuBois (kdub) wrote :

seems like we're landing a failing 'test', but calling it an example. I suppose this is unusual but okay as long as a test makes lands along with the fix.

review: Abstain
Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

> I guess it is pre-existing, but why can't we do as the other examples do and exit cleanly?

+1, the program shutdown code is useless since it never gets executed...

review: Approve
Revision history for this message
Chris Halse Rogers (raof) wrote :

You've broken specifying -m (the getopt string should be "hm:w:", because both m and w have a mandatory argument).

Also, this doesn't actually trigger the bug for me; if you're seeing problems, they're not the same as the nested-multi-output hang. That doesn't make this change unuseful, though. Fix the getopt string and you've got an approved from me.

review: Needs Fixing

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'examples/scroll.cpp'
2--- examples/scroll.cpp 2014-02-14 09:27:02 +0000
3+++ examples/scroll.cpp 2014-02-27 05:47:13 +0000
4@@ -23,46 +23,21 @@
5 #include <signal.h>
6 #include <string.h>
7 #include <stdio.h>
8+#include <stdlib.h>
9 #include <unistd.h>
10 #include <getopt.h>
11 #include <EGL/egl.h>
12 #include <GLES2/gl2.h>
13
14+#include <thread>
15+
16 static char const *socket_file = NULL;
17-
18-int main(int argc, char* argv[])
19+static EGLDisplay disp;
20+
21+
22+void create_and_run_scroll_surface(MirConnection *connection)
23 {
24- MirConnection *connection = 0;
25 MirSurface *surface = 0;
26- int arg;
27- opterr = 0;
28- while ((arg = getopt (argc, argv, "hm:")) != -1)
29- {
30- switch (arg)
31- {
32- case 'm':
33- socket_file = optarg;
34- break;
35-
36- case '?':
37- case 'h':
38- default:
39- puts(argv[0]);
40- puts("Usage:");
41- puts(" -m <Mir server socket>");
42- puts(" -h: this help text");
43- return -1;
44- }
45- }
46-
47- puts("Starting");
48-
49- connection = mir_connect_sync(socket_file, __PRETTY_FUNCTION__);
50- assert(connection != NULL);
51- assert(mir_connection_is_valid(connection));
52- assert(strcmp(mir_connection_get_error_message(connection), "") == 0);
53- puts("Connected");
54-
55 MirPixelFormat pixel_format;
56 unsigned int valid_formats;
57 mir_connection_get_available_surface_formats(connection, &pixel_format, 1, &valid_formats);
58@@ -79,7 +54,6 @@
59
60 /* egl setup */
61 int major, minor, n, rc;
62- EGLDisplay disp;
63 EGLContext context;
64 EGLSurface egl_surface;
65 EGLConfig egl_config;
66@@ -93,13 +67,9 @@
67 EGL_NONE };
68 EGLint context_attribs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE };
69
70- EGLNativeDisplayType native_display = (EGLNativeDisplayType) mir_connection_get_egl_native_display(connection);
71 EGLNativeWindowType native_window = (EGLNativeWindowType) mir_surface_get_egl_native_window(surface);
72 assert(native_window != (EGLNativeWindowType)NULL);
73
74- disp = eglGetDisplay(native_display);
75- assert(disp != EGL_NO_DISPLAY);
76-
77 rc = eglInitialize(disp, &major, &minor);
78 assert(rc == EGL_TRUE);
79 assert(major == 1);
80@@ -131,16 +101,67 @@
81
82 eglDestroySurface(disp, egl_surface);
83 eglDestroyContext(disp, context);
84- eglTerminate(disp);
85-
86+
87 mir_surface_release_sync(surface);
88 puts("Surface released");
89+}
90+
91+int main(int argc, char* argv[])
92+{
93+ MirConnection *connection = 0;
94+ unsigned num_windows = 1;
95+ int arg;
96+ opterr = 0;
97+ while ((arg = getopt (argc, argv, "hmw:")) != -1)
98+ {
99+ switch (arg)
100+ {
101+ case 'm':
102+ socket_file = optarg;
103+ break;
104+ case 'w':
105+ num_windows = atoi(optarg);
106+ break;
107+ case '?':
108+ case 'h':
109+ default:
110+ puts(argv[0]);
111+ puts("Usage:");
112+ puts(" -m <Mir server socket>");
113+ puts(" -w <Number of windows to create>:");
114+ puts(" -h: this help text");
115+ return -1;
116+ }
117+ }
118+
119+ puts("Starting");
120+
121+ connection = mir_connect_sync(socket_file, __PRETTY_FUNCTION__);
122+ assert(connection != NULL);
123+ assert(mir_connection_is_valid(connection));
124+ assert(strcmp(mir_connection_get_error_message(connection), "") == 0);
125+ puts("Connected");
126+
127+ EGLNativeDisplayType native_display = (EGLNativeDisplayType) mir_connection_get_egl_native_display(connection);
128+ disp = eglGetDisplay(native_display);
129+ assert(disp != EGL_NO_DISPLAY);
130+
131+ if (num_windows == 1)
132+ {
133+ create_and_run_scroll_surface(connection);
134+ }
135+ else
136+ {
137+ for (unsigned i = 0; i < num_windows; i++) std::thread(create_and_run_scroll_surface, connection).detach();
138+ for(;;) {}
139+ }
140+
141+
142+ eglTerminate(disp);
143
144 mir_connection_release(connection);
145 puts("Connection released");
146
147- (void)rc;
148-
149 return 0;
150 }
151

Subscribers

People subscribed via source and target branches