Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for FSR 2 #615

Open
emersion opened this issue Sep 8, 2022 · 27 comments
Open

Add support for FSR 2 #615

emersion opened this issue Sep 8, 2022 · 27 comments
Labels
enhancement New feature or request

Comments

@emersion
Copy link
Collaborator

emersion commented Sep 8, 2022

No description provided.

@emersion emersion added the enhancement New feature or request label Sep 8, 2022
@DadSchoorse
Copy link
Collaborator

I really don't see how this would be possible. FSR2 needs depth and motion vectors which we don't have access to.

@Joshua-Ashton
Copy link
Collaborator

Joshua-Ashton commented Sep 8, 2022

@DadSchoorse I have a branch that can extract motion vectors on Deck here: https://github.com/Plagman/gamescope/tree/motion_vector_fun

May be interesting to hook up to this for for 'motion smoothing' for dropped frames. Using them to stretch the last frame out to fill in the gaps.

@DadSchoorse
Copy link
Collaborator

Even then we are still missing depth and viewport jitter.

@pchome
Copy link

pchome commented Sep 9, 2022

Maybe reshade depth addon could be used as shared library with minimal modifications (in case you may want to share your findings/fixes later)
https://github.com/crosire/reshade/blob/main/examples/07-generic_depth/generic_depth.cpp

DESCRIPTION = "Automatic depth buffer detection that works in the majority of games."

@estrogently
Copy link

You can provide input to FSR2 without depth or motion vectors using the reactive mask, though I don't know what it'll produce if you do that for the whole image.

As some areas of a rendered image do not leave a footprint in the depth buffer or include motion vectors, FSR2 provides support for a reactive mask texture which can be used to indicate to FSR2 where such areas are

@mercuriete
Copy link

Sorry for my little understanding but I have an idea that I don't know if is useful or not.

  1. Can you talk with the video IP block (VCE) and ask for MPEG motion compensation (motion vectors) of previous frames?
  2. It is possible to ask the Vulkan group to extend the API to allow the GPU to talk with the video block for such a task?

maybe I am totally wrong but I hope someone thinks my idea is useful.
thanks for your effort!

@lavilao
Copy link

lavilao commented Oct 15, 2022

Sorry for my little understanding but I have an idea that I don't know if is useful or not.

1. Can you talk with the video IP block (VCE) and ask for MPEG motion compensation (motion vectors) of previous frames?

2. It is possible to ask the Vulkan group to extend the API to allow the GPU to talk with the video block for such a task?

maybe I am totally wrong but I hope someone thinks my idea is useful. thanks for your effort!

1 wouldn't that be FSR 3? if you have access to that data (motion vectors) couldn't you interpolate frames?
2 I think thats what reshade does, and it gives access to depht to shaders like rtgi.

@charmandercha
Copy link

can this be a relevant paper for this question??

https://jcgt.org/published/0010/03/02/

@ruanformigoni
Copy link

ruanformigoni commented Dec 16, 2022

I didn't see it mentioned, there is TFAA by JakobPCoder, it uses an estimation of motion vectors and depth to implement "TAA" as a reshade shader. Here is a comparison with the original crysis:

No AA:
off

TFAA:
on

To use it:

  • Install vkBasalt

  • Configure reshade

    • Download the reshade shaders (clone the repo or download the files)
    • In vkBasalt.conf, set the paths to the downloaded repo:

    reshadeTexturePath = "/home/user/.config/vkBasalt/reshade/textures"
    reshadeIncludePath = "/home/user/.config/vkBasalt/reshade/shaders"

  • Download the TFAA files here and put them into the shaders folder.

  • Download the Motion Vector Approximation files here and put them into the shaders folder.

  • Set the path to the TFAA shader in vkBasalt.conf: tfaa = "/home/user/.config/vkBasalt/reshade/shaders/TFAA.fx".

  • Set the path to the DRME shader in vkBasalt.conf: drme = "/home/user/.config/vkBasalt/reshade/shaders/MotionEstimation.fx"

  • Configure the effects, e.g.: effects = smaa:fxaa:drme:tfaa.

@charmandercha
Copy link

With TFAA looks good, there is some way to use Color Buffer/Motion Vector Approximation to make FSR 2 on gamescope?

If TAA and FSR have similarities, can i presume that this will be possible in any way???

And Vkbasalt is descontinued, it's hard to do something like reshade GUI to use on gamescope ?? (to load reshade code etc)

@KayKay91
Copy link

Seems that AMD released a source code for FSR 2.2
https://community.amd.com/t5/gaming/amd-fsr-2-2-now-available-on-gpuopen-and-fsr-supported-in-250/ba-p/586393

@MilkFlavor
Copy link

any updates?

@laclcia
Copy link

laclcia commented Jun 30, 2023

i am also interested in FSR 2 support.
is there any progress in figuring out if it is possible? people seam to have a good amount of interesting/promissing idea in this thread and with the source open i hope this becomes possible.

@not-NEKO
Copy link

not-NEKO commented Aug 8, 2023

also interested

@SysError99
Copy link

I don't think it's possible due to the way FSR 2 works. It requires motion vector that's only available inside the game itself, and Gamescope has no way to know it. I think this can be closed as not solved?

@charmandercha
Copy link

TAA too, and there is some kind of solution provided by reshade to mimic the original TAA.

@pchome
Copy link

pchome commented Aug 18, 2023

Since FSR2 is the FSR1+builtin AA just slap an optional FXAA before FSR/NIR and call it a day ;)

Additionally if the FSR option enabled and any AA(add SMAA too, maybe) option not enabled then just warn in console that it is recommended to use AA with the FSR option and user should either enable AA in the game options or here.

