Improved stat accumulation and context names

This commit is contained in:
Andrew Meadows 2014-07-09 11:53:53 -07:00
parent d214998d1a
commit d26585728b
8 changed files with 163 additions and 126 deletions

View file

@ -682,7 +682,7 @@ void Application::paintGL() {
} }
{ {
PerformanceTimer perfTimer("paintGL/renderOverlay"); PerformanceTimer perfTimer("renderOverlay");
//If alpha is 1, we can render directly to the screen. //If alpha is 1, we can render directly to the screen.
if (_applicationOverlay.getAlpha() == 1.0f) { if (_applicationOverlay.getAlpha() == 1.0f) {
_applicationOverlay.renderOverlay(); _applicationOverlay.renderOverlay();
@ -1355,18 +1355,18 @@ void Application::idle() {
if (timeSinceLastUpdate > IDLE_SIMULATE_MSECS) { if (timeSinceLastUpdate > IDLE_SIMULATE_MSECS) {
_lastTimeUpdated.start(); _lastTimeUpdated.start();
{ {
PerformanceTimer perfTimer("idle/update"); PerformanceTimer perfTimer("update");
PerformanceWarning warn(showWarnings, "Application::idle()... update()"); PerformanceWarning warn(showWarnings, "Application::idle()... update()");
const float BIGGEST_DELTA_TIME_SECS = 0.25f; const float BIGGEST_DELTA_TIME_SECS = 0.25f;
update(glm::clamp((float)timeSinceLastUpdate / 1000.f, 0.f, BIGGEST_DELTA_TIME_SECS)); update(glm::clamp((float)timeSinceLastUpdate / 1000.f, 0.f, BIGGEST_DELTA_TIME_SECS));
} }
{ {
PerformanceTimer perfTimer("idle/updateGL"); PerformanceTimer perfTimer("updateGL");
PerformanceWarning warn(showWarnings, "Application::idle()... updateGL()"); PerformanceWarning warn(showWarnings, "Application::idle()... updateGL()");
_glWidget->updateGL(); _glWidget->updateGL();
} }
{ {
PerformanceTimer perfTimer("idle/rest"); PerformanceTimer perfTimer("rest");
PerformanceWarning warn(showWarnings, "Application::idle()... rest of it"); PerformanceWarning warn(showWarnings, "Application::idle()... rest of it");
_idleLoopStdev.addValue(timeSinceLastUpdate); _idleLoopStdev.addValue(timeSinceLastUpdate);
@ -1378,7 +1378,7 @@ void Application::idle() {
} }
if (Menu::getInstance()->isOptionChecked(MenuOption::BuckyBalls)) { if (Menu::getInstance()->isOptionChecked(MenuOption::BuckyBalls)) {
PerformanceTimer perfTimer("idle/rest/_buckyBalls"); PerformanceTimer perfTimer("buckyBalls");
_buckyBalls.simulate(timeSinceLastUpdate / 1000.f, Application::getInstance()->getAvatar()->getHandData()); _buckyBalls.simulate(timeSinceLastUpdate / 1000.f, Application::getInstance()->getAvatar()->getHandData());
} }
@ -1792,7 +1792,7 @@ bool Application::isLookingAtMyAvatar(Avatar* avatar) {
} }
void Application::updateLOD() { void Application::updateLOD() {
PerformanceTimer perfTimer("idle/update/updateLOD"); PerformanceTimer perfTimer("LOD");
// adjust it unless we were asked to disable this feature, or if we're currently in throttleRendering mode // adjust it unless we were asked to disable this feature, or if we're currently in throttleRendering mode
if (!Menu::getInstance()->isOptionChecked(MenuOption::DisableAutoAdjustLOD) && !isThrottleRendering()) { if (!Menu::getInstance()->isOptionChecked(MenuOption::DisableAutoAdjustLOD) && !isThrottleRendering()) {
Menu::getInstance()->autoAdjustLOD(_fps); Menu::getInstance()->autoAdjustLOD(_fps);
@ -1802,7 +1802,7 @@ void Application::updateLOD() {
} }
void Application::updateMouseRay() { void Application::updateMouseRay() {
PerformanceTimer perfTimer("idle/update/updateMouseRay"); PerformanceTimer perfTimer("mouseRay");
bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
PerformanceWarning warn(showWarnings, "Application::updateMouseRay()"); PerformanceWarning warn(showWarnings, "Application::updateMouseRay()");
@ -1835,7 +1835,7 @@ void Application::updateMouseRay() {
} }
void Application::updateFaceshift() { void Application::updateFaceshift() {
PerformanceTimer perfTimer("idle/update/updateFaceshift"); PerformanceTimer perfTimer("faceshift");
bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
PerformanceWarning warn(showWarnings, "Application::updateFaceshift()"); PerformanceWarning warn(showWarnings, "Application::updateFaceshift()");
@ -1850,7 +1850,7 @@ void Application::updateFaceshift() {
} }
void Application::updateVisage() { void Application::updateVisage() {
PerformanceTimer perfTimer("idle/update/updateVisage"); PerformanceTimer perfTimer("visage");
bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
PerformanceWarning warn(showWarnings, "Application::updateVisage()"); PerformanceWarning warn(showWarnings, "Application::updateVisage()");
@ -1860,11 +1860,11 @@ void Application::updateVisage() {
} }
void Application::updateMyAvatarLookAtPosition() { void Application::updateMyAvatarLookAtPosition() {
PerformanceTimer perfTimer("idle/update/updateMyAvatarLookAtPosition"); PerformanceTimer perfTimer("lookAt");
bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
PerformanceWarning warn(showWarnings, "Application::updateMyAvatarLookAtPosition()"); PerformanceWarning warn(showWarnings, "Application::updateMyAvatarLookAtPosition()");
_myAvatar->updateLookAtTargetAvatar();
FaceTracker* tracker = getActiveFaceTracker(); FaceTracker* tracker = getActiveFaceTracker();
bool isLookingAtSomeone = false; bool isLookingAtSomeone = false;
@ -1927,7 +1927,7 @@ void Application::updateMyAvatarLookAtPosition() {
} }
void Application::updateThreads(float deltaTime) { void Application::updateThreads(float deltaTime) {
PerformanceTimer perfTimer("idle/update/updateThreads"); PerformanceTimer perfTimer("updateThreads");
bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
PerformanceWarning warn(showWarnings, "Application::updateThreads()"); PerformanceWarning warn(showWarnings, "Application::updateThreads()");
@ -1942,7 +1942,7 @@ void Application::updateThreads(float deltaTime) {
} }
void Application::updateMetavoxels(float deltaTime) { void Application::updateMetavoxels(float deltaTime) {
PerformanceTimer perfTimer("idle/update/updateMetavoxels"); PerformanceTimer perfTimer("updateMetavoxels");
bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
PerformanceWarning warn(showWarnings, "Application::updateMetavoxels()"); PerformanceWarning warn(showWarnings, "Application::updateMetavoxels()");
@ -1972,7 +1972,7 @@ void Application::cameraMenuChanged() {
} }
void Application::updateCamera(float deltaTime) { void Application::updateCamera(float deltaTime) {
PerformanceTimer perfTimer("idle/update/updateCamera"); PerformanceTimer perfTimer("updateCamera");
bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
PerformanceWarning warn(showWarnings, "Application::updateCamera()"); PerformanceWarning warn(showWarnings, "Application::updateCamera()");
@ -1990,7 +1990,7 @@ void Application::updateCamera(float deltaTime) {
} }
void Application::updateDialogs(float deltaTime) { void Application::updateDialogs(float deltaTime) {
PerformanceTimer perfTimer("idle/update/updateDialogs"); PerformanceTimer perfTimer("updateDialogs");
bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
PerformanceWarning warn(showWarnings, "Application::updateDialogs()"); PerformanceWarning warn(showWarnings, "Application::updateDialogs()");
@ -2007,7 +2007,7 @@ void Application::updateDialogs(float deltaTime) {
} }
void Application::updateCursor(float deltaTime) { void Application::updateCursor(float deltaTime) {
PerformanceTimer perfTimer("idle/update/updateCursor"); PerformanceTimer perfTimer("updateCursor");
bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
PerformanceWarning warn(showWarnings, "Application::updateCursor()"); PerformanceWarning warn(showWarnings, "Application::updateCursor()");
@ -2032,8 +2032,6 @@ void Application::updateCursor(float deltaTime) {
} }
void Application::update(float deltaTime) { void Application::update(float deltaTime) {
//PerformanceTimer perfTimer("idle/update"); // NOTE: we track this above in Application::idle()
bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
PerformanceWarning warn(showWarnings, "Application::update()"); PerformanceWarning warn(showWarnings, "Application::update()");
@ -2043,72 +2041,61 @@ void Application::update(float deltaTime) {
updateVisage(); updateVisage();
{ {
PerformanceTimer perfTimer("idle/update/updateLookAtTargetAvatar"); PerformanceTimer perfTimer("myAvatar");
_myAvatar->updateLookAtTargetAvatar(); updateMyAvatarLookAtPosition();
} {
updateMyAvatarLookAtPosition(); PerformanceTimer perfTimer("devices");
{ _sixenseManager.update(deltaTime);
PerformanceTimer perfTimer("idle/update/sixense,joystick,prioVR"); _joystickManager.update();
_sixenseManager.update(deltaTime); _prioVR.update(deltaTime);
_joystickManager.update(); }
_prioVR.update(deltaTime);
}
{
PerformanceTimer perfTimer("idle/update/updateMyAvatar");
updateMyAvatar(deltaTime); // Sample hardware, update view frustum if needed, and send avatar data to mixer/nodes updateMyAvatar(deltaTime); // Sample hardware, update view frustum if needed, and send avatar data to mixer/nodes
} }
updateThreads(deltaTime); // If running non-threaded, then give the threads some time to process... updateThreads(deltaTime); // If running non-threaded, then give the threads some time to process...
{ _avatarManager.updateOtherAvatars(deltaTime); //loop through all the other avatars and simulate them...
PerformanceTimer perfTimer("idle/update/_avatarManager");
_avatarManager.updateOtherAvatars(deltaTime); //loop through all the other avatars and simulate them...
}
updateMetavoxels(deltaTime); // update metavoxels updateMetavoxels(deltaTime); // update metavoxels
updateCamera(deltaTime); // handle various camera tweaks like off axis projection updateCamera(deltaTime); // handle various camera tweaks like off axis projection
updateDialogs(deltaTime); // update various stats dialogs if present updateDialogs(deltaTime); // update various stats dialogs if present
updateCursor(deltaTime); // Handle cursor updates updateCursor(deltaTime); // Handle cursor updates
{ {
PerformanceTimer perfTimer("idle/update/_particles"); PerformanceTimer perfTimer("particles");
_particles.update(); // update the particles... _particles.update(); // update the particles...
} {
{ PerformanceTimer perfTimer("collisions");
PerformanceTimer perfTimer("idle/update/_particleCollisionSystem"); _particleCollisionSystem.update(); // collide the particles...
_particleCollisionSystem.update(); // collide the particles... }
} }
{ {
PerformanceTimer perfTimer("idle/update/_models"); PerformanceTimer perfTimer("models");
_models.update(); // update the models... _models.update(); // update the models...
} }
{ {
PerformanceTimer perfTimer("idle/update/_overlays"); PerformanceTimer perfTimer("overlays");
_overlays.update(deltaTime); _overlays.update(deltaTime);
} }
{ {
PerformanceTimer perfTimer("idle/update/emit simulating"); PerformanceTimer perfTimer("emitSimulating");
// let external parties know we're updating // let external parties know we're updating
emit simulating(deltaTime); emit simulating(deltaTime);
} }
} }
void Application::updateMyAvatar(float deltaTime) { void Application::updateMyAvatar(float deltaTime) {
PerformanceTimer perfTimer("updateMyAvatar");
bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
PerformanceWarning warn(showWarnings, "Application::updateMyAvatar()"); PerformanceWarning warn(showWarnings, "Application::updateMyAvatar()");
{ _myAvatar->update(deltaTime);
PerformanceTimer perfTimer("updateMyAvatar/_myAvatar->update()");
_myAvatar->update(deltaTime);
}
{ {
// send head/hand data to the avatar mixer and voxel server // send head/hand data to the avatar mixer and voxel server
PerformanceTimer perfTimer("updateMyAvatar/sendToAvatarMixer"); PerformanceTimer perfTimer("send");
QByteArray packet = byteArrayWithPopulatedHeader(PacketTypeAvatarData); QByteArray packet = byteArrayWithPopulatedHeader(PacketTypeAvatarData);
packet.append(_myAvatar->toByteArray()); packet.append(_myAvatar->toByteArray());
controlledBroadcastToNodes(packet, NodeSet() << NodeType::AvatarMixer); controlledBroadcastToNodes(packet, NodeSet() << NodeType::AvatarMixer);
@ -2121,13 +2108,13 @@ void Application::updateMyAvatar(float deltaTime) {
// actually need to calculate the view frustum planes to send these details // actually need to calculate the view frustum planes to send these details
// to the server. // to the server.
{ {
PerformanceTimer perfTimer("updateMyAvatar/loadViewFrustum"); PerformanceTimer perfTimer("loadViewFrustum");
loadViewFrustum(_myCamera, _viewFrustum); loadViewFrustum(_myCamera, _viewFrustum);
} }
// Update my voxel servers with my current voxel query... // Update my voxel servers with my current voxel query...
{ {
PerformanceTimer perfTimer("updateMyAvatar/queryOctree"); PerformanceTimer perfTimer("queryOctree");
quint64 now = usecTimestampNow(); quint64 now = usecTimestampNow();
quint64 sinceLastQuery = now - _lastQueriedTime; quint64 sinceLastQuery = now - _lastQueriedTime;
const quint64 TOO_LONG_SINCE_LAST_QUERY = 3 * USECS_PER_SECOND; const quint64 TOO_LONG_SINCE_LAST_QUERY = 3 * USECS_PER_SECOND;
@ -2460,7 +2447,7 @@ glm::vec3 Application::getSunDirection() {
} }
void Application::updateShadowMap() { void Application::updateShadowMap() {
PerformanceTimer perfTimer("paintGL/updateShadowMap"); PerformanceTimer perfTimer("shadowMap");
QOpenGLFramebufferObject* fbo = _textureCache.getShadowFramebufferObject(); QOpenGLFramebufferObject* fbo = _textureCache.getShadowFramebufferObject();
fbo->bind(); fbo->bind();
glEnable(GL_DEPTH_TEST); glEnable(GL_DEPTH_TEST);
@ -2622,7 +2609,7 @@ QImage Application::renderAvatarBillboard() {
} }
void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) {
PerformanceTimer perfTimer("paintGL/displaySide"); PerformanceTimer perfTimer("display");
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), "Application::displaySide()"); PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), "Application::displaySide()");
// transform by eye offset // transform by eye offset
@ -2656,7 +2643,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) {
// Setup 3D lights (after the camera transform, so that they are positioned in world space) // Setup 3D lights (after the camera transform, so that they are positioned in world space)
{ {
PerformanceTimer perfTimer("paintGL/displaySide/setupWorldLight"); PerformanceTimer perfTimer("lights");
setupWorldLight(); setupWorldLight();
} }
@ -2675,7 +2662,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) {
} }
if (!selfAvatarOnly && Menu::getInstance()->isOptionChecked(MenuOption::Stars)) { if (!selfAvatarOnly && Menu::getInstance()->isOptionChecked(MenuOption::Stars)) {
PerformanceTimer perfTimer("paintGL/displaySide/stars"); PerformanceTimer perfTimer("stars");
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
"Application::displaySide() ... stars..."); "Application::displaySide() ... stars...");
if (!_stars.isStarsLoaded()) { if (!_stars.isStarsLoaded()) {
@ -2704,7 +2691,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) {
// draw the sky dome // draw the sky dome
if (!selfAvatarOnly && Menu::getInstance()->isOptionChecked(MenuOption::Atmosphere)) { if (!selfAvatarOnly && Menu::getInstance()->isOptionChecked(MenuOption::Atmosphere)) {
PerformanceTimer perfTimer("paintGL/displaySide/atmosphere"); PerformanceTimer perfTimer("atmosphere");
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
"Application::displaySide() ... atmosphere..."); "Application::displaySide() ... atmosphere...");
_environment.renderAtmospheres(whichCamera); _environment.renderAtmospheres(whichCamera);
@ -2725,13 +2712,13 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) {
// draw the audio reflector overlay // draw the audio reflector overlay
{ {
PerformanceTimer perfTimer("paintGL/displaySide/audioReflector"); PerformanceTimer perfTimer("audio");
_audioReflector.render(); _audioReflector.render();
} }
// Draw voxels // Draw voxels
if (Menu::getInstance()->isOptionChecked(MenuOption::Voxels)) { if (Menu::getInstance()->isOptionChecked(MenuOption::Voxels)) {
PerformanceTimer perfTimer("paintGL/displaySide/voxels"); PerformanceTimer perfTimer("voxels");
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
"Application::displaySide() ... voxels..."); "Application::displaySide() ... voxels...");
_voxels.render(); _voxels.render();
@ -2739,14 +2726,14 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) {
// also, metavoxels // also, metavoxels
if (Menu::getInstance()->isOptionChecked(MenuOption::Metavoxels)) { if (Menu::getInstance()->isOptionChecked(MenuOption::Metavoxels)) {
PerformanceTimer perfTimer("paintGL/displaySide/metavoxels"); PerformanceTimer perfTimer("metavoxels");
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
"Application::displaySide() ... metavoxels..."); "Application::displaySide() ... metavoxels...");
_metavoxels.render(); _metavoxels.render();
} }
if (Menu::getInstance()->isOptionChecked(MenuOption::BuckyBalls)) { if (Menu::getInstance()->isOptionChecked(MenuOption::BuckyBalls)) {
PerformanceTimer perfTimer("paintGL/displaySide/buckyBalls"); PerformanceTimer perfTimer("buckyBalls");
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
"Application::displaySide() ... bucky balls..."); "Application::displaySide() ... bucky balls...");
_buckyBalls.render(); _buckyBalls.render();
@ -2754,7 +2741,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) {
// render particles... // render particles...
if (Menu::getInstance()->isOptionChecked(MenuOption::Particles)) { if (Menu::getInstance()->isOptionChecked(MenuOption::Particles)) {
PerformanceTimer perfTimer("paintGL/displaySide/particles"); PerformanceTimer perfTimer("particles");
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
"Application::displaySide() ... particles..."); "Application::displaySide() ... particles...");
_particles.render(); _particles.render();
@ -2762,7 +2749,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) {
// render models... // render models...
if (Menu::getInstance()->isOptionChecked(MenuOption::Models)) { if (Menu::getInstance()->isOptionChecked(MenuOption::Models)) {
PerformanceTimer perfTimer("paintGL/displaySide/models"); PerformanceTimer perfTimer("models");
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
"Application::displaySide() ... models..."); "Application::displaySide() ... models...");
_models.render(); _models.render();
@ -2770,7 +2757,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) {
// render the ambient occlusion effect if enabled // render the ambient occlusion effect if enabled
if (Menu::getInstance()->isOptionChecked(MenuOption::AmbientOcclusion)) { if (Menu::getInstance()->isOptionChecked(MenuOption::AmbientOcclusion)) {
PerformanceTimer perfTimer("paintGL/displaySide/AmbientOcclusion"); PerformanceTimer perfTimer("ambientOcclusion");
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
"Application::displaySide() ... AmbientOcclusion..."); "Application::displaySide() ... AmbientOcclusion...");
_ambientOcclusionEffect.render(); _ambientOcclusionEffect.render();
@ -2785,20 +2772,20 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) {
bool mirrorMode = (whichCamera.getInterpolatedMode() == CAMERA_MODE_MIRROR); bool mirrorMode = (whichCamera.getInterpolatedMode() == CAMERA_MODE_MIRROR);
{ {
PerformanceTimer perfTimer("paintGL/displaySide/renderAvatars"); PerformanceTimer perfTimer("avatars");
_avatarManager.renderAvatars(mirrorMode ? Avatar::MIRROR_RENDER_MODE : Avatar::NORMAL_RENDER_MODE, selfAvatarOnly); _avatarManager.renderAvatars(mirrorMode ? Avatar::MIRROR_RENDER_MODE : Avatar::NORMAL_RENDER_MODE, selfAvatarOnly);
} }
if (!selfAvatarOnly) { if (!selfAvatarOnly) {
// Render the world box // Render the world box
if (whichCamera.getMode() != CAMERA_MODE_MIRROR && Menu::getInstance()->isOptionChecked(MenuOption::Stats)) { if (whichCamera.getMode() != CAMERA_MODE_MIRROR && Menu::getInstance()->isOptionChecked(MenuOption::Stats)) {
PerformanceTimer perfTimer("paintGL/displaySide/renderWorldBox"); PerformanceTimer perfTimer("worldBox");
renderWorldBox(); renderWorldBox();
} }
// view frustum for debugging // view frustum for debugging
if (Menu::getInstance()->isOptionChecked(MenuOption::DisplayFrustum) && whichCamera.getMode() != CAMERA_MODE_MIRROR) { if (Menu::getInstance()->isOptionChecked(MenuOption::DisplayFrustum) && whichCamera.getMode() != CAMERA_MODE_MIRROR) {
PerformanceTimer perfTimer("paintGL/displaySide/ViewFrustum"); PerformanceTimer perfTimer("viewFrustum");
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
"Application::displaySide() ... renderViewFrustum..."); "Application::displaySide() ... renderViewFrustum...");
renderViewFrustum(_viewFrustum); renderViewFrustum(_viewFrustum);
@ -2806,7 +2793,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) {
// render voxel fades if they exist // render voxel fades if they exist
if (_voxelFades.size() > 0) { if (_voxelFades.size() > 0) {
PerformanceTimer perfTimer("paintGL/displaySide/voxel fades"); PerformanceTimer perfTimer("voxelFades");
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
"Application::displaySide() ... voxel fades..."); "Application::displaySide() ... voxel fades...");
_voxelFadesLock.lockForWrite(); _voxelFadesLock.lockForWrite();
@ -2823,13 +2810,13 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) {
// give external parties a change to hook in // give external parties a change to hook in
{ {
PerformanceTimer perfTimer("paintGL/displaySide/inWorldInterface"); PerformanceTimer perfTimer("inWorldInterface");
emit renderingInWorldInterface(); emit renderingInWorldInterface();
} }
// render JS/scriptable overlays // render JS/scriptable overlays
{ {
PerformanceTimer perfTimer("paintGL/displaySide/3dOverlays"); PerformanceTimer perfTimer("3dOverlays");
_overlays.render3D(); _overlays.render3D();
} }
} }

View file

@ -15,12 +15,12 @@
#include <glm/gtx/quaternion.hpp> #include <glm/gtx/quaternion.hpp>
#include <glm/gtx/vector_angle.hpp> #include <glm/gtx/vector_angle.hpp>
#include <GeometryUtil.h>
#include <NodeList.h> #include <NodeList.h>
#include <PacketHeaders.h> #include <PacketHeaders.h>
#include <PerfStat.h>
#include <SharedUtil.h> #include <SharedUtil.h>
#include <GeometryUtil.h>
#include "Application.h" #include "Application.h"
#include "Avatar.h" #include "Avatar.h"
#include "Hand.h" #include "Hand.h"
@ -118,29 +118,36 @@ void Avatar::simulate(float deltaTime) {
bool inViewFrustum = Application::getInstance()->getViewFrustum()->sphereInFrustum(_position, boundingRadius) != bool inViewFrustum = Application::getInstance()->getViewFrustum()->sphereInFrustum(_position, boundingRadius) !=
ViewFrustum::OUTSIDE; ViewFrustum::OUTSIDE;
getHand()->simulate(deltaTime, false); {
PerformanceTimer perfTimer("hand");
getHand()->simulate(deltaTime, false);
}
_skeletonModel.setLODDistance(getLODDistance()); _skeletonModel.setLODDistance(getLODDistance());
if (!_shouldRenderBillboard && inViewFrustum) { if (!_shouldRenderBillboard && inViewFrustum) {
if (_hasNewJointRotations) { if (_hasNewJointRotations) {
PerformanceTimer perfTimer("skeleton");
for (int i = 0; i < _jointData.size(); i++) { for (int i = 0; i < _jointData.size(); i++) {
const JointData& data = _jointData.at(i); const JointData& data = _jointData.at(i);
_skeletonModel.setJointState(i, data.valid, data.rotation); _skeletonModel.setJointState(i, data.valid, data.rotation);
} }
_skeletonModel.simulate(deltaTime); _skeletonModel.simulate(deltaTime);
} }
_skeletonModel.simulate(deltaTime, _hasNewJointRotations); {
simulateAttachments(deltaTime); PerformanceTimer perfTimer("head");
_hasNewJointRotations = false; _skeletonModel.simulate(deltaTime, _hasNewJointRotations);
simulateAttachments(deltaTime);
_hasNewJointRotations = false;
glm::vec3 headPosition = _position; glm::vec3 headPosition = _position;
_skeletonModel.getHeadPosition(headPosition); _skeletonModel.getHeadPosition(headPosition);
Head* head = getHead(); Head* head = getHead();
head->setPosition(headPosition); head->setPosition(headPosition);
head->setScale(_scale); head->setScale(_scale);
head->simulate(deltaTime, false, _shouldRenderBillboard); head->simulate(deltaTime, false, _shouldRenderBillboard);
}
if (Menu::getInstance()->isOptionChecked(MenuOption::StringHair)) { if (Menu::getInstance()->isOptionChecked(MenuOption::StringHair)) {
PerformanceTimer perfTimer("hair");
simulateHair(deltaTime); simulateHair(deltaTime);
} }
} }

View file

@ -41,9 +41,13 @@ void AvatarManager::init() {
} }
void AvatarManager::updateOtherAvatars(float deltaTime) { void AvatarManager::updateOtherAvatars(float deltaTime) {
if (_avatarHash.size() > 1) {
return;
}
bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
PerformanceWarning warn(showWarnings, "Application::updateAvatars()"); PerformanceWarning warn(showWarnings, "Application::updateAvatars()");
PerformanceTimer perfTimer("otherAvatars");
Application* applicationInstance = Application::getInstance(); Application* applicationInstance = Application::getInstance();
glm::vec3 mouseOrigin = applicationInstance->getMouseRayOrigin(); glm::vec3 mouseOrigin = applicationInstance->getMouseRayOrigin();
glm::vec3 mouseDirection = applicationInstance->getMouseRayDirection(); glm::vec3 mouseDirection = applicationInstance->getMouseRayDirection();

View file

@ -108,15 +108,10 @@ void MyAvatar::reset() {
} }
void MyAvatar::update(float deltaTime) { void MyAvatar::update(float deltaTime) {
PerformanceTimer perfTimer("MyAvatar::update/");
Head* head = getHead(); Head* head = getHead();
head->relaxLean(deltaTime); head->relaxLean(deltaTime);
{ updateFromTrackers(deltaTime);
PerformanceTimer perfTimer("MyAvatar::update/updateFromTrackers");
updateFromTrackers(deltaTime);
}
if (Menu::getInstance()->isOptionChecked(MenuOption::MoveWithLean)) { if (Menu::getInstance()->isOptionChecked(MenuOption::MoveWithLean)) {
PerformanceTimer perfTimer("MyAvatar::update/moveWithLean");
// Faceshift drive is enabled, set the avatar drive based on the head position // Faceshift drive is enabled, set the avatar drive based on the head position
moveWithLean(); moveWithLean();
} }
@ -127,18 +122,14 @@ void MyAvatar::update(float deltaTime) {
head->setAudioAverageLoudness(audio->getAudioAverageInputLoudness()); head->setAudioAverageLoudness(audio->getAudioAverageInputLoudness());
if (_motionBehaviors & AVATAR_MOTION_OBEY_ENVIRONMENTAL_GRAVITY) { if (_motionBehaviors & AVATAR_MOTION_OBEY_ENVIRONMENTAL_GRAVITY) {
PerformanceTimer perfTimer("MyAvatar::update/gravityWork");
setGravity(Application::getInstance()->getEnvironment()->getGravity(getPosition())); setGravity(Application::getInstance()->getEnvironment()->getGravity(getPosition()));
} }
{ simulate(deltaTime);
PerformanceTimer perfTimer("MyAvatar::update/simulate");
simulate(deltaTime);
}
} }
void MyAvatar::simulate(float deltaTime) { void MyAvatar::simulate(float deltaTime) {
PerformanceTimer perfTimer("MyAvatar::simulate"); PerformanceTimer perfTimer("simulate");
if (_scale != _targetScale) { if (_scale != _targetScale) {
float scale = (1.0f - SMOOTHING_RATIO) * _scale + SMOOTHING_RATIO * _targetScale; float scale = (1.0f - SMOOTHING_RATIO) * _scale + SMOOTHING_RATIO * _targetScale;
@ -150,31 +141,28 @@ void MyAvatar::simulate(float deltaTime) {
_handState = HAND_STATE_NULL; _handState = HAND_STATE_NULL;
{ {
PerformanceTimer perfTimer("MyAvatar::simulate/updateOrientation"); PerformanceTimer perfTimer("transform");
updateOrientation(deltaTime); updateOrientation(deltaTime);
}
{
PerformanceTimer perfTimer("MyAvatar::simulate/updatePosition");
updatePosition(deltaTime); updatePosition(deltaTime);
} }
{ {
PerformanceTimer perfTimer("MyAvatar::simulate/hand Collision,simulate"); PerformanceTimer perfTimer("hand");
// update avatar skeleton and simulate hand and head // update avatar skeleton and simulate hand and head
getHand()->simulate(deltaTime, true); getHand()->simulate(deltaTime, true);
} }
{ {
PerformanceTimer perfTimer("MyAvatar::simulate/_skeletonModel.simulate()"); PerformanceTimer perfTimer("skeleton");
_skeletonModel.simulate(deltaTime); _skeletonModel.simulate(deltaTime);
} }
{ {
PerformanceTimer perfTimer("MyAvatar::simulate/simulateAttachments"); PerformanceTimer perfTimer("attachments");
simulateAttachments(deltaTime); simulateAttachments(deltaTime);
} }
{ {
PerformanceTimer perfTimer("MyAvatar::simulate/copy joints"); PerformanceTimer perfTimer("joints");
// copy out the skeleton joints from the model // copy out the skeleton joints from the model
_jointData.resize(_skeletonModel.getJointStateCount()); _jointData.resize(_skeletonModel.getJointStateCount());
for (int i = 0; i < _jointData.size(); i++) { for (int i = 0; i < _jointData.size(); i++) {
@ -184,7 +172,7 @@ void MyAvatar::simulate(float deltaTime) {
} }
{ {
PerformanceTimer perfTimer("MyAvatar::simulate/head Simulate"); PerformanceTimer perfTimer("head");
Head* head = getHead(); Head* head = getHead();
glm::vec3 headPosition; glm::vec3 headPosition;
if (!_skeletonModel.getHeadPosition(headPosition)) { if (!_skeletonModel.getHeadPosition(headPosition)) {
@ -196,14 +184,14 @@ void MyAvatar::simulate(float deltaTime) {
} }
{ {
PerformanceTimer perfTimer("MyAvatar::simulate/hair Simulate"); PerformanceTimer perfTimer("hair");
if (Menu::getInstance()->isOptionChecked(MenuOption::StringHair)) { if (Menu::getInstance()->isOptionChecked(MenuOption::StringHair)) {
simulateHair(deltaTime); simulateHair(deltaTime);
} }
} }
{ {
PerformanceTimer perfTimer("MyAvatar::simulate/ragdoll"); PerformanceTimer perfTimer("ragdoll");
if (Menu::getInstance()->isOptionChecked(MenuOption::CollideAsRagdoll)) { if (Menu::getInstance()->isOptionChecked(MenuOption::CollideAsRagdoll)) {
const int minError = 0.01f; const int minError = 0.01f;
const float maxIterations = 10; const float maxIterations = 10;
@ -216,7 +204,7 @@ void MyAvatar::simulate(float deltaTime) {
// now that we're done stepping the avatar forward in time, compute new collisions // now that we're done stepping the avatar forward in time, compute new collisions
if (_collisionGroups != 0) { if (_collisionGroups != 0) {
PerformanceTimer perfTimer("MyAvatar::simulate/_collisionGroups"); PerformanceTimer perfTimer("collisions");
Camera* myCamera = Application::getInstance()->getCamera(); Camera* myCamera = Application::getInstance()->getCamera();
float radius = getSkeletonHeight() * COLLISION_RADIUS_SCALE; float radius = getSkeletonHeight() * COLLISION_RADIUS_SCALE;
@ -225,18 +213,18 @@ void MyAvatar::simulate(float deltaTime) {
radius *= COLLISION_RADIUS_SCALAR; radius *= COLLISION_RADIUS_SCALAR;
} }
if (_collisionGroups & COLLISION_GROUP_ENVIRONMENT) { if (_collisionGroups & COLLISION_GROUP_ENVIRONMENT) {
PerformanceTimer perfTimer("MyAvatar::simulate/updateCollisionWithEnvironment"); PerformanceTimer perfTimer("environment");
updateCollisionWithEnvironment(deltaTime, radius); updateCollisionWithEnvironment(deltaTime, radius);
} }
if (_collisionGroups & COLLISION_GROUP_VOXELS) { if (_collisionGroups & COLLISION_GROUP_VOXELS) {
PerformanceTimer perfTimer("MyAvatar::simulate/updateCollisionWithVoxels"); PerformanceTimer perfTimer("voxels");
updateCollisionWithVoxels(deltaTime, radius); updateCollisionWithVoxels(deltaTime, radius);
} else { } else {
_trapDuration = 0.0f; _trapDuration = 0.0f;
} }
/* TODO: Andrew to make this work /* TODO: Andrew to make this work
if (_collisionGroups & COLLISION_GROUP_AVATARS) { if (_collisionGroups & COLLISION_GROUP_AVATARS) {
PerformanceTimer perfTimer("MyAvatar::simulate/updateCollisionWithAvatars"); PerformanceTimer perfTimer("avatars");
updateCollisionWithAvatars(deltaTime); updateCollisionWithAvatars(deltaTime);
} }
*/ */
@ -910,7 +898,6 @@ bool MyAvatar::shouldRenderHead(const glm::vec3& cameraPosition, RenderMode rend
} }
float MyAvatar::computeDistanceToFloor(const glm::vec3& startPoint) { float MyAvatar::computeDistanceToFloor(const glm::vec3& startPoint) {
PerformanceTimer perfTimer("MyAvatar::computeDistanceToFloor()");
glm::vec3 direction = -_worldUpDirection; glm::vec3 direction = -_worldUpDirection;
OctreeElement* elementHit; // output from findRayIntersection OctreeElement* elementHit; // output from findRayIntersection
float distance = FLT_MAX; // output from findRayIntersection float distance = FLT_MAX; // output from findRayIntersection
@ -976,7 +963,6 @@ void MyAvatar::updateOrientation(float deltaTime) {
const float NEARBY_FLOOR_THRESHOLD = 5.0f; const float NEARBY_FLOOR_THRESHOLD = 5.0f;
void MyAvatar::updatePosition(float deltaTime) { void MyAvatar::updatePosition(float deltaTime) {
PerformanceTimer perfTimer("MyAvatar::updatePosition");
float keyboardInput = fabsf(_driveKeys[FWD] - _driveKeys[BACK]) + float keyboardInput = fabsf(_driveKeys[FWD] - _driveKeys[BACK]) +
fabsf(_driveKeys[RIGHT] - _driveKeys[LEFT]) + fabsf(_driveKeys[RIGHT] - _driveKeys[LEFT]) +
fabsf(_driveKeys[UP] - _driveKeys[DOWN]); fabsf(_driveKeys[UP] - _driveKeys[DOWN]);

View file

@ -121,7 +121,7 @@ static void maybeRelease(QOpenGLFramebufferObject* fbo) {
} }
QOpenGLFramebufferObject* GlowEffect::render(bool toTexture) { QOpenGLFramebufferObject* GlowEffect::render(bool toTexture) {
PerformanceTimer perfTimer("paintGL/glowEffect"); PerformanceTimer perfTimer("glowEffect");
QOpenGLFramebufferObject* primaryFBO = Application::getInstance()->getTextureCache()->getPrimaryFramebufferObject(); QOpenGLFramebufferObject* primaryFBO = Application::getInstance()->getTextureCache()->getPrimaryFramebufferObject();
primaryFBO->release(); primaryFBO->release();

View file

@ -601,6 +601,8 @@ void Stats::display(
drawText(horizontalOffset, verticalOffset, scale, rotation, font, (char*)voxelStats.str().c_str(), color); drawText(horizontalOffset, verticalOffset, scale, rotation, font, (char*)voxelStats.str().c_str(), color);
} }
PerformanceTimer::tallyAllTimerRecords();
// TODO: the display of these timing details should all be moved to JavaScript // TODO: the display of these timing details should all be moved to JavaScript
if (_expanded && Menu::getInstance()->isOptionChecked(MenuOption::DisplayTimingDetails)) { if (_expanded && Menu::getInstance()->isOptionChecked(MenuOption::DisplayTimingDetails)) {
// Timing details... // Timing details...

View file

@ -17,6 +17,12 @@
#include "PerfStat.h" #include "PerfStat.h"
#include "SharedUtil.h"
// ----------------------------------------------------------------------------
// PerformanceWarning
// ----------------------------------------------------------------------------
// Static class members initialization here! // Static class members initialization here!
bool PerformanceWarning::_suppressShortTimings = false; bool PerformanceWarning::_suppressShortTimings = false;
@ -52,14 +58,50 @@ PerformanceWarning::~PerformanceWarning() {
} }
}; };
// ----------------------------------------------------------------------------
// PerformanceTimerRecord
// ----------------------------------------------------------------------------
const quint64 STALE_STAT_PERIOD = 4 * USECS_PER_SECOND;
void PerformanceTimerRecord::tallyResult(const quint64& now) {
if (_numAccumulations > 0) {
_numTallies++;
_movingAverage.updateAverage(_runningTotal - _lastTotal);
_lastTotal = _runningTotal;
_numAccumulations = 0;
_expiry = now + STALE_STAT_PERIOD;
}
}
// ----------------------------------------------------------------------------
// PerformanceTimer
// ----------------------------------------------------------------------------
QString PerformanceTimer::_fullName;
QMap<QString, PerformanceTimerRecord> PerformanceTimer::_records; QMap<QString, PerformanceTimerRecord> PerformanceTimer::_records;
PerformanceTimer::~PerformanceTimer() { PerformanceTimer::~PerformanceTimer() {
quint64 end = usecTimestampNow(); quint64 elapsedusec = (usecTimestampNow() - _start);
quint64 elapsedusec = (end - _start); PerformanceTimerRecord& namedRecord = _records[_fullName];
PerformanceTimerRecord& namedRecord = _records[_name]; namedRecord.accumulateResult(elapsedusec);
namedRecord.recordResult(elapsedusec); _fullName.resize(_fullName.size() - (_name.size() + 1));
}
// static
void PerformanceTimer::tallyAllTimerRecords() {
QMap<QString, PerformanceTimerRecord>::iterator recordsItr = _records.begin();
QMap<QString, PerformanceTimerRecord>::const_iterator recordsEnd = _records.end();
quint64 now = usecTimestampNow();
while (recordsItr != recordsEnd) {
recordsItr.value().tallyResult(now);
if (recordsItr.value().isStale(now)) {
// purge stale records
recordsItr = _records.erase(recordsItr);
} else {
++recordsItr;
}
}
} }
void PerformanceTimer::dumpAllTimerRecords() { void PerformanceTimer::dumpAllTimerRecords() {

View file

@ -52,16 +52,21 @@ public:
class PerformanceTimerRecord { class PerformanceTimerRecord {
public: public:
PerformanceTimerRecord() : _runningTotal(0), _totalCalls(0) {} PerformanceTimerRecord() : _runningTotal(0), _lastTotal(0), _numAccumulations(0), _numTallies(0), _expiry(0) {}
void recordResult(quint64 elapsed) { _runningTotal += elapsed; _totalCalls++; _movingAverage.updateAverage(elapsed); } void accumulateResult(const quint64& elapsed) { _runningTotal += elapsed; ++_numAccumulations; }
quint64 getAverage() const { return (_totalCalls == 0) ? 0 : _runningTotal / _totalCalls; } void tallyResult(const quint64& now);
quint64 getMovingAverage() const { return (_totalCalls == 0) ? 0 : _movingAverage.getAverage(); } bool isStale(const quint64& now) const { return now > _expiry; }
quint64 getCount() const { return _totalCalls; } quint64 getAverage() const { return (_numTallies == 0) ? 0 : _runningTotal / _numTallies; }
quint64 getMovingAverage() const { return (_numTallies == 0) ? 0 : _movingAverage.getAverage(); }
quint64 getCount() const { return _numTallies; }
private: private:
quint64 _runningTotal; quint64 _runningTotal;
quint64 _totalCalls; quint64 _lastTotal;
quint64 _numAccumulations;
quint64 _numTallies;
quint64 _expiry;
SimpleMovingAverage _movingAverage; SimpleMovingAverage _movingAverage;
}; };
@ -69,20 +74,24 @@ class PerformanceTimer {
public: public:
PerformanceTimer(const QString& name) : PerformanceTimer(const QString& name) :
_start(usecTimestampNow()), _start(0),
_name(name) { } _name(name) {
_fullName.append("/");
_fullName.append(_name);
_start = usecTimestampNow();
}
quint64 elapsed() const { return (usecTimestampNow() - _start); };
~PerformanceTimer(); ~PerformanceTimer();
static const PerformanceTimerRecord& getTimerRecord(const QString& name) { return _records[name]; }; static const PerformanceTimerRecord& getTimerRecord(const QString& name) { return _records[name]; };
static const QMap<QString, PerformanceTimerRecord>& getAllTimerRecords() { return _records; }; static const QMap<QString, PerformanceTimerRecord>& getAllTimerRecords() { return _records; };
static void tallyAllTimerRecords();
static void dumpAllTimerRecords(); static void dumpAllTimerRecords();
private: private:
quint64 _start; quint64 _start;
QString _name; QString _name;
static QString _fullName;
static QMap<QString, PerformanceTimerRecord> _records; static QMap<QString, PerformanceTimerRecord> _records;
}; };