summaryrefslogtreecommitdiff
path: root/indra/newview/pipeline.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/pipeline.cpp')
-rw-r--r--indra/newview/pipeline.cpp255
1 files changed, 4 insertions, 251 deletions
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 610804c5eb..b37645d2de 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -70,6 +70,7 @@
#include "llgldbg.h"
#include "llhudmanager.h"
#include "lllightconstants.h"
+#include "llmeshrepository.h"
#include "llresmgr.h"
#include "llselectmgr.h"
#include "llsky.h"
@@ -103,6 +104,7 @@
#include "llspatialpartition.h"
#include "llmutelist.h"
#include "lltoolpie.h"
+#include "llcurl.h"
#ifdef _DEBUG
@@ -342,8 +344,6 @@ LLPipeline::LLPipeline() :
mGlowPool(NULL),
mBumpPool(NULL),
mWLSkyPool(NULL),
- mMeshMutex(NULL),
- mMeshThreadCount(0),
mLightMask(0),
mLightMovingMask(0),
mLightingDetail(0),
@@ -403,7 +403,6 @@ void LLPipeline::init()
stop_glerror();
- mMeshMutex = new LLMutex(NULL);
for (U32 i = 0; i < 2; ++i)
{
mSpotLightFade[i] = 1.f;
@@ -478,9 +477,6 @@ void LLPipeline::cleanup()
//delete mWLSkyPool;
mWLSkyPool = NULL;
- delete mMeshMutex;
- mMeshMutex = NULL;
-
releaseGLBuffers();
mBloomImagep = NULL;
@@ -1802,6 +1798,8 @@ void LLPipeline::rebuildPriorityGroups()
assertInitialized();
+ gMeshRepo.notifyLoadedMeshes();
+
// Iterate through all drawables on the priority build queue,
for (LLSpatialGroup::sg_list_t::iterator iter = mGroupQ1.begin();
iter != mGroupQ1.end(); ++iter)
@@ -1881,8 +1879,6 @@ void LLPipeline::updateGeom(F32 max_dtime)
// for now, only LLVOVolume does this to throttle LOD changes
LLVOVolume::preUpdateGeom();
- notifyLoadedMeshes();
-
// Iterate through all drawables on the priority build queue,
for (LLDrawable::drawable_list_t::iterator iter = mBuildQ1.begin();
iter != mBuildQ1.end();)
@@ -8912,246 +8908,3 @@ LLCullResult::sg_list_t::iterator LLPipeline::endAlphaGroups()
}
-void LLPipeline::loadMesh(LLVOVolume* vobj, LLUUID mesh_id, S32 detail)
-{
- if (detail < 0 || detail > 4)
- {
- return;
- }
-
- {
- LLMutexLock lock(mMeshMutex);
- //add volume to list of loading meshes
- mesh_load_map::iterator iter = mLoadingMeshes[detail].find(mesh_id);
- if (iter != mLoadingMeshes[detail].end())
- { //request pending for this mesh, append volume id to list
- iter->second.insert(vobj->getID());
- return;
- }
-
- //first request for this mesh
- mLoadingMeshes[detail][mesh_id].insert(vobj->getID());
- }
-
- if (gAssetStorage->hasLocalAsset(mesh_id, LLAssetType::AT_MESH))
- { //already have asset, load desired LOD in background
- mPendingMeshes.push_back(new LLMeshThread(mesh_id, vobj->getVolume(), detail));
- }
- else
- { //fetch asset and load when done
- gAssetStorage->getAssetData(mesh_id, LLAssetType::AT_MESH,
- getMeshAssetCallback, vobj->getVolume(), TRUE);
- }
-
- //do a quick search to see if we can't display something while we wait for this mesh to load
- LLVolume* volume = vobj->getVolume();
-
- if (volume)
- {
- LLVolumeParams params = volume->getParams();
-
- LLVolumeLODGroup* group = LLPrimitive::getVolumeManager()->getGroup(params);
-
- if (group)
- {
- //first see what the next lowest LOD available might be
- for (S32 i = detail-1; i >= 0; --i)
- {
- LLVolume* lod = group->refLOD(i);
- if (lod && !lod->isTetrahedron() && lod->getNumVolumeFaces() > 0)
- {
- volume->copyVolumeFaces(lod);
- group->derefLOD(lod);
- return;
- }
-
- group->derefLOD(lod);
- }
-
- //no lower LOD is a available, is a higher lod available?
- for (S32 i = detail+1; i < 4; ++i)
- {
- LLVolume* lod = group->refLOD(i);
- if (lod && !lod->isTetrahedron() && lod->getNumVolumeFaces() > 0)
- {
- volume->copyVolumeFaces(lod);
- group->derefLOD(lod);
- return;
- }
-
- group->derefLOD(lod);
- }
- }
- else
- {
- llerrs << "WTF?" << llendl;
- }
-
- //nothing found, so make a tetrahedron
- volume->makeTetrahedron();
- }
-}
-
-//static
-void LLPipeline::getMeshAssetCallback(LLVFS *vfs,
- const LLUUID& asset_uuid,
- LLAssetType::EType type,
- void* user_data, S32 status, LLExtStat ext_status)
-{
- gPipeline.mPendingMeshes.push_back(new LLMeshThread(asset_uuid, (LLVolume*) user_data));
-}
-
-
-LLPipeline::LLMeshThread::LLMeshThread(LLUUID mesh_id, LLVolume* target, S32 detail)
-: LLThread("mesh_loading_thread")
-{
- mMeshID = mesh_id;
- mVolume = NULL;
- mDetail = target->getDetail();
-
- if (detail == -1)
- {
- mDetailIndex = LLVolumeLODGroup::getVolumeDetailFromScale(target->getDetail());
- }
- else
- {
- mDetailIndex = detail;
- }
-
- mTargetVolume = target;
-}
-
-LLPipeline::LLMeshThread::~LLMeshThread()
-{
-
-}
-
-void LLPipeline::LLMeshThread::run()
-{
- if (!gAssetStorage || LLApp::instance()->isQuitting())
- {
- return;
- }
-
- char* buffer = NULL;
- S32 size = 0;
-
- LLVFS* vfs = gAssetStorage->mVFS;
-
- {
- LLVFile file(vfs, mMeshID, LLAssetType::AT_MESH, LLVFile::READ);
- file.waitForLock(VFSLOCK_READ);
- size = file.getSize();
-
- if (size == 0)
- {
- gPipeline.meshLoaded(this);
- return;
- }
-
- buffer = new char[size];
- file.read((U8*)&buffer[0], size);
- }
-
- {
- std::string buffer_string(buffer, size);
- std::istringstream buffer_stream(buffer_string);
-
- {
- LLVolumeParams volume_params;
- volume_params.setType(LL_PCODE_PROFILE_SQUARE, LL_PCODE_PATH_LINE);
- volume_params.setSculptID(mMeshID, LL_SCULPT_TYPE_MESH);
- mVolume = new LLVolume(volume_params, mDetail);
- mVolume->createVolumeFacesFromStream(buffer_stream);
- }
- }
- delete[] buffer;
-
- gPipeline.meshLoaded(this);
-}
-
-void LLPipeline::meshLoaded(LLPipeline::LLMeshThread* mesh_thread)
-{
- LLMutexLock lock(mMeshMutex);
- mLoadedMeshes.push_back(mesh_thread);
-}
-
-void LLPipeline::notifyLoadedMeshes()
-{ //called from main thread
-
- U32 max_thread_count = llmax(gSavedSettings.getU32("MeshThreadCount"), (U32) 1);
- while (mMeshThreadCount < max_thread_count && !mPendingMeshes.empty())
- {
- LLMeshThread* mesh_thread = mPendingMeshes.front();
- mesh_thread->start();
- ++mMeshThreadCount;
- mPendingMeshes.pop_front();
- }
-
- LLMutexLock lock(mMeshMutex);
- std::list<LLMeshThread*> stopping_threads;
-
- for (std::list<LLMeshThread*>::iterator iter = mLoadedMeshes.begin(); iter != mLoadedMeshes.end(); ++iter)
- { //for each mesh done loading
- LLMeshThread* mesh = *iter;
-
- if (!mesh->isStopped())
- { //don't process a LLMeshThread until it's stopped
- stopping_threads.push_back(mesh);
- continue;
- }
-
- S32 detail = mesh->mDetailIndex;
-
- //get list of objects waiting to be notified this mesh is loaded
- mesh_load_map::iterator obj_iter = mLoadingMeshes[detail].find(mesh->mMeshID);
-
- if (mesh->mVolume && obj_iter != mLoadingMeshes[detail].end())
- {
- //make sure target volume is still valid
- BOOL valid = FALSE;
-
- for (std::set<LLUUID>::iterator vobj_iter = obj_iter->second.begin(); vobj_iter != obj_iter->second.end(); ++vobj_iter)
- {
- LLVOVolume* vobj = (LLVOVolume*) gObjectList.findObject(*vobj_iter);
-
- if (vobj)
- {
- if (vobj->getVolume() == mesh->mTargetVolume)
- {
- valid = TRUE;
- }
- }
- }
-
-
- if (valid)
- {
- if (mesh->mVolume->getNumVolumeFaces() <= 0)
- {
- llwarns << "Mesh loading returned empty volume." << llendl;
- mesh->mVolume->makeTetrahedron();
- }
-
- mesh->mTargetVolume->copyVolumeFaces(mesh->mVolume);
-
- for (std::set<LLUUID>::iterator vobj_iter = obj_iter->second.begin(); vobj_iter != obj_iter->second.end(); ++vobj_iter)
- {
- LLVOVolume* vobj = (LLVOVolume*) gObjectList.findObject(*vobj_iter);
- if (vobj)
- {
- vobj->notifyMeshLoaded();
- }
- }
- }
-
- mLoadingMeshes[detail].erase(mesh->mMeshID);
- }
-
- delete mesh;
- --mMeshThreadCount;
- }
-
- mLoadedMeshes = stopping_threads;
-}
-