From 29dc641fbe7ab77f77fe19e2e7976980f0649b5b Mon Sep 17 00:00:00 2001 From: "Nyx (Neal Orman)" Date: Tue, 22 Mar 2011 20:39:31 -0400 Subject: initial effort to enable a debug display to show render complexity. Using for internal demo, will get it code reviewed if it merges in. --- indra/newview/llspatialpartition.cpp | 38 ++++++++++++++++++++++ indra/newview/llviewermenu.cpp | 4 +++ indra/newview/llviewerobjectlist.cpp | 4 +++ indra/newview/llvovolume.cpp | 18 ++++++++-- indra/newview/llvovolume.h | 10 +++++- indra/newview/pipeline.h | 1 + indra/newview/skins/default/xui/en/menu_viewer.xml | 10 ++++++ .../skins/default/xui/en/panel_region_terrain.xml | 34 +++++++++++++++++++ 8 files changed, 116 insertions(+), 3 deletions(-) diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp index 5e7af6bbb3..b604908474 100644 --- a/indra/newview/llspatialpartition.cpp +++ b/indra/newview/llspatialpartition.cpp @@ -2792,6 +2792,40 @@ void renderUpdateType(LLDrawable* drawablep) } } +void renderComplexityDisplay(LLDrawable* drawablep) +{ + LLViewerObject* vobj = drawablep->getVObj(); + if (!vobj) + { + return; + } + + LLVOVolume *voVol = dynamic_cast(vobj); + + if (!voVol) + { + return; + } + + LLVOVolume::texture_cost_t textures; + F32 cost = (F32) voVol->getRenderCost(textures) / (F32) LLVOVolume::getRenderComplexityMax(); + + LLGLEnable blend(GL_BLEND); + + F32 red = cost; + F32 green = 1.0f - cost; + + glColor4f(red,green,0,0.5f); + + S32 num_faces = drawablep->getNumFaces(); + if (num_faces) + { + for (S32 i = 0; i < num_faces; ++i) + { + pushVerts(drawablep->getFace(i), LLVertexBuffer::MAP_VERTEX); + } + } +} void renderBoundingBox(LLDrawable* drawable, BOOL set_color = TRUE) { @@ -3906,6 +3940,10 @@ public: { renderUpdateType(drawable); } + if(gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_RENDER_COMPLEXITY)) + { + renderComplexityDisplay(drawable); + } LLVOAvatar* avatar = dynamic_cast(drawable->getVObj().get()); diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index f5b0857425..30be2fb8e0 100755 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -993,6 +993,10 @@ U32 info_display_from_string(std::string info_display) { return LLPipeline::RENDER_DEBUG_AGENT_TARGET; } + else if ("" == info_display) + { + return LLPipeline::RENDER_DEBUG_RENDER_COMPLEXITY; + } else { return 0; diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp index 0071753831..2e8eb9f4a8 100644 --- a/indra/newview/llviewerobjectlist.cpp +++ b/indra/newview/llviewerobjectlist.cpp @@ -58,6 +58,7 @@ #include "llviewerregion.h" #include "llviewerstats.h" #include "llviewerstatsrecorder.h" +#include "llvovolume.h" #include "llvoavatarself.h" #include "lltoolmgr.h" #include "lltoolpie.h" @@ -997,6 +998,9 @@ void LLViewerObjectList::update(LLAgent &agent, LLWorld &world) mNumSizeCulled = 0; mNumVisCulled = 0; + // update max computed render cost + LLVOVolume::updateRenderComplexity(); + // compute all sorts of time-based stats // don't factor frames that were paused into the stats if (! mWasPaused) diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index e2d1850e58..7c772ce835 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -87,6 +87,8 @@ F32 LLVOVolume::sLODFactor = 1.f; F32 LLVOVolume::sLODSlopDistanceFactor = 0.5f; //Changing this to zero, effectively disables the LOD transition slop F32 LLVOVolume::sDistanceFactor = 1.0f; S32 LLVOVolume::sNumLODChanges = 0; +S32 LLVOVolume::mRenderComplexity_last = 0; +S32 LLVOVolume::mRenderComplexity_current = 0; LLPointer LLVOVolume::sObjectMediaClient = NULL; LLPointer LLVOVolume::sObjectMediaNavigateClient = NULL; @@ -3206,6 +3208,11 @@ U32 LLVOVolume::getRenderCost(texture_cost_t &textures) const shame += num_particles * part_size * ARC_PARTICLE_COST; } + if (shame > mRenderComplexity_current) + { + mRenderComplexity_current = (S32)shame; + } + return (U32)shame; } @@ -3223,7 +3230,14 @@ F32 LLVOVolume::getStreamingCost() return 0.f; } -U32 LLVOVolume::getTriangleCount() +//static +void LLVOVolume::updateRenderComplexity() +{ + mRenderComplexity_last = mRenderComplexity_current; + mRenderComplexity_current = 0; +} + +U32 LLVOVolume::getTriangleCount() const { U32 count = 0; LLVolume* volume = getVolume(); @@ -4068,7 +4082,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) if ( bindCnt > 0 ) { const int jointCnt = pSkinData->mJointNames.size(); - const int pelvisZOffset = pSkinData->mPelvisOffset; + const int pelvisZOffset = (int)pSkinData->mPelvisOffset; bool fullRig = (jointCnt>=20) ? true : false; if ( fullRig ) { diff --git a/indra/newview/llvovolume.h b/indra/newview/llvovolume.h index 5af88c6cbd..57faee556f 100644 --- a/indra/newview/llvovolume.h +++ b/indra/newview/llvovolume.h @@ -132,7 +132,7 @@ public: typedef std::map texture_cost_t; U32 getRenderCost(texture_cost_t &textures) const; /*virtual*/ F32 getStreamingCost(); - /*virtual*/ U32 getTriangleCount(); + /*virtual*/ U32 getTriangleCount() const; /*virtual*/ BOOL lineSegmentIntersect(const LLVector3& start, const LLVector3& end, S32 face = -1, // which face to check, -1 = ALL_SIDES BOOL pick_transparent = FALSE, @@ -320,11 +320,19 @@ protected: LLFace* addFace(S32 face_index); void updateTEData(); + // stats tracking for render complexity + static S32 mRenderComplexity_last; + static S32 mRenderComplexity_current; + void requestMediaDataUpdate(bool isNew); void cleanUpMediaImpls(); void addMediaImpl(LLViewerMediaImpl* media_impl, S32 texture_index) ; void removeMediaImpl(S32 texture_index) ; public: + + static S32 getRenderComplexityMax() {return mRenderComplexity_last;} + static void updateRenderComplexity(); + LLViewerTextureAnim *mTextureAnimp; U8 mTexAnimMode; private: diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h index be58af947c..02bb6d618e 100644 --- a/indra/newview/pipeline.h +++ b/indra/newview/pipeline.h @@ -448,6 +448,7 @@ public: RENDER_DEBUG_PHYSICS_SHAPES = 0x1000000, RENDER_DEBUG_NORMALS = 0x2000000, RENDER_DEBUG_LOD_INFO = 0x4000000, + RENDER_DEBUG_RENDER_COMPLEXITY = 0x8000000 }; public: diff --git a/indra/newview/skins/default/xui/en/menu_viewer.xml b/indra/newview/skins/default/xui/en/menu_viewer.xml index ea40a08c95..7a227fb5f9 100644 --- a/indra/newview/skins/default/xui/en/menu_viewer.xml +++ b/indra/newview/skins/default/xui/en/menu_viewer.xml @@ -2338,6 +2338,16 @@ function="Advanced.ToggleInfoDisplay" parameter="raycast" /> + + + + + + +