Mir

Merge lp:~kdub/mir/nbs-option into lp:mir

Proposed by Kevin DuBois
Status: Merged
Approved by: Daniel van Vugt
Approved revision: no longer in the source branch.
Merged at revision: 3010
Proposed branch: lp:~kdub/mir/nbs-option
Merge into: lp:mir
Diff against target: 100 lines (+22/-11)
3 files modified
src/server/compositor/buffer_map.cpp (+2/-2)
src/server/compositor/buffer_map.h (+3/-3)
src/server/compositor/buffer_stream_factory.cpp (+17/-6)
To merge this branch: bzr merge lp:~kdub/mir/nbs-option
Reviewer Review Type Date Requested Status
Daniel van Vugt Approve
Alan Griffiths Approve
Chris Halse Rogers Approve
PS Jenkins bot (community) continuous-integration Approve
Brandon Schaefer (community) Approve
Review via email: mp+273523@code.launchpad.net

Commit message

add an option to enable the new buffer semantics under the hood, by setting "--nbuffers 0"

Description of the change

add an option to enable the new buffer semantics under the hood, by setting "--nbuffers 0".

There are still a few optimizations (overallocation, timeout-dropping) and performance studies that need to be added before switching over entirely, but its useful to have this option around to play with the new system. Titlebars on the demo server are also not drawn yet, have to transition from surface-based titlebars.

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
Brandon Schaefer (brandontschaefer) wrote :

- if (nbuffers < 2)
- throw std::logic_error("nbuffers must be at least 2");

Should we at lease assert nbuffers >= 0? (Or throw if its lower then 0)

Otherwise LGTM

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

Nice transitional option. Although nbuffers==1 will probably break things so better fix that error checking.

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

What does the EventSink => BufferSink change have to do with adding the option?

I'm not sure that "--nbuffers 0" is an obvious way to make this choice. Is this a transitional mechanism or will it remain around?

review: Needs Information
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Chris Halse Rogers (raof) wrote :

