Add -j argument for hecl cooking

This commit is contained in:
Jack Andersen 2019-02-03 14:01:12 -10:00
parent f35285b076
commit 23a6d66a8c
5 changed files with 52 additions and 5 deletions

View File

@ -192,8 +192,15 @@ int main(int argc, const char** argv)
}
/* Iterate flags */
bool threadArg = false;
for (auto it = args.cbegin(); it != args.cend();) {
const hecl::SystemString& arg = *it;
if (threadArg) {
threadArg = false;
hecl::CpuCountOverride = int(hecl::StrToUl(arg.c_str(), nullptr, 0));
it = args.erase(it);
continue;
}
if (arg.size() < 2 || arg[0] != _SYS_STR('-') || arg[1] == _SYS_STR('-')) {
++it;
continue;
@ -208,6 +215,14 @@ int main(int argc, const char** argv)
info.yes = true;
else if (*chit == _SYS_STR('g'))
info.gui = true;
else if (*chit == _SYS_STR('j')) {
++chit;
if (*chit)
hecl::CpuCountOverride = int(hecl::StrToUl(&*chit, nullptr, 0));
else
threadArg = true;
break;
}
else
info.flags.push_back(*chit);
}

2
hecl/extern/boo vendored

@ -1 +1 @@
Subproject commit 9658d1372d36220c2ff94242109bdfb7531fefa6
Subproject commit 2135f4e4dc6ee7fa5a2b6398b97632dc5af9c822

View File

@ -11,6 +11,9 @@
namespace hecl {
extern int CpuCountOverride;
void SetCpuCountOverride(int argc, const SystemChar** argv);
class ClientProcess {
std::mutex m_mutex;
std::condition_variable m_cv;

View File

@ -67,11 +67,12 @@ public:
std::string makeVert() const {
return m_backend.makeVert(m_tag.getColorCount(), m_tag.getUvCount(), m_tag.getWeightCount(),
m_tag.getSkinSlotCount(), m_extension.texCount, m_extension.texs,
m_tag.getReflectionType());
m_extension.noReflection ? Backend::ReflectionType::None : m_tag.getReflectionType());
}
std::string makeFrag() const {
return m_backend.makeFrag(m_extension.blockCount, m_extension.blockNames,
m_tag.getAlphaTest() || m_extension.forceAlphaTest, m_tag.getReflectionType(),
m_tag.getAlphaTest() || m_extension.forceAlphaTest,
m_extension.noReflection ? Backend::ReflectionType::None : m_tag.getReflectionType(),
m_backend.m_blendSrc, m_backend.m_blendDst, m_extension.lighting, m_extension.post,
m_extension.texCount, m_extension.texs);
}

View File

@ -3,6 +3,7 @@
#include "athena/FileReader.hpp"
#include "hecl/Blender/Connection.hpp"
#include "hecl/MultiProgressPrinter.hpp"
#include "boo/IApplication.hpp"
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
@ -18,14 +19,41 @@ static logvisor::Module CP_Log("hecl::ClientProcess");
ThreadLocalPtr<ClientProcess::Worker> ClientProcess::ThreadWorker;
int CpuCountOverride = 0;
void SetCpuCountOverride(int argc, const SystemChar** argv) {
bool threadArg = false;
for (int i = 1; i < argc; ++i) {
if (threadArg) {
if (int count = int(hecl::StrToUl(argv[i], nullptr, 0))) {
CpuCountOverride = count;
return;
}
}
if (!hecl::StrNCmp(argv[i], _SYS_STR("-j"), 2)) {
if (int count = int(hecl::StrToUl(argv[i] + 2, nullptr, 0))) {
CpuCountOverride = count;
return;
}
threadArg = true;
}
}
}
static int GetCPUCount() {
int ret;
#if _WIN32
SYSTEM_INFO sysinfo;
GetSystemInfo(&sysinfo);
return sysinfo.dwNumberOfProcessors;
ret = sysinfo.dwNumberOfProcessors;
#else
return sysconf(_SC_NPROCESSORS_ONLN);
ret = sysconf(_SC_NPROCESSORS_ONLN);
#endif
if (CpuCountOverride)
return std::min(CpuCountOverride, ret);
return ret;
}
void ClientProcess::BufferTransaction::run(blender::Token& btok) {