Expose whether nsight is running to the app, disable some stuff under nsight

This commit is contained in:
Brad Davis 2016-08-07 12:03:33 -07:00
parent 4795ddd014
commit d548da02d9
5 changed files with 34 additions and 18 deletions

View file

@ -257,7 +257,10 @@ public:
void run() override { void run() override {
while (!_quit) { while (!_quit) {
QThread::sleep(HEARTBEAT_UPDATE_INTERVAL_SECS); QThread::sleep(HEARTBEAT_UPDATE_INTERVAL_SECS);
// Don't do heartbeat detection under nsight
if (nsightActive()) {
continue;
}
uint64_t lastHeartbeat = _heartbeat; // sample atomic _heartbeat, because we could context switch away and have it updated on us uint64_t lastHeartbeat = _heartbeat; // sample atomic _heartbeat, because we could context switch away and have it updated on us
uint64_t now = usecTimestampNow(); uint64_t now = usecTimestampNow();
auto lastHeartbeatAge = (now > lastHeartbeat) ? now - lastHeartbeat : 0; auto lastHeartbeatAge = (now > lastHeartbeat) ? now - lastHeartbeat : 0;
@ -305,8 +308,6 @@ public:
// Don't actually crash in debug builds, in case this apparent deadlock is simply from // Don't actually crash in debug builds, in case this apparent deadlock is simply from
// the developer actively debugging code // the developer actively debugging code
#ifdef NDEBUG #ifdef NDEBUG
deadlockDetectionCrash(); deadlockDetectionCrash();
#endif #endif
} }

View file

@ -57,7 +57,10 @@ EntityTreeRenderer::EntityTreeRenderer(bool wantScripts, AbstractViewStateInterf
REGISTER_ENTITY_TYPE_WITH_FACTORY(Model, RenderableModelEntityItem::factory) REGISTER_ENTITY_TYPE_WITH_FACTORY(Model, RenderableModelEntityItem::factory)
REGISTER_ENTITY_TYPE_WITH_FACTORY(Light, RenderableLightEntityItem::factory) REGISTER_ENTITY_TYPE_WITH_FACTORY(Light, RenderableLightEntityItem::factory)
REGISTER_ENTITY_TYPE_WITH_FACTORY(Text, RenderableTextEntityItem::factory) REGISTER_ENTITY_TYPE_WITH_FACTORY(Text, RenderableTextEntityItem::factory)
REGISTER_ENTITY_TYPE_WITH_FACTORY(Web, RenderableWebEntityItem::factory) // Offscreen web surfaces are incompatible with nSight
if (!nsightActive()) {
REGISTER_ENTITY_TYPE_WITH_FACTORY(Web, RenderableWebEntityItem::factory)
}
REGISTER_ENTITY_TYPE_WITH_FACTORY(ParticleEffect, RenderableParticleEffectEntityItem::factory) REGISTER_ENTITY_TYPE_WITH_FACTORY(ParticleEffect, RenderableParticleEffectEntityItem::factory)
REGISTER_ENTITY_TYPE_WITH_FACTORY(Zone, RenderableZoneEntityItem::factory) REGISTER_ENTITY_TYPE_WITH_FACTORY(Zone, RenderableZoneEntityItem::factory)
REGISTER_ENTITY_TYPE_WITH_FACTORY(Line, RenderableLineEntityItem::factory) REGISTER_ENTITY_TYPE_WITH_FACTORY(Line, RenderableLineEntityItem::factory)
@ -159,7 +162,9 @@ void EntityTreeRenderer::init() {
} }
void EntityTreeRenderer::shutdown() { void EntityTreeRenderer::shutdown() {
_entitiesScriptEngine->disconnectNonEssentialSignals(); // disconnect all slots/signals from the script engine, except essential if (_entitiesScriptEngine) {
_entitiesScriptEngine->disconnectNonEssentialSignals(); // disconnect all slots/signals from the script engine, except essential
}
_shuttingDown = true; _shuttingDown = true;
clear(); // always clear() on shutdown clear(); // always clear() on shutdown

View file

@ -8,10 +8,19 @@
#include "NsightHelpers.h" #include "NsightHelpers.h"
#ifdef _WIN32
#if defined(NSIGHT_FOUND) #if defined(_WIN32) && defined(NSIGHT_FOUND)
#include <QtCore/QProcessEnvironment>
#include "nvToolsExt.h" #include "nvToolsExt.h"
static const QString NSIGHT_FLAG("NSIGHT_LAUNCHED");
static const bool nsightLaunched = QProcessEnvironment::systemEnvironment().contains(NSIGHT_FLAG);
bool nsightActive() {
return nsightLaunched;
}
ProfileRange::ProfileRange(const char *name) { ProfileRange::ProfileRange(const char *name) {
_rangeId = nvtxRangeStart(name); _rangeId = nvtxRangeStart(name);
} }
@ -35,8 +44,9 @@ ProfileRange::~ProfileRange() {
} }
#else #else
ProfileRange::ProfileRange(const char *name) {}
ProfileRange::ProfileRange(const char *name, uint32_t argbColor, uint64_t payload) {} bool nsightActive() {
ProfileRange::~ProfileRange() {} return false;
#endif }
#endif // _WIN32 #endif // _WIN32

View file

@ -9,7 +9,9 @@
#ifndef hifi_gl_NsightHelpers_h #ifndef hifi_gl_NsightHelpers_h
#define hifi_gl_NsightHelpers_h #define hifi_gl_NsightHelpers_h
#ifdef _WIN32 bool nsightActive();
#if defined(_WIN32) && defined(NSIGHT_FOUND)
#include <stdint.h> #include <stdint.h>
class ProfileRange { class ProfileRange {
@ -18,9 +20,7 @@ public:
ProfileRange(const char *name, uint32_t argbColor, uint64_t payload); ProfileRange(const char *name, uint32_t argbColor, uint64_t payload);
~ProfileRange(); ~ProfileRange();
private: private:
#if defined(NSIGHT_FOUND)
uint64_t _rangeId{ 0 }; uint64_t _rangeId{ 0 };
#endif
}; };
#define PROFILE_RANGE(name) ProfileRange profileRangeThis(name); #define PROFILE_RANGE(name) ProfileRange profileRangeThis(name);

View file

@ -277,7 +277,9 @@ public:
auto duration = usecTimestampNow() - start; auto duration = usecTimestampNow() - start;
float frameTime = (float)duration / (float)USECS_PER_SECOND; float frameTime = (float)duration / (float)USECS_PER_SECOND;
float averageFrameTime = 1.0f / _fps; float averageFrameTime = 1.0f / _fps;
if ((abs(frameTime - averageFrameTime) - 1.0f) > 2.0f) { float diff = frameTime - averageFrameTime;
diff = std::max(diff, -diff);
if ((diff - 1.0f) > 2.0f) {
qDebug() << "Long frame " << frameTime * MSECS_PER_SECOND; qDebug() << "Long frame " << frameTime * MSECS_PER_SECOND;
} }
return true; return true;
@ -402,9 +404,7 @@ public:
AbstractViewStateInterface::setInstance(this); AbstractViewStateInterface::setInstance(this);
_octree = DependencyManager::set<EntityTreeRenderer>(false, this, nullptr); _octree = DependencyManager::set<EntityTreeRenderer>(false, this, nullptr);
_octree->init(); _octree->init();
// Prevent web entities from rendering
REGISTER_ENTITY_TYPE_WITH_FACTORY(Web, WebEntityItem::factory);
DependencyManager::set<ParentFinder>(_octree->getTree()); DependencyManager::set<ParentFinder>(_octree->getTree());
getEntities()->setViewFrustum(_viewFrustum); getEntities()->setViewFrustum(_viewFrustum);
auto nodeList = DependencyManager::get<LimitedNodeList>(); auto nodeList = DependencyManager::get<LimitedNodeList>();