From ff7f8a1542c8291fc8f67de6241c5c802e39bc2e Mon Sep 17 00:00:00 2001 From: Eric Wasylishen Date: Mon, 23 Aug 2021 00:10:11 -0600 Subject: [PATCH] qbsp: add -nothreads debug option --- include/qbsp/qbsp.hh | 4 +++- qbsp/qbsp.cc | 12 ++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/include/qbsp/qbsp.hh b/include/qbsp/qbsp.hh index eff7c070..502b25c4 100644 --- a/include/qbsp/qbsp.hh +++ b/include/qbsp/qbsp.hh @@ -391,6 +391,7 @@ public: bool fLeakTest; bool fContentHack; vec_t worldExtent; + bool fNoThreads; options_t() : fNofill(false), @@ -432,7 +433,8 @@ public: fTestExpand(false), fLeakTest(false), fContentHack(false), - worldExtent(65536.0f) {} + worldExtent(65536.0f), + fNoThreads(false) {} }; extern options_t options; diff --git a/qbsp/qbsp.cc b/qbsp/qbsp.cc index 875968f9..33abd4cd 100644 --- a/qbsp/qbsp.cc +++ b/qbsp/qbsp.cc @@ -19,12 +19,15 @@ See file, 'COPYING', for details. */ +#include #include #include #include #include +#include "tbb/global_control.h" + static const char *IntroString = "---- qbsp / ericw-tools " stringify(ERICWTOOLS_VERSION) " ----\n"; @@ -714,6 +717,7 @@ PrintOptions(void) " -expand Write hull 1 expanded brushes to expanded.map for debugging\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" + " -nothreads Disable multithreading\n" " sourcefile .MAP file to process\n" " destfile .BSP file to output\n"); @@ -944,6 +948,8 @@ ParseOptions(char *szOptions) options.fLeakTest = true; } else if (!Q_strcasecmp(szTok, "contenthack")) { options.fContentHack = true; + } else if (!Q_strcasecmp(szTok, "nothreads")) { + options.fNoThreads = true; } else if (!Q_strcasecmp(szTok, "?") || !Q_strcasecmp(szTok, "help")) PrintOptions(); else @@ -1064,6 +1070,12 @@ int qbsp_main(int argc, const char **argv) InitQBSP(argc, argv); + // disable TBB if requested + auto tbbOptions = std::unique_ptr(); + if (options.fNoThreads) { + tbbOptions = std::make_unique(tbb::global_control::max_allowed_parallelism, 1); + } + // do it! start = I_FloatTime(); ProcessFile();