summaryrefslogtreecommitdiff
path: root/indra/newview/llmeshrepository.cpp
diff options
context:
space:
mode:
authorDave Houlton <euclid@lindenlab.com>2021-12-15 14:37:18 -0700
committerDave Houlton <euclid@lindenlab.com>2021-12-15 14:37:18 -0700
commitcf35d27dfb86a8a8d8223bc344f35984efaa7b98 (patch)
tree883758ee1282e0936343ec27d80d25329aae9242 /indra/newview/llmeshrepository.cpp
parent199775b7ac214cfc3492c343c3f6046effcde7ed (diff)
parent0a873cd95547f003878c6d00d0883ff792f4a865 (diff)
DRTVWR-546 merge up to 6.5.2
Diffstat (limited to 'indra/newview/llmeshrepository.cpp')
-rw-r--r--indra/newview/llmeshrepository.cpp109
1 files changed, 67 insertions, 42 deletions
diff --git a/indra/newview/llmeshrepository.cpp b/indra/newview/llmeshrepository.cpp
index c5a3ff44b3..61418ba547 100644
--- a/indra/newview/llmeshrepository.cpp
+++ b/indra/newview/llmeshrepository.cpp
@@ -49,7 +49,7 @@
#include "llsdutil_math.h"
#include "llsdserialize.h"
#include "llthread.h"
-#include "llvfile.h"
+#include "llfilesystem.h"
#include "llviewercontrol.h"
#include "llviewerinventory.h"
#include "llviewermenufile.h"
@@ -294,8 +294,6 @@
// * Header parse failures come without much explanation. Elaborate.
// * Work queue for uploads? Any need for this or is the current scheme good
// enough?
-// * Various temp buffers used in VFS I/O might be allocated once or even
-// statically. Look for some wins here.
// * Move data structures holding mesh data used by main thread into main-
// thread-only access so that no locking is needed. May require duplication
// of some data so that worker thread has a minimal data set to guide
@@ -1336,8 +1334,8 @@ bool LLMeshRepoThread::fetchMeshSkinInfo(const LLUUID& mesh_id)
if (version <= MAX_MESH_VERSION && offset >= 0 && size > 0)
{
- //check VFS for mesh skin info
- LLVFile file(gVFS, mesh_id, LLAssetType::AT_MESH);
+ //check cache for mesh skin info
+ LLFileSystem file(mesh_id, LLAssetType::AT_MESH);
if (file.getSize() >= offset+size)
{
U8* buffer = new(std::nothrow) U8[size];
@@ -1370,7 +1368,7 @@ bool LLMeshRepoThread::fetchMeshSkinInfo(const LLUUID& mesh_id)
delete[] buffer;
}
- //reading from VFS failed for whatever reason, fetch from sim
+ //reading from cache failed for whatever reason, fetch from sim
std::string http_url;
constructUrl(mesh_id, &http_url);
@@ -1432,8 +1430,8 @@ bool LLMeshRepoThread::fetchMeshDecomposition(const LLUUID& mesh_id)
if (version <= MAX_MESH_VERSION && offset >= 0 && size > 0)
{
- //check VFS for mesh skin info
- LLVFile file(gVFS, mesh_id, LLAssetType::AT_MESH);
+ //check cache for mesh skin info
+ LLFileSystem file(mesh_id, LLAssetType::AT_MESH);
if (file.getSize() >= offset+size)
{
U8* buffer = new(std::nothrow) U8[size];
@@ -1467,7 +1465,7 @@ bool LLMeshRepoThread::fetchMeshDecomposition(const LLUUID& mesh_id)
delete[] buffer;
}
- //reading from VFS failed for whatever reason, fetch from sim
+ //reading from cache failed for whatever reason, fetch from sim
std::string http_url;
constructUrl(mesh_id, &http_url);
@@ -1529,8 +1527,8 @@ bool LLMeshRepoThread::fetchMeshPhysicsShape(const LLUUID& mesh_id)
if (version <= MAX_MESH_VERSION && offset >= 0 && size > 0)
{
- //check VFS for mesh physics shape info
- LLVFile file(gVFS, mesh_id, LLAssetType::AT_MESH);
+ //check cache for mesh physics shape info
+ LLFileSystem file(mesh_id, LLAssetType::AT_MESH);
if (file.getSize() >= offset+size)
{
LLMeshRepository::sCacheBytesRead += size;
@@ -1563,7 +1561,7 @@ bool LLMeshRepoThread::fetchMeshPhysicsShape(const LLUUID& mesh_id)
delete[] buffer;
}
- //reading from VFS failed for whatever reason, fetch from sim
+ //reading from cache failed for whatever reason, fetch from sim
std::string http_url;
constructUrl(mesh_id, &http_url);
@@ -1634,8 +1632,8 @@ bool LLMeshRepoThread::fetchMeshHeader(const LLVolumeParams& mesh_params, bool c
++LLMeshRepository::sMeshRequestCount;
{
- //look for mesh in asset in vfs
- LLVFile file(gVFS, mesh_params.getSculptID(), LLAssetType::AT_MESH);
+ //look for mesh in asset in cache
+ LLFileSystem file(mesh_params.getSculptID(), LLAssetType::AT_MESH);
S32 size = file.getSize();
@@ -1649,7 +1647,11 @@ bool LLMeshRepoThread::fetchMeshHeader(const LLVolumeParams& mesh_params, bool c
file.read(buffer, bytes);
if (headerReceived(mesh_params, buffer, bytes) == MESH_OK)
{
- // Found mesh in VFS cache
+ 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;
+
+ // Found mesh in cache
return true;
}
}
@@ -1660,8 +1662,13 @@ bool LLMeshRepoThread::fetchMeshHeader(const LLVolumeParams& mesh_params, bool c
std::string http_url;
constructUrl(mesh_params.getSculptID(), &http_url);
+
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;
+
//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
//NOTE -- this will break of headers ever exceed 4KB
@@ -1713,8 +1720,8 @@ bool LLMeshRepoThread::fetchMeshLOD(const LLVolumeParams& mesh_params, S32 lod,
if (version <= MAX_MESH_VERSION && offset >= 0 && size > 0)
{
- //check VFS for mesh asset
- LLVFile file(gVFS, mesh_id, LLAssetType::AT_MESH);
+ //check cache for mesh asset
+ LLFileSystem file(mesh_id, LLAssetType::AT_MESH);
if (file.getSize() >= offset+size)
{
U8* buffer = new(std::nothrow) U8[size];
@@ -1742,6 +1749,11 @@ bool LLMeshRepoThread::fetchMeshLOD(const LLVolumeParams& mesh_params, S32 lod,
if (lodReceived(mesh_params, lod, buffer, size) == MESH_OK)
{
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;
+
return true;
}
}
@@ -1749,12 +1761,16 @@ bool LLMeshRepoThread::fetchMeshLOD(const LLVolumeParams& mesh_params, S32 lod,
delete[] buffer;
}
- //reading from VFS failed for whatever reason, fetch from sim
+ //reading from cache failed for whatever reason, fetch from sim
std::string http_url;
constructUrl(mesh_id, &http_url);
-
+
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;
+
LLMeshHandlerBase::ptr_t handler(new LLMeshLODHandler(mesh_params, lod, offset, size));
LLCore::HttpHandle handle = getByteRange(http_url, offset, size, handler);
if (LLCORE_HTTP_HANDLE_INVALID == handle)
@@ -3208,7 +3224,7 @@ void LLMeshHeaderHandler::processData(LLCore::BufferArray * /* body */, S32 /* b
}
else if (data && data_size > 0)
{
- // header was successfully retrieved from sim and parsed, cache in vfs
+ // header was successfully retrieved from sim and parsed and is in cache
S32 header_bytes = 0;
LLSD header;
@@ -3247,31 +3263,32 @@ void LLMeshHeaderHandler::processData(LLCore::BufferArray * /* body */, S32 /* b
// It's possible for the remote asset to have more data than is needed for the local cache
- // only allocate as much space in the VFS as is needed for the local cache
+ // only allocate as much space in the cache as is needed for the local cache
data_size = llmin(data_size, bytes);
- LLVFile file(gVFS, mesh_id, LLAssetType::AT_MESH, LLVFile::WRITE);
- if (file.getMaxSize() >= bytes || file.setMaxSize(bytes))
+ // <FS:Ansariel> 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)
{
LLMeshRepository::sCacheBytesWritten += data_size;
++LLMeshRepository::sCacheWrites;
file.write(data, data_size);
-
- // zero out the rest of the file
- U8 block[MESH_HEADER_SIZE];
- memset(block, 0, sizeof(block));
- while (bytes-file.tell() > sizeof(block))
- {
- file.write(block, sizeof(block));
- }
-
- S32 remaining = bytes-file.tell();
+ // <FS:Ansariel> Fix asset caching
+ S32 remaining = bytes - file.tell();
if (remaining > 0)
{
- file.write(block, remaining);
+ U8* block = new(std::nothrow) U8[remaining];
+ if (block)
+ {
+ memset(block, 0, remaining);
+ file.write(block, remaining);
+ delete[] block;
+ }
}
+ // </FS:Ansariel>
}
}
else
@@ -3323,8 +3340,10 @@ void LLMeshLODHandler::processData(LLCore::BufferArray * /* body */, S32 /* body
EMeshProcessingResult result = gMeshRepo.mThread->lodReceived(mMeshParams, mLOD, data, data_size);
if (result == MESH_OK)
{
- // good fetch from sim, write to VFS for caching
- LLVFile file(gVFS, mMeshParams.getSculptID(), LLAssetType::AT_MESH, LLVFile::WRITE);
+ // good fetch from sim, write to cache
+ // <FS:Ansariel> 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;
S32 size = mRequestedBytes;
@@ -3387,8 +3406,10 @@ void LLMeshSkinInfoHandler::processData(LLCore::BufferArray * /* body */, S32 /*
&& ((data != NULL) == (data_size > 0)) // if we have data but no size or have size but no data, something is wrong
&& gMeshRepo.mThread->skinInfoReceived(mMeshID, data, data_size))
{
- // good fetch from sim, write to VFS for caching
- LLVFile file(gVFS, mMeshID, LLAssetType::AT_MESH, LLVFile::WRITE);
+ // good fetch from sim, write to cache
+ // <FS:Ansariel> Fix asset caching
+ //LLFileSystem file(mMeshID, LLAssetType::AT_MESH, LLFileSystem::WRITE);
+ LLFileSystem file(mMeshID, LLAssetType::AT_MESH, LLFileSystem::READ_WRITE);
S32 offset = mOffset;
S32 size = mRequestedBytes;
@@ -3435,8 +3456,10 @@ void LLMeshDecompositionHandler::processData(LLCore::BufferArray * /* body */, S
&& ((data != NULL) == (data_size > 0)) // if we have data but no size or have size but no data, something is wrong
&& gMeshRepo.mThread->decompositionReceived(mMeshID, data, data_size))
{
- // good fetch from sim, write to VFS for caching
- LLVFile file(gVFS, mMeshID, LLAssetType::AT_MESH, LLVFile::WRITE);
+ // good fetch from sim, write to cache
+ // <FS:Ansariel> Fix asset caching
+ //LLFileSystem file(mMeshID, LLAssetType::AT_MESH, LLFileSystem::WRITE);
+ LLFileSystem file(mMeshID, LLAssetType::AT_MESH, LLFileSystem::READ_WRITE);
S32 offset = mOffset;
S32 size = mRequestedBytes;
@@ -3482,8 +3505,10 @@ void LLMeshPhysicsShapeHandler::processData(LLCore::BufferArray * /* body */, S3
&& ((data != NULL) == (data_size > 0)) // if we have data but no size or have size but no data, something is wrong
&& gMeshRepo.mThread->physicsShapeReceived(mMeshID, data, data_size) == MESH_OK)
{
- // good fetch from sim, write to VFS for caching
- LLVFile file(gVFS, mMeshID, LLAssetType::AT_MESH, LLVFile::WRITE);
+ // good fetch from sim, write to cache for caching
+ // <FS:Ansariel> Fix asset caching
+ //LLFileSystem file(mMeshID, LLAssetType::AT_MESH, LLFileSystem::WRITE);
+ LLFileSystem file(mMeshID, LLAssetType::AT_MESH, LLFileSystem::READ_WRITE);
S32 offset = mOffset;
S32 size = mRequestedBytes;