Add persistent target FPS option.

This commit is contained in:
Bartosz Taudul 2023-05-01 19:07:49 +02:00
parent 3150a48561
commit bd2f903c08
No known key found for this signature in database
GPG Key ID: B7FE2008B7575DF3
3 changed files with 18 additions and 2 deletions

View File

@ -169,6 +169,7 @@ static void LoadConfig()
int v; int v;
if( ini_sget( ini, "core", "threadedRendering", "%d", &v ) ) s_config.threadedRendering = v; if( ini_sget( ini, "core", "threadedRendering", "%d", &v ) ) s_config.threadedRendering = v;
if( ini_sget( ini, "timeline", "targetFps", "%d", &v ) && v >= 1 && v < 10000 ) s_config.targetFps = v;
ini_free( ini ); ini_free( ini );
} }
@ -182,6 +183,9 @@ static bool SaveConfig()
fprintf( f, "[core]\n" ); fprintf( f, "[core]\n" );
fprintf( f, "threadedRendering = %i\n", (int)s_config.threadedRendering ); fprintf( f, "threadedRendering = %i\n", (int)s_config.threadedRendering );
fprintf( f, "\n[timeline]\n" );
fprintf( f, "targetFps = %i\n", s_config.targetFps );
fclose( f ); fclose( f );
return true; return true;
} }
@ -553,17 +557,24 @@ static void DrawContents()
ImGui::Separator(); ImGui::Separator();
if( ImGui::TreeNode( ICON_FA_TOOLBOX " Global settings" ) ) if( ImGui::TreeNode( ICON_FA_TOOLBOX " Global settings" ) )
{ {
ImGui::PushStyleVar( ImGuiStyleVar_FramePadding, ImVec2( 0, 0 ) );
ImGui::TextUnformatted( "Threaded rendering" ); ImGui::TextUnformatted( "Threaded rendering" );
ImGui::Indent(); ImGui::Indent();
ImGui::PushStyleVar( ImGuiStyleVar_FramePadding, ImVec2( 0, 0 ) );
if( ImGui::RadioButton( "Enabled", s_config.threadedRendering ) ) { s_config.threadedRendering = true; SaveConfig(); } if( ImGui::RadioButton( "Enabled", s_config.threadedRendering ) ) { s_config.threadedRendering = true; SaveConfig(); }
ImGui::SameLine(); ImGui::SameLine();
tracy::DrawHelpMarker( "Uses all available CPU cores for rendering. May affect performance of the profiled application when running on the same machine." ); tracy::DrawHelpMarker( "Uses all available CPU cores for rendering. May affect performance of the profiled application when running on the same machine." );
if( ImGui::RadioButton( "Disabled", !s_config.threadedRendering ) ) { s_config.threadedRendering = false; SaveConfig(); } if( ImGui::RadioButton( "Disabled", !s_config.threadedRendering ) ) { s_config.threadedRendering = false; SaveConfig(); }
ImGui::SameLine(); ImGui::SameLine();
tracy::DrawHelpMarker( "Restricts rendering to a single CPU core. Can reduce profiler frame rate." ); tracy::DrawHelpMarker( "Restricts rendering to a single CPU core. Can reduce profiler frame rate." );
ImGui::PopStyleVar();
ImGui::Unindent(); ImGui::Unindent();
ImGui::Spacing();
ImGui::TextUnformatted( "Target FPS" );
ImGui::SameLine();
int tmp = s_config.targetFps;
ImGui::SetNextItemWidth( 90 * dpiScale );
if( ImGui::InputInt( "##targetfps", &tmp ) ) { s_config.targetFps = std::clamp( tmp, 1, 9999 ); SaveConfig(); }
ImGui::PopStyleVar();
ImGui::TreePop(); ImGui::TreePop();
} }
ImGui::Separator(); ImGui::Separator();

View File

@ -7,6 +7,7 @@ namespace tracy
struct Config struct Config
{ {
bool threadedRendering = true; bool threadedRendering = true;
int targetFps = 60;
}; };
} }

View File

@ -66,6 +66,8 @@ View::View( void(*cbMainThread)(const std::function<void()>&, bool), const char*
{ {
InitMemory(); InitMemory();
InitTextEditor(); InitTextEditor();
m_vd.frameTarget = config.targetFps;
} }
View::View( void(*cbMainThread)(const std::function<void()>&, bool), FileRead& f, ImFont* fixedWidth, ImFont* smallFont, ImFont* bigFont, SetTitleCallback stcb, SetScaleCallback sscb, AttentionCallback acb, const Config& config ) View::View( void(*cbMainThread)(const std::function<void()>&, bool), FileRead& f, ImFont* fixedWidth, ImFont* smallFont, ImFont* bigFont, SetTitleCallback stcb, SetScaleCallback sscb, AttentionCallback acb, const Config& config )
@ -99,6 +101,8 @@ View::View( void(*cbMainThread)(const std::function<void()>&, bool), FileRead& f
if( m_worker.GetCallstackFrameCount() == 0 ) m_showUnknownFrames = false; if( m_worker.GetCallstackFrameCount() == 0 ) m_showUnknownFrames = false;
if( m_worker.GetCallstackSampleCount() == 0 ) m_showAllSymbols = true; if( m_worker.GetCallstackSampleCount() == 0 ) m_showAllSymbols = true;
m_vd.frameTarget = config.targetFps;
} }
View::~View() View::~View()