Mir

Merge lp:~afrantzis/mir/fix-render-surfaces-vt-switch into lp:~mir-team/mir/trunk

Proposed by Alexandros Frantzis
Status: Merged
Approved by: Daniel van Vugt
Approved revision: no longer in the source branch.
Merged at revision: 790
Proposed branch: lp:~afrantzis/mir/fix-render-surfaces-vt-switch
Merge into: lp:~mir-team/mir/trunk
Diff against target: 74 lines (+26/-7)
2 files modified
src/server/compositor/multi_threaded_compositor.cpp (+24/-6)
tests/unit-tests/compositor/test_multi_threaded_compositor.cpp (+2/-1)
To merge this branch: bzr merge lp:~afrantzis/mir/fix-render-surfaces-vt-switch
Reviewer Review Type Date Requested Status
Thomas Voß (community) Approve
Daniel van Vugt Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+171755@code.launchpad.net

Commit message

compositor: Manage the rendering target properly in the compositing threads

Description of the change

compositor: Manage the rendering target properly in the compositing threads

This fixes an issue with VT switching while running render_surfaces.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

What was the original issue? I can't seem to reproduce any problems switching VTs with render_surfaces. Other than the predictable issue that you need to be root.

review: Needs Information
Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

When switching back from a VT switch, we create new compositing threads, which don't have a current GL context. render_surfaces assumes that a context is current and calls GL functions when rendering, causing Mesa to crash on my system. You could argue that Mesa shouldn't crash in the first place, so this is a workaround for this, but at the same time this is a better, more symmetrical way to handle the context, i.e., the compositing thread makes a context current when starting and releases that context when it finishes.

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

Makes sense

review: Approve
Revision history for this message
Thomas Voß (thomas-voss) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/server/compositor/multi_threaded_compositor.cpp'
--- src/server/compositor/multi_threaded_compositor.cpp 2013-04-24 05:22:20 +0000
+++ src/server/compositor/multi_threaded_compositor.cpp 2013-06-27 09:52:32 +0000
@@ -33,6 +33,24 @@
33namespace compositor33namespace compositor
34{34{
3535
36class CurrentRenderingTarget
37{
38public:
39 CurrentRenderingTarget(mg::DisplayBuffer& buffer)
40 : buffer(buffer)
41 {
42 buffer.make_current();
43 }
44
45 ~CurrentRenderingTarget()
46 {
47 buffer.release_current();
48 }
49
50private:
51 mg::DisplayBuffer& buffer;
52};
53
36class CompositingFunctor54class CompositingFunctor
37{55{
38public:56public:
@@ -49,6 +67,12 @@
49 {67 {
50 std::unique_lock<std::mutex> lock{run_mutex};68 std::unique_lock<std::mutex> lock{run_mutex};
5169
70 /*
71 * Make the buffer the current rendering target, and release
72 * it when the thread is finished.
73 */
74 CurrentRenderingTarget target{buffer};
75
52 while (running)76 while (running)
53 {77 {
54 /* Wait until compositing has been scheduled or we are stopped */78 /* Wait until compositing has been scheduled or we are stopped */
@@ -68,12 +92,6 @@
68 lock.lock();92 lock.lock();
69 }93 }
70 }94 }
71
72 /*
73 * Release the display buffer from this thread, so that it can be
74 * made current in another thread.
75 */
76 buffer.release_current();
77 }95 }
7896
79 void schedule_compositing()97 void schedule_compositing()
8098
=== modified file 'tests/unit-tests/compositor/test_multi_threaded_compositor.cpp'
--- tests/unit-tests/compositor/test_multi_threaded_compositor.cpp 2013-06-12 10:27:50 +0000
+++ tests/unit-tests/compositor/test_multi_threaded_compositor.cpp 2013-06-27 09:52:32 +0000
@@ -355,7 +355,7 @@
355 compositor.stop();355 compositor.stop();
356}356}
357357
358TEST(MultiThreadedCompositor, releases_display_buffer_context_when_stopping)358TEST(MultiThreadedCompositor, makes_and_releases_display_buffer_current_target)
359{359{
360 using namespace testing;360 using namespace testing;
361361
@@ -368,6 +368,7 @@
368368
369 display->for_each_mock_buffer([](mtd::MockDisplayBuffer& mock_buf)369 display->for_each_mock_buffer([](mtd::MockDisplayBuffer& mock_buf)
370 {370 {
371 EXPECT_CALL(mock_buf, make_current()).Times(1);
371 EXPECT_CALL(mock_buf, release_current()).Times(1);372 EXPECT_CALL(mock_buf, release_current()).Times(1);
372 });373 });
373374

Subscribers

People subscribed via source and target branches