Mir

Merge lp:~kdub/mir/fix-1663062-0.26.1 into lp:~mir-team/mir/0.26-old

Proposed by Kevin DuBois on 2017-02-09
Status: Merged
Merged at revision: 4024
Proposed branch: lp:~kdub/mir/fix-1663062-0.26.1
Merge into: lp:~mir-team/mir/0.26-old
Diff against target: 116 lines (+17/-15)
5 files modified
src/server/graphics/nested/host_connection.h (+1/-1)
src/server/graphics/nested/mir_client_host_connection.cpp (+6/-6)
src/server/graphics/nested/mir_client_host_connection.h (+1/-1)
src/server/graphics/nested/platform.cpp (+8/-6)
tests/include/mir/test/doubles/stub_host_connection.h (+1/-1)
To merge this branch: bzr merge lp:~kdub/mir/fix-1663062-0.26.1
Reviewer Review Type Date Requested Status
Cemil Azizoglu (community) 2017-02-09 Approve on 2017-02-09
Review via email: mp+316891@code.launchpad.net

Commit message

nested: disable passthrough on MirBuffers backed by ShmBuffer. Attempts to upload ShmBuffer via EGLImageTargetTexture2D doesn't work which was causing LP: #1663062. The ShmBuffer needs to be uploaded via TexImage2D, but more plumbing is needed in the nested platform to do that quickly. As a bonus, don't allocate a buffer to try to infer passthrough capabilities in the nested server.

Description of the change

nested: disable passthrough on MirBuffers backed by ShmBuffer. Attempts to upload ShmBuffer via EGLImageTargetTexture2D doesn't work which was causing LP: #1663062. The ShmBuffer needs to be uploaded via TexImage2D, but more plumbing is needed in the nested platform to do that quickly. As a bonus, don't allocate a buffer to try to infer passthrough capabilities in the nested server.

testing: mesa hardware, mesa software, android hardware, android software (passthrough candidates)

To post a comment you must log in.
Cemil Azizoglu (cemil-azizoglu) wrote :

