From 339edc67c8efca481754b0147616be527e47ed91 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Mon, 16 Oct 2017 17:27:53 -0700 Subject: [PATCH] ifdef out more per-frame-per-entity profiling --- libraries/animation/src/Rig.cpp | 16 ++++++++++++++-- .../src/RenderableModelEntityItem.cpp | 6 +++++- libraries/render-utils/src/Model.cpp | 9 +++++++++ 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/libraries/animation/src/Rig.cpp b/libraries/animation/src/Rig.cpp index 0897c26a12..5609baf548 100644 --- a/libraries/animation/src/Rig.cpp +++ b/libraries/animation/src/Rig.cpp @@ -32,6 +32,9 @@ #include "AnimUtil.h" #include "IKTarget.h" +// uncomment WANT_DETAILED_PROFILING for profiling that would otherwise impact performance +//#define WANT_DETAILED_PROFILING + static int nextRigId = 1; static std::map rigRegistry; static std::mutex rigRegistryMutex; @@ -999,14 +1002,17 @@ void Rig::updateAnimationStateHandlers() { // called on avatar update thread (wh } void Rig::updateAnimations(float deltaTime, const glm::mat4& rootTransform, const glm::mat4& rigToWorldTransform) { - +#ifdef WANT_DETAILED_PROFILING PROFILE_RANGE_EX(simulation_animation_detail, __FUNCTION__, 0xffff00ff, 0); PerformanceTimer perfTimer("updateAnimations"); +#endif setModelOffset(rootTransform); if (_animNode && _enabledAnimations) { +#ifdef WANT_DETAILED_PROFILING PerformanceTimer perfTimer("handleTriggers"); +#endif updateAnimationStateHandlers(); _animVars.setRigToGeometryTransform(_rigToGeometryTransform); @@ -1658,7 +1664,9 @@ bool Rig::getModelRegistrationPoint(glm::vec3& modelRegistrationPointOut) const } void Rig::applyOverridePoses() { +#ifdef WANT_DETAILED_PROFILING PerformanceTimer perfTimer("override"); +#endif if (_numOverrides == 0 || !_animSkeleton) { return; } @@ -1675,7 +1683,9 @@ void Rig::applyOverridePoses() { } void Rig::buildAbsoluteRigPoses(const AnimPoseVec& relativePoses, AnimPoseVec& absolutePosesOut) { +#ifdef WANT_DETAILED_PROFILING PerformanceTimer perfTimer("buildAbsolute"); +#endif if (!_animSkeleton) { return; } @@ -1730,8 +1740,10 @@ void Rig::copyJointsIntoJointData(QVector& jointDataVec) const { } void Rig::copyJointsFromJointData(const QVector& jointDataVec) { - PerformanceTimer perfTimer("copyJoints"); +#ifdef WANT_DETAILED_PROFILING PROFILE_RANGE(simulation_animation_detail, "copyJoints"); + PerformanceTimer perfTimer("copyJoints"); +#endif if (!_animSkeleton) { return; } diff --git a/libraries/entities-renderer/src/RenderableModelEntityItem.cpp b/libraries/entities-renderer/src/RenderableModelEntityItem.cpp index f36525b527..3b7b180f7a 100644 --- a/libraries/entities-renderer/src/RenderableModelEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableModelEntityItem.cpp @@ -352,7 +352,9 @@ bool RenderableModelEntityItem::isReadyToComputeShape() const { // we have both URLs AND both geometries AND they are both fully loaded. if (_needsInitialSimulation) { // the _model's offset will be wrong until _needsInitialSimulation is false +#ifdef WANT_DETAILED_PROFILING PerformanceTimer perfTimer("_model->simulate"); +#endif const_cast(this)->doInitialModelSimulation(); } return true; @@ -898,7 +900,9 @@ void RenderableModelEntityItem::setJointTranslationsSet(const QVector& tra } void RenderableModelEntityItem::locationChanged(bool tellPhysics) { +#ifdef WANT_DETAILED_PROFILING PerformanceTimer pertTimer("locationChanged"); +#endif EntityItem::locationChanged(tellPhysics); auto model = getModel(); if (model && model->isLoaded()) { @@ -1317,8 +1321,8 @@ void ModelEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& sce void ModelEntityRenderer::doRender(RenderArgs* args) { #ifdef WANT_DETAILED_PROFILING PROFILE_RANGE(render_detail, "MetaModelRender"); -#endif PerformanceTimer perfTimer("RMEIrender"); +#endif ModelPointer model; withReadLock([&]{ diff --git a/libraries/render-utils/src/Model.cpp b/libraries/render-utils/src/Model.cpp index fcda330f4a..616b1554b5 100644 --- a/libraries/render-utils/src/Model.cpp +++ b/libraries/render-utils/src/Model.cpp @@ -32,6 +32,9 @@ #include "RenderUtilsLogging.h" #include +// uncomment WANT_DETAILED_PROFILING to enable profiling that causes measureable performance impact +//#define WANT_DETAILED_PROFILING + using namespace std; int nakedModelPointerTypeId = qRegisterMetaType(); @@ -963,7 +966,9 @@ Blender::Blender(ModelPointer model, int blendNumber, const Geometry::WeakPointe } void Blender::run() { +#ifdef WANT_DETAILED_PROFILING PROFILE_RANGE_EX(simulation_animation, __FUNCTION__, 0xFFFF0000, 0, { { "url", _model->getURL().toString() } }); +#endif QVector vertices, normals; if (_model) { int offset = 0; @@ -1084,8 +1089,10 @@ void Model::snapToRegistrationPoint() { } void Model::simulate(float deltaTime, bool fullUpdate) { +#ifdef WANT_DETAILED_PROFILING PROFILE_RANGE(simulation_detail, __FUNCTION__); PerformanceTimer perfTimer("Model::simulate"); +#endif fullUpdate = updateGeometry() || fullUpdate || (_scaleToFit && !_scaledToFit) || (_snapModelToRegistrationPoint && !_snappedToRegistrationPoint); @@ -1123,7 +1130,9 @@ void Model::computeMeshPartLocalBounds() { // virtual void Model::updateClusterMatrices() { +#ifdef WANT_DETAILED_PROFILING PerformanceTimer perfTimer("Model::updateClusterMatrices"); +#endif if (!_needsUpdateClusterMatrices || !isLoaded()) { return;