Mir

Merge lp:~vanvugt/mir/eglapp-bits into lp:mir

Proposed by Daniel van Vugt
Status: Merged
Approved by: Alberto Aguirre
Approved revision: no longer in the source branch.
Merged at revision: 2729
Proposed branch: lp:~vanvugt/mir/eglapp-bits
Merge into: lp:mir
Diff against target: 58 lines (+21/-2)
1 file modified
examples/eglapp.c (+21/-2)
To merge this branch: bzr merge lp:~vanvugt/mir/eglapp-bits
Reviewer Review Type Date Requested Status
Robert Carr (community) Approve
Kevin DuBois (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Alexandros Frantzis (community) Approve
Review via email: mp+263482@code.launchpad.net

Commit message

eglapp: Add a parameter "-eN" for adjusting the EGL colour channel size
in bits. Using -e5 on some devices like Nexus 4 is sufficient to
reproduce LP: #1460149.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

Does this work reliably? From the EGL spec:

"3.4.1.2 Sorting of EGLConfig

...

3. Special: by larger total number of color bits (for an RGB color buffer,
this is the sum of EGL_RED_SIZE , EGL_GREEN_SIZE , EGL_BLUE_SIZE ,
and EGL_ALPHA_SIZE ;"

Which means that for 5,5,5,1 we would get the largest buffer size with at least those r,g,b,a sizes, i.e. probably a 32-bit 8,8,8,8.

review: Needs Information
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Good observation!

The simple answer is we have buggy/non-conformant EGL implementations on Nexus 4 and other devices which do not follow that rule. If you ask for 555, they give you 565 instead of 888.

So yes, the branch works reliably. Though it would not be too useful /if/ we did not have buggy platforms to support :)

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Although the EGL spec itself is questionable and I understand people not following it properly. Because if all implementations really did just choose the highest colour depth available then specifying any value<=max in the EGLConfig would always give the same result (maximum colour depth). Hence those channel attributes should not exist at all if the spec really expects everyone to choose the maximum depth all the time. Sounds like the EGL spec needs rewording.

Back in the real world we should not make any assumptions about the chosen EGLConfig. It clearly might not be what we expected, and we should query what was chosen.

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

I agree that the sorting order in the spec is broken, but we do have a way around this: use eglGetConfigs to get all configs and manually select a matching EGLConfig with the properties we want. This ensures that it works reliably on all platforms and it's only slightly more complicated.

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Yes you could do it that way. Although both approaches require a stupid/ugly linear search.

I suggest what is proposed here is a bit cleaner though. Because it allows the toolkit/app to choose its config in a way that is not bound to the limited/changeable list of Mir pixel formats. In fact, this way the toolkit/app never even has to see what its Mir pixel format is.

Setting up EGL before creating the native window is also how the EGL docs approach it:
https://www.khronos.org/registry/egl/sdk/docs/man/html/eglIntro.xhtml

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Other readers: Please ignore the above conversation. It actually belongs in:
https://code.launchpad.net/~vanvugt/mir/eglapp-choose-pixel-format/+merge/263622

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Actually alf's approach might be better. Still investigating, but it does not affect this branch. Only later work... So you can still ignore the above discussion :)

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

> Still investigating, but it does not affect this branch. Only later work... So you can still ignore the above discussion :)

OK. Perhaps we should support -e r:g:b:a instead, but not a blocker.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Kevin DuBois (kdub) wrote :

lgtm

review: Approve
Revision history for this message
Robert Carr (robertcarr) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'examples/eglapp.c'
2--- examples/eglapp.c 2015-06-17 05:20:42 +0000
3+++ examples/eglapp.c 2015-07-07 02:31:43 +0000
4@@ -197,6 +197,7 @@
5 unsigned int output_id = mir_display_output_id_invalid;
6 char *mir_socket = NULL;
7 char const* cursor_name = mir_default_cursor_name;
8+ unsigned int rgb_bits = 8;
9
10 if (argc > 1)
11 {
12@@ -230,6 +231,21 @@
13 }
14 }
15 break;
16+ case 'e':
17+ {
18+ arg += 2;
19+ if (!arg[0] && i < argc-1)
20+ {
21+ ++i;
22+ arg = argv[i];
23+ }
24+ if (sscanf(arg, "%u", &rgb_bits) != 1)
25+ {
26+ printf("Invalid colour channel depth: %s\n", arg);
27+ help = 1;
28+ }
29+ }
30+ break;
31 case 'n':
32 swapinterval = 0;
33 break;
34@@ -305,6 +321,7 @@
35 {
36 printf("Usage: %s [<options>]\n"
37 " -b Background opacity (0.0 - 1.0)\n"
38+ " -e EGL colour channel size in bits\n"
39 " -h Show this help text\n"
40 " -f Force full screen\n"
41 " -o ID Force placement on output monitor ID\n"
42@@ -371,13 +388,15 @@
43
44 printf("Server supports %d of %d surface pixel formats. Using format: %d\n",
45 nformats, mir_pixel_formats, pixel_format);
46- unsigned int bpp = 8 * MIR_BYTES_PER_PIXEL(pixel_format);
47 EGLint attribs[] =
48 {
49 EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
50 EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
51 EGL_COLOR_BUFFER_TYPE, EGL_RGB_BUFFER,
52- EGL_BUFFER_SIZE, bpp,
53+ EGL_RED_SIZE, rgb_bits,
54+ EGL_GREEN_SIZE, rgb_bits,
55+ EGL_BLUE_SIZE, rgb_bits,
56+ EGL_ALPHA_SIZE, mir_eglapp_background_opacity == 1.0f ? 0 : rgb_bits,
57 EGL_NONE
58 };
59

Subscribers

People subscribed via source and target branches