diff options
author | Andrey Lihatskiy <alihatskiy@productengine.com> | 2025-05-28 22:48:17 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-05-28 22:48:17 +0300 |
commit | 91adb11d10fe0c18790be64fa7a6ce5b0bbdcb09 (patch) | |
tree | 3e5294e3b8ff07778e6134ed9dd41458386032ac /indra/newview/llmeshrepository.h | |
parent | b9ab6c3644da02bed6941dc8df433fb1c626f8c7 (diff) | |
parent | b08ba3fa7bc9e6309891e510fbfb5c4e2b5c922e (diff) |
Merge pull request #4183 from secondlife/marchcat/2505-merge
Marchcat/2505 merge
Diffstat (limited to 'indra/newview/llmeshrepository.h')
-rw-r--r-- | indra/newview/llmeshrepository.h | 71 |
1 files changed, 62 insertions, 9 deletions
diff --git a/indra/newview/llmeshrepository.h b/indra/newview/llmeshrepository.h index 2ac90f7b10..0c3a3559c2 100644 --- a/indra/newview/llmeshrepository.h +++ b/indra/newview/llmeshrepository.h @@ -168,7 +168,6 @@ public: void submitRequest(Request* request); static S32 llcdCallback(const char*, S32, S32); - void cancel(); void setMeshData(LLCDMeshData& mesh, bool vertex_based); void doDecomposition(); @@ -206,19 +205,19 @@ private: LLFrameTimer mTimer; }; - +class MeshLoadData; class PendingRequestBase { public: struct CompareScoreGreater { - bool operator()(const std::unique_ptr<PendingRequestBase>& lhs, const std::unique_ptr<PendingRequestBase>& rhs) + bool operator()(const std::shared_ptr<PendingRequestBase>& lhs, const std::shared_ptr<PendingRequestBase>& rhs) { return lhs->mScore > rhs->mScore; // greatest = first } }; - PendingRequestBase() : mScore(0.f) {}; + PendingRequestBase() : mScore(0.f), mTrackedData(nullptr), mScoreDirty(true) {}; virtual ~PendingRequestBase() {} bool operator<(const PendingRequestBase& rhs) const @@ -226,14 +225,34 @@ public: return mId < rhs.mId; } - void setScore(F32 score) { mScore = score; } F32 getScore() const { return mScore; } + void checkScore() + { + constexpr F32 EXPIRE_TIME_SECS = 8.f; + if (mScoreTimer.getElapsedTimeF32() > EXPIRE_TIME_SECS || mScoreDirty) + { + updateScore(); + mScoreDirty = false; + mScoreTimer.reset(); + } + }; + LLUUID getId() const { return mId; } virtual EMeshRequestType getRequestType() const = 0; + void trackData(MeshLoadData* data) { mTrackedData = data; mScoreDirty = true; } + void untrackData() { mTrackedData = nullptr; } + bool hasTrackedData() { return mTrackedData != nullptr; } + void setScoreDirty() { mScoreDirty = true; } + protected: - F32 mScore; + void updateScore(); + LLUUID mId; + F32 mScore; + bool mScoreDirty; + LLTimer mScoreTimer; + MeshLoadData* mTrackedData; }; class PendingRequestLOD : public PendingRequestBase @@ -267,6 +286,37 @@ private: EMeshRequestType mRequestType; }; + +class MeshLoadData +{ +public: + MeshLoadData() {} + ~MeshLoadData() + { + if (std::shared_ptr<PendingRequestBase> request = mRequest.lock()) + { + request->untrackData(); + } + } + void initData(LLVOVolume* vol, std::shared_ptr<PendingRequestBase>& request) + { + mVolumes.push_back(vol); + request->trackData(this); + mRequest = request; + } + void addVolume(LLVOVolume* vol) + { + mVolumes.push_back(vol); + if (std::shared_ptr<PendingRequestBase> request = mRequest.lock()) + { + request->setScoreDirty(); + } + } + std::vector<LLVOVolume*> mVolumes; +private: + std::weak_ptr<PendingRequestBase> mRequest; +}; + class LLMeshHeader { public: @@ -515,6 +565,8 @@ public: ~LLMeshRepoThread(); virtual void run(); + void cleanup(); + bool isShuttingDown() { return mShuttingDown; } void lockAndLoadMeshLOD(const LLVolumeParams& mesh_params, S32 lod); void loadMeshLOD(const LLVolumeParams& mesh_params, S32 lod); @@ -583,6 +635,7 @@ private: U8* getDiskCacheBuffer(S32 size); S32 mDiskCacheBufferSize = 0; U8* mDiskCacheBuffer = nullptr; + bool mShuttingDown = false; }; @@ -817,7 +870,7 @@ public: static void metricsProgress(unsigned int count); static void metricsUpdate(); - typedef std::unordered_map<LLUUID, std::vector<LLVOVolume*> > mesh_load_map; + typedef std::unordered_map<LLUUID, MeshLoadData> mesh_load_map; mesh_load_map mLoadingMeshes[4]; typedef std::unordered_map<LLUUID, LLPointer<LLMeshSkinInfo>> skin_map; @@ -828,11 +881,11 @@ public: LLMutex* mMeshMutex; - typedef std::vector <std::unique_ptr<PendingRequestBase> > pending_requests_vec; + typedef std::vector <std::shared_ptr<PendingRequestBase> > pending_requests_vec; pending_requests_vec mPendingRequests; //list of mesh ids awaiting skin info - typedef std::unordered_map<LLUUID, std::vector<LLVOVolume*> > skin_load_map; + typedef std::unordered_map<LLUUID, MeshLoadData > skin_load_map; skin_load_map mLoadingSkins; //list of mesh ids awaiting decompositions |