Mir

Merge lp:~peat-new/mir/avoid-hardcoding-color-format-in-device-quirks into lp:mir

Proposed by Ratchanan Srirattanamet
Status: Merged
Merged at revision: 3636
Proposed branch: lp:~peat-new/mir/avoid-hardcoding-color-format-in-device-quirks
Merge into: lp:mir
Diff against target: 151 lines (+69/-4)
4 files modified
src/platforms/android/server/device_quirks.cpp (+4/-4)
src/platforms/android/server/gl_context.cpp (+41/-0)
src/platforms/android/server/gl_context.h (+5/-0)
tests/unit-tests/graphics/android/test_device_detection.cpp (+19/-0)
To merge this branch: bzr merge lp:~peat-new/mir/avoid-hardcoding-color-format-in-device-quirks
Reviewer Review Type Date Requested Status
Mir CI Bot continuous-integration Needs Fixing
Cemil Azizoglu (community) Approve
Kevin DuBois (community) Approve
Alan Griffiths Approve
Daniel van Vugt Approve
Review via email: mp+302248@code.launchpad.net

Commit message

Originally, DeviceQuirks creates a PbufferGLContext with mir_pixel_format_abgr_8888 hard-coded as a format. This causes a problem on a device without mir_pixel_format_abgr_8888 support (in particular, Samsung Galaxy Tab 2 7.0). This MP creates new PbufferGLContext constructor which doesn't have to specify a display format. Then, the DeviceQuirks is modified to use this new constructor. This makes the code not depending on the availability of mir_pixel_format_abgr_8888 format on the device.

To post a comment you must log in.
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Cool, thanks. Always nice to add support for more devices.

Hard-coding of pixel formats is a problem we continue to fix throughout the whole software stack...

I'm assuming our system compositor doesn't have a strict need for an alpha channel on the framebuffer, because we're no longer enforcing that here (would require EGL_ALPHA_SIZE).

I've verified tests pass locally but it would be nice if we could get the Mir CI bot to run all tests.

review: Approve
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

LGTM, my only concern is to verify that it passes CI on krillin

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

alright, wonder why ci isnt running on branch.

review: Approve
Revision history for this message
Ratchanan Srirattanamet (peat-new) wrote :

> alright, wonder why ci isnt running on branch.

I guess that CI is configured to run only on MP by developer members.
From https://mir-jenkins.ubuntu.com/job/trigger-ci/lastSuccessfulBuild/console

>DEBUG: Users "peat-new" not allowed to trigger jobs

So, I think one of the developers have to do something special to kick off the CI.

Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

> So, I think one of the developers have to do something special to kick off the
> CI.

