Add LLFloaterAbout info (esp. GPU info) to Frame Profile stats dump

With the About info added, `getProfileStatsContext()` need not redundantly add
`"channel"`, `"version"` or `"region"`.

Slightly improve the efficiency of `LlsdToJson()` and `LlsdFromJson()` by
preallocating the known size of the source array or map. (Unfortunately the C++
`LLSD` class offers us no way to preallocate a map.)

In `LLAppViewer::getViewerInfo()`, avoid immediate successive calls to
`gAgent.getRegion()`.

(cherry picked from commit f4b65638879c10c832b3bb8448f82001106ffd11)
master
Nat Goodspeed 2024-09-16 17:25:48 -04:00
parent ee1b0061c3
commit e6d0138a6a
3 changed files with 41 additions and 4 deletions

View File

@ -61,12 +61,20 @@ LLSD LlsdFromJson(const boost::json::value& val)
result = LLSD(val.as_bool());
break;
case boost::json::kind::array:
{
result = LLSD::emptyArray();
for (const auto &element : val.as_array())
auto& array = val.as_array();
// allocate elements 0 .. (size() - 1) to avoid incremental allocation
if (! array.empty())
{
result[array.size() - 1] = LLSD();
}
for (const auto &element : array)
{
result.append(LlsdFromJson(element));
}
break;
}
case boost::json::kind::object:
result = LLSD::emptyMap();
for (const auto& element : val.as_object())
@ -106,6 +114,7 @@ boost::json::value LlsdToJson(const LLSD &val)
case LLSD::TypeMap:
{
boost::json::object& obj = result.emplace_object();
obj.reserve(val.size());
for (const auto& llsd_dat : llsd::inMap(val))
{
obj[llsd_dat.first] = LlsdToJson(llsd_dat.second);
@ -115,6 +124,7 @@ boost::json::value LlsdToJson(const LLSD &val)
case LLSD::TypeArray:
{
boost::json::array& json_array = result.emplace_array();
json_array.reserve(val.size());
for (const auto& llsd_dat : llsd::inArray(val))
{
json_array.push_back(LlsdToJson(llsd_dat));
@ -123,7 +133,8 @@ boost::json::value LlsdToJson(const LLSD &val)
}
case LLSD::TypeBinary:
default:
LL_ERRS("LlsdToJson") << "Unsupported conversion to JSON from LLSD type (" << val.type() << ")." << LL_ENDL;
LL_ERRS("LlsdToJson") << "Unsupported conversion to JSON from LLSD type ("
<< val.type() << ")." << LL_ENDL;
break;
}

View File

@ -3285,10 +3285,10 @@ LLSD LLAppViewer::getViewerInfo() const
LLVector3d pos = gAgent.getPositionGlobal();
info["POSITION"] = ll_sd_from_vector3d(pos);
info["POSITION_LOCAL"] = ll_sd_from_vector3(gAgent.getPosAgentFromGlobal(pos));
info["REGION"] = gAgent.getRegion()->getName();
info["REGION"] = region->getName();
boost::regex regex("\\.(secondlife|lindenlab)\\..*");
info["HOSTNAME"] = boost::regex_replace(gAgent.getRegion()->getSimHostName(), regex, "");
info["HOSTNAME"] = boost::regex_replace(region->getSimHostName(), regex, "");
info["SERVER_VERSION"] = gLastVersionChannel;
LLSLURL slurl;
LLAgentUI::buildSLURL(slurl);

View File

@ -58,6 +58,7 @@
#include "llpostprocess.h"
#include "llrender.h"
#include "llscenemonitor.h"
#include "llsdjson.h"
#include "llselectmgr.h"
#include "llsky.h"
#include "llspatialpartition.h"
@ -1044,6 +1045,31 @@ void display(bool rebuild, F32 zoom_factor, int subfield, bool for_snapshot)
}
}
void getProfileStatsContext(boost::json::object& stats)
{
// populate the context with info from LLFloaterAbout
auto contextit = stats.emplace("context",
LlsdToJson(LLAppViewer::instance()->getViewerInfo())).first;
auto& context = contextit->value().as_object();
// then add a few more things
unsigned char unique_id[MAC_ADDRESS_BYTES]{};
LLMachineID::getUniqueID(unique_id, sizeof(unique_id));
context.emplace("machine", stringize(LL::hexdump(unique_id, sizeof(unique_id))));
context.emplace("grid", LLGridManager::instance().getGrid());
LLViewerRegion* region = gAgent.getRegion();
if (region)
{
context.emplace("regionid", stringize(region->getRegionID()));
}
LLParcel* parcel = LLViewerParcelMgr::instance().getAgentParcel();
if (parcel)
{
context.emplace("parcel", parcel->getName());
context.emplace("parcelid", parcel->getLocalID());
}
}
std::string getProfileStatsFilename()
{
std::ostringstream basebuff;