Mir

Merge lp:~kdub/mir/fix-1378326 into lp:mir

Proposed by Kevin DuBois
Status: Merged
Approved by: Kevin DuBois
Approved revision: no longer in the source branch.
Merged at revision: 1980
Proposed branch: lp:~kdub/mir/fix-1378326
Merge into: lp:mir
Diff against target: 33 lines (+10/-2)
2 files modified
src/platform/graphics/android/hwc_fallback_gl_renderer.cpp (+8/-1)
tests/unit-tests/graphics/android/test_hwc_fallback_gl_renderer.cpp (+2/-1)
To merge this branch: bzr merge lp:~kdub/mir/fix-1378326
Reviewer Review Type Date Requested Status
Cemil Azizoglu (community) Approve
Alexandros Frantzis (community) Approve
Daniel van Vugt Abstain
Alan Griffiths Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+237827@code.launchpad.net

Commit message

android: have the fallback renderer clear the FB_TARGET layer to transparent black pixels (instead of opaque black pixels). This is necessary for the operation of some drivers, which choose to put the gl-rendered layer on top, and 'underlay' the hardware-optimized layers.

lp: #1378326

Description of the change

android: have the fallback renderer clear the FB_TARGET layer to transparent black pixels (instead of opaque black pixels). This is necessary for the operation of some drivers, which choose to put the gl-rendered layer on top, and 'underlay' the hardware-optimized layers.

lp: #1378326

note: this seems to be what surfaceflinger does as well.

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
Alan Griffiths (alan-griffiths) wrote :

Weird. I'm not sure where to look for unexpected side-effects but I can imagine this breaking unstated assumptions somewhere.

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

I don't think all display hw would require this. Shouldn't we be doing this based on the following hint from hwc?

    /*
     * HWC sets HWC_HINT_CLEAR_FB to tell SurfaceFlinger that it should clear the
     * framebuffer with transparent pixels where this layer would be.
     * SurfaceFlinger will only honor this flag when the layer has no blending
     *
     */
    HWC_HINT_CLEAR_FB = 0x00000002

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

Looks reasonable, but Cemil makes a good point.

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

We could clear just the region behind the squares that will be tagged overlays (and have that flag set).
After looking at surfaceflinger [1] though, I decided to go with this approach. SF clears the framebuffer to transparent black because clearing the whole region to black is more resource friendly than arranging to clear only the union of rectangles that have been marked overlays.

[1]
https://android.googlesource.com/platform/frameworks/native/+/master/services/surfaceflinger/SurfaceFlinger.cpp (line 1562)

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

OK.

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

I think it's okay, but there is one minor concern. Some GPUs are severely bandwidth-bound. Clearing the whole region would result in a lot of pixels being pushed out. So even though clearing the whole buffer is convenient, it may cause performance issues.

OTOH, usually these bandwidth-bound GPUs have (much smaller) "tile status" buffers. When a full surface is cleared, the tile status buffers get cleared to reflect that, and the buffer is not really written to with millions of pixels. But if you selectively clear partial rectangles, then the tile status buffers are not used and actual clear operation takes place.

So paradoxically, on these architectures at least, clearing the whole buffer would be much faster.

Anyways, if there are issues in the future, this should be easy to change.

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

So, in this mixed mode composition, we have a portion of the screen we have to render via gl, and a portion that we have to clear. In our use cases, we still push out all the pixels on the display, but just save in terms of the number of pixels that have been rendered vs the number that have been fast-cleared. So yes, there's still room for optimization, but it seems more of a subset of trying to do partial screen updates (which we don't try to do at the moment)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/platform/graphics/android/hwc_fallback_gl_renderer.cpp'
2--- src/platform/graphics/android/hwc_fallback_gl_renderer.cpp 2014-09-30 06:43:36 +0000
3+++ src/platform/graphics/android/hwc_fallback_gl_renderer.cpp 2014-10-09 17:21:32 +0000
4@@ -103,7 +103,14 @@
5 {
6 glUseProgram(*program);
7
8- glClearColor(0.0, 0.0, 0.0, 1.0);
9+ /* NOTE: some HWC implementations rely on the framebuffer target layer
10+ * being cleared to transparent black. eg, in mixed-mode composition,
11+ * krillin actually arranges the fb_target in the topmost level of its
12+ * display controller and relies on blending to make the overlays appear
13+ * /under/ the gl layer. (lp: #1378326)
14+ */
15+ glClearColor(0.0, 0.0, 0.0, 0.0);
16+ glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
17 glClear(GL_COLOR_BUFFER_BIT);
18 glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
19 glEnableVertexAttribArray(position_attr);
20
21=== modified file 'tests/unit-tests/graphics/android/test_hwc_fallback_gl_renderer.cpp'
22--- tests/unit-tests/graphics/android/test_hwc_fallback_gl_renderer.cpp 2014-09-11 05:51:44 +0000
23+++ tests/unit-tests/graphics/android/test_hwc_fallback_gl_renderer.cpp 2014-10-09 17:21:32 +0000
24@@ -291,7 +291,8 @@
25
26 InSequence seq;
27 EXPECT_CALL(mock_gl, glUseProgram(_));
28- EXPECT_CALL(mock_gl, glClearColor(FloatEq(0.0), FloatEq(0.0), FloatEq(0.0), FloatEq(1.0)));
29+ EXPECT_CALL(mock_gl, glClearColor(FloatEq(0.0), FloatEq(0.0), FloatEq(0.0), FloatEq(0.0)));
30+ EXPECT_CALL(mock_gl, glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE));
31 EXPECT_CALL(mock_gl, glClear(GL_COLOR_BUFFER_BIT));
32 EXPECT_CALL(mock_gl, glEnableVertexAttribArray(position_attr_loc));
33 EXPECT_CALL(mock_gl, glEnableVertexAttribArray(texcoord_attr_loc));

Subscribers

People subscribed via source and target branches