Skip to content

Commit 40d7644

Browse files
committed
viewer#3070 Make lod and skin request share priorities
skins are needed to decloud avatars as much as lods
1 parent 7bdd2b5 commit 40d7644

File tree

2 files changed

+165
-74
lines changed

2 files changed

+165
-74
lines changed

indra/newview/llmeshrepository.cpp

Lines changed: 90 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -925,7 +925,7 @@ void LLMeshRepoThread::run()
925925
}
926926
sRequestWaterLevel = static_cast<S32>(mHttpRequestSet.size()); // Stats data update
927927

928-
// NOTE: order of queue processing intentionally favors LOD requests over header requests
928+
// NOTE: order of queue processing intentionally favors LOD and Skin requests over header requests
929929
// Todo: we are processing mLODReqQ, mHeaderReqQ, mSkinRequests, mDecompositionRequests and mPhysicsShapeRequests
930930
// in relatively similar manners, remake code to simplify/unify the process,
931931
// like processRequests(&requestQ, fetchFunction); which does same thing for each element
@@ -979,6 +979,50 @@ void LLMeshRepoThread::run()
979979
}
980980
}
981981

982+
if (mHttpRequestSet.size() < sRequestHighWater
983+
&& !mSkinRequests.empty())
984+
{
985+
if (!mSkinRequests.empty())
986+
{
987+
std::list<UUIDBasedRequest> incomplete;
988+
while (!mSkinRequests.empty() && mHttpRequestSet.size() < sRequestHighWater)
989+
{
990+
991+
mMutex->lock();
992+
auto req = mSkinRequests.front();
993+
mSkinRequests.pop_front();
994+
mMutex->unlock();
995+
if (req.isDelayed())
996+
{
997+
incomplete.emplace_back(req);
998+
}
999+
else if (!fetchMeshSkinInfo(req.mId, req.canRetry()))
1000+
{
1001+
if (req.canRetry())
1002+
{
1003+
req.updateTime();
1004+
incomplete.emplace_back(req);
1005+
}
1006+
else
1007+
{
1008+
LLMutexLock locker(mMutex);
1009+
mSkinUnavailableQ.push_back(req);
1010+
LL_DEBUGS() << "mSkinReqQ failed: " << req.mId << LL_ENDL;
1011+
}
1012+
}
1013+
}
1014+
1015+
if (!incomplete.empty())
1016+
{
1017+
LLMutexLock locker(mMutex);
1018+
for (const auto& req : incomplete)
1019+
{
1020+
mSkinRequests.push_back(req);
1021+
}
1022+
}
1023+
}
1024+
}
1025+
9821026
if (!mHeaderReqQ.empty() && mHttpRequestSet.size() < sRequestHighWater)
9831027
{
9841028
std::list<HeaderRequest> incomplete;
@@ -1028,54 +1072,13 @@ void LLMeshRepoThread::run()
10281072
// performing long-duration actions.
10291073

10301074
if (mHttpRequestSet.size() < sRequestHighWater
1031-
&& (!mSkinRequests.empty()
1032-
|| !mDecompositionRequests.empty()
1075+
&& (!mDecompositionRequests.empty()
10331076
|| !mPhysicsShapeRequests.empty()))
10341077
{
10351078
// Something to do probably, lock and double-check. We don't want
10361079
// to hold the lock long here. That will stall main thread activities
10371080
// so we bounce it.
10381081

1039-
if (!mSkinRequests.empty())
1040-
{
1041-
std::list<UUIDBasedRequest> incomplete;
1042-
while (!mSkinRequests.empty() && mHttpRequestSet.size() < sRequestHighWater)
1043-
{
1044-
1045-
mMutex->lock();
1046-
auto req = mSkinRequests.front();
1047-
mSkinRequests.pop_front();
1048-
mMutex->unlock();
1049-
if (req.isDelayed())
1050-
{
1051-
incomplete.emplace_back(req);
1052-
}
1053-
else if (!fetchMeshSkinInfo(req.mId, req.canRetry()))
1054-
{
1055-
if (req.canRetry())
1056-
{
1057-
req.updateTime();
1058-
incomplete.emplace_back(req);
1059-
}
1060-
else
1061-
{
1062-
LLMutexLock locker(mMutex);
1063-
mSkinUnavailableQ.push_back(req);
1064-
LL_DEBUGS() << "mSkinReqQ failed: " << req.mId << LL_ENDL;
1065-
}
1066-
}
1067-
}
1068-
1069-
if (!incomplete.empty())
1070-
{
1071-
LLMutexLock locker(mMutex);
1072-
for (const auto& req : incomplete)
1073-
{
1074-
mSkinRequests.push_back(req);
1075-
}
1076-
}
1077-
}
1078-
10791082
// holding lock, try next list
10801083
// *TODO: For UI/debug-oriented lists, we might drop the fine-
10811084
// grained locking as there's a lowered expectation of smoothness
@@ -1195,7 +1198,6 @@ void LLMeshRepoThread::lockAndLoadMeshLOD(const LLVolumeParams& mesh_params, S32
11951198
}
11961199
}
11971200

1198-
11991201
void LLMeshRepoThread::loadMeshLOD(const LLVolumeParams& mesh_params, S32 lod)
12001202
{ //could be called from any thread
12011203
const LLUUID& mesh_id = mesh_params.getSculptID();
@@ -3781,7 +3783,7 @@ S32 LLMeshRepository::loadMesh(LLVOVolume* vobj, const LLVolumeParams& mesh_para
37813783
{
37823784
//first request for this mesh
37833785
mLoadingMeshes[detail][mesh_id].push_back(vobj);
3784-
mPendingRequests.push_back(LLMeshRepoThread::LODRequest(mesh_params, detail));
3786+
mPendingRequests.push_back(PendingRequestLOD(mesh_params, detail));
37853787
LLMeshRepository::sLODPending++;
37863788
}
37873789
}
@@ -4054,35 +4056,64 @@ void LLMeshRepository::notifyLoadedMeshes()
40544056
score_map[iter->first] = max_score;
40554057
}
40564058
}
4059+
for (mesh_load_map::iterator iter = mLoadingSkins.begin(); iter != mLoadingSkins.end(); ++iter)
4060+
{
4061+
F32 max_score = 0.f;
4062+
for (auto obj_iter = iter->second.begin(); obj_iter != iter->second.end(); ++obj_iter)
4063+
{
4064+
LLVOVolume* object = *obj_iter;
4065+
if (object)
4066+
{
4067+
LLDrawable* drawable = object->mDrawable;
4068+
if (drawable)
4069+
{
4070+
F32 cur_score = drawable->getRadius() / llmax(drawable->mDistanceWRTCamera, 1.f);
4071+
max_score = llmax(max_score, cur_score);
4072+
}
4073+
}
4074+
}
4075+
4076+
score_map[iter->first] = max_score;
4077+
}
40574078

40584079
//set "score" for pending requests
4059-
for (std::vector<LLMeshRepoThread::LODRequest>::iterator iter = mPendingRequests.begin(); iter != mPendingRequests.end(); ++iter)
4080+
for (std::vector<PendingRequestBase>::iterator iter = mPendingRequests.begin(); iter != mPendingRequests.end(); ++iter)
40604081
{
4061-
iter->mScore = score_map[iter->mMeshParams.getSculptID()];
4082+
iter->setScore(score_map[iter->getId()]);
40624083
}
40634084

40644085
//sort by "score"
40654086
std::partial_sort(mPendingRequests.begin(), mPendingRequests.begin() + push_count,
4066-
mPendingRequests.end(), LLMeshRepoThread::CompareScoreGreater());
4087+
mPendingRequests.end(), PendingRequestBase::CompareScoreGreater());
40674088
}
40684089

40694090
while (!mPendingRequests.empty() && push_count > 0)
40704091
{
4071-
LLMeshRepoThread::LODRequest& request = mPendingRequests.front();
4072-
mThread->loadMeshLOD(request.mMeshParams, request.mLOD);
4092+
PendingRequestBase& request = mPendingRequests.front();
4093+
switch (request.getRequestType())
4094+
{
4095+
case MESH_REQUEST_LOD:
4096+
{
4097+
PendingRequestLOD& lod = (PendingRequestLOD&)request;
4098+
mThread->loadMeshLOD(lod.mMeshParams, lod.mLOD);
4099+
LLMeshRepository::sLODPending--;
4100+
break;
4101+
}
4102+
case MESH_REQUEST_SKIN:
4103+
{
4104+
PendingRequestUUID& skin = (PendingRequestUUID&)request;
4105+
mThread->loadMeshSkinInfo(skin.getId());
4106+
break;
4107+
}
4108+
4109+
default:
4110+
break;
4111+
}
40734112
mPendingRequests.erase(mPendingRequests.begin());
4074-
LLMeshRepository::sLODPending--;
40754113
push_count--;
40764114
}
40774115
}
40784116

4079-
//send skin info requests
4080-
while (!mPendingSkinRequests.empty())
4081-
{
4082-
mThread->loadMeshSkinInfo(mPendingSkinRequests.front());
4083-
mPendingSkinRequests.pop();
4084-
}
4085-
40864117
//send decomposition requests
40874118
while (!mPendingDecompositionRequests.empty())
40884119
{
@@ -4274,7 +4305,7 @@ const LLMeshSkinInfo* LLMeshRepository::getSkinInfo(const LLUUID& mesh_id, LLVOV
42744305
{
42754306
//first request for this mesh
42764307
mLoadingSkins[mesh_id].push_back(requesting_obj);
4277-
mPendingSkinRequests.push(mesh_id);
4308+
mPendingRequests.push_back(PendingRequestUUID(mesh_id, MESH_REQUEST_SKIN));
42784309
}
42794310
}
42804311
}

indra/newview/llmeshrepository.h

Lines changed: 75 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,16 @@ typedef enum e_mesh_processing_result_enum
6363
MESH_UNKNOWN
6464
} EMeshProcessingResult;
6565

66+
typedef enum e_mesh_request_type_enum
67+
{
68+
MESH_REQUEST_HEADER,
69+
MESH_REQUEST_LOD,
70+
MESH_REQUEST_SKIN,
71+
MESH_REQUEST_DECOMPOSITION,
72+
MESH_REQUEST_PHYSICS,
73+
MESH_REQUEST_UKNOWN
74+
} EMeshRequestType;
75+
6676
class LLMeshUploadData
6777
{
6878
public:
@@ -183,7 +193,8 @@ class LLPhysicsDecomp : public LLThread
183193
class RequestStats
184194
{
185195
public:
186-
RequestStats() : mRetries(0) {};
196+
197+
RequestStats() :mRetries(0) {};
187198

188199
void updateTime();
189200
bool canRetry() const;
@@ -195,6 +206,67 @@ class RequestStats
195206
LLFrameTimer mTimer;
196207
};
197208

209+
210+
class PendingRequestBase
211+
{
212+
public:
213+
struct CompareScoreGreater
214+
{
215+
bool operator()(const PendingRequestBase& lhs, const PendingRequestBase& rhs)
216+
{
217+
return lhs.mScore > rhs.mScore; // greatest = first
218+
}
219+
};
220+
221+
PendingRequestBase() : mScore(0.f) {};
222+
virtual ~PendingRequestBase() {}
223+
224+
bool operator<(const PendingRequestBase& rhs) const
225+
{
226+
return mId < rhs.mId;
227+
}
228+
229+
void setScore(F32 score) { mScore = score; }
230+
F32 getScore() const { return mScore; }
231+
LLUUID getId() const { return mId; }
232+
virtual EMeshRequestType getRequestType() const { return MESH_REQUEST_UKNOWN; }
233+
234+
protected:
235+
F32 mScore;
236+
LLUUID mId;
237+
};
238+
239+
class PendingRequestLOD : public PendingRequestBase
240+
{
241+
public:
242+
LLVolumeParams mMeshParams;
243+
S32 mLOD;
244+
245+
PendingRequestLOD(const LLVolumeParams& mesh_params, S32 lod)
246+
: PendingRequestBase(), mMeshParams(mesh_params), mLOD(lod)
247+
{
248+
mId = mMeshParams.getSculptID();
249+
}
250+
251+
EMeshRequestType getRequestType() const override { return MESH_REQUEST_LOD; }
252+
};
253+
254+
class PendingRequestUUID : public PendingRequestBase
255+
{
256+
public:
257+
258+
PendingRequestUUID(const LLUUID& id, EMeshRequestType type)
259+
: PendingRequestBase(), mRequestType(type)
260+
{
261+
mId = id;
262+
}
263+
264+
EMeshRequestType getRequestType() const override { return mRequestType; }
265+
266+
private:
267+
EMeshRequestType mRequestType;
268+
};
269+
198270
class LLMeshHeader
199271
{
200272
public:
@@ -292,22 +364,13 @@ class LLMeshRepoThread : public LLThread
292364
public:
293365
LLVolumeParams mMeshParams;
294366
S32 mLOD;
295-
F32 mScore;
296367

297368
LODRequest(const LLVolumeParams& mesh_params, S32 lod)
298-
: RequestStats(), mMeshParams(mesh_params), mLOD(lod), mScore(0.f)
369+
: RequestStats(), mMeshParams(mesh_params), mLOD(lod)
299370
{
300371
}
301372
};
302373

303-
struct CompareScoreGreater
304-
{
305-
bool operator()(const LODRequest& lhs, const LODRequest& rhs)
306-
{
307-
return lhs.mScore > rhs.mScore; // greatest = first
308-
}
309-
};
310-
311374
class UUIDBasedRequest : public RequestStats
312375
{
313376
public:
@@ -697,15 +760,12 @@ class LLMeshRepository
697760

698761
LLMutex* mMeshMutex;
699762

700-
std::vector<LLMeshRepoThread::LODRequest> mPendingRequests;
763+
std::vector<PendingRequestBase> mPendingRequests;
701764

702765
//list of mesh ids awaiting skin info
703766
typedef boost::unordered_map<LLUUID, std::vector<LLVOVolume*> > skin_load_map;
704767
skin_load_map mLoadingSkins;
705768

706-
//list of mesh ids that need to send skin info fetch requests
707-
std::queue<LLUUID> mPendingSkinRequests;
708-
709769
//list of mesh ids awaiting decompositions
710770
std::unordered_set<LLUUID> mLoadingDecompositions;
711771

0 commit comments

Comments
 (0)