From c180fe2ae2b5d2e00149f9902717e02ed7042143 Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Mon, 19 Nov 2012 22:28:12 -0700 Subject: for SH-3561: capture the frame buffer contents and compare pixel differences between frames. --- indra/newview/llscenemonitor.cpp | 358 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 358 insertions(+) create mode 100644 indra/newview/llscenemonitor.cpp (limited to 'indra/newview/llscenemonitor.cpp') diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp new file mode 100644 index 0000000000..8597767c61 --- /dev/null +++ b/indra/newview/llscenemonitor.cpp @@ -0,0 +1,358 @@ +/** + * @file llscenemonitor.cpp + * @brief monitor the scene loading process. + * + * $LicenseInfo:firstyear=2003&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" +#include "llrendertarget.h" +#include "llscenemonitor.h" +#include "llviewerwindow.h" +#include "llviewerdisplay.h" +#include "llviewercontrol.h" +#include "llviewershadermgr.h" +#include "llui.h" +#include "llstartup.h" +#include "llappviewer.h" +#include "llwindow.h" +#include "llpointer.h" + +LLSceneMonitorView* gSceneMonitorView = NULL; + +LLSceneMonitor::LLSceneMonitor() : mEnabled(false), mDiff(NULL), mNeedsUpdateDiff(FALSE) +{ + mFrames[0] = NULL; + mFrames[1] = NULL; +} + +LLSceneMonitor::~LLSceneMonitor() +{ + destroyClass(); +} + +void LLSceneMonitor::destroyClass() +{ + reset(); +} + +void LLSceneMonitor::reset() +{ + delete mFrames[0]; + delete mFrames[1]; + delete mDiff; + + mFrames[0] = NULL; + mFrames[1] = NULL; + mDiff = NULL; +} + +void LLSceneMonitor::setEnabled(bool enabled) +{ + if(enabled == (bool)gSavedSettings.getBOOL("SceneLoadingMonitorEnabled")) + { + return; + } + gSavedSettings.setBOOL("SceneLoadingMonitorEnabled", enabled); +} + +bool LLSceneMonitor::preCapture() +{ + static LLCachedControl enabled(gSavedSettings,"SceneLoadingMonitorEnabled"); + static LLFrameTimer timer; + + mCurTarget = NULL; + if (!LLGLSLShader::sNoFixedFunction) + { + return false; + } + if(mEnabled != (BOOL)enabled) + { + if(mEnabled) + { + reset(); + unfreezeScene(); + } + else + { + freezeScene(); + } + + mEnabled = (BOOL)enabled; + } + + if(!mEnabled) + { + return false; + } + + if (LLStartUp::getStartupState() < STATE_STARTED) + { + return false; + } + + if(LLAppViewer::instance()->logoutRequestSent()) + { + return false; + } + + if(gWindowResized || gHeadlessClient || gTeleportDisplay || gRestoreGL || gDisconnected) + { + return false; + } + + if ( !gViewerWindow->getActive() + || !gViewerWindow->getWindow()->getVisible() + || gViewerWindow->getWindow()->getMinimized() ) + { + return false; + } + + if(timer.getElapsedTimeF32() < 1.0f) + { + return false; + } + timer.reset(); + + S32 width = gViewerWindow->getWorldViewWidthRaw(); + S32 height = gViewerWindow->getWorldViewHeightRaw(); + + if(!mFrames[0]) + { + mFrames[0] = new LLRenderTarget(); + mFrames[0]->allocate(width, height, GL_RGB, false, false, LLTexUnit::TT_TEXTURE, true); + gGL.getTexUnit(0)->bind(mFrames[0]); + gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_POINT); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + + mCurTarget = mFrames[0]; + } + else if(!mFrames[1]) + { + mFrames[1] = new LLRenderTarget(); + mFrames[1]->allocate(width, height, GL_RGB, false, false, LLTexUnit::TT_TEXTURE, true); + gGL.getTexUnit(0)->bind(mFrames[1]); + gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_POINT); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + + mCurTarget = mFrames[1]; + } + else //swap + { + mCurTarget = mFrames[0]; + mFrames[0] = mFrames[1]; + mFrames[1] = mCurTarget; + } + + if(mCurTarget->getWidth() != width || mCurTarget->getHeight() != height) //size changed + { + mCurTarget->resize(width, height, GL_RGB); + } + + return true; +} + +void LLSceneMonitor::postCapture() +{ + mCurTarget = NULL; + mNeedsUpdateDiff = TRUE; +} + +void LLSceneMonitor::freezeAvatar(LLCharacter* avatarp) +{ + mAvatarPauseHandles.push_back(avatarp->requestPause()); +} + +void LLSceneMonitor::freezeScene() +{ + //freeze all avatars + for (std::vector::iterator iter = LLCharacter::sInstances.begin(); + iter != LLCharacter::sInstances.end(); ++iter) + { + freezeAvatar((LLCharacter*)(*iter)); + } + + // freeze everything else + gSavedSettings.setBOOL("FreezeTime", TRUE); +} + +void LLSceneMonitor::unfreezeScene() +{ + //thaw all avatars + mAvatarPauseHandles.clear(); + + // thaw everything else + gSavedSettings.setBOOL("FreezeTime", FALSE); +} + +LLRenderTarget* LLSceneMonitor::getDiffTarget() const +{ + return mDiff; +} + +void LLSceneMonitor::capture() +{ + static U32 count = 0; + if(count == gFrameCount) + { + return; + } + count = gFrameCount; + + preCapture(); + + if(!mCurTarget) + { + return; + } + + U32 old_FBO = LLRenderTarget::sCurFBO; + + gGL.getTexUnit(0)->bind(mCurTarget); + glBindFramebuffer(GL_READ_FRAMEBUFFER, 0); //point to the main frame buffer. + + glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, mCurTarget->getWidth(), mCurTarget->getHeight()); //copy the content + + glBindFramebuffer(GL_READ_FRAMEBUFFER, 0); + glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); + glBindFramebuffer(GL_FRAMEBUFFER, old_FBO); + + postCapture(); +} + +void LLSceneMonitor::compare() +{ + if(!mNeedsUpdateDiff) + { + return; + } + + if(!mFrames[0] || !mFrames[1]) + { + return; + } + if(mFrames[0]->getWidth() != mFrames[1]->getWidth() || mFrames[0]->getHeight() != mFrames[1]->getHeight()) + { + return; //size does not match + } + + if (!LLGLSLShader::sNoFixedFunction) + { + return; + } + + S32 width = mFrames[0]->getWidth(); + S32 height = mFrames[0]->getHeight(); + if(!mDiff) + { + mDiff = new LLRenderTarget(); + mDiff->allocate(width, height, GL_RGBA, false, false, LLTexUnit::TT_TEXTURE, true); + } + else if(mDiff->getWidth() != width || mDiff->getHeight() != height) + { + mDiff->resize(width, height, GL_RGBA); + } + mDiff->bindTarget(); + mDiff->clear(); + + gTwoTextureCompareProgram.bind(); + + gGL.getTexUnit(0)->activate(); + gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE); + gGL.getTexUnit(0)->bind(mFrames[0]); + gGL.getTexUnit(0)->activate(); + + gGL.getTexUnit(1)->activate(); + gGL.getTexUnit(1)->enable(LLTexUnit::TT_TEXTURE); + gGL.getTexUnit(1)->bind(mFrames[1]); + gGL.getTexUnit(1)->activate(); + + gl_rect_2d_simple_tex(width, height); + + gGL.flush(); + mDiff->flush(); + + gTwoTextureCompareProgram.unbind(); + + gGL.getTexUnit(0)->disable(); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + gGL.getTexUnit(1)->disable(); + gGL.getTexUnit(1)->unbind(LLTexUnit::TT_TEXTURE); + + mNeedsUpdateDiff = FALSE; +} + +//------------------------------------------------------------------------------------------------------------- +//definition of class LLSceneMonitorView +//------------------------------------------------------------------------------------------------------------- +LLSceneMonitorView::LLSceneMonitorView(const LLRect& rect) + : LLFloater(LLSD()) +{ + setRect(rect); + setVisible(FALSE); + + setCanMinimize(false); + setCanClose(true); +} + +void LLSceneMonitorView::onClickCloseBtn() +{ + setVisible(false); +} + +void LLSceneMonitorView::setVisible(BOOL visible) +{ + if(visible != (BOOL)LLSceneMonitor::getInstance()->isEnabled()) + { + LLSceneMonitor::getInstance()->setEnabled(visible); + } + + LLView::setVisible(visible); +} + +void LLSceneMonitorView::draw() +{ + if (!LLGLSLShader::sNoFixedFunction) + { + return; + } + LLRenderTarget* target = LLSceneMonitor::getInstance()->getDiffTarget(); + if(!target) + { + return; + } + + S32 height = (S32) (gViewerWindow->getWindowRectScaled().getHeight()*0.75f); + S32 width = (S32) (gViewerWindow->getWindowRectScaled().getWidth() * 0.75f); + + LLRect new_rect; + new_rect.setLeftTopAndSize(getRect().mLeft, getRect().mTop, width, height); + setRect(new_rect); + + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + gl_rect_2d(0, getRect().getHeight(), getRect().getWidth(), 0, LLColor4(0.f, 0.f, 0.f, 0.25f)); + + gl_draw_scaled_target(0, 0, getRect().getWidth(), getRect().getHeight(), target);//, LLColor4(0.f, 0.f, 0.f, 0.25f)); + + LLView::draw(); +} + -- cgit v1.2.3 From 6ae6abae26200c80a15d2e2d899ae6970602ff04 Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Wed, 21 Nov 2012 13:29:15 -0700 Subject: more for SH-3571: display frame-to-frame pixel differences on screen --- indra/newview/llscenemonitor.cpp | 43 ++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 22 deletions(-) (limited to 'indra/newview/llscenemonitor.cpp') diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp index 8597767c61..0730281d85 100644 --- a/indra/newview/llscenemonitor.cpp +++ b/indra/newview/llscenemonitor.cpp @@ -39,7 +39,12 @@ LLSceneMonitorView* gSceneMonitorView = NULL; -LLSceneMonitor::LLSceneMonitor() : mEnabled(false), mDiff(NULL), mNeedsUpdateDiff(FALSE) +LLSceneMonitor::LLSceneMonitor() : + mEnabled(FALSE), + mDiff(NULL), + mCurTarget(NULL), + mNeedsUpdateDiff(FALSE), + mDebugViewerVisible(FALSE) { mFrames[0] = NULL; mFrames[1] = NULL; @@ -66,18 +71,14 @@ void LLSceneMonitor::reset() mDiff = NULL; } -void LLSceneMonitor::setEnabled(bool enabled) +void LLSceneMonitor::setDebugViewerVisible(BOOL visible) { - if(enabled == (bool)gSavedSettings.getBOOL("SceneLoadingMonitorEnabled")) - { - return; - } - gSavedSettings.setBOOL("SceneLoadingMonitorEnabled", enabled); + mDebugViewerVisible = visible; } bool LLSceneMonitor::preCapture() { - static LLCachedControl enabled(gSavedSettings,"SceneLoadingMonitorEnabled"); + static LLCachedControl monitor_enabled(gSavedSettings,"SceneLoadingMonitorEnabled"); static LLFrameTimer timer; mCurTarget = NULL; @@ -85,7 +86,9 @@ bool LLSceneMonitor::preCapture() { return false; } - if(mEnabled != (BOOL)enabled) + + BOOL enabled = (BOOL)monitor_enabled || mDebugViewerVisible; + if(mEnabled != enabled) { if(mEnabled) { @@ -97,7 +100,7 @@ bool LLSceneMonitor::preCapture() freezeScene(); } - mEnabled = (BOOL)enabled; + mEnabled = enabled; } if(!mEnabled) @@ -260,8 +263,8 @@ void LLSceneMonitor::compare() return; } - S32 width = mFrames[0]->getWidth(); - S32 height = mFrames[0]->getHeight(); + S32 width = gViewerWindow->getWindowWidthRaw(); + S32 height = gViewerWindow->getWindowHeightRaw(); if(!mDiff) { mDiff = new LLRenderTarget(); @@ -288,7 +291,6 @@ void LLSceneMonitor::compare() gl_rect_2d_simple_tex(width, height); - gGL.flush(); mDiff->flush(); gTwoTextureCompareProgram.unbind(); @@ -321,10 +323,7 @@ void LLSceneMonitorView::onClickCloseBtn() void LLSceneMonitorView::setVisible(BOOL visible) { - if(visible != (BOOL)LLSceneMonitor::getInstance()->isEnabled()) - { - LLSceneMonitor::getInstance()->setEnabled(visible); - } + LLSceneMonitor::getInstance()->setDebugViewerVisible(visible); LLView::setVisible(visible); } @@ -341,17 +340,17 @@ void LLSceneMonitorView::draw() return; } - S32 height = (S32) (gViewerWindow->getWindowRectScaled().getHeight()*0.75f); - S32 width = (S32) (gViewerWindow->getWindowRectScaled().getWidth() * 0.75f); + S32 height = (S32) (gViewerWindow->getWindowRectScaled().getHeight()*0.5f); + S32 width = (S32) (gViewerWindow->getWindowRectScaled().getWidth() * 0.5f); LLRect new_rect; new_rect.setLeftTopAndSize(getRect().mLeft, getRect().mTop, width, height); setRect(new_rect); - gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - gl_rect_2d(0, getRect().getHeight(), getRect().getWidth(), 0, LLColor4(0.f, 0.f, 0.f, 0.25f)); + //gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + //gl_rect_2d(0, getRect().getHeight(), getRect().getWidth(), 0, LLColor4(0.f, 0.f, 0.f, 0.25f)); - gl_draw_scaled_target(0, 0, getRect().getWidth(), getRect().getHeight(), target);//, LLColor4(0.f, 0.f, 0.f, 0.25f)); + gl_draw_scaled_target(0, 0, getRect().getWidth(), getRect().getHeight(), target); LLView::draw(); } -- cgit v1.2.3 From 21409a3aaaef71102195d65fc35cebdb5d941a26 Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Fri, 30 Nov 2012 22:50:06 -0700 Subject: for SH-3350 and SH-3353: Report frame-to-frame visual deltas as an LLStat --- indra/newview/llscenemonitor.cpp | 188 ++++++++++++++++++++++++++------------- 1 file changed, 127 insertions(+), 61 deletions(-) (limited to 'indra/newview/llscenemonitor.cpp') diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp index 0730281d85..adeada04ca 100644 --- a/indra/newview/llscenemonitor.cpp +++ b/indra/newview/llscenemonitor.cpp @@ -36,18 +36,24 @@ #include "llappviewer.h" #include "llwindow.h" #include "llpointer.h" +#include "llspatialpartition.h" LLSceneMonitorView* gSceneMonitorView = NULL; LLSceneMonitor::LLSceneMonitor() : mEnabled(FALSE), - mDiff(NULL), + mDiff(NULL), + mDiffResult(0.f), + mDiffTolerance(0.1f), mCurTarget(NULL), - mNeedsUpdateDiff(FALSE), - mDebugViewerVisible(FALSE) + mNeedsUpdateDiff(FALSE), + mHasNewDiff(FALSE), + mHasNewQueryResult(FALSE), + mDebugViewerVisible(FALSE), + mQueryObject(0) { mFrames[0] = NULL; - mFrames[1] = NULL; + mFrames[1] = NULL; } LLSceneMonitor::~LLSceneMonitor() @@ -69,6 +75,15 @@ void LLSceneMonitor::reset() mFrames[0] = NULL; mFrames[1] = NULL; mDiff = NULL; + mCurTarget = NULL; + + unfreezeScene(); + + if(mQueryObject > 0) + { + release_occlusion_query_object_name(mQueryObject); + mQueryObject = 0; + } } void LLSceneMonitor::setDebugViewerVisible(BOOL visible) @@ -108,28 +123,6 @@ bool LLSceneMonitor::preCapture() return false; } - if (LLStartUp::getStartupState() < STATE_STARTED) - { - return false; - } - - if(LLAppViewer::instance()->logoutRequestSent()) - { - return false; - } - - if(gWindowResized || gHeadlessClient || gTeleportDisplay || gRestoreGL || gDisconnected) - { - return false; - } - - if ( !gViewerWindow->getActive() - || !gViewerWindow->getWindow()->getVisible() - || gViewerWindow->getWindow()->getMinimized() ) - { - return false; - } - if(timer.getElapsedTimeF32() < 1.0f) { return false; @@ -174,12 +167,6 @@ bool LLSceneMonitor::preCapture() return true; } -void LLSceneMonitor::postCapture() -{ - mCurTarget = NULL; - mNeedsUpdateDiff = TRUE; -} - void LLSceneMonitor::freezeAvatar(LLCharacter* avatarp) { mAvatarPauseHandles.push_back(avatarp->requestPause()); @@ -207,19 +194,14 @@ void LLSceneMonitor::unfreezeScene() gSavedSettings.setBOOL("FreezeTime", FALSE); } -LLRenderTarget* LLSceneMonitor::getDiffTarget() const -{ - return mDiff; -} - void LLSceneMonitor::capture() { - static U32 count = 0; - if(count == gFrameCount) + static U32 last_capture_time = 0; + if(last_capture_time == gFrameCount) { return; } - count = gFrameCount; + last_capture_time = gFrameCount; preCapture(); @@ -239,7 +221,8 @@ void LLSceneMonitor::capture() glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); glBindFramebuffer(GL_FRAMEBUFFER, old_FBO); - postCapture(); + mCurTarget = NULL; + mNeedsUpdateDiff = TRUE; } void LLSceneMonitor::compare() @@ -248,6 +231,7 @@ void LLSceneMonitor::compare() { return; } + mNeedsUpdateDiff = FALSE; if(!mFrames[0] || !mFrames[1]) { @@ -258,11 +242,6 @@ void LLSceneMonitor::compare() return; //size does not match } - if (!LLGLSLShader::sNoFixedFunction) - { - return; - } - S32 width = gViewerWindow->getWindowWidthRaw(); S32 height = gViewerWindow->getWindowHeightRaw(); if(!mDiff) @@ -274,9 +253,10 @@ void LLSceneMonitor::compare() { mDiff->resize(width, height, GL_RGBA); } + mDiff->bindTarget(); mDiff->clear(); - + gTwoTextureCompareProgram.bind(); gGL.getTexUnit(0)->activate(); @@ -288,21 +268,108 @@ void LLSceneMonitor::compare() gGL.getTexUnit(1)->enable(LLTexUnit::TT_TEXTURE); gGL.getTexUnit(1)->bind(mFrames[1]); gGL.getTexUnit(1)->activate(); - + gl_rect_2d_simple_tex(width, height); - mDiff->flush(); + mDiff->flush(); gTwoTextureCompareProgram.unbind(); - + gGL.getTexUnit(0)->disable(); gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); gGL.getTexUnit(1)->disable(); gGL.getTexUnit(1)->unbind(LLTexUnit::TT_TEXTURE); - mNeedsUpdateDiff = FALSE; + mHasNewDiff = TRUE; + + //send out the query request. + queryDiff(); +} + +void LLSceneMonitor::queryDiff() +{ + if(mDebugViewerVisible) + { + return; + } + + calcDiffAggregate(); +} + +//calculate Diff aggregate information in GPU, and enable gl occlusion query to capture it. +void LLSceneMonitor::calcDiffAggregate() +{ + if(!mHasNewDiff && !mDebugViewerVisible) + { + return; + } + + if(!mQueryObject) + { + mQueryObject = get_new_occlusion_query_object_name(); + } + + LLGLDepthTest depth(true, false, GL_ALWAYS); + if(!mDebugViewerVisible) + { + glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); + } + + LLGLSLShader* cur_shader = NULL; + + cur_shader = LLGLSLShader::sCurBoundShaderPtr; + gOneTextureFilterProgram.bind(); + gOneTextureFilterProgram.uniform1f("tolerance", mDiffTolerance); + + if(mHasNewDiff) + { + glBeginQueryARB(GL_SAMPLES_PASSED_ARB, mQueryObject); + } + + gl_draw_scaled_target(0, 0, mDiff->getWidth() * 0.5f, mDiff->getHeight() * 0.5f, mDiff); + + if(mHasNewDiff) + { + glEndQueryARB(GL_SAMPLES_PASSED_ARB); + mHasNewDiff = FALSE; + mHasNewQueryResult = TRUE; + } + + gOneTextureFilterProgram.unbind(); + + if(cur_shader != NULL) + { + cur_shader->bind(); + } + + if(!mDebugViewerVisible) + { + glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); + } } +void LLSceneMonitor::fetchQueryResult() +{ + if(!mHasNewQueryResult) + { + return; + } + mHasNewQueryResult = FALSE; + + GLuint available = 0; + glGetQueryObjectuivARB(mQueryObject, GL_QUERY_RESULT_AVAILABLE_ARB, &available); + if(!available) + { + return; + } + + GLuint count = 0; + glGetQueryObjectuivARB(mQueryObject, GL_QUERY_RESULT_ARB, &count); + + mDiffResult = count * 0.5f / (mDiff->getWidth() * mDiff->getHeight() * 0.25f); + + //llinfos << count << " : " << mDiffResult << llendl; +} //------------------------------------------------------------------------------------------------------------- //definition of class LLSceneMonitorView //------------------------------------------------------------------------------------------------------------- @@ -330,27 +397,26 @@ void LLSceneMonitorView::setVisible(BOOL visible) void LLSceneMonitorView::draw() { - if (!LLGLSLShader::sNoFixedFunction) - { - return; - } - LLRenderTarget* target = LLSceneMonitor::getInstance()->getDiffTarget(); + const LLRenderTarget* target = LLSceneMonitor::getInstance()->getDiffTarget(); if(!target) { return; } - S32 height = (S32) (gViewerWindow->getWindowRectScaled().getHeight()*0.5f); - S32 width = (S32) (gViewerWindow->getWindowRectScaled().getWidth() * 0.5f); + S32 height = target->getHeight() * 0.5f; + S32 width = target->getWidth() * 0.5f; + //S32 height = (S32) (gViewerWindow->getWindowRectScaled().getHeight()*0.5f); + //S32 width = (S32) (gViewerWindow->getWindowRectScaled().getWidth() * 0.5f); LLRect new_rect; new_rect.setLeftTopAndSize(getRect().mLeft, getRect().mTop, width, height); setRect(new_rect); - //gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - //gl_rect_2d(0, getRect().getHeight(), getRect().getWidth(), 0, LLColor4(0.f, 0.f, 0.f, 0.25f)); + //draw background + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + gl_rect_2d(0, getRect().getHeight(), getRect().getWidth(), 0, LLColor4(0.f, 0.f, 0.f, 0.25f)); - gl_draw_scaled_target(0, 0, getRect().getWidth(), getRect().getHeight(), target); + LLSceneMonitor::getInstance()->calcDiffAggregate(); LLView::draw(); } -- cgit v1.2.3 From 0270ce079c2090cd25244516648ac1691db00a0d Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Sun, 2 Dec 2012 22:12:43 -0700 Subject: more for SH-3350, add debug texts --- indra/newview/llscenemonitor.cpp | 43 ++++++++++++++++++++++++++++++++++------ 1 file changed, 37 insertions(+), 6 deletions(-) (limited to 'indra/newview/llscenemonitor.cpp') diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp index adeada04ca..43f9e9208b 100644 --- a/indra/newview/llscenemonitor.cpp +++ b/indra/newview/llscenemonitor.cpp @@ -40,6 +40,18 @@ LLSceneMonitorView* gSceneMonitorView = NULL; +// +//The procedures of monitoring when the scene finishes loading visually, +//i.e., no pixel differences among frames, are: +//1, freeze all dynamic objects and avatars; +//2, (?) disable all sky and water; +//3, capture frames periodically, by calling "capture()"; +//4, compute pixel differences between two latest captured frames, by calling "compare()", results are stored at mDiff; +//5, compute the number of pixels in mDiff above some tolerance threshold in GPU, by calling "queryDiff() -> calcDiffAggregate()"; +//6, use gl occlusion query to fetch the result from GPU, by calling "fetchQueryResult()"; +//END. +// + LLSceneMonitor::LLSceneMonitor() : mEnabled(FALSE), mDiff(NULL), @@ -50,7 +62,9 @@ LLSceneMonitor::LLSceneMonitor() : mHasNewDiff(FALSE), mHasNewQueryResult(FALSE), mDebugViewerVisible(FALSE), - mQueryObject(0) + mQueryObject(0), + mSamplingTime(1.0f), + mDiffPixelRatio(0.5f) { mFrames[0] = NULL; mFrames[1] = NULL; @@ -123,7 +137,7 @@ bool LLSceneMonitor::preCapture() return false; } - if(timer.getElapsedTimeF32() < 1.0f) + if(timer.getElapsedTimeF32() < mSamplingTime) { return false; } @@ -326,7 +340,7 @@ void LLSceneMonitor::calcDiffAggregate() glBeginQueryARB(GL_SAMPLES_PASSED_ARB, mQueryObject); } - gl_draw_scaled_target(0, 0, mDiff->getWidth() * 0.5f, mDiff->getHeight() * 0.5f, mDiff); + gl_draw_scaled_target(0, 0, mDiff->getWidth() * mDiffPixelRatio, mDiff->getHeight() * mDiffPixelRatio, mDiff); if(mHasNewDiff) { @@ -366,7 +380,7 @@ void LLSceneMonitor::fetchQueryResult() GLuint count = 0; glGetQueryObjectuivARB(mQueryObject, GL_QUERY_RESULT_ARB, &count); - mDiffResult = count * 0.5f / (mDiff->getWidth() * mDiff->getHeight() * 0.25f); + mDiffResult = count * 0.5f / (mDiff->getWidth() * mDiff->getHeight() * mDiffPixelRatio * mDiffPixelRatio); //0.5 -> (front face + back face) //llinfos << count << " : " << mDiffResult << llendl; } @@ -403,8 +417,9 @@ void LLSceneMonitorView::draw() return; } - S32 height = target->getHeight() * 0.5f; - S32 width = target->getWidth() * 0.5f; + F32 ratio = LLSceneMonitor::getInstance()->getDiffPixelRatio(); + S32 height = target->getHeight() * ratio; + S32 width = target->getWidth() * ratio; //S32 height = (S32) (gViewerWindow->getWindowRectScaled().getHeight()*0.5f); //S32 width = (S32) (gViewerWindow->getWindowRectScaled().getWidth() * 0.5f); @@ -418,6 +433,22 @@ void LLSceneMonitorView::draw() LLSceneMonitor::getInstance()->calcDiffAggregate(); + //show some texts + LLColor4 color = LLColor4::white; + S32 line_height = LLFontGL::getFontMonospace()->getLineHeight(); + + S32 lines = 0; + std::string num_str = llformat("Frame difference: %.6f", LLSceneMonitor::getInstance()->getDiffResult()); + LLFontGL::getFontMonospace()->renderUTF8(num_str, 0, 5, getRect().getHeight() - line_height * lines, color, LLFontGL::LEFT, LLFontGL::TOP); + lines++; + + num_str = llformat("Pixel tolerance: (R+G+B) < %.4f", LLSceneMonitor::getInstance()->getDiffTolerance()); + LLFontGL::getFontMonospace()->renderUTF8(num_str, 0, 5, getRect().getHeight() - line_height * lines, color, LLFontGL::LEFT, LLFontGL::TOP); + lines++; + + num_str = llformat("Sampling time: %.3f seconds", LLSceneMonitor::getInstance()->getSamplingTime()); + LLFontGL::getFontMonospace()->renderUTF8(num_str, 0, 5, getRect().getHeight() - line_height * lines, color, LLFontGL::LEFT, LLFontGL::TOP); + LLView::draw(); } -- cgit v1.2.3 From 1fbd45672fcb1e5bfc194712fc7d0d4847a651cd Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Wed, 19 Dec 2012 23:21:31 -0700 Subject: fix for SH-3640: Can not edit objects --- indra/newview/llscenemonitor.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'indra/newview/llscenemonitor.cpp') diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp index 43f9e9208b..4872200f24 100644 --- a/indra/newview/llscenemonitor.cpp +++ b/indra/newview/llscenemonitor.cpp @@ -211,6 +211,7 @@ void LLSceneMonitor::unfreezeScene() void LLSceneMonitor::capture() { static U32 last_capture_time = 0; + if(last_capture_time == gFrameCount) { return; @@ -239,6 +240,11 @@ void LLSceneMonitor::capture() mNeedsUpdateDiff = TRUE; } +bool LLSceneMonitor::needsUpdate() const +{ + return mNeedsUpdateDiff; +} + void LLSceneMonitor::compare() { if(!mNeedsUpdateDiff) -- cgit v1.2.3 From 840540be186904b1e711d79dede0c771c967950c Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 10 Jan 2013 18:42:39 -0800 Subject: SH-3405 WIP convert existing stats to lltrace system fixed gcc errors in llscenemonitor.cpp --- indra/newview/llscenemonitor.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'indra/newview/llscenemonitor.cpp') diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp index 4872200f24..189697dcf0 100644 --- a/indra/newview/llscenemonitor.cpp +++ b/indra/newview/llscenemonitor.cpp @@ -346,7 +346,7 @@ void LLSceneMonitor::calcDiffAggregate() glBeginQueryARB(GL_SAMPLES_PASSED_ARB, mQueryObject); } - gl_draw_scaled_target(0, 0, mDiff->getWidth() * mDiffPixelRatio, mDiff->getHeight() * mDiffPixelRatio, mDiff); + gl_draw_scaled_target(0, 0, S32(mDiff->getWidth() * mDiffPixelRatio), S32(mDiff->getHeight() * mDiffPixelRatio), mDiff); if(mHasNewDiff) { @@ -424,8 +424,8 @@ void LLSceneMonitorView::draw() } F32 ratio = LLSceneMonitor::getInstance()->getDiffPixelRatio(); - S32 height = target->getHeight() * ratio; - S32 width = target->getWidth() * ratio; + S32 height = (S32)(target->getHeight() * ratio); + S32 width = (S32)(target->getWidth() * ratio); //S32 height = (S32) (gViewerWindow->getWindowRectScaled().getHeight()*0.5f); //S32 width = (S32) (gViewerWindow->getWindowRectScaled().getWidth() * 0.5f); -- cgit v1.2.3 From ba54846697aded3a19cb91d53436d3ab26fa0aed Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Thu, 14 Mar 2013 20:54:28 -0600 Subject: for SH-3968: Rendering issues when scene loading monitoring code disabled on Mac. --- indra/newview/llscenemonitor.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'indra/newview/llscenemonitor.cpp') diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp index 189697dcf0..82ab90e325 100644 --- a/indra/newview/llscenemonitor.cpp +++ b/indra/newview/llscenemonitor.cpp @@ -410,6 +410,7 @@ void LLSceneMonitorView::onClickCloseBtn() void LLSceneMonitorView::setVisible(BOOL visible) { + visible = visible && LLGLSLShader::sNoFixedFunction; LLSceneMonitor::getInstance()->setDebugViewerVisible(visible); LLView::setVisible(visible); -- cgit v1.2.3 From 1f507c3cfca0c7722ebeaf71883fbaa83988e1a9 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 21 Mar 2013 00:37:20 -0700 Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics copied over scene load frame differencing changes from viewer-interesting made periodicrecording flexible enough to allow for indefinite number of periods added scene loading stats floater fixed collapsing behavior of container views --- indra/newview/llscenemonitor.cpp | 108 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 107 insertions(+), 1 deletion(-) (limited to 'indra/newview/llscenemonitor.cpp') diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp index 189697dcf0..c69f276aa2 100644 --- a/indra/newview/llscenemonitor.cpp +++ b/indra/newview/llscenemonitor.cpp @@ -37,6 +37,8 @@ #include "llwindow.h" #include "llpointer.h" #include "llspatialpartition.h" +#include "llagent.h" +#include "pipeline.h" LLSceneMonitorView* gSceneMonitorView = NULL; @@ -67,7 +69,10 @@ LLSceneMonitor::LLSceneMonitor() : mDiffPixelRatio(0.5f) { mFrames[0] = NULL; - mFrames[1] = NULL; + mFrames[1] = NULL; + + mRecording = new LLTrace::ExtendableRecording(); + mRecording->start(); } LLSceneMonitor::~LLSceneMonitor() @@ -78,6 +83,10 @@ LLSceneMonitor::~LLSceneMonitor() void LLSceneMonitor::destroyClass() { reset(); + + delete mRecording; + mRecording = NULL; + mDitheringTexture = NULL; } void LLSceneMonitor::reset() @@ -100,6 +109,67 @@ void LLSceneMonitor::reset() } } +void LLSceneMonitor::generateDitheringTexture(S32 width, S32 height) +{ +#if 1 + //4 * 4 matrix + mDitherMatrixWidth = 4; + S32 dither_matrix[4][4] = + { + {1, 9, 3, 11}, + {13, 5, 15, 7}, + {4, 12, 2, 10}, + {16, 8, 14, 6} + }; + + mDitherScale = 255.f / 17; +#else + //8 * 8 matrix + mDitherMatrixWidth = 16; + S32 dither_matrix[16][16] = + { + {1, 49, 13, 61, 4, 52, 16, 64, 1, 49, 13, 61, 4, 52, 16, 64}, + {33, 17, 45, 29, 36, 20, 48, 32, 33, 17, 45, 29, 36, 20, 48, 32}, + {9, 57, 5, 53, 12, 60, 8, 56, 9, 57, 5, 53, 12, 60, 8, 56}, + {41, 25, 37, 21, 44, 28, 40, 24, 41, 25, 37, 21, 44, 28, 40, 24}, + {3, 51, 15, 63, 2, 50, 14, 62, 3, 51, 15, 63, 2, 50, 14, 62}, + {35, 19, 47, 31, 34, 18, 46, 30, 35, 19, 47, 31, 34, 18, 46, 30}, + {11, 59, 7, 55, 10, 58, 6, 54, 11, 59, 7, 55, 10, 58, 6, 54}, + {43, 27, 39, 23, 42, 26, 38, 22, 43, 27, 39, 23, 42, 26, 38, 22}, + {1, 49, 13, 61, 4, 52, 16, 64, 1, 49, 13, 61, 4, 52, 16, 64}, + {33, 17, 45, 29, 36, 20, 48, 32, 33, 17, 45, 29, 36, 20, 48, 32}, + {9, 57, 5, 53, 12, 60, 8, 56, 9, 57, 5, 53, 12, 60, 8, 56}, + {41, 25, 37, 21, 44, 28, 40, 24, 41, 25, 37, 21, 44, 28, 40, 24}, + {3, 51, 15, 63, 2, 50, 14, 62, 3, 51, 15, 63, 2, 50, 14, 62}, + {35, 19, 47, 31, 34, 18, 46, 30, 35, 19, 47, 31, 34, 18, 46, 30}, + {11, 59, 7, 55, 10, 58, 6, 54, 11, 59, 7, 55, 10, 58, 6, 54}, + {43, 27, 39, 23, 42, 26, 38, 22, 43, 27, 39, 23, 42, 26, 38, 22} + }; + + mDitherScale = 255.f / 65; +#endif + + LLPointer image_raw = new LLImageRaw(mDitherMatrixWidth, mDitherMatrixWidth, 3); + U8* data = image_raw->getData(); + for (S32 i = 0; i < mDitherMatrixWidth; i++) + { + for (S32 j = 0; j < mDitherMatrixWidth; j++) + { + U8 val = dither_matrix[i][j]; + *data++ = val; + *data++ = val; + *data++ = val; + } + } + + mDitheringTexture = LLViewerTextureManager::getLocalTexture(image_raw.get(), FALSE) ; + mDitheringTexture->setAddressMode(LLTexUnit::TAM_WRAP); + mDitheringTexture->setFilteringOption(LLTexUnit::TFO_POINT); + + mDitherScaleS = (F32)width / mDitherMatrixWidth; + mDitherScaleT = (F32)height / mDitherMatrixWidth; +} + void LLSceneMonitor::setDebugViewerVisible(BOOL visible) { mDebugViewerVisible = visible; @@ -137,6 +207,11 @@ bool LLSceneMonitor::preCapture() return false; } + if(gAgent.isPositionChanged()) + { + mRecording->reset(); + } + if(timer.getElapsedTimeF32() < mSamplingTime) { return false; @@ -197,6 +272,9 @@ void LLSceneMonitor::freezeScene() // freeze everything else gSavedSettings.setBOOL("FreezeTime", TRUE); + + gPipeline.clearRenderTypeMask(LLPipeline::RENDER_TYPE_SKY, LLPipeline::RENDER_TYPE_WL_SKY, + LLPipeline::RENDER_TYPE_WATER, LLPipeline::RENDER_TYPE_CLOUDS, LLPipeline::END_RENDER_TYPES); } void LLSceneMonitor::unfreezeScene() @@ -206,6 +284,9 @@ void LLSceneMonitor::unfreezeScene() // thaw everything else gSavedSettings.setBOOL("FreezeTime", FALSE); + + gPipeline.setRenderTypeMask(LLPipeline::RENDER_TYPE_SKY, LLPipeline::RENDER_TYPE_WL_SKY, + LLPipeline::RENDER_TYPE_WATER, LLPipeline::RENDER_TYPE_CLOUDS, LLPipeline::END_RENDER_TYPES); } void LLSceneMonitor::capture() @@ -268,10 +349,13 @@ void LLSceneMonitor::compare() { mDiff = new LLRenderTarget(); mDiff->allocate(width, height, GL_RGBA, false, false, LLTexUnit::TT_TEXTURE, true); + + generateDitheringTexture(width, height); } else if(mDiff->getWidth() != width || mDiff->getHeight() != height) { mDiff->resize(width, height, GL_RGBA); + generateDitheringTexture(width, height); } mDiff->bindTarget(); @@ -279,6 +363,10 @@ void LLSceneMonitor::compare() gTwoTextureCompareProgram.bind(); + gTwoTextureCompareProgram.uniform1f("dither_scale", mDitherScale); + gTwoTextureCompareProgram.uniform1f("dither_scale_s", mDitherScaleS); + gTwoTextureCompareProgram.uniform1f("dither_scale_t", mDitherScaleT); + gGL.getTexUnit(0)->activate(); gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE); gGL.getTexUnit(0)->bind(mFrames[0]); @@ -289,6 +377,11 @@ void LLSceneMonitor::compare() gGL.getTexUnit(1)->bind(mFrames[1]); gGL.getTexUnit(1)->activate(); + gGL.getTexUnit(2)->activate(); + gGL.getTexUnit(2)->enable(LLTexUnit::TT_TEXTURE); + gGL.getTexUnit(2)->bind(mDitheringTexture); + gGL.getTexUnit(2)->activate(); + gl_rect_2d_simple_tex(width, height); mDiff->flush(); @@ -299,6 +392,8 @@ void LLSceneMonitor::compare() gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); gGL.getTexUnit(1)->disable(); gGL.getTexUnit(1)->unbind(LLTexUnit::TT_TEXTURE); + gGL.getTexUnit(2)->disable(); + gGL.getTexUnit(2)->unbind(LLTexUnit::TT_TEXTURE); mHasNewDiff = TRUE; @@ -368,6 +463,7 @@ void LLSceneMonitor::calcDiffAggregate() } } +static LLTrace::MeasurementStatHandle<> sFramePixelDiff("FramePixelDifference"); void LLSceneMonitor::fetchQueryResult() { if(!mHasNewQueryResult) @@ -388,6 +484,11 @@ void LLSceneMonitor::fetchQueryResult() mDiffResult = count * 0.5f / (mDiff->getWidth() * mDiff->getHeight() * mDiffPixelRatio * mDiffPixelRatio); //0.5 -> (front face + back face) + if(mDiffResult > 0.01f) + { + mRecording->extend(); + sample(sFramePixelDiff, mDiffResult); + } //llinfos << count << " : " << mDiffResult << llendl; } //------------------------------------------------------------------------------------------------------------- @@ -454,6 +555,11 @@ void LLSceneMonitorView::draw() num_str = llformat("Sampling time: %.3f seconds", LLSceneMonitor::getInstance()->getSamplingTime()); LLFontGL::getFontMonospace()->renderUTF8(num_str, 0, 5, getRect().getHeight() - line_height * lines, color, LLFontGL::LEFT, LLFontGL::TOP); + lines++; + + num_str = llformat("Scene Loading time: %.3f seconds", (F32)LLSceneMonitor::getInstance()->getRecording()->getAcceptedRecording().getDuration().value()); + LLFontGL::getFontMonospace()->renderUTF8(num_str, 0, 5, getRect().getHeight() - line_height * lines, color, LLFontGL::LEFT, LLFontGL::TOP); + lines++; LLView::draw(); } -- cgit v1.2.3 From 268ea2902d1108a1b30909340ca10ee0bea9f147 Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Mon, 25 Mar 2013 21:23:59 -0600 Subject: for SH-3833: dump frame diff values from the scene loading monitor to a log file --- indra/newview/llscenemonitor.cpp | 41 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) (limited to 'indra/newview/llscenemonitor.cpp') diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp index 0145f6f37e..5cde573855 100644 --- a/indra/newview/llscenemonitor.cpp +++ b/indra/newview/llscenemonitor.cpp @@ -486,11 +486,46 @@ void LLSceneMonitor::fetchQueryResult() if(mDiffResult > 0.01f) { - mRecording->extend(); - sample(sFramePixelDiff, mDiffResult); + addMonitorResult(); } - //llinfos << count << " : " << mDiffResult << llendl; } + +void LLSceneMonitor::addMonitorResult() +{ + mRecording->extend(); + sample(sFramePixelDiff, mDiffResult); + + ll_monitor_result_t result; + result.mTimeStamp = LLImageGL::sLastFrameTime; + result.mDiff = mDiffResult; + mMonitorResults.push_back(result); +} + +//dump results to a file _scene_monitor_results.csv +void LLSceneMonitor::dumpToFile(std::string file_name) +{ + if(mMonitorResults.empty()) + { + return; //nothing to dump + } + + std::ofstream os(file_name.c_str()); + + //total scene loading time + os << llformat("Scene Loading time: %.4f seconds\n", (F32)getRecording()->getAcceptedRecording().getDuration().value()); + + S32 num_results = mMonitorResults.size(); + for(S32 i = 0; i < num_results; i++) + { + os << llformat("%.4f %.4f\n", mMonitorResults[i].mTimeStamp, mMonitorResults[i].mDiff); + } + + os.flush(); + os.close(); + + mMonitorResults.clear(); +} + //------------------------------------------------------------------------------------------------------------- //definition of class LLSceneMonitorView //------------------------------------------------------------------------------------------------------------- -- cgit v1.2.3 From 5334c15852b0669be74546d4fa11c58a279dda2d Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Thu, 28 Mar 2013 16:31:49 -0600 Subject: change scene loading monitor frame diff filter threshold value. --- indra/newview/llscenemonitor.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'indra/newview/llscenemonitor.cpp') diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp index 5cde573855..8655aa4521 100644 --- a/indra/newview/llscenemonitor.cpp +++ b/indra/newview/llscenemonitor.cpp @@ -483,15 +483,18 @@ void LLSceneMonitor::fetchQueryResult() glGetQueryObjectuivARB(mQueryObject, GL_QUERY_RESULT_ARB, &count); mDiffResult = count * 0.5f / (mDiff->getWidth() * mDiff->getHeight() * mDiffPixelRatio * mDiffPixelRatio); //0.5 -> (front face + back face) - - if(mDiffResult > 0.01f) - { - addMonitorResult(); - } + + addMonitorResult(); } void LLSceneMonitor::addMonitorResult() { + const F32 diff_threshold = 0.001f; + if(mDiffResult < diff_threshold) + { + return; + } + mRecording->extend(); sample(sFramePixelDiff, mDiffResult); -- cgit v1.2.3 From 7a33d88886d9f9d83d3d12c95bb41e0093159d58 Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Thu, 28 Mar 2013 16:52:36 -0600 Subject: freeze particle system when monitor scene loading --- indra/newview/llscenemonitor.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'indra/newview/llscenemonitor.cpp') diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp index 8655aa4521..afb03ff268 100644 --- a/indra/newview/llscenemonitor.cpp +++ b/indra/newview/llscenemonitor.cpp @@ -39,6 +39,7 @@ #include "llspatialpartition.h" #include "llagent.h" #include "pipeline.h" +#include "llviewerpartsim.h" LLSceneMonitorView* gSceneMonitorView = NULL; @@ -273,8 +274,12 @@ void LLSceneMonitor::freezeScene() // freeze everything else gSavedSettings.setBOOL("FreezeTime", TRUE); + //disable sky, water and clouds gPipeline.clearRenderTypeMask(LLPipeline::RENDER_TYPE_SKY, LLPipeline::RENDER_TYPE_WL_SKY, LLPipeline::RENDER_TYPE_WATER, LLPipeline::RENDER_TYPE_CLOUDS, LLPipeline::END_RENDER_TYPES); + + //disable particle system + LLViewerPartSim::getInstance()->enable(false); } void LLSceneMonitor::unfreezeScene() @@ -285,8 +290,12 @@ void LLSceneMonitor::unfreezeScene() // thaw everything else gSavedSettings.setBOOL("FreezeTime", FALSE); + //enable sky, water and clouds gPipeline.setRenderTypeMask(LLPipeline::RENDER_TYPE_SKY, LLPipeline::RENDER_TYPE_WL_SKY, LLPipeline::RENDER_TYPE_WATER, LLPipeline::RENDER_TYPE_CLOUDS, LLPipeline::END_RENDER_TYPES); + + //enable particle system + LLViewerPartSim::getInstance()->enable(true); } void LLSceneMonitor::capture() -- cgit v1.2.3 From 164273afbb8131c5961266b7cb2c1e1d7973ea0b Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Thu, 4 Apr 2013 16:47:36 -0600 Subject: fix some warnings caused by scenen loading monitoring when quit viewer. --- indra/newview/llscenemonitor.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'indra/newview/llscenemonitor.cpp') diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp index afb03ff268..3a2171a014 100644 --- a/indra/newview/llscenemonitor.cpp +++ b/indra/newview/llscenemonitor.cpp @@ -65,6 +65,7 @@ LLSceneMonitor::LLSceneMonitor() : mHasNewDiff(FALSE), mHasNewQueryResult(FALSE), mDebugViewerVisible(FALSE), + mQuitting(FALSE), mQueryObject(0), mSamplingTime(1.0f), mDiffPixelRatio(0.5f) @@ -78,6 +79,7 @@ LLSceneMonitor::LLSceneMonitor() : LLSceneMonitor::~LLSceneMonitor() { + mQuitting = TRUE; destroyClass(); } @@ -287,6 +289,11 @@ void LLSceneMonitor::unfreezeScene() //thaw all avatars mAvatarPauseHandles.clear(); + if(mQuitting) + { + return; //we are quitting viewer. + } + // thaw everything else gSavedSettings.setBOOL("FreezeTime", FALSE); -- cgit v1.2.3 From 7e4c8b94d82680891116bd954289171b8f620bbc Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Wed, 10 Apr 2013 20:24:51 -0600 Subject: fix a logout crash --- indra/newview/llscenemonitor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llscenemonitor.cpp') diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp index c06d9d2689..15fe77f028 100644 --- a/indra/newview/llscenemonitor.cpp +++ b/indra/newview/llscenemonitor.cpp @@ -523,7 +523,7 @@ void LLSceneMonitor::addMonitorResult() //dump results to a file _scene_monitor_results.csv void LLSceneMonitor::dumpToFile(std::string file_name) { - if(mMonitorResults.empty()) + if(mMonitorResults.empty() || !getRecording()) { return; //nothing to dump } -- cgit v1.2.3 From c6737163854981d94fde8bdd440eaf4bbc816b4f Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 23 Apr 2013 18:52:34 -0700 Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics convert scene monitor to use extendable periodic recording --- indra/newview/llscenemonitor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llscenemonitor.cpp') diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp index 15fe77f028..7f7e61cc88 100644 --- a/indra/newview/llscenemonitor.cpp +++ b/indra/newview/llscenemonitor.cpp @@ -73,7 +73,7 @@ LLSceneMonitor::LLSceneMonitor() : mFrames[0] = NULL; mFrames[1] = NULL; - mRecording = new LLTrace::ExtendableRecording(); + mRecording = new LLTrace::ExtendablePeriodicRecording(); mRecording->start(); } -- cgit v1.2.3 From 3a0e45ff088278cba5314974be6539b05009b8da Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 10 May 2013 17:57:12 -0700 Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics renamed LLView::handleVisibilityChange to onVisibilityChange to reflect standard naming conventions for handlers vs. reactors --- indra/newview/llscenemonitor.cpp | 183 ++++++++++++++++++--------------------- 1 file changed, 85 insertions(+), 98 deletions(-) (limited to 'indra/newview/llscenemonitor.cpp') diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp index 7f7e61cc88..5a5fd6f333 100644 --- a/indra/newview/llscenemonitor.cpp +++ b/indra/newview/llscenemonitor.cpp @@ -56,18 +56,16 @@ LLSceneMonitorView* gSceneMonitorView = NULL; // LLSceneMonitor::LLSceneMonitor() : - mEnabled(FALSE), + mEnabled(false), mDiff(NULL), mDiffResult(0.f), mDiffTolerance(0.1f), - mCurTarget(NULL), - mNeedsUpdateDiff(FALSE), - mHasNewDiff(FALSE), - mHasNewQueryResult(FALSE), - mDebugViewerVisible(FALSE), - mQuitting(FALSE), + mNeedsUpdateDiff(false), + mHasNewDiff(false), + mHasNewQueryResult(false), + mDebugViewerVisible(false), + mQuitting(false), mQueryObject(0), - mSamplingTime(1.0f), mDiffPixelRatio(0.5f) { mFrames[0] = NULL; @@ -79,7 +77,7 @@ LLSceneMonitor::LLSceneMonitor() : LLSceneMonitor::~LLSceneMonitor() { - mQuitting = TRUE; + mQuitting = true; destroyClass(); } @@ -101,7 +99,6 @@ void LLSceneMonitor::reset() mFrames[0] = NULL; mFrames[1] = NULL; mDiff = NULL; - mCurTarget = NULL; unfreezeScene(); @@ -173,54 +170,15 @@ void LLSceneMonitor::generateDitheringTexture(S32 width, S32 height) mDitherScaleT = (F32)height / mDitherMatrixWidth; } -void LLSceneMonitor::setDebugViewerVisible(BOOL visible) +void LLSceneMonitor::setDebugViewerVisible(bool visible) { mDebugViewerVisible = visible; } -bool LLSceneMonitor::preCapture() +LLRenderTarget& LLSceneMonitor::getCaptureTarget() { - static LLCachedControl monitor_enabled(gSavedSettings,"SceneLoadingMonitorEnabled"); - static LLFrameTimer timer; - - mCurTarget = NULL; - if (!LLGLSLShader::sNoFixedFunction) - { - return false; - } - - BOOL enabled = (BOOL)monitor_enabled || mDebugViewerVisible; - if(mEnabled != enabled) - { - if(mEnabled) - { - reset(); - unfreezeScene(); - } - else - { - freezeScene(); - } - - mEnabled = enabled; - } - - if(!mEnabled) - { - return false; - } - - if(gAgent.isPositionChanged()) - { - mRecording->reset(); - } + LLRenderTarget* cur_target = NULL; - if(timer.getElapsedTimeF32() < mSamplingTime) - { - return false; - } - timer.reset(); - S32 width = gViewerWindow->getWorldViewWidthRaw(); S32 height = gViewerWindow->getWorldViewHeightRaw(); @@ -232,7 +190,7 @@ bool LLSceneMonitor::preCapture() gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_POINT); gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - mCurTarget = mFrames[0]; + cur_target = mFrames[0]; } else if(!mFrames[1]) { @@ -242,21 +200,22 @@ bool LLSceneMonitor::preCapture() gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_POINT); gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - mCurTarget = mFrames[1]; + cur_target = mFrames[1]; } else //swap { - mCurTarget = mFrames[0]; + cur_target = mFrames[0]; mFrames[0] = mFrames[1]; - mFrames[1] = mCurTarget; + mFrames[1] = cur_target; } - if(mCurTarget->getWidth() != width || mCurTarget->getHeight() != height) //size changed + if(cur_target->getWidth() != width || cur_target->getHeight() != height) //size changed { - mCurTarget->resize(width, height, GL_RGB); + cur_target->resize(width, height, GL_RGB); } - return true; + // we're promising the target exists + return *cur_target; } void LLSceneMonitor::freezeAvatar(LLCharacter* avatarp) @@ -308,33 +267,56 @@ void LLSceneMonitor::unfreezeScene() void LLSceneMonitor::capture() { static U32 last_capture_time = 0; + static LLCachedControl monitor_enabled(gSavedSettings,"SceneLoadingMonitorEnabled"); + static LLCachedControl scene_load_sample_time(gSavedSettings, "SceneLoadingMonitorSampleTime"); + static LLFrameTimer timer; - if(last_capture_time == gFrameCount) + LLTrace::Recording* last_frame_recording = LLTrace::get_frame_recording()->getPrevRecording(); + if (last_frame_recording->getMax(LLViewerCamera::getVelocityStat()) > 0.001f + || last_frame_recording->getMax(LLViewerCamera::getAngularVelocityStat() > 0.01f) { - return; + mRecording->reset(); } - last_capture_time = gFrameCount; - preCapture(); - - if(!mCurTarget) + bool enabled = monitor_enabled || mDebugViewerVisible; + if(mEnabled != enabled) { - return; + if(mEnabled) + { + reset(); + unfreezeScene(); + } + else + { + freezeScene(); + } + + mEnabled = enabled; } - - U32 old_FBO = LLRenderTarget::sCurFBO; - gGL.getTexUnit(0)->bind(mCurTarget); - glBindFramebuffer(GL_READ_FRAMEBUFFER, 0); //point to the main frame buffer. + if(timer.getElapsedTimeF32() > scene_load_sample_time() + && mEnabled + && LLGLShader::sNoFixedFunction + && last_capture_time != gFrameCount) + { + timer.reset(); + last_capture_time = gFrameCount; + + LLRenderTarget& cur_target = getCaptureTarget(); + + U32 old_FBO = LLRenderTarget::sCurFBO; + + gGL.getTexUnit(0)->bind(&cur_target); + glBindFramebuffer(GL_READ_FRAMEBUFFER, 0); //point to the main frame buffer. - glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, mCurTarget->getWidth(), mCurTarget->getHeight()); //copy the content + glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, cur_target.getWidth(), cur_target.getHeight()); //copy the content - glBindFramebuffer(GL_READ_FRAMEBUFFER, 0); - glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); - glBindFramebuffer(GL_FRAMEBUFFER, old_FBO); + glBindFramebuffer(GL_READ_FRAMEBUFFER, 0); + glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); + glBindFramebuffer(GL_FRAMEBUFFER, old_FBO); - mCurTarget = NULL; - mNeedsUpdateDiff = TRUE; + mNeedsUpdateDiff = true; + } } bool LLSceneMonitor::needsUpdate() const @@ -342,27 +324,33 @@ bool LLSceneMonitor::needsUpdate() const return mNeedsUpdateDiff; } +static LLFastTimer::DeclareTimer FTM_GENERATE_SCENE_LOAD_DITHER_TEXTURE("Generate Scene Load Dither Texture"); +static LLFastTimer::DeclareTimer FTM_SCENE_LOAD_IMAGE_DIFF("Scene Load Image Diff"); + void LLSceneMonitor::compare() { if(!mNeedsUpdateDiff) { return; } - mNeedsUpdateDiff = FALSE; + mNeedsUpdateDiff = false; if(!mFrames[0] || !mFrames[1]) { return; } if(mFrames[0]->getWidth() != mFrames[1]->getWidth() || mFrames[0]->getHeight() != mFrames[1]->getHeight()) - { - return; //size does not match + { //size does not match + return; } + LLFastTimer _(FTM_SCENE_LOAD_IMAGE_DIFF); + S32 width = gViewerWindow->getWindowWidthRaw(); S32 height = gViewerWindow->getWindowHeightRaw(); if(!mDiff) { + LLFastTimer _(FTM_GENERATE_SCENE_LOAD_DITHER_TEXTURE); mDiff = new LLRenderTarget(); mDiff->allocate(width, height, GL_RGBA, false, false, LLTexUnit::TT_TEXTURE, true); @@ -370,6 +358,7 @@ void LLSceneMonitor::compare() } else if(mDiff->getWidth() != width || mDiff->getHeight() != height) { + LLFastTimer _(FTM_GENERATE_SCENE_LOAD_DITHER_TEXTURE); mDiff->resize(width, height, GL_RGBA); generateDitheringTexture(width, height); } @@ -411,9 +400,8 @@ void LLSceneMonitor::compare() gGL.getTexUnit(2)->disable(); gGL.getTexUnit(2)->unbind(LLTexUnit::TT_TEXTURE); - mHasNewDiff = TRUE; + mHasNewDiff = true; - //send out the query request. queryDiff(); } @@ -430,6 +418,8 @@ void LLSceneMonitor::queryDiff() //calculate Diff aggregate information in GPU, and enable gl occlusion query to capture it. void LLSceneMonitor::calcDiffAggregate() { + LLFastTimer _(FTM_SCENE_LOAD_IMAGE_DIFF); + if(!mHasNewDiff && !mDebugViewerVisible) { return; @@ -462,8 +452,8 @@ void LLSceneMonitor::calcDiffAggregate() if(mHasNewDiff) { glEndQueryARB(GL_SAMPLES_PASSED_ARB); - mHasNewDiff = FALSE; - mHasNewQueryResult = TRUE; + mHasNewDiff = false; + mHasNewQueryResult = true; } gOneTextureFilterProgram.unbind(); @@ -482,11 +472,13 @@ void LLSceneMonitor::calcDiffAggregate() static LLTrace::MeasurementStatHandle<> sFramePixelDiff("FramePixelDifference"); void LLSceneMonitor::fetchQueryResult() { + LLFastTimer _(FTM_SCENE_LOAD_IMAGE_DIFF); + if(!mHasNewQueryResult) { return; } - mHasNewQueryResult = FALSE; + mHasNewQueryResult = false; GLuint available = 0; glGetQueryObjectuivARB(mQueryObject, GL_QUERY_RESULT_AVAILABLE_ARB, &available); @@ -500,25 +492,22 @@ void LLSceneMonitor::fetchQueryResult() mDiffResult = count * 0.5f / (mDiff->getWidth() * mDiff->getHeight() * mDiffPixelRatio * mDiffPixelRatio); //0.5 -> (front face + back face) - addMonitorResult(); -} + sample(sFramePixelDiff, mDiffResult); -void LLSceneMonitor::addMonitorResult() -{ const F32 diff_threshold = 0.001f; - if(mDiffResult < diff_threshold) + if(mDiffResult > diff_threshold) { - return; - } - mRecording->extend(); - sample(sFramePixelDiff, mDiffResult); + } +} +void LLSceneMonitor::addMonitorResult() +{ ll_monitor_result_t result; result.mTimeStamp = LLImageGL::sLastFrameTime; result.mDiff = mDiffResult; mMonitorResults.push_back(result); - } +} //dump results to a file _scene_monitor_results.csv void LLSceneMonitor::dumpToFile(std::string file_name) @@ -563,12 +552,10 @@ void LLSceneMonitorView::onClickCloseBtn() setVisible(false); } -void LLSceneMonitorView::setVisible(BOOL visible) +void LLSceneMonitorView::onVisibilityChange(BOOL visible) { visible = visible && LLGLSLShader::sNoFixedFunction; LLSceneMonitor::getInstance()->setDebugViewerVisible(visible); - - LLView::setVisible(visible); } void LLSceneMonitorView::draw() @@ -608,7 +595,7 @@ void LLSceneMonitorView::draw() LLFontGL::getFontMonospace()->renderUTF8(num_str, 0, 5, getRect().getHeight() - line_height * lines, color, LLFontGL::LEFT, LLFontGL::TOP); lines++; - num_str = llformat("Sampling time: %.3f seconds", LLSceneMonitor::getInstance()->getSamplingTime()); + num_str = llformat("Sampling time: %.3f seconds", gSavedSettings->getF32("SceneLoadingMonitorSampleTime")); LLFontGL::getFontMonospace()->renderUTF8(num_str, 0, 5, getRect().getHeight() - line_height * lines, color, LLFontGL::LEFT, LLFontGL::TOP); lines++; -- cgit v1.2.3 From edf731c180a61dc49255ebb25342b6256e8d6065 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 10 May 2013 22:24:18 -0700 Subject: BUILDFIX - bad logic in scene monitor frame recording --- indra/newview/llscenemonitor.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'indra/newview/llscenemonitor.cpp') diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp index 5a5fd6f333..2e819c8efe 100644 --- a/indra/newview/llscenemonitor.cpp +++ b/indra/newview/llscenemonitor.cpp @@ -271,9 +271,9 @@ void LLSceneMonitor::capture() static LLCachedControl scene_load_sample_time(gSavedSettings, "SceneLoadingMonitorSampleTime"); static LLFrameTimer timer; - LLTrace::Recording* last_frame_recording = LLTrace::get_frame_recording()->getPrevRecording(); - if (last_frame_recording->getMax(LLViewerCamera::getVelocityStat()) > 0.001f - || last_frame_recording->getMax(LLViewerCamera::getAngularVelocityStat() > 0.01f) + LLTrace::Recording& last_frame_recording = LLTrace::get_frame_recording().getLastRecording(); + if (last_frame_recording.getSum(*LLViewerCamera::getVelocityStat()) > 0.001f + || last_frame_recording.getSum(*LLViewerCamera::getAngularVelocityStat()) > 0.01f) { mRecording->reset(); } @@ -296,7 +296,7 @@ void LLSceneMonitor::capture() if(timer.getElapsedTimeF32() > scene_load_sample_time() && mEnabled - && LLGLShader::sNoFixedFunction + && LLGLSLShader::sNoFixedFunction && last_capture_time != gFrameCount) { timer.reset(); @@ -595,7 +595,7 @@ void LLSceneMonitorView::draw() LLFontGL::getFontMonospace()->renderUTF8(num_str, 0, 5, getRect().getHeight() - line_height * lines, color, LLFontGL::LEFT, LLFontGL::TOP); lines++; - num_str = llformat("Sampling time: %.3f seconds", gSavedSettings->getF32("SceneLoadingMonitorSampleTime")); + num_str = llformat("Sampling time: %.3f seconds", gSavedSettings.getF32("SceneLoadingMonitorSampleTime")); LLFontGL::getFontMonospace()->renderUTF8(num_str, 0, 5, getRect().getHeight() - line_height * lines, color, LLFontGL::LEFT, LLFontGL::TOP); lines++; -- cgit v1.2.3 From 405aa5b1ba7b786da05136fc9cc1f0a664111ce8 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 13 May 2013 11:04:10 -0700 Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics added log output for scene monitoring --- indra/newview/llscenemonitor.cpp | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'indra/newview/llscenemonitor.cpp') diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp index 2e819c8efe..9546c786d1 100644 --- a/indra/newview/llscenemonitor.cpp +++ b/indra/newview/llscenemonitor.cpp @@ -50,7 +50,7 @@ LLSceneMonitorView* gSceneMonitorView = NULL; //2, (?) disable all sky and water; //3, capture frames periodically, by calling "capture()"; //4, compute pixel differences between two latest captured frames, by calling "compare()", results are stored at mDiff; -//5, compute the number of pixels in mDiff above some tolerance threshold in GPU, by calling "queryDiff() -> calcDiffAggregate()"; +//5, compute the number of pixels in mDiff above some tolerance threshold in GPU, by calling "calcDiffAggregate()"; //6, use gl occlusion query to fetch the result from GPU, by calling "fetchQueryResult()"; //END. // @@ -402,17 +402,10 @@ void LLSceneMonitor::compare() mHasNewDiff = true; - queryDiff(); -} - -void LLSceneMonitor::queryDiff() -{ - if(mDebugViewerVisible) + if (!mDebugViewerVisible) { - return; + calcDiffAggregate(); } - - calcDiffAggregate(); } //calculate Diff aggregate information in GPU, and enable gl occlusion query to capture it. @@ -492,6 +485,7 @@ void LLSceneMonitor::fetchQueryResult() mDiffResult = count * 0.5f / (mDiff->getWidth() * mDiff->getHeight() * mDiffPixelRatio * mDiffPixelRatio); //0.5 -> (front face + back face) + LL_DEBUGS("SceneMonitor") << "Frame difference: " << mDiffResult << LL_ENDL; sample(sFramePixelDiff, mDiffResult); const F32 diff_threshold = 0.001f; -- cgit v1.2.3 From 35f1fcc399f07571fc6b7d7af00e7d4e1e07418d Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 13 May 2013 11:44:42 -0700 Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics improved precision of scene diff log output --- indra/newview/llscenemonitor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llscenemonitor.cpp') diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp index 9546c786d1..3d8e1513dd 100644 --- a/indra/newview/llscenemonitor.cpp +++ b/indra/newview/llscenemonitor.cpp @@ -485,7 +485,7 @@ void LLSceneMonitor::fetchQueryResult() mDiffResult = count * 0.5f / (mDiff->getWidth() * mDiff->getHeight() * mDiffPixelRatio * mDiffPixelRatio); //0.5 -> (front face + back face) - LL_DEBUGS("SceneMonitor") << "Frame difference: " << mDiffResult << LL_ENDL; + LL_DEBUGS("SceneMonitor") << "Frame difference: " << std::setprecision(4) << mDiffResult << LL_ENDL; sample(sFramePixelDiff, mDiffResult); const F32 diff_threshold = 0.001f; -- cgit v1.2.3 From 12c34dc30f0cb6270c11e100fcaceb3fa6b27e81 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 16 May 2013 00:53:01 -0700 Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics renamed LLView::handleVisibilityChange to onVisibilityChange to reflect cleaned up scene monitor stats recording, now all trace stats dumped to csv also fixed extendablerecording, periodicrecording, etc. to properly implement start/stop/etc --- indra/newview/llscenemonitor.cpp | 196 ++++++++++++++++++++++++++++----------- 1 file changed, 143 insertions(+), 53 deletions(-) (limited to 'indra/newview/llscenemonitor.cpp') diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp index 3d8e1513dd..c101fe7deb 100644 --- a/indra/newview/llscenemonitor.cpp +++ b/indra/newview/llscenemonitor.cpp @@ -60,11 +60,8 @@ LLSceneMonitor::LLSceneMonitor() : mDiff(NULL), mDiffResult(0.f), mDiffTolerance(0.1f), - mNeedsUpdateDiff(false), - mHasNewDiff(false), - mHasNewQueryResult(false), + mDiffState(WAITING_FOR_NEXT_DIFF), mDebugViewerVisible(false), - mQuitting(false), mQueryObject(0), mDiffPixelRatio(0.5f) { @@ -72,12 +69,11 @@ LLSceneMonitor::LLSceneMonitor() : mFrames[1] = NULL; mRecording = new LLTrace::ExtendablePeriodicRecording(); - mRecording->start(); } LLSceneMonitor::~LLSceneMonitor() { - mQuitting = true; + mDiffState = VIEWER_QUITTING; destroyClass(); } @@ -100,6 +96,8 @@ void LLSceneMonitor::reset() mFrames[1] = NULL; mDiff = NULL; + mRecording->reset(); + unfreezeScene(); if(mQueryObject > 0) @@ -248,7 +246,7 @@ void LLSceneMonitor::unfreezeScene() //thaw all avatars mAvatarPauseHandles.clear(); - if(mQuitting) + if(mDiffState == VIEWER_QUITTING) { return; //we are quitting viewer. } @@ -267,7 +265,7 @@ void LLSceneMonitor::unfreezeScene() void LLSceneMonitor::capture() { static U32 last_capture_time = 0; - static LLCachedControl monitor_enabled(gSavedSettings,"SceneLoadingMonitorEnabled"); + static LLCachedControl monitor_enabled(gSavedSettings, "SceneLoadingMonitorEnabled"); static LLCachedControl scene_load_sample_time(gSavedSettings, "SceneLoadingMonitorSampleTime"); static LLFrameTimer timer; @@ -275,7 +273,7 @@ void LLSceneMonitor::capture() if (last_frame_recording.getSum(*LLViewerCamera::getVelocityStat()) > 0.001f || last_frame_recording.getSum(*LLViewerCamera::getAngularVelocityStat()) > 0.01f) { - mRecording->reset(); + reset(); } bool enabled = monitor_enabled || mDebugViewerVisible; @@ -283,11 +281,11 @@ void LLSceneMonitor::capture() { if(mEnabled) { - reset(); unfreezeScene(); } else { + reset(); freezeScene(); } @@ -299,7 +297,10 @@ void LLSceneMonitor::capture() && LLGLSLShader::sNoFixedFunction && last_capture_time != gFrameCount) { + mRecording->resume(); + timer.reset(); + last_capture_time = gFrameCount; LLRenderTarget& cur_target = getCaptureTarget(); @@ -315,13 +316,13 @@ void LLSceneMonitor::capture() glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); glBindFramebuffer(GL_FRAMEBUFFER, old_FBO); - mNeedsUpdateDiff = true; + mDiffState = NEED_DIFF; } } bool LLSceneMonitor::needsUpdate() const { - return mNeedsUpdateDiff; + return mDiffState == NEED_DIFF; } static LLFastTimer::DeclareTimer FTM_GENERATE_SCENE_LOAD_DITHER_TEXTURE("Generate Scene Load Dither Texture"); @@ -329,11 +330,10 @@ static LLFastTimer::DeclareTimer FTM_SCENE_LOAD_IMAGE_DIFF("Scene Load Image Dif void LLSceneMonitor::compare() { - if(!mNeedsUpdateDiff) + if(mDiffState != NEED_DIFF) { return; } - mNeedsUpdateDiff = false; if(!mFrames[0] || !mFrames[1]) { @@ -345,6 +345,7 @@ void LLSceneMonitor::compare() } LLFastTimer _(FTM_SCENE_LOAD_IMAGE_DIFF); + mDiffState = EXECUTE_DIFF; S32 width = gViewerWindow->getWindowWidthRaw(); S32 height = gViewerWindow->getWindowHeightRaw(); @@ -400,8 +401,6 @@ void LLSceneMonitor::compare() gGL.getTexUnit(2)->disable(); gGL.getTexUnit(2)->unbind(LLTexUnit::TT_TEXTURE); - mHasNewDiff = true; - if (!mDebugViewerVisible) { calcDiffAggregate(); @@ -413,7 +412,7 @@ void LLSceneMonitor::calcDiffAggregate() { LLFastTimer _(FTM_SCENE_LOAD_IMAGE_DIFF); - if(!mHasNewDiff && !mDebugViewerVisible) + if(mDiffState != EXECUTE_DIFF && !mDebugViewerVisible) { return; } @@ -435,18 +434,17 @@ void LLSceneMonitor::calcDiffAggregate() gOneTextureFilterProgram.bind(); gOneTextureFilterProgram.uniform1f("tolerance", mDiffTolerance); - if(mHasNewDiff) + if(mDiffState == EXECUTE_DIFF) { glBeginQueryARB(GL_SAMPLES_PASSED_ARB, mQueryObject); } gl_draw_scaled_target(0, 0, S32(mDiff->getWidth() * mDiffPixelRatio), S32(mDiff->getHeight() * mDiffPixelRatio), mDiff); - if(mHasNewDiff) + if(mDiffState == EXECUTE_DIFF) { glEndQueryARB(GL_SAMPLES_PASSED_ARB); - mHasNewDiff = false; - mHasNewQueryResult = true; + mDiffState = WAIT_ON_RESULT; } gOneTextureFilterProgram.unbind(); @@ -467,31 +465,30 @@ void LLSceneMonitor::fetchQueryResult() { LLFastTimer _(FTM_SCENE_LOAD_IMAGE_DIFF); - if(!mHasNewQueryResult) - { - return; - } - mHasNewQueryResult = false; - - GLuint available = 0; - glGetQueryObjectuivARB(mQueryObject, GL_QUERY_RESULT_AVAILABLE_ARB, &available); - if(!available) + if(mDiffState == WAIT_ON_RESULT) { - return; - } + mDiffState = WAITING_FOR_NEXT_DIFF; - GLuint count = 0; - glGetQueryObjectuivARB(mQueryObject, GL_QUERY_RESULT_ARB, &count); + GLuint available = 0; + glGetQueryObjectuivARB(mQueryObject, GL_QUERY_RESULT_AVAILABLE_ARB, &available); + if(available) + { + GLuint count = 0; + glGetQueryObjectuivARB(mQueryObject, GL_QUERY_RESULT_ARB, &count); - mDiffResult = count * 0.5f / (mDiff->getWidth() * mDiff->getHeight() * mDiffPixelRatio * mDiffPixelRatio); //0.5 -> (front face + back face) + mDiffResult = count * 0.5f / (mDiff->getWidth() * mDiff->getHeight() * mDiffPixelRatio * mDiffPixelRatio); //0.5 -> (front face + back face) - LL_DEBUGS("SceneMonitor") << "Frame difference: " << std::setprecision(4) << mDiffResult << LL_ENDL; - sample(sFramePixelDiff, mDiffResult); + LL_DEBUGS("SceneMonitor") << "Frame difference: " << std::setprecision(4) << mDiffResult << LL_ENDL; + sample(sFramePixelDiff, mDiffResult); - const F32 diff_threshold = 0.001f; - if(mDiffResult > diff_threshold) - { - mRecording->extend(); + mRecording->getPotentialRecording().nextPeriod(); + + static LLCachedControl diff_threshold(gSavedSettings,"SceneLoadingPixelDiffThreshold"); + if(mDiffResult > diff_threshold()) + { + mRecording->extend(); + } + } } } @@ -503,29 +500,124 @@ void LLSceneMonitor::addMonitorResult() mMonitorResults.push_back(result); } -//dump results to a file _scene_monitor_results.csv +//dump results to a file _scene_xmonitor_results.csv void LLSceneMonitor::dumpToFile(std::string file_name) { - if(mMonitorResults.empty() || !getRecording()) - { - return; //nothing to dump - } + LL_INFOS("SceneMonitor") << "Saving scene load stats to " << file_name << LL_ENDL; std::ofstream os(file_name.c_str()); //total scene loading time - os << llformat("Scene Loading time: %.4f seconds\n", (F32)getRecording()->getAcceptedRecording().getDuration().value()); + os << std::setprecision(4); + + LLTrace::PeriodicRecording& scene_load_recording = mRecording->getAcceptedRecording(); + U32 frame_count = scene_load_recording.getNumPeriods(); + + LLUnit frame_time; + + os << "Stat"; + for (S32 frame = 0; frame < frame_count; frame++) + { + frame_time += scene_load_recording.getPrevRecording(frame_count - frame).getDuration(); + os << ", " << frame_time.value(); + } + os << std::endl; + + for (LLTrace::CountStatHandle::instance_iter it = LLTrace::CountStatHandle::beginInstances(), end_it = LLTrace::CountStatHandle::endInstances(); + it != end_it; + ++it) + { + std::ostringstream row; + row << it->getName(); + + S32 samples = 0; + + for (S32 i = frame_count - 1; i >= 0; --i) + { + samples += scene_load_recording.getPrevRecording(i).getSampleCount(*it); + row << ", " << scene_load_recording.getPrevRecording(i).getSum(*it); + } + + row << std::endl; + + if (samples > 0) + { + os << row.str(); + } + } + + for (LLTrace::CountStatHandle::instance_iter it = LLTrace::CountStatHandle::beginInstances(), end_it = LLTrace::CountStatHandle::endInstances(); + it != end_it; + ++it) + { + std::ostringstream row; + row << it->getName(); + + S32 samples = 0; + + for (S32 i = frame_count - 1; i >= 0; --i) + { + samples += scene_load_recording.getPrevRecording(i).getSampleCount(*it); + row << ", " << scene_load_recording.getPrevRecording(i).getSum(*it); + } + + row << std::endl; + + if (samples > 0) + { + os << row.str(); + } + } + + for (LLTrace::MeasurementStatHandle::instance_iter it = LLTrace::MeasurementStatHandle::beginInstances(), end_it = LLTrace::MeasurementStatHandle::endInstances(); + it != end_it; + ++it) + { + std::ostringstream row; + row << it->getName(); + + S32 samples = 0; - S32 num_results = mMonitorResults.size(); - for(S32 i = 0; i < num_results; i++) + for (S32 i = frame_count - 1; i >= 0; --i) + { + samples += scene_load_recording.getPrevRecording(i).getSampleCount(*it); + row << ", " << scene_load_recording.getPrevRecording(i).getMean(*it); + } + + row << std::endl; + + if (samples > 0) + { + os << row.str(); + } + } + + for (LLTrace::MeasurementStatHandle::instance_iter it = LLTrace::MeasurementStatHandle::beginInstances(), end_it = LLTrace::MeasurementStatHandle::endInstances(); + it != end_it; + ++it) { - os << llformat("%.4f %.4f\n", mMonitorResults[i].mTimeStamp, mMonitorResults[i].mDiff); + std::ostringstream row; + row << it->getName(); + + S32 samples = 0; + + for (S32 i = frame_count - 1; i >= 0; --i) + { + samples += scene_load_recording.getPrevRecording(i).getSampleCount(*it); + row << ", " << scene_load_recording.getPrevRecording(i).getMean(*it); + } + + row << std::endl; + + if (samples > 0) + { + os << row.str(); + } } os.flush(); os.close(); - mMonitorResults.clear(); } //------------------------------------------------------------------------------------------------------------- @@ -563,8 +655,6 @@ void LLSceneMonitorView::draw() F32 ratio = LLSceneMonitor::getInstance()->getDiffPixelRatio(); S32 height = (S32)(target->getHeight() * ratio); S32 width = (S32)(target->getWidth() * ratio); - //S32 height = (S32) (gViewerWindow->getWindowRectScaled().getHeight()*0.5f); - //S32 width = (S32) (gViewerWindow->getWindowRectScaled().getWidth() * 0.5f); LLRect new_rect; new_rect.setLeftTopAndSize(getRect().mLeft, getRect().mTop, width, height); -- cgit v1.2.3 From f850ae03b399a5cc7aa32f82b8ed996518a86a2a Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 20 May 2013 00:01:57 -0700 Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics fixed copy construction of Recorders, eliminated most zero-length frames fixed reset behavior of periodic recordings and extendable recordings to clear entire history removed busy-loop recording of stats from worker threads...stats reported only when work is done --- indra/newview/llscenemonitor.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/newview/llscenemonitor.cpp') diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp index c101fe7deb..c2e00384a1 100644 --- a/indra/newview/llscenemonitor.cpp +++ b/indra/newview/llscenemonitor.cpp @@ -481,13 +481,13 @@ void LLSceneMonitor::fetchQueryResult() LL_DEBUGS("SceneMonitor") << "Frame difference: " << std::setprecision(4) << mDiffResult << LL_ENDL; sample(sFramePixelDiff, mDiffResult); - mRecording->getPotentialRecording().nextPeriod(); - static LLCachedControl diff_threshold(gSavedSettings,"SceneLoadingPixelDiffThreshold"); if(mDiffResult > diff_threshold()) { mRecording->extend(); } + + mRecording->getPotentialRecording().nextPeriod(); } } } -- cgit v1.2.3 From 1225a7a3cc29e3b6429fa0af87204599e98bee3e Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 20 May 2013 00:49:57 -0700 Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics further improvements that should eliminate more short duration recording periods --- indra/newview/llscenemonitor.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'indra/newview/llscenemonitor.cpp') diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp index c2e00384a1..b7517a057e 100644 --- a/indra/newview/llscenemonitor.cpp +++ b/indra/newview/llscenemonitor.cpp @@ -486,8 +486,10 @@ void LLSceneMonitor::fetchQueryResult() { mRecording->extend(); } - - mRecording->getPotentialRecording().nextPeriod(); + else + { + mRecording->getPotentialRecording().nextPeriod(); + } } } } -- cgit v1.2.3 From ab5106535758393e02b075d1e404e4e1fcf81abf Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 20 May 2013 19:27:50 -0700 Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics removed extra dereference for copy on write pointer moved copyonwrite mechanism to RecordingBuffers from individual buffer fixed logic that was leaving scene unfrozen when camera moved during metrics gathering --- indra/newview/llscenemonitor.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'indra/newview/llscenemonitor.cpp') diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp index b7517a057e..b303dfbdb4 100644 --- a/indra/newview/llscenemonitor.cpp +++ b/indra/newview/llscenemonitor.cpp @@ -270,10 +270,12 @@ void LLSceneMonitor::capture() static LLFrameTimer timer; LLTrace::Recording& last_frame_recording = LLTrace::get_frame_recording().getLastRecording(); - if (last_frame_recording.getSum(*LLViewerCamera::getVelocityStat()) > 0.001f - || last_frame_recording.getSum(*LLViewerCamera::getAngularVelocityStat()) > 0.01f) + if (mEnabled + && (last_frame_recording.getSum(*LLViewerCamera::getVelocityStat()) > 0.001f + || last_frame_recording.getSum(*LLViewerCamera::getAngularVelocityStat()) > 0.01f)) { reset(); + freezeScene(); } bool enabled = monitor_enabled || mDebugViewerVisible; -- cgit v1.2.3 From e8daeb177deccff29182ee97c143b0350e8c727c Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 22 May 2013 21:19:46 -0700 Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics clean up of llscenemonitor.cpp --- indra/newview/llscenemonitor.cpp | 8 -------- 1 file changed, 8 deletions(-) (limited to 'indra/newview/llscenemonitor.cpp') diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp index b303dfbdb4..94c2e40bb1 100644 --- a/indra/newview/llscenemonitor.cpp +++ b/indra/newview/llscenemonitor.cpp @@ -496,14 +496,6 @@ void LLSceneMonitor::fetchQueryResult() } } -void LLSceneMonitor::addMonitorResult() -{ - ll_monitor_result_t result; - result.mTimeStamp = LLImageGL::sLastFrameTime; - result.mDiff = mDiffResult; - mMonitorResults.push_back(result); -} - //dump results to a file _scene_xmonitor_results.csv void LLSceneMonitor::dumpToFile(std::string file_name) { -- cgit v1.2.3 From 16616ae48d86da75b3809fa6be6c846a9d420603 Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Thu, 23 May 2013 18:25:21 -0600 Subject: for SH-4145: Interesting: Implement occlusion culling for object cache --- indra/newview/llscenemonitor.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/newview/llscenemonitor.cpp') diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp index 15fe77f028..c592fd0a38 100644 --- a/indra/newview/llscenemonitor.cpp +++ b/indra/newview/llscenemonitor.cpp @@ -107,7 +107,7 @@ void LLSceneMonitor::reset() if(mQueryObject > 0) { - release_occlusion_query_object_name(mQueryObject); + LLOcclusionCullingGroup::releaseOcclusionQueryObjectName(mQueryObject); mQueryObject = 0; } } @@ -437,7 +437,7 @@ void LLSceneMonitor::calcDiffAggregate() if(!mQueryObject) { - mQueryObject = get_new_occlusion_query_object_name(); + mQueryObject = LLOcclusionCullingGroup::getNewOcclusionQueryObjectName(); } LLGLDepthTest depth(true, false, GL_ALWAYS); -- cgit v1.2.3 From 9ae76d12157641033431381959ef4f798a119b8d Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 29 May 2013 17:00:50 -0700 Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics fixed copy construction behavior of Recordings to not zero out data split measurement into event and sample, with sample representing a continuous function --- indra/newview/llscenemonitor.cpp | 57 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 52 insertions(+), 5 deletions(-) (limited to 'indra/newview/llscenemonitor.cpp') diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp index 94c2e40bb1..15f2f6d762 100644 --- a/indra/newview/llscenemonitor.cpp +++ b/indra/newview/llscenemonitor.cpp @@ -462,7 +462,7 @@ void LLSceneMonitor::calcDiffAggregate() } } -static LLTrace::MeasurementStatHandle<> sFramePixelDiff("FramePixelDifference"); +static LLTrace::EventStatHandle<> sFramePixelDiff("FramePixelDifference"); void LLSceneMonitor::fetchQueryResult() { LLFastTimer _(FTM_SCENE_LOAD_IMAGE_DIFF); @@ -481,16 +481,18 @@ void LLSceneMonitor::fetchQueryResult() mDiffResult = count * 0.5f / (mDiff->getWidth() * mDiff->getHeight() * mDiffPixelRatio * mDiffPixelRatio); //0.5 -> (front face + back face) LL_DEBUGS("SceneMonitor") << "Frame difference: " << std::setprecision(4) << mDiffResult << LL_ENDL; - sample(sFramePixelDiff, mDiffResult); + record(sFramePixelDiff, mDiffResult); static LLCachedControl diff_threshold(gSavedSettings,"SceneLoadingPixelDiffThreshold"); if(mDiffResult > diff_threshold()) { mRecording->extend(); + llassert(mRecording->getAcceptedRecording().getLastRecording().getSum(LLStatViewer::FPS)); } else { mRecording->getPotentialRecording().nextPeriod(); + llassert(mRecording->getPotentialRecording().getLastRecording().getSum(LLStatViewer::FPS)); } } } @@ -503,7 +505,6 @@ void LLSceneMonitor::dumpToFile(std::string file_name) std::ofstream os(file_name.c_str()); - //total scene loading time os << std::setprecision(4); LLTrace::PeriodicRecording& scene_load_recording = mRecording->getAcceptedRecording(); @@ -565,7 +566,7 @@ void LLSceneMonitor::dumpToFile(std::string file_name) } } - for (LLTrace::MeasurementStatHandle::instance_iter it = LLTrace::MeasurementStatHandle::beginInstances(), end_it = LLTrace::MeasurementStatHandle::endInstances(); + for (LLTrace::EventStatHandle::instance_iter it = LLTrace::EventStatHandle::beginInstances(), end_it = LLTrace::EventStatHandle::endInstances(); it != end_it; ++it) { @@ -588,7 +589,53 @@ void LLSceneMonitor::dumpToFile(std::string file_name) } } - for (LLTrace::MeasurementStatHandle::instance_iter it = LLTrace::MeasurementStatHandle::beginInstances(), end_it = LLTrace::MeasurementStatHandle::endInstances(); + for (LLTrace::EventStatHandle::instance_iter it = LLTrace::EventStatHandle::beginInstances(), end_it = LLTrace::EventStatHandle::endInstances(); + it != end_it; + ++it) + { + std::ostringstream row; + row << it->getName(); + + S32 samples = 0; + + for (S32 i = frame_count - 1; i >= 0; --i) + { + samples += scene_load_recording.getPrevRecording(i).getSampleCount(*it); + row << ", " << scene_load_recording.getPrevRecording(i).getMean(*it); + } + + row << std::endl; + + if (samples > 0) + { + os << row.str(); + } + } + + for (LLTrace::SampleStatHandle::instance_iter it = LLTrace::SampleStatHandle::beginInstances(), end_it = LLTrace::SampleStatHandle::endInstances(); + it != end_it; + ++it) + { + std::ostringstream row; + row << it->getName(); + + S32 samples = 0; + + for (S32 i = frame_count - 1; i >= 0; --i) + { + samples += scene_load_recording.getPrevRecording(i).getSampleCount(*it); + row << ", " << scene_load_recording.getPrevRecording(i).getMean(*it); + } + + row << std::endl; + + if (samples > 0) + { + os << row.str(); + } + } + + for (LLTrace::SampleStatHandle::instance_iter it = LLTrace::SampleStatHandle::beginInstances(), end_it = LLTrace::SampleStatHandle::endInstances(); it != end_it; ++it) { -- cgit v1.2.3 From 9def3590f41dee3cba7760e4443fdc71f5fb2db6 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 31 May 2013 16:01:46 -0700 Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics fixed multithreading lltrace causing values to be interpolated towards 0 added Radians unit improved sceneloadmonitor restart heuristic to use accumulated camera motion --- indra/newview/llscenemonitor.cpp | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) (limited to 'indra/newview/llscenemonitor.cpp') diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp index a28c2eac20..7eb48eb575 100644 --- a/indra/newview/llscenemonitor.cpp +++ b/indra/newview/llscenemonitor.cpp @@ -67,22 +67,13 @@ LLSceneMonitor::LLSceneMonitor() : { mFrames[0] = NULL; mFrames[1] = NULL; - - mRecording = new LLTrace::ExtendablePeriodicRecording(); } LLSceneMonitor::~LLSceneMonitor() { mDiffState = VIEWER_QUITTING; - destroyClass(); -} - -void LLSceneMonitor::destroyClass() -{ reset(); - delete mRecording; - mRecording = NULL; mDitheringTexture = NULL; } @@ -96,7 +87,8 @@ void LLSceneMonitor::reset() mFrames[1] = NULL; mDiff = NULL; - mRecording->reset(); + mMonitorRecording.reset(); + mSceneLoadRecording.reset(); unfreezeScene(); @@ -269,10 +261,9 @@ void LLSceneMonitor::capture() static LLCachedControl scene_load_sample_time(gSavedSettings, "SceneLoadingMonitorSampleTime"); static LLFrameTimer timer; - LLTrace::Recording& last_frame_recording = LLTrace::get_frame_recording().getLastRecording(); if (mEnabled - && (last_frame_recording.getSum(*LLViewerCamera::getVelocityStat()) > 0.001f - || last_frame_recording.getSum(*LLViewerCamera::getAngularVelocityStat()) > 0.01f)) + && (mMonitorRecording.getSum(*LLViewerCamera::getVelocityStat()) > 0.1f + || mMonitorRecording.getSum(*LLViewerCamera::getAngularVelocityStat()) > 0.05f)) { reset(); freezeScene(); @@ -299,7 +290,8 @@ void LLSceneMonitor::capture() && LLGLSLShader::sNoFixedFunction && last_capture_time != gFrameCount) { - mRecording->resume(); + mSceneLoadRecording.resume(); + mMonitorRecording.resume(); timer.reset(); @@ -486,13 +478,13 @@ void LLSceneMonitor::fetchQueryResult() static LLCachedControl diff_threshold(gSavedSettings,"SceneLoadingPixelDiffThreshold"); if(mDiffResult > diff_threshold()) { - mRecording->extend(); - llassert(mRecording->getAcceptedRecording().getLastRecording().getSum(LLStatViewer::FPS)); + mSceneLoadRecording.extend(); + llassert(mSceneLoadRecording.getAcceptedRecording().getLastRecording().getSum(LLStatViewer::FPS)); } else { - mRecording->getPotentialRecording().nextPeriod(); - llassert(mRecording->getPotentialRecording().getLastRecording().getSum(LLStatViewer::FPS)); + mSceneLoadRecording.getPotentialRecording().nextPeriod(); + llassert(mSceneLoadRecording.getPotentialRecording().getLastRecording().getSum(LLStatViewer::FPS)); } } } @@ -501,13 +493,15 @@ void LLSceneMonitor::fetchQueryResult() //dump results to a file _scene_xmonitor_results.csv void LLSceneMonitor::dumpToFile(std::string file_name) { + if (!hasResults()) return; + LL_INFOS("SceneMonitor") << "Saving scene load stats to " << file_name << LL_ENDL; std::ofstream os(file_name.c_str()); os << std::setprecision(4); - LLTrace::PeriodicRecording& scene_load_recording = mRecording->getAcceptedRecording(); + LLTrace::PeriodicRecording& scene_load_recording = mSceneLoadRecording.getAcceptedRecording(); U32 frame_count = scene_load_recording.getNumPeriods(); LLUnit frame_time; -- cgit v1.2.3 From fd21ddd9d0adf7342fe89d371868c3f7f7ca9f5f Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 31 May 2013 23:40:10 -0700 Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics made recordings auto-update when executing query while active --- indra/newview/llscenemonitor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llscenemonitor.cpp') diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp index 7eb48eb575..bb1cfaa9a8 100644 --- a/indra/newview/llscenemonitor.cpp +++ b/indra/newview/llscenemonitor.cpp @@ -240,7 +240,7 @@ void LLSceneMonitor::unfreezeScene() if(mDiffState == VIEWER_QUITTING) { - return; //we are quitting viewer. + return; } // thaw everything else -- cgit v1.2.3 From 233201f8227f92e93061d3e2393a17b42dfa3dd1 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Sun, 2 Jun 2013 22:49:17 -0700 Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics removed unnecessary templates from accumulator types...now always track data in double precision floating point, using templated accessors to convert to and from arbitrary types --- indra/newview/llscenemonitor.cpp | 36 +++++++----------------------------- 1 file changed, 7 insertions(+), 29 deletions(-) (limited to 'indra/newview/llscenemonitor.cpp') diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp index bb1cfaa9a8..1bbd6ae2b9 100644 --- a/indra/newview/llscenemonitor.cpp +++ b/indra/newview/llscenemonitor.cpp @@ -493,6 +493,7 @@ void LLSceneMonitor::fetchQueryResult() //dump results to a file _scene_xmonitor_results.csv void LLSceneMonitor::dumpToFile(std::string file_name) { + using namespace LLTrace; if (!hasResults()) return; LL_INFOS("SceneMonitor") << "Saving scene load stats to " << file_name << LL_ENDL; @@ -501,7 +502,7 @@ void LLSceneMonitor::dumpToFile(std::string file_name) os << std::setprecision(4); - LLTrace::PeriodicRecording& scene_load_recording = mSceneLoadRecording.getAcceptedRecording(); + PeriodicRecording& scene_load_recording = mSceneLoadRecording.getAcceptedRecording(); U32 frame_count = scene_load_recording.getNumPeriods(); LLUnit frame_time; @@ -514,7 +515,7 @@ void LLSceneMonitor::dumpToFile(std::string file_name) } os << std::endl; - for (LLTrace::CountStatHandle::instance_iter it = LLTrace::CountStatHandle::beginInstances(), end_it = LLTrace::CountStatHandle::endInstances(); + for (CountStatHandle::instance_iter it = CountStatHandle::beginInstances(), end_it = CountStatHandle::endInstances(); it != end_it; ++it) { @@ -537,7 +538,7 @@ void LLSceneMonitor::dumpToFile(std::string file_name) } } - for (LLTrace::CountStatHandle::instance_iter it = LLTrace::CountStatHandle::beginInstances(), end_it = LLTrace::CountStatHandle::endInstances(); + for (CountStatHandle::instance_iter it = CountStatHandle::beginInstances(), end_it = CountStatHandle::endInstances(); it != end_it; ++it) { @@ -560,7 +561,7 @@ void LLSceneMonitor::dumpToFile(std::string file_name) } } - for (LLTrace::EventStatHandle::instance_iter it = LLTrace::EventStatHandle::beginInstances(), end_it = LLTrace::EventStatHandle::endInstances(); + for (EventStatHandle::instance_iter it = EventStatHandle::beginInstances(), end_it = EventStatHandle::endInstances(); it != end_it; ++it) { @@ -583,7 +584,7 @@ void LLSceneMonitor::dumpToFile(std::string file_name) } } - for (LLTrace::EventStatHandle::instance_iter it = LLTrace::EventStatHandle::beginInstances(), end_it = LLTrace::EventStatHandle::endInstances(); + for (EventStatHandle::instance_iter it = EventStatHandle::beginInstances(), end_it = EventStatHandle::endInstances(); it != end_it; ++it) { @@ -606,30 +607,7 @@ void LLSceneMonitor::dumpToFile(std::string file_name) } } - for (LLTrace::SampleStatHandle::instance_iter it = LLTrace::SampleStatHandle::beginInstances(), end_it = LLTrace::SampleStatHandle::endInstances(); - it != end_it; - ++it) - { - std::ostringstream row; - row << it->getName(); - - S32 samples = 0; - - for (S32 i = frame_count - 1; i >= 0; --i) - { - samples += scene_load_recording.getPrevRecording(i).getSampleCount(*it); - row << ", " << scene_load_recording.getPrevRecording(i).getMean(*it); - } - - row << std::endl; - - if (samples > 0) - { - os << row.str(); - } - } - - for (LLTrace::SampleStatHandle::instance_iter it = LLTrace::SampleStatHandle::beginInstances(), end_it = LLTrace::SampleStatHandle::endInstances(); + for (TraceType::instance_iter it = TraceType::beginInstances(), end_it = TraceType::endInstances(); it != end_it; ++it) { -- cgit v1.2.3 From 5b48107dbf969529267874bff9a0a4b892b348cf Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 4 Jun 2013 08:33:11 -0700 Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics added labels to LLUnit types added memstat dumps to llscenemonitor --- indra/newview/llscenemonitor.cpp | 58 +++++++++++----------------------------- 1 file changed, 16 insertions(+), 42 deletions(-) (limited to 'indra/newview/llscenemonitor.cpp') diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp index 1bbd6ae2b9..1a5b43c703 100644 --- a/indra/newview/llscenemonitor.cpp +++ b/indra/newview/llscenemonitor.cpp @@ -492,18 +492,18 @@ void LLSceneMonitor::fetchQueryResult() //dump results to a file _scene_xmonitor_results.csv void LLSceneMonitor::dumpToFile(std::string file_name) -{ - using namespace LLTrace; +{ using namespace LLTrace; + if (!hasResults()) return; LL_INFOS("SceneMonitor") << "Saving scene load stats to " << file_name << LL_ENDL; std::ofstream os(file_name.c_str()); - os << std::setprecision(4); + os << std::setprecision(3); PeriodicRecording& scene_load_recording = mSceneLoadRecording.getAcceptedRecording(); - U32 frame_count = scene_load_recording.getNumPeriods(); + const U32 frame_count = scene_load_recording.getNumPeriods(); LLUnit frame_time; @@ -515,7 +515,8 @@ void LLSceneMonitor::dumpToFile(std::string file_name) } os << std::endl; - for (CountStatHandle::instance_iter it = CountStatHandle::beginInstances(), end_it = CountStatHandle::endInstances(); + typedef TraceType trace_count; + for (trace_count::instance_iter it = trace_count::beginInstances(), end_it = trace_count::endInstances(); it != end_it; ++it) { @@ -538,30 +539,9 @@ void LLSceneMonitor::dumpToFile(std::string file_name) } } - for (CountStatHandle::instance_iter it = CountStatHandle::beginInstances(), end_it = CountStatHandle::endInstances(); - it != end_it; - ++it) - { - std::ostringstream row; - row << it->getName(); - - S32 samples = 0; - - for (S32 i = frame_count - 1; i >= 0; --i) - { - samples += scene_load_recording.getPrevRecording(i).getSampleCount(*it); - row << ", " << scene_load_recording.getPrevRecording(i).getSum(*it); - } - - row << std::endl; - - if (samples > 0) - { - os << row.str(); - } - } + typedef TraceType trace_event; - for (EventStatHandle::instance_iter it = EventStatHandle::beginInstances(), end_it = EventStatHandle::endInstances(); + for (trace_event::instance_iter it = trace_event::beginInstances(), end_it = trace_event::endInstances(); it != end_it; ++it) { @@ -584,7 +564,9 @@ void LLSceneMonitor::dumpToFile(std::string file_name) } } - for (EventStatHandle::instance_iter it = EventStatHandle::beginInstances(), end_it = EventStatHandle::endInstances(); + typedef TraceType trace_sample; + + for (trace_sample::instance_iter it = trace_sample::beginInstances(), end_it = trace_sample::endInstances(); it != end_it; ++it) { @@ -607,27 +589,19 @@ void LLSceneMonitor::dumpToFile(std::string file_name) } } - for (TraceType::instance_iter it = TraceType::beginInstances(), end_it = TraceType::endInstances(); + typedef TraceType trace_mem; + for (trace_mem::instance_iter it = trace_mem::beginInstances(), end_it = trace_mem::endInstances(); it != end_it; ++it) { - std::ostringstream row; - row << it->getName(); - - S32 samples = 0; + os << it->getName(); for (S32 i = frame_count - 1; i >= 0; --i) { - samples += scene_load_recording.getPrevRecording(i).getSampleCount(*it); - row << ", " << scene_load_recording.getPrevRecording(i).getMean(*it); + os << ", " << scene_load_recording.getPrevRecording(i).getSum(*it).as().value(); } - row << std::endl; - - if (samples > 0) - { - os << row.str(); - } + os << std::endl; } os.flush(); -- cgit v1.2.3 From 715385eed7b2276963015861d7e6b8196e6ae5cd Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 4 Jun 2013 10:54:12 -0700 Subject: BUILDFIX: don't multiple define class statics...use inline static method instead --- indra/newview/llscenemonitor.cpp | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) (limited to 'indra/newview/llscenemonitor.cpp') diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp index 1a5b43c703..f7abb982e1 100644 --- a/indra/newview/llscenemonitor.cpp +++ b/indra/newview/llscenemonitor.cpp @@ -523,12 +523,18 @@ void LLSceneMonitor::dumpToFile(std::string file_name) std::ostringstream row; row << it->getName(); + const char* unit_label = it->getUnitLabel(); + if(unit_label[0]) + { + row << "(" << unit_label << ")"; + } + S32 samples = 0; - for (S32 i = frame_count - 1; i >= 0; --i) + for (S32 frame = 0; frame < frame_count; frame++) { - samples += scene_load_recording.getPrevRecording(i).getSampleCount(*it); - row << ", " << scene_load_recording.getPrevRecording(i).getSum(*it); + samples += scene_load_recording.getPrevRecording(frame_count - frame).getSampleCount(*it); + row << ", " << scene_load_recording.getPrevRecording(frame_count - frame).getSum(*it); } row << std::endl; @@ -550,10 +556,10 @@ void LLSceneMonitor::dumpToFile(std::string file_name) S32 samples = 0; - for (S32 i = frame_count - 1; i >= 0; --i) + for (S32 frame = 0; frame < frame_count; frame++) { - samples += scene_load_recording.getPrevRecording(i).getSampleCount(*it); - row << ", " << scene_load_recording.getPrevRecording(i).getMean(*it); + samples += scene_load_recording.getPrevRecording(frame_count - frame).getSampleCount(*it); + row << ", " << scene_load_recording.getPrevRecording(frame_count - frame).getMean(*it); } row << std::endl; @@ -575,10 +581,10 @@ void LLSceneMonitor::dumpToFile(std::string file_name) S32 samples = 0; - for (S32 i = frame_count - 1; i >= 0; --i) + for (S32 frame = 0; frame < frame_count; frame++) { - samples += scene_load_recording.getPrevRecording(i).getSampleCount(*it); - row << ", " << scene_load_recording.getPrevRecording(i).getMean(*it); + samples += scene_load_recording.getPrevRecording(frame_count - frame).getSampleCount(*it); + row << ", " << scene_load_recording.getPrevRecording(frame_count - frame).getMean(*it); } row << std::endl; @@ -596,9 +602,9 @@ void LLSceneMonitor::dumpToFile(std::string file_name) { os << it->getName(); - for (S32 i = frame_count - 1; i >= 0; --i) + for (S32 frame = 0; frame < frame_count; frame++) { - os << ", " << scene_load_recording.getPrevRecording(i).getSum(*it).as().value(); + os << ", " << scene_load_recording.getPrevRecording(frame_count - frame).getSum(*it).value(); } os << std::endl; @@ -606,7 +612,6 @@ void LLSceneMonitor::dumpToFile(std::string file_name) os.flush(); os.close(); - } //------------------------------------------------------------------------------------------------------------- -- cgit v1.2.3 From a74b5dfa923f8eeccc9b786143f0f832de3ad450 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 4 Jun 2013 19:45:33 -0700 Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics fixed mem stat tracking...now properly tracks memory footprint with floating point precision cleaned up macros for unit declaration renamed units to SI standard for 1024 multiples (kibibytes, etc) fixed units output for scene monitor dump --- indra/newview/llscenemonitor.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'indra/newview/llscenemonitor.cpp') diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp index f7abb982e1..dccf8a2a17 100644 --- a/indra/newview/llscenemonitor.cpp +++ b/indra/newview/llscenemonitor.cpp @@ -554,6 +554,12 @@ void LLSceneMonitor::dumpToFile(std::string file_name) std::ostringstream row; row << it->getName(); + const char* unit_label = it->getUnitLabel(); + if(unit_label[0]) + { + row << "(" << unit_label << ")"; + } + S32 samples = 0; for (S32 frame = 0; frame < frame_count; frame++) @@ -579,6 +585,12 @@ void LLSceneMonitor::dumpToFile(std::string file_name) std::ostringstream row; row << it->getName(); + const char* unit_label = it->getUnitLabel(); + if(unit_label[0]) + { + row << "(" << unit_label << ")"; + } + S32 samples = 0; for (S32 frame = 0; frame < frame_count; frame++) @@ -600,11 +612,11 @@ void LLSceneMonitor::dumpToFile(std::string file_name) it != end_it; ++it) { - os << it->getName(); + os << it->getName() << "(KiB)"; for (S32 frame = 0; frame < frame_count; frame++) { - os << ", " << scene_load_recording.getPrevRecording(frame_count - frame).getSum(*it).value(); + os << ", " << scene_load_recording.getPrevRecording(frame_count - frame).getMax(*it).as().value(); } os << std::endl; -- cgit v1.2.3