Bug 257566 - Wobbly Windows effect with bi/trilinear filtering make windows' decorations flicker
Summary: Wobbly Windows effect with bi/trilinear filtering make windows' decorations f...
Status: RESOLVED FIXED
Alias: None
Product: kwin
Classification: Plasma
Component: effects-various (show other bugs)
Version: unspecified
Platform: Debian unstable Linux
: NOR normal
Target Milestone: ---
Assignee: Vlad Zahorodnii
URL:
Keywords:
: 245393 293592 307736 352270 402595 405933 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-11-22 01:32 UTC by ultr
Modified: 2020-01-09 13:13 UTC (History)
11 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.18.0


Attachments
wobblywindowsbitrilinear.png (225.06 KB, image/png)
2010-11-22 01:35 UTC, ultr
Details
KWin Wobbly Flicker (1.89 MB, application/x-matroska)
2019-01-08 19:59 UTC, Filip Fila
Details

Note You need to log in before you can comment on or make changes to this bug.
Description ultr 2010-11-22 01:32:09 UTC
Version:           unspecified (using KDE 4.5.1) 
OS:                Linux

Wobbly Windows effect makes windows' decorations flicker when bilinear or trilinear filtering is enabled. This does not occur with nearest filtering.

Flickering can be seen as 0-1px dark line between window's decoration and the window content (see attached screenshot).

It happens with all styles and decorations. I use QtCurve, but flickering occurs with original Oxygen styles as well.

Yet I could not reproduce this bug with the Konsole window. It happens for Konqueror, Dolphin, SystemSettings window and others, but not for the Konsole. Quite wired.


Reproducible: Sometimes

Steps to Reproduce:
1) enable Wobbly Windows effect
2) set filtering to bilinear or trilinear
3) open Konqueror/Dolphin and move its window around
Comment 1 ultr 2010-11-22 01:35:03 UTC
Created attachment 53624 [details]
wobblywindowsbitrilinear.png
Comment 2 Martin Flöser 2010-12-18 12:28:09 UTC
*** Bug 245393 has been marked as a duplicate of this bug. ***
Comment 3 Martin Flöser 2010-12-18 12:32:22 UTC
I can confirm that linear filtering does not show the issue. Seems to be a clamping problem. Seems I need to read again the section on clamping with filtering in the super bible.
Comment 4 ultr 2010-12-18 13:09:16 UTC
Would be great if you could fix it.

It is the only thing stopping me from using trilinear filtering which makes windows look much nicer.

Thanks.


ultr
Comment 5 Martin Flöser 2011-01-13 22:20:29 UTC
I investigated a little bit on the issue. It is not an issue caused by clamping. The problem is that we have textures for the decoration and one texture for the window. The window texture has the size of the window + the decoration and the decoration area is black. Now during wobbly windows the edge includes texels from the black area. I tried with once only showing decorations and once only showing the window and the black stipples were only visible in the latter case.

