I have continued working on color correction support in KWin. Last week we had the first results that have visible effects on how things look, but of course, at the moment, this is rather about color incorrection than correction. Now, it is possible to accelerate development and move on to other areas.
To make CC possible, KWin’s shaders needed to be altered. More specifically, the fragment shaders. In order to do this, their source code is intercepted before sending to the graphics card for compilation, and a couple of lines are inserted in the appropriate places. There is a special algorithm for parsing the sources, and if it finds anything fishy, it abandons making any changes to the shader source. However, it should be robust enough to handle any valid GLSL 1.2 fragment shader thrown at it.
There are no big modifications to KWin’s rendering process. The only ones are the painting split for multiple screens inside SceneOpenGL::Window::performPaint(), mentioned in the previous posts.
The code related to CC will be organized in a separate class, and enabling or disabling it will be possible at compile time, and on runtime (from one of KWin’s KCM). Now I am working on refurbishing these latest modifications and making the enabling and disabling possible.
Soon work will start on the KDED module (color server) that should do most of the hard work involved with CC.
Last week wasn’t the most productive of all, since time spent on the graduation project induced some delays, but here’s what I did:
Implemented the new approach with the painting split in performPaint() very quickly. It appears to be working, but for now I am not able to test it properly. I did try to disable one of the screens, and the results were as expected (no further paints on it).
Next stage is to modify the shaders so they will do the color correction. The most robust solution is to inject a couple of lines in the shader code, just before sending it to the graphics card for compilation. But one needs to know where exactly to put those lines so the shader doesn’t end up broken. I have envisioned an algorithm to do this for GLSL 1.2, and have started working on the implementation. It should be okay, and I’m confident all cases are covered. I will do careful testing when implementing this.
I have continued working on my GSoC project with the goal of achieving color correction in KWin. Last week, I concentrated my efforts on splitting the painting process to get a painting pass for each screen. But, unfortunately, there were unforeseen complications. Although the modifications work fine in KWin core, they break a significant number of the effects (unlucky me, the most complicated ones).
I have spent most of the time debugging around the effects and trying to fix each one. The problem is that in most of them it is assumed that there is only one big screen (that is an aggregation of the actual screens). So, obviously, things start to break after modifying the rendering pipeline.
It has been decided that I will put that approach on hold for a while, and begin working on a simpler one, that has very little chances of breaking effects again. However, this simpler approach (based on doing the splitting very near to the actual rendering) will have a significant performance impact. But the primary objective is to have something working.
Now I am much more confident than before, since by hacking around the effects and the core painting parts, I have a much better understanding of the code.
And, of course:
Last week I focused on splitting the painting process into multiple painting passes, one for each screen. Implemented a first crude attempt which was working, but there were issues with some of the effects, as well as a performance decrease. It had coding style flaws too, but that’s because I wasn’t warmed up with the style yet.
Changed the KWin effects API to allow those multiple passes. But this is not definitive and needs to be discussed more and changed. Fixed the relative drop in performance, but with the cost of some regressions.
Some of the effects are broken with the changes, and all of them need to be fixed. Some of them are already handling multiple screens, and they need to be adjusted to the new behavior. So, there will be much to do until the split is completed, and that is what I will be concentrating on.