From 13ae0d218b81fd276f135decf1ebf6871b5be1fc Mon Sep 17 00:00:00 2001 From: netborg <137700136+netborg-afps@users.noreply.github.com> Date: Tue, 18 Feb 2025 21:01:19 +0100 Subject: [PATCH] [dxvk] Add config variables for frame pacing --- dxvk.conf | 52 ++++++++++++++++++++++++++++++++++++++- src/dxvk/dxvk_options.cpp | 6 ++++- src/dxvk/dxvk_options.h | 16 +++++++++++- 3 files changed, 71 insertions(+), 3 deletions(-) diff --git a/dxvk.conf b/dxvk.conf index 799991eee..0b8deba8c 100644 --- a/dxvk.conf +++ b/dxvk.conf @@ -18,6 +18,51 @@ # dxgi.enableHDR = True +# Frame pacing mode managing CPU-GPU synchronization. +# Defaults to "low-latency" in the draft-PR for demonstration purposes. +# +# "max-frame-latency" provides stable latency in the GPU-limit as long as +# GPU render times are stable. Latency generally is higher but offers great +# visual smoothness. +# +# "low-latency" provides lower latency in the GPU-limit and can be fine-tuned +# via dxvk.lowLatencyOffset and dxvk.lowLatencyAllowCpuFramesOverlap. +# +# "min-latency" possibly provides the lowest latency (low-latency can be +# quicker in some situations), and offers less fps in the GPU-limit +# due to stalling the GPU between frames. Generally not recommended, +# but helpful to get insights to fine-tune the low-latency mode and +# possibly is useful for running games in the CPU-limit. +# +# "low/min-latency" also supports its own fps-limiting enabled via common +# variables. +# +# Supported values: "max-frame-latency", "low-latency", "min-latency" + +# dxvk.framePacing = "" + + +# Allows fine-tuning the low-latency frame pacing mode. +# Positive values make a frame begin later which might improve responsiveness, +# although only very slightly, but may be relevant for edge cases. +# Negative values make a frame begin earlier which might improve fps. +# Values are given in microseconds. Defaults to 0. +# +# Supported values: -10000 to 10000 + +# dxvk.lowLatencyOffset = 0 + + +# Determines whether a frame is allowed to begin before finishing processing +# the cpu-part of the previous one, when low-latency frame pacing is used. +# Snappiness may be improved when disallowing overlap. On the other hand, this +# might also decrease fps in certain cases. Defaults to True. +# +# Supported values: True, False + +# dxvk.lowLatencyAllowCpuFramesOverlap = True + + # Expose support for dcomp swap chains with a dummy window. # # This is not a valid implementation of DirectComposition swapchains, @@ -104,8 +149,13 @@ # The implementation will either use VK_NV_low_latency2 if supported # by the driver, or a custom algorithm. # - False: Disable Reflex support as well as built-in latency reduction. +# This build defaults to False to enable dxvk.framePacing. You need to +# enable Reflex manually (Auto) until we support switching back and +# forth between Reflex and the low-latency frame pacing - for example +# via the ingame options - and more critically we want to enable +# low-latency frame pacing if the game doesn't support Reflex. -# dxvk.latencySleep = Auto +# dxvk.latencySleep = False # Tolerance for the latency sleep heuristic, in microseconds. Higher values diff --git a/src/dxvk/dxvk_options.cpp b/src/dxvk/dxvk_options.cpp index d2d455c33..85fc3ec3e 100644 --- a/src/dxvk/dxvk_options.cpp +++ b/src/dxvk/dxvk_options.cpp @@ -12,12 +12,16 @@ namespace dxvk { useRawSsbo = config.getOption("dxvk.useRawSsbo", Tristate::Auto); hud = config.getOption("dxvk.hud", ""); tearFree = config.getOption("dxvk.tearFree", Tristate::Auto); - latencySleep = config.getOption("dxvk.latencySleep", Tristate::Auto); + latencySleep = config.getOption("dxvk.latencySleep", Tristate::False); latencyTolerance = config.getOption ("dxvk.latencyTolerance", 1000); disableNvLowLatency2 = config.getOption("dxvk.disableNvLowLatency2", Tristate::Auto); hideIntegratedGraphics = config.getOption ("dxvk.hideIntegratedGraphics", false); zeroMappedMemory = config.getOption ("dxvk.zeroMappedMemory", false); allowFse = config.getOption ("dxvk.allowFse", false); + framePace = config.getOption("dxvk.framePace", ""); + lowLatencyOffset = config.getOption ("dxvk.lowLatencyOffset", 0); + lowLatencyAllowCpuFramesOverlap + = config.getOption ("dxvk.lowLatencyAllowCpuFramesOverlap", true); deviceFilter = config.getOption("dxvk.deviceFilter", ""); tilerMode = config.getOption("dxvk.tilerMode", Tristate::Auto); } diff --git a/src/dxvk/dxvk_options.h b/src/dxvk/dxvk_options.h index 5351ac68b..fd2977143 100644 --- a/src/dxvk/dxvk_options.h +++ b/src/dxvk/dxvk_options.h @@ -38,7 +38,9 @@ namespace dxvk { Tristate tearFree = Tristate::Auto; /// Enables latency sleep - Tristate latencySleep = Tristate::Auto; + /// Defaults to false in this build to activate the FramePacer, + /// especially for the case when the game doesn't support Reflex + Tristate latencySleep = Tristate::False; /// Latency tolerance, in microseconds int32_t latencyTolerance = 0u; @@ -61,6 +63,18 @@ namespace dxvk { /// Whether to enable tiler optimizations Tristate tilerMode = Tristate::Auto; + /// Frame pacing + std::string framePace; + + /// A value in microseconds to fine-tune the low-latency frame pacing. + /// Positive values make a frame begin later which might improve responsiveness. + /// Negative values make a frame begin earlier which might improve fps. + int32_t lowLatencyOffset; + + /// Determines whether a frame is allowed to begin before finishing processing + /// the cpu-part of the previous one, when low-latency frame pacing is used. + bool lowLatencyAllowCpuFramesOverlap; + // Device name std::string deviceFilter; };