Nux

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

Proposed by John S. Gruber
Status: Needs review
Proposed branch: lp:~jsjgruber/nux/lp1167018.1
Merge into: lp:nux
Diff against target: 432 lines (+399/-0)
6 files modified
debian/changelog (+46/-0)
debian/patches/02-ubuntu-ls-blur-return.patch (+17/-0)
debian/patches/03-ubuntu-ls-blur-max-program.patch (+143/-0)
debian/patches/04-ubuntu-fix-ls-blur-weight-adjustment.patch (+14/-0)
debian/patches/06-ubuntu-simplify-ls-shaders.patch (+175/-0)
debian/patches/series (+4/-0)
To merge this branch: bzr merge lp:~jsjgruber/nux/lp1167018.1
Reviewer Review Type Date Requested Status
Marco Trevisan (Treviño) Pending
Unity Team Pending
Review via email: mp+181614@code.launchpad.net

Description of the change

Proposed fix for https://bugs.launchpad.net/ubuntu/+source/nux/+bug/1167018 formatted as distribution patches (as I can't sign the Inalogic CLA). The current blur remains (my previous proposal to fix this problem had adjusted it). This seems like a more powerful approach and shouldn't affect the result except to speed it up.

The first bzr revision contains three small patches for problems I discovered as I worked. Each is a form of indexing problem.

The second contains the bug fix, which moves as much processing as possible from the per pixel shader to the shader set-up. The actual blur algorithm remains unchanged.

------

The specifics of the moved processing is to precompute a set of vec2(offsets) and weights, the set containing one row per sample needed for the blur, with the offsets normalized to the texture length or width. These are assembled in order for purposes of improving the chance that a subsequent texture sample will find its texture memory available in its cache without rereading memory--speeding up the shader.

The shader program is adjusted to take the above input, add the offset to the current pixels coordinate in texture space, get the texture sample, and add the weighted sample to the accumulating pixel gl_FragColor. On my X1250 R400 hardware each sample needs just three shader instructions, the texture address calculation, the sample, and the weighted sample accumulation.

I have a patch I'm not proposing here to alter the LS blur algorithm to produce a more Gaussian blur, it requires an increase of about 1.5 to the sigma to produce a blur similar in strength to the current one.

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. See https://launchpad.net/~jsjgruber/+archive/ppatwo/+packages for the build.

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
Stephen M. Webb (bregma) wrote :

Could you please submit your 02-ubuntu-ls-blur-return.patch and 04-ubuntu-fix-ls-blur-weight-adjustment.patch as separate merge proposals to the Nux (rather than as packaging patches), since they're atomic, stand alone, and are not substatial enough to require a CLA?

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

John, any update?

Revision history for this message
John S. Gruber (jsjgruber) wrote :

