Mir

Merge lp:~vanvugt/mir/fix-1398296-better into lp:mir

Proposed by Daniel van Vugt
Status: Merged
Approved by: Cemil Azizoglu
Approved revision: no longer in the source branch.
Merged at revision: 2175
Proposed branch: lp:~vanvugt/mir/fix-1398296-better
Merge into: lp:mir
Diff against target: 127 lines (+49/-12)
2 files modified
src/platforms/mesa/display_buffer.cpp (+3/-8)
tests/unit-tests/graphics/mesa/test_display_buffer.cpp (+46/-4)
To merge this branch: bzr merge lp:~vanvugt/mir/fix-1398296-better
Reviewer Review Type Date Requested Status
Cemil Azizoglu (community) Approve
Alan Griffiths Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+245061@code.launchpad.net

Commit message

Fix LP: #1398296 more correctly. Turns out we were never running out
of resources. Just occasionally creating scan-out capable buffers and
trying to bypass them even when they were the wrong dimensions for the
screen (due to lag LP: #1398722).

This could happen because the surface/renderable dimensions match the
screen a frame or two earlier than the buffer dimensions do.

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 :

Plausible

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

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/platforms/mesa/display_buffer.cpp'
2--- src/platforms/mesa/display_buffer.cpp 2014-12-17 08:20:48 +0000
3+++ src/platforms/mesa/display_buffer.cpp 2014-12-18 02:34:51 +0000
4@@ -199,10 +199,9 @@
5 if (bypass_it != renderable_list.rend())
6 {
7 auto bypass_buf = (*bypass_it)->buffer();
8- if (bypass_buf->can_bypass())
9+ if (bypass_buf->can_bypass() &&
10+ bypass_buf->size() == geom::Size{fb_width,fb_height})
11 {
12- // Bypass might still fail when we try to acquire other
13- // resources, so returning false is still possible:
14 return post_update(bypass_buf);
15 }
16 }
17@@ -249,11 +248,7 @@
18 auto native = bypass_buf->native_buffer_handle();
19 auto gbm_native = static_cast<mgm::GBMNativeBuffer*>(native.get());
20 bufobj = get_buffer_object(gbm_native->bo);
21- /*
22- * Bypass is allowed to fail. Sometimes DRM has insufficient resources
23- * (briefly) to create the additional framebuffer object. So just fall
24- * back to compositing...
25- */
26+ // If bypass fails, just fall back to compositing.
27 if (!bufobj)
28 return false;
29 }
30
31=== modified file 'tests/unit-tests/graphics/mesa/test_display_buffer.cpp'
32--- tests/unit-tests/graphics/mesa/test_display_buffer.cpp 2014-12-17 08:43:52 +0000
33+++ tests/unit-tests/graphics/mesa/test_display_buffer.cpp 2014-12-18 02:34:51 +0000
34@@ -25,6 +25,7 @@
35 #include "mir_test_doubles/mock_gbm.h"
36 #include "mir_test_doubles/stub_gl_config.h"
37 #include "mir_test_doubles/platform_factory.h"
38+#include "mir_test_doubles/stub_gbm_native_buffer.h"
39 #include "mir_test_framework/udev_environment.h"
40 #include "mir_test_doubles/fake_renderable.h"
41 #include "mock_kms_output.h"
42@@ -46,7 +47,12 @@
43 {
44 public:
45 MesaDisplayBufferTest()
46- : bypassable_list{std::make_shared<FakeRenderable>(display_area)}
47+ : mock_bypassable_buffer{std::make_shared<NiceMock<MockBuffer>>()}
48+ , fake_bypassable_renderable{
49+ std::make_shared<FakeRenderable>(display_area)}
50+ , stub_gbm_native_buffer{
51+ std::make_shared<StubGBMNativeBuffer>(display_area.size)}
52+ , bypassable_list{fake_bypassable_renderable}
53 {
54 ON_CALL(mock_egl, eglChooseConfig(_,_,_,1,_))
55 .WillByDefault(DoAll(SetArgPointee<2>(mock_egl.fake_configs[0]),
56@@ -72,6 +78,14 @@
57 .WillByDefault(Return(true));
58 ON_CALL(*mock_kms_output, schedule_page_flip(_))
59 .WillByDefault(Return(true));
60+
61+ ON_CALL(*mock_bypassable_buffer, size())
62+ .WillByDefault(Return(display_area.size));
63+ ON_CALL(*mock_bypassable_buffer, can_bypass())
64+ .WillByDefault(Return(true));
65+ ON_CALL(*mock_bypassable_buffer, native_buffer_handle())
66+ .WillByDefault(Return(stub_gbm_native_buffer));
67+ fake_bypassable_renderable->set_buffer(mock_bypassable_buffer);
68 }
69
70 // The platform has an implicit dependency on mock_gbm etc so must be
71@@ -82,18 +96,21 @@
72 }
73
74 protected:
75+ int const width{56};
76+ int const height{78};
77+ mir::geometry::Rectangle const display_area{{12,34}, {width,height}};
78 NiceMock<MockGBM> mock_gbm;
79 NiceMock<MockEGL> mock_egl;
80 NiceMock<MockGL> mock_gl;
81 NiceMock<MockDRM> mock_drm;
82+ std::shared_ptr<MockBuffer> mock_bypassable_buffer;
83+ std::shared_ptr<FakeRenderable> fake_bypassable_renderable;
84+ std::shared_ptr<mesa::GBMNativeBuffer> stub_gbm_native_buffer;
85 gbm_bo* fake_bo;
86 gbm_bo_handle fake_handle;
87 UdevEnvironment fake_devices;
88 std::shared_ptr<MockKMSOutput> mock_kms_output;
89 StubGLConfig gl_config;
90- int const width{56};
91- int const height{78};
92- mir::geometry::Rectangle const display_area{{12,34}, {width,height}};
93 mir::graphics::RenderableList const bypassable_list;
94
95 };
96@@ -150,6 +167,31 @@
97 EXPECT_TRUE(db.post_renderables_if_optimizable(bypassable_list));
98 }
99
100+TEST_F(MesaDisplayBufferTest, skips_bypass_because_of_lagging_resize)
101+{ // Another regression test for LP: #1398296
102+ auto fullscreen = std::make_shared<FakeRenderable>(display_area);
103+ auto nonbypassable = std::make_shared<testing::NiceMock<MockBuffer>>();
104+ ON_CALL(*nonbypassable, can_bypass())
105+ .WillByDefault(Return(true)); // It has the scanout flag set
106+ ON_CALL(*nonbypassable, size())
107+ .WillByDefault(Return(mir::geometry::Size{12,34}));
108+
109+ fullscreen->set_buffer(nonbypassable);
110+ graphics::RenderableList list{fullscreen};
111+
112+ graphics::mesa::DisplayBuffer db(
113+ create_platform(),
114+ null_display_report(),
115+ {mock_kms_output},
116+ nullptr,
117+ display_area,
118+ mir_orientation_normal,
119+ gl_config,
120+ mock_egl.fake_egl_context);
121+
122+ EXPECT_FALSE(db.post_renderables_if_optimizable(list));
123+}
124+
125 TEST_F(MesaDisplayBufferTest, rotated_cannot_bypass)
126 {
127 graphics::mesa::DisplayBuffer db(

Subscribers

People subscribed via source and target branches