Bug 428003 - kwin schedules bad repaints for weston-simple-damage
Summary: kwin schedules bad repaints for weston-simple-damage
Status: RESOLVED FIXED
Alias: None
Product: kwin
Classification: Plasma
Component: wayland-generic (other bugs)
Version First Reported In: git master
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-10-19 21:08 UTC by Vlad Zahorodnii
Modified: 2020-10-20 15:41 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments
this bug can't be reproduced with a nested kwin_wayland compositor (36.93 KB, image/png)
2020-10-19 21:08 UTC, Vlad Zahorodnii
Details
weston-simple-damage running with kwin_wayland on drm (2.33 MB, image/jpeg)
2020-10-19 21:10 UTC, Vlad Zahorodnii
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Vlad Zahorodnii 2020-10-19 21:08:27 UTC
STEPS TO REPRODUCE
1. Run kwin with drm backend
2. Launch weston-simple-damage with --transform=90

OBSERVED RESULT
The contents of westom-simple-damage is corrupted 

EXPECTED RESULT
No visual artifacts

ADDITIONAL INFORMATION
This bug can't be reproduced with a nested kwin_wayland.
Comment 1 Vlad Zahorodnii 2020-10-19 21:08:57 UTC
Created attachment 132571 [details]
this bug can't be reproduced with a nested kwin_wayland compositor
Comment 2 Vlad Zahorodnii 2020-10-19 21:10:10 UTC
Created attachment 132572 [details]
weston-simple-damage running with kwin_wayland on drm
Comment 3 Vlad Zahorodnii 2020-10-19 21:18:38 UTC
If kwin_wayland runs with KWIN_USE_BUFFER_AGE=0, weston-simple-damage is rendered as expected.
Comment 4 Vlad Zahorodnii 2020-10-20 06:48:24 UTC
The problem is in WindowQuad::makeSubQuad().
Comment 5 Bug Janitor Service 2020-10-20 08:39:38 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/368
Comment 6 Vlad Zahorodnii 2020-10-20 15:41:11 UTC
Git commit 7301564e4ff884f5a83ccb20bdbcbd9d81ecc96c by Vlad Zahorodnii.
Committed on 20/10/2020 at 15:41.
Pushed by vladz into branch 'master'.

Use bilinear interpolation to compute texture coords of subquads

On Wayland, a surface must be displayed the same way no matter how the
attached buffer is transformed. In order to guarantee that, we build the
surface-to-buffer matrix, which is used to compute the texture coords.

The surface-to-buffer matrix represents an affine transformation. Thus,
performing linear interpolation between texture coordinates won't end up
in corrupted rendered results. This is the main assumption that we make
during generation of contents window quads. After creating a sub-quad,
the new quad's texture coordinates are computed by interpolating between
the source quad's texture coords.

However, WindowQuad::makeSubQuad() makes a concrete assumption about the
order of texture coords, which might be false if the attached wayland
buffer is rotated 90 or 270 degrees.

This issue went unnoticed after merging the viewporter patches because
the developer who was working on it had been using primarily nested
kwin_wayland for testing purposes. And it appears like kwin schedules
full screen repaints even though it supports buffer age. It still needs
some investigation why that happens.

M  +8    -8    autotests/libkwineffects/windowquadlisttest.cpp
M  +29   -35   libkwineffects/kwineffects.cpp

https://invent.kde.org/plasma/kwin/commit/7301564e4ff884f5a83ccb20bdbcbd9d81ecc96c