summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
authorAndrey Kleshchev <andreykproductengine@lindenlab.com>2025-02-22 10:42:28 +0200
committerAndrey Kleshchev <andreykproductengine@lindenlab.com>2025-02-22 10:42:28 +0200
commit1503e84602f91bef31a5c414852e480805e613b4 (patch)
treeb6b9efbf0f6d63d81eae2c8517e6e7b1106d0f04 /indra/newview
parent29b13af84b6092f2368ef8ebfd6431003a963c10 (diff)
#3596 Fix mMutex in mesh thread
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/llmeshrepository.cpp50
-rw-r--r--indra/newview/llmeshrepository.h1
2 files changed, 42 insertions, 9 deletions
diff --git a/indra/newview/llmeshrepository.cpp b/indra/newview/llmeshrepository.cpp
index 283e5e51da..18ca0798bc 100644
--- a/indra/newview/llmeshrepository.cpp
+++ b/indra/newview/llmeshrepository.cpp
@@ -1244,25 +1244,57 @@ void LLMeshRepoThread::loadMeshLOD(const LLVolumeParams& mesh_params, S32 lod)
}
void LLMeshRepoThread::loadMeshLODs(const lod_list_t& list)
-{ //could be called from any thread
+{ // expectes mMutex to be locked
for (auto lod_pair : list)
{
const LLVolumeParams& mesh_params = lod_pair.first;
const LLUUID& mesh_id = mesh_params.getSculptID();
S32 lod = lod_pair.second;
- loadMeshLOD(mesh_id, mesh_params, lod);
+
+ if (hasHeader(mesh_id))
+ { //if we have the header, request LOD byte range
+
+ LODRequest req(mesh_params, lod);
+ {
+ mLODReqQ.push(req);
+ LLMeshRepository::sLODProcessing++;
+ }
+ }
+ else
+ {
+ LLMutexLock lock(mPendingMutex);
+ HeaderRequest req(mesh_params);
+ pending_lod_map::iterator pending = mPendingLOD.find(mesh_id);
+
+ if (pending != mPendingLOD.end())
+ {
+ //append this lod request to existing header request
+ if (lod < LLModel::NUM_LODS && lod >= 0)
+ {
+ pending->second[lod]++;
+ }
+ else
+ {
+ LL_WARNS(LOG_MESH) << "Invalid LOD request: " << lod << "for mesh" << mesh_id << LL_ENDL;
+ }
+ llassert_msg(lod < LLModel::NUM_LODS, "Requested lod is out of bounds");
+ }
+ else
+ {
+ //if no header request is pending, fetch header
+ auto& array = mPendingLOD[mesh_id];
+ std::fill(array.begin(), array.end(), 0);
+ array[lod]++;
+
+ mHeaderReqQ.push(req);
+ }
+ }
}
}
void LLMeshRepoThread::loadMeshLOD(const LLUUID& mesh_id, const LLVolumeParams& mesh_params, S32 lod)
{
- bool has_header = false;
- {
- LLMutexLock header_lock(mHeaderMutex);
- mesh_header_map::iterator iter = mMeshHeader.find(mesh_id);
- has_header = iter != mMeshHeader.end();
- }
- if (has_header)
+ if (hasHeader(mesh_id))
{ //if we have the header, request LOD byte range
LODRequest req(mesh_params, lod);
diff --git a/indra/newview/llmeshrepository.h b/indra/newview/llmeshrepository.h
index 07d3e465d1..ed4514dff8 100644
--- a/indra/newview/llmeshrepository.h
+++ b/indra/newview/llmeshrepository.h
@@ -520,6 +520,7 @@ public:
void loadMeshLOD(const LLVolumeParams& mesh_params, S32 lod);
typedef std::vector<std::pair<const LLVolumeParams&, S32> > lod_list_t;
+ // Mutex: must be holding mMutex when called
void loadMeshLODs(const lod_list_t& mesh_vect);
bool fetchMeshHeader(const LLVolumeParams& mesh_params);