mtsgui: added support for -a, -h, and -p command line parameters known from the 'mitsuba' executable
parent
3d84105a47
commit
2331b16f54
|
@ -901,6 +901,7 @@ struct NativeBuffer {
|
||||||
case Bitmap::EUInt8: result = bp::object(((uint8_t *) buf.ptr)[idx]); break;
|
case Bitmap::EUInt8: result = bp::object(((uint8_t *) buf.ptr)[idx]); break;
|
||||||
case Bitmap::EUInt16: result = bp::object(((uint16_t *) buf.ptr)[idx]); break;
|
case Bitmap::EUInt16: result = bp::object(((uint16_t *) buf.ptr)[idx]); break;
|
||||||
case Bitmap::EUInt32: result = bp::object(((uint32_t *) buf.ptr)[idx]); break;
|
case Bitmap::EUInt32: result = bp::object(((uint32_t *) buf.ptr)[idx]); break;
|
||||||
|
case Bitmap::EFloat16: result = bp::object((float) ((half *) buf.ptr)[idx]); break;
|
||||||
case Bitmap::EFloat32: result = bp::object(((float *) buf.ptr)[idx]); break;
|
case Bitmap::EFloat32: result = bp::object(((float *) buf.ptr)[idx]); break;
|
||||||
case Bitmap::EFloat64: result = bp::object(((double *) buf.ptr)[idx]); break;
|
case Bitmap::EFloat64: result = bp::object(((double *) buf.ptr)[idx]); break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -163,7 +163,7 @@ void collect_zombies(int s) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
int retval;
|
int retval = -1;
|
||||||
|
|
||||||
/* Initialize the core framework */
|
/* Initialize the core framework */
|
||||||
Class::staticInitialization();
|
Class::staticInitialization();
|
||||||
|
@ -298,8 +298,8 @@ int main(int argc, char *argv[]) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
mainWindow = new MainWindow();
|
mainWindow = new MainWindow();
|
||||||
mainWindow->initWorkers();
|
if (mainWindow->initWorkersProcessArgv())
|
||||||
retval = app.exec();
|
retval = app.exec();
|
||||||
|
|
||||||
#if defined(MTS_HAS_BREAKPAD)
|
#if defined(MTS_HAS_BREAKPAD)
|
||||||
#if defined(__OSX__)
|
#if defined(__OSX__)
|
||||||
|
@ -313,7 +313,6 @@ int main(int argc, char *argv[]) {
|
||||||
SLog(EWarn, "Critical exception during startup: %s", e.what());
|
SLog(EWarn, "Critical exception during startup: %s", e.what());
|
||||||
QMessageBox::critical(NULL, QString("Critical exception"),
|
QMessageBox::critical(NULL, QString("Critical exception"),
|
||||||
e.what(), QMessageBox::Ok);
|
e.what(), QMessageBox::Ok);
|
||||||
retval = -1;
|
|
||||||
}
|
}
|
||||||
Statistics::getInstance()->printStats();
|
Statistics::getInstance()->printStats();
|
||||||
|
|
||||||
|
|
|
@ -246,7 +246,8 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||||
MainWindow::~MainWindow() {
|
MainWindow::~MainWindow() {
|
||||||
m_renderQueue->unregisterListener(m_renderListener);
|
m_renderQueue->unregisterListener(m_renderListener);
|
||||||
ref<Scheduler> scheduler = Scheduler::getInstance();
|
ref<Scheduler> scheduler = Scheduler::getInstance();
|
||||||
scheduler->pause();
|
if (scheduler->isRunning())
|
||||||
|
scheduler->pause();
|
||||||
for (int i=0; i<m_connections.size(); ++i) {
|
for (int i=0; i<m_connections.size(); ++i) {
|
||||||
ServerConnection &c = m_connections[i];
|
ServerConnection &c = m_connections[i];
|
||||||
scheduler->unregisterWorker(c.worker);
|
scheduler->unregisterWorker(c.worker);
|
||||||
|
@ -259,10 +260,52 @@ MainWindow::~MainWindow() {
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::initWorkers() {
|
bool MainWindow::initWorkersProcessArgv() {
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
ref<Scheduler> scheduler = Scheduler::getInstance();
|
QStringList args = qApp->arguments(), toBeLoaded;
|
||||||
int localWorkerCount = settings.value("localWorkers", getCoreCount()).toInt();
|
int localWorkerCount = settings.value("localWorkers", getCoreCount()).toInt();
|
||||||
|
ref<Scheduler> scheduler = Scheduler::getInstance();
|
||||||
|
|
||||||
|
for (int i=1; i<args.count(); ++i) {
|
||||||
|
if (args[i].startsWith("-D")) {
|
||||||
|
QString value = args[i].mid(2);
|
||||||
|
if (value.length() == 0 && i+1<args.count())
|
||||||
|
value = args[++i];
|
||||||
|
QStringList list = value.split("=");
|
||||||
|
if (list.length() == 2)
|
||||||
|
m_parameters[list[0].toStdString()] = list[1].toStdString();
|
||||||
|
} else if (args[i].startsWith("-a")) {
|
||||||
|
ref<FileResolver> resolver = Thread::getThread()->getFileResolver();
|
||||||
|
QString value = args[i].mid(2);
|
||||||
|
if (value.length() == 0 && i+1<args.count())
|
||||||
|
value = args[++i];
|
||||||
|
resolver->appendPath(value.toStdString());
|
||||||
|
} else if (args[i].startsWith("-p")) {
|
||||||
|
QString value = args[i].mid(2);
|
||||||
|
if (value.length() == 0 && i+1<args.count())
|
||||||
|
value = args[++i];
|
||||||
|
bool ok = false;
|
||||||
|
unsigned int numCores = value.toUInt(&ok, 10);
|
||||||
|
if (ok)
|
||||||
|
localWorkerCount = numCores;
|
||||||
|
} else if (args[i] == "-h") {
|
||||||
|
cout << "Mitsuba version " << Version(MTS_VERSION).toStringComplete()
|
||||||
|
<< ", Copyright (c) " MTS_YEAR " Wenzel Jakob" << endl;
|
||||||
|
cout << "Usage: mtsgui [options] <One or more scene XML files>" << endl;
|
||||||
|
cout << "Options/Arguments:" << endl;
|
||||||
|
cout << " -h Display this help text" << endl << endl;
|
||||||
|
cout << " -D key=val Define a constant, which can referenced as \"$key\" in the scene" << endl << endl;
|
||||||
|
cout << " -a p1;p2;.. Add one or more entries to the resource search path" << endl << endl;
|
||||||
|
cout << " -p count Override the detected number of processors." << endl << endl;
|
||||||
|
cout << " For documentation, please refer to http://www.mitsuba-renderer.org/docs.html" << endl;
|
||||||
|
return false;
|
||||||
|
} else if (args[i].startsWith("-")) {
|
||||||
|
cerr << "Unknown option \"" << args[i].toStdString() << "\"" << endl;
|
||||||
|
} else {
|
||||||
|
toBeLoaded.append(args[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
m_workerPriority = (Thread::EThreadPriority)
|
m_workerPriority = (Thread::EThreadPriority)
|
||||||
settings.value("workerPriority", (int) Thread::ELowPriority).toInt();
|
settings.value("workerPriority", (int) Thread::ELowPriority).toInt();
|
||||||
for (int i=0; i<localWorkerCount; ++i)
|
for (int i=0; i<localWorkerCount; ++i)
|
||||||
|
@ -317,22 +360,12 @@ void MainWindow::initWorkers() {
|
||||||
scheduler->registerWorker(new LocalWorker(0, formatString("wrk%i", localWorkerCtr++), m_workerPriority));
|
scheduler->registerWorker(new LocalWorker(0, formatString("wrk%i", localWorkerCtr++), m_workerPriority));
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList args = qApp->arguments();
|
for (int i=0; i<toBeLoaded.size(); ++i)
|
||||||
for (int i=1; i<args.count(); ++i) {
|
loadFile(toBeLoaded[i]);
|
||||||
if (args[i].startsWith("-D")) {
|
|
||||||
QString value = args[i].mid(2);
|
|
||||||
if (value.length() == 0 && i+1<args.count())
|
|
||||||
value = args[++i];
|
|
||||||
QStringList list = value.split("=");
|
|
||||||
if (list.length() == 2)
|
|
||||||
m_parameters[list[0].toStdString()] = list[1].toStdString();
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
loadFile(args[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
scheduler->start();
|
scheduler->start();
|
||||||
raise();
|
raise();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -120,7 +120,7 @@ public:
|
||||||
void loadFile(QString filename);
|
void loadFile(QString filename);
|
||||||
void adjustSize();
|
void adjustSize();
|
||||||
bool isActive();
|
bool isActive();
|
||||||
void initWorkers();
|
bool initWorkersProcessArgv();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
SceneContext *loadScene(const QString &filename);
|
SceneContext *loadScene(const QString &filename);
|
||||||
|
|
Loading…
Reference in New Issue