Skip to content

Commit

Permalink
Added option to set upscaler filter
Browse files Browse the repository at this point in the history
- Removed options to set filters explicitly (-n, -U, -Y)
- Changed scaler option from -s to -S
- Reordered usage slightly
  • Loading branch information
Root-Core authored and Joshua-Ashton committed Jun 14, 2023
1 parent a7c60be commit 7a1fe2d
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 24 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ On any X11 or Wayland desktop, you can set the Steam launch arguments of your ga

```sh
# Upscale a 720p game to 1440p with integer scaling
gamescope -h 720 -H 1440 -s integer -- %command%
gamescope -h 720 -H 1440 -S integer -- %command%

# Limit a vsynced game to 30 FPS
gamescope -r 30 -- %command%
Expand All @@ -63,9 +63,9 @@ See `gamescope --help` for a full list of options.
* `-w`, `-h`: set the resolution used by the game. If `-h` is specified but `-w` isn't, a 16:9 aspect ratio is assumed. Defaults to the values specified in `-W` and `-H`.
* `-r`: set a frame-rate limit for the game. Specified in frames per second. Defaults to unlimited.
* `-o`: set a frame-rate limit for the game when unfocused. Specified in frames per second. Defaults to unlimited.
* `-U`: use AMD FidelityFX™ Super Resolution 1.0 for upscaling
* `-Y`: use NVIDIA Image Scaling v1.0.3 for upscaling
* `-s integer`: use integer scaling.
* `-s stretch`: use stretch scaling, the game will fill the window. (e.g. 4:3 to 16:9)
* `-F fsr`: use AMD FidelityFX™ Super Resolution 1.0 for upscaling
* `-F nis`: use NVIDIA Image Scaling v1.0.3 for upscaling
* `-S integer`: use integer scaling.
* `-S stretch`: use stretch scaling, the game will fill the window. (e.g. 4:3 to 16:9)
* `-b`: create a border-less window.
* `-f`: create a full-screen window.
46 changes: 27 additions & 19 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,10 @@ const struct option *gamescope_options = (struct option[]){
{ "nested-height", required_argument, nullptr, 'h' },
{ "nested-refresh", required_argument, nullptr, 'r' },
{ "max-scale", required_argument, nullptr, 'm' },
{ "scaler", required_argument, nullptr, 's' },
{ "scaler", required_argument, nullptr, 'S' },
{ "filter", required_argument, nullptr, 'F' },
{ "output-width", required_argument, nullptr, 'W' },
{ "output-height", required_argument, nullptr, 'H' },
{ "nearest-neighbor-filter", no_argument, nullptr, 'n' },
{ "fsr-upscaling", no_argument, nullptr, 'U' },
{ "nis-upscaling", no_argument, nullptr, 'Y' },
{ "sharpness", required_argument, nullptr, 0 },
{ "fsr-sharpness", required_argument, nullptr, 0 },
{ "rt", no_argument, nullptr, 0 },
Expand Down Expand Up @@ -133,16 +131,16 @@ const char usage[] =
"\n"
"Options:\n"
" --help show help message\n"
" -W, --output-width output width\n"
" -H, --output-height output height\n"
" -w, --nested-width game width\n"
" -h, --nested-height game height\n"
" -r, --nested-refresh game refresh rate (frames per second)\n"
" -m, --max-scale maximum scale factor\n"
" -s, --scaler force scaler type (auto, integer, fit, fill, stretch)\n"
" -W, --output-width output width\n"
" -H, --output-height output height\n"
" -n, --nearest-neighbor-filter use nearest neighbor filtering\n"
" -U, --fsr-upscaling use AMD FidelityFX™ Super Resolution 1.0 for upscaling\n"
" -Y, --nis-upscaling use NVIDIA Image Scaling v1.0.3 for upscaling\n"
" -S, --scaler upscaler type (auto, integer, fit, fill, stretch)\n"
" -F, --filter upscaler filter (linear, nearest, fsr, nis)\n"
" fsr => AMD FidelityFX™ Super Resolution 1.0\n"
" nis => NVIDIA Image Scaling v1.0.3\n"
" --sharpness, --fsr-sharpness upscaler sharpness from 0 (max) to 20 (min)\n"
" --expose-wayland support wayland clients using xdg-shell\n"
" --cursor path to default cursor image\n"
Expand Down Expand Up @@ -355,6 +353,22 @@ static enum GamescopeUpscaleScaler parse_upscaler_scaler(const char *str)
}
}

static enum GamescopeUpscaleFilter parse_upscaler_filter(const char *str)
{
if (strcmp(str, "linear") == 0) {
return GamescopeUpscaleFilter::LINEAR;
} else if (strcmp(str, "nearest") == 0) {
return GamescopeUpscaleFilter::NEAREST;
} else if (strcmp(str, "fsr") == 0) {
return GamescopeUpscaleFilter::FSR;
} else if (strcmp(str, "nis") == 0) {
return GamescopeUpscaleFilter::NIS;
} else {
fprintf( stderr, "gamescope: invalid value for --filter\n" );
exit(1);
}
}

static void handle_signal( int sig )
{
switch ( sig ) {
Expand Down Expand Up @@ -473,11 +487,11 @@ int main(int argc, char **argv)
case 'm':
g_flMaxWindowScale = atof( optarg );
break;
case 's':
case 'S':
g_wantedUpscaleScaler = parse_upscaler_scaler(optarg);
break;
case 'n':
g_wantedUpscaleFilter = GamescopeUpscaleFilter::NEAREST;
case 'F':
g_wantedUpscaleFilter = parse_upscaler_filter(optarg);
break;
case 'b':
g_bBorderlessOutputWindow = true;
Expand All @@ -488,12 +502,6 @@ int main(int argc, char **argv)
case 'O':
g_sOutputName = optarg;
break;
case 'U':
g_wantedUpscaleFilter = GamescopeUpscaleFilter::FSR;
break;
case 'Y':
g_wantedUpscaleFilter = GamescopeUpscaleFilter::NIS;
break;
case 'g':
g_bGrabbed = true;
break;
Expand Down

0 comments on commit 7a1fe2d

Please sign in to comment.