Vendor and game agnostic latency reduction middleware. An alternative to NVIDIA Reflex.

Overview

LatencyFleX (LFX)

Vendor and game agnostic latency reduction middleware. An alternative to NVIDIA Reflex.

Why LatencyFleX?

There is a phenomenon commonly known among gamers, where input lag would increase when the game FPS is left uncapped and the game reaches maximum GPU utilization. [video]

The reason this happens is that GPU work is dispatched asynchronously, and when the GPU reaches maximum utilization, it fails to catch up to the CPU and creates a queue of work, resulting in extra latency.

The traditional solution to this was to cap the framerate at the highest number the machine can sustain: it creates a CPU-bound scenario, and combined with variable refresh-rate support like FreeSync, it could consistently achieve the lowest possible input lag. The obvious drawback with this method is that the limit sacrifices the frame rate even when machine could run at a higher frame rate.

LatencyFleX is an easy-to-integrate solution that achieves the same minimal latency as capping the frame rate, while dynamically adapting to workload, unleashing the system's full rendering potential. It takes inspiration from researches in internet congestion control, where a similar problem called Bufferbloat has been studied.

Limitations

  • LatencyFleX current does not provide any benefits when VSync is enabled.
    This is blocked on presentation timing support.
  • LatencyFleX introduces jitter in frame time as a part of its algorithm, which results in microstutters.
    Though, most games tend to have a larger frame time fluctuation already, so this is likely unperceivable.

Known issues

  • Minor stutters might happen during gaming session. The algorithm is still being tuned, but open an issue if the stutter is severe.
  • GPU utilization will be lower when running with LatencyFleX. Overall LatencyFleX should be able to achieve ~95% utilization (assuming GPU bound). Open an issue if utilization is significantly low.

Building from source

The layer (layer/) depends on CMake, Meson and the Vulkan SDK.

Build and install with:

cd layer
meson build
ninja -C build
meson install -C build --skip-subprojects

The Wine extension (layer/wine/) additionally depends on a Wine installation.

Build with:

cd layer/wine
export LIBRARY_PATH="$PWD/../build/" # Required if the layer has not been installed globally
meson build
ninja -C build

See install instructions for the locations to copy the files to.

Installation

LatencyFleX Vulkan layer (essential)

For Debian-like distros, copy the following files from release artifacts to your root filesystem.

/usr/lib/x86_64-linux-gnu/liblatencyflex_layer.so
/usr/share/vulkan/implicit_layer.d/latencyflex.json

For Arch-like distros, you need to copy /usr/lib/x86_64-linux-gnu/liblatencyflex_layer.so -> /usr/lib/liblatencyflex_layer.so and additionally update the path specified in /usr/share/vulkan/implicit_layer.d/latencyflex.json.

LatencyFleX Wine extensions (required for Proton Reflex integration)

Copy the following files from release artifacts to your Wine installation location.

For Wine 7.x (including Proton-GE-Custom): change /usr/lib/wine to wherever Wine/Proton is installed. For Proton and certain distros, you also need to change lib to lib64. Copy the following files.

/usr/lib/wine/x86_64-unix/latencyflex_wine.dll.so
/usr/lib/wine/x86_64-windows/latencyflex_wine.dll

For Wine <= 6.x and current Proton versions: copy the files as follows:

/usr/lib/wine/x86_64-unix/latencyflex_wine.dll.so -> lib64/wine/latencyflex_wine.dll.so
/usr/lib/wine/x86_64-windows/latencyflex_wine.dll -> lib64/wine/fakedlls/latencyflex_wine.dll

DXVK-NVAPI with LatencyFleX integration (required for Proton Reflex integration)

Obtain binaries from GitHub Actions.

For Proton, copy nvapi64.dll into dist/lib64/wine/nvapi.

For other Wine installations, see DXVK-NVAPI documentation.

MangoHud with metric support (optional)

Obtain binaries from GitHub Actions and install it to your system.

Put the following line in MangoHud.conf to have real-time latency metrics:

