Última atividade 1723488943

Revisão 67a1a2eab170f3e36bea0af205ad7c0ad894c13c

00.gamescope_tips.md Bruto

gamescope

Preface

I'm using endeavourOS, KDE Plasma 6.1, a RTX 3080, nvidia-open-dkms 555.58-2, Wayland.

My main monitor is a Samsung Odyssey Neo G7 (3840x2160 165hz "HDR10") and my second is a Acer Predator XB271HU (1440x2560 165hz)


Ideally, these are my launch options for each game:

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

There are some issues with it:

  • Steam overlay and input won't work (-e flag is broken)
  • --mangoapp won't show some info
  • Performance is incredibly low after a while

and the workarounds...

Steam overlay and input

GitHub issue

Creating a gamescope window on the terminal and attaching the game to it will work, but HDR will be broken.

First I run this on a terminal:

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

I take note of the window's number on wlserver: [xwayland/server.c:107] Starting Xwayland on :2, then set the game's launch options:

DISPLAY=:x gamemoderun %command%

Where x is the display number. The game might take a while to open up and also to completely exit, but it works just fine, except for HDR.

There are some tweaks that could get HDR running, but I couldn't get it to work for me. To try it, I would run gamescope with the following variables:

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_GAMESCOPE_WSI=1 DXVK_HDR=1 DISPLAY=:1 gamemoderun %command%

but that's a no go for me. Check the GitHub issues for more info

mangohud and --mangoapp

It is recommended to run --mangoapp if using gamescope, however it won't display any GPU info. Running it as mangohud before %command% will show GPU info, but might have some other issues down the line. On both ways, information like HDR, FSR, gamemoderun status won't be displayed at all.

Performance

When you run gamescope, you might notice on the terminal something like

No CAP_SYS_NICE, falling back to regular-priority compute and threads. Performance will be affected.

Performance WILL be affected. After a while, your game will look like a slideshow, but your frame counter will still display the FPS as normal.

That means you have to set the niceness of gamescope. Run, as sudo:

setcap 'CAP_SYS_NICE=eip' $(which gamescope)`

It seems that after a while it loses its niceness, so I made a systemd service that runs on login, checking if the niceness is set, and setting it if it's not. Check the 01.gamescope-niceness.service

VRR

VRR (adaptive sync, GSYNC) will not work on NVIDIA cards if you have more than one monitor enabled on that card. A workaround is to have your extra monitors plugged in another GPU or on your motherboard if your CPU has an iGPU. I don't think NVIDIA has even recognised this issue.

While this is not a problem related to gamescope, mangohud or gamemoderun, I've added this section because it might come in handy.

Since I don have a second (i)GPU. I need to disable my extra monitors. I've made the 02.start-gamescope.sh script to be run as a launch parameter on the game, it'll start a gamescope window, turn off my extra display and start the game with gamemoderun and connecting it to the window. When quitting the game, the script turns the extra monitor back on and properly disposes of the gamescope window.

01.gamescope-niceness.service Bruto
1[Unit]
2Description=Check gamescope niceness and set it if needed
3After=network.target
4
5[Service]
6Type=oneshot
7User=root
8ExecStart=/bin/bash -c 'if getcap $(which gamescope) | grep -q "cap_sys_nice=eip"; then exit 0; else setcap "CAP_SYS_NICE=eip" $(which gamescope); fi'
9RemainAfterExit=yes
10
11ProtectSystem=full
12ProtectHome=read-only
13PrivateTmp=true
14NoNewPrivileges=true
15
16[Install]
17WantedBy=default.target
02.start-gamescope.sh Bruto
1#!/bin/sh
2
3echo "########## Starting a gamescope window"
4gamescope -W 3840 -H 2160 -r 165 --hdr-enabled --hdr-itm-enable --hdr-itm-sdr-nits 300 --hdr-sdr-content-nits 300 -f --mangoapp &
5
6# trying to trap the gamescope window so it can properly quit after exiting the game
7export gamescope_pid=$!
8trap "echo \"########## Killing gamescope window\" && kill -- $gamescope_pid" SIGINT SIGTERM EXIT
9
10
11sleep 1s
12
13if [ -n "$WAYLAND_DISPLAY" ] || [ "$XDG_SESSION_TYPE" == "wayland" ]; then
14 echo "########## We're Running on wayland"
15 export WLND=1
16fi
17
18sleep 1s
19
20echo "########## Disabling secondary monitor."
21if [ $WLND ]; then
22 kscreen-doctor output.DP-1.disable &>/dev/null
23fi
24
25sleep 1s
26
27DISPLAY=:1 gamemoderun "$@"
28
29sleep 1s
30
31echo "########## Enabling secondary monitor."
32if [ $WLND ]; then
33 kscreen-doctor output.DP-1.enable &>/dev/null
34 kscreen-doctor output.DP-1.position.0,0 output.DP-3.position.1440,200 &>/dev/null
35fi
36