From e23b3972a00370aff25d582ce33dc0db6d795213 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 22 Mar 2023 18:25:47 -0500 Subject: DRTVWR-559 Fix for bad hashing of materials breaking render batches and who knows what else. --- indra/llprimitive/llgltfmaterial.cpp | 10 ++++++++++ indra/llprimitive/llgltfmaterial.h | 9 +-------- indra/llprimitive/llmaterial.cpp | 2 +- 3 files changed, 12 insertions(+), 9 deletions(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llgltfmaterial.cpp b/indra/llprimitive/llgltfmaterial.cpp index 62b693919c..f3aa5b0648 100644 --- a/indra/llprimitive/llgltfmaterial.cpp +++ b/indra/llprimitive/llgltfmaterial.cpp @@ -692,3 +692,13 @@ void LLGLTFMaterial::applyOverride(const LLGLTFMaterial& override_mat) } } } + +LLUUID LLGLTFMaterial::getHash() const +{ + LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; + // HACK - hash the bytes of this object but don't include the ref count + LLUUID hash; + HBXXH128::digest(hash, (unsigned char*)this + sizeof(LLRefCount), sizeof(*this) - sizeof(LLRefCount)); + return hash; +} + diff --git a/indra/llprimitive/llgltfmaterial.h b/indra/llprimitive/llgltfmaterial.h index b453b91e67..a53b68a50f 100644 --- a/indra/llprimitive/llgltfmaterial.h +++ b/indra/llprimitive/llgltfmaterial.h @@ -115,14 +115,7 @@ public: bool mOverrideAlphaMode = false; // get a UUID based on a hash of this LLGLTFMaterial - LLUUID getHash() const - { - LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; - // HACK - hash the bytes of this object but don't include the ref count - LLUUID hash; - HBXXH128::digest(hash, (unsigned char*)this + sizeof(S32), sizeof(this) - sizeof(S32)); - return hash; - } + LLUUID getHash() const; //setters for various members (will clamp to acceptable ranges) // for_override - set to true if this value is being set as part of an override (important for handling override to default value) diff --git a/indra/llprimitive/llmaterial.cpp b/indra/llprimitive/llmaterial.cpp index a694a666c6..37525e4a3d 100644 --- a/indra/llprimitive/llmaterial.cpp +++ b/indra/llprimitive/llmaterial.cpp @@ -481,7 +481,7 @@ LLUUID LLMaterial::getHash() const LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; // HACK - hash the bytes of this LLMaterial, but trim off the S32 in LLRefCount LLUUID id; - HBXXH128::digest(id, (unsigned char*)this + sizeof(S32), sizeof(this) - sizeof(S32)); + HBXXH128::digest(id, (unsigned char*)this + sizeof(LLRefCount), sizeof(*this) - sizeof(LLRefCount)); return id; } -- cgit v1.2.3 From d423263d54fc72cf857f3e147ac3860ca16c652f Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Thu, 23 Mar 2023 01:18:07 +0200 Subject: SL-19169 Local material updates aren't applied with non-default transforms --- indra/llprimitive/llgltfmaterial.h | 7 +++++++ indra/llprimitive/lltextureentry.cpp | 27 +++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/llgltfmaterial.h b/indra/llprimitive/llgltfmaterial.h index a53b68a50f..bdabd657e1 100644 --- a/indra/llprimitive/llgltfmaterial.h +++ b/indra/llprimitive/llgltfmaterial.h @@ -41,6 +41,8 @@ namespace tinygltf class Model; } +class LLTextureEntry; + class LLGLTFMaterial : public LLRefCount { public: @@ -193,6 +195,11 @@ public: // True if setBaseMaterial() was just called bool isClearedForBaseMaterial(); + // For local materials, they have to keep track of where + // they are assigned to for full updates + virtual void addTextureEntry(LLTextureEntry* te) {}; + virtual void removeTextureEntry(LLTextureEntry* te) {}; + private: template void setFromTexture(const tinygltf::Model& model, const T& texture_info, TextureInfo texture_info_id); diff --git a/indra/llprimitive/lltextureentry.cpp b/indra/llprimitive/lltextureentry.cpp index 49f67918f8..a665db378b 100644 --- a/indra/llprimitive/lltextureentry.cpp +++ b/indra/llprimitive/lltextureentry.cpp @@ -112,7 +112,15 @@ LLTextureEntry &LLTextureEntry::operator=(const LLTextureEntry &rhs) mMaterialID = rhs.mMaterialID; + if (mGLTFMaterial) + { + mGLTFMaterial->removeTextureEntry(this); + } mGLTFMaterial = rhs.mGLTFMaterial; + if (mGLTFMaterial) + { + mGLTFMaterial->addTextureEntry(this); + } if (rhs.mGLTFMaterialOverrides.notNull()) { @@ -155,6 +163,12 @@ LLTextureEntry::~LLTextureEntry() delete mMediaEntry; mMediaEntry = NULL; } + + if (mGLTFMaterial) + { + mGLTFMaterial->removeTextureEntry(this); + mGLTFMaterial = NULL; + } } bool LLTextureEntry::operator!=(const LLTextureEntry &rhs) const @@ -524,7 +538,20 @@ void LLTextureEntry::setGLTFMaterial(LLGLTFMaterial* material, bool local_origin // NOTE: if you're hitting this assert, try to make sure calling code is using LLViewerObject::setRenderMaterialID llassert(!local_origin || getGLTFMaterialOverride() == nullptr || getGLTFMaterialOverride()->isClearedForBaseMaterial()); + if (mGLTFMaterial) + { + // Local materials have to keep track + // due to update mechanics + mGLTFMaterial->removeTextureEntry(this); + } + mGLTFMaterial = material; + + if (mGLTFMaterial) + { + mGLTFMaterial->addTextureEntry(this); + } + if (mGLTFMaterial == nullptr) { setGLTFRenderMaterial(nullptr); -- cgit v1.2.3