diff options
author | Mnikolenko Productengine <mnikolenko@productengine.com> | 2021-06-24 16:17:04 +0300 |
---|---|---|
committer | Mnikolenko Productengine <mnikolenko@productengine.com> | 2021-06-24 16:17:04 +0300 |
commit | f33605f8b113f1fed84564c7618630acd5c9427a (patch) | |
tree | 2abe94c95d80863eeb6df934c62d581cbe6b755a /indra/newview | |
parent | 3fe7715197c1e9a4ae781201df7a9ec24354f15e (diff) |
SL-15297 WIP Implement performance floater - implement complexity bars
Diffstat (limited to 'indra/newview')
-rw-r--r-- | indra/newview/llfloaterperformance.cpp | 118 | ||||
-rw-r--r-- | indra/newview/llfloaterperformance.h | 4 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/floater_performance.xml | 3 |
3 files changed, 101 insertions, 24 deletions
diff --git a/indra/newview/llfloaterperformance.cpp b/indra/newview/llfloaterperformance.cpp index 424ca04b1f..beeebcb202 100644 --- a/indra/newview/llfloaterperformance.cpp +++ b/indra/newview/llfloaterperformance.cpp @@ -26,13 +26,15 @@ #include "llviewerprecompiledheaders.h" #include "llfloaterperformance.h" +#include "llagent.h" +#include "llagentcamera.h" #include "llappearancemgr.h" #include "llavataractions.h" #include "llavatarrendernotifier.h" #include "llfeaturemanager.h" +#include "llfloaterpreference.h" // LLAvatarComplexityControls #include "llfloaterreg.h" #include "llnamelistctrl.h" -#include "llfloaterpreference.h" // LLAvatarComplexityControls #include "llsliderctrl.h" #include "lltextbox.h" #include "lltrans.h" @@ -40,12 +42,16 @@ #include "llvoavatarself.h" const F32 REFRESH_INTERVAL = 1.0f; -const S32 COMPLEXITY_THRESHOLD_1 = 100000; - +const S32 COMPLEXITY_THRESHOLD_HIGH = 100000; +const S32 COMPLEXITY_THRESHOLD_MEDIUM = 30000; +const S32 BAR_LEFT_PAD = 2; +const S32 BAR_RIGHT_PAD = 5; +const S32 BAR_BOTTOM_PAD = 9; LLFloaterPerformance::LLFloaterPerformance(const LLSD& key) : LLFloater(key), - mUpdateTimer(new LLTimer()) + mUpdateTimer(new LLTimer()), + mNearbyMaxComplexity(0) { } @@ -120,6 +126,10 @@ void LLFloaterPerformance::showSelectedPanel(LLPanel* selected_panel) { populateNearbyList(); } + else if (mComplexityPanel == selected_panel) + { + populateObjectList(); + } } void LLFloaterPerformance::draw() @@ -179,6 +189,7 @@ void LLFloaterPerformance::initBackBtn(LLPanel* panel) void LLFloaterPerformance::populateHUDList() { + S32 prev_pos = mHUDList->getScrollPos(); mHUDList->clearRows(); mHUDList->updateColumns(true); @@ -186,9 +197,15 @@ void LLFloaterPerformance::populateHUDList() hud_complexity_list_t::iterator iter = complexity_list.begin(); hud_complexity_list_t::iterator end = complexity_list.end(); - + + U32 max_complexity = 0; for (; iter != end; ++iter) { + max_complexity = llmax(max_complexity, (*iter).objectsCost); + } + + for (iter = complexity_list.begin(); iter != end; ++iter) + { LLHUDComplexity hud_object_complexity = *iter; LLSD item; @@ -196,8 +213,12 @@ void LLFloaterPerformance::populateHUDList() item["target"] = LLNameListCtrl::SPECIAL; LLSD& row = item["columns"]; row[0]["column"] = "complex_visual"; - row[0]["type"] = "text"; - row[0]["value"] = "*"; + row[0]["type"] = "image"; + LLSD& value = row[0]["value"]; + value["ratio"] = (F32)hud_object_complexity.objectsCost / max_complexity; + value["bottom"] = BAR_BOTTOM_PAD; + value["left_pad"] = BAR_LEFT_PAD; + value["right_pad"] = BAR_RIGHT_PAD; row[1]["column"] = "complex_value"; row[1]["type"] = "text"; @@ -212,12 +233,14 @@ void LLFloaterPerformance::populateHUDList() mHUDList->addElement(item); } mHUDList->sortByColumnIndex(1, FALSE); + mHUDList->setScrollPos(prev_pos); mHUDsPanel->getChild<LLTextBox>("huds_value")->setValue(std::to_string(complexity_list.size())); } void LLFloaterPerformance::populateObjectList() { + S32 prev_pos = mObjectList->getScrollPos(); mObjectList->clearRows(); mObjectList->updateColumns(true); @@ -226,8 +249,14 @@ void LLFloaterPerformance::populateObjectList() object_complexity_list_t::iterator iter = complexity_list.begin(); object_complexity_list_t::iterator end = complexity_list.end(); + U32 max_complexity = 0; for (; iter != end; ++iter) { + max_complexity = llmax(max_complexity, (*iter).objectCost); + } + + for (iter = complexity_list.begin(); iter != end; ++iter) + { LLObjectComplexity object_complexity = *iter; LLSD item; @@ -235,8 +264,12 @@ void LLFloaterPerformance::populateObjectList() item["target"] = LLNameListCtrl::SPECIAL; LLSD& row = item["columns"]; row[0]["column"] = "complex_visual"; - row[0]["type"] = "text"; - row[0]["value"] = "*"; + row[0]["type"] = "image"; + LLSD& value = row[0]["value"]; + value["ratio"] = (F32)object_complexity.objectCost / max_complexity; + value["bottom"] = BAR_BOTTOM_PAD; + value["left_pad"] = BAR_LEFT_PAD; + value["right_pad"] = BAR_RIGHT_PAD; row[1]["column"] = "complex_value"; row[1]["type"] = "text"; @@ -251,30 +284,35 @@ void LLFloaterPerformance::populateObjectList() mObjectList->addElement(item); } mObjectList->sortByColumnIndex(1, FALSE); + mObjectList->setScrollPos(prev_pos); } void LLFloaterPerformance::populateNearbyList() { + S32 prev_pos = mNearbyList->getScrollPos(); mNearbyList->clearRows(); mNearbyList->updateColumns(true); - S32 avatars = 0; static LLCachedControl<U32> max_render_cost(gSavedSettings, "RenderAvatarMaxComplexity", 0); + std::vector<LLCharacter*> valid_nearby_avs; + getNearbyAvatars(valid_nearby_avs); - std::vector<LLCharacter*>::iterator char_iter = LLCharacter::sInstances.begin(); - while (char_iter != LLCharacter::sInstances.end()) + std::vector<LLCharacter*>::iterator char_iter = valid_nearby_avs.begin(); + while (char_iter != valid_nearby_avs.end()) { LLVOAvatar* avatar = dynamic_cast<LLVOAvatar*>(*char_iter); - if (avatar && !avatar->isDead() && !avatar->isControlAvatar() && !avatar->isSelf()) + if (avatar) { - avatar->calculateUpdateRenderComplexity(); - LLSD item; item["id"] = avatar->getID(); LLSD& row = item["columns"]; row[0]["column"] = "complex_visual"; - row[0]["type"] = "text"; - row[0]["value"] = "*"; + row[0]["type"] = "image"; + LLSD& value = row[0]["value"]; + value["ratio"] = (F32)avatar->getVisualComplexity() / mNearbyMaxComplexity; + value["bottom"] = BAR_BOTTOM_PAD; + value["left_pad"] = BAR_LEFT_PAD; + value["right_pad"] = BAR_RIGHT_PAD; row[1]["column"] = "complex_value"; row[1]["type"] = "text"; @@ -296,6 +334,11 @@ void LLFloaterPerformance::populateNearbyList() if (avatar->getVisualComplexity() > max_render_cost) { color = "LabelDisabledColor"; + LLScrollListBar* bar = dynamic_cast<LLScrollListBar*>(av_item->getColumn(0)); + if (bar) + { + bar->setColor(LLUIColorTable::instance().getColor(color)); + } } else if (LLAvatarActions::isFriend(avatar->getID())) { @@ -304,28 +347,55 @@ void LLFloaterPerformance::populateNearbyList() name_text->setColor(LLUIColorTable::instance().getColor(color)); } } - avatars++; } char_iter++; } - mNearbyList->sortByColumnIndex(1, FALSE); + mNearbyList->sortByColumnIndex(1, FALSE); + mNearbyList->setScrollPos(prev_pos); } -void LLFloaterPerformance::updateNearbyComplexityDesc() +void LLFloaterPerformance::getNearbyAvatars(std::vector<LLCharacter*> &valid_nearby_avs) { - static LLCachedControl<U32> max_render_cost(gSavedSettings, "RenderAvatarMaxComplexity", 0); - S32 max_complexity = 0; + static LLCachedControl<F32> render_far_clip(gSavedSettings, "RenderFarClip", 64); + F32 radius = render_far_clip * render_far_clip; std::vector<LLCharacter*>::iterator char_iter = LLCharacter::sInstances.begin(); while (char_iter != LLCharacter::sInstances.end()) { LLVOAvatar* avatar = dynamic_cast<LLVOAvatar*>(*char_iter); if (avatar && !avatar->isDead() && !avatar->isControlAvatar() && !avatar->isSelf()) { - max_complexity = llmax(max_complexity, (S32)avatar->getVisualComplexity()); + if ((dist_vec_squared(avatar->getPositionGlobal(), gAgent.getPositionGlobal()) > radius) && + (dist_vec_squared(avatar->getPositionGlobal(), gAgentCamera.getCameraPositionGlobal()) > radius)) + { + char_iter++; + continue; + } + avatar->calculateUpdateRenderComplexity(); + mNearbyMaxComplexity = llmax(mNearbyMaxComplexity, (S32)avatar->getVisualComplexity()); + valid_nearby_avs.push_back(*char_iter); } char_iter++; } - std::string desc = getString(max_complexity > llmin((S32)max_render_cost, COMPLEXITY_THRESHOLD_1) ? "very_high" : "medium"); +} + +void LLFloaterPerformance::updateNearbyComplexityDesc() +{ + std::string desc = getString("low"); + + static LLCachedControl<U32> max_render_cost(gSavedSettings, "RenderAvatarMaxComplexity", 0); + if (mMainPanel->getVisible()) + { + std::vector<LLCharacter*> valid_nearby_avs; + getNearbyAvatars(valid_nearby_avs); + } + if (mNearbyMaxComplexity > COMPLEXITY_THRESHOLD_HIGH) + { + desc = getString("very_high"); + } + else if (mNearbyMaxComplexity > COMPLEXITY_THRESHOLD_MEDIUM) + { + desc = getString("medium"); + } if (mMainPanel->getVisible()) { diff --git a/indra/newview/llfloaterperformance.h b/indra/newview/llfloaterperformance.h index 7aec7c3f6c..ea15873b95 100644 --- a/indra/newview/llfloaterperformance.h +++ b/indra/newview/llfloaterperformance.h @@ -28,6 +28,7 @@ #include "llfloater.h" +class LLCharacter; class LLNameListCtrl; class LLFloaterPerformance : public LLFloater @@ -57,6 +58,7 @@ private: void updateMaxComplexity(); void updateComplexityText(); + void getNearbyAvatars(std::vector<LLCharacter*> &valid_nearby_avs); void updateNearbyComplexityDesc(); LLPanel* mMainPanel; @@ -72,6 +74,8 @@ private: LLTimer* mUpdateTimer; + S32 mNearbyMaxComplexity; + boost::signals2::connection mComplexityChangedSignal; }; diff --git a/indra/newview/skins/default/xui/en/floater_performance.xml b/indra/newview/skins/default/xui/en/floater_performance.xml index e415ac5be0..4cd3c7a603 100644 --- a/indra/newview/skins/default/xui/en/floater_performance.xml +++ b/indra/newview/skins/default/xui/en/floater_performance.xml @@ -12,6 +12,9 @@ <string name="medium" value="medium"/> + <string + name="low" + value="low"/> <panel bevel_style="none" follows="left|top" |