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
|
||||
${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
|
||||
${ZLIB_LIBRARIES} ${LZO_LIB} ${PLAT_LIBS} ${BOO_SYS_LIBS})
|
||||
|
||||
|
|
|
@ -63,6 +63,7 @@ protected:
|
|||
hecl::Printf(_S("\n" BLUE BOLD "Continue?" NORMAL " (Y/n) "));
|
||||
else
|
||||
hecl::Printf(_S("\nContinue? (Y/n) "));
|
||||
fflush(stdout);
|
||||
|
||||
int ch;
|
||||
#ifndef _WIN32
|
||||
|
@ -269,9 +270,27 @@ static hecl::SystemString MakePathArgAbsolute(const hecl::SystemString& arg,
|
|||
#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,
|
||||
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();
|
||||
|
||||
bool blocks = factor >= 0.0;
|
||||
|
@ -297,17 +316,17 @@ void ToolPrintProgress(const hecl::SystemChar* message, const hecl::SystemChar*
|
|||
|
||||
if (!message)
|
||||
message = _S("");
|
||||
size_t messageLen = hecl::StrLen(message);
|
||||
int messageLen = hecl::StrLen(message);
|
||||
if (!submessage)
|
||||
submessage = _S("");
|
||||
size_t submessageLen = hecl::StrLen(submessage);
|
||||
int submessageLen = hecl::StrLen(submessage);
|
||||
if (half - messageLen < submessageLen-2)
|
||||
submessageLen = 0;
|
||||
|
||||
if (submessageLen)
|
||||
{
|
||||
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
|
||||
{
|
||||
hecl::Printf(_S("%s"), message);
|
||||
|
@ -332,9 +351,9 @@ void ToolPrintProgress(const hecl::SystemChar* message, const hecl::SystemChar*
|
|||
{
|
||||
if (XTERM_COLOR)
|
||||
{
|
||||
size_t blocks = half - 7;
|
||||
size_t filled = blocks * factor;
|
||||
size_t rem = blocks - filled;
|
||||
int blocks = half - 7;
|
||||
int filled = blocks * factor;
|
||||
int rem = blocks - filled;
|
||||
hecl::Printf(_S("" BOLD "%3d%% ["), iFactor);
|
||||
for (int b=0 ; b<filled ; ++b)
|
||||
hecl::Printf(_S("#"));
|
||||
|
@ -344,9 +363,9 @@ void ToolPrintProgress(const hecl::SystemChar* message, const hecl::SystemChar*
|
|||
}
|
||||
else
|
||||
{
|
||||
size_t blocks = half - 7;
|
||||
size_t filled = blocks * factor;
|
||||
size_t rem = blocks - filled;
|
||||
int blocks = half - 7;
|
||||
int filled = blocks * factor;
|
||||
int rem = blocks - filled;
|
||||
hecl::Printf(_S("%3d%% ["), iFactor);
|
||||
for (int b=0 ; b<filled ; ++b)
|
||||
hecl::Printf(_S("#"));
|
||||
|
|
|
@ -65,6 +65,7 @@ static const hecl::SystemRegex regOPEN(_S("-o([^\"]*|\\S*)"), std::regex::ECMASc
|
|||
static void SIGINTHandler(int sig)
|
||||
{
|
||||
hecl::blender::Connection::Shutdown();
|
||||
logvisor::KillProcessTree();
|
||||
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
|
||||
Connection.cpp
|
||||
Connection.cpp
|
||||
HMDL.cpp)
|
||||
|
||||
hecl_add_list(Blender BLENDER_SOURCES)
|
||||
|
|
|
@ -278,7 +278,6 @@ Connection::Connection(int verbosityLevel)
|
|||
int installAttempt = 0;
|
||||
while (true)
|
||||
{
|
||||
|
||||
/* Construct communication pipes */
|
||||
#if _WIN32
|
||||
_pipe(m_readpipe, 2048, _O_BINARY);
|
||||
|
@ -1648,7 +1647,7 @@ Action::Action(Connection& conn)
|
|||
subtypeAABBs.reserve(aabbCount);
|
||||
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.back().first.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)
|
||||
endif()
|
||||
|
||||
add_library(hecl-common
|
||||
${BLENDER_SOURCES}
|
||||
set(HECL_HEADERS
|
||||
../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}
|
||||
${FRONTEND_SOURCES}
|
||||
${RUNTIME_SOURCES}
|
||||
hecl.cpp
|
||||
Project.cpp
|
||||
ProjectPath.cpp
|
||||
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
|
||||
${BLENDER_SOURCES}
|
||||
${COMMON_SOURCES}
|
||||
${HECL_HEADERS}
|
||||
${PLAT_SRCS})
|
||||
add_library(hecl-light
|
||||
${RUNTIME_SOURCES}
|
||||
${COMMON_SOURCES}
|
||||
${HECL_HEADERS}
|
||||
${PLAT_SRCS})
|
||||
|
||||
if(COMMAND add_sanitizers)
|
||||
add_sanitizers(hecl-common)
|
||||
endif()
|
||||
if(COMMAND cotire)
|
||||
set_target_properties(hecl-common PROPERTIES COTIRE_ADD_UNITY_BUILD FALSE)
|
||||
cotire(hecl-common)
|
||||
add_sanitizers(hecl-full)
|
||||
add_sanitizers(hecl-light)
|
||||
endif()
|
||||
|
||||
if(WINDOWS_STORE)
|
||||
set_property(TARGET hecl-common PROPERTY VS_WINRT_COMPONENT TRUE)
|
||||
set_property(TARGET hecl-full PROPERTY VS_WINRT_COMPONENT TRUE)
|
||||
endif()
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
namespace hecl
|
||||
{
|
||||
static logvisor::Module Log("hecl-wsconv");
|
||||
|
||||
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);
|
||||
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;
|
||||
}
|
||||
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);
|
||||
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;
|
||||
}
|
||||
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);
|
||||
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;
|
||||
}
|
||||
buf += len;
|
||||
|
@ -71,7 +72,7 @@ std::u16string UTF8ToChar16(std::string_view src)
|
|||
utf8proc_ssize_t len = utf8proc_iterate(buf, -1, &wc);
|
||||
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;
|
||||
}
|
||||
buf += len;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
add_executable(heclTest WIN32 main.cpp)
|
||||
target_link_libraries(heclTest
|
||||
hecl-common hecl-blender-addon athena-core athena-libyaml xxhash
|
||||
logvisor boo ${ZLIB_LIBRARIES} ${LZO_LIB} ${BOO_SYS_LIBS})
|
||||
hecl-full hecl-blender-addon
|
||||
athena-core athena-libyaml xxhash logvisor boo
|
||||
${ZLIB_LIBRARIES} ${LZO_LIB} ${BOO_SYS_LIBS})
|
||||
|
|
Loading…
Reference in New Issue