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

Added Adaptive Tearing options and enabled Latent Sync 2x.. modes #152

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Nustat0
Copy link
Contributor

@Nustat0 Nustat0 commented Mar 20, 2024

  • Added new tearing modes for regular V-Sync:

    • Always Off (Low Latency): temporarily lowers FPS limit if Render Latency exceeds 1 frame.
    • Adaptive V-Sync: temporarily turns V-Sync Off (without enabling Latent Sync) if FPS is unstable or Render Latency exceeds 1 frame.
  • Added new tearing modes for Latent Sync:

    • Always Off (Low Latency): temporarily lowers FPS limit if Render Latency exceeds 1 frame.
    • Adaptive (Prefer On): only disables tearing if FPS is unstable.
    • Adaptive (Prefer Off): only enables tearing if FPS is unstable or Render Latency exceeds 1 frame.
  • Made Latent Sync non-tearing modes functional in D3D9 / FSE games by forcing Presentation Interval 1.

  • Reset frame limiter when V-Sync gets stuck at high variation or ±0.0 ms input latency (applies to "Adaptive V-Sync", "Adaptive (Prefer Off)" and "Always Off (Low Latency)" tearing modes).

  • Display actual Delay Bias value when Auto Bias is enabled (updates every 200 ms).

  • Remember last selected Target Input Latency value when switching between millisecond / percentage modes.

  • Hidden Maximum Bias slider if Target Input Latency is in percentage mode (it will only take effect in millisecond mode).

  • Refactored and enabled Latent Sync 2x.. modes.

  • Restricted 2x.. Scan Mode selection to 5 entries after enabling 4x mode or higher:

    • 1/x 1:1 (2x) 3x 4x
    • 1/x 1:1 2x 3x (4x) 5x 6x
    • 1/x 1:1 4x 5x (6x) 7x 8x
    • 1/x 1:1 6x 7x (8x) 9x 10x ...
  • Re-enabled Buffer Count and Max Device Latency settings for OpenGL-IK and NVIDIA's OpenGL / Vulkan -> D3D11 interop:

    • They do work even in non-direct D3D11 and can be useful for 2x.. modes (e.g., Buffer Count of 4+ allows to render above refresh rate with Tearing Off).
  • Always show Visualize Tearlines checkbox:

    • Fixes an issue of users not being able to hide FCAT bars after disabling tearing while tearline visualizer was still on.
    • FCAT bars are disabled automatically after switching from Latent Sync to another mode.
  • Made Resync Rate second-based instead of frame-count-based (60 seconds by default).

  • Updated Delay Bias tooltip (Adaptive Sync option is obsolete).

image
image

@Kaldaien
Copy link
Member

Kaldaien commented Mar 25, 2024

Adaptive (Prefer Off): only enables tearing if Render Latency exceeds 1 frame.

Does that even happen? Latent Sync is VSYNC off, I'm having a hard time picturing how render latency gets > 1 frame.

This seems more like a feature appropriate for non-Latent Sync modes. I like the premise of letting the screen tear for 1 or more frames until latency comes down for fixed-refresh users, a lot, but I don't think that's a problem that Latent Sync has to begin with.

@Nustat0
Copy link
Contributor Author

Nustat0 commented Mar 25, 2024

Does that even happen? Latent Sync is VSYNC off, I'm having a hard time picturing how render latency gets > 1 frame.

It happens when Latent Sync is used with Allow Tearing option unchecked. With tearing disabled, Latent Sync acts similarly to VSync and increases Render Latency in some scenarios (gets "stuck" above 1 frame after experiencing loading screens, sudden frame drops, loss of Independent Flip).

You can easily reproduce it by enabling Latent Sync, disabling tearing and temporarily losing Independent Flip. When presentation mode transitions from Composed Flip to Independent Flip, Render Latency rises above 1 frame.

I only tested this on a fixed-refresh 60 Hz monitor, maybe it's less of an issue on higher refresh rates?

This seems more like a feature appropriate for non-Latent Sync modes. I like the premise of letting the screen tear for 1 or more frames until latency comes down for fixed-refresh users, a lot, but I don't think that's a problem that Latent Sync has to begin with.

In non-Latent Sync mode, especially fixed-refresh VSync, you'd have to toggle presentation interval to 0/1 which goes back and forth between Latent Sync and Normal modes. That's why I restricted Adaptive Tearing modes to Latent Sync - presentation interval stays the same (0) and it's simply easier toggling tearing On/Off.

@Nustat0
Copy link
Contributor Author

Nustat0 commented Mar 28, 2024

This seems more like a feature appropriate for non-Latent Sync modes. I like the premise of letting the screen tear for 1 or more frames until latency comes down for fixed-refresh users, a lot, but I don't think that's a problem that Latent Sync has to begin with.

In non-Latent Sync mode, especially fixed-refresh VSync, you'd have to toggle presentation interval to 0/1 which goes back and forth between Latent Sync and Normal modes. That's why I restricted Adaptive Tearing modes to Latent Sync - presentation interval stays the same (0) and it's simply easier toggling tearing On/Off.

Update: I also implemented Adaptive VSync mode for non-Latent-Sync usage. It temporarily turns VSync Off / Tearing On (without enabling Latent Sync) if FPS is unstable or Render Latency exceeds 1 frame.

@Nustat0 Nustat0 changed the title Added Adaptive Tearing modes to Latent Sync Added Adaptive VSync/Tearing options and enabled Latent Sync 2x.. modes Apr 11, 2024
@Nustat0 Nustat0 marked this pull request as draft July 1, 2024 21:52
@Nustat0
Copy link
Contributor Author

Nustat0 commented Jul 1, 2024

Marked as draft. I'm finishing off another Tearing Mode "Always Off (Low Latency)" (temporarily lowers FPS limit if Render Latency exceeds 1 frame) :)

@Nustat0 Nustat0 changed the title Added Adaptive VSync/Tearing options and enabled Latent Sync 2x.. modes Added Adaptive Tearing options and enabled Latent Sync 2x.. modes Jul 12, 2024
@Nustat0 Nustat0 marked this pull request as ready for review July 12, 2024 15:08
@Nustat0 Nustat0 marked this pull request as draft August 27, 2024 20:32
@cathyjf
Copy link
Contributor

cathyjf commented Aug 30, 2024

@Nustat0, you should consider squashing these 106 commits together into a single commit, or just a few commits. The total overall patch is far too small to justify 106 commits.

@Nustat0
Copy link
Contributor Author

Nustat0 commented Aug 30, 2024

@Nustat0, you should consider squashing these 106 commits together into a single commit, or just a few commits. The total overall patch is far too small to justify 106 commits.

Sorry about the commits, I wasn't satisfied with the original implementation and things got out of control after I started discovering more and more edge cases.

I'll mark this PR as ready for review once I'm done reworking adaptive tearing modes and then we can discuss whether to squash the commits or split this mess into smaller PRs :D

@Nustat0 Nustat0 force-pushed the latent-sync-adaptive-tearing branch from 8960ab0 to 4766697 Compare December 2, 2024 12:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants