Add debug functionalities: Busy wait for decode() and Log SGCT out-of-order errors

This commit is contained in:
Erik Broberg
2016-09-06 12:44:03 -04:00
parent 3cac5858be
commit aada13a656
5 changed files with 85 additions and 24 deletions

View File

@@ -228,26 +228,23 @@ std::stringstream& operator<<(std::stringstream& o, const FunctionLogKey& l) {
const FunctionLogKey PRE_SYNC = {'1', '2'};
const FunctionLogKey ENCODE = {'E', 'e'};
const FunctionLogKey DECODE = {'D', 'd'};
const FunctionLogKey PRE_SYNC = { '1', '2' };
const FunctionLogKey ENCODE = { 'E', 'e' };
const FunctionLogKey DECODE = { 'D', 'd' };
const FunctionLogKey POST_SYNC = { '3', '4' };
const FunctionLogKey RENDER = {'R', 'r'};
const FunctionLogKey POST_DRAW = {'P', 'p'};
const FunctionLogKey RENDER = { 'R', 'r' };
const FunctionLogKey POST_DRAW = { 'P', 'p' };
std::stringstream minilog;
std::stringstream masterlog;
std::stringstream slavelog;
const std::string EXPECTED_MASTER_LOG = (masterlog << PRE_SYNC << ENCODE << POST_SYNC << RENDER << POST_DRAW).str();
const std::string EXPECTED_SLAVE_LOG = (slavelog << PRE_SYNC << DECODE << POST_SYNC << RENDER << POST_DRAW).str();
const std::string EXPECTED_SLAVE_LOG = (slavelog << PRE_SYNC << DECODE << POST_SYNC << RENDER << POST_DRAW).str();
#define LOG_BEGIN(x) minilog << (x).begin
#define LOG_END(x) minilog << (x).end
#define BUSY_WAIT_FOR(x) \
while (minilog.str().size() && minilog.str().back() != (x)) { \
std::this_thread::sleep_for(std::chrono::microseconds(10)); \
}\
void mainPreSyncFunc() {
LOG_BEGIN(PRE_SYNC);
@@ -256,9 +253,12 @@ void mainPreSyncFunc() {
LOG_END(PRE_SYNC);
}
volatile bool busyWaitDecode = false;
void mainPostSyncPreDrawFunc() {
if (!sgct::Engine::instance()->isMaster()) {
BUSY_WAIT_FOR(DECODE.end);
if (OsEng.useBusyWaitForDecode() && !sgct::Engine::instance()->isMaster()) {
while (minilog.str().size() && minilog.str().back() != DECODE.end) {
std::this_thread::sleep_for(std::chrono::microseconds(10));
}
}
LOG_BEGIN(POST_SYNC);
OsEng.postSynchronizationPreDraw();
@@ -270,11 +270,11 @@ void mainRenderFunc() {
using glm::mat4;
using glm::translate;
//not the most efficient, but for clarity @JK
mat4 userMatrix = translate(mat4(1.f), _sgctEngine->getDefaultUserPtr()->getPos());
mat4 sceneMatrix = _sgctEngine->getModelMatrix();
mat4 viewMatrix = _sgctEngine->getCurrentViewMatrix() * userMatrix;
//dont shift nav-direction on master, makes it very tricky to navigate @JK
if (!OsEng.ref().isMaster())
viewMatrix = viewMatrix * sceneMatrix;
@@ -289,17 +289,20 @@ void mainPostDrawFunc() {
OsEng.postDraw();
LOG_END(POST_DRAW);
if (sgct::Engine::instance()->isMaster()) {
if (minilog.str() != EXPECTED_MASTER_LOG) {
LERRORC("Minilog", "Bad combination: " << minilog.str());
if (OsEng.logSGCTOutOfOrderErrors()) {
if (sgct::Engine::instance()->isMaster()) {
if (minilog.str() != EXPECTED_MASTER_LOG) {
LERRORC("Minilog", "Bad combination: " << minilog.str());
}
}
}
else {
if (minilog.str() != EXPECTED_SLAVE_LOG) {
LERRORC("Minilog", "Bad combination: " << minilog.str());
else {
if (minilog.str() != EXPECTED_SLAVE_LOG) {
LERRORC("Minilog", "Bad combination: " << minilog.str());
}
}
}
// clear
minilog.str(std::string());
}
@@ -315,7 +318,7 @@ void mainKeyboardCallback(int key, int, int action, int mods) {
openspace::Key(key),
openspace::KeyModifier(mods),
openspace::KeyAction(action)
);
);
}
}
@@ -324,7 +327,7 @@ void mainMouseButtonCallback(int key, int action) {
OsEng.mouseButtonCallback(
openspace::MouseButton(key),
openspace::MouseAction(action)
);
);
}
}

View File

@@ -115,6 +115,9 @@ public:
void disableBarrier();
void toggleShutdownMode();
bool useBusyWaitForDecode();
bool logSGCTOutOfOrderErrors();
void runPostInitializationScripts(const std::string& sceneDescription);

View File

@@ -43,14 +43,22 @@ public:
void setModules(std::vector<OpenSpaceModule*> modules);
bool busyWaitForDecode();
bool logSGCTOutOfOrderErrors();
private:
void initEyeSeparation();
void initSceneFiles();
void initShowFrameNumber();
void initBusyWaitForDecode();
void initLogSGCTOutOfOrderErrors();
properties::FloatProperty _eyeSeparation;
properties::OptionProperty _scenes;
properties::BoolProperty _showFrameNumber;
properties::BoolProperty _busyWaitForDecode;
properties::BoolProperty _logSGCTOutOfOrderErrors;
};
} // namespace openspace

View File

@@ -770,8 +770,8 @@ void OpenSpaceEngine::preSynchronization() {
_interactionHandler->updateInputStates(dt);
_renderEngine->updateSceneGraph();
_renderEngine->camera()->invalidateCache();
_interactionHandler->updateCamera();
_renderEngine->camera()->invalidateCache();
_parallelConnection->preSynchronization();
}
@@ -1001,6 +1001,14 @@ scripting::LuaLibrary OpenSpaceEngine::luaLibrary() {
};
}
bool OpenSpaceEngine::useBusyWaitForDecode() {
return _settingsEngine->busyWaitForDecode();
}
bool OpenSpaceEngine::logSGCTOutOfOrderErrors() {
return _settingsEngine->logSGCTOutOfOrderErrors();
}
void OpenSpaceEngine::enableBarrier() {
_windowWrapper->setBarrier(true);
}

