@@ -1109,7 +1109,7 @@ void LLMeshRepoThread::run()
1109
1109
}
1110
1110
else
1111
1111
{
1112
- LL_DEBUGS () << " mDecompositionRequests failed: " << req.mId << LL_ENDL;
1112
+ LL_DEBUGS (LOG_MESH ) << " mDecompositionRequests failed: " << req.mId << LL_ENDL;
1113
1113
}
1114
1114
}
1115
1115
}
@@ -1145,7 +1145,7 @@ void LLMeshRepoThread::run()
1145
1145
}
1146
1146
else
1147
1147
{
1148
- LL_DEBUGS () << " mPhysicsShapeRequests failed: " << req.mId << LL_ENDL;
1148
+ LL_DEBUGS (LOG_MESH ) << " mPhysicsShapeRequests failed: " << req.mId << LL_ENDL;
1149
1149
}
1150
1150
}
1151
1151
}
@@ -1206,6 +1206,25 @@ void LLMeshRepoThread::loadMeshLOD(const LLVolumeParams& mesh_params, S32 lod)
1206
1206
const LLUUID& mesh_id = mesh_params.getSculptID ();
1207
1207
LLMutexLock lock (mMutex );
1208
1208
LLMutexLock header_lock (mHeaderMutex );
1209
+ loadMeshLOD (mesh_id, mesh_params, lod);
1210
+ }
1211
+
1212
+ void LLMeshRepoThread::loadMeshLODs (const lod_list_t & list)
1213
+ { // could be called from any thread
1214
+ LLMutexLock lock (mMutex );
1215
+ LLMutexLock header_lock (mHeaderMutex );
1216
+ for (auto lod_pair : list)
1217
+ {
1218
+ const LLVolumeParams& mesh_params = lod_pair.first ;
1219
+ const LLUUID& mesh_id = mesh_params.getSculptID ();
1220
+ S32 lod = lod_pair.second ;
1221
+ loadMeshLOD (mesh_id, mesh_params, lod);
1222
+ }
1223
+ }
1224
+
1225
+ void LLMeshRepoThread::loadMeshLOD (const LLUUID& mesh_id, const LLVolumeParams& mesh_params, S32 lod)
1226
+ {
1227
+ // must be mutex locked by caller
1209
1228
mesh_header_map::iterator iter = mMeshHeader .find (mesh_id);
1210
1229
if (iter != mMeshHeader .end ())
1211
1230
{ // if we have the header, request LOD byte range
@@ -1222,50 +1241,25 @@ void LLMeshRepoThread::loadMeshLOD(const LLVolumeParams& mesh_params, S32 lod)
1222
1241
pending_lod_map::iterator pending = mPendingLOD .find (mesh_id);
1223
1242
1224
1243
if (pending != mPendingLOD .end ())
1225
- { // append this lod request to existing header request
1226
- pending->second .push_back (lod);
1227
- llassert (pending->second .size () <= LLModel::NUM_LODS);
1228
- }
1229
- else
1230
- { // if no header request is pending, fetch header
1231
- mHeaderReqQ .push (req);
1232
- mPendingLOD [mesh_id].push_back (lod);
1233
- }
1234
- }
1235
- }
1236
-
1237
- void LLMeshRepoThread::loadMeshLODs (const lod_list_t & list)
1238
- { // could be called from any thread
1239
- LLMutexLock lock (mMutex );
1240
- LLMutexLock header_lock (mHeaderMutex );
1241
- for (auto lod_pair : list)
1242
- {
1243
- const LLVolumeParams& mesh_params = lod_pair.first ;
1244
- const LLUUID& mesh_id = mesh_params.getSculptID ();
1245
- S32 lod = lod_pair.second ;
1246
- mesh_header_map::iterator iter = mMeshHeader .find (mesh_id);
1247
- if (iter != mMeshHeader .end ())
1248
- { // if we have the header, request LOD byte range
1249
- LODRequest req (mesh_params, lod);
1244
+ {
1245
+ // append this lod request to existing header request
1246
+ if (lod < LLModel::NUM_LODS && lod >= 0 )
1250
1247
{
1251
- mLODReqQ .push (req);
1252
- LLMeshRepository::sLODProcessing ++;
1248
+ pending->second [lod]++;
1253
1249
}
1250
+ else
1251
+ {
1252
+ LL_WARNS (LOG_MESH) << " Invalid LOD request: " << lod << " for mesh" << mesh_id << LL_ENDL;
1253
+ }
1254
+ llassert_msg (lod < LLModel::NUM_LODS, " Requested lod is out of bounds" );
1254
1255
}
1255
1256
else
1256
1257
{
1257
- HeaderRequest req (mesh_params);
1258
- pending_lod_map::iterator pending = mPendingLOD .find (mesh_id);
1259
- if (pending != mPendingLOD .end ())
1260
- { // append this lod request to existing header request
1261
- pending->second .push_back (lod);
1262
- llassert (pending->second .size () <= LLModel::NUM_LODS);
1263
- }
1264
- else
1265
- { // if no header request is pending, fetch header
1266
- mHeaderReqQ .push (req);
1267
- mPendingLOD [mesh_id].push_back (lod);
1268
- }
1258
+ // if no header request is pending, fetch header
1259
+ mHeaderReqQ .push (req);
1260
+ auto & array = mPendingLOD [mesh_id];
1261
+ std::fill (array.begin (), array.end (), 0 );
1262
+ array[lod]++;
1269
1263
}
1270
1264
}
1271
1265
}
@@ -2024,11 +2018,27 @@ EMeshProcessingResult LLMeshRepoThread::headerReceived(const LLVolumeParams& mes
2024
2018
pending_lod_map::iterator iter = mPendingLOD .find (mesh_id);
2025
2019
if (iter != mPendingLOD .end ())
2026
2020
{
2027
- for (U32 i = 0 ; i < iter->second .size (); ++i)
2021
+ for (S32 i = 0 ; i < iter->second .size (); ++i)
2028
2022
{
2029
- LODRequest req (mesh_params, iter->second [i]);
2030
- mLODReqQ .push (req);
2031
- LLMeshRepository::sLODProcessing ++;
2023
+ if (iter->second [i] > 1 )
2024
+ {
2025
+ // mLoadingMeshes should be protecting from dupplciates, but looks
2026
+ // like this is possible if object rezzes, unregisterMesh, then
2027
+ // rezzes again before first request completes.
2028
+ // mLoadingMeshes might need to change a bit to not rerequest if
2029
+ // mesh is already pending.
2030
+ //
2031
+ // Todo: Improve mLoadingMeshes and once done turn this into an assert.
2032
+ // Low priority since such situation should be relatively rare
2033
+ LL_INFOS (LOG_MESH) << " Multiple dupplicate requests for mesd ID: " << mesh_id << " LOD: " << i
2034
+ << LL_ENDL;
2035
+ }
2036
+ if (iter->second [i] > 0 )
2037
+ {
2038
+ LODRequest req (mesh_params, i);
2039
+ mLODReqQ .push (req);
2040
+ LLMeshRepository::sLODProcessing ++;
2041
+ }
2032
2042
}
2033
2043
mPendingLOD .erase (iter);
2034
2044
}
0 commit comments