Merge lp:~vanvugt/mir/more-mesa-displaybuffer-transform into lp:mir
- more-mesa-displaybuffer-transform
- Merge into development-branch
Status: | Merged |
---|---|
Approved by: | Alberto Aguirre |
Approved revision: | no longer in the source branch. |
Merged at revision: | 4154 |
Proposed branch: | lp:~vanvugt/mir/more-mesa-displaybuffer-transform |
Merge into: | lp:mir |
Prerequisite: | lp:~vanvugt/mir/simplify-fb_for |
Diff against target: |
354 lines (+47/-53) 4 files modified
src/platforms/mesa/server/kms/display.cpp (+15/-8) src/platforms/mesa/server/kms/display_buffer.cpp (+7/-20) src/platforms/mesa/server/kms/display_buffer.h (+3/-3) tests/unit-tests/platforms/mesa/kms/test_display_buffer.cpp (+22/-22) |
To merge this branch: | bzr merge lp:~vanvugt/mir/more-mesa-displaybuffer-transform |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Alberto Aguirre (community) | Approve | ||
Alexandros Frantzis (community) | Abstain | ||
Mir CI Bot | continuous-integration | Approve | |
Review via email: mp+320893@code.launchpad.net |
Commit message
Construct mesa::DisplayBuffer with a general transformation matrix
instead of orientation.
Description of the change
Mir CI Bot (mir-ci-bot) wrote : | # |
Mir CI Bot (mir-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:4112
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Mir CI Bot (mir-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:4115
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Alexandros Frantzis (afrantzis) wrote : | # |
+ auto const physical_size = transformation * logical_size;
We should multiply with the inverse transformation matrix here, which is the correct way to get from logical back to physical. It won't make a difference in the results with the orientations/
Probably pre-existing: I noticed that no test covers this code path (e.g. if we set physical_size = logical_size in the code above, all tests still pass).
Daniel van Vugt (vanvugt) wrote : | # |
That's incorrect I think. And the branch is correct. I have intentionally designed the transformations such that:
physical_size = transformation * logical_size;
and no matrix inversion is ever needed (in the entire source tree!).
For example, when the logical view area size is 12x34 and the transformation is 2x scale then the physical DisplayBuffer size is expected to be 24x68.
See also the documentation for transformation in:
include/
where it is more obvious that transformation is for mapping logical to physical.
Mir CI Bot (mir-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:4119
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
ABORTED: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Daniel van Vugt (vanvugt) wrote : | # |
06:29:13 Build timed out (after 180 minutes). Marking the build as aborted.
Mir CI Bot (mir-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:4120
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
ABORTED: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Mir CI Bot (mir-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:4121
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
ABORTED: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Mir CI Bot (mir-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:4122
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
ABORTED: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Mir CI Bot (mir-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:4122
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
ABORTED: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Mir CI Bot (mir-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:4123
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Alexandros Frantzis (afrantzis) : | # |
Alberto Aguirre (albaguirre) wrote : | # |
Yep. We can add testing in a separate branch
Preview Diff
1 | === modified file 'src/platforms/mesa/server/kms/display.cpp' |
2 | --- src/platforms/mesa/server/kms/display.cpp 2017-03-31 06:56:29 +0000 |
3 | +++ src/platforms/mesa/server/kms/display.cpp 2017-04-06 09:50:37 +0000 |
4 | @@ -30,6 +30,7 @@ |
5 | #include "mir/graphics/virtual_output.h" |
6 | #include "mir/graphics/display_report.h" |
7 | #include "mir/graphics/display_configuration_policy.h" |
8 | +#include "mir/graphics/transformation.h" |
9 | #include "mir/geometry/rectangle.h" |
10 | #include "mir/renderer/gl/context.h" |
11 | |
12 | @@ -544,18 +545,24 @@ |
13 | orientation = conf_output.orientation; |
14 | }); |
15 | |
16 | + // TODO in future outputs should emit transformation instead of |
17 | + // orientation |
18 | + auto const transformation = mg::transformation(orientation); |
19 | + |
20 | if (comp) |
21 | { |
22 | - display_buffers[group_idx++]->set_orientation(orientation, bounding_rect); |
23 | + display_buffers[group_idx++]->set_transformation(transformation, |
24 | + bounding_rect); |
25 | } |
26 | else |
27 | { |
28 | - uint32_t width = bounding_rect.size.width.as_uint32_t(); |
29 | - uint32_t height = bounding_rect.size.height.as_uint32_t(); |
30 | - if (orientation == mir_orientation_left || orientation == mir_orientation_right) |
31 | - { |
32 | - std::swap(width, height); |
33 | - } |
34 | + glm::vec2 const logical_size{ |
35 | + bounding_rect.size.width.as_uint32_t(), |
36 | + bounding_rect.size.height.as_uint32_t()}; |
37 | + |
38 | + auto const physical_size = transformation * logical_size; |
39 | + uint32_t width = abs(physical_size.x); |
40 | + uint32_t height = abs(physical_size.y); |
41 | |
42 | for (auto const& group : kms_output_groups) |
43 | { |
44 | @@ -585,7 +592,7 @@ |
45 | } |
46 | }, |
47 | bounding_rect, |
48 | - orientation); |
49 | + transformation); |
50 | |
51 | display_buffers_new.push_back(std::move(db)); |
52 | } |
53 | |
54 | === modified file 'src/platforms/mesa/server/kms/display_buffer.cpp' |
55 | --- src/platforms/mesa/server/kms/display_buffer.cpp 2017-03-27 22:18:17 +0000 |
56 | +++ src/platforms/mesa/server/kms/display_buffer.cpp 2017-04-06 09:50:37 +0000 |
57 | @@ -489,29 +489,16 @@ |
58 | std::vector<std::shared_ptr<KMSOutput>> const& outputs, |
59 | GBMOutputSurface&& surface_gbm, |
60 | geom::Rectangle const& area, |
61 | - MirOrientation rot) |
62 | + glm::mat2 const& transformation) |
63 | : listener(listener), |
64 | bypass_option(option), |
65 | outputs(outputs), |
66 | surface{std::move(surface_gbm)}, |
67 | area(area), |
68 | - transform{mg::transformation(rot)}, |
69 | + transform{transformation}, |
70 | needs_set_crtc{false}, |
71 | page_flips_pending{false} |
72 | { |
73 | - uint32_t area_width = area.size.width.as_uint32_t(); |
74 | - uint32_t area_height = area.size.height.as_uint32_t(); |
75 | - if (rot == mir_orientation_left || rot == mir_orientation_right) |
76 | - { |
77 | - fb_width = area_height; |
78 | - fb_height = area_width; |
79 | - } |
80 | - else |
81 | - { |
82 | - fb_width = area_width; |
83 | - fb_height = area_height; |
84 | - } |
85 | - |
86 | listener->report_successful_setup_of_native_resources(); |
87 | |
88 | make_current(); |
89 | @@ -534,8 +521,8 @@ |
90 | std::mem_fn(&EGLBufferCopier::copy_front_buffer_from), |
91 | std::make_shared<EGLBufferCopier>( |
92 | outputs.front()->drm_fd(), |
93 | - fb_width, |
94 | - fb_height, |
95 | + surface.size().width.as_int(), |
96 | + surface.size().height.as_int(), |
97 | GBM_BO_FORMAT_XRGB8888), |
98 | std::placeholders::_1); |
99 | } |
100 | @@ -586,9 +573,9 @@ |
101 | return transform; |
102 | } |
103 | |
104 | -void mgm::DisplayBuffer::set_orientation(MirOrientation const rot, geometry::Rectangle const& a) |
105 | +void mgm::DisplayBuffer::set_transformation(glm::mat2 const& t, geometry::Rectangle const& a) |
106 | { |
107 | - transform = mg::transformation(rot); |
108 | + transform = t; |
109 | area = a; |
110 | } |
111 | |
112 | @@ -607,7 +594,7 @@ |
113 | if (!native) |
114 | BOOST_THROW_EXCEPTION(std::invalid_argument("could not convert NativeBuffer")); |
115 | if (native->flags & mir_buffer_flag_can_scanout && |
116 | - bypass_buffer->size() == geom::Size{fb_width,fb_height} && |
117 | + bypass_buffer->size() == surface.size() && |
118 | !needs_bounce_buffer(*outputs.front(), native->bo)) |
119 | { |
120 | if (auto bufobj = outputs.front()->fb_for(native->bo)) |
121 | |
122 | === modified file 'src/platforms/mesa/server/kms/display_buffer.h' |
123 | --- src/platforms/mesa/server/kms/display_buffer.h 2017-03-22 23:09:51 +0000 |
124 | +++ src/platforms/mesa/server/kms/display_buffer.h 2017-04-06 09:50:37 +0000 |
125 | @@ -85,6 +85,7 @@ |
126 | |
127 | FrontBuffer lock_front(); |
128 | void report_egl_configuration(std::function<void(EGLDisplay, EGLConfig)> const& to); |
129 | + geometry::Size size() const { return {width, height}; } |
130 | private: |
131 | int const drm_fd; |
132 | uint32_t width, height; |
133 | @@ -103,7 +104,7 @@ |
134 | std::vector<std::shared_ptr<KMSOutput>> const& outputs, |
135 | GBMOutputSurface&& surface_gbm, |
136 | geometry::Rectangle const& area, |
137 | - MirOrientation rot); |
138 | + glm::mat2 const& transformation); |
139 | ~DisplayBuffer(); |
140 | |
141 | geometry::Rectangle view_area() const override; |
142 | @@ -121,7 +122,7 @@ |
143 | glm::mat2 transformation() const override; |
144 | NativeDisplayBuffer* native_display_buffer() override; |
145 | |
146 | - void set_orientation(MirOrientation const rot, geometry::Rectangle const& a); |
147 | + void set_transformation(glm::mat2 const& t, geometry::Rectangle const& a); |
148 | void schedule_set_crtc(); |
149 | void wait_for_page_flip(); |
150 | |
151 | @@ -148,7 +149,6 @@ |
152 | std::function<GBMOutputSurface::FrontBuffer(GBMOutputSurface::FrontBuffer&&)> get_front_buffer; |
153 | |
154 | geometry::Rectangle area; |
155 | - uint32_t fb_width, fb_height; |
156 | glm::mat2 transform; |
157 | std::atomic<bool> needs_set_crtc; |
158 | std::chrono::milliseconds recommend_sleep{0}; |
159 | |
160 | === modified file 'tests/unit-tests/platforms/mesa/kms/test_display_buffer.cpp' |
161 | --- tests/unit-tests/platforms/mesa/kms/test_display_buffer.cpp 2017-03-27 22:18:17 +0000 |
162 | +++ tests/unit-tests/platforms/mesa/kms/test_display_buffer.cpp 2017-04-06 09:50:37 +0000 |
163 | @@ -31,6 +31,7 @@ |
164 | #include "mir/test/doubles/stub_gbm_native_buffer.h" |
165 | #include "mir_test_framework/udev_environment.h" |
166 | #include "mir/test/doubles/fake_renderable.h" |
167 | +#include "mir/graphics/transformation.h" |
168 | #include "mock_kms_output.h" |
169 | |
170 | #include <gtest/gtest.h> |
171 | @@ -155,7 +156,7 @@ |
172 | {mock_kms_output}, |
173 | make_output_surface(), |
174 | display_area, |
175 | - mir_orientation_normal); |
176 | + {}); |
177 | |
178 | EXPECT_EQ(display_area, db.view_area()); |
179 | } |
180 | @@ -168,7 +169,7 @@ |
181 | {mock_kms_output}, |
182 | make_output_surface(), |
183 | display_area, |
184 | - mir_orientation_normal); |
185 | + {}); |
186 | |
187 | auto original_count = mock_bypassable_buffer.use_count(); |
188 | |
189 | @@ -192,7 +193,7 @@ |
190 | {mock_kms_output}, |
191 | make_output_surface(), |
192 | display_area, |
193 | - mir_orientation_normal); |
194 | + {}); |
195 | |
196 | for (int frame = 0; frame < 5; ++frame) |
197 | { |
198 | @@ -218,7 +219,7 @@ |
199 | {mock_kms_output}, |
200 | make_output_surface(), |
201 | display_area, |
202 | - mir_orientation_normal); |
203 | + {}); |
204 | |
205 | for (int frame = 0; frame < 5; ++frame) |
206 | { |
207 | @@ -238,7 +239,7 @@ |
208 | {mock_kms_output}, |
209 | make_output_surface(), |
210 | display_area, |
211 | - mir_orientation_normal); |
212 | + {}); |
213 | |
214 | auto original_count = mock_bypassable_buffer.use_count(); |
215 | |
216 | @@ -251,7 +252,7 @@ |
217 | EXPECT_EQ(original_count+1, mock_bypassable_buffer.use_count()); |
218 | } |
219 | |
220 | -TEST_F(MesaDisplayBufferTest, normal_orientation_with_bypassable_list_can_bypass) |
221 | +TEST_F(MesaDisplayBufferTest, untransformed_with_bypassable_list_can_bypass) |
222 | { |
223 | graphics::mesa::DisplayBuffer db( |
224 | graphics::mesa::BypassOption::allowed, |
225 | @@ -259,7 +260,7 @@ |
226 | {mock_kms_output}, |
227 | make_output_surface(), |
228 | display_area, |
229 | - mir_orientation_normal); |
230 | + {}); |
231 | |
232 | EXPECT_TRUE(db.overlay(bypassable_list)); |
233 | } |
234 | @@ -277,7 +278,7 @@ |
235 | {mock_kms_output}, |
236 | make_output_surface(), |
237 | display_area, |
238 | - mir_orientation_normal); |
239 | + {}); |
240 | |
241 | EXPECT_FALSE(db.overlay(bypassable_list)); |
242 | // And then we recover. DRM finds enough resources to AddFB ... |
243 | @@ -302,7 +303,7 @@ |
244 | {mock_kms_output}, |
245 | make_output_surface(), |
246 | display_area, |
247 | - mir_orientation_normal); |
248 | + {}); |
249 | |
250 | EXPECT_FALSE(db.overlay(list)); |
251 | } |
252 | @@ -315,7 +316,7 @@ |
253 | {mock_kms_output}, |
254 | make_output_surface(), |
255 | display_area, |
256 | - mir_orientation_right); |
257 | + transformation(mir_orientation_right)); |
258 | |
259 | EXPECT_FALSE(db.overlay(bypassable_list)); |
260 | } |
261 | @@ -333,7 +334,7 @@ |
262 | {mock_kms_output}, |
263 | make_output_surface(), |
264 | display_area, |
265 | - mir_orientation_normal); |
266 | + {}); |
267 | |
268 | EXPECT_FALSE(db.overlay(list)); |
269 | } |
270 | @@ -351,7 +352,7 @@ |
271 | {mock_kms_output}, |
272 | make_output_surface(), |
273 | display_area, |
274 | - mir_orientation_normal); |
275 | + {}); |
276 | |
277 | // If you find yourself using gbm_ functions on a Shm buffer then you're |
278 | // asking for a crash (LP: #1493721) ... |
279 | @@ -359,10 +360,9 @@ |
280 | db.overlay(list); |
281 | } |
282 | |
283 | -TEST_F(MesaDisplayBufferTest, orientation_not_implemented_internally) |
284 | +TEST_F(MesaDisplayBufferTest, transformation_not_implemented_internally) |
285 | { |
286 | - glm::mat2 const rotate_left( 0, 1, // transposed! |
287 | - -1, 0); |
288 | + glm::mat2 const rotate_left = transformation(mir_orientation_left); |
289 | |
290 | graphics::mesa::DisplayBuffer db( |
291 | graphics::mesa::BypassOption::allowed, |
292 | @@ -370,7 +370,7 @@ |
293 | {mock_kms_output}, |
294 | make_output_surface(), |
295 | display_area, |
296 | - mir_orientation_left); |
297 | + rotate_left); |
298 | |
299 | EXPECT_EQ(rotate_left, db.transformation()); |
300 | } |
301 | @@ -390,7 +390,7 @@ |
302 | {mock_kms_output, mock_kms_output}, |
303 | make_output_surface(), |
304 | display_area, |
305 | - mir_orientation_normal); |
306 | + {}); |
307 | |
308 | db.swap_buffers(); |
309 | db.post(); |
310 | @@ -409,7 +409,7 @@ |
311 | {mock_kms_output}, |
312 | make_output_surface(), |
313 | display_area, |
314 | - mir_orientation_normal); |
315 | + {}); |
316 | |
317 | db.swap_buffers(); |
318 | db.post(); |
319 | @@ -436,7 +436,7 @@ |
320 | {mock_kms_output, mock_kms_output}, |
321 | make_output_surface(), |
322 | display_area, |
323 | - mir_orientation_normal); |
324 | + {}); |
325 | |
326 | db.swap_buffers(); |
327 | db.post(); |
328 | @@ -458,7 +458,7 @@ |
329 | {mock_kms_output}, |
330 | make_output_surface(), |
331 | display_area, |
332 | - mir_orientation_normal); |
333 | + {}); |
334 | |
335 | EXPECT_FALSE(db.overlay(list)); |
336 | } |
337 | @@ -483,7 +483,7 @@ |
338 | {mock_kms_output}, |
339 | make_output_surface(), |
340 | display_area, |
341 | - mir_orientation_normal); |
342 | + {}); |
343 | |
344 | EXPECT_FALSE(db.overlay(list)); |
345 | } |
346 | @@ -499,7 +499,7 @@ |
347 | {mock_kms_output}, |
348 | make_output_surface(), |
349 | display_area, |
350 | - mir_orientation_normal); |
351 | + {}); |
352 | |
353 | EXPECT_FALSE(db.overlay(bypassable_list)); |
354 | } |
FAILED: Continuous integration, rev:4111 /mir-jenkins. ubuntu. com/job/ mir-ci/ 3235/ /mir-jenkins. ubuntu. com/job/ build-mir/ 4353/console /mir-jenkins. ubuntu. com/job/ build-0- fetch/4440 /mir-jenkins. ubuntu. com/job/ build-1- sourcepkg/ release= vivid+overlay/ 4430 /mir-jenkins. ubuntu. com/job/ build-1- sourcepkg/ release= xenial+ overlay/ 4430 /mir-jenkins. ubuntu. com/job/ build-1- sourcepkg/ release= zesty/4430 /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= amd64,compiler= clang,platform= mesa,release= zesty/4385 /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= amd64,compiler= clang,platform= mesa,release= zesty/4385/ artifact/ output/ *zip*/output. zip /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= amd64,compiler= gcc,platform= mesa,release= xenial+ overlay/ 4385 /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= amd64,compiler= gcc,platform= mesa,release= xenial+ overlay/ 4385/artifact/ output/ *zip*/output. zip /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= amd64,compiler= gcc,platform= mesa,release= zesty/4385 /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= amd64,compiler= gcc,platform= mesa,release= zesty/4385/ artifact/ output/ *zip*/output. zip /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= cross-armhf, compiler= gcc,platform= android, release= vivid+overlay/ 4385/console /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= i386,compiler= gcc,platform= android, release= vivid+overlay/ 4385/console /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= i386,compiler= gcc,platform= mesa,release= xenial+ overlay/ 4385 /mir-jenkins. ubuntu. com/job/ build-2- binpkg- mir/arch= i386,compiler= gcc,platform= mesa,release= xenial+ overlay/ 4385/artifact/ output/ *zip*/output. zip
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
FAILURE: https:/
FAILURE: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild: /mir-jenkins. ubuntu. com/job/ mir-ci/ 3235/rebuild
https:/