graphs=custom_Latency

Usage

For now, LatencyFleX can be used through one of the following injection method. Game engine integration is planned.

Running games with LatencyFleX

Warning: Avoid using LatencyFleX with anti-cheat enabled games! It can almost certainly get you banned.

Tested games:

Game Support Method
Splitgate Linux UE4 Hook
Ghostrunner Proton NVAPI

Game supported but not in list? File a PR to update the table.

Proton NVAPI (for games that already have NVIDIA Reflex integration)

Install the Vulkan layer, wine extension and the modified branch of DXVK-NVAPI.

Put the following in dxvk.conf (only for DX11 games):

dxgi.nvapiHack = False
dxgi.customVendorId = 10de # If running on non-NVIDIA GPU

Launch with the following environment variables:

PROTON_ENABLE_NVAPI=1 DXVK_NVAPI_DRIVER_VERSION=49729 DXVK_NVAPI_ALLOW_OTHER_DRIVERS=1 LFX=1 %command%

UE4 Hook

Note: for now, the UE4 hook only supports Linux UE4 builds with PIE disabled.

Install the Vulkan layer.

The first step is to obtain an offset to FEngineLoop::Tick. If the game ships with debug symbols, the offset can be obtained with the command:

readelf -Ws PortalWars/Binaries/Linux/PortalWars-Linux-Shipping.debug | c++filt | grep FEngineLoop::Tick

Find the line corresponding to the actual function (other entries are for types used in the function and unrelated):

268: 00000000026698e0  9876 FUNC    LOCAL  HIDDEN    15 FEngineLoop::Tick()

Here 26698e0 is the offset we need. We will call it <OFFSET> below.

Then, modify the launch command-line as follows.