Now about fixing: with the OpenGL 1.x backend I don't think it is fixable except forcing linear filtering during wobbly. With the new OpenGL 2.x/GLES backend I think it is fixable in the shader. We just need to bind all the decoration textures and the window texture and use the correct texture at the border. Though I don't know yet if I will look at such a change.
Comment 6 Martin Flöser 2012-02-08 05:28:30 UTC
*** Bug 293592 has been marked as a duplicate of this bug. ***
Comment 7 Martin Flöser 2013-01-03 22:02:16 UTC
*** Bug 307736 has been marked as a duplicate of this bug. ***
Comment 8 Thomas Lübking 2015-09-04 14:59:25 UTC
*** Bug 352270 has been marked as a duplicate of this bug. ***
Comment 9 Ivan Stanton 2017-03-21 22:38:55 UTC
Still having this issue on neon Developer-Unstable. In 2017.
Surprised we still don't have a fix.
Comment 10 Filip Fila 2018-06-10 12:25:01 UTC
(In reply to Ivan Stanton from comment #9)
> Still having this issue on neon Developer-Unstable. In 2017.
> Surprised we still don't have a fix.

I don't know where the filtering options can be set or if they exist anymore, but this is still very reproducible.
Comment 11 Martin Flöser 2018-12-27 13:19:52 UTC
*** Bug 402595 has been marked as a duplicate of this bug. ***
Comment 12 Filip Fila 2019-01-08 19:59:32 UTC
Created attachment 117346 [details]
KWin Wobbly Flicker

Flickering is less pronounced with Crisp set as the scaling method, but is still present.
Comment 13 Vlad Zahorodnii 2019-03-27 21:31:49 UTC
*** Bug 405933 has been marked as a duplicate of this bug. ***
Comment 14 Vlad Zahorodnii 2019-12-02 13:11:16 UTC
Git commit ac4dce1c20a1cbfd3974bf8da6dd7557d35a4ca1 by Vlad Zahorodnii.
Committed on 02/12/2019 at 13:08.
Pushed by vladz into branch 'master'.

[scene] Fix decoration texture bleeding

Summary:
Quite long time ago, window decorations were painted on real X11 windows.
The nicest thing about that approach is that we get both contents of the
client and the frame window at the same time. However, somewhere around
KDE 4.2 - 4.3 times, decoration rendering architecture had been changed
to what we have now.

I've mentioned the previous decoration rendering design because it didn't
have a problem that the new design has, namely the texture bleeding issue.

In the name of better performance, opengl scene puts all decoration parts
to an atlas. This is totally reasonable, however we must be super cautious
about things such as the GL_LINEAR filter.

The GL_LINEAR filter may need to sample a couple of neighboring texels
in order to produce the final texel value. However, since all decoration
parts now live in a single texture, we have to make sure that we don't
sample texels that belong to another decoration part.

This patch fixes the texture bleeding problem by padding each individual
decoration part in the atlas. There is another solution for this problem
though. We could render a window into an offscreen texture and then map
that texture on the transformed window geometry. This would work well and
we definitely need an offscreen rendering path in the opengl scene,
however it's not feasible at the moment since we need to break the window
quads API. Also, it would be great to have as less as possible stuff going
on between invocation of Scene::Window::performPaint() and getting the
corresponding pixel data on the screen.

There is a good chance that the new padding stuff may make you vomit. If
it does so, I'm all ears for the suggestions how to make the code more
nicer.
Related: bug 360549, bug 412573
FIXED-IN: 5.18.0

Reviewers: #kwin

Subscribers: fredrik, kwin, fvogt

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D25611

M  +6    -1    decorations/decorationrenderer.cpp
M  +1    -0    decorations/decorationrenderer.h
M  +108  -9    plugins/scenes/opengl/scene_opengl.cpp
M  +11   -4    scene.cpp

https://commits.kde.org/kwin/ac4dce1c20a1cbfd3974bf8da6dd7557d35a4ca1
Comment 15 Vlad Zahorodnii 2019-12-02 18:00:01 UTC
Git commit 6e000314b34820760cd08593d18708e1f8905cc9 by Vlad Zahorodnii.
Committed on 02/12/2019 at 17:45.
Pushed by vladz into branch 'master'.

Revert the fix for the texture bleeding issue

This reverts commit 9151bb7b9e71fdfeb3d3682ee8a42d796fa315e9.
This reverts commit ac4dce1c20a1cbfd3974bf8da6dd7557d35a4ca1.
This reverts commit 754b72d155820a6c8a9ba94b2c0960da1b2f86ce.

In order to make the fix work, we need to redirect the client window
instead of the frame window. However, we cannot to do that because
Xwayland expects the toplevel window(in our case, the frame window)
to be redirected.

Another solution to the texture bleeding issue must be found.
Related: bug 360549

M  +6    -0    composite.cpp
M  +1    -6    decorations/decorationrenderer.cpp
M  +0    -1    decorations/decorationrenderer.h
M  +6    -1    deleted.cpp
M  +2    -1    deleted.h
M  +2    -3    effects.cpp
M  +1    -1    events.cpp
M  +54   -50   geometry.cpp
M  +16   -109  plugins/scenes/opengl/scene_opengl.cpp
M  +18   -17   scene.cpp
M  +13   -1    scene.h
M  +8    -9    toplevel.cpp
M  +10   -1    toplevel.h
M  +56   -8    x11client.cpp
M  +6    -22   x11client.h

https://commits.kde.org/kwin/6e000314b34820760cd08593d18708e1f8905cc9
Comment 16 David Edmundson 2020-01-09 13:04:05 UTC
Git commit d1cfcf4c975e1dfe6f54c470f9c2ead2548afacf by David Edmundson.
Committed on 09/01/2020 at 13:03.
Pushed by davidedmundson into branch 'master'.

Avoid texture bleed rendering X11 window

Summary:
We currently see a gap on transformed windows between the window and the
top decoration.

This is partly the atlas bleed on the decoration, and partly a bleed on
the window content itself.

On X11, the window we composite is the frame window - which is a larger
texture containing a transparent border where the frame normally would
be. When we sample with a linear filter we include these texels. Hence
GL_CLAMP_TO_EDGE doesn't work.

Vlad's patch to composite the correct window, not the frame was my
preferred approach, but we had to revert it as it caused an issue with
xwayland :(

Half pixel correction nearly worked, but caused blurry fonts.

This patch resolves it in the fragment shader used by effects doing
transforms. We pass the real texture geometry of the window to the
client with a half pixel correction. Any samples outside the outer half
pixel are then clamped within bounds.

Arguably a hack, but solves the problem in a comparatively
non-invasive way.
Related: bug 360549

Test Plan:
X11:
Using Vlad's atlas padding for decoration
Slowed animations, wobbled a dark window over a light background
No artifacts

Wayland:
This isn't needed. Now tested that everything still renders the same.

Reviewers: #kwin, zzag

Reviewed By: #kwin, zzag

Subscribers: zzag, jgrulich, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D25737

M  +14   -3    libkwineffects/kwinglutils.cpp
M  +2    -0    libkwineffects/kwinglutils.h
M  +40   -13   plugins/scenes/opengl/scene_opengl.cpp

https://commits.kde.org/kwin/d1cfcf4c975e1dfe6f54c470f9c2ead2548afacf
Comment 17 Vlad Zahorodnii 2020-01-09 13:13:40 UTC
Git commit af71763be53054925f27b7614fc992e6380a1d02 by Vlad Zahorodnii.
Committed on 09/01/2020 at 13:13.
Pushed by vladz into branch 'master'.

[scene] Fix decoration texture bleeding

Summary:
Quite long time ago, window decorations were painted on real X11 windows.
The nicest thing about that approach is that we get both contents of the
client and the frame window at the same time. However, somewhere around
KDE 4.2 - 4.3 times, decoration rendering architecture had been changed
to what we have now.

I've mentioned the previous decoration rendering design because it didn't
have a problem that the new design has, namely the texture bleeding issue.

In the name of better performance, opengl scene puts all decoration parts
to an atlas. This is totally reasonable, however we must be super cautious
about things such as the GL_LINEAR filter.

The GL_LINEAR filter may need to sample a couple of neighboring texels
in order to produce the final texel value. However, since all decoration
parts now live in a single texture, we have to make sure that we don't
sample texels that belong to another decoration part.

This patch fixes the texture bleeding problem by padding each individual
decoration part in the atlas. There is another solution for this problem
though. We could render a window into an offscreen texture and then map
that texture on the transformed window geometry. This would work well and
we definitely need an offscreen rendering path in the opengl scene,
however it's not feasible at the moment since we need to break the window
quads API. Also, it would be great to have as less as possible stuff going
on between invocation of Scene::Window::performPaint() and getting the
corresponding pixel data on the screen.

There is a good chance that the new padding stuff may make you vomit. If
it does so, I'm all ears for the suggestions how to make the code more
nicer.
Related: bug 360549, bug 412573
FIXED-IN: 5.18.0

Reviewers: #kwin

Subscribers: fredrik, kwin, fvogt

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D25611

M  +6    -1    decorations/decorationrenderer.cpp
M  +1    -0    decorations/decorationrenderer.h
M  +108  -9    plugins/scenes/opengl/scene_opengl.cpp
M  +11   -4    scene.cpp

https://commits.kde.org/kwin/af71763be53054925f27b7614fc992e6380a1d02