gamescope icon indicating copy to clipboard operation
gamescope copied to clipboard

Games running in gamescope have broken colors

Open Stalkero opened this issue 1 year ago • 4 comments

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

Stalkero avatar Aug 20 '24 21:08 Stalkero

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

gitiy1 avatar Sep 07 '24 04:09 gitiy1

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>

sharkautarch avatar Sep 07 '24 13:09 sharkautarch

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

Pheoxy avatar Sep 08 '24 15:09 Pheoxy

@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:

  • see if switching your desktop kwin to use x11 reduces stuttering
  • try setting gamescope's nested refresh rate to double your actual refresh rate
  • try running gamescope w/ this env var: MESA_VK_WSI_PRESENT_MODE=immediate

sharkautarch avatar Sep 08 '24 15:09 sharkautarch

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

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

Stalkero avatar Sep 17 '24 07:09 Stalkero

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 avatar Sep 17 '24 09:09 Pheoxy

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 avatar Sep 17 '24 11:09 Pheoxy

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?

Pheoxy avatar Sep 17 '24 13:09 Pheoxy

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.

Stalkero avatar Sep 24 '24 18:09 Stalkero

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.

Pheoxy avatar Sep 25 '24 18:09 Pheoxy

I have the same problem on my machine !

The difference is, I'm using gamescope to scale up the resolution because I have a HiDPI screen. The fix SDL_VIDEODRIVER=x11 is basically useless

Lygaen avatar May 21 '25 19:05 Lygaen

Same problem on Proxmox/Arch VM with GPU passthrough to NVIDIA 3080 / Arc 310, using Hyprland. I'm not sure if I can somehow use gamescope with Intel card while game renders on NVIDIA. I believe I had color problem even when specifying gamescope to use Arc 310 for compositing. Tested it on Steam, game is No Man's Sky.

NVIDIA Driver Version: 575.57.08
gamescope version 3.16.9+ (gcc 15.1.1)

$ lspci -k -d ::03xx
01:00.0 VGA compatible controller: NVIDIA Corporation GA102 [GeForce RTX 3080 12GB] (rev a1)
	Subsystem: Micro-Star International Co., Ltd. [MSI] Device 389b
	Kernel driver in use: nvidia
lspci: Unable to load libkmod resources: error -2
03:00.0 VGA compatible controller: Intel Corporation DG2 [Arc A310] (rev 05)
	Subsystem: Device 172f:4240
	Kernel driver in use: i915

The SDL_VIDEODRIVER=x11 helped me, I have tried playing the game for around 4 hours, there were no issues.

konovalov-nk avatar Jun 01 '25 02:06 konovalov-nk