From 6c226ac96c8ba01e62ea1085177b2859b74b85d8 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Fri, 13 Sep 2024 16:01:05 -0400 Subject: Add context info to Develop->Render Tests->Frame Profile stats file. Specifically, add the viewer version, the machine ID, the grid, the region name and ID, the parcel name and ID and the timestamp. This is both richer and less fragile than trying to extract that information from the generated filename: e.g. we now have region and parcel names. Instead of making `LLGLSLShader::finishProfile()` mess with file I/O, pass it a reference to a `boost::json::value` to be filled in with statistics, if it's a `boost::json::object`. Otherwise it's `boost::json::null`, meaning no report. Make llviewerdisplay.cpp's `display()` function instantiate a `boost::json::value` to pass to `finishProfile()`. That lets llviewerdisplay.cpp also set the `"context"` entry, with a new `getProfileStatsContext()` function quite similar to `getProfileStatsFilename()`. --- indra/newview/llviewerdisplay.cpp | 44 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) (limited to 'indra/newview') diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp index fdfe477a6c..aad11d9372 100644 --- a/indra/newview/llviewerdisplay.cpp +++ b/indra/newview/llviewerdisplay.cpp @@ -138,6 +138,7 @@ void render_ui_3d(); void render_ui_2d(); void render_disconnected_background(); +void getProfileStatsContext(boost::json::object& stats); std::string getProfileStatsFilename(); void display_startup() @@ -1040,8 +1041,49 @@ void display(bool rebuild, F32 zoom_factor, int subfield, bool for_snapshot) if (gShaderProfileFrame) { gShaderProfileFrame = false; - LLGLSLShader::finishProfile(getProfileStatsFilename()); + boost::json::value stats{ boost::json::object_kind }; + getProfileStatsContext(stats.as_object()); + LLGLSLShader::finishProfile(stats); + + auto report_name = getProfileStatsFilename(); + std::ofstream outf(report_name); + if (! outf) + { + LL_WARNS() << "Couldn't write to " << std::quoted(report_name) << LL_ENDL; + } + else + { + outf << stats; + LL_INFOS() << "(also dumped to " << std::quoted(report_name) << ")" << LL_ENDL; + } + } +} + +void getProfileStatsContext(boost::json::object& stats) +{ + auto contextit = stats.emplace("context", boost::json::object_kind).first; + auto& context = contextit->value().as_object(); + + auto& versionInfo = LLVersionInfo::instance(); + context.emplace("channel", versionInfo.getChannel()); + context.emplace("version", versionInfo.getVersion()); + 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("region", region->getName()); + context.emplace("regionid", stringize(region->getRegionID())); + } + LLParcel* parcel = LLViewerParcelMgr::instance().getAgentParcel(); + if (parcel) + { + context.emplace("parcel", parcel->getName()); + context.emplace("parcelid", parcel->getLocalID()); } + context.emplace("time", LLDate::now().toHTTPDateString("%Y-%m-%dT%H:%M:%S")); } std::string getProfileStatsFilename() -- cgit v1.2.3 From f4b65638879c10c832b3bb8448f82001106ffd11 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Mon, 16 Sep 2024 17:25:48 -0400 Subject: 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()`. --- indra/newview/llappviewer.cpp | 4 ++-- indra/newview/llviewerdisplay.cpp | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 789aaab70d..77797ad5f0 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -3351,10 +3351,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); diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp index aad11d9372..f722d0bd1d 100644 --- a/indra/newview/llviewerdisplay.cpp +++ b/indra/newview/llviewerdisplay.cpp @@ -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" @@ -1061,12 +1062,12 @@ void display(bool rebuild, F32 zoom_factor, int subfield, bool for_snapshot) void getProfileStatsContext(boost::json::object& stats) { - auto contextit = stats.emplace("context", boost::json::object_kind).first; + // populate the context with info from LLFloaterAbout + auto contextit = stats.emplace("context", + LlsdToJson(LLAppViewer::instance()->getViewerInfo())).first; auto& context = contextit->value().as_object(); - auto& versionInfo = LLVersionInfo::instance(); - context.emplace("channel", versionInfo.getChannel()); - context.emplace("version", versionInfo.getVersion()); + // 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)))); @@ -1074,7 +1075,6 @@ void getProfileStatsContext(boost::json::object& stats) LLViewerRegion* region = gAgent.getRegion(); if (region) { - context.emplace("region", region->getName()); context.emplace("regionid", stringize(region->getRegionID())); } LLParcel* parcel = LLViewerParcelMgr::instance().getAgentParcel(); -- cgit v1.2.3