[Interpolation] Allow Matching & Limit Max FPS (#2466)

This commit is contained in:
David Chavez 2023-03-01 16:12:55 +01:00 committed by GitHub
parent 7551fba3d2
commit b13f6f4b70
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 24 deletions

View File

@ -890,15 +890,10 @@ namespace GameMenuBar {
const char* fps_cvar = "gInterpolationFPS"; const char* fps_cvar = "gInterpolationFPS";
{ {
#if defined(__SWITCH__) || defined(__WIIU__)
int minFps = 20; int minFps = 20;
int maxFps = 60; int maxFps = Ship::Window::GetInstance()->GetCurrentRefreshRate();
#else
int minFps = 20;
int maxFps = 360;
#endif
int val = CVarGetInteger(fps_cvar, minFps); int val = OTRGlobals::Instance->GetInterpolationFPS();
val = fmax(fmin(val, maxFps), 20); val = fmax(fmin(val, maxFps), 20);
#ifdef __WIIU__ #ifdef __WIIU__
@ -916,6 +911,11 @@ namespace GameMenuBar {
{ {
ImGui::Text("Frame interpolation: %d FPS", fps); ImGui::Text("Frame interpolation: %d FPS", fps);
} }
if (CVarGetInteger("gMatchRefreshRate", 0)) {
ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true);
ImGui::PushStyleVar(ImGuiStyleVar_Alpha, ImGui::GetStyle().Alpha * 0.5f);
}
std::string MinusBTNFPSI = " - ##FPSInterpolation"; std::string MinusBTNFPSI = " - ##FPSInterpolation";
std::string PlusBTNFPSI = " + ##FPSInterpolation"; std::string PlusBTNFPSI = " + ##FPSInterpolation";
@ -976,24 +976,18 @@ namespace GameMenuBar {
CVarSetInteger(fps_cvar, val); CVarSetInteger(fps_cvar, val);
SohImGui::RequestCvarSaveOnNextTick(); SohImGui::RequestCvarSaveOnNextTick();
} }
}
if (CVarGetInteger("gMatchRefreshRate", 0)) {
if (SohImGui::WindowBackend() == SohImGui::Backend::DX11) ImGui::PopItemFlag();
{ ImGui::PopStyleVar(1);
UIWidgets::Spacer(0);
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(6.0f, 4.0f));
if (ImGui::Button("Match Refresh Rate"))
{
int hz = Ship::Window::GetInstance()->GetCurrentRefreshRate();
if (hz >= 20 && hz <= 360)
{
CVarSetInteger(fps_cvar, hz);
SohImGui::RequestCvarSaveOnNextTick();
}
} }
ImGui::PopStyleVar(1);
UIWidgets::Spacer(0);
} }
UIWidgets::Spacer(0);
UIWidgets::EnhancementCheckbox("Match Refresh Rate", "gMatchRefreshRate");
UIWidgets::Tooltip("Matches interpolation value to the current game's window refresh rate");
UIWidgets::Spacer(0);
UIWidgets::EnhancementCheckbox("Disable LOD", "gDisableLOD"); UIWidgets::EnhancementCheckbox("Disable LOD", "gDisableLOD");
UIWidgets::Tooltip("Turns off the Level of Detail setting, making models use their higher-poly variants at any distance"); UIWidgets::Tooltip("Turns off the Level of Detail setting, making models use their higher-poly variants at any distance");
if (UIWidgets::PaddedEnhancementCheckbox("Disable Draw Distance", "gDisableDrawDistance", true, false)) { if (UIWidgets::PaddedEnhancementCheckbox("Disable Draw Distance", "gDisableDrawDistance", true, false)) {

View File

@ -313,6 +313,14 @@ bool OTRGlobals::HasOriginal() {
return hasOriginal; return hasOriginal;
} }
uint32_t OTRGlobals::GetInterpolationFPS() {
if (CVarGetInteger("gMatchRefreshRate", 0)) {
return Ship::Window::GetInstance()->GetCurrentRefreshRate();
}
return std::min<uint32_t>(Ship::Window::GetInstance()->GetCurrentRefreshRate(), CVarGetInteger("gInterpolationFPS", 20));
}
std::shared_ptr<std::vector<std::string>> OTRGlobals::ListFiles(std::string path) { std::shared_ptr<std::vector<std::string>> OTRGlobals::ListFiles(std::string path) {
return context->GetResourceManager()->ListFiles(path); return context->GetResourceManager()->ListFiles(path);
} }
@ -731,7 +739,7 @@ extern "C" void Graph_ProcessGfxCommands(Gfx* commands) {
audio.cv_to_thread.notify_one(); audio.cv_to_thread.notify_one();
std::vector<std::unordered_map<Mtx*, MtxF>> mtx_replacements; std::vector<std::unordered_map<Mtx*, MtxF>> mtx_replacements;
int target_fps = CVarGetInteger("gInterpolationFPS", 20); int target_fps = OTRGlobals::Instance->GetInterpolationFPS();
static int last_fps; static int last_fps;
static int last_update_rate; static int last_update_rate;
static int time; static int time;

View File

@ -28,6 +28,7 @@ public:
bool HasMasterQuest(); bool HasMasterQuest();
bool HasOriginal(); bool HasOriginal();
uint32_t GetInterpolationFPS();
std::shared_ptr<std::vector<std::string>> ListFiles(std::string path); std::shared_ptr<std::vector<std::string>> ListFiles(std::string path);
private: private: