ValveSoftware / gamescope

SteamOS session compositing window manager
Other
2.84k stars 189 forks source link

HDR washed out colours when running gamescope on a separate terminal #1404

Open Virkkunen opened 4 days ago

Virkkunen commented 4 days ago

My system info:


Title can be a bit confusing, but here's the situation:

When I run a HDR capable game with the following launch options:

gamescope -W 3840 -H 2160 -r 165 --hdr-enabled --hdr-itm-enable --hdr-itm-sdr-nits 300 --hdr-sdr-content-nits 300 -f -e --mangoapp -- gamemoderun %command%

I'm able to have HDR working without issues. The logs show the following:

xdg_backend: PreferredMetadata: Red: 0.708 0.292, Green: 0.17 0.797, Blue: 0.131 0.046, White: 0.3127 0.329, Max Luminance: 1015 nits, Min Luminance: 0 nits, Max Full Frame Luminance: 351 nits
josh edid: Patching res 800x1280 -> 3840x2160
pipewire: renegotiating stream params (size: 3840x2160)
gamemodeauto: 
wlserver: [types/wlr_compositor.c:771] New wlr_surface 0x61b093b1c810 (res 0x61b093b49df0)
[Gamescope WSI] Creating Gamescope surface: xid: 0x1400081
[Gamescope WSI] Atom of T was wrong type. Expected XCB_ATOM_CARDINAL.
wlserver: [types/wlr_compositor.c:771] New wlr_surface 0x61b093bc6580 (res 0x61b093b5c9e0)
[Gamescope WSI] Made gamescope surface for xid: 0x1400081
[Gamescope WSI] Surface state:
  steam app id:                  1778820
  window xid:                    0x1400081
  wayland surface res id:        5
  layer client flags:            0x4
  server hdr output enabled:     true
  hdr formats exposed to client: true
xwm: got the same buffer committed twice, ignoring.
[Gamescope WSI] Creating swapchain for xid: 0x1400081 - minImageCount: 3 - format: VK_FORMAT_A2B10G10R10_UNORM_PACK32 - colorspace: VK_COLOR_SPACE_SRGB_NONLINEAR_KHR - flip: true
[Gamescope WSI] Created swapchain for xid: 0x1400081 - imageCount: 3

As you can see, the HDR info is being properly passed on to my display/compositor. The following pictures were taken with ISO 100 23mm F1.8 1/20s WB 6000K (the pictures might not look good but trust me, HDR is on and working perfectly here)

20240704_094945 20240704_095639

Also note that mangohud displays HDR: ON

image

The problem with running games this way is that both Steam Overlay and Steam Input do not work at all. A workaround is to create a gamescope window on a separate terminal, and connect the game to that display. So I run this on a terminal, to create my gamescope window:

gamescope -W 3840 -H 2160 -r 165 --hdr-enabled --hdr-itm-enable --hdr-itm-sdr-nits 300 --hdr-sdr-content-nits 300 -f --mangoapp

This creates gamescope as display :1, so on my game launch options I use:

DISPLAY=:1 gamemoderun %command%

However, HDR does not work this way. Logs only show:

xdg_backend: PreferredMetadata: Red: 0.708 0.292, Green: 0.17 0.797, Blue: 0.131 0.046, White: 0.3127 0.329, Max Luminance: 1015 nits, Min Luminance: 0 nits, Max Full Frame Luminance: 351 nits
pipewire: renegotiating stream params (size: 1440x2560)
pipewire: renegotiating stream params (size: 3840x2160)

And I'm unable to enable HDR on the game's settings. There is a workaround for this, which is to manually set some env flags for both the window and gamescope:

DXVK_HDR=1 gamescope -W 3840 -H 2160 -r 165 --hdr-enabled --hdr-itm-enable --hdr-itm-sdr-nits 300 --hdr-sdr-content-nits 300 -f --mangoapp

And the launch parameters

ENABLE_HDR_WSI=1 DXVK_HDR=1 DISPLAY=:1 gamemoderun %command%

This way, I'm able to enable HDR on my game, but it seems that it's just forcing HDR to be enabled without passing the correct information to my display, as shown by the logs and the pictures (taken with the same configuration as the previous ones). Mangohud/mangoapp also do not display the HDR status, probably because it isn't actually working:

xdg_backend: PreferredMetadata: Red: 0.708 0.292, Green: 0.17 0.797, Blue: 0.131 0.046, White: 0.3127 0.329, Max Luminance: 1015 nits, Min Luminance: 0 nits, Max Full Frame Luminance: 351 nits
josh edid: Patching res 800x1280 -> 3840x2160
pipewire: renegotiating stream params (size: 3840x2160)

20240704_095425 20240704_095524


