Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiling with O3 on Clang causes blurriness on Wayland #1493

Open
Exotic0015 opened this issue Aug 27, 2024 · 8 comments · May be fixed by #1494
Open

Compiling with O3 on Clang causes blurriness on Wayland #1493

Exotic0015 opened this issue Aug 27, 2024 · 8 comments · May be fixed by #1494

Comments

@Exotic0015
Copy link

Compiling a release build or with -O3 using Clang causes output image to be blurry. I've narrowed it down to commit 7fe73df, without it everything looks as it should. Below are comparison screenshots, though the difference may be too subtle to notice.

With 7fe73df:
Screenshot_20240827_212953

Without 7fe73df:
Screenshot_20240827_212818

Both instances were built using the same compile options.

@matte-schwartz
Copy link

Nice find, the issue happens on the drm backend as well. Hadn't gotten around to investigating for myself why it happened yet ublue-os/bazzite#1539 but it's also fixed by switching to gcc rather than clang.

@misyltoad
Copy link
Collaborator

Screen blurring when composition may be something else? Does it happen if native res..?

Thanks for the report about this one though.

@matte-schwartz
Copy link

Screen blurring when composition may be something else? Does it happen if native res..?

Thanks for the report about this one though.

You're right, different issue it seems since it only starts to happen with composition. However the fix was the same, switching to GCC, as reported by stereophonick. I'll try to verify on my Deck later.

@matte-schwartz
Copy link

matte-schwartz commented Aug 28, 2024

its two separate issues but both come from the same commit after all.

I also see this specific issue with the Wayland backend, pretty apparent in Dota 2 + Deadlock's settings menus for me:

command:
SteamDeck=0 gamescope -f -h 1440 -w 3440 -r 175 --adaptive-sync --force-grab-cursor --mangoapp --composite-debug -- %command%

from git:
SteamDeck=0 gamescope -f -h 1440 -w 3440 -r 175 --adaptive-sync --force-grab-cursor --mangoapp --composite-debug -- %command%

from git with revert of 7fe73df:
SteamDeck=0 gamescope -f -h 1440 -w 3440 -r 175 --adaptive-sync --force-grab-cursor --mangoapp --composite-debug -- %command%

kind of like going to the eye doctor...

my clang.ini

[binaries]
c = 'clang'
cpp = 'clang++'
ld = 'clang'
ar = 'llvm-ar'
strip = 'llvm-strip'

[properties]
c_args = ['-march=native', '-O3']
cpp_args = ['-march=native', '-O3']

@sharkautarch
Copy link

@Exotic0015 @matte-schwartz
Try adding the meson flag: -Db_sanitize=address,undefined
and add these other flags:

CARGS="-fsanitize=float-cast-overflow -fsanitize=integer -fsanitize=float-divide-by-zero -fno-omit-frame-pointer -g -shared-libsan -fsanitize-recover=all"
LINK_ARGS="-fuse-ld=lld -Wl,-rpath=$(echo /usr/lib/clang/*/lib/linux)"
-Dc_args="$CARGS" -Dc_link_args="$CARGS $LINK_ARGS" -Dcpp_args="$CARGS" -Dcpp_link_args="$CARGS $LINK_ARGS"

@sharkautarch
Copy link

@Joshua-Ashton
If this is confirmed to be only happening when:

  • compiling w/ clang
    And
  • only when building a release build (so need confirmation that the issue isn't present on builds w/ -O0 aka --buildtype=debug)

Then it could be that either a) rare case of scary compiler bug in clang/llvm OR b) gcc is more forgiving w/ -O3 + -ffast-math than clang

I did a mini-test of the ceil behavior for gcc vs clang on godbolt https://godbolt.org/z/vh8TTjzfz and it definitely showed that clang and gcc have very different optimization behavior (tho more similar when targeting native cpu). Though nothing definitive especially when this is without linking & whatnot

might need to reach out to llvm project on github if we can't figure this out...

@sharkautarch
Copy link

I used https://github.com/GrammaTech/ddisasm for disassembling versions of gamescope with and without commit 7fe73df reverted
I diff'd around the two, and didn't see any change outside of CWaylandPlane::Present(FrameInfo_t::Layer_t const*)

Here's the dissaseembly with the commit reverted:
https://gist.github.com/sharkautarch/b7545b638f44fb3115a1d929913ae2b6

and without the commit reverted:
https://gist.github.com/sharkautarch/c358ab2e12fac442d94684534b994e33

This is making my head hurt... 0_o

@matte-schwartz
Copy link

did some investigating this evening and the problem seems to be "-vectorize-slp" which gets added in -O2 and -O3 optimization. the window becomes "focused" again if I build with '-fno-slp-vectorize' without reverting anything.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants