diff --git a/BUILD.md b/BUILD.md index 4d321146c3..feed677828 100644 --- a/BUILD.md +++ b/BUILD.md @@ -25,7 +25,7 @@ The above dependencies will be downloaded, built, linked and included automatica These are not placed in your normal build tree when doing an out of source build so that they do not need to be re-downloaded and re-compiled every time the CMake build folder is cleared. Should you want to force a re-download and re-compile of a specific external, you can simply remove that directory from the appropriate subfolder in `build/ext`. Should you want to force a re-download and re-compile of all externals, just remove the `build/ext` folder. -If you would like to use a specific install of a dependency instead of the version that would be grabbed as a CMake ExternalProject, you can pass -DUSE_LOCAL_$NAME=0 (where $NAME is the name of the subfolder in [cmake/externals](cmake/externals)) when you run CMake to tell it not to get that dependency as an external project. +If you would like to use a specific install of a dependency instead of the version that would be grabbed as a CMake ExternalProject, you can pass -DUSE\_LOCAL\_$NAME=0 (where $NAME is the name of the subfolder in [cmake/externals](cmake/externals)) when you run CMake to tell it not to get that dependency as an external project. ### OS Specific Build Guides diff --git a/libraries/animation/src/Rig.cpp b/libraries/animation/src/Rig.cpp index 5609baf548..0f2bce5ca4 100644 --- a/libraries/animation/src/Rig.cpp +++ b/libraries/animation/src/Rig.cpp @@ -32,8 +32,6 @@ #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; @@ -1002,17 +1000,13 @@ 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 + DETAILED_PROFILE_RANGE_EX(simulation_animation_detail, __FUNCTION__, 0xffff00ff, 0); + DETAILED_PERFORMANCE_TIMER("updateAnimations"); setModelOffset(rootTransform); if (_animNode && _enabledAnimations) { -#ifdef WANT_DETAILED_PROFILING - PerformanceTimer perfTimer("handleTriggers"); -#endif + DETAILED_PERFORMANCE_TIMER("handleTriggers"); updateAnimationStateHandlers(); _animVars.setRigToGeometryTransform(_rigToGeometryTransform); @@ -1664,9 +1658,7 @@ bool Rig::getModelRegistrationPoint(glm::vec3& modelRegistrationPointOut) const } void Rig::applyOverridePoses() { -#ifdef WANT_DETAILED_PROFILING - PerformanceTimer perfTimer("override"); -#endif + DETAILED_PERFORMANCE_TIMER("override"); if (_numOverrides == 0 || !_animSkeleton) { return; } @@ -1683,9 +1675,7 @@ void Rig::applyOverridePoses() { } void Rig::buildAbsoluteRigPoses(const AnimPoseVec& relativePoses, AnimPoseVec& absolutePosesOut) { -#ifdef WANT_DETAILED_PROFILING - PerformanceTimer perfTimer("buildAbsolute"); -#endif + DETAILED_PERFORMANCE_TIMER("buildAbsolute"); if (!_animSkeleton) { return; } @@ -1740,10 +1730,9 @@ void Rig::copyJointsIntoJointData(QVector& jointDataVec) const { } void Rig::copyJointsFromJointData(const QVector& jointDataVec) { -#ifdef WANT_DETAILED_PROFILING - PROFILE_RANGE(simulation_animation_detail, "copyJoints"); - PerformanceTimer perfTimer("copyJoints"); -#endif + DETAILED_PROFILE_RANGE(simulation_animation_detail, "copyJoints"); + DETAILED_PERFORMANCE_TIMER("copyJoints"); + if (!_animSkeleton) { return; } diff --git a/libraries/entities-renderer/src/RenderableEntityItem.cpp b/libraries/entities-renderer/src/RenderableEntityItem.cpp index ff581f8e8d..07c5694a2a 100644 --- a/libraries/entities-renderer/src/RenderableEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableEntityItem.cpp @@ -26,8 +26,6 @@ #include "RenderableWebEntityItem.h" #include "RenderableZoneEntityItem.h" -// uncomment WANT_DETAILED_PROFILING to see some of the interesting profiling contexts -//#define WANT_DETAILED_PROFILING using namespace render; using namespace render::entities; @@ -274,9 +272,7 @@ void EntityRenderer::removeFromScene(const ScenePointer& scene, Transaction& tra } void EntityRenderer::updateInScene(const ScenePointer& scene, Transaction& transaction) { -#ifdef WANT_DETAILED_PROFILING - PROFILE_RANGE(simulation_physics, __FUNCTION__); -#endif + DETAILED_PROFILE_RANGE(simulation_physics, __FUNCTION__); if (!isValidRenderItem()) { return; } @@ -336,9 +332,7 @@ bool EntityRenderer::needsRenderUpdateFromEntity(const EntityItemPointer& entity } void EntityRenderer::doRenderUpdateSynchronous(const ScenePointer& scene, Transaction& transaction, const EntityItemPointer& entity) { -#ifdef WANT_DETAILED_PROFILING - PROFILE_RANGE(simulation_physics, __FUNCTION__); -#endif + DETAILED_PROFILE_RANGE(simulation_physics, __FUNCTION__); withWriteLock([&] { auto transparent = isTransparent(); if (_prevIsTransparent && !transparent) { diff --git a/libraries/entities-renderer/src/RenderableModelEntityItem.cpp b/libraries/entities-renderer/src/RenderableModelEntityItem.cpp index 3b7b180f7a..e9fbc43420 100644 --- a/libraries/entities-renderer/src/RenderableModelEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableModelEntityItem.cpp @@ -34,8 +34,6 @@ #include "EntityTreeRenderer.h" #include "EntitiesRendererLogging.h" -// uncomment WANT_DETAILED_PROFILING to profile the interesting contexts -//#define WANT_DETAILED_PROFILING static CollisionRenderMeshCache collisionMeshCache; @@ -110,9 +108,7 @@ QVariantMap parseTexturesToMap(QString textures, const QVariantMap& defaultTextu } void RenderableModelEntityItem::doInitialModelSimulation() { -#ifdef WANT_DETAILED_PROFILING - PROFILE_RANGE(simulation_physics, __FUNCTION__); -#endif + DETAILED_PROFILE_RANGE(simulation_physics, __FUNCTION__); ModelPointer model = getModel(); if (!model) { return; @@ -144,9 +140,7 @@ void RenderableModelEntityItem::autoResizeJointArrays() { } bool RenderableModelEntityItem::needsUpdateModelBounds() const { -#ifdef WANT_DETAILED_PROFILING - PROFILE_RANGE(simulation_physics, __FUNCTION__); -#endif + DETAILED_PROFILE_RANGE(simulation_physics, __FUNCTION__); ModelPointer model = getModel(); if (!hasModel() || !model) { return false; @@ -191,9 +185,7 @@ bool RenderableModelEntityItem::needsUpdateModelBounds() const { } void RenderableModelEntityItem::updateModelBounds() { -#ifdef WANT_DETAILED_PROFILING - PROFILE_RANGE(simulation_physics, "updateModelBounds"); -#endif + DETAILED_PROFILE_RANGE(simulation_physics, "updateModelBounds"); if (!_dimensionsInitialized || !hasModel()) { return; @@ -352,9 +344,7 @@ 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 + DETAILED_PERFORMANCE_TIMER("_model->simulate"); const_cast(this)->doInitialModelSimulation(); } return true; @@ -900,9 +890,7 @@ void RenderableModelEntityItem::setJointTranslationsSet(const QVector& tra } void RenderableModelEntityItem::locationChanged(bool tellPhysics) { -#ifdef WANT_DETAILED_PROFILING - PerformanceTimer pertTimer("locationChanged"); -#endif + DETAILED_PERFORMANCE_TIMER("locationChanged"); EntityItem::locationChanged(tellPhysics); auto model = getModel(); if (model && model->isLoaded()) { @@ -1182,9 +1170,7 @@ bool ModelEntityRenderer::needsRenderUpdateFromTypedEntity(const TypedEntityPoin } void ModelEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& scene, Transaction& transaction, const TypedEntityPointer& entity) { -#ifdef WANT_DETAILED_PROFILING - PROFILE_RANGE(simulation_physics, __FUNCTION__); -#endif + DETAILED_PROFILE_RANGE(simulation_physics, __FUNCTION__); if (_hasModel != entity->hasModel()) { _hasModel = entity->hasModel(); } @@ -1274,9 +1260,7 @@ void ModelEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& sce // TODO? early exit here when not visible? { -#ifdef WANT_DETAILED_PROFILING - PROFILE_RANGE(simulation_physics, "Fixup"); -#endif + DETAILED_PROFILE_RANGE(simulation_physics, "Fixup"); if (model->needsFixupInScene()) { model->removeFromScene(scene, transaction); render::Item::Status::Getters statusGetters; @@ -1292,9 +1276,7 @@ void ModelEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& sce } { -#ifdef WANT_DETAILED_PROFILING - PROFILE_RANGE(simulation_physics, "CheckAnimation"); -#endif + DETAILED_PROFILE_RANGE(simulation_physics, "CheckAnimation"); // make a copy of the animation properites auto newAnimationProperties = entity->getAnimationProperties(); if (newAnimationProperties != _renderAnimationProperties) { @@ -1306,9 +1288,7 @@ void ModelEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& sce } if (_animating) { -#ifdef WANT_DETAILED_PROFILING - PROFILE_RANGE(simulation_physics, "Animate"); -#endif + DETAILED_PROFILE_RANGE(simulation_physics, "Animate"); if (!jointsMapped()) { mapJoints(entity, model->getJointNames()); } @@ -1319,10 +1299,8 @@ void ModelEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& sce // NOTE: this only renders the "meta" portion of the Model, namely it renders debugging items void ModelEntityRenderer::doRender(RenderArgs* args) { -#ifdef WANT_DETAILED_PROFILING - PROFILE_RANGE(render_detail, "MetaModelRender"); - PerformanceTimer perfTimer("RMEIrender"); -#endif + DETAILED_PROFILE_RANGE(render_detail, "MetaModelRender"); + DETAILED_PERFORMANCE_TIMER("RMEIrender"); ModelPointer model; withReadLock([&]{ diff --git a/libraries/render-utils/src/Model.cpp b/libraries/render-utils/src/Model.cpp index 616b1554b5..964a1961d6 100644 --- a/libraries/render-utils/src/Model.cpp +++ b/libraries/render-utils/src/Model.cpp @@ -32,9 +32,6 @@ #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(); @@ -966,9 +963,7 @@ 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 + DETAILED_PROFILE_RANGE_EX(simulation_animation, __FUNCTION__, 0xFFFF0000, 0, { { "url", _model->getURL().toString() } }); QVector vertices, normals; if (_model) { int offset = 0; @@ -1089,10 +1084,7 @@ void Model::snapToRegistrationPoint() { } void Model::simulate(float deltaTime, bool fullUpdate) { -#ifdef WANT_DETAILED_PROFILING - PROFILE_RANGE(simulation_detail, __FUNCTION__); - PerformanceTimer perfTimer("Model::simulate"); -#endif + DETAILED_PROFILE_RANGE(simulation_detail, __FUNCTION__); fullUpdate = updateGeometry() || fullUpdate || (_scaleToFit && !_scaledToFit) || (_snapModelToRegistrationPoint && !_snappedToRegistrationPoint); @@ -1130,9 +1122,7 @@ void Model::computeMeshPartLocalBounds() { // virtual void Model::updateClusterMatrices() { -#ifdef WANT_DETAILED_PROFILING - PerformanceTimer perfTimer("Model::updateClusterMatrices"); -#endif + DETAILED_PERFORMANCE_TIMER("Model::updateClusterMatrices"); if (!_needsUpdateClusterMatrices || !isLoaded()) { return; diff --git a/libraries/shared/src/PerfStat.h b/libraries/shared/src/PerfStat.h index 785920779e..b09cb38808 100644 --- a/libraries/shared/src/PerfStat.h +++ b/libraries/shared/src/PerfStat.h @@ -97,5 +97,12 @@ private: static QMap _records; }; +// uncomment WANT_DETAILED_PERFORMANCE_TIMERS definition to enable performance timers in high-frequency contexts +//#define WANT_DETAILED_PERFORMANCE_TIMERS +#ifdef WANT_DETAILED_PERFORMANCE_TIMERS + #define DETAILED_PERFORMANCE_TIMER(name) PerformanceTimer detailedPerformanceTimer(name); +#else // WANT_DETAILED_PERFORMANCE_TIMERS + #define DETAILED_PERFORMANCE_TIMER(name) ; // no-op +#endif // WANT_DETAILED_PERFORMANCE_TIMERS #endif // hifi_PerfStat_h diff --git a/libraries/shared/src/Profile.h b/libraries/shared/src/Profile.h index 5de4e8f41a..fc6a2a52cb 100644 --- a/libraries/shared/src/Profile.h +++ b/libraries/shared/src/Profile.h @@ -108,4 +108,14 @@ inline void metadata(const QString& metadataType, const QVariantMap& args) { #define SAMPLE_PROFILE_COUNTER(chance, category, name, ...) if (randFloat() <= chance) { PROFILE_COUNTER(category, name, ##__VA_ARGS__); } #define SAMPLE_PROFILE_INSTANT(chance, category, name, ...) if (randFloat() <= chance) { PROFILE_INSTANT(category, name, ##__VA_ARGS__); } +// uncomment WANT_DETAILED_PROFILING definition to enable profiling in high-frequency contexts +//#define WANT_DETAILED_PROFILING +#ifdef WANT_DETAILED_PROFILING +#define DETAILED_PROFILE_RANGE(category, name) Duration profileRangeThis(trace_##category(), name); +#define DETAILED_PROFILE_RANGE_EX(category, name, argbColor, payload, ...) Duration profileRangeThis(trace_##category(), name, argbColor, (uint64_t)payload, ##__VA_ARGS__); +#else // WANT_DETAILED_PROFILING +#define DETAILED_PROFILE_RANGE(category, name) ; // no-op +#define DETAILED_PROFILE_RANGE_EX(category, name, argbColor, payload, ...) ; // no-op +#endif // WANT_DETAILED_PROFILING + #endif