Merge lp:~gebner/compiz/compiz.vertexbuffer-autoprogram-uniform-segfault into lp:compiz/0.9.9

Proposed by Gabriel Ebner
Status: Superseded
Proposed branch: lp:~gebner/compiz/compiz.vertexbuffer-autoprogram-uniform-segfault
Merge into: lp:compiz/0.9.9
Diff against target: 12 lines (+1/-1)
1 file modified
plugins/opengl/src/vertexbuffer.cpp (+1/-1)
To merge this branch: bzr merge lp:~gebner/compiz/compiz.vertexbuffer-autoprogram-uniform-segfault
Reviewer Review Type Date Requested Status
Daniel van Vugt Needs Resubmitting
Sam Spilsbury Approve
Review via email: mp+156313@code.launchpad.net

This proposal has been superseded by a proposal from 2013-04-02.

Commit message

Adding a uniform to a GLVertexBuffer that uses AutoProgram causes compiz to segfault.

Example:
  gWindow->addShaders("cms", "", fragment_shader);
  gWindow->vertexBuffer()->addUniform("cms_lut", unit);
  // segfault happens later in PrivateVertexBuffer::render

The patch modifies PrivateVertexBuffer::render to set the uniform on the generated AutoProgram instead of the provided program, which in this case is NULL, causing a segfault.

(LP: #1162598)

Description of the change

Adding a uniform to a GLVertexBuffer that uses AutoProgram causes compiz to segfault.

Example:
  gWindow->addShaders("cms", "", fragment_shader);
  gWindow->vertexBuffer()->addUniform("cms_lut", unit);
  // segfault happens later in PrivateVertexBuffer::render

The patch modifies PrivateVertexBuffer::render to set the uniform on the generated AutoProgram instead of the provided program, which in this case is NULL, causing a segfault.

This feature is used in a plugin for full-screen color management, compiz-cms[1], where the unit of a color transformation texture is passed as a uniform.

[1] https://github.com/gebner/compiz-cms

To post a comment you must log in.
Revision history for this message
Sam Spilsbury (smspillaz) wrote :

This makes sense, thanks.

This reminds me that I need to fix the VertexBuffer class to behave in a more sane way when it comes to having no active program set. At the moment it just crashes if you don't call setProgram or setAutoProgram. I remember I wanted to enforce something in its constructor, but at the time didn't want to break ABI. I've filed bug 1162597 about that.

One more thing before we merge this - can you add commit metadata to link this to a bug? I didn't see anything, so I've filed bug 1162598. You can link it by doing this:

bzr commit --empty --fixes lp:1162598
bzr push

On another note, nice work with the color management plugin. If you want it to be included in-tree, just file a bug about it on launchpad and we'll do the paperwork to get it in.

review: Approve
3645. By Gabriel Ebner

(LP: #1162598). Fixes: https://bugs.launchpad.net/bugs/1162598.

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

Please re-target this for lp:compiz/0.9.10

review: Needs Resubmitting

Unmerged revisions

3645. By Gabriel Ebner

(LP: #1162598). Fixes: https://bugs.launchpad.net/bugs/1162598.

3644. By Gabriel Ebner

OpenGL plugin:
Allow uniforms for automatically generated programs in
PrivateVertexBuffer::render.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/opengl/src/vertexbuffer.cpp'
2--- plugins/opengl/src/vertexbuffer.cpp 2012-11-04 16:15:51 +0000
3+++ plugins/opengl/src/vertexbuffer.cpp 2013-04-01 06:33:19 +0000
4@@ -523,7 +523,7 @@
5 // set per-plugin uniforms
6 for (unsigned int i = 0; i < uniforms.size (); i++)
7 {
8- uniforms[i]->set (program);
9+ uniforms[i]->set (tmpProgram);
10 }
11
12 //convert paint attribs to 0-1 range

Subscribers

People subscribed via source and target branches