Gamescope

From LinuxReviews
Jump to navigationJump to search
Gamescope
Original author(s)Pierre-Loup "Plagman" A. Griffais
Repositorygithub.com/Plagman/gamescope/
Written inC++
Operating systemLinux
PlatformX, Wayland
Joystick-icon.png

Gamescope is a really handy tool that lets you up-scale and play any game or graphical application full screen or in a large window while telling the game that it is running on a monitor with a lower resolution - if you have a AMD GPU using the Mesa drivers. It will not work with other graphics cards or drivers. It is, behind the scenes, a bare-bones Wayland compositor that works fine with both the X and Wayland display servers on Linux.

Any in-game support is not required to use Gamescope. Gamescope starts a nested Wayland server at the resolution you want a game to run at and that becomes your true screen resolution as far as the games are concerned. Gamescope will up-scale that nested Wayland server so it is rendered full-screen or at any desired resolution.

Features And Usability

Gamescope upscaling a scene demo in wine from 720p to 1440p.jpg
Gamescope up-scaling a scene demo in Wine from 720p to a 1440p window.

Gamescope is specially useful for three kinds of games and applications:

  • Newer games that run too slow at the resolution you would like them to run at (you can render games at 720p and play at 4k)
  • Very old games insisting on running in a tiny (like 320x200) window (ie. xrick).
  • Games and applications who insit on running full-screen with no option to make them appear in a window if a window is what you want for a particular game or application (many scene demos will only run full screen at your current resolution).

gamescope is something you will have to use from the command-line or use by creating bash scripts or .desktop files calling it. It does not have any graphical configuration interface or anything like that.

The way to run gamescope is:

gamescope -option value -more_options more_values -- application

Notice that you need to enter -- between gamescope and the arguments for it and the executable file you want to run.

gamescope is only useful if give it some command-line options and a executable. The arguments that are the most important are:

-w The width the games/applications will see and run at
-h The height the games/applications will see and run at

There are, additionally, -W and -H arguments that should not be confused with -w and -h:

-W The width of the gamescope output window you will see
-H The height of the gamescope output window you will see

The -W and -H options will be "updated" (changed) if you flip the game to full-screen or re-size the window the game is running in.

Switching to full-screen is very easy thanks to one of the only three keyboard shortcuts that are available in gamescope:

Super+f Make the window full-screen
Super+n Toggle integer scaling on/off
Super+s Take a screenshot (those are saved as .bmp files in /tmp/gamescope_$DATE.bmp. The location and name is not configurable - well, not unless you consider hand-editing src/rendervulkan.cpp and re-compiling "configurable"..)

There are, additionally, five other command-line options you may want to use.

-r Set a frame-limit in frames per second (like 30 or 60). Defaults to unlimited.
-o Set a frame-limit in frames per second (like 30 or 60) when it is unfocused. Defaults to unlimited. Setting this to something very low like 2 or 10 will prevent games from heavily loading the game if you take a pause from a game while leaving it's window open.
-n Toggle integer scaling on/off. There is a visible difference between the default scaling and integer scaling.
-f Start the game full-screen
-b Start in a border-less window

To recap: If you want the game to run at 720p, as if you were using a 720p monitor as far as the game is concerned, you need to use -w and -h to specify the resolution the game sees and add -- and the application you want to run:

gamescope -w 1280 -h 720 -- wine Asahi_by_Futuris.exe

..and if you want that game running at 720p output to a 1440p border-less window, you need to add -b for border-less window and -W and -H to specify the size of the output window:

gamescope -w 1280 -h 720 -b -W 2626 -H 1440 -- wine Asahi_by_Futuris.exe
Lovelyz Kei ProTip.jpg
TIP: You do not need to bother with the -W and -H options if you just want to run a game output full screen. Just set the -w and -h sizes you want the game to think your screen resolution with and press super+f once you have launched your game - or add -f to the gamescope launch options.

Entering long command-line commands is a bit tiresome, so you can create simple files that run it such as:

File: $HOME/bin/gamescope-1080p
#!/bin/sh
# Run at:   -w 1920 -h 1080 
# Scale to: -W 1920 -H 1080
gamescope -w 1920 -h 1080 -n -- $*

and

File: $HOME/bin/gamescope-1080p-to-4k
#!/bin/sh
# run at:   -w 1920 -h 1080
# scale to: -W 1920 -H 1080
gamescope -w 1920 -h 1080 -W 3840 -H 2160 -n -- $*

Those would let you run gamescope-1080p coolgame or gamescope-1080p-to-4k coolgame to run at game at 1080p.

One disadvantage of using the above scripts is that whatever arguments you give them will come after the -- separating gamescope arguments from the game executable and it's arguments - so gamescope-1080p -f coolgame will not work with those scripts.

Scaling Options

Gamescope defaults to simple linear scaling. Enabling integer scaling will make many games look better. It isn't really integer scaling.

"Integer scaling is actually a bit of a simplification since it doesn't force the scale factor to be an integer, but -n is a needed piece of achieving integer scaling.

It just removes the filtering from the scale so the pixels are nice and crisp

Without -n it's linear filtering, with -n it's nearest/point filtering"

Plagman, April 27th, 2021

You can toggle "integer" scaling on/off in-game with super+n to see the difference. It is pretty apparent if you up-scale games running at really low resolutions (like 320x200) to 4K.

Performance

Gamescope uses Vulkan async compute to render the up-scaled image. It's not free, it doesn't necessarily come with a performance penalty.

UNIGINE Superposition, 1080p Medium (higher is better)
Final Fantasy XIV Stormblood Benchmark in Wine 6.7 with DXVK 1.8.1, 1080p

The UNIGINE Superposition benchmark at 1080p medium scores slightly slower in Gamescope. The Final Fantasy XIV Stormblood Benchmark in Wine, on the other hand, scores slightly higher in Gamescope, up-scaled from 1080p to 1440p, than it does in a native 1080p Xorg window.

The Capcom Street Fighter V Benchmark at 1080p with "Picture Quality Max", in Wine 6.7 with DXVK 1.8.1, scores 59.9 fps (it is capped at 60) with our without Gamescope up-scaling it to 1440p.

All these benchmarks were done with "integer" scaling enabled. It does not seem to make any difference if linear or integer scaling is used performance-wise.

Verdict And Conclusion

Xrick-in-gamescope.jpg
''Xrick, an old game meant to be ran at 320x200 resolution, in gamescope. Xrick does have a -zoom options that takes arguments up to four (=1280x1200). gamescope lets you up-scale it to 4k.

gamescope is really useful and it is definitively something worth installing - as long as you have a AMD graphics card and you use the standard Mesa graphics drivers. It simply does not work with graphics cards from other brands. That may change in the future, but as of April 2021 you're out of luck if you do not have a AMD graphics card.

gamescope is meant for games, thought here is another use-case where it is rather useful: A lot of scene demos insist on running full-screen at the displays native resolution. That is far from ideal if you have a 4K display because it is nice for desktop use and it's only powered by an older mid-range graphics card like a AMD RX 570. gamescope is a really handy way to force everything insisting on running full-screen at native resolution into running into a lower resolution that's more ideal with output at the displays native resolution.

Support For Non-AMD Graphics Cards

It may become possible to use Gamescope on Intel graphics hardware in the future. See https://github.com/Plagman/gamescope/issues/49 to get an idea of how that is progressing. It is, for now, just for AMD graphics cards.

Installation

Some GNU/Linux distributions have packages for Gamescope in their repositories, some do not. Using the distribution-provided package is easiest if Gamescope is available in the regular repositories.

Installing all the required dependencies (like the wayland server, meson and ninja) is the biggest hurdle if you choose to compile it from source. What those are will depend on your distribution. Checking out the source code and compiling it is very strait forward if, and only if, you are using GCC version prior to GCC 11.x.

mkdir $HOME/src;cd $HOME/src
git clone https://github.com/Plagman/gamescope.git
cd gamescope/
git submodule init
git submodule update
meson build 
cd build
ninja
sudo ninja install

See Also

  • The Current State Of Gamescope, an article we wrote about it in September 2020. It has a video with Pierre-Loup A Griffais talking about Gamescope at the X.Org Developers Conference 2020.

Links

The gamescope source code repository is at https://github.com/Plagman/gamescope/


Add your comment
LinuxReviews welcomes all comments. If you do not want to be anonymous, register or log in. It is free.