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
1=== modified file 'src/server/compositor/multi_threaded_compositor.cpp'
2--- src/server/compositor/multi_threaded_compositor.cpp 2013-04-24 05:22:20 +0000
3+++ src/server/compositor/multi_threaded_compositor.cpp 2013-06-27 09:52:32 +0000
4@@ -33,6 +33,24 @@
5 namespace compositor
6 {
7
8+class CurrentRenderingTarget
9+{
10+public:
11+ CurrentRenderingTarget(mg::DisplayBuffer& buffer)
12+ : buffer(buffer)
13+ {
14+ buffer.make_current();
15+ }
16+
17+ ~CurrentRenderingTarget()
18+ {
19+ buffer.release_current();
20+ }
21+
22+private:
23+ mg::DisplayBuffer& buffer;
24+};
25+
26 class CompositingFunctor
27 {
28 public:
29@@ -49,6 +67,12 @@
30 {
31 std::unique_lock<std::mutex> lock{run_mutex};
32
33+ /*
34+ * Make the buffer the current rendering target, and release
35+ * it when the thread is finished.
36+ */
37+ CurrentRenderingTarget target{buffer};
38+
39 while (running)
40 {
41 /* Wait until compositing has been scheduled or we are stopped */
42@@ -68,12 +92,6 @@
43 lock.lock();
44 }
45 }
46-
47- /*
48- * Release the display buffer from this thread, so that it can be
49- * made current in another thread.
50- */
51- buffer.release_current();
52 }
53
54 void schedule_compositing()
55
56=== modified file 'tests/unit-tests/compositor/test_multi_threaded_compositor.cpp'
57--- tests/unit-tests/compositor/test_multi_threaded_compositor.cpp 2013-06-12 10:27:50 +0000
58+++ tests/unit-tests/compositor/test_multi_threaded_compositor.cpp 2013-06-27 09:52:32 +0000
59@@ -355,7 +355,7 @@
60 compositor.stop();
61 }
62
63-TEST(MultiThreadedCompositor, releases_display_buffer_context_when_stopping)
64+TEST(MultiThreadedCompositor, makes_and_releases_display_buffer_current_target)
65 {
66 using namespace testing;
67
68@@ -368,6 +368,7 @@
69
70 display->for_each_mock_buffer([](mtd::MockDisplayBuffer& mock_buf)
71 {
72+ EXPECT_CALL(mock_buf, make_current()).Times(1);
73 EXPECT_CALL(mock_buf, release_current()).Times(1);
74 });
75

Subscribers

People subscribed via source and target branches