Skip to content
Snippets Groups Projects
Commit bbc8770b authored by Rye Mutt's avatar Rye Mutt :bread:
Browse files

Merge branch 'topbar-fps' into 'master'

Add FPS counter to top bar

See merge request alchemy/alchemy-next!28
parents a1249727 adc6ea01
No related branches found
No related tags found
No related merge requests found
......@@ -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>
......
......@@ -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)
......
......@@ -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;
......
......@@ -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>
......@@ -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>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment