Merge pull request #1023 from ZappoMan/wider_view_frustum

added some timing debugging
This commit is contained in:
ZappoMan 2013-10-05 00:56:55 -07:00
commit 825d397e21
7 changed files with 71 additions and 8 deletions

View file

@ -324,6 +324,8 @@ void Application::initializeGL() {
} }
void Application::paintGL() { void Application::paintGL() {
PerformanceWarning::setSuppressShortTimings(Menu::getInstance()->isOptionChecked(MenuOption::SuppressShortTimings));
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), "Application::paintGL()");
PerfStat("display"); PerfStat("display");
glEnable(GL_LINE_SMOOTH); glEnable(GL_LINE_SMOOTH);
@ -1181,6 +1183,7 @@ void Application::idle() {
double timeSinceLastUpdate = diffclock(&_lastTimeUpdated, &check); double timeSinceLastUpdate = diffclock(&_lastTimeUpdated, &check);
if (timeSinceLastUpdate > IDLE_SIMULATE_MSECS) { if (timeSinceLastUpdate > IDLE_SIMULATE_MSECS) {
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));
_glWidget->updateGL(); _glWidget->updateGL();
@ -2379,6 +2382,7 @@ void Application::computeOffAxisFrustum(float& left, float& right, float& bottom
} }
void Application::displaySide(Camera& whichCamera) { void Application::displaySide(Camera& whichCamera) {
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), "Application::displaySide()");
// transform by eye offset // transform by eye offset
// flip x if in mirror mode (also requires reversing winding order for backface culling) // flip x if in mirror mode (also requires reversing winding order for backface culling)
@ -2410,6 +2414,8 @@ void Application::displaySide(Camera& whichCamera) {
setupWorldLight(whichCamera); setupWorldLight(whichCamera);
if (Menu::getInstance()->isOptionChecked(MenuOption::Stars)) { if (Menu::getInstance()->isOptionChecked(MenuOption::Stars)) {
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
"Application::displaySide() ... stars...");
if (!_stars.getFileLoaded()) { if (!_stars.getFileLoaded()) {
_stars.readInput(STAR_FILE, STAR_CACHE_FILE, 0); _stars.readInput(STAR_FILE, STAR_CACHE_FILE, 0);
} }
@ -2435,6 +2441,8 @@ void Application::displaySide(Camera& whichCamera) {
// draw the sky dome // draw the sky dome
if (Menu::getInstance()->isOptionChecked(MenuOption::Atmosphere)) { if (Menu::getInstance()->isOptionChecked(MenuOption::Atmosphere)) {
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
"Application::displaySide() ... atmosphere...");
_environment.renderAtmospheres(whichCamera); _environment.renderAtmospheres(whichCamera);
} }
@ -2457,6 +2465,9 @@ void Application::displaySide(Camera& whichCamera) {
//draw a grid ground plane.... //draw a grid ground plane....
if (Menu::getInstance()->isOptionChecked(MenuOption::GroundPlane)) { if (Menu::getInstance()->isOptionChecked(MenuOption::GroundPlane)) {
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
"Application::displaySide() ... ground plane...");
// draw grass plane with fog // draw grass plane with fog
glEnable(GL_FOG); glEnable(GL_FOG);
glEnable(GL_NORMALIZE); glEnable(GL_NORMALIZE);
@ -2480,7 +2491,11 @@ void Application::displaySide(Camera& whichCamera) {
} }
// Draw voxels // Draw voxels
if (Menu::getInstance()->isOptionChecked(MenuOption::Voxels)) { if (Menu::getInstance()->isOptionChecked(MenuOption::Voxels)) {
_voxels.render(Menu::getInstance()->isOptionChecked(MenuOption::VoxelTextures)); PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
"Application::displaySide() ... voxels...");
if (!Menu::getInstance()->isOptionChecked(MenuOption::DontRenderVoxels)) {
_voxels.render(Menu::getInstance()->isOptionChecked(MenuOption::VoxelTextures));
}
} }
// restore default, white specular // restore default, white specular
@ -2488,6 +2503,9 @@ void Application::displaySide(Camera& whichCamera) {
// indicate what we'll be adding/removing in mouse mode, if anything // indicate what we'll be adding/removing in mouse mode, if anything
if (_mouseVoxel.s != 0) { if (_mouseVoxel.s != 0) {
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
"Application::displaySide() ... voxels TOOLS UX...");
glDisable(GL_LIGHTING); glDisable(GL_LIGHTING);
glPushMatrix(); glPushMatrix();
glScalef(TREE_SCALE, TREE_SCALE, TREE_SCALE); glScalef(TREE_SCALE, TREE_SCALE, TREE_SCALE);
@ -2533,6 +2551,9 @@ void Application::displaySide(Camera& whichCamera) {
} }
if (Menu::getInstance()->isOptionChecked(MenuOption::VoxelSelectMode) && _pasteMode) { if (Menu::getInstance()->isOptionChecked(MenuOption::VoxelSelectMode) && _pasteMode) {
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
"Application::displaySide() ... PASTE Preview...");
glPushMatrix(); glPushMatrix();
glTranslatef(_mouseVoxel.x * TREE_SCALE, glTranslatef(_mouseVoxel.x * TREE_SCALE,
_mouseVoxel.y * TREE_SCALE, _mouseVoxel.y * TREE_SCALE,
@ -2548,6 +2569,10 @@ void Application::displaySide(Camera& whichCamera) {
_myAvatar.renderScreenTint(SCREEN_TINT_BEFORE_AVATARS, whichCamera); _myAvatar.renderScreenTint(SCREEN_TINT_BEFORE_AVATARS, whichCamera);
if (Menu::getInstance()->isOptionChecked(MenuOption::Avatars)) { if (Menu::getInstance()->isOptionChecked(MenuOption::Avatars)) {
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
"Application::displaySide() ... Avatars...");
// Render avatars of other nodes // Render avatars of other nodes
NodeList* nodeList = NodeList::getInstance(); NodeList* nodeList = NodeList::getInstance();
@ -2592,16 +2617,22 @@ void Application::displaySide(Camera& whichCamera) {
// 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)) {
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
"Application::displaySide() ... AmbientOcclusion...");
_ambientOcclusionEffect.render(); _ambientOcclusionEffect.render();
} }
// brad's frustum for debugging // brad's frustum for debugging
if (Menu::getInstance()->isOptionChecked(MenuOption::DisplayFrustum)) { if (Menu::getInstance()->isOptionChecked(MenuOption::DisplayFrustum)) {
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
"Application::displaySide() ... renderViewFrustum...");
renderViewFrustum(_viewFrustum); renderViewFrustum(_viewFrustum);
} }
// render voxel fades if they exist // render voxel fades if they exist
if (_voxelFades.size() > 0) { if (_voxelFades.size() > 0) {
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
"Application::displaySide() ... voxel fades...");
for(std::vector<VoxelFade>::iterator fade = _voxelFades.begin(); fade != _voxelFades.end();) { for(std::vector<VoxelFade>::iterator fade = _voxelFades.begin(); fade != _voxelFades.end();) {
fade->render(); fade->render();
if(fade->isDone()) { if(fade->isDone()) {
@ -2611,11 +2642,18 @@ void Application::displaySide(Camera& whichCamera) {
} }
} }
} }
renderFollowIndicator(); {
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
"Application::displaySide() ... renderFollowIndicator...");
renderFollowIndicator();
}
// render transmitter pick ray, if non-empty // render transmitter pick ray, if non-empty
if (_transmitterPickStart != _transmitterPickEnd) { if (_transmitterPickStart != _transmitterPickEnd) {
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
"Application::displaySide() ... transmitter pick ray...");
Glower glower; Glower glower;
const float TRANSMITTER_PICK_COLOR[] = { 1.0f, 1.0f, 0.0f }; const float TRANSMITTER_PICK_COLOR[] = { 1.0f, 1.0f, 0.0f };
glColor3fv(TRANSMITTER_PICK_COLOR); glColor3fv(TRANSMITTER_PICK_COLOR);
@ -2637,6 +2675,8 @@ void Application::displaySide(Camera& whichCamera) {
} }
void Application::displayOverlay() { void Application::displayOverlay() {
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), "Application::displayOverlay()");
// Render 2D overlay: I/O level bar graphs and text // Render 2D overlay: I/O level bar graphs and text
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);
glPushMatrix(); glPushMatrix();

View file

@ -239,6 +239,7 @@ Menu::Menu() :
true, true,
appInstance, appInstance,
SLOT(setRenderVoxels(bool))); SLOT(setRenderVoxels(bool)));
addCheckableActionToQMenuAndActionHash(voxelOptionsMenu, MenuOption::DontRenderVoxels);
addCheckableActionToQMenuAndActionHash(voxelOptionsMenu, MenuOption::VoxelTextures); addCheckableActionToQMenuAndActionHash(voxelOptionsMenu, MenuOption::VoxelTextures);
addCheckableActionToQMenuAndActionHash(voxelOptionsMenu, MenuOption::AmbientOcclusion); addCheckableActionToQMenuAndActionHash(voxelOptionsMenu, MenuOption::AmbientOcclusion);
addCheckableActionToQMenuAndActionHash(voxelOptionsMenu, MenuOption::UseVoxelShader, 0, addCheckableActionToQMenuAndActionHash(voxelOptionsMenu, MenuOption::UseVoxelShader, 0,
@ -346,6 +347,7 @@ Menu::Menu() :
QMenu* renderDebugMenu = developerMenu->addMenu("Render Debugging Tools"); QMenu* renderDebugMenu = developerMenu->addMenu("Render Debugging Tools");
addCheckableActionToQMenuAndActionHash(renderDebugMenu, MenuOption::PipelineWarnings); addCheckableActionToQMenuAndActionHash(renderDebugMenu, MenuOption::PipelineWarnings);
addCheckableActionToQMenuAndActionHash(renderDebugMenu, MenuOption::SuppressShortTimings);
addActionToQMenuAndActionHash(renderDebugMenu, addActionToQMenuAndActionHash(renderDebugMenu,
MenuOption::KillLocalVoxels, MenuOption::KillLocalVoxels,

View file

@ -138,6 +138,7 @@ namespace MenuOption {
const QString DestructiveAddVoxel = "Create Voxel is Destructive"; const QString DestructiveAddVoxel = "Create Voxel is Destructive";
const QString DeltaSending = "Delta Sending"; const QString DeltaSending = "Delta Sending";
const QString DisplayFrustum = "Display Frustum"; const QString DisplayFrustum = "Display Frustum";
const QString DontRenderVoxels = "Don't Render Voxels";
const QString EchoAudio = "Echo Audio"; const QString EchoAudio = "Echo Audio";
const QString ExportVoxels = "Export Voxels"; const QString ExportVoxels = "Export Voxels";
const QString HeadMouse = "Head Mouse"; const QString HeadMouse = "Head Mouse";
@ -193,6 +194,7 @@ namespace MenuOption {
const QString ShowTrueColors = "Show TRUE Colors"; const QString ShowTrueColors = "Show TRUE Colors";
const QString SimulateLeapHand = "Simulate Leap Hand"; const QString SimulateLeapHand = "Simulate Leap Hand";
const QString SkeletonTracking = "Skeleton Tracking"; const QString SkeletonTracking = "Skeleton Tracking";
const QString SuppressShortTimings = "Suppress Timings Less than 10ms";
const QString LEDTracking = "LED Tracking"; const QString LEDTracking = "LED Tracking";
const QString Stars = "Stars"; const QString Stars = "Stars";
const QString Stats = "Stats"; const QString Stats = "Stats";

View file

@ -47,15 +47,18 @@ void VoxelPacketProcessor::processPacket(sockaddr& senderAddress, unsigned char*
if (Menu::getInstance()->isOptionChecked(MenuOption::Voxels)) { if (Menu::getInstance()->isOptionChecked(MenuOption::Voxels)) {
Node* voxelServer = NodeList::getInstance()->nodeWithAddress(&senderAddress); Node* voxelServer = NodeList::getInstance()->nodeWithAddress(&senderAddress);
if (voxelServer && socketMatch(voxelServer->getActiveSocket(), &senderAddress)) { if (voxelServer && socketMatch(voxelServer->getActiveSocket(), &senderAddress)) {
voxelServer->lock();
voxelServer->lock(); // do we really need to lock this? just to get the ID?
int nodeID = voxelServer->getNodeID();
voxelServer->unlock();
if (packetData[0] == PACKET_TYPE_ENVIRONMENT_DATA) { if (packetData[0] == PACKET_TYPE_ENVIRONMENT_DATA) {
app->_environment.parseData(&senderAddress, packetData, messageLength); app->_environment.parseData(&senderAddress, packetData, messageLength);
} else { } else {
app->_voxels.setDataSourceID(voxelServer->getNodeID()); app->_voxels.setDataSourceID(nodeID);
app->_voxels.parseData(packetData, messageLength); app->_voxels.parseData(packetData, messageLength);
app->_voxels.setDataSourceID(UNKNOWN_NODE_ID); app->_voxels.setDataSourceID(UNKNOWN_NODE_ID);
} }
voxelServer->unlock();
} }
} }
} }

View file

@ -1077,6 +1077,8 @@ void VoxelSystem::render(bool texture) {
updateVBOs(); updateVBOs();
if (_useVoxelShader) { if (_useVoxelShader) {
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
"render().. _useVoxelShader openGL..");
Application::getInstance()->getVoxelShader().begin(); Application::getInstance()->getVoxelShader().begin();
@ -1106,6 +1108,8 @@ void VoxelSystem::render(bool texture) {
Application::getInstance()->getVoxelShader().end(); Application::getInstance()->getVoxelShader().end();
} else { } else {
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), "render().. openGL...");
// tell OpenGL where to find vertex and color information // tell OpenGL where to find vertex and color information
glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_COLOR_ARRAY); glEnableClientState(GL_COLOR_ARRAY);

View file

@ -103,6 +103,7 @@ int PerfStat::DumpStats(char** array) {
return lineCount; return lineCount;
} }
bool PerformanceWarning::_suppressShortTimings = false;
// Destructor handles recording all of our stats // Destructor handles recording all of our stats
PerformanceWarning::~PerformanceWarning() { PerformanceWarning::~PerformanceWarning() {
@ -111,9 +112,17 @@ PerformanceWarning::~PerformanceWarning() {
if ((_alwaysDisplay || _renderWarningsOn) && elapsedmsec > 1) { if ((_alwaysDisplay || _renderWarningsOn) && elapsedmsec > 1) {
if (elapsedmsec > 1000) { if (elapsedmsec > 1000) {
double elapsedsec = (end - _start) / 1000000.0; double elapsedsec = (end - _start) / 1000000.0;
qDebug("%s%s took %lf seconds\n", (_alwaysDisplay ? "" : "WARNING!"), _message, elapsedsec); qDebug("%s took %lf seconds %s\n", _message, elapsedsec, (_alwaysDisplay ? "" : "WARNING!") );
} else { } else {
qDebug("%s%s took %lf milliseconds\n", (_alwaysDisplay ? "" : "WARNING!"), _message, elapsedmsec); if (_suppressShortTimings) {
if (elapsedmsec > 10) {
qDebug("%s took %lf milliseconds %s\n", _message, elapsedmsec,
(_alwaysDisplay || (elapsedmsec < 10) ? "" : "WARNING!"));
}
} else {
qDebug("%s took %lf milliseconds %s\n", _message, elapsedmsec,
(_alwaysDisplay || (elapsedmsec < 10) ? "" : "WARNING!"));
}
} }
} else if (_alwaysDisplay) { } else if (_alwaysDisplay) {
qDebug("%s took %lf milliseconds\n", _message, elapsedmsec); qDebug("%s took %lf milliseconds\n", _message, elapsedmsec);

View file

@ -89,6 +89,7 @@ private:
const char* _message; const char* _message;
bool _renderWarningsOn; bool _renderWarningsOn;
bool _alwaysDisplay; bool _alwaysDisplay;
static bool _suppressShortTimings;
public: public:
PerformanceWarning(bool renderWarnings, const char* message, bool alwaysDisplay = false) : PerformanceWarning(bool renderWarnings, const char* message, bool alwaysDisplay = false) :
_start(usecTimestampNow()), _start(usecTimestampNow()),
@ -97,6 +98,8 @@ public:
_alwaysDisplay(alwaysDisplay) { } _alwaysDisplay(alwaysDisplay) { }
~PerformanceWarning(); ~PerformanceWarning();
static void setSuppressShortTimings(bool suppressShortTimings) { _suppressShortTimings = suppressShortTimings; }
}; };