-
-
Notifications
You must be signed in to change notification settings - Fork 21.3k
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
[Windows] Fix NVIDIA app profile creation #85188
Conversation
ac92591
to
33a8f93
Compare
feb04c4
to
78dcde9
Compare
78dcde9
to
43cbb60
Compare
When adding an executable to the NVIDIA profile created to disable threaded optimization, wrong values were passed to `launcher` and `fileInFolder` params, which resulted in 1) the NVIDIA driver not applying the profile and 2) the app being repeatedly added to the profile. This patch fixes the faulty app creation params and deletes the potentially corrupted profile if found.
Hey, thanks for contributing and sorry this has been sitting for a while! One reason may be that this is a very specific part of a already specific subset of the engine and it's user base (only affecting Windows, only on NVIDIA, and needs intersecting knowledge of rendering, engine core, Windows/NVIDIA, etc., or at least willingness to dive in). What would've helped me review this is more context, as everything is scattered through past PRs and issues and I had to dig a bit. ContextFirst, some context: originally introduced in PR #71472 to fix #33969 and #45660, later changed by PR #81251 (which may have broken things), semi-related issue: #85111. This work was included in 4.2, and has since been cherry-picked to 4.1, and is still slated to maybe be cherrypicked to 3.x, so we should do the same with this PR. We disable NVIDIA's OpenGL threading optimization for the OpenGL backend by creating a custom NVIDIA Profile per Godot project name, which is applied to executables by executable name (i.e., matching something like This code is called via This means this is run whenever the project manager opens, because it is always running in OpenGL/Compat. Whether we should always create a NVIDIA Profile, and only for specific backends, and without much dev input is IMO worthy of discussion, but outside of the scope of this PR, as we already do that. IMO it should be a project setting. This PRThis PR makes the following changes:
✅ The changes look correct to me, and seem to work fine after building and testing.
✅ This makes sense, needs to be done and works correctly. I could verify that it successfully deletes the old profile if it exists and creates a new one, and also runs without issue if no pre-existing profile, well, exists.
✅ This makes sense, as the "NVIDIA Profile" part of the name stood out compared to all others in my list. Wouldn't bother making this change for the sake of it, but as we are already touching this, may as well.
✅ Makes sense. Works as it should.
✅ Makes sense and didn't have any negative effects in my testing. Indeed,
✅ OK I built and tested this PR, and verified the NVIDIA Profile both with NVIDIA's own control panel and the tool linked above before and after this PR. |
lgtm |
Thanks! |
Note: hopefully to be considered for inclusion in 4.2, as the existing bug potentially results in an ever-expanding NVIDIA app profile with every execution of the engine.
When adding an executable to the NVIDIA profile created to disable threaded optimization, wrong values were passed to the
launcher
andfileInFolder
params:memcpy
was reading a single byte off a multibyte string for each, potentially resulting in gargabe being read into these values. Non-empty values in any of these fields resulted in a corrupted profile, which wouldn't be applied to the executable at launch (and wasn't even editable from NVIDIA Control Panel, only from NVIDIA Profile Inspector).On top of that, since #81251, the invalid profile resulted in NVIDIA API's
findApplicationByName
to always fail (as it relies on the driver's capacity to apply a profile to the target executable), and in turn the executable being re-added to the profile on every engine launch. In summary, an ever-expanding list of apps added to the profile, that wasn't ever properly applied.This PR fixes that condition by taking three steps:
launcher
andfileInFolder
settings to receive a "full" empty mb string (I'm a total C++ noob, so would love some review to my approach to fixingmemcpy
).Nvidia Profile
from its name).GetApplicationInfo
method to check if an executable already exists inside a profile, as it doesn't rely on the driver being able to apply the profile, just on the profile metadata itself.Some other params of the profile app are dropped, as they seem superfluous in my tests:
userFriendlyName
is better left to default to the executable name, as this makes its distinguishable from other executables covered by the same profile in NVIDIA Control Panel (and is what most applications default to).isMetro
andisCommandLine
seem to be ignored by the creation API no matter what value is passed (they're always read as 0 in my tests), probably unused values in the current version kept for backwards compatibility?Since this bug results in garbage being quietly accumulated in NVIDIA profiles as users launch games or the editor, I think it'd be really interesting to consider the fix for inclusion in 4.2, to avoid that leaky behaviour to spread when the stable release sees wide adoption in a few weeks.