diff --git a/indra/newview/fsfloaterperformance.cpp b/indra/newview/fsfloaterperformance.cpp index 7576ff5eb9..81279fc469 100644 --- a/indra/newview/fsfloaterperformance.cpp +++ b/indra/newview/fsfloaterperformance.cpp @@ -315,7 +315,7 @@ void FSFloaterPerformance::draw() args["FPSCAP"] = llformat("%02u", (U32)fpsCap); args["FPSTARGET"] = llformat("%02u", (U32)targetFPS); S32 refresh_rate = gViewerWindow->getWindow()->getRefreshRate(); - args["VSYNCFREQ"] = llformat("%02d", (U32)refresh_rate); + args["VSYNCFREQ"] = llformat("%03d", (U32)refresh_rate); auto textbox = getChild("fps_warning"); // Note: the ordering of these is important. // 1) background_yield should override others diff --git a/indra/newview/llstatusbar.cpp b/indra/newview/llstatusbar.cpp index 5284d40d86..4b07a763f4 100644 --- a/indra/newview/llstatusbar.cpp +++ b/indra/newview/llstatusbar.cpp @@ -63,10 +63,12 @@ #include "llresmgr.h" #include "llworld.h" #include "llstatgraph.h" +#include "llurlaction.h" #include "llviewermedia.h" #include "llviewermenu.h" // for gMenuBarView #include "llviewerparcelmgr.h" #include "llviewerthrottle.h" +#include "llwindow.h" #include "lluictrlfactory.h" #include "lltoolmgr.h" @@ -304,6 +306,9 @@ bool LLStatusBar::postBuild() mBoxBalance = getChild("balance"); mBoxBalance->setClickedCallback( &LLStatusBar::onClickBalance, this ); + // show fpslimit reached in FPS status bar + getChild("FPSText")->setClickedCallback( std::bind(&LLUrlAction::executeSLURL, "secondlife:///app/openfloater/preferences?search=limit%20framerate", true)); + mIconPresetsCamera = getChild( "presets_icon_camera" ); //mIconPresetsCamera->setMouseEnterCallback(boost::bind(&LLStatusBar::mIconPresetsCamera, this)); if (gSavedSettings.getBOOL("FSStatusBarMenuButtonPopupOnRollover")) @@ -483,7 +488,10 @@ bool LLStatusBar::postBuild() mBalancePanel = getChild("balance_bg"); mTimeMediaPanel = getChild("time_and_media_bg"); + // Make FPS a clickable button with contextual colour mFPSText = getChild("FPSText"); + // mFPSText = getChild("FPSText"); + // mVolumeIconsWidth = mBtnVolume->getRect().mRight - mStreamToggle->getRect().mLeft; initParcelIcons(); @@ -598,8 +606,60 @@ void LLStatusBar::refresh() static LLCachedControl fsStatusBarShowFPS(gSavedSettings, "FSStatusBarShowFPS"); if (fsStatusBarShowFPS && mFPSUpdateTimer.getElapsedTimeF32() > 1.f) { + static LLCachedControl max_fps(gSavedSettings, "FramePerSecondLimit"); + static LLCachedControl limit_fps_enabled(gSavedSettings, "FSLimitFramerate"); + static LLCachedControl vsync_enabled(gSavedSettings, "RenderVSyncEnable"); + + const auto FPS_below_limit_color = LLUIColorTable::instance().getColor( "Yellow" ); + const auto FPS_limit_reached_color = LLUIColorTable::instance().getColor( "Green" ); + const auto vsync_limit_reached_color = LLUIColorTable::instance().getColor( "Green" ); + const auto FPS_uncapped_color = LLUIColorTable::instance().getColor( "White" ); + const auto FPS_unfocussed_color = LLUIColorTable::instance().getColor( "Gray" ); mFPSUpdateTimer.reset(); - mFPSText->setText(llformat("%.1f", LLTrace::get_frame_recording().getPeriodMedianPerSec(LLStatViewer::FPS))); + S32 vsync_freq=-1; + auto fps = LLTrace::get_frame_recording().getPeriodMedianPerSec(LLStatViewer::FPS); + if (gViewerWindow && gViewerWindow->getWindow()) + { + vsync_freq = gViewerWindow->getWindow()->getRefreshRate(); + } + mFPSText->setText(llformat("%.1f", fps )); + // if background, go grey, else go white unless we have a cap (checked next) + auto fps_color = FPS_uncapped_color; + if ((gViewerWindow && !gViewerWindow->getWindow()->getVisible()) + || !gFocusMgr.getAppHasFocus()) + { + fps_color = FPS_unfocussed_color; + } + else + { + if (limit_fps_enabled && max_fps > 0) + { + if (fps >= max_fps-1) // allow a small undershoot + { + fps_color = FPS_limit_reached_color; + } + else + { + fps_color = FPS_below_limit_color; + } + } + // use vsync if enabled and the freq is lower than the max_fps + if (vsync_enabled && vsync_freq > 0) + { + if ( !limit_fps_enabled || (limit_fps_enabled && vsync_freq < (S32)max_fps) ) + { + if (fps >= vsync_freq -1 ) + { + fps_color = vsync_limit_reached_color; + } + else + { + fps_color = FPS_below_limit_color; + } + } + } + } + mFPSText->setColor(fps_color); } // diff --git a/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml b/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml index 2c927502a1..de58146dc6 100644 --- a/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml +++ b/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml @@ -1110,6 +1110,47 @@ If you do not understand the distinction then leave this control alone." top_pad="6" width="256"/> + + + + + - - 200.0