You could split out the EventSink → BufferSink change (I agree that it's correct and sensible).

Under the assumption that --nbuffers is a transitional option that will go away entirely once NBS is the supported buffer mechanism, +1.

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

Thanks for fixing that.

(1) The EventSink->BufferSink change is syntactically required only because BufferMap is constructed in the absence of the former. But I find it odd they're apparently compatible, while not type compatible though. Can we separate that or find a way to give the right EventSink to BufferMap?

(2) I think --nbuffers will linger for a while yet. We'll need it as a fallback even when using NBS in production, because we need to be able to compare functionality and performance for a while. The timeframe for large architectural changes like this seems to be around a year; which is the average time we seem to take to flesh out all the significant regressions from any large change. Using the repo history unfortunately is no longer an alternative to this. Because we keep breaking backward compatibility, you can't rely on an old copy of the Mir source code to be buildable in future distros. So instead, keep the old functionality in the current source code.

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

With the EventSink to BufferSink change, this is some correction that should have happened in rev2765 when EventSink was kept private, and BufferSink was made a public header. Its better to give BufferMap a BufferSink then to change the factory to take an EventSink, as all the BufferMap needs is the BufferSink interfaces.

--nbuffers is a transitional option useful to testing that will go away eventually. It will (probably) be around for a release or three while we ensure the new system is up-to-par with the old.

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

OK. (I'm still not convinced "--nbuffers 0" is a good name for this but it isn't worth blocking over.)

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

I agree with Alan that it would be more self explanatory as something like:
  --bufferqueue=0 (meaning BufferQueue is disabled)

However we are bound to the existing option syntax. Better to have something microscopically confusing than to break backward-compatibility too much.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/server/compositor/buffer_map.cpp'
2--- src/server/compositor/buffer_map.cpp 2015-08-05 19:01:39 +0000
3+++ src/server/compositor/buffer_map.cpp 2015-10-07 18:29:25 +0000
4@@ -17,7 +17,7 @@
5 */
6
7 #include "mir/graphics/graphic_buffer_allocator.h"
8-#include "mir/frontend/event_sink.h"
9+#include "mir/frontend/buffer_sink.h"
10 #include "buffer_map.h"
11 #include <boost/throw_exception.hpp>
12
13@@ -27,7 +27,7 @@
14
15 mc::BufferMap::BufferMap(
16 mf::BufferStreamId id,
17- std::shared_ptr<mf::EventSink> const& sink,
18+ std::shared_ptr<mf::BufferSink> const& sink,
19 std::shared_ptr<mg::GraphicBufferAllocator> const& allocator) :
20 stream_id(id),
21 sink(sink),
22
23=== modified file 'src/server/compositor/buffer_map.h'
24--- src/server/compositor/buffer_map.h 2015-08-05 19:01:39 +0000
25+++ src/server/compositor/buffer_map.h 2015-10-07 18:29:25 +0000
26@@ -27,7 +27,7 @@
27 namespace mir
28 {
29 namespace graphics { class GraphicBufferAllocator; }
30-namespace frontend { class EventSink; }
31+namespace frontend { class BufferSink; }
32 namespace compositor
33 {
34 class BufferMap : public frontend::ClientBuffers
35@@ -35,7 +35,7 @@
36 public:
37 BufferMap(
38 frontend::BufferStreamId id,
39- std::shared_ptr<frontend::EventSink> const& sink,
40+ std::shared_ptr<frontend::BufferSink> const& sink,
41 std::shared_ptr<graphics::GraphicBufferAllocator> const& allocator);
42
43 graphics::BufferID add_buffer(graphics::BufferProperties const& properties) override;
44@@ -51,7 +51,7 @@
45 Map::iterator checked_buffers_find(graphics::BufferID, std::unique_lock<std::mutex> const&);
46
47 frontend::BufferStreamId const stream_id;
48- std::shared_ptr<frontend::EventSink> const sink;
49+ std::shared_ptr<frontend::BufferSink> const sink;
50 std::shared_ptr<graphics::GraphicBufferAllocator> const allocator;
51 };
52 }
53
54=== modified file 'src/server/compositor/buffer_stream_factory.cpp'
55--- src/server/compositor/buffer_stream_factory.cpp 2015-07-22 02:54:31 +0000
56+++ src/server/compositor/buffer_stream_factory.cpp 2015-10-07 18:29:25 +0000
57@@ -22,6 +22,8 @@
58 #include "buffer_stream_surfaces.h"
59 #include "mir/graphics/buffer_properties.h"
60 #include "buffer_queue.h"
61+#include "stream.h"
62+#include "buffer_map.h"
63 #include "mir/graphics/buffer.h"
64 #include "mir/graphics/buffer_id.h"
65 #include "mir/graphics/graphic_buffer_allocator.h"
66@@ -45,8 +47,8 @@
67 {
68 assert(gralloc);
69 assert(policy_factory);
70- if (nbuffers < 2)
71- throw std::logic_error("nbuffers must be at least 2");
72+ if (nbuffers == 1)
73+ throw std::logic_error("nbuffers cannot be 1");
74 }
75
76
77@@ -58,10 +60,19 @@
78 }
79
80 std::shared_ptr<mc::BufferStream> mc::BufferStreamFactory::create_buffer_stream(
81- mf::BufferStreamId, std::shared_ptr<mf::BufferSink> const&,
82+ mf::BufferStreamId id, std::shared_ptr<mf::BufferSink> const& sink,
83 int nbuffers, mg::BufferProperties const& buffer_properties)
84 {
85- auto switching_bundle = std::make_shared<mc::BufferQueue>(
86- nbuffers, gralloc, buffer_properties, *policy_factory);
87- return std::make_shared<mc::BufferStreamSurfaces>(switching_bundle);
88+ if (nbuffers == 0)
89+ {
90+ return std::make_shared<mc::Stream>(
91+ std::make_unique<mc::BufferMap>(id, sink, gralloc),
92+ buffer_properties.size, buffer_properties.format);
93+ }
94+ else
95+ {
96+ auto switching_bundle = std::make_shared<mc::BufferQueue>(
97+ nbuffers, gralloc, buffer_properties, *policy_factory);
98+ return std::make_shared<mc::BufferStreamSurfaces>(switching_bundle);
99+ }
100 }

Subscribers

People subscribed via source and target branches