LGTM. Pleased that Android retains passthrough for both.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/server/graphics/nested/host_connection.h'
2--- src/server/graphics/nested/host_connection.h 2017-02-02 19:38:06 +0000
3+++ src/server/graphics/nested/host_connection.h 2017-02-09 18:20:33 +0000
4@@ -78,7 +78,7 @@
5 virtual std::shared_ptr<NativeBuffer> create_buffer(graphics::BufferProperties const&) = 0;
6 virtual std::shared_ptr<NativeBuffer> create_buffer(mir::geometry::Size, MirPixelFormat format) = 0;
7 virtual std::shared_ptr<NativeBuffer> create_buffer(geometry::Size, uint32_t format, uint32_t flags) = 0;
8- virtual bool supports_passthrough() = 0;
9+ virtual bool supports_passthrough(graphics::BufferUsage) = 0;
10
11 protected:
12 HostConnection() = default;
13
14=== modified file 'src/server/graphics/nested/mir_client_host_connection.cpp'
15--- src/server/graphics/nested/mir_client_host_connection.cpp 2017-02-02 19:38:06 +0000
16+++ src/server/graphics/nested/mir_client_host_connection.cpp 2017-02-09 18:20:33 +0000
17@@ -854,13 +854,13 @@
18 return std::make_unique<SurfaceSpec>(mir_connection);
19 }
20
21-bool mgn::MirClientHostConnection::supports_passthrough()
22+bool mgn::MirClientHostConnection::supports_passthrough(mg::BufferUsage usage)
23 {
24- auto buffer = create_buffer(geom::Size{1, 1} , mir_pixel_format_abgr_8888);
25- auto hints = buffer->egl_image_creation_hints();
26- if (std::get<1>(hints) == nullptr && std::get<2>(hints) == nullptr)
27- return false;
28- return true;
29+ //FIXME: ShmBuffers currently don't upload properly. The logic here uses
30+ // passthrough where supported (ANativeWindowBuffer and gbm_bo)
31+ // (LP: #1663062 for more details)
32+ return (mir_extension_android_buffer_v1(mir_connection) ||
33+ ((mir_extension_gbm_buffer_v1(mir_connection) && usage == mg::BufferUsage::hardware)));
34 }
35
36 namespace
37
38=== modified file 'src/server/graphics/nested/mir_client_host_connection.h'
39--- src/server/graphics/nested/mir_client_host_connection.h 2017-01-18 19:57:47 +0000
40+++ src/server/graphics/nested/mir_client_host_connection.h 2017-02-09 18:20:33 +0000
41@@ -87,7 +87,7 @@
42 std::shared_ptr<NativeBuffer> create_buffer(graphics::BufferProperties const&) override;
43 std::shared_ptr<NativeBuffer> create_buffer(geometry::Size, MirPixelFormat) override;
44 std::shared_ptr<NativeBuffer> create_buffer(geometry::Size, uint32_t format, uint32_t flags) override;
45- bool supports_passthrough() override;
46+ bool supports_passthrough(BufferUsage usage) override;
47
48 optional_value<std::shared_ptr<MesaAuthExtension>> auth_extension() override;
49 optional_value<std::shared_ptr<SetGbmExtension>> set_gbm_extension() override;
50
51=== modified file 'src/server/graphics/nested/platform.cpp'
52--- src/server/graphics/nested/platform.cpp 2017-02-02 18:18:49 +0000
53+++ src/server/graphics/nested/platform.cpp 2017-02-09 18:20:33 +0000
54@@ -75,7 +75,7 @@
55
56 std::shared_ptr<mg::Buffer> alloc_buffer(mg::BufferProperties const& properties) override
57 {
58- if (passthrough_candidate(properties.size))
59+ if (passthrough_candidate(properties.size, properties.usage))
60 return std::make_shared<mgn::Buffer>(connection, properties);
61 else
62 return guest_allocator->alloc_buffer(properties);
63@@ -84,7 +84,7 @@
64 std::shared_ptr<mg::Buffer> alloc_buffer(
65 mir::geometry::Size size, uint32_t native_format, uint32_t native_flags) override
66 {
67- if (passthrough_candidate(size))
68+ if (passthrough_candidate(size, mg::BufferUsage::hardware))
69 return std::make_shared<mgn::Buffer>(connection, size, native_format, native_flags);
70 else
71 return guest_allocator->alloc_buffer(size, native_format, native_flags);
72@@ -92,7 +92,7 @@
73
74 std::shared_ptr<mg::Buffer> alloc_software_buffer(mir::geometry::Size size, MirPixelFormat format) override
75 {
76- if (passthrough_candidate(size))
77+ if (passthrough_candidate(size, mg::BufferUsage::software))
78 return std::make_shared<mgn::Buffer>(connection, size, format);
79 else
80 return guest_allocator->alloc_software_buffer(size, format);
81@@ -104,9 +104,10 @@
82 }
83
84 private:
85- bool passthrough_candidate(mir::geometry::Size size)
86+ bool passthrough_candidate(mir::geometry::Size size, mg::BufferUsage usage)
87 {
88- return (size.width >= mir::geometry::Width{480}) && (size.height >= mir::geometry::Height{480});
89+ return connection->supports_passthrough(usage) &&
90+ (size.width >= mir::geometry::Width{480}) && (size.height >= mir::geometry::Height{480});
91 }
92 std::shared_ptr<mgn::HostConnection> const connection;
93 std::shared_ptr<mg::GraphicBufferAllocator> const guest_allocator;
94@@ -115,7 +116,8 @@
95
96 mir::UniqueModulePtr<mg::GraphicBufferAllocator> mgn::Platform::create_buffer_allocator()
97 {
98- if (connection->supports_passthrough())
99+ if (connection->supports_passthrough(mg::BufferUsage::software) ||
100+ connection->supports_passthrough(mg::BufferUsage::hardware))
101 {
102 return mir::make_module_ptr<BufferAllocator>(connection, guest_platform->create_buffer_allocator());
103 }
104
105=== modified file 'tests/include/mir/test/doubles/stub_host_connection.h'
106--- tests/include/mir/test/doubles/stub_host_connection.h 2017-02-02 19:38:06 +0000
107+++ tests/include/mir/test/doubles/stub_host_connection.h 2017-02-09 18:20:33 +0000
108@@ -177,7 +177,7 @@
109 };
110 return std::make_unique<NullSpec>();
111 }
112- bool supports_passthrough()
113+ bool supports_passthrough(graphics::BufferUsage)
114 {
115 return true;
116 }

Subscribers

People subscribed via source and target branches