Status: | Superseded |
---|---|
Proposed branch: | lp:~mir-team/mir/0.18.3 |
Merge into: | lp:mir/0.18 |
Diff against target: |
1674 lines (+513/-67) 60 files modified
debian/changelog (+7/-1) include/renderers/gl/mir/renderer/gl/texture_source.h (+10/-0) src/common/graphics/android/CMakeLists.txt (+2/-0) src/common/graphics/android/android_native_buffer.cpp (+15/-1) src/gl/recently_used_cache.cpp (+8/-7) src/include/common/mir/graphics/android/android_native_buffer.h (+6/-0) src/include/common/mir/graphics/android/native_buffer.h (+3/-0) src/platform/symbols.map (+14/-0) src/platforms/android/client/CMakeLists.txt (+3/-0) src/platforms/android/client/gralloc_registrar.cpp (+3/-1) src/platforms/android/server/CMakeLists.txt (+1/-0) src/platforms/android/server/android_alloc_adaptor.cpp (+12/-5) src/platforms/android/server/android_alloc_adaptor.h (+6/-2) src/platforms/android/server/android_buffer_allocator.cpp (+10/-4) src/platforms/android/server/android_graphic_buffer_allocator.h (+5/-1) src/platforms/android/server/buffer.cpp (+23/-4) src/platforms/android/server/buffer.h (+6/-0) src/platforms/android/server/cmdstream_sync_factory.h (+48/-0) src/platforms/android/server/device_quirks.cpp (+7/-1) src/platforms/android/server/device_quirks.h (+1/-0) src/platforms/android/server/display_buffer.cpp (+3/-0) src/platforms/android/server/display_component_factory.h (+2/-0) src/platforms/android/server/display_device.h (+2/-0) src/platforms/android/server/egl_sync_factory.cpp (+34/-0) src/platforms/android/server/fb_device.cpp (+5/-2) src/platforms/android/server/fb_device.h (+1/-0) src/platforms/android/server/hal_component_factory.cpp (+20/-1) src/platforms/android/server/hal_component_factory.h (+4/-1) src/platforms/android/server/hwc_device.cpp (+11/-6) src/platforms/android/server/hwc_device.h (+1/-0) src/platforms/android/server/hwc_fb_device.cpp (+5/-0) src/platforms/android/server/hwc_fb_device.h (+1/-0) src/platforms/android/server/ipc_operations.cpp (+1/-0) src/platforms/android/server/platform.cpp (+10/-4) src/platforms/android/server/platform.h (+3/-0) src/platforms/mesa/server/common/gbm_buffer.cpp (+9/-0) src/platforms/mesa/server/common/gbm_buffer.h (+2/-0) src/platforms/mesa/server/common/shm_buffer.cpp (+9/-0) src/platforms/mesa/server/common/shm_buffer.h (+2/-0) tests/include/mir/test/doubles/mock_android_native_buffer.h (+2/-0) tests/include/mir/test/doubles/mock_buffer.h (+1/-0) tests/include/mir/test/doubles/mock_display_device.h (+3/-0) tests/include/mir/test/doubles/mock_gl_buffer.h (+2/-0) tests/include/mir/test/doubles/stub_android_native_buffer.h (+3/-0) tests/include/mir/test/doubles/stub_cmdstream_sync_factory.h (+41/-0) tests/include/mir/test/doubles/stub_display_builder.h (+5/-0) tests/include/mir/test/doubles/stub_gl_buffer.h (+2/-0) tests/integration-tests/graphics/mesa/test_buffer_integration.cpp (+3/-0) tests/unit-tests/gl/test_gl_texture_cache.cpp (+3/-1) tests/unit-tests/gl/test_program_factory.cpp (+1/-1) tests/unit-tests/graphics/android/test_android_alloc_adaptor.cpp (+5/-2) tests/unit-tests/graphics/android/test_android_buffer_allocator.cpp (+6/-2) tests/unit-tests/graphics/android/test_buffer_tex_bind.cpp (+13/-1) tests/unit-tests/graphics/android/test_display_buffer.cpp (+15/-0) tests/unit-tests/graphics/android/test_display_hotplug.cpp (+5/-0) tests/unit-tests/graphics/android/test_fb_device.cpp (+8/-0) tests/unit-tests/graphics/android/test_hwc_device.cpp (+9/-8) tests/unit-tests/graphics/android/test_hwc_fb_device.cpp (+6/-0) tests/unit-tests/graphics/android/test_native_buffer.cpp (+50/-7) tests/unit-tests/graphics/android/test_platform.cpp (+15/-4) |
To merge this branch: | bzr merge lp:~mir-team/mir/0.18.3 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Mir development team | Pending | ||
Review via email: mp+283845@code.launchpad.net |
Commit message
MP for Temporary silo to address lp: #1517205
Description of the change
MP for Temporary silo to address lp: #1517205
To post a comment you must log in.
Unmerged revisions
- 3197. By Kevin DuBois
-
add quirk to clear fence for another device during FB GL rendering
- 3196. By Kevin DuBois
-
disable eglsync on mx4 due to driver problem necessitating gles3.0
- 3195. By Kevin DuBois
-
bump changelog to 0.18.2
- 3194. By Kevin DuBois
-
reintroduce sync fences
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'debian/changelog' |
2 | --- debian/changelog 2016-01-18 18:06:23 +0000 |
3 | +++ debian/changelog 2016-01-25 17:04:59 +0000 |
4 | @@ -1,4 +1,10 @@ |
5 | -mir (0.18.1-0ubuntu1) UNRELEASED; urgency=medium |
6 | +mir (0.18.2-0ubuntu1) UNRELEASED; urgency=medium |
7 | + |
8 | + * Add egl sync fences for devices that need it. (LP: #1517205) |
9 | + |
10 | + -- Kevin DuBois <kevin.dubois@canonical.com> Mon, 25 Jan 2016 09:58:43 -0500 |
11 | + |
12 | +mir (0.18.1-0ubuntu1) xenial; urgency=medium |
13 | |
14 | * New upstream release 0.18.1 (https://launchpad.net/mir/+milestone/0.18.1) |
15 | - No ABI changes. Bug fix release only. |
16 | |
17 | === modified file 'include/renderers/gl/mir/renderer/gl/texture_source.h' |
18 | --- include/renderers/gl/mir/renderer/gl/texture_source.h 2015-12-11 12:22:15 +0000 |
19 | +++ include/renderers/gl/mir/renderer/gl/texture_source.h 2016-01-25 17:04:59 +0000 |
20 | @@ -26,12 +26,22 @@ |
21 | namespace gl |
22 | { |
23 | |
24 | +//FIXME: (kdub) we're not hiding the differences in texture upload approaches between our platforms |
25 | +// very well with this interface. |
26 | class TextureSource |
27 | { |
28 | public: |
29 | virtual ~TextureSource() = default; |
30 | |
31 | + // \warning deprecated, provided for convenience and legacy transition. |
32 | + //will call bind() and then secure_for_render() |
33 | virtual void gl_bind_to_texture() = 0; |
34 | + //Uploads texture. |
35 | + virtual void bind() = 0; |
36 | + //add synchronization points to the command stream to ensure resources |
37 | + //are present during the draw. Will not upload texture. |
38 | + //should be called if an already uploaded texture is reused. |
39 | + virtual void secure_for_render() = 0; |
40 | |
41 | protected: |
42 | TextureSource() = default; |
43 | |
44 | === modified file 'src/common/graphics/android/CMakeLists.txt' |
45 | --- src/common/graphics/android/CMakeLists.txt 2015-12-11 12:22:15 +0000 |
46 | +++ src/common/graphics/android/CMakeLists.txt 2016-01-25 17:04:59 +0000 |
47 | @@ -1,5 +1,7 @@ |
48 | include_directories(SYSTEM ${LIBHARDWARE_INCLUDE_DIRS}) |
49 | include_directories(SYSTEM ${CMAKE_SOURCE_DIR}/3rd_party/android-deps) |
50 | +include_directories(SYSTEM ${CMAKE_SOURCE_DIR}/include/platform) |
51 | +include_directories(SYSTEM ${CMAKE_SOURCE_DIR}/src/include/platform) |
52 | |
53 | add_definitions( -DANDROID ) |
54 | |
55 | |
56 | === modified file 'src/common/graphics/android/android_native_buffer.cpp' |
57 | --- src/common/graphics/android/android_native_buffer.cpp 2015-12-11 12:22:15 +0000 |
58 | +++ src/common/graphics/android/android_native_buffer.cpp 2016-01-25 17:04:59 +0000 |
59 | @@ -17,14 +17,17 @@ |
60 | */ |
61 | |
62 | #include "mir/graphics/android/android_native_buffer.h" |
63 | +#include "mir/graphics/egl_sync_fence.h" |
64 | |
65 | namespace mga=mir::graphics::android; |
66 | |
67 | mga::AndroidNativeBuffer::AndroidNativeBuffer( |
68 | std::shared_ptr<ANativeWindowBuffer> const& anwb, |
69 | + std::shared_ptr<CommandStreamSync> const& cmdstream_sync, |
70 | std::shared_ptr<Fence> const& fence, |
71 | BufferAccess access) |
72 | - : fence(fence), |
73 | + : cmdstream_sync(cmdstream_sync), |
74 | + fence(fence), |
75 | access(access), |
76 | native_window_buffer(anwb) |
77 | { |
78 | @@ -58,3 +61,14 @@ |
79 | { |
80 | return fence->copy_native_handle(); |
81 | } |
82 | + |
83 | +void mga::AndroidNativeBuffer::lock_for_gpu() |
84 | +{ |
85 | + cmdstream_sync->raise(); |
86 | +} |
87 | + |
88 | +void mga::AndroidNativeBuffer::wait_for_unlock_by_gpu() |
89 | +{ |
90 | + using namespace std::chrono; |
91 | + cmdstream_sync->wait_for(duration_cast<nanoseconds>(seconds(2))); |
92 | +} |
93 | |
94 | === modified file 'src/gl/recently_used_cache.cpp' |
95 | --- src/gl/recently_used_cache.cpp 2015-12-11 12:22:15 +0000 |
96 | +++ src/gl/recently_used_cache.cpp 2016-01-25 17:04:59 +0000 |
97 | @@ -27,6 +27,7 @@ |
98 | namespace mg = mir::graphics; |
99 | namespace mgl = mir::gl; |
100 | namespace geom = mir::geometry; |
101 | +namespace mrgl = mir::renderer::gl; |
102 | |
103 | std::shared_ptr<mgl::Texture> mgl::RecentlyUsedCache::load(mg::Renderable const& renderable) |
104 | { |
105 | @@ -35,18 +36,18 @@ |
106 | auto& texture = textures[renderable.id()]; |
107 | texture.texture->bind(); |
108 | |
109 | + auto const texture_source = dynamic_cast<mrgl::TextureSource*>(buffer->native_buffer_base()); |
110 | + if (!texture_source) |
111 | + BOOST_THROW_EXCEPTION(std::logic_error("Buffer does not support GL rendering")); |
112 | + |
113 | if ((texture.last_bound_buffer != buffer_id) || (!texture.valid_binding)) |
114 | { |
115 | - auto const texture_source = |
116 | - dynamic_cast<mir::renderer::gl::TextureSource*>( |
117 | - buffer->native_buffer_base()); |
118 | - if (!texture_source) |
119 | - BOOST_THROW_EXCEPTION(std::logic_error("Buffer does not support GL rendering")); |
120 | - |
121 | - texture_source->gl_bind_to_texture(); |
122 | + texture_source->bind(); |
123 | texture.resource = buffer; |
124 | texture.last_bound_buffer = buffer_id; |
125 | } |
126 | + texture_source->secure_for_render(); |
127 | + |
128 | texture.valid_binding = true; |
129 | texture.used = true; |
130 | |
131 | |
132 | === modified file 'src/include/common/mir/graphics/android/android_native_buffer.h' |
133 | --- src/include/common/mir/graphics/android/android_native_buffer.h 2015-12-11 12:22:15 +0000 |
134 | +++ src/include/common/mir/graphics/android/android_native_buffer.h 2016-01-25 17:04:59 +0000 |
135 | @@ -27,6 +27,7 @@ |
136 | { |
137 | namespace graphics |
138 | { |
139 | +class CommandStreamSync; |
140 | namespace android |
141 | { |
142 | class Fence; |
143 | @@ -35,6 +36,7 @@ |
144 | { |
145 | AndroidNativeBuffer( |
146 | std::shared_ptr<ANativeWindowBuffer> const& handle, |
147 | + std::shared_ptr<CommandStreamSync> const& cmdstream_sync, |
148 | std::shared_ptr<Fence> const& fence, |
149 | BufferAccess fence_access); |
150 | |
151 | @@ -45,7 +47,11 @@ |
152 | void ensure_available_for(BufferAccess); |
153 | void update_usage(NativeFence& merge_fd, BufferAccess); |
154 | |
155 | + void lock_for_gpu(); |
156 | + void wait_for_unlock_by_gpu(); |
157 | + |
158 | private: |
159 | + std::shared_ptr<CommandStreamSync> cmdstream_sync; |
160 | std::shared_ptr<Fence> fence; |
161 | BufferAccess access; |
162 | std::shared_ptr<ANativeWindowBuffer> native_window_buffer; |
163 | |
164 | === modified file 'src/include/common/mir/graphics/android/native_buffer.h' |
165 | --- src/include/common/mir/graphics/android/native_buffer.h 2015-12-11 12:22:15 +0000 |
166 | +++ src/include/common/mir/graphics/android/native_buffer.h 2016-01-25 17:04:59 +0000 |
167 | @@ -53,6 +53,9 @@ |
168 | virtual void ensure_available_for(android::BufferAccess intent) = 0; |
169 | virtual void update_usage(android::NativeFence& fence, android::BufferAccess current_usage) = 0; |
170 | |
171 | + virtual void lock_for_gpu() = 0; |
172 | + virtual void wait_for_unlock_by_gpu() = 0; |
173 | + |
174 | protected: |
175 | NativeBuffer() = default; |
176 | NativeBuffer(NativeBuffer const&) = delete; |
177 | |
178 | === modified file 'src/platform/symbols.map' |
179 | --- src/platform/symbols.map 2015-12-11 12:22:15 +0000 |
180 | +++ src/platform/symbols.map 2016-01-25 17:04:59 +0000 |
181 | @@ -219,6 +219,7 @@ |
182 | vtable?for?mir::graphics::EventHandlerRegister; |
183 | vtable?for?mir::graphics::GLConfig; |
184 | vtable?for?mir::graphics::GLContext; |
185 | + vtable?for?mir::graphics::NullCommandSync; |
186 | vtable?for?mir::graphics::GraphicBufferAllocator; |
187 | vtable?for?mir::graphics::Platform; |
188 | vtable?for?mir::graphics::PlatformIpcOperations; |
189 | @@ -237,6 +238,19 @@ |
190 | mir::graphics::blue_channel_depth*; |
191 | mir::graphics::contains_alpha*; |
192 | mir::graphics::EGLExtensions::EGLExtensions*; |
193 | + mir::graphics::EGLSyncExtensions::EGLSyncExtensions*; |
194 | + mir::graphics::CommandStreamSync::?CommandStreamSync*; |
195 | + mir::graphics::CommandStreamSync::CommandStreamSync*; |
196 | + mir::graphics::CommandStreamSync::CommandStreamSync*; |
197 | + mir::graphics::CommandStreamSync::operator*; |
198 | + mir::graphics::NullCommandSync::?NullCommandSync*; |
199 | + mir::graphics::NullCommandSync::NullCommandSync*; |
200 | + mir::graphics::NullCommandSync::NullCommandSync*; |
201 | + mir::graphics::NullCommandSync::operator*; |
202 | + mir::graphics::EGLSyncFence::?EGLSyncFence*; |
203 | + mir::graphics::EGLSyncFence::EGLSyncFence*; |
204 | + mir::graphics::EGLSyncFence::EGLSyncFence*; |
205 | + mir::graphics::EGLSyncFence::operator*; |
206 | mir::graphics::EGLContextStore::?EGLContextStore*; |
207 | mir::graphics::EGLContextStore::EGLContextStore*; |
208 | mir::graphics::EGLContextStore::EGLContextStore*; |
209 | |
210 | === modified file 'src/platforms/android/client/CMakeLists.txt' |
211 | --- src/platforms/android/client/CMakeLists.txt 2015-12-11 12:22:15 +0000 |
212 | +++ src/platforms/android/client/CMakeLists.txt 2016-01-25 17:04:59 +0000 |
213 | @@ -1,6 +1,8 @@ |
214 | include_directories(${client_common_include_dirs}) |
215 | include_directories(SYSTEM ${LIBHARDWARE_INCLUDE_DIRS}) |
216 | include_directories(SYSTEM ${CMAKE_SOURCE_DIR}/3rd_party/android-deps) |
217 | +include_directories(${CMAKE_SOURCE_DIR}/include/platform) |
218 | +include_directories(${CMAKE_SOURCE_DIR}/src/include/platform) |
219 | |
220 | add_definitions(-DANDROID) |
221 | |
222 | @@ -35,6 +37,7 @@ |
223 | mirclient |
224 | client_platform_common |
225 | mirsharedandroid-static |
226 | + mirplatform |
227 | ${LIBHARDWARE_LIBRARIES} |
228 | ) |
229 | |
230 | |
231 | === modified file 'src/platforms/android/client/gralloc_registrar.cpp' |
232 | --- src/platforms/android/client/gralloc_registrar.cpp 2015-12-11 12:22:15 +0000 |
233 | +++ src/platforms/android/client/gralloc_registrar.cpp 2016-01-25 17:04:59 +0000 |
234 | @@ -18,6 +18,7 @@ |
235 | |
236 | #include "mir/graphics/android/android_native_buffer.h" |
237 | #include "mir/graphics/android/sync_fence.h" |
238 | +#include "mir/graphics/egl_sync_fence.h" |
239 | #include "gralloc_registrar.h" |
240 | #include "mir/client_buffer.h" |
241 | |
242 | @@ -82,7 +83,8 @@ |
243 | anwb->usage = GRALLOC_USAGE_HW_TEXTURE | GRALLOC_USAGE_HW_RENDER; |
244 | anwb->handle = handle.get(); |
245 | |
246 | - return std::make_shared<mga::AndroidNativeBuffer>(anwb, fence, mga::BufferAccess::read); |
247 | + auto sync = std::make_shared<mg::NullCommandSync>(); //no need for eglsync client side |
248 | + return std::make_shared<mga::AndroidNativeBuffer>(anwb, sync, fence, mga::BufferAccess::read); |
249 | } |
250 | } |
251 | std::shared_ptr<mg::NativeBuffer> mcla::GrallocRegistrar::register_buffer( |
252 | |
253 | === modified file 'src/platforms/android/server/CMakeLists.txt' |
254 | --- src/platforms/android/server/CMakeLists.txt 2015-12-11 12:22:15 +0000 |
255 | +++ src/platforms/android/server/CMakeLists.txt 2016-01-25 17:04:59 +0000 |
256 | @@ -43,6 +43,7 @@ |
257 | hwc_fallback_gl_renderer.cpp |
258 | ipc_operations.cpp |
259 | hwc_blanking_control.cpp |
260 | + egl_sync_factory.cpp |
261 | ) |
262 | |
263 | add_library(mirplatformgraphicsandroid SHARED |
264 | |
265 | === modified file 'src/platforms/android/server/android_alloc_adaptor.cpp' |
266 | --- src/platforms/android/server/android_alloc_adaptor.cpp 2015-12-11 12:22:15 +0000 |
267 | +++ src/platforms/android/server/android_alloc_adaptor.cpp 2016-01-25 17:04:59 +0000 |
268 | @@ -20,7 +20,9 @@ |
269 | #include "mir/graphics/android/android_native_buffer.h" |
270 | #include "mir/graphics/android/sync_fence.h" |
271 | #include "mir/graphics/android/android_format_conversion-inl.h" |
272 | +#include "mir/graphics/egl_sync_fence.h" |
273 | #include "android_alloc_adaptor.h" |
274 | +#include "cmdstream_sync_factory.h" |
275 | #include "device_quirks.h" |
276 | |
277 | #include <boost/throw_exception.hpp> |
278 | @@ -48,10 +50,13 @@ |
279 | }; |
280 | } |
281 | |
282 | -mga::AndroidAllocAdaptor::AndroidAllocAdaptor(std::shared_ptr<struct alloc_device_t> const& alloc_device, |
283 | - std::shared_ptr<DeviceQuirks> const& quirks) |
284 | - : alloc_dev(alloc_device), |
285 | - quirks(quirks) |
286 | +mga::AndroidAllocAdaptor::AndroidAllocAdaptor( |
287 | + std::shared_ptr<struct alloc_device_t> const& alloc_device, |
288 | + std::shared_ptr<CommandStreamSyncFactory> const& sync_factory, |
289 | + std::shared_ptr<DeviceQuirks> const& quirks) : |
290 | + alloc_dev(alloc_device), |
291 | + sync_factory(sync_factory), |
292 | + quirks(quirks) |
293 | { |
294 | } |
295 | |
296 | @@ -94,7 +99,9 @@ |
297 | anwb->format = format; |
298 | anwb->usage = usage_flag; |
299 | |
300 | - return std::make_shared<mga::AndroidNativeBuffer>(anwb, fence, mga::BufferAccess::read); |
301 | + return std::make_shared<mga::AndroidNativeBuffer>(anwb, |
302 | + sync_factory->create_command_stream_sync(), |
303 | + fence, mga::BufferAccess::read); |
304 | } |
305 | |
306 | int mga::AndroidAllocAdaptor::convert_to_android_usage(BufferUsage usage) |
307 | |
308 | === modified file 'src/platforms/android/server/android_alloc_adaptor.h' |
309 | --- src/platforms/android/server/android_alloc_adaptor.h 2015-12-11 12:22:15 +0000 |
310 | +++ src/platforms/android/server/android_alloc_adaptor.h 2016-01-25 17:04:59 +0000 |
311 | @@ -31,12 +31,15 @@ |
312 | namespace android |
313 | { |
314 | class DeviceQuirks; |
315 | +class CommandStreamSyncFactory; |
316 | |
317 | class AndroidAllocAdaptor : public GraphicAllocAdaptor |
318 | { |
319 | public: |
320 | - explicit AndroidAllocAdaptor(std::shared_ptr<struct alloc_device_t> const& alloc_device, |
321 | - std::shared_ptr<DeviceQuirks> const& quirks); |
322 | + explicit AndroidAllocAdaptor( |
323 | + std::shared_ptr<struct alloc_device_t> const& alloc_device, |
324 | + std::shared_ptr<CommandStreamSyncFactory> const& cmdstream_sync_factory, |
325 | + std::shared_ptr<DeviceQuirks> const& quirks); |
326 | std::shared_ptr<NativeBuffer> alloc_buffer(geometry::Size, |
327 | MirPixelFormat, BufferUsage usage); |
328 | |
329 | @@ -44,6 +47,7 @@ |
330 | |
331 | private: |
332 | std::shared_ptr<struct alloc_device_t> alloc_dev; |
333 | + std::shared_ptr<CommandStreamSyncFactory> const sync_factory; |
334 | std::shared_ptr<DeviceQuirks> const quirks; |
335 | int convert_to_android_usage(BufferUsage usage); |
336 | }; |
337 | |
338 | === modified file 'src/platforms/android/server/android_buffer_allocator.cpp' |
339 | --- src/platforms/android/server/android_buffer_allocator.cpp 2015-12-11 12:22:15 +0000 |
340 | +++ src/platforms/android/server/android_buffer_allocator.cpp 2016-01-25 17:04:59 +0000 |
341 | @@ -19,12 +19,14 @@ |
342 | |
343 | #include "mir/graphics/platform.h" |
344 | #include "mir/graphics/egl_extensions.h" |
345 | +#include "mir/graphics/egl_sync_fence.h" |
346 | #include "mir/graphics/buffer_properties.h" |
347 | #include "mir/graphics/android/sync_fence.h" |
348 | #include "mir/graphics/android/android_native_buffer.h" |
349 | #include "android_graphic_buffer_allocator.h" |
350 | #include "android_alloc_adaptor.h" |
351 | #include "buffer.h" |
352 | +#include "cmdstream_sync_factory.h" |
353 | #include "device_quirks.h" |
354 | |
355 | #include <boost/throw_exception.hpp> |
356 | @@ -50,8 +52,11 @@ |
357 | |
358 | } |
359 | |
360 | -mga::AndroidGraphicBufferAllocator::AndroidGraphicBufferAllocator(std::shared_ptr<DeviceQuirks> const& quirks) |
361 | - : egl_extensions(std::make_shared<mg::EGLExtensions>()) |
362 | +mga::AndroidGraphicBufferAllocator::AndroidGraphicBufferAllocator( |
363 | + std::shared_ptr<CommandStreamSyncFactory> const& cmdstream_sync_factory, |
364 | + std::shared_ptr<DeviceQuirks> const& quirks) |
365 | + : egl_extensions(std::make_shared<mg::EGLExtensions>()), |
366 | + cmdstream_sync_factory(cmdstream_sync_factory) |
367 | { |
368 | int err; |
369 | |
370 | @@ -70,7 +75,7 @@ |
371 | std::shared_ptr<struct alloc_device_t> alloc_dev_ptr( |
372 | alloc_dev, |
373 | quirks->gralloc_cannot_be_closed_safely() ? null_alloc_dev_deleter : alloc_dev_deleter); |
374 | - alloc_device = std::shared_ptr<mga::GraphicAllocAdaptor>(new AndroidAllocAdaptor(alloc_dev_ptr, quirks)); |
375 | + alloc_device = std::shared_ptr<mga::GraphicAllocAdaptor>(new AndroidAllocAdaptor(alloc_dev_ptr, cmdstream_sync_factory, quirks)); |
376 | } |
377 | |
378 | std::shared_ptr<mg::Buffer> mga::AndroidGraphicBufferAllocator::alloc_buffer( |
379 | @@ -89,9 +94,10 @@ |
380 | [](ANativeWindowBuffer* buffer){ buffer->common.decRef(&buffer->common); }); |
381 | anwb->common.incRef(&anwb->common); |
382 | |
383 | + //TODO: we should have an android platform function for accessing the fence. |
384 | auto native_handle = std::make_shared<mga::AndroidNativeBuffer>( |
385 | native_window_buffer, |
386 | - //TODO: we should have an android platform function for accessing the fence. |
387 | + cmdstream_sync_factory->create_command_stream_sync(), |
388 | std::make_shared<mga::SyncFence>(std::make_shared<mga::RealSyncFileOps>(), mir::Fd()), |
389 | mga::BufferAccess::read); |
390 | return std::make_unique<Buffer>( |
391 | |
392 | === modified file 'src/platforms/android/server/android_graphic_buffer_allocator.h' |
393 | --- src/platforms/android/server/android_graphic_buffer_allocator.h 2015-12-11 12:22:15 +0000 |
394 | +++ src/platforms/android/server/android_graphic_buffer_allocator.h 2016-01-25 17:04:59 +0000 |
395 | @@ -39,11 +39,14 @@ |
396 | |
397 | class GraphicAllocAdaptor; |
398 | class DeviceQuirks; |
399 | +class CommandStreamSyncFactory; |
400 | |
401 | class AndroidGraphicBufferAllocator: public GraphicBufferAllocator, public graphics::GraphicBufferAllocator |
402 | { |
403 | public: |
404 | - AndroidGraphicBufferAllocator(std::shared_ptr<DeviceQuirks> const& quirks); |
405 | + AndroidGraphicBufferAllocator( |
406 | + std::shared_ptr<CommandStreamSyncFactory> const& cmdstream_sync_factory, |
407 | + std::shared_ptr<DeviceQuirks> const& quirks); |
408 | |
409 | std::shared_ptr<graphics::Buffer> alloc_buffer( |
410 | graphics::BufferProperties const& buffer_properties) override; |
411 | @@ -61,6 +64,7 @@ |
412 | const hw_module_t *hw_module; |
413 | std::shared_ptr<GraphicAllocAdaptor> alloc_device; |
414 | std::shared_ptr<EGLExtensions> const egl_extensions; |
415 | + std::shared_ptr<CommandStreamSyncFactory> const cmdstream_sync_factory; |
416 | }; |
417 | |
418 | } |
419 | |
420 | === modified file 'src/platforms/android/server/buffer.cpp' |
421 | --- src/platforms/android/server/buffer.cpp 2015-12-11 12:22:15 +0000 |
422 | +++ src/platforms/android/server/buffer.cpp 2016-01-25 17:04:59 +0000 |
423 | @@ -74,6 +74,18 @@ |
424 | void mga::Buffer::gl_bind_to_texture() |
425 | { |
426 | std::unique_lock<std::mutex> lk(content_lock); |
427 | + bind(lk); |
428 | + secure_for_render(lk); |
429 | +} |
430 | + |
431 | +void mga::Buffer::bind() |
432 | +{ |
433 | + std::unique_lock<std::mutex> lk(content_lock); |
434 | + bind(lk); |
435 | +} |
436 | + |
437 | +void mga::Buffer::bind(std::unique_lock<std::mutex> const&) |
438 | +{ |
439 | native_buffer->ensure_available_for(mga::BufferAccess::read); |
440 | |
441 | DispContextPair current |
442 | @@ -113,10 +125,6 @@ |
443 | } |
444 | |
445 | egl_extensions->glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, image); |
446 | - |
447 | - //TODO: we should make use of the android egl fence extension here to update the fence. |
448 | - // if the extension is not available, we should pass out a token that the user |
449 | - // will have to keep until the completion of the gl draw |
450 | } |
451 | |
452 | std::shared_ptr<mg::NativeBuffer> mga::Buffer::native_buffer_handle() const |
453 | @@ -196,3 +204,14 @@ |
454 | { |
455 | return this; |
456 | } |
457 | + |
458 | +void mga::Buffer::secure_for_render() |
459 | +{ |
460 | + std::unique_lock<std::mutex> lk(content_lock); |
461 | + secure_for_render(lk); |
462 | +} |
463 | + |
464 | +void mga::Buffer::secure_for_render(std::unique_lock<std::mutex> const&) |
465 | +{ |
466 | + native_buffer->lock_for_gpu(); |
467 | +} |
468 | |
469 | === modified file 'src/platforms/android/server/buffer.h' |
470 | --- src/platforms/android/server/buffer.h 2015-12-11 12:22:15 +0000 |
471 | +++ src/platforms/android/server/buffer.h 2016-01-25 17:04:59 +0000 |
472 | @@ -56,6 +56,10 @@ |
473 | geometry::Stride stride() const override; |
474 | MirPixelFormat pixel_format() const override; |
475 | void gl_bind_to_texture() override; |
476 | + void bind() override; |
477 | + void secure_for_render() override; |
478 | + |
479 | + |
480 | //note, you will get the native representation of an android buffer, including |
481 | //the fences associated with the buffer. You must close these fences |
482 | std::shared_ptr<NativeBuffer> native_buffer_handle() const override; |
483 | @@ -66,6 +70,8 @@ |
484 | NativeBufferBase* native_buffer_base() override; |
485 | |
486 | private: |
487 | + void bind(std::unique_lock<std::mutex> const&); |
488 | + void secure_for_render(std::unique_lock<std::mutex> const&); |
489 | gralloc_module_t const* hw_module; |
490 | |
491 | typedef std::pair<EGLDisplay, EGLContext> DispContextPair; |
492 | |
493 | === added file 'src/platforms/android/server/cmdstream_sync_factory.h' |
494 | --- src/platforms/android/server/cmdstream_sync_factory.h 1970-01-01 00:00:00 +0000 |
495 | +++ src/platforms/android/server/cmdstream_sync_factory.h 2016-01-25 17:04:59 +0000 |
496 | @@ -0,0 +1,48 @@ |
497 | +/* |
498 | + * Copyright © 2015 Canonical Ltd. |
499 | + * |
500 | + * This program is free software: you can redistribute it and/or modify it |
501 | + * under the terms of the GNU Lesser General Public License version 3, |
502 | + * as published by the Free Software Foundation. |
503 | + * |
504 | + * This program is distributed in the hope that it will be useful, |
505 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
506 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
507 | + * GNU Lesser General Public License for more details. |
508 | + * |
509 | + * You should have received a copy of the GNU Lesser General Public License |
510 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
511 | + * |
512 | + * Authored by: Kevin DuBois <kevin.dubois@canonical.com> |
513 | + */ |
514 | + |
515 | +#ifndef MIR_GRAPHICS_ANDROID_CMDSTREAM_SYNC_FACTORY_H_ |
516 | +#define MIR_GRAPHICS_ANDROID_CMDSTREAM_SYNC_FACTORY_H_ |
517 | + |
518 | +#include <memory> |
519 | +namespace mir |
520 | +{ |
521 | +namespace graphics |
522 | +{ |
523 | +class CommandStreamSync; |
524 | +namespace android |
525 | +{ |
526 | +class CommandStreamSyncFactory |
527 | +{ |
528 | +public: |
529 | + virtual ~CommandStreamSyncFactory() = default; |
530 | + virtual std::unique_ptr<CommandStreamSync> create_command_stream_sync() = 0; |
531 | +protected: |
532 | + CommandStreamSyncFactory() = default; |
533 | + CommandStreamSyncFactory(CommandStreamSyncFactory const&) = delete; |
534 | + CommandStreamSyncFactory& operator=(CommandStreamSyncFactory const&) = delete; |
535 | +}; |
536 | + |
537 | +class EGLSyncFactory : public CommandStreamSyncFactory |
538 | +{ |
539 | + std::unique_ptr<CommandStreamSync> create_command_stream_sync() override; |
540 | +}; |
541 | +} |
542 | +} |
543 | +} |
544 | +#endif /* MIR_GRAPHICS_ANDROID_CMDSTREAM_SYNC_FACTORY_H_ */ |
545 | |
546 | === modified file 'src/platforms/android/server/device_quirks.cpp' |
547 | --- src/platforms/android/server/device_quirks.cpp 2015-11-30 18:29:57 +0000 |
548 | +++ src/platforms/android/server/device_quirks.cpp 2016-01-25 17:04:59 +0000 |
549 | @@ -62,7 +62,7 @@ |
550 | |
551 | bool clear_fb_context_fence_for(std::string const& device_name) |
552 | { |
553 | - return device_name == "krillin" || device_name == "mx4" || device_name == "manta"; |
554 | + return device_name == "krillin" || device_name == "mx4" || device_name == "manta" || device_name =="Aquaris_M10_FHD"; |
555 | } |
556 | |
557 | } |
558 | @@ -107,6 +107,12 @@ |
559 | return clear_fb_context_fence_; |
560 | } |
561 | |
562 | +bool mga::DeviceQuirks::working_egl_sync() const |
563 | +{ |
564 | + //FIXME: this really should be all powervr devices. |
565 | + return device_name != "mx4"; |
566 | +} |
567 | + |
568 | void mga::DeviceQuirks::add_options(boost::program_options::options_description& config) |
569 | { |
570 | config.add_options() |
571 | |
572 | === modified file 'src/platforms/android/server/device_quirks.h' |
573 | --- src/platforms/android/server/device_quirks.h 2015-11-30 12:36:04 +0000 |
574 | +++ src/platforms/android/server/device_quirks.h 2016-01-25 17:04:59 +0000 |
575 | @@ -64,6 +64,7 @@ |
576 | bool gralloc_cannot_be_closed_safely() const; |
577 | int aligned_width(int width) const; |
578 | bool clear_fb_context_fence() const; |
579 | + bool working_egl_sync() const; |
580 | |
581 | static void add_options(boost::program_options::options_description& config); |
582 | |
583 | |
584 | === modified file 'src/platforms/android/server/display_buffer.cpp' |
585 | --- src/platforms/android/server/display_buffer.cpp 2015-12-11 12:22:15 +0000 |
586 | +++ src/platforms/android/server/display_buffer.cpp 2016-01-25 17:04:59 +0000 |
587 | @@ -98,6 +98,9 @@ |
588 | void mga::DisplayBuffer::swap_buffers() |
589 | { |
590 | layer_list->update_list({}, offset_from_origin); |
591 | + //HWC 1.0 cannot call eglSwapBuffers() on the display context |
592 | + if (display_device->can_swap_buffers()) |
593 | + gl_context.swap_buffers(); |
594 | } |
595 | |
596 | MirOrientation mga::DisplayBuffer::orientation() const |
597 | |
598 | === modified file 'src/platforms/android/server/display_component_factory.h' |
599 | --- src/platforms/android/server/display_component_factory.h 2015-12-11 12:22:15 +0000 |
600 | +++ src/platforms/android/server/display_component_factory.h 2016-01-25 17:04:59 +0000 |
601 | @@ -19,6 +19,7 @@ |
602 | #ifndef MIR_GRAPHICS_ANDROID_DISPLAY_COMPONENT_FACTORY_H_ |
603 | #define MIR_GRAPHICS_ANDROID_DISPLAY_COMPONENT_FACTORY_H_ |
604 | |
605 | +#include "mir/graphics/egl_sync_fence.h" |
606 | #include "display_device.h" |
607 | #include "framebuffer_bundle.h" |
608 | #include <memory> |
609 | @@ -28,6 +29,7 @@ |
610 | namespace graphics |
611 | { |
612 | class DisplayConfigurationOutput; |
613 | +class CommandStreamSync; |
614 | namespace android |
615 | { |
616 | class HwcConfiguration; |
617 | |
618 | === modified file 'src/platforms/android/server/display_device.h' |
619 | --- src/platforms/android/server/display_device.h 2015-12-11 12:22:15 +0000 |
620 | +++ src/platforms/android/server/display_device.h 2016-01-25 17:04:59 +0000 |
621 | @@ -69,6 +69,8 @@ |
622 | |
623 | virtual std::chrono::milliseconds recommended_sleep() const = 0; |
624 | |
625 | + virtual bool can_swap_buffers() const = 0; |
626 | + |
627 | protected: |
628 | DisplayDevice() = default; |
629 | DisplayDevice& operator=(DisplayDevice const&) = delete; |
630 | |
631 | === added file 'src/platforms/android/server/egl_sync_factory.cpp' |
632 | --- src/platforms/android/server/egl_sync_factory.cpp 1970-01-01 00:00:00 +0000 |
633 | +++ src/platforms/android/server/egl_sync_factory.cpp 2016-01-25 17:04:59 +0000 |
634 | @@ -0,0 +1,34 @@ |
635 | +/* |
636 | + * Copyright © 2015 Canonical Ltd. |
637 | + * |
638 | + * This program is free software: you can redistribute it and/or modify it |
639 | + * under the terms of the GNU Lesser General Public License version 3, |
640 | + * as published by the Free Software Foundation. |
641 | + * |
642 | + * This program is distributed in the hope that it will be useful, |
643 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
644 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
645 | + * GNU Lesser General Public License for more details. |
646 | + * |
647 | + * You should have received a copy of the GNU Lesser General Public License |
648 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
649 | + * |
650 | + * Authored by: Kevin DuBois <kevin.dubois@canonical.com> |
651 | + */ |
652 | + |
653 | +#include "cmdstream_sync_factory.h" |
654 | +#include "mir/graphics/egl_sync_fence.h" |
655 | +namespace mg = mir::graphics; |
656 | +namespace mga = mir::graphics::android; |
657 | + |
658 | +std::unique_ptr<mg::CommandStreamSync> mga::EGLSyncFactory::create_command_stream_sync() |
659 | +{ |
660 | + try |
661 | + { |
662 | + return std::make_unique<EGLSyncFence>(std::make_shared<mg::EGLSyncExtensions>()); |
663 | + } |
664 | + catch (std::runtime_error&) |
665 | + { |
666 | + return std::make_unique<NullCommandSync>(); |
667 | + } |
668 | +} |
669 | |
670 | === modified file 'src/platforms/android/server/fb_device.cpp' |
671 | --- src/platforms/android/server/fb_device.cpp 2015-12-11 12:22:15 +0000 |
672 | +++ src/platforms/android/server/fb_device.cpp 2016-01-25 17:04:59 +0000 |
673 | @@ -99,8 +99,6 @@ |
674 | }); |
675 | if (primary_contents == contents.end()) return; |
676 | auto& context = primary_contents->context; |
677 | - |
678 | - context.swap_buffers(); |
679 | auto const& buffer = context.last_rendered_buffer(); |
680 | auto native_buffer = buffer->native_buffer_handle(); |
681 | native_buffer->ensure_available_for(mga::BufferAccess::read); |
682 | @@ -123,3 +121,8 @@ |
683 | { |
684 | return std::chrono::milliseconds::zero(); |
685 | } |
686 | + |
687 | +bool mga::FBDevice::can_swap_buffers() const |
688 | +{ |
689 | + return true; |
690 | +} |
691 | |
692 | === modified file 'src/platforms/android/server/fb_device.h' |
693 | --- src/platforms/android/server/fb_device.h 2015-12-11 12:22:15 +0000 |
694 | +++ src/platforms/android/server/fb_device.h 2016-01-25 17:04:59 +0000 |
695 | @@ -52,6 +52,7 @@ |
696 | bool compatible_renderlist(RenderableList const& renderlist) override; |
697 | void commit(std::list<DisplayContents> const& contents) override; |
698 | std::chrono::milliseconds recommended_sleep() const override; |
699 | + bool can_swap_buffers() const override; |
700 | |
701 | private: |
702 | std::shared_ptr<framebuffer_device_t> const fb_device; |
703 | |
704 | === modified file 'src/platforms/android/server/hal_component_factory.cpp' |
705 | --- src/platforms/android/server/hal_component_factory.cpp 2015-12-11 12:22:15 +0000 |
706 | +++ src/platforms/android/server/hal_component_factory.cpp 2016-01-25 17:04:59 +0000 |
707 | @@ -46,7 +46,8 @@ |
708 | res_factory(res_factory), |
709 | hwc_report(hwc_report), |
710 | force_backup_display(false), |
711 | - num_framebuffers{quirks->num_framebuffers()} |
712 | + num_framebuffers{quirks->num_framebuffers()}, |
713 | + working_egl_sync(quirks->working_egl_sync()) |
714 | { |
715 | try |
716 | { |
717 | @@ -65,6 +66,24 @@ |
718 | } |
719 | } |
720 | |
721 | +std::unique_ptr<mg::CommandStreamSync> mga::HalComponentFactory::create_command_stream_sync() |
722 | +{ |
723 | + if (hwc_version == mga::HwcVersion::hwc10) |
724 | + return std::make_unique<NullCommandSync>(); |
725 | + |
726 | + if (!working_egl_sync) |
727 | + return std::make_unique<NullCommandSync>(); |
728 | + |
729 | + try |
730 | + { |
731 | + return std::make_unique<EGLSyncFence>(std::make_shared<mg::EGLSyncExtensions>()); |
732 | + } |
733 | + catch (std::runtime_error&) |
734 | + { |
735 | + return std::make_unique<NullCommandSync>(); |
736 | + } |
737 | +} |
738 | + |
739 | std::unique_ptr<mga::FramebufferBundle> mga::HalComponentFactory::create_framebuffers(mg::DisplayConfigurationOutput const& config) |
740 | { |
741 | return std::unique_ptr<mga::FramebufferBundle>(new mga::Framebuffers( |
742 | |
743 | === modified file 'src/platforms/android/server/hal_component_factory.h' |
744 | --- src/platforms/android/server/hal_component_factory.h 2015-12-11 12:22:15 +0000 |
745 | +++ src/platforms/android/server/hal_component_factory.h 2016-01-25 17:04:59 +0000 |
746 | @@ -19,6 +19,7 @@ |
747 | #ifndef MIR_GRAPHICS_ANDROID_HAL_COMPONENT_FACTORY_H_ |
748 | #define MIR_GRAPHICS_ANDROID_HAL_COMPONENT_FACTORY_H_ |
749 | |
750 | +#include "cmdstream_sync_factory.h" |
751 | #include "display_component_factory.h" |
752 | #include "display_resource_factory.h" |
753 | |
754 | @@ -39,7 +40,7 @@ |
755 | |
756 | //NOTE: this should be the only class that inspects the HWC version and assembles |
757 | //the components accordingly |
758 | -class HalComponentFactory : public DisplayComponentFactory |
759 | +class HalComponentFactory : public DisplayComponentFactory, public CommandStreamSyncFactory |
760 | { |
761 | public: |
762 | HalComponentFactory( |
763 | @@ -48,6 +49,7 @@ |
764 | std::shared_ptr<HwcReport> const& hwc_report, |
765 | std::shared_ptr<DeviceQuirks> const& quirks); |
766 | |
767 | + std::unique_ptr<CommandStreamSync> create_command_stream_sync() override; |
768 | std::unique_ptr<FramebufferBundle> create_framebuffers(DisplayConfigurationOutput const&) override; |
769 | std::unique_ptr<DisplayDevice> create_display_device() override; |
770 | std::unique_ptr<HwcConfiguration> create_hwc_configuration() override; |
771 | @@ -61,6 +63,7 @@ |
772 | std::shared_ptr<FramebufferBundle> framebuffers; |
773 | bool force_backup_display; |
774 | size_t num_framebuffers; |
775 | + bool working_egl_sync; |
776 | |
777 | std::shared_ptr<HwcWrapper> hwc_wrapper; |
778 | std::shared_ptr<framebuffer_device_t> fb_native; |
779 | |
780 | === modified file 'src/platforms/android/server/hwc_device.cpp' |
781 | --- src/platforms/android/server/hwc_device.cpp 2015-12-11 12:22:15 +0000 |
782 | +++ src/platforms/android/server/hwc_device.cpp 2016-01-25 17:04:59 +0000 |
783 | @@ -106,13 +106,13 @@ |
784 | if (content.list.needs_swapbuffers()) |
785 | { |
786 | auto rejected_renderables = content.list.rejected_renderables(); |
787 | - auto current_context = mir::raii::paired_calls( |
788 | - [&]{ content.context.make_current(); }, |
789 | - [&]{ content.context.release_current(); }); |
790 | - if (rejected_renderables.empty()) |
791 | - content.context.swap_buffers(); |
792 | - else |
793 | + if (!rejected_renderables.empty()) |
794 | + { |
795 | + auto current_context = mir::raii::paired_calls( |
796 | + [&]{ content.context.make_current(); }, |
797 | + [&]{ content.context.release_current(); }); |
798 | content.compositor.render(std::move(rejected_renderables), content.list_offset, content.context); |
799 | + } |
800 | content.list.setup_fb(content.context.last_rendered_buffer()); |
801 | content.list.swap_occurred(); |
802 | purely_overlays = false; |
803 | @@ -161,3 +161,8 @@ |
804 | { |
805 | onscreen_overlay_buffers.clear(); |
806 | } |
807 | + |
808 | +bool mga::HwcDevice::can_swap_buffers() const |
809 | +{ |
810 | + return true; |
811 | +} |
812 | |
813 | === modified file 'src/platforms/android/server/hwc_device.h' |
814 | --- src/platforms/android/server/hwc_device.h 2015-12-11 12:22:15 +0000 |
815 | +++ src/platforms/android/server/hwc_device.h 2016-01-25 17:04:59 +0000 |
816 | @@ -47,6 +47,7 @@ |
817 | void commit(std::list<DisplayContents> const& contents) override; |
818 | void content_cleared() override; |
819 | std::chrono::milliseconds recommended_sleep() const override; |
820 | + bool can_swap_buffers() const override; |
821 | |
822 | private: |
823 | bool buffer_is_onscreen(Buffer const&) const; |
824 | |
825 | === modified file 'src/platforms/android/server/hwc_fb_device.cpp' |
826 | --- src/platforms/android/server/hwc_fb_device.cpp 2015-12-11 12:22:15 +0000 |
827 | +++ src/platforms/android/server/hwc_fb_device.cpp 2016-01-25 17:04:59 +0000 |
828 | @@ -118,3 +118,8 @@ |
829 | { |
830 | return std::chrono::milliseconds::zero(); |
831 | } |
832 | + |
833 | +bool mga::HwcFbDevice::can_swap_buffers() const |
834 | +{ |
835 | + return false; |
836 | +} |
837 | |
838 | === modified file 'src/platforms/android/server/hwc_fb_device.h' |
839 | --- src/platforms/android/server/hwc_fb_device.h 2015-12-11 12:22:15 +0000 |
840 | +++ src/platforms/android/server/hwc_fb_device.h 2016-01-25 17:04:59 +0000 |
841 | @@ -44,6 +44,7 @@ |
842 | bool compatible_renderlist(RenderableList const& renderlist) override; |
843 | void commit(std::list<DisplayContents> const& contents) override; |
844 | std::chrono::milliseconds recommended_sleep() const override; |
845 | + bool can_swap_buffers() const override; |
846 | |
847 | private: |
848 | void content_cleared() override; |
849 | |
850 | === modified file 'src/platforms/android/server/ipc_operations.cpp' |
851 | --- src/platforms/android/server/ipc_operations.cpp 2015-12-11 12:22:15 +0000 |
852 | +++ src/platforms/android/server/ipc_operations.cpp 2016-01-25 17:04:59 +0000 |
853 | @@ -32,6 +32,7 @@ |
854 | { |
855 | auto native_buffer = buffer.native_buffer_handle(); |
856 | |
857 | + native_buffer->wait_for_unlock_by_gpu(); |
858 | mir::Fd fence_fd(native_buffer->copy_fence()); |
859 | if (fence_fd != mir::Fd::invalid) |
860 | { |
861 | |
862 | === modified file 'src/platforms/android/server/platform.cpp' |
863 | --- src/platforms/android/server/platform.cpp 2015-12-11 12:22:15 +0000 |
864 | +++ src/platforms/android/server/platform.cpp 2016-01-25 17:04:59 +0000 |
865 | @@ -85,11 +85,13 @@ |
866 | mga::Platform::Platform( |
867 | std::shared_ptr<graphics::GraphicBufferAllocator> const& buffer_allocator, |
868 | std::shared_ptr<mga::DisplayComponentFactory> const& display_buffer_builder, |
869 | + std::shared_ptr<CommandStreamSyncFactory> const& sync_factory, |
870 | std::shared_ptr<mg::DisplayReport> const& display_report, |
871 | mga::OverlayOptimization overlay_option, |
872 | std::shared_ptr<mga::DeviceQuirks> const& quirks) : |
873 | buffer_allocator(buffer_allocator), |
874 | display_buffer_builder(display_buffer_builder), |
875 | + sync_factory(sync_factory), |
876 | display_report(display_report), |
877 | quirks(quirks), |
878 | overlay_option(overlay_option) |
879 | @@ -153,10 +155,13 @@ |
880 | auto overlay_option = should_use_overlay_optimization(*options); |
881 | hwc_report->report_overlay_optimization(overlay_option); |
882 | auto display_resource_factory = std::make_shared<mga::ResourceFactory>(); |
883 | - auto buffer_allocator = std::make_shared<mga::AndroidGraphicBufferAllocator>(quirks); |
884 | + auto sync_factory = std::make_shared<mga::EGLSyncFactory>(); |
885 | + auto buffer_allocator = std::make_shared<mga::AndroidGraphicBufferAllocator>(sync_factory, quirks); |
886 | auto component_factory = std::make_shared<mga::HalComponentFactory>( |
887 | buffer_allocator, display_resource_factory, hwc_report, quirks); |
888 | - return mir::make_module_ptr<mga::Platform>(buffer_allocator, component_factory, display_report, overlay_option, quirks); |
889 | + |
890 | + return mir::make_module_ptr<mga::Platform>( |
891 | + buffer_allocator, component_factory, component_factory, display_report, overlay_option, quirks); |
892 | } |
893 | |
894 | mir::UniqueModulePtr<mg::Platform> create_guest_platform( |
895 | @@ -166,10 +171,11 @@ |
896 | mir::assert_entry_point_signature<mg::CreateGuestPlatform>(&create_guest_platform); |
897 | //TODO: actually allow disabling quirks for guest platform |
898 | auto quirks = std::make_shared<mga::DeviceQuirks>(mga::PropertiesOps{}); |
899 | + auto sync_factory = std::make_shared<mga::EGLSyncFactory>(); |
900 | //TODO: remove nullptr parameter once platform classes are sorted. |
901 | // mg::NativePlatform cannot create a display anyways, so it doesnt need a display builder |
902 | - auto const buffer_allocator = std::make_shared<mga::AndroidGraphicBufferAllocator>(quirks); |
903 | - return mir::make_module_ptr<mga::Platform>(buffer_allocator, nullptr, display_report, mga::OverlayOptimization::disabled, quirks); |
904 | + auto const buffer_allocator = std::make_shared<mga::AndroidGraphicBufferAllocator>(sync_factory, quirks); |
905 | + return mir::make_module_ptr<mga::Platform>(buffer_allocator, nullptr, sync_factory, display_report, mga::OverlayOptimization::disabled, quirks); |
906 | } |
907 | |
908 | void add_graphics_platform_options( |
909 | |
910 | === modified file 'src/platforms/android/server/platform.h' |
911 | --- src/platforms/android/server/platform.h 2015-12-11 12:22:15 +0000 |
912 | +++ src/platforms/android/server/platform.h 2016-01-25 17:04:59 +0000 |
913 | @@ -33,6 +33,7 @@ |
914 | class GraphicBufferAllocator; |
915 | class FramebufferFactory; |
916 | class DisplayComponentFactory; |
917 | +class CommandStreamSyncFactory; |
918 | |
919 | class Platform : public graphics::Platform |
920 | { |
921 | @@ -40,6 +41,7 @@ |
922 | Platform( |
923 | std::shared_ptr<graphics::GraphicBufferAllocator> const& buffer_allocator, |
924 | std::shared_ptr<DisplayComponentFactory> const& display_buffer_builder, |
925 | + std::shared_ptr<CommandStreamSyncFactory> const& sync_factory, |
926 | std::shared_ptr<DisplayReport> const& display_report, |
927 | OverlayOptimization overlay_option, |
928 | std::shared_ptr<DeviceQuirks> const& quirks); |
929 | @@ -55,6 +57,7 @@ |
930 | private: |
931 | std::shared_ptr<graphics::GraphicBufferAllocator> const buffer_allocator; |
932 | std::shared_ptr<DisplayComponentFactory> const display_buffer_builder; |
933 | + std::shared_ptr<CommandStreamSyncFactory> const sync_factory; |
934 | std::shared_ptr<DisplayReport> const display_report; |
935 | std::shared_ptr<PlatformIpcOperations> const ipc_operations; |
936 | std::shared_ptr<DeviceQuirks> const quirks; |
937 | |
938 | === modified file 'src/platforms/mesa/server/common/gbm_buffer.cpp' |
939 | --- src/platforms/mesa/server/common/gbm_buffer.cpp 2015-12-11 12:22:15 +0000 |
940 | +++ src/platforms/mesa/server/common/gbm_buffer.cpp 2016-01-25 17:04:59 +0000 |
941 | @@ -197,3 +197,12 @@ |
942 | { |
943 | return this; |
944 | } |
945 | + |
946 | +void mgm::GBMBuffer::secure_for_render() |
947 | +{ |
948 | +} |
949 | + |
950 | +void mgm::GBMBuffer::bind() |
951 | +{ |
952 | + gl_bind_to_texture(); |
953 | +} |
954 | |
955 | === modified file 'src/platforms/mesa/server/common/gbm_buffer.h' |
956 | --- src/platforms/mesa/server/common/gbm_buffer.h 2015-12-11 12:22:15 +0000 |
957 | +++ src/platforms/mesa/server/common/gbm_buffer.h 2016-01-25 17:04:59 +0000 |
958 | @@ -67,6 +67,8 @@ |
959 | virtual std::shared_ptr<MirNativeBuffer> native_buffer_handle() const override; |
960 | |
961 | virtual void gl_bind_to_texture() override; |
962 | + virtual void bind() override; |
963 | + virtual void secure_for_render() override; |
964 | |
965 | void write(unsigned char const* pixels, size_t size) override; |
966 | void read(std::function<void(unsigned char const*)> const& do_with_pixels) override; |
967 | |
968 | === modified file 'src/platforms/mesa/server/common/shm_buffer.cpp' |
969 | --- src/platforms/mesa/server/common/shm_buffer.cpp 2015-12-11 12:22:15 +0000 |
970 | +++ src/platforms/mesa/server/common/shm_buffer.cpp 2016-01-25 17:04:59 +0000 |
971 | @@ -176,3 +176,12 @@ |
972 | { |
973 | return this; |
974 | } |
975 | + |
976 | +void mgm::ShmBuffer::bind() |
977 | +{ |
978 | + gl_bind_to_texture(); |
979 | +} |
980 | + |
981 | +void mgm::ShmBuffer::secure_for_render() |
982 | +{ |
983 | +} |
984 | |
985 | === modified file 'src/platforms/mesa/server/common/shm_buffer.h' |
986 | --- src/platforms/mesa/server/common/shm_buffer.h 2015-12-11 12:22:15 +0000 |
987 | +++ src/platforms/mesa/server/common/shm_buffer.h 2016-01-25 17:04:59 +0000 |
988 | @@ -51,6 +51,8 @@ |
989 | MirPixelFormat pixel_format() const override; |
990 | std::shared_ptr<MirNativeBuffer> native_buffer_handle() const override; |
991 | void gl_bind_to_texture() override; |
992 | + void bind() override; |
993 | + void secure_for_render() override; |
994 | void write(unsigned char const* data, size_t size) override; |
995 | void read(std::function<void(unsigned char const*)> const& do_with_pixels) override; |
996 | NativeBufferBase* native_buffer_base() override; |
997 | |
998 | === modified file 'tests/include/mir/test/doubles/mock_android_native_buffer.h' |
999 | --- tests/include/mir/test/doubles/mock_android_native_buffer.h 2015-12-11 12:22:15 +0000 |
1000 | +++ tests/include/mir/test/doubles/mock_android_native_buffer.h 2016-01-25 17:04:59 +0000 |
1001 | @@ -57,6 +57,8 @@ |
1002 | MOCK_METHOD1(ensure_available_for, void(graphics::android::BufferAccess)); |
1003 | MOCK_METHOD2(update_usage, void(graphics::android::NativeFence&, graphics::android::BufferAccess)); |
1004 | |
1005 | + MOCK_METHOD0(lock_for_gpu, void()); |
1006 | + MOCK_METHOD0(wait_for_unlock_by_gpu, void()); |
1007 | ANativeWindowBuffer stub_anwb; |
1008 | native_handle_t native_handle; |
1009 | }; |
1010 | |
1011 | === modified file 'tests/include/mir/test/doubles/mock_buffer.h' |
1012 | --- tests/include/mir/test/doubles/mock_buffer.h 2015-12-11 12:22:15 +0000 |
1013 | +++ tests/include/mir/test/doubles/mock_buffer.h 2016-01-25 17:04:59 +0000 |
1014 | @@ -72,6 +72,7 @@ |
1015 | MOCK_METHOD2(write, void(unsigned char const*, size_t)); |
1016 | MOCK_METHOD1(read, void(std::function<void(unsigned char const*)> const&)); |
1017 | MOCK_METHOD0(native_buffer_base, graphics::NativeBufferBase*()); |
1018 | + MOCK_METHOD0(used_as_texture, void()); |
1019 | }; |
1020 | |
1021 | } |
1022 | |
1023 | === modified file 'tests/include/mir/test/doubles/mock_display_device.h' |
1024 | --- tests/include/mir/test/doubles/mock_display_device.h 2015-12-11 12:22:15 +0000 |
1025 | +++ tests/include/mir/test/doubles/mock_display_device.h 2016-01-25 17:04:59 +0000 |
1026 | @@ -39,6 +39,8 @@ |
1027 | { |
1028 | ON_CALL(*this, compatible_renderlist(testing::_)) |
1029 | .WillByDefault(testing::Return(true)); |
1030 | + ON_CALL(*this, can_swap_buffers()) |
1031 | + .WillByDefault(testing::Return(true)); |
1032 | } |
1033 | ~MockDisplayDevice() noexcept {} |
1034 | MOCK_METHOD0(content_cleared, void()); |
1035 | @@ -46,6 +48,7 @@ |
1036 | MOCK_METHOD1(compatible_renderlist, bool( |
1037 | graphics::RenderableList const&)); |
1038 | MOCK_CONST_METHOD0(recommended_sleep, std::chrono::milliseconds()); |
1039 | + MOCK_CONST_METHOD0(can_swap_buffers, bool()); |
1040 | }; |
1041 | } |
1042 | } |
1043 | |
1044 | === modified file 'tests/include/mir/test/doubles/mock_gl_buffer.h' |
1045 | --- tests/include/mir/test/doubles/mock_gl_buffer.h 2015-12-11 12:22:15 +0000 |
1046 | +++ tests/include/mir/test/doubles/mock_gl_buffer.h 2016-01-25 17:04:59 +0000 |
1047 | @@ -36,6 +36,8 @@ |
1048 | using MockBuffer::MockBuffer; |
1049 | |
1050 | MOCK_METHOD0(gl_bind_to_texture, void()); |
1051 | + MOCK_METHOD0(secure_for_render, void()); |
1052 | + MOCK_METHOD0(bind, void()); |
1053 | }; |
1054 | |
1055 | } |
1056 | |
1057 | === modified file 'tests/include/mir/test/doubles/stub_android_native_buffer.h' |
1058 | --- tests/include/mir/test/doubles/stub_android_native_buffer.h 2015-12-11 12:22:15 +0000 |
1059 | +++ tests/include/mir/test/doubles/stub_android_native_buffer.h 2016-01-25 17:04:59 +0000 |
1060 | @@ -47,6 +47,9 @@ |
1061 | void ensure_available_for(graphics::android::BufferAccess) {} |
1062 | void update_usage(graphics::android::NativeFence&, graphics::android::BufferAccess) {} |
1063 | |
1064 | + void lock_for_gpu() {}; |
1065 | + void wait_for_unlock_by_gpu() {}; |
1066 | + |
1067 | ANativeWindowBuffer stub_anwb; |
1068 | native_handle_t native_handle; |
1069 | }; |
1070 | |
1071 | === added file 'tests/include/mir/test/doubles/stub_cmdstream_sync_factory.h' |
1072 | --- tests/include/mir/test/doubles/stub_cmdstream_sync_factory.h 1970-01-01 00:00:00 +0000 |
1073 | +++ tests/include/mir/test/doubles/stub_cmdstream_sync_factory.h 2016-01-25 17:04:59 +0000 |
1074 | @@ -0,0 +1,41 @@ |
1075 | +/* |
1076 | + * Copyright © 2015 Canonical Ltd. |
1077 | + * |
1078 | + * This program is free software: you can redistribute it and/or modify it |
1079 | + * under the terms of the GNU General Public License version 3, |
1080 | + * as published by the Free Software Foundation. |
1081 | + * |
1082 | + * This program is distributed in the hope that it will be useful, |
1083 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1084 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1085 | + * GNU General Public License for more details. |
1086 | + * |
1087 | + * You should have received a copy of the GNU General Public License |
1088 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1089 | + * |
1090 | + * Authored by: Kevin DuBois <kevin.dubois@canonical.com> |
1091 | + */ |
1092 | + |
1093 | +#ifndef MIR_TEST_DOUBLES_STUB_CMDSTREAM_SYNC_FACTORY_H_ |
1094 | +#define MIR_TEST_DOUBLES_STUB_CMDSTREAM_SYNC_FACTORY_H_ |
1095 | + |
1096 | +#include "src/platforms/android/server/cmdstream_sync_factory.h" |
1097 | + |
1098 | +namespace mir |
1099 | +{ |
1100 | +namespace test |
1101 | +{ |
1102 | +namespace doubles |
1103 | +{ |
1104 | +struct StubCmdStreamSyncFactory : graphics::android::CommandStreamSyncFactory |
1105 | +{ |
1106 | + std::unique_ptr<graphics::CommandStreamSync> create_command_stream_sync() override |
1107 | + { |
1108 | + return std::make_unique<graphics::NullCommandSync>(); |
1109 | + } |
1110 | +}; |
1111 | +} |
1112 | +} |
1113 | +} |
1114 | + |
1115 | +#endif /* MIR_TEST_DOUBLES_STUB_CMDSTREAM_SYNC_FACTORY_H_ */ |
1116 | |
1117 | === modified file 'tests/include/mir/test/doubles/stub_display_builder.h' |
1118 | --- tests/include/mir/test/doubles/stub_display_builder.h 2015-12-11 12:22:15 +0000 |
1119 | +++ tests/include/mir/test/doubles/stub_display_builder.h 2016-01-25 17:04:59 +0000 |
1120 | @@ -126,6 +126,11 @@ |
1121 | config = std::move(mock_config); |
1122 | } |
1123 | |
1124 | + std::unique_ptr<graphics::CommandStreamSync> create_command_stream_sync() |
1125 | + { |
1126 | + return std::make_unique<graphics::NullCommandSync>(); |
1127 | + } |
1128 | + |
1129 | geometry::Size sz; |
1130 | std::unique_ptr<graphics::android::HwcConfiguration> config; |
1131 | }; |
1132 | |
1133 | === modified file 'tests/include/mir/test/doubles/stub_gl_buffer.h' |
1134 | --- tests/include/mir/test/doubles/stub_gl_buffer.h 2015-12-11 12:22:15 +0000 |
1135 | +++ tests/include/mir/test/doubles/stub_gl_buffer.h 2016-01-25 17:04:59 +0000 |
1136 | @@ -36,6 +36,8 @@ |
1137 | using StubBuffer::StubBuffer; |
1138 | |
1139 | void gl_bind_to_texture() {} |
1140 | + void bind() {} |
1141 | + void secure_for_render() {} |
1142 | }; |
1143 | |
1144 | } |
1145 | |
1146 | === modified file 'tests/integration-tests/graphics/mesa/test_buffer_integration.cpp' |
1147 | --- tests/integration-tests/graphics/mesa/test_buffer_integration.cpp 2015-12-11 12:22:15 +0000 |
1148 | +++ tests/integration-tests/graphics/mesa/test_buffer_integration.cpp 2016-01-25 17:04:59 +0000 |
1149 | @@ -77,6 +77,9 @@ |
1150 | } |
1151 | } |
1152 | |
1153 | + void bind() override { gl_bind_to_texture(); } |
1154 | + void secure_for_render() override {} |
1155 | + |
1156 | private: |
1157 | std::thread::id creation_thread_id; |
1158 | }; |
1159 | |
1160 | === modified file 'tests/unit-tests/gl/test_gl_texture_cache.cpp' |
1161 | --- tests/unit-tests/gl/test_gl_texture_cache.cpp 2015-12-11 12:22:15 +0000 |
1162 | +++ tests/unit-tests/gl/test_gl_texture_cache.cpp 2016-01-25 17:04:59 +0000 |
1163 | @@ -17,7 +17,7 @@ |
1164 | * Originally by: Daniel van Vugt <daniel.van.vugt@canonical.com> |
1165 | */ |
1166 | |
1167 | -#include "mir/gl/recently_used_cache.h" |
1168 | +#include "src/gl/recently_used_cache.h" |
1169 | #include "mir/test/doubles/mock_gl_buffer.h" |
1170 | #include "mir/test/doubles/mock_renderable.h" |
1171 | #include "mir/test/doubles/mock_gl.h" |
1172 | @@ -75,6 +75,7 @@ |
1173 | EXPECT_CALL(mock_gl, glBindTexture(GL_TEXTURE_2D, stub_texture)); |
1174 | EXPECT_CALL(*mock_buffer,gl_bind_to_texture()) |
1175 | .Times(0); |
1176 | + EXPECT_CALL(*mock_buffer, used_as_texture()); |
1177 | |
1178 | // Frame 3: Texture found in cache but refreshed with new buffer |
1179 | EXPECT_CALL(*mock_buffer, id()) |
1180 | @@ -92,6 +93,7 @@ |
1181 | EXPECT_CALL(*mock_buffer, id()) |
1182 | .WillOnce(Return(mg::BufferID(456))); |
1183 | EXPECT_CALL(mock_gl, glBindTexture(GL_TEXTURE_2D, stub_texture)); |
1184 | + EXPECT_CALL(*mock_buffer, used_as_texture()); |
1185 | |
1186 | EXPECT_CALL(mock_gl, glDeleteTextures(1, Pointee(stub_texture))); |
1187 | |
1188 | |
1189 | === modified file 'tests/unit-tests/gl/test_program_factory.cpp' |
1190 | --- tests/unit-tests/gl/test_program_factory.cpp 2015-12-11 12:22:15 +0000 |
1191 | +++ tests/unit-tests/gl/test_program_factory.cpp 2016-01-25 17:04:59 +0000 |
1192 | @@ -24,7 +24,7 @@ |
1193 | #include <gtest/gtest.h> |
1194 | #include <gmock/gmock.h> |
1195 | #include <mir/geometry/rectangle.h> |
1196 | -#include "src/gl/default_program_factory.h" |
1197 | +#include "mir/gl/default_program_factory.h" |
1198 | #include <mir/test/fake_shared.h> |
1199 | #include <mir/test/doubles/mock_buffer.h> |
1200 | #include <mir/test/doubles/mock_renderable.h> |
1201 | |
1202 | === modified file 'tests/unit-tests/graphics/android/test_android_alloc_adaptor.cpp' |
1203 | --- tests/unit-tests/graphics/android/test_android_alloc_adaptor.cpp 2015-12-11 12:22:15 +0000 |
1204 | +++ tests/unit-tests/graphics/android/test_android_alloc_adaptor.cpp 2016-01-25 17:04:59 +0000 |
1205 | @@ -17,11 +17,13 @@ |
1206 | */ |
1207 | |
1208 | #include "src/platforms/android/server/android_alloc_adaptor.h" |
1209 | +#include "src/platforms/android/server/cmdstream_sync_factory.h" |
1210 | #include "src/platforms/android/server/device_quirks.h" |
1211 | #include "mir/graphics/android/native_buffer.h" |
1212 | |
1213 | #include "mir/test/doubles/mock_android_alloc_device.h" |
1214 | #include "mir/test/doubles/mock_alloc_adaptor.h" |
1215 | +#include "mir/test/doubles/mock_egl.h" |
1216 | |
1217 | #include <gtest/gtest.h> |
1218 | #include <gmock/gmock.h> |
1219 | @@ -32,7 +34,6 @@ |
1220 | namespace geom = mir::geometry; |
1221 | namespace mtd = mir::test::doubles; |
1222 | |
1223 | - |
1224 | class AdaptorICSTest : public ::testing::Test |
1225 | { |
1226 | public: |
1227 | @@ -48,13 +49,15 @@ |
1228 | mock_alloc_device = std::make_shared<NiceMock<mtd::MockAllocDevice>>(); |
1229 | |
1230 | auto quirks = std::make_shared<mga::DeviceQuirks>(mga::PropertiesOps{}); |
1231 | - alloc_adaptor = std::make_shared<mga::AndroidAllocAdaptor>(mock_alloc_device, quirks); |
1232 | + alloc_adaptor = std::make_shared<mga::AndroidAllocAdaptor>(mock_alloc_device, sync_factory, quirks); |
1233 | |
1234 | pf = mir_pixel_format_abgr_8888; |
1235 | size = geom::Size{300, 200}; |
1236 | usage = mga::BufferUsage::use_hardware; |
1237 | } |
1238 | |
1239 | + mtd::MockEGL mock_egl; |
1240 | + std::shared_ptr<mga::CommandStreamSyncFactory> sync_factory{std::make_shared<mga::EGLSyncFactory>()}; |
1241 | std::shared_ptr<mtd::MockAllocDevice> mock_alloc_device; |
1242 | std::shared_ptr<mga::AndroidAllocAdaptor> alloc_adaptor; |
1243 | |
1244 | |
1245 | === modified file 'tests/unit-tests/graphics/android/test_android_buffer_allocator.cpp' |
1246 | --- tests/unit-tests/graphics/android/test_android_buffer_allocator.cpp 2015-12-11 12:22:15 +0000 |
1247 | +++ tests/unit-tests/graphics/android/test_android_buffer_allocator.cpp 2016-01-25 17:04:59 +0000 |
1248 | @@ -23,6 +23,8 @@ |
1249 | #include "mir/graphics/buffer.h" |
1250 | #include "mir/graphics/android/native_buffer.h" |
1251 | |
1252 | +#include "mir/test/doubles/stub_display_builder.h" |
1253 | +#include "mir/test/doubles/stub_cmdstream_sync_factory.h" |
1254 | #include "mir/test/doubles/mock_egl.h" |
1255 | |
1256 | #include <hardware/gralloc.h> |
1257 | @@ -43,7 +45,9 @@ |
1258 | |
1259 | testing::NiceMock<mtd::HardwareAccessMock> hw_access_mock; |
1260 | testing::NiceMock<mtd::MockEGL> mock_egl; |
1261 | - mga::AndroidGraphicBufferAllocator allocator{std::make_shared<mga::DeviceQuirks>(mga::PropertiesOps{})}; |
1262 | + mga::AndroidGraphicBufferAllocator allocator{ |
1263 | + std::make_shared<mtd::StubCmdStreamSyncFactory>(), |
1264 | + std::make_shared<mga::DeviceQuirks>(mga::PropertiesOps{})}; |
1265 | }; |
1266 | |
1267 | TEST_F(AndroidGraphicBufferAllocatorTest, allocator_accesses_gralloc_module) |
1268 | @@ -54,7 +58,7 @@ |
1269 | .Times(1); |
1270 | |
1271 | auto quirks = std::make_shared<mga::DeviceQuirks>(mga::PropertiesOps{}); |
1272 | - mga::AndroidGraphicBufferAllocator allocator{quirks}; |
1273 | + mga::AndroidGraphicBufferAllocator allocator{std::make_shared<mtd::StubCmdStreamSyncFactory>(), quirks}; |
1274 | } |
1275 | |
1276 | TEST_F(AndroidGraphicBufferAllocatorTest, supported_pixel_formats_contain_common_formats) |
1277 | |
1278 | === modified file 'tests/unit-tests/graphics/android/test_buffer_tex_bind.cpp' |
1279 | --- tests/unit-tests/graphics/android/test_buffer_tex_bind.cpp 2015-12-11 12:22:15 +0000 |
1280 | +++ tests/unit-tests/graphics/android/test_buffer_tex_bind.cpp 2016-01-25 17:04:59 +0000 |
1281 | @@ -289,7 +289,7 @@ |
1282 | |
1283 | |
1284 | /* binding tests */ |
1285 | -TEST_F(AndroidBufferBinding, buffer_calls_binding_extension) |
1286 | +TEST_F(AndroidBufferBinding, buffer_calls_binding_extension_and_notes_gpu_usage) |
1287 | { |
1288 | using namespace testing; |
1289 | EXPECT_CALL(mock_egl, glEGLImageTargetTexture2DOES(_, _)) |
1290 | @@ -298,11 +298,23 @@ |
1291 | buffer.gl_bind_to_texture(); |
1292 | } |
1293 | |
1294 | +TEST_F(AndroidBufferBinding, notes_gpu_usage_when_explicity_told) |
1295 | +{ |
1296 | + using namespace testing; |
1297 | + EXPECT_CALL(mock_egl, glEGLImageTargetTexture2DOES(_, _)) |
1298 | + .Times(0); |
1299 | + EXPECT_CALL(*mock_native_buffer, lock_for_gpu()); |
1300 | + mga::Buffer buffer(gralloc, mock_native_buffer, extensions); |
1301 | + buffer.secure_for_render(); |
1302 | +} |
1303 | + |
1304 | TEST_F(AndroidBufferBinding, buffer_calls_binding_extension_every_time) |
1305 | { |
1306 | using namespace testing; |
1307 | EXPECT_CALL(mock_egl, glEGLImageTargetTexture2DOES(_, _)) |
1308 | .Times(Exactly(3)); |
1309 | + EXPECT_CALL(*mock_native_buffer, lock_for_gpu()) |
1310 | + .Times(Exactly(3)); |
1311 | |
1312 | mga::Buffer buffer(gralloc, mock_native_buffer, extensions); |
1313 | buffer.gl_bind_to_texture(); |
1314 | |
1315 | === modified file 'tests/unit-tests/graphics/android/test_display_buffer.cpp' |
1316 | --- tests/unit-tests/graphics/android/test_display_buffer.cpp 2015-12-11 12:22:15 +0000 |
1317 | +++ tests/unit-tests/graphics/android/test_display_buffer.cpp 2016-01-25 17:04:59 +0000 |
1318 | @@ -235,6 +235,21 @@ |
1319 | db.release_current(); |
1320 | } |
1321 | |
1322 | +//In HWC 1.0 notably we cannot eglSwapBuffers on the fb context. |
1323 | +TEST_F(DisplayBuffer, swaps_when_allowed) |
1324 | +{ |
1325 | + using namespace testing; |
1326 | + EXPECT_CALL(*mock_display_device, can_swap_buffers()) |
1327 | + .Times(2) |
1328 | + .WillOnce(Return(true)) |
1329 | + .WillOnce(Return(false)); |
1330 | + EXPECT_CALL(mock_egl, eglSwapBuffers(dummy_display, mock_egl.fake_egl_surface)) |
1331 | + .Times(1); |
1332 | + |
1333 | + db.swap_buffers(); |
1334 | + db.swap_buffers(); |
1335 | +} |
1336 | + |
1337 | TEST_F(DisplayBuffer, notifies_list_that_content_is_cleared) |
1338 | { |
1339 | EXPECT_CALL(*mock_display_device, content_cleared()) |
1340 | |
1341 | === modified file 'tests/unit-tests/graphics/android/test_display_hotplug.cpp' |
1342 | --- tests/unit-tests/graphics/android/test_display_hotplug.cpp 2015-12-11 12:22:15 +0000 |
1343 | +++ tests/unit-tests/graphics/android/test_display_hotplug.cpp 2016-01-25 17:04:59 +0000 |
1344 | @@ -103,6 +103,11 @@ |
1345 | new mga::LayerList(std::make_shared<mga::IntegerSourceCrop>(), {}, geom::Displacement{})); |
1346 | } |
1347 | |
1348 | + std::unique_ptr<mg::CommandStreamSync> create_command_stream_sync() |
1349 | + { |
1350 | + return nullptr; |
1351 | + } |
1352 | + |
1353 | StubHwcConfig stub_config; |
1354 | }; |
1355 | |
1356 | |
1357 | === modified file 'tests/unit-tests/graphics/android/test_fb_device.cpp' |
1358 | --- tests/unit-tests/graphics/android/test_fb_device.cpp 2015-12-11 12:22:15 +0000 |
1359 | +++ tests/unit-tests/graphics/android/test_fb_device.cpp 2016-01-25 17:04:59 +0000 |
1360 | @@ -72,6 +72,12 @@ |
1361 | mga::DisplayName primary{mga::DisplayName::primary}; |
1362 | }; |
1363 | |
1364 | +TEST_F(FBDevice, reports_it_can_swap) |
1365 | +{ |
1366 | + mga::FBDevice fbdev(fb_hal_mock); |
1367 | + EXPECT_TRUE(fbdev.can_swap_buffers()); |
1368 | +} |
1369 | + |
1370 | TEST_F(FBDevice, rejects_renderables) |
1371 | { |
1372 | mg::RenderableList renderlist |
1373 | @@ -92,6 +98,8 @@ |
1374 | .WillOnce(Return(-1)) |
1375 | .WillOnce(Return(0)); |
1376 | |
1377 | + EXPECT_CALL(mock_context, swap_buffers()) |
1378 | + .Times(0); |
1379 | mga::FBDevice fbdev(fb_hal_mock); |
1380 | mga::DisplayContents content{primary, list, geom::Displacement{}, mock_context, stub_compositor}; |
1381 | |
1382 | |
1383 | === modified file 'tests/unit-tests/graphics/android/test_hwc_device.cpp' |
1384 | --- tests/unit-tests/graphics/android/test_hwc_device.cpp 2015-12-11 12:22:15 +0000 |
1385 | +++ tests/unit-tests/graphics/android/test_hwc_device.cpp 2016-01-25 17:04:59 +0000 |
1386 | @@ -120,6 +120,12 @@ |
1387 | }; |
1388 | } |
1389 | |
1390 | +TEST_F(HwcDevice, reports_it_can_swap) |
1391 | +{ |
1392 | + mga::HwcDevice device(mock_device); |
1393 | + EXPECT_TRUE(device.can_swap_buffers()); |
1394 | +} |
1395 | + |
1396 | TEST_F(HwcDevice, prepares_a_skip_and_target_layer_by_default) |
1397 | { |
1398 | using namespace testing; |
1399 | @@ -174,7 +180,7 @@ |
1400 | device.commit({content}); |
1401 | } |
1402 | |
1403 | -TEST_F(HwcDevice, swaps_buffers_directly_when_no_renderables) |
1404 | +TEST_F(HwcDevice, does_not_swap_buffers_when_no_renderables) |
1405 | { |
1406 | using namespace testing; |
1407 | mtd::MockRenderableListCompositor mock_compositor; |
1408 | @@ -184,7 +190,8 @@ |
1409 | |
1410 | EXPECT_CALL(mock_compositor, render(_,_,_)) |
1411 | .Times(0); |
1412 | - EXPECT_CALL(mock_context, swap_buffers()); |
1413 | + EXPECT_CALL(mock_context, swap_buffers()) |
1414 | + .Times(0); |
1415 | |
1416 | mga::LayerList list(layer_adapter, {}, geom::Displacement{}); |
1417 | mga::DisplayContents content{primary, list, offset, mock_context, mock_compositor}; |
1418 | @@ -465,8 +472,6 @@ |
1419 | NiceMock<mtd::MockSwappingGLContext> mock_context; |
1420 | ON_CALL(mock_context, last_rendered_buffer()) |
1421 | .WillByDefault(Return(stub_fb_buffer)); |
1422 | - EXPECT_CALL(mock_context, swap_buffers()) |
1423 | - .Times(AtLeast(5)); |
1424 | |
1425 | mga::LayerList list(layer_adapter, {}, geom::Displacement{}); |
1426 | mtd::MockRenderableListCompositor mock_compositor; |
1427 | @@ -844,10 +849,6 @@ |
1428 | |
1429 | InSequence seq; |
1430 | EXPECT_CALL(*mock_device, prepare(MatchesLists(expected_list, expected_list))); |
1431 | - EXPECT_CALL(mock_context1, make_current()); |
1432 | - EXPECT_CALL(mock_context1, release_current()); |
1433 | - EXPECT_CALL(mock_context2, make_current()); |
1434 | - EXPECT_CALL(mock_context2, release_current()); |
1435 | EXPECT_CALL(*mock_device, set(MatchesLists(expected_list, expected_list))); |
1436 | |
1437 | mga::LayerList primary_list(layer_adapter, {}, geom::Displacement{}); |
1438 | |
1439 | === modified file 'tests/unit-tests/graphics/android/test_hwc_fb_device.cpp' |
1440 | --- tests/unit-tests/graphics/android/test_hwc_fb_device.cpp 2015-12-11 12:22:15 +0000 |
1441 | +++ tests/unit-tests/graphics/android/test_hwc_fb_device.cpp 2016-01-25 17:04:59 +0000 |
1442 | @@ -104,6 +104,12 @@ |
1443 | }; |
1444 | } |
1445 | |
1446 | +TEST_F(HwcFbDevice, reports_it_cannot_swap) |
1447 | +{ |
1448 | + mga::HwcFbDevice device(mock_hwc_device_wrapper, mock_fb_device); |
1449 | + EXPECT_FALSE(device.can_swap_buffers()); |
1450 | +} |
1451 | + |
1452 | TEST_F(HwcFbDevice, hwc10_subscribes_to_vsync_events) |
1453 | { |
1454 | using namespace testing; |
1455 | |
1456 | === modified file 'tests/unit-tests/graphics/android/test_native_buffer.cpp' |
1457 | --- tests/unit-tests/graphics/android/test_native_buffer.cpp 2015-12-11 12:22:15 +0000 |
1458 | +++ tests/unit-tests/graphics/android/test_native_buffer.cpp 2016-01-25 17:04:59 +0000 |
1459 | @@ -17,25 +17,41 @@ |
1460 | */ |
1461 | |
1462 | #include "mir/graphics/android/android_native_buffer.h" |
1463 | +#include "mir/graphics/egl_sync_fence.h" |
1464 | #include "mir/test/doubles/mock_fence.h" |
1465 | #include <memory> |
1466 | #include <gtest/gtest.h> |
1467 | |
1468 | namespace mtd=mir::test::doubles; |
1469 | namespace mga=mir::graphics::android; |
1470 | +using namespace testing; |
1471 | + |
1472 | +namespace |
1473 | +{ |
1474 | +struct MockCommandStreamSync : public mir::graphics::CommandStreamSync |
1475 | +{ |
1476 | + MOCK_METHOD0(raise, void()); |
1477 | + MOCK_METHOD0(reset, void()); |
1478 | + MOCK_METHOD1(wait_for, bool(std::chrono::nanoseconds)); |
1479 | +}; |
1480 | +} |
1481 | |
1482 | struct NativeBuffer : public testing::Test |
1483 | { |
1484 | NativeBuffer() : |
1485 | a_native_window_buffer(std::make_shared<ANativeWindowBuffer>()), |
1486 | mock_fence(std::make_shared<testing::NiceMock<mtd::MockFence>>()), |
1487 | - fake_fd{48484} |
1488 | + fake_fd{48484}, |
1489 | + timeout{std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::seconds(2))}, |
1490 | + mock_cmdstream_sync{std::make_shared<MockCommandStreamSync>()} |
1491 | { |
1492 | } |
1493 | |
1494 | std::shared_ptr<ANativeWindowBuffer> a_native_window_buffer; |
1495 | std::shared_ptr<mtd::MockFence> mock_fence; |
1496 | int fake_fd; |
1497 | + std::chrono::nanoseconds timeout; |
1498 | + std::shared_ptr<MockCommandStreamSync> mock_cmdstream_sync; |
1499 | }; |
1500 | |
1501 | TEST_F(NativeBuffer, extends_lifetime_when_driver_calls_external_refcount_hooks) |
1502 | @@ -88,7 +104,7 @@ |
1503 | { |
1504 | EXPECT_CALL(*mock_fence, wait()) |
1505 | .Times(0); |
1506 | - mga::AndroidNativeBuffer buffer(a_native_window_buffer, mock_fence, mga::BufferAccess::read); |
1507 | + mga::AndroidNativeBuffer buffer(a_native_window_buffer, mock_cmdstream_sync, mock_fence, mga::BufferAccess::read); |
1508 | buffer.ensure_available_for(mga::BufferAccess::read); |
1509 | } |
1510 | |
1511 | @@ -96,7 +112,7 @@ |
1512 | { |
1513 | EXPECT_CALL(*mock_fence, wait()) |
1514 | .Times(1); |
1515 | - mga::AndroidNativeBuffer buffer(a_native_window_buffer, mock_fence, mga::BufferAccess::write); |
1516 | + mga::AndroidNativeBuffer buffer(a_native_window_buffer, mock_cmdstream_sync, mock_fence, mga::BufferAccess::write); |
1517 | buffer.ensure_available_for(mga::BufferAccess::read); |
1518 | } |
1519 | |
1520 | @@ -104,7 +120,7 @@ |
1521 | { |
1522 | EXPECT_CALL(*mock_fence, wait()) |
1523 | .Times(1); |
1524 | - mga::AndroidNativeBuffer buffer(a_native_window_buffer, mock_fence, mga::BufferAccess::read); |
1525 | + mga::AndroidNativeBuffer buffer(a_native_window_buffer, mock_cmdstream_sync, mock_fence, mga::BufferAccess::read); |
1526 | buffer.ensure_available_for(mga::BufferAccess::write); |
1527 | } |
1528 | |
1529 | @@ -112,7 +128,7 @@ |
1530 | { |
1531 | EXPECT_CALL(*mock_fence, wait()) |
1532 | .Times(1); |
1533 | - mga::AndroidNativeBuffer buffer(a_native_window_buffer, mock_fence, mga::BufferAccess::write); |
1534 | + mga::AndroidNativeBuffer buffer(a_native_window_buffer, mock_cmdstream_sync, mock_fence, mga::BufferAccess::write); |
1535 | buffer.ensure_available_for(mga::BufferAccess::write); |
1536 | } |
1537 | |
1538 | @@ -120,7 +136,7 @@ |
1539 | { |
1540 | EXPECT_CALL(*mock_fence, merge_with(fake_fd)) |
1541 | .Times(1); |
1542 | - mga::AndroidNativeBuffer buffer(a_native_window_buffer, mock_fence, mga::BufferAccess::read); |
1543 | + mga::AndroidNativeBuffer buffer(a_native_window_buffer, mock_cmdstream_sync, mock_fence, mga::BufferAccess::read); |
1544 | buffer.update_usage(fake_fd, mga::BufferAccess::write); |
1545 | } |
1546 | |
1547 | @@ -129,7 +145,7 @@ |
1548 | EXPECT_CALL(*mock_fence, wait()) |
1549 | .Times(3); |
1550 | |
1551 | - mga::AndroidNativeBuffer buffer(a_native_window_buffer, mock_fence, mga::BufferAccess::read); |
1552 | + mga::AndroidNativeBuffer buffer(a_native_window_buffer, mock_cmdstream_sync, mock_fence, mga::BufferAccess::read); |
1553 | buffer.ensure_available_for(mga::BufferAccess::write); |
1554 | buffer.ensure_available_for(mga::BufferAccess::read); |
1555 | |
1556 | @@ -137,3 +153,30 @@ |
1557 | buffer.ensure_available_for(mga::BufferAccess::write); |
1558 | buffer.ensure_available_for(mga::BufferAccess::read); |
1559 | } |
1560 | + |
1561 | +TEST_F(NativeBuffer, raises_egl_fence) |
1562 | +{ |
1563 | + mga::AndroidNativeBuffer buffer(a_native_window_buffer, mock_cmdstream_sync, mock_fence, mga::BufferAccess::read); |
1564 | + |
1565 | + EXPECT_CALL(*mock_cmdstream_sync, raise()); |
1566 | + buffer.lock_for_gpu(); |
1567 | +} |
1568 | + |
1569 | +TEST_F(NativeBuffer, clears_egl_fence_successfully) |
1570 | +{ |
1571 | + mga::AndroidNativeBuffer buffer(a_native_window_buffer, mock_cmdstream_sync, mock_fence, mga::BufferAccess::read); |
1572 | + EXPECT_CALL(*mock_cmdstream_sync, wait_for(timeout)) |
1573 | + .Times(1) |
1574 | + .WillOnce(Return(true)); |
1575 | + buffer.wait_for_unlock_by_gpu(); |
1576 | +} |
1577 | + |
1578 | +//not really helpful to throw if the timeout fails |
1579 | +TEST_F(NativeBuffer, ignores_clears_egl_fence_failure) |
1580 | +{ |
1581 | + mga::AndroidNativeBuffer buffer(a_native_window_buffer, mock_cmdstream_sync, mock_fence, mga::BufferAccess::read); |
1582 | + EXPECT_CALL(*mock_cmdstream_sync, wait_for(timeout)) |
1583 | + .Times(1) |
1584 | + .WillOnce(Return(false)); |
1585 | + buffer.wait_for_unlock_by_gpu(); |
1586 | +} |
1587 | |
1588 | === modified file 'tests/unit-tests/graphics/android/test_platform.cpp' |
1589 | --- tests/unit-tests/graphics/android/test_platform.cpp 2015-12-11 12:22:15 +0000 |
1590 | +++ tests/unit-tests/graphics/android/test_platform.cpp 2016-01-25 17:04:59 +0000 |
1591 | @@ -26,6 +26,7 @@ |
1592 | #include "mir/test/doubles/mock_display_report.h" |
1593 | #include "mir/test/doubles/mock_egl.h" |
1594 | #include "mir/test/doubles/stub_display_builder.h" |
1595 | +#include "mir/test/doubles/stub_cmdstream_sync_factory.h" |
1596 | #include "mir/test/doubles/fd_matcher.h" |
1597 | #include "mir/test/fake_shared.h" |
1598 | #include "mir/test/doubles/mock_android_native_buffer.h" |
1599 | @@ -54,6 +55,7 @@ |
1600 | using namespace testing; |
1601 | |
1602 | stub_display_builder = std::make_shared<mtd::StubDisplayBuilder>(); |
1603 | + stub_sync_factory = std::make_shared<mtd::StubCmdStreamSyncFactory>(); |
1604 | stub_display_report = mr::null_display_report(); |
1605 | stride = geom::Stride(300*4); |
1606 | |
1607 | @@ -86,6 +88,7 @@ |
1608 | std::shared_ptr<mtd::MockAndroidNativeBuffer> native_buffer; |
1609 | std::shared_ptr<mtd::StubBufferAllocator> stub_buffer_allocator; |
1610 | std::shared_ptr<mtd::StubDisplayBuilder> stub_display_builder; |
1611 | + std::shared_ptr<mtd::StubCmdStreamSyncFactory> stub_sync_factory; |
1612 | std::shared_ptr<mtd::MockBuffer> mock_buffer; |
1613 | std::shared_ptr<native_handle_t> native_buffer_handle; |
1614 | std::shared_ptr<mg::DisplayReport> stub_display_report; |
1615 | @@ -99,10 +102,12 @@ |
1616 | { |
1617 | using namespace ::testing; |
1618 | int fake_fence{333}; |
1619 | + EXPECT_CALL(*native_buffer, wait_for_unlock_by_gpu()); |
1620 | EXPECT_CALL(*native_buffer, copy_fence()) |
1621 | .WillOnce(Return(fake_fence)); |
1622 | |
1623 | - mga::Platform platform(stub_buffer_allocator, stub_display_builder, stub_display_report, mga::OverlayOptimization::enabled, quirks); |
1624 | + mga::Platform platform(stub_buffer_allocator, stub_display_builder, |
1625 | + stub_sync_factory, stub_display_report, mga::OverlayOptimization::enabled, quirks); |
1626 | |
1627 | mtd::MockBufferIpcMessage mock_ipc_msg; |
1628 | int offset = 0; |
1629 | @@ -130,10 +135,12 @@ |
1630 | TEST_F(PlatformBufferIPCPackaging, test_ipc_data_packed_correctly_for_full_ipc_without_fence) |
1631 | { |
1632 | using namespace ::testing; |
1633 | + EXPECT_CALL(*native_buffer, wait_for_unlock_by_gpu()); |
1634 | EXPECT_CALL(*native_buffer, copy_fence()) |
1635 | .WillOnce(Return(-1)); |
1636 | |
1637 | - mga::Platform platform(stub_buffer_allocator, stub_display_builder, stub_display_report, mga::OverlayOptimization::enabled, quirks); |
1638 | + mga::Platform platform(stub_buffer_allocator, stub_display_builder, |
1639 | + stub_sync_factory, stub_display_report, mga::OverlayOptimization::enabled, quirks); |
1640 | |
1641 | mtd::MockBufferIpcMessage mock_ipc_msg; |
1642 | int offset = 0; |
1643 | @@ -169,10 +176,12 @@ |
1644 | TEST_F(PlatformBufferIPCPackaging, test_ipc_data_packed_correctly_for_nested) |
1645 | { |
1646 | using namespace ::testing; |
1647 | + EXPECT_CALL(*native_buffer, wait_for_unlock_by_gpu()); |
1648 | EXPECT_CALL(*native_buffer, copy_fence()) |
1649 | .WillOnce(Return(-1)); |
1650 | |
1651 | - mga::Platform platform(stub_buffer_allocator, stub_display_builder, stub_display_report, mga::OverlayOptimization::enabled, quirks); |
1652 | + mga::Platform platform(stub_buffer_allocator, stub_display_builder, |
1653 | + stub_sync_factory, stub_display_report, mga::OverlayOptimization::enabled, quirks); |
1654 | |
1655 | mtd::MockBufferIpcMessage mock_ipc_msg; |
1656 | int offset = 0; |
1657 | @@ -207,7 +216,8 @@ |
1658 | using namespace ::testing; |
1659 | |
1660 | int fake_fence{33}; |
1661 | - mga::Platform platform(stub_buffer_allocator, stub_display_builder, stub_display_report, mga::OverlayOptimization::enabled, quirks); |
1662 | + mga::Platform platform(stub_buffer_allocator, stub_display_builder, |
1663 | + stub_sync_factory, stub_display_report, mga::OverlayOptimization::enabled, quirks); |
1664 | auto ipc_ops = platform.make_ipc_operations(); |
1665 | |
1666 | mtd::MockBufferIpcMessage mock_ipc_msg; |
1667 | @@ -234,6 +244,7 @@ |
1668 | mga::Platform platform( |
1669 | std::make_shared<mtd::StubBufferAllocator>(), |
1670 | std::make_shared<mtd::StubDisplayBuilder>(), |
1671 | + std::make_shared<mtd::StubCmdStreamSyncFactory>(), |
1672 | mr::null_display_report(), |
1673 | mga::OverlayOptimization::enabled, |
1674 | std::make_shared<mga::DeviceQuirks>(mga::PropertiesOps{})); |