From 7b102270f5bee9dbfd36a2afb5c6fc32a773abea Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 8 Jul 2011 23:32:30 -0500 Subject: SH-2007 Don't eat an entire core when uploading meshes or requesting fee information. --- indra/newview/llmeshrepository.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'indra') diff --git a/indra/newview/llmeshrepository.cpp b/indra/newview/llmeshrepository.cpp index 9e4b749ea1..2e5d65afaf 100755 --- a/indra/newview/llmeshrepository.cpp +++ b/indra/newview/llmeshrepository.cpp @@ -1532,6 +1532,8 @@ void LLMeshUploadThread::doWholeModelUpload() do { mCurlRequest->process(); + //sleep for 10ms to prevent eating a whole core + apr_sleep(10000); } while (mCurlRequest->getQueued() > 0); } @@ -1562,6 +1564,8 @@ void LLMeshUploadThread::requestWholeModelFee() do { mCurlRequest->process(); + //sleep for 10ms to prevent eating a whole core + apr_sleep(10000); } while (mCurlRequest->getQueued() > 0); delete mCurlRequest; @@ -2018,10 +2022,9 @@ void LLMeshHeaderResponder::completedRaw(U32 status, const std::string& reason, if (remaining < 0 || remaining > 4096) { - llerrs << "Bad padding of mesh asset cache entry." << llendl; + llwarns << "Bad padding of mesh asset cache entry." << llendl; } - - if (remaining > 0) + else if (remaining > 0) { file.write(block, remaining); } -- cgit v1.2.3 From 29d5413ea6c2d0782ab55916d9d9428ae00c1ace Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Sat, 9 Jul 2011 17:01:33 -0500 Subject: SH-2007 Code cleanup, expand minimum header size to 4KB, better comments around magic numbers, remove dead calcResourceCost --- indra/newview/app_settings/settings.xml | 11 ---- indra/newview/llfloatermodelpreview.cpp | 22 +------- indra/newview/llfloatermodelpreview.h | 2 - indra/newview/llmeshrepository.cpp | 58 ++++------------------ indra/newview/llmeshrepository.h | 8 +-- indra/newview/llviewerwindow.cpp | 13 ----- indra/newview/pipeline.cpp | 57 --------------------- indra/newview/skins/default/xui/en/menu_viewer.xml | 5 +- 8 files changed, 15 insertions(+), 161 deletions(-) (limited to 'indra') diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 2372c19fb9..e69fce6c6d 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -1935,17 +1935,6 @@ Value 0 - DebugShowUploadCost - - Comment - Show what it would cost to upload assets in current scene - Persist - 1 - Type - Boolean - Value - 0 - DebugShowRenderMatrices Comment diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp index eb48955a64..b5a1bceebf 100755 --- a/indra/newview/llfloatermodelpreview.cpp +++ b/indra/newview/llfloatermodelpreview.cpp @@ -407,7 +407,6 @@ BOOL LLFloaterModelPreview::postBuild() childSetTextArg("status", "[STATUS]", getString("status_idle")); - //childSetLabelArg("ok_btn", "[AMOUNT]", llformat("%d",sUploadAmount)); childSetAction("ok_btn", onUpload, this); childDisable("ok_btn"); @@ -780,15 +779,6 @@ void LLFloaterModelPreview::draw() childSetVisible("decompose_cancel", false); } - U32 resource_cost = mModelPreview->mResourceCost*10; - - if (childGetValue("upload_textures").asBoolean()) - { - resource_cost += mModelPreview->mTextureSet.size()*10; - } - - childSetLabelArg("ok_btn", "[AMOUNT]", llformat("%d", resource_cost)); - if (mModelPreview) { gGL.color3f(1.f, 1.f, 1.f); @@ -3012,7 +3002,6 @@ U32 LLModelPreview::calcResourceCost() //ok_btn should not have been changed unless something was wrong with joint list } - U32 cost = 0; std::set accounted; U32 num_points = 0; U32 num_hulls = 0; @@ -3060,8 +3049,7 @@ U32 LLModelPreview::calcResourceCost() mFMP->childGetValue("upload_skin").asBoolean(), mFMP->childGetValue("upload_joints").asBoolean(), TRUE); - cost += gMeshRepo.calcResourceCost(ret); - + num_hulls += decomp.mHull.size(); for (U32 i = 0; i < decomp.mHull.size(); ++i) { @@ -3093,7 +3081,7 @@ U32 LLModelPreview::calcResourceCost() updateStatusMessages(); - return cost; + return streaming_cost; } void LLFloaterModelPreview::setDetails(F32 x, F32 y, F32 z, F32 streaming_cost, F32 physics_cost) @@ -5405,12 +5393,6 @@ void LLFloaterModelPreview::refresh(LLUICtrl* ctrl, void* user_data) sInstance->mModelPreview->mDirty = true; } -void LLFloaterModelPreview::updateResourceCost() -{ - U32 cost = mModelPreview->mResourceCost; - childSetLabelArg("ok_btn", "[AMOUNT]", llformat("%d",cost)); -} - //static void LLModelPreview::textureLoadedCallback( BOOL success, LLViewerFetchedTexture *src_vi, LLImageRaw* src, LLImageRaw* src_aux, S32 discard_level, BOOL final, void* userdata ) { diff --git a/indra/newview/llfloatermodelpreview.h b/indra/newview/llfloatermodelpreview.h index e252c9a677..f434987b9e 100644 --- a/indra/newview/llfloatermodelpreview.h +++ b/indra/newview/llfloatermodelpreview.h @@ -184,8 +184,6 @@ public: static void refresh(LLUICtrl* ctrl, void* data); - void updateResourceCost(); - void loadModel(S32 lod); void loadModel(S32 lod, const std::string& file_name, bool force_disable_slm = false); diff --git a/indra/newview/llmeshrepository.cpp b/indra/newview/llmeshrepository.cpp index 2e5d65afaf..158ca56148 100755 --- a/indra/newview/llmeshrepository.cpp +++ b/indra/newview/llmeshrepository.cpp @@ -664,7 +664,7 @@ bool LLMeshRepoThread::fetchMeshSkinInfo(const LLUUID& mesh_id) } U32 header_size = mMeshHeaderSize[mesh_id]; - + if (header_size > 0) { S32 version = mMeshHeader[mesh_id]["version"].asInteger(); @@ -684,7 +684,7 @@ bool LLMeshRepoThread::fetchMeshSkinInfo(const LLUUID& mesh_id) U8* buffer = new U8[size]; file.read(buffer, size); - //make sure buffer isn't all 0's (reserved block but not written) + //make sure buffer isn't all 0's by checking the first 1KB (reserved block but not written) bool zero = true; for (S32 i = 0; i < llmin(size, 1024) && zero; ++i) { @@ -757,7 +757,7 @@ bool LLMeshRepoThread::fetchMeshDecomposition(const LLUUID& mesh_id) U8* buffer = new U8[size]; file.read(buffer, size); - //make sure buffer isn't all 0's (reserved block but not written) + //make sure buffer isn't all 0's by checking the first 1KB (reserved block but not written) bool zero = true; for (S32 i = 0; i < llmin(size, 1024) && zero; ++i) { @@ -830,7 +830,7 @@ bool LLMeshRepoThread::fetchMeshPhysicsShape(const LLUUID& mesh_id) U8* buffer = new U8[size]; file.read(buffer, size); - //make sure buffer isn't all 0's (reserved block but not written) + //make sure buffer isn't all 0's by checking the first 1KB (reserved block but not written) bool zero = true; for (S32 i = 0; i < llmin(size, 1024) && zero; ++i) { @@ -887,9 +887,9 @@ bool LLMeshRepoThread::fetchMeshHeader(const LLVolumeParams& mesh_params) S32 size = file.getSize(); if (size > 0) - { - U8 buffer[1024]; - S32 bytes = llmin(size, 1024); + { //NOTE -- if the header size is ever more than 4KB, this will break + U8 buffer[4096]; + S32 bytes = llmin(size, 4096); LLMeshRepository::sCacheBytesRead += bytes; file.read(buffer, bytes); if (headerReceived(mesh_params, buffer, bytes)) @@ -911,6 +911,7 @@ bool LLMeshRepoThread::fetchMeshHeader(const LLVolumeParams& mesh_params) retval = true; //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 LLMeshRepository::sHTTPRequestCount++; mCurlRequest->getByteRange(http_url, headers, 0, 4096, new LLMeshHeaderResponder(mesh_params)); } @@ -947,7 +948,7 @@ bool LLMeshRepoThread::fetchMeshLOD(const LLVolumeParams& mesh_params, S32 lod) U8* buffer = new U8[size]; file.read(buffer, size); - //make sure buffer isn't all 0's (reserved block but not written) + //make sure buffer isn't all 0's by checking the first 1KB (reserved block but not written) bool zero = true; for (S32 i = 0; i < llmin(size, 1024) && zero; ++i) { @@ -1033,14 +1034,11 @@ bool LLMeshRepoThread::headerReceived(const LLVolumeParams& mesh_params, U8* dat } { - U32 cost = gMeshRepo.calcResourceCost(header); - LLUUID mesh_id = mesh_params.getSculptID(); mHeaderMutex->lock(); mMeshHeaderSize[mesh_id] = header_size; mMeshHeader[mesh_id] = header; - mMeshResourceCost[mesh_id] = cost; mHeaderMutex->unlock(); //check for pending requests @@ -1673,19 +1671,6 @@ S32 LLMeshRepository::getActualMeshLOD(LLSD& header, S32 lod) return -1; } -U32 LLMeshRepoThread::getResourceCost(const LLUUID& mesh_id) -{ - LLMutexLock lock(mHeaderMutex); - - std::map::iterator iter = mMeshResourceCost.find(mesh_id); - if (iter != mMeshResourceCost.end()) - { - return iter->second; - } - - return 0; -} - void LLMeshRepository::cacheOutgoingMesh(LLMeshUploadData& data, LLSD& header) { mThread->mMeshHeader[data.mUUID] = header; @@ -2020,11 +2005,7 @@ void LLMeshHeaderResponder::completedRaw(U32 status, const std::string& reason, S32 remaining = bytes-file.tell(); - if (remaining < 0 || remaining > 4096) - { - llwarns << "Bad padding of mesh asset cache entry." << llendl; - } - else if (remaining > 0) + if (remaining > 0) { file.write(block, remaining); } @@ -2480,25 +2461,6 @@ S32 LLMeshRepository::getActualMeshLOD(const LLVolumeParams& mesh_params, S32 lo return mThread->getActualMeshLOD(mesh_params, lod); } -U32 LLMeshRepository::calcResourceCost(LLSD& header) -{ - U32 bytes = 0; - - for (U32 i = 0; i < 4; i++) - { - bytes += header[header_lod[i]]["size"].asInteger(); - } - - bytes += header["skin"]["size"].asInteger(); - - return bytes/4096 + 1; -} - -U32 LLMeshRepository::getResourceCost(const LLUUID& mesh_id) -{ - return mThread->getResourceCost(mesh_id); -} - const LLMeshSkinInfo* LLMeshRepository::getSkinInfo(const LLUUID& mesh_id, LLVOVolume* requesting_obj) { if (mesh_id.notNull()) diff --git a/indra/newview/llmeshrepository.h b/indra/newview/llmeshrepository.h index d775e8f74a..a15650463e 100755 --- a/indra/newview/llmeshrepository.h +++ b/indra/newview/llmeshrepository.h @@ -231,8 +231,7 @@ public: mesh_header_map mMeshHeader; std::map mMeshHeaderSize; - std::map mMeshResourceCost; - + class HeaderRequest { public: @@ -335,8 +334,7 @@ public: void notifyLoadedMeshes(); S32 getActualMeshLOD(const LLVolumeParams& mesh_params, S32 lod); - U32 getResourceCost(const LLUUID& mesh_params); - + void loadMeshSkinInfo(const LLUUID& mesh_id); void loadMeshDecomposition(const LLUUID& mesh_id); void loadMeshPhysicsShape(const LLUUID& mesh_id); @@ -466,8 +464,6 @@ public: S32 getActualMeshLOD(const LLVolumeParams& mesh_params, S32 lod); static S32 getActualMeshLOD(LLSD& header, S32 lod); - U32 calcResourceCost(LLSD& header); - U32 getResourceCost(const LLUUID& mesh_params); const LLMeshSkinInfo* getSkinInfo(const LLUUID& mesh_id, LLVOVolume* requesting_obj); LLModel::Decomposition* getDecomposition(const LLUUID& mesh_id); void fetchPhysicsShape(const LLUUID& mesh_id); diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 4e5ebb690f..98cbbad89f 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -726,19 +726,6 @@ public: } } - if (gSavedSettings.getBOOL("DebugShowUploadCost")) - { - addText(xpos, ypos, llformat(" Meshes: L$%d", gPipeline.mDebugMeshUploadCost)); - ypos += y_inc/2; - addText(xpos, ypos, llformat(" Sculpties: L$%d", gPipeline.mDebugSculptUploadCost)); - ypos += y_inc/2; - addText(xpos, ypos, llformat(" Textures: L$%d", gPipeline.mDebugTextureUploadCost)); - ypos += y_inc/2; - addText(xpos, ypos, "Upload Cost: "); - - ypos += y_inc; - } - //temporary hack to give feedback on mesh upload progress if (!gMeshRepo.mUploads.empty()) { diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index e74bf2a620..2d61a049f7 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -4134,63 +4134,6 @@ void LLPipeline::renderDebug() } } - if (gSavedSettings.getBOOL("DebugShowUploadCost")) - { - std::set textures; - std::set sculpts; - std::set meshes; - - BOOL selected = TRUE; - if (LLSelectMgr::getInstance()->getSelection()->isEmpty()) - { - selected = FALSE; - } - - for (LLCullResult::sg_list_t::iterator iter = sCull->beginVisibleGroups(); iter != sCull->endVisibleGroups(); ++iter) - { - LLSpatialGroup* group = *iter; - LLSpatialGroup::OctreeNode* node = group->mOctreeNode; - for (LLSpatialGroup::OctreeNode::element_iter elem = node->getData().begin(); elem != node->getData().end(); ++elem) - { - LLDrawable* drawable = *elem; - LLVOVolume* volume = drawable->getVOVolume(); - if (volume && volume->isSelected() == selected) - { - for (U32 i = 0; i < volume->getNumTEs(); ++i) - { - LLTextureEntry* te = volume->getTE(i); - textures.insert(te->getID()); - } - - if (volume->isSculpted()) - { - LLUUID sculpt_id = volume->getVolume()->getParams().getSculptID(); - if (volume->isMesh()) - { - meshes.insert(sculpt_id); - } - else - { - sculpts.insert(sculpt_id); - } - } - } - } - } - - gPipeline.mDebugTextureUploadCost = textures.size() * 10; - gPipeline.mDebugSculptUploadCost = sculpts.size()*10; - - U32 mesh_cost = 0; - - for (std::set::iterator iter = meshes.begin(); iter != meshes.end(); ++iter) - { - mesh_cost += gMeshRepo.getResourceCost(*iter)*10; - } - - gPipeline.mDebugMeshUploadCost = mesh_cost; - } - if (hasRenderDebugMask(LLPipeline::RENDER_DEBUG_SHADOW_FRUSTA)) { LLVertexBuffer::unbind(); diff --git a/indra/newview/skins/default/xui/en/menu_viewer.xml b/indra/newview/skins/default/xui/en/menu_viewer.xml index 598f500e4f..4b068a1724 100644 --- a/indra/newview/skins/default/xui/en/menu_viewer.xml +++ b/indra/newview/skins/default/xui/en/menu_viewer.xml @@ -1997,10 +1997,7 @@ label="Show Upload Cost" layout="topleft" name="Show Upload Cost"> - - -- cgit v1.2.3