@@ -78,6 +78,7 @@ int minimizeOnStart = 0;
78
78
// General
79
79
int resChangeDelayMs = 3000 ;
80
80
int dataAverageSamples = 128 ;
81
+ bool externalResChangeCompatibility = false ;
81
82
std::string blacklistApps = " steam.app.620980 steam.app.658920 steam.app.2177750 steam.app.2177760" ; // Beat Saber and HL2VR
82
83
std::set<std::string> blacklistAppsSet = {" steam.app.620980" , " steam.app.658920" , " steam.app.2177750" , " steam.app.2177760" };
83
84
bool whitelistEnabled = false ;
@@ -154,6 +155,7 @@ bool loadSettings()
154
155
// General
155
156
resChangeDelayMs = std::stoi (ini.GetValue (" General" , " resChangeDelayMs" , std::to_string (resChangeDelayMs).c_str ()));
156
157
dataAverageSamples = std::stoi (ini.GetValue (" General" , " dataAverageSamples" , std::to_string (dataAverageSamples).c_str ()));
158
+ externalResChangeCompatibility = std::stoi (ini.GetValue (" General" , " externalResChangeCompatibility" , std::to_string (externalResChangeCompatibility).c_str ()));
157
159
if (dataAverageSamples > 128 )
158
160
dataAverageSamples = 128 ; // Max stored by OpenVR
159
161
// blacklist
@@ -210,6 +212,7 @@ void saveSettings()
210
212
// General
211
213
ini.SetValue (" General" , " resChangeDelayMs" , std::to_string (resChangeDelayMs).c_str ());
212
214
ini.SetValue (" General" , " dataAverageSamples" , std::to_string (dataAverageSamples).c_str ());
215
+ ini.SetValue (" General" , " externalResChangeCompatibility" , std::to_string (externalResChangeCompatibility).c_str ());
213
216
ini.SetValue (" General" , " disabledApps" , setToConfigString (blacklistAppsSet).c_str ());
214
217
ini.SetValue (" General" , " whitelistEnabled" , std::to_string (whitelistEnabled).c_str ());
215
218
ini.SetValue (" General" , " whitelistApps" , setToConfigString (whitelistAppsSet).c_str ());
@@ -446,7 +449,7 @@ int main(int argc, char *argv[])
446
449
glfwWindowHint (GLFW_RESIZABLE, false );
447
450
448
451
// Create window with graphics context
449
- glfwWindow = glfwCreateWindow (mainWindowWidth, mainWindowHeight, fmt::format ( " OVR Dynamic Resolution {} " , version). c_str () , nullptr , nullptr );
452
+ glfwWindow = glfwCreateWindow (mainWindowWidth, mainWindowHeight, " OVR Dynamic Resolution" , nullptr , nullptr );
450
453
if (glfwWindow == nullptr )
451
454
return 1 ;
452
455
glfwMakeContextCurrent (glfwWindow);
@@ -497,9 +500,10 @@ int main(int argc, char *argv[])
497
500
#pragma endregion
498
501
499
502
// Load settings from ini file
500
- if (!loadSettings ()) {
503
+ if (!loadSettings ())
504
+ {
501
505
std::replace (blacklistApps.begin (), blacklistApps.end (), ' ' , ' \n ' ); // Set blacklist newlines
502
- saveSettings (); // Restore settings
506
+ saveSettings (); // Restore settings
503
507
}
504
508
505
509
// Set auto-start
@@ -621,7 +625,7 @@ int main(int argc, char *argv[])
621
625
float averageGpuTime = 0 ;
622
626
float averageCpuTime = 0 ;
623
627
float averageFrameShown = 0 ;
624
- int newRes = 0 ;
628
+ float newRes = initialRes ;
625
629
int targetFps = 0 ;
626
630
float targetFrametime = 0 ;
627
631
int hmdHz = 0 ;
@@ -645,8 +649,14 @@ int main(int argc, char *argv[])
645
649
lastChangeTime = currentTime;
646
650
647
651
#pragma region Getting data
652
+ float currentRes = vr::VRSettings ()->GetFloat (vr::k_pch_SteamVR_Section, vr::k_pch_SteamVR_SupersampleScale_Float) * 100 .0f ;
653
+
654
+ // Check for external resolution change compatibility
655
+ if (externalResChangeCompatibility && std::fabs (newRes - currentRes) > 0 .001f && !manualRes)
656
+ manualRes = true ;
657
+
648
658
// Fetch resolution and target fps
649
- newRes = vr::VRSettings ()-> GetFloat (vr::k_pch_SteamVR_Section, vr::k_pch_SteamVR_SupersampleScale_Float) * 100 ;
659
+ newRes = currentRes ;
650
660
float lastRes = newRes;
651
661
targetFps = std::round (vr::VRSystem ()->GetFloatTrackedDeviceProperty (0 , Prop_DisplayFrequency_Float));
652
662
targetFrametime = 1000 .0f / targetFps;
@@ -759,11 +769,11 @@ int main(int argc, char *argv[])
759
769
else if (vramOnlyMode && newRes < initialRes && vramUsed < vramTarget / 100 .0f )
760
770
{
761
771
// When in VRAM-only mode, make sure the res goes back up when possible.
762
- newRes = std::min (initialRes, newRes + resIncreaseMin);
772
+ newRes = std::min (initialRes, ( int ) std::round ( newRes) + resIncreaseMin);
763
773
}
764
774
765
775
// Clamp the new resolution
766
- newRes = std::clamp (newRes, minRes, maxRes);
776
+ newRes = std::clamp (( int ) std::round ( newRes) , minRes, maxRes);
767
777
}
768
778
}
769
779
else if ((appKey == " " || (resetOnThreshold && averageCpuTime < minCpuTimeThreshold)) && !manualRes)
@@ -803,7 +813,7 @@ int main(int argc, char *argv[])
803
813
ImGui::SetWindowSize (ImVec2 (mainWindowWidth, mainWindowHeight));
804
814
805
815
// Title
806
- ImGui::Text (" OVR Dynamic Resolution" );
816
+ ImGui::Text (fmt::format ( " OVR Dynamic Resolution {} " , version). c_str () );
807
817
808
818
ImGui::Separator ();
809
819
ImGui::NewLine ();
@@ -858,7 +868,7 @@ int main(int argc, char *argv[])
858
868
}
859
869
else
860
870
{
861
- ImGui::Text (" %s" , fmt::format (" Resolution = {}" , newRes).c_str ());
871
+ ImGui::Text (" %s" , fmt::format (" Resolution = {:.0f }" , newRes).c_str ());
862
872
}
863
873
864
874
// Resolution adjustment status
@@ -869,7 +879,7 @@ int main(int argc, char *argv[])
869
879
{
870
880
ImGui::PushItemWidth (192 );
871
881
ImGui::PushStyleVar (ImGuiStyleVar_FramePadding, ImVec2 (0 , 0 ));
872
- if (ImGui::SliderInt (" " , &newRes, 20 , 500 , " %d " , ImGuiSliderFlags_AlwaysClamp))
882
+ if (ImGui::SliderFloat (" " , &newRes, 20 . 0f , 500 . 0f , " %.0f " , ImGuiSliderFlags_AlwaysClamp))
873
883
{
874
884
vr::VRSettings ()->SetFloat (vr::k_pch_SteamVR_Section, vr::k_pch_SteamVR_SupersampleScale_Float, newRes / 100 .0f );
875
885
}
@@ -954,6 +964,9 @@ int main(int argc, char *argv[])
954
964
}
955
965
addTooltip (" Number of frames' frametimes to average out." );
956
966
967
+ ImGui::Checkbox (" External res change compatibility" , &externalResChangeCompatibility);
968
+ addTooltip (" Automatically switch to manual resolution adjustment within the app when VR resolution is changed from an external source (SteamVR setting, Oyasumi, etc.) as to let the external source control the resolution. Does not automatically switch back to dynamic resolution adjustment." );
969
+
957
970
ImGui::Text (" Blacklist" );
958
971
addTooltip (" Don't allow resolution changes in blacklisted applications." );
959
972
if (ImGui::InputTextMultiline (" Blacklisted apps" , &blacklistApps, ImVec2 (130 , 60 ), ImGuiInputTextFlags_CharsNoBlank))
@@ -965,7 +978,8 @@ int main(int argc, char *argv[])
965
978
if (!isApplicationBlacklisted (appKey))
966
979
{
967
980
blacklistAppsSet.insert (appKey);
968
- if (blacklistApps != " " ) blacklistApps += " \n " ;
981
+ if (blacklistApps != " " )
982
+ blacklistApps += " \n " ;
969
983
blacklistApps += appKey;
970
984
}
971
985
}
@@ -982,7 +996,8 @@ int main(int argc, char *argv[])
982
996
if (!isApplicationWhitelisted (appKey))
983
997
{
984
998
whitelistAppsSet.insert (appKey);
985
- if (whitelistApps != " " ) whitelistApps += " \n " ;
999
+ if (whitelistApps != " " )
1000
+ whitelistApps += " \n " ;
986
1001
whitelistApps += appKey;
987
1002
}
988
1003
}
0 commit comments