Nux

Merge lp:~jsjgruber/nux/lp1167018 into lp:nux

Proposed by John S. Gruber
Status: Work in progress
Proposed branch: lp:~jsjgruber/nux/lp1167018
Merge into: lp:nux
Diff against target: 122 lines (+104/-0)
3 files modified
debian/changelog (+24/-0)
debian/patches/02-radeon-ls-blur.patch (+79/-0)
debian/patches/series (+1/-0)
To merge this branch: bzr merge lp:~jsjgruber/nux/lp1167018
Reviewer Review Type Date Requested Status
Unity Team Pending
Review via email: mp+169476@code.launchpad.net

Description of the change

Proposal to fix lp: #1167018.

In the Linear Sampling Blur routines:

  1. Clamp the sampling in the shader to the texture. This removes
     the strange and ugly pattern.

  2. To produce the blur reduce the number of shader passes to those
     possible by using the linear sampling to sample each texel just
     once.

To post a comment you must log in.
Revision history for this message
John S. Gruber (jsjgruber) wrote :

This has been built for testing in ppa:jsjgruber/ppatwo.

To test (on the affected Radeon GPU):

1. Install the associated package.
2. Use ccsm to turn on active or static blur.
3. Press the "Super" or Alt button or bring up the Logout dialog box. Any
   of these should bring up a blur of the underlying screen on which to
   interact.

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

I've tested this with a card that was not affected by this issue, but here the blur effect is now weaker... You can see a comparison here: http://imgur.com/a/VixqK

So we need to fix this. Have you found a way to detect the case where you need to use the codepath you've proposed?

Also, did you add the patch as a debian patch because you don't want to sign the CLA?

Unmerged revisions

795. By John S. Gruber

* debian/patches/02-radeon-le-blur.patch:
[John S. Gruber
* Since the linear sample mechanism gets data of neighbouring pixels with
  each sample, use this fact to reduce the number of samples obtained
  from the texture. This allows higher sigmas to be used than
  otherwise. In particular it allows sigma = 3.0 to be used for blurs for
  some Radeon GPU's. The offsets generated for a sigma of 3.0 are 0.00,
  +/- 1.45, +/- 3.40, +/- 5.35, +/ -7.30, covering plus and minus pixels
  0, 1-2, 3-4, 5-6, and 6-8.
  Fixes the return value to give the total number
  of weights and offsets rather than that number minus 1, leaving
  enough room in the shader vectors for all values.
[John S. Gruber]
* Perform clamping in the Linear Sampling Gaussian shaders as it doesn't seem
  to be done by the Radeon RS690. Closes LP: #1167018.

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 2013-06-05 06:09:18 +0000
3+++ debian/changelog 2013-06-14 16:05:37 +0000
4@@ -1,3 +1,27 @@
5+nux (4.0.2daily13.06.05-0ubuntu2~jgr001) saucy; urgency=low
6+
7+ * debian/patches/02-radeon-le-blur.patch:
8+
9+ [John S. Gruber
10+ * Since the linear sample mechanism gets data of neighbouring pixels with
11+ each sample, use this fact to reduce the number of samples obtained
12+ from the texture. This allows higher sigmas to be used than
13+ otherwise. In particular it allows sigma = 3.0 to be used for blurs for
14+ some Radeon GPU's. The offsets generated for a sigma of 3.0 are 0.00,
15+ +/- 1.45, +/- 3.40, +/- 5.35, +/ -7.30, covering plus and minus pixels
16+ 0, 1-2, 3-4, 5-6, and 6-8.
17+
18+ Fixes the return value to give the total number
19+ of weights and offsets rather than that number minus 1, leaving
20+ enough room in the shader vectors for all values.
21+
22+
23+ [John S. Gruber]
24+ * Perform clamping in the Linear Sampling Gaussian shaders as it doesn't seem
25+ to be done by the Radeon RS690. Closes LP: #1167018.
26+
27+ -- John S Gruber <JohnSGruber@gmail.com> Wed, 12 Jun 2013 21:08:41 -0400
28+
29 nux (4.0.2daily13.06.05-0ubuntu1) saucy; urgency=low
30
31 [ Stephen M. Webb ]
32
33=== added file 'debian/patches/02-radeon-ls-blur.patch'
34--- debian/patches/02-radeon-ls-blur.patch 1970-01-01 00:00:00 +0000
35+++ debian/patches/02-radeon-ls-blur.patch 2013-06-14 16:05:37 +0000
36@@ -0,0 +1,79 @@
37+## Description: Make corrections in the nux LS Blur functionality for Radeon RS690 and related GPUS's.
38+## Origin/Author: John S. Gruber
39+## Bug: https://bugs.launchpad.net/ubuntu/+source/nux/+bug/1167018
40+===================================================================
41+--- lp1167018.orig/NuxGraphics/GraphicsEngine.cpp 2013-06-12 21:00:34.821397000 -0400
42++++ lp1167018/NuxGraphics/GraphicsEngine.cpp 2013-06-12 21:03:39.589781174 -0400
43+@@ -1354,26 +1354,26 @@
44+ //Our first weight has an offset of 0.
45+ offsets.push_back(0);
46+
47+- for (int i = 1; i <= support; i++)
48++ for (int i = 1; i <= support; i+=2)
49+ {
50+ float w1 = exp(-(i*i)/(2*sigma*sigma))/(sqrt(2*constants::pi)*sigma);
51+ float w2 = exp(-((i+1)*(i+1))/(2*sigma*sigma))/(sqrt(2*constants::pi)*sigma);
52+
53+ weights.push_back(w1 + w2);
54+- total += 2.0f * weights[i];
55++ total += 2.0f * (w1 + w2);
56+
57+ //Calculate our offset to utilise our GPU's bilinear sampling capability. By sampling in between texel we get the data of
58+ //neighbouring pixels with only one sample.
59+- offsets.push_back((i * w1 + (i + 1) * w2) / weights[i]);
60++ offsets.push_back((i * w1 + (i + 1) * w2) / (w1 + w2));
61+ }
62+
63+ //Normalise our weights.
64+- for (int i = 0; i < support; i++)
65++ for (int i = 0; i < (int) weights.size(); i++)
66+ {
67+ weights[i] /= total;
68+ }
69+
70+- return support;
71++ return weights.size();
72+ }
73+
74+ void GraphicsEngine::GaussianWeights(float **weights, float sigma, unsigned int num_tap)
75+Index: lp1167018/NuxGraphics/RenderingPipeGLSL.cpp
76+===================================================================
77+--- lp1167018.orig/NuxGraphics/RenderingPipeGLSL.cpp 2013-06-12 21:00:34.821397000 -0400
78++++ lp1167018/NuxGraphics/RenderingPipeGLSL.cpp 2013-06-12 21:07:47.973032922 -0400
79+@@ -664,8 +664,8 @@
80+ vec3 acc = texture2D(tex_object, v_tex_coord.st).rgb*weights[0];\n\
81+ for (int i = 1; i < NUM_SAMPLES; i++) \n\
82+ { \n\
83+- acc += texture2D(tex_object, (v_tex_coord.st+(vec2(offsets[i], 0.0)/tex_size))).rgb*weights[i]; \n\
84+- acc += texture2D(tex_object, (v_tex_coord.st-(vec2(offsets[i], 0.0)/tex_size))).rgb*weights[i]; \n\
85++ acc += texture2D(tex_object,clamp((v_tex_coord.st+(vec2(offsets[i], 0.0)/tex_size)),0.0, 1.0)).rgb*weights[i]; \n\
86++ acc += texture2D(tex_object,clamp((v_tex_coord.st-(vec2(offsets[i], 0.0)/tex_size)),0.0, 1.0)).rgb*weights[i]; \n\
87+ } \n\
88+ gl_FragColor = vec4(acc, 1.0); \n\
89+ }";
90+@@ -720,8 +720,8 @@
91+ vec3 acc = texture2D(tex_object, v_tex_coord.st).rgb*weights[0]; \n\
92+ for (int i = 1; i < NUM_SAMPLES; i++) \n\
93+ { \n\
94+- acc += texture2D(tex_object, (v_tex_coord.st+(vec2(0.0, offsets[i])/tex_size))).rgb*weights[i]; \n\
95+- acc += texture2D(tex_object, (v_tex_coord.st-(vec2(0.0, offsets[i])/tex_size))).rgb*weights[i]; \n\
96++ acc += texture2D(tex_object,clamp((v_tex_coord.st+(vec2(0.0, offsets[i])/tex_size)),0.0, 1.0)).rgb*weights[i]; \n\
97++ acc += texture2D(tex_object,clamp((v_tex_coord.st-(vec2(0.0, offsets[i])/tex_size)),0.0, 1.0)).rgb*weights[i]; \n\
98+ } \n\
99+ gl_FragColor = vec4(acc, 1.0); \n\
100+ }";
101+@@ -2845,11 +2845,11 @@
102+
103+ CHECKGL(glClearColor(0, 0, 0, 0));
104+ fx_structure->src_texture->SetWrap(GL_CLAMP, GL_CLAMP, GL_CLAMP);
105+- fx_structure->src_texture->SetFiltering(GL_NEAREST, GL_NEAREST);
106++ fx_structure->src_texture->SetFiltering(GL_LINEAR, GL_LINEAR);
107+ fx_structure->dst_texture->SetWrap(GL_CLAMP, GL_CLAMP, GL_CLAMP);
108+- fx_structure->dst_texture->SetFiltering(GL_NEAREST, GL_NEAREST);
109++ fx_structure->dst_texture->SetFiltering(GL_LINEAR, GL_LINEAR);
110+ fx_structure->temp_texture->SetWrap(GL_CLAMP, GL_CLAMP, GL_CLAMP);
111+- fx_structure->temp_texture->SetFiltering(GL_NEAREST, GL_NEAREST);
112++ fx_structure->temp_texture->SetFiltering(GL_LINEAR, GL_LINEAR);
113+
114+ SetFrameBufferHelper(_offscreen_fbo, fx_structure->dst_texture, _offscreen_depth_rt0, buffer_width, buffer_height);
115+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
116
117=== modified file 'debian/patches/series'
118--- debian/patches/series 2012-08-01 16:09:01 +0000
119+++ debian/patches/series 2013-06-14 16:05:37 +0000
120@@ -1,1 +1,2 @@
121 01_blacklist_llvmpipe.patch
122+02-radeon-ls-blur.patch

Subscribers

People subscribed via source and target branches