Merge lp:~vanvugt/unity/fix-861061-trunk into lp:unity

Proposed by Daniel van Vugt
Status: Merged
Merged at revision: 1816
Proposed branch: lp:~vanvugt/unity/fix-861061-trunk
Merge into: lp:unity
Diff against target: 60 lines (+13/-4)
4 files modified
plugins/unityshell/src/BackgroundEffectHelper.cpp (+9/-0)
plugins/unityshell/src/BackgroundEffectHelper.h (+1/-1)
plugins/unityshell/src/PanelView.cpp (+1/-2)
plugins/unityshell/src/unityshell.cpp (+2/-1)
To merge this branch: bzr merge lp:~vanvugt/unity/fix-861061-trunk
Reviewer Review Type Date Requested Status
Sam Spilsbury (community) Approve
Unity Team Pending
Review via email: mp+82861@code.launchpad.net

Description of the change

Fix major performance regressions due to unnecessary UnityFBO binding (LP: #861061) (LP: #880707)

UnityFBO was being bound even when not required. This caused major lag in glPaintOutput, which slowed down all rendering. This was seen in reduced framerates in apps (LP: #861061) and significantly worse screen tearing with Unity 4.x compared to 3.x (LP: #880707).

To post a comment you must log in.
Revision history for this message
Mikkel Kamstrup Erlandsen (kamstrup) wrote :

(please excuse me, I don't know this code very well and I only looked
at the diff)

Does the ref handling not break now that bind() is conditionalized? It
would seem that you always unbind, but only conditionally bind the
fbo.

Revision history for this message
Daniel van Vugt (vanvugt) wrote :
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

I guess that this merge request should be placed also for lp:unity/4.0 in case that Sam confirms it's fine.

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

I already planned doing a proposal for oneiric after it's been approved for lp:unity.

Sam tells me he will get around to looking at this in the near future.

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

This fix has now been verified by the two users who reported bug 861061 (and 1 duplicate). They both report it works for them using ppa:vanvugt/unity. More details in bug 861061.

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

Of course, I too have verified the fix and tested it on i915, nvidia, nouveau, radeon and fglrx.

Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

Ok, it looks good to me and user testing seems to confirm that is fine, however I guess that you need at least a manual test, so please add one as documented on Unity trunk

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

The test case is documented at the top of bug 861061.

Revision history for this message
Sam Spilsbury (smspillaz) wrote :

(Will add a standalone version of the UnityFBO stuff very soon, along with lp:~smspillaz/unity/unity.big_fbo)

Revision history for this message
Sam Spilsbury (smspillaz) wrote :

(This branch has been merged into a larger work-branch to do with unityfbo in https://code.launchpad.net/~smspillaz/unity/unity.fix_864784_868120_872625v2/+merge/86064)

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

I thought it might overlap with you ongoing FBO work in precise. But should I also target this simple fix in a new proposal for oneiric?...

I'm a little concerned that by delaying the fix in precise, it means a fix for oneiric won't get approved until even later than that.

Revision history for this message
Sam Spilsbury (smspillaz) wrote :

Well, the testcases for all of them need to come at the same time basically, so its easier to roll it all into one branch.

The plan is to SRU the framebuffer object work in oneiric once its tested. Namely because it fixes a boost::shared_ptr related abort () when hotplugging monitors and it also fixes noticable visual glitches with the expo plugin. Plus, I had planned to incorporate some of the same changes you had made in this branch which improve performance when no framebuffer objects need to be updated.

Unfortunately getting people to actually test this is difficult since everybody is on holiday. Additionally, I'm waiting on a way that we can automate the testcase that was made in https://code.launchpad.net/~smspillaz/unity/unity.fix_864784_868120_872625v2/+merge/86064 using gmock, and I think that's being done now or very soon in the future.

Considering that we finally got someone to test it on fglrx, I'm quite keen on getting all of this landed at the same time.

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

I thought it was obvious already, but your branch looks way to complicated to be considered for an SRU. I was assuming this one would be used in the SRU.

Revision history for this message
Sam Spilsbury (smspillaz) wrote :

On Tue, 20 Dec 2011, Daniel van Vugt wrote:

> I thought it was obvious already, but your branch looks way to complicated to be considered for an SRU. I was assuming this one would be used in the SRU.

It may look noisy, but the majority of the noise comes from the fact that
I needed to rip out the fbo classes into something that could be tested
independently and that a few variable names were changed.

The actual *behavioural* change is the move from using one framebuffer
object per monitor to using one framebuffer object per screen. (eg, one
framebuffer object).

I'm confident that we can SRU it.

> --
> https://code.launchpad.net/~vanvugt/unity/fix-861061-trunk/+merge/82861
> You are requested to review the proposed merge of lp:~vanvugt/unity/fix-861061-trunk into lp:unity.
>

Revision history for this message
Sam Spilsbury (smspillaz) :
review: Approve
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Please fix! The critical part of this bug fix did not get merged:

 - mFbos[output]->bind ();
 + if (BackgroundEffectHelper::HasDirtyHelpers())
 + mFbos[output]->bind ();

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

Please "re-merge", I mean :)

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

Sorry, my mistake. The fix is present and looks complete in lp:unity. Merge done.

Revision history for this message
Sam Spilsbury (smspillaz) wrote :

+void unity::ScreenEffectFramebufferObject::bind (const nux::Geometry &output)
+{
+ if (!BackgroundEffectHelper::HasDirtyHelpers())
+ return;

Confirmed.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/unityshell/src/BackgroundEffectHelper.cpp'
2--- plugins/unityshell/src/BackgroundEffectHelper.cpp 2011-09-28 05:19:39 +0000
3+++ plugins/unityshell/src/BackgroundEffectHelper.cpp 2011-11-21 10:41:26 +0000
4@@ -91,6 +91,15 @@
5 return false;
6 }
7
8+bool BackgroundEffectHelper::HasDirtyHelpers()
9+{
10+ for (BackgroundEffectHelper * bg_effect_helper : registered_list_)
11+ if (bg_effect_helper->enabled && bg_effect_helper->cache_dirty)
12+ return true;
13+
14+ return false;
15+}
16+
17 void BackgroundEffectHelper::Register(BackgroundEffectHelper* self)
18 {
19 registered_list_.push_back(self);
20
21=== modified file 'plugins/unityshell/src/BackgroundEffectHelper.h'
22--- plugins/unityshell/src/BackgroundEffectHelper.h 2011-10-19 22:13:57 +0000
23+++ plugins/unityshell/src/BackgroundEffectHelper.h 2011-11-21 10:41:26 +0000
24@@ -53,7 +53,7 @@
25 void DirtyCache();
26
27 static void ProcessDamage(nux::Geometry geo);
28-
29+ static bool HasDirtyHelpers();
30 static bool HasEnabledHelpers();
31
32 static nux::Property<unity::BlurType> blur_type;
33
34=== modified file 'plugins/unityshell/src/PanelView.cpp'
35--- plugins/unityshell/src/PanelView.cpp 2011-10-25 16:08:30 +0000
36+++ plugins/unityshell/src/PanelView.cpp 2011-11-21 10:41:26 +0000
37@@ -593,8 +593,7 @@
38
39 _opacity = opacity;
40
41- if (_opacity < 1.0f && !_dash_is_open)
42- bg_effect_helper_.enabled = false;
43+ bg_effect_helper_.enabled = (_opacity < 1.0f || _dash_is_open);
44
45 ForceUpdateBackground();
46 }
47
48=== modified file 'plugins/unityshell/src/unityshell.cpp'
49--- plugins/unityshell/src/unityshell.cpp 2011-11-14 18:39:33 +0000
50+++ plugins/unityshell/src/unityshell.cpp 2011-11-21 10:41:26 +0000
51@@ -940,7 +940,8 @@
52 * attempts to bind it will only increment
53 * its bind reference so make sure that
54 * you always unbind as much as you bind */
55- mFbos[output]->bind ();
56+ if (BackgroundEffectHelper::HasDirtyHelpers())
57+ mFbos[output]->bind ();
58
59 doShellRepaint = true;
60 allowWindowPaint = true;