mirror of https://github.com/AxioDL/metaforce.git
Add CVarCommons; hecl-light library
This commit is contained in:
parent
9b23877654
commit
2d0f079991
|
@ -23,7 +23,7 @@ endif()
|
||||||
|
|
||||||
target_link_libraries(hecl
|
target_link_libraries(hecl
|
||||||
${DATA_SPEC_LIBS}
|
${DATA_SPEC_LIBS}
|
||||||
hecl-common hecl-blender-addon athena-core nod
|
hecl-full hecl-blender-addon athena-core nod
|
||||||
logvisor athena-libyaml ${PNG_LIB} squish xxhash zeus boo
|
logvisor athena-libyaml ${PNG_LIB} squish xxhash zeus boo
|
||||||
${ZLIB_LIBRARIES} ${LZO_LIB} ${PLAT_LIBS} ${BOO_SYS_LIBS})
|
${ZLIB_LIBRARIES} ${LZO_LIB} ${PLAT_LIBS} ${BOO_SYS_LIBS})
|
||||||
|
|
||||||
|
|
|
@ -63,6 +63,7 @@ protected:
|
||||||
hecl::Printf(_S("\n" BLUE BOLD "Continue?" NORMAL " (Y/n) "));
|
hecl::Printf(_S("\n" BLUE BOLD "Continue?" NORMAL " (Y/n) "));
|
||||||
else
|
else
|
||||||
hecl::Printf(_S("\nContinue? (Y/n) "));
|
hecl::Printf(_S("\nContinue? (Y/n) "));
|
||||||
|
fflush(stdout);
|
||||||
|
|
||||||
int ch;
|
int ch;
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
|
@ -269,9 +270,27 @@ static hecl::SystemString MakePathArgAbsolute(const hecl::SystemString& arg,
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool g_HasLastProgTime = false;
|
||||||
|
static std::chrono::steady_clock::time_point g_LastProgTime;
|
||||||
|
|
||||||
void ToolPrintProgress(const hecl::SystemChar* message, const hecl::SystemChar* submessage,
|
void ToolPrintProgress(const hecl::SystemChar* message, const hecl::SystemChar* submessage,
|
||||||
int lidx, float factor, int& lineIdx)
|
int lidx, float factor, int& lineIdx)
|
||||||
{
|
{
|
||||||
|
if (g_HasLastProgTime)
|
||||||
|
{
|
||||||
|
std::chrono::steady_clock::time_point newPoint = std::chrono::steady_clock::now();
|
||||||
|
std::chrono::milliseconds::rep delta =
|
||||||
|
std::chrono::duration_cast<std::chrono::milliseconds>(newPoint - g_LastProgTime).count();
|
||||||
|
if (delta < 50)
|
||||||
|
return;
|
||||||
|
g_LastProgTime = newPoint;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g_HasLastProgTime = true;
|
||||||
|
g_LastProgTime = std::chrono::steady_clock::now();
|
||||||
|
}
|
||||||
|
|
||||||
auto lk = logvisor::LockLog();
|
auto lk = logvisor::LockLog();
|
||||||
|
|
||||||
bool blocks = factor >= 0.0;
|
bool blocks = factor >= 0.0;
|
||||||
|
@ -297,17 +316,17 @@ void ToolPrintProgress(const hecl::SystemChar* message, const hecl::SystemChar*
|
||||||
|
|
||||||
if (!message)
|
if (!message)
|
||||||
message = _S("");
|
message = _S("");
|
||||||
size_t messageLen = hecl::StrLen(message);
|
int messageLen = hecl::StrLen(message);
|
||||||
if (!submessage)
|
if (!submessage)
|
||||||
submessage = _S("");
|
submessage = _S("");
|
||||||
size_t submessageLen = hecl::StrLen(submessage);
|
int submessageLen = hecl::StrLen(submessage);
|
||||||
if (half - messageLen < submessageLen-2)
|
if (half - messageLen < submessageLen-2)
|
||||||
submessageLen = 0;
|
submessageLen = 0;
|
||||||
|
|
||||||
if (submessageLen)
|
if (submessageLen)
|
||||||
{
|
{
|
||||||
if (messageLen > half-submessageLen-1)
|
if (messageLen > half-submessageLen-1)
|
||||||
hecl::Printf(_S("%.*s... %s "), half-int(submessageLen)-4, message, submessage);
|
hecl::Printf(_S("%.*s... %s "), half-submessageLen-4, message, submessage);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
hecl::Printf(_S("%s"), message);
|
hecl::Printf(_S("%s"), message);
|
||||||
|
@ -332,9 +351,9 @@ void ToolPrintProgress(const hecl::SystemChar* message, const hecl::SystemChar*
|
||||||
{
|
{
|
||||||
if (XTERM_COLOR)
|
if (XTERM_COLOR)
|
||||||
{
|
{
|
||||||
size_t blocks = half - 7;
|
int blocks = half - 7;
|
||||||
size_t filled = blocks * factor;
|
int filled = blocks * factor;
|
||||||
size_t rem = blocks - filled;
|
int rem = blocks - filled;
|
||||||
hecl::Printf(_S("" BOLD "%3d%% ["), iFactor);
|
hecl::Printf(_S("" BOLD "%3d%% ["), iFactor);
|
||||||
for (int b=0 ; b<filled ; ++b)
|
for (int b=0 ; b<filled ; ++b)
|
||||||
hecl::Printf(_S("#"));
|
hecl::Printf(_S("#"));
|
||||||
|
@ -344,9 +363,9 @@ void ToolPrintProgress(const hecl::SystemChar* message, const hecl::SystemChar*
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
size_t blocks = half - 7;
|
int blocks = half - 7;
|
||||||
size_t filled = blocks * factor;
|
int filled = blocks * factor;
|
||||||
size_t rem = blocks - filled;
|
int rem = blocks - filled;
|
||||||
hecl::Printf(_S("%3d%% ["), iFactor);
|
hecl::Printf(_S("%3d%% ["), iFactor);
|
||||||
for (int b=0 ; b<filled ; ++b)
|
for (int b=0 ; b<filled ; ++b)
|
||||||
hecl::Printf(_S("#"));
|
hecl::Printf(_S("#"));
|
||||||
|
|
|
@ -65,6 +65,7 @@ static const hecl::SystemRegex regOPEN(_S("-o([^\"]*|\\S*)"), std::regex::ECMASc
|
||||||
static void SIGINTHandler(int sig)
|
static void SIGINTHandler(int sig)
|
||||||
{
|
{
|
||||||
hecl::blender::Connection::Shutdown();
|
hecl::blender::Connection::Shutdown();
|
||||||
|
logvisor::KillProcessTree();
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 872ab3900df9c3e39909c9fd26a02930698a73f8
|
Subproject commit 4257fc0b10a71d4661ab12dd035397ea74d31213
|
|
@ -0,0 +1,80 @@
|
||||||
|
#ifndef CVARCOMMONS_HPP
|
||||||
|
#define CVARCOMMONS_HPP
|
||||||
|
|
||||||
|
#include "CVarManager.hpp"
|
||||||
|
|
||||||
|
#undef min
|
||||||
|
#undef max
|
||||||
|
|
||||||
|
namespace hecl
|
||||||
|
{
|
||||||
|
|
||||||
|
using namespace std::literals;
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#define DEFAULT_GRAPHICS_API "D3D11"sv
|
||||||
|
#elif defined(__APPLE__)
|
||||||
|
#define DEFAULT_GRAPHICS_API "Metal"sv
|
||||||
|
#else
|
||||||
|
#define DEFAULT_GRAPHICS_API "OpenGL"sv
|
||||||
|
#endif
|
||||||
|
|
||||||
|
class CVarCommons
|
||||||
|
{
|
||||||
|
CVarManager& m_mgr;
|
||||||
|
CVar* m_graphicsApi;
|
||||||
|
CVar* m_drawSamples;
|
||||||
|
CVar* m_texAnisotropy;
|
||||||
|
public:
|
||||||
|
CVarCommons(CVarManager& manager) : m_mgr(manager)
|
||||||
|
{
|
||||||
|
m_graphicsApi = m_mgr.findOrMakeCVar("graphicsApi"sv,
|
||||||
|
"API to use for rendering graphics"sv,
|
||||||
|
DEFAULT_GRAPHICS_API, hecl::CVar::EFlags::System | hecl::CVar::EFlags::Archive);
|
||||||
|
m_drawSamples = m_mgr.findOrMakeCVar("drawSamples"sv,
|
||||||
|
"Number of MSAA samples to use for render targets"sv,
|
||||||
|
1, hecl::CVar::EFlags::System | hecl::CVar::EFlags::Archive);
|
||||||
|
m_texAnisotropy = m_mgr.findOrMakeCVar("texAnisotropy"sv,
|
||||||
|
"Number of anisotropic samples to use for sampling textures"sv,
|
||||||
|
1, hecl::CVar::EFlags::System | hecl::CVar::EFlags::Archive);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string getGraphicsApi() const
|
||||||
|
{
|
||||||
|
return m_graphicsApi->toLiteral();
|
||||||
|
}
|
||||||
|
|
||||||
|
void setGraphicsApi(std::string_view api)
|
||||||
|
{
|
||||||
|
m_graphicsApi->fromLiteral(api);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t getSamples() const
|
||||||
|
{
|
||||||
|
return uint32_t(std::max(1, m_drawSamples->toInteger()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void setSamples(uint32_t v)
|
||||||
|
{
|
||||||
|
m_drawSamples->fromInteger(std::max(uint32_t(1), v));
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t getAnisotropy() const
|
||||||
|
{
|
||||||
|
return uint32_t(std::max(1, m_texAnisotropy->toInteger()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void setAnisotropy(uint32_t v) const
|
||||||
|
{
|
||||||
|
m_texAnisotropy->fromInteger(std::max(uint32_t(1), v));
|
||||||
|
}
|
||||||
|
|
||||||
|
void serialize()
|
||||||
|
{
|
||||||
|
m_mgr.serialize();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // CVARCOMMONS_HPP
|
|
@ -1,5 +1,5 @@
|
||||||
set(BLENDER_SOURCES
|
set(BLENDER_SOURCES
|
||||||
Connection.cpp
|
Connection.cpp
|
||||||
HMDL.cpp)
|
HMDL.cpp)
|
||||||
|
|
||||||
hecl_add_list(Blender BLENDER_SOURCES)
|
hecl_add_list(Blender BLENDER_SOURCES)
|
||||||
|
|
|
@ -278,7 +278,6 @@ Connection::Connection(int verbosityLevel)
|
||||||
int installAttempt = 0;
|
int installAttempt = 0;
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
|
|
||||||
/* Construct communication pipes */
|
/* Construct communication pipes */
|
||||||
#if _WIN32
|
#if _WIN32
|
||||||
_pipe(m_readpipe, 2048, _O_BINARY);
|
_pipe(m_readpipe, 2048, _O_BINARY);
|
||||||
|
@ -1648,7 +1647,7 @@ Action::Action(Connection& conn)
|
||||||
subtypeAABBs.reserve(aabbCount);
|
subtypeAABBs.reserve(aabbCount);
|
||||||
for (uint32_t i=0 ; i<aabbCount ; ++i)
|
for (uint32_t i=0 ; i<aabbCount ; ++i)
|
||||||
{
|
{
|
||||||
printf("AABB %s %d\n", name.c_str(), i);
|
//printf("AABB %s %d\n", name.c_str(), i);
|
||||||
subtypeAABBs.emplace_back();
|
subtypeAABBs.emplace_back();
|
||||||
subtypeAABBs.back().first.read(conn);
|
subtypeAABBs.back().first.read(conn);
|
||||||
subtypeAABBs.back().second.read(conn);
|
subtypeAABBs.back().second.read(conn);
|
||||||
|
|
|
@ -24,56 +24,65 @@ if("${CMAKE_BUILD_TYPE}" STREQUAL "Release" OR "${CMAKE_BUILD_TYPE}" STREQUAL "R
|
||||||
add_definitions(-DHECL_MULTIPROCESSOR)
|
add_definitions(-DHECL_MULTIPROCESSOR)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_library(hecl-common
|
set(HECL_HEADERS
|
||||||
${BLENDER_SOURCES}
|
../include/hecl/CVar.hpp
|
||||||
|
../include/hecl/CVarManager.hpp
|
||||||
|
../include/hecl/CVarCommons.hpp
|
||||||
|
../include/hecl/hecl.hpp
|
||||||
|
../include/hecl/FourCC.hpp
|
||||||
|
../include/hecl/HMDLMeta.hpp
|
||||||
|
../include/hecl/Backend/Backend.hpp
|
||||||
|
../include/hecl/Backend/GX.hpp
|
||||||
|
../include/hecl/Backend/ProgrammableCommon.hpp
|
||||||
|
../include/hecl/Backend/GLSL.hpp
|
||||||
|
../include/hecl/Backend/HLSL.hpp
|
||||||
|
../include/hecl/Backend/Metal.hpp
|
||||||
|
../include/hecl/Blender/Connection.hpp
|
||||||
|
../include/hecl/Blender/Token.hpp
|
||||||
|
../include/hecl/SteamFinder.hpp
|
||||||
|
../include/hecl/Frontend.hpp
|
||||||
|
../include/hecl/Database.hpp
|
||||||
|
../include/hecl/Runtime.hpp
|
||||||
|
../include/hecl/ClientProcess.hpp
|
||||||
|
../include/hecl/SystemChar.hpp
|
||||||
|
../include/hecl/BitVector.hpp
|
||||||
|
../include/hecl/MathExtras.hpp
|
||||||
|
../include/hecl/UniformBufferPool.hpp
|
||||||
|
../include/hecl/VertexBufferPool.hpp)
|
||||||
|
set(COMMON_SOURCES
|
||||||
|
hecl.cpp
|
||||||
|
Project.cpp
|
||||||
|
ProjectPath.cpp
|
||||||
|
HumanizeNumber.cpp
|
||||||
|
CVar.cpp
|
||||||
|
CVarManager.cpp
|
||||||
|
ClientProcess.cpp
|
||||||
|
SteamFinder.cpp
|
||||||
|
WideStringConvert.cpp
|
||||||
|
atdna_HMDLMeta.cpp
|
||||||
|
atdna_Frontend.cpp
|
||||||
|
atdna_Runtime.cpp
|
||||||
|
atdna_CVar.cpp)
|
||||||
|
|
||||||
|
add_library(hecl-full
|
||||||
${BACKEND_SOURCES}
|
${BACKEND_SOURCES}
|
||||||
${FRONTEND_SOURCES}
|
${FRONTEND_SOURCES}
|
||||||
${RUNTIME_SOURCES}
|
${RUNTIME_SOURCES}
|
||||||
hecl.cpp
|
${BLENDER_SOURCES}
|
||||||
Project.cpp
|
${COMMON_SOURCES}
|
||||||
ProjectPath.cpp
|
${HECL_HEADERS}
|
||||||
WideStringConvert.cpp
|
|
||||||
HumanizeNumber.cpp
|
|
||||||
CVar.cpp
|
|
||||||
CVarManager.cpp
|
|
||||||
../include/hecl/CVar.hpp
|
|
||||||
../include/hecl/CVarManager.hpp
|
|
||||||
../include/hecl/hecl.hpp
|
|
||||||
../include/hecl/FourCC.hpp
|
|
||||||
../include/hecl/HMDLMeta.hpp
|
|
||||||
../include/hecl/Backend/Backend.hpp
|
|
||||||
../include/hecl/Backend/GX.hpp
|
|
||||||
../include/hecl/Backend/ProgrammableCommon.hpp
|
|
||||||
../include/hecl/Backend/GLSL.hpp
|
|
||||||
../include/hecl/Backend/HLSL.hpp
|
|
||||||
../include/hecl/Backend/Metal.hpp
|
|
||||||
../include/hecl/Blender/Connection.hpp
|
|
||||||
../include/hecl/Blender/Token.hpp
|
|
||||||
../include/hecl/SteamFinder.hpp
|
|
||||||
../include/hecl/Frontend.hpp
|
|
||||||
../include/hecl/Database.hpp
|
|
||||||
../include/hecl/Runtime.hpp
|
|
||||||
../include/hecl/ClientProcess.hpp
|
|
||||||
../include/hecl/SystemChar.hpp
|
|
||||||
../include/hecl/BitVector.hpp
|
|
||||||
../include/hecl/MathExtras.hpp
|
|
||||||
../include/hecl/UniformBufferPool.hpp
|
|
||||||
../include/hecl/VertexBufferPool.hpp
|
|
||||||
SteamFinder.cpp
|
|
||||||
ClientProcess.cpp
|
|
||||||
atdna_HMDLMeta.cpp
|
|
||||||
atdna_Frontend.cpp
|
|
||||||
atdna_Runtime.cpp
|
|
||||||
atdna_CVar.cpp
|
|
||||||
${PLAT_SRCS})
|
${PLAT_SRCS})
|
||||||
|
add_library(hecl-light
|
||||||
|
${RUNTIME_SOURCES}
|
||||||
|
${COMMON_SOURCES}
|
||||||
|
${HECL_HEADERS}
|
||||||
|
${PLAT_SRCS})
|
||||||
|
|
||||||
if(COMMAND add_sanitizers)
|
if(COMMAND add_sanitizers)
|
||||||
add_sanitizers(hecl-common)
|
add_sanitizers(hecl-full)
|
||||||
endif()
|
add_sanitizers(hecl-light)
|
||||||
if(COMMAND cotire)
|
|
||||||
set_target_properties(hecl-common PROPERTIES COTIRE_ADD_UNITY_BUILD FALSE)
|
|
||||||
cotire(hecl-common)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(WINDOWS_STORE)
|
if(WINDOWS_STORE)
|
||||||
set_property(TARGET hecl-common PROPERTY VS_WINRT_COMPONENT TRUE)
|
set_property(TARGET hecl-full PROPERTY VS_WINRT_COMPONENT TRUE)
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
namespace hecl
|
namespace hecl
|
||||||
{
|
{
|
||||||
|
static logvisor::Module Log("hecl-wsconv");
|
||||||
|
|
||||||
std::string WideToUTF8(std::wstring_view src)
|
std::string WideToUTF8(std::wstring_view src)
|
||||||
{
|
{
|
||||||
|
@ -14,7 +15,7 @@ std::string WideToUTF8(std::wstring_view src)
|
||||||
utf8proc_ssize_t c = utf8proc_encode_char(utf8proc_int32_t(ch), mb);
|
utf8proc_ssize_t c = utf8proc_encode_char(utf8proc_int32_t(ch), mb);
|
||||||
if (c < 0)
|
if (c < 0)
|
||||||
{
|
{
|
||||||
LogModule.report(logvisor::Warning, "invalid UTF-8 character while encoding");
|
Log.report(logvisor::Warning, "invalid UTF-8 character while encoding");
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
retval.append(reinterpret_cast<char*>(mb), c);
|
retval.append(reinterpret_cast<char*>(mb), c);
|
||||||
|
@ -32,7 +33,7 @@ std::string Char16ToUTF8(std::u16string_view src)
|
||||||
utf8proc_ssize_t c = utf8proc_encode_char(utf8proc_int32_t(ch), mb);
|
utf8proc_ssize_t c = utf8proc_encode_char(utf8proc_int32_t(ch), mb);
|
||||||
if (c < 0)
|
if (c < 0)
|
||||||
{
|
{
|
||||||
LogModule.report(logvisor::Warning, "invalid UTF-8 character while encoding");
|
Log.report(logvisor::Warning, "invalid UTF-8 character while encoding");
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
retval.append(reinterpret_cast<char*>(mb), c);
|
retval.append(reinterpret_cast<char*>(mb), c);
|
||||||
|
@ -51,7 +52,7 @@ std::wstring UTF8ToWide(std::string_view src)
|
||||||
utf8proc_ssize_t len = utf8proc_iterate(buf, -1, &wc);
|
utf8proc_ssize_t len = utf8proc_iterate(buf, -1, &wc);
|
||||||
if (len < 0)
|
if (len < 0)
|
||||||
{
|
{
|
||||||
LogModule.report(logvisor::Warning, "invalid UTF-8 character while decoding");
|
Log.report(logvisor::Warning, "invalid UTF-8 character while decoding");
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
buf += len;
|
buf += len;
|
||||||
|
@ -71,7 +72,7 @@ std::u16string UTF8ToChar16(std::string_view src)
|
||||||
utf8proc_ssize_t len = utf8proc_iterate(buf, -1, &wc);
|
utf8proc_ssize_t len = utf8proc_iterate(buf, -1, &wc);
|
||||||
if (len < 0)
|
if (len < 0)
|
||||||
{
|
{
|
||||||
LogModule.report(logvisor::Warning, "invalid UTF-8 character while decoding");
|
Log.report(logvisor::Warning, "invalid UTF-8 character while decoding");
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
buf += len;
|
buf += len;
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
add_executable(heclTest WIN32 main.cpp)
|
add_executable(heclTest WIN32 main.cpp)
|
||||||
target_link_libraries(heclTest
|
target_link_libraries(heclTest
|
||||||
hecl-common hecl-blender-addon athena-core athena-libyaml xxhash
|
hecl-full hecl-blender-addon
|
||||||
logvisor boo ${ZLIB_LIBRARIES} ${LZO_LIB} ${BOO_SYS_LIBS})
|
athena-core athena-libyaml xxhash logvisor boo
|
||||||
|
${ZLIB_LIBRARIES} ${LZO_LIB} ${BOO_SYS_LIBS})
|
||||||
|
|
Loading…
Reference in New Issue