Let me know if I'm missing any logs or info that could be useful (and how to take them)

sharkautarch commented 4 days ago

@Virkkunen Try adding ENABLE_GAMESCOPE_WSI=1 to the launch options: ENABLE_GAMESCOPE_WSI=1 ENABLE_HDR_WSI=1 DXVK_HDR=1 DISPLAY=:1 gamemoderun %command%

normally gamescope sets that environment variable automatically, in your case you have to set it yourself

Virkkunen commented 4 days ago

Unfortunately that had no effect. I also tried with --hdr-debug-force-output and nothing. It allows the game to enable HDR, but the information is not passed to my display.

With that env variable, the only relevant parts of the log I could find, related to HDR were these:

xdg_backend: PreferredMetadata: Red: 0.708 0.292, Green: 0.17 0.797, Blue: 0.131 0.046, White: 0.3127 0.329, Max Luminance: 1015 nits, Min Luminance: 0 nits, Max Full Frame Luminance: 351 nits
josh edid: Patching res 800x1280 -> 3840x2160
pipewire: renegotiating stream params (size: 3840x2160)
[Gamescope WSI] Forcing on VK_EXT_swapchain_maintenance1.

When I set the parameters as gamescope -W 3840 -H 2160 -r 165 --hdr-enabled --hdr-itm-enable --hdr-itm-sdr-nits 300 --hdr-sdr-content-nits 300 -f -e --mangoapp -- gamemoderun %command%, whenever I toggle HDR in my game I get this:

[Gamescope WSI] Creating swapchain for xid: 0x1400081 - minImageCount: 3 - format: VK_FORMAT_A2B10G10R10_UNORM_PACK32 - colorspace: VK_COLOR_SPACE_SRGB_NONLINEAR_KHR - flip: true
[Gamescope WSI] Created swapchain for xid: 0x1400081 - imageCount: 3
[Gamescope WSI] Creating swapchain for xid: 0x1400081 - minImageCount: 3 - format: VK_FORMAT_A2B10G10R10_UNORM_PACK32 - colorspace: VK_COLOR_SPACE_HDR10_ST2084_EXT - flip: true
[Gamescope WSI] Created swapchain for xid: 0x1400081 - imageCount: 3

With VK_COLOR_SPACE_SRGB_NONLINEAR_KHR when it's off and VK_COLOR_SPACE_HDR10_ST2084_EXT when it's on. The problem is that the second method (creating a gamescope window on a tty and attaching the game to it) cannot properly create a gamescope surface and pass its info to my display, it seems. I'd expect to find logs like

[Gamescope WSI] Made gamescope surface for xid: 0x1400081
[Gamescope WSI] Surface state:
  steam app id:                  1778820
  window xid:                    0x1400081
  wayland surface res id:        5
  layer client flags:            0x4
  server hdr output enabled:     true
  hdr formats exposed to client: true

but cannot find anything this way.

Joshua-Ashton commented 4 days ago

You need GAMESCOPE_WAYLAND_DISPLAY to be set to the right gamescope display, you need DXVK_HDR=1, you need ENABLE_GAMESCOPE_WSI=1.

Really you should probably just launch the game with Gamescope. The overlay thing is a sore point right now, but hopefully I can look into it soon by changing how the LD_PRELOAD stuff works there.

I also should probably add a gamescopectl command to launch inside gamescope, or a command for Gamescope to launch inside the existing gamescope if it can.

Virkkunen commented 4 days ago

You need GAMESCOPE_WAYLAND_DISPLAY to be set to the right gamescope display

You mean by having GAMESCOPE_WAYLAND_DISPLAY=:1 instead of just DISPLAY=:1 on my launch parameters? I tried doing that but unfortunately it's the same result, no actual HDR.

I wanted to run this workaround because if not, then both the overlay and input won't work, mostly because of the Steam input to be fair (and now game recording since it's quite convenient), but I understand there's some quirks to be worked out yet, it's all fair.


The overlay thing is a sore point right now, but hopefully I can look into it soon by changing how the LD_PRELOAD stuff works there.

I have noticed a lot of ERROR: ld.so: object '/home/vrkknn/.local/share/Steam/ubuntu12_32/gameoverlayrenderer.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS32): ignored. whenever I run gamescope; I'd love to be able to help troubleshooting this one, but I know it's another ticket/issue.

Joshua-Ashton commented 4 days ago

Gamescope waylabd display is like gamescope-0.

The elf32 thing is a red berring meaningless warning

Virkkunen commented 3 days ago

I still haven't had any luck with that. I've checked and my gamescope creates a gamescope-0 and :1 window, so I tried:

20240704_070646

Honestly I couldn't find anything different on the logs too. Maybe it's better if I just wait for one of the fixes or workarounds you've mentioned whenever possible.