I doubt there will be a big difference between the builtin fake motion/depth+FSR2 and the current any AA(external)+FSR1(gemascope). When using game's final image as a source.

@charmandercha
Copy link

But any AA external will be inject after FSR (gamescope), or not?

@pchome
Copy link

pchome commented Aug 21, 2023

@charmandercha

But any AA external will be inject after FSR (gamescope), or not?

It's a bit tricky but not impossible for user to control this.
For example try enable an AA vulkan layer before gamecope and disable before application (or keep and get "two pass AA" :) ).

ENABLE_AN_VKAA=1 gamescope -- env DISABLE_AN_VKAA=yesplease vkcube

IIRC vkbasalt have special handling in gamescope, try something else if it will not work.

If it will work then someone should benchmark this and show as some before/after screenshots, cpu/gpu load and fps ;) .

EDIT: or not. I'm tired and a bit confused now. Should try this by myself later.
Could be just gamescope -- env ENABLE_AN_VKAA=1 vkcube, we need to apply everything to application before gamescope will FSR it (?).

@SysError99
Copy link

SysError99 commented Aug 21, 2023

Since FSR2 is the FSR1+builtin AA just slap an optional FXAA before FSR/NIR and call it a day ;)

Although not exactly accurate but I fully support this. FSR + FXAA produces fine image even in low-res scenarios with few of extreme blurry spots and pixel artifacts. This is GTA V running at 621p upscaled to almost 1080p with internal FXAA and Gamescope's FSR enabled.
Screenshot_20230821_161424

@charmandercha
Copy link

Witch AA is more eficient?

There is any chance to use this method with lowest input possible and receive any good results?

Like 720p (trying to be realistic in there but i wanna 540p) to scale to 4K.

But there is anothers AA like CMAA2, somente know if there is version of it for vkbasalt? or another AA with results better than fxaa?

@pchome
Copy link

pchome commented Aug 25, 2023

So, FSR3 have the builtin AA ... good, let's do a poor man's FSR3 step-by-step ;)
(I'm not expert in this things, but I'm a random dude from the internet, so trust me)

  1. Prepare (game's side)

    • Disable some in-game post-fx
      Film grain, etc.
    • LOD Bias
      They have a formula but just experiment with the simple values like -0.4, -0.7 or -1. More is better for FSR but will introduce additional shimmering which will be "doubled" by FSR.
      I's e.g STRANGLE_PICMIP=-1 (libstrangle) or d3d11.samplerLodBias = -1.0 (dxvk)
    • AA
      Well, the maximum in-game or external AA you can afford.
      It's e.g effects = smaa:fxaa (vkbasalt)
    • Frame limiter
      Do not torture your HW, apps should not own all available system resources. Despite they usually act like they do.
      If crontab, notification, etc. will spawn in background during gameplay your framerate will go brrr.
      It's e.g. STRANGLE_VSYNC=0 STRANGLE_FPS=40 (libstrangle) or alternative.
    • "Frame generator" ;)
      It's e.g. STRANGLE_FPS=60 (libstrangle) and d3d9.presentInterval=2 or dxgi.syncInterval=2 (dxvk).
      In this case app will run at 30 fps but will look like 60 fps. Will cost you some in-game responsiveness though.
  2. "FSR" (Spatial Upscaling)
    I'm not completely sure if it should have built-in sharpening step enabled in our case. Also I didn't dug too much (at all) into the algorithm, but I think the sharpening step could be the separate step also. Either before or after the upscaling step (e.g. CAS via vkbasalt). Or even disabled.

    Via gamescope, fs-hack, etc.

    A real poor man could use the WM compositor's Zoom effect. I tried the KDE kwin zoom on an old screenshot from a random game (where I used negative lod bias, etc.) and the resulting image is kind-of acceptable.

  3. Post-process
    Add additional sharpening, post-fx, etc.

In case some people want to tinker a bit ;)

EDIT: For those wondering how to use pre- and post fx- with gamescope:
Since they disable vkbasalt env var here

unsetenv( "ENABLE_VKBASALT" );

it could be something like:
ENABLE_VKBASALT=1 VKBASALT_CONFIG_FILE=/path/to/post-fx.conf gamescope -- env ENABLE_VKBASALT=1 VKBASALT_CONFIG_FILE=/path/to/fx.conf run_game

Full variant:
ENABLE_VKBASALT=1 VKBASALT_CONFIG_FILE=/path/to/post-fx.conf gamescope -- env ENABLE_VKBASALT=1 VKBASALT_CONFIG_FILE=/path/to/fx.conf ENABLE_VK_LAYER_TORKEL104_libstrangle=1 STRANGLE_VSYNC=0 STRANGLE_FPS=60 DXVK_CONFIG="[gamename.exe];d3d11.samplerLodBias=-1.0;dxgi.syncInterval=2" run_game

I didn't tested it though.

@charmandercha
Copy link

charmandercha commented Aug 25, 2023

Replying to #615 (comment)

I did not understand anything but it's because i do not know anything about this things lol

But, if anyone tries this visually enhancing method, could they post it here for others to see?

@BrandowLucas
Copy link

+1

@superkeka
Copy link

@KingKrouch
Copy link

I am wondering, with AFMF finally released, if there's a way Gamescope will get an equivalent to that, as it essentially works with any DirectX 11 or 12 game that uses Flip Composition (And this can include OpenGL and Vulkan games with an interop or AMD's OpenGL optimizations option in their control panel).

@shinfo44
Copy link

+1 for this request please!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests