Add support for generating shaders at runtime
Review Request #120280 - Created Sept. 22, 2014 and submitted
This makes kwin generate shaders on-demand that are optimized for the current rendering operation.
It is possible that this will break assumptions in some effects. For example I noticed that the cube effect relied on paintWindow() using the generic vertex shader without setting the shader in WindowPaintData.
The projection matrix used by the generated shaders is always a perspective matrix, since there is no performance advantage to using an orhtographic matrix. The perspective matrix produces the same result as the orthographic matrix when the Z-coordinate is zero. The matrix is now also set by paintWindow(), so effects can no longer change the matrix uniforms directly before they call paintWindow(). Instead I've added a projection and a model-view matrix in WindowPaintData.
This also fixes a long standing bug; when you activate the cube effect and a taskbar thumbnail is visible, the cube transformation is no longer applied to the thumbnail image.
This series is also available in the dynamic-shaders branch in my kwin clone.
|I suggest to add unit tests to verify that the generated shader source looks as expected||Martin Flöser|
One thing I forgot to mention is that the new API supports generating shaders that use GL_TEXTURE_RECTANGLE instead of GL_TEXTURE_2D.
KWin currently doesn't use rectangular textures, so I'm not sure if we actually want this.
- Do rendering tests with each generated shader to verify that it works as expected.
Bringing up the GL backend in a unit test opens up a can of worms I don't particularly feel like dealing
with, so the tests are performed during startup instead. The downside is that all shaders are now
compiled when compositing is initialized instead of on demand.
- Remove the support for rectangular textures.
- Rename some variables and enums.
Revision 2 (+627 -92)