ValveSoftware / gamescope

SteamOS session compositing window manager
Other
3.02k stars 197 forks source link

Games running in gamescope have broken colors #1484

Open Stalkero opened 1 month ago

Stalkero commented 1 month ago

Description

Every game that i try to run with gamescope have broken colors. No matter which game i play the results are the same

This one is without gamescope Screenshot_20240820_231515

And this is with gamescope enabled Screenshot_20240820_231626

Expectation

Fix the colors and find what is causing it to shift colors

Steps to reproduce

Open any game with gamescope --backend sdl other backends do not work

Gamescope version: 3.14.29-1 Distro: Arch DE: KDE Plasma wayland Drivers: NVIDIA proprietary 555.58.02-1

gitiy1 commented 3 weeks ago

I also encountered this on KDE Plasma 6 Wayland and NVIDIA GPU. Could someone help us?

sharkautarch commented 3 weeks ago

I'm not sure if this is due to something broken w/ nvidia driver's handling of formats/colorspace, or if it is something weird w/ how the nvidia driver handle's gamescope's color management shaders....

Since you guys are on wayland, first thing to try would be forcing sdl backend to use x11 driver w/ this env variable: SDL_VIDEODRIVER=x11

if that doesn't help, you could try building this branch/fork I have where the color management shaders are hardcoded off: (currently there isn't actually a functional option to turn color management off in upstream gamescope yet, tho that will be added in the future) https://github.com/sharkautarch/gamescope/tree/test_w_no_lut_newer

git clone https://github.com/sharkautarch/gamescope
cd gamescope
meson setup --buildtype=release -Db_lto=true --force-fallback-for=wlroots,vkroots,libliftoff,libdisplay-info build
ninja -C build

then you'd just run w/ ${HOME}/gamescope/build/src/gamescope <parameters>

Pheoxy commented 2 weeks ago

@sharkautarch SDL_VIDEODRIVER=x11 Seems to fix it for me but I maybe notice stuttering, not sure?

sharkautarch commented 2 weeks ago

@sharkautarch SDL_VIDEODRIVER=x11 Seems to fix it for me but I maybe notice stuttering, not sure?

Probably some weirdness w/ interaction between nvidia driver and/or shared lib stuff and x11. Couple ideas for workarounds to try:

Stalkero commented 1 week ago

Replying to https://github.com/ValveSoftware/gamescope/issues/1484#issuecomment-2335194837

Seems like this fixes colours. I haven't noticed any stutters

Pheoxy commented 1 week ago

Replying to https://github.com/ValveSoftware/gamescope/issues/1484#issuecomment-2336732586

First off sorry for the late reply, life gets in the way.

I have tried MESA_VK_WSI_PRESENT_MODE=immediate but didn't notice any differences, the actual issue isn't game breaking and is playable its just like every 3-5 seconds it will consistently skip/jump frames or something.

What logs would help diagnose this and what commands/packages are needed to narrow this down? It might be something strange going on with my laptop's hybrid setup with NVIDIA?

Replying to https://github.com/ValveSoftware/gamescope/issues/1484#issuecomment-2354777055

I'll give this a go next.

Pheoxy commented 1 week ago

After building I ran DRI_PRIME=1 ${HOME}/gamescope/build/src/gamescope vkcube

