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 {
while (!_quit) {
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 now = usecTimestampNow();
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
// the developer actively debugging code
#ifdef NDEBUG
deadlockDetectionCrash();
#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(Light, RenderableLightEntityItem::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(Zone, RenderableZoneEntityItem::factory)
REGISTER_ENTITY_TYPE_WITH_FACTORY(Line, RenderableLineEntityItem::factory)
@ -159,7 +162,9 @@ void EntityTreeRenderer::init() {
}
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;
clear(); // always clear() on shutdown

View file

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

View file

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

View file

@ -277,7 +277,9 @@ public:
auto duration = usecTimestampNow() - start;
float frameTime = (float)duration / (float)USECS_PER_SECOND;
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;
}
return true;
@ -402,9 +404,7 @@ public:
AbstractViewStateInterface::setInstance(this);
_octree = DependencyManager::set<EntityTreeRenderer>(false, this, nullptr);
_octree->init();
// Prevent web entities from rendering
REGISTER_ENTITY_TYPE_WITH_FACTORY(Web, WebEntityItem::factory);
DependencyManager::set<ParentFinder>(_octree->getTree());
getEntities()->setViewFrustum(_viewFrustum);
auto nodeList = DependencyManager::get<LimitedNodeList>();