summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
Diffstat (limited to 'indra')
-rw-r--r--indra/llcommon/llsdjson.cpp15
-rw-r--r--indra/llrender/llglslshader.cpp21
-rw-r--r--indra/llrender/llglslshader.h10
-rw-r--r--indra/newview/llappviewer.cpp4
-rw-r--r--indra/newview/llviewerdisplay.cpp44
5 files changed, 67 insertions, 27 deletions
diff --git a/indra/llcommon/llsdjson.cpp b/indra/llcommon/llsdjson.cpp
index 5d38e55686..1df2a8f9eb 100644
--- a/indra/llcommon/llsdjson.cpp
+++ b/indra/llcommon/llsdjson.cpp
@@ -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;
}
diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp
index 56f1533708..6ba5463acd 100644
--- a/indra/llrender/llglslshader.cpp
+++ b/indra/llrender/llglslshader.cpp
@@ -41,8 +41,6 @@
#include "OpenGL/OpenGL.h"
#endif
-#include <fstream>
-
// Print-print list of shader included source files that are linked together via glAttachShader()
// i.e. On macOS / OSX the AMD GLSL linker will display an error if a varying is left in an undefined state.
#define DEBUG_SHADER_INCLUDES 0
@@ -65,7 +63,7 @@ U64 LLGLSLShader::sTotalTimeElapsed = 0;
U32 LLGLSLShader::sTotalTrianglesDrawn = 0;
U64 LLGLSLShader::sTotalSamplesDrawn = 0;
U32 LLGLSLShader::sTotalBinds = 0;
-std::string LLGLSLShader::sDefaultReportName;
+boost::json::value LLGLSLShader::sDefaultStats;
//UI shader -- declared here so llui_libtest will link properly
LLGLSLShader gUIProgram;
@@ -120,16 +118,16 @@ struct LLGLSLShaderCompareTimeElapsed
};
//static
-void LLGLSLShader::finishProfile(const std::string& report_name)
+void LLGLSLShader::finishProfile(boost::json::value& statsv)
{
sProfileEnabled = false;
- if (! report_name.empty())
+ if (! statsv.is_null())
{
std::vector<LLGLSLShader*> sorted(sInstances.begin(), sInstances.end());
std::sort(sorted.begin(), sorted.end(), LLGLSLShaderCompareTimeElapsed());
- boost::json::object stats;
+ auto& stats = statsv.as_object();
auto shadersit = stats.emplace("shaders", boost::json::array_kind).first;
auto& shaders = shadersit->value().as_array();
bool unbound = false;
@@ -174,17 +172,6 @@ void LLGLSLShader::finishProfile(const std::string& report_name)
}
}
}
-
- 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;
- }
}
}
diff --git a/indra/llrender/llglslshader.h b/indra/llrender/llglslshader.h
index a9b9bfafa8..2d669c70a9 100644
--- a/indra/llrender/llglslshader.h
+++ b/indra/llrender/llglslshader.h
@@ -170,7 +170,7 @@ public:
static U32 sMaxGLTFNodes;
static void initProfile();
- static void finishProfile(const std::string& report_name=sDefaultReportName);
+ static void finishProfile(boost::json::value& stats=sDefaultStats);
static void startProfile();
static void stopProfile();
@@ -365,10 +365,10 @@ public:
private:
void unloadInternal();
// This must be static because finishProfile() is called at least once
- // within a __try block. If we default its report_name parameter to a
- // temporary std::string, that temporary must be destroyed when the stack
- // is unwound, which __try forbids.
- static std::string sDefaultReportName;
+ // within a __try block. If we default its stats parameter to a temporary
+ // json::value, that temporary must be destroyed when the stack is
+ // unwound, which __try forbids.
+ static boost::json::value sDefaultStats;
};
//UI shader (declared here so llui_libtest will link properly)
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index a9ac48ac88..dbbc7541cc 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -3337,10 +3337,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 fdfe477a6c..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"
@@ -138,6 +139,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 +1042,48 @@ 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)
+{
+ // 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());
}
+ context.emplace("time", LLDate::now().toHTTPDateString("%Y-%m-%dT%H:%M:%S"));
}
std::string getProfileStatsFilename()