Skip to content

Wayland windows' colors are too dark #7318

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

Closed
johanhelsing opened this issue Jan 21, 2023 · 10 comments · Fixed by #8336
Closed

Wayland windows' colors are too dark #7318

johanhelsing opened this issue Jan 21, 2023 · 10 comments · Fixed by #8336
Labels
A-Rendering Drawing game state to the screen C-Bug An unexpected or incorrect behavior O-Linux Specific to the Linux desktop operating system

Comments

@johanhelsing
Copy link
Contributor

Screenshot_20230121_175039

breakout-wayland.log
Screenshot_20230121_175325

  • kwin
  • bevy: cb4e8c8
  • Nvidia GTX 970
@JMS55
Copy link
Contributor

JMS55 commented Jan 21, 2023

Bloom has known issues with transparency, which will be fixed by #6677.

The lightness shift is interesting though.

@alice-i-cecile alice-i-cecile added C-Bug An unexpected or incorrect behavior A-Rendering Drawing game state to the screen O-Linux Specific to the Linux desktop operating system labels Jan 21, 2023
@johanhelsing johanhelsing changed the title Wayland windows' colors are too dark (and transparent on hdr) Wayland windows' colors are too dark Jan 21, 2023
@johanhelsing
Copy link
Contributor Author

Alright, removing bloom from the title to keep the issue focused.

For what it's worth, I tested on gnome as well, and it's behaving the same, so likely not a compositor bug.

image

wayland on the left, x11 on the right

The colors on X11 are consistent with what I see on Windows and wasm, (just confirming it's wayland that is off, and not x11)

@johanhelsing
Copy link
Contributor Author

johanhelsing commented Jan 21, 2023

From the wayland logs, it looks like we're creating the right kind of surface:

[1036841.262]  -> [email protected](new id wl_callback@43)
[1036841.622]  -> [email protected]_params(new id zwp_linux_buffer_params_v1@51)
[1036841.633]  -> [email protected](fd 51, 0, 0, 5120, 50331648, 5234708)
[1036841.639]  -> [email protected]_immed(new id wl_buffer@54, 1280, 720, 875713089, 0)
[1036841.644]  -> [email protected]()

We're creating a surface with the 875713089 format, which is AR24 in fourcc (ARGB8888)

I'm not really sure how to dig further. I took some RUST_LOG=debug logs from running the breakout example as well. Let me know if there's any other way I can help.

breakout-debug-wayland.log

EDIT: I tried bisecting. And on v0.8.0, I got:

2023-01-21T23:31:47.426572Z  INFO bevy_render::renderer: AdapterInfo { name: "NVIDIA GeForce GTX 970", vendor: 4318, device: 5058, device_type: DiscreteGpu, backend: Vulkan }
thread 'main' panicked at 'Error in Surface::configure: requested format Bgra8UnormSrgb is not in list of supported formats: [Bgra8Unorm]', /home/johan/.cargo/registry/src/github.1485827954.workers.dev-1ecc6299db9ec823/wgpu-0.13.1/src/backend/direct.rs:281:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

It stopped panicking on startup in f5322cd. That commit message explains the weird behavior. We're just choosing ARGB8888 even though the image we produce probably is srgb.

@Elabajaba
Copy link
Contributor

So we should be able to fix this once we land wgpu 0.15, but it requires using texture_views on non-srgb surfaces (and we should still default to srgb surfaces if they're available).

The problem is I wasn't able to get them working without a ton of vulkan validation errors, so I opted out of it for that PR.

@JMS55
Copy link
Contributor

JMS55 commented Feb 11, 2023

@Elabajaba the recently released wgpu 0.15.1 should fix this. Do you mind taking another stab at it?

@VitalyAnkh
Copy link
Contributor

@JMS55 I found the color is still too dark on Wayland with the lasted commit (eaac730) which contains wgpu 0.15.1 update:
On Wayland:

RUST_BACKTRACE=1 RUST_LOG=info WGPU_BACKEND=vulkan cargo run --features wayland --example fog

image

and on X11:

RUST_BACKTRACE=1 RUST_LOG=info WGPU_BACKEND=vulkan cargo run --example fog

image

@Hellzbellz123
Copy link

Hellzbellz123 commented Feb 18, 2023

bug exists on nvidia-dkms it seems. testing nvidia-open-dkms to see if there is a difference.
no change on nvidia-open-dkms
nvidia-dkms/525.89.02 with an RTX 3070 lhr
running cachyos linux kernel 6.1.12-1
running said apps with wayland and using swrast/lavapipe gets me the correct colors so that leads me to believe its a driver issue, while testing this i also discovered that the bloom example has a bug where the window is transparent when intensity is postive
xorg:
x11
wayland:
wayland

@VitalyAnkh
Copy link
Contributor

So this problem only happens on NVIDIA's GPU? Are there any similar issues on Intel or AMD?

I'm also using nvidia-dkms-open and experiencing this problem.

@Elabajaba
Copy link
Contributor

So this problem only happens on NVIDIA's GPU? Are there any similar issues on Intel or AMD?

I'm also using nvidia-dkms-open and experiencing this problem.

Afaik Nvidia's Linux driver kinda sucks and doesn't support sRGB surface formats.

I'll try and get a pr up tomorrow to use an srgb texture view when the surface format isn't srgb now that it was fixed on the wgpu side.

@martinkozle
Copy link

Surprise fix 😲

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen C-Bug An unexpected or incorrect behavior O-Linux Specific to the Linux desktop operating system
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants