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

feat(nvprefs): add V-Sync and frame limiter options #3317

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Unarelith
Copy link

@Unarelith Unarelith commented Oct 20, 2024

Description

Title.

A lot of users are already setting frame limiter / disabling V-Sync in Nvidia Control Panel to reduce stutter with Sunshine.

However it would require to switch back and forth between:

  • Default config (no frame limiter, vsync set to passive)
  • Sunshine config (fps limit to 60, vsync forced off)

This PR aims to make this automatic.

Screenshot

Will provide later

Issues Fixed or Closed

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Dependency update (updates to dependencies)
  • Documentation update (changes to documentation)
  • Repository update (changes to repository files, e.g. .github/...)

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated the in code docstring/documentation-blocks for new or existing methods/components

@ReenigneArcher ReenigneArcher changed the title Options to force disable V-Sync / enable frame limiter using NVAPI. feat(nvprefs): add V-Sync and frame limiter options Oct 20, 2024
Copy link
Member

@ReenigneArcher ReenigneArcher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! this is a preliminary review.

@@ -114,6 +114,26 @@ const config = ref(props.config)
</select>
<div class="form-text">{{ $t('config.nvenc_h264_cavlc_desc') }}</div>
</div>

<!-- Force disable V-Sync (NVAPI) -->
<div class="mb-3" v-if="platform === 'windows'">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is fine, but I'm not sure why the one above is missing the conditional for the windows platform... or if any of them are even needed as the entire nvenc encoder is Windows only.

}

// TODO: save current setting and restore it later
setting.u32CurrentValue = 60; // TODO: change this according to host refresh rate
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose you can get this from #2894 after it's merged.

Copy link

sonarcloud bot commented Oct 20, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
3 New issues
3 New Code Smells (required ≤ 0)

See analysis details on SonarCloud

Catch issues before they fail your Quality Gate with our IDE extension SonarLint

@Unarelith
Copy link
Author

I managed to try this and it worked as expected: it changed the settings for vsync and fps limit

I'd need a bit more info on those things:

  • What would be the best place to enable the temporary settings? (should be when the stream starts, but where in the code would be the best?)
  • What would be the best place to reset the original settings?
  • It's already possible to get the display refresh rate, how to use that in my PR to replace the hardcoded "60"?

@FrogTheFrog
Copy link
Collaborator

* What would be the best place to enable the temporary settings? (should be when the stream starts, but where in the code would be the best?)
* What would be the best place to reset the original settings?

Take a look at my PR where the display_device::revert_configuration(); and display_device::configure_display(...) are used (process.cpp, stream.cpp, nvhttp.cpp). I think those should cover all of the cases of where and how.
#3441

* It's already possible to get the display refresh rate, how to use that in my PR to replace the hardcoded "60"?

I would not recommend using refresh rate, but would take it from const auto launch_session = make_launch_session(host_audio, args); (refer to my previous comment). It provides FPS value from Moonlight. When using the actual display for streaming I usually leave it at 120Hz, but limit FPS to 60, because for whatever reason I perceive it as a smoother stream.

It might also be a good idea to provide an override value to be used instead of an automatic one for the limiter.

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.

Still jittery after all these years when Vsync on, Client and Server set to same refresh rate.
3 participants