Marco, I'm waiting to hear back from Stephen who is working on the overall CLA issue for the patch set. If I get a good affirmative response through Stephen I'll reformat all of this as direct changes to Nux rather than as a set of distribution patches and request a merge of that. (I assume that's OK with you, too).

Unmerged revisions

813. By John S. Gruber

debian/patches/06-ubuntu-simplify-ls-shaders.patch :
Radically simplify (and generalize) the linear sampling gaussian
blur shader programs by calculating the coordinates normalized
by texture by width or height in the setup. Express these
as x,y vectors.
Apply them as simply as possible in the shader to save
shader instructions.
Also see that the offsets are given to the shader in
order, providing much improved locality of memory access.
This alone causes much time savings as the hardware
can have subsequent memory locations cached--which is impossible
when going from, e.g., texture coordinate (0,-9) directly to
(0, 9). Instead the order is (0, -9), (0, -8)...(0, 0), (0, 1)...
(0, 8), (0, 9).
Fixes lp: #1167018

812. By John S. Gruber

Add three patches to debian/patches to resolve problems related to LS
blurring:
02-ubuntu-ls-blur-return.patch
Return the length of the vectors so there is room in the shader
for all of them. This resolves an inconsistency between the
shader, shader setup and function return.
03-ubuntu-ls-blur-max-program.patch
Use the sigma rather than the number of samples required when
calculating the place to store one of the two linear sampling
gaussian blur shader programs in the cache.
The number of cache locations is limited to 11 and the
number of samples required can easily exceed that.
04-ubuntu-fix-ls-blur-weight-adjustment.patch
In the linear sampling gaussian blur calculation of offsets and
weights adjust the last weight as well as all others.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/changelog'
--- debian/changelog 2013-08-16 10:34:41 +0000
+++ debian/changelog 2013-08-22 16:28:41 +0000
@@ -1,3 +1,49 @@
1nux (4.0.2+13.10.20130816.2-0ubuntu2~jgu002) saucy; urgency=low
2
3 * debian/patches/06-ubuntu-simplify-ls-shaders.patch :
4 Radically simplify (and generalize) the linear sampling gaussian
5 blur shader programs by calculating the coordinates normalized
6 by texture by width or height in the setup. Express these
7 as x,y vectors.
8
9 Apply them as simply as possible in the shader to save
10 shader instructions.
11
12 Also see that the offsets are given to the shader in
13 order, providing much improved locality of memory access.
14 This alone causes much time savings as the hardware
15 can have subsequent memory locations cached--which is impossible
16 when going from, e.g., texture coordinate (0,-9) directly to
17 (0, 9). Instead the order is (0, -9), (0, -8)...(0, 0), (0, 1)...
18 (0, 8), (0, 9).
19
20 Fixes lp: #1167018
21
22 -- John S Gruber <JohnSGruber@gmail.com> Tue, 20 Aug 2013 17:49:11 -0400
23
24nux (4.0.2+13.10.20130816.2-0ubuntu2~jgu001) saucy; urgency=low
25
26 * Add three patches to debian/patches to resolve problems related to LS
27 blurring:
28
29 02-ubuntu-ls-blur-return.patch
30 Return the length of the vectors so there is room in the shader
31 for all of them. This resolves an inconsistency between the
32 shader, shader setup and function return.
33
34 03-ubuntu-ls-blur-max-program.patch
35 Use the sigma rather than the number of samples required when
36 calculating the place to store one of the two linear sampling
37 gaussian blur shader programs in the cache.
38 The number of cache locations is limited to 11 and the
39 number of samples required can easily exceed that.
40
41 04-ubuntu-fix-ls-blur-weight-adjustment.patch
42 In the linear sampling gaussian blur calculation of offsets and
43 weights adjust the last weight as well as all others.
44
45 -- John S Gruber <JohnSGruber@gmail.com> Tue, 20 Aug 2013 14:40:43 -0400
46
1nux (4.0.2+13.10.20130816.2-0ubuntu1) saucy; urgency=low47nux (4.0.2+13.10.20130816.2-0ubuntu1) saucy; urgency=low
248
3 [ Stephen M. Webb ]49 [ Stephen M. Webb ]
450
=== added file 'debian/patches/02-ubuntu-ls-blur-return.patch'
--- debian/patches/02-ubuntu-ls-blur-return.patch 1970-01-01 00:00:00 +0000
+++ debian/patches/02-ubuntu-ls-blur-return.patch 2013-08-22 16:28:41 +0000
@@ -0,0 +1,17 @@
1Description: Return the length of the vectors so there is room in the shader
2 for all of them. This resolves an inconsistency between the
3 shader, shader setup and function return.
4Author: John S. Gruber <JohnSGruber@gmail.com>
5Index: lp-1167018/NuxGraphics/GraphicsEngine.cpp
6===================================================================
7--- lp-1167018.orig/NuxGraphics/GraphicsEngine.cpp 2013-06-21 14:27:15.234611000 -0400
8+++ lp-1167018/NuxGraphics/GraphicsEngine.cpp 2013-06-21 14:31:09.445907747 -0400
9@@ -1373,7 +1373,7 @@
10 weights[i] /= total;
11 }
12
13- return support;
14+ return (int) weights.size();
15 }
16
17 void GraphicsEngine::GaussianWeights(float **weights, float sigma, unsigned int num_tap)
018
=== added file 'debian/patches/03-ubuntu-ls-blur-max-program.patch'
--- debian/patches/03-ubuntu-ls-blur-max-program.patch 1970-01-01 00:00:00 +0000
+++ debian/patches/03-ubuntu-ls-blur-max-program.patch 2013-08-22 16:28:41 +0000
@@ -0,0 +1,143 @@
1Description: Use the sigma rather than the number of samples required when
2 calculating the place to store one of the two linear sampling
3 gaussian blur shader programs in the cache.
4 The number of cache locations is limited to 11 and the
5 number of samples required can easily exceed that.
6Author: John S. Gruber <JohnSGruber@gmail.com>
7--- a/NuxGraphics/RenderingPipeGLSL.cpp
8+++ b/NuxGraphics/RenderingPipeGLSL.cpp
9@@ -630,9 +630,9 @@
10 _vertical_hq_gauss_filter_prog[k-1]->Link();
11 }
12
13- void GraphicsEngine::InitSLHorizontalLSGaussFilter(int k)
14+ void GraphicsEngine::InitSLHorizontalLSGaussFilter(int k, int index)
15 {
16- if (_horizontal_ls_gauss_filter_prog[k-1].IsValid())
17+ if (_horizontal_ls_gauss_filter_prog[index].IsValid())
18 {
19 // Shader program already compiled
20 return;
21@@ -674,21 +674,21 @@
22 char* shader_prog = new char[l+10];
23 sprintf(shader_prog, ps_string.c_str(), k);
24
25- _horizontal_ls_gauss_filter_prog[k-1] = _graphics_display.m_DeviceFactory->CreateShaderProgram();
26+ _horizontal_ls_gauss_filter_prog[index] = _graphics_display.m_DeviceFactory->CreateShaderProgram();
27 vs->SetShaderCode(vs_string.c_str());
28 ps->SetShaderCode(shader_prog);
29 delete[] shader_prog;
30
31- _horizontal_ls_gauss_filter_prog[k-1]->ClearShaderObjects();
32- _horizontal_ls_gauss_filter_prog[k-1]->AddShaderObject(vs);
33- _horizontal_ls_gauss_filter_prog[k-1]->AddShaderObject(ps);
34- CHECKGL(glBindAttribLocation(_horizontal_ls_gauss_filter_prog[k-1]->GetOpenGLID(), 0, "vertex"));
35- _horizontal_ls_gauss_filter_prog[k-1]->Link();
36+ _horizontal_ls_gauss_filter_prog[index]->ClearShaderObjects();
37+ _horizontal_ls_gauss_filter_prog[index]->AddShaderObject(vs);
38+ _horizontal_ls_gauss_filter_prog[index]->AddShaderObject(ps);
39+ CHECKGL(glBindAttribLocation(_horizontal_ls_gauss_filter_prog[index]->GetOpenGLID(), 0, "vertex"));
40+ _horizontal_ls_gauss_filter_prog[index]->Link();
41 }
42
43- void GraphicsEngine::InitSLVerticalLSGaussFilter(int k)
44+ void GraphicsEngine::InitSLVerticalLSGaussFilter(int k, int index)
45 {
46- if (_vertical_ls_gauss_filter_prog[k-1].IsValid())
47+ if (_vertical_ls_gauss_filter_prog[index].IsValid())
48 {
49 // Shader program already compiled
50 return;
51@@ -730,16 +730,16 @@
52 char* shader_prog = new char[l+10];
53 sprintf(shader_prog, ps_string.c_str(), k);
54
55- _vertical_ls_gauss_filter_prog[k-1] = _graphics_display.m_DeviceFactory->CreateShaderProgram();
56+ _vertical_ls_gauss_filter_prog[index] = _graphics_display.m_DeviceFactory->CreateShaderProgram();
57 vs->SetShaderCode(vs_string.c_str());
58 ps->SetShaderCode(shader_prog);
59 delete[] shader_prog;
60
61- _vertical_ls_gauss_filter_prog[k-1]->ClearShaderObjects();
62- _vertical_ls_gauss_filter_prog[k-1]->AddShaderObject(vs);
63- _vertical_ls_gauss_filter_prog[k-1]->AddShaderObject(ps);
64- CHECKGL(glBindAttribLocation(_vertical_ls_gauss_filter_prog[k-1]->GetOpenGLID(), 0, "vertex"));
65- _vertical_ls_gauss_filter_prog[k-1]->Link();
66+ _vertical_ls_gauss_filter_prog[index]->ClearShaderObjects();
67+ _vertical_ls_gauss_filter_prog[index]->AddShaderObject(vs);
68+ _vertical_ls_gauss_filter_prog[index]->AddShaderObject(ps);
69+ CHECKGL(glBindAttribLocation(_vertical_ls_gauss_filter_prog[index]->GetOpenGLID(), 0, "vertex"));
70+ _vertical_ls_gauss_filter_prog[index]->Link();
71 }
72
73 void GraphicsEngine::InitSLColorMatrixFilter()
74@@ -2097,14 +2097,15 @@
75
76 void GraphicsEngine::QRP_GLSL_HorizontalLSGauss(int x, int y, int width, int height, ObjectPtr<IOpenGLBaseTexture> device_texture, TexCoordXForm &texxform0, const Color & /* c0 */, float sigma)
77 {
78+ int index = int(sigma) - 1;
79 std::vector<float> weights(0);
80 std::vector<float> offsets(0);
81
82 int num_samples = LinearSampleGaussianWeights(weights, offsets, sigma);
83
84- if (_horizontal_ls_gauss_filter_prog[num_samples-1].IsValid() == false)
85+ if (_horizontal_ls_gauss_filter_prog[index].IsValid() == false)
86 {
87- InitSLHorizontalLSGaussFilter(num_samples);
88+ InitSLHorizontalLSGaussFilter(num_samples, index);
89 }
90
91 m_quad_tex_stats++;
92@@ -2125,7 +2126,7 @@
93 return;
94 }
95
96- shader_prog = _horizontal_ls_gauss_filter_prog[num_samples-1];
97+ shader_prog = _horizontal_ls_gauss_filter_prog[index];
98
99 CHECKGL(glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0));
100 CHECKGL(glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0));
101@@ -2171,14 +2172,15 @@
102
103 void GraphicsEngine::QRP_GLSL_VerticalLSGauss(int x, int y, int width, int height, ObjectPtr<IOpenGLBaseTexture> device_texture, TexCoordXForm &texxform0, const Color & /* c0 */, float sigma)
104 {
105+ int index = int(sigma) - 1;
106 std::vector<float> weights(0);
107 std::vector<float> offsets(0);
108
109 int num_samples = LinearSampleGaussianWeights(weights, offsets, sigma);
110
111- if (_vertical_ls_gauss_filter_prog[num_samples-1].IsValid() == false)
112+ if (_vertical_ls_gauss_filter_prog[index].IsValid() == false)
113 {
114- InitSLVerticalLSGaussFilter(num_samples);
115+ InitSLVerticalLSGaussFilter(num_samples, index);
116 }
117
118 m_quad_tex_stats++;
119@@ -2199,7 +2201,7 @@
120 return;
121 }
122
123- shader_prog = _vertical_ls_gauss_filter_prog[num_samples-1];
124+ shader_prog = _vertical_ls_gauss_filter_prog[index];
125
126 CHECKGL(glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0));
127 CHECKGL(glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0));
128--- a/NuxGraphics/GraphicsEngine.h
129+++ b/NuxGraphics/GraphicsEngine.h
130@@ -1028,11 +1028,11 @@
131 //! Gauss vertical filter.
132 ObjectPtr<IOpenGLShaderProgram> _vertical_hq_gauss_filter_prog[NUX_MAX_GAUSSIAN_SIGMA];
133
134- void InitSLHorizontalLSGaussFilter(int k);
135+ void InitSLHorizontalLSGaussFilter(int k, int index);
136 //! Gauss horizontal filter.
137 ObjectPtr<IOpenGLShaderProgram> _horizontal_ls_gauss_filter_prog[NUX_MAX_GAUSSIAN_SIGMA];
138
139- void InitSLVerticalLSGaussFilter(int k);
140+ void InitSLVerticalLSGaussFilter(int k, int index);
141 //! Gauss vertical filter.
142 ObjectPtr<IOpenGLShaderProgram> _vertical_ls_gauss_filter_prog[NUX_MAX_GAUSSIAN_SIGMA];
143
0144
=== added file 'debian/patches/04-ubuntu-fix-ls-blur-weight-adjustment.patch'
--- debian/patches/04-ubuntu-fix-ls-blur-weight-adjustment.patch 1970-01-01 00:00:00 +0000
+++ debian/patches/04-ubuntu-fix-ls-blur-weight-adjustment.patch 2013-08-22 16:28:41 +0000
@@ -0,0 +1,14 @@
1Description: In the linear sampling gaussian blur calculation of offsets and
2 weights adjust the last weight as well as all others.
3Author: John S. Gruber <JohnSGruber@gmail.com>
4--- a/NuxGraphics/GraphicsEngine.cpp
5+++ b/NuxGraphics/GraphicsEngine.cpp
6@@ -1368,7 +1368,7 @@
7 }
8
9 //Normalise our weights.
10- for (int i = 0; i < support; i++)
11+ for (int i = 0; i <= support; i++)
12 {
13 weights[i] /= total;
14 }
015
=== added file 'debian/patches/06-ubuntu-simplify-ls-shaders.patch'
--- debian/patches/06-ubuntu-simplify-ls-shaders.patch 1970-01-01 00:00:00 +0000
+++ debian/patches/06-ubuntu-simplify-ls-shaders.patch 2013-08-22 16:28:41 +0000
@@ -0,0 +1,175 @@
1Description: Radically simplify (and generalize) the linear sampling gaussian
2 blur shader programs by calculating the coordinates normalized
3 by texture by width or height in the setup. Express these
4 as x,y vectors.
5
6 Apply them as simply as possible in the shader to save
7 shader instructions.
8
9 Also see that the offsets are given to the shader in
10 order, providing much improved locality of memory access.
11 This alone causes much time savings as the hardware
12 can have subsequent memory locations cached--which is impossible
13 when going from, e.g., texture coordinate (0,-9) directly to
14 (0, 9). Instead the order is (0, -9), (0, -8)...(0, 0), (0, 1)...
15 (0, 8), (0, 9).
16
17 Fixes lp: #1167018
18
19Bug: https://bugs.launchpad.net/ubuntu/+source/nux/+bug/1167018
20Author: John S. Gruber<JohnSGruber@gmail.com>
21--- a/NuxGraphics/RenderingPipeGLSL.cpp
22+++ b/NuxGraphics/RenderingPipeGLSL.cpp
23@@ -655,19 +655,15 @@
24 std::string ps_string = NUX_FRAGMENT_SHADER_HEADER
25 "varying vec4 v_tex_coord; \n\
26 uniform sampler2D tex_object; \n\
27- uniform vec2 tex_size; \n\
28 #define NUM_SAMPLES %d \n\
29- uniform float weights[NUM_SAMPLES]; \n\
30- uniform float offsets[NUM_SAMPLES]; \n\
31+ uniform vec3 blur_input[2*NUM_SAMPLES-1]; \n\
32 void main() \n\
33 { \n\
34- vec3 acc = texture2D(tex_object, v_tex_coord.st).rgb*weights[0];\n\
35- for (int i = 1; i < NUM_SAMPLES; i++) \n\
36+ gl_FragColor.rgba = vec4(0.0, 0.0, 0.0, 1.0); \n\
37+ for (int i = 0; i < 2*NUM_SAMPLES-1; i++) \n\
38 { \n\
39- acc += texture2D(tex_object, (v_tex_coord.st+(vec2(offsets[i], 0.0)/tex_size))).rgb*weights[i]; \n\
40- acc += texture2D(tex_object, (v_tex_coord.st-(vec2(offsets[i], 0.0)/tex_size))).rgb*weights[i]; \n\
41+ gl_FragColor.rgb += texture2D(tex_object, (v_tex_coord.st+blur_input[i].st)).rgb*blur_input[i].p; \n\
42 } \n\
43- gl_FragColor = vec4(acc, 1.0); \n\
44 }";
45
46 int l = ps_string.length();
47@@ -711,19 +707,15 @@
48 std::string ps_string = NUX_FRAGMENT_SHADER_HEADER
49 "varying vec4 v_tex_coord; \n\
50 uniform sampler2D tex_object; \n\
51- uniform vec2 tex_size; \n\
52 #define NUM_SAMPLES %d \n\
53- uniform float weights[NUM_SAMPLES]; \n\
54- uniform float offsets[NUM_SAMPLES]; \n\
55+ uniform vec3 blur_input[2*NUM_SAMPLES-1]; \n\
56 void main() \n\
57 { \n\
58- vec3 acc = texture2D(tex_object, v_tex_coord.st).rgb*weights[0]; \n\
59- for (int i = 1; i < NUM_SAMPLES; i++) \n\
60+ gl_FragColor.rgba = vec4(0.0, 0.0, 0.0, 1.0); \n\
61+ for (int i = 0; i < 2*NUM_SAMPLES-1; i++) \n\
62 { \n\
63- acc += texture2D(tex_object, (v_tex_coord.st+(vec2(0.0, offsets[i])/tex_size))).rgb*weights[i]; \n\
64- acc += texture2D(tex_object, (v_tex_coord.st-(vec2(0.0, offsets[i])/tex_size))).rgb*weights[i]; \n\
65+ gl_FragColor.rgb += texture2D(tex_object, (v_tex_coord.st+blur_input[i].st)).rgb*blur_input[i].p; \n\
66 } \n\
67- gl_FragColor = vec4(acc, 1.0); \n\
68 }";
69
70 int l = ps_string.length();
71@@ -2100,8 +2092,19 @@
72 int index = int(sigma) - 1;
73 std::vector<float> weights(0);
74 std::vector<float> offsets(0);
75-
76 int num_samples = LinearSampleGaussianWeights(weights, offsets, sigma);
77+ float *blur_input = new float [3*(2*num_samples - 1)];
78+ int base = num_samples - 1;
79+ for (int i=0; i < num_samples; i++)
80+ {
81+ offsets[i] /= width;
82+ blur_input[(base-i)*3+0] = -offsets[i];
83+ blur_input[(base-i)*3+1] = 0;
84+ blur_input[(base-i)*3+2] = weights[i];
85+ blur_input[(base+i)*3+0] = offsets[i];
86+ blur_input[(base+i)*3+1] = 0;
87+ blur_input[(base+i)*3+2] = weights[i];
88+ }
89
90 if (_horizontal_ls_gauss_filter_prog[index].IsValid() == false)
91 {
92@@ -2133,19 +2138,13 @@
93 shader_prog->Begin();
94
95 int tex_object_location = shader_prog->GetUniformLocationARB("tex_object");
96- int weights_location = shader_prog->GetUniformLocationARB("weights");
97- int offsets_location = shader_prog->GetUniformLocationARB("offsets");
98- int tex_size_location = shader_prog->GetUniformLocationARB("tex_size");
99+ int blur_input_location = shader_prog->GetUniformLocationARB("blur_input");
100 int vertex_location = shader_prog->GetAttributeLocation("vertex");
101 int tex_coord_location = shader_prog->GetAttributeLocation("tex_coord");
102
103 SetTexture(GL_TEXTURE0, device_texture);
104 CHECKGL(glUniform1iARB(tex_object_location, 0));
105-
106- CHECKGL(glUniform1fv(weights_location, weights.size(), &weights[0]));
107- CHECKGL(glUniform1fv(offsets_location, offsets.size(), &offsets[0]));
108-
109- CHECKGL(glUniform2fARB(tex_size_location, width, height));
110+ CHECKGL(glUniform3fv(blur_input_location, 2*num_samples - 1, &blur_input[0]));
111
112 int VPMatrixLocation = shader_prog->GetUniformLocationARB("view_projection_matrix");
113 Matrix4 MVPMatrix = GetOpenGLModelViewProjectionMatrix();
114@@ -2168,6 +2167,8 @@
115 CHECKGL(glDisableVertexAttribArrayARB(tex_coord_location));
116
117 shader_prog->End();
118+ delete [] blur_input;
119+ blur_input = NULL;
120 }
121
122 void GraphicsEngine::QRP_GLSL_VerticalLSGauss(int x, int y, int width, int height, ObjectPtr<IOpenGLBaseTexture> device_texture, TexCoordXForm &texxform0, const Color & /* c0 */, float sigma)
123@@ -2175,8 +2176,19 @@
124 int index = int(sigma) - 1;
125 std::vector<float> weights(0);
126 std::vector<float> offsets(0);
127-
128 int num_samples = LinearSampleGaussianWeights(weights, offsets, sigma);
129+ float *blur_input = new float [3*(2*num_samples - 1)];
130+ int base = num_samples - 1;
131+ for (int i=0; i < num_samples; i++)
132+ {
133+ offsets[i] /= height;
134+ blur_input[(base-i)*3+0] = 0;
135+ blur_input[(base-i)*3+1] = -offsets[i];
136+ blur_input[(base-i)*3+2] = weights[i];
137+ blur_input[(base+i)*3+0] = 0;
138+ blur_input[(base+i)*3+1] = offsets[i];
139+ blur_input[(base+i)*3+2] = weights[i];
140+ }
141
142 if (_vertical_ls_gauss_filter_prog[index].IsValid() == false)
143 {
144@@ -2208,20 +2222,14 @@
145 shader_prog->Begin();
146
147 int tex_object_location = shader_prog->GetUniformLocationARB("tex_object");
148- int weights_location = shader_prog->GetUniformLocationARB("weights");
149- int offsets_location = shader_prog->GetUniformLocationARB("offsets");
150- int tex_size_location = shader_prog->GetUniformLocationARB("tex_size");
151+ int blur_input_location = shader_prog->GetUniformLocationARB("blur_input");
152 int vertex_location = shader_prog->GetAttributeLocation("vertex");
153 int tex_coord_location = shader_prog->GetAttributeLocation("tex_coord");
154
155 SetTexture(GL_TEXTURE0, device_texture);
156
157 CHECKGL(glUniform1iARB(tex_object_location, 0));
158-
159- CHECKGL(glUniform1fv(weights_location, weights.size(), &weights[0]));
160- CHECKGL(glUniform1fv(offsets_location, offsets.size(), &offsets[0]));
161-
162- CHECKGL(glUniform2fARB(tex_size_location, width, height));
163+ CHECKGL(glUniform3fv(blur_input_location, 2*num_samples - 1, &blur_input[0]));
164
165 int VPMatrixLocation = shader_prog->GetUniformLocationARB("view_projection_matrix");
166 Matrix4 MVPMatrix = GetOpenGLModelViewProjectionMatrix();
167@@ -2244,6 +2252,8 @@
168 CHECKGL(glDisableVertexAttribArrayARB(tex_coord_location));
169
170 shader_prog->End();
171+ delete [] blur_input;
172+ blur_input = NULL;
173 }
174
175 void GraphicsEngine::QRP_GLSL_ColorMatrix(int x, int y, int width, int height, ObjectPtr<IOpenGLBaseTexture> device_texture, TexCoordXForm &texxform0,
0176
=== modified file 'debian/patches/series'
--- debian/patches/series 2012-08-01 16:09:01 +0000
+++ debian/patches/series 2013-08-22 16:28:41 +0000
@@ -1,1 +1,5 @@
101_blacklist_llvmpipe.patch101_blacklist_llvmpipe.patch
202-ubuntu-ls-blur-return.patch
303-ubuntu-ls-blur-max-program.patch
404-ubuntu-fix-ls-blur-weight-adjustment.patch
506-ubuntu-simplify-ls-shaders.patch

Subscribers

People subscribed via source and target branches