View File

@@ -32,13 +32,26 @@
#include <ghoul/ghoul.h>
#include <ghoul/filesystem/filesystem.h>
#include <ghoul/logging/logmanager.h>
#include <string>
namespace {
const std::string _loggerCat = "SettingsEngine";
}
namespace openspace {
SettingsEngine::SettingsEngine()
: _eyeSeparation("eyeSeparation", "Eye Separation" , 0.f, 0.f, 10.f)
, _scenes("scenes", "Scene", properties::OptionProperty::DisplayType::DROPDOWN)
, _showFrameNumber("showFrameNumber", "Show frame number", false)
, _busyWaitForDecode("busyWaitForDecode", "Busy Wait for decode", false)
, _logSGCTOutOfOrderErrors("logSGCTOutOfOrderErrors", "Log SGCT out-of-order", false)
{
setName("Global Properties");
}
@@ -47,6 +60,8 @@ void SettingsEngine::initialize() {
initEyeSeparation();
initSceneFiles();
initShowFrameNumber();
initBusyWaitForDecode();
initLogSGCTOutOfOrderErrors();
}
void SettingsEngine::setModules(std::vector<OpenSpaceModule*> modules) {
@@ -70,6 +85,30 @@ void SettingsEngine::initShowFrameNumber() {
[this]() { OsEng.renderEngine().setShowFrameNumber(_showFrameNumber.value()); } );
}
void SettingsEngine::initBusyWaitForDecode() {
addProperty(_busyWaitForDecode);
_busyWaitForDecode.onChange(
[this]() {
LINFO((_busyWaitForDecode.value() ? "Busy wait for decode" : "Async decode"));
});
}
bool SettingsEngine::busyWaitForDecode() {
return _busyWaitForDecode.value();
}
void SettingsEngine::initLogSGCTOutOfOrderErrors() {
addProperty(_logSGCTOutOfOrderErrors);
_logSGCTOutOfOrderErrors.onChange(
[this]() {
LINFO("Turn " << (_logSGCTOutOfOrderErrors.value() ? "on" : "off") << " SGCT out of order logging");
});
}
bool SettingsEngine::logSGCTOutOfOrderErrors() {
return _logSGCTOutOfOrderErrors.value();
}
void SettingsEngine::initSceneFiles() {
addProperty(_scenes);