[gamescope] [Info]  console: gamescope version 3.14.22-118-ga2b45e1 (gcc 14.2.1)
No CAP_SYS_NICE, falling back to regular-priority compute and threads.
Performance will be affected.
ATTENTION: default value of option vk_khr_present_wait overridden by environment.
ATTENTION: default value of option vk_khr_present_wait overridden by environment.
ATTENTION: default value of option vk_khr_present_wait overridden by environment.
[gamescope] [Info]  vulkan: selecting physical device 'NVIDIA GeForce RTX 3070 Laptop GPU': queue family 2 (general queue family 0)
[gamescope] [Info]  vulkan: physical device supports DRM format modifiers
[gamescope] [Info]  wlserver: [backend/headless/backend.c:67] Creating headless backend
[gamescope] [Info]  xdg_backend: Seat name: 
[gamescope] [Error] vulkan: vkGetPhysicalDeviceFormatProperties2 returned zero modifiers for DRM format 0x38344241 (VkResult: 0)
[gamescope] [Error] vulkan: vkGetPhysicalDeviceFormatProperties2 returned zero modifiers for DRM format 0x38344258 (VkResult: 0)
[gamescope] [Info]  vulkan: supported DRM formats for sampling usage:
[gamescope] [Info]  vulkan:   AR24 (0x34325241)
[gamescope] [Info]  vulkan:   XR24 (0x34325258)
[gamescope] [Info]  vulkan:   AB24 (0x34324241)
[gamescope] [Info]  vulkan:   XB24 (0x34324258)
[gamescope] [Info]  vulkan:   RG16 (0x36314752)
[gamescope] [Info]  vulkan:   NV12 (0x3231564E)
[gamescope] [Info]  vulkan:   AB4H (0x48344241)
[gamescope] [Info]  vulkan:   XB4H (0x48344258)
[gamescope] [Info]  vulkan:   AB30 (0x30334241)
[gamescope] [Info]  vulkan:   AR30 (0x30335241)
[gamescope] [Info]  vulkan:   XR30 (0x30335258)
gamescope: ../src/rendervulkan.cpp:2139: bool CVulkanTexture::BInit(uint32_t, uint32_t, uint32_t, uint32_t, createFlags, wlr_dmabuf_attributes*, uint32_t, uint32_t, CVulkanTexture*, gamescope::OwningRc<gamescope::IBackendFb>): Assertion `modifiers.size() > 0' failed.
Job 1, '... terminated by signal SIGABRT (Abort)

And with --backend=sdl

[gamescope] [Info]  console: gamescope version 3.14.22-118-ga2b45e1 (gcc 14.2.1)
No CAP_SYS_NICE, falling back to regular-priority compute and threads.
Performance will be affected.
ATTENTION: default value of option vk_khr_present_wait overridden by environment.
ATTENTION: default value of option vk_khr_present_wait overridden by environment.
ATTENTION: default value of option vk_khr_present_wait overridden by environment.
[gamescope] [Info]  vulkan: physical device 10de:249d compute queue doesn't support presenting on our surface, using graphics queue
[gamescope] [Info]  vulkan: selecting physical device 'NVIDIA GeForce RTX 3070 Laptop GPU': queue family 0 (general queue family 0)
[gamescope] [Info]  vulkan: physical device supports DRM format modifiers
[gamescope] [Info]  wlserver: [backend/headless/backend.c:67] Creating headless backend
[gamescope] [Error] vulkan: vkGetPhysicalDeviceFormatProperties2 returned zero modifiers for DRM format 0x38344241 (VkResult: 0)
[gamescope] [Error] vulkan: vkGetPhysicalDeviceFormatProperties2 returned zero modifiers for DRM format 0x38344258 (VkResult: 0)
[gamescope] [Info]  vulkan: supported DRM formats for sampling usage:
[gamescope] [Info]  vulkan: Creating Gamescope nested swapchain with format 58 and colorspace 0
gamescope: types/wlr_linux_dmabuf_v1.c:532: feedback_compile: Assertion `table_len > 0' failed.
 Job 1, '…' terminated by signal SIGABRT (Abort)
Pheoxy commented 1 week ago

Ok, I've tried again and changed branch to master @ a2b45e15009f80ca1ad346840f2574bbe060fa94 commit instead to test and the colors also seem to be fine their now but if I try to launch with NVIDIA using DRI_PRIME=1 or launching with switcheroo it just crashes.

However I have been noticing during testing that some times its not consistent and I reboot once that starts.

Can anyone confirm its fixed in master, the fix might be before commit a2b45e15009f80ca1ad346840f2574bbe060fa94?

Stalkero commented 4 days ago

I can confirm after weeks of tests SDL_VIDEODRIVER=x11 fixes broken colors. No additional compiling etc. But what the heck is going on with wayland that makes this happen in the first place.

Pheoxy commented 3 days ago

I'll stick to SDL_VIDEODRIVER=x11 and --backend=sdl at the moment because the wayland backend still doesn't have copy/paste support last I checked, this is annoying in games like Warframe or with passwords that I usually just use my password manager for.