LFX=1 LFX_UE4_HOOK=0x<OFFSET> %command%
Issues
  • Microstutter fix suggestion: wake early and spin.

    Microstutter fix suggestion: wake early and spin.

    Looking through the code I notice you wait for the OS scheduler to wake on time and then begin the frame.

    The problem with this model is the accuracy of the OS thread scheduler.

    Blocks the execution of the current thread for at least the specified sleep_duration. This function may block for longer than sleep_duration due to scheduling or resource contention delays. The standard recommends that a steady clock is used to measure the duration. If an implementation uses a system clock instead, the wait time may also be sensitive to clock adjustments.

    I would suggest we wake early using some sort of bias and then spin checking the clock until we meet the deadline.

    I'm just setting up a dev environment now. :)

    opened by YellowOnion 13
  • Not working

    Not working

    Checked everything according to the guide. https://github.com/ishitatsuyuki/LatencyFleX/blob/master/docs/TROUBLESHOOTING.md At the end of the log file is :

    ../builtin.cpp: Querying MemoryWineUnixFuncs failed c0000135
    ../builtin.cpp: Look for library loading errors in the log and check if liblatencyflex_layer.so is installed on your system.
    

    latencyflex_layer.so is in /usr/lib/wine/x86_64-unix/ and /usr/lib64/wine/x86_64-unix/, and liblatencyflex_layer.so is also in /usr/lib/

    opened by guglovich 13
  • Apex Legends does not allow to enable Reflex

    Apex Legends does not allow to enable Reflex

    Trying to enable the middleware on Apex Legends, but game doesn't seem to allow me to enable it.

    What I've done, have I missed anything?

    • Installed latencyflex and latencyflex-wine
    • Copied nvapi.dll64 to steamapps/common/Proton - Experimental/files/lib64/wine/nvapi/
    • Added dxvk.conf to steamapps/common/Apex Legends/ as described in README
    • Symlinked latencyflex_layer.dll and latencyflex_wine.dll from /usr/lib/wine/x86_64-windows/ into steamapps/compatdata/1172470/pfx/drive_c/windows/system32/
    • Added launch parameters PROTON_ENABLE_NVAPI=1 DXVK_NVAPI_DRIVER_VERSION=49729 DXVK_NVAPI_ALLOW_OTHER_DRIVERS=1 LFX=1 %command%

    Full Log (with DXVK_NVAPI_LOG_LEVEL=info).

    System: Arch Linux 5.16.10 GPU: Radeon RX590 Driver: Mesa 21.3.6

    opened by valters-tomsons 8
  • Deep Rock Galactic support

    Deep Rock Galactic support

    As of 6 days ago, Deep Rock Galactic supports Nvidia Reflex.

    However, I enabled LatencyFlex, and once I click "continue" on the initial loading screen, the game freezes and crashes during the "initializing" splash screen while loading into the spacerig. Disabling Mangohud causes the crash to go away, but Nvidia Reflex is still greyed out in-game, despite having it working with the same launch options and same proton version as Apex, where it is working fine.

    The option stayed greyed out no matter if I selected DX11 vs DX12, fullscreen vs borderlerss windows, fps cap enabled vs disabled, etc. V-sync was disabled for all testing.

    I know it's not a competitive game, so reflex isn't too necessary, but still neat that another linux game has it.

    opened by neilunger 4
  • Confusion about finding UE4 Hook offset for Splitgate

    Confusion about finding UE4 Hook offset for Splitgate

    The readme instructions for setting up the UE4 Hook offset say to run this command: readelf -Ws PortalWars/Binaries/Linux/PortalWars-Linux-Shipping.debug | c++filt | grep FEngineLoop::Tick

    However, PortalWars-Linux-Shipping.debug does not exist for me. PortalWars-Linux-Shipping does though. When running this command on PortalWars-Linux-Shipping, it returns nothing. However, running readelf -Ws PortalWars/Binaries/Linux/PortalWars-Linux-Shipping | c++filt | grep FEngineLoop (without the ::Tick on the end) returns:

    10585: 0000000000ae11c8 56 OBJECT GLOBAL DEFAULT 11 vtable for FEngineLoop.

    Running readelf -Ws PortalWars/Binaries/Linux/PortalWars-Linux-Shipping | c++filt | grep Tick (without the FEngineLipp on the end) returns an extremely large amount of variables, and running it with ::Tick or ::tickalso returns nothing.

    Would ae11c8 be the offset then? I'm concerned about the absence of the .debug extension in the file name, and concerned about the absence of the ::Tick() extension in the readelf... command.

    Also, is there no concern over getting banned in Splitgate for using UE4 Hooking? Splitgate, even on linux, uses EQ8 anti-cheat. However, in the table of tested games in the readme, only Apex and Overwatch have anti-cheat warnings on them -- not Splitgate. Is there a reason these games have this warning, but Splitgate doesn't?

    opened by neilunger 2
  • Mention Titanfall 2's Northstar client as a supported game.

    Mention Titanfall 2's Northstar client as a supported game.

    Next release of Northstar will support this. The original title never supported Nvidia Reflex, so this is a "native" implementation of LatencyFlex using the wine extensions.

    opened by KyleGospo 2
  • v0.1.0 inconsistently causes framerate to drop to ~20fps and remain there until Nvidia Reflex is disabled

    v0.1.0 inconsistently causes framerate to drop to ~20fps and remain there until Nvidia Reflex is disabled

    While I am playing Overwatch and Apex Legends, there are times where I will be getting 100+ fps, and then the framerate will decide to drop to ~20fps and remain there until I disable Nvidia Reflex in-game.

    For Apex, this only happens when I alt+tab back into the game while loading into a match (character select / champion screen). Even then, it seems inconsistent to reproduce -- so that isn't too much of an issue, as the few times it does happen, I can just quickly disable and re-enable reflex to fix it.

    However with Overwatch, it usually happens multiple times per match, to where I have to disable reflex to play the game comfortably. I have noticed it pretty consistently happens whenever an enemy Sombra uses their ultimate. It is oddly inconsistent -- some matches it never happens, most matches it happens 3-5 times per game. It also usually happens the first time I load into a match. I tried moving the game off of my HDD and reinstalling on my SSD in case this was due to stutters from accessing the shader/DXVK cache, but that did not make a difference.

    I saw that one of the dev branch build artifacts had a commit titled "Reduce jitter strength and pace down factor," which sounds like it could fix the issue (?), but the dev branch build artifacts are expired, so I am unable to download and test that.

    Are there any other reports of this happening? If the issue can't be reproduced, let me know which logs/additional info (if any) are needed. Thanks for the amazing work by the way, it at least makes a massive difference in Apex.

    opened by neilunger 1
  • apex greyed out reflex options... werid bug

    apex greyed out reflex options... werid bug

    The titled is true but towards the end of this post it won't be lol because I encounter a weird bug I think its specific to having the installed game on a different drive. for example on my setup before I fixed the problem by redoing the steps but having apex on the same drive.

    here is how it was structured

    drive: a) has apex on my mainos drive: b) accessing apex in drive a where originally I was using drive:a as my gaming but decided later to use a new os for my gaming. After finishing the new install and downloading the required packages to get steam to run apex. A biit later, I got everything all setup an running, now I just imported my steam library where in this case would be in drive:a so I choose drive:A/home/kunihiro/.local/share/Steam... and it found my apex install thats good.

    Drive:A ) Main OS/
    ├─ Apex - installed with MainOs steam install 
    Drive:B ) Gaming OS/
    ├─ Steam accessing Apex in Drive:A
    

    at this point I grabbed lutris fixed up everything there along with the env vars for apex to get latencyflex running. I installed everything to the right place but a weird things I had to do was directly set the DXVK_CONFIG_FILE=/fullpathto/dxvk.conf in lutris as directly place the dxvkl.conf in the apex folder will result in a error outputted in the logs using the env var in launch options for apex PROTON_LOG=1 DXVK_NVAPI_LOG_LEVEL=info

    so to solve this I had to redo every step slowly and moving my Apex to my GamingOs and setting the dxvk conf env var.

    additional information:

    My main os has the folder with the appid on the main os so when I start apex it starts the wine prefix in the main os where I had originally installed apex and not the second os.

    so my gaming os does not create the folder steamapps/compatdata/**appid** as it is already using the one created on the main os drive:a/home/..../steamapps/compatdata/**appid**

    my logs got overwritten as I keep starting Apex... sorry about that

    opened by kunihir0 4
  • Documentation suggests excessive environment variables on nvidia GPUs

    Documentation suggests excessive environment variables on nvidia GPUs

    The documentation says to include DXVK_NVAPI_DRIVER_VERSION=49729 DXVK_NVAPI_ALLOW_OTHER_DRIVERS=1 when enabling latencyflex, but this is unnecessary for people using Nvidia GPUs.

    I suggest having a version for Nvidia GPUs and one for everyone else. That way the game will see the actual driver version rather than 497.29, which is out of date.

    opened by ryao 1
  • LFX_MAX_FPS does not work

    LFX_MAX_FPS does not work

    I have the following setup:

    • GeForce RTX 3080
    • Ryzen 7 5800X
    • 64GB ECC DDR4 RAM
    • Nvidia Driver 510.54
    • Linux 5.16.14-gentoo-x86_64
    • X11 with gsync compatibility enabled
    • KDE with the kwin compositor set to prefer lower latency
    • Eve Spectrum ES07D03 (144Hz 4K gsync-compatible monitor)

    I am starting Apex Legends with LFX_MAX_FPS=140 PROTON_ENABLE_NVAPI=1 LFX=1 DXVK_HUD=compiler,scale=2 gamemoderun %command% -dev +fps_max=0. My dxvk.conf contains:

    dxgi.nvapiHack = False
    dxgi.maxFrameLatency = 1
    

    I want to limit my FPS to 140 as per various recommendations for 144Hz gsync monitors, but when I do it via LFX_MAX_FPS in Apex Legends, my FPS often hits 144 or even rarely 145, which is outside of the gsync range and is said to disable gsync. Steam's FPS meter, Apex Legend's built-in FPS meter and DXVK's FPS meter all show FPS exceeding the value that I have set.

    If I switch to DXVK_FRAME_RATE=140, then the frame rate is consistently limited to 140 FPS, but then I suspect that the DXVK limiter is causing latencyflex to misjudge how long it takes to render a frame.

    I suspect that the frame rate limiter introduced in 7fed2864d5c6d4613b6aed2535e78965aa6b376f needs to be changed to do a better job of clamping the frame rate.

    opened by ryao 7
  • LFX=1 shifts steam overlay to the right and halfway off of screen in Apex Legends

    LFX=1 shifts steam overlay to the right and halfway off of screen in Apex Legends

    My launch options for Apex Legends are: PROTON_LOG=1 DXVK_NVAPI_LOG_LEVEL=info PROTON_ENABLE_NVAPI=1 LFX=1 gamemoderun %command% -novid +fps_max 180

    This results in the following happening to the Steam overlay: Screenshot from 2022-03-17 21-57-11

    Once I remove LFX=1 from the launch options, this no longer happens.

    Some possibly important things to note: I have Mangohud globally enabled through GOverlay. I'm playing on a 1440p, 144hz X11 session on Pop!_OS 21.10, with the Steam .deb package (not flatpak) on the latest version of Proton Experimental. I have a second 1080p monitor configured to be to the left of my main 1440p monitor. I've attached my Proton log file, which should include the DXVK_NVAPI_LOG_LEVEL=info information as well.

    lfx_breaking_steam_overlay_proton.log

    Let me know if I can provide any other forms of debug information, or do any kind of testing/debugging for you.

    opened by neilunger 5
  • Installation instructions for other distros

    Installation instructions for other distros

    Pretty much the title.

    Installation involves messing directly with the root filesystem, so it'd be nice to have detailed instructions not just for Debian and Arch. If the process is identical to one of those two, at least mentioning it would be good.

    It doesn't have to be detailed for every single distro out there, but at least a couple of more common branches, like Fedora and openSUSE, would be nice.

    opened by not-a-dev-stein 1
Releases(v0.1.0)
  • v0.1.0(Mar 4, 2022)

    Celebrating Apex Legends' Proton launch with LatencyFleX v0.1.0!

    LatencyFleX provides Linux players with day-one drop-in replacement for Nvidia Reflex, and brings optimal latency with flexible framerate onto AMD platforms for the first time. This build has been tested for a few days in Apex games and should bring a stable experience in Apex and other games you love.

    If you want to try out upcoming changes, see the dev branch builds.

    Source code(tar.gz)
    Source code(zip)
    latencyflex-v0.1.0.tar.xz(371.23 KB)
Owner
Tatsuyuki Ishi
Computer Science burnout
Tatsuyuki Ishi
Double weave on high latency add-on for Final Fantasy XIV for Windows PC.

XivAlexander Connection Image Korea to NA DC VPN only Korea to NA DC XivAlexander enabled Korea to Korean DC Direct connection Use XivMitmLatencyMitig

srkizer 447 Jun 21, 2022
Zero-latency convolution on Bela platform

bela-zlc Zero-latency convolution on Bela platform | Report | Video | Overview Convolution has many applications in audio, such as equalization and ar

Christian J. Steinmetz 19 Jun 25, 2022
Docker files and scripts to setup and run VINS-FUSION-gpu on NVIDIA jetson boards inside a docker container.

jetson_vins_fusion_docker This repository provides Docker files and scripts to easily setup and run VINS-FUSION-gpu on NVIDIA jetson boards inside a d

Mohamed Abdelkader Zahana 18 May 30, 2022
Hardware-accelerated DNN model inference ROS2 packages using NVIDIA Triton/TensorRT for both Jetson and x86_64 with CUDA-capable GPU.

Isaac ROS DNN Inference Overview This repository provides two NVIDIA GPU-accelerated ROS2 nodes that perform deep learning inference using custom mode

NVIDIA Isaac ROS 36 Jun 20, 2022
Visual odometry package based on hardware-accelerated NVIDIA Elbrus library with world class quality and performance.

Isaac ROS Visual Odometry This repository provides a ROS2 package that estimates stereo visual inertial odometry using the Isaac Elbrus GPU-accelerate

NVIDIA Isaac ROS 164 Jun 19, 2022
The core engine forked from NVidia's Q2RTX. Heavily modified and extended to allow for a nicer experience all-round.

Nail & Crescent - Development Branch Scratchpad - Things to do or not forget: Items are obviously broken. Physics.cpp needs more work, revising. Proba

PalmliX Studio 12 Jun 28, 2022
NVIDIA Texture Tools samples for compression, image processing, and decompression.

NVTT 3 Samples This repository contains a number of samples showing how to use NVTT 3, a GPU-accelerated texture compression and image processing libr

NVIDIA DesignWorks Samples 31 Jun 13, 2022
TensorRT is a C++ library for high performance inference on NVIDIA GPUs and deep learning accelerators.

TensorRT Open Source Software This repository contains the Open Source Software (OSS) components of NVIDIA TensorRT. Included are the sources for Tens

NVIDIA Corporation 5.5k Jun 27, 2022
GPU Cloth TOP in TouchDesigner using CUDA-enabled NVIDIA Flex

This project demonstrates how to use NVIDIA FleX for GPU cloth simulation in a TouchDesigner Custom Operator. It also shows how to render dynamic meshes from the texture data using custom PBR GLSL material shaders inside TouchDesigner.

Vinícius Ginja 35 Apr 7, 2022
Forward - A library for high performance deep learning inference on NVIDIA GPUs

a library for high performance deep learning inference on NVIDIA GPUs.

Tencent 123 Mar 17, 2021
A library for high performance deep learning inference on NVIDIA GPUs.

Forward - A library for high performance deep learning inference on NVIDIA GPUs Forward - A library for high performance deep learning inference on NV

Tencent 502 May 31, 2022
Gstreamer plugin that allows use of NVIDIA Maxine SDK in a generic pipeline.

GST-NVMAXINE Gstreamer plugin that allows use of NVIDIA MaxineTM sdk in a generic pipeline. This plugin is intended for use with NVIDIA hardware. Visi

Alex Pitrolo 14 May 11, 2022
GPU ray tracing framework using NVIDIA OptiX 7

GPU ray tracing framework using NVIDIA OptiX 7

Shunji Kiuchi 22 Jun 11, 2022
ROS2 packages based on NVIDIA libArgus library for hardware-accelerated CSI camera support.

Isaac ROS Argus Camera This repository provides monocular and stereo nodes that enable ROS developers to use cameras connected to Jetson platforms ove

NVIDIA Isaac ROS 26 Jun 16, 2022
NVIDIA Image Scaling SDK

NVIDIA Image Scaling SDK v1.0 The MIT License(MIT) Copyright(c) 2021 NVIDIA CORPORATION & AFFILIATES. All rights reserved. Permission is hereby grante

NVIDIA GameWorks 346 Jun 23, 2022
Golang bindings for Nvidia Datacenter GPU Manager (DCGM)

Bindings Golang bindings are provided for NVIDIA Data Center GPU Manager (DCGM). DCGM is a set of tools for managing and monitoring NVIDIA GPUs in clu

NVIDIA Corporation 28 Jun 23, 2022
Dataset Synthesizer - NVIDIA Deep learning Dataset Synthesizer (NDDS)

NVIDIA Deep learning Dataset Synthesizer (NDDS) Overview NDDS is a UE4 plugin from NVIDIA to empower computer vision researchers to export high-qualit

NVIDIA Corporation 502 Jun 15, 2022
NVIDIA PhysX SDK

NVIDIA PhysX SDK 4.1 Copyright (c) 2021 NVIDIA Corporation. All rights reserved. Redistribution and use in source and binary forms, with or without mo

NVIDIA GameWorks 2.4k Jun 23, 2022