tildearrow / kwin-lowlatency

archived - X11 full-screen unredirection and lots'a settings for KWin
372 stars 10 forks source link

[Feature idea] Re-implement fullscreen unredirection back #1

Closed clapbr closed 2 years ago

clapbr commented 5 years ago

First of all, thanks for this, it's working really well for me, no issues yet and browsers/scrolling is smooth as butter now, I've finally come back from compton :) Oddly enough my trusty stutterless compton was the old one with --vsync=opengl, which used the same method you implemented here (dev deprecated it recently).

Now to the point, kwin used to do fullscreen unredirection so you could play games without compositor overhead and still alt+tab to a composited desktop. Mutter and compton still can do that but kwin deprecated it in favor of totally disabling it with a Block composition window rule OR by application's request (https://blog.martin-graesslin.com/blog/2016/08/opengl-changes-in-kwin-compositing/). What's your thoughts on bringing the feature back, at least as an option? Seems to align with the forks goal.

tildearrow commented 5 years ago

OK, so I've traced the removal commit to 996ee34e14ece93421fee7bf7447ecfa785871d1.

The reason why KWin fullscreen un-redirection was removed was because it looked a lot like a hack, and didn't even work in some graphics cards.

But I'll try doing some experiments on bringing the feature back in a separate branch soon.

clapbr commented 5 years ago

Might be worth looking into how mutter does it, I've heard it works well enough no one bothers turning compositor off in Gnome.

clapbr commented 5 years ago

Someone on reddit shared this useful script that enables/suspend compositing based on window properties, https://gist.github.com/Sporif/8f472bc603dac7564fa12ee0a1091498 - Tried with a couple of games and seems to work.

tildearrow commented 5 years ago

I've created a new branch named "unredirect" with the changes in place. Please test and tell me if it works. Will merge if does for most users.

(note: if building and testing in-place (e.g. ./bin/kwin_x11), remember to copy <buildDir>/bin/org.kde.kwin.scenes/KWinSceneOpenGL.so to /usr/lib/qt/plugins/org.kde.kwin.scenes/KWinSceneOpenGL.so)

(also: PKGBUILD for Arch Linux with unredirect)

clapbr commented 5 years ago

I've created a new branch named "unredirect" with the changes in place. Please test and tell me if it works. Will merge if does for most users.

(note: if building and testing in-place (e.g. ./bin/kwin_x11), remember to copy <buildDir>/bin/org.kde.kwin.scenes/KWinSceneOpenGL.so to /usr/lib/qt/plugins/org.kde.kwin.scenes/KWinSceneOpenGL.so)

Couldn't make it work, tried putting UnredirectFullscreen=true under [Compositing] in kwinrc but still no luck.

tildearrow commented 5 years ago

Did you build the right branch? If so, is it that the compositor crashed?

(by the way, unredirection is enabled by default)

clapbr commented 5 years ago

Did you build the right branch? If so, is it that the compositor crashed?

(by the way, unredirection is enabled by default)

Figured it out, it was my tiling script messing it up. Tested unigine benchs and a couple of dxvk games and it's working now :1st_place_medal:

tildearrow commented 5 years ago

I'm not merging this yet because I have noticed an issue that causes KWin to use 100% CPU time when unredirecting under specific conditions.

Edit: fixed in 51a6b5fe2941c17221364b07d5ebb54a9ea29bf4

laloch commented 5 years ago

@clapbr : Could you please share which tiling script you use and what was the issue with unredirection of fullscreen clients? Thanks.

clapbr commented 5 years ago

@clapbr : Could you please share which tiling script you use and what was the issue with unredirection of fullscreen clients? Thanks.

It was an old version of quarter-tiling, for some reason the screen would not unredirect with it enabled. I've just migrated to a better maintained script (https://github.com/kwin-scripts/kwin-tiling) and had no problems since.

laloch commented 5 years ago

@clapbr: Thanks for the reply. I asked, because I'm one of the maintainers of kwin-tiling, so I wanted to know whether it was problem with our script or not.

Sporif commented 5 years ago

Unredirection seems to work well on native games, proton games and games launched directly from wine. But strangely it doesn't work for games started from a non-native launcher like battle.net or origin. For example if I start Overwatch directly it works, but from battle.net it doesn't.

Edit: Ok this just seems very inconsistent, alt-tabbing out and back in is enough to stop unredirection form working in certain games.

tildearrow commented 5 years ago

Can you please make a list of games that don't unredirect well? I've tested with RetroArch, Xonotic and StepMania (under both AMD and NVIDIA) and seems to work in my side, even after doing alt-tab (proof is that the "Show FPS" graph disappears when unredirecting and under NVIDIA the draw mode changes from blit to flip).

(also, may you run xwininfo on the Overwatch fullscreen window as soon as unredirect stops working?)

Sporif commented 5 years ago

I think the issue is latte-dock. xwininfo was showing Override Redirect State: yes even after Alt-tabbing. But the nvidia API/Gsync indicators were showing flipping and Gsync being disabled. I was out of ideas, tried closing latte-dock and what do you know, it went back to flipping and Gsync started working. So I thought since it happens after Alt-tabbing maybe it's the transparency of latte-dock that is the cause, and it looks like that's the case. Disabling the "hide background when not needed" setting in latte-dock has seemingly caused the issue to vanish.

Edit: Still occurs with cs:go, but restarting latte-dock fixes it. Very strange.

tildearrow commented 5 years ago

OK so I'm beginning to reproduce the latte-dock issues with unredirect...

Edit: Actually not latte-dock issues, but seems like calfjackhost prevents unredirect from working...

tildearrow commented 5 years ago

I've merged the unredirect branch now. KWin-lowlatency 5.15.5 going to be released in a few hours.

(I'm still leaving this issue open as there are some issues to fix for later versions)

aufkrawall commented 5 years ago

@tildearrow Thanks for your efforts, vsync of KWin is now finally working well.

Fullscreen unredirection generally works for me with Mesa RX 580, but it stops to do so when the Battle.net client is running in Wine. This then also applies to native Linux programs like vkquake, they only get correctly unredirected when Battle.net is not running in the background (no matter if minimized or in Plasma's tray).

aufkrawall commented 5 years ago

One more issue: Wine fullscreen application windows can't be opened again after alt + tabbing to the desktop, they stay black then.

tildearrow commented 5 years ago

@aufkrawall Just confirmed the issue. However, it is not just restricted to Battle.net. It also reproduces with taskmgr for some reason.

tildearrow commented 5 years ago

Apparently both calfjackhost and taskmgr create an invisible 32x32 window which serves as a simulated "tray" on GNOME, which interferes with unredirect. I'm working on a fix (although sort of a hack) to this problem.

Edit: The Battle.net client does the same as well.

aufkrawall commented 5 years ago

@tildearrow Thanks for your continued efforts. Unfortunately, 09f889058ac3103a6f6c36a23ccc8dfb38f40e4b doesn't do the trick for me. When Battle.net launcher is started, unredirect is still turned off and Heroes of the Storm window doesn't recover after alt + tab by its windows just staying black.

Edit: The HotS window staying black is unrelated to unredirect, I suppose I should open a new ticket for it.

tildearrow commented 5 years ago

Thanks for the feedback. Can you test again and provide the output of kwin_x11 when unredirect doesn't work? (especially the no. this: lines (if they don't appear try going back to 09f8890 and try again))

tildearrow commented 5 years ago

When unredirection is enabled, every time you switch to a full-screen application that is busy it will display a black screen until the application repaints, but in your case the application isn't busy...

aufkrawall commented 5 years ago

Good news: Unredirect seems to work fine now with Battle.net client and 5.16.2 (for whatever reason). :tada:

Just the Wine black window issue remains, which also occurs without unredirect (but not with mainline kwin). It btw. also doesn't show sound volume OSD when pressing keyboard media buttons while being in HotS with unredirected compositing. Dummy question: How do I get KWin to verbosity? When I start it via kwin_x11 --replace, there is no output when starting HotS.

tildearrow commented 5 years ago

It btw. also doesn't show sound volume OSD when pressing keyboard media buttons while being in HotS with unredirected compositing.

Yeah, that's a bug caused by the hacky workaround. I'll be fixing this for -2, or 5.16.3.

tildearrow commented 5 years ago

Dummy question: How do I get KWin to verbosity? When I start it via kwin_x11 --replace, there is no output when starting HotS.

By rolling back to commit 09f8890 and launching KWin via:

cd build
QT_PLUGIN_PATH="$PWD/bin" ./bin/kwin_x11 --replace

Then you'll be able to see the "yes", " yes via hack" and "no. this:" debug messages I added on that commit.

Just the Wine black window issue remains, which also occurs without unredirect (but not with mainline kwin).

OK, thank you for telling me. This should be moved to a new issue.

aufkrawall commented 5 years ago

Ehh, my mistake: I overlooked that you use git checkout in PKGBUILD. I've changed it to 09f889058ac3103a6f6c36a23ccc8dfb38f40e4b and of course it continued to work this time. Sorry!

Well, but now to the black screen issue.

tildearrow commented 5 years ago

That's OK. If unredirection stops working at some point, please provide the no. this: output lines from KWin.

Sporif commented 5 years ago

Unredirection seems to work very well now. I've tested it for a few days and not once has Gsync been disabled.

aufkrawall commented 4 years ago

It indeed works very well here with Nvidia and latest software versions, I couldn't make it fail so far.

tildearrow commented 4 years ago

Totally breaks in osu! (through Wine) for unknown reasons. It used to work but not anymore.

2X3 commented 3 years ago

How to turn on unredirection in version 5.20? Is it activated using the variable in kwinrc?

aufkrawall commented 3 years ago

@tildearrow There were some adjustments to make direct scanout work better with Wine: https://invent.kde.org/plasma/kwin/-/commit/7cc95d931b6d79e5b57361f8fcfa51aa806124a7 https://invent.kde.org/plasma/kwin/-/commit/7a937fc7af71cce6928fa5680adba30dff1bd298

Perhaps this can be similarly implemented for unredirection on Xorg to make it more reliable?

tildearrow commented 2 years ago

Hopefully done with KWin-lowlatency 5.22+ and the new unredirection code.