tracing polish

This commit is contained in:
Brad Davis 2016-12-16 13:41:33 -08:00 committed by Seth Alves
parent e03e57a480
commit d0d6b1f87e
36 changed files with 191 additions and 122 deletions

View file

@ -184,6 +184,8 @@ extern "C" {
} }
#endif #endif
Q_LOGGING_CATEGORY(trace_app_input_mouse, "trace.app.input.mouse")
using namespace std; using namespace std;
static QTimer locationUpdateTimer; static QTimer locationUpdateTimer;
@ -2003,16 +2005,6 @@ void Application::initializeUi() {
} }
void Application::paintGL() { void Application::paintGL() {
PROFILE_COUNTER(interfaceapp, "fps", { { "fps", _frameCounter.rate() } });
PROFILE_COUNTER(interfaceapp, "downloads", {
{ "current", ResourceCache::getLoadingRequests().length() },
{ "pending", ResourceCache::getPendingRequestCount() }
});
PROFILE_COUNTER(interfaceapp, "processing", {
{ "current", DependencyManager::get<StatTracker>()->getStat("Processing") },
{ "pending", DependencyManager::get<StatTracker>()->getStat("PendingProcessing") }
});
// Some plugins process message events, allowing paintGL to be called reentrantly. // Some plugins process message events, allowing paintGL to be called reentrantly.
if (_inPaint || _aboutToQuit) { if (_inPaint || _aboutToQuit) {
return; return;
@ -2024,7 +2016,7 @@ void Application::paintGL() {
_frameCount++; _frameCount++;
auto lastPaintBegin = usecTimestampNow(); auto lastPaintBegin = usecTimestampNow();
PROFILE_RANGE_EX(interfaceapp, __FUNCTION__, 0xff0000ff, (uint64_t)_frameCount); PROFILE_RANGE_EX(render, __FUNCTION__, 0xff0000ff, (uint64_t)_frameCount);
PerformanceTimer perfTimer("paintGL"); PerformanceTimer perfTimer("paintGL");
if (nullptr == _displayPlugin) { if (nullptr == _displayPlugin) {
@ -2201,7 +2193,7 @@ void Application::paintGL() {
auto finalFramebuffer = framebufferCache->getFramebuffer(); auto finalFramebuffer = framebufferCache->getFramebuffer();
{ {
PROFILE_RANGE(interfaceapp, "/mainRender"); PROFILE_RANGE(render, "/mainRender");
PerformanceTimer perfTimer("mainRender"); PerformanceTimer perfTimer("mainRender");
renderArgs._boomOffset = boomOffset; renderArgs._boomOffset = boomOffset;
// Viewport is assigned to the size of the framebuffer // Viewport is assigned to the size of the framebuffer
@ -2256,7 +2248,7 @@ void Application::paintGL() {
frame->overlay = _applicationOverlay.getOverlayTexture(); frame->overlay = _applicationOverlay.getOverlayTexture();
// deliver final scene rendering commands to the display plugin // deliver final scene rendering commands to the display plugin
{ {
PROFILE_RANGE(interfaceapp, "/pluginOutput"); PROFILE_RANGE(render, "/pluginOutput");
PerformanceTimer perfTimer("pluginOutput"); PerformanceTimer perfTimer("pluginOutput");
_frameCounter.increment(); _frameCounter.increment();
displayPlugin->submitFrame(frame); displayPlugin->submitFrame(frame);
@ -2344,7 +2336,7 @@ void Application::resizeEvent(QResizeEvent* event) {
} }
void Application::resizeGL() { void Application::resizeGL() {
PROFILE_RANGE(interfaceapp, __FUNCTION__); PROFILE_RANGE(render, __FUNCTION__);
if (nullptr == _displayPlugin) { if (nullptr == _displayPlugin) {
return; return;
} }
@ -3012,7 +3004,7 @@ void Application::maybeToggleMenuVisible(QMouseEvent* event) const {
} }
void Application::mouseMoveEvent(QMouseEvent* event) { void Application::mouseMoveEvent(QMouseEvent* event) {
PROFILE_RANGE(interfaceapp, __FUNCTION__); PROFILE_RANGE(app_input_mouse, __FUNCTION__);
if (_aboutToQuit) { if (_aboutToQuit) {
return; return;
@ -3322,6 +3314,18 @@ void Application::idle(float nsecsElapsed) {
connect(offscreenUi.data(), &OffscreenUi::showDesktop, this, &Application::showDesktop); connect(offscreenUi.data(), &OffscreenUi::showDesktop, this, &Application::showDesktop);
} }
PROFILE_COUNTER(app, "fps", { { "fps", _frameCounter.rate() } });
PROFILE_COUNTER(app, "downloads", {
{ "current", ResourceCache::getLoadingRequests().length() },
{ "pending", ResourceCache::getPendingRequestCount() }
});
PROFILE_COUNTER(app, "processing", {
{ "current", DependencyManager::get<StatTracker>()->getStat("Processing") },
{ "pending", DependencyManager::get<StatTracker>()->getStat("PendingProcessing") }
});
PROFILE_RANGE(app, __FUNCTION__);
if (auto steamClient = PluginManager::getInstance()->getSteamClientPlugin()) { if (auto steamClient = PluginManager::getInstance()->getSteamClientPlugin()) {
steamClient->runCallbacks(); steamClient->runCallbacks();
} }
@ -4087,7 +4091,7 @@ static bool domainLoadingInProgress = false;
void Application::update(float deltaTime) { void Application::update(float deltaTime) {
PROFILE_RANGE_EX(interfaceapp, __FUNCTION__, 0xffff0000, (uint64_t)_frameCount + 1); PROFILE_RANGE_EX(app, __FUNCTION__, 0xffff0000, (uint64_t)_frameCount + 1);
bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
PerformanceWarning warn(showWarnings, "Application::update()"); PerformanceWarning warn(showWarnings, "Application::update()");
@ -4096,7 +4100,7 @@ void Application::update(float deltaTime) {
if (!_physicsEnabled) { if (!_physicsEnabled) {
if (!domainLoadingInProgress) { if (!domainLoadingInProgress) {
PROFILE_ASYNC_BEGIN(interfaceapp, "Scene Loading", ""); PROFILE_ASYNC_BEGIN(app, "Scene Loading", "");
domainLoadingInProgress = true; domainLoadingInProgress = true;
} }
@ -4131,7 +4135,7 @@ void Application::update(float deltaTime) {
} }
} else if (domainLoadingInProgress) { } else if (domainLoadingInProgress) {
domainLoadingInProgress = false; domainLoadingInProgress = false;
PROFILE_ASYNC_END(interfaceapp, "Scene Loading", ""); PROFILE_ASYNC_END(app, "Scene Loading", "");
} }
{ {
@ -4225,12 +4229,12 @@ void Application::update(float deltaTime) {
QSharedPointer<AvatarManager> avatarManager = DependencyManager::get<AvatarManager>(); QSharedPointer<AvatarManager> avatarManager = DependencyManager::get<AvatarManager>();
if (_physicsEnabled) { if (_physicsEnabled) {
PROFILE_RANGE_EX(interfaceapp, "Physics", 0xffff0000, (uint64_t)getActiveDisplayPlugin()->presentCount()); PROFILE_RANGE_EX(simulation_physics, "Physics", 0xffff0000, (uint64_t)getActiveDisplayPlugin()->presentCount());
PerformanceTimer perfTimer("physics"); PerformanceTimer perfTimer("physics");
{ {
PROFILE_RANGE_EX(interfaceapp, "UpdateStats", 0xffffff00, (uint64_t)getActiveDisplayPlugin()->presentCount()); PROFILE_RANGE_EX(simulation_physics, "UpdateStats", 0xffffff00, (uint64_t)getActiveDisplayPlugin()->presentCount());
PerformanceTimer perfTimer("updateStates)"); PerformanceTimer perfTimer("updateStates)");
static VectorOfMotionStates motionStates; static VectorOfMotionStates motionStates;
@ -4264,14 +4268,14 @@ void Application::update(float deltaTime) {
}); });
} }
{ {
PROFILE_RANGE_EX(interfaceapp, "StepSimulation", 0xffff8000, (uint64_t)getActiveDisplayPlugin()->presentCount()); PROFILE_RANGE_EX(simulation_physics, "StepSimulation", 0xffff8000, (uint64_t)getActiveDisplayPlugin()->presentCount());
PerformanceTimer perfTimer("stepSimulation"); PerformanceTimer perfTimer("stepSimulation");
getEntities()->getTree()->withWriteLock([&] { getEntities()->getTree()->withWriteLock([&] {
_physicsEngine->stepSimulation(); _physicsEngine->stepSimulation();
}); });
} }
{ {
PROFILE_RANGE_EX(interfaceapp, "HarvestChanges", 0xffffff00, (uint64_t)getActiveDisplayPlugin()->presentCount()); PROFILE_RANGE_EX(simulation_physics, "HarvestChanges", 0xffffff00, (uint64_t)getActiveDisplayPlugin()->presentCount());
PerformanceTimer perfTimer("harvestChanges"); PerformanceTimer perfTimer("harvestChanges");
if (_physicsEngine->hasOutgoingChanges()) { if (_physicsEngine->hasOutgoingChanges()) {
getEntities()->getTree()->withWriteLock([&] { getEntities()->getTree()->withWriteLock([&] {
@ -4313,20 +4317,20 @@ void Application::update(float deltaTime) {
_avatarSimCounter.increment(); _avatarSimCounter.increment();
{ {
PROFILE_RANGE_EX(interfaceapp, "OtherAvatars", 0xffff00ff, (uint64_t)getActiveDisplayPlugin()->presentCount()); PROFILE_RANGE_EX(simulation, "OtherAvatars", 0xffff00ff, (uint64_t)getActiveDisplayPlugin()->presentCount());
avatarManager->updateOtherAvatars(deltaTime); avatarManager->updateOtherAvatars(deltaTime);
} }
qApp->updateMyAvatarLookAtPosition(); qApp->updateMyAvatarLookAtPosition();
{ {
PROFILE_RANGE_EX(interfaceapp, "MyAvatar", 0xffff00ff, (uint64_t)getActiveDisplayPlugin()->presentCount()); PROFILE_RANGE_EX(simulation, "MyAvatar", 0xffff00ff, (uint64_t)getActiveDisplayPlugin()->presentCount());
avatarManager->updateMyAvatar(deltaTime); avatarManager->updateMyAvatar(deltaTime);
} }
} }
{ {
PROFILE_RANGE_EX(interfaceapp, "Overlays", 0xffff0000, (uint64_t)getActiveDisplayPlugin()->presentCount()); PROFILE_RANGE_EX(app, "Overlays", 0xffff0000, (uint64_t)getActiveDisplayPlugin()->presentCount());
PerformanceTimer perfTimer("overlays"); PerformanceTimer perfTimer("overlays");
_overlays.update(deltaTime); _overlays.update(deltaTime);
} }
@ -4346,7 +4350,7 @@ void Application::update(float deltaTime) {
// Update my voxel servers with my current voxel query... // Update my voxel servers with my current voxel query...
{ {
PROFILE_RANGE_EX(interfaceapp, "QueryOctree", 0xffff0000, (uint64_t)getActiveDisplayPlugin()->presentCount()); PROFILE_RANGE_EX(app, "QueryOctree", 0xffff0000, (uint64_t)getActiveDisplayPlugin()->presentCount());
QMutexLocker viewLocker(&_viewMutex); QMutexLocker viewLocker(&_viewMutex);
PerformanceTimer perfTimer("queryOctree"); PerformanceTimer perfTimer("queryOctree");
quint64 sinceLastQuery = now - _lastQueriedTime; quint64 sinceLastQuery = now - _lastQueriedTime;
@ -4386,7 +4390,7 @@ void Application::update(float deltaTime) {
avatarManager->postUpdate(deltaTime); avatarManager->postUpdate(deltaTime);
{ {
PROFILE_RANGE_EX(interfaceapp, "PreRenderLambdas", 0xffff0000, (uint64_t)0); PROFILE_RANGE_EX(app, "PreRenderLambdas", 0xffff0000, (uint64_t)0);
std::unique_lock<std::mutex> guard(_postUpdateLambdasLock); std::unique_lock<std::mutex> guard(_postUpdateLambdasLock);
for (auto& iter : _postUpdateLambdas) { for (auto& iter : _postUpdateLambdas) {
@ -4663,8 +4667,11 @@ QRect Application::getDesirableApplicationGeometry() const {
// or the "myCamera". // or the "myCamera".
// //
void Application::loadViewFrustum(Camera& camera, ViewFrustum& viewFrustum) { void Application::loadViewFrustum(Camera& camera, ViewFrustum& viewFrustum) {
<<<<<<< HEAD
PROFILE_RANGE(interfaceapp, __FUNCTION__); PROFILE_RANGE(interfaceapp, __FUNCTION__);
PerformanceTimer perfTimer("loadViewFrustum"); PerformanceTimer perfTimer("loadViewFrustum");
=======
>>>>>>> tracing polish
// We will use these below, from either the camera or head vectors calculated above // We will use these below, from either the camera or head vectors calculated above
viewFrustum.setProjection(camera.getProjection()); viewFrustum.setProjection(camera.getProjection());
@ -4840,7 +4847,7 @@ void Application::displaySide(RenderArgs* renderArgs, Camera& theCamera, bool se
myAvatar->preDisplaySide(renderArgs); myAvatar->preDisplaySide(renderArgs);
activeRenderingThread = QThread::currentThread(); activeRenderingThread = QThread::currentThread();
PROFILE_RANGE(interfaceapp, __FUNCTION__); PROFILE_RANGE(render, __FUNCTION__);
PerformanceTimer perfTimer("display"); PerformanceTimer perfTimer("display");
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), "Application::displaySide()"); PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), "Application::displaySide()");

View file

@ -57,7 +57,7 @@ ApplicationOverlay::~ApplicationOverlay() {
// Renders the overlays either to a texture or to the screen // Renders the overlays either to a texture or to the screen
void ApplicationOverlay::renderOverlay(RenderArgs* renderArgs) { void ApplicationOverlay::renderOverlay(RenderArgs* renderArgs) {
PROFILE_RANGE(interfaceapp, __FUNCTION__); PROFILE_RANGE(render, __FUNCTION__);
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), "ApplicationOverlay::displayOverlay()"); PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), "ApplicationOverlay::displayOverlay()");
buildFramebufferObject(); buildFramebufferObject();
@ -96,7 +96,7 @@ void ApplicationOverlay::renderOverlay(RenderArgs* renderArgs) {
} }
void ApplicationOverlay::renderQmlUi(RenderArgs* renderArgs) { void ApplicationOverlay::renderQmlUi(RenderArgs* renderArgs) {
PROFILE_RANGE(interfaceapp, __FUNCTION__); PROFILE_RANGE(app, __FUNCTION__);
if (!_uiTexture) { if (!_uiTexture) {
_uiTexture = gpu::TexturePointer(gpu::Texture::createExternal2D(OffscreenQmlSurface::getDiscardLambda())); _uiTexture = gpu::TexturePointer(gpu::Texture::createExternal2D(OffscreenQmlSurface::getDiscardLambda()));
@ -124,7 +124,7 @@ void ApplicationOverlay::renderQmlUi(RenderArgs* renderArgs) {
} }
void ApplicationOverlay::renderAudioScope(RenderArgs* renderArgs) { void ApplicationOverlay::renderAudioScope(RenderArgs* renderArgs) {
PROFILE_RANGE(interfaceapp, __FUNCTION__); PROFILE_RANGE(app, __FUNCTION__);
gpu::Batch& batch = *renderArgs->_batch; gpu::Batch& batch = *renderArgs->_batch;
auto geometryCache = DependencyManager::get<GeometryCache>(); auto geometryCache = DependencyManager::get<GeometryCache>();
@ -143,7 +143,7 @@ void ApplicationOverlay::renderAudioScope(RenderArgs* renderArgs) {
} }
void ApplicationOverlay::renderOverlays(RenderArgs* renderArgs) { void ApplicationOverlay::renderOverlays(RenderArgs* renderArgs) {
PROFILE_RANGE(interfaceapp, __FUNCTION__); PROFILE_RANGE(app, __FUNCTION__);
gpu::Batch& batch = *renderArgs->_batch; gpu::Batch& batch = *renderArgs->_batch;
auto geometryCache = DependencyManager::get<GeometryCache>(); auto geometryCache = DependencyManager::get<GeometryCache>();
@ -262,7 +262,7 @@ static const auto DEFAULT_SAMPLER = gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_LI
static const auto DEPTH_FORMAT = gpu::Element(gpu::SCALAR, gpu::FLOAT, gpu::DEPTH); static const auto DEPTH_FORMAT = gpu::Element(gpu::SCALAR, gpu::FLOAT, gpu::DEPTH);
void ApplicationOverlay::buildFramebufferObject() { void ApplicationOverlay::buildFramebufferObject() {
PROFILE_RANGE(interfaceapp, __FUNCTION__); PROFILE_RANGE(app, __FUNCTION__);
auto uiSize = qApp->getUiSize(); auto uiSize = qApp->getUiSize();
if (!_overlayFramebuffer || uiSize != _overlayFramebuffer->getSize()) { if (!_overlayFramebuffer || uiSize != _overlayFramebuffer->getSize()) {

View file

@ -37,6 +37,7 @@
#include "Web3DOverlay.h" #include "Web3DOverlay.h"
#include <QtQuick/QQuickWindow> #include <QtQuick/QQuickWindow>
Q_LOGGING_CATEGORY(trace_render_overlays, "trace.render.overlays")
Overlays::Overlays() : Overlays::Overlays() :
_nextOverlayID(1) {} _nextOverlayID(1) {}
@ -102,7 +103,7 @@ void Overlays::cleanupOverlaysToDelete() {
} }
void Overlays::renderHUD(RenderArgs* renderArgs) { void Overlays::renderHUD(RenderArgs* renderArgs) {
PROFILE_RANGE(interfaceapp, __FUNCTION__); PROFILE_RANGE(render_overlays, __FUNCTION__);
QReadLocker lock(&_lock); QReadLocker lock(&_lock);
gpu::Batch& batch = *renderArgs->_batch; gpu::Batch& batch = *renderArgs->_batch;

View file

@ -394,7 +394,7 @@ const AnimPoseVec& AnimInverseKinematics::overlay(const AnimVariantMap& animVars
loadPoses(underPoses); loadPoses(underPoses);
} else { } else {
PROFILE_RANGE_EX(animation, "ik/relax", 0xffff00ff, 0); PROFILE_RANGE_EX(simulation_animation, "ik/relax", 0xffff00ff, 0);
// relax toward underPoses // relax toward underPoses
// HACK: this relaxation needs to be constant per-frame rather than per-realtime // HACK: this relaxation needs to be constant per-frame rather than per-realtime
@ -433,7 +433,7 @@ const AnimPoseVec& AnimInverseKinematics::overlay(const AnimVariantMap& animVars
// build a list of targets from _targetVarVec // build a list of targets from _targetVarVec
std::vector<IKTarget> targets; std::vector<IKTarget> targets;
{ {
PROFILE_RANGE_EX(animation, "ik/computeTargets", 0xffff00ff, 0); PROFILE_RANGE_EX(simulation_animation, "ik/computeTargets", 0xffff00ff, 0);
computeTargets(animVars, targets, underPoses); computeTargets(animVars, targets, underPoses);
} }
@ -450,7 +450,7 @@ const AnimPoseVec& AnimInverseKinematics::overlay(const AnimVariantMap& animVars
} else { } else {
{ {
PROFILE_RANGE_EX(animation, "ik/shiftHips", 0xffff00ff, 0); PROFILE_RANGE_EX(simulation_animation, "ik/shiftHips", 0xffff00ff, 0);
// shift hips according to the _hipsOffset from the previous frame // shift hips according to the _hipsOffset from the previous frame
float offsetLength = glm::length(_hipsOffset); float offsetLength = glm::length(_hipsOffset);
@ -476,12 +476,12 @@ const AnimPoseVec& AnimInverseKinematics::overlay(const AnimVariantMap& animVars
} }
{ {
PROFILE_RANGE_EX(animation, "ik/ccd", 0xffff00ff, 0); PROFILE_RANGE_EX(simulation_animation, "ik/ccd", 0xffff00ff, 0);
solveWithCyclicCoordinateDescent(targets); solveWithCyclicCoordinateDescent(targets);
} }
{ {
PROFILE_RANGE_EX(animation, "ik/measureHipsOffset", 0xffff00ff, 0); PROFILE_RANGE_EX(simulation_animation, "ik/measureHipsOffset", 0xffff00ff, 0);
// measure new _hipsOffset for next frame // measure new _hipsOffset for next frame
// by looking for discrepancies between where a targeted endEffector is // by looking for discrepancies between where a targeted endEffector is

View file

@ -55,7 +55,7 @@ void AnimationReader::run() {
DependencyManager::get<StatTracker>()->decrementStat("PendingProcessing"); DependencyManager::get<StatTracker>()->decrementStat("PendingProcessing");
CounterStat counter("Processing"); CounterStat counter("Processing");
PROFILE_RANGE_EX(animation, __FUNCTION__, 0xFF00FF00, 0, { { "url", _url.toString() } }); PROFILE_RANGE_EX(resource_parse, __FUNCTION__, 0xFF00FF00, 0, { { "url", _url.toString() } });
auto originalPriority = QThread::currentThread()->priority(); auto originalPriority = QThread::currentThread()->priority();
if (originalPriority == QThread::InheritPriority) { if (originalPriority == QThread::InheritPriority) {
originalPriority = QThread::NormalPriority; originalPriority = QThread::NormalPriority;

View file

@ -883,7 +883,7 @@ void Rig::updateAnimationStateHandlers() { // called on avatar update thread (wh
void Rig::updateAnimations(float deltaTime, glm::mat4 rootTransform) { void Rig::updateAnimations(float deltaTime, glm::mat4 rootTransform) {
PROFILE_RANGE_EX(animation, __FUNCTION__, 0xffff00ff, 0); PROFILE_RANGE_EX(simulation_animation, __FUNCTION__, 0xffff00ff, 0);
setModelOffset(rootTransform); setModelOffset(rootTransform);

View file

@ -129,7 +129,7 @@ public:
_context->makeCurrent(); _context->makeCurrent();
while (!_shutdown) { while (!_shutdown) {
if (_pendingMainThreadOperation) { if (_pendingMainThreadOperation) {
PROFILE_RANGE(displayPlugins, "MainThreadOp") PROFILE_RANGE(render, "MainThreadOp")
{ {
Lock lock(_mutex); Lock lock(_mutex);
_context->doneCurrent(); _context->doneCurrent();
@ -203,7 +203,7 @@ public:
// Execute the frame and present it to the display device. // Execute the frame and present it to the display device.
_context->makeCurrent(); _context->makeCurrent();
{ {
PROFILE_RANGE(displayPlugins, "PluginPresent") PROFILE_RANGE(render, "PluginPresent")
currentPlugin->present(); currentPlugin->present();
CHECK_GL_ERROR(); CHECK_GL_ERROR();
} }
@ -560,22 +560,22 @@ void OpenGLDisplayPlugin::compositeLayers() {
updateCompositeFramebuffer(); updateCompositeFramebuffer();
{ {
PROFILE_RANGE_EX(displayPlugins, "compositeScene", 0xff0077ff, (uint64_t)presentCount()) PROFILE_RANGE_EX(render, "compositeScene", 0xff0077ff, (uint64_t)presentCount())
compositeScene(); compositeScene();
} }
{ {
PROFILE_RANGE_EX(displayPlugins, "compositeOverlay", 0xff0077ff, (uint64_t)presentCount()) PROFILE_RANGE_EX(render, "compositeOverlay", 0xff0077ff, (uint64_t)presentCount())
compositeOverlay(); compositeOverlay();
} }
auto compositorHelper = DependencyManager::get<CompositorHelper>(); auto compositorHelper = DependencyManager::get<CompositorHelper>();
if (compositorHelper->getReticleVisible()) { if (compositorHelper->getReticleVisible()) {
PROFILE_RANGE_EX(displayPlugins, "compositePointer", 0xff0077ff, (uint64_t)presentCount()) PROFILE_RANGE_EX(render, "compositePointer", 0xff0077ff, (uint64_t)presentCount())
compositePointer(); compositePointer();
} }
{ {
PROFILE_RANGE_EX(displayPlugins, "compositeExtra", 0xff0077ff, (uint64_t)presentCount()) PROFILE_RANGE_EX(render, "compositeExtra", 0xff0077ff, (uint64_t)presentCount())
compositeExtra(); compositeExtra();
} }
} }
@ -595,12 +595,12 @@ void OpenGLDisplayPlugin::internalPresent() {
} }
void OpenGLDisplayPlugin::present() { void OpenGLDisplayPlugin::present() {
PROFILE_RANGE_EX(displayPlugins, __FUNCTION__, 0xffffff00, (uint64_t)presentCount()) PROFILE_RANGE_EX(render, __FUNCTION__, 0xffffff00, (uint64_t)presentCount())
updateFrameData(); updateFrameData();
incrementPresentCount(); incrementPresentCount();
{ {
PROFILE_RANGE_EX(displayPlugins, "recycle", 0xff00ff00, (uint64_t)presentCount()) PROFILE_RANGE_EX(render, "recycle", 0xff00ff00, (uint64_t)presentCount())
_gpuContext->recycle(); _gpuContext->recycle();
} }
@ -614,19 +614,19 @@ void OpenGLDisplayPlugin::present() {
_lastFrame = _currentFrame.get(); _lastFrame = _currentFrame.get();
}); });
// Execute the frame rendering commands // Execute the frame rendering commands
PROFILE_RANGE_EX(displayPlugins, "execute", 0xff00ff00, (uint64_t)presentCount()) PROFILE_RANGE_EX(render, "execute", 0xff00ff00, (uint64_t)presentCount())
_gpuContext->executeFrame(_currentFrame); _gpuContext->executeFrame(_currentFrame);
} }
// Write all layers to a local framebuffer // Write all layers to a local framebuffer
{ {
PROFILE_RANGE_EX(displayPlugins, "composite", 0xff00ffff, (uint64_t)presentCount()) PROFILE_RANGE_EX(render, "composite", 0xff00ffff, (uint64_t)presentCount())
compositeLayers(); compositeLayers();
} }
// Take the composite framebuffer and send it to the output device // Take the composite framebuffer and send it to the output device
{ {
PROFILE_RANGE_EX(displayPlugins, "internalPresent", 0xff00ffff, (uint64_t)presentCount()) PROFILE_RANGE_EX(render, "internalPresent", 0xff00ffff, (uint64_t)presentCount())
internalPresent(); internalPresent();
} }

View file

@ -206,7 +206,7 @@ float HmdDisplayPlugin::getLeftCenterPixel() const {
} }
void HmdDisplayPlugin::internalPresent() { void HmdDisplayPlugin::internalPresent() {
PROFILE_RANGE_EX(displayPlugins, __FUNCTION__, 0xff00ff00, (uint64_t)presentCount()) PROFILE_RANGE_EX(render, __FUNCTION__, 0xff00ff00, (uint64_t)presentCount())
// Composite together the scene, overlay and mouse cursor // Composite together the scene, overlay and mouse cursor
hmdPresent(); hmdPresent();

View file

@ -211,7 +211,7 @@ namespace render {
template <> void payloadRender(const RenderableModelEntityItemMeta::Pointer& payload, RenderArgs* args) { template <> void payloadRender(const RenderableModelEntityItemMeta::Pointer& payload, RenderArgs* args) {
if (args) { if (args) {
if (payload && payload->entity) { if (payload && payload->entity) {
PROFILE_RANGE(renderlogging, "MetaModelRender"); PROFILE_RANGE(render, "MetaModelRender");
payload->entity->render(args); payload->entity->render(args);
} }
} }

View file

@ -321,7 +321,7 @@ FBXNode parseTextFBXNode(Tokenizer& tokenizer) {
} }
FBXNode FBXReader::parseFBX(QIODevice* device) { FBXNode FBXReader::parseFBX(QIODevice* device) {
PROFILE_RANGE_EX(modelformat, __FUNCTION__, 0xff0000ff, device); PROFILE_RANGE_EX(resource_parse, __FUNCTION__, 0xff0000ff, device);
// verify the prolog // verify the prolog
const QByteArray BINARY_PROLOG = "Kaydara FBX Binary "; const QByteArray BINARY_PROLOG = "Kaydara FBX Binary ";
if (device->peek(BINARY_PROLOG.size()) != BINARY_PROLOG) { if (device->peek(BINARY_PROLOG.size()) != BINARY_PROLOG) {

View file

@ -420,7 +420,7 @@ done:
FBXGeometry* OBJReader::readOBJ(QByteArray& model, const QVariantHash& mapping, const QUrl& url) { FBXGeometry* OBJReader::readOBJ(QByteArray& model, const QVariantHash& mapping, const QUrl& url) {
PROFILE_RANGE_EX(modelformat, __FUNCTION__, 0xffff0000, nullptr); PROFILE_RANGE_EX(resource_parse, __FUNCTION__, 0xffff0000, nullptr);
QBuffer buffer { &model }; QBuffer buffer { &model };
buffer.open(QIODevice::ReadOnly); buffer.open(QIODevice::ReadOnly);

View file

@ -38,6 +38,9 @@
#include "GLLogging.h" #include "GLLogging.h"
#include "Context.h" #include "Context.h"
Q_LOGGING_CATEGORY(trace_render_qml, "trace.render.qml")
Q_LOGGING_CATEGORY(trace_render_qml_gl, "trace.render.qml.gl")
struct TextureSet { struct TextureSet {
// The number of surfaces with this size // The number of surfaces with this size
size_t count { 0 }; size_t count { 0 };
@ -276,6 +279,7 @@ void OffscreenQmlSurface::render() {
return; return;
} }
PROFILE_RANGE(render_qml_gl, __FUNCTION__)
_canvas->makeCurrent(); _canvas->makeCurrent();
_renderControl->sync(); _renderControl->sync();
@ -284,7 +288,6 @@ void OffscreenQmlSurface::render() {
GLuint texture = offscreenTextures.getNextTexture(_size); GLuint texture = offscreenTextures.getNextTexture(_size);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, _fbo); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, _fbo);
glFramebufferTexture(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, texture, 0); glFramebufferTexture(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, texture, 0);
PROFILE_RANGE(glLogging, "qml_render->rendercontrol")
_renderControl->render(); _renderControl->render();
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
glBindTexture(GL_TEXTURE_2D, texture); glBindTexture(GL_TEXTURE_2D, texture);
@ -617,12 +620,12 @@ void OffscreenQmlSurface::updateQuick() {
} }
if (_polish) { if (_polish) {
PROFILE_RANGE(render_qml, "OffscreenQML polish")
_renderControl->polishItems(); _renderControl->polishItems();
_polish = false; _polish = false;
} }
if (_render) { if (_render) {
PROFILE_RANGE(glLogging, __FUNCTION__);
render(); render();
_render = false; _render = false;
} }

View file

@ -200,7 +200,7 @@ void GLBackend::renderPassTransfer(const Batch& batch) {
_inRenderTransferPass = true; _inRenderTransferPass = true;
{ // Sync all the buffers { // Sync all the buffers
PROFILE_RANGE(gpugllogging, "syncGPUBuffer"); PROFILE_RANGE(render_gpu_gl, "syncGPUBuffer");
for (auto& cached : batch._buffers._items) { for (auto& cached : batch._buffers._items) {
if (cached._data) { if (cached._data) {
@ -210,7 +210,7 @@ void GLBackend::renderPassTransfer(const Batch& batch) {
} }
{ // Sync all the buffers { // Sync all the buffers
PROFILE_RANGE(gpugllogging, "syncCPUTransform"); PROFILE_RANGE(render_gpu_gl, "syncCPUTransform");
_transform._cameras.clear(); _transform._cameras.clear();
_transform._cameraOffsets.clear(); _transform._cameraOffsets.clear();
@ -242,7 +242,7 @@ void GLBackend::renderPassTransfer(const Batch& batch) {
} }
{ // Sync the transform buffers { // Sync the transform buffers
PROFILE_RANGE(gpugllogging, "syncGPUTransform"); PROFILE_RANGE(render_gpu_gl, "syncGPUTransform");
transferTransformState(batch); transferTransformState(batch);
} }
@ -304,7 +304,7 @@ void GLBackend::render(const Batch& batch) {
} }
{ {
PROFILE_RANGE(gpugllogging, "Transfer"); PROFILE_RANGE(render_gpu_gl, "Transfer");
renderPassTransfer(batch); renderPassTransfer(batch);
} }
@ -314,7 +314,7 @@ void GLBackend::render(const Batch& batch) {
} }
#endif #endif
{ {
PROFILE_RANGE(gpugllogging, _stereo._enable ? "Render Stereo" : "Render"); PROFILE_RANGE(render_gpu_gl, _stereo._enable ? "Render Stereo" : "Render");
renderPassDraw(batch); renderPassDraw(batch);
} }
#ifdef GPU_STEREO_DRAWCALL_INSTANCED #ifdef GPU_STEREO_DRAWCALL_INSTANCED

View file

@ -28,7 +28,7 @@ void GLBackend::do_beginQuery(const Batch& batch, size_t paramOffset) {
auto query = batch._queries.get(batch._params[paramOffset]._uint); auto query = batch._queries.get(batch._params[paramOffset]._uint);
GLQuery* glquery = syncGPUObject(*query); GLQuery* glquery = syncGPUObject(*query);
if (glquery) { if (glquery) {
PROFILE_RANGE_BEGIN(gpugllogging, glquery->_profileRangeId, query->getName().c_str(), 0xFFFF7F00); PROFILE_RANGE_BEGIN(render_gpu_gl, glquery->_profileRangeId, query->getName().c_str(), 0xFFFF7F00);
++_queryStage._rangeQueryDepth; ++_queryStage._rangeQueryDepth;
glGetInteger64v(GL_TIMESTAMP, (GLint64*)&glquery->_batchElapsedTime); glGetInteger64v(GL_TIMESTAMP, (GLint64*)&glquery->_batchElapsedTime);
@ -62,7 +62,7 @@ void GLBackend::do_endQuery(const Batch& batch, size_t paramOffset) {
glGetInteger64v(GL_TIMESTAMP, &now); glGetInteger64v(GL_TIMESTAMP, &now);
glquery->_batchElapsedTime = now - glquery->_batchElapsedTime; glquery->_batchElapsedTime = now - glquery->_batchElapsedTime;
PROFILE_RANGE_END(gpugllogging, glquery->_profileRangeId); PROFILE_RANGE_END(render_gpu_gl, glquery->_profileRangeId);
(void)CHECK_GL_ERROR(); (void)CHECK_GL_ERROR();
} }

View file

@ -16,6 +16,7 @@
#include <fstream> #include <fstream>
Q_LOGGING_CATEGORY(gpugllogging, "hifi.gpu.gl") Q_LOGGING_CATEGORY(gpugllogging, "hifi.gpu.gl")
Q_LOGGING_CATEGORY(trace_render_gpu_gl, "trace.render.gpu.gl")
namespace gpu { namespace gl { namespace gpu { namespace gl {

View file

@ -15,6 +15,7 @@
#include <QLoggingCategory> #include <QLoggingCategory>
Q_DECLARE_LOGGING_CATEGORY(gpugllogging) Q_DECLARE_LOGGING_CATEGORY(gpugllogging)
Q_DECLARE_LOGGING_CATEGORY(trace_render_gpu_gl)
namespace gpu { namespace gl { namespace gpu { namespace gl {

View file

@ -122,7 +122,7 @@ void GL41Texture::transferMip(uint16_t mipLevel, uint8_t face) const {
} }
void GL41Texture::startTransfer() { void GL41Texture::startTransfer() {
PROFILE_RANGE(gpugllogging, __FUNCTION__); PROFILE_RANGE(render_gpu_gl, __FUNCTION__);
Parent::startTransfer(); Parent::startTransfer();
glBindTexture(_target, _id); glBindTexture(_target, _id);

View file

@ -759,7 +759,7 @@ bool sphericalHarmonicsFromTexture(const gpu::Texture& cubeTexture, std::vector<
return false; return false;
} }
PROFILE_RANGE(gpulogging, "sphericalHarmonicsFromTexture"); PROFILE_RANGE(render_gpu, "sphericalHarmonicsFromTexture");
const uint sqOrder = order*order; const uint sqOrder = order*order;
@ -792,7 +792,7 @@ bool sphericalHarmonicsFromTexture(const gpu::Texture& cubeTexture, std::vector<
// for each face of cube texture // for each face of cube texture
for(int face=0; face < gpu::Texture::NUM_CUBE_FACES; face++) { for(int face=0; face < gpu::Texture::NUM_CUBE_FACES; face++) {
PROFILE_RANGE(gpulogging, "ProcessFace"); PROFILE_RANGE(render_gpu, "ProcessFace");
auto numComponents = cubeTexture.accessStoredMipFace(0,face)->getFormat().getScalarCount(); auto numComponents = cubeTexture.accessStoredMipFace(0,face)->getFormat().getScalarCount();
auto data = cubeTexture.accessStoredMipFace(0,face)->readData(); auto data = cubeTexture.accessStoredMipFace(0,face)->readData();

View file

@ -24,6 +24,8 @@
#include <Trace.h> #include <Trace.h>
#include <StatTracker.h> #include <StatTracker.h>
Q_LOGGING_CATEGORY(trace_resource_parse_geometry, "trace.resource.parse.geometry")
class GeometryReader; class GeometryReader;
class GeometryExtra { class GeometryExtra {
@ -54,7 +56,7 @@ private:
}; };
void GeometryMappingResource::downloadFinished(const QByteArray& data) { void GeometryMappingResource::downloadFinished(const QByteArray& data) {
PROFILE_ASYNC_BEGIN(modelnetworking, "GeometryMappingResource::downloadFinished", _url.toString(), PROFILE_ASYNC_BEGIN(resource_parse_geometry, "GeometryMappingResource::downloadFinished", _url.toString(),
{ { "url", _url.toString() } }); { { "url", _url.toString() } });
auto mapping = FSTReader::readMapping(data); auto mapping = FSTReader::readMapping(data);
@ -120,7 +122,7 @@ void GeometryMappingResource::onGeometryMappingLoaded(bool success) {
disconnect(_connection); // FIXME Should not have to do this disconnect(_connection); // FIXME Should not have to do this
} }
PROFILE_ASYNC_END(modelnetworking, "GeometryMappingResource::downloadFinished", _url.toString()); PROFILE_ASYNC_END(resource_parse_geometry, "GeometryMappingResource::downloadFinished", _url.toString());
finishedLoading(success); finishedLoading(success);
} }
@ -145,7 +147,7 @@ private:
void GeometryReader::run() { void GeometryReader::run() {
DependencyManager::get<StatTracker>()->decrementStat("PendingProcessing"); DependencyManager::get<StatTracker>()->decrementStat("PendingProcessing");
CounterStat counter("Processing"); CounterStat counter("Processing");
PROFILE_RANGE_EX(modelnetworking, "GeometryReader::run", 0xFF00FF00, 0, { { "url", _url.toString() } }); PROFILE_RANGE_EX(resource_parse_geometry, "GeometryReader::run", 0xFF00FF00, 0, { { "url", _url.toString() } });
auto originalPriority = QThread::currentThread()->priority(); auto originalPriority = QThread::currentThread()->priority();
if (originalPriority == QThread::InheritPriority) { if (originalPriority == QThread::InheritPriority) {
originalPriority = QThread::NormalPriority; originalPriority = QThread::NormalPriority;

View file

@ -36,6 +36,8 @@
#include <Trace.h> #include <Trace.h>
#include <StatTracker.h> #include <StatTracker.h>
Q_LOGGING_CATEGORY(trace_resource_parse_image, "trace.resource.parse.image")
TextureCache::TextureCache() { TextureCache::TextureCache() {
setUnusedResourceCacheSize(0); setUnusedResourceCacheSize(0);
setObjectName("TextureCache"); setObjectName("TextureCache");
@ -349,7 +351,7 @@ void ImageReader::run() {
CounterStat counter("Processing"); CounterStat counter("Processing");
PROFILE_RANGE_EX(modelnetworking, __FUNCTION__, 0xffff0000, 0, { { "url", _url.toString() } }); PROFILE_RANGE_EX(resource_parse_image, __FUNCTION__, 0xffff0000, 0, { { "url", _url.toString() } });
auto originalPriority = QThread::currentThread()->priority(); auto originalPriority = QThread::currentThread()->priority();
if (originalPriority == QThread::InheritPriority) { if (originalPriority == QThread::InheritPriority) {
originalPriority = QThread::NormalPriority; originalPriority = QThread::NormalPriority;
@ -395,7 +397,7 @@ void ImageReader::run() {
auto url = _url.toString().toStdString(); auto url = _url.toString().toStdString();
PROFILE_RANGE_EX(modelnetworking, __FUNCTION__, 0xffffff00, 0); PROFILE_RANGE_EX(resource_parse_image, __FUNCTION__, 0xffffff00, 0);
texture.reset(resource.dynamicCast<NetworkTexture>()->getTextureLoader()(image, url)); texture.reset(resource.dynamicCast<NetworkTexture>()->getTextureLoader()(image, url));
} }

View file

@ -746,7 +746,7 @@ const CubeLayout CubeLayout::CUBEMAP_LAYOUTS[] = {
const int CubeLayout::NUM_CUBEMAP_LAYOUTS = sizeof(CubeLayout::CUBEMAP_LAYOUTS) / sizeof(CubeLayout); const int CubeLayout::NUM_CUBEMAP_LAYOUTS = sizeof(CubeLayout::CUBEMAP_LAYOUTS) / sizeof(CubeLayout);
gpu::Texture* TextureUsage::processCubeTextureColorFromImage(const QImage& srcImage, const std::string& srcImageName, bool isLinear, bool doCompress, bool generateMips, bool generateIrradiance) { gpu::Texture* TextureUsage::processCubeTextureColorFromImage(const QImage& srcImage, const std::string& srcImageName, bool isLinear, bool doCompress, bool generateMips, bool generateIrradiance) {
PROFILE_RANGE(modelLog, "processCubeTextureColorFromImage"); PROFILE_RANGE(resource_parse, "processCubeTextureColorFromImage");
gpu::Texture* theTexture = nullptr; gpu::Texture* theTexture = nullptr;
if ((srcImage.width() > 0) && (srcImage.height() > 0)) { if ((srcImage.width() > 0) && (srcImage.height() > 0)) {
@ -805,13 +805,13 @@ gpu::Texture* TextureUsage::processCubeTextureColorFromImage(const QImage& srcIm
} }
if (generateMips) { if (generateMips) {
PROFILE_RANGE(modelLog, "generateMips"); PROFILE_RANGE(resource_parse, "generateMips");
theTexture->autoGenerateMips(-1); theTexture->autoGenerateMips(-1);
} }
// Generate irradiance while we are at it // Generate irradiance while we are at it
if (generateIrradiance) { if (generateIrradiance) {
PROFILE_RANGE(modelLog, "generateIrradiance"); PROFILE_RANGE(resource_parse, "generateIrradiance");
theTexture->generateIrradiance(); theTexture->generateIrradiance();
} }
} }

View file

@ -650,12 +650,12 @@ void Resource::reinsert() {
void Resource::makeRequest() { void Resource::makeRequest() {
if (_request) { if (_request) {
PROFILE_ASYNC_END(resourceLog, "Resource:" + getType(), QString::number(_requestID)); PROFILE_ASYNC_END(resource, "Resource:" + getType(), QString::number(_requestID));
_request->disconnect(); _request->disconnect();
_request->deleteLater(); _request->deleteLater();
} }
PROFILE_ASYNC_BEGIN(resourceLog, "Resource:" + getType(), QString::number(_requestID), { { "url", _url.toString() }, { "activeURL", _activeUrl.toString() } }); PROFILE_ASYNC_BEGIN(resource, "Resource:" + getType(), QString::number(_requestID), { { "url", _url.toString() }, { "activeURL", _activeUrl.toString() } });
_request = ResourceManager::createResourceRequest(this, _activeUrl); _request = ResourceManager::createResourceRequest(this, _activeUrl);
@ -663,7 +663,7 @@ void Resource::makeRequest() {
qCDebug(networking).noquote() << "Failed to get request for" << _url.toDisplayString(); qCDebug(networking).noquote() << "Failed to get request for" << _url.toDisplayString();
ResourceCache::requestCompleted(_self); ResourceCache::requestCompleted(_self);
finishedLoading(false); finishedLoading(false);
PROFILE_ASYNC_END(resourceLog, "Resource:" + getType(), QString::number(_requestID)); PROFILE_ASYNC_END(resource, "Resource:" + getType(), QString::number(_requestID));
return; return;
} }
@ -688,7 +688,7 @@ void Resource::handleDownloadProgress(uint64_t bytesReceived, uint64_t bytesTota
void Resource::handleReplyFinished() { void Resource::handleReplyFinished() {
Q_ASSERT_X(_request, "Resource::handleReplyFinished", "Request should not be null while in handleReplyFinished"); Q_ASSERT_X(_request, "Resource::handleReplyFinished", "Request should not be null while in handleReplyFinished");
PROFILE_ASYNC_END(resourceLog, "Resource:" + getType(), QString::number(_requestID), { PROFILE_ASYNC_END(resource, "Resource:" + getType(), QString::number(_requestID), {
{ "from_cache", _request->loadedFromCache() }, { "from_cache", _request->loadedFromCache() },
{ "size_mb", _bytesTotal / 1000000.0 } { "size_mb", _bytesTotal / 1000000.0 }
}); });

View file

@ -86,7 +86,7 @@ SendQueue::SendQueue(Socket* socket, HifiSockAddr dest) :
_socket(socket), _socket(socket),
_destination(dest) _destination(dest)
{ {
PROFILE_ASYNC_BEGIN(networking, "SendQueue", _destination.toString()); PROFILE_ASYNC_BEGIN(network, "SendQueue", _destination.toString());
// setup psuedo-random number generation for all instances of SendQueue // setup psuedo-random number generation for all instances of SendQueue
static std::random_device rd; static std::random_device rd;
@ -106,7 +106,7 @@ SendQueue::SendQueue(Socket* socket, HifiSockAddr dest) :
} }
SendQueue::~SendQueue() { SendQueue::~SendQueue() {
PROFILE_ASYNC_END(networking, "SendQueue", _destination.toString()); PROFILE_ASYNC_END(network, "SendQueue", _destination.toString());
} }
void SendQueue::queuePacket(std::unique_ptr<Packet> packet) { void SendQueue::queuePacket(std::unique_ptr<Packet> packet) {
@ -227,7 +227,7 @@ void SendQueue::sendHandshake() {
if (!_hasReceivedHandshakeACK) { if (!_hasReceivedHandshakeACK) {
// we haven't received a handshake ACK from the client, send another now // we haven't received a handshake ACK from the client, send another now
auto handshakePacket = ControlPacket::create(ControlPacket::Handshake, sizeof(SequenceNumber)); auto handshakePacket = ControlPacket::create(ControlPacket::Handshake, sizeof(SequenceNumber));
PROFILE_ASYNC_BEGIN(networking, "SendQueue:Handshake", _destination.toString()); PROFILE_ASYNC_BEGIN(network, "SendQueue:Handshake", _destination.toString());
handshakePacket->writePrimitive(_initialSequenceNumber); handshakePacket->writePrimitive(_initialSequenceNumber);
_socket->writeBasePacket(*handshakePacket, _destination); _socket->writeBasePacket(*handshakePacket, _destination);
@ -244,7 +244,7 @@ void SendQueue::handshakeACK(SequenceNumber initialSequenceNumber) {
std::lock_guard<std::mutex> locker { _handshakeMutex }; std::lock_guard<std::mutex> locker { _handshakeMutex };
_hasReceivedHandshakeACK = true; _hasReceivedHandshakeACK = true;
} }
PROFILE_ASYNC_END(networking, "SendQueue:Handshake", _destination.toString()); PROFILE_ASYNC_END(network, "SendQueue:Handshake", _destination.toString());
// Notify on the handshake ACK condition // Notify on the handshake ACK condition
_handshakeACKCondition.notify_one(); _handshakeACKCondition.notify_one();

View file

@ -392,7 +392,6 @@ OctreeElementPointer OctreeElement::addChildAtIndex(int childIndex) {
_isDirty = true; _isDirty = true;
markWithChangedTime(); markWithChangedTime();
PROFILE_INSTANT(octree, "EntityAdd", "g");
} }
return childAt; return childAt;
} }

View file

@ -793,7 +793,7 @@ void RenderDeferred::configure(const Config& config) {
} }
void RenderDeferred::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, const Inputs& inputs) { void RenderDeferred::run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext, const Inputs& inputs) {
PROFILE_RANGE(renderlogging, "DeferredLighting"); PROFILE_RANGE(render, "DeferredLighting");
auto deferredTransform = inputs.get0(); auto deferredTransform = inputs.get0();
auto deferredFramebuffer = inputs.get1(); auto deferredFramebuffer = inputs.get1();

View file

@ -281,7 +281,7 @@ void Model::reset() {
} }
bool Model::updateGeometry() { bool Model::updateGeometry() {
PROFILE_RANGE(renderutils, __FUNCTION__); PROFILE_RANGE(render, __FUNCTION__);
PerformanceTimer perfTimer("Model::updateGeometry"); PerformanceTimer perfTimer("Model::updateGeometry");
bool needFullUpdate = false; bool needFullUpdate = false;
@ -476,7 +476,7 @@ bool Model::convexHullContains(glm::vec3 point) {
// entity-scripts to call. I think it would be best to do the picking once-per-frame (in cpu, or gpu if possible) // entity-scripts to call. I think it would be best to do the picking once-per-frame (in cpu, or gpu if possible)
// and then the calls use the most recent such result. // and then the calls use the most recent such result.
void Model::recalculateMeshBoxes(bool pickAgainstTriangles) { void Model::recalculateMeshBoxes(bool pickAgainstTriangles) {
PROFILE_RANGE(renderutils, __FUNCTION__); PROFILE_RANGE(render, __FUNCTION__);
bool calculatedMeshTrianglesNeeded = pickAgainstTriangles && !_calculatedMeshTrianglesValid; bool calculatedMeshTrianglesNeeded = pickAgainstTriangles && !_calculatedMeshTrianglesValid;
if (!_calculatedMeshBoxesValid || calculatedMeshTrianglesNeeded || (!_calculatedMeshPartBoxesValid && pickAgainstTriangles) ) { if (!_calculatedMeshBoxesValid || calculatedMeshTrianglesNeeded || (!_calculatedMeshPartBoxesValid && pickAgainstTriangles) ) {
@ -969,7 +969,7 @@ Blender::Blender(ModelPointer model, int blendNumber, const Geometry::WeakPointe
} }
void Blender::run() { void Blender::run() {
PROFILE_RANGE_EX(renderutils, __FUNCTION__, 0xFFFF0000, 0, { { "url", _model->getURL().toString() } }); PROFILE_RANGE_EX(simulation_animation, __FUNCTION__, 0xFFFF0000, 0, { { "url", _model->getURL().toString() } });
QVector<glm::vec3> vertices, normals; QVector<glm::vec3> vertices, normals;
if (_model) { if (_model) {
int offset = 0; int offset = 0;
@ -1090,7 +1090,7 @@ void Model::snapToRegistrationPoint() {
} }
void Model::simulate(float deltaTime, bool fullUpdate) { void Model::simulate(float deltaTime, bool fullUpdate) {
PROFILE_RANGE(renderutils, __FUNCTION__); PROFILE_RANGE(simulation, __FUNCTION__);
PerformanceTimer perfTimer("Model::simulate"); PerformanceTimer perfTimer("Model::simulate");
fullUpdate = updateGeometry() || fullUpdate || (_scaleToFit && !_scaledToFit) fullUpdate = updateGeometry() || fullUpdate || (_scaleToFit && !_scaledToFit)
|| (_snapModelToRegistrationPoint && !_snappedToRegistrationPoint); || (_snapModelToRegistrationPoint && !_snappedToRegistrationPoint);

View file

@ -78,13 +78,16 @@ void consolidateChangeQueue(PendingChangesQueue& queue, PendingChanges& singleBa
} }
void Scene::processPendingChangesQueue() { void Scene::processPendingChangesQueue() {
PROFILE_RANGE(renderlogging, __FUNCTION__); PROFILE_RANGE(render, __FUNCTION__);
_changeQueueMutex.lock();
PendingChanges consolidatedPendingChanges; PendingChanges consolidatedPendingChanges;
consolidateChangeQueue(_changeQueue, consolidatedPendingChanges);
_changeQueueMutex.unlock();
_itemsMutex.lock(); {
std::unique_lock<std::mutex> lock(_changeQueueMutex);
consolidateChangeQueue(_changeQueue, consolidatedPendingChanges);
}
{
std::unique_lock<std::mutex> lock(_itemsMutex);
// Here we should be able to check the value of last ItemID allocated // Here we should be able to check the value of last ItemID allocated
// and allocate new items accordingly // and allocate new items accordingly
ItemID maxID = _IDAllocator.load(); ItemID maxID = _IDAllocator.load();
@ -108,9 +111,7 @@ void Scene::processPendingChangesQueue() {
// Update the numItemsAtomic counter AFTER the pending changes went through // Update the numItemsAtomic counter AFTER the pending changes went through
_numAllocatedItems.exchange(maxID); _numAllocatedItems.exchange(maxID);
}
// ready to go back to rendering activities
_itemsMutex.unlock();
} }
void Scene::resetItems(const ItemIDs& ids, Payloads& payloads) { void Scene::resetItems(const ItemIDs& ids, Payloads& payloads) {

View file

@ -572,7 +572,7 @@ public:
void run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext) { void run(const SceneContextPointer& sceneContext, const RenderContextPointer& renderContext) {
PerformanceTimer perfTimer(_name.c_str()); PerformanceTimer perfTimer(_name.c_str());
PROFILE_RANGE(renderlogging, _name.c_str()); PROFILE_RANGE(render, _name.c_str());
auto start = usecTimestampNow(); auto start = usecTimestampNow();
_concept->run(sceneContext, renderContext); _concept->run(sceneContext, renderContext);

View file

@ -8,6 +8,21 @@
#include "Profile.h" #include "Profile.h"
Q_LOGGING_CATEGORY(trace_app, "trace.app")
Q_LOGGING_CATEGORY(trace_network, "trace.network")
Q_LOGGING_CATEGORY(trace_parse, "trace.parse")
Q_LOGGING_CATEGORY(trace_render, "trace.render")
Q_LOGGING_CATEGORY(trace_render_gpu, "trace.render.gpu")
Q_LOGGING_CATEGORY(trace_resource, "trace.resource")
Q_LOGGING_CATEGORY(trace_resource_network, "trace.resource.network")
Q_LOGGING_CATEGORY(trace_resource_parse, "trace.resource.parse")
Q_LOGGING_CATEGORY(trace_simulation, "trace.simulation")
Q_LOGGING_CATEGORY(trace_simulation_animation, "trace.simulation.animation")
Q_LOGGING_CATEGORY(trace_simulation_physics, "trace.simulation.physics")
void foo() {
randFloat();
}
#if defined(NSIGHT_FOUND) #if defined(NSIGHT_FOUND)
#include "nvToolsExt.h" #include "nvToolsExt.h"

View file

@ -11,6 +11,18 @@
#define HIFI_PROFILE_ #define HIFI_PROFILE_
#include "Trace.h" #include "Trace.h"
#include "SharedUtil.h"
Q_DECLARE_LOGGING_CATEGORY(trace_app)
Q_DECLARE_LOGGING_CATEGORY(trace_network)
Q_DECLARE_LOGGING_CATEGORY(trace_render)
Q_DECLARE_LOGGING_CATEGORY(trace_render_gpu)
Q_DECLARE_LOGGING_CATEGORY(trace_resource)
Q_DECLARE_LOGGING_CATEGORY(trace_resource_parse)
Q_DECLARE_LOGGING_CATEGORY(trace_resource_network)
Q_DECLARE_LOGGING_CATEGORY(trace_simulation)
Q_DECLARE_LOGGING_CATEGORY(trace_simulation_animation)
Q_DECLARE_LOGGING_CATEGORY(trace_simulation_physics)
class Duration { class Duration {
public: public:
@ -51,13 +63,18 @@ inline void counter(const QLoggingCategory& category, const QString& name, const
} }
} }
#define PROFILE_RANGE(category, name) Duration profileRangeThis(category(), name); #define PROFILE_RANGE(category, name) Duration profileRangeThis(trace_##category(), name);
#define PROFILE_RANGE_EX(category, name, argbColor, payload, ...) Duration profileRangeThis(category(), name, argbColor, (uint64_t)payload, ##__VA_ARGS__); #define PROFILE_RANGE_EX(category, name, argbColor, payload, ...) Duration profileRangeThis(trace_##category(), name, argbColor, (uint64_t)payload, ##__VA_ARGS__);
#define PROFILE_RANGE_BEGIN(category, rangeId, name, argbColor) rangeId = Duration::beginRange(category(), name, argbColor) #define PROFILE_RANGE_BEGIN(category, rangeId, name, argbColor) rangeId = Duration::beginRange(trace_##category(), name, argbColor)
#define PROFILE_RANGE_END(category, rangeId) Duration::endRange(category(), rangeId) #define PROFILE_RANGE_END(category, rangeId) Duration::endRange(trace_##category(), rangeId)
#define PROFILE_ASYNC_BEGIN(category, name, id, ...) asyncBegin(category(), name, id, ##__VA_ARGS__); #define PROFILE_ASYNC_BEGIN(category, name, id, ...) asyncBegin(trace_##category(), name, id, ##__VA_ARGS__);
#define PROFILE_ASYNC_END(category, name, id, ...) asyncEnd(category(), name, id, ##__VA_ARGS__); #define PROFILE_ASYNC_END(category, name, id, ...) asyncEnd(trace_##category(), name, id, ##__VA_ARGS__);
#define PROFILE_COUNTER(category, name, ...) counter(category(), name, ##__VA_ARGS__); #define PROFILE_COUNTER(category, name, ...) counter(trace_##category(), name, ##__VA_ARGS__);
#define PROFILE_INSTANT(category, name, ...) instant(category(), name, ##__VA_ARGS__); #define PROFILE_INSTANT(category, name, ...) instant(trace_##category(), name, ##__VA_ARGS__);
#define SAMPLE_PROFILE_RANGE(chance, category, name, ...) if (randFloat() <= chance) { PROFILE_RANGE(category, name); }
#define SAMPLE_PROFILE_RANGE_EX(chance, category, name, ...) if (randFloat() <= chance) { PROFILE_RANGE_EX(category, name, argbColor, payload, ##__VA_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__); }
#endif #endif

View file

@ -13,6 +13,9 @@
#include <QtCore/QDebug> #include <QtCore/QDebug>
#include <QtCore/QCoreApplication> #include <QtCore/QCoreApplication>
#include <QtCore/QThread> #include <QtCore/QThread>
#include <QtCore/QFileInfo>
#include <QtCore/QDir>
#include <QtCore/QStandardPaths>
#include <QtCore/QFile> #include <QtCore/QFile>
#include <QtCore/QFileInfo> #include <QtCore/QFileInfo>
@ -100,7 +103,24 @@ void TraceEvent::writeJson(QTextStream& out) const {
#endif #endif
} }
void Tracer::serialize(const QString& path) { void Tracer::serialize(const QString& originalPath) {
QString path = originalPath;
// If the filename is relative, turn it into an absolute path relative to the document directory.
QFileInfo originalFileInfo(path);
if (originalFileInfo.isRelative()) {
QString docsLocation = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
path = docsLocation + "/" + path;
QFileInfo info(path);
if (!info.absoluteDir().exists()) {
QString originalRelativePath = originalFileInfo.path();
QDir(docsLocation).mkpath(originalRelativePath);
}
}
std::list<TraceEvent> currentEvents; std::list<TraceEvent> currentEvents;
{ {
std::lock_guard<std::mutex> guard(_eventsMutex); std::lock_guard<std::mutex> guard(_eventsMutex);

View file

@ -21,8 +21,6 @@
#include "DependencyManager.h" #include "DependencyManager.h"
#define TRACE_ENABLED
namespace tracing { namespace tracing {
bool enabled(); bool enabled();

View file

@ -110,7 +110,7 @@ void OculusDisplayPlugin::hmdPresent() {
return; return;
} }
PROFILE_RANGE_EX(displayplugins, __FUNCTION__, 0xff00ff00, (uint64_t)_currentFrame->frameIndex) PROFILE_RANGE_EX(render, __FUNCTION__, 0xff00ff00, (uint64_t)_currentFrame->frameIndex)
int curIndex; int curIndex;
ovr_GetTextureSwapChainCurrentIndex(_session, _textureSwapChain, &curIndex); ovr_GetTextureSwapChainCurrentIndex(_session, _textureSwapChain, &curIndex);

View file

@ -529,7 +529,7 @@ static bool isBadPose(vr::HmdMatrix34_t* mat) {
} }
bool OpenVrDisplayPlugin::beginFrameRender(uint32_t frameIndex) { bool OpenVrDisplayPlugin::beginFrameRender(uint32_t frameIndex) {
PROFILE_RANGE_EX(displayplugins, __FUNCTION__, 0xff7fff00, frameIndex) PROFILE_RANGE_EX(render, __FUNCTION__, 0xff7fff00, frameIndex)
handleOpenVrEvents(); handleOpenVrEvents();
if (openVrQuitRequested()) { if (openVrQuitRequested()) {
QMetaObject::invokeMethod(qApp, "quit"); QMetaObject::invokeMethod(qApp, "quit");
@ -633,7 +633,7 @@ void OpenVrDisplayPlugin::compositeLayers() {
} }
void OpenVrDisplayPlugin::hmdPresent() { void OpenVrDisplayPlugin::hmdPresent() {
PROFILE_RANGE_EX(displayplugins, __FUNCTION__, 0xff00ff00, (uint64_t)_currentFrame->frameIndex) PROFILE_RANGE_EX(render, __FUNCTION__, 0xff00ff00, (uint64_t)_currentFrame->frameIndex)
if (_threadedSubmit) { if (_threadedSubmit) {
_submitThread->waitForPresent(); _submitThread->waitForPresent();
@ -654,7 +654,7 @@ void OpenVrDisplayPlugin::hmdPresent() {
} }
void OpenVrDisplayPlugin::postPreview() { void OpenVrDisplayPlugin::postPreview() {
PROFILE_RANGE_EX(displayplugins, __FUNCTION__, 0xff00ff00, (uint64_t)_currentFrame->frameIndex) PROFILE_RANGE_EX(render, __FUNCTION__, 0xff00ff00, (uint64_t)_currentFrame->frameIndex)
PoseData nextRender, nextSim; PoseData nextRender, nextSim;
nextRender.frameIndex = presentCount(); nextRender.frameIndex = presentCount();

View file

@ -900,7 +900,7 @@ private:
gpu::doInBatch(gpuContext, [&](gpu::Batch& batch) { gpu::doInBatch(gpuContext, [&](gpu::Batch& batch) {
batch.resetStages(); batch.resetStages();
}); });
PROFILE_RANGE(renderperflogging, __FUNCTION__); PROFILE_RANGE(render, __FUNCTION__);
PerformanceTimer perfTimer("draw"); PerformanceTimer perfTimer("draw");
// The pending changes collecting the changes here // The pending changes collecting the changes here
render::PendingChanges pendingChanges; render::PendingChanges pendingChanges;

View file

@ -9,33 +9,35 @@
#include "TraceTests.h" #include "TraceTests.h"
#include <QtTest/QtTest> #include <QtTest/QtTest>
#include <Trace.h> #include <QtGui/QDesktopServices>
#include <Profile.h>
#include <SharedUtil.h>
#include <NumericalConstants.h> #include <NumericalConstants.h>
#include <../QTestExtensions.h> #include <../QTestExtensions.h>
QTEST_MAIN(TraceTests) QTEST_MAIN(TraceTests)
Q_LOGGING_CATEGORY(tracertestlogging, "hifi.tracer.test") Q_LOGGING_CATEGORY(trace_test, "trace.test")
const QString OUTPUT_FILE = "traces/testTrace.json.gz";
void TraceTests::testTraceSerialization() { void TraceTests::testTraceSerialization() {
auto tracer = DependencyManager::set<tracing::Tracer>(); auto tracer = DependencyManager::set<tracing::Tracer>();
tracer->startTracing(); tracer->startTracing();
tracer->traceEvent(tracertestlogging(), "TestEvent", tracing::DurationBegin);
{ {
auto start = usecTimestampNow(); auto start = usecTimestampNow();
PROFILE_RANGE(test, "TestEvent")
for (size_t i = 0; i < 10000; ++i) { for (size_t i = 0; i < 10000; ++i) {
tracer->traceEvent(tracertestlogging(), "TestCounter", tracing::Counter, "", { { "i", i } }); SAMPLE_PROFILE_COUNTER(0.1f, test, "TestCounter", { { "i", i } })
} }
auto duration = usecTimestampNow() - start; auto duration = usecTimestampNow() - start;
duration /= USECS_PER_MSEC; duration /= USECS_PER_MSEC;
qDebug() << "Recording took " << duration << "ms"; qDebug() << "Recording took " << duration << "ms";
} }
tracer->traceEvent(tracertestlogging(), "TestEvent", tracing::DurationEnd);
tracer->stopTracing(); tracer->stopTracing();
{ {
auto start = usecTimestampNow(); auto start = usecTimestampNow();
tracer->serialize("testTrace.json.gz"); tracer->serialize(OUTPUT_FILE);
auto duration = usecTimestampNow() - start; auto duration = usecTimestampNow() - start;
duration /= USECS_PER_MSEC; duration /= USECS_PER_MSEC;
qDebug() << "Serialization took " << duration << "ms"; qDebug() << "Serialization took " << duration << "ms";