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
1=== modified file 'debian/changelog'
2--- debian/changelog 2013-08-16 10:34:41 +0000
3+++ debian/changelog 2013-08-22 16:28:41 +0000
4@@ -1,3 +1,49 @@
5+nux (4.0.2+13.10.20130816.2-0ubuntu2~jgu002) saucy; urgency=low
6+
7+ * debian/patches/06-ubuntu-simplify-ls-shaders.patch :
8+ Radically simplify (and generalize) the linear sampling gaussian
9+ blur shader programs by calculating the coordinates normalized
10+ by texture by width or height in the setup. Express these
11+ as x,y vectors.
12+
13+ Apply them as simply as possible in the shader to save
14+ shader instructions.
15+
16+ Also see that the offsets are given to the shader in
17+ order, providing much improved locality of memory access.
18+ This alone causes much time savings as the hardware
19+ can have subsequent memory locations cached--which is impossible
20+ when going from, e.g., texture coordinate (0,-9) directly to
21+ (0, 9). Instead the order is (0, -9), (0, -8)...(0, 0), (0, 1)...
22+ (0, 8), (0, 9).
23+
24+ Fixes lp: #1167018
25+
26+ -- John S Gruber <JohnSGruber@gmail.com> Tue, 20 Aug 2013 17:49:11 -0400
27+
28+nux (4.0.2+13.10.20130816.2-0ubuntu2~jgu001) saucy; urgency=low
29+
30+ * Add three patches to debian/patches to resolve problems related to LS
31+ blurring:
32+
33+ 02-ubuntu-ls-blur-return.patch
34+ Return the length of the vectors so there is room in the shader
35+ for all of them. This resolves an inconsistency between the
36+ shader, shader setup and function return.
37+
38+ 03-ubuntu-ls-blur-max-program.patch
39+ Use the sigma rather than the number of samples required when
40+ calculating the place to store one of the two linear sampling
41+ gaussian blur shader programs in the cache.
42+ The number of cache locations is limited to 11 and the
43+ number of samples required can easily exceed that.
44+
45+ 04-ubuntu-fix-ls-blur-weight-adjustment.patch
46+ In the linear sampling gaussian blur calculation of offsets and
47+ weights adjust the last weight as well as all others.
48+
49+ -- John S Gruber <JohnSGruber@gmail.com> Tue, 20 Aug 2013 14:40:43 -0400
50+
51 nux (4.0.2+13.10.20130816.2-0ubuntu1) saucy; urgency=low
52
53 [ Stephen M. Webb ]
54
55=== added file 'debian/patches/02-ubuntu-ls-blur-return.patch'
56--- debian/patches/02-ubuntu-ls-blur-return.patch 1970-01-01 00:00:00 +0000
57+++ debian/patches/02-ubuntu-ls-blur-return.patch 2013-08-22 16:28:41 +0000
58@@ -0,0 +1,17 @@
59+Description: Return the length of the vectors so there is room in the shader
60+ for all of them. This resolves an inconsistency between the
61+ shader, shader setup and function return.
62+Author: John S. Gruber <JohnSGruber@gmail.com>
63+Index: lp-1167018/NuxGraphics/GraphicsEngine.cpp
64+===================================================================
65+--- lp-1167018.orig/NuxGraphics/GraphicsEngine.cpp 2013-06-21 14:27:15.234611000 -0400
66++++ lp-1167018/NuxGraphics/GraphicsEngine.cpp 2013-06-21 14:31:09.445907747 -0400
67+@@ -1373,7 +1373,7 @@
68+ weights[i] /= total;
69+ }
70+
71+- return support;
72++ return (int) weights.size();
73+ }
74+
75+ void GraphicsEngine::GaussianWeights(float **weights, float sigma, unsigned int num_tap)
76
77=== added file 'debian/patches/03-ubuntu-ls-blur-max-program.patch'
78--- debian/patches/03-ubuntu-ls-blur-max-program.patch 1970-01-01 00:00:00 +0000
79+++ debian/patches/03-ubuntu-ls-blur-max-program.patch 2013-08-22 16:28:41 +0000
80@@ -0,0 +1,143 @@
81+Description: Use the sigma rather than the number of samples required when
82+ calculating the place to store one of the two linear sampling
83+ gaussian blur shader programs in the cache.
84+ The number of cache locations is limited to 11 and the
85+ number of samples required can easily exceed that.
86+Author: John S. Gruber <JohnSGruber@gmail.com>
87+--- a/NuxGraphics/RenderingPipeGLSL.cpp
88++++ b/NuxGraphics/RenderingPipeGLSL.cpp
89+@@ -630,9 +630,9 @@
90+ _vertical_hq_gauss_filter_prog[k-1]->Link();
91+ }
92+
93+- void GraphicsEngine::InitSLHorizontalLSGaussFilter(int k)
94++ void GraphicsEngine::InitSLHorizontalLSGaussFilter(int k, int index)
95+ {
96+- if (_horizontal_ls_gauss_filter_prog[k-1].IsValid())
97++ if (_horizontal_ls_gauss_filter_prog[index].IsValid())
98+ {
99+ // Shader program already compiled
100+ return;
101+@@ -674,21 +674,21 @@
102+ char* shader_prog = new char[l+10];
103+ sprintf(shader_prog, ps_string.c_str(), k);
104+
105+- _horizontal_ls_gauss_filter_prog[k-1] = _graphics_display.m_DeviceFactory->CreateShaderProgram();
106++ _horizontal_ls_gauss_filter_prog[index] = _graphics_display.m_DeviceFactory->CreateShaderProgram();
107+ vs->SetShaderCode(vs_string.c_str());
108+ ps->SetShaderCode(shader_prog);
109+ delete[] shader_prog;
110+
111+- _horizontal_ls_gauss_filter_prog[k-1]->ClearShaderObjects();
112+- _horizontal_ls_gauss_filter_prog[k-1]->AddShaderObject(vs);
113+- _horizontal_ls_gauss_filter_prog[k-1]->AddShaderObject(ps);
114+- CHECKGL(glBindAttribLocation(_horizontal_ls_gauss_filter_prog[k-1]->GetOpenGLID(), 0, "vertex"));
115+- _horizontal_ls_gauss_filter_prog[k-1]->Link();
116++ _horizontal_ls_gauss_filter_prog[index]->ClearShaderObjects();
117++ _horizontal_ls_gauss_filter_prog[index]->AddShaderObject(vs);
118++ _horizontal_ls_gauss_filter_prog[index]->AddShaderObject(ps);
119++ CHECKGL(glBindAttribLocation(_horizontal_ls_gauss_filter_prog[index]->GetOpenGLID(), 0, "vertex"));
120++ _horizontal_ls_gauss_filter_prog[index]->Link();
121+ }
122+
123+- void GraphicsEngine::InitSLVerticalLSGaussFilter(int k)
124++ void GraphicsEngine::InitSLVerticalLSGaussFilter(int k, int index)
125+ {
126+- if (_vertical_ls_gauss_filter_prog[k-1].IsValid())
127++ if (_vertical_ls_gauss_filter_prog[index].IsValid())
128+ {
129+ // Shader program already compiled
130+ return;
131+@@ -730,16 +730,16 @@
132+ char* shader_prog = new char[l+10];
133+ sprintf(shader_prog, ps_string.c_str(), k);
134+
135+- _vertical_ls_gauss_filter_prog[k-1] = _graphics_display.m_DeviceFactory->CreateShaderProgram();
136++ _vertical_ls_gauss_filter_prog[index] = _graphics_display.m_DeviceFactory->CreateShaderProgram();
137+ vs->SetShaderCode(vs_string.c_str());
138+ ps->SetShaderCode(shader_prog);
139+ delete[] shader_prog;
140+
141+- _vertical_ls_gauss_filter_prog[k-1]->ClearShaderObjects();
142+- _vertical_ls_gauss_filter_prog[k-1]->AddShaderObject(vs);
143+- _vertical_ls_gauss_filter_prog[k-1]->AddShaderObject(ps);
144+- CHECKGL(glBindAttribLocation(_vertical_ls_gauss_filter_prog[k-1]->GetOpenGLID(), 0, "vertex"));
145+- _vertical_ls_gauss_filter_prog[k-1]->Link();
146++ _vertical_ls_gauss_filter_prog[index]->ClearShaderObjects();
147++ _vertical_ls_gauss_filter_prog[index]->AddShaderObject(vs);
148++ _vertical_ls_gauss_filter_prog[index]->AddShaderObject(ps);
149++ CHECKGL(glBindAttribLocation(_vertical_ls_gauss_filter_prog[index]->GetOpenGLID(), 0, "vertex"));
150++ _vertical_ls_gauss_filter_prog[index]->Link();
151+ }
152+
153+ void GraphicsEngine::InitSLColorMatrixFilter()
154+@@ -2097,14 +2097,15 @@
155+
156+ void GraphicsEngine::QRP_GLSL_HorizontalLSGauss(int x, int y, int width, int height, ObjectPtr<IOpenGLBaseTexture> device_texture, TexCoordXForm &texxform0, const Color & /* c0 */, float sigma)
157+ {
158++ int index = int(sigma) - 1;
159+ std::vector<float> weights(0);
160+ std::vector<float> offsets(0);
161+
162+ int num_samples = LinearSampleGaussianWeights(weights, offsets, sigma);
163+
164+- if (_horizontal_ls_gauss_filter_prog[num_samples-1].IsValid() == false)
165++ if (_horizontal_ls_gauss_filter_prog[index].IsValid() == false)
166+ {
167+- InitSLHorizontalLSGaussFilter(num_samples);
168++ InitSLHorizontalLSGaussFilter(num_samples, index);
169+ }
170+
171+ m_quad_tex_stats++;
172+@@ -2125,7 +2126,7 @@
173+ return;
174+ }
175+
176+- shader_prog = _horizontal_ls_gauss_filter_prog[num_samples-1];
177++ shader_prog = _horizontal_ls_gauss_filter_prog[index];
178+
179+ CHECKGL(glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0));
180+ CHECKGL(glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0));
181+@@ -2171,14 +2172,15 @@
182+
183+ void GraphicsEngine::QRP_GLSL_VerticalLSGauss(int x, int y, int width, int height, ObjectPtr<IOpenGLBaseTexture> device_texture, TexCoordXForm &texxform0, const Color & /* c0 */, float sigma)
184+ {
185++ int index = int(sigma) - 1;
186+ std::vector<float> weights(0);
187+ std::vector<float> offsets(0);
188+
189+ int num_samples = LinearSampleGaussianWeights(weights, offsets, sigma);
190+
191+- if (_vertical_ls_gauss_filter_prog[num_samples-1].IsValid() == false)
192++ if (_vertical_ls_gauss_filter_prog[index].IsValid() == false)
193+ {
194+- InitSLVerticalLSGaussFilter(num_samples);
195++ InitSLVerticalLSGaussFilter(num_samples, index);
196+ }
197+
198+ m_quad_tex_stats++;
199+@@ -2199,7 +2201,7 @@
200+ return;
201+ }
202+
203+- shader_prog = _vertical_ls_gauss_filter_prog[num_samples-1];
204++ shader_prog = _vertical_ls_gauss_filter_prog[index];
205+
206+ CHECKGL(glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0));
207+ CHECKGL(glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0));
208+--- a/NuxGraphics/GraphicsEngine.h
209++++ b/NuxGraphics/GraphicsEngine.h
210+@@ -1028,11 +1028,11 @@
211+ //! Gauss vertical filter.
212+ ObjectPtr<IOpenGLShaderProgram> _vertical_hq_gauss_filter_prog[NUX_MAX_GAUSSIAN_SIGMA];
213+
214+- void InitSLHorizontalLSGaussFilter(int k);
215++ void InitSLHorizontalLSGaussFilter(int k, int index);
216+ //! Gauss horizontal filter.
217+ ObjectPtr<IOpenGLShaderProgram> _horizontal_ls_gauss_filter_prog[NUX_MAX_GAUSSIAN_SIGMA];
218+
219+- void InitSLVerticalLSGaussFilter(int k);
220++ void InitSLVerticalLSGaussFilter(int k, int index);
221+ //! Gauss vertical filter.
222+ ObjectPtr<IOpenGLShaderProgram> _vertical_ls_gauss_filter_prog[NUX_MAX_GAUSSIAN_SIGMA];
223+
224
225=== added file 'debian/patches/04-ubuntu-fix-ls-blur-weight-adjustment.patch'
226--- debian/patches/04-ubuntu-fix-ls-blur-weight-adjustment.patch 1970-01-01 00:00:00 +0000
227+++ debian/patches/04-ubuntu-fix-ls-blur-weight-adjustment.patch 2013-08-22 16:28:41 +0000
228@@ -0,0 +1,14 @@
229+Description: In the linear sampling gaussian blur calculation of offsets and
230+ weights adjust the last weight as well as all others.
231+Author: John S. Gruber <JohnSGruber@gmail.com>
232+--- a/NuxGraphics/GraphicsEngine.cpp
233++++ b/NuxGraphics/GraphicsEngine.cpp
234+@@ -1368,7 +1368,7 @@
235+ }
236+
237+ //Normalise our weights.
238+- for (int i = 0; i < support; i++)
239++ for (int i = 0; i <= support; i++)
240+ {
241+ weights[i] /= total;
242+ }
243
244=== added file 'debian/patches/06-ubuntu-simplify-ls-shaders.patch'
245--- debian/patches/06-ubuntu-simplify-ls-shaders.patch 1970-01-01 00:00:00 +0000
246+++ debian/patches/06-ubuntu-simplify-ls-shaders.patch 2013-08-22 16:28:41 +0000
247@@ -0,0 +1,175 @@
248+Description: Radically simplify (and generalize) the linear sampling gaussian
249+ blur shader programs by calculating the coordinates normalized
250+ by texture by width or height in the setup. Express these
251+ as x,y vectors.
252+
253+ Apply them as simply as possible in the shader to save
254+ shader instructions.
255+
256+ Also see that the offsets are given to the shader in
257+ order, providing much improved locality of memory access.
258+ This alone causes much time savings as the hardware
259+ can have subsequent memory locations cached--which is impossible
260+ when going from, e.g., texture coordinate (0,-9) directly to
261+ (0, 9). Instead the order is (0, -9), (0, -8)...(0, 0), (0, 1)...
262+ (0, 8), (0, 9).
263+
264+ Fixes lp: #1167018
265+
266+Bug: https://bugs.launchpad.net/ubuntu/+source/nux/+bug/1167018
267+Author: John S. Gruber<JohnSGruber@gmail.com>
268+--- a/NuxGraphics/RenderingPipeGLSL.cpp
269++++ b/NuxGraphics/RenderingPipeGLSL.cpp
270+@@ -655,19 +655,15 @@
271+ std::string ps_string = NUX_FRAGMENT_SHADER_HEADER
272+ "varying vec4 v_tex_coord; \n\
273+ uniform sampler2D tex_object; \n\
274+- uniform vec2 tex_size; \n\
275+ #define NUM_SAMPLES %d \n\
276+- uniform float weights[NUM_SAMPLES]; \n\
277+- uniform float offsets[NUM_SAMPLES]; \n\
278++ uniform vec3 blur_input[2*NUM_SAMPLES-1]; \n\
279+ void main() \n\
280+ { \n\
281+- vec3 acc = texture2D(tex_object, v_tex_coord.st).rgb*weights[0];\n\
282+- for (int i = 1; i < NUM_SAMPLES; i++) \n\
283++ gl_FragColor.rgba = vec4(0.0, 0.0, 0.0, 1.0); \n\
284++ for (int i = 0; i < 2*NUM_SAMPLES-1; i++) \n\
285+ { \n\
286+- acc += texture2D(tex_object, (v_tex_coord.st+(vec2(offsets[i], 0.0)/tex_size))).rgb*weights[i]; \n\
287+- acc += texture2D(tex_object, (v_tex_coord.st-(vec2(offsets[i], 0.0)/tex_size))).rgb*weights[i]; \n\
288++ gl_FragColor.rgb += texture2D(tex_object, (v_tex_coord.st+blur_input[i].st)).rgb*blur_input[i].p; \n\
289+ } \n\
290+- gl_FragColor = vec4(acc, 1.0); \n\
291+ }";
292+
293+ int l = ps_string.length();
294+@@ -711,19 +707,15 @@
295+ std::string ps_string = NUX_FRAGMENT_SHADER_HEADER
296+ "varying vec4 v_tex_coord; \n\
297+ uniform sampler2D tex_object; \n\
298+- uniform vec2 tex_size; \n\
299+ #define NUM_SAMPLES %d \n\
300+- uniform float weights[NUM_SAMPLES]; \n\
301+- uniform float offsets[NUM_SAMPLES]; \n\
302++ uniform vec3 blur_input[2*NUM_SAMPLES-1]; \n\
303+ void main() \n\
304+ { \n\
305+- vec3 acc = texture2D(tex_object, v_tex_coord.st).rgb*weights[0]; \n\
306+- for (int i = 1; i < NUM_SAMPLES; i++) \n\
307++ gl_FragColor.rgba = vec4(0.0, 0.0, 0.0, 1.0); \n\
308++ for (int i = 0; i < 2*NUM_SAMPLES-1; i++) \n\
309+ { \n\
310+- acc += texture2D(tex_object, (v_tex_coord.st+(vec2(0.0, offsets[i])/tex_size))).rgb*weights[i]; \n\
311+- acc += texture2D(tex_object, (v_tex_coord.st-(vec2(0.0, offsets[i])/tex_size))).rgb*weights[i]; \n\
312++ gl_FragColor.rgb += texture2D(tex_object, (v_tex_coord.st+blur_input[i].st)).rgb*blur_input[i].p; \n\
313+ } \n\
314+- gl_FragColor = vec4(acc, 1.0); \n\
315+ }";
316+
317+ int l = ps_string.length();
318+@@ -2100,8 +2092,19 @@
319+ int index = int(sigma) - 1;
320+ std::vector<float> weights(0);
321+ std::vector<float> offsets(0);
322+-
323+ int num_samples = LinearSampleGaussianWeights(weights, offsets, sigma);
324++ float *blur_input = new float [3*(2*num_samples - 1)];
325++ int base = num_samples - 1;
326++ for (int i=0; i < num_samples; i++)
327++ {
328++ offsets[i] /= width;
329++ blur_input[(base-i)*3+0] = -offsets[i];
330++ blur_input[(base-i)*3+1] = 0;
331++ blur_input[(base-i)*3+2] = weights[i];
332++ blur_input[(base+i)*3+0] = offsets[i];
333++ blur_input[(base+i)*3+1] = 0;
334++ blur_input[(base+i)*3+2] = weights[i];
335++ }
336+
337+ if (_horizontal_ls_gauss_filter_prog[index].IsValid() == false)
338+ {
339+@@ -2133,19 +2138,13 @@
340+ shader_prog->Begin();
341+
342+ int tex_object_location = shader_prog->GetUniformLocationARB("tex_object");
343+- int weights_location = shader_prog->GetUniformLocationARB("weights");
344+- int offsets_location = shader_prog->GetUniformLocationARB("offsets");
345+- int tex_size_location = shader_prog->GetUniformLocationARB("tex_size");
346++ int blur_input_location = shader_prog->GetUniformLocationARB("blur_input");
347+ int vertex_location = shader_prog->GetAttributeLocation("vertex");
348+ int tex_coord_location = shader_prog->GetAttributeLocation("tex_coord");
349+
350+ SetTexture(GL_TEXTURE0, device_texture);
351+ CHECKGL(glUniform1iARB(tex_object_location, 0));
352+-
353+- CHECKGL(glUniform1fv(weights_location, weights.size(), &weights[0]));
354+- CHECKGL(glUniform1fv(offsets_location, offsets.size(), &offsets[0]));
355+-
356+- CHECKGL(glUniform2fARB(tex_size_location, width, height));
357++ CHECKGL(glUniform3fv(blur_input_location, 2*num_samples - 1, &blur_input[0]));
358+
359+ int VPMatrixLocation = shader_prog->GetUniformLocationARB("view_projection_matrix");
360+ Matrix4 MVPMatrix = GetOpenGLModelViewProjectionMatrix();
361+@@ -2168,6 +2167,8 @@
362+ CHECKGL(glDisableVertexAttribArrayARB(tex_coord_location));
363+
364+ shader_prog->End();
365++ delete [] blur_input;
366++ blur_input = NULL;
367+ }
368+
369+ void GraphicsEngine::QRP_GLSL_VerticalLSGauss(int x, int y, int width, int height, ObjectPtr<IOpenGLBaseTexture> device_texture, TexCoordXForm &texxform0, const Color & /* c0 */, float sigma)
370+@@ -2175,8 +2176,19 @@
371+ int index = int(sigma) - 1;
372+ std::vector<float> weights(0);
373+ std::vector<float> offsets(0);
374+-
375+ int num_samples = LinearSampleGaussianWeights(weights, offsets, sigma);
376++ float *blur_input = new float [3*(2*num_samples - 1)];
377++ int base = num_samples - 1;
378++ for (int i=0; i < num_samples; i++)
379++ {
380++ offsets[i] /= height;
381++ blur_input[(base-i)*3+0] = 0;
382++ blur_input[(base-i)*3+1] = -offsets[i];
383++ blur_input[(base-i)*3+2] = weights[i];
384++ blur_input[(base+i)*3+0] = 0;
385++ blur_input[(base+i)*3+1] = offsets[i];
386++ blur_input[(base+i)*3+2] = weights[i];
387++ }
388+
389+ if (_vertical_ls_gauss_filter_prog[index].IsValid() == false)
390+ {
391+@@ -2208,20 +2222,14 @@
392+ shader_prog->Begin();
393+
394+ int tex_object_location = shader_prog->GetUniformLocationARB("tex_object");
395+- int weights_location = shader_prog->GetUniformLocationARB("weights");
396+- int offsets_location = shader_prog->GetUniformLocationARB("offsets");
397+- int tex_size_location = shader_prog->GetUniformLocationARB("tex_size");
398++ int blur_input_location = shader_prog->GetUniformLocationARB("blur_input");
399+ int vertex_location = shader_prog->GetAttributeLocation("vertex");
400+ int tex_coord_location = shader_prog->GetAttributeLocation("tex_coord");
401+
402+ SetTexture(GL_TEXTURE0, device_texture);
403+
404+ CHECKGL(glUniform1iARB(tex_object_location, 0));
405+-
406+- CHECKGL(glUniform1fv(weights_location, weights.size(), &weights[0]));
407+- CHECKGL(glUniform1fv(offsets_location, offsets.size(), &offsets[0]));
408+-
409+- CHECKGL(glUniform2fARB(tex_size_location, width, height));
410++ CHECKGL(glUniform3fv(blur_input_location, 2*num_samples - 1, &blur_input[0]));
411+
412+ int VPMatrixLocation = shader_prog->GetUniformLocationARB("view_projection_matrix");
413+ Matrix4 MVPMatrix = GetOpenGLModelViewProjectionMatrix();
414+@@ -2244,6 +2252,8 @@
415+ CHECKGL(glDisableVertexAttribArrayARB(tex_coord_location));
416+
417+ shader_prog->End();
418++ delete [] blur_input;
419++ blur_input = NULL;
420+ }
421+
422+ void GraphicsEngine::QRP_GLSL_ColorMatrix(int x, int y, int width, int height, ObjectPtr<IOpenGLBaseTexture> device_texture, TexCoordXForm &texxform0,
423
424=== modified file 'debian/patches/series'
425--- debian/patches/series 2012-08-01 16:09:01 +0000
426+++ debian/patches/series 2013-08-22 16:28:41 +0000
427@@ -1,1 +1,5 @@
428 01_blacklist_llvmpipe.patch
429+02-ubuntu-ls-blur-return.patch
430+03-ubuntu-ls-blur-max-program.patch
431+04-ubuntu-fix-ls-blur-weight-adjustment.patch
432+06-ubuntu-simplify-ls-shaders.patch

Subscribers

People subscribed via source and target branches