From 9fdca96f8bd2211a99fe88e57b70cbecefa20b6d Mon Sep 17 00:00:00 2001 From: Ansariel Date: Mon, 8 Jul 2024 20:27:14 +0200 Subject: Re-enable compiler warnings C4244 and C4396 except for lltracerecording.h and llunittype.h for now --- indra/newview/llmeshrepository.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'indra/newview/llmeshrepository.cpp') diff --git a/indra/newview/llmeshrepository.cpp b/indra/newview/llmeshrepository.cpp index 01c922df16..cd75e1c313 100644 --- a/indra/newview/llmeshrepository.cpp +++ b/indra/newview/llmeshrepository.cpp @@ -1869,7 +1869,7 @@ EMeshProcessingResult LLMeshRepoThread::headerReceived(const LLVolumeParams& mes llssize dsize = data_size; char* result_ptr = strip_deprecated_header((char*)data, dsize, &header_size); - data_size = dsize; + data_size = (S32)dsize; boost::iostreams::stream stream(result_ptr, data_size); @@ -1910,8 +1910,8 @@ EMeshProcessingResult LLMeshRepoThread::headerReceived(const LLVolumeParams& mes { LLMutexLock lock(mHeaderMutex); - mMeshHeader[mesh_id] = { header_size, header }; - LLMeshRepository::sCacheBytesHeaders += header_size; + mMeshHeader[mesh_id] = { (U32)header_size, header }; + LLMeshRepository::sCacheBytesHeaders += (U32)header_size; } LLMutexLock lock(mMutex); // make sure only one thread access mPendingLOD at the same time. @@ -4763,7 +4763,7 @@ F32 LLMeshCostData::getRadiusBasedStreamingCost(F32 radius) F32 LLMeshCostData::getTriangleBasedStreamingCost() { - F32 result = ANIMATED_OBJECT_COST_PER_KTRI * 0.001 * getEstTrisForStreamingCost(); + F32 result = ANIMATED_OBJECT_COST_PER_KTRI * 0.001f * getEstTrisForStreamingCost(); return result; } @@ -5473,7 +5473,7 @@ void on_new_single_inventory_upload_complete( LL_INFOS() << "inventory_item_flags " << inventory_item_flags << LL_ENDL; } } - S32 creation_date_now = time_corrected(); + S32 creation_date_now = (S32)time_corrected(); LLPointer item = new LLViewerInventoryItem( server_response["new_inventory_item"].asUUID(), item_folder_id, -- cgit v1.2.3 From 7ebbc58ae310b5c41efb3fe1460d63663ab92004 Mon Sep 17 00:00:00 2001 From: Rye Mutt Date: Mon, 22 Jul 2024 08:29:35 -0400 Subject: Cache various frequently accessed settings (#2080) --- indra/newview/llmeshrepository.cpp | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) (limited to 'indra/newview/llmeshrepository.cpp') diff --git a/indra/newview/llmeshrepository.cpp b/indra/newview/llmeshrepository.cpp index cd75e1c313..c02a12e6b2 100644 --- a/indra/newview/llmeshrepository.cpp +++ b/indra/newview/llmeshrepository.cpp @@ -1685,9 +1685,7 @@ bool LLMeshRepoThread::fetchMeshHeader(const LLVolumeParams& mesh_params, bool c file.read(buffer, bytes); if (headerReceived(mesh_params, buffer, bytes) == MESH_OK) { - std::string mid; - mesh_params.getSculptID().toString(mid); - LL_DEBUGS(LOG_MESH) << "Mesh/Cache: Mesh header for ID " << mid << " - was retrieved from the cache." << LL_ENDL; + LL_DEBUGS(LOG_MESH) << "Mesh/Cache: Mesh header for ID " << mesh_params.getSculptID() << " - was retrieved from the cache." << LL_ENDL; // Found mesh in cache return true; @@ -1703,9 +1701,7 @@ bool LLMeshRepoThread::fetchMeshHeader(const LLVolumeParams& mesh_params, bool c if (!http_url.empty()) { - std::string mid; - mesh_params.getSculptID().toString(mid); - LL_DEBUGS(LOG_MESH) << "Mesh/Cache: Mesh header for ID " << mid << " - was retrieved from the simulator." << LL_ENDL; + LL_DEBUGS(LOG_MESH) << "Mesh/Cache: Mesh header for ID " << mesh_params.getSculptID() << " - was retrieved from the simulator." << LL_ENDL; //grab first 4KB if we're going to bother with a fetch. Cache will prevent future fetches if a full mesh fits //within the first 4KB @@ -1793,9 +1789,7 @@ bool LLMeshRepoThread::fetchMeshLOD(const LLVolumeParams& mesh_params, S32 lod, { delete[] buffer; - std::string mid; - mesh_id.toString(mid); - LL_DEBUGS(LOG_MESH) << "Mesh/Cache: Mesh body for ID " << mid << " - was retrieved from the cache." << LL_ENDL; + LL_DEBUGS(LOG_MESH) << "Mesh/Cache: Mesh body for ID " << mesh_id << " - was retrieved from the cache." << LL_ENDL; return true; } @@ -1810,9 +1804,7 @@ bool LLMeshRepoThread::fetchMeshLOD(const LLVolumeParams& mesh_params, S32 lod, if (!http_url.empty()) { - std::string mid; - mesh_id.toString(mid); - LL_DEBUGS(LOG_MESH) << "Mesh/Cache: Mesh body for ID " << mid << " - was retrieved from the simulator." << LL_ENDL; + LL_DEBUGS(LOG_MESH) << "Mesh/Cache: Mesh body for ID " << mesh_id << " - was retrieved from the simulator." << LL_ENDL; LLMeshHandlerBase::ptr_t handler(new LLMeshLODHandler(mesh_params, lod, offset, size)); LLCore::HttpHandle handle = getByteRange(http_url, offset, size, handler); @@ -4607,7 +4599,8 @@ F32 LLMeshRepository::getStreamingCostLegacy(LLMeshHeader& header, F32 radius, S *unscaled_value = weighted_avg; } - return weighted_avg/gSavedSettings.getU32("MeshTriangleBudget")*15000.f; + static LLCachedControl mesh_triangle_budget(gSavedSettings, "MeshTriangleBudget"); + return weighted_avg / mesh_triangle_budget * 15000.f; } LLMeshCostData::LLMeshCostData() @@ -4758,7 +4751,8 @@ F32 LLMeshCostData::getEstTrisForStreamingCost() F32 LLMeshCostData::getRadiusBasedStreamingCost(F32 radius) { - return getRadiusWeightedTris(radius)/gSavedSettings.getU32("MeshTriangleBudget")*15000.f; + static LLCachedControl mesh_triangle_budget(gSavedSettings, "MeshTriangleBudget"); + return getRadiusWeightedTris(radius)/mesh_triangle_budget*15000.f; } F32 LLMeshCostData::getTriangleBasedStreamingCost() @@ -5334,8 +5328,9 @@ bool LLMeshRepository::meshUploadEnabled() bool LLMeshRepository::meshRezEnabled() { + static LLCachedControl mesh_enabled(gSavedSettings, "MeshEnabled"); LLViewerRegion *region = gAgent.getRegion(); - if(gSavedSettings.getBOOL("MeshEnabled") && + if(mesh_enabled && region) { return region->meshRezEnabled(); -- cgit v1.2.3 From 4b543b618b101aca9dee1f224d8dbd4fbf937d71 Mon Sep 17 00:00:00 2001 From: Rye Mutt Date: Wed, 24 Jul 2024 15:05:08 -0400 Subject: Cache more frequently accessed settings --- indra/newview/llmeshrepository.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'indra/newview/llmeshrepository.cpp') diff --git a/indra/newview/llmeshrepository.cpp b/indra/newview/llmeshrepository.cpp index c02a12e6b2..1c64ed6822 100644 --- a/indra/newview/llmeshrepository.cpp +++ b/indra/newview/llmeshrepository.cpp @@ -3743,7 +3743,8 @@ void LLMeshRepository::notifyLoadedMeshes() ? (2 * LLAppCoreHttp::PIPELINING_DEPTH) : 5); - LLMeshRepoThread::sMaxConcurrentRequests = gSavedSettings.getU32("Mesh2MaxConcurrentRequests"); + static LLCachedControl mesh2_max_req(gSavedSettings, "Mesh2MaxConcurrentRequests"); + LLMeshRepoThread::sMaxConcurrentRequests = mesh2_max_req; LLMeshRepoThread::sRequestHighWater = llclamp(scale * S32(LLMeshRepoThread::sMaxConcurrentRequests), REQUEST2_HIGH_WATER_MIN, REQUEST2_HIGH_WATER_MAX); -- cgit v1.2.3 From c4ff0b48898de86b9ee8e198395e16a8429c8aa4 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Fri, 19 Jul 2024 20:17:37 +0300 Subject: viewer#2071 Properly handle 'out of memory' for meshes --- indra/newview/llmeshrepository.cpp | 60 ++++++++++++++++++++++++++++++++++---- 1 file changed, 54 insertions(+), 6 deletions(-) (limited to 'indra/newview/llmeshrepository.cpp') diff --git a/indra/newview/llmeshrepository.cpp b/indra/newview/llmeshrepository.cpp index 1c64ed6822..a1b2d502af 100644 --- a/indra/newview/llmeshrepository.cpp +++ b/indra/newview/llmeshrepository.cpp @@ -1360,7 +1360,19 @@ bool LLMeshRepoThread::fetchMeshSkinInfo(const LLUUID& mesh_id, bool can_retry) U8* buffer = new(std::nothrow) U8[size]; if (!buffer) { - LL_WARNS(LOG_MESH) << "Failed to allocate memory for skin info, size: " << size << LL_ENDL; + // Not sure what size is reasonable for skin info, + // but if 20MB allocation failed, we definetely have issues + const S32 MAX_SIZE = 20 * 1024 * 1024; //20MB + if (size < MAX_SIZE) + { + LLError::LLUserWarningMsg::showOutOfMemory(); + LL_ERRS() << "Bad memory allocation for skin info, size: " << size << LL_ENDL; + } + else + { + // Ignore failures for anomalously large data + LL_WARNS(LOG_MESH) << "Failed to allocate memory for skin info, size: " << size << LL_ENDL; + } return false; } LLMeshRepository::sCacheBytesRead += size; @@ -1473,7 +1485,19 @@ bool LLMeshRepoThread::fetchMeshDecomposition(const LLUUID& mesh_id) U8* buffer = new(std::nothrow) U8[size]; if (!buffer) { - LL_WARNS(LOG_MESH) << "Failed to allocate memory for mesh decomposition, size: " << size << LL_ENDL; + // Not sure what size is reasonable for decomposition + // but if 20MB allocation failed, we definetely have issues + const S32 MAX_SIZE = 20 * 1024 * 1024; //20MB + if (size < MAX_SIZE) + { + LLError::LLUserWarningMsg::showOutOfMemory(); + LL_ERRS() << "Failed to allocate memory for mesh decomposition, size: " << size << LL_ENDL; + } + else + { + // Ignore failures for anomalously large decompositiions + LL_WARNS(LOG_MESH) << "Failed to allocate memory for mesh decomposition, size: " << size << LL_ENDL; + } return false; } LLMeshRepository::sCacheBytesRead += size; @@ -1575,7 +1599,19 @@ bool LLMeshRepoThread::fetchMeshPhysicsShape(const LLUUID& mesh_id) U8* buffer = new(std::nothrow) U8[size]; if (!buffer) { - LL_WARNS(LOG_MESH) << "Failed to allocate memory for physics shape, size: " << size << LL_ENDL; + // Not sure what size is reasonable for physcis + // but if 20MB allocation failed, we definetely have issues + const S32 MAX_SIZE = 20 * 1024 * 1024; //20MB + if (size < MAX_SIZE) + { + LLError::LLUserWarningMsg::showOutOfMemory(); + LL_ERRS() << "Failed to allocate memory for mesh decomposition, size: " << size << LL_ENDL; + } + else + { + // Ignore failures for anomalously large meshes + LL_WARNS(LOG_MESH) << "Failed to allocate memory for mesh decomposition, size: " << size << LL_ENDL; + } return false; } file.read(buffer, size); @@ -1766,9 +1802,21 @@ bool LLMeshRepoThread::fetchMeshLOD(const LLVolumeParams& mesh_params, S32 lod, U8* buffer = new(std::nothrow) U8[size]; if (!buffer) { - LL_WARNS(LOG_MESH) << "Can't allocate memory for mesh " << mesh_id << " LOD " << lod << ", size: " << size << LL_ENDL; - // todo: for now it will result in indefinite constant retries, should result in timeout - // or in retry-count and disabling mesh. (but usually viewer is beyond saving at this point) + // Not sure what size is reasonable for a mesh, + // but if 20MB allocation failed, we definetely have issues + const S32 MAX_SIZE = 20 * 1024 * 1024; //20MB + if (size < MAX_SIZE) + { + LLError::LLUserWarningMsg::showOutOfMemory(); + LL_ERRS() << "Can't allocate memory for mesh " << mesh_id << " LOD " << lod << ", size: " << size << LL_ENDL; + } + else + { + // Ignore failures for anomalously large data + LL_WARNS(LOG_MESH) << "Can't allocate memory for mesh " << mesh_id << " LOD " << lod << ", size: " << size << LL_ENDL; + // todo: for now it will result in indefinite constant retries, should result in timeout + // or in retry-count and disabling mesh. (but usually viewer is beyond saving at this point) + } return false; } LLMeshRepository::sCacheBytesRead += size; -- cgit v1.2.3 From c5d2e92089344b115d657eb23487144cb3d9842a Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Mon, 29 Jul 2024 11:00:05 +0300 Subject: viewer#2071 Soft quit on 'out of memory' for meshes #2 --- indra/newview/llmeshrepository.cpp | 70 +++++++++++++++----------------------- 1 file changed, 28 insertions(+), 42 deletions(-) (limited to 'indra/newview/llmeshrepository.cpp') diff --git a/indra/newview/llmeshrepository.cpp b/indra/newview/llmeshrepository.cpp index a1b2d502af..4c5cc37766 100644 --- a/indra/newview/llmeshrepository.cpp +++ b/indra/newview/llmeshrepository.cpp @@ -1360,20 +1360,18 @@ bool LLMeshRepoThread::fetchMeshSkinInfo(const LLUUID& mesh_id, bool can_retry) U8* buffer = new(std::nothrow) U8[size]; if (!buffer) { + LL_WARNS(LOG_MESH) << "Failed to allocate memory for skin info, size: " << size << LL_ENDL; + // Not sure what size is reasonable for skin info, // but if 20MB allocation failed, we definetely have issues - const S32 MAX_SIZE = 20 * 1024 * 1024; //20MB + const S32 MAX_SIZE = 30 * 1024 * 1024; //30MB if (size < MAX_SIZE) { - LLError::LLUserWarningMsg::showOutOfMemory(); - LL_ERRS() << "Bad memory allocation for skin info, size: " << size << LL_ENDL; - } - else - { - // Ignore failures for anomalously large data - LL_WARNS(LOG_MESH) << "Failed to allocate memory for skin info, size: " << size << LL_ENDL; - } - return false; + LLAppViewer::instance()->outOfMemorySoftQuit(); + } // else ignore failures for anomalously large data + LLMutexLock locker(mMutex); + mSkinUnavailableQ.emplace_back(mesh_id); + return true; } LLMeshRepository::sCacheBytesRead += size; ++LLMeshRepository::sCacheReads; @@ -1485,20 +1483,16 @@ bool LLMeshRepoThread::fetchMeshDecomposition(const LLUUID& mesh_id) U8* buffer = new(std::nothrow) U8[size]; if (!buffer) { + LL_WARNS(LOG_MESH) << "Failed to allocate memory for mesh decomposition, size: " << size << LL_ENDL; + // Not sure what size is reasonable for decomposition // but if 20MB allocation failed, we definetely have issues - const S32 MAX_SIZE = 20 * 1024 * 1024; //20MB + const S32 MAX_SIZE = 30 * 1024 * 1024; //30MB if (size < MAX_SIZE) { - LLError::LLUserWarningMsg::showOutOfMemory(); - LL_ERRS() << "Failed to allocate memory for mesh decomposition, size: " << size << LL_ENDL; - } - else - { - // Ignore failures for anomalously large decompositiions - LL_WARNS(LOG_MESH) << "Failed to allocate memory for mesh decomposition, size: " << size << LL_ENDL; - } - return false; + LLAppViewer::instance()->outOfMemorySoftQuit(); + } // else ignore failures for anomalously large decompositiions + return true; } LLMeshRepository::sCacheBytesRead += size; ++LLMeshRepository::sCacheReads; @@ -1599,20 +1593,16 @@ bool LLMeshRepoThread::fetchMeshPhysicsShape(const LLUUID& mesh_id) U8* buffer = new(std::nothrow) U8[size]; if (!buffer) { + LL_WARNS(LOG_MESH) << "Failed to allocate memory for mesh decomposition, size: " << size << LL_ENDL; + // Not sure what size is reasonable for physcis // but if 20MB allocation failed, we definetely have issues - const S32 MAX_SIZE = 20 * 1024 * 1024; //20MB + const S32 MAX_SIZE = 30 * 1024 * 1024; //30MB if (size < MAX_SIZE) { - LLError::LLUserWarningMsg::showOutOfMemory(); - LL_ERRS() << "Failed to allocate memory for mesh decomposition, size: " << size << LL_ENDL; - } - else - { - // Ignore failures for anomalously large meshes - LL_WARNS(LOG_MESH) << "Failed to allocate memory for mesh decomposition, size: " << size << LL_ENDL; - } - return false; + LLAppViewer::instance()->outOfMemorySoftQuit(); + } // else ignore failures for anomalously large data + return true; } file.read(buffer, size); @@ -1802,22 +1792,18 @@ bool LLMeshRepoThread::fetchMeshLOD(const LLVolumeParams& mesh_params, S32 lod, U8* buffer = new(std::nothrow) U8[size]; if (!buffer) { + LL_WARNS(LOG_MESH) << "Can't allocate memory for mesh " << mesh_id << " LOD " << lod << ", size: " << size << LL_ENDL; + // Not sure what size is reasonable for a mesh, // but if 20MB allocation failed, we definetely have issues - const S32 MAX_SIZE = 20 * 1024 * 1024; //20MB + const S32 MAX_SIZE = 30 * 1024 * 1024; //30MB if (size < MAX_SIZE) { - LLError::LLUserWarningMsg::showOutOfMemory(); - LL_ERRS() << "Can't allocate memory for mesh " << mesh_id << " LOD " << lod << ", size: " << size << LL_ENDL; - } - else - { - // Ignore failures for anomalously large data - LL_WARNS(LOG_MESH) << "Can't allocate memory for mesh " << mesh_id << " LOD " << lod << ", size: " << size << LL_ENDL; - // todo: for now it will result in indefinite constant retries, should result in timeout - // or in retry-count and disabling mesh. (but usually viewer is beyond saving at this point) - } - return false; + LLAppViewer::instance()->outOfMemorySoftQuit(); + } // else ignore failures for anomalously large data + LLMutexLock lock(mMutex); + mUnavailableQ.push_back(LODRequest(mesh_params, lod)); + return true; } LLMeshRepository::sCacheBytesRead += size; ++LLMeshRepository::sCacheReads; -- cgit v1.2.3 From a37590b45220cc21f038e715527c35e2b74b5a15 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Fri, 2 Aug 2024 14:33:22 +0300 Subject: viewer#853 Fix upload losing face data. Multiple faces can share same mMaterial --- indra/newview/llmeshrepository.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'indra/newview/llmeshrepository.cpp') diff --git a/indra/newview/llmeshrepository.cpp b/indra/newview/llmeshrepository.cpp index 4c5cc37766..349df11f35 100644 --- a/indra/newview/llmeshrepository.cpp +++ b/indra/newview/llmeshrepository.cpp @@ -2363,10 +2363,11 @@ void LLMeshUploadThread::wholeModelToLLSD(LLSD& dest, bool include_textures) // We want to be able to allow more than 8 materials... // - S32 end = llmin((S32)instance.mMaterial.size(), instance.mModel->getNumVolumeFaces()) ; + S32 end = llmin((S32)data.mBaseModel->mMaterialList.size(), instance.mModel->getNumVolumeFaces()) ; for (S32 face_num = 0; face_num < end; face_num++) { + // multiple faces can reuse the same material LLImportMaterial& material = instance.mMaterial[data.mBaseModel->mMaterialList[face_num]]; LLSD face_entry = LLSD::emptyMap(); -- cgit v1.2.3 From d6190bbf13547800c56828d7670944f1a06af7dd Mon Sep 17 00:00:00 2001 From: Ansariel Hiller Date: Mon, 19 Aug 2024 08:39:35 +0200 Subject: Refactor LLFileSystem for and fix an old issue in LLFile (#2332) --- indra/newview/llmeshrepository.cpp | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'indra/newview/llmeshrepository.cpp') diff --git a/indra/newview/llmeshrepository.cpp b/indra/newview/llmeshrepository.cpp index 349df11f35..26e2d8f319 100644 --- a/indra/newview/llmeshrepository.cpp +++ b/indra/newview/llmeshrepository.cpp @@ -3292,8 +3292,6 @@ void LLMeshHeaderHandler::processData(LLCore::BufferArray * /* body */, S32 /* b // only allocate as much space in the cache as is needed for the local cache data_size = llmin(data_size, bytes); - // Fix asset caching - //LLFileSystem file(mesh_id, LLAssetType::AT_MESH, LLFileSystem::WRITE); LLFileSystem file(mesh_id, LLAssetType::AT_MESH, LLFileSystem::READ_WRITE); if (file.getMaxSize() >= bytes) { @@ -3302,7 +3300,6 @@ void LLMeshHeaderHandler::processData(LLCore::BufferArray * /* body */, S32 /* b file.write(data, data_size); - // Fix asset caching S32 remaining = bytes - file.tell(); if (remaining > 0) { @@ -3314,7 +3311,6 @@ void LLMeshHeaderHandler::processData(LLCore::BufferArray * /* body */, S32 /* b delete[] block; } } - // } } else @@ -3367,8 +3363,6 @@ void LLMeshLODHandler::processData(LLCore::BufferArray * /* body */, S32 /* body if (result == MESH_OK) { // good fetch from sim, write to cache - // Fix asset caching - //LLFileSystem file(mMeshParams.getSculptID(), LLAssetType::AT_MESH, LLFileSystem::WRITE); LLFileSystem file(mMeshParams.getSculptID(), LLAssetType::AT_MESH, LLFileSystem::READ_WRITE); S32 offset = mOffset; @@ -3432,8 +3426,6 @@ void LLMeshSkinInfoHandler::processData(LLCore::BufferArray * /* body */, S32 /* && gMeshRepo.mThread->skinInfoReceived(mMeshID, data, data_size)) { // good fetch from sim, write to cache - // Fix asset caching - //LLFileSystem file(mMeshID, LLAssetType::AT_MESH, LLFileSystem::WRITE); LLFileSystem file(mMeshID, LLAssetType::AT_MESH, LLFileSystem::READ_WRITE); S32 offset = mOffset; @@ -3483,8 +3475,6 @@ void LLMeshDecompositionHandler::processData(LLCore::BufferArray * /* body */, S && gMeshRepo.mThread->decompositionReceived(mMeshID, data, data_size)) { // good fetch from sim, write to cache - // Fix asset caching - //LLFileSystem file(mMeshID, LLAssetType::AT_MESH, LLFileSystem::WRITE); LLFileSystem file(mMeshID, LLAssetType::AT_MESH, LLFileSystem::READ_WRITE); S32 offset = mOffset; @@ -3532,8 +3522,6 @@ void LLMeshPhysicsShapeHandler::processData(LLCore::BufferArray * /* body */, S3 && gMeshRepo.mThread->physicsShapeReceived(mMeshID, data, data_size) == MESH_OK) { // good fetch from sim, write to cache for caching - // Fix asset caching - //LLFileSystem file(mMeshID, LLAssetType::AT_MESH, LLFileSystem::WRITE); LLFileSystem file(mMeshID, LLAssetType::AT_MESH, LLFileSystem::READ_WRITE); S32 offset = mOffset; -- cgit v1.2.3