From 513ac361b13b081a13f1f6dde1c0c34c4eb41b3a Mon Sep 17 00:00:00 2001 From: Brad Linden Date: Wed, 26 Apr 2023 17:32:19 -0700 Subject: Got things to compile again after DRTVWR-559 & DRTVWR-539 merge. removing dead code and references to members that don't exist anymore --- indra/newview/llperfstats.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'indra/newview/llperfstats.cpp') diff --git a/indra/newview/llperfstats.cpp b/indra/newview/llperfstats.cpp index 7ff363c3c1..e37c2a4479 100644 --- a/indra/newview/llperfstats.cpp +++ b/indra/newview/llperfstats.cpp @@ -443,6 +443,7 @@ namespace LLPerfStats { // 1 - hack the water to opaque. all non opaque have a significant hit, this is a big boost for (arguably) a minor visual hit. // the other reflection options make comparatively little change and if this overshoots we'll be stepping back up later +# if 0 // TODO RenderReflectionDetail went away if(LLPipeline::RenderReflectionDetail != -2) { LLPerfStats::tunables.updateReflectionDetail(-2); @@ -450,6 +451,7 @@ namespace LLPerfStats return; } else // deliberately "else" here so we only do one of these in any given frame +#endif { // step down the DD by 10m per update auto new_dd = (LLPipeline::RenderFarClip - DD_STEP > tunables.userMinDrawDistance)?(LLPipeline::RenderFarClip - DD_STEP) : tunables.userMinDrawDistance; @@ -539,7 +541,9 @@ namespace LLPerfStats if( (tot_frame_time_raw * 1.5) < target_frame_time_raw ) { // if everything else is "max" and we have >50% headroom let's knock the water quality up a notch at a time. +# if 0 // RenderReflectionDetail went away LLPerfStats::tunables.updateReflectionDetail( std::min(LLPipeline::RenderReflectionDetail + 1, tunables.userTargetReflections) ); +#endif } } } -- cgit v1.3 From 10b2ec92ec74176422fa8c6013dee1036eed57c5 Mon Sep 17 00:00:00 2001 From: Brad Linden Date: Thu, 27 Apr 2023 18:02:48 -0700 Subject: More merge cleanup after DRTVWR-559 & DRTVWR-539 merge. (thanks Ansariel) --- indra/newview/app_settings/settings.xml | 11 ----------- indra/newview/featuretable.txt | 5 ----- indra/newview/featuretable_mac.txt | 5 ----- indra/newview/llappviewer.cpp | 2 ++ indra/newview/llfloaterperformance.cpp | 2 -- indra/newview/llperfstats.cpp | 2 -- indra/newview/llperfstats.h | 2 -- indra/newview/llviewercontrol.cpp | 8 +------- 8 files changed, 3 insertions(+), 34 deletions(-) (limited to 'indra/newview/llperfstats.cpp') diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index d21b686ec8..54246da92b 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -16953,17 +16953,6 @@ Value 256.0 - UserTargetReflections - - Comment - Set by auto tune floater on build - Persist - 0 - Type - S32 - Value - 4 - PerfStatsCaptureEnabled Comment diff --git a/indra/newview/featuretable.txt b/indra/newview/featuretable.txt index a5b6b01d5a..79d92adcc2 100644 --- a/indra/newview/featuretable.txt +++ b/indra/newview/featuretable.txt @@ -113,7 +113,6 @@ RenderReflectionProbeLevel 1 0 list LowMid RenderAnisotropic 1 0 RenderAvatarLODFactor 1 0.5 -RenderAvatarMaxNonImpostors 1 5 RenderAvatarMaxComplexity 1 100000 RenderAvatarPhysicsLODFactor 1 0.75 RenderAvatarMaxNonImpostors 1 5 @@ -144,7 +143,6 @@ RenderReflectionProbeLevel 1 1 list Mid RenderAnisotropic 1 1 RenderAvatarLODFactor 1 1.0 -RenderAvatarMaxNonImpostors 1 7 RenderAvatarMaxComplexity 1 200000 RenderAvatarPhysicsLODFactor 1 1.0 RenderAvatarMaxNonImpostors 1 7 @@ -175,7 +173,6 @@ RenderReflectionProbeLevel 1 2 list MidHigh RenderAnisotropic 1 1 RenderAvatarLODFactor 1 1.0 -RenderAvatarMaxNonImpostors 1 9 RenderAvatarMaxComplexity 1 250000 RenderAvatarPhysicsLODFactor 1 1.0 RenderAvatarMaxNonImpostors 1 9 @@ -206,7 +203,6 @@ RenderReflectionProbeLevel 1 2 list High RenderAnisotropic 1 1 RenderAvatarLODFactor 1 1.0 -RenderAvatarMaxNonImpostors 1 11 RenderAvatarMaxComplexity 1 300000 RenderAvatarPhysicsLODFactor 1 1.0 RenderAvatarMaxNonImpostors 1 11 @@ -237,7 +233,6 @@ RenderReflectionProbeLevel 1 3 list HighUltra RenderAnisotropic 1 1 RenderAvatarLODFactor 1 1.0 -RenderAvatarMaxNonImpostors 1 16 RenderAvatarMaxComplexity 1 350000 RenderAvatarPhysicsLODFactor 1 1.0 RenderAvatarMaxNonImpostors 1 16 diff --git a/indra/newview/featuretable_mac.txt b/indra/newview/featuretable_mac.txt index 56242ce23d..72deabd9f1 100644 --- a/indra/newview/featuretable_mac.txt +++ b/indra/newview/featuretable_mac.txt @@ -111,7 +111,6 @@ RenderReflectionProbeLevel 1 0 list LowMid RenderAnisotropic 1 0 RenderAvatarLODFactor 1 0.5 -RenderAvatarMaxNonImpostors 1 5 RenderAvatarMaxComplexity 1 100000 RenderAvatarPhysicsLODFactor 1 0.75 RenderAvatarMaxNonImpostors 1 5 @@ -142,7 +141,6 @@ RenderReflectionProbeLevel 1 1 list Mid RenderAnisotropic 1 1 RenderAvatarLODFactor 1 1.0 -RenderAvatarMaxNonImpostors 1 7 RenderAvatarMaxComplexity 1 200000 RenderAvatarPhysicsLODFactor 1 1.0 RenderAvatarMaxNonImpostors 1 7 @@ -173,7 +171,6 @@ RenderReflectionProbeLevel 1 2 list MidHigh RenderAnisotropic 1 1 RenderAvatarLODFactor 1 1.0 -RenderAvatarMaxNonImpostors 1 9 RenderAvatarMaxComplexity 1 250000 RenderAvatarPhysicsLODFactor 1 1.0 RenderAvatarMaxNonImpostors 1 9 @@ -204,7 +201,6 @@ RenderReflectionProbeLevel 1 2 list High RenderAnisotropic 1 1 RenderAvatarLODFactor 1 1.0 -RenderAvatarMaxNonImpostors 1 11 RenderAvatarMaxComplexity 1 300000 RenderAvatarPhysicsLODFactor 1 1.0 RenderAvatarMaxNonImpostors 1 11 @@ -265,7 +261,6 @@ RenderReflectionProbeLevel 1 3 list Ultra RenderAnisotropic 1 1 RenderAvatarLODFactor 1 1.0 -RenderAvatarMaxNonImpostors 1 16 RenderAvatarPhysicsLODFactor 1 1.0 RenderAvatarMaxNonImpostors 1 16 RenderFarClip 1 256 diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index dc2ffdb26a..b2349e9f74 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -1442,6 +1442,8 @@ bool LLAppViewer::doFrame() LL_PROFILE_ZONE_NAMED_CATEGORY_APP("df suspend") // give listeners a chance to run llcoro::suspend(); + // if one of our coroutines threw an uncaught exception, rethrow it now + LLCoros::instance().rethrow(); } } diff --git a/indra/newview/llfloaterperformance.cpp b/indra/newview/llfloaterperformance.cpp index c221da539c..3321374f65 100644 --- a/indra/newview/llfloaterperformance.cpp +++ b/indra/newview/llfloaterperformance.cpp @@ -142,8 +142,6 @@ BOOL LLFloaterPerformance::postBuild() mMaxARTChangedSignal = gSavedSettings.getControl("RenderAvatarMaxART")->getCommitSignal()->connect(boost::bind(&LLFloaterPerformance::updateMaxRenderTime, this)); mNearbyPanel->getChild("RenderAvatarMaxART")->setCommitCallback(boost::bind(&LLFloaterPerformance::updateMaxRenderTime, this)); - // store the current setting as the users desired reflection detail and DD - //gSavedSettings.setS32("UserTargetReflections", LLPipeline::RenderReflectionDetail); if(!LLPerfStats::tunables.userAutoTuneEnabled) { gSavedSettings.setF32("AutoTuneRenderFarClipTarget", LLPipeline::RenderFarClip); diff --git a/indra/newview/llperfstats.cpp b/indra/newview/llperfstats.cpp index e37c2a4479..c63aae2089 100644 --- a/indra/newview/llperfstats.cpp +++ b/indra/newview/llperfstats.cpp @@ -75,7 +75,6 @@ namespace LLPerfStats if( tuningFlag & UserAutoTuneEnabled ){ gSavedSettings.setBOOL("AutoTuneFPS", userAutoTuneEnabled); }; if( tuningFlag & UserAutoTuneLock ){ gSavedSettings.setBOOL("AutoTuneLock", userAutoTuneLock); }; if( tuningFlag & UserTargetFPS ){ gSavedSettings.setU32("TargetFPS", userTargetFPS); }; - if( tuningFlag & UserTargetReflections ){ gSavedSettings.setS32("UserTargetReflections", userTargetReflections); }; // Note: The Max ART slider is logarithmic and thus we have an intermediate proxy value if( tuningFlag & UserARTCutoff ){ gSavedSettings.setF32("RenderAvatarMaxART", userARTCutoffSliderValue); }; resetChanges(); @@ -122,7 +121,6 @@ namespace LLPerfStats LLPerfStats::tunables.userFPSTuningStrategy = gSavedSettings.getU32("TuningFPSStrategy"); LLPerfStats::tunables.userTargetFPS = gSavedSettings.getU32("TargetFPS"); LLPerfStats::tunables.vsyncEnabled = gSavedSettings.getBOOL("RenderVSyncEnable"); - LLPerfStats::tunables.userTargetReflections = gSavedSettings.getS32("UserTargetReflections"); LLPerfStats::tunables.userAutoTuneLock = gSavedSettings.getBOOL("AutoTuneLock") && gSavedSettings.getU32("KeepAutoTuneLock"); diff --git a/indra/newview/llperfstats.h b/indra/newview/llperfstats.h index 3289f396f1..dbb88a141d 100644 --- a/indra/newview/llperfstats.h +++ b/indra/newview/llperfstats.h @@ -117,7 +117,6 @@ namespace LLPerfStats static constexpr U32 UserAutoTuneEnabled{256}; static constexpr U32 UserTargetFPS{512}; static constexpr U32 UserARTCutoff{1024}; - static constexpr U32 UserTargetReflections{2048}; static constexpr U32 UserAutoTuneLock{4096}; U32 tuningFlag{0}; // bit mask for changed settings @@ -151,7 +150,6 @@ namespace LLPerfStats void updateUserARTCutoffSlider(F32 nv){userARTCutoffSliderValue=nv; tuningFlag |= UserARTCutoff;}; void updateUserAutoTuneEnabled(bool nv){userAutoTuneEnabled=nv; tuningFlag |= UserAutoTuneEnabled;}; void updateUserAutoTuneLock(bool nv){userAutoTuneLock=nv; tuningFlag |= UserAutoTuneLock;}; - void updateUserTargetReflections(S32 nv){userTargetReflections=nv; tuningFlag |= UserTargetReflections;}; void resetChanges(){tuningFlag=Nothing;}; void initialiseFromSettings(); diff --git a/indra/newview/llviewercontrol.cpp b/indra/newview/llviewercontrol.cpp index f197722698..faeebc33ee 100644 --- a/indra/newview/llviewercontrol.cpp +++ b/indra/newview/llviewercontrol.cpp @@ -638,12 +638,6 @@ void handleUserTargetDrawDistanceChanged(const LLSD& newValue) LLPerfStats::tunables.userTargetDrawDistance = newval; } -void handleUserTargetReflectionsChanged(const LLSD& newValue) -{ - const auto newval = gSavedSettings.getS32("UserTargetReflections"); - LLPerfStats::tunables.userTargetReflections = newval; -} - void handlePerformanceStatsEnabledChanged(const LLSD& newValue) { const auto newval = gSavedSettings.getBOOL("PerfStatsCaptureEnabled"); @@ -736,6 +730,7 @@ void settings_setup_listeners() setting_setup_signal_listener(gSavedSettings, "RenderReflectionProbeDetail", handleReflectionProbeDetailChanged); setting_setup_signal_listener(gSavedSettings, "RenderReflectionsEnabled", handleReflectionProbeDetailChanged); setting_setup_signal_listener(gSavedSettings, "RenderScreenSpaceReflections", handleReflectionProbeDetailChanged); + setting_setup_signal_listener(gSavedSettings, "RenderShadowDetail", handleSetShaderChanged); setting_setup_signal_listener(gSavedSettings, "RenderDeferredSSAO", handleSetShaderChanged); setting_setup_signal_listener(gSavedSettings, "RenderPerformanceTest", handleRenderPerfTestChanged); setting_setup_signal_listener(gSavedSettings, "ChatFontSize", handleChatFontSizeChanged); @@ -838,7 +833,6 @@ void settings_setup_listeners() setting_setup_signal_listener(gSavedSettings, "AutoTuneLock", handleAutoTuneLockChanged); setting_setup_signal_listener(gSavedSettings, "RenderAvatarMaxART", handleRenderAvatarMaxARTChanged); setting_setup_signal_listener(gSavedSettings, "PerfStatsCaptureEnabled", handlePerformanceStatsEnabledChanged); - setting_setup_signal_listener(gSavedSettings, "UserTargetReflections", handleUserTargetReflectionsChanged); setting_setup_signal_listener(gSavedSettings, "AutoTuneRenderFarClipTarget", handleUserTargetDrawDistanceChanged); setting_setup_signal_listener(gSavedSettings, "AutoTuneImpostorFarAwayDistance", handleUserImpostorDistanceChanged); setting_setup_signal_listener(gSavedSettings, "AutoTuneImpostorByDistEnabled", handleUserImpostorByDistEnabledChanged); -- cgit v1.3 From 334d71e9107ae3c4d35b181f2ed6e5c9ff1de519 Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Mon, 1 May 2023 17:05:09 -0500 Subject: SL-19656 Rewrite avatar and attachment render metrics to not interfere with render pipe and be representative of actual render cost instead of driver synchronization time. * SL-19656 Rewrite avatar and attachment render metrics to not interfere with render pipe and be representative of actual render cost instead of driver synchronization time. * SL-19656 Remove now dead code (trackAttachments et al). * SL-19656 Fix for crash on GL <= 3.2 --- indra/newview/lldrawpool.cpp | 70 ---------- indra/newview/lldrawpoolalpha.cpp | 36 ----- indra/newview/lldrawpoolavatar.cpp | 5 +- indra/newview/lldrawpoolbump.cpp | 36 ----- indra/newview/lldrawpoolmaterials.cpp | 14 -- indra/newview/llfloaterperformance.cpp | 246 ++++++++++++++++++++------------- indra/newview/llfloaterperformance.h | 4 +- indra/newview/llperfstats.cpp | 13 +- indra/newview/llperfstats.h | 73 +--------- indra/newview/llviewerjointmesh.cpp | 10 -- indra/newview/llviewerobject.h | 4 + indra/newview/llvoavatar.cpp | 3 +- indra/newview/llvoavatar.h | 39 +++++- indra/newview/llvovolume.cpp | 22 +-- indra/newview/llworld.cpp | 8 +- indra/newview/llworld.h | 4 +- indra/newview/pipeline.cpp | 125 +++++++++++++++-- indra/newview/pipeline.h | 3 +- 18 files changed, 324 insertions(+), 391 deletions(-) (limited to 'indra/newview/llperfstats.cpp') diff --git a/indra/newview/lldrawpool.cpp b/indra/newview/lldrawpool.cpp index 34d8f8b9ce..187e290066 100644 --- a/indra/newview/lldrawpool.cpp +++ b/indra/newview/lldrawpool.cpp @@ -52,8 +52,6 @@ #include "llglcommonfunc.h" #include "llvoavatar.h" #include "llviewershadermgr.h" -#include "llperfstats.h" - S32 LLDrawPool::sNumDrawPools = 0; @@ -387,22 +385,11 @@ void LLRenderPass::renderGroup(LLSpatialGroup* group, U32 type, bool texture) LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; LLSpatialGroup::drawmap_elem_t& draw_info = group->mDrawMap[type]; - std::unique_ptr ratPtr{}; // Perf stats for (LLSpatialGroup::drawmap_elem_t::iterator k = draw_info.begin(); k != draw_info.end(); ++k) { LLDrawInfo *pparams = *k; if (pparams) { -#if 0 // TODO SL-19656 figure out how to reenable trackAttachments() - if(pparams->mFace) - { - LLViewerObject* vobj = pparams->mFace->getViewerObject(); - if(vobj->isAttachment()) - { - trackAttachments(vobj, false, &ratPtr); - } - } -#endif pushBatch(*pparams, texture); } } @@ -415,23 +402,11 @@ void LLRenderPass::renderRiggedGroup(LLSpatialGroup* group, U32 type, bool textu LLVOAvatar* lastAvatar = nullptr; U64 lastMeshId = 0; - std::unique_ptr ratPtr{}; // Perf stats for (LLSpatialGroup::drawmap_elem_t::iterator k = draw_info.begin(); k != draw_info.end(); ++k) { LLDrawInfo* pparams = *k; if (pparams) { -#if 0 // TODO SL-19656 figure out how to reenable trackAttachments() - if(pparams->mFace) - { - LLViewerObject* vobj = pparams->mFace->getViewerObject(); - if(vobj->isAttachment()) - { - trackAttachments( vobj, true ,&ratPtr); - } - } -#endif - if (lastAvatar != pparams->mAvatar || lastMeshId != pparams->mSkinInfo->mHash) { uploadMatrixPalette(*pparams); @@ -447,7 +422,6 @@ void LLRenderPass::renderRiggedGroup(LLSpatialGroup* group, U32 type, bool textu void LLRenderPass::pushBatches(U32 type, bool texture, bool batch_textures) { LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; - std::unique_ptr ratPtr{}; auto* begin = gPipeline.beginRenderMap(type); auto* end = gPipeline.endRenderMap(type); for (LLCullResult::drawinfo_iterator i = begin; i != end; ) @@ -455,16 +429,6 @@ void LLRenderPass::pushBatches(U32 type, bool texture, bool batch_textures) LLDrawInfo* pparams = *i; LLCullResult::increment_iterator(i, end); -#if 0 // TODO SL-19656 figure out how to reenable trackAttachments() - if(pparams->mFace) - { - LLViewerObject* vobj = pparams->mFace->getViewerObject(); - if(vobj->isAttachment()) - { - trackAttachments( vobj, false, &ratPtr); - } - } -#endif pushBatch(*pparams, texture, batch_textures); } } @@ -476,23 +440,11 @@ void LLRenderPass::pushRiggedBatches(U32 type, bool texture, bool batch_textures U64 lastMeshId = 0; auto* begin = gPipeline.beginRenderMap(type); auto* end = gPipeline.endRenderMap(type); - std::unique_ptr ratPtr{}; // Perf stats for (LLCullResult::drawinfo_iterator i = begin; i != end; ) { LLDrawInfo* pparams = *i; LLCullResult::increment_iterator(i, end); -#if 0 // TODO SL-19656 figure out how to reenable trackAttachments() - if(pparams->mFace) - { - LLViewerObject* vobj = pparams->mFace->getViewerObject(); - if(vobj->isAttachment()) - { - trackAttachments( vobj, true, &ratPtr); - } - } -#endif - if (pparams->mAvatar.notNull() && (lastAvatar != pparams->mAvatar || lastMeshId != pparams->mSkinInfo->mHash)) { uploadMatrixPalette(*pparams); @@ -507,23 +459,12 @@ void LLRenderPass::pushRiggedBatches(U32 type, bool texture, bool batch_textures void LLRenderPass::pushMaskBatches(U32 type, bool texture, bool batch_textures) { LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; - std::unique_ptr ratPtr{}; auto* begin = gPipeline.beginRenderMap(type); auto* end = gPipeline.endRenderMap(type); for (LLCullResult::drawinfo_iterator i = begin; i != end; ) { LLDrawInfo* pparams = *i; LLCullResult::increment_iterator(i, end); -#if 0 // TODO SL-19656 figure out how to reenable trackAttachments() - if((*pparams).mFace) - { - LLViewerObject* vobj = (*pparams).mFace->getViewerObject(); - if(vobj->isAttachment()) - { - trackAttachments( vobj, false, &ratPtr); - } - } -#endif LLGLSLShader::sCurBoundShaderPtr->setMinimumAlpha(pparams->mAlphaMaskCutoff); pushBatch(*pparams, texture, batch_textures); } @@ -534,7 +475,6 @@ void LLRenderPass::pushRiggedMaskBatches(U32 type, bool texture, bool batch_text LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; LLVOAvatar* lastAvatar = nullptr; U64 lastMeshId = 0; - std::unique_ptr ratPtr{}; auto* begin = gPipeline.beginRenderMap(type); auto* end = gPipeline.endRenderMap(type); for (LLCullResult::drawinfo_iterator i = begin; i != end; ) @@ -544,16 +484,6 @@ void LLRenderPass::pushRiggedMaskBatches(U32 type, bool texture, bool batch_text LLCullResult::increment_iterator(i, end); llassert(pparams); -#if 0 // TODO SL-19656 figure out how to reenable trackAttachments() - if((*pparams).mFace) - { - LLViewerObject* vobj = (*pparams).mFace->getViewerObject(); - if(vobj->isAttachment()) - { - trackAttachments( vobj, true, &ratPtr); - } - } -#endif if (LLGLSLShader::sCurBoundShaderPtr) { diff --git a/indra/newview/lldrawpoolalpha.cpp b/indra/newview/lldrawpoolalpha.cpp index da4c963a97..404039189b 100644 --- a/indra/newview/lldrawpoolalpha.cpp +++ b/indra/newview/lldrawpoolalpha.cpp @@ -49,7 +49,6 @@ #include "llspatialpartition.h" #include "llglcommonfunc.h" #include "llvoavatar.h" -#include "llperfstats.h" #include "llenvironment.h" @@ -349,22 +348,10 @@ void LLDrawPoolAlpha::renderAlphaHighlight(U32 mask) { LLSpatialGroup::drawmap_elem_t& draw_info = group->mDrawMap[LLRenderPass::PASS_ALPHA+pass]; // <-- hacky + pass to use PASS_ALPHA_RIGGED on second pass - std::unique_ptr ratPtr{}; // Render time Stats collection for (LLSpatialGroup::drawmap_elem_t::iterator k = draw_info.begin(); k != draw_info.end(); ++k) { LLDrawInfo& params = **k; -# if 0 // TODO SL-19656 figure out how to reenable trackAttachments() - if(params.mFace) - { - LLViewerObject* vobj = (LLViewerObject *)params.mFace->getViewerObject(); - if(vobj->isAttachment()) - { - trackAttachments( vobj, params.mFace->isState(LLFace::RIGGED), &ratPtr ); - } - } -#endif - bool rigged = (params.mAvatar != nullptr); gHighlightProgram.bind(rigged); gGL.diffuseColor4f(1, 0, 0, 1); @@ -548,17 +535,9 @@ void LLDrawPoolAlpha::renderRiggedEmissives(std::vector& emissives) LLVOAvatar* lastAvatar = nullptr; U64 lastMeshId = 0; - std::unique_ptr ratPtr{}; // Render time Stats collection for (LLDrawInfo* draw : emissives) { LL_PROFILE_ZONE_NAMED_CATEGORY_DRAWPOOL("Emissives"); -# if 0 // TODO SL-19656 figure out how to reenable trackAttachments() - auto vobj = draw->mFace?draw->mFace->getViewerObject():nullptr; - if(vobj && vobj->isAttachment()) - { - trackAttachments( vobj, draw->mFace->isState(LLFace::RIGGED), &ratPtr ); - } -#endif bool tex_setup = TexSetup(draw, false); if (lastAvatar != draw->mAvatar || lastMeshId != draw->mSkinInfo->mHash) @@ -687,7 +666,6 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask, bool depth_only, bool rigged) LLSpatialGroup::drawmap_elem_t& draw_info = rigged ? group->mDrawMap[LLRenderPass::PASS_ALPHA_RIGGED] : group->mDrawMap[LLRenderPass::PASS_ALPHA]; - std::unique_ptr ratPtr{}; // Render time Stats collection for (LLSpatialGroup::drawmap_elem_t::iterator k = draw_info.begin(); k != draw_info.end(); ++k) { LLDrawInfo& params = **k; @@ -700,18 +678,6 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask, bool depth_only, bool rigged) LLRenderPass::applyModelMatrix(params); -# if 0 // TODO SL-19656 figure out how to reenable trackAttachments() - if(params.mFace) - { - LLViewerObject* vobj = (LLViewerObject *)params.mFace->getViewerObject(); - - if(vobj->isAttachment()) - { - trackAttachments( vobj, params.mFace->isState(LLFace::RIGGED), &ratPtr ); - } - } -#endif - LLMaterial* mat = NULL; LLGLTFMaterial *gltf_mat = params.mGLTFMaterial; @@ -905,8 +871,6 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask, bool depth_only, bool rigged) } } - ratPtr.reset(); // force the final batch to terminate to avoid double counting on the subsidiary batches for FB and Emmissives - // render emissive faces into alpha channel for bloom effects if (!depth_only) { diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp index c398087b20..19b23609a6 100644 --- a/indra/newview/lldrawpoolavatar.cpp +++ b/indra/newview/lldrawpoolavatar.cpp @@ -52,7 +52,6 @@ #include "llviewerpartsim.h" #include "llviewercontrol.h" // for gSavedSettings #include "llviewertexturelist.h" -#include "llperfstats.h" static U32 sShaderLevel = 0; @@ -370,9 +369,8 @@ void LLDrawPoolAvatar::renderShadow(S32 pass) { return; } - LLPerfStats::RecordAvatarTime T(avatarp->getID(), LLPerfStats::StatType_t::RENDER_SHADOWS); - LLVOAvatar::AvatarOverallAppearance oa = avatarp->getOverallAppearance(); + LLVOAvatar::AvatarOverallAppearance oa = avatarp->getOverallAppearance(); BOOL impostor = !LLPipeline::sImpostorRender && avatarp->isImpostor(); // no shadows if the shadows are causing this avatar to breach the limit. if (avatarp->isTooSlow() || impostor || (oa == LLVOAvatar::AOA_INVISIBLE)) @@ -741,7 +739,6 @@ void LLDrawPoolAvatar::renderAvatars(LLVOAvatar* single_avatar, S32 pass) { return; } - LLPerfStats::RecordAvatarTime T(avatarp->getID(), LLPerfStats::StatType_t::RENDER_GEOMETRY); if (!single_avatar && !avatarp->isFullyLoaded() ) { diff --git a/indra/newview/lldrawpoolbump.cpp b/indra/newview/lldrawpoolbump.cpp index a548740ec4..9ed776f49e 100644 --- a/indra/newview/lldrawpoolbump.cpp +++ b/indra/newview/lldrawpoolbump.cpp @@ -49,7 +49,6 @@ #include "llspatialpartition.h" #include "llviewershadermgr.h" #include "llmodel.h" -#include "llperfstats.h" //#include "llimagebmp.h" //#include "../tools/imdebug/imdebug.h" @@ -406,19 +405,10 @@ void LLDrawPoolBump::renderGroup(LLSpatialGroup* group, U32 type, bool texture = { LLSpatialGroup::drawmap_elem_t& draw_info = group->mDrawMap[type]; - std::unique_ptr ratPtr{}; for (LLSpatialGroup::drawmap_elem_t::iterator k = draw_info.begin(); k != draw_info.end(); ++k) { LLDrawInfo& params = **k; -#if 0 // TODO SL-19656 figure out how to reenable trackAttachments() - LLViewerObject* vobj = (LLViewerObject *)params.mFace->getViewerObject(); - if( vobj && vobj->isAttachment() ) - { - trackAttachments( vobj, params.mFace->isState(LLFace::RIGGED), &ratPtr ); - } -#endif - applyModelMatrix(params); params.mVertexBuffer->setBuffer(); @@ -568,25 +558,12 @@ void LLDrawPoolBump::renderDeferred(S32 pass) LLVOAvatar* avatar = nullptr; U64 skin = 0; - std::unique_ptr ratPtr{}; for (LLCullResult::drawinfo_iterator i = begin; i != end; ) { LLDrawInfo& params = **i; LLCullResult::increment_iterator(i, end); -#if 0 // TODO SL-19656 figure out how to reenable trackAttachments() - if(params.mFace) - { - LLViewerObject* vobj = (LLViewerObject *)params.mFace->getViewerObject(); - - if(vobj && vobj->isAttachment()) - { - trackAttachments( vobj, params.mFace->isState(LLFace::RIGGED), &ratPtr ); - } - } -#endif - LLGLSLShader::sCurBoundShaderPtr->setMinimumAlpha(params.mAlphaMaskCutoff); LLDrawPoolBump::bindBumpMap(params, bump_channel); @@ -1215,23 +1192,10 @@ void LLDrawPoolBump::pushBumpBatches(U32 type) LLCullResult::drawinfo_iterator begin = gPipeline.beginRenderMap(type); LLCullResult::drawinfo_iterator end = gPipeline.endRenderMap(type); - std::unique_ptr ratPtr{}; for (LLCullResult::drawinfo_iterator i = begin; i != end; ++i) { LLDrawInfo& params = **i; -#if 0 // TODO SL-19656 figure out how to reenable trackAttachments() - if(params.mFace) - { - LLViewerObject* vobj = (LLViewerObject *)params.mFace->getViewerObject(); - - if( vobj && vobj->isAttachment() ) - { - trackAttachments( vobj, params.mFace->isState(LLFace::RIGGED), &ratPtr ); - } - } -#endif - if (LLDrawPoolBump::bindBumpMap(params)) { if (mRigged) diff --git a/indra/newview/lldrawpoolmaterials.cpp b/indra/newview/lldrawpoolmaterials.cpp index e025651cce..6a7e05ac74 100644 --- a/indra/newview/lldrawpoolmaterials.cpp +++ b/indra/newview/lldrawpoolmaterials.cpp @@ -32,7 +32,6 @@ #include "pipeline.h" #include "llglcommonfunc.h" #include "llvoavatar.h" -#include "llperfstats.h" LLDrawPoolMaterials::LLDrawPoolMaterials() : LLRenderPass(LLDrawPool::POOL_MATERIALS) @@ -151,7 +150,6 @@ void LLDrawPoolMaterials::renderDeferred(S32 pass) LLCullResult::drawinfo_iterator begin = gPipeline.beginRenderMap(type); LLCullResult::drawinfo_iterator end = gPipeline.endRenderMap(type); - std::unique_ptr ratPtr{}; F32 lastIntensity = 0.f; F32 lastFullbright = 0.f; F32 lastMinimumAlpha = 0.f; @@ -201,18 +199,6 @@ void LLDrawPoolMaterials::renderDeferred(S32 pass) LLCullResult::increment_iterator(i, end); -#if 0 // TODO SL-19656 figure out how to reenable trackAttachments() - if(params.mFace) - { - LLViewerObject* vobj = (LLViewerObject *)params.mFace->getViewerObject(); - - if( vobj && vobj->isAttachment() ) - { - trackAttachments( vobj, params.mFace->isState(LLFace::RIGGED), &ratPtr ); - } - } -#endif - if (specular > -1 && params.mSpecColor != lastSpecular) { lastSpecular = params.mSpecColor; diff --git a/indra/newview/llfloaterperformance.cpp b/indra/newview/llfloaterperformance.cpp index 3321374f65..25b744a5ab 100644 --- a/indra/newview/llfloaterperformance.cpp +++ b/indra/newview/llfloaterperformance.cpp @@ -57,8 +57,6 @@ const S32 BAR_RIGHT_PAD = 5; const S32 BAR_BOTTOM_PAD = 9; constexpr auto AvType {LLPerfStats::ObjType_t::OT_AVATAR}; -constexpr auto AttType {LLPerfStats::ObjType_t::OT_ATTACHMENT}; -constexpr auto HudType {LLPerfStats::ObjType_t::OT_HUD}; class LLExceptionsContextMenu : public LLListContextMenu { @@ -83,8 +81,7 @@ protected: LLFloaterPerformance::LLFloaterPerformance(const LLSD& key) : LLFloater(key), - mUpdateTimer(new LLTimer()), - mNearbyMaxComplexity(0) + mUpdateTimer(new LLTimer()) { mContextMenu = new LLExceptionsContextMenu(this); } @@ -247,47 +244,82 @@ void LLFloaterPerformance::populateHUDList() mHUDList->clearRows(); mHUDList->updateColumns(true); - hud_complexity_list_t complexity_list = LLHUDRenderNotifier::getInstance()->getHUDComplexityList(); - - hud_complexity_list_t::iterator iter = complexity_list.begin(); - hud_complexity_list_t::iterator end = complexity_list.end(); - - auto huds_max_render_time_raw = LLPerfStats::StatsRecorder::getMax(HudType, LLPerfStats::StatType_t::RENDER_GEOMETRY); - for (iter = complexity_list.begin(); iter != end; ++iter) - { - LLHUDComplexity hud_object_complexity = *iter; - - auto hud_render_time_raw = LLPerfStats::StatsRecorder::get(HudType, hud_object_complexity.objectId, LLPerfStats::StatType_t::RENDER_GEOMETRY); - - LLSD item; - item["special_id"] = hud_object_complexity.objectId; - item["target"] = LLNameListCtrl::SPECIAL; - LLSD& row = item["columns"]; - row[0]["column"] = "complex_visual"; - row[0]["type"] = "bar"; - LLSD& value = row[0]["value"]; - value["ratio"] = (F32)hud_render_time_raw / huds_max_render_time_raw; - value["bottom"] = BAR_BOTTOM_PAD; - value["left_pad"] = BAR_LEFT_PAD; - value["right_pad"] = BAR_RIGHT_PAD; - - row[1]["column"] = "complex_value"; - row[1]["type"] = "text"; - row[1]["value"] = llformat( "%.f", llmax(LLPerfStats::raw_to_us(hud_render_time_raw), (double)1)); - row[1]["font"]["name"] = "SANSSERIF"; - - row[2]["column"] = "name"; - row[2]["type"] = "text"; - row[2]["value"] = hud_object_complexity.objectName; - row[2]["font"]["name"] = "SANSSERIF"; - - LLScrollListItem* obj = mHUDList->addElement(item); - if (obj) + LLVOAvatar* avatar = gAgentAvatarp; + + gPipeline.profileAvatar(avatar, true); + + LLVOAvatar::attachment_map_t::iterator iter; + LLVOAvatar::attachment_map_t::iterator begin = avatar->mAttachmentPoints.begin(); + LLVOAvatar::attachment_map_t::iterator end = avatar->mAttachmentPoints.end(); + + // get max gpu render time of all attachments + F32 max_gpu_time = -1.f; + + for (iter = begin; iter != end; ++iter) + { + LLViewerJointAttachment* attachment = iter->second; + for (LLViewerJointAttachment::attachedobjs_vec_t::iterator attachment_iter = attachment->mAttachedObjects.begin(); + attachment_iter != attachment->mAttachedObjects.end(); + ++attachment_iter) + { + LLViewerObject* attached_object = attachment_iter->get(); + if (attached_object && attached_object->isHUDAttachment()) + { + max_gpu_time = llmax(max_gpu_time, attached_object->mGPURenderTime); + } + } + } + + + for (iter = begin; iter != end; ++iter) + { + if (!iter->second) { - LLScrollListText* value_text = dynamic_cast(obj->getColumn(1)); - if (value_text) + continue; + } + + LLViewerJointAttachment* attachment = iter->second; + for (LLViewerJointAttachment::attachedobjs_vec_t::iterator attachment_iter = attachment->mAttachedObjects.begin(); + attachment_iter != attachment->mAttachedObjects.end(); + ++attachment_iter) + { + LLViewerObject* attached_object = attachment_iter->get(); + if (attached_object && attached_object->isHUDAttachment()) { - value_text->setAlignment(LLFontGL::HCENTER); + F32 gpu_time = attached_object->mGPURenderTime; + + LLSD item; + item["special_id"] = attached_object->getID(); + item["target"] = LLNameListCtrl::SPECIAL; + LLSD& row = item["columns"]; + row[0]["column"] = "complex_visual"; + row[0]["type"] = "bar"; + LLSD& value = row[0]["value"]; + value["ratio"] = gpu_time / max_gpu_time; + value["bottom"] = BAR_BOTTOM_PAD; + value["left_pad"] = BAR_LEFT_PAD; + value["right_pad"] = BAR_RIGHT_PAD; + + row[1]["column"] = "complex_value"; + row[1]["type"] = "text"; + // show gpu time in us + row[1]["value"] = llformat("%.f", gpu_time * 1000.f); + row[1]["font"]["name"] = "SANSSERIF"; + + row[2]["column"] = "name"; + row[2]["type"] = "text"; + row[2]["value"] = attached_object->getAttachmentItemName(); + row[2]["font"]["name"] = "SANSSERIF"; + + LLScrollListItem* obj = mHUDList->addElement(item); + if (obj) + { + LLScrollListText* value_text = dynamic_cast(obj->getColumn(1)); + if (value_text) + { + value_text->setAlignment(LLFontGL::HCENTER); + } + } } } } @@ -303,50 +335,82 @@ void LLFloaterPerformance::populateObjectList() mObjectList->clearRows(); mObjectList->updateColumns(true); - object_complexity_list_t complexity_list = LLAvatarRenderNotifier::getInstance()->getObjectComplexityList(); + LLVOAvatar* avatar = gAgentAvatarp; - object_complexity_list_t::iterator iter = complexity_list.begin(); - object_complexity_list_t::iterator end = complexity_list.end(); + gPipeline.profileAvatar(avatar, true); - // for consistency we lock the buffer while we build the list. In theory this is uncontended as the buffer should only toggle on end of frame - { - std::lock_guard guard{ LLPerfStats::bufferToggleLock }; - auto att_max_render_time_raw = LLPerfStats::StatsRecorder::getMax(AttType, LLPerfStats::StatType_t::RENDER_COMBINED); + LLVOAvatar::attachment_map_t::iterator iter; + LLVOAvatar::attachment_map_t::iterator begin = avatar->mAttachmentPoints.begin(); + LLVOAvatar::attachment_map_t::iterator end = avatar->mAttachmentPoints.end(); - for (iter = complexity_list.begin(); iter != end; ++iter) - { - LLObjectComplexity object_complexity = *iter; + // get max gpu render time of all attachments + F32 max_gpu_time = -1.f; - auto attach_render_time_raw = LLPerfStats::StatsRecorder::get(AttType, object_complexity.objectId, LLPerfStats::StatType_t::RENDER_COMBINED); - LLSD item; - item["special_id"] = object_complexity.objectId; - item["target"] = LLNameListCtrl::SPECIAL; - LLSD& row = item["columns"]; - row[0]["column"] = "complex_visual"; - row[0]["type"] = "bar"; - LLSD& value = row[0]["value"]; - value["ratio"] = ((F32)attach_render_time_raw) / att_max_render_time_raw; - value["bottom"] = BAR_BOTTOM_PAD; - value["left_pad"] = BAR_LEFT_PAD; - value["right_pad"] = BAR_RIGHT_PAD; - - row[1]["column"] = "complex_value"; - row[1]["type"] = "text"; - row[1]["value"] = llformat("%.f", llmax(LLPerfStats::raw_to_us(attach_render_time_raw), (double)1)); - row[1]["font"]["name"] = "SANSSERIF"; + for (iter = begin; iter != end; ++iter) + { + LLViewerJointAttachment* attachment = iter->second; + for (LLViewerJointAttachment::attachedobjs_vec_t::iterator attachment_iter = attachment->mAttachedObjects.begin(); + attachment_iter != attachment->mAttachedObjects.end(); + ++attachment_iter) + { + LLViewerObject* attached_object = attachment_iter->get(); + if (attached_object && !attached_object->isHUDAttachment()) + { + max_gpu_time = llmax(max_gpu_time, attached_object->mGPURenderTime); + } + } + } - row[2]["column"] = "name"; - row[2]["type"] = "text"; - row[2]["value"] = object_complexity.objectName; - row[2]["font"]["name"] = "SANSSERIF"; + { + for (iter = begin; iter != end; ++iter) + { + if (!iter->second) + { + continue; + } - LLScrollListItem* obj = mObjectList->addElement(item); - if (obj) + LLViewerJointAttachment* attachment = iter->second; + for (LLViewerJointAttachment::attachedobjs_vec_t::iterator attachment_iter = attachment->mAttachedObjects.begin(); + attachment_iter != attachment->mAttachedObjects.end(); + ++attachment_iter) { - LLScrollListText* value_text = dynamic_cast(obj->getColumn(1)); - if (value_text) + LLViewerObject* attached_object = attachment_iter->get(); + if (attached_object && !attached_object->isHUDAttachment()) { - value_text->setAlignment(LLFontGL::HCENTER); + F32 gpu_time = attached_object->mGPURenderTime; + + LLSD item; + item["special_id"] = attached_object->getID(); + item["target"] = LLNameListCtrl::SPECIAL; + LLSD& row = item["columns"]; + row[0]["column"] = "complex_visual"; + row[0]["type"] = "bar"; + LLSD& value = row[0]["value"]; + value["ratio"] = gpu_time / max_gpu_time; + value["bottom"] = BAR_BOTTOM_PAD; + value["left_pad"] = BAR_LEFT_PAD; + value["right_pad"] = BAR_RIGHT_PAD; + + row[1]["column"] = "complex_value"; + row[1]["type"] = "text"; + // show gpu time in us + row[1]["value"] = llformat("%.f", gpu_time * 1000.f); + row[1]["font"]["name"] = "SANSSERIF"; + + row[2]["column"] = "name"; + row[2]["type"] = "text"; + row[2]["value"] = attached_object->getAttachmentItemName(); + row[2]["font"]["name"] = "SANSSERIF"; + + LLScrollListItem* obj = mObjectList->addElement(item); + if (obj) + { + LLScrollListText* value_text = dynamic_cast(obj->getColumn(1)); + if (value_text) + { + value_text->setAlignment(LLFontGL::HCENTER); + } + } } } } @@ -358,6 +422,7 @@ void LLFloaterPerformance::populateObjectList() void LLFloaterPerformance::populateNearbyList() { + LL_PROFILE_ZONE_SCOPED_CATEGORY_APP; static LLCachedControl showTunedART(gSavedSettings, "ShowTunedART"); S32 prev_pos = mNearbyList->getScrollPos(); LLUUID prev_selected_id = mNearbyList->getStringUUIDSelectedItem(); @@ -366,22 +431,16 @@ void LLFloaterPerformance::populateNearbyList() static LLCachedControl max_render_cost(gSavedSettings, "RenderAvatarMaxComplexity", 0); std::vector valid_nearby_avs; - mNearbyMaxComplexity = LLWorld::getInstance()->getNearbyAvatarsAndCompl(valid_nearby_avs); + mNearbyMaxGPUTime = LLWorld::getInstance()->getNearbyAvatarsAndMaxGPUTime(valid_nearby_avs); std::vector::iterator char_iter = valid_nearby_avs.begin(); - LLPerfStats::bufferToggleLock.lock(); - auto av_render_max_raw = LLPerfStats::StatsRecorder::getMax(AvType, LLPerfStats::StatType_t::RENDER_COMBINED); - LLPerfStats::bufferToggleLock.unlock(); - while (char_iter != valid_nearby_avs.end()) { LLVOAvatar* avatar = dynamic_cast(*char_iter); if (avatar && (LLVOAvatar::AOA_INVISIBLE != avatar->getOverallAppearance())) { - LLPerfStats::bufferToggleLock.lock(); - auto render_av_raw = LLPerfStats::StatsRecorder::get(AvType, avatar->getID(),LLPerfStats::StatType_t::RENDER_COMBINED); - LLPerfStats::bufferToggleLock.unlock(); + F32 render_av_gpu_ms = avatar->getGPURenderTime(); auto is_slow = avatar->isTooSlow(); LLSD item; @@ -392,7 +451,7 @@ void LLFloaterPerformance::populateNearbyList() LLSD& value = row[0]["value"]; // The ratio used in the bar is the current cost, as soon as we take action this changes so we keep the // pre-tune value for the numerical column and sorting. - value["ratio"] = (double)render_av_raw / av_render_max_raw; + value["ratio"] = render_av_gpu_ms / mNearbyMaxGPUTime; value["bottom"] = BAR_BOTTOM_PAD; value["left_pad"] = BAR_LEFT_PAD; value["right_pad"] = BAR_RIGHT_PAD; @@ -405,14 +464,15 @@ void LLFloaterPerformance::populateNearbyList() } else { - row[1]["value"] = llformat( "%.f", LLPerfStats::raw_to_us( render_av_raw ) ); + // use GPU time in us + row[1]["value"] = llformat( "%.f", render_av_gpu_ms * 1000.f); } row[1]["font"]["name"] = "SANSSERIF"; - row[2]["column"] = "name"; - row[2]["type"] = "text"; - row[2]["value"] = avatar->getFullname(); - row[2]["font"]["name"] = "SANSSERIF"; + row[3]["column"] = "name"; + row[3]["type"] = "text"; + row[3]["value"] = avatar->getFullname(); + row[3]["font"]["name"] = "SANSSERIF"; LLScrollListItem* av_item = mNearbyList->addElement(item); if(av_item) diff --git a/indra/newview/llfloaterperformance.h b/indra/newview/llfloaterperformance.h index 00f904f6d6..620dbac5bb 100644 --- a/indra/newview/llfloaterperformance.h +++ b/indra/newview/llfloaterperformance.h @@ -94,7 +94,9 @@ private: LLTimer* mUpdateTimer; - S32 mNearbyMaxComplexity; + // maximum GPU time of nearby avatars in ms according to LLWorld::getNearbyAvatarsAndMaxGPUTime + // -1.f if no profile has happened yet + F32 mNearbyMaxGPUTime = -1.f; boost::signals2::connection mMaxARTChangedSignal; }; diff --git a/indra/newview/llperfstats.cpp b/indra/newview/llperfstats.cpp index c63aae2089..b680d8761b 100644 --- a/indra/newview/llperfstats.cpp +++ b/indra/newview/llperfstats.cpp @@ -199,18 +199,7 @@ namespace LLPerfStats // LL_INFOS("scenestats") << "Scenestat: " << static_cast(statEntry) << " before=" << avg << " new=" << val << " newavg=" << statsDoubleBuffer[writeBuffer][static_cast(ObjType_t::OT_GENERAL)][LLUUID::null][static_cast(statEntry)] << LL_ENDL; } } -// Allow attachment times etc to update even when FPS limited or sleeping. - auto& statsMap = statsDoubleBuffer[writeBuffer][static_cast(ObjType_t::OT_ATTACHMENT)]; - for(auto& stat_entry : statsMap) - { - auto val = stat_entry.second[static_cast(ST::RENDER_COMBINED)]; - if(val > SMOOTHING_PERIODS){ - auto avg = statsDoubleBuffer[writeBuffer ^ 1][static_cast(ObjType_t::OT_ATTACHMENT)][stat_entry.first][static_cast(ST::RENDER_COMBINED)]; - stat_entry.second[static_cast(ST::RENDER_COMBINED)] = avg + (val / SMOOTHING_PERIODS) - (avg / SMOOTHING_PERIODS); - } - } - - + auto& statsMapAv = statsDoubleBuffer[writeBuffer][static_cast(ObjType_t::OT_AVATAR)]; for(auto& stat_entry : statsMapAv) { diff --git a/indra/newview/llperfstats.h b/indra/newview/llperfstats.h index dbb88a141d..a4768272b9 100644 --- a/indra/newview/llperfstats.h +++ b/indra/newview/llperfstats.h @@ -69,8 +69,6 @@ namespace LLPerfStats enum class ObjType_t{ OT_GENERAL=0, // Also Unknown. Used for n/a type stats such as scenery OT_AVATAR, - OT_ATTACHMENT, - OT_HUD, OT_COUNT }; enum class StatType_t{ @@ -260,31 +258,6 @@ namespace LLPerfStats doUpd(avKey, ot, type, val); return; } - - if (ot == ObjType_t::OT_ATTACHMENT) - { - if( !upd.isHUD ) // don't include HUD cost in self. - { - LL_PROFILE_ZONE_NAMED("Att as Av") - // For all attachments that are not rigged we add them to the avatar (for all avatars) cost. - doUpd(avKey, ObjType_t::OT_AVATAR, type, val); - } - if( avKey == focusAv ) - { - LL_PROFILE_ZONE_NAMED("Att as Att") - // For attachments that are for the focusAv (self for now) we record them for the attachment/complexity view - if(upd.isHUD) - { - ot = ObjType_t::OT_HUD; - } - // LL_INFOS("perfstats") << "frame: " << gFrameCount << " Attachment update("<< (type==StatType_t::RENDER_GEOMETRY?"GEOMETRY":"SHADOW") << ": " << key.asString() << " = " << val << LL_ENDL; - doUpd(key, ot, type, val); - } - // else - // { - // // LL_INFOS("perfstats") << "frame: " << gFrameCount << " non-self Att update("<< (type==StatType_t::RENDER_GEOMETRY?"GEOMETRY":"SHADOW") << ": " << key.asString() << " = " << val << " for av " << avKey.asString() << LL_ENDL; - // } - } } static inline void doUpd(const LLUUID& key, ObjType_t ot, StatType_t type, uint64_t val) @@ -409,51 +382,7 @@ namespace LLPerfStats using RecordSceneTime = RecordTime; using RecordAvatarTime = RecordTime; - using RecordAttachmentTime = RecordTime; - using RecordHudAttachmentTime = RecordTime; - -};// namespace LLPerfStats - -// helper functions -using RATptr = std::unique_ptr; -using RSTptr = std::unique_ptr; -template -static inline void trackAttachments(const T * vobj, bool isRigged, RATptr* ratPtrp) -{ - if( !vobj ){ ratPtrp->reset(); return;}; - - const T* rootAtt{vobj}; - if (rootAtt->isAttachment()) - { - LL_PROFILE_ZONE_SCOPED_CATEGORY_STATS; - - while( !rootAtt->isRootEdit() ) - { - rootAtt = (T*)(rootAtt->getParent()); - } - - auto avPtr = (T*)(rootAtt->getParent()); - if(!avPtr){ratPtrp->reset(); return;} - - auto& av = avPtr->getID(); - auto& obj = rootAtt->getAttachmentItemID(); - if (!*ratPtrp || (*ratPtrp)->stat.objID != obj || (*ratPtrp)->stat.avID != av) - { - if (*ratPtrp) - { - // deliberately reset to ensure destruction before construction of replacement. - ratPtrp->reset(); - }; - *ratPtrp = std::make_unique( - av, - obj, - ( LLPipeline::sShadowRender?LLPerfStats::StatType_t::RENDER_SHADOWS : LLPerfStats::StatType_t::RENDER_GEOMETRY ), - isRigged, - rootAtt->isHUDAttachment()); - } - } - return; -}; +};// namespace LLPerfStats #endif diff --git a/indra/newview/llviewerjointmesh.cpp b/indra/newview/llviewerjointmesh.cpp index 00e1179896..5ce8f4023d 100644 --- a/indra/newview/llviewerjointmesh.cpp +++ b/indra/newview/llviewerjointmesh.cpp @@ -227,16 +227,6 @@ U32 LLViewerJointMesh::drawShape( F32 pixelArea, BOOL first_pass, BOOL is_dummy) return 0; } - // render time capture - // This path does not appear to have attachments. Prove this then remove. - std::unique_ptr ratPtr{}; - auto vobj = mFace->getViewerObject(); - if( vobj && vobj->isAttachment() ) - { - trackAttachments( vobj, mFace->isState(LLFace::RIGGED), &ratPtr ); - LL_WARNS("trackAttachments") << "Attachment render time is captuted." << LL_ENDL; - } - U32 triangle_count = 0; S32 diffuse_channel = LLDrawPoolAvatar::sDiffuseChannel; diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h index fe27227e6b..cd2363a1b9 100644 --- a/indra/newview/llviewerobject.h +++ b/indra/newview/llviewerobject.h @@ -941,6 +941,10 @@ public: // reflection probe state bool mIsReflectionProbe = false; // if true, this object should register itself with LLReflectionProbeManager LLPointer mReflectionProbe = nullptr; // reflection probe coupled to this viewer object. If not null, should be deregistered when this object is destroyed + + // the amount of GPU time (in ms) it took to render this object according to LLPipeline::profileAvatar + // -1.f if no profile data available + F32 mGPURenderTime = -1.f; }; /////////////////// diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index 5b8f4767db..e38a6457f4 100644 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -8357,7 +8357,7 @@ void LLVOAvatar::updateTooSlow() { // use the cached values. render_time_raw = mRenderTime; - render_geom_time_raw = mGeomTime; + render_geom_time_raw = mGeomTime; } bool autotune = LLPerfStats::tunables.userAutoTuneEnabled && !mIsControlAvatar && !isSelf(); @@ -10984,6 +10984,7 @@ void LLVOAvatar::accountRenderComplexityForObject( // Calculations for mVisualComplexity value void LLVOAvatar::calculateUpdateRenderComplexity() { + LL_PROFILE_ZONE_SCOPED_CATEGORY_AVATAR; /***************************************************************** * This calculation should not be modified by third party viewers, * since it is used to limit rendering and should be uniform for diff --git a/indra/newview/llvoavatar.h b/indra/newview/llvoavatar.h index 1502c25b4d..0bb19c4420 100644 --- a/indra/newview/llvoavatar.h +++ b/indra/newview/llvoavatar.h @@ -305,8 +305,27 @@ public: static const U32 VISUAL_COMPLEXITY_UNKNOWN; void updateVisualComplexity(); - U32 getVisualComplexity() { return mVisualComplexity; }; // Numbers calculated here by rendering AV - F32 getAttachmentSurfaceArea() { return mAttachmentSurfaceArea; }; // estimated surface area of attachments + // get the GPU time in ms of rendering this avatar including all attachments + // returns -1 if this avatar has not been profiled using gPipeline.profileAvatar + F32 getGPURenderTime() { return mGPURenderTime; } + + // get the CPU time in ms of rendering this avatar including all attachments + // return -1 if this avatar has not been profiled using gPipeline.mProfileAvatar + F32 getCPURenderTime() { return mCPURenderTime; } + + // get the number of samples passed during the avatar profile + // return -1 if this avatar has not been profiled using gPipeline.mProfileAvatar + S32 getGPUSamplesPassed() { return mGPUSamplesPassed; } + + // get the number of triangles rendered during the avatar profile + // return -1 if this avatar has not been profiled using gPipeline.mProfileAvatar + S32 getGPUTrianglesRendered() { return mGPUTrianglesRendered; } + + // DEPRECATED -- obsolete avatar render cost + U32 getVisualComplexity() { return mVisualComplexity; }; + + // DEPRECATED -- obsolete surface area calculation + F32 getAttachmentSurfaceArea() { return mAttachmentSurfaceArea; }; U32 getReportedVisualComplexity() { return mReportedVisualComplexity; }; // Numbers as reported by the SL server void setReportedVisualComplexity(U32 value) { mReportedVisualComplexity = value; }; @@ -523,6 +542,7 @@ public: S32 mSpecialRenderMode; // special lighting private: + friend class LLPipeline; AvatarOverallAppearance mOverallAppearance; F32 mAttachmentSurfaceArea; //estimated surface area of attachments U32 mAttachmentVisibleTriangleCount; @@ -535,7 +555,22 @@ private: S32 mUpdatePeriod; S32 mNumInitFaces; //number of faces generated when creating the avatar drawable, does not inculde splitted faces due to long vertex buffer. + // profile results + + // GPU render time in ms + F32 mGPURenderTime = -1.f; + + // CPU render time in ms + F32 mCPURenderTime = -1.f; + + // number of samples passed according to GPU + S32 mGPUSamplesPassed = -1; + + // number of triangles rendered according to GPU + S32 mGPUTrianglesRendered = -1; + // the isTooComplex method uses these mutable values to avoid recalculating too frequently + // DEPRECATED -- obsolete avatar render cost values mutable U32 mVisualComplexity; mutable bool mVisualComplexityStale; U32 mReportedVisualComplexity; // from other viewers through the simulator diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 12ceb86e52..da5a505d3b 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -88,7 +88,6 @@ #include "llcallstack.h" #include "llsculptidsize.h" #include "llavatarappearancedefines.h" -#include "llperfstats.h" #include "llgltfmateriallist.h" const F32 FORCE_SIMPLE_RENDER_AREA = 512.f; @@ -5657,7 +5656,6 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) LL_PROFILE_ZONE_NAMED("rebuildGeom - face list"); //get all the faces into a list - std::unique_ptr ratPtr{}; for (LLSpatialGroup::element_iter drawable_iter = group->getDataBegin(); drawable_iter != group->getDataEnd(); ++drawable_iter) { @@ -5693,11 +5691,6 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) continue; } - if(vobj->isAttachment()) - { - trackAttachments( vobj, drawablep->isState(LLDrawable::RIGGED),&ratPtr); - } - LLVolume* volume = vobj->getVolume(); if (volume) { @@ -6095,8 +6088,7 @@ void LLVolumeGeometryManager::rebuildMesh(LLSpatialGroup* group) U32 buffer_count = 0; - std::unique_ptr ratPtr{}; - for (LLSpatialGroup::element_iter drawable_iter = group->getDataBegin(); drawable_iter != group->getDataEnd(); ++drawable_iter) + for (LLSpatialGroup::element_iter drawable_iter = group->getDataBegin(); drawable_iter != group->getDataEnd(); ++drawable_iter) { LLDrawable* drawablep = (LLDrawable*)(*drawable_iter)->getDrawable(); @@ -6106,11 +6098,6 @@ void LLVolumeGeometryManager::rebuildMesh(LLSpatialGroup* group) if (!vobj) continue; - if (vobj->isAttachment()) - { - trackAttachments( vobj, drawablep->isState(LLDrawable::RIGGED), &ratPtr ); - } - if (debugLoggingEnabled("AnimatedObjectsLinkset")) { if (vobj->isAnimatedObject() && vobj->isRiggedMesh()) @@ -6479,16 +6466,11 @@ U32 LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace U32 indices_index = 0; U16 index_offset = 0; - std::unique_ptr ratPtr; while (face_iter < i) { //update face indices for new buffer facep = *face_iter; - LLViewerObject* vobj = facep->getViewerObject(); - if(vobj && vobj->isAttachment()) - { - trackAttachments(vobj, LLPipeline::sShadowRender, &ratPtr); - } + if (buffer.isNull()) { // Bulk allocation failed diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp index 72c8cb371f..732ef1da6c 100644 --- a/indra/newview/llworld.cpp +++ b/indra/newview/llworld.cpp @@ -1424,10 +1424,10 @@ void LLWorld::getAvatars(uuid_vec_t* avatar_ids, std::vector* positi } } -S32 LLWorld::getNearbyAvatarsAndCompl(std::vector &valid_nearby_avs) +F32 LLWorld::getNearbyAvatarsAndMaxGPUTime(std::vector &valid_nearby_avs) { static LLCachedControl render_far_clip(gSavedSettings, "RenderFarClip", 64); - S32 nearby_max_complexity = 0; + F32 nearby_max_complexity = 0; F32 radius = render_far_clip * render_far_clip; std::vector::iterator char_iter = LLCharacter::sInstances.begin(); while (char_iter != LLCharacter::sInstances.end()) @@ -1441,8 +1441,8 @@ S32 LLWorld::getNearbyAvatarsAndCompl(std::vector &valid_nearby_av char_iter++; continue; } - avatar->calculateUpdateRenderComplexity(); - nearby_max_complexity = llmax(nearby_max_complexity, (S32)avatar->getVisualComplexity()); + gPipeline.profileAvatar(avatar); + nearby_max_complexity = llmax(nearby_max_complexity, avatar->getGPURenderTime()); valid_nearby_avs.push_back(*char_iter); } char_iter++; diff --git a/indra/newview/llworld.h b/indra/newview/llworld.h index b2be36d72c..f78cbcaa48 100644 --- a/indra/newview/llworld.h +++ b/indra/newview/llworld.h @@ -172,7 +172,9 @@ public: // or if the circuit to this simulator had been lost. bool isRegionListed(const LLViewerRegion* region) const; - S32 getNearbyAvatarsAndCompl(std::vector &valid_nearby_avs); + // profile nearby avatars using gPipeline.profileAvatar and update their render times + // return max GPU time + F32 getNearbyAvatarsAndMaxGPUTime(std::vector &valid_nearby_avs); private: void clearHoleWaterObjects(); diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 2912d0da82..df8b8a552a 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -10070,7 +10070,88 @@ void LLPipeline::renderRiggedGroups(LLRenderPass* pass, U32 type, bool texture) static LLTrace::BlockTimerStatHandle FTM_GENERATE_IMPOSTOR("Generate Impostor"); -void LLPipeline::generateImpostor(LLVOAvatar* avatar, bool preview_avatar) +void LLPipeline::profileAvatar(LLVOAvatar* avatar, bool profile_attachments) +{ + if (gGLManager.mGLVersion < 3.25f) + { // profiling requires GL 3.3 or later + return; + } + LLGLSLShader* cur_shader = LLGLSLShader::sCurBoundShaderPtr; + + mRT->deferredScreen.bindTarget(); + mRT->deferredScreen.clear(); + + bool profile_enabled = LLGLSLShader::sProfileEnabled; + LLGLSLShader::sProfileEnabled = true; + + if (!profile_attachments) + { + // profile entire avatar all at once + + // use gDebugProgram as a proxy for getting profile results + gDebugProgram.clearStats(); + gDebugProgram.placeProfileQuery(); + LLGLSLShader::sProfileEnabled = false; + + LLTimer cpu_timer; + + generateImpostor(avatar, false, true); + + avatar->mCPURenderTime = (F32)cpu_timer.getElapsedTimeF32() * 1000.f; + + LLGLSLShader::sProfileEnabled = true; + gDebugProgram.readProfileQuery(); + + avatar->mGPURenderTime = gDebugProgram.mTimeElapsed / 1000000.f; + + avatar->mGPUSamplesPassed = gDebugProgram.mSamplesDrawn; + avatar->mGPUTrianglesRendered = gDebugProgram.mTrianglesDrawn; + } + else + { + // profile attachments one at a time + LLVOAvatar::attachment_map_t::iterator iter; + LLVOAvatar::attachment_map_t::iterator begin = avatar->mAttachmentPoints.begin(); + LLVOAvatar::attachment_map_t::iterator end = avatar->mAttachmentPoints.end(); + + for (iter = begin; + iter != end; + ++iter) + { + LLViewerJointAttachment* attachment = iter->second; + for (LLViewerJointAttachment::attachedobjs_vec_t::iterator attachment_iter = attachment->mAttachedObjects.begin(); + attachment_iter != attachment->mAttachedObjects.end(); + ++attachment_iter) + { + LLViewerObject* attached_object = attachment_iter->get(); + if (attached_object) + { + gDebugProgram.clearStats(); + gDebugProgram.placeProfileQuery(); + LLGLSLShader::sProfileEnabled = false; + + generateImpostor(avatar, false, true, attached_object); + LLGLSLShader::sProfileEnabled = true; + gDebugProgram.readProfileQuery(); + + attached_object->mGPURenderTime = gDebugProgram.mTimeElapsed / 1000000.f; + + // TODO: maybe also record triangles and samples + } + } + } + } + + LLGLSLShader::sProfileEnabled = profile_enabled; + mRT->deferredScreen.flush(); + + if (cur_shader) + { + cur_shader->bind(); + } +} + +void LLPipeline::generateImpostor(LLVOAvatar* avatar, bool preview_avatar, bool for_profile, LLViewerObject* specific_attachment) { LL_RECORD_BLOCK_TIME(FTM_GENERATE_IMPOSTOR); LL_PROFILE_GPU_ZONE("generateImpostor"); @@ -10090,11 +10171,11 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar, bool preview_avatar) assertInitialized(); // previews can't be muted or impostered - bool visually_muted = !preview_avatar && avatar->isVisuallyMuted(); + bool visually_muted = !for_profile && !preview_avatar && avatar->isVisuallyMuted(); LL_DEBUGS_ONCE("AvatarRenderPipeline") << "Avatar " << avatar->getID() << " is " << ( visually_muted ? "" : "not ") << "visually muted" << LL_ENDL; - bool too_complex = !preview_avatar && avatar->isTooComplex(); + bool too_complex = !for_profile && !preview_avatar && avatar->isTooComplex(); LL_DEBUGS_ONCE("AvatarRenderPipeline") << "Avatar " << avatar->getID() << " is " << ( too_complex ? "" : "not ") << "too complex" << LL_ENDL; @@ -10129,6 +10210,11 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar, bool preview_avatar) ); } + if (specific_attachment && specific_attachment->isHUDAttachment()) + { //enable HUD rendering + setRenderTypeMask(RENDER_TYPE_HUD, END_RENDER_TYPES); + } + S32 occlusion = sUseOcclusion; sUseOcclusion = 0; @@ -10185,20 +10271,30 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar, bool preview_avatar) } else { - LLVOAvatar::attachment_map_t::iterator iter; - for (iter = avatar->mAttachmentPoints.begin(); - iter != avatar->mAttachmentPoints.end(); - ++iter) + if (specific_attachment) { - LLViewerJointAttachment *attachment = iter->second; - for (LLViewerJointAttachment::attachedobjs_vec_t::iterator attachment_iter = attachment->mAttachedObjects.begin(); - attachment_iter != attachment->mAttachedObjects.end(); - ++attachment_iter) + markVisible(specific_attachment->mDrawable->getSpatialBridge(), *viewer_camera); + } + else + { + LLVOAvatar::attachment_map_t::iterator iter; + LLVOAvatar::attachment_map_t::iterator begin = avatar->mAttachmentPoints.begin(); + LLVOAvatar::attachment_map_t::iterator end = avatar->mAttachmentPoints.end(); + + for (iter = begin; + iter != end; + ++iter) { - LLViewerObject* attached_object = attachment_iter->get(); - if (attached_object) + LLViewerJointAttachment* attachment = iter->second; + for (LLViewerJointAttachment::attachedobjs_vec_t::iterator attachment_iter = attachment->mAttachedObjects.begin(); + attachment_iter != attachment->mAttachedObjects.end(); + ++attachment_iter) { - markVisible(attached_object->mDrawable->getSpatialBridge(), *viewer_camera); + LLViewerObject* attached_object = attachment_iter->get(); + if (attached_object) + { + markVisible(attached_object->mDrawable->getSpatialBridge(), *viewer_camera); + } } } } @@ -10327,6 +10423,7 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar, bool preview_avatar) LLDrawPoolAvatar::sMinimumAlpha = old_alpha; + if (!for_profile) { //create alpha mask based on depth buffer (grey out if muted) if (LLPipeline::sRenderDeferred) { diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h index dbd1a34f61..45842a3948 100644 --- a/indra/newview/pipeline.h +++ b/indra/newview/pipeline.h @@ -132,7 +132,8 @@ public: bool allocateShadowBuffer(U32 resX, U32 resY); void resetVertexBuffers(LLDrawable* drawable); - void generateImpostor(LLVOAvatar* avatar, bool preview_avatar = false); + void profileAvatar(LLVOAvatar* avatar, bool profile_attachments = false); + void generateImpostor(LLVOAvatar* avatar, bool preview_avatar = false, bool for_profile = false, LLViewerObject* specific_attachment = nullptr); void bindScreenToTexture(); void renderFinalize(); void copyScreenSpaceReflections(LLRenderTarget* src, LLRenderTarget* dst); -- cgit v1.3 From 8077d33ba05a46ea61914be686816be5b54bae6d Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Thu, 11 May 2023 13:20:34 -0500 Subject: SL-19656 Remove LLPerfStats thread and fold into General thread. Hook avatar GPU time into LLPerfStats. Incidental decruft. --- indra/newview/llappviewer.cpp | 2 + indra/newview/llfloaterperformance.cpp | 11 +-- indra/newview/llperfstats.cpp | 67 ++++++++++----- indra/newview/llperfstats.h | 68 ++++----------- indra/newview/llviewerstats.cpp | 2 +- indra/newview/llvoavatar.cpp | 146 ++++++++++++++++++++------------- indra/newview/llvoavatar.h | 30 +++---- indra/newview/llworld.cpp | 6 +- indra/newview/pipeline.cpp | 42 ++++++---- 9 files changed, 201 insertions(+), 173 deletions(-) (limited to 'indra/newview/llperfstats.cpp') diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 6efbaeacf7..c9fc0e2cc8 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -4698,6 +4698,8 @@ void LLAppViewer::idle() LLFrameTimer::updateFrameTime(); LLFrameTimer::updateFrameCount(); LLEventTimer::updateClass(); + LLPerfStats::updateClass(); + // LLApp::stepFrame() performs the above three calls plus mRunner.run(). // Not sure why we don't call stepFrame() here, except that LLRunner seems // completely redundant with LLEventTimer. diff --git a/indra/newview/llfloaterperformance.cpp b/indra/newview/llfloaterperformance.cpp index 8c5745aa43..19fc3e673e 100644 --- a/indra/newview/llfloaterperformance.cpp +++ b/indra/newview/llfloaterperformance.cpp @@ -456,15 +456,8 @@ void LLFloaterPerformance::populateNearbyList() row[1]["column"] = "complex_value"; row[1]["type"] = "text"; - if (is_slow && !showTunedART) - { - row[1]["value"] = llformat( "%.f", LLPerfStats::raw_to_us( avatar->getLastART() ) ); - } - else - { - // use GPU time in us - row[1]["value"] = llformat( "%.f", render_av_gpu_ms * 1000.f); - } + // use GPU time in us + row[1]["value"] = llformat( "%.f", render_av_gpu_ms * 1000.f); row[1]["font"]["name"] = "SANSSERIF"; row[3]["column"] = "name"; diff --git a/indra/newview/llperfstats.cpp b/indra/newview/llperfstats.cpp index b680d8761b..2281475d4a 100644 --- a/indra/newview/llperfstats.cpp +++ b/indra/newview/llperfstats.cpp @@ -39,6 +39,11 @@ extern LLControlGroup gSavedSettings; namespace LLPerfStats { + // avatar timing metrics in ms (updated once per mainloop iteration) + std::atomic sTotalAvatarTime = 0.f; + std::atomic sAverageAvatarTime = 0.f; + std::atomic sMaxAvatarTime = 0.f; + std::atomic tunedAvatars{0}; std::atomic renderAvatarMaxART_ns{(U64)(ART_UNLIMITED_NANOS)}; // highest render time we'll allow without culling features bool belowTargetFPS{false}; @@ -141,14 +146,12 @@ namespace LLPerfStats resetChanges(); } - StatsRecorder::StatsRecorder():q(1024*16),t(&StatsRecorder::run) + StatsRecorder::StatsRecorder():q(1024*16) { // create a queue - // create a thread to consume from the queue tunables.initialiseFromSettings(); LLPerfStats::cpu_hertz = (F64)LLTrace::BlockTimer::countsPerSecond(); LLPerfStats::vsync_max_fps = gViewerWindow->getWindow()->getRefreshRate(); - t.detach(); } // static @@ -200,20 +203,6 @@ namespace LLPerfStats } } - auto& statsMapAv = statsDoubleBuffer[writeBuffer][static_cast(ObjType_t::OT_AVATAR)]; - for(auto& stat_entry : statsMapAv) - { - for(auto& stat : avatarStatsToAvg) - { - auto val = stat_entry.second[static_cast(stat)]; - if(val > SMOOTHING_PERIODS) - { - auto avg = statsDoubleBuffer[writeBuffer ^ 1][static_cast(ObjType_t::OT_AVATAR)][stat_entry.first][static_cast(stat)]; - stat_entry.second[static_cast(stat)] = avg + (val / SMOOTHING_PERIODS) - (avg / SMOOTHING_PERIODS); - } - } - } - // swap the buffers if(enabled()) { @@ -293,6 +282,36 @@ namespace LLPerfStats } } + // called once per main loop iteration on main thread + void updateClass() + { + LL_PROFILE_ZONE_SCOPED_CATEGORY_STATS; + + sTotalAvatarTime = LLVOAvatar::getTotalGPURenderTime(); + sAverageAvatarTime = LLVOAvatar::getAverageGPURenderTime(); + sMaxAvatarTime = LLVOAvatar::getMaxGPURenderTime(); + + auto& general = LL::WorkQueue::getInstance("General"); + + if (general) + { + general->post([] { StatsRecorder::update(); }); + } + } + + // called once per main loop iteration on General thread + void StatsRecorder::update() + { + LL_PROFILE_ZONE_SCOPED_CATEGORY_STATS; + StatsRecord upd; + auto& instance{ StatsRecorder::getInstance() }; + + while (enabled() && !LLApp::isQuitting() && instance.q.tryPop(upd)) + { + instance.processUpdate(upd); + } + } + //static int StatsRecorder::countNearbyAvatars(S32 distance) { @@ -327,6 +346,8 @@ namespace LLPerfStats // static void StatsRecorder::updateAvatarParams() { + LL_PROFILE_ZONE_SCOPED_CATEGORY_STATS; + if(tunables.autoTuneTimeout) { LLPerfStats::lastSleepedFrame = gFrameCount; @@ -380,10 +401,10 @@ namespace LLPerfStats } } - auto av_render_max_raw = LLPerfStats::StatsRecorder::getMax(ObjType_t::OT_AVATAR, LLPerfStats::StatType_t::RENDER_COMBINED); + auto av_render_max_raw = ms_to_raw(sMaxAvatarTime); // Is our target frame time lower than current? If so we need to take action to reduce draw overheads. // cumulative avatar time (includes idle processing, attachments and base av) - auto tot_avatar_time_raw = LLPerfStats::StatsRecorder::getSum(ObjType_t::OT_AVATAR, LLPerfStats::StatType_t::RENDER_COMBINED); + auto tot_avatar_time_raw = ms_to_raw(sTotalAvatarTime); // The frametime budget we have based on the target FPS selected auto target_frame_time_raw = (U64)llround(LLPerfStats::cpu_hertz / (target_fps == 0 ? 1 : target_fps)); @@ -417,7 +438,7 @@ namespace LLPerfStats // if so we've got work to do // how much of the frame was spent on non avatar related work? - U64 non_avatar_time_raw = tot_frame_time_raw - tot_avatar_time_raw; + U64 non_avatar_time_raw = tot_frame_time_raw > tot_avatar_time_raw ? tot_frame_time_raw - tot_avatar_time_raw : 0; // If the target frame time < scene time (estimated as non_avatar time) U64 target_avatar_time_raw; @@ -475,7 +496,11 @@ namespace LLPerfStats { new_render_limit_ns = renderAvatarMaxART_ns; } - new_render_limit_ns -= LLPerfStats::ART_MIN_ADJUST_DOWN_NANOS; + + if (new_render_limit_ns > LLPerfStats::ART_MIN_ADJUST_DOWN_NANOS) + { + new_render_limit_ns -= LLPerfStats::ART_MIN_ADJUST_DOWN_NANOS; + } // bounce at the bottom to prevent "no limit" new_render_limit_ns = std::max((U64)new_render_limit_ns, (U64)LLPerfStats::ART_MINIMUM_NANOS); diff --git a/indra/newview/llperfstats.h b/indra/newview/llperfstats.h index a4768272b9..bb5677f237 100644 --- a/indra/newview/llperfstats.h +++ b/indra/newview/llperfstats.h @@ -42,6 +42,10 @@ extern U32 gFrameCount; extern LLUUID gAgentID; namespace LLPerfStats { + + // called once per main loop iteration + void updateClass(); + // Note if changing these, they should correspond with the log range of the correpsonding sliders static constexpr U64 ART_UNLIMITED_NANOS{50000000}; static constexpr U64 ART_MINIMUM_NANOS{100000}; @@ -68,7 +72,6 @@ namespace LLPerfStats enum class ObjType_t{ OT_GENERAL=0, // Also Unknown. Used for n/a type stats such as scenery - OT_AVATAR, OT_COUNT }; enum class StatType_t{ @@ -162,6 +165,9 @@ namespace LLPerfStats using Queue = LLThreadSafeQueue; public: + // called once per main loop iteration on General thread + static void update(); + static inline StatsRecorder& getInstance() { static StatsRecorder instance; @@ -241,7 +247,6 @@ namespace LLPerfStats auto ot{upd.objType}; auto& key{upd.objID}; - auto& avKey{upd.avID}; auto type {upd.statType}; auto val {upd.time}; @@ -251,13 +256,6 @@ namespace LLPerfStats doUpd(key, ot, type,val); return; } - - if (ot == ObjType_t::OT_AVATAR) - { - // LL_INFOS("perfstats") << "Avatar update:" << LL_ENDL; - doUpd(avKey, ot, type, val); - return; - } } static inline void doUpd(const LLUUID& key, ObjType_t ot, StatType_t type, uint64_t val) @@ -286,42 +284,7 @@ namespace LLPerfStats static void toggleBuffer(); static void clearStatsBuffers(); - // thread entry - static void run() - { - StatsRecord upd[10]; - auto & instance {StatsRecorder::getInstance()}; - LL_PROFILER_SET_THREAD_NAME("PerfStats"); - - while( enabled() && !LLApp::isExiting() ) - { - auto count = 0; - while (count < 10) - { - if (instance.q.tryPopFor(std::chrono::milliseconds(10), upd[count])) - { - count++; - } - else - { - break; - } - } - //LL_PROFILER_THREAD_BEGIN("PerfStats"); - if(count) - { - // LL_INFOS("perfstats") << "processing " << count << " updates." << LL_ENDL; - for(auto i =0; i < count; i++) - { - instance.processUpdate(upd[i]); - } - } - //LL_PROFILER_THREAD_END("PerfStats"); - } - } - Queue q; - std::thread t; ~StatsRecorder() = default; StatsRecorder(const StatsRecorder&) = delete; @@ -354,13 +317,6 @@ namespace LLPerfStats LL_PROFILE_ZONE_SCOPED_CATEGORY_STATS; }; - template < ObjType_t OD = ObjTypeDiscriminator, - std::enable_if_t * = nullptr> - RecordTime( const LLUUID & av, StatType_t type ):RecordTime(std::move(av), LLUUID::null, type) - { - //LL_PROFILE_ZONE_COLOR(tracy::Color::Purple); - }; - ~RecordTime() { if(!LLPerfStats::StatsRecorder::enabled()) @@ -375,13 +331,19 @@ namespace LLPerfStats }; }; - + inline double raw_to_ns(U64 raw) { return (static_cast(raw) * 1000000000.0) / LLPerfStats::cpu_hertz; }; inline double raw_to_us(U64 raw) { return (static_cast(raw) * 1000000.0) / LLPerfStats::cpu_hertz; }; inline double raw_to_ms(U64 raw) { return (static_cast(raw) * 1000.0) / LLPerfStats::cpu_hertz; }; + inline U64 ns_to_raw(double ns) { return (U64)(LLPerfStats::cpu_hertz * (ns / 1000000000.0)); } + inline U64 us_to_raw(double us) { return (U64)(LLPerfStats::cpu_hertz * (us / 1000000.0)); } + inline U64 ms_to_raw(double ms) { return (U64)(LLPerfStats::cpu_hertz * (ms / 1000.0)); + + } + + using RecordSceneTime = RecordTime; - using RecordAvatarTime = RecordTime; };// namespace LLPerfStats diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp index 609e8290da..37999e58ff 100644 --- a/indra/newview/llviewerstats.cpp +++ b/indra/newview/llviewerstats.cpp @@ -472,7 +472,7 @@ void update_statistics() auto tot_frame_time_raw = LLPerfStats::StatsRecorder::getSceneStat(LLPerfStats::StatType_t::RENDER_FRAME); // cumulative avatar time (includes idle processing, attachments and base av) - auto tot_avatar_time_raw = LLPerfStats::StatsRecorder::getSum(LLPerfStats::ObjType_t::OT_AVATAR, LLPerfStats::StatType_t::RENDER_COMBINED); + auto tot_avatar_time_raw = LLPerfStats::us_to_raw(LLVOAvatar::getTotalGPURenderTime()); // cumulative avatar render specific time (a bit arbitrary as the processing is too.) // auto tot_av_idle_time_raw = LLPerfStats::StatsRecorder::getSum(AvType, LLPerfStats::StatType_t::RENDER_IDLE); // auto tot_avatar_render_time_raw = tot_avatar_time_raw - tot_av_idle_time_raw; diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index 95e9321d6f..af65588709 100644 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -2562,7 +2562,6 @@ void LLVOAvatar::idleUpdate(LLAgent &agent, const F64 &time) return; } // record time and refresh "tooSlow" status - LLPerfStats::RecordAvatarTime T(getID(), LLPerfStats::StatType_t::RENDER_IDLE); // per avatar "idle" time. updateTooSlow(); static LLCachedControl disable_all_render_types(gSavedSettings, "DisableAllRenderTypes"); @@ -8310,14 +8309,6 @@ bool LLVOAvatar::isTooSlow() const return mTooSlow; } -// use Avatar Render Time as complexity metric -// markARTStale - Mark stale and set the frameupdate to now so that we can wait at least one frame to get a revised number. -void LLVOAvatar::markARTStale() -{ - mARTStale=true; - mLastARTUpdateFrame = LLFrameTimer::getFrameCount(); -} - // Udpate Avatar state based on render time void LLVOAvatar::updateTooSlow() { @@ -8328,41 +8319,9 @@ void LLVOAvatar::updateTooSlow() // mTooSlow - Is the avatar flagged as being slow (includes shadow time) // mTooSlowWithoutShadows - Is the avatar flagged as being slow even with shadows removed. - // mARTStale - the rendertime we have is stale because of an update. We need to force a re-render to re-assess slowness - - if( mARTStale ) - { - if ( LLFrameTimer::getFrameCount() - mLastARTUpdateFrame < 5 ) - { - // LL_INFOS() << this->getFullname() << " marked stale " << LL_ENDL; - // we've not had a chance to update yet (allow a few to be certain a full frame has passed) - return; - } - - mARTStale = false; - mTooSlow = false; - mTooSlowWithoutShadows = false; - // LL_INFOS() << this->getFullname() << " refreshed ART combined = " << mRenderTime << " @ " << mLastARTUpdateFrame << LL_ENDL; - } - - // Either we're not stale or we've updated. - - U64 render_time_raw; - U64 render_geom_time_raw; - - if( !mTooSlow ) - { - // we are fully rendered, so we use the live values - std::lock_guard lock{LLPerfStats::bufferToggleLock}; - render_time_raw = LLPerfStats::StatsRecorder::get(LLPerfStats::ObjType_t::OT_AVATAR, id, LLPerfStats::StatType_t::RENDER_COMBINED); - render_geom_time_raw = LLPerfStats::StatsRecorder::get(LLPerfStats::ObjType_t::OT_AVATAR, id, LLPerfStats::StatType_t::RENDER_GEOMETRY); - } - else - { - // use the cached values. - render_time_raw = mRenderTime; - render_geom_time_raw = mGeomTime; - } + + // get max render time in ms + F32 max_art_ms = (F32) (LLPerfStats::renderAvatarMaxART_ns / 1000000.0); bool autotune = LLPerfStats::tunables.userAutoTuneEnabled && !mIsControlAvatar && !isSelf(); @@ -8378,19 +8337,13 @@ void LLVOAvatar::updateTooSlow() } bool exceeds_max_ART = - ((LLPerfStats::renderAvatarMaxART_ns > 0) && (LLPerfStats::raw_to_ns(render_time_raw) >= LLPerfStats::renderAvatarMaxART_ns)); + ((LLPerfStats::renderAvatarMaxART_ns > 0) && + (mGPURenderTime >= max_art_ms)); // NOTE: don't use getGPURenderTime accessor here to avoid "isTooSlow" feedback loop if (exceeds_max_ART && !ignore_tune) { - if( !mTooSlow ) // if we were previously not slow (with or without shadows.) - { - // if we weren't capped, we are now - mLastARTUpdateFrame = LLFrameTimer::getFrameCount(); - mRenderTime = render_time_raw; - mGeomTime = render_geom_time_raw; - mARTStale = false; - mTooSlow = true; - } + mTooSlow = true; + if(!mTooSlowWithoutShadows) // if we were not previously above the full impostor cap { bool render_friend_or_exception = ( alwaysRenderFriends && LLAvatarTracker::instance().isBuddy( id ) ) || @@ -8398,13 +8351,12 @@ void LLVOAvatar::updateTooSlow() if( (!isSelf() || allowSelfImpostor) && !render_friend_or_exception ) { // Note: slow rendering Friends still get their shadows zapped. - mTooSlowWithoutShadows = (LLPerfStats::raw_to_ns(render_geom_time_raw) >= LLPerfStats::renderAvatarMaxART_ns); + mTooSlowWithoutShadows = getGPURenderTime()*2.f >= max_art_ms; // NOTE: assumes shadow rendering doubles render time } } } else { - // LL_INFOS() << this->getFullname() << " ("<< (combined?"combined":"geometry") << ") good render time = " << LLPerfStats::raw_to_ns(render_time_raw) << " vs ("<< LLVOAvatar::sRenderTimeCap_ns << " set @ " << mLastARTUpdateFrame << LL_ENDL; mTooSlow = false; mTooSlowWithoutShadows = false; @@ -11103,6 +11055,21 @@ void LLVOAvatar::calculateUpdateRenderComplexity() // HUD complexity LLHUDRenderNotifier::getInstance()->updateNotificationHUD(hud_complexity_list); } + + //schedule an update to ART next frame if needed + if (LLPerfStats::tunables.userAutoTuneEnabled && + LLPerfStats::tunables.userFPSTuningStrategy != LLPerfStats::TUNE_SCENE_ONLY && + !isVisuallyMuted()) + { + LLUUID id = getID(); // <== use id to make sure this avatar didn't get deleted between frames + LL::WorkQueue::getInstance("mainloop")->post([this, id]() + { + if (gObjectList.findObject(id) != nullptr) + { + gPipeline.profileAvatar(this); + } + }); + } } } @@ -11465,6 +11432,9 @@ void LLVOAvatar::readProfileQuery(S32 retries) glGetQueryObjectui64v(mGPUTimerQuery, GL_QUERY_RESULT, &time_elapsed); mGPURenderTime = time_elapsed / 1000000.f; mGPUProfilePending = false; + + setDebugText(llformat("%d", (S32)(mGPURenderTime * 1000.f))); + } else { // wait until next frame @@ -11477,3 +11447,67 @@ void LLVOAvatar::readProfileQuery(S32 retries) } } + +F32 LLVOAvatar::getGPURenderTime() +{ + return isVisuallyMuted() ? 0.f : mGPURenderTime; +} + +// static +F32 LLVOAvatar::getTotalGPURenderTime() +{ + LL_PROFILE_ZONE_SCOPED_CATEGORY_AVATAR; + + F32 ret = 0.f; + + for (LLCharacter* iter : LLCharacter::sInstances) + { + LLVOAvatar* inst = (LLVOAvatar*) iter; + ret += inst->getGPURenderTime(); + } + + return ret; +} + +F32 LLVOAvatar::getMaxGPURenderTime() +{ + LL_PROFILE_ZONE_SCOPED_CATEGORY_AVATAR; + + F32 ret = 0.f; + + for (LLCharacter* iter : LLCharacter::sInstances) + { + LLVOAvatar* inst = (LLVOAvatar*)iter; + ret = llmax(inst->getGPURenderTime(), ret); + } + + return ret; +} + +F32 LLVOAvatar::getAverageGPURenderTime() +{ + LL_PROFILE_ZONE_SCOPED_CATEGORY_AVATAR; + + F32 ret = 0.f; + + S32 count = 0; + + for (LLCharacter* iter : LLCharacter::sInstances) + { + LLVOAvatar* inst = (LLVOAvatar*)iter; + if (!inst->isTooSlow()) + { + ret += inst->getGPURenderTime(); + ++count; + } + } + + if (count > 0) + { + ret /= count; + } + + return ret; +} + + diff --git a/indra/newview/llvoavatar.h b/indra/newview/llvoavatar.h index 2ca44b041a..e8604464ae 100644 --- a/indra/newview/llvoavatar.h +++ b/indra/newview/llvoavatar.h @@ -309,11 +309,21 @@ public: void readProfileQuery(S32 retries); // get the GPU time in ms of rendering this avatar including all attachments - // returns -1 if this avatar has not been profiled using gPipeline.profileAvatar - F32 getGPURenderTime() { return mGPURenderTime; } + // returns 0.f if this avatar has not been profiled using gPipeline.profileAvatar + // or the avatar is visually muted + F32 getGPURenderTime(); + + // get the total GPU render time in ms of all avatars that have been benched + static F32 getTotalGPURenderTime(); + + // get the max GPU render time in ms of all avatars that have been benched + static F32 getMaxGPURenderTime(); + + // get the average GPU render time in ms of all avatars that have been benched + static F32 getAverageGPURenderTime(); // get the CPU time in ms of rendering this avatar including all attachments - // return -1 if this avatar has not been profiled using gPipeline.mProfileAvatar + // return 0.f if this avatar has not been profiled using gPipeline.mProfileAvatar F32 getCPURenderTime() { return mCPURenderTime; } @@ -401,8 +411,7 @@ public: void logMetricsTimerRecord(const std::string& phase_name, F32 elapsed, bool completed); void calcMutedAVColor(); - void markARTStale(); - + protected: LLViewerStats::PhaseMap& getPhases() { return mPhases; } BOOL updateIsFullyLoaded(); @@ -423,11 +432,6 @@ private: LLFrameTimer mFullyLoadedTimer; LLFrameTimer mRuthTimer; - U32 mLastARTUpdateFrame{0}; - U64 mRenderTime{0}; - U64 mGeomTime{0}; - bool mARTStale{true}; - bool mARTCapped{false}; // variables to hold "slowness" status bool mTooSlow{false}; bool mTooSlowWithoutShadows{false}; @@ -557,11 +561,11 @@ private: // profile results // GPU render time in ms - F32 mGPURenderTime = -1.f; + F32 mGPURenderTime = 0.f; bool mGPUProfilePending = false; // CPU render time in ms - F32 mCPURenderTime = -1.f; + F32 mCPURenderTime = 0.f; // the isTooComplex method uses these mutable values to avoid recalculating too frequently // DEPRECATED -- obsolete avatar render cost values @@ -1203,8 +1207,6 @@ public: // COF version of last appearance message received for this av. S32 mLastUpdateReceivedCOFVersion; - U64 getLastART() const { return mRenderTime; } - /** Diagnostics ** ** *******************************************************************************/ diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp index 732ef1da6c..0e0dbdc071 100644 --- a/indra/newview/llworld.cpp +++ b/indra/newview/llworld.cpp @@ -1441,7 +1441,11 @@ F32 LLWorld::getNearbyAvatarsAndMaxGPUTime(std::vector &valid_near char_iter++; continue; } - gPipeline.profileAvatar(avatar); + + if (!avatar->isTooSlow()) + { + gPipeline.profileAvatar(avatar); + } nearby_max_complexity = llmax(nearby_max_complexity, avatar->getGPURenderTime()); valid_nearby_avs.push_back(*char_iter); } diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 4d9a8a594a..6ea86c4cbb 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -10073,6 +10073,9 @@ void LLPipeline::profileAvatar(LLVOAvatar* avatar, bool profile_attachments) LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; + // don't continue to profile an avatar that is known to be too slow + llassert(!avatar->isTooSlow()); + LLGLSLShader* cur_shader = LLGLSLShader::sCurBoundShaderPtr; mRT->deferredScreen.bindTarget(); @@ -10345,25 +10348,28 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar, bool preview_avatar, bool resY = llmin(nhpo2((U32) (fov*pa)), (U32) 512); resX = llmin(nhpo2((U32) (atanf(tdim.mV[0]/distance)*2.f*RAD_TO_DEG*pa)), (U32) 512); - if (!avatar->mImpostor.isComplete()) - { - avatar->mImpostor.allocate(resX, resY, GL_RGBA, true); + if (!for_profile) + { + if (!avatar->mImpostor.isComplete()) + { + avatar->mImpostor.allocate(resX, resY, GL_RGBA, true); - if (LLPipeline::sRenderDeferred) - { - addDeferredAttachments(avatar->mImpostor, true); - } - - gGL.getTexUnit(0)->bind(&avatar->mImpostor); - gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_POINT); - gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - } - else if(resX != avatar->mImpostor.getWidth() || resY != avatar->mImpostor.getHeight()) - { - avatar->mImpostor.resize(resX,resY); - } + if (LLPipeline::sRenderDeferred) + { + addDeferredAttachments(avatar->mImpostor, true); + } + + gGL.getTexUnit(0)->bind(&avatar->mImpostor); + gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_POINT); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + } + else if (resX != avatar->mImpostor.getWidth() || resY != avatar->mImpostor.getHeight()) + { + avatar->mImpostor.resize(resX, resY); + } - avatar->mImpostor.bindTarget(); + avatar->mImpostor.bindTarget(); + } } F32 old_alpha = LLDrawPoolAvatar::sMinimumAlpha; @@ -10466,7 +10472,7 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar, bool preview_avatar, bool gGL.popMatrix(); } - if (!preview_avatar) + if (!preview_avatar && !for_profile) { avatar->mImpostor.flush(); avatar->setImpostorDim(tdim); -- cgit v1.3 From 06bdee663433bf5b12eddcbcfcb8785546354c28 Mon Sep 17 00:00:00 2001 From: Brad Linden Date: Thu, 11 May 2023 12:18:45 -0700 Subject: Xcode build fixes for DRTVWR-559 --- indra/newview/llperfstats.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'indra/newview/llperfstats.cpp') diff --git a/indra/newview/llperfstats.cpp b/indra/newview/llperfstats.cpp index 2281475d4a..395ac0e788 100644 --- a/indra/newview/llperfstats.cpp +++ b/indra/newview/llperfstats.cpp @@ -175,11 +175,13 @@ namespace LLPerfStats // RENDER_MESHREPO, StatType_t::RENDER_IDLE }; +#if 0 static constexpr std::initializer_list avatarStatsToAvg = { StatType_t::RENDER_GEOMETRY, StatType_t::RENDER_SHADOWS, StatType_t::RENDER_COMBINED, StatType_t::RENDER_IDLE }; +#endif if( /*sceneStats[static_cast(StatType_t::RENDER_FPSLIMIT)] != 0 ||*/ sceneStats[static_cast(StatType_t::RENDER_SLEEP)] != 0 ) @@ -291,7 +293,7 @@ namespace LLPerfStats sAverageAvatarTime = LLVOAvatar::getAverageGPURenderTime(); sMaxAvatarTime = LLVOAvatar::getMaxGPURenderTime(); - auto& general = LL::WorkQueue::getInstance("General"); + auto general = LL::WorkQueue::getInstance("General"); if (general) { -- cgit v1.3 From e3f9244375e3ddfb96a38afac007f0a5a68d3b46 Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Fri, 12 May 2023 18:09:35 -0500 Subject: SL-19710 Fix for deadlock in LLPerfStats. Move General thread initialization to earlier in session (unrelated). --- indra/newview/llappviewer.cpp | 6 ++++++ indra/newview/llperfstats.cpp | 22 +--------------------- indra/newview/llperfstats.h | 32 +++++++++++++++++++------------- indra/newview/llstartup.cpp | 3 --- indra/newview/llviewerdisplay.cpp | 3 ++- 5 files changed, 28 insertions(+), 38 deletions(-) (limited to 'indra/newview/llperfstats.cpp') diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index c9fc0e2cc8..ecb5b81abd 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -2214,6 +2214,10 @@ bool LLAppViewer::initThreads() LLAppViewer::sTextureFetch = new LLTextureFetch(LLAppViewer::getTextureCache(), enable_threads && true, app_metrics_qa_mode); + + // general task background thread (LLPerfStats, etc) + LLAppViewer::instance()->initGeneralThread(); + LLAppViewer::sPurgeDiskCacheThread = new LLPurgeDiskCacheThread(); if (LLTrace::BlockTimer::sLog || LLTrace::BlockTimer::sMetricLog) @@ -5632,6 +5636,8 @@ void LLAppViewer::pauseMainloopTimeout() void LLAppViewer::pingMainloopTimeout(const std::string& state, F32 secs) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_APP; + if(mMainloopTimeout) { if(secs < 0.0f) diff --git a/indra/newview/llperfstats.cpp b/indra/newview/llperfstats.cpp index 395ac0e788..64e66d520b 100644 --- a/indra/newview/llperfstats.cpp +++ b/indra/newview/llperfstats.cpp @@ -146,7 +146,7 @@ namespace LLPerfStats resetChanges(); } - StatsRecorder::StatsRecorder():q(1024*16) + StatsRecorder::StatsRecorder() { // create a queue tunables.initialiseFromSettings(); @@ -292,26 +292,6 @@ namespace LLPerfStats sTotalAvatarTime = LLVOAvatar::getTotalGPURenderTime(); sAverageAvatarTime = LLVOAvatar::getAverageGPURenderTime(); sMaxAvatarTime = LLVOAvatar::getMaxGPURenderTime(); - - auto general = LL::WorkQueue::getInstance("General"); - - if (general) - { - general->post([] { StatsRecorder::update(); }); - } - } - - // called once per main loop iteration on General thread - void StatsRecorder::update() - { - LL_PROFILE_ZONE_SCOPED_CATEGORY_STATS; - StatsRecord upd; - auto& instance{ StatsRecorder::getInstance() }; - - while (enabled() && !LLApp::isQuitting() && instance.q.tryPop(upd)) - { - instance.processUpdate(upd); - } } //static diff --git a/indra/newview/llperfstats.h b/indra/newview/llperfstats.h index bb5677f237..33777abdbf 100644 --- a/indra/newview/llperfstats.h +++ b/indra/newview/llperfstats.h @@ -162,12 +162,7 @@ namespace LLPerfStats extern Tunables tunables; class StatsRecorder{ - using Queue = LLThreadSafeQueue; public: - - // called once per main loop iteration on General thread - static void update(); - static inline StatsRecorder& getInstance() { static StatsRecorder instance; @@ -176,9 +171,24 @@ namespace LLPerfStats static inline void setFocusAv(const LLUUID& avID){focusAv = avID;}; static inline const LLUUID& getFocusAv(){return focusAv;}; static inline void setAutotuneInit(){autotuneInit = true;}; - static inline void send(StatsRecord && upd){StatsRecorder::getInstance().q.pushFront(std::move(upd));}; - static void endFrame(){StatsRecorder::getInstance().q.pushFront(StatsRecord{StatType_t::RENDER_DONE, ObjType_t::OT_GENERAL, LLUUID::null, LLUUID::null, 0});}; - static void clearStats(){StatsRecorder::getInstance().q.pushFront(StatsRecord{StatType_t::RENDER_DONE, ObjType_t::OT_GENERAL, LLUUID::null, LLUUID::null, 1});}; + + static inline void send(StatsRecord && upd) + { + LL_PROFILE_ZONE_SCOPED_CATEGORY_STATS; + StatsRecorder::getInstance().processUpdate(upd); + } + + static void endFrame() + { + LL_PROFILE_ZONE_SCOPED_CATEGORY_STATS; + StatsRecorder::getInstance().processUpdate(StatsRecord{StatType_t::RENDER_DONE, ObjType_t::OT_GENERAL, LLUUID::null, LLUUID::null, 0}); + } + + static void clearStats() + { + LL_PROFILE_ZONE_SCOPED_CATEGORY_STATS; + StatsRecorder::getInstance().processUpdate(StatsRecord{StatType_t::RENDER_DONE, ObjType_t::OT_GENERAL, LLUUID::null, LLUUID::null, 1}); + } static inline void setEnabled(bool on_or_off){collectionEnabled=on_or_off;}; static inline void enable() { collectionEnabled=true; }; @@ -284,8 +294,6 @@ namespace LLPerfStats static void toggleBuffer(); static void clearStatsBuffers(); - Queue q; - ~StatsRecorder() = default; StatsRecorder(const StatsRecorder&) = delete; StatsRecorder& operator=(const StatsRecorder&) = delete; @@ -307,7 +315,7 @@ namespace LLPerfStats start{LLTrace::BlockTimer::getCPUClockCount64()}, stat{type, ObjTypeDiscriminator, std::move(av), std::move(id), 0, isRiggedAtt, isHUDAtt} { - //LL_PROFILE_ZONE_COLOR(tracy::Color::Orange); + LL_PROFILE_ZONE_SCOPED_CATEGORY_STATS; }; template < ObjType_t OD = ObjTypeDiscriminator, @@ -324,8 +332,6 @@ namespace LLPerfStats return; } - //LL_PROFILE_ZONE_COLOR(tracy::Color::Red); - stat.time = LLTrace::BlockTimer::getCPUClockCount64() - start; StatsRecorder::send(std::move(stat)); }; diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index 65fdd400bf..3ddc33f783 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -1553,9 +1553,6 @@ bool idle_startup() gAgentCamera.resetCamera(); display_startup(); - // start up the ThreadPool we'll use for textures et al. - LLAppViewer::instance()->initGeneralThread(); - // Initialize global class data needed for surfaces (i.e. textures) LL_DEBUGS("AppInit") << "Initializing sky..." << LL_ENDL; // Initialize all of the viewer object classes for the first time (doing things like texture fetches. diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp index a2938eaefe..6065fa1b34 100644 --- a/indra/newview/llviewerdisplay.cpp +++ b/indra/newview/llviewerdisplay.cpp @@ -244,9 +244,10 @@ void display_stats() // Paint the display! void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) { - LLPerfStats::RecordSceneTime T (LLPerfStats::StatType_t::RENDER_DISPLAY); // render time capture - This is the main stat for overall rendering. LL_PROFILE_ZONE_NAMED_CATEGORY_DISPLAY("Render"); + LLPerfStats::RecordSceneTime T (LLPerfStats::StatType_t::RENDER_DISPLAY); // render time capture - This is the main stat for overall rendering. + if (gWindowResized) { //skip render on frames where window has been resized LL_DEBUGS("Window") << "Resizing window" << LL_ENDL; -- cgit v1.3