qbsp: replace `-nothreads` with `-threads 1` for consistency with light/vis
This commit is contained in:
parent
e0981b356b
commit
8531286777
|
|
@ -25,4 +25,4 @@ add_library(common STATIC
|
||||||
${CMAKE_SOURCE_DIR}/include/common/fs.hh
|
${CMAKE_SOURCE_DIR}/include/common/fs.hh
|
||||||
${CMAKE_SOURCE_DIR}/include/common/imglib.hh)
|
${CMAKE_SOURCE_DIR}/include/common/imglib.hh)
|
||||||
|
|
||||||
target_link_libraries(common ${CMAKE_THREAD_LIBS_INIT} fmt::fmt nlohmann_json::nlohmann_json)
|
target_link_libraries(common ${CMAKE_THREAD_LIBS_INIT} TBB::tbb fmt::fmt nlohmann_json::nlohmann_json)
|
||||||
|
|
|
||||||
|
|
@ -169,3 +169,20 @@ void RunThreadsOn(int start, int workcnt, void *(func)(void *), void *arg)
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* HAVE_THREADS */
|
#endif /* HAVE_THREADS */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* =======================================================================
|
||||||
|
* TBB
|
||||||
|
* =======================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
std::unique_ptr<tbb::global_control> ConfigureTBB(int maxthreads)
|
||||||
|
{
|
||||||
|
auto tbbOptions = std::unique_ptr<tbb::global_control>();
|
||||||
|
|
||||||
|
if (maxthreads > 0) {
|
||||||
|
tbbOptions = std::make_unique<tbb::global_control>(tbb::global_control::max_allowed_parallelism, maxthreads);
|
||||||
|
}
|
||||||
|
|
||||||
|
return tbbOptions;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,10 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
#include "tbb/global_control.h"
|
||||||
|
|
||||||
extern int numthreads;
|
extern int numthreads;
|
||||||
|
|
||||||
void LowerProcessPriority(void);
|
void LowerProcessPriority(void);
|
||||||
|
|
@ -15,3 +19,10 @@ void ThreadUnlock(void);
|
||||||
|
|
||||||
/* Call if needing to print to stdout - should be called with lock held */
|
/* Call if needing to print to stdout - should be called with lock held */
|
||||||
void InterruptThreadProgress__(void);
|
void InterruptThreadProgress__(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configures TBB to have the given max threads (specify 0 for unlimited).
|
||||||
|
*
|
||||||
|
* Call this from main() and keep the returned object until main() finishes.
|
||||||
|
*/
|
||||||
|
std::unique_ptr<tbb::global_control> ConfigureTBB(int maxthreads);
|
||||||
|
|
|
||||||
|
|
@ -117,7 +117,7 @@ public:
|
||||||
bool fLeakTest = false;
|
bool fLeakTest = false;
|
||||||
bool fContentHack = false;
|
bool fContentHack = false;
|
||||||
vec_t worldExtent = 0.f;
|
vec_t worldExtent = 0.f;
|
||||||
bool fNoThreads = false;
|
int threads = 0; // 0 = let TBB auto select ideal number of threads
|
||||||
bool includeSkip = false;
|
bool includeSkip = false;
|
||||||
bool fNoTJunc = false;
|
bool fNoTJunc = false;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
16
qbsp/qbsp.cc
16
qbsp/qbsp.cc
|
|
@ -26,6 +26,7 @@
|
||||||
#include <common/log.hh>
|
#include <common/log.hh>
|
||||||
#include <common/aabb.hh>
|
#include <common/aabb.hh>
|
||||||
#include <common/fs.hh>
|
#include <common/fs.hh>
|
||||||
|
#include <common/threads.hh>
|
||||||
#include <qbsp/qbsp.hh>
|
#include <qbsp/qbsp.hh>
|
||||||
#include <qbsp/wad.hh>
|
#include <qbsp/wad.hh>
|
||||||
#include <fmt/chrono.h>
|
#include <fmt/chrono.h>
|
||||||
|
|
@ -1059,7 +1060,7 @@ PrintOptions
|
||||||
" -expand Write hull 1 expanded brushes to expanded.map for debugging\n"
|
" -expand Write hull 1 expanded brushes to expanded.map for debugging\n"
|
||||||
" -leaktest Make compilation fail if the map leaks\n"
|
" -leaktest Make compilation fail if the map leaks\n"
|
||||||
" -contenthack Hack to fix leaks through solids. Causes missing faces in some cases so disabled by default.\n"
|
" -contenthack Hack to fix leaks through solids. Causes missing faces in some cases so disabled by default.\n"
|
||||||
" -nothreads Disable multithreading\n"
|
" -threads n Set the number of threads (1 to disable multithreading)\n"
|
||||||
" sourcefile .MAP file to process\n"
|
" sourcefile .MAP file to process\n"
|
||||||
" destfile .BSP file to output\n");
|
" destfile .BSP file to output\n");
|
||||||
|
|
||||||
|
|
@ -1295,8 +1296,11 @@ static void ParseOptions(char *szOptions)
|
||||||
options.fLeakTest = true;
|
options.fLeakTest = true;
|
||||||
} else if (!Q_strcasecmp(szTok, "contenthack")) {
|
} else if (!Q_strcasecmp(szTok, "contenthack")) {
|
||||||
options.fContentHack = true;
|
options.fContentHack = true;
|
||||||
} else if (!Q_strcasecmp(szTok, "nothreads")) {
|
} else if (!Q_strcasecmp(szTok, "threads")) {
|
||||||
options.fNoThreads = true;
|
szTok2 = GetTok(szTok + strlen(szTok) + 1, szEnd);
|
||||||
|
if (!szTok2)
|
||||||
|
FError("Invalid argument to option {}", szTok);
|
||||||
|
options.threads = atoi(szTok2);
|
||||||
} else if (!Q_strcasecmp(szTok, "?") || !Q_strcasecmp(szTok, "help")) {
|
} else if (!Q_strcasecmp(szTok, "?") || !Q_strcasecmp(szTok, "help")) {
|
||||||
PrintOptions();
|
PrintOptions();
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -1421,11 +1425,7 @@ int qbsp_main(int argc, const char **argv)
|
||||||
|
|
||||||
InitQBSP(argc, argv);
|
InitQBSP(argc, argv);
|
||||||
|
|
||||||
// disable TBB if requested
|
auto tbbOptions = ConfigureTBB(options.threads);
|
||||||
auto tbbOptions = std::unique_ptr<tbb::global_control>();
|
|
||||||
if (options.fNoThreads) {
|
|
||||||
tbbOptions = std::make_unique<tbb::global_control>(tbb::global_control::max_allowed_parallelism, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// do it!
|
// do it!
|
||||||
auto start = I_FloatTime();
|
auto start = I_FloatTime();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue