mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-16 22:30:42 +02:00
use general worker threads for fbx baking
This commit is contained in:
parent
c9024f5e87
commit
88b8fb4c5e
6 changed files with 6 additions and 31 deletions
|
@ -397,6 +397,7 @@ void FBXBaker::rewriteAndBakeSceneModels() {
|
|||
for (int i = 0; (i + 2) < part.quadTrianglesIndices.size(); i += 3) {
|
||||
addFace(part.quadTrianglesIndices, i, face++);
|
||||
}
|
||||
|
||||
for (int i = 0; (i + 2) < part.triangleIndices.size(); i += 3) {
|
||||
addFace(part.triangleIndices, i, face++);
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ void BakerCLI::bakeFile(QUrl inputUrl, const QString outputPath) {
|
|||
// create our appropiate baker
|
||||
if (isFBX) {
|
||||
_baker = std::unique_ptr<Baker> { new FBXBaker(inputUrl, []() -> QThread* { return qApp->getNextWorkerThread(); }, outputPath) };
|
||||
_baker->moveToThread(qApp->getFBXBakerThread());
|
||||
_baker->moveToThread(qApp->getNextWorkerThread());
|
||||
} else if (isSupportedImage) {
|
||||
_baker = std::unique_ptr<Baker> { new TextureBaker(inputUrl, image::TextureUsage::CUBE_TEXTURE, outputPath) };
|
||||
_baker->moveToThread(qApp->getNextWorkerThread());
|
||||
|
@ -61,4 +61,4 @@ void BakerCLI::bakeFile(QUrl inputUrl, const QString outputPath) {
|
|||
void BakerCLI::handleFinishedBaker() {
|
||||
qCDebug(model_baking) << "Finished baking file.";
|
||||
QApplication::exit(_baker.get()->hasErrors());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -214,7 +214,7 @@ void DomainBaker::enumerateEntities() {
|
|||
|
||||
// move the baker to the baker thread
|
||||
// and kickoff the bake
|
||||
baker->moveToThread(qApp->getFBXBakerThread());
|
||||
baker->moveToThread(qApp->getNextWorkerThread());
|
||||
QMetaObject::invokeMethod(baker.data(), "bake");
|
||||
|
||||
// keep track of the total number of baking entities
|
||||
|
|
|
@ -51,11 +51,7 @@ Oven::Oven(int argc, char* argv[]) :
|
|||
image::setCubeTexturesCompressionEnabled(true);
|
||||
|
||||
// setup our worker threads
|
||||
setupWorkerThreads(QThread::idealThreadCount() - 1);
|
||||
|
||||
// Autodesk's SDK means that we need a single thread for all FBX importing/exporting in the same process
|
||||
// setup the FBX Baker thread
|
||||
setupFBXBakerThread();
|
||||
setupWorkerThreads(QThread::idealThreadCount());
|
||||
|
||||
// check if we were passed any command line arguments that would tell us just to run without the GUI
|
||||
if (parser.isSet(CLI_INPUT_PARAMETER) || parser.isSet(CLI_OUTPUT_PARAMETER)) {
|
||||
|
@ -81,10 +77,6 @@ Oven::~Oven() {
|
|||
_workerThreads[i]->quit();
|
||||
_workerThreads[i]->wait();
|
||||
}
|
||||
|
||||
// cleanup the FBX Baker thread
|
||||
_fbxBakerThread->quit();
|
||||
_fbxBakerThread->wait();
|
||||
}
|
||||
|
||||
void Oven::setupWorkerThreads(int numWorkerThreads) {
|
||||
|
@ -97,22 +89,6 @@ void Oven::setupWorkerThreads(int numWorkerThreads) {
|
|||
}
|
||||
}
|
||||
|
||||
void Oven::setupFBXBakerThread() {
|
||||
// we're being asked for the FBX baker thread, but we don't have one yet
|
||||
// so set that up now
|
||||
_fbxBakerThread = new QThread(this);
|
||||
_fbxBakerThread->setObjectName("Oven FBX Baker Thread");
|
||||
}
|
||||
|
||||
QThread* Oven::getFBXBakerThread() {
|
||||
if (!_fbxBakerThread->isRunning()) {
|
||||
// start the FBX baker thread if it isn't running yet
|
||||
_fbxBakerThread->start();
|
||||
}
|
||||
|
||||
return _fbxBakerThread;
|
||||
}
|
||||
|
||||
QThread* Oven::getNextWorkerThread() {
|
||||
// Here we replicate some of the functionality of QThreadPool by giving callers an available worker thread to use.
|
||||
// We can't use QThreadPool because we want to put QObjects with signals/slots on these threads.
|
||||
|
|
|
@ -34,7 +34,6 @@ public:
|
|||
|
||||
OvenMainWindow* getMainWindow() const { return _mainWindow; }
|
||||
|
||||
QThread* getFBXBakerThread();
|
||||
QThread* getNextWorkerThread();
|
||||
|
||||
private:
|
||||
|
@ -42,7 +41,6 @@ private:
|
|||
void setupFBXBakerThread();
|
||||
|
||||
OvenMainWindow* _mainWindow;
|
||||
QThread* _fbxBakerThread;
|
||||
QList<QThread*> _workerThreads;
|
||||
|
||||
std::atomic<uint> _nextWorkerThreadIndex;
|
||||
|
|
|
@ -201,7 +201,7 @@ void ModelBakeWidget::bakeButtonClicked() {
|
|||
};
|
||||
|
||||
// move the baker to the FBX baker thread
|
||||
baker->moveToThread(qApp->getFBXBakerThread());
|
||||
baker->moveToThread(qApp->getNextWorkerThread());
|
||||
|
||||
// invoke the bake method on the baker thread
|
||||
QMetaObject::invokeMethod(baker.get(), "bake");
|
||||
|
|
Loading…
Reference in a new issue