I *thought* Daniel did that (by requesting mir-ci-bot review). I was obviously wrong. :(

Revision history for this message
Cemil Azizoglu (cemil-azizoglu) wrote :

Sure

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

I was hoping adding mir-ci-bot would work, but did not expect it to.

Now let's see if autolanding runs all the CI jobs at least. Or if it doesn't work at all...

Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Autolanding.
No commit message was specified in the merge proposal. Hit 'Add commit message' on the merge proposal web page or follow the link below. You can approve the merge proposal yourself to rerun.
https://code.launchpad.net/~peat-new/mir/avoid-hardcoding-color-format-in-device-quirks/+merge/302248/+edit-commit-message

review: Needs Fixing (continuous-integration)
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

It's not yet clear that CI has been run and the bot might be trying to land it untested.

Now waiting on full test run:
https://code.launchpad.net/~mir-team/mir/avoid-hardcoding-color-format-in-device-quirks/+merge/302367

Just in case.

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

CI passed when I submitted it.

https://mir-jenkins.ubuntu.com/job/mir-ci/1413/
Executed test runs:
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-mir/1723
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/1776
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/1767
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/1767
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=yakkety/1767
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=vivid+overlay/1745
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=vivid+overlay/1745/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/1745
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/1745/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=yakkety/1745
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=yakkety/1745/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/1745
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/1745/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/1745
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/1745/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/1745
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/1745/artifact/output/*zip*/output.zip

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/platforms/android/server/device_quirks.cpp'
2--- src/platforms/android/server/device_quirks.cpp 2016-07-28 09:10:43 +0000
3+++ src/platforms/android/server/device_quirks.cpp 2016-08-08 06:26:59 +0000
4@@ -50,13 +50,13 @@
5 std::string const egl_sync_default = "default";
6 std::string const egl_sync_force_on = "force_on";
7 std::string const egl_sync_force_off = "force_off";
8-
9+
10
11 std::string determine_device_name(mga::PropertiesWrapper const& properties)
12 {
13 char const default_value[] = "";
14 char value[PROP_VALUE_MAX] = "";
15- char const key[] = "ro.product.device";
16+ char const key[] = "ro.product.device";
17 properties.property_get(key, value, default_value);
18 return std::string{value};
19 }
20@@ -167,13 +167,13 @@
21 }
22
23 mga::DeviceQuirks::DeviceQuirks(PropertiesWrapper const& properties) :
24- DeviceQuirks(properties, mga::PbufferGLContext{mir_pixel_format_abgr_8888, config, report})
25+ DeviceQuirks(properties, mga::PbufferGLContext{config, report})
26 {
27 }
28
29 mga::DeviceQuirks::DeviceQuirks(PropertiesWrapper const& properties, mo::Option const& options)
30 : device_name(determine_device_name(properties)),
31- gpu_info(determine_gpu_info(mga::PbufferGLContext(mir_pixel_format_abgr_8888, config, report))),
32+ gpu_info(determine_gpu_info(mga::PbufferGLContext(config, report))),
33 num_framebuffers_(num_framebuffers_for(device_name, options.get(num_framebuffers_opt, true))),
34 gralloc_cannot_be_closed_safely_(gralloc_cannot_be_closed_safely_for(device_name, options.get(gralloc_cannot_be_closed_safely_opt, true))),
35 enable_width_alignment_quirk(options.get(width_alignment_opt, true)),
36
37=== modified file 'src/platforms/android/server/gl_context.cpp'
38--- src/platforms/android/server/gl_context.cpp 2016-07-28 09:10:43 +0000
39+++ src/platforms/android/server/gl_context.cpp 2016-08-08 06:26:59 +0000
40@@ -103,6 +103,30 @@
41 return *pegl_config;
42 }
43
44+//Sometimes it's useful not to specify a format when one doesn't know which format to use yet.
45+//This is used by DeviceQuirks to create a context for finding out GL vendor and renderer.
46+EGLConfig select_egl_config_with_any_format(
47+ EGLDisplay egl_display, mg::GLConfig const& gl_config)
48+{
49+ EGLint const required_egl_config_attr [] =
50+ {
51+ EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_PBUFFER_BIT,
52+ EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
53+ EGL_DEPTH_SIZE, gl_config.depth_buffer_bits(),
54+ EGL_STENCIL_SIZE, gl_config.stencil_buffer_bits(),
55+ EGL_NONE
56+ };
57+
58+ EGLConfig the_config;
59+ EGLint num_returned_config;
60+
61+ eglChooseConfig(egl_display, required_egl_config_attr, &the_config, 1, &num_returned_config);
62+
63+ if (num_returned_config != 1)
64+ BOOST_THROW_EXCEPTION(std::runtime_error("could not select EGL config"));
65+
66+ return the_config;
67+}
68 }
69
70 void mga::GLContext::make_current(EGLSurface egl_surface) const
71@@ -139,6 +163,16 @@
72 report.report_egl_configuration(egl_display, egl_config);
73 }
74
75+mga::GLContext::GLContext(mg::GLConfig const& gl_config, mg::DisplayReport& report) :
76+ egl_display(create_and_initialize_display()),
77+ egl_config(select_egl_config_with_any_format(egl_display, gl_config)),
78+ egl_context{egl_display,
79+ eglCreateContext(egl_display, egl_config, EGL_NO_CONTEXT, default_egl_context_attr)},
80+ own_display(true)
81+{
82+ report.report_egl_configuration(egl_display, egl_config);
83+}
84+
85 mga::GLContext::GLContext(GLContext const& shared_gl_context) :
86 mir::renderer::gl::Context(),
87 egl_display(shared_gl_context.egl_display),
88@@ -158,6 +192,13 @@
89 {
90 }
91
92+mga::PbufferGLContext::PbufferGLContext(mg::GLConfig const& gl_config, mg::DisplayReport& report) :
93+ GLContext(gl_config, report),
94+ egl_surface{egl_display,
95+ eglCreatePbufferSurface(egl_display, egl_config, dummy_pbuffer_attribs)}
96+{
97+}
98+
99 mga::PbufferGLContext::PbufferGLContext(PbufferGLContext const& shared_gl_context) :
100 GLContext(shared_gl_context),
101 egl_surface{egl_display,
102
103=== modified file 'src/platforms/android/server/gl_context.h'
104--- src/platforms/android/server/gl_context.h 2016-07-28 09:10:43 +0000
105+++ src/platforms/android/server/gl_context.h 2016-08-08 06:26:59 +0000
106@@ -46,6 +46,8 @@
107 GLContext(MirPixelFormat display_format,
108 GLConfig const& gl_config,
109 DisplayReport& report);
110+ GLContext(GLConfig const& gl_config,
111+ DisplayReport& report);
112
113 GLContext(GLContext const& shared_gl_context);
114
115@@ -68,6 +70,9 @@
116 GLConfig const& gl_config,
117 DisplayReport& report);
118
119+ PbufferGLContext(GLConfig const& gl_config,
120+ DisplayReport& report);
121+
122 PbufferGLContext(PbufferGLContext const& shared_gl_context);
123
124 void make_current() const override;
125
126=== modified file 'tests/unit-tests/graphics/android/test_device_detection.cpp'
127--- tests/unit-tests/graphics/android/test_device_detection.cpp 2016-06-28 14:58:46 +0000
128+++ tests/unit-tests/graphics/android/test_device_detection.cpp 2016-08-08 06:26:59 +0000
129@@ -387,3 +387,22 @@
130 mga::DeviceQuirks broken_quirks(mock_ops, options);
131 EXPECT_FALSE(broken_quirks.working_egl_sync());
132 }
133+
134+TEST_F(DeviceQuirks, detects_gl_vendor_on_device_with_only_argb_8888_support)
135+{
136+ using namespace testing;
137+ ON_CALL(mock_egl, eglGetConfigAttrib(_, _, EGL_NATIVE_VISUAL_ID, _))
138+ .WillByDefault(DoAll(
139+ SetArgPointee<3>(HAL_PIXEL_FORMAT_BGRA_8888),
140+ Return(EGL_TRUE)));
141+ //In the reality, Qualcomm does support abgr_8888. But we do this to make sure gl_vendor will be checked.
142+ EXPECT_CALL(mock_gl, glGetString(GL_VENDOR))
143+ .Times(1)
144+ .WillOnce(Return(reinterpret_cast<const unsigned char*>("Qualcomm")));
145+ EXPECT_CALL(mock_gl, glGetString(GL_RENDERER))
146+ .Times(1);
147+ MockOps mock_ops;
148+
149+ mga::DeviceQuirks quirks(mock_ops, options);
150+ EXPECT_TRUE(quirks.working_egl_sync());
151+}

Subscribers

People subscribed via source and target branches