summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorDave Parks <davep@lindenlab.com>2022-11-01 08:31:01 -0500
committerDave Parks <davep@lindenlab.com>2022-11-01 08:31:01 -0500
commit9f21fba6d9a28cd1b324a115a0a2f86613a134e7 (patch)
tree0974887ff63add5279f2e5b756b2ef6112097a3f /indra
parent8faa5a3305a3dad31ee3584aa5404d0ee80923ed (diff)
SL-18513 Put profile markers around GLTF code.
Diffstat (limited to 'indra')
-rw-r--r--indra/llprimitive/llgltfmaterial.cpp17
-rw-r--r--indra/llprimitive/lltextureentry.cpp2
-rw-r--r--indra/newview/llgltfmateriallist.cpp73
-rw-r--r--indra/newview/llviewerobject.cpp1
4 files changed, 55 insertions, 38 deletions
diff --git a/indra/llprimitive/llgltfmaterial.cpp b/indra/llprimitive/llgltfmaterial.cpp
index f771337c92..cd629dbbd8 100644
--- a/indra/llprimitive/llgltfmaterial.cpp
+++ b/indra/llprimitive/llgltfmaterial.cpp
@@ -42,6 +42,7 @@ LLGLTFMaterial::LLGLTFMaterial(const LLGLTFMaterial& rhs)
LLGLTFMaterial& LLGLTFMaterial::operator=(const LLGLTFMaterial& rhs)
{
+ LL_PROFILE_ZONE_SCOPED;
//have to do a manual operator= because of LLRefCount
mBaseColorId = rhs.mBaseColorId;
mNormalId = rhs.mNormalId;
@@ -65,7 +66,7 @@ LLGLTFMaterial& LLGLTFMaterial::operator=(const LLGLTFMaterial& rhs)
bool LLGLTFMaterial::fromJSON(const std::string& json, std::string& warn_msg, std::string& error_msg)
{
-#if 1
+ LL_PROFILE_ZONE_SCOPED;
tinygltf::TinyGLTF gltf;
tinygltf::Model model_in;
@@ -74,18 +75,14 @@ bool LLGLTFMaterial::fromJSON(const std::string& json, std::string& warn_msg, st
{
setFromModel(model_in, 0);
- //DEBUG generate json and print
- LL_INFOS() << asJSON(true) << LL_ENDL;
-
return true;
}
-#endif
return false;
}
std::string LLGLTFMaterial::asJSON(bool prettyprint) const
{
-#if 1
+ LL_PROFILE_ZONE_SCOPED;
tinygltf::TinyGLTF gltf;
tinygltf::Model model_out;
@@ -97,13 +94,11 @@ std::string LLGLTFMaterial::asJSON(bool prettyprint) const
gltf.WriteGltfSceneToStream(&model_out, str, prettyprint, false);
return str.str();
-#else
- return "";
-#endif
}
void LLGLTFMaterial::setFromModel(const tinygltf::Model& model, S32 mat_index)
{
+ LL_PROFILE_ZONE_SCOPED;
if (model.materials.size() <= mat_index)
{
return;
@@ -198,6 +193,7 @@ std::string gltf_get_texture_image(const tinygltf::Model& model, const T& textur
template<typename T>
void LLGLTFMaterial::setFromTexture(const tinygltf::Model& model, const T& texture_info, TextureInfo texture_info_id, LLUUID& texture_id_out)
{
+ LL_PROFILE_ZONE_SCOPED;
const std::string uri = gltf_get_texture_image(model, texture_info);
texture_id_out.set(uri);
@@ -219,6 +215,7 @@ void LLGLTFMaterial::setFromTexture(const tinygltf::Model& model, const T& textu
void LLGLTFMaterial::writeToModel(tinygltf::Model& model, S32 mat_index) const
{
+ LL_PROFILE_ZONE_SCOPED;
if (model.materials.size() < mat_index+1)
{
model.materials.resize(mat_index + 1);
@@ -277,6 +274,7 @@ void gltf_allocate_texture_image(tinygltf::Model& model, T& texture_info, const
template<typename T>
void LLGLTFMaterial::writeToTexture(tinygltf::Model& model, T& texture_info, TextureInfo texture_info_id, const LLUUID& texture_id, bool is_override, const LLUUID& base_texture_id) const
{
+ LL_PROFILE_ZONE_SCOPED;
if (texture_id.isNull() || (is_override && texture_id == base_texture_id))
{
return;
@@ -447,6 +445,7 @@ F32 LLGLTFMaterial::getDefaultTextureRotation()
void LLGLTFMaterial::applyOverride(const LLGLTFMaterial& override_mat)
{
+ LL_PROFILE_ZONE_SCOPED;
// TODO: potentially reimplement this with a more general purpose JSON merge
if (override_mat.mBaseColorId != getDefaultBaseColorId())
diff --git a/indra/llprimitive/lltextureentry.cpp b/indra/llprimitive/lltextureentry.cpp
index 611f146a84..a0d5793dcc 100644
--- a/indra/llprimitive/lltextureentry.cpp
+++ b/indra/llprimitive/lltextureentry.cpp
@@ -198,6 +198,7 @@ LLSD LLTextureEntry::asLLSD() const
void LLTextureEntry::asLLSD(LLSD& sd) const
{
+ LL_PROFILE_ZONE_SCOPED;
sd["imageid"] = mID;
sd["colors"] = ll_sd_from_color4(mColor);
sd["scales"] = mScaleS;
@@ -225,6 +226,7 @@ void LLTextureEntry::asLLSD(LLSD& sd) const
bool LLTextureEntry::fromLLSD(const LLSD& sd)
{
+ LL_PROFILE_ZONE_SCOPED;
const char *w, *x;
w = "imageid";
if (sd.has(w))
diff --git a/indra/newview/llgltfmateriallist.cpp b/indra/newview/llgltfmateriallist.cpp
index d91a448bc8..a4033f0d4d 100644
--- a/indra/newview/llgltfmateriallist.cpp
+++ b/indra/newview/llgltfmateriallist.cpp
@@ -61,6 +61,7 @@ namespace
bool operator()(const LLDispatcher* dispatcher, const std::string& key, const LLUUID& invoice, const sparam_t& strings) override
{
+ LL_PROFILE_ZONE_SCOPED;
// receive override data from simulator via LargeGenericMessage
// message should have:
// object_id - UUID of LLViewerObject
@@ -196,6 +197,7 @@ void LLGLTFMaterialList::queueOverrideUpdate(const LLUUID& id, S32 side, LLGLTFM
void LLGLTFMaterialList::applyQueuedOverrides(LLViewerObject* obj)
{
+ LL_PROFILE_ZONE_SCOPED;
const LLUUID& id = obj->getID();
auto iter = mQueuedOverrides.find(id);
@@ -225,9 +227,11 @@ void LLGLTFMaterialList::applyQueuedOverrides(LLViewerObject* obj)
LLGLTFMaterial* LLGLTFMaterialList::getMaterial(const LLUUID& id)
{
+ LL_PROFILE_ZONE_SCOPED;
uuid_mat_map_t::iterator iter = mList.find(id);
if (iter == mList.end())
{
+ LL_PROFILE_ZONE_NAMED("gltf fetch")
LLFetchedGLTFMaterial* mat = new LLFetchedGLTFMaterial();
mList[id] = mat;
@@ -242,55 +246,66 @@ LLGLTFMaterial* LLGLTFMaterialList::getMaterial(const LLUUID& id)
gAssetStorage->getAssetData(id, LLAssetType::AT_MATERIAL,
[=](const LLUUID& id, LLAssetType::EType asset_type, void* user_data, S32 status, LLExtStat ext_status)
{
+ LL_PROFILE_ZONE_SCOPED("gltf asset callback");
if (status)
{
LL_WARNS() << "Error getting material asset data: " << LLAssetStorage::getErrorString(status) << " (" << status << ")" << LL_ENDL;
}
- LLFileSystem file(id, asset_type, LLFileSystem::READ);
- auto size = file.getSize();
- if (!size)
+ std::vector<char> buffer;
+
{
- LL_DEBUGS() << "Zero size material." << LL_ENDL;
- mat->mFetching = false;
- mat->unref();
- return;
- }
+ LL_PROFILE_ZONE_SCOPED("gltf read asset");
+ LLFileSystem file(id, asset_type, LLFileSystem::READ);
+ auto size = file.getSize();
+ if (!size)
+ {
+ LL_DEBUGS() << "Zero size material." << LL_ENDL;
+ mat->mFetching = false;
+ mat->unref();
+ return;
+ }
- std::vector<char> buffer;
- buffer.resize(size);
- file.read((U8*)&buffer[0], buffer.size());
- LLSD asset;
- // read file into buffer
- std::istrstream str(&buffer[0], buffer.size());
+ buffer.resize(size);
+ file.read((U8*)&buffer[0], buffer.size());
+ }
- if (LLSDSerialize::deserialize(asset, str, buffer.size()))
{
- if (asset.has("version") && asset["version"] == "1.0")
+ LL_PROFILE_ZONE_SCOPED("gltf deserialize asset");
+
+ LLSD asset;
+
+ // read file into buffer
+ std::istrstream str(&buffer[0], buffer.size());
+
+ if (LLSDSerialize::deserialize(asset, str, buffer.size()))
{
- if (asset.has("type") && asset["type"].asString() == "GLTF 2.0")
+ if (asset.has("version") && asset["version"] == "1.0")
{
- if (asset.has("data") && asset["data"].isString())
+ if (asset.has("type") && asset["type"].asString() == "GLTF 2.0")
{
- std::string data = asset["data"];
+ if (asset.has("data") && asset["data"].isString())
+ {
+ std::string data = asset["data"];
- std::string warn_msg, error_msg;
+ std::string warn_msg, error_msg;
- if (!mat->fromJSON(data, warn_msg, error_msg))
- {
- LL_WARNS() << "Failed to decode material asset: " << LL_ENDL;
- LL_WARNS() << warn_msg << LL_ENDL;
- LL_WARNS() << error_msg << LL_ENDL;
+ if (!mat->fromJSON(data, warn_msg, error_msg))
+ {
+ LL_WARNS() << "Failed to decode material asset: " << LL_ENDL;
+ LL_WARNS() << warn_msg << LL_ENDL;
+ LL_WARNS() << error_msg << LL_ENDL;
+ }
}
}
}
}
- }
- else
- {
- LL_WARNS() << "Failed to deserialize material LLSD" << LL_ENDL;
+ else
+ {
+ LL_WARNS() << "Failed to deserialize material LLSD" << LL_ENDL;
+ }
}
mat->mFetching = false;
diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index 43525a3173..a649387795 100644
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -5350,6 +5350,7 @@ S32 LLViewerObject::setTEMaterialParams(const U8 te, const LLMaterialPtr pMateri
S32 LLViewerObject::setTEGLTFMaterialOverride(U8 te, LLGLTFMaterial* override_mat)
{
+ LL_PROFILE_ZONE_SCOPED;
S32 retval = TEM_CHANGE_NONE;
LLTextureEntry* tep = getTE(te);