From 9a8dbb852056834ebdbea23d8475a4ec4b685549 Mon Sep 17 00:00:00 2001 From: "Brad Payne (Vir Linden)" Date: Fri, 17 Dec 2010 14:13:07 -0500 Subject: SH-682 WIP: allow DEBUG_FAST_TIMER_THREADS to work when enabled --- indra/llcommon/llfasttimer_class.h | 2 +- indra/llcommon/llthread.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) mode change 100644 => 100755 indra/llcommon/llfasttimer_class.h mode change 100644 => 100755 indra/llcommon/llthread.cpp (limited to 'indra') diff --git a/indra/llcommon/llfasttimer_class.h b/indra/llcommon/llfasttimer_class.h old mode 100644 new mode 100755 index 2a645315c9..4e59d4ab9d --- a/indra/llcommon/llfasttimer_class.h +++ b/indra/llcommon/llfasttimer_class.h @@ -39,7 +39,7 @@ class LLMutex; #include "llsd.h" #if DEBUG_FAST_TIMER_THREADS -void assert_main_thread(); +LL_COMMON_API void assert_main_thread(); #endif class LL_COMMON_API LLFastTimer diff --git a/indra/llcommon/llthread.cpp b/indra/llcommon/llthread.cpp old mode 100644 new mode 100755 index f0b7ac5def..b4617c5453 --- a/indra/llcommon/llthread.cpp +++ b/indra/llcommon/llthread.cpp @@ -62,7 +62,7 @@ U32 ll_thread_local sThreadID = 0; U32 LLThread::sIDIter = 0; -void assert_main_thread() +LL_COMMON_API void assert_main_thread() { static U32 s_thread_id = LLThread::currentID(); if (LLThread::currentID() != s_thread_id) -- cgit v1.2.3 From 6a0e8fc13ec246f69e5718ee91a30117ae703c2a Mon Sep 17 00:00:00 2001 From: "Brad Payne (Vir Linden)" Date: Mon, 20 Dec 2010 13:52:48 -0500 Subject: thread safety checking --- indra/llcommon/llfasttimer_class.h | 2 - indra/newview/llfloatermodelpreview.cpp | 175 +++++++++++++++++--------------- indra/newview/llfloatermodelpreview.h | 3 +- 3 files changed, 94 insertions(+), 86 deletions(-) mode change 100644 => 100755 indra/newview/llfloatermodelpreview.h (limited to 'indra') diff --git a/indra/llcommon/llfasttimer_class.h b/indra/llcommon/llfasttimer_class.h index 4e59d4ab9d..68efb69e87 100755 --- a/indra/llcommon/llfasttimer_class.h +++ b/indra/llcommon/llfasttimer_class.h @@ -38,9 +38,7 @@ class LLMutex; #include #include "llsd.h" -#if DEBUG_FAST_TIMER_THREADS LL_COMMON_API void assert_main_thread(); -#endif class LL_COMMON_API LLFastTimer { diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp index 660157df1e..4d8e71918f 100755 --- a/indra/newview/llfloatermodelpreview.cpp +++ b/indra/newview/llfloatermodelpreview.cpp @@ -2057,7 +2057,7 @@ U32 LLModelPreview::calcResourceCost() if ( mModelLoader->getLoadState() != LLModelLoader::ERROR_PARSING ) { - mFMP->childEnable("ok_btn"); + getFMP()->childEnable("ok_btn"); } U32 cost = 0; @@ -2065,7 +2065,7 @@ U32 LLModelPreview::calcResourceCost() U32 num_points = 0; U32 num_hulls = 0; - F32 debug_scale = mFMP->childGetValue("import_scale").asReal(); + F32 debug_scale = getFMP()->childGetValue("import_scale").asReal(); F32 streaming_cost = 0.f; for (U32 i = 0; i < mUploadData.size(); ++i) @@ -2089,8 +2089,8 @@ U32 LLModelPreview::calcResourceCost() instance.mLOD[1], instance.mLOD[0], decomp, - mFMP->childGetValue("upload_skin").asBoolean(), - mFMP->childGetValue("upload_joints").asBoolean(), + getFMP()->childGetValue("upload_skin").asBoolean(), + getFMP()->childGetValue("upload_joints").asBoolean(), TRUE); cost += gMeshRepo.calcResourceCost(ret); @@ -2119,13 +2119,13 @@ U32 LLModelPreview::calcResourceCost() } } - //mFMP->childSetTextArg(info_name[LLModel::LOD_PHYSICS], "[HULLS]", llformat("%d",num_hulls)); - //mFMP->childSetTextArg(info_name[LLModel::LOD_PHYSICS], "[POINTS]", llformat("%d",num_points)); - mFMP->childSetTextArg("streaming cost", "[COST]", llformat("%.3f", streaming_cost)); - F32 scale = mFMP->childGetValue("import_scale").asReal()*2.f; - mFMP->childSetTextArg("import_dimensions", "[X]", llformat("%.3f", mPreviewScale[0]*scale)); - mFMP->childSetTextArg("import_dimensions", "[Y]", llformat("%.3f", mPreviewScale[1]*scale)); - mFMP->childSetTextArg("import_dimensions", "[Z]", llformat("%.3f", mPreviewScale[2]*scale)); + //getFMP()->childSetTextArg(info_name[LLModel::LOD_PHYSICS], "[HULLS]", llformat("%d",num_hulls)); + //getFMP()->childSetTextArg(info_name[LLModel::LOD_PHYSICS], "[POINTS]", llformat("%d",num_points)); + getFMP()->childSetTextArg("streaming cost", "[COST]", llformat("%.3f", streaming_cost)); + F32 scale = getFMP()->childGetValue("import_scale").asReal()*2.f; + getFMP()->childSetTextArg("import_dimensions", "[X]", llformat("%.3f", mPreviewScale[0]*scale)); + getFMP()->childSetTextArg("import_dimensions", "[Y]", llformat("%.3f", mPreviewScale[1]*scale)); + getFMP()->childSetTextArg("import_dimensions", "[Z]", llformat("%.3f", mPreviewScale[2]*scale)); updateStatusMessages(); @@ -2139,10 +2139,10 @@ void LLModelPreview::rebuildUploadData() //fill uploaddata instance vectors from scene data - std::string requested_name = mFMP->getChild("description_form")->getValue().asString(); + std::string requested_name = getFMP()->getChild("description_form")->getValue().asString(); - LLSpinCtrl* scale_spinner = mFMP->getChild("import_scale"); + LLSpinCtrl* scale_spinner = getFMP()->getChild("import_scale"); if (!scale_spinner) { @@ -2158,7 +2158,7 @@ void LLModelPreview::rebuildUploadData() if ( mBaseScene.size() > 0 ) { - mFMP->childEnable("ok_btn"); + getFMP()->childEnable("ok_btn"); } for (LLModelLoader::scene::iterator iter = mBaseScene.begin(); iter != mBaseScene.end(); ++iter) @@ -2226,7 +2226,7 @@ void LLModelPreview::rebuildUploadData() } //refill "layer" combo in physics panel - LLComboBox* combo_box = mFMP->getChild("physics_layer"); + LLComboBox* combo_box = getFMP()->getChild("physics_layer"); if (combo_box) { S32 current = combo_box->getCurrentIndex(); @@ -2270,7 +2270,7 @@ void LLModelPreview::loadModel(std::string filename, S32 lod) { // this is the initial file picking. Close the whole floater // if we don't have a base model to show for high LOD. - mFMP->closeFloater(false); + getFMP()->closeFloater(false); } mLoading = false; @@ -2288,25 +2288,25 @@ void LLModelPreview::loadModel(std::string filename, S32 lod) mModelLoader->start(); - mFMP->childSetTextArg("status", "[STATUS]", mFMP->getString("status_reading_file")); + getFMP()->childSetTextArg("status", "[STATUS]", getFMP()->getString("status_reading_file")); setPreviewLOD(lod); if ( mModelLoader->getLoadState() == LLModelLoader::ERROR_PARSING ) { - mFMP->childDisable("ok_btn"); + getFMP()->childDisable("ok_btn"); } if (lod == mPreviewLOD) { - mFMP->childSetText("lod_file", mLODFile[mPreviewLOD]); + getFMP()->childSetText("lod_file", mLODFile[mPreviewLOD]); } else if (lod == LLModel::LOD_PHYSICS) { - mFMP->childSetText("physics_file", mLODFile[lod]); + getFMP()->childSetText("physics_file", mLODFile[lod]); } - mFMP->openFloater(); + getFMP()->openFloater(); } void LLModelPreview::setPhysicsFromLOD(S32 lod) @@ -2316,7 +2316,7 @@ void LLModelPreview::setPhysicsFromLOD(S32 lod) mModel[LLModel::LOD_PHYSICS] = mModel[lod]; mScene[LLModel::LOD_PHYSICS] = mScene[lod]; mLODFile[LLModel::LOD_PHYSICS].clear(); - mFMP->childSetText("physics_file", mLODFile[LLModel::LOD_PHYSICS]); + getFMP()->childSetText("physics_file", mLODFile[LLModel::LOD_PHYSICS]); mVertexBuffer[LLModel::LOD_PHYSICS].clear(); rebuildUploadData(); refresh(); @@ -2365,6 +2365,13 @@ void LLModelPreview::clearGLODGroup() } } +LLFloater* LLModelPreview::getFMP() +{ + // Shouldn't be accessing this outside the main UI thread. + assert_main_thread(); + return mFMP; +} + void LLModelPreview::loadModelCallback(S32 lod) { //NOT the main thread LLMutexLock lock(this); @@ -2430,7 +2437,7 @@ void LLModelPreview::generateNormals() return; } - F32 angle_cutoff = mFMP->childGetValue("crease_angle").asReal(); + F32 angle_cutoff = getFMP()->childGetValue("crease_angle").asReal(); angle_cutoff *= DEG_TO_RAD; @@ -2724,20 +2731,20 @@ void LLModelPreview::genLODs(S32 which_lod) U32 lod_mode = 0; - LLCtrlSelectionInterface* iface = mFMP->childGetSelectionInterface("lod_mode"); + LLCtrlSelectionInterface* iface = getFMP()->childGetSelectionInterface("lod_mode"); if (iface) { lod_mode = iface->getFirstSelectedIndex(); } - F32 lod_error_threshold = mFMP->childGetValue("lod_error_threshold").asReal(); + F32 lod_error_threshold = getFMP()->childGetValue("lod_error_threshold").asReal(); if (lod_mode == 0) { lod_mode = GLOD_TRIANGLE_BUDGET; if (which_lod != -1) { - limit = mFMP->childGetValue("lod_triangle_limit").asInteger(); + limit = getFMP()->childGetValue("lod_triangle_limit").asInteger(); } } else @@ -2747,7 +2754,7 @@ void LLModelPreview::genLODs(S32 which_lod) U32 build_operator = 0; - iface = mFMP->childGetSelectionInterface("build_operator"); + iface = getFMP()->childGetSelectionInterface("build_operator"); if (iface) { build_operator = iface->getFirstSelectedIndex(); @@ -2763,7 +2770,7 @@ void LLModelPreview::genLODs(S32 which_lod) } U32 queue_mode=0; - iface = mFMP->childGetSelectionInterface("queue_mode"); + iface = getFMP()->childGetSelectionInterface("queue_mode"); if (iface) { queue_mode = iface->getFirstSelectedIndex(); @@ -2784,7 +2791,7 @@ void LLModelPreview::genLODs(S32 which_lod) U32 border_mode = 0; - iface = mFMP->childGetSelectionInterface("border_mode"); + iface = getFMP()->childGetSelectionInterface("border_mode"); if (iface) { border_mode = iface->getFirstSelectedIndex(); @@ -2818,7 +2825,7 @@ void LLModelPreview::genLODs(S32 which_lod) object_dirty = true; } - F32 share_tolerance = mFMP->childGetValue("share_tolerance").asReal(); + F32 share_tolerance = getFMP()->childGetValue("share_tolerance").asReal(); if (share_tolerance != mBuildShareTolerance) { mBuildShareTolerance = share_tolerance; @@ -3109,9 +3116,9 @@ void LLModelPreview::updateStatusMessages() } - mFMP->childSetTextArg("submeshes_info", "[SUBMESHES]", llformat("%d", total_submeshes[LLModel::LOD_HIGH])); + getFMP()->childSetTextArg("submeshes_info", "[SUBMESHES]", llformat("%d", total_submeshes[LLModel::LOD_HIGH])); - std::string mesh_status_na = mFMP->getString("mesh_status_na"); + std::string mesh_status_na = getFMP()->getString("mesh_status_na"); S32 upload_status[LLModel::LOD_HIGH+1]; @@ -3125,8 +3132,8 @@ void LLModelPreview::updateStatusMessages() if (total_tris[lod] > 0) { - mFMP->childSetText(lod_triangles_name[lod], llformat("%d", total_tris[lod])); - mFMP->childSetText(lod_vertices_name[lod], llformat("%d", total_verts[lod])); + getFMP()->childSetText(lod_triangles_name[lod], llformat("%d", total_tris[lod])); + getFMP()->childSetText(lod_vertices_name[lod], llformat("%d", total_verts[lod])); } else { @@ -3147,8 +3154,8 @@ void LLModelPreview::updateStatusMessages() } } - mFMP->childSetText(lod_triangles_name[lod], mesh_status_na); - mFMP->childSetText(lod_vertices_name[lod], mesh_status_na); + getFMP()->childSetText(lod_triangles_name[lod], mesh_status_na); + getFMP()->childSetText(lod_vertices_name[lod], mesh_status_na); } const U32 lod_high = LLModel::LOD_HIGH; @@ -3183,7 +3190,7 @@ void LLModelPreview::updateStatusMessages() } } - LLIconCtrl* icon = mFMP->getChild(lod_icon_name[lod]); + LLIconCtrl* icon = getFMP()->getChild(lod_icon_name[lod]); LLUIImagePtr img = LLUI::getUIImage(lod_status_image[upload_status[lod]]); icon->setVisible(true); icon->setImage(img); @@ -3195,8 +3202,8 @@ void LLModelPreview::updateStatusMessages() if (lod == mPreviewLOD) { - mFMP->childSetText("lod_status_message_text", mFMP->getString(message)); - icon = mFMP->getChild("lod_status_message_icon"); + getFMP()->childSetText("lod_status_message_text", getFMP()->getString(message)); + icon = getFMP()->getChild("lod_status_message_icon"); icon->setImage(img); } } @@ -3205,18 +3212,18 @@ void LLModelPreview::updateStatusMessages() if ( upload_ok && !errorStateFromLoader ) { - mFMP->childEnable("ok_btn"); + getFMP()->childEnable("ok_btn"); } else { - mFMP->childDisable("ok_btn"); + getFMP()->childDisable("ok_btn"); } //add up physics triangles etc S32 start = 0; S32 end = mModel[LLModel::LOD_PHYSICS].size(); - S32 idx = mFMP->childGetValue("physics_layer").asInteger(); + S32 idx = getFMP()->childGetValue("physics_layer").asInteger(); if (idx >= 0 && idx < mModel[LLModel::LOD_PHYSICS].size()) { @@ -3255,22 +3262,22 @@ void LLModelPreview::updateStatusMessages() if (phys_tris > 0) { - mFMP->childSetTextArg("physics_triangles", "[TRIANGLES]", llformat("%d", phys_tris)); + getFMP()->childSetTextArg("physics_triangles", "[TRIANGLES]", llformat("%d", phys_tris)); } else { - mFMP->childSetTextArg("physics_triangles", "[TRIANGLES]", mesh_status_na); + getFMP()->childSetTextArg("physics_triangles", "[TRIANGLES]", mesh_status_na); } if (phys_hulls > 0) { - mFMP->childSetTextArg("physics_hulls", "[HULLS]", llformat("%d", phys_hulls)); - mFMP->childSetTextArg("physics_points", "[POINTS]", llformat("%d", phys_points)); + getFMP()->childSetTextArg("physics_hulls", "[HULLS]", llformat("%d", phys_hulls)); + getFMP()->childSetTextArg("physics_points", "[POINTS]", llformat("%d", phys_points)); } else { - mFMP->childSetTextArg("physics_hulls", "[HULLS]", mesh_status_na); - mFMP->childSetTextArg("physics_points", "[POINTS]", mesh_status_na); + getFMP()->childSetTextArg("physics_hulls", "[HULLS]", mesh_status_na); + getFMP()->childSetTextArg("physics_points", "[POINTS]", mesh_status_na); } LLFloaterModelPreview* fmp = LLFloaterModelPreview::sInstance; @@ -3315,43 +3322,43 @@ void LLModelPreview::updateStatusMessages() const U32 num_file_controls = sizeof(file_controls)/sizeof(char*); //enable/disable controls based on radio groups - if (mFMP->childGetValue("lod_from_file").asBoolean()) + if (getFMP()->childGetValue("lod_from_file").asBoolean()) { for (U32 i = 0; i < num_file_controls; ++i) { - mFMP->childEnable(file_controls[i]); + getFMP()->childEnable(file_controls[i]); } for (U32 i = 0; i < num_lod_controls; ++i) { - mFMP->childDisable(lod_controls[i]); + getFMP()->childDisable(lod_controls[i]); } } - else if (mFMP->childGetValue("lod_auto_generate").asBoolean()) + else if (getFMP()->childGetValue("lod_auto_generate").asBoolean()) { for (U32 i = 0; i < num_file_controls; ++i) { - mFMP->childDisable(file_controls[i]); + getFMP()->childDisable(file_controls[i]); } for (U32 i = 0; i < num_lod_controls; ++i) { - mFMP->childEnable(lod_controls[i]); + getFMP()->childEnable(lod_controls[i]); } //if (threshold) { U32 lod_mode = 0; - LLCtrlSelectionInterface* iface = mFMP->childGetSelectionInterface("lod_mode"); + LLCtrlSelectionInterface* iface = getFMP()->childGetSelectionInterface("lod_mode"); if (iface) { lod_mode = iface->getFirstSelectedIndex(); } - LLSpinCtrl* threshold = mFMP->getChild("lod_error_threshold"); - LLSpinCtrl* limit = mFMP->getChild("lod_triangle_limit"); + LLSpinCtrl* threshold = getFMP()->getChild("lod_error_threshold"); + LLSpinCtrl* limit = getFMP()->getChild("lod_triangle_limit"); limit->setMaxValue(mMaxTriangleLimit); limit->setValue(total_tris[mPreviewLOD]); @@ -3374,12 +3381,12 @@ void LLModelPreview::updateStatusMessages() { // "None" is chosen for (U32 i = 0; i < num_file_controls; ++i) { - mFMP->childDisable(file_controls[i]); + getFMP()->childDisable(file_controls[i]); } for (U32 i = 0; i < num_lod_controls; ++i) { - mFMP->childDisable(lod_controls[i]); + getFMP()->childDisable(lod_controls[i]); } if (!mModel[mPreviewLOD].empty()) @@ -3394,17 +3401,17 @@ void LLModelPreview::updateStatusMessages() } } - if (mFMP->childGetValue("physics_load_from_file").asBoolean()) + if (getFMP()->childGetValue("physics_load_from_file").asBoolean()) { - mFMP->childDisable("physics_lod_combo"); - mFMP->childEnable("physics_file"); - mFMP->childEnable("physics_browse"); + getFMP()->childDisable("physics_lod_combo"); + getFMP()->childEnable("physics_file"); + getFMP()->childEnable("physics_browse"); } else { - mFMP->childEnable("physics_lod_combo"); - mFMP->childDisable("physics_file"); - mFMP->childDisable("physics_browse"); + getFMP()->childEnable("physics_lod_combo"); + getFMP()->childDisable("physics_file"); + getFMP()->childDisable("physics_browse"); } } @@ -3576,6 +3583,8 @@ void LLModelPreview::update() //----------------------------------------------------------------------------- BOOL LLModelPreview::render() { + assert_main_thread(); + LLMutexLock lock(this); mNeedsUpdate = FALSE; @@ -3627,8 +3636,8 @@ BOOL LLModelPreview::render() } bool has_skin_weights = false; - bool upload_skin = mFMP->childGetValue("upload_skin").asBoolean(); - bool upload_joints = mFMP->childGetValue("upload_joints").asBoolean(); + bool upload_skin = getFMP()->childGetValue("upload_skin").asBoolean(); + bool upload_joints = getFMP()->childGetValue("upload_joints").asBoolean(); for (LLModelLoader::scene::iterator iter = mScene[mPreviewLOD].begin(); iter != mScene[mPreviewLOD].end(); ++iter) { @@ -3650,11 +3659,11 @@ BOOL LLModelPreview::render() fmp->enableViewOption("show_skin_weight"); fmp->setViewOptionEnabled("show_joint_positions", skin_weight); } - mFMP->childEnable("upload_skin"); + getFMP()->childEnable("upload_skin"); } else { - mFMP->childDisable("upload_skin"); + getFMP()->childDisable("upload_skin"); if (fmp) { fmp->setViewOption("show_skin_weight", false); @@ -3666,23 +3675,23 @@ BOOL LLModelPreview::render() if (upload_skin && !has_skin_weights) { //can't upload skin weights if model has no skin weights - mFMP->childSetValue("upload_skin", false); + getFMP()->childSetValue("upload_skin", false); upload_skin = false; } if (!upload_skin && upload_joints) { //can't upload joints if not uploading skin weights - mFMP->childSetValue("upload_joints", false); + getFMP()->childSetValue("upload_joints", false); upload_joints = false; } - mFMP->childSetEnabled("upload_joints", upload_skin); + getFMP()->childSetEnabled("upload_joints", upload_skin); - F32 explode = mFMP->childGetValue("physics_explode").asReal(); + F32 explode = getFMP()->childGetValue("physics_explode").asReal(); glClear(GL_DEPTH_BUFFER_BIT); - LLRect preview_rect = mFMP->getChildView("preview_panel")->getRect(); + LLRect preview_rect = getFMP()->getChildView("preview_panel")->getRect(); F32 aspect = (F32) preview_rect.getWidth()/preview_rect.getHeight(); LLViewerCamera::getInstance()->setAspect(aspect); @@ -3736,7 +3745,7 @@ BOOL LLModelPreview::render() //genLODs(); } - S32 physics_idx = mFMP->childGetValue("physics_layer").asInteger(); + S32 physics_idx = getFMP()->childGetValue("physics_layer").asInteger(); if (!mModel[mPreviewLOD].empty()) { @@ -4116,10 +4125,10 @@ void LLModelPreview::setPreviewLOD(S32 lod) { mPreviewLOD = lod; - LLComboBox* combo_box = mFMP->getChild("preview_lod_combo"); + LLComboBox* combo_box = getFMP()->getChild("preview_lod_combo"); combo_box->setCurrentByIndex((NUM_LOD-1)-mPreviewLOD); // combo box list of lods is in reverse order - mFMP->childSetTextArg("lod_table_footer", "[DETAIL]", mFMP->getString(lod_name[mPreviewLOD])); - mFMP->childSetText("lod_file", mLODFile[mPreviewLOD]); + getFMP()->childSetTextArg("lod_table_footer", "[DETAIL]", getFMP()->getString(lod_name[mPreviewLOD])); + getFMP()->childSetText("lod_file", mLODFile[mPreviewLOD]); LLColor4 highlight_color = LLUIColorTable::instance().getColor("MeshImportTableHighlightColor"); LLColor4 normal_color = LLUIColorTable::instance().getColor("MeshImportTableNormalColor"); @@ -4128,10 +4137,10 @@ void LLModelPreview::setPreviewLOD(S32 lod) { const LLColor4& color = (i == lod) ? highlight_color : normal_color; - mFMP->childSetColor(lod_status_name[i], color); - mFMP->childSetColor(lod_label_name[i], color); - mFMP->childSetColor(lod_triangles_name[i], color); - mFMP->childSetColor(lod_vertices_name[i], color); + getFMP()->childSetColor(lod_status_name[i], color); + getFMP()->childSetColor(lod_label_name[i], color); + getFMP()->childSetColor(lod_triangles_name[i], color); + getFMP()->childSetColor(lod_vertices_name[i], color); } } refresh(); diff --git a/indra/newview/llfloatermodelpreview.h b/indra/newview/llfloatermodelpreview.h old mode 100644 new mode 100755 index e233f3672a..2c89927203 --- a/indra/newview/llfloatermodelpreview.h +++ b/indra/newview/llfloatermodelpreview.h @@ -278,7 +278,8 @@ class LLModelPreview : public LLViewerDynamicTexture, public LLMutex friend class LLFloaterModelPreview::DecompRequest; friend class LLPhysicsDecomp; - LLFloater* mFMP; + LLFloater* mFMP; + LLFloater* getFMP(); BOOL mNeedsUpdate; bool mDirty; -- cgit v1.2.3 From e9d21ba941a52665d7ad2ee3483c6ac7b7ec6486 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Mon, 20 Dec 2010 15:09:15 -0600 Subject: Fix for windows build. Reviewed by Nyx. --- indra/llmath/llsimdmath.h | 2 ++ indra/llmath/llvolume.cpp | 2 ++ 2 files changed, 4 insertions(+) (limited to 'indra') diff --git a/indra/llmath/llsimdmath.h b/indra/llmath/llsimdmath.h index b6ac5190a7..c7cdf7b32c 100644 --- a/indra/llmath/llsimdmath.h +++ b/indra/llmath/llsimdmath.h @@ -35,7 +35,9 @@ #error SSE2 not enabled. LLVector4a and related class will not compile. #endif +#if !LL_WINDOWS #include +#endif template T* LL_NEXT_ALIGNED_ADDRESS(T* address) { diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp index c0b50b606e..8a7b19800c 100644 --- a/indra/llmath/llvolume.cpp +++ b/indra/llmath/llvolume.cpp @@ -29,7 +29,9 @@ #include "llmath.h" #include +#if !LL_WINDOWS #include +#endif #include "llerror.h" #include "llmemtype.h" -- cgit v1.2.3 From 4bd6edc6b037195012583467a3e5e754f6a5af77 Mon Sep 17 00:00:00 2001 From: "Brad Payne (Vir Linden)" Date: Mon, 20 Dec 2010 17:11:34 -0500 Subject: SH-682 FIX, SH-594 FIX - removed mFMP wrapper, added thread checking. Moved onIdle functions to llcallbacklist. --- indra/llcommon/llfasttimer_class.h | 2 +- indra/newview/llappearancemgr.cpp | 69 ----------- indra/newview/llappearancemgr.h | 9 -- indra/newview/llcallbacklist.cpp | 65 +++++++++++ indra/newview/llcallbacklist.h | 9 ++ indra/newview/llfloatermodelpreview.cpp | 196 +++++++++++++++++--------------- indra/newview/llfloatermodelpreview.h | 1 - 7 files changed, 178 insertions(+), 173 deletions(-) mode change 100644 => 100755 indra/newview/llappearancemgr.cpp mode change 100644 => 100755 indra/newview/llappearancemgr.h mode change 100644 => 100755 indra/newview/llcallbacklist.cpp mode change 100644 => 100755 indra/newview/llcallbacklist.h (limited to 'indra') diff --git a/indra/llcommon/llfasttimer_class.h b/indra/llcommon/llfasttimer_class.h index 68efb69e87..038a2d246a 100755 --- a/indra/llcommon/llfasttimer_class.h +++ b/indra/llcommon/llfasttimer_class.h @@ -31,7 +31,7 @@ #define FAST_TIMER_ON 1 #define TIME_FAST_TIMERS 0 -#define DEBUG_FAST_TIMER_THREADS 0 +#define DEBUG_FAST_TIMER_THREADS 1 class LLMutex; diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp old mode 100644 new mode 100755 index 80734b0d41..0e080e713b --- a/indra/newview/llappearancemgr.cpp +++ b/indra/newview/llappearancemgr.cpp @@ -2759,75 +2759,6 @@ BOOL LLAppearanceMgr::getIsProtectedCOFItem(const LLUUID& obj_id) const */ } -// Shim class to allow arbitrary boost::bind -// expressions to be run as one-time idle callbacks. -// -// TODO: rework idle function spec to take a boost::function in the first place. -class OnIdleCallbackOneTime -{ -public: - OnIdleCallbackOneTime(nullary_func_t callable): - mCallable(callable) - { - } - static void onIdle(void *data) - { - gIdleCallbacks.deleteFunction(onIdle, data); - OnIdleCallbackOneTime* self = reinterpret_cast(data); - self->call(); - delete self; - } - void call() - { - mCallable(); - } -private: - nullary_func_t mCallable; -}; - -void doOnIdleOneTime(nullary_func_t callable) -{ - OnIdleCallbackOneTime* cb_functor = new OnIdleCallbackOneTime(callable); - gIdleCallbacks.addFunction(&OnIdleCallbackOneTime::onIdle,cb_functor); -} - -// Shim class to allow generic boost functions to be run as -// recurring idle callbacks. Callable should return true when done, -// false to continue getting called. -// -// TODO: rework idle function spec to take a boost::function in the first place. -class OnIdleCallbackRepeating -{ -public: - OnIdleCallbackRepeating(bool_func_t callable): - mCallable(callable) - { - } - // Will keep getting called until the callable returns true. - static void onIdle(void *data) - { - OnIdleCallbackRepeating* self = reinterpret_cast(data); - bool done = self->call(); - if (done) - { - gIdleCallbacks.deleteFunction(onIdle, data); - delete self; - } - } - bool call() - { - return mCallable(); - } -private: - bool_func_t mCallable; -}; - -void doOnIdleRepeating(bool_func_t callable) -{ - OnIdleCallbackRepeating* cb_functor = new OnIdleCallbackRepeating(callable); - gIdleCallbacks.addFunction(&OnIdleCallbackRepeating::onIdle,cb_functor); -} - class CallAfterCategoryFetchStage2: public LLInventoryFetchItemsObserver { public: diff --git a/indra/newview/llappearancemgr.h b/indra/newview/llappearancemgr.h old mode 100644 new mode 100755 index c65d9dc9ee..4b1d95cf25 --- a/indra/newview/llappearancemgr.h +++ b/indra/newview/llappearancemgr.h @@ -248,15 +248,6 @@ private: LLUUID findDescendentCategoryIDByName(const LLUUID& parent_id,const std::string& name); -typedef boost::function nullary_func_t; -typedef boost::function bool_func_t; - -// Call a given callable once in idle loop. -void doOnIdleOneTime(nullary_func_t callable); - -// Repeatedly call a callable in idle loop until it returns true. -void doOnIdleRepeating(bool_func_t callable); - // Invoke a given callable after category contents are fully fetched. void callAfterCategoryFetch(const LLUUID& cat_id, nullary_func_t cb); diff --git a/indra/newview/llcallbacklist.cpp b/indra/newview/llcallbacklist.cpp old mode 100644 new mode 100755 index a54c77b4a0..357a6582d1 --- a/indra/newview/llcallbacklist.cpp +++ b/indra/newview/llcallbacklist.cpp @@ -115,6 +115,71 @@ void LLCallbackList::callFunctions() } } +// Shim class to allow arbitrary boost::bind +// expressions to be run as one-time idle callbacks. +class OnIdleCallbackOneTime +{ +public: + OnIdleCallbackOneTime(nullary_func_t callable): + mCallable(callable) + { + } + static void onIdle(void *data) + { + gIdleCallbacks.deleteFunction(onIdle, data); + OnIdleCallbackOneTime* self = reinterpret_cast(data); + self->call(); + delete self; + } + void call() + { + mCallable(); + } +private: + nullary_func_t mCallable; +}; + +void doOnIdleOneTime(nullary_func_t callable) +{ + OnIdleCallbackOneTime* cb_functor = new OnIdleCallbackOneTime(callable); + gIdleCallbacks.addFunction(&OnIdleCallbackOneTime::onIdle,cb_functor); +} + +// Shim class to allow generic boost functions to be run as +// recurring idle callbacks. Callable should return true when done, +// false to continue getting called. +class OnIdleCallbackRepeating +{ +public: + OnIdleCallbackRepeating(bool_func_t callable): + mCallable(callable) + { + } + // Will keep getting called until the callable returns true. + static void onIdle(void *data) + { + OnIdleCallbackRepeating* self = reinterpret_cast(data); + bool done = self->call(); + if (done) + { + gIdleCallbacks.deleteFunction(onIdle, data); + delete self; + } + } + bool call() + { + return mCallable(); + } +private: + bool_func_t mCallable; +}; + +void doOnIdleRepeating(bool_func_t callable) +{ + OnIdleCallbackRepeating* cb_functor = new OnIdleCallbackRepeating(callable); + gIdleCallbacks.addFunction(&OnIdleCallbackRepeating::onIdle,cb_functor); +} + #ifdef _DEBUG void test1(void *data) diff --git a/indra/newview/llcallbacklist.h b/indra/newview/llcallbacklist.h old mode 100644 new mode 100755 index 07ac21f5e9..97f3bfd9ee --- a/indra/newview/llcallbacklist.h +++ b/indra/newview/llcallbacklist.h @@ -52,6 +52,15 @@ protected: callback_list_t mCallbackList; }; +typedef boost::function nullary_func_t; +typedef boost::function bool_func_t; + +// Call a given callable once in idle loop. +void doOnIdleOneTime(nullary_func_t callable); + +// Repeatedly call a callable in idle loop until it returns true. +void doOnIdleRepeating(bool_func_t callable); + extern LLCallbackList gIdleCallbacks; #endif diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp index 4d8e71918f..f9648b0e3b 100755 --- a/indra/newview/llfloatermodelpreview.cpp +++ b/indra/newview/llfloatermodelpreview.cpp @@ -94,8 +94,7 @@ #include "lltoggleablemenu.h" #include "llvfile.h" #include "llvfs.h" - - +#include "llcallbacklist.h" #include "glod/glod.h" @@ -1600,8 +1599,8 @@ void LLModelLoader::run() } processElement(scene); - - mPreview->loadModelCallback(mLod); + + doOnIdleOneTime(boost::bind(&LLModelPreview::loadModelCallback,mPreview,mLod)); } } @@ -2053,11 +2052,13 @@ LLModelPreview::~LLModelPreview() U32 LLModelPreview::calcResourceCost() { + assert_main_thread(); + rebuildUploadData(); if ( mModelLoader->getLoadState() != LLModelLoader::ERROR_PARSING ) { - getFMP()->childEnable("ok_btn"); + mFMP->childEnable("ok_btn"); } U32 cost = 0; @@ -2065,7 +2066,7 @@ U32 LLModelPreview::calcResourceCost() U32 num_points = 0; U32 num_hulls = 0; - F32 debug_scale = getFMP()->childGetValue("import_scale").asReal(); + F32 debug_scale = mFMP->childGetValue("import_scale").asReal(); F32 streaming_cost = 0.f; for (U32 i = 0; i < mUploadData.size(); ++i) @@ -2089,8 +2090,8 @@ U32 LLModelPreview::calcResourceCost() instance.mLOD[1], instance.mLOD[0], decomp, - getFMP()->childGetValue("upload_skin").asBoolean(), - getFMP()->childGetValue("upload_joints").asBoolean(), + mFMP->childGetValue("upload_skin").asBoolean(), + mFMP->childGetValue("upload_joints").asBoolean(), TRUE); cost += gMeshRepo.calcResourceCost(ret); @@ -2119,13 +2120,13 @@ U32 LLModelPreview::calcResourceCost() } } - //getFMP()->childSetTextArg(info_name[LLModel::LOD_PHYSICS], "[HULLS]", llformat("%d",num_hulls)); - //getFMP()->childSetTextArg(info_name[LLModel::LOD_PHYSICS], "[POINTS]", llformat("%d",num_points)); - getFMP()->childSetTextArg("streaming cost", "[COST]", llformat("%.3f", streaming_cost)); - F32 scale = getFMP()->childGetValue("import_scale").asReal()*2.f; - getFMP()->childSetTextArg("import_dimensions", "[X]", llformat("%.3f", mPreviewScale[0]*scale)); - getFMP()->childSetTextArg("import_dimensions", "[Y]", llformat("%.3f", mPreviewScale[1]*scale)); - getFMP()->childSetTextArg("import_dimensions", "[Z]", llformat("%.3f", mPreviewScale[2]*scale)); + //mFMP->childSetTextArg(info_name[LLModel::LOD_PHYSICS], "[HULLS]", llformat("%d",num_hulls)); + //mFMP->childSetTextArg(info_name[LLModel::LOD_PHYSICS], "[POINTS]", llformat("%d",num_points)); + mFMP->childSetTextArg("streaming cost", "[COST]", llformat("%.3f", streaming_cost)); + F32 scale = mFMP->childGetValue("import_scale").asReal()*2.f; + mFMP->childSetTextArg("import_dimensions", "[X]", llformat("%.3f", mPreviewScale[0]*scale)); + mFMP->childSetTextArg("import_dimensions", "[Y]", llformat("%.3f", mPreviewScale[1]*scale)); + mFMP->childSetTextArg("import_dimensions", "[Z]", llformat("%.3f", mPreviewScale[2]*scale)); updateStatusMessages(); @@ -2134,15 +2135,17 @@ U32 LLModelPreview::calcResourceCost() void LLModelPreview::rebuildUploadData() { + assert_main_thread(); + mUploadData.clear(); mTextureSet.clear(); //fill uploaddata instance vectors from scene data - std::string requested_name = getFMP()->getChild("description_form")->getValue().asString(); + std::string requested_name = mFMP->getChild("description_form")->getValue().asString(); - LLSpinCtrl* scale_spinner = getFMP()->getChild("import_scale"); + LLSpinCtrl* scale_spinner = mFMP->getChild("import_scale"); if (!scale_spinner) { @@ -2158,7 +2161,7 @@ void LLModelPreview::rebuildUploadData() if ( mBaseScene.size() > 0 ) { - getFMP()->childEnable("ok_btn"); + mFMP->childEnable("ok_btn"); } for (LLModelLoader::scene::iterator iter = mBaseScene.begin(); iter != mBaseScene.end(); ++iter) @@ -2226,7 +2229,7 @@ void LLModelPreview::rebuildUploadData() } //refill "layer" combo in physics panel - LLComboBox* combo_box = getFMP()->getChild("physics_layer"); + LLComboBox* combo_box = mFMP->getChild("physics_layer"); if (combo_box) { S32 current = combo_box->getCurrentIndex(); @@ -2256,6 +2259,8 @@ void LLModelPreview::clearModel(S32 lod) void LLModelPreview::loadModel(std::string filename, S32 lod) { + assert_main_thread(); + LLMutexLock lock(this); if (mModelLoader) @@ -2270,7 +2275,7 @@ void LLModelPreview::loadModel(std::string filename, S32 lod) { // this is the initial file picking. Close the whole floater // if we don't have a base model to show for high LOD. - getFMP()->closeFloater(false); + mFMP->closeFloater(false); } mLoading = false; @@ -2288,35 +2293,37 @@ void LLModelPreview::loadModel(std::string filename, S32 lod) mModelLoader->start(); - getFMP()->childSetTextArg("status", "[STATUS]", getFMP()->getString("status_reading_file")); + mFMP->childSetTextArg("status", "[STATUS]", mFMP->getString("status_reading_file")); setPreviewLOD(lod); if ( mModelLoader->getLoadState() == LLModelLoader::ERROR_PARSING ) { - getFMP()->childDisable("ok_btn"); + mFMP->childDisable("ok_btn"); } if (lod == mPreviewLOD) { - getFMP()->childSetText("lod_file", mLODFile[mPreviewLOD]); + mFMP->childSetText("lod_file", mLODFile[mPreviewLOD]); } else if (lod == LLModel::LOD_PHYSICS) { - getFMP()->childSetText("physics_file", mLODFile[lod]); + mFMP->childSetText("physics_file", mLODFile[lod]); } - getFMP()->openFloater(); + mFMP->openFloater(); } void LLModelPreview::setPhysicsFromLOD(S32 lod) { + assert_main_thread(); + if (lod >= 0 && lod <= 3) { mModel[LLModel::LOD_PHYSICS] = mModel[lod]; mScene[LLModel::LOD_PHYSICS] = mScene[lod]; mLODFile[LLModel::LOD_PHYSICS].clear(); - getFMP()->childSetText("physics_file", mLODFile[LLModel::LOD_PHYSICS]); + mFMP->childSetText("physics_file", mLODFile[LLModel::LOD_PHYSICS]); mVertexBuffer[LLModel::LOD_PHYSICS].clear(); rebuildUploadData(); refresh(); @@ -2365,15 +2372,10 @@ void LLModelPreview::clearGLODGroup() } } -LLFloater* LLModelPreview::getFMP() +void LLModelPreview::loadModelCallback(S32 lod) { - // Shouldn't be accessing this outside the main UI thread. assert_main_thread(); - return mFMP; -} -void LLModelPreview::loadModelCallback(S32 lod) -{ //NOT the main thread LLMutexLock lock(this); if (!mModelLoader) { @@ -2428,6 +2430,8 @@ void LLModelPreview::resetPreviewTarget() void LLModelPreview::generateNormals() { + assert_main_thread(); + S32 which_lod = mPreviewLOD; @@ -2437,7 +2441,7 @@ void LLModelPreview::generateNormals() return; } - F32 angle_cutoff = getFMP()->childGetValue("crease_angle").asReal(); + F32 angle_cutoff = mFMP->childGetValue("crease_angle").asReal(); angle_cutoff *= DEG_TO_RAD; @@ -2731,20 +2735,20 @@ void LLModelPreview::genLODs(S32 which_lod) U32 lod_mode = 0; - LLCtrlSelectionInterface* iface = getFMP()->childGetSelectionInterface("lod_mode"); + LLCtrlSelectionInterface* iface = mFMP->childGetSelectionInterface("lod_mode"); if (iface) { lod_mode = iface->getFirstSelectedIndex(); } - F32 lod_error_threshold = getFMP()->childGetValue("lod_error_threshold").asReal(); + F32 lod_error_threshold = mFMP->childGetValue("lod_error_threshold").asReal(); if (lod_mode == 0) { lod_mode = GLOD_TRIANGLE_BUDGET; if (which_lod != -1) { - limit = getFMP()->childGetValue("lod_triangle_limit").asInteger(); + limit = mFMP->childGetValue("lod_triangle_limit").asInteger(); } } else @@ -2754,7 +2758,7 @@ void LLModelPreview::genLODs(S32 which_lod) U32 build_operator = 0; - iface = getFMP()->childGetSelectionInterface("build_operator"); + iface = mFMP->childGetSelectionInterface("build_operator"); if (iface) { build_operator = iface->getFirstSelectedIndex(); @@ -2770,7 +2774,7 @@ void LLModelPreview::genLODs(S32 which_lod) } U32 queue_mode=0; - iface = getFMP()->childGetSelectionInterface("queue_mode"); + iface = mFMP->childGetSelectionInterface("queue_mode"); if (iface) { queue_mode = iface->getFirstSelectedIndex(); @@ -2791,7 +2795,7 @@ void LLModelPreview::genLODs(S32 which_lod) U32 border_mode = 0; - iface = getFMP()->childGetSelectionInterface("border_mode"); + iface = mFMP->childGetSelectionInterface("border_mode"); if (iface) { border_mode = iface->getFirstSelectedIndex(); @@ -2825,7 +2829,7 @@ void LLModelPreview::genLODs(S32 which_lod) object_dirty = true; } - F32 share_tolerance = getFMP()->childGetValue("share_tolerance").asReal(); + F32 share_tolerance = mFMP->childGetValue("share_tolerance").asReal(); if (share_tolerance != mBuildShareTolerance) { mBuildShareTolerance = share_tolerance; @@ -3070,6 +3074,8 @@ void LLModelPreview::genLODs(S32 which_lod) void LLModelPreview::updateStatusMessages() { + assert_main_thread(); + //triangle/vertex/submesh count for each mesh asset for each lod std::vector tris[LLModel::NUM_LODS]; std::vector verts[LLModel::NUM_LODS]; @@ -3116,9 +3122,9 @@ void LLModelPreview::updateStatusMessages() } - getFMP()->childSetTextArg("submeshes_info", "[SUBMESHES]", llformat("%d", total_submeshes[LLModel::LOD_HIGH])); + mFMP->childSetTextArg("submeshes_info", "[SUBMESHES]", llformat("%d", total_submeshes[LLModel::LOD_HIGH])); - std::string mesh_status_na = getFMP()->getString("mesh_status_na"); + std::string mesh_status_na = mFMP->getString("mesh_status_na"); S32 upload_status[LLModel::LOD_HIGH+1]; @@ -3132,8 +3138,8 @@ void LLModelPreview::updateStatusMessages() if (total_tris[lod] > 0) { - getFMP()->childSetText(lod_triangles_name[lod], llformat("%d", total_tris[lod])); - getFMP()->childSetText(lod_vertices_name[lod], llformat("%d", total_verts[lod])); + mFMP->childSetText(lod_triangles_name[lod], llformat("%d", total_tris[lod])); + mFMP->childSetText(lod_vertices_name[lod], llformat("%d", total_verts[lod])); } else { @@ -3154,8 +3160,8 @@ void LLModelPreview::updateStatusMessages() } } - getFMP()->childSetText(lod_triangles_name[lod], mesh_status_na); - getFMP()->childSetText(lod_vertices_name[lod], mesh_status_na); + mFMP->childSetText(lod_triangles_name[lod], mesh_status_na); + mFMP->childSetText(lod_vertices_name[lod], mesh_status_na); } const U32 lod_high = LLModel::LOD_HIGH; @@ -3190,7 +3196,7 @@ void LLModelPreview::updateStatusMessages() } } - LLIconCtrl* icon = getFMP()->getChild(lod_icon_name[lod]); + LLIconCtrl* icon = mFMP->getChild(lod_icon_name[lod]); LLUIImagePtr img = LLUI::getUIImage(lod_status_image[upload_status[lod]]); icon->setVisible(true); icon->setImage(img); @@ -3202,8 +3208,8 @@ void LLModelPreview::updateStatusMessages() if (lod == mPreviewLOD) { - getFMP()->childSetText("lod_status_message_text", getFMP()->getString(message)); - icon = getFMP()->getChild("lod_status_message_icon"); + mFMP->childSetText("lod_status_message_text", mFMP->getString(message)); + icon = mFMP->getChild("lod_status_message_icon"); icon->setImage(img); } } @@ -3212,18 +3218,18 @@ void LLModelPreview::updateStatusMessages() if ( upload_ok && !errorStateFromLoader ) { - getFMP()->childEnable("ok_btn"); + mFMP->childEnable("ok_btn"); } else { - getFMP()->childDisable("ok_btn"); + mFMP->childDisable("ok_btn"); } //add up physics triangles etc S32 start = 0; S32 end = mModel[LLModel::LOD_PHYSICS].size(); - S32 idx = getFMP()->childGetValue("physics_layer").asInteger(); + S32 idx = mFMP->childGetValue("physics_layer").asInteger(); if (idx >= 0 && idx < mModel[LLModel::LOD_PHYSICS].size()) { @@ -3262,22 +3268,22 @@ void LLModelPreview::updateStatusMessages() if (phys_tris > 0) { - getFMP()->childSetTextArg("physics_triangles", "[TRIANGLES]", llformat("%d", phys_tris)); + mFMP->childSetTextArg("physics_triangles", "[TRIANGLES]", llformat("%d", phys_tris)); } else { - getFMP()->childSetTextArg("physics_triangles", "[TRIANGLES]", mesh_status_na); + mFMP->childSetTextArg("physics_triangles", "[TRIANGLES]", mesh_status_na); } if (phys_hulls > 0) { - getFMP()->childSetTextArg("physics_hulls", "[HULLS]", llformat("%d", phys_hulls)); - getFMP()->childSetTextArg("physics_points", "[POINTS]", llformat("%d", phys_points)); + mFMP->childSetTextArg("physics_hulls", "[HULLS]", llformat("%d", phys_hulls)); + mFMP->childSetTextArg("physics_points", "[POINTS]", llformat("%d", phys_points)); } else { - getFMP()->childSetTextArg("physics_hulls", "[HULLS]", mesh_status_na); - getFMP()->childSetTextArg("physics_points", "[POINTS]", mesh_status_na); + mFMP->childSetTextArg("physics_hulls", "[HULLS]", mesh_status_na); + mFMP->childSetTextArg("physics_points", "[POINTS]", mesh_status_na); } LLFloaterModelPreview* fmp = LLFloaterModelPreview::sInstance; @@ -3322,43 +3328,43 @@ void LLModelPreview::updateStatusMessages() const U32 num_file_controls = sizeof(file_controls)/sizeof(char*); //enable/disable controls based on radio groups - if (getFMP()->childGetValue("lod_from_file").asBoolean()) + if (mFMP->childGetValue("lod_from_file").asBoolean()) { for (U32 i = 0; i < num_file_controls; ++i) { - getFMP()->childEnable(file_controls[i]); + mFMP->childEnable(file_controls[i]); } for (U32 i = 0; i < num_lod_controls; ++i) { - getFMP()->childDisable(lod_controls[i]); + mFMP->childDisable(lod_controls[i]); } } - else if (getFMP()->childGetValue("lod_auto_generate").asBoolean()) + else if (mFMP->childGetValue("lod_auto_generate").asBoolean()) { for (U32 i = 0; i < num_file_controls; ++i) { - getFMP()->childDisable(file_controls[i]); + mFMP->childDisable(file_controls[i]); } for (U32 i = 0; i < num_lod_controls; ++i) { - getFMP()->childEnable(lod_controls[i]); + mFMP->childEnable(lod_controls[i]); } //if (threshold) { U32 lod_mode = 0; - LLCtrlSelectionInterface* iface = getFMP()->childGetSelectionInterface("lod_mode"); + LLCtrlSelectionInterface* iface = mFMP->childGetSelectionInterface("lod_mode"); if (iface) { lod_mode = iface->getFirstSelectedIndex(); } - LLSpinCtrl* threshold = getFMP()->getChild("lod_error_threshold"); - LLSpinCtrl* limit = getFMP()->getChild("lod_triangle_limit"); + LLSpinCtrl* threshold = mFMP->getChild("lod_error_threshold"); + LLSpinCtrl* limit = mFMP->getChild("lod_triangle_limit"); limit->setMaxValue(mMaxTriangleLimit); limit->setValue(total_tris[mPreviewLOD]); @@ -3381,12 +3387,12 @@ void LLModelPreview::updateStatusMessages() { // "None" is chosen for (U32 i = 0; i < num_file_controls; ++i) { - getFMP()->childDisable(file_controls[i]); + mFMP->childDisable(file_controls[i]); } for (U32 i = 0; i < num_lod_controls; ++i) { - getFMP()->childDisable(lod_controls[i]); + mFMP->childDisable(lod_controls[i]); } if (!mModel[mPreviewLOD].empty()) @@ -3401,17 +3407,17 @@ void LLModelPreview::updateStatusMessages() } } - if (getFMP()->childGetValue("physics_load_from_file").asBoolean()) + if (mFMP->childGetValue("physics_load_from_file").asBoolean()) { - getFMP()->childDisable("physics_lod_combo"); - getFMP()->childEnable("physics_file"); - getFMP()->childEnable("physics_browse"); + mFMP->childDisable("physics_lod_combo"); + mFMP->childEnable("physics_file"); + mFMP->childEnable("physics_browse"); } else { - getFMP()->childEnable("physics_lod_combo"); - getFMP()->childDisable("physics_file"); - getFMP()->childDisable("physics_browse"); + mFMP->childEnable("physics_lod_combo"); + mFMP->childDisable("physics_file"); + mFMP->childDisable("physics_browse"); } } @@ -3636,8 +3642,8 @@ BOOL LLModelPreview::render() } bool has_skin_weights = false; - bool upload_skin = getFMP()->childGetValue("upload_skin").asBoolean(); - bool upload_joints = getFMP()->childGetValue("upload_joints").asBoolean(); + bool upload_skin = mFMP->childGetValue("upload_skin").asBoolean(); + bool upload_joints = mFMP->childGetValue("upload_joints").asBoolean(); for (LLModelLoader::scene::iterator iter = mScene[mPreviewLOD].begin(); iter != mScene[mPreviewLOD].end(); ++iter) { @@ -3659,11 +3665,11 @@ BOOL LLModelPreview::render() fmp->enableViewOption("show_skin_weight"); fmp->setViewOptionEnabled("show_joint_positions", skin_weight); } - getFMP()->childEnable("upload_skin"); + mFMP->childEnable("upload_skin"); } else { - getFMP()->childDisable("upload_skin"); + mFMP->childDisable("upload_skin"); if (fmp) { fmp->setViewOption("show_skin_weight", false); @@ -3675,23 +3681,23 @@ BOOL LLModelPreview::render() if (upload_skin && !has_skin_weights) { //can't upload skin weights if model has no skin weights - getFMP()->childSetValue("upload_skin", false); + mFMP->childSetValue("upload_skin", false); upload_skin = false; } if (!upload_skin && upload_joints) { //can't upload joints if not uploading skin weights - getFMP()->childSetValue("upload_joints", false); + mFMP->childSetValue("upload_joints", false); upload_joints = false; } - getFMP()->childSetEnabled("upload_joints", upload_skin); + mFMP->childSetEnabled("upload_joints", upload_skin); - F32 explode = getFMP()->childGetValue("physics_explode").asReal(); + F32 explode = mFMP->childGetValue("physics_explode").asReal(); glClear(GL_DEPTH_BUFFER_BIT); - LLRect preview_rect = getFMP()->getChildView("preview_panel")->getRect(); + LLRect preview_rect = mFMP->getChildView("preview_panel")->getRect(); F32 aspect = (F32) preview_rect.getWidth()/preview_rect.getHeight(); LLViewerCamera::getInstance()->setAspect(aspect); @@ -3745,7 +3751,7 @@ BOOL LLModelPreview::render() //genLODs(); } - S32 physics_idx = getFMP()->childGetValue("physics_layer").asInteger(); + S32 physics_idx = mFMP->childGetValue("physics_layer").asInteger(); if (!mModel[mPreviewLOD].empty()) { @@ -4125,10 +4131,10 @@ void LLModelPreview::setPreviewLOD(S32 lod) { mPreviewLOD = lod; - LLComboBox* combo_box = getFMP()->getChild("preview_lod_combo"); + LLComboBox* combo_box = mFMP->getChild("preview_lod_combo"); combo_box->setCurrentByIndex((NUM_LOD-1)-mPreviewLOD); // combo box list of lods is in reverse order - getFMP()->childSetTextArg("lod_table_footer", "[DETAIL]", getFMP()->getString(lod_name[mPreviewLOD])); - getFMP()->childSetText("lod_file", mLODFile[mPreviewLOD]); + mFMP->childSetTextArg("lod_table_footer", "[DETAIL]", mFMP->getString(lod_name[mPreviewLOD])); + mFMP->childSetText("lod_file", mLODFile[mPreviewLOD]); LLColor4 highlight_color = LLUIColorTable::instance().getColor("MeshImportTableHighlightColor"); LLColor4 normal_color = LLUIColorTable::instance().getColor("MeshImportTableNormalColor"); @@ -4137,10 +4143,10 @@ void LLModelPreview::setPreviewLOD(S32 lod) { const LLColor4& color = (i == lod) ? highlight_color : normal_color; - getFMP()->childSetColor(lod_status_name[i], color); - getFMP()->childSetColor(lod_label_name[i], color); - getFMP()->childSetColor(lod_triangles_name[i], color); - getFMP()->childSetColor(lod_vertices_name[i], color); + mFMP->childSetColor(lod_status_name[i], color); + mFMP->childSetColor(lod_label_name[i], color); + mFMP->childSetColor(lod_triangles_name[i], color); + mFMP->childSetColor(lod_vertices_name[i], color); } } refresh(); @@ -4150,6 +4156,8 @@ void LLModelPreview::setPreviewLOD(S32 lod) //static void LLFloaterModelPreview::onBrowseLOD(void* data) { + assert_main_thread(); + LLFloaterModelPreview* mp = (LLFloaterModelPreview*) data; mp->loadModel(mp->mModelPreview->mPreviewLOD); } @@ -4157,6 +4165,8 @@ void LLFloaterModelPreview::onBrowseLOD(void* data) //static void LLFloaterModelPreview::onUpload(void* user_data) { + assert_main_thread(); + LLFloaterModelPreview* mp = (LLFloaterModelPreview*) user_data; mp->mModelPreview->rebuildUploadData(); diff --git a/indra/newview/llfloatermodelpreview.h b/indra/newview/llfloatermodelpreview.h index 2c89927203..ae4cf18fee 100755 --- a/indra/newview/llfloatermodelpreview.h +++ b/indra/newview/llfloatermodelpreview.h @@ -279,7 +279,6 @@ class LLModelPreview : public LLViewerDynamicTexture, public LLMutex friend class LLPhysicsDecomp; LLFloater* mFMP; - LLFloater* getFMP(); BOOL mNeedsUpdate; bool mDirty; -- cgit v1.2.3 From e79bd15fe0828bf057cc4e2b0b8f7e102b1de432 Mon Sep 17 00:00:00 2001 From: "Nyx (Neal Orman)" Date: Mon, 20 Dec 2010 18:14:44 -0500 Subject: SH-68 WIP adding debug switch for performance testing Adding functionality to a previously added debug switch. This will allow me to have UI, etc turned off and thus not impact framerates when testing for rendering features. --- indra/newview/llviewercontrol.cpp | 40 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'indra') diff --git a/indra/newview/llviewercontrol.cpp b/indra/newview/llviewercontrol.cpp index 8991c21518..dadda29416 100644 --- a/indra/newview/llviewercontrol.cpp +++ b/indra/newview/llviewercontrol.cpp @@ -128,6 +128,45 @@ static bool handleSetShaderChanged(const LLSD& newvalue) return true; } +static bool handleRenderPerfTestChanged(const LLSD& newvalue) +{ + bool status = !newvalue.asBoolean(); + if (!status) + { + gPipeline.clearRenderTypeMask(LLPipeline::RENDER_TYPE_WL_SKY, + LLPipeline::RENDER_TYPE_GROUND, + LLPipeline::RENDER_TYPE_TERRAIN, + LLPipeline::RENDER_TYPE_GRASS, + LLPipeline::RENDER_TYPE_TREE, + LLPipeline::RENDER_TYPE_WATER, + LLPipeline::RENDER_TYPE_PASS_GRASS, + LLPipeline::RENDER_TYPE_HUD, + LLPipeline::RENDER_TYPE_PARTICLES, + LLPipeline::RENDER_TYPE_CLOUDS, + LLPipeline::RENDER_TYPE_HUD_PARTICLES, + LLPipeline::END_RENDER_TYPES); + gPipeline.setRenderDebugFeatureControl(LLPipeline::RENDER_DEBUG_FEATURE_UI, false); + } + else + { + gPipeline.setRenderTypeMask(LLPipeline::RENDER_TYPE_WL_SKY, + LLPipeline::RENDER_TYPE_GROUND, + LLPipeline::RENDER_TYPE_TERRAIN, + LLPipeline::RENDER_TYPE_GRASS, + LLPipeline::RENDER_TYPE_TREE, + LLPipeline::RENDER_TYPE_WATER, + LLPipeline::RENDER_TYPE_PASS_GRASS, + LLPipeline::RENDER_TYPE_HUD, + LLPipeline::RENDER_TYPE_PARTICLES, + LLPipeline::RENDER_TYPE_CLOUDS, + LLPipeline::RENDER_TYPE_HUD_PARTICLES, + LLPipeline::END_RENDER_TYPES); + gPipeline.setRenderDebugFeatureControl(LLPipeline::RENDER_DEBUG_FEATURE_UI, true); + } + + return true; +} + bool handleRenderTransparentWaterChanged(const LLSD& newvalue) { LLWorld::getInstance()->updateWaterObjects(); @@ -565,6 +604,7 @@ void settings_setup_listeners() gSavedSettings.getControl("RenderShadowDetail")->getSignal()->connect(boost::bind(&handleSetShaderChanged, _2)); gSavedSettings.getControl("RenderDeferredSSAO")->getSignal()->connect(boost::bind(&handleSetShaderChanged, _2)); gSavedSettings.getControl("RenderDeferredGI")->getSignal()->connect(boost::bind(&handleSetShaderChanged, _2)); + gSavedSettings.getControl("RenderPerformanceTest")->getSignal()->connect(boost::bind(&handleRenderPerfTestChanged, _2)); gSavedSettings.getControl("TextureMemory")->getSignal()->connect(boost::bind(&handleVideoMemoryChanged, _2)); gSavedSettings.getControl("AuditTexture")->getSignal()->connect(boost::bind(&handleAuditTextureChanged, _2)); gSavedSettings.getControl("ChatFontSize")->getSignal()->connect(boost::bind(&handleChatFontSizeChanged, _2)); -- cgit v1.2.3 From e7f3f3bdbbec310030209e09d389cd434adb7991 Mon Sep 17 00:00:00 2001 From: leyla_linden Date: Mon, 20 Dec 2010 17:32:05 -0800 Subject: model upload wizard - added optimization and state changes --- indra/newview/llfloatermodelpreview.cpp | 15 +- indra/newview/llfloatermodelpreview.h | 4 +- indra/newview/llfloatermodelwizard.cpp | 141 +++- indra/newview/llfloatermodelwizard.h | 38 +- .../skins/default/xui/en/floater_model_wizard.xml | 832 +++++++++++++++------ 5 files changed, 774 insertions(+), 256 deletions(-) (limited to 'indra') diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp index f9648b0e3b..85d0ae02cf 100755 --- a/indra/newview/llfloatermodelpreview.cpp +++ b/indra/newview/llfloatermodelpreview.cpp @@ -107,7 +107,6 @@ const S32 PREVIEW_RESIZE_HANDLE_SIZE = S32(RESIZE_HANDLE_WIDTH * OO_SQRT2) + PRE const S32 PREVIEW_HPAD = PREVIEW_RESIZE_HANDLE_SIZE; const S32 PREF_BUTTON_HEIGHT = 16 + 7 + 16; const S32 PREVIEW_TEXTURE_HEIGHT = 300; -const S32 NUM_LOD = 4; void drawBoxOutline(const LLVector3& pos, const LLVector3& size); @@ -476,12 +475,10 @@ void LLFloaterModelPreview::onPreviewLODCommit(LLUICtrl* ctrl, void* userdata) S32 which_mode = 0; - LLCtrlSelectionInterface* iface = fp->childGetSelectionInterface("preview_lod_combo"); - if (iface) - { - which_mode = iface->getFirstSelectedIndex(); - } - which_mode = (NUM_LOD-1)-which_mode; // combo box list of lods is in reverse order + LLComboBox* combo = (LLComboBox*) ctrl; + + which_mode = (NUM_LOD-1)-combo->getFirstSelectedIndex(); // combo box list of lods is in reverse order + fp->mModelPreview->setPreviewLOD(which_mode); } @@ -2699,7 +2696,7 @@ bool LLModelPreview::containsRiggedAsset( void ) } return false; } -void LLModelPreview::genLODs(S32 which_lod) +void LLModelPreview::genLODs(S32 which_lod, U32 decimation) { if (mBaseModel.empty()) { @@ -2916,7 +2913,7 @@ void LLModelPreview::genLODs(S32 which_lod) { if (lod < start) { - triangle_count /= 3; + triangle_count /= decimation; } } else diff --git a/indra/newview/llfloatermodelpreview.h b/indra/newview/llfloatermodelpreview.h index ae4cf18fee..64b220d86b 100755 --- a/indra/newview/llfloatermodelpreview.h +++ b/indra/newview/llfloatermodelpreview.h @@ -52,6 +52,8 @@ class domTranslate; class LLMenuButton; class LLToggleableMenu; +const S32 NUM_LOD = 4; + class LLModelLoader : public LLThread { public: @@ -258,7 +260,7 @@ class LLModelPreview : public LLViewerDynamicTexture, public LLMutex void clearModel(S32 lod); void loadModel(std::string filename, S32 lod); void loadModelCallback(S32 lod); - void genLODs(S32 which_lod = -1); + void genLODs(S32 which_lod = -1, U32 decimation = 3); void generateNormals(); void consolidate(); void clearMaterials(); diff --git a/indra/newview/llfloatermodelwizard.cpp b/indra/newview/llfloatermodelwizard.cpp index 79c29ef017..6a92e43d1a 100644 --- a/indra/newview/llfloatermodelwizard.cpp +++ b/indra/newview/llfloatermodelwizard.cpp @@ -28,19 +28,71 @@ #include "llviewerprecompiledheaders.h" +#include "llbutton.h" #include "lldrawable.h" +#include "llcombobox.h" #include "llfloater.h" #include "llfloatermodelwizard.h" #include "llfloatermodelpreview.h" #include "llfloaterreg.h" +#include "llslider.h" +static const std::string stateNames[]={ + "choose_file", + "optimize", + "physics", + "review", + "upload"}; LLFloaterModelWizard::LLFloaterModelWizard(const LLSD& key) : LLFloater(key) { } +void LLFloaterModelWizard::setState(int state) +{ + mState = state; + setButtons(state); + + for(size_t t=0; t(stateNames[t]+"_panel"); + if (view) + { + view->setVisible(state == (int) t ? TRUE : FALSE); + } + } + + if (state == OPTIMIZE) + { + mModelPreview->genLODs(-1); + } +} + +void LLFloaterModelWizard::setButtons(int state) +{ + for(size_t i=0; i(stateNames[i]+"_btn"); + + if (i < state) + { + button->setEnabled(TRUE); + button->setToggleState(FALSE); + } + else if (i == state) + { + button->setEnabled(TRUE); + button->setToggleState(TRUE); + } + else + { + button->setEnabled(FALSE); + } + } +} + void LLFloaterModelWizard::loadModel() { mModelPreview->mLoading = TRUE; @@ -48,6 +100,30 @@ void LLFloaterModelWizard::loadModel() (new LLMeshFilePicker(mModelPreview, 3))->getFile(); } +void LLFloaterModelWizard::onClickCancel() +{ + closeFloater(); +} + +void LLFloaterModelWizard::onClickBack() +{ + setState(llmax((int) CHOOSE_FILE, mState-1)); +} + +void LLFloaterModelWizard::onClickNext() +{ + setState(llmin((int) UPLOAD, mState+1)); +} + +bool LLFloaterModelWizard::onEnableNext() +{ + return true; +} + +bool LLFloaterModelWizard::onEnableBack() +{ + return true; +} BOOL LLFloaterModelWizard::postBuild() { @@ -56,7 +132,20 @@ BOOL LLFloaterModelWizard::postBuild() childSetValue("import_scale", (F32) 0.67335826); getChild("browse")->setCommitCallback(boost::bind(&LLFloaterModelWizard::loadModel, this)); + getChild("cancel")->setCommitCallback(boost::bind(&LLFloaterModelWizard::onClickCancel, this)); + getChild("back")->setCommitCallback(boost::bind(&LLFloaterModelWizard::onClickBack, this)); + getChild("next")->setCommitCallback(boost::bind(&LLFloaterModelWizard::onClickNext, this)); + childSetCommitCallback("preview_lod_combo", onPreviewLODCommit, this); + getChild("accuracy_slider")->setCommitCallback(boost::bind(&LLFloaterModelWizard::onAccuracyPerformance, this, _2)); + + childSetAction("ok_btn", onUpload, this); + LLUICtrl::EnableCallbackRegistry::ScopedRegistrar enable_registrar; + + enable_registrar.add("Next.OnEnable", boost::bind(&LLFloaterModelWizard::onEnableNext, this)); + enable_registrar.add("Back.OnEnable", boost::bind(&LLFloaterModelWizard::onEnableBack, this)); + + mPreviewRect = preview_panel->getRect(); mModelPreview = new LLModelPreview(512, 512, this); @@ -64,9 +153,55 @@ BOOL LLFloaterModelWizard::postBuild() center(); + setState(CHOOSE_FILE); + + childSetTextArg("import_dimensions", "[X]", LLStringUtil::null); + childSetTextArg("import_dimensions", "[Y]", LLStringUtil::null); + childSetTextArg("import_dimensions", "[Z]", LLStringUtil::null); + return TRUE; } +void LLFloaterModelWizard::onUpload(void* user_data) +{ + LLFloaterModelWizard* mp = (LLFloaterModelWizard*) user_data; + + mp->mModelPreview->rebuildUploadData(); + + gMeshRepo.uploadModel(mp->mModelPreview->mUploadData, mp->mModelPreview->mPreviewScale, + mp->childGetValue("upload_textures").asBoolean(), mp->childGetValue("upload_skin"), mp->childGetValue("upload_joints")); + + mp->closeFloater(false); +} + + +void LLFloaterModelWizard::onAccuracyPerformance(const LLSD& data) +{ + int val = (int) data.asInteger(); + + mModelPreview->genLODs(-1, NUM_LOD-val); + + mModelPreview->refresh(); +} + +void LLFloaterModelWizard::onPreviewLODCommit(LLUICtrl* ctrl, void* userdata) +{ + LLFloaterModelWizard *fp =(LLFloaterModelWizard *)userdata; + + if (!fp->mModelPreview) + { + return; + } + + S32 which_mode = 0; + + LLComboBox* combo = (LLComboBox*) ctrl; + + which_mode = (NUM_LOD-1)-combo->getFirstSelectedIndex(); // combo box list of lods is in reverse order + + fp->mModelPreview->setPreviewLOD(which_mode); +} + void LLFloaterModelWizard::draw() { LLFloater::draw(); @@ -74,14 +209,14 @@ void LLFloaterModelWizard::draw() mModelPreview->update(); - if (mModelPreview && mModelPreview->mModelLoader) + if (mModelPreview) { gGL.color3f(1.f, 1.f, 1.f); gGL.getTexUnit(0)->bind(mModelPreview); - - LLView* preview_panel = getChild("preview_panel"); + LLView *view = getChild(stateNames[mState]+"_panel"); + LLView* preview_panel = view->getChild("preview_panel"); LLRect rect = preview_panel->getRect(); if (rect != mPreviewRect) diff --git a/indra/newview/llfloatermodelwizard.h b/indra/newview/llfloatermodelwizard.h index c766697d47..ab69d93b63 100644 --- a/indra/newview/llfloatermodelwizard.h +++ b/indra/newview/llfloatermodelwizard.h @@ -35,24 +35,36 @@ public: virtual ~LLFloaterModelWizard() {}; /*virtual*/ BOOL postBuild(); void draw(); - void loadModel(); - //void onSave(); - //void onReset(); - //void onCancel(); - ///*virtual*/ void onOpen(const LLSD& key); private: - + enum EWizardState + { + CHOOSE_FILE = 0, + OPTIMIZE, + PHYSICS, + REVIEW, + UPLOAD + }; + + void setState(int state); + void setButtons(int state); + void onClickCancel(); + void onClickBack(); + void onClickNext(); + bool onEnableNext(); + bool onEnableBack(); + void loadModel(); + static void onPreviewLODCommit(LLUICtrl*,void*); + void onAccuracyPerformance(const LLSD& data); + static void onUpload(void* data); + LLModelPreview* mModelPreview; LLRect mPreviewRect; + int mState; + + + }; -/* -namespace LLFloaterDisplayNameUtil -{ - // Register with LLFloaterReg - void registerFloater(); -} -*/ #endif diff --git a/indra/newview/skins/default/xui/en/floater_model_wizard.xml b/indra/newview/skins/default/xui/en/floater_model_wizard.xml index 4a4b8075c8..18dc33a23a 100644 --- a/indra/newview/skins/default/xui/en/floater_model_wizard.xml +++ b/indra/newview/skins/default/xui/en/floater_model_wizard.xml @@ -1,230 +1,602 @@ - - - - - - Model Preview: - - - - - - - - Dimensions (meters): - - - X: [X] | Y: [Y] | Z: [Z] - - - - Note: -Advanced users familiar with 3d content creation tools may prefer to use the Advanced Mesh Import window. - - - + + Model Preview: + + + + + + Dimensions (meters): + + + X: [X] | Y: [Y] | Z: [Z] + + + Note: + Advanced users familiar with 3d content creation tools may prefer to use the Advanced Mesh Import window. + + + + High + + + Medium + + + Lowest + + + Low + + + + + + + + + + Optimize + + + + This wizard is optimizing your model. This may take several minutes. To stop the process click the back button + + + Generating Level of Detail + + + Generate Level of Detail: High + + Generate Level of Detail: Medium + + Generate Level of Detail: Low + + Generate Level of Detail: Lowest + + + + Model Preview: + + + + High + + + Medium + + + Lowest + + + Low + + + + + Performance Accuracy + + + | | | + + + + + + + + + + Physics + + + + The wizard will create a physical shape, which determines how the object interacts with other objects and avatars. Set the slider to the detail level most appropriate for how your object will be used: + + + + + + + + + Review + + + + Review the details below then click. Upload to upload your model. Your L$ balance will be charged when you click Upload. + + + + + + + + + + + Upload Complete! + + + + Congratulations! Your model has been sucessfully uploaded. You will find the model in the Objects folder in your inventory. + + +