diff --git a/indra/newview/app_settings/settings_alchemy.xml b/indra/newview/app_settings/settings_alchemy.xml index ab08a6d465020ee51921db33906a136e62b65d00..9913d87c8a50204c7a8bdc35753cd53d83226ff8 100644 --- a/indra/newview/app_settings/settings_alchemy.xml +++ b/indra/newview/app_settings/settings_alchemy.xml @@ -695,6 +695,17 @@ <key>Value</key> <integer>0</integer> </map> + <key>ShowStatusBarFPS</key> + <map> + <key>Comment</key> + <string>Show FPS in Status Bar</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>Boolean</string> + <key>Value</key> + <integer>1</integer> + </map> <key>UIImgTransparentUUID</key> <map> <key>Comment</key> diff --git a/indra/newview/llstatusbar.cpp b/indra/newview/llstatusbar.cpp index f074755c7a20e6ed211bc88824770ed854927b43..477bf5d86932e3db460d1f96d372867b37656d95 100644 --- a/indra/newview/llstatusbar.cpp +++ b/indra/newview/llstatusbar.cpp @@ -108,6 +108,7 @@ const F32 ICON_TIMER_EXPIRY = 3.f; // How long the balance and health icons sho LLStatusBar::LLStatusBar(const LLRect& rect) : LLPanel(), mTextTime(NULL), + mTextFPS(nullptr), mSGBandwidth(NULL), mSGPacketLoss(NULL), mPanelPopupHolder(nullptr), @@ -129,6 +130,7 @@ LLStatusBar::LLStatusBar(const LLRect& rect) mBalanceTimer = new LLFrameTimer(); mHealthTimer = new LLFrameTimer(); + mFPSUpdateTimer = new LLFrameTimer(); buildFromFile("panel_status_bar.xml"); } @@ -148,6 +150,25 @@ LLStatusBar::~LLStatusBar() // Overrides //----------------------------------------------------------------------- +static int32_t fastFloor(const float* in, const ptrdiff_t length = 1) +{ + int32_t* out; + #define ALIGNMENT alignof(max_align_t) + static_assert(sizeof(float) == sizeof(int32_t), ""); + assert((uintptr_t)(void*)in % ALIGNMENT == 0); + assert((uintptr_t)(void*)out % ALIGNMENT == 0); + assert((size_t)length % (ALIGNMENT/sizeof(int32_t)) == 0); + + alignas(ALIGNMENT) const float* const input = in; + alignas(ALIGNMENT) int32_t* const output = out; + + // Do the conversion + for (int i = 0; i < length; ++i) { + output[i] = static_cast<int32_t>(std::floor(input[i])); + } + return *out; +} + // virtual void LLStatusBar::draw() { @@ -204,6 +225,8 @@ BOOL LLStatusBar::postBuild() gSavedSettings.getControl("MuteAudio")->getSignal()->connect(boost::bind(&LLStatusBar::onVolumeChanged, this, _2)); gSavedPerAccountSettings.getControl("AlchemyAOEnable")->getCommitSignal()->connect(boost::bind(&LLStatusBar::onAOStateChanged, this)); + mTextFPS = getChild<LLTextBox>("FPSText"); + // Adding Net Stat Graph S32 x = getRect().getWidth() - 2; S32 y = 0; @@ -300,6 +323,7 @@ BOOL LLStatusBar::postBuild() void LLStatusBar::refresh() { static LLCachedControl<bool> show_net_stats(gSavedSettings, "ShowNetStats", false); + static LLCachedControl<bool> show_fps(gSavedSettings, "ShowStatusBarFPS", false); bool net_stats_visible = show_net_stats; if (net_stats_visible) @@ -365,6 +389,13 @@ void LLStatusBar::refresh() media_inst->isParcelMediaPlaying() || media_inst->isParcelAudioPlaying()); mMediaToggle->setValue(!any_media_playing); + + if (show_fps && mFPSUpdateTimer->getElapsedTimeF32() > 0.125f) + { + mFPSUpdateTimer->reset(); + auto fps = (float)LLTrace::get_frame_recording().getPeriodMean(LLStatViewer::FPS); + mTextFPS->setText(fmt::format(FMT_STRING("{:d}"), fastFloor(&fps))); + } } void LLStatusBar::setVisibleForMouselook(bool visible) @@ -382,6 +413,7 @@ void LLStatusBar::setVisibleForMouselook(bool visible) setBackgroundVisible(visible); mIconPresetsCamera->setVisible(visible); mIconPresetsGraphic->setVisible(visible); + mTextFPS->setVisible(visible); } void LLStatusBar::debitBalance(S32 debit) diff --git a/indra/newview/llstatusbar.h b/indra/newview/llstatusbar.h index ac807ec82f6c178668eaed49bd6cc7f4ac29d61b..ab6e9007d54ff317640cd8f2873ddb42d37691b2 100644 --- a/indra/newview/llstatusbar.h +++ b/indra/newview/llstatusbar.h @@ -128,6 +128,7 @@ class LLStatusBar final void onAOStateChanged(); LLTextBox *mTextTime; + LLTextBox *mTextFPS; LLStatGraph *mSGBandwidth; LLStatGraph *mSGPacketLoss; @@ -141,6 +142,7 @@ class LLStatusBar final LLTextBox *mBoxBalance; LLButton *mMediaToggle; LLFrameTimer mClockUpdateTimer; + LLFrameTimer* mFPSUpdateTimer; S32 mBalance; S32 mHealth; diff --git a/indra/newview/skins/default/xui/en/menu_hide_navbar.xml b/indra/newview/skins/default/xui/en/menu_hide_navbar.xml index b517fd7957d03eff614ae5d34b097683ba58b970..1dd2c295c695f2dcfd965941b8bdd28e20afff83 100644 --- a/indra/newview/skins/default/xui/en/menu_hide_navbar.xml +++ b/indra/newview/skins/default/xui/en/menu_hide_navbar.xml @@ -30,4 +30,15 @@ function="CheckControl" parameter="ShowMiniLocationPanel" /> </menu_item_check> + <menu_item_check + label="Show FPS" + layout="topleft" + name="ShowStatusBarFPS"> + <on_click + function="ToggleControl" + parameter="ShowStatusBarFPS" /> + <on_check + function="CheckControl" + parameter="ShowStatusBarFPS" /> + </menu_item_check> </menu> diff --git a/indra/newview/skins/default/xui/en/panel_status_bar.xml b/indra/newview/skins/default/xui/en/panel_status_bar.xml index 7995d43f08e29fab48ea59063dfe3cc8687a7f5a..590045391716121ec025aec9891496428802e13c 100644 --- a/indra/newview/skins/default/xui/en/panel_status_bar.xml +++ b/indra/newview/skins/default/xui/en/panel_status_bar.xml @@ -75,7 +75,7 @@ </panel> <panel height="18" - left="-474" + left="-510" width="185" top="1" follows="right|top" @@ -210,4 +210,25 @@ function="Floater.ToggleOrBringToFront" parameter="quick_settings" /> </button> + <panel + height="18" + left_pad="0" + width="40" + top="2" + follows="right|top" + visibility_control="ShowStatusBarFPS" + name="fps_bg"> + <text + type="string" + follows="right|top" + halign="center" + height="16" + top="3" + left="0" + name="FPSText" + tool_tip="Current FPS" + width="35"> + 000.0 + </text> + </panel> </panel>