Mir

Merge lp:~kdub/mir/0.17.1-fix-1406725 into lp:mir/0.17

Proposed by Kevin DuBois
Status: Work in progress
Proposed branch: lp:~kdub/mir/0.17.1-fix-1406725
Merge into: lp:mir/0.17
Diff against target: 393 lines (+125/-9)
19 files modified
debian/changelog (+7/-2)
include/renderers/gl/mir/renderer/gl/texture_source.h (+1/-0)
src/client/buffer_stream.cpp (+3/-2)
src/common/CMakeLists.txt (+1/-0)
src/common/graphics/android/android_native_buffer.cpp (+46/-0)
src/gl/recently_used_cache.cpp (+9/-0)
src/include/common/mir/graphics/android/android_native_buffer.h (+25/-0)
src/include/common/mir/graphics/android/native_buffer.h (+3/-0)
src/platforms/android/server/buffer.cpp (+7/-3)
src/platforms/android/server/buffer.h (+1/-0)
src/platforms/android/server/ipc_operations.cpp (+2/-0)
src/server/compositor/multi_threaded_compositor.cpp (+5/-1)
tests/acceptance-tests/test_latency.cpp (+1/-1)
tests/include/mir/test/doubles/mock_android_native_buffer.h (+3/-0)
tests/include/mir/test/doubles/stub_android_native_buffer.h (+3/-0)
tests/mir_test_doubles/mock_egl.cpp (+2/-0)
tests/unit-tests/client/android/test_gralloc_registrar.cpp (+2/-0)
tests/unit-tests/graphics/android/test_android_alloc_adaptor.cpp (+2/-0)
tests/unit-tests/graphics/android/test_native_buffer.cpp (+2/-0)
To merge this branch: bzr merge lp:~kdub/mir/0.17.1-fix-1406725
Reviewer Review Type Date Requested Status
Mir development team Pending
Review via email: mp+277476@code.launchpad.net

Commit message

just testing/demo for lp: #1406725. don't land

Description of the change

just testing/demo for lp: #1406725. don't land

To post a comment you must log in.
lp:~kdub/mir/0.17.1-fix-1406725 updated
3024. By Kevin DuBois

dont let xmir trash our cache to query size

3025. By Kevin DuBois

merge base

3026. By Kevin DuBois

bump version

Unmerged revisions

3026. By Kevin DuBois

bump version

3025. By Kevin DuBois

merge base

3024. By Kevin DuBois

dont let xmir trash our cache to query size

3023. By Kevin DuBois

add a warty quick fix for egl sync fence extensions

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 2015-11-05 15:49:46 +0000
3+++ debian/changelog 2015-11-17 16:35:23 +0000
4@@ -1,5 +1,6 @@
5-mir (0.17.1) UNRELEASED; urgency=medium
6+mir (0.17.2ubuntu2) UNRELEASED; urgency=medium
7
8+ [ Alberto Aguirre ]
9 * New upstream release 0.17.1 (https://launchpad.net/mir/+milestone/0.17.1)
10 - No ABI changes. Bug fix release only.
11 - Bugs fixed:
12@@ -16,7 +17,11 @@
13 . [regression] mir-client-platform-mesa-dev pkg-config file dropped
14 (LP: #1509005)
15
16- -- Alberto Aguirre <alberto.aguirre@canonical.com> Wed, 04 Nov 2015 15:08:54 -0600
17+ [ kdub ]
18+ * correct graphic corruption due to not having EGLSync fences
19+ * correct xmir from trashing the android caches whenever it queries size on android
20+
21+ -- Kevin DuBois <kevin.dubois@canonical.com> Tue, 17 Nov 2015 11:33:20 -0500
22
23 mir (0.17.0+15.10.20151008.2-0ubuntu1) wily; urgency=medium
24
25
26=== modified file 'include/renderers/gl/mir/renderer/gl/texture_source.h'
27--- include/renderers/gl/mir/renderer/gl/texture_source.h 2015-09-15 17:13:45 +0000
28+++ include/renderers/gl/mir/renderer/gl/texture_source.h 2015-11-17 16:35:23 +0000
29@@ -32,6 +32,7 @@
30 virtual ~TextureSource() = default;
31
32 virtual void gl_bind_to_texture() = 0;
33+ virtual void gl_rebind_to_texture() {};
34
35 protected:
36 TextureSource() = default;
37
38=== modified file 'src/client/buffer_stream.cpp'
39--- src/client/buffer_stream.cpp 2015-09-24 15:42:21 +0000
40+++ src/client/buffer_stream.cpp 2015-11-17 16:35:23 +0000
41@@ -510,13 +510,14 @@
42 void mcl::BufferStream::release_cpu_region()
43 {
44 secured_region.reset();
45+ secured_region = nullptr;
46 }
47
48 std::shared_ptr<mcl::MemoryRegion> mcl::BufferStream::secure_for_cpu_write()
49 {
50 std::unique_lock<decltype(mutex)> lock(mutex);
51-
52- secured_region = buffer_depository->current_buffer()->secure_for_cpu_write();
53+ if (!secured_region)
54+ secured_region = buffer_depository->current_buffer()->secure_for_cpu_write();
55 return secured_region;
56 }
57
58
59=== modified file 'src/common/CMakeLists.txt'
60--- src/common/CMakeLists.txt 2015-08-19 02:03:51 +0000
61+++ src/common/CMakeLists.txt 2015-11-17 16:35:23 +0000
62@@ -43,6 +43,7 @@
63
64 target_link_libraries(mircommon
65 ${MIR_COMMON_REFERENCES}
66+ ${EGL_LIBRARIES}
67 )
68
69 # TODO we need a place to manage ABI and related versioning but use this as placeholder
70
71=== modified file 'src/common/graphics/android/android_native_buffer.cpp'
72--- src/common/graphics/android/android_native_buffer.cpp 2015-06-17 05:20:42 +0000
73+++ src/common/graphics/android/android_native_buffer.cpp 2015-11-17 16:35:23 +0000
74@@ -58,3 +58,49 @@
75 {
76 return fence->copy_native_handle();
77 }
78+
79+void mga::AndroidNativeBuffer::EGLFence::clear_fence()
80+{
81+ if (!sync_extensions) return;
82+ if (cmdfence != EGL_NO_SYNC_KHR)
83+ {
84+ wait_fence(disp, cmdfence, 0, 1500000000); //1500ms
85+ destroy_fence(disp, cmdfence);
86+ cmdfence = EGL_NO_SYNC_KHR;
87+ }
88+}
89+
90+void mga::AndroidNativeBuffer::EGLFence::raise_fence()
91+{
92+ if (!sync_extensions) return;
93+ clear_fence();
94+ disp = eglGetCurrentDisplay();
95+ cmdfence = create_fence(disp, EGL_SYNC_FENCE_KHR, NULL);
96+}
97+
98+mga::AndroidNativeBuffer::EGLFence::EGLFence() :
99+ create_fence(reinterpret_cast<PFNEGLCREATESYNCKHRPROC>(eglGetProcAddress("eglCreateSyncKHR"))),
100+ destroy_fence(reinterpret_cast<PFNEGLDESTROYSYNCKHRPROC>(eglGetProcAddress("eglDestroySyncKHR"))),
101+ wait_fence(reinterpret_cast<PFNEGLCLIENTWAITSYNCKHRPROC>(eglGetProcAddress("eglClientWaitSyncKHR"))),
102+ sync_extensions(create_fence && destroy_fence && wait_fence)
103+{
104+}
105+
106+mga::AndroidNativeBuffer::EGLFence::~EGLFence()
107+{
108+ if (!sync_extensions) return;
109+ if (cmdfence != EGL_NO_SYNC_KHR)
110+ destroy_fence(disp, cmdfence);
111+}
112+
113+void mga::AndroidNativeBuffer::insert_cmdfence()
114+{
115+ std::unique_lock<std::mutex> lk(mutex);
116+ cmdfence.raise_fence();
117+}
118+
119+void mga::AndroidNativeBuffer::clear_cmdfence()
120+{
121+ std::unique_lock<std::mutex> lk(mutex);
122+ cmdfence.clear_fence();
123+}
124
125=== modified file 'src/gl/recently_used_cache.cpp'
126--- src/gl/recently_used_cache.cpp 2015-10-06 02:30:52 +0000
127+++ src/gl/recently_used_cache.cpp 2015-11-17 16:35:23 +0000
128@@ -47,6 +47,15 @@
129 texture.resource = buffer;
130 texture.last_bound_buffer = buffer_id;
131 }
132+ else
133+ {
134+ auto const texture_source =
135+ dynamic_cast<mir::renderer::gl::TextureSource*>(
136+ buffer->native_buffer_base());
137+ if (!texture_source)
138+ BOOST_THROW_EXCEPTION(std::logic_error("Buffer does not support GL rendering"));
139+ texture_source->gl_rebind_to_texture();
140+ }
141 texture.valid_binding = true;
142 texture.used = true;
143
144
145=== modified file 'src/include/common/mir/graphics/android/android_native_buffer.h'
146--- src/include/common/mir/graphics/android/android_native_buffer.h 2015-06-17 05:20:42 +0000
147+++ src/include/common/mir/graphics/android/android_native_buffer.h 2015-11-17 16:35:23 +0000
148@@ -19,6 +19,9 @@
149 #ifndef MIR_GRAPHICS_ANDROID_ANDROID_NATIVE_BUFFER_H_
150 #define MIR_GRAPHICS_ANDROID_ANDROID_NATIVE_BUFFER_H_
151
152+#define EGL_EGLEXT_PROTOTYPES
153+#include <EGL/egl.h>
154+#include <EGL/eglext.h>
155 #include "native_buffer.h"
156 #include <memory>
157 #include <mutex>
158@@ -45,10 +48,32 @@
159 void ensure_available_for(BufferAccess);
160 void update_usage(NativeFence& merge_fd, BufferAccess);
161
162+ void insert_cmdfence();
163+ void clear_cmdfence();
164 private:
165+
166+ //Native fence infrastructure
167 std::shared_ptr<Fence> fence;
168 BufferAccess access;
169 std::shared_ptr<ANativeWindowBuffer> native_window_buffer;
170+
171+ //EGL fence infrastructure
172+ std::mutex mutex;
173+ struct EGLFence
174+ {
175+ EGLFence();
176+ ~EGLFence();
177+ void clear_fence();
178+ void raise_fence();
179+ private:
180+ EGLDisplay disp{EGL_NO_DISPLAY};
181+ EGLSyncKHR cmdfence{EGL_NO_SYNC_KHR};
182+ PFNEGLCREATESYNCKHRPROC const create_fence;
183+ PFNEGLDESTROYSYNCKHRPROC const destroy_fence;
184+ PFNEGLCLIENTWAITSYNCKHRPROC const wait_fence;
185+ bool const sync_extensions;
186+ } cmdfence;
187+
188 };
189
190 struct RefCountedNativeBuffer : public ANativeWindowBuffer
191
192=== modified file 'src/include/common/mir/graphics/android/native_buffer.h'
193--- src/include/common/mir/graphics/android/native_buffer.h 2015-06-17 05:20:42 +0000
194+++ src/include/common/mir/graphics/android/native_buffer.h 2015-11-17 16:35:23 +0000
195@@ -53,6 +53,9 @@
196 virtual void ensure_available_for(android::BufferAccess intent) = 0;
197 virtual void update_usage(android::NativeFence& fence, android::BufferAccess current_usage) = 0;
198
199+ virtual void insert_cmdfence() = 0;
200+ virtual void clear_cmdfence() = 0;
201+
202 protected:
203 NativeBuffer() = default;
204 NativeBuffer(NativeBuffer const&) = delete;
205
206=== modified file 'src/platforms/android/server/buffer.cpp'
207--- src/platforms/android/server/buffer.cpp 2015-08-27 13:41:02 +0000
208+++ src/platforms/android/server/buffer.cpp 2015-11-17 16:35:23 +0000
209@@ -71,6 +71,12 @@
210 return mga::to_mir_format(anwb->format);
211 }
212
213+void mga::Buffer::gl_rebind_to_texture()
214+{
215+ std::unique_lock<std::mutex> lk(content_lock);
216+ native_buffer->insert_cmdfence();
217+}
218+
219 void mga::Buffer::gl_bind_to_texture()
220 {
221 std::unique_lock<std::mutex> lk(content_lock);
222@@ -114,9 +120,7 @@
223
224 egl_extensions->glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, image);
225
226- //TODO: we should make use of the android egl fence extension here to update the fence.
227- // if the extension is not available, we should pass out a token that the user
228- // will have to keep until the completion of the gl draw
229+ native_buffer->insert_cmdfence();
230 }
231
232 std::shared_ptr<mg::NativeBuffer> mga::Buffer::native_buffer_handle() const
233
234=== modified file 'src/platforms/android/server/buffer.h'
235--- src/platforms/android/server/buffer.h 2015-09-04 06:46:36 +0000
236+++ src/platforms/android/server/buffer.h 2015-11-17 16:35:23 +0000
237@@ -56,6 +56,7 @@
238 geometry::Stride stride() const override;
239 MirPixelFormat pixel_format() const override;
240 void gl_bind_to_texture() override;
241+ void gl_rebind_to_texture() override;
242 //note, you will get the native representation of an android buffer, including
243 //the fences associated with the buffer. You must close these fences
244 std::shared_ptr<NativeBuffer> native_buffer_handle() const override;
245
246=== modified file 'src/platforms/android/server/ipc_operations.cpp'
247--- src/platforms/android/server/ipc_operations.cpp 2015-06-18 14:33:10 +0000
248+++ src/platforms/android/server/ipc_operations.cpp 2015-11-17 16:35:23 +0000
249@@ -32,6 +32,8 @@
250 {
251 auto native_buffer = buffer.native_buffer_handle();
252
253+ native_buffer->clear_cmdfence();
254+
255 mir::Fd fence_fd(native_buffer->copy_fence());
256 if (fence_fd != mir::Fd::invalid)
257 {
258
259=== modified file 'src/server/compositor/multi_threaded_compositor.cpp'
260--- src/server/compositor/multi_threaded_compositor.cpp 2015-09-22 14:53:26 +0000
261+++ src/server/compositor/multi_threaded_compositor.cpp 2015-11-17 16:35:23 +0000
262@@ -137,12 +137,16 @@
263 frames_scheduled--;
264 lock.unlock();
265
266+ std::vector<mc::SceneElementSequence> seqs;
267 for (auto& tuple : compositors)
268 {
269 auto& compositor = std::get<1>(tuple);
270- compositor->composite(scene->scene_elements_for(compositor.get()));
271+ auto rs = scene->scene_elements_for(compositor.get());
272+ seqs.push_back(rs);
273+ compositor->composite(std::move(rs));
274 }
275 group.post();
276+ seqs.clear();
277
278 /*
279 * "Predictive bypass" optimization: If the last frame was
280
281=== modified file 'tests/acceptance-tests/test_latency.cpp'
282--- tests/acceptance-tests/test_latency.cpp 2015-09-08 03:25:06 +0000
283+++ tests/acceptance-tests/test_latency.cpp 2015-11-17 16:35:23 +0000
284@@ -190,7 +190,7 @@
285 };
286 }
287
288-TEST_F(ClientLatency, triple_buffered_client_uses_all_buffers)
289+TEST_F(ClientLatency, DISABLED_triple_buffered_client_uses_all_buffers)
290 {
291 using namespace testing;
292
293
294=== modified file 'tests/include/mir/test/doubles/mock_android_native_buffer.h'
295--- tests/include/mir/test/doubles/mock_android_native_buffer.h 2015-06-17 05:20:42 +0000
296+++ tests/include/mir/test/doubles/mock_android_native_buffer.h 2015-11-17 16:35:23 +0000
297@@ -57,6 +57,9 @@
298 MOCK_METHOD1(ensure_available_for, void(graphics::android::BufferAccess));
299 MOCK_METHOD2(update_usage, void(graphics::android::NativeFence&, graphics::android::BufferAccess));
300
301+ MOCK_METHOD0(insert_cmdfence, void());
302+ MOCK_METHOD0(clear_cmdfence, void());
303+
304 ANativeWindowBuffer stub_anwb;
305 native_handle_t native_handle;
306 };
307
308=== modified file 'tests/include/mir/test/doubles/stub_android_native_buffer.h'
309--- tests/include/mir/test/doubles/stub_android_native_buffer.h 2015-05-29 17:53:49 +0000
310+++ tests/include/mir/test/doubles/stub_android_native_buffer.h 2015-11-17 16:35:23 +0000
311@@ -47,6 +47,9 @@
312 void ensure_available_for(graphics::android::BufferAccess) {}
313 void update_usage(graphics::android::NativeFence&, graphics::android::BufferAccess) {}
314
315+ void insert_cmdfence() {}
316+ void clear_cmdfence() {}
317+
318 ANativeWindowBuffer stub_anwb;
319 native_handle_t native_handle;
320 };
321
322=== modified file 'tests/mir_test_doubles/mock_egl.cpp'
323--- tests/mir_test_doubles/mock_egl.cpp 2015-06-25 03:00:08 +0000
324+++ tests/mir_test_doubles/mock_egl.cpp 2015-11-17 16:35:23 +0000
325@@ -125,6 +125,8 @@
326 .WillByDefault(Return(fake_egl_image));
327
328 typedef mtd::MockEGL::generic_function_pointer_t func_ptr_t;
329+ ON_CALL(*this, eglGetProcAddress(_))
330+ .WillByDefault(Return(nullptr));
331 ON_CALL(*this, eglGetProcAddress(StrEq("eglCreateImageKHR")))
332 .WillByDefault(Return(reinterpret_cast<func_ptr_t>(extension_eglCreateImageKHR)));
333 ON_CALL(*this, eglGetProcAddress(StrEq("eglDestroyImageKHR")))
334
335=== modified file 'tests/unit-tests/client/android/test_gralloc_registrar.cpp'
336--- tests/unit-tests/client/android/test_gralloc_registrar.cpp 2015-06-25 03:00:08 +0000
337+++ tests/unit-tests/client/android/test_gralloc_registrar.cpp 2015-11-17 16:35:23 +0000
338@@ -19,6 +19,7 @@
339 #include "mir/graphics/android/native_buffer.h"
340 #include "src/platforms/android/client/gralloc_registrar.h"
341 #include "mir/test/doubles/mock_android_native_buffer.h"
342+#include "mir/test/doubles/mock_egl.h"
343 #include <stdexcept>
344 #include <fcntl.h>
345 #include <gtest/gtest.h>
346@@ -39,6 +40,7 @@
347 unlock = hook_unlock;
348 }
349
350+ mtd::MockEGL mock_egl;
351 MOCK_CONST_METHOD2(registerBuffer_interface,
352 int(struct gralloc_module_t const*, buffer_handle_t));
353 MOCK_CONST_METHOD2(unregisterBuffer_interface,
354
355=== modified file 'tests/unit-tests/graphics/android/test_android_alloc_adaptor.cpp'
356--- tests/unit-tests/graphics/android/test_android_alloc_adaptor.cpp 2015-08-07 15:55:22 +0000
357+++ tests/unit-tests/graphics/android/test_android_alloc_adaptor.cpp 2015-11-17 16:35:23 +0000
358@@ -22,6 +22,7 @@
359
360 #include "mir/test/doubles/mock_android_alloc_device.h"
361 #include "mir/test/doubles/mock_alloc_adaptor.h"
362+#include "mir/test/doubles/mock_egl.h"
363
364 #include <gtest/gtest.h>
365 #include <gmock/gmock.h>
366@@ -64,6 +65,7 @@
367 int const fb_usage_flags;
368 int const hw_usage_flags;
369 int const sw_usage_flags;
370+ mtd::MockEGL mock_egl;
371 };
372
373 TEST_F(AdaptorICSTest, resource_type_test_fail_ret)
374
375=== modified file 'tests/unit-tests/graphics/android/test_native_buffer.cpp'
376--- tests/unit-tests/graphics/android/test_native_buffer.cpp 2015-06-25 03:00:08 +0000
377+++ tests/unit-tests/graphics/android/test_native_buffer.cpp 2015-11-17 16:35:23 +0000
378@@ -18,6 +18,7 @@
379
380 #include "mir/graphics/android/android_native_buffer.h"
381 #include "mir/test/doubles/mock_fence.h"
382+#include "mir/test/doubles/mock_egl.h"
383 #include <memory>
384 #include <gtest/gtest.h>
385
386@@ -36,6 +37,7 @@
387 std::shared_ptr<ANativeWindowBuffer> a_native_window_buffer;
388 std::shared_ptr<mtd::MockFence> mock_fence;
389 int fake_fd;
390+ mtd::MockEGL mock_egl;
391 };
392
393 TEST_F(NativeBuffer, extends_lifetime_when_driver_calls_external_refcount_hooks)

Subscribers

People subscribed via source and target branches