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

[Interpolation] Allow Matching & Limit Max FPS #2466

Merged
merged 1 commit into from
Mar 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 17 additions & 23 deletions soh/soh/GameMenuBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -890,15 +890,10 @@ namespace GameMenuBar {

const char* fps_cvar = "gInterpolationFPS";
{
#if defined(__SWITCH__) || defined(__WIIU__)
int minFps = 20;
int maxFps = 60;
#else
int minFps = 20;
int maxFps = 360;
#endif
int maxFps = Ship::Window::GetInstance()->GetCurrentRefreshRate();

int val = CVarGetInteger(fps_cvar, minFps);
int val = OTRGlobals::Instance->GetInterpolationFPS();
val = fmax(fmin(val, maxFps), 20);

#ifdef __WIIU__
Expand All @@ -916,6 +911,11 @@ namespace GameMenuBar {
{
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 PlusBTNFPSI = " + ##FPSInterpolation";
Expand Down Expand Up @@ -976,24 +976,18 @@ namespace GameMenuBar {
CVarSetInteger(fps_cvar, val);
SohImGui::RequestCvarSaveOnNextTick();
}
}

if (SohImGui::WindowBackend() == SohImGui::Backend::DX11)
{
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();
}

if (CVarGetInteger("gMatchRefreshRate", 0)) {
ImGui::PopItemFlag();
ImGui::PopStyleVar(1);
}
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::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)) {
Expand Down
10 changes: 9 additions & 1 deletion soh/soh/OTRGlobals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,14 @@ bool OTRGlobals::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) {
return context->GetResourceManager()->ListFiles(path);
}
Expand Down Expand Up @@ -731,7 +739,7 @@ extern "C" void Graph_ProcessGfxCommands(Gfx* commands) {

audio.cv_to_thread.notify_one();
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_update_rate;
static int time;
Expand Down
1 change: 1 addition & 0 deletions soh/soh/OTRGlobals.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class OTRGlobals

bool HasMasterQuest();
bool HasOriginal();
uint32_t GetInterpolationFPS();
std::shared_ptr<std::vector<std::string>> ListFiles(std::string path);

private:
Expand Down