Humungous refactor

This commit is contained in:
Jack Andersen 2016-03-04 13:02:44 -10:00
parent 2a7ae959fa
commit 31fa668e78
62 changed files with 782 additions and 782 deletions

View File

@ -15,21 +15,21 @@ endif()
configure_file(DataSpecRegistry.hpp.in ${CMAKE_CURRENT_SOURCE_DIR}/DataSpecRegistry.hpp @ONLY) configure_file(DataSpecRegistry.hpp.in ${CMAKE_CURRENT_SOURCE_DIR}/DataSpecRegistry.hpp @ONLY)
set(ATHENA_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/extern/Athena/include) set(ATHENA_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/extern/athena/include)
set(ATHENA_INCLUDE_DIR ${ATHENA_INCLUDE_DIR} PARENT_SCOPE) set(ATHENA_INCLUDE_DIR ${ATHENA_INCLUDE_DIR} PARENT_SCOPE)
set(SQUISH_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/extern/libSquish) set(SQUISH_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/extern/libSquish)
set(SQUISH_INCLUDE_DIR ${SQUISH_INCLUDE_DIR} PARENT_SCOPE) set(SQUISH_INCLUDE_DIR ${SQUISH_INCLUDE_DIR} PARENT_SCOPE)
set(BOO_INCLUDE_DIR extern/libBoo/include) set(BOO_INCLUDE_DIR extern/boo/include)
add_subdirectory(bintoc) add_subdirectory(bintoc)
add_subdirectory(extern) add_subdirectory(extern)
add_definitions(${BOO_SYS_DEFINES}) add_definitions(${BOO_SYS_DEFINES})
include_directories(include ${LOG_VISOR_INCLUDE_DIR} ${ATHENA_INCLUDE_DIR} ${BOO_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR}) include_directories(include ${LOGVISOR_INCLUDE_DIR} ${ATHENA_INCLUDE_DIR} ${BOO_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR})
add_subdirectory(lib) add_subdirectory(lib)
add_subdirectory(blender) add_subdirectory(blender)
add_subdirectory(driver) add_subdirectory(driver)
install(DIRECTORY include/HECL DESTINATION include/HECL) install(DIRECTORY include/hecl DESTINATION include/hecl)
# Runtime test # Runtime test
add_subdirectory(test) add_subdirectory(test)

View File

@ -6,9 +6,9 @@
#endif #endif
#define DATA_SPEC_REGISTRY_HPP #define DATA_SPEC_REGISTRY_HPP
#include "HECL/Database.hpp" #include "hecl/Database.hpp"
namespace HECL namespace hecl
{ {
namespace Database namespace Database
{ {

View File

@ -7,9 +7,9 @@
#include <string> #include <string>
#include <algorithm> #include <algorithm>
#include <HECL/HECL.hpp> #include <hecl/hecl.hpp>
#include <HECL/Database.hpp> #include <hecl/Database.hpp>
#include <LogVisor/LogVisor.hpp> #include "logvisor/logvisor.hpp"
#include "BlenderConnection.hpp" #include "BlenderConnection.hpp"
#if _WIN32 #if _WIN32
@ -30,10 +30,10 @@ template <> struct hash<std::pair<uint32_t,uint32_t>>
}; };
} }
namespace HECL namespace hecl
{ {
LogVisor::LogModule BlenderLog("BlenderConnection"); logvisor::Module BlenderLog("BlenderConnection");
BlenderConnection* SharedBlenderConnection = nullptr; BlenderConnection* SharedBlenderConnection = nullptr;
#ifdef __APPLE__ #ifdef __APPLE__
@ -53,18 +53,18 @@ extern "C" size_t HECL_STARTUP_SZ;
static void InstallBlendershell(const SystemChar* path) static void InstallBlendershell(const SystemChar* path)
{ {
FILE* fp = HECL::Fopen(path, _S("w")); FILE* fp = hecl::Fopen(path, _S("w"));
if (!fp) if (!fp)
BlenderLog.report(LogVisor::FatalError, _S("unable to open %s for writing"), path); BlenderLog.report(logvisor::Fatal, _S("unable to open %s for writing"), path);
fwrite(HECL_BLENDERSHELL, 1, HECL_BLENDERSHELL_SZ, fp); fwrite(HECL_BLENDERSHELL, 1, HECL_BLENDERSHELL_SZ, fp);
fclose(fp); fclose(fp);
} }
static void InstallAddon(const SystemChar* path) static void InstallAddon(const SystemChar* path)
{ {
FILE* fp = HECL::Fopen(path, _S("wb")); FILE* fp = hecl::Fopen(path, _S("wb"));
if (!fp) if (!fp)
BlenderLog.report(LogVisor::FatalError, _S("Unable to install blender addon at '%s'"), path); BlenderLog.report(logvisor::Fatal, _S("Unable to install blender addon at '%s'"), path);
fwrite(HECL_ADDON, 1, HECL_ADDON_SZ, fp); fwrite(HECL_ADDON, 1, HECL_ADDON_SZ, fp);
fclose(fp); fclose(fp);
} }
@ -73,7 +73,7 @@ static void InstallStartup(const char* path)
{ {
FILE* fp = fopen(path, "wb"); FILE* fp = fopen(path, "wb");
if (!fp) if (!fp)
BlenderLog.report(LogVisor::FatalError, "Unable to place hecl_startup.blend at '%s'", path); BlenderLog.report(logvisor::Fatal, "Unable to place hecl_startup.blend at '%s'", path);
fwrite(HECL_STARTUP, 1, HECL_STARTUP_SZ, fp); fwrite(HECL_STARTUP, 1, HECL_STARTUP_SZ, fp);
fclose(fp); fclose(fp);
} }
@ -85,14 +85,14 @@ size_t BlenderConnection::_readLine(char* buf, size_t bufSz)
{ {
if (readBytes >= bufSz) if (readBytes >= bufSz)
{ {
BlenderLog.report(LogVisor::FatalError, "Pipe buffer overrun"); BlenderLog.report(logvisor::Fatal, "Pipe buffer overrun");
*(buf-1) = '\0'; *(buf-1) = '\0';
return bufSz - 1; return bufSz - 1;
} }
int ret = read(m_readpipe[0], buf, 1); int ret = read(m_readpipe[0], buf, 1);
if (ret < 0) if (ret < 0)
{ {
BlenderLog.report(LogVisor::FatalError, strerror(errno)); BlenderLog.report(logvisor::Fatal, strerror(errno));
return 0; return 0;
} }
else if (ret == 1) else if (ret == 1)
@ -102,7 +102,7 @@ size_t BlenderConnection::_readLine(char* buf, size_t bufSz)
*buf = '\0'; *buf = '\0';
if (readBytes >= 4) if (readBytes >= 4)
if (!memcmp(buf, "EXCEPTION", std::min(readBytes, size_t(9)))) if (!memcmp(buf, "EXCEPTION", std::min(readBytes, size_t(9))))
BlenderLog.report(LogVisor::FatalError, "Blender exception"); BlenderLog.report(logvisor::Fatal, "Blender exception");
return readBytes; return readBytes;
} }
++readBytes; ++readBytes;
@ -113,7 +113,7 @@ size_t BlenderConnection::_readLine(char* buf, size_t bufSz)
*buf = '\0'; *buf = '\0';
if (readBytes >= 4) if (readBytes >= 4)
if (!memcmp(buf, "EXCEPTION", std::min(readBytes, size_t(9)))) if (!memcmp(buf, "EXCEPTION", std::min(readBytes, size_t(9))))
BlenderLog.report(LogVisor::FatalError, "Blender exception"); BlenderLog.report(logvisor::Fatal, "Blender exception");
return readBytes; return readBytes;
} }
} }
@ -130,7 +130,7 @@ size_t BlenderConnection::_writeLine(const char* buf)
goto err; goto err;
return (size_t)ret; return (size_t)ret;
err: err:
BlenderLog.report(LogVisor::FatalError, strerror(errno)); BlenderLog.report(logvisor::Fatal, strerror(errno));
return 0; return 0;
} }
@ -141,10 +141,10 @@ size_t BlenderConnection::_readBuf(void* buf, size_t len)
goto err; goto err;
if (len >= 4) if (len >= 4)
if (!memcmp((char*)buf, "EXCEPTION", std::min(len, size_t(9)))) if (!memcmp((char*)buf, "EXCEPTION", std::min(len, size_t(9))))
BlenderLog.report(LogVisor::FatalError, "Blender exception"); BlenderLog.report(logvisor::Fatal, "Blender exception");
return ret; return ret;
err: err:
BlenderLog.report(LogVisor::FatalError, strerror(errno)); BlenderLog.report(logvisor::Fatal, strerror(errno));
return 0; return 0;
} }
@ -155,7 +155,7 @@ size_t BlenderConnection::_writeBuf(const void* buf, size_t len)
goto err; goto err;
return ret; return ret;
err: err:
BlenderLog.report(LogVisor::FatalError, strerror(errno)); BlenderLog.report(logvisor::Fatal, strerror(errno));
return 0; return 0;
} }
@ -167,25 +167,25 @@ void BlenderConnection::_closePipe()
BlenderConnection::BlenderConnection(int verbosityLevel) BlenderConnection::BlenderConnection(int verbosityLevel)
{ {
BlenderLog.report(LogVisor::Info, "Establishing BlenderConnection..."); BlenderLog.report(logvisor::Info, "Establishing BlenderConnection...");
/* Put hecl_blendershell.py in temp dir */ /* Put hecl_blendershell.py in temp dir */
#ifdef _WIN32 #ifdef _WIN32
wchar_t* TMPDIR = _wgetenv(L"TEMP"); wchar_t* TMPDIR = _wgetenv(L"TEMP");
if (!TMPDIR) if (!TMPDIR)
TMPDIR = (wchar_t*)L"\\Temp"; TMPDIR = (wchar_t*)L"\\Temp";
m_startupBlend = HECL::WideToUTF8(TMPDIR); m_startupBlend = hecl::WideToUTF8(TMPDIR);
#else #else
char* TMPDIR = getenv("TMPDIR"); char* TMPDIR = getenv("TMPDIR");
if (!TMPDIR) if (!TMPDIR)
TMPDIR = (char*)"/tmp"; TMPDIR = (char*)"/tmp";
m_startupBlend = TMPDIR; m_startupBlend = TMPDIR;
#endif #endif
HECL::SystemString blenderShellPath(TMPDIR); hecl::SystemString blenderShellPath(TMPDIR);
blenderShellPath += _S("/hecl_blendershell.py"); blenderShellPath += _S("/hecl_blendershell.py");
InstallBlendershell(blenderShellPath.c_str()); InstallBlendershell(blenderShellPath.c_str());
HECL::SystemString blenderAddonPath(TMPDIR); hecl::SystemString blenderAddonPath(TMPDIR);
blenderAddonPath += _S("/hecl_blenderaddon.zip"); blenderAddonPath += _S("/hecl_blenderaddon.zip");
InstallAddon(blenderAddonPath.c_str()); InstallAddon(blenderAddonPath.c_str());
@ -224,7 +224,7 @@ BlenderConnection::BlenderConnection(int verbosityLevel)
/* Environment not set; use default */ /* Environment not set; use default */
wchar_t progFiles[256]; wchar_t progFiles[256];
if (!GetEnvironmentVariableW(L"ProgramFiles", progFiles, 256)) if (!GetEnvironmentVariableW(L"ProgramFiles", progFiles, 256))
BlenderLog.report(LogVisor::FatalError, L"unable to determine 'Program Files' path"); BlenderLog.report(logvisor::Fatal, L"unable to determine 'Program Files' path");
_snwprintf(BLENDER_BIN_BUF, 2048, L"%s\\Blender Foundation\\Blender\\blender.exe", progFiles); _snwprintf(BLENDER_BIN_BUF, 2048, L"%s\\Blender Foundation\\Blender\\blender.exe", progFiles);
blenderBin = BLENDER_BIN_BUF; blenderBin = BLENDER_BIN_BUF;
} }
@ -251,7 +251,7 @@ BlenderConnection::BlenderConnection(int verbosityLevel)
LPWSTR messageBuffer = nullptr; LPWSTR messageBuffer = nullptr;
size_t size = FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, size_t size = FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPWSTR)&messageBuffer, 0, NULL); NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPWSTR)&messageBuffer, 0, NULL);
BlenderLog.report(LogVisor::FatalError, L"unable to launch blender from %s: %s", blenderBin, messageBuffer); BlenderLog.report(logvisor::Fatal, L"unable to launch blender from %s: %s", blenderBin, messageBuffer);
} }
close(m_writepipe[0]); close(m_writepipe[0]);
@ -323,16 +323,16 @@ BlenderConnection::BlenderConnection(int verbosityLevel)
if (!strcmp(lineBuf, "NOLAUNCH")) if (!strcmp(lineBuf, "NOLAUNCH"))
{ {
_closePipe(); _closePipe();
BlenderLog.report(LogVisor::FatalError, "Unable to launch blender"); BlenderLog.report(logvisor::Fatal, "Unable to launch blender");
} }
else if (!strcmp(lineBuf, "NOBLENDER")) else if (!strcmp(lineBuf, "NOBLENDER"))
{ {
_closePipe(); _closePipe();
if (blenderBin) if (blenderBin)
BlenderLog.report(LogVisor::FatalError, _S("Unable to find blender at '%s' or '%s'"), BlenderLog.report(logvisor::Fatal, _S("Unable to find blender at '%s' or '%s'"),
blenderBin, DEFAULT_BLENDER_BIN); blenderBin, DEFAULT_BLENDER_BIN);
else else
BlenderLog.report(LogVisor::FatalError, _S("Unable to find blender at '%s'"), BlenderLog.report(logvisor::Fatal, _S("Unable to find blender at '%s'"),
DEFAULT_BLENDER_BIN); DEFAULT_BLENDER_BIN);
} }
else if (!strcmp(lineBuf, "NOADDON")) else if (!strcmp(lineBuf, "NOADDON"))
@ -341,7 +341,7 @@ BlenderConnection::BlenderConnection(int verbosityLevel)
InstallAddon(blenderAddonPath.c_str()); InstallAddon(blenderAddonPath.c_str());
++installAttempt; ++installAttempt;
if (installAttempt >= 2) if (installAttempt >= 2)
BlenderLog.report(LogVisor::FatalError, _S("unable to install blender addon using '%s'"), blenderAddonPath.c_str()); BlenderLog.report(logvisor::Fatal, _S("unable to install blender addon using '%s'"), blenderAddonPath.c_str());
continue; continue;
} }
else if (!strcmp(lineBuf, "ADDONINSTALLED")) else if (!strcmp(lineBuf, "ADDONINSTALLED"))
@ -353,7 +353,7 @@ BlenderConnection::BlenderConnection(int verbosityLevel)
else if (strcmp(lineBuf, "READY")) else if (strcmp(lineBuf, "READY"))
{ {
_closePipe(); _closePipe();
BlenderLog.report(LogVisor::FatalError, "read '%s' from blender; expected 'READY'", lineBuf); BlenderLog.report(logvisor::Fatal, "read '%s' from blender; expected 'READY'", lineBuf);
} }
_writeLine("ACK"); _writeLine("ACK");
@ -383,7 +383,7 @@ bool BlenderConnection::createBlend(const ProjectPath& path, BlendType type)
{ {
if (m_lock) if (m_lock)
{ {
BlenderLog.report(LogVisor::FatalError, BlenderLog.report(logvisor::Fatal,
"BlenderConnection::createBlend() musn't be called with stream active"); "BlenderConnection::createBlend() musn't be called with stream active");
return false; return false;
} }
@ -403,7 +403,7 @@ bool BlenderConnection::openBlend(const ProjectPath& path, bool force)
{ {
if (m_lock) if (m_lock)
{ {
BlenderLog.report(LogVisor::FatalError, BlenderLog.report(logvisor::Fatal,
"BlenderConnection::openBlend() musn't be called with stream active"); "BlenderConnection::openBlend() musn't be called with stream active");
return false; return false;
} }
@ -437,7 +437,7 @@ bool BlenderConnection::saveBlend()
{ {
if (m_lock) if (m_lock)
{ {
BlenderLog.report(LogVisor::FatalError, BlenderLog.report(logvisor::Fatal,
"BlenderConnection::saveBlend() musn't be called with stream active"); "BlenderConnection::saveBlend() musn't be called with stream active");
return false; return false;
} }
@ -453,8 +453,8 @@ void BlenderConnection::deleteBlend()
{ {
if (m_loadedBlend) if (m_loadedBlend)
{ {
HECL::Unlink(m_loadedBlend.getAbsolutePath().c_str()); hecl::Unlink(m_loadedBlend.getAbsolutePath().c_str());
BlenderLog.report(LogVisor::Info, _S("Deleted '%s'"), m_loadedBlend.getAbsolutePath().c_str()); BlenderLog.report(logvisor::Info, _S("Deleted '%s'"), m_loadedBlend.getAbsolutePath().c_str());
m_loadedBlend = ProjectPath(); m_loadedBlend = ProjectPath();
} }
} }
@ -534,7 +534,7 @@ BlenderConnection::DataStream::Mesh::Mesh
conn._readBuf(&colorLayerCount, 4); conn._readBuf(&colorLayerCount, 4);
if (colorLayerCount > 4) if (colorLayerCount > 4)
LogModule.report(LogVisor::FatalError, "mesh has %u color-layers; max 4", colorLayerCount); LogModule.report(logvisor::Fatal, "mesh has %u color-layers; max 4", colorLayerCount);
conn._readBuf(&count, 4); conn._readBuf(&count, 4);
color.reserve(count); color.reserve(count);
for (uint32_t i=0 ; i<count ; ++i) for (uint32_t i=0 ; i<count ; ++i)
@ -542,7 +542,7 @@ BlenderConnection::DataStream::Mesh::Mesh
conn._readBuf(&uvLayerCount, 4); conn._readBuf(&uvLayerCount, 4);
if (uvLayerCount > 8) if (uvLayerCount > 8)
LogModule.report(LogVisor::FatalError, "mesh has %u UV-layers; max 8", uvLayerCount); LogModule.report(logvisor::Fatal, "mesh has %u UV-layers; max 8", uvLayerCount);
conn._readBuf(&count, 4); conn._readBuf(&count, 4);
uv.reserve(count); uv.reserve(count);
for (uint32_t i=0 ; i<count ; ++i) for (uint32_t i=0 ; i<count ; ++i)

View File

@ -20,15 +20,15 @@
#include <iostream> #include <iostream>
#include <unordered_map> #include <unordered_map>
#include "HECL/HECL.hpp" #include "hecl/hecl.hpp"
#include "HECL/HMDLMeta.hpp" #include "hecl/HMDLMeta.hpp"
#include <Athena/Types.hpp> #include <athena/Types.hpp>
#include <Athena/MemoryWriter.hpp> #include <athena/MemoryWriter.hpp>
namespace HECL namespace hecl
{ {
extern LogVisor::LogModule BlenderLog; extern logvisor::Module BlenderLog;
extern class BlenderConnection* SharedBlenderConnection; extern class BlenderConnection* SharedBlenderConnection;
class HMDLBuffers; class HMDLBuffers;
@ -97,7 +97,7 @@ public:
int_type overflow(int_type ch) int_type overflow(int_type ch)
{ {
if (!m_parent.m_parent || !m_parent.m_parent->m_lock) if (!m_parent.m_parent || !m_parent.m_parent->m_lock)
BlenderLog.report(LogVisor::FatalError, "lock not held for PyOutStream writing"); BlenderLog.report(logvisor::Fatal, "lock not held for PyOutStream writing");
if (ch != traits_type::eof() && ch != '\n' && ch != '\0') if (ch != traits_type::eof() && ch != '\n' && ch != '\0')
{ {
m_lineBuf += char_type(ch); m_lineBuf += char_type(ch);
@ -111,7 +111,7 @@ public:
{ {
if (m_deleteOnError) if (m_deleteOnError)
m_parent.m_parent->deleteBlend(); m_parent.m_parent->deleteBlend();
BlenderLog.report(LogVisor::FatalError, "error sending '%s' to blender", m_lineBuf.c_str()); BlenderLog.report(logvisor::Fatal, "error sending '%s' to blender", m_lineBuf.c_str());
} }
m_lineBuf.clear(); m_lineBuf.clear();
return ch; return ch;
@ -128,7 +128,7 @@ public:
char readBuf[16]; char readBuf[16];
m_parent->_readLine(readBuf, 16); m_parent->_readLine(readBuf, 16);
if (strcmp(readBuf, "READY")) if (strcmp(readBuf, "READY"))
BlenderLog.report(LogVisor::FatalError, "unable to open PyOutStream with blender"); BlenderLog.report(logvisor::Fatal, "unable to open PyOutStream with blender");
} }
public: public:
PyOutStream(const PyOutStream& other) = delete; PyOutStream(const PyOutStream& other) = delete;
@ -144,7 +144,7 @@ public:
char readBuf[16]; char readBuf[16];
m_parent->_readLine(readBuf, 16); m_parent->_readLine(readBuf, 16);
if (strcmp(readBuf, "DONE")) if (strcmp(readBuf, "DONE"))
BlenderLog.report(LogVisor::FatalError, "unable to close PyOutStream with blender"); BlenderLog.report(logvisor::Fatal, "unable to close PyOutStream with blender");
m_parent->m_lock = false; m_parent->m_lock = false;
} }
} }
@ -154,7 +154,7 @@ public:
void format(const char* fmt, ...) void format(const char* fmt, ...)
{ {
if (!m_parent || !m_parent->m_lock) if (!m_parent || !m_parent->m_lock)
BlenderLog.report(LogVisor::FatalError, "lock not held for PyOutStream::format()"); BlenderLog.report(logvisor::Fatal, "lock not held for PyOutStream::format()");
va_list ap; va_list ap;
va_start(ap, fmt); va_start(ap, fmt);
char* result = nullptr; char* result = nullptr;
@ -236,7 +236,7 @@ public:
char readBuf[16]; char readBuf[16];
m_parent->_readLine(readBuf, 16); m_parent->_readLine(readBuf, 16);
if (strcmp(readBuf, "ANIMREADY")) if (strcmp(readBuf, "ANIMREADY"))
BlenderLog.report(LogVisor::FatalError, "unable to open ANIMOutStream"); BlenderLog.report(logvisor::Fatal, "unable to open ANIMOutStream");
} }
~ANIMOutStream() ~ANIMOutStream()
{ {
@ -245,12 +245,12 @@ public:
char readBuf[16]; char readBuf[16];
m_parent->_readLine(readBuf, 16); m_parent->_readLine(readBuf, 16);
if (strcmp(readBuf, "ANIMDONE")) if (strcmp(readBuf, "ANIMDONE"))
BlenderLog.report(LogVisor::FatalError, "unable to close ANIMOutStream"); BlenderLog.report(logvisor::Fatal, "unable to close ANIMOutStream");
} }
void changeCurve(CurveType type, unsigned crvIdx, unsigned keyCount) void changeCurve(CurveType type, unsigned crvIdx, unsigned keyCount)
{ {
if (m_curCount != m_totalCount) if (m_curCount != m_totalCount)
BlenderLog.report(LogVisor::FatalError, "incomplete ANIMOutStream for change"); BlenderLog.report(logvisor::Fatal, "incomplete ANIMOutStream for change");
m_curCount = 0; m_curCount = 0;
m_totalCount = keyCount; m_totalCount = keyCount;
char tp = char(type); char tp = char(type);
@ -266,7 +266,7 @@ public:
void write(unsigned frame, float val) void write(unsigned frame, float val)
{ {
if (!m_inCurve) if (!m_inCurve)
BlenderLog.report(LogVisor::FatalError, "changeCurve not called before write"); BlenderLog.report(logvisor::Fatal, "changeCurve not called before write");
if (m_curCount < m_totalCount) if (m_curCount < m_totalCount)
{ {
struct struct
@ -278,7 +278,7 @@ public:
++m_curCount; ++m_curCount;
} }
else else
BlenderLog.report(LogVisor::FatalError, "ANIMOutStream keyCount overflow"); BlenderLog.report(logvisor::Fatal, "ANIMOutStream keyCount overflow");
} }
}; };
ANIMOutStream beginANIMCurve() ANIMOutStream beginANIMCurve()
@ -289,7 +289,7 @@ public:
PyOutStream beginPythonOut(bool deleteOnError=false) PyOutStream beginPythonOut(bool deleteOnError=false)
{ {
if (m_lock) if (m_lock)
BlenderLog.report(LogVisor::FatalError, "lock already held for BlenderConnection::beginPythonOut()"); BlenderLog.report(logvisor::Fatal, "lock already held for BlenderConnection::beginPythonOut()");
return PyOutStream(this, deleteOnError); return PyOutStream(this, deleteOnError);
} }
@ -305,7 +305,7 @@ public:
char readBuf[16]; char readBuf[16];
m_parent->_readLine(readBuf, 16); m_parent->_readLine(readBuf, 16);
if (strcmp(readBuf, "READY")) if (strcmp(readBuf, "READY"))
BlenderLog.report(LogVisor::FatalError, "unable to open DataStream with blender"); BlenderLog.report(logvisor::Fatal, "unable to open DataStream with blender");
} }
public: public:
DataStream(const DataStream& other) = delete; DataStream(const DataStream& other) = delete;
@ -320,7 +320,7 @@ public:
char readBuf[16]; char readBuf[16];
m_parent->_readLine(readBuf, 16); m_parent->_readLine(readBuf, 16);
if (strcmp(readBuf, "DONE")) if (strcmp(readBuf, "DONE"))
BlenderLog.report(LogVisor::FatalError, "unable to close DataStream with blender"); BlenderLog.report(logvisor::Fatal, "unable to close DataStream with blender");
m_parent->m_lock = false; m_parent->m_lock = false;
} }
} }
@ -532,7 +532,7 @@ public:
Mesh::SurfProgFunc surfProg=[](int){}) Mesh::SurfProgFunc surfProg=[](int){})
{ {
if (m_parent->m_loadedType != BlendType::Mesh) if (m_parent->m_loadedType != BlendType::Mesh)
BlenderLog.report(LogVisor::FatalError, _S("%s is not a MESH blend"), BlenderLog.report(logvisor::Fatal, _S("%s is not a MESH blend"),
m_parent->m_loadedBlend.getAbsolutePath().c_str()); m_parent->m_loadedBlend.getAbsolutePath().c_str());
char req[128]; char req[128];
@ -543,7 +543,7 @@ public:
char readBuf[256]; char readBuf[256];
m_parent->_readLine(readBuf, 256); m_parent->_readLine(readBuf, 256);
if (strcmp(readBuf, "OK")) if (strcmp(readBuf, "OK"))
BlenderLog.report(LogVisor::FatalError, "unable to cook mesh: %s", readBuf); BlenderLog.report(logvisor::Fatal, "unable to cook mesh: %s", readBuf);
return Mesh(*m_parent, topology, skinSlotCount, surfProg); return Mesh(*m_parent, topology, skinSlotCount, surfProg);
} }
@ -553,7 +553,7 @@ public:
Mesh::SurfProgFunc surfProg=[](int){}) Mesh::SurfProgFunc surfProg=[](int){})
{ {
if (m_parent->m_loadedType != BlendType::Area) if (m_parent->m_loadedType != BlendType::Area)
BlenderLog.report(LogVisor::FatalError, _S("%s is not an AREA blend"), BlenderLog.report(logvisor::Fatal, _S("%s is not an AREA blend"),
m_parent->m_loadedBlend.getAbsolutePath().c_str()); m_parent->m_loadedBlend.getAbsolutePath().c_str());
char req[128]; char req[128];
@ -564,7 +564,7 @@ public:
char readBuf[256]; char readBuf[256];
m_parent->_readLine(readBuf, 256); m_parent->_readLine(readBuf, 256);
if (strcmp(readBuf, "OK")) if (strcmp(readBuf, "OK"))
BlenderLog.report(LogVisor::FatalError, "unable to cook mesh '%s': %s", name.c_str(), readBuf); BlenderLog.report(logvisor::Fatal, "unable to cook mesh '%s': %s", name.c_str(), readBuf);
return Mesh(*m_parent, topology, skinSlotCount, surfProg); return Mesh(*m_parent, topology, skinSlotCount, surfProg);
} }
@ -574,7 +574,7 @@ public:
Mesh::SurfProgFunc surfProg=[](int){}) Mesh::SurfProgFunc surfProg=[](int){})
{ {
if (m_parent->m_loadedType != BlendType::Area) if (m_parent->m_loadedType != BlendType::Area)
BlenderLog.report(LogVisor::FatalError, _S("%s is not an AREA blend"), BlenderLog.report(logvisor::Fatal, _S("%s is not an AREA blend"),
m_parent->m_loadedBlend.getAbsolutePath().c_str()); m_parent->m_loadedBlend.getAbsolutePath().c_str());
char req[128]; char req[128];
@ -586,7 +586,7 @@ public:
char readBuf[256]; char readBuf[256];
m_parent->_readLine(readBuf, 256); m_parent->_readLine(readBuf, 256);
if (strcmp(readBuf, "OK")) if (strcmp(readBuf, "OK"))
BlenderLog.report(LogVisor::FatalError, "unable to cook all meshes: %s", readBuf); BlenderLog.report(logvisor::Fatal, "unable to cook all meshes: %s", readBuf);
return Mesh(*m_parent, topology, skinSlotCount, surfProg); return Mesh(*m_parent, topology, skinSlotCount, surfProg);
} }
@ -659,7 +659,7 @@ public:
Actor compileActor() Actor compileActor()
{ {
if (m_parent->m_loadedType != BlendType::Actor) if (m_parent->m_loadedType != BlendType::Actor)
BlenderLog.report(LogVisor::FatalError, _S("%s is not an ACTOR blend"), BlenderLog.report(logvisor::Fatal, _S("%s is not an ACTOR blend"),
m_parent->m_loadedBlend.getAbsolutePath().c_str()); m_parent->m_loadedBlend.getAbsolutePath().c_str());
m_parent->_writeLine("ACTORCOMPILE"); m_parent->_writeLine("ACTORCOMPILE");
@ -667,7 +667,7 @@ public:
char readBuf[256]; char readBuf[256];
m_parent->_readLine(readBuf, 256); m_parent->_readLine(readBuf, 256);
if (strcmp(readBuf, "OK")) if (strcmp(readBuf, "OK"))
BlenderLog.report(LogVisor::FatalError, "unable to compile actor: %s", readBuf); BlenderLog.report(logvisor::Fatal, "unable to compile actor: %s", readBuf);
return Actor(*m_parent); return Actor(*m_parent);
} }
@ -675,7 +675,7 @@ public:
DataStream beginData() DataStream beginData()
{ {
if (m_lock) if (m_lock)
BlenderLog.report(LogVisor::FatalError, "lock already held for BlenderConnection::beginDataIn()"); BlenderLog.report(logvisor::Fatal, "lock already held for BlenderConnection::beginDataIn()");
return DataStream(this); return DataStream(this);
} }
@ -684,7 +684,7 @@ public:
static BlenderConnection& SharedConnection() static BlenderConnection& SharedConnection()
{ {
if (!SharedBlenderConnection) if (!SharedBlenderConnection)
SharedBlenderConnection = new BlenderConnection(HECL::VerbosityLevel); SharedBlenderConnection = new BlenderConnection(hecl::VerbosityLevel);
return *SharedBlenderConnection; return *SharedBlenderConnection;
} }
@ -702,7 +702,7 @@ public:
SharedBlenderConnection->quitBlender(); SharedBlenderConnection->quitBlender();
delete SharedBlenderConnection; delete SharedBlenderConnection;
SharedBlenderConnection = nullptr; SharedBlenderConnection = nullptr;
BlenderLog.report(LogVisor::Info, "BlenderConnection Shutdown Successful"); BlenderLog.report(logvisor::Info, "BlenderConnection Shutdown Successful");
} }
} }
@ -724,7 +724,7 @@ private:
m_surfaces(std::move(surfaces)), m_skinBanks(skinBanks) m_surfaces(std::move(surfaces)), m_skinBanks(skinBanks)
{ {
{ {
Athena::io::MemoryWriter w(m_iboData.get(), m_iboSz); athena::io::MemoryWriter w(m_iboData.get(), m_iboSz);
w.enumerateLittle(iboData); w.enumerateLittle(iboData);
} }
} }

View File

@ -22,7 +22,7 @@ add_custom_command(OUTPUT hecl.zip DEPENDS ${PY_SOURCES}
bintoc(hecl_addon.c "${CMAKE_CURRENT_BINARY_DIR}/hecl.zip" HECL_ADDON) bintoc(hecl_addon.c "${CMAKE_CURRENT_BINARY_DIR}/hecl.zip" HECL_ADDON)
bintoc(hecl_startup.c hecl_startup.blend HECL_STARTUP) bintoc(hecl_startup.c hecl_startup.blend HECL_STARTUP)
add_library(HECLBlender add_library(hecl-blender
BlenderConnection.cpp BlenderConnection.cpp
BlenderConnection.hpp BlenderConnection.hpp
HMDL.cpp HMDL.cpp

View File

@ -1,6 +1,6 @@
#include "BlenderConnection.hpp" #include "BlenderConnection.hpp"
namespace HECL namespace hecl
{ {
HMDLBuffers BlenderConnection::DataStream::Mesh::getHMDLBuffers() const HMDLBuffers BlenderConnection::DataStream::Mesh::getHMDLBuffers() const
@ -69,7 +69,7 @@ HMDLBuffers BlenderConnection::DataStream::Mesh::getHMDLBuffers() const
size_t vboSz = metaOut.vertCount * metaOut.vertStride; size_t vboSz = metaOut.vertCount * metaOut.vertStride;
HMDLBuffers ret(std::move(metaOut), vboSz, iboData, std::move(outSurfaces), skinBanks); HMDLBuffers ret(std::move(metaOut), vboSz, iboData, std::move(outSurfaces), skinBanks);
Athena::io::MemoryWriter vboW(ret.m_vboData.get(), vboSz); athena::io::MemoryWriter vboW(ret.m_vboData.get(), vboSz);
for (const std::pair<const Surface*, const Surface::Vert*>& sv : vertPool) for (const std::pair<const Surface*, const Surface::Vert*>& sv : vertPool)
{ {
const Surface& s = *sv.first; const Surface& s = *sv.first;

View File

@ -24,5 +24,5 @@ endif()
target_link_libraries(hecl target_link_libraries(hecl
${DATA_SPEC_LIBS} ${DATA_SPEC_LIBS}
HECLDatabase HECLBackend HECLFrontend HECLBlender HECLCommon AthenaCore NOD hecl-database hecl-backend hecl-frontend hecl-blender hecl-common athena-core nod
LogVisor AthenaLibYaml ${PNG_LIB} squish xxhash Boo ${ZLIB_LIBRARIES} ${LZO_LIB} ${PLAT_LIBS} ${BOO_SYS_LIBS}) logvisor athena-libyaml ${PNG_LIB} squish xxhash boo ${ZLIB_LIBRARIES} ${LZO_LIB} ${PLAT_LIBS} ${BOO_SYS_LIBS})

View File

@ -49,7 +49,7 @@ public:
help.endWrap(); help.endWrap();
} }
HECL::SystemString toolName() const {return _S("add");} hecl::SystemString toolName() const {return _S("add");}
int run() int run()
{ {

View File

@ -11,19 +11,19 @@
#include <unistd.h> #include <unistd.h>
#endif #endif
#include "HECL/Database.hpp" #include "hecl/Database.hpp"
#include "LogVisor/LogVisor.hpp" #include "logvisor/logvisor.hpp"
extern LogVisor::LogModule LogModule; extern logvisor::Module LogModule;
struct ToolPassInfo struct ToolPassInfo
{ {
HECL::SystemString pname; hecl::SystemString pname;
HECL::SystemString cwd; hecl::SystemString cwd;
std::vector<HECL::SystemString> args; std::vector<hecl::SystemString> args;
std::vector<HECL::SystemChar> flags; std::vector<hecl::SystemChar> flags;
HECL::SystemString output; hecl::SystemString output;
HECL::Database::Project* project = nullptr; hecl::Database::Project* project = nullptr;
unsigned verbosityLevel = 0; unsigned verbosityLevel = 0;
bool force = false; bool force = false;
}; };
@ -37,10 +37,10 @@ public:
ToolBase(const ToolPassInfo& info) ToolBase(const ToolPassInfo& info)
: m_info(info) : m_info(info)
{ {
HECL::VerbosityLevel = info.verbosityLevel; hecl::VerbosityLevel = info.verbosityLevel;
} }
virtual ~ToolBase() {} virtual ~ToolBase() {}
virtual HECL::SystemString toolName() const=0; virtual hecl::SystemString toolName() const=0;
virtual int run()=0; virtual int run()=0;
inline operator bool() const {return m_good;} inline operator bool() const {return m_good;}
}; };
@ -69,16 +69,16 @@ private:
FILE* m_sout; FILE* m_sout;
HelpFunc m_helpFunc; HelpFunc m_helpFunc;
int m_lineWidth; int m_lineWidth;
HECL::SystemString m_wrapBuffer; hecl::SystemString m_wrapBuffer;
void _wrapBuf(HECL::SystemString& string) void _wrapBuf(hecl::SystemString& string)
{ {
int counter; int counter;
HECL::SystemString::iterator it = string.begin(); hecl::SystemString::iterator it = string.begin();
while (it != string.end()) while (it != string.end())
{ {
HECL::SystemString::iterator v=it; hecl::SystemString::iterator v=it;
/* copy string until the end of the line is reached */ /* copy string until the end of the line is reached */
for (counter=WRAP_INDENT ; counter < m_lineWidth ; ++counter) for (counter=WRAP_INDENT ; counter < m_lineWidth ; ++counter)
@ -108,7 +108,7 @@ private:
else else
{ {
/* check for nearest whitespace back in string */ /* check for nearest whitespace back in string */
for (HECL::SystemString::iterator k=it ; k!=string.begin() ; --k) for (hecl::SystemString::iterator k=it ; k!=string.begin() ; --k)
{ {
if (isspace(*k)) if (isspace(*k))
{ {
@ -131,7 +131,7 @@ private:
public: public:
HelpOutput(HelpFunc helpFunc) HelpOutput(HelpFunc helpFunc)
: m_sout(NULL), m_helpFunc(helpFunc), m_lineWidth(HECL::ConsoleWidth()) : m_sout(NULL), m_helpFunc(helpFunc), m_lineWidth(hecl::ConsoleWidth())
{} {}
void go() void go()
@ -154,33 +154,33 @@ public:
#endif #endif
} }
void print(const HECL::SystemChar* str) void print(const hecl::SystemChar* str)
{ {
HECL::FPrintf(m_sout, _S("%s"), str); hecl::FPrintf(m_sout, _S("%s"), str);
} }
void printBold(const HECL::SystemChar* str) void printBold(const hecl::SystemChar* str)
{ {
if (XTERM_COLOR) if (XTERM_COLOR)
HECL::FPrintf(m_sout, _S("" BOLD "%s" NORMAL ""), str); hecl::FPrintf(m_sout, _S("" BOLD "%s" NORMAL ""), str);
else else
HECL::FPrintf(m_sout, _S("%s"), str); hecl::FPrintf(m_sout, _S("%s"), str);
} }
void secHead(const HECL::SystemChar* headName) void secHead(const hecl::SystemChar* headName)
{ {
if (XTERM_COLOR) if (XTERM_COLOR)
HECL::FPrintf(m_sout, _S("" BOLD "%s" NORMAL "\n"), headName); hecl::FPrintf(m_sout, _S("" BOLD "%s" NORMAL "\n"), headName);
else else
HECL::FPrintf(m_sout, _S("%s\n"), headName); hecl::FPrintf(m_sout, _S("%s\n"), headName);
} }
void optionHead(const HECL::SystemChar* flag, const HECL::SystemChar* synopsis) void optionHead(const hecl::SystemChar* flag, const hecl::SystemChar* synopsis)
{ {
if (XTERM_COLOR) if (XTERM_COLOR)
HECL::FPrintf(m_sout, _S("" BOLD "%s" NORMAL " (%s)\n"), flag, synopsis); hecl::FPrintf(m_sout, _S("" BOLD "%s" NORMAL " (%s)\n"), flag, synopsis);
else else
HECL::FPrintf(m_sout, _S("%s (%s)\n"), flag, synopsis); hecl::FPrintf(m_sout, _S("%s (%s)\n"), flag, synopsis);
} }
void beginWrap() void beginWrap()
@ -188,12 +188,12 @@ public:
m_wrapBuffer.clear(); m_wrapBuffer.clear();
} }
void wrap(const HECL::SystemChar* str) void wrap(const hecl::SystemChar* str)
{ {
m_wrapBuffer += str; m_wrapBuffer += str;
} }
void wrapBold(const HECL::SystemChar* str) void wrapBold(const hecl::SystemChar* str)
{ {
if (XTERM_COLOR) if (XTERM_COLOR)
m_wrapBuffer += _S("" BOLD ""); m_wrapBuffer += _S("" BOLD "");
@ -206,13 +206,13 @@ public:
{ {
_wrapBuf(m_wrapBuffer); _wrapBuf(m_wrapBuffer);
m_wrapBuffer += _S('\n'); m_wrapBuffer += _S('\n');
HECL::FPrintf(m_sout, _S("%s"), m_wrapBuffer.c_str()); hecl::FPrintf(m_sout, _S("%s"), m_wrapBuffer.c_str());
m_wrapBuffer.clear(); m_wrapBuffer.clear();
} }
}; };
static HECL::SystemString MakePathArgAbsolute(const HECL::SystemString& arg, static hecl::SystemString MakePathArgAbsolute(const hecl::SystemString& arg,
const HECL::SystemString& cwd) const hecl::SystemString& cwd)
{ {
#if _WIN32 #if _WIN32
if (arg.size() >= 2 && iswalpha(arg[0]) && arg[1] == _S(':')) if (arg.size() >= 2 && iswalpha(arg[0]) && arg[1] == _S(':'))
@ -227,24 +227,24 @@ static HECL::SystemString MakePathArgAbsolute(const HECL::SystemString& arg,
#endif #endif
} }
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)
{ {
bool blocks = factor >= 0.0; bool blocks = factor >= 0.0;
factor = std::max(0.0f, std::min(1.0f, factor)); factor = std::max(0.0f, std::min(1.0f, factor));
int iFactor = factor * 100.0; int iFactor = factor * 100.0;
if (XTERM_COLOR) if (XTERM_COLOR)
HECL::Printf(_S("" HIDE_CURSOR "")); hecl::Printf(_S("" HIDE_CURSOR ""));
if (lidx > lineIdx) if (lidx > lineIdx)
{ {
HECL::Printf(_S("\n ")); hecl::Printf(_S("\n "));
lineIdx = lidx; lineIdx = lidx;
} }
else else
HECL::Printf(_S(" ")); hecl::Printf(_S(" "));
int width = HECL::ConsoleWidth(); int width = hecl::ConsoleWidth();
int half; int half;
if (blocks) if (blocks)
half = width / 2 - 2; half = width / 2 - 2;
@ -253,34 +253,34 @@ void ToolPrintProgress(const HECL::SystemChar* message, const HECL::SystemChar*
if (!message) if (!message)
message = _S(""); message = _S("");
size_t messageLen = HECL::StrLen(message); size_t messageLen = hecl::StrLen(message);
if (!submessage) if (!submessage)
submessage = _S(""); submessage = _S("");
size_t submessageLen = HECL::StrLen(submessage); size_t 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-int(submessageLen)-4, message, submessage);
else else
{ {
HECL::Printf(_S("%s"), message); hecl::Printf(_S("%s"), message);
for (int i=half-messageLen-submessageLen-1 ; i>=0 ; --i) for (int i=half-messageLen-submessageLen-1 ; i>=0 ; --i)
HECL::Printf(_S(" ")); hecl::Printf(_S(" "));
HECL::Printf(_S("%s "), submessage); hecl::Printf(_S("%s "), submessage);
} }
} }
else else
{ {
if (messageLen > half) if (messageLen > half)
HECL::Printf(_S("%.*s... "), half-3, message); hecl::Printf(_S("%.*s... "), half-3, message);
else else
{ {
HECL::Printf(_S("%s"), message); hecl::Printf(_S("%s"), message);
for (int i=half-messageLen ; i>=0 ; --i) for (int i=half-messageLen ; i>=0 ; --i)
HECL::Printf(_S(" ")); hecl::Printf(_S(" "));
} }
} }
@ -291,30 +291,30 @@ void ToolPrintProgress(const HECL::SystemChar* message, const HECL::SystemChar*
size_t blocks = half - 7; size_t blocks = half - 7;
size_t filled = blocks * factor; size_t filled = blocks * factor;
size_t rem = blocks - filled; size_t 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("#"));
for (int b=0 ; b<rem ; ++b) for (int b=0 ; b<rem ; ++b)
HECL::Printf(_S("-")); hecl::Printf(_S("-"));
HECL::Printf(_S("]" NORMAL "")); hecl::Printf(_S("]" NORMAL ""));
} }
else else
{ {
size_t blocks = half - 7; size_t blocks = half - 7;
size_t filled = blocks * factor; size_t filled = blocks * factor;
size_t rem = blocks - filled; size_t 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("#"));
for (int b=0 ; b<rem ; ++b) for (int b=0 ; b<rem ; ++b)
HECL::Printf(_S("-")); hecl::Printf(_S("-"));
HECL::Printf(_S("]")); hecl::Printf(_S("]"));
} }
} }
HECL::Printf(_S("\r")); hecl::Printf(_S("\r"));
if (XTERM_COLOR) if (XTERM_COLOR)
HECL::Printf(_S("" SHOW_CURSOR "")); hecl::Printf(_S("" SHOW_CURSOR ""));
fflush(stdout); fflush(stdout);
} }

View File

@ -59,7 +59,7 @@ public:
help.endWrap(); help.endWrap();
} }
HECL::SystemString toolName() const {return _S("clean");} hecl::SystemString toolName() const {return _S("clean");}
int run() int run()
{ {

View File

@ -6,9 +6,9 @@
class ToolCook final : public ToolBase class ToolCook final : public ToolBase
{ {
std::vector<HECL::ProjectPath> m_selectedItems; std::vector<hecl::ProjectPath> m_selectedItems;
std::unique_ptr<HECL::Database::Project> m_fallbackProj; std::unique_ptr<hecl::Database::Project> m_fallbackProj;
HECL::Database::Project* m_useProj; hecl::Database::Project* m_useProj;
bool m_recursive = false; bool m_recursive = false;
bool m_fast = false; bool m_fast = false;
public: public:
@ -16,7 +16,7 @@ public:
: ToolBase(info), m_useProj(info.project) : ToolBase(info), m_useProj(info.project)
{ {
/* Check for recursive flag */ /* Check for recursive flag */
for (HECL::SystemChar arg : info.flags) for (hecl::SystemChar arg : info.flags)
if (arg == _S('r')) if (arg == _S('r'))
m_recursive = true; m_recursive = true;
@ -25,7 +25,7 @@ public:
{ {
/* See if project path is supplied via args and use that over the getcwd one */ /* See if project path is supplied via args and use that over the getcwd one */
m_selectedItems.reserve(info.args.size()); m_selectedItems.reserve(info.args.size());
for (const HECL::SystemString& arg : info.args) for (const hecl::SystemString& arg : info.args)
{ {
if (arg.empty()) if (arg.empty())
continue; continue;
@ -37,17 +37,17 @@ public:
else if (arg.size() >= 2 && arg[0] == _S('-') && arg[1] == _S('-')) else if (arg.size() >= 2 && arg[0] == _S('-') && arg[1] == _S('-'))
continue; continue;
HECL::SystemString subPath; hecl::SystemString subPath;
HECL::ProjectRootPath root = HECL::SearchForProject(MakePathArgAbsolute(arg, info.cwd), subPath); hecl::ProjectRootPath root = hecl::SearchForProject(MakePathArgAbsolute(arg, info.cwd), subPath);
if (root) if (root)
{ {
if (!m_fallbackProj) if (!m_fallbackProj)
{ {
m_fallbackProj.reset(new HECL::Database::Project(root)); m_fallbackProj.reset(new hecl::Database::Project(root));
m_useProj = m_fallbackProj.get(); m_useProj = m_fallbackProj.get();
} }
else if (m_fallbackProj->getProjectRootPath() != root) else if (m_fallbackProj->getProjectRootPath() != root)
LogModule.report(LogVisor::FatalError, LogModule.report(logvisor::Fatal,
_S("hecl cook can only process multiple items in the same project; ") _S("hecl cook can only process multiple items in the same project; ")
_S("'%s' and '%s' are different projects"), _S("'%s' and '%s' are different projects"),
m_fallbackProj->getProjectRootPath().getAbsolutePath().c_str(), m_fallbackProj->getProjectRootPath().getAbsolutePath().c_str(),
@ -57,7 +57,7 @@ public:
} }
} }
if (!m_useProj) if (!m_useProj)
LogModule.report(LogVisor::FatalError, LogModule.report(logvisor::Fatal,
"hecl cook must be ran within a project directory or " "hecl cook must be ran within a project directory or "
"provided a path within a project"); "provided a path within a project");
@ -65,7 +65,7 @@ public:
if (m_selectedItems.empty()) if (m_selectedItems.empty())
{ {
m_selectedItems.reserve(1); m_selectedItems.reserve(1);
m_selectedItems.push_back({HECL::ProjectPath(*m_useProj, _S(""))}); m_selectedItems.push_back({hecl::ProjectPath(*m_useProj, _S(""))});
m_recursive = true; m_recursive = true;
} }
} }
@ -132,16 +132,16 @@ public:
help.endWrap(); help.endWrap();
} }
HECL::SystemString toolName() const {return _S("cook");} hecl::SystemString toolName() const {return _S("cook");}
int run() int run()
{ {
for (const HECL::ProjectPath& path : m_selectedItems) for (const hecl::ProjectPath& path : m_selectedItems)
{ {
int lineIdx = 0; int lineIdx = 0;
m_useProj->cookPath(path, m_useProj->cookPath(path,
[&lineIdx](const HECL::SystemChar* message, [&lineIdx](const hecl::SystemChar* message,
const HECL::SystemChar* submessage, const hecl::SystemChar* submessage,
int lidx, float factor) int lidx, float factor)
{ToolPrintProgress(message, submessage, lidx, factor, lineIdx);}, {ToolPrintProgress(message, submessage, lidx, factor, lineIdx);},
m_recursive, m_info.force, m_fast); m_recursive, m_info.force, m_fast);

View File

@ -12,51 +12,51 @@
class ToolExtract final : public ToolBase class ToolExtract final : public ToolBase
{ {
HECL::Database::IDataSpec::ExtractPassInfo m_einfo; hecl::Database::IDataSpec::ExtractPassInfo m_einfo;
struct SpecExtractPass struct SpecExtractPass
{ {
const HECL::Database::DataSpecEntry* m_entry; const hecl::Database::DataSpecEntry* m_entry;
std::unique_ptr<HECL::Database::IDataSpec> m_instance; std::unique_ptr<hecl::Database::IDataSpec> m_instance;
SpecExtractPass(const HECL::Database::DataSpecEntry* entry, HECL::Database::IDataSpec* instance) SpecExtractPass(const hecl::Database::DataSpecEntry* entry, hecl::Database::IDataSpec* instance)
: m_entry(entry), m_instance(instance) {} : m_entry(entry), m_instance(instance) {}
SpecExtractPass(const SpecExtractPass& other) = delete; SpecExtractPass(const SpecExtractPass& other) = delete;
SpecExtractPass(SpecExtractPass&& other) = default; SpecExtractPass(SpecExtractPass&& other) = default;
}; };
std::vector<SpecExtractPass> m_specPasses; std::vector<SpecExtractPass> m_specPasses;
std::vector<HECL::Database::IDataSpec::ExtractReport> m_reps; std::vector<hecl::Database::IDataSpec::ExtractReport> m_reps;
std::unique_ptr<HECL::Database::Project> m_fallbackProj; std::unique_ptr<hecl::Database::Project> m_fallbackProj;
HECL::Database::Project* m_useProj; hecl::Database::Project* m_useProj;
public: public:
ToolExtract(const ToolPassInfo& info) ToolExtract(const ToolPassInfo& info)
: ToolBase(info) : ToolBase(info)
{ {
if (!m_info.args.size()) if (!m_info.args.size())
LogModule.report(LogVisor::FatalError, "hecl extract needs a source path as its first argument"); LogModule.report(logvisor::Fatal, "hecl extract needs a source path as its first argument");
if (!info.project) if (!info.project)
{ {
/* Get name from input file and init project there */ /* Get name from input file and init project there */
HECL::SystemString baseFile = info.args.front(); hecl::SystemString baseFile = info.args.front();
size_t slashPos = baseFile.rfind(_S('/')); size_t slashPos = baseFile.rfind(_S('/'));
if (slashPos == HECL::SystemString::npos) if (slashPos == hecl::SystemString::npos)
slashPos = baseFile.rfind(_S('\\')); slashPos = baseFile.rfind(_S('\\'));
if (slashPos != HECL::SystemString::npos) if (slashPos != hecl::SystemString::npos)
baseFile.assign(baseFile.begin() + slashPos + 1, baseFile.end()); baseFile.assign(baseFile.begin() + slashPos + 1, baseFile.end());
size_t dotPos = baseFile.rfind(_S('.')); size_t dotPos = baseFile.rfind(_S('.'));
if (dotPos != HECL::SystemString::npos) if (dotPos != hecl::SystemString::npos)
baseFile.assign(baseFile.begin(), baseFile.begin() + dotPos); baseFile.assign(baseFile.begin(), baseFile.begin() + dotPos);
if (baseFile.empty()) if (baseFile.empty())
LogModule.report(LogVisor::FatalError, "hecl extract must be ran within a project directory"); LogModule.report(logvisor::Fatal, "hecl extract must be ran within a project directory");
size_t ErrorRef = LogVisor::ErrorCount; size_t ErrorRef = logvisor::ErrorCount;
HECL::SystemString rootDir = info.cwd + baseFile; hecl::SystemString rootDir = info.cwd + baseFile;
HECL::ProjectRootPath newProjRoot(rootDir); hecl::ProjectRootPath newProjRoot(rootDir);
newProjRoot.makeDir(); newProjRoot.makeDir();
m_fallbackProj.reset(new HECL::Database::Project(newProjRoot)); m_fallbackProj.reset(new hecl::Database::Project(newProjRoot));
if (LogVisor::ErrorCount > ErrorRef) if (logvisor::ErrorCount > ErrorRef)
LogModule.report(LogVisor::FatalError, "unable to init project at '%s'", rootDir.c_str()); LogModule.report(logvisor::Fatal, "unable to init project at '%s'", rootDir.c_str());
LogModule.report(LogVisor::Info, _S("initialized project at '%s/.hecl'"), rootDir.c_str()); LogModule.report(logvisor::Info, _S("initialized project at '%s/.hecl'"), rootDir.c_str());
m_useProj = m_fallbackProj.get(); m_useProj = m_fallbackProj.get();
} }
else else
@ -70,10 +70,10 @@ public:
for (; it != info.args.cend(); ++it) for (; it != info.args.cend(); ++it)
m_einfo.extractArgs.push_back(*it); m_einfo.extractArgs.push_back(*it);
m_specPasses.reserve(HECL::Database::DATA_SPEC_REGISTRY.size()); m_specPasses.reserve(hecl::Database::DATA_SPEC_REGISTRY.size());
for (const HECL::Database::DataSpecEntry* entry : HECL::Database::DATA_SPEC_REGISTRY) for (const hecl::Database::DataSpecEntry* entry : hecl::Database::DATA_SPEC_REGISTRY)
{ {
HECL::Database::IDataSpec* ds = entry->m_factory(*m_useProj, HECL::Database::DataSpecTool::Extract); hecl::Database::IDataSpec* ds = entry->m_factory(*m_useProj, hecl::Database::DataSpecTool::Extract);
if (ds) if (ds)
{ {
if (ds->canExtract(m_einfo, m_reps)) if (ds->canExtract(m_einfo, m_reps))
@ -111,21 +111,21 @@ public:
help.endWrap(); help.endWrap();
} }
HECL::SystemString toolName() const {return _S("extract");} hecl::SystemString toolName() const {return _S("extract");}
static void _recursivePrint(int level, HECL::Database::IDataSpec::ExtractReport& rep) static void _recursivePrint(int level, hecl::Database::IDataSpec::ExtractReport& rep)
{ {
for (int l=0 ; l<level ; ++l) for (int l=0 ; l<level ; ++l)
HECL::Printf(_S(" ")); hecl::Printf(_S(" "));
if (XTERM_COLOR) if (XTERM_COLOR)
HECL::Printf(_S("" BOLD "%s" NORMAL ""), rep.name.c_str()); hecl::Printf(_S("" BOLD "%s" NORMAL ""), rep.name.c_str());
else else
HECL::Printf(_S("%s"), rep.name.c_str()); hecl::Printf(_S("%s"), rep.name.c_str());
if (rep.desc.size()) if (rep.desc.size())
HECL::Printf(_S(" [%s]"), rep.desc.c_str()); hecl::Printf(_S(" [%s]"), rep.desc.c_str());
HECL::Printf(_S("\n")); hecl::Printf(_S("\n"));
for (HECL::Database::IDataSpec::ExtractReport& child : rep.childOpts) for (hecl::Database::IDataSpec::ExtractReport& child : rep.childOpts)
_recursivePrint(level + 1, child); _recursivePrint(level + 1, child);
} }
@ -134,27 +134,27 @@ public:
if (m_specPasses.empty()) if (m_specPasses.empty())
{ {
if (XTERM_COLOR) if (XTERM_COLOR)
HECL::Printf(_S("" RED BOLD "NOTHING TO EXTRACT" NORMAL "\n")); hecl::Printf(_S("" RED BOLD "NOTHING TO EXTRACT" NORMAL "\n"));
else else
HECL::Printf(_S("NOTHING TO EXTRACT\n")); hecl::Printf(_S("NOTHING TO EXTRACT\n"));
return -1; return -1;
} }
if (XTERM_COLOR) if (XTERM_COLOR)
HECL::Printf(_S("" GREEN BOLD "ABOUT TO EXTRACT:" NORMAL "\n")); hecl::Printf(_S("" GREEN BOLD "ABOUT TO EXTRACT:" NORMAL "\n"));
else else
HECL::Printf(_S("ABOUT TO EXTRACT:\n")); hecl::Printf(_S("ABOUT TO EXTRACT:\n"));
for (HECL::Database::IDataSpec::ExtractReport& rep : m_reps) for (hecl::Database::IDataSpec::ExtractReport& rep : m_reps)
{ {
_recursivePrint(0, rep); _recursivePrint(0, rep);
HECL::Printf(_S("\n")); hecl::Printf(_S("\n"));
} }
if (XTERM_COLOR) if (XTERM_COLOR)
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) "));
int ch; int ch;
#ifndef _WIN32 #ifndef _WIN32
@ -177,22 +177,22 @@ public:
tcsetattr(0, TCSANOW, &tioOld); tcsetattr(0, TCSANOW, &tioOld);
#endif #endif
HECL::Printf(_S("\n")); hecl::Printf(_S("\n"));
for (SpecExtractPass& ds : m_specPasses) for (SpecExtractPass& ds : m_specPasses)
{ {
if (XTERM_COLOR) if (XTERM_COLOR)
HECL::Printf(_S("" MAGENTA BOLD "Using DataSpec %s:" NORMAL "\n"), ds.m_entry->m_name); hecl::Printf(_S("" MAGENTA BOLD "Using DataSpec %s:" NORMAL "\n"), ds.m_entry->m_name);
else else
HECL::Printf(_S("Using DataSpec %s:\n"), ds.m_entry->m_name); hecl::Printf(_S("Using DataSpec %s:\n"), ds.m_entry->m_name);
int lineIdx = 0; int lineIdx = 0;
ds.m_instance->doExtract(m_einfo, ds.m_instance->doExtract(m_einfo,
[&lineIdx](const HECL::SystemChar* message, [&lineIdx](const hecl::SystemChar* message,
const HECL::SystemChar* submessage, const hecl::SystemChar* submessage,
int lidx, float factor) int lidx, float factor)
{ToolPrintProgress(message, submessage, lidx, factor, lineIdx);}); {ToolPrintProgress(message, submessage, lidx, factor, lineIdx);});
HECL::Printf(_S("\n\n")); hecl::Printf(_S("\n\n"));
} }
return 0; return 0;

View File

@ -11,7 +11,7 @@ public:
: ToolBase(info) : ToolBase(info)
{ {
if (!info.project) if (!info.project)
LogModule.report(LogVisor::FatalError, "hecl group must be ran within a project directory"); LogModule.report(logvisor::Fatal, "hecl group must be ran within a project directory");
} }
~ToolGroup() ~ToolGroup()
@ -58,7 +58,7 @@ public:
help.endWrap(); help.endWrap();
} }
HECL::SystemString toolName() const {return _S("group");} hecl::SystemString toolName() const {return _S("group");}
int run() int run()
{ {

View File

@ -15,7 +15,7 @@ public:
{ {
if (m_info.args.empty()) if (m_info.args.empty())
{ {
LogModule.report(LogVisor::Error, "help requires a tool name argument"); LogModule.report(logvisor::Error, "help requires a tool name argument");
return; return;
} }
m_good = true; m_good = true;
@ -56,7 +56,7 @@ public:
_S("...................................,\n")); _S("...................................,\n"));
} }
static void ShowHelp(const HECL::SystemString& toolName) static void ShowHelp(const hecl::SystemString& toolName)
{ {
/* Select tool's help-text streamer */ /* Select tool's help-text streamer */
HelpOutput::HelpFunc helpFunc = NULL; HelpOutput::HelpFunc helpFunc = NULL;
@ -82,7 +82,7 @@ public:
helpFunc = ToolHelp::Help; helpFunc = ToolHelp::Help;
else else
{ {
LogModule.report(LogVisor::Error, _S("unrecognized tool '%s' - can't help"), toolName.c_str()); LogModule.report(logvisor::Error, _S("unrecognized tool '%s' - can't help"), toolName.c_str());
return; return;
} }
@ -90,7 +90,7 @@ public:
ho.go(); ho.go();
} }
HECL::SystemString toolName() const {return _S("help");} hecl::SystemString toolName() const {return _S("help");}
int run() int run()
{ {

View File

@ -6,37 +6,37 @@
class ToolInit final : public ToolBase class ToolInit final : public ToolBase
{ {
const HECL::SystemString* m_dir = NULL; const hecl::SystemString* m_dir = NULL;
public: public:
ToolInit(const ToolPassInfo& info) ToolInit(const ToolPassInfo& info)
: ToolBase(info) : ToolBase(info)
{ {
HECL::Sstat theStat; hecl::Sstat theStat;
const HECL::SystemString* dir; const hecl::SystemString* dir;
if (info.args.size()) if (info.args.size())
dir = &info.args.front(); dir = &info.args.front();
else else
dir = &info.cwd; dir = &info.cwd;
if (HECL::Stat(dir->c_str(), &theStat)) if (hecl::Stat(dir->c_str(), &theStat))
{ {
HECL::MakeDir(dir->c_str()); hecl::MakeDir(dir->c_str());
if (HECL::Stat(dir->c_str(), &theStat)) if (hecl::Stat(dir->c_str(), &theStat))
{ {
LogModule.report(LogVisor::FatalError, _S("unable to stat '%s'"), dir->c_str()); LogModule.report(logvisor::Fatal, _S("unable to stat '%s'"), dir->c_str());
return; return;
} }
} }
if (!S_ISDIR(theStat.st_mode)) if (!S_ISDIR(theStat.st_mode))
{ {
LogModule.report(LogVisor::FatalError, _S("'%s' is not a directory"), dir->c_str()); LogModule.report(logvisor::Fatal, _S("'%s' is not a directory"), dir->c_str());
return; return;
} }
HECL::SystemString testPath = *dir + _S("/.hecl/beacon"); hecl::SystemString testPath = *dir + _S("/.hecl/beacon");
if (!HECL::Stat(testPath.c_str(), &theStat)) if (!hecl::Stat(testPath.c_str(), &theStat))
{ {
LogModule.report(LogVisor::FatalError, _S("project already exists at '%s'"), dir->c_str()); LogModule.report(logvisor::Fatal, _S("project already exists at '%s'"), dir->c_str());
return; return;
} }
@ -47,11 +47,11 @@ public:
{ {
if (!m_dir) if (!m_dir)
return -1; return -1;
size_t ErrorRef = LogVisor::ErrorCount; size_t ErrorRef = logvisor::ErrorCount;
HECL::Database::Project proj((HECL::ProjectRootPath(*m_dir))); hecl::Database::Project proj((hecl::ProjectRootPath(*m_dir)));
if (LogVisor::ErrorCount > ErrorRef) if (logvisor::ErrorCount > ErrorRef)
return -1; return -1;
LogModule.report(LogVisor::Info, _S("initialized project at '%s/.hecl'"), m_dir->c_str()); LogModule.report(logvisor::Info, _S("initialized project at '%s/.hecl'"), m_dir->c_str());
return 0; return 0;
} }
@ -82,7 +82,7 @@ public:
help.endWrap(); help.endWrap();
} }
HECL::SystemString toolName() const {return _S("init");} hecl::SystemString toolName() const {return _S("init");}
}; };
#endif // CTOOL_INIT #endif // CTOOL_INIT

View File

@ -13,7 +13,7 @@ public:
: ToolBase(info) : ToolBase(info)
{ {
if (!info.project) if (!info.project)
LogModule.report(LogVisor::FatalError, "hecl package must be ran within a project directory"); LogModule.report(logvisor::Fatal, "hecl package must be ran within a project directory");
} }
~ToolPackage() ~ToolPackage()
@ -61,7 +61,7 @@ public:
help.endWrap(); help.endWrap();
} }
HECL::SystemString toolName() const {return _S("package");} hecl::SystemString toolName() const {return _S("package");}
int run() int run()
{ {

View File

@ -51,7 +51,7 @@ public:
help.endWrap(); help.endWrap();
} }
HECL::SystemString toolName() const {return _S("remove");} hecl::SystemString toolName() const {return _S("remove");}
int run() int run()
{ {

View File

@ -21,15 +21,15 @@ public:
return; return;
if (!info.project) if (!info.project)
LogModule.report(LogVisor::FatalError, LogModule.report(logvisor::Fatal,
"hecl spec must be ran within a project directory"); "hecl spec must be ran within a project directory");
const auto& specs = info.project->getDataSpecs(); const auto& specs = info.project->getDataSpecs();
HECL::SystemString firstArg = info.args.front(); hecl::SystemString firstArg = info.args.front();
HECL::ToLower(firstArg); hecl::ToLower(firstArg);
static const HECL::SystemString enable(_S("enable")); static const hecl::SystemString enable(_S("enable"));
static const HECL::SystemString disable(_S("disable")); static const hecl::SystemString disable(_S("disable"));
if (!firstArg.compare(enable)) if (!firstArg.compare(enable))
mode = MENABLE; mode = MENABLE;
else if (!firstArg.compare(disable)) else if (!firstArg.compare(disable))
@ -38,7 +38,7 @@ public:
return; return;
if (info.args.size() < 2) if (info.args.size() < 2)
LogModule.report(LogVisor::FatalError, "Speclist argument required"); LogModule.report(logvisor::Fatal, "Speclist argument required");
auto it = info.args.begin(); auto it = info.args.begin();
++it; ++it;
@ -56,7 +56,7 @@ public:
} }
} }
if (!found) if (!found)
LogModule.report(LogVisor::FatalError, LogModule.report(logvisor::Fatal,
_S("'%s' is not found in the dataspec registry"), _S("'%s' is not found in the dataspec registry"),
it->c_str()); it->c_str());
} }
@ -88,19 +88,19 @@ public:
help.endWrap(); help.endWrap();
} }
HECL::SystemString toolName() const {return _S("spec");} hecl::SystemString toolName() const {return _S("spec");}
int run() int run()
{ {
if (!m_info.project) if (!m_info.project)
{ {
for (const HECL::Database::DataSpecEntry* spec : HECL::Database::DATA_SPEC_REGISTRY) for (const hecl::Database::DataSpecEntry* spec : hecl::Database::DATA_SPEC_REGISTRY)
{ {
if (XTERM_COLOR) if (XTERM_COLOR)
HECL::Printf(_S("" BOLD CYAN "%s" NORMAL "\n"), spec->m_name); hecl::Printf(_S("" BOLD CYAN "%s" NORMAL "\n"), spec->m_name);
else else
HECL::Printf(_S("%s\n"), spec->m_name); hecl::Printf(_S("%s\n"), spec->m_name);
HECL::Printf(_S(" %s\n"), spec->m_desc); hecl::Printf(_S(" %s\n"), spec->m_desc);
} }
return 0; return 0;
} }
@ -111,32 +111,32 @@ public:
for (auto& spec : specs) for (auto& spec : specs)
{ {
if (XTERM_COLOR) if (XTERM_COLOR)
HECL::Printf(_S("" BOLD CYAN "%s" NORMAL ""), spec.spec.m_name); hecl::Printf(_S("" BOLD CYAN "%s" NORMAL ""), spec.spec.m_name);
else else
HECL::Printf(_S("%s"), spec.spec.m_name); hecl::Printf(_S("%s"), spec.spec.m_name);
if (spec.active) if (spec.active)
{ {
if (XTERM_COLOR) if (XTERM_COLOR)
HECL::Printf(_S(" " BOLD GREEN "[ENABLED]" NORMAL "")); hecl::Printf(_S(" " BOLD GREEN "[ENABLED]" NORMAL ""));
else else
HECL::Printf(_S(" [ENABLED]")); hecl::Printf(_S(" [ENABLED]"));
} }
HECL::Printf(_S("\n %s\n"), spec.spec.m_desc); hecl::Printf(_S("\n %s\n"), spec.spec.m_desc);
} }
return 0; return 0;
} }
std::vector<HECL::SystemString> opSpecs; std::vector<hecl::SystemString> opSpecs;
auto it = m_info.args.begin(); auto it = m_info.args.begin();
++it; ++it;
for (; it != m_info.args.end() ; ++it) for (; it != m_info.args.end() ; ++it)
{ {
HECL::SystemString itName = *it; hecl::SystemString itName = *it;
HECL::ToLower(itName); hecl::ToLower(itName);
for (auto& spec : specs) for (auto& spec : specs)
{ {
HECL::SystemString compName(spec.spec.m_name); hecl::SystemString compName(spec.spec.m_name);
HECL::ToLower(compName); hecl::ToLower(compName);
if (!itName.compare(compName)) if (!itName.compare(compName))
{ {
opSpecs.push_back(spec.spec.m_name); opSpecs.push_back(spec.spec.m_name);

View File

@ -14,11 +14,11 @@
#include <signal.h> #include <signal.h>
#include <regex> #include <regex>
#include <list> #include <list>
#include "HECL/Database.hpp" #include "hecl/Database.hpp"
#include "../blender/BlenderConnection.hpp" #include "../blender/BlenderConnection.hpp"
#include "LogVisor/LogVisor.hpp" #include "logvisor/logvisor.hpp"
LogVisor::LogModule LogModule("HECLDriver"); logvisor::Module LogModule("HECLDriver");
#include "ToolBase.hpp" #include "ToolBase.hpp"
#include "ToolInit.hpp" #include "ToolInit.hpp"
@ -47,41 +47,41 @@ bool XTERM_COLOR = false;
*/ */
/* Main usage message */ /* Main usage message */
static void printHelp(const HECL::SystemChar* pname) static void printHelp(const hecl::SystemChar* pname)
{ {
if (XTERM_COLOR) if (XTERM_COLOR)
HECL::Printf(_S("" BOLD "HECL" NORMAL "")); hecl::Printf(_S("" BOLD "HECL" NORMAL ""));
else else
HECL::Printf(_S("HECL")); hecl::Printf(_S("HECL"));
#if HECL_GIT #if HECL_GIT
HECL::Printf(_S(" Commit " HECL_GIT_S " " HECL_BRANCH_S "\nUsage: %s init|add|remove|group|cook|clean|package|help\n"), pname); hecl::Printf(_S(" Commit " HECL_GIT_S " " HECL_BRANCH_S "\nUsage: %s init|add|remove|group|cook|clean|package|help\n"), pname);
#elif HECL_VER #elif HECL_VER
HECL::Printf(_S(" Version " HECL_VER_S "\nUsage: %s init|add|remove|group|cook|clean|package|help\n"), pname); hecl::Printf(_S(" Version " HECL_VER_S "\nUsage: %s init|add|remove|group|cook|clean|package|help\n"), pname);
#else #else
HECL::Printf(_S("\nUsage: %s init|add|remove|group|cook|clean|package|help\n"), pname); hecl::Printf(_S("\nUsage: %s init|add|remove|group|cook|clean|package|help\n"), pname);
#endif #endif
} }
/* Regex patterns */ /* Regex patterns */
static const HECL::SystemRegex regOPEN(_S("-o([^\"]*|\\S*)"), std::regex::ECMAScript|std::regex::optimize); static const hecl::SystemRegex regOPEN(_S("-o([^\"]*|\\S*)"), std::regex::ECMAScript|std::regex::optimize);
/* SIGINT will gracefully close blender connections and delete blends in progress */ /* SIGINT will gracefully close blender connections and delete blends in progress */
static void SIGINTHandler(int sig) static void SIGINTHandler(int sig)
{ {
HECL::BlenderConnection::Shutdown(); hecl::BlenderConnection::Shutdown();
exit(1); exit(1);
} }
/* SIGWINCH should do nothing */ /* SIGWINCH should do nothing */
static void SIGWINCHHandler(int sig) {} static void SIGWINCHHandler(int sig) {}
static LogVisor::LogModule AthenaLog("Athena"); static logvisor::Module AthenaLog("Athena");
static void AthenaExc(Athena::error::Level level, const char* file, static void AthenaExc(athena::error::Level level, const char* file,
const char*, int line, const char* fmt, ...) const char*, int line, const char* fmt, ...)
{ {
va_list ap; va_list ap;
va_start(ap, fmt); va_start(ap, fmt);
AthenaLog.reportSource(LogVisor::Level(level), file, line, fmt, ap); AthenaLog.reportSource(logvisor::Level(level), file, line, fmt, ap);
va_end(ap); va_end(ap);
} }
@ -110,7 +110,7 @@ int main(int argc, const char** argv)
#endif #endif
signal(SIGINT, SIGINTHandler); signal(SIGINT, SIGINTHandler);
LogVisor::RegisterConsoleLogger(); logvisor::RegisterConsoleLogger();
atSetExceptionHandler(AthenaExc); atSetExceptionHandler(AthenaExc);
/* Basic usage check */ /* Basic usage check */
@ -137,8 +137,8 @@ int main(int argc, const char** argv)
/* Assemble common tool pass info */ /* Assemble common tool pass info */
ToolPassInfo info; ToolPassInfo info;
info.pname = argv[0]; info.pname = argv[0];
HECL::SystemChar cwdbuf[1024]; hecl::SystemChar cwdbuf[1024];
if (HECL::Getcwd(cwdbuf, 1024)) if (hecl::Getcwd(cwdbuf, 1024))
{ {
info.cwd = cwdbuf; info.cwd = cwdbuf;
if (info.cwd.size() && info.cwd.back() != _S('/') && info.cwd.back() != _S('\\')) if (info.cwd.size() && info.cwd.back() != _S('/') && info.cwd.back() != _S('\\'))
@ -150,21 +150,21 @@ int main(int argc, const char** argv)
} }
/* Concatenate args */ /* Concatenate args */
std::vector<HECL::SystemString> args; std::vector<hecl::SystemString> args;
args.reserve(argc-2); args.reserve(argc-2);
for (int i=2 ; i<argc ; ++i) for (int i=2 ; i<argc ; ++i)
args.push_back(HECL::SystemString(argv[i])); args.push_back(hecl::SystemString(argv[i]));
if (!args.empty()) if (!args.empty())
{ {
/* Extract output argument */ /* Extract output argument */
for (auto it = args.cbegin() ; it != args.cend() ;) for (auto it = args.cbegin() ; it != args.cend() ;)
{ {
const HECL::SystemString& arg = *it; const hecl::SystemString& arg = *it;
HECL::SystemRegexMatch oMatch; hecl::SystemRegexMatch oMatch;
if (std::regex_search(arg, oMatch, regOPEN)) if (std::regex_search(arg, oMatch, regOPEN))
{ {
const HECL::SystemString& token = oMatch[1].str(); const hecl::SystemString& token = oMatch[1].str();
if (token.size()) if (token.size())
{ {
if (info.output.empty()) if (info.output.empty())
@ -188,7 +188,7 @@ int main(int argc, const char** argv)
/* Iterate flags */ /* Iterate flags */
for (auto it = args.cbegin() ; it != args.cend() ;) for (auto it = args.cbegin() ; it != args.cend() ;)
{ {
const HECL::SystemString& arg = *it; const hecl::SystemString& arg = *it;
if (arg.size() < 2 || arg[0] != _S('-') || arg[1] == _S('-')) if (arg.size() < 2 || arg[0] != _S('-') || arg[1] == _S('-'))
{ {
++it; ++it;
@ -210,18 +210,18 @@ int main(int argc, const char** argv)
/* Gather remaining args */ /* Gather remaining args */
info.args.reserve(args.size()); info.args.reserve(args.size());
for (const HECL::SystemString& arg : args) for (const hecl::SystemString& arg : args)
info.args.push_back(arg); info.args.push_back(arg);
} }
/* Attempt to find hecl project */ /* Attempt to find hecl project */
HECL::ProjectRootPath rootPath = HECL::SearchForProject(info.cwd); hecl::ProjectRootPath rootPath = hecl::SearchForProject(info.cwd);
std::unique_ptr<HECL::Database::Project> project; std::unique_ptr<hecl::Database::Project> project;
if (rootPath) if (rootPath)
{ {
size_t ErrorRef = LogVisor::ErrorCount; size_t ErrorRef = logvisor::ErrorCount;
HECL::Database::Project* newProj = new HECL::Database::Project(rootPath); hecl::Database::Project* newProj = new hecl::Database::Project(rootPath);
if (LogVisor::ErrorCount > ErrorRef) if (logvisor::ErrorCount > ErrorRef)
{ {
#if WIN_PAUSE #if WIN_PAUSE
system("PAUSE"); system("PAUSE");
@ -234,11 +234,11 @@ int main(int argc, const char** argv)
} }
/* Construct selected tool */ /* Construct selected tool */
HECL::SystemString toolName(argv[1]); hecl::SystemString toolName(argv[1]);
HECL::ToLower(toolName); hecl::ToLower(toolName);
std::unique_ptr<ToolBase> tool; std::unique_ptr<ToolBase> tool;
size_t ErrorRef = LogVisor::ErrorCount; size_t ErrorRef = logvisor::ErrorCount;
if (toolName == _S("init")) if (toolName == _S("init"))
tool.reset(new ToolInit(info)); tool.reset(new ToolInit(info));
else if (toolName == _S("spec")) else if (toolName == _S("spec"))
@ -261,9 +261,9 @@ int main(int argc, const char** argv)
tool.reset(new ToolHelp(info)); tool.reset(new ToolHelp(info));
else else
{ {
FILE* fp = HECL::Fopen(argv[1], _S("rb")); FILE* fp = hecl::Fopen(argv[1], _S("rb"));
if (!fp) if (!fp)
LogModule.report(LogVisor::Error, _S("unrecognized tool '%s'"), toolName.c_str()); LogModule.report(logvisor::Error, _S("unrecognized tool '%s'"), toolName.c_str());
else else
{ {
/* Shortcut-case: implicit extract */ /* Shortcut-case: implicit extract */
@ -273,7 +273,7 @@ int main(int argc, const char** argv)
} }
} }
if (LogVisor::ErrorCount > ErrorRef) if (logvisor::ErrorCount > ErrorRef)
{ {
#if WIN_PAUSE #if WIN_PAUSE
system("PAUSE"); system("PAUSE");
@ -282,22 +282,22 @@ int main(int argc, const char** argv)
} }
if (info.verbosityLevel) if (info.verbosityLevel)
LogModule.report(LogVisor::Info, _S("Constructed tool '%s' %d\n"), LogModule.report(logvisor::Info, _S("Constructed tool '%s' %d\n"),
tool->toolName().c_str(), info.verbosityLevel); tool->toolName().c_str(), info.verbosityLevel);
/* Run tool */ /* Run tool */
ErrorRef = LogVisor::ErrorCount; ErrorRef = logvisor::ErrorCount;
int retval = tool->run(); int retval = tool->run();
if (LogVisor::ErrorCount > ErrorRef) if (logvisor::ErrorCount > ErrorRef)
{ {
HECL::BlenderConnection::Shutdown(); hecl::BlenderConnection::Shutdown();
#if WIN_PAUSE #if WIN_PAUSE
system("PAUSE"); system("PAUSE");
#endif #endif
return -1; return -1;
} }
HECL::BlenderConnection::Shutdown(); hecl::BlenderConnection::Shutdown();
#if WIN_PAUSE #if WIN_PAUSE
system("PAUSE"); system("PAUSE");
#endif #endif

View File

@ -1,5 +1,5 @@
add_subdirectory(libBoo) add_subdirectory(boo)
add_subdirectory(libSquish) add_subdirectory(libSquish)
add_subdirectory(xxhash) add_subdirectory(xxhash)
add_subdirectory(Athena) add_subdirectory(athena)
add_subdirectory(libpng) add_subdirectory(libpng)

2
hecl/extern/athena vendored

@ -1 +1 @@
Subproject commit a0515fe4aa96a1c427d76192857fc5360d8ee63c Subproject commit b791b7e42698eb2f9e173af07368b888055730a8

2
hecl/extern/boo vendored

@ -1 +1 @@
Subproject commit 5c66d46cfe227f81c3ce0caeb3a3172ca929d9a9 Subproject commit 8ac929d140d25f9e6ba267a1a9b0a9a57fd81295

View File

@ -1,9 +1,9 @@
#ifndef HECLBACKEND_HPP #ifndef HECLBACKEND_HPP
#define HECLBACKEND_HPP #define HECLBACKEND_HPP
#include "HECL/Frontend.hpp" #include "hecl/Frontend.hpp"
namespace HECL namespace hecl
{ {
namespace Backend namespace Backend
{ {

View File

@ -3,7 +3,7 @@
#include "ProgrammableCommon.hpp" #include "ProgrammableCommon.hpp"
namespace HECL namespace hecl
{ {
namespace Backend namespace Backend
{ {
@ -26,7 +26,7 @@ private:
std::string EmitVec3(const atVec4f& vec) const std::string EmitVec3(const atVec4f& vec) const
{ {
return HECL::Format("vec3(%g,%g,%g)", vec.vec[0], vec.vec[1], vec.vec[2]); return hecl::Format("vec3(%g,%g,%g)", vec.vec[0], vec.vec[1], vec.vec[2]);
} }
std::string EmitTexGenSource2(TexGenSrc src, int uvIdx) const; std::string EmitTexGenSource2(TexGenSrc src, int uvIdx) const;

View File

@ -2,12 +2,12 @@
#define HECLBACKEND_GX_HPP #define HECLBACKEND_GX_HPP
#include "Backend.hpp" #include "Backend.hpp"
#include <Athena/DNA.hpp> #include <athena/DNA.hpp>
#include <stdint.h> #include <stdint.h>
#include <stdlib.h> #include <stdlib.h>
#include <algorithm> #include <algorithm>
namespace HECL namespace hecl
{ {
namespace Backend namespace Backend
{ {
@ -405,7 +405,7 @@ struct GX : IBackend
BlendFactor m_blendSrc; BlendFactor m_blendSrc;
BlendFactor m_blendDst; BlendFactor m_blendDst;
struct Color : Athena::io::DNA<Athena::BigEndian> struct Color : athena::io::DNA<athena::BigEndian>
{ {
union union
{ {
@ -445,9 +445,9 @@ struct GX : IBackend
uint8_t operator[](size_t idx) const {return color[idx];} uint8_t operator[](size_t idx) const {return color[idx];}
uint8_t& operator[](size_t idx) {return color[idx];} uint8_t& operator[](size_t idx) {return color[idx];}
void read(Athena::io::IStreamReader& reader) void read(athena::io::IStreamReader& reader)
{reader.readUBytesToBuf(&num, 4);} {reader.readUBytesToBuf(&num, 4);}
void write(Athena::io::IStreamWriter& writer) const void write(athena::io::IStreamWriter& writer) const
{writer.writeUBytes(reinterpret_cast<const atUint8*>(&num), 4);} {writer.writeUBytes(reinterpret_cast<const atUint8*>(&num), 4);}
size_t binarySize(size_t __isz) const size_t binarySize(size_t __isz) const
{return __isz + 4;} {return __isz + 4;}

View File

@ -3,7 +3,7 @@
#include "ProgrammableCommon.hpp" #include "ProgrammableCommon.hpp"
namespace HECL namespace hecl
{ {
namespace Backend namespace Backend
{ {
@ -24,7 +24,7 @@ private:
std::string EmitVec3(const atVec4f& vec) const std::string EmitVec3(const atVec4f& vec) const
{ {
return HECL::Format("float3(%g,%g,%g)", vec.vec[0], vec.vec[1], vec.vec[2]); return hecl::Format("float3(%g,%g,%g)", vec.vec[0], vec.vec[1], vec.vec[2]);
} }
std::string EmitTexGenSource2(TexGenSrc src, int uvIdx) const; std::string EmitTexGenSource2(TexGenSrc src, int uvIdx) const;

View File

@ -2,7 +2,7 @@
#define HECLBACKEND_METAL_HPP #define HECLBACKEND_METAL_HPP
#if BOO_HAS_METAL #if BOO_HAS_METAL
namespace HECL namespace hecl
{ {
namespace Backend namespace Backend
{ {
@ -23,7 +23,7 @@ private:
std::string EmitVec3(const atVec4f& vec) const std::string EmitVec3(const atVec4f& vec) const
{ {
return HECL::Format("float3(%g,%g,%g)", vec.vec[0], vec.vec[1], vec.vec[2]); return hecl::Format("float3(%g,%g,%g)", vec.vec[0], vec.vec[1], vec.vec[2]);
} }
std::string EmitTexGenSource2(TexGenSrc src, int uvIdx) const; std::string EmitTexGenSource2(TexGenSrc src, int uvIdx) const;

View File

@ -2,14 +2,14 @@
#define HECLBACKEND_PROGCOMMON_HPP #define HECLBACKEND_PROGCOMMON_HPP
#include "Backend.hpp" #include "Backend.hpp"
#include "HECL/Runtime.hpp" #include "hecl/Runtime.hpp"
#include <Athena/DNA.hpp> #include <athena/DNA.hpp>
#include <boo/graphicsdev/IGraphicsDataFactory.hpp> #include <boo/graphicsdev/IGraphicsDataFactory.hpp>
#include <stdint.h> #include <stdint.h>
#include <stdlib.h> #include <stdlib.h>
#include <algorithm> #include <algorithm>
namespace HECL namespace hecl
{ {
namespace Backend namespace Backend
{ {
@ -65,17 +65,17 @@ private:
std::string EmitSamplingUseRGB(unsigned samplingIdx) const std::string EmitSamplingUseRGB(unsigned samplingIdx) const
{ {
return HECL::Format("sampling%u.rgb", samplingIdx); return hecl::Format("sampling%u.rgb", samplingIdx);
} }
std::string EmitSamplingUseAlpha(unsigned samplingIdx) const std::string EmitSamplingUseAlpha(unsigned samplingIdx) const
{ {
return HECL::Format("sampling%u.a", samplingIdx); return hecl::Format("sampling%u.a", samplingIdx);
} }
std::string EmitColorRegUse(unsigned idx) const std::string EmitColorRegUse(unsigned idx) const
{ {
return HECL::Format("colorReg%u", idx); return hecl::Format("colorReg%u", idx);
} }
std::string EmitLighting() const std::string EmitLighting() const
@ -87,7 +87,7 @@ private:
std::string EmitVal(float val) const std::string EmitVal(float val) const
{ {
return HECL::Format("%g", val); return hecl::Format("%g", val);
} }
std::string EmitAdd(const std::string& a, const std::string& b) const std::string EmitAdd(const std::string& a, const std::string& b) const

View File

@ -3,11 +3,11 @@
#include <string> #include <string>
#include <functional> #include <functional>
#include <Athena/Types.hpp> #include <athena/Types.hpp>
#include <Athena/Global.hpp> #include <athena/Global.hpp>
#include <Athena/DNAYaml.hpp> #include <athena/DNAYaml.hpp>
namespace HECL namespace hecl
{ {
namespace DNACVAR namespace DNACVAR
{ {
@ -35,7 +35,7 @@ enum EFlags
}; };
ENABLE_BITWISE_ENUM(EFlags) ENABLE_BITWISE_ENUM(EFlags)
class CVar : public Athena::io::DNAYaml<Athena::BigEndian> class CVar : public athena::io::DNAYaml<athena::BigEndian>
{ {
public: public:
DECL_YAML DECL_YAML
@ -44,7 +44,7 @@ public:
Value<EType> m_type; Value<EType> m_type;
}; };
struct CVarContainer : public Athena::io::DNAYaml<Athena::BigEndian> struct CVarContainer : public athena::io::DNAYaml<athena::BigEndian>
{ {
DECL_YAML DECL_YAML
Value<atUint32> magic = 'CVAR'; Value<atUint32> magic = 'CVAR';

View File

@ -5,7 +5,7 @@
#include <vector> #include <vector>
#include "CVar.hpp" #include "CVar.hpp"
namespace HECL namespace hecl
{ {
namespace Runtime namespace Runtime
{ {
@ -29,7 +29,7 @@ class CVarManager final
return nullptr; return nullptr;
} }
HECL::Runtime::FileStoreManager& m_store; hecl::Runtime::FileStoreManager& m_store;
bool m_useBinary; bool m_useBinary;
static CVarManager* m_instance; static CVarManager* m_instance;
public: public:
@ -37,7 +37,7 @@ public:
CVarManager(const CVarManager&) = delete; CVarManager(const CVarManager&) = delete;
CVarManager& operator=(const CVarManager&) = delete; CVarManager& operator=(const CVarManager&) = delete;
CVarManager& operator=(const CVarManager&&) = delete; CVarManager& operator=(const CVarManager&&) = delete;
CVarManager(HECL::Runtime::FileStoreManager& store, bool useBinary = false); CVarManager(hecl::Runtime::FileStoreManager& store, bool useBinary = false);
~CVarManager(); ~CVarManager();
void update(); void update();

View File

@ -15,20 +15,20 @@
#include <stdint.h> #include <stdint.h>
#include <assert.h> #include <assert.h>
#include <Athena/IStreamReader.hpp> #include <athena/IStreamReader.hpp>
#include <LogVisor/LogVisor.hpp> #include "logvisor/logvisor.hpp"
#include "HECL.hpp" #include "hecl.hpp"
namespace HECL namespace hecl
{ {
namespace Database namespace Database
{ {
class Project; class Project;
extern LogVisor::LogModule LogModule; extern logvisor::Module LogModule;
typedef std::function<void(const HECL::SystemChar*, const HECL::SystemChar*, int, float)> FProgress; typedef std::function<void(const hecl::SystemChar*, const hecl::SystemChar*, int, float)> FProgress;
/** /**
* @brief Nodegraph class for gathering dependency-resolved objects for packaging * @brief Nodegraph class for gathering dependency-resolved objects for packaging
@ -66,7 +66,7 @@ class IDataSpec
{ {
public: public:
virtual ~IDataSpec() {} virtual ~IDataSpec() {}
using FProgress = HECL::Database::FProgress; using FProgress = hecl::Database::FProgress;
using FCookProgress = std::function<void(const SystemChar*)>; using FCookProgress = std::function<void(const SystemChar*)>;
/** /**
@ -96,12 +96,12 @@ public:
}; };
virtual bool canExtract(const ExtractPassInfo& info, std::vector<ExtractReport>& reps) virtual bool canExtract(const ExtractPassInfo& info, std::vector<ExtractReport>& reps)
{(void)info;(void)reps;LogModule.report(LogVisor::Error, "not implemented");return false;} {(void)info;(void)reps;LogModule.report(logvisor::Error, "not implemented");return false;}
virtual void doExtract(const ExtractPassInfo& info, FProgress progress) virtual void doExtract(const ExtractPassInfo& info, FProgress progress)
{(void)info;(void)progress;} {(void)info;(void)progress;}
virtual bool canCook(const ProjectPath& path) virtual bool canCook(const ProjectPath& path)
{(void)path;LogModule.report(LogVisor::Error, "not implemented");return false;} {(void)path;LogModule.report(logvisor::Error, "not implemented");return false;}
virtual void doCook(const ProjectPath& path, const ProjectPath& cookedPath, virtual void doCook(const ProjectPath& path, const ProjectPath& cookedPath,
bool fast, FCookProgress progress) bool fast, FCookProgress progress)
{(void)path;(void)cookedPath;(void)fast;(void)progress;} {(void)path;(void)cookedPath;(void)fast;(void)progress;}
@ -263,7 +263,7 @@ private:
std::vector<ProjectDataSpec> m_compiledSpecs; std::vector<ProjectDataSpec> m_compiledSpecs;
bool m_valid = false; bool m_valid = false;
public: public:
Project(const HECL::ProjectRootPath& rootPath); Project(const hecl::ProjectRootPath& rootPath);
operator bool() const {return m_valid;} operator bool() const {return m_valid;}
/** /**
@ -330,7 +330,7 @@ public:
for (const ProjectDataSpec& sp : m_compiledSpecs) for (const ProjectDataSpec& sp : m_compiledSpecs)
if (&sp.spec == &spec) if (&sp.spec == &spec)
return sp.cookedPath; return sp.cookedPath;
LogModule.report(LogVisor::FatalError, "Unable to find spec '%s'", spec.m_name); LogModule.report(logvisor::Fatal, "Unable to find spec '%s'", spec.m_name);
return m_cookedRoot; return m_cookedRoot;
} }
@ -380,7 +380,7 @@ public:
/** /**
* @brief Re-reads the data store holding user's spec preferences * @brief Re-reads the data store holding user's spec preferences
* *
* Call periodically in a long-term use of the HECL::Database::Project class. * Call periodically in a long-term use of the hecl::Database::Project class.
* Install filesystem event-hooks if possible. * Install filesystem event-hooks if possible.
*/ */
void rescanDataSpecs(); void rescanDataSpecs();

View File

@ -4,11 +4,11 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include <forward_list> #include <forward_list>
#include <Athena/Types.hpp> #include <athena/Types.hpp>
#include <Athena/DNA.hpp> #include <athena/DNA.hpp>
#include <HECL/HECL.hpp> #include <hecl/hecl.hpp>
namespace HECL namespace hecl
{ {
namespace Frontend namespace Frontend
{ {
@ -113,7 +113,7 @@ public:
Parser(Diagnostics& diag) : m_diag(diag) {} Parser(Diagnostics& diag) : m_diag(diag) {}
}; };
using BigDNA = Athena::io::DNA<Athena::BigEndian>; using BigDNA = athena::io::DNA<athena::BigEndian>;
struct IR : BigDNA struct IR : BigDNA
{ {
@ -188,7 +188,7 @@ struct IR : BigDNA
case OpType::Swizzle: case OpType::Swizzle:
return 1; return 1;
default: default:
LogModule.report(LogVisor::FatalError, "invalid op type"); LogModule.report(logvisor::Fatal, "invalid op type");
} }
return -1; return -1;
} }
@ -201,14 +201,14 @@ struct IR : BigDNA
return ir.m_instructions.at(m_call.m_argInstIdxs.at(idx)); return ir.m_instructions.at(m_call.m_argInstIdxs.at(idx));
case OpType::Arithmetic: case OpType::Arithmetic:
if (idx > 1) if (idx > 1)
LogModule.report(LogVisor::FatalError, "arithmetic child idx must be 0 or 1"); LogModule.report(logvisor::Fatal, "arithmetic child idx must be 0 or 1");
return ir.m_instructions.at(m_arithmetic.m_instIdxs[idx]); return ir.m_instructions.at(m_arithmetic.m_instIdxs[idx]);
case OpType::Swizzle: case OpType::Swizzle:
if (idx > 0) if (idx > 0)
LogModule.report(LogVisor::FatalError, "swizzle child idx must be 0"); LogModule.report(logvisor::Fatal, "swizzle child idx must be 0");
return ir.m_instructions.at(m_swizzle.m_instIdx); return ir.m_instructions.at(m_swizzle.m_instIdx);
default: default:
LogModule.report(LogVisor::FatalError, "invalid op type"); LogModule.report(logvisor::Fatal, "invalid op type");
} }
return *this; return *this;
} }
@ -216,11 +216,11 @@ struct IR : BigDNA
const atVec4f& getImmVec() const const atVec4f& getImmVec() const
{ {
if (m_op != OpType::LoadImm) if (m_op != OpType::LoadImm)
LogModule.report(LogVisor::FatalError, "invalid op type"); LogModule.report(logvisor::Fatal, "invalid op type");
return m_loadImm.m_immVec; return m_loadImm.m_immVec;
} }
void read(Athena::io::IStreamReader& reader) void read(athena::io::IStreamReader& reader)
{ {
m_op = OpType(reader.readUByte()); m_op = OpType(reader.readUByte());
m_target = reader.readUint16Big(); m_target = reader.readUint16Big();
@ -242,7 +242,7 @@ struct IR : BigDNA
} }
} }
void write(Athena::io::IStreamWriter& writer) const void write(athena::io::IStreamWriter& writer) const
{ {
writer.writeUByte(m_op); writer.writeUByte(m_op);
writer.writeUint16Big(m_target); writer.writeUint16Big(m_target);
@ -286,14 +286,14 @@ struct IR : BigDNA
return sz; return sz;
} }
Instruction(Athena::io::IStreamReader& reader) {read(reader);} Instruction(athena::io::IStreamReader& reader) {read(reader);}
}; };
atUint64 m_hash = 0; atUint64 m_hash = 0;
atUint16 m_regCount = 0; atUint16 m_regCount = 0;
std::vector<Instruction> m_instructions; std::vector<Instruction> m_instructions;
void read(Athena::io::IStreamReader& reader) void read(athena::io::IStreamReader& reader)
{ {
m_hash = reader.readUint64Big(); m_hash = reader.readUint64Big();
m_regCount = reader.readUint16Big(); m_regCount = reader.readUint16Big();
@ -304,7 +304,7 @@ struct IR : BigDNA
m_instructions.emplace_back(reader); m_instructions.emplace_back(reader);
} }
void write(Athena::io::IStreamWriter& writer) const void write(athena::io::IStreamWriter& writer) const
{ {
writer.writeUint64Big(m_hash); writer.writeUint64Big(m_hash);
writer.writeUint16Big(m_regCount); writer.writeUint16Big(m_regCount);

View File

@ -1,10 +1,10 @@
#ifndef HMDLMETA_HPP #ifndef HMDLMETA_HPP
#define HMDLMETA_HPP #define HMDLMETA_HPP
#include <HECL/HECL.hpp> #include <hecl/hecl.hpp>
#include <Athena/DNA.hpp> #include <athena/DNA.hpp>
namespace HECL namespace hecl
{ {
enum class HMDLTopology : atUint32 enum class HMDLTopology : atUint32
@ -15,7 +15,7 @@ enum class HMDLTopology : atUint32
#define HECL_HMDL_META_SZ 32 #define HECL_HMDL_META_SZ 32
struct HMDLMeta : Athena::io::DNA<Athena::BigEndian> struct HMDLMeta : athena::io::DNA<athena::BigEndian>
{ {
DECL_DNA DECL_DNA
Value<atUint32> magic = 'TACO'; Value<atUint32> magic = 'TACO';

View File

@ -1,14 +1,14 @@
#ifndef HECLRUNTIME_HPP #ifndef HECLRUNTIME_HPP
#define HECLRUNTIME_HPP #define HECLRUNTIME_HPP
#include "HECL.hpp" #include "hecl.hpp"
#include "Frontend.hpp" #include "Frontend.hpp"
#include <boo/graphicsdev/IGraphicsDataFactory.hpp> #include <boo/graphicsdev/IGraphicsDataFactory.hpp>
#include <Athena/DNA.hpp> #include <athena/DNA.hpp>
#include <Athena/FileReader.hpp> #include <athena/FileReader.hpp>
#include <unordered_map> #include <unordered_map>
namespace HECL namespace hecl
{ {
struct HMDLMeta; struct HMDLMeta;
@ -59,7 +59,7 @@ public:
: Hash(source), m_colorCount(c), m_uvCount(u), m_weightCount(w), m_skinSlotCount(s), m_texMtxCount(t), : Hash(source), m_colorCount(c), m_uvCount(u), m_weightCount(w), m_skinSlotCount(s), m_texMtxCount(t),
m_depthTest(depthTest), m_depthWrite(depthWrite), m_backfaceCulling(backfaceCulling) m_depthTest(depthTest), m_depthWrite(depthWrite), m_backfaceCulling(backfaceCulling)
{hash ^= m_meta;} {hash ^= m_meta;}
ShaderTag(const HECL::Frontend::IR& ir, uint8_t c, uint8_t u, uint8_t w, uint8_t s, uint8_t t, ShaderTag(const hecl::Frontend::IR& ir, uint8_t c, uint8_t u, uint8_t w, uint8_t s, uint8_t t,
bool depthTest, bool depthWrite, bool backfaceCulling) bool depthTest, bool depthWrite, bool backfaceCulling)
: Hash(ir.m_hash), m_colorCount(c), m_uvCount(u), m_weightCount(w), m_skinSlotCount(s), m_texMtxCount(t), : Hash(ir.m_hash), m_colorCount(c), m_uvCount(u), m_weightCount(w), m_skinSlotCount(s), m_texMtxCount(t),
m_depthTest(depthTest), m_depthWrite(depthWrite), m_backfaceCulling(backfaceCulling) m_depthTest(depthTest), m_depthWrite(depthWrite), m_backfaceCulling(backfaceCulling)
@ -157,13 +157,13 @@ protected:
unsigned m_rtHint = 1; unsigned m_rtHint = 1;
using FReturnExtensionShader = std::function<void(boo::IShaderPipeline*)>; using FReturnExtensionShader = std::function<void(boo::IShaderPipeline*)>;
virtual ShaderCachedData buildShaderFromIR(const ShaderTag& tag, virtual ShaderCachedData buildShaderFromIR(const ShaderTag& tag,
const HECL::Frontend::IR& ir, const hecl::Frontend::IR& ir,
HECL::Frontend::Diagnostics& diag, hecl::Frontend::Diagnostics& diag,
boo::IShaderPipeline*& objOut)=0; boo::IShaderPipeline*& objOut)=0;
virtual boo::IShaderPipeline* buildShaderFromCache(const ShaderCachedData& data)=0; virtual boo::IShaderPipeline* buildShaderFromCache(const ShaderCachedData& data)=0;
virtual ShaderCachedData buildExtendedShaderFromIR(const ShaderTag& tag, virtual ShaderCachedData buildExtendedShaderFromIR(const ShaderTag& tag,
const HECL::Frontend::IR& ir, const hecl::Frontend::IR& ir,
HECL::Frontend::Diagnostics& diag, hecl::Frontend::Diagnostics& diag,
const std::vector<ShaderCacheExtensions::ExtensionSlot>& extensionSlots, const std::vector<ShaderCacheExtensions::ExtensionSlot>& extensionSlots,
FReturnExtensionShader returnFunc)=0; FReturnExtensionShader returnFunc)=0;
virtual void buildExtendedShaderFromCache(const ShaderCachedData& data, virtual void buildExtendedShaderFromCache(const ShaderCachedData& data,
@ -182,10 +182,10 @@ class ShaderCacheManager
ShaderCacheExtensions m_extensions; ShaderCacheExtensions m_extensions;
uint64_t m_extensionsHash = 0; uint64_t m_extensionsHash = 0;
std::unique_ptr<IShaderBackendFactory> m_factory; std::unique_ptr<IShaderBackendFactory> m_factory;
Athena::io::FileReader m_idxFr; athena::io::FileReader m_idxFr;
Athena::io::FileReader m_datFr; athena::io::FileReader m_datFr;
HECL::Frontend::Frontend FE; hecl::Frontend::Frontend FE;
struct IndexEntry : Athena::io::DNA<Athena::BigEndian> struct IndexEntry : athena::io::DNA<athena::BigEndian>
{ {
DECL_DNA DECL_DNA
Value<atUint64> m_hash; Value<atUint64> m_hash;
@ -217,11 +217,11 @@ public:
boo::IShaderPipeline* buildShader(const ShaderTag& tag, const std::string& source, boo::IShaderPipeline* buildShader(const ShaderTag& tag, const std::string& source,
const std::string& diagName); const std::string& diagName);
boo::IShaderPipeline* buildShader(const ShaderTag& tag, const HECL::Frontend::IR& ir, boo::IShaderPipeline* buildShader(const ShaderTag& tag, const hecl::Frontend::IR& ir,
const std::string& diagName); const std::string& diagName);
std::vector<boo::IShaderPipeline*> buildExtendedShader(const ShaderTag& tag, const std::string& source, std::vector<boo::IShaderPipeline*> buildExtendedShader(const ShaderTag& tag, const std::string& source,
const std::string& diagName); const std::string& diagName);
std::vector<boo::IShaderPipeline*> buildExtendedShader(const ShaderTag& tag, const HECL::Frontend::IR& ir, std::vector<boo::IShaderPipeline*> buildExtendedShader(const ShaderTag& tag, const hecl::Frontend::IR& ir,
const std::string& diagName); const std::string& diagName);
}; };
@ -254,9 +254,9 @@ struct HMDLData
namespace std namespace std
{ {
template <> struct hash<HECL::Runtime::ShaderTag> template <> struct hash<hecl::Runtime::ShaderTag>
{ {
size_t operator()(const HECL::Runtime::ShaderTag& val) const NOEXCEPT size_t operator()(const hecl::Runtime::ShaderTag& val) const NOEXCEPT
{return val.valSizeT();} {return val.valSizeT();}
}; };
} }

View File

@ -32,11 +32,11 @@
#include <regex> #include <regex>
#include <list> #include <list>
#include <map> #include <map>
#include <LogVisor/LogVisor.hpp> #include "logvisor/logvisor.hpp"
#include <Athena/Global.hpp> #include <athena/Global.hpp>
#include "../extern/xxhash/xxhash.h" #include "../extern/xxhash/xxhash.h"
namespace HECL namespace hecl
{ {
namespace Database namespace Database
{ {
@ -46,7 +46,7 @@ struct DataSpecEntry;
extern unsigned VerbosityLevel; extern unsigned VerbosityLevel;
extern LogVisor::LogModule LogModule; extern logvisor::Module LogModule;
#if _WIN32 && UNICODE #if _WIN32 && UNICODE
#define HECL_UCS2 1 #define HECL_UCS2 1
@ -176,11 +176,11 @@ static inline void MakeDir(const char* dir)
HRESULT err; HRESULT err;
if (!CreateDirectoryA(dir, NULL)) if (!CreateDirectoryA(dir, NULL))
if ((err = GetLastError()) != ERROR_ALREADY_EXISTS) if ((err = GetLastError()) != ERROR_ALREADY_EXISTS)
LogModule.report(LogVisor::FatalError, _S("MakeDir(%s)"), dir); LogModule.report(logvisor::Fatal, _S("MakeDir(%s)"), dir);
#else #else
if (mkdir(dir, 0755)) if (mkdir(dir, 0755))
if (errno != EEXIST) if (errno != EEXIST)
LogModule.report(LogVisor::FatalError, "MakeDir(%s): %s", dir, strerror(errno)); LogModule.report(logvisor::Fatal, "MakeDir(%s): %s", dir, strerror(errno));
#endif #endif
} }
@ -190,7 +190,7 @@ static inline void MakeDir(const wchar_t* dir)
HRESULT err; HRESULT err;
if (!CreateDirectoryW(dir, NULL)) if (!CreateDirectoryW(dir, NULL))
if ((err = GetLastError()) != ERROR_ALREADY_EXISTS) if ((err = GetLastError()) != ERROR_ALREADY_EXISTS)
LogModule.report(LogVisor::FatalError, _S("MakeDir(%s)"), dir); LogModule.report(logvisor::Fatal, _S("MakeDir(%s)"), dir);
} }
#endif #endif
@ -215,7 +215,7 @@ static SystemString GetcwdStr()
if (errno != ERANGE) if (errno != ERANGE)
{ {
// It's not ERANGE, so we don't know how to handle it // It's not ERANGE, so we don't know how to handle it
LogModule.report(LogVisor::FatalError, "Cannot determine the current path."); LogModule.report(logvisor::Fatal, "Cannot determine the current path.");
// Of course you may choose a different error reporting method // Of course you may choose a different error reporting method
} }
// Ok, the stack buffer isn't long enough; fallback to heap allocation // Ok, the stack buffer isn't long enough; fallback to heap allocation
@ -229,11 +229,11 @@ static SystemString GetcwdStr()
if (errno != ERANGE) if (errno != ERANGE)
{ {
// It's not ERANGE, so we don't know how to handle it // It's not ERANGE, so we don't know how to handle it
LogModule.report(LogVisor::FatalError, "Cannot determine the current path."); LogModule.report(logvisor::Fatal, "Cannot determine the current path.");
// Of course you may choose a different error reporting method // Of course you may choose a different error reporting method
} }
} }
LogModule.report(LogVisor::FatalError, "Cannot determine the current path; the path is apparently unreasonably long"); LogModule.report(logvisor::Fatal, "Cannot determine the current path; the path is apparently unreasonably long");
return SystemString(); return SystemString();
} }
@ -276,7 +276,7 @@ static inline FILE* Fopen(const SystemChar* path, const SystemChar* mode, FileLo
LockFileEx((HANDLE)(uintptr_t)_fileno(fp), (lock == FileLockType::Write) ? LOCKFILE_EXCLUSIVE_LOCK : 0, 0, 0, 1, &ov); LockFileEx((HANDLE)(uintptr_t)_fileno(fp), (lock == FileLockType::Write) ? LOCKFILE_EXCLUSIVE_LOCK : 0, 0, 0, 1, &ov);
#else #else
if (flock(fileno(fp), ((lock == FileLockType::Write) ? LOCK_EX : LOCK_SH) | LOCK_NB)) if (flock(fileno(fp), ((lock == FileLockType::Write) ? LOCK_EX : LOCK_SH) | LOCK_NB))
LogModule.report(LogVisor::Error, "flock %s: %s", path, strerror(errno)); LogModule.report(logvisor::Error, "flock %s: %s", path, strerror(errno));
#endif #endif
} }
@ -434,16 +434,16 @@ static inline bool CheckFreeSpace(const SystemChar* path, size_t reqSz)
wchar_t* end; wchar_t* end;
DWORD ret = GetFullPathNameW(path, 1024, buf, &end); DWORD ret = GetFullPathNameW(path, 1024, buf, &end);
if (!ret || ret > 1024) if (!ret || ret > 1024)
LogModule.report(LogVisor::FatalError, _S("GetFullPathNameW %s"), path); LogModule.report(logvisor::Fatal, _S("GetFullPathNameW %s"), path);
if (end) if (end)
end[0] = L'\0'; end[0] = L'\0';
if (!GetDiskFreeSpaceExW(buf, &freeBytes, nullptr, nullptr)) if (!GetDiskFreeSpaceExW(buf, &freeBytes, nullptr, nullptr))
LogModule.report(LogVisor::FatalError, _S("GetDiskFreeSpaceExW %s: %d"), path, GetLastError()); LogModule.report(logvisor::Fatal, _S("GetDiskFreeSpaceExW %s: %d"), path, GetLastError());
return reqSz < freeBytes.QuadPart; return reqSz < freeBytes.QuadPart;
#else #else
struct statvfs svfs; struct statvfs svfs;
if (statvfs(path, &svfs)) if (statvfs(path, &svfs))
LogModule.report(LogVisor::FatalError, "statvfs %s: %s", path, strerror(errno)); LogModule.report(logvisor::Fatal, "statvfs %s: %s", path, strerror(errno));
return reqSz < svfs.f_frsize * svfs.f_bavail; return reqSz < svfs.f_frsize * svfs.f_bavail;
#endif #endif
} }
@ -602,14 +602,14 @@ public:
}; };
struct Entry struct Entry
{ {
HECL::SystemString m_path; hecl::SystemString m_path;
HECL::SystemString m_name; hecl::SystemString m_name;
size_t m_fileSz; size_t m_fileSz;
bool m_isDir; bool m_isDir;
private: private:
friend class DirectoryEnumerator; friend class DirectoryEnumerator;
Entry(HECL::SystemString&& path, const HECL::SystemChar* name, size_t sz, bool isDir) Entry(hecl::SystemString&& path, const hecl::SystemChar* name, size_t sz, bool isDir)
: m_path(std::move(path)), m_name(name), m_fileSz(sz), m_isDir(isDir) {} : m_path(std::move(path)), m_name(name), m_fileSz(sz), m_isDir(isDir) {}
}; };
@ -617,10 +617,10 @@ private:
std::vector<Entry> m_entries; std::vector<Entry> m_entries;
public: public:
DirectoryEnumerator(const HECL::SystemString& path, Mode mode=Mode::DirsThenFilesSorted, DirectoryEnumerator(const hecl::SystemString& path, Mode mode=Mode::DirsThenFilesSorted,
bool sizeSort=false, bool reverse=false, bool noHidden=false) bool sizeSort=false, bool reverse=false, bool noHidden=false)
: DirectoryEnumerator(path.c_str(), mode, sizeSort, reverse, noHidden) {} : DirectoryEnumerator(path.c_str(), mode, sizeSort, reverse, noHidden) {}
DirectoryEnumerator(const HECL::SystemChar* path, Mode mode=Mode::DirsThenFilesSorted, DirectoryEnumerator(const hecl::SystemChar* path, Mode mode=Mode::DirsThenFilesSorted,
bool sizeSort=false, bool reverse=false, bool noHidden=false); bool sizeSort=false, bool reverse=false, bool noHidden=false);
operator bool() const {return m_entries.size() != 0;} operator bool() const {return m_entries.size() != 0;}
@ -632,7 +632,7 @@ public:
/** /**
* @brief Build list of common OS-specific directories * @brief Build list of common OS-specific directories
*/ */
std::vector<std::pair<HECL::SystemString, std::string>> GetSystemLocations(); std::vector<std::pair<hecl::SystemString, std::string>> GetSystemLocations();
/** /**
* @brief Special ProjectRootPath class for opening HECLDatabase::IProject instances * @brief Special ProjectRootPath class for opening HECLDatabase::IProject instances
@ -690,7 +690,7 @@ public:
return SystemString(beginIt, absPath.cend()); return SystemString(beginIt, absPath.cend());
} }
} }
LogModule.report(LogVisor::FatalError, "unable to resolve '%s' as project relative '%s'", LogModule.report(logvisor::Fatal, "unable to resolve '%s' as project relative '%s'",
absPath.c_str(), m_projRoot.c_str()); absPath.c_str(), m_projRoot.c_str());
return SystemString(); return SystemString();
} }
@ -881,7 +881,7 @@ public:
ProjectPath getParentPath() const ProjectPath getParentPath() const
{ {
if (m_relPath == _S(".")) if (m_relPath == _S("."))
LogModule.report(LogVisor::FatalError, "attempted to resolve parent of root project path"); LogModule.report(logvisor::Fatal, "attempted to resolve parent of root project path");
size_t pos = m_relPath.rfind(_S('/')); size_t pos = m_relPath.rfind(_S('/'));
if (pos == SystemString::npos) if (pos == SystemString::npos)
return ProjectPath(*m_proj, _S("")); return ProjectPath(*m_proj, _S(""));
@ -936,9 +936,9 @@ public:
* @brief Build vector of project-relative directory/file components * @brief Build vector of project-relative directory/file components
* @return Vector of path components * @return Vector of path components
*/ */
std::vector<HECL::SystemString> getPathComponents() const std::vector<hecl::SystemString> getPathComponents() const
{ {
std::vector<HECL::SystemString> ret; std::vector<hecl::SystemString> ret;
if (m_relPath.empty()) if (m_relPath.empty())
return ret; return ret;
auto it = m_relPath.cbegin(); auto it = m_relPath.cbegin();
@ -947,7 +947,7 @@ public:
ret.push_back(_S("/")); ret.push_back(_S("/"));
++it; ++it;
} }
HECL::SystemString comp; hecl::SystemString comp;
for (; it != m_relPath.cend() ; ++it) for (; it != m_relPath.cend() ; ++it)
{ {
if (*it == _S('/')) if (*it == _S('/'))
@ -1061,7 +1061,7 @@ public:
/** /**
* @brief Construct DirectoryEnumerator set to project path * @brief Construct DirectoryEnumerator set to project path
*/ */
HECL::DirectoryEnumerator enumerateDir() const; hecl::DirectoryEnumerator enumerateDir() const;
/** /**
* @brief Insert glob matches into existing vector * @brief Insert glob matches into existing vector
@ -1097,7 +1097,7 @@ public:
Database::Project& getProject() const Database::Project& getProject() const
{ {
if (!m_proj) if (!m_proj)
LogModule.report(LogVisor::FatalError, "ProjectPath::getProject() called on unqualified path"); LogModule.report(logvisor::Fatal, "ProjectPath::getProject() called on unqualified path");
return *m_proj; return *m_proj;
} }
@ -1131,21 +1131,21 @@ ProjectRootPath SearchForProject(const SystemString& path, SystemString& subpath
* @param path Path to test * @param path Path to test
* @return true if PNG * @return true if PNG
*/ */
bool IsPathPNG(const HECL::ProjectPath& path); bool IsPathPNG(const hecl::ProjectPath& path);
/** /**
* @brief Test if given path is a blend (based on file header) * @brief Test if given path is a blend (based on file header)
* @param path Path to test * @param path Path to test
* @return true if blend * @return true if blend
*/ */
bool IsPathBlend(const HECL::ProjectPath& path); bool IsPathBlend(const hecl::ProjectPath& path);
/** /**
* @brief Test if given path is a yaml (based on file extension) * @brief Test if given path is a yaml (based on file extension)
* @param path Path to test * @param path Path to test
* @return true if yaml * @return true if yaml
*/ */
bool IsPathYAML(const HECL::ProjectPath& path); bool IsPathYAML(const hecl::ProjectPath& path);
#undef bswap16 #undef bswap16
#undef bswap32 #undef bswap32
@ -1244,19 +1244,19 @@ static inline uint64_t SBig(uint64_t val) {return val;}
namespace std namespace std
{ {
template <> struct hash<HECL::FourCC> template <> struct hash<hecl::FourCC>
{ {
size_t operator()(const HECL::FourCC& val) const NOEXCEPT size_t operator()(const hecl::FourCC& val) const NOEXCEPT
{return val.toUint32();} {return val.toUint32();}
}; };
template <> struct hash<HECL::ProjectPath> template <> struct hash<hecl::ProjectPath>
{ {
size_t operator()(const HECL::ProjectPath& val) const NOEXCEPT size_t operator()(const hecl::ProjectPath& val) const NOEXCEPT
{return val.hash().valSizeT();} {return val.hash().valSizeT();}
}; };
template <> struct hash<HECL::Hash> template <> struct hash<hecl::Hash>
{ {
size_t operator()(const HECL::Hash& val) const NOEXCEPT size_t operator()(const hecl::Hash& val) const NOEXCEPT
{return val.valSizeT();} {return val.valSizeT();}
}; };
} }

View File

@ -5,7 +5,7 @@ if(APPLE)
set(PLAT_SRCS Metal.cpp) set(PLAT_SRCS Metal.cpp)
endif() endif()
add_library(HECLBackend add_library(hecl-backend
GX.cpp GX.cpp
ProgrammableCommon.cpp ProgrammableCommon.cpp
GLSL.cpp GLSL.cpp

View File

@ -1,13 +1,13 @@
#include "HECL/Backend/GLSL.hpp" #include "hecl/Backend/GLSL.hpp"
#include "HECL/Runtime.hpp" #include "hecl/Runtime.hpp"
#include <Athena/MemoryReader.hpp> #include <athena/MemoryReader.hpp>
#include <Athena/MemoryWriter.hpp> #include <athena/MemoryWriter.hpp>
#include <boo/graphicsdev/GL.hpp> #include <boo/graphicsdev/GL.hpp>
#include <boo/graphicsdev/Vulkan.hpp> #include <boo/graphicsdev/Vulkan.hpp>
static LogVisor::LogModule Log("HECL::Backend::GLSL"); static logvisor::Module Log("hecl::Backend::GLSL");
namespace HECL namespace hecl
{ {
namespace Backend namespace Backend
{ {
@ -21,7 +21,7 @@ std::string GLSL::EmitTexGenSource2(TexGenSrc src, int uvIdx) const
case TexGenSrc::Normal: case TexGenSrc::Normal:
return "normIn.xy\n"; return "normIn.xy\n";
case TexGenSrc::UV: case TexGenSrc::UV:
return HECL::Format("uvIn[%u]", uvIdx); return hecl::Format("uvIn[%u]", uvIdx);
default: break; default: break;
} }
return std::string(); return std::string();
@ -36,7 +36,7 @@ std::string GLSL::EmitTexGenSource4(TexGenSrc src, int uvIdx) const
case TexGenSrc::Normal: case TexGenSrc::Normal:
return "vec4(normIn, 1.0)\n"; return "vec4(normIn, 1.0)\n";
case TexGenSrc::UV: case TexGenSrc::UV:
return HECL::Format("vec4(uvIn[%u], 0.0, 1.0)", uvIdx); return hecl::Format("vec4(uvIn[%u], 0.0, 1.0)", uvIdx);
default: break; default: break;
} }
return std::string(); return std::string();
@ -51,19 +51,19 @@ std::string GLSL::GenerateVertInStruct(unsigned col, unsigned uv, unsigned w) co
unsigned idx = 2; unsigned idx = 2;
if (col) if (col)
{ {
retval += HECL::Format("layout(location=%u) in vec4 colIn[%u];\n", idx, col); retval += hecl::Format("layout(location=%u) in vec4 colIn[%u];\n", idx, col);
idx += col; idx += col;
} }
if (uv) if (uv)
{ {
retval += HECL::Format("layout(location=%u) in vec2 uvIn[%u];\n", idx, uv); retval += hecl::Format("layout(location=%u) in vec2 uvIn[%u];\n", idx, uv);
idx += uv; idx += uv;
} }
if (w) if (w)
{ {
retval += HECL::Format("layout(location=%u) in vec4 weightIn[%u];\n", idx, w); retval += hecl::Format("layout(location=%u) in vec4 weightIn[%u];\n", idx, w);
} }
return retval; return retval;
@ -78,7 +78,7 @@ std::string GLSL::GenerateVertToFragStruct() const
" vec4 mvNorm;\n"; " vec4 mvNorm;\n";
if (m_tcgs.size()) if (m_tcgs.size())
retval += HECL::Format(" vec2 tcgs[%u];\n", unsigned(m_tcgs.size())); retval += hecl::Format(" vec2 tcgs[%u];\n", unsigned(m_tcgs.size()));
return retval + "};\n"; return retval + "};\n";
} }
@ -87,14 +87,14 @@ std::string GLSL::GenerateVertUniformStruct(unsigned skinSlots, unsigned texMtxs
{ {
if (skinSlots == 0) if (skinSlots == 0)
skinSlots = 1; skinSlots = 1;
std::string retval = HECL::Format("UBINDING0 uniform HECLVertUniform\n" std::string retval = hecl::Format("UBINDING0 uniform HECLVertUniform\n"
"{\n" "{\n"
" mat4 mv[%u];\n" " mat4 mv[%u];\n"
" mat4 mvInv[%u];\n" " mat4 mvInv[%u];\n"
" mat4 proj;\n", " mat4 proj;\n",
skinSlots, skinSlots); skinSlots, skinSlots);
if (texMtxs) if (texMtxs)
retval += HECL::Format(" mat4 texMtxs[%u];\n", texMtxs); retval += hecl::Format(" mat4 texMtxs[%u];\n", texMtxs);
return retval + "};\n"; return retval + "};\n";
} }
@ -120,7 +120,7 @@ std::string GLSL::makeVert(const char* glslVer, unsigned col, unsigned uv, unsig
retval += " vec4 posAccum = vec4(0.0,0.0,0.0,0.0);\n" retval += " vec4 posAccum = vec4(0.0,0.0,0.0,0.0);\n"
" vec4 normAccum = vec4(0.0,0.0,0.0,0.0);\n"; " vec4 normAccum = vec4(0.0,0.0,0.0,0.0);\n";
for (size_t i=0 ; i<s ; ++i) for (size_t i=0 ; i<s ; ++i)
retval += HECL::Format(" posAccum += (mv[%" PRISize "] * vec4(posIn, 1.0)) * weightIn[%" PRISize "][%" PRISize "];\n" retval += hecl::Format(" posAccum += (mv[%" PRISize "] * vec4(posIn, 1.0)) * weightIn[%" PRISize "][%" PRISize "];\n"
" normAccum += (mvInv[%" PRISize "] * vec4(normIn, 1.0)) * weightIn[%" PRISize "][%" PRISize "];\n", " normAccum += (mvInv[%" PRISize "] * vec4(normIn, 1.0)) * weightIn[%" PRISize "][%" PRISize "];\n",
i, i/4, i%4, i, i/4, i%4); i, i/4, i%4, i, i/4, i%4);
retval += " posAccum[3] = 1.0;\n" retval += " posAccum[3] = 1.0;\n"
@ -140,10 +140,10 @@ std::string GLSL::makeVert(const char* glslVer, unsigned col, unsigned uv, unsig
for (const TexCoordGen& tcg : m_tcgs) for (const TexCoordGen& tcg : m_tcgs)
{ {
if (tcg.m_mtx < 0) if (tcg.m_mtx < 0)
retval += HECL::Format(" vtf.tcgs[%u] = %s;\n", tcgIdx, retval += hecl::Format(" vtf.tcgs[%u] = %s;\n", tcgIdx,
EmitTexGenSource2(tcg.m_src, tcg.m_uvIdx).c_str()); EmitTexGenSource2(tcg.m_src, tcg.m_uvIdx).c_str());
else else
retval += HECL::Format(" vtf.tcgs[%u] = (texMtxs[%u] * %s).xy;\n", tcgIdx, tcg.m_mtx, retval += hecl::Format(" vtf.tcgs[%u] = (texMtxs[%u] * %s).xy;\n", tcgIdx, tcg.m_mtx,
EmitTexGenSource4(tcg.m_src, tcg.m_uvIdx).c_str()); EmitTexGenSource4(tcg.m_src, tcg.m_uvIdx).c_str());
++tcgIdx; ++tcgIdx;
} }
@ -160,7 +160,7 @@ std::string GLSL::makeFrag(const char* glslVer,
std::string texMapDecl; std::string texMapDecl;
if (m_texMapEnd) if (m_texMapEnd)
texMapDecl = HECL::Format("TBINDING0 uniform sampler2D texs[%u];\n", m_texMapEnd); texMapDecl = hecl::Format("TBINDING0 uniform sampler2D texs[%u];\n", m_texMapEnd);
std::string retval = std::string(glslVer) + "\n" BOO_GLSL_BINDING_HEAD + std::string retval = std::string(glslVer) + "\n" BOO_GLSL_BINDING_HEAD +
GenerateVertToFragStruct() + GenerateVertToFragStruct() +
@ -174,14 +174,14 @@ std::string GLSL::makeFrag(const char* glslVer,
if (m_lighting) if (m_lighting)
{ {
if (lighting.m_entry) if (lighting.m_entry)
retval += HECL::Format(" vec4 lighting = %s();\n", lighting.m_entry); retval += hecl::Format(" vec4 lighting = %s();\n", lighting.m_entry);
else else
retval += " vec4 lighting = vec4(1.0,1.0,1.0,1.0);\n"; retval += " vec4 lighting = vec4(1.0,1.0,1.0,1.0);\n";
} }
unsigned sampIdx = 0; unsigned sampIdx = 0;
for (const TexSampling& sampling : m_texSamplings) for (const TexSampling& sampling : m_texSamplings)
retval += HECL::Format(" vec4 sampling%u = texture(texs[%u], vtf.tcgs[%u]);\n", retval += hecl::Format(" vec4 sampling%u = texture(texs[%u], vtf.tcgs[%u]);\n",
sampIdx++, sampling.mapIdx, sampling.tcgIdx); sampIdx++, sampling.mapIdx, sampling.tcgIdx);
if (m_alphaExpr.size()) if (m_alphaExpr.size())
@ -210,7 +210,7 @@ std::string GLSL::makeFrag(const char* glslVer,
std::string texMapDecl; std::string texMapDecl;
if (m_texMapEnd) if (m_texMapEnd)
texMapDecl = HECL::Format("TBINDING0 uniform sampler2D texs[%u];\n", m_texMapEnd); texMapDecl = hecl::Format("TBINDING0 uniform sampler2D texs[%u];\n", m_texMapEnd);
std::string retval = std::string(glslVer) + "\n" BOO_GLSL_BINDING_HEAD + std::string retval = std::string(glslVer) + "\n" BOO_GLSL_BINDING_HEAD +
GenerateVertToFragStruct() + GenerateVertToFragStruct() +
@ -224,14 +224,14 @@ std::string GLSL::makeFrag(const char* glslVer,
if (m_lighting) if (m_lighting)
{ {
if (lighting.m_entry) if (lighting.m_entry)
retval += HECL::Format(" vec4 lighting = %s();\n", lighting.m_entry); retval += hecl::Format(" vec4 lighting = %s();\n", lighting.m_entry);
else else
retval += " vec4 lighting = vec4(1.0,1.0,1.0,1.0);\n"; retval += " vec4 lighting = vec4(1.0,1.0,1.0,1.0);\n";
} }
unsigned sampIdx = 0; unsigned sampIdx = 0;
for (const TexSampling& sampling : m_texSamplings) for (const TexSampling& sampling : m_texSamplings)
retval += HECL::Format(" vec4 sampling%u = texture(texs[%u], vtf.tcgs[%u]);\n", retval += hecl::Format(" vec4 sampling%u = texture(texs[%u], vtf.tcgs[%u]);\n",
sampIdx++, sampling.mapIdx, sampling.tcgIdx); sampIdx++, sampling.mapIdx, sampling.tcgIdx);
if (m_alphaExpr.size()) if (m_alphaExpr.size())
@ -257,8 +257,8 @@ struct GLSLBackendFactory : IShaderBackendFactory
: m_gfxFactory(dynamic_cast<boo::GLDataFactory*>(gfxFactory)) {} : m_gfxFactory(dynamic_cast<boo::GLDataFactory*>(gfxFactory)) {}
ShaderCachedData buildShaderFromIR(const ShaderTag& tag, ShaderCachedData buildShaderFromIR(const ShaderTag& tag,
const HECL::Frontend::IR& ir, const hecl::Frontend::IR& ir,
HECL::Frontend::Diagnostics& diag, hecl::Frontend::Diagnostics& diag,
boo::IShaderPipeline*& objOut) boo::IShaderPipeline*& objOut)
{ {
m_backend.reset(ir, diag); m_backend.reset(ir, diag);
@ -280,10 +280,10 @@ struct GLSLBackendFactory : IShaderBackendFactory
tag.getDepthTest(), tag.getDepthWrite(), tag.getDepthTest(), tag.getDepthWrite(),
tag.getBackfaceCulling()); tag.getBackfaceCulling());
if (!objOut) if (!objOut)
Log.report(LogVisor::FatalError, "unable to build shader"); Log.report(logvisor::Fatal, "unable to build shader");
ShaderCachedData dataOut(tag, cachedSz); ShaderCachedData dataOut(tag, cachedSz);
Athena::io::MemoryWriter w(dataOut.m_data.get(), dataOut.m_sz); athena::io::MemoryWriter w(dataOut.m_data.get(), dataOut.m_sz);
w.writeUByte(m_backend.m_texMapEnd); w.writeUByte(m_backend.m_texMapEnd);
w.writeUByte(atUint8(m_backend.m_blendSrc)); w.writeUByte(atUint8(m_backend.m_blendSrc));
w.writeUByte(atUint8(m_backend.m_blendDst)); w.writeUByte(atUint8(m_backend.m_blendDst));
@ -296,7 +296,7 @@ struct GLSLBackendFactory : IShaderBackendFactory
boo::IShaderPipeline* buildShaderFromCache(const ShaderCachedData& data) boo::IShaderPipeline* buildShaderFromCache(const ShaderCachedData& data)
{ {
const ShaderTag& tag = data.m_tag; const ShaderTag& tag = data.m_tag;
Athena::io::MemoryReader r(data.m_data.get(), data.m_sz); athena::io::MemoryReader r(data.m_data.get(), data.m_sz);
atUint8 texMapEnd = r.readUByte(); atUint8 texMapEnd = r.readUByte();
boo::BlendFactor blendSrc = boo::BlendFactor(r.readUByte()); boo::BlendFactor blendSrc = boo::BlendFactor(r.readUByte());
boo::BlendFactor blendDst = boo::BlendFactor(r.readUByte()); boo::BlendFactor blendDst = boo::BlendFactor(r.readUByte());
@ -310,13 +310,13 @@ struct GLSLBackendFactory : IShaderBackendFactory
tag.getDepthTest(), tag.getDepthWrite(), tag.getDepthTest(), tag.getDepthWrite(),
tag.getBackfaceCulling()); tag.getBackfaceCulling());
if (!ret) if (!ret)
Log.report(LogVisor::FatalError, "unable to build shader"); Log.report(logvisor::Fatal, "unable to build shader");
return ret; return ret;
} }
ShaderCachedData buildExtendedShaderFromIR(const ShaderTag& tag, ShaderCachedData buildExtendedShaderFromIR(const ShaderTag& tag,
const HECL::Frontend::IR& ir, const hecl::Frontend::IR& ir,
HECL::Frontend::Diagnostics& diag, hecl::Frontend::Diagnostics& diag,
const std::vector<ShaderCacheExtensions::ExtensionSlot>& extensionSlots, const std::vector<ShaderCacheExtensions::ExtensionSlot>& extensionSlots,
FReturnExtensionShader returnFunc) FReturnExtensionShader returnFunc)
{ {
@ -343,12 +343,12 @@ struct GLSLBackendFactory : IShaderBackendFactory
tag.getDepthTest(), tag.getDepthWrite(), tag.getDepthTest(), tag.getDepthWrite(),
tag.getBackfaceCulling()); tag.getBackfaceCulling());
if (!ret) if (!ret)
Log.report(LogVisor::FatalError, "unable to build shader"); Log.report(logvisor::Fatal, "unable to build shader");
returnFunc(ret); returnFunc(ret);
} }
ShaderCachedData dataOut(tag, cachedSz); ShaderCachedData dataOut(tag, cachedSz);
Athena::io::MemoryWriter w(dataOut.m_data.get(), dataOut.m_sz); athena::io::MemoryWriter w(dataOut.m_data.get(), dataOut.m_sz);
w.writeUByte(m_backend.m_texMapEnd); w.writeUByte(m_backend.m_texMapEnd);
w.writeUByte(atUint8(m_backend.m_blendSrc)); w.writeUByte(atUint8(m_backend.m_blendSrc));
w.writeUByte(atUint8(m_backend.m_blendDst)); w.writeUByte(atUint8(m_backend.m_blendDst));
@ -364,7 +364,7 @@ struct GLSLBackendFactory : IShaderBackendFactory
FReturnExtensionShader returnFunc) FReturnExtensionShader returnFunc)
{ {
const ShaderTag& tag = data.m_tag; const ShaderTag& tag = data.m_tag;
Athena::io::MemoryReader r(data.m_data.get(), data.m_sz); athena::io::MemoryReader r(data.m_data.get(), data.m_sz);
atUint8 texMapEnd = r.readUByte(); atUint8 texMapEnd = r.readUByte();
boo::BlendFactor blendSrc = boo::BlendFactor(r.readUByte()); boo::BlendFactor blendSrc = boo::BlendFactor(r.readUByte());
boo::BlendFactor blendDst = boo::BlendFactor(r.readUByte()); boo::BlendFactor blendDst = boo::BlendFactor(r.readUByte());
@ -380,7 +380,7 @@ struct GLSLBackendFactory : IShaderBackendFactory
tag.getDepthTest(), tag.getDepthWrite(), tag.getDepthTest(), tag.getDepthWrite(),
tag.getBackfaceCulling()); tag.getBackfaceCulling());
if (!ret) if (!ret)
Log.report(LogVisor::FatalError, "unable to build shader"); Log.report(logvisor::Fatal, "unable to build shader");
returnFunc(ret); returnFunc(ret);
} }
} }
@ -402,8 +402,8 @@ struct SPIRVBackendFactory : IShaderBackendFactory
: m_gfxFactory(dynamic_cast<boo::VulkanDataFactory*>(gfxFactory)) {} : m_gfxFactory(dynamic_cast<boo::VulkanDataFactory*>(gfxFactory)) {}
ShaderCachedData buildShaderFromIR(const ShaderTag& tag, ShaderCachedData buildShaderFromIR(const ShaderTag& tag,
const HECL::Frontend::IR& ir, const hecl::Frontend::IR& ir,
HECL::Frontend::Diagnostics& diag, hecl::Frontend::Diagnostics& diag,
boo::IShaderPipeline*& objOut) boo::IShaderPipeline*& objOut)
{ {
m_backend.reset(ir, diag); m_backend.reset(ir, diag);
@ -426,7 +426,7 @@ struct SPIRVBackendFactory : IShaderBackendFactory
tag.getDepthTest(), tag.getDepthWrite(), tag.getDepthTest(), tag.getDepthWrite(),
tag.getBackfaceCulling()); tag.getBackfaceCulling());
if (!objOut) if (!objOut)
Log.report(LogVisor::FatalError, "unable to build shader"); Log.report(logvisor::Fatal, "unable to build shader");
atUint32 vertSz = vertBlob.size() * sizeof(unsigned int); atUint32 vertSz = vertBlob.size() * sizeof(unsigned int);
@ -436,7 +436,7 @@ struct SPIRVBackendFactory : IShaderBackendFactory
size_t cachedSz = 15 + vertSz + fragSz + pipelineSz; size_t cachedSz = 15 + vertSz + fragSz + pipelineSz;
ShaderCachedData dataOut(tag, cachedSz); ShaderCachedData dataOut(tag, cachedSz);
Athena::io::MemoryWriter w(dataOut.m_data.get(), dataOut.m_sz); athena::io::MemoryWriter w(dataOut.m_data.get(), dataOut.m_sz);
w.writeUByte(atUint8(m_backend.m_texMapEnd)); w.writeUByte(atUint8(m_backend.m_texMapEnd));
w.writeUByte(atUint8(m_backend.m_blendSrc)); w.writeUByte(atUint8(m_backend.m_blendSrc));
w.writeUByte(atUint8(m_backend.m_blendDst)); w.writeUByte(atUint8(m_backend.m_blendDst));
@ -471,7 +471,7 @@ struct SPIRVBackendFactory : IShaderBackendFactory
boo::IShaderPipeline* buildShaderFromCache(const ShaderCachedData& data) boo::IShaderPipeline* buildShaderFromCache(const ShaderCachedData& data)
{ {
const ShaderTag& tag = data.m_tag; const ShaderTag& tag = data.m_tag;
Athena::io::MemoryReader r(data.m_data.get(), data.m_sz); athena::io::MemoryReader r(data.m_data.get(), data.m_sz);
size_t texCount = size_t(r.readByte()); size_t texCount = size_t(r.readByte());
boo::BlendFactor blendSrc = boo::BlendFactor(r.readUByte()); boo::BlendFactor blendSrc = boo::BlendFactor(r.readUByte());
boo::BlendFactor blendDst = boo::BlendFactor(r.readUByte()); boo::BlendFactor blendDst = boo::BlendFactor(r.readUByte());
@ -499,13 +499,13 @@ struct SPIRVBackendFactory : IShaderBackendFactory
tag.getDepthTest(), tag.getDepthWrite(), tag.getDepthTest(), tag.getDepthWrite(),
tag.getBackfaceCulling()); tag.getBackfaceCulling());
if (!ret) if (!ret)
Log.report(LogVisor::FatalError, "unable to build shader"); Log.report(logvisor::Fatal, "unable to build shader");
return ret; return ret;
} }
ShaderCachedData buildExtendedShaderFromIR(const ShaderTag& tag, ShaderCachedData buildExtendedShaderFromIR(const ShaderTag& tag,
const HECL::Frontend::IR& ir, const hecl::Frontend::IR& ir,
HECL::Frontend::Diagnostics& diag, hecl::Frontend::Diagnostics& diag,
const std::vector<ShaderCacheExtensions::ExtensionSlot>& extensionSlots, const std::vector<ShaderCacheExtensions::ExtensionSlot>& extensionSlots,
FReturnExtensionShader returnFunc) FReturnExtensionShader returnFunc)
{ {
@ -534,7 +534,7 @@ struct SPIRVBackendFactory : IShaderBackendFactory
tag.getDepthTest(), tag.getDepthWrite(), tag.getDepthTest(), tag.getDepthWrite(),
tag.getBackfaceCulling()); tag.getBackfaceCulling());
if (!ret) if (!ret)
Log.report(LogVisor::FatalError, "unable to build shader"); Log.report(logvisor::Fatal, "unable to build shader");
cachedSz += fragPipeBlob.first.size() * sizeof(unsigned int); cachedSz += fragPipeBlob.first.size() * sizeof(unsigned int);
cachedSz += fragPipeBlob.second.size(); cachedSz += fragPipeBlob.second.size();
returnFunc(ret); returnFunc(ret);
@ -543,7 +543,7 @@ struct SPIRVBackendFactory : IShaderBackendFactory
cachedSz += vertBlobSz; cachedSz += vertBlobSz;
ShaderCachedData dataOut(tag, cachedSz); ShaderCachedData dataOut(tag, cachedSz);
Athena::io::MemoryWriter w(dataOut.m_data.get(), dataOut.m_sz); athena::io::MemoryWriter w(dataOut.m_data.get(), dataOut.m_sz);
w.writeUByte(atUint8(m_backend.m_texMapEnd)); w.writeUByte(atUint8(m_backend.m_texMapEnd));
w.writeUByte(atUint8(m_backend.m_blendSrc)); w.writeUByte(atUint8(m_backend.m_blendSrc));
w.writeUByte(atUint8(m_backend.m_blendDst)); w.writeUByte(atUint8(m_backend.m_blendDst));
@ -586,7 +586,7 @@ struct SPIRVBackendFactory : IShaderBackendFactory
FReturnExtensionShader returnFunc) FReturnExtensionShader returnFunc)
{ {
const ShaderTag& tag = data.m_tag; const ShaderTag& tag = data.m_tag;
Athena::io::MemoryReader r(data.m_data.get(), data.m_sz); athena::io::MemoryReader r(data.m_data.get(), data.m_sz);
size_t texCount = size_t(r.readByte()); size_t texCount = size_t(r.readByte());
boo::BlendFactor blendSrc = boo::BlendFactor(r.readUByte()); boo::BlendFactor blendSrc = boo::BlendFactor(r.readUByte());
boo::BlendFactor blendDst = boo::BlendFactor(r.readUByte()); boo::BlendFactor blendDst = boo::BlendFactor(r.readUByte());
@ -616,7 +616,7 @@ struct SPIRVBackendFactory : IShaderBackendFactory
tag.getDepthTest(), tag.getDepthWrite(), tag.getDepthTest(), tag.getDepthWrite(),
tag.getBackfaceCulling()); tag.getBackfaceCulling());
if (!ret) if (!ret)
Log.report(LogVisor::FatalError, "unable to build shader"); Log.report(logvisor::Fatal, "unable to build shader");
returnFunc(ret); returnFunc(ret);
} }
} }

View File

@ -1,7 +1,7 @@
#include "HECL/Backend/GX.hpp" #include "hecl/Backend/GX.hpp"
#include <map> #include <map>
namespace HECL namespace hecl
{ {
namespace Backend namespace Backend
{ {

View File

@ -1,12 +1,12 @@
#include "HECL/Backend/HLSL.hpp" #include "hecl/Backend/HLSL.hpp"
#include "HECL/Runtime.hpp" #include "hecl/Runtime.hpp"
#include <Athena/MemoryReader.hpp> #include <athena/MemoryReader.hpp>
#include <Athena/MemoryWriter.hpp> #include <athena/MemoryWriter.hpp>
#include <boo/graphicsdev/D3D.hpp> #include <boo/graphicsdev/D3D.hpp>
static LogVisor::LogModule Log("HECL::Backend::HLSL"); static logvisor::Module Log("hecl::Backend::HLSL");
namespace HECL namespace hecl
{ {
namespace Backend namespace Backend
{ {
@ -20,7 +20,7 @@ std::string HLSL::EmitTexGenSource2(TexGenSrc src, int uvIdx) const
case TexGenSrc::Normal: case TexGenSrc::Normal:
return "v.normIn.xy\n"; return "v.normIn.xy\n";
case TexGenSrc::UV: case TexGenSrc::UV:
return HECL::Format("v.uvIn[%u]", uvIdx); return hecl::Format("v.uvIn[%u]", uvIdx);
default: break; default: break;
} }
return std::string(); return std::string();
@ -35,7 +35,7 @@ std::string HLSL::EmitTexGenSource4(TexGenSrc src, int uvIdx) const
case TexGenSrc::Normal: case TexGenSrc::Normal:
return "float4(v.normIn, 1.0)\n"; return "float4(v.normIn, 1.0)\n";
case TexGenSrc::UV: case TexGenSrc::UV:
return HECL::Format("float4(v.uvIn[%u], 0.0, 1.0)", uvIdx); return hecl::Format("float4(v.uvIn[%u], 0.0, 1.0)", uvIdx);
default: break; default: break;
} }
return std::string(); return std::string();
@ -50,13 +50,13 @@ std::string HLSL::GenerateVertInStruct(unsigned col, unsigned uv, unsigned w) co
" float3 normIn : NORMAL;\n"; " float3 normIn : NORMAL;\n";
if (col) if (col)
retval += HECL::Format(" float4 colIn[%u] : COLOR;\n", col); retval += hecl::Format(" float4 colIn[%u] : COLOR;\n", col);
if (uv) if (uv)
retval += HECL::Format(" float2 uvIn[%u] : UV;\n", uv); retval += hecl::Format(" float2 uvIn[%u] : UV;\n", uv);
if (w) if (w)
retval += HECL::Format(" float4 weightIn[%u] : WEIGHT;\n", w); retval += hecl::Format(" float4 weightIn[%u] : WEIGHT;\n", w);
return retval + "};\n"; return retval + "};\n";
} }
@ -71,7 +71,7 @@ std::string HLSL::GenerateVertToFragStruct() const
" float4 mvNorm : NORMAL;\n"; " float4 mvNorm : NORMAL;\n";
if (m_tcgs.size()) if (m_tcgs.size())
retval += HECL::Format(" float2 tcgs[%u] : UV;\n", unsigned(m_tcgs.size())); retval += hecl::Format(" float2 tcgs[%u] : UV;\n", unsigned(m_tcgs.size()));
return retval + "};\n"; return retval + "};\n";
} }
@ -80,14 +80,14 @@ std::string HLSL::GenerateVertUniformStruct(unsigned skinSlots, unsigned texMtxs
{ {
if (skinSlots == 0) if (skinSlots == 0)
skinSlots = 1; skinSlots = 1;
std::string retval = HECL::Format("cbuffer HECLVertUniform : register(b0)\n" std::string retval = hecl::Format("cbuffer HECLVertUniform : register(b0)\n"
"{\n" "{\n"
" float4x4 mv[%u];\n" " float4x4 mv[%u];\n"
" float4x4 mvInv[%u];\n" " float4x4 mvInv[%u];\n"
" float4x4 proj;\n", " float4x4 proj;\n",
skinSlots, skinSlots); skinSlots, skinSlots);
if (texMtxs) if (texMtxs)
retval += HECL::Format(" float4x4 texMtxs[%u];\n", texMtxs); retval += hecl::Format(" float4x4 texMtxs[%u];\n", texMtxs);
return retval + "};\n"; return retval + "};\n";
} }
@ -114,7 +114,7 @@ std::string HLSL::makeVert(unsigned col, unsigned uv, unsigned w,
retval += " vec4 posAccum = float4(0.0,0.0,0.0,0.0);\n" retval += " vec4 posAccum = float4(0.0,0.0,0.0,0.0);\n"
" vec4 normAccum = float4(0.0,0.0,0.0,0.0);\n"; " vec4 normAccum = float4(0.0,0.0,0.0,0.0);\n";
for (size_t i=0 ; i<s ; ++i) for (size_t i=0 ; i<s ; ++i)
retval += HECL::Format(" posAccum += mul(mv[%" PRISize "], float4(v.posIn, 1.0)) * v.weightIn[%" PRISize "][%" PRISize "];\n" retval += hecl::Format(" posAccum += mul(mv[%" PRISize "], float4(v.posIn, 1.0)) * v.weightIn[%" PRISize "][%" PRISize "];\n"
" normAccum += mul(mvInv[%" PRISize "], float4(v.normIn, 1.0)) * v.weightIn[%" PRISize "][%" PRISize "];\n", " normAccum += mul(mvInv[%" PRISize "], float4(v.normIn, 1.0)) * v.weightIn[%" PRISize "][%" PRISize "];\n",
i, i/4, i%4, i, i/4, i%4); i, i/4, i%4, i, i/4, i%4);
retval += " posAccum[3] = 1.0;\n" retval += " posAccum[3] = 1.0;\n"
@ -134,10 +134,10 @@ std::string HLSL::makeVert(unsigned col, unsigned uv, unsigned w,
for (const TexCoordGen& tcg : m_tcgs) for (const TexCoordGen& tcg : m_tcgs)
{ {
if (tcg.m_mtx < 0) if (tcg.m_mtx < 0)
retval += HECL::Format(" vtf.tcgs[%u] = %s;\n", tcgIdx, retval += hecl::Format(" vtf.tcgs[%u] = %s;\n", tcgIdx,
EmitTexGenSource2(tcg.m_src, tcg.m_uvIdx).c_str()); EmitTexGenSource2(tcg.m_src, tcg.m_uvIdx).c_str());
else else
retval += HECL::Format(" vtf.tcgs[%u] = mul(texMtxs[%u], %s).xy;\n", tcgIdx, tcg.m_mtx, retval += hecl::Format(" vtf.tcgs[%u] = mul(texMtxs[%u], %s).xy;\n", tcgIdx, tcg.m_mtx,
EmitTexGenSource4(tcg.m_src, tcg.m_uvIdx).c_str()); EmitTexGenSource4(tcg.m_src, tcg.m_uvIdx).c_str());
++tcgIdx; ++tcgIdx;
} }
@ -154,7 +154,7 @@ std::string HLSL::makeFrag(const ShaderFunction& lighting) const
std::string texMapDecl; std::string texMapDecl;
if (m_texMapEnd) if (m_texMapEnd)
texMapDecl = HECL::Format("Texture2D texs[%u] : register(t0);\n", m_texMapEnd); texMapDecl = hecl::Format("Texture2D texs[%u] : register(t0);\n", m_texMapEnd);
std::string retval = std::string retval =
"SamplerState samp : register(s0);\n" + "SamplerState samp : register(s0);\n" +
@ -167,14 +167,14 @@ std::string HLSL::makeFrag(const ShaderFunction& lighting) const
if (m_lighting) if (m_lighting)
{ {
if (lighting.m_entry) if (lighting.m_entry)
retval += HECL::Format(" float4 lighting = %s();\n", lighting.m_entry); retval += hecl::Format(" float4 lighting = %s();\n", lighting.m_entry);
else else
retval += " float4 lighting = vec4(1.0,1.0,1.0,1.0);\n"; retval += " float4 lighting = vec4(1.0,1.0,1.0,1.0);\n";
} }
unsigned sampIdx = 0; unsigned sampIdx = 0;
for (const TexSampling& sampling : m_texSamplings) for (const TexSampling& sampling : m_texSamplings)
retval += HECL::Format(" float4 sampling%u = texs[%u].Sample(samp, vtf.tcgs[%u]);\n", retval += hecl::Format(" float4 sampling%u = texs[%u].Sample(samp, vtf.tcgs[%u]);\n",
sampIdx++, sampling.mapIdx, sampling.tcgIdx); sampIdx++, sampling.mapIdx, sampling.tcgIdx);
if (m_alphaExpr.size()) if (m_alphaExpr.size())
@ -202,7 +202,7 @@ std::string HLSL::makeFrag(const ShaderFunction& lighting,
std::string texMapDecl; std::string texMapDecl;
if (m_texMapEnd) if (m_texMapEnd)
texMapDecl = HECL::Format("Texture2D texs[%u] : register(t0);\n", m_texMapEnd); texMapDecl = hecl::Format("Texture2D texs[%u] : register(t0);\n", m_texMapEnd);
std::string retval = std::string retval =
"SamplerState samp : register(s0);\n" + "SamplerState samp : register(s0);\n" +
@ -215,14 +215,14 @@ std::string HLSL::makeFrag(const ShaderFunction& lighting,
if (m_lighting) if (m_lighting)
{ {
if (lighting.m_entry) if (lighting.m_entry)
retval += HECL::Format(" float4 lighting = %s();\n", lighting.m_entry); retval += hecl::Format(" float4 lighting = %s();\n", lighting.m_entry);
else else
retval += " float4 lighting = float4(1.0,1.0,1.0,1.0);\n"; retval += " float4 lighting = float4(1.0,1.0,1.0,1.0);\n";
} }
unsigned sampIdx = 0; unsigned sampIdx = 0;
for (const TexSampling& sampling : m_texSamplings) for (const TexSampling& sampling : m_texSamplings)
retval += HECL::Format(" float4 sampling%u = texs[%u].Sample(samp, vtf.tcgs[%u]);\n", retval += hecl::Format(" float4 sampling%u = texs[%u].Sample(samp, vtf.tcgs[%u]);\n",
sampIdx++, sampling.mapIdx, sampling.tcgIdx); sampIdx++, sampling.mapIdx, sampling.tcgIdx);
if (m_alphaExpr.size()) if (m_alphaExpr.size())
@ -246,8 +246,8 @@ struct HLSLBackendFactory : IShaderBackendFactory
: m_gfxFactory(dynamic_cast<boo::ID3DDataFactory*>(gfxFactory)) {} : m_gfxFactory(dynamic_cast<boo::ID3DDataFactory*>(gfxFactory)) {}
ShaderCachedData buildShaderFromIR(const ShaderTag& tag, ShaderCachedData buildShaderFromIR(const ShaderTag& tag,
const HECL::Frontend::IR& ir, const hecl::Frontend::IR& ir,
HECL::Frontend::Diagnostics& diag, hecl::Frontend::Diagnostics& diag,
boo::IShaderPipeline*& objOut) boo::IShaderPipeline*& objOut)
{ {
m_backend.reset(ir, diag); m_backend.reset(ir, diag);
@ -268,7 +268,7 @@ struct HLSLBackendFactory : IShaderBackendFactory
tag.getDepthTest(), tag.getDepthWrite(), tag.getDepthTest(), tag.getDepthWrite(),
tag.getBackfaceCulling()); tag.getBackfaceCulling());
if (!objOut) if (!objOut)
Log.report(LogVisor::FatalError, "unable to build shader"); Log.report(logvisor::Fatal, "unable to build shader");
atUint32 vertSz = 0; atUint32 vertSz = 0;
atUint32 fragSz = 0; atUint32 fragSz = 0;
@ -283,7 +283,7 @@ struct HLSLBackendFactory : IShaderBackendFactory
size_t cachedSz = 14 + vertSz + fragSz + pipelineSz; size_t cachedSz = 14 + vertSz + fragSz + pipelineSz;
ShaderCachedData dataOut(tag, cachedSz); ShaderCachedData dataOut(tag, cachedSz);
Athena::io::MemoryWriter w(dataOut.m_data.get(), dataOut.m_sz); athena::io::MemoryWriter w(dataOut.m_data.get(), dataOut.m_sz);
w.writeUByte(atUint8(m_backend.m_blendSrc)); w.writeUByte(atUint8(m_backend.m_blendSrc));
w.writeUByte(atUint8(m_backend.m_blendDst)); w.writeUByte(atUint8(m_backend.m_blendDst));
@ -317,7 +317,7 @@ struct HLSLBackendFactory : IShaderBackendFactory
boo::IShaderPipeline* buildShaderFromCache(const ShaderCachedData& data) boo::IShaderPipeline* buildShaderFromCache(const ShaderCachedData& data)
{ {
const ShaderTag& tag = data.m_tag; const ShaderTag& tag = data.m_tag;
Athena::io::MemoryReader r(data.m_data.get(), data.m_sz); athena::io::MemoryReader r(data.m_data.get(), data.m_sz);
boo::BlendFactor blendSrc = boo::BlendFactor(r.readUByte()); boo::BlendFactor blendSrc = boo::BlendFactor(r.readUByte());
boo::BlendFactor blendDst = boo::BlendFactor(r.readUByte()); boo::BlendFactor blendDst = boo::BlendFactor(r.readUByte());
@ -353,13 +353,13 @@ struct HLSLBackendFactory : IShaderBackendFactory
tag.getDepthTest(), tag.getDepthWrite(), tag.getDepthTest(), tag.getDepthWrite(),
tag.getBackfaceCulling()); tag.getBackfaceCulling());
if (!ret) if (!ret)
Log.report(LogVisor::FatalError, "unable to build shader"); Log.report(logvisor::Fatal, "unable to build shader");
return ret; return ret;
} }
ShaderCachedData buildExtendedShaderFromIR(const ShaderTag& tag, ShaderCachedData buildExtendedShaderFromIR(const ShaderTag& tag,
const HECL::Frontend::IR& ir, const hecl::Frontend::IR& ir,
HECL::Frontend::Diagnostics& diag, hecl::Frontend::Diagnostics& diag,
const std::vector<ShaderCacheExtensions::ExtensionSlot>& extensionSlots, const std::vector<ShaderCacheExtensions::ExtensionSlot>& extensionSlots,
FReturnExtensionShader returnFunc) FReturnExtensionShader returnFunc)
{ {
@ -387,7 +387,7 @@ struct HLSLBackendFactory : IShaderBackendFactory
tag.getDepthTest(), tag.getDepthWrite(), tag.getDepthTest(), tag.getDepthWrite(),
tag.getBackfaceCulling()); tag.getBackfaceCulling());
if (!ret) if (!ret)
Log.report(LogVisor::FatalError, "unable to build shader"); Log.report(logvisor::Fatal, "unable to build shader");
if (fragPipeBlob.first) if (fragPipeBlob.first)
cachedSz += fragPipeBlob.first->GetBufferSize(); cachedSz += fragPipeBlob.first->GetBufferSize();
if (fragPipeBlob.second) if (fragPipeBlob.second)
@ -398,7 +398,7 @@ struct HLSLBackendFactory : IShaderBackendFactory
cachedSz += vertBlob->GetBufferSize(); cachedSz += vertBlob->GetBufferSize();
ShaderCachedData dataOut(tag, cachedSz); ShaderCachedData dataOut(tag, cachedSz);
Athena::io::MemoryWriter w(dataOut.m_data.get(), dataOut.m_sz); athena::io::MemoryWriter w(dataOut.m_data.get(), dataOut.m_sz);
w.writeUByte(atUint8(m_backend.m_blendSrc)); w.writeUByte(atUint8(m_backend.m_blendSrc));
w.writeUByte(atUint8(m_backend.m_blendDst)); w.writeUByte(atUint8(m_backend.m_blendDst));
@ -437,7 +437,7 @@ struct HLSLBackendFactory : IShaderBackendFactory
FReturnExtensionShader returnFunc) FReturnExtensionShader returnFunc)
{ {
const ShaderTag& tag = data.m_tag; const ShaderTag& tag = data.m_tag;
Athena::io::MemoryReader r(data.m_data.get(), data.m_sz); athena::io::MemoryReader r(data.m_data.get(), data.m_sz);
boo::BlendFactor blendSrc = boo::BlendFactor(r.readUByte()); boo::BlendFactor blendSrc = boo::BlendFactor(r.readUByte());
boo::BlendFactor blendDst = boo::BlendFactor(r.readUByte()); boo::BlendFactor blendDst = boo::BlendFactor(r.readUByte());
@ -475,7 +475,7 @@ struct HLSLBackendFactory : IShaderBackendFactory
tag.getDepthTest(), tag.getDepthWrite(), tag.getDepthTest(), tag.getDepthWrite(),
tag.getBackfaceCulling()); tag.getBackfaceCulling());
if (!ret) if (!ret)
Log.report(LogVisor::FatalError, "unable to build shader"); Log.report(logvisor::Fatal, "unable to build shader");
returnFunc(ret); returnFunc(ret);
} }
} }

View File

@ -1,13 +1,13 @@
#include "HECL/Backend/Metal.hpp" #include "hecl/Backend/Metal.hpp"
#if BOO_HAS_METAL #if BOO_HAS_METAL
#include "HECL/Runtime.hpp" #include "hecl/Runtime.hpp"
#include <Athena/MemoryReader.hpp> #include <athena/MemoryReader.hpp>
#include <Athena/MemoryWriter.hpp> #include <athena/MemoryWriter.hpp>
#include <boo/graphicsdev/Metal.hpp> #include <boo/graphicsdev/Metal.hpp>
static LogVisor::LogModule Log("HECL::Backend::Metal"); static logvisor::Module Log("hecl::Backend::Metal");
namespace HECL namespace hecl
{ {
namespace Backend namespace Backend
{ {
@ -21,7 +21,7 @@ std::string Metal::EmitTexGenSource2(TexGenSrc src, int uvIdx) const
case TexGenSrc::Normal: case TexGenSrc::Normal:
return "v.normIn.xy\n"; return "v.normIn.xy\n";
case TexGenSrc::UV: case TexGenSrc::UV:
return HECL::Format("v.uvIn%u", uvIdx); return hecl::Format("v.uvIn%u", uvIdx);
default: break; default: break;
} }
return std::string(); return std::string();
@ -36,7 +36,7 @@ std::string Metal::EmitTexGenSource4(TexGenSrc src, int uvIdx) const
case TexGenSrc::Normal: case TexGenSrc::Normal:
return "float4(v.normIn, 1.0)\n"; return "float4(v.normIn, 1.0)\n";
case TexGenSrc::UV: case TexGenSrc::UV:
return HECL::Format("float4(v.uvIn%u, 0.0, 1.0)", uvIdx); return hecl::Format("float4(v.uvIn%u, 0.0, 1.0)", uvIdx);
default: break; default: break;
} }
return std::string(); return std::string();
@ -54,19 +54,19 @@ std::string Metal::GenerateVertInStruct(unsigned col, unsigned uv, unsigned w) c
if (col) if (col)
{ {
for (unsigned i=0 ; i<col ; ++i, ++idx) for (unsigned i=0 ; i<col ; ++i, ++idx)
retval += HECL::Format(" float4 colIn%u [[ attribute(%u) ]];\n", i, idx); retval += hecl::Format(" float4 colIn%u [[ attribute(%u) ]];\n", i, idx);
} }
if (uv) if (uv)
{ {
for (unsigned i=0 ; i<uv ; ++i, ++idx) for (unsigned i=0 ; i<uv ; ++i, ++idx)
retval += HECL::Format(" float2 uvIn%u [[ attribute(%u) ]];\n", i, idx); retval += hecl::Format(" float2 uvIn%u [[ attribute(%u) ]];\n", i, idx);
} }
if (w) if (w)
{ {
for (unsigned i=0 ; i<w ; ++i, ++idx) for (unsigned i=0 ; i<w ; ++i, ++idx)
retval += HECL::Format(" float4 weightIn%u [[ attribute(%u) ]];\n", i, idx); retval += hecl::Format(" float4 weightIn%u [[ attribute(%u) ]];\n", i, idx);
} }
return retval + "};\n"; return retval + "};\n";
@ -84,7 +84,7 @@ std::string Metal::GenerateVertToFragStruct() const
if (m_tcgs.size()) if (m_tcgs.size())
{ {
for (size_t i=0 ; i<m_tcgs.size() ; ++i) for (size_t i=0 ; i<m_tcgs.size() ; ++i)
retval += HECL::Format(" float2 tcgs%" PRISize ";\n", i); retval += hecl::Format(" float2 tcgs%" PRISize ";\n", i);
} }
return retval + "};\n"; return retval + "};\n";
@ -94,14 +94,14 @@ std::string Metal::GenerateVertUniformStruct(unsigned skinSlots, unsigned texMtx
{ {
if (skinSlots == 0) if (skinSlots == 0)
skinSlots = 1; skinSlots = 1;
std::string retval = HECL::Format("struct HECLVertUniform\n" std::string retval = hecl::Format("struct HECLVertUniform\n"
"{\n" "{\n"
" float4x4 mv[%u];\n" " float4x4 mv[%u];\n"
" float4x4 mvInv[%u];\n" " float4x4 mvInv[%u];\n"
" float4x4 proj;\n", " float4x4 proj;\n",
skinSlots, skinSlots); skinSlots, skinSlots);
if (texMtxs) if (texMtxs)
retval += HECL::Format(" float4x4 texMtxs[%u];\n", texMtxs); retval += hecl::Format(" float4x4 texMtxs[%u];\n", texMtxs);
return retval + "};\n"; return retval + "};\n";
} }
@ -127,7 +127,7 @@ std::string Metal::makeVert(unsigned col, unsigned uv, unsigned w,
retval += " float4 posAccum = float4(0.0,0.0,0.0,0.0);\n" retval += " float4 posAccum = float4(0.0,0.0,0.0,0.0);\n"
" float4 normAccum = float4(0.0,0.0,0.0,0.0);\n"; " float4 normAccum = float4(0.0,0.0,0.0,0.0);\n";
for (size_t i=0 ; i<s ; ++i) for (size_t i=0 ; i<s ; ++i)
retval += HECL::Format(" posAccum += (vu.mv[%" PRISize "] * float4(v.posIn, 1.0)) * v.weightIn%" PRISize "[%" PRISize "];\n" retval += hecl::Format(" posAccum += (vu.mv[%" PRISize "] * float4(v.posIn, 1.0)) * v.weightIn%" PRISize "[%" PRISize "];\n"
" normAccum += (vu.mvInv[%" PRISize "] * float4(v.normIn, 1.0)) * v.weightIn%" PRISize "[%" PRISize "];\n", " normAccum += (vu.mvInv[%" PRISize "] * float4(v.normIn, 1.0)) * v.weightIn%" PRISize "[%" PRISize "];\n",
i, i/4, i%4, i, i/4, i%4); i, i/4, i%4, i, i/4, i%4);
retval += " posAccum[3] = 1.0;\n" retval += " posAccum[3] = 1.0;\n"
@ -147,10 +147,10 @@ std::string Metal::makeVert(unsigned col, unsigned uv, unsigned w,
for (const TexCoordGen& tcg : m_tcgs) for (const TexCoordGen& tcg : m_tcgs)
{ {
if (tcg.m_mtx < 0) if (tcg.m_mtx < 0)
retval += HECL::Format(" vtf.tcgs%u = %s;\n", tcgIdx, retval += hecl::Format(" vtf.tcgs%u = %s;\n", tcgIdx,
EmitTexGenSource2(tcg.m_src, tcg.m_uvIdx).c_str()); EmitTexGenSource2(tcg.m_src, tcg.m_uvIdx).c_str());
else else
retval += HECL::Format(" vtf.tcgs%u = (vu.texMtxs[%u] * %s).xy;\n", tcgIdx, tcg.m_mtx, retval += hecl::Format(" vtf.tcgs%u = (vu.texMtxs[%u] * %s).xy;\n", tcgIdx, tcg.m_mtx,
EmitTexGenSource4(tcg.m_src, tcg.m_uvIdx).c_str()); EmitTexGenSource4(tcg.m_src, tcg.m_uvIdx).c_str());
++tcgIdx; ++tcgIdx;
} }
@ -168,7 +168,7 @@ std::string Metal::makeFrag(const ShaderFunction& lighting) const
if (m_texMapEnd) if (m_texMapEnd)
{ {
for (int i=0 ; i<m_texMapEnd ; ++i) for (int i=0 ; i<m_texMapEnd ; ++i)
texMapDecl += HECL::Format("\n, texture2d<float> tex%u [[ texture(%u) ]]", i, i); texMapDecl += hecl::Format("\n, texture2d<float> tex%u [[ texture(%u) ]]", i, i);
} }
std::string retval = "#include <metal_stdlib>\nusing namespace metal;\n" std::string retval = "#include <metal_stdlib>\nusing namespace metal;\n"
@ -181,14 +181,14 @@ std::string Metal::makeFrag(const ShaderFunction& lighting) const
if (m_lighting) if (m_lighting)
{ {
if (lighting.m_entry) if (lighting.m_entry)
retval += HECL::Format(" float4 lighting = %s();\n", lighting.m_entry); retval += hecl::Format(" float4 lighting = %s();\n", lighting.m_entry);
else else
retval += " float4 lighting = float4(1.0,1.0,1.0,1.0);\n"; retval += " float4 lighting = float4(1.0,1.0,1.0,1.0);\n";
} }
unsigned sampIdx = 0; unsigned sampIdx = 0;
for (const TexSampling& sampling : m_texSamplings) for (const TexSampling& sampling : m_texSamplings)
retval += HECL::Format(" float4 sampling%u = tex%u.sample(samp, vtf.tcgs%u);\n", retval += hecl::Format(" float4 sampling%u = tex%u.sample(samp, vtf.tcgs%u);\n",
sampIdx++, sampling.mapIdx, sampling.tcgIdx); sampIdx++, sampling.mapIdx, sampling.tcgIdx);
if (m_alphaExpr.size()) if (m_alphaExpr.size())
@ -218,7 +218,7 @@ std::string Metal::makeFrag(const ShaderFunction& lighting,
if (m_texMapEnd) if (m_texMapEnd)
{ {
for (int i=0 ; i<m_texMapEnd ; ++i) for (int i=0 ; i<m_texMapEnd ; ++i)
texMapDecl += HECL::Format("texture2d<float> tex%u [[ texture(%u) ]],\n", i, i); texMapDecl += hecl::Format("texture2d<float> tex%u [[ texture(%u) ]],\n", i, i);
} }
std::string retval = "#include <metal_stdlib>\nusing namespace metal;\n" std::string retval = "#include <metal_stdlib>\nusing namespace metal;\n"
@ -230,14 +230,14 @@ std::string Metal::makeFrag(const ShaderFunction& lighting,
if (m_lighting) if (m_lighting)
{ {
if (lighting.m_entry) if (lighting.m_entry)
retval += HECL::Format(" float4 lighting = %s();\n", lighting.m_entry); retval += hecl::Format(" float4 lighting = %s();\n", lighting.m_entry);
else else
retval += " float4 lighting = float4(1.0,1.0,1.0,1.0);\n"; retval += " float4 lighting = float4(1.0,1.0,1.0,1.0);\n";
} }
unsigned sampIdx = 0; unsigned sampIdx = 0;
for (const TexSampling& sampling : m_texSamplings) for (const TexSampling& sampling : m_texSamplings)
retval += HECL::Format(" float4 sampling%u = tex%u.sample(samp, vtf.tcgs%u);\n", retval += hecl::Format(" float4 sampling%u = tex%u.sample(samp, vtf.tcgs%u);\n",
sampIdx++, sampling.mapIdx, sampling.tcgIdx); sampIdx++, sampling.mapIdx, sampling.tcgIdx);
if (m_alphaExpr.size()) if (m_alphaExpr.size())
@ -261,12 +261,12 @@ struct MetalBackendFactory : IShaderBackendFactory
: m_gfxFactory(dynamic_cast<boo::MetalDataFactory*>(gfxFactory)) {} : m_gfxFactory(dynamic_cast<boo::MetalDataFactory*>(gfxFactory)) {}
ShaderCachedData buildShaderFromIR(const ShaderTag& tag, ShaderCachedData buildShaderFromIR(const ShaderTag& tag,
const HECL::Frontend::IR& ir, const hecl::Frontend::IR& ir,
HECL::Frontend::Diagnostics& diag, hecl::Frontend::Diagnostics& diag,
boo::IShaderPipeline*& objOut) boo::IShaderPipeline*& objOut)
{ {
if (!m_rtHint) if (!m_rtHint)
Log.report(LogVisor::FatalError, Log.report(logvisor::Fatal,
"ShaderCacheManager::setRenderTargetHint must be called before making metal shaders"); "ShaderCacheManager::setRenderTargetHint must be called before making metal shaders");
m_backend.reset(ir, diag); m_backend.reset(ir, diag);
@ -286,10 +286,10 @@ struct MetalBackendFactory : IShaderBackendFactory
tag.getDepthTest(), tag.getDepthWrite(), tag.getDepthTest(), tag.getDepthWrite(),
tag.getBackfaceCulling()); tag.getBackfaceCulling());
if (!*objOut) if (!*objOut)
Log.report(LogVisor::FatalError, "unable to build shader"); Log.report(logvisor::Fatal, "unable to build shader");
ShaderCachedData dataOut(tag, cachedSz); ShaderCachedData dataOut(tag, cachedSz);
Athena::io::MemoryWriter w(dataOut.m_data.get(), dataOut.m_sz); athena::io::MemoryWriter w(dataOut.m_data.get(), dataOut.m_sz);
w.writeUByte(atUint8(m_backend.m_blendSrc)); w.writeUByte(atUint8(m_backend.m_blendSrc));
w.writeUByte(atUint8(m_backend.m_blendDst)); w.writeUByte(atUint8(m_backend.m_blendDst));
w.writeString(vertSource); w.writeString(vertSource);
@ -301,11 +301,11 @@ struct MetalBackendFactory : IShaderBackendFactory
boo::IShaderPipeline* buildShaderFromCache(const ShaderCachedData& data) boo::IShaderPipeline* buildShaderFromCache(const ShaderCachedData& data)
{ {
if (!m_rtHint) if (!m_rtHint)
Log.report(LogVisor::FatalError, Log.report(logvisor::Fatal,
"ShaderCacheManager::setRenderTargetHint must be called before making metal shaders"); "ShaderCacheManager::setRenderTargetHint must be called before making metal shaders");
const ShaderTag& tag = data.m_tag; const ShaderTag& tag = data.m_tag;
Athena::io::MemoryReader r(data.m_data.get(), data.m_sz); athena::io::MemoryReader r(data.m_data.get(), data.m_sz);
boo::BlendFactor blendSrc = boo::BlendFactor(r.readUByte()); boo::BlendFactor blendSrc = boo::BlendFactor(r.readUByte());
boo::BlendFactor blendDst = boo::BlendFactor(r.readUByte()); boo::BlendFactor blendDst = boo::BlendFactor(r.readUByte());
std::string vertSource = r.readString(); std::string vertSource = r.readString();
@ -317,18 +317,18 @@ struct MetalBackendFactory : IShaderBackendFactory
tag.getDepthTest(), tag.getDepthWrite(), tag.getDepthTest(), tag.getDepthWrite(),
tag.getBackfaceCulling()); tag.getBackfaceCulling());
if (!ret) if (!ret)
Log.report(LogVisor::FatalError, "unable to build shader"); Log.report(logvisor::Fatal, "unable to build shader");
return ret; return ret;
} }
ShaderCachedData buildExtendedShaderFromIR(const ShaderTag& tag, ShaderCachedData buildExtendedShaderFromIR(const ShaderTag& tag,
const HECL::Frontend::IR& ir, const hecl::Frontend::IR& ir,
HECL::Frontend::Diagnostics& diag, hecl::Frontend::Diagnostics& diag,
const std::vector<ShaderCacheExtensions::ExtensionSlot>& extensionSlots, const std::vector<ShaderCacheExtensions::ExtensionSlot>& extensionSlots,
FReturnExtensionShader returnFunc) FReturnExtensionShader returnFunc)
{ {
if (!m_rtHint) if (!m_rtHint)
Log.report(LogVisor::FatalError, Log.report(logvisor::Fatal,
"ShaderCacheManager::setRenderTargetHint must be called before making metal shaders"); "ShaderCacheManager::setRenderTargetHint must be called before making metal shaders");
m_backend.reset(ir, diag); m_backend.reset(ir, diag);
@ -352,12 +352,12 @@ struct MetalBackendFactory : IShaderBackendFactory
tag.getDepthTest(), tag.getDepthWrite(), tag.getDepthTest(), tag.getDepthWrite(),
tag.getBackfaceCulling()); tag.getBackfaceCulling());
if (!ret) if (!ret)
Log.report(LogVisor::FatalError, "unable to build shader"); Log.report(logvisor::Fatal, "unable to build shader");
returnFunc(ret); returnFunc(ret);
} }
ShaderCachedData dataOut(tag, cachedSz); ShaderCachedData dataOut(tag, cachedSz);
Athena::io::MemoryWriter w(dataOut.m_data.get(), dataOut.m_sz); athena::io::MemoryWriter w(dataOut.m_data.get(), dataOut.m_sz);
w.writeUByte(atUint8(m_backend.m_blendSrc)); w.writeUByte(atUint8(m_backend.m_blendSrc));
w.writeUByte(atUint8(m_backend.m_blendDst)); w.writeUByte(atUint8(m_backend.m_blendDst));
w.writeString(vertSource); w.writeString(vertSource);
@ -372,11 +372,11 @@ struct MetalBackendFactory : IShaderBackendFactory
FReturnExtensionShader returnFunc) FReturnExtensionShader returnFunc)
{ {
if (!m_rtHint) if (!m_rtHint)
Log.report(LogVisor::FatalError, Log.report(logvisor::Fatal,
"ShaderCacheManager::setRenderTargetHint must be called before making metal shaders"); "ShaderCacheManager::setRenderTargetHint must be called before making metal shaders");
const ShaderTag& tag = data.m_tag; const ShaderTag& tag = data.m_tag;
Athena::io::MemoryReader r(data.m_data.get(), data.m_sz); athena::io::MemoryReader r(data.m_data.get(), data.m_sz);
boo::BlendFactor blendSrc = boo::BlendFactor(r.readUByte()); boo::BlendFactor blendSrc = boo::BlendFactor(r.readUByte());
boo::BlendFactor blendDst = boo::BlendFactor(r.readUByte()); boo::BlendFactor blendDst = boo::BlendFactor(r.readUByte());
std::string vertSource = r.readString(); std::string vertSource = r.readString();
@ -390,7 +390,7 @@ struct MetalBackendFactory : IShaderBackendFactory
tag.getDepthTest(), tag.getDepthWrite(), tag.getDepthTest(), tag.getDepthWrite(),
tag.getBackfaceCulling()); tag.getBackfaceCulling());
if (!ret) if (!ret)
Log.report(LogVisor::FatalError, "unable to build shader"); Log.report(logvisor::Fatal, "unable to build shader");
returnFunc(ret); returnFunc(ret);
} }
} }

View File

@ -1,7 +1,7 @@
#include "HECL/Backend/ProgrammableCommon.hpp" #include "hecl/Backend/ProgrammableCommon.hpp"
#include <map> #include <map>
namespace HECL namespace hecl
{ {
namespace Backend namespace Backend
{ {

View File

@ -4,34 +4,34 @@ add_subdirectory(Frontend)
add_subdirectory(Runtime) add_subdirectory(Runtime)
if(WIN32) if(WIN32)
list(APPEND PLAT_SRCS winsupport.cpp ../include/HECL/winsupport.hpp) list(APPEND PLAT_SRCS winsupport.cpp ../include/hecl/winsupport.hpp)
endif() endif()
atdna(atdna_HMDLMeta.cpp ../include/HECL/HMDLMeta.hpp) atdna(atdna_HMDLMeta.cpp ../include/hecl/HMDLMeta.hpp)
atdna(atdna_Frontend.cpp ../include/HECL/Frontend.hpp) atdna(atdna_Frontend.cpp ../include/hecl/Frontend.hpp)
atdna(atdna_Runtime.cpp ../include/HECL/Runtime.hpp) atdna(atdna_Runtime.cpp ../include/hecl/Runtime.hpp)
atdna(atdna_CVar.cpp ../include/HECL/CVar.hpp) atdna(atdna_CVar.cpp ../include/hecl/CVar.hpp)
add_library(HECLCommon add_library(hecl-common
HECL.cpp hecl.cpp
ProjectPath.cpp ProjectPath.cpp
WideStringConvert.cpp WideStringConvert.cpp
HumanizeNumber.cpp HumanizeNumber.cpp
CVar.cpp CVar.cpp
CVarManager.cpp CVarManager.cpp
../include/HECL/CVar.hpp ../include/hecl/CVar.hpp
../include/HECL/CVarManager.hpp ../include/hecl/CVarManager.hpp
../include/HECL/HECL.hpp ../include/hecl/hecl.hpp
../include/HECL/HMDLMeta.hpp ../include/hecl/HMDLMeta.hpp
../include/HECL/Backend/Backend.hpp ../include/hecl/Backend/Backend.hpp
../include/HECL/Backend/GX.hpp ../include/hecl/Backend/GX.hpp
../include/HECL/Backend/ProgrammableCommon.hpp ../include/hecl/Backend/ProgrammableCommon.hpp
../include/HECL/Backend/GLSL.hpp ../include/hecl/Backend/GLSL.hpp
../include/HECL/Backend/HLSL.hpp ../include/hecl/Backend/HLSL.hpp
../include/HECL/Backend/Metal.hpp ../include/hecl/Backend/Metal.hpp
../include/HECL/Frontend.hpp ../include/hecl/Frontend.hpp
../include/HECL/Database.hpp ../include/hecl/Database.hpp
../include/HECL/Runtime.hpp ../include/hecl/Runtime.hpp
atdna_HMDLMeta.cpp atdna_HMDLMeta.cpp
atdna_Frontend.cpp atdna_Frontend.cpp
atdna_Runtime.cpp atdna_Runtime.cpp

View File

@ -1,11 +1,11 @@
#include "HECL/HECL.hpp" #include "hecl/hecl.hpp"
#include "HECL/CVar.hpp" #include "hecl/CVar.hpp"
#include "HECL/CVarManager.hpp" #include "hecl/CVarManager.hpp"
#include <Athena/Utility.hpp> #include <athena/Utility.hpp>
#include <algorithm> #include <algorithm>
namespace HECL namespace hecl
{ {
extern CVar* com_developer; extern CVar* com_developer;
extern CVar* com_enableCheats; extern CVar* com_enableCheats;
@ -234,7 +234,7 @@ const std::wstring CVar::toWideLiteral(bool* isValid) const
*isValid = true; *isValid = true;
// Even if it's not a literal, it's still safe to return // Even if it's not a literal, it's still safe to return
return HECL::UTF8ToWide(m_value); return hecl::UTF8ToWide(m_value);
} }
bool CVar::fromVec4f(const atVec4f& val) bool CVar::fromVec4f(const atVec4f& val)
@ -250,7 +250,7 @@ bool CVar::fromVec4f(const atVec4f& val)
if (isReadOnly() && (com_developer && !com_developer->toBoolean())) if (isReadOnly() && (com_developer && !com_developer->toBoolean()))
return false; return false;
m_value.assign(HECL::Format("%f %f %f %f", val.vec[0], val.vec[1], val.vec[2], val.vec[3])); m_value.assign(hecl::Format("%f %f %f %f", val.vec[0], val.vec[1], val.vec[2], val.vec[3]));
m_flags |= EFlags::Modified; m_flags |= EFlags::Modified;
return true; return true;
} }
@ -268,7 +268,7 @@ bool CVar::fromFloat(float val)
if (isReadOnly() && (com_developer && !com_developer->toBoolean())) if (isReadOnly() && (com_developer && !com_developer->toBoolean()))
return false; return false;
m_value.assign(HECL::Format("%f", val)); m_value.assign(hecl::Format("%f", val));
setModified(); setModified();
return true; return true;
} }
@ -308,7 +308,7 @@ bool CVar::fromInteger(int val)
if (isReadOnly() && (com_developer && !com_developer->toBoolean())) if (isReadOnly() && (com_developer && !com_developer->toBoolean()))
return false; return false;
m_value = HECL::Format("%i", val); m_value = hecl::Format("%i", val);
setModified(); setModified();
return true; return true;
} }
@ -344,7 +344,7 @@ bool CVar::fromLiteral(const std::wstring& val)
if (isReadOnly() && (com_developer && !com_developer->toBoolean())) if (isReadOnly() && (com_developer && !com_developer->toBoolean()))
return false; return false;
m_value.assign(HECL::WideToUTF8(val)); m_value.assign(hecl::WideToUTF8(val));
setModified(); setModified();
return true; return true;
} }

View File

@ -1,11 +1,11 @@
#include "HECL/CVarManager.hpp" #include "hecl/CVarManager.hpp"
#include "HECL/CVar.hpp" #include "hecl/CVar.hpp"
#include <Athena/FileWriter.hpp> #include <athena/FileWriter.hpp>
#include <Athena/Utility.hpp> #include <athena/Utility.hpp>
#include <HECL/Runtime.hpp> #include <hecl/Runtime.hpp>
#include <memory> #include <memory>
namespace HECL namespace hecl
{ {
CVar* com_developer = nullptr; CVar* com_developer = nullptr;
@ -14,8 +14,8 @@ CVar* com_enableCheats = nullptr;
CVarManager* CVarManager::m_instance = nullptr; CVarManager* CVarManager::m_instance = nullptr;
LogVisor::LogModule CVarLog("CVarManager"); logvisor::Module CVarLog("CVarManager");
CVarManager::CVarManager(HECL::Runtime::FileStoreManager& store, bool useBinary) CVarManager::CVarManager(hecl::Runtime::FileStoreManager& store, bool useBinary)
: m_store(store), : m_store(store),
m_useBinary(useBinary) m_useBinary(useBinary)
{ {
@ -42,7 +42,7 @@ void CVarManager::update()
bool CVarManager::registerCVar(CVar* cvar) bool CVarManager::registerCVar(CVar* cvar)
{ {
std::string tmp = cvar->name(); std::string tmp = cvar->name();
Athena::utility::tolower(tmp); athena::utility::tolower(tmp);
if (m_cvars.find(tmp) != m_cvars.end()) if (m_cvars.find(tmp) != m_cvars.end())
return false; return false;
@ -52,7 +52,7 @@ bool CVarManager::registerCVar(CVar* cvar)
CVar* CVarManager::findCVar(std::string name) CVar* CVarManager::findCVar(std::string name)
{ {
Athena::utility::tolower(name); athena::utility::tolower(name);
if (m_cvars.find(name) == m_cvars.end()) if (m_cvars.find(name) == m_cvars.end())
return nullptr; return nullptr;
@ -85,27 +85,27 @@ void CVarManager::deserialize(CVar* cvar)
CVarContainer container; CVarContainer container;
#if _WIN32 #if _WIN32
HECL::SystemString filename = m_store.getStoreRoot() + _S('/') + com_configfile->toWideLiteral(); hecl::SystemString filename = m_store.getStoreRoot() + _S('/') + com_configfile->toWideLiteral();
#else #else
HECL::SystemString filename = m_store.getStoreRoot() + _S('/') + com_configfile->toLiteral(); hecl::SystemString filename = m_store.getStoreRoot() + _S('/') + com_configfile->toLiteral();
#endif #endif
HECL::Sstat st; hecl::Sstat st;
if (m_useBinary) if (m_useBinary)
{ {
filename += _S(".bin"); filename += _S(".bin");
if (HECL::Stat(filename.c_str(), &st) || !S_ISREG(st.st_mode)) if (hecl::Stat(filename.c_str(), &st) || !S_ISREG(st.st_mode))
return; return;
Athena::io::FileReader reader(filename); athena::io::FileReader reader(filename);
if (reader.isOpen()) if (reader.isOpen())
container.read(reader); container.read(reader);
} }
else else
{ {
filename += _S(".yaml"); filename += _S(".yaml");
if (HECL::Stat(filename.c_str(), &st) || !S_ISREG(st.st_mode)) if (hecl::Stat(filename.c_str(), &st) || !S_ISREG(st.st_mode))
return; return;
FILE* f = HECL::Fopen(filename.c_str(), _S("rb")); FILE* f = hecl::Fopen(filename.c_str(), _S("rb"));
if (f) if (f)
container.fromYAMLFile(f); container.fromYAMLFile(f);
fclose(f); fclose(f);
@ -122,7 +122,7 @@ void CVarManager::deserialize(CVar* cvar)
DNACVAR::CVar& tmp = *serialized; DNACVAR::CVar& tmp = *serialized;
if (tmp.m_type != cvar->type()) if (tmp.m_type != cvar->type())
{ {
CVarLog.report(LogVisor::Error, _S("Stored type for %s does not match actual type!"), tmp.m_name.c_str()); CVarLog.report(logvisor::Error, _S("Stored type for %s does not match actual type!"), tmp.m_name.c_str());
return; return;
} }
@ -148,22 +148,22 @@ void CVarManager::serialize()
container.cvarCount = container.cvars.size(); container.cvarCount = container.cvars.size();
#if _WIN32 #if _WIN32
HECL::SystemString filename = m_store.getStoreRoot() + _S('/') + com_configfile->toWideLiteral(); hecl::SystemString filename = m_store.getStoreRoot() + _S('/') + com_configfile->toWideLiteral();
#else #else
HECL::SystemString filename = m_store.getStoreRoot() + _S('/') + com_configfile->toLiteral(); hecl::SystemString filename = m_store.getStoreRoot() + _S('/') + com_configfile->toLiteral();
#endif #endif
if (m_useBinary) if (m_useBinary)
{ {
filename += _S(".bin"); filename += _S(".bin");
Athena::io::FileWriter writer(filename); athena::io::FileWriter writer(filename);
if (writer.isOpen()) if (writer.isOpen())
container.write(writer); container.write(writer);
} }
else else
{ {
filename += _S(".yaml"); filename += _S(".yaml");
FILE* f = HECL::Fopen(filename.c_str(), _S("wb")); FILE* f = hecl::Fopen(filename.c_str(), _S("wb"));
if (f) if (f)
container.toYAMLFile(f); container.toYAMLFile(f);
fclose(f); fclose(f);

View File

@ -1,3 +1,3 @@
add_library(HECLDatabase add_library(hecl-database
Project.cpp) Project.cpp)

View File

@ -9,14 +9,14 @@
#include <unistd.h> #include <unistd.h>
#endif #endif
#include "HECL/Database.hpp" #include "hecl/Database.hpp"
namespace HECL namespace hecl
{ {
namespace Database namespace Database
{ {
LogVisor::LogModule LogModule("HECLDatabase"); logvisor::Module LogModule("HECLDatabase");
/********************************************** /**********************************************
* Project::ConfigFile * Project::ConfigFile
@ -53,7 +53,7 @@ std::vector<std::string>& Project::ConfigFile::lockAndRead()
if (m_lockedFile) if (m_lockedFile)
return m_lines; return m_lines;
m_lockedFile = HECL::Fopen(m_filepath.c_str(), _S("a+"), FileLockType::Write); m_lockedFile = hecl::Fopen(m_filepath.c_str(), _S("a+"), FileLockType::Write);
std::string mainString; std::string mainString;
char readBuf[1024]; char readBuf[1024];
@ -95,7 +95,7 @@ void Project::ConfigFile::removeLine(const std::string& refLine)
{ {
if (!m_lockedFile) if (!m_lockedFile)
{ {
LogModule.reportSource(LogVisor::FatalError, __FILE__, __LINE__, LogModule.reportSource(logvisor::Fatal, __FILE__, __LINE__,
"Project::ConfigFile::lockAndRead not yet called"); "Project::ConfigFile::lockAndRead not yet called");
return; return;
} }
@ -116,7 +116,7 @@ bool Project::ConfigFile::checkForLine(const std::string& refLine)
{ {
if (!m_lockedFile) if (!m_lockedFile)
{ {
LogModule.reportSource(LogVisor::FatalError, __FILE__, __LINE__, LogModule.reportSource(logvisor::Fatal, __FILE__, __LINE__,
"Project::ConfigFile::lockAndRead not yet called"); "Project::ConfigFile::lockAndRead not yet called");
return false; return false;
} }
@ -131,7 +131,7 @@ void Project::ConfigFile::unlockAndDiscard()
{ {
if (!m_lockedFile) if (!m_lockedFile)
{ {
LogModule.reportSource(LogVisor::FatalError, __FILE__, __LINE__, LogModule.reportSource(logvisor::Fatal, __FILE__, __LINE__,
"Project::ConfigFile::lockAndRead not yet called"); "Project::ConfigFile::lockAndRead not yet called");
return; return;
} }
@ -145,13 +145,13 @@ bool Project::ConfigFile::unlockAndCommit()
{ {
if (!m_lockedFile) if (!m_lockedFile)
{ {
LogModule.reportSource(LogVisor::FatalError, __FILE__, __LINE__, LogModule.reportSource(logvisor::Fatal, __FILE__, __LINE__,
"Project::ConfigFile::lockAndRead not yet called"); "Project::ConfigFile::lockAndRead not yet called");
return false; return false;
} }
SystemString newPath = m_filepath + _S(".part"); SystemString newPath = m_filepath + _S(".part");
FILE* newFile = HECL::Fopen(newPath.c_str(), _S("w"), FileLockType::Write); FILE* newFile = hecl::Fopen(newPath.c_str(), _S("w"), FileLockType::Write);
bool fail = false; bool fail = false;
for (const std::string& line : m_lines) for (const std::string& line : m_lines)
{ {
@ -205,15 +205,15 @@ Project::Project(const ProjectRootPath& rootPath)
{ {
/* Stat for existing project directory (must already exist) */ /* Stat for existing project directory (must already exist) */
Sstat myStat; Sstat myStat;
if (HECL::Stat(m_rootPath.getAbsolutePath().c_str(), &myStat)) if (hecl::Stat(m_rootPath.getAbsolutePath().c_str(), &myStat))
{ {
LogModule.report(LogVisor::Error, _S("unable to stat %s"), m_rootPath.getAbsolutePath().c_str()); LogModule.report(logvisor::Error, _S("unable to stat %s"), m_rootPath.getAbsolutePath().c_str());
return; return;
} }
if (!S_ISDIR(myStat.st_mode)) if (!S_ISDIR(myStat.st_mode))
{ {
LogModule.report(LogVisor::Error, _S("provided path must be a directory; '%s' isn't"), m_rootPath.getAbsolutePath().c_str()); LogModule.report(logvisor::Error, _S("provided path must be a directory; '%s' isn't"), m_rootPath.getAbsolutePath().c_str());
return; return;
} }
@ -223,14 +223,14 @@ Project::Project(const ProjectRootPath& rootPath)
/* Ensure beacon is valid or created */ /* Ensure beacon is valid or created */
ProjectPath beaconPath(m_dotPath, _S("beacon")); ProjectPath beaconPath(m_dotPath, _S("beacon"));
FILE* bf = HECL::Fopen(beaconPath.getAbsolutePath().c_str(), _S("a+b")); FILE* bf = hecl::Fopen(beaconPath.getAbsolutePath().c_str(), _S("a+b"));
struct BeaconStruct struct BeaconStruct
{ {
HECL::FourCC magic; hecl::FourCC magic;
uint32_t version; uint32_t version;
} beacon; } beacon;
#define DATA_VERSION 1 #define DATA_VERSION 1
static const HECL::FourCC HECLfcc("HECL"); static const hecl::FourCC HECLfcc("HECL");
if (fread(&beacon, 1, sizeof(beacon), bf) != sizeof(beacon)) if (fread(&beacon, 1, sizeof(beacon), bf) != sizeof(beacon))
{ {
fseek(bf, 0, SEEK_SET); fseek(bf, 0, SEEK_SET);
@ -242,7 +242,7 @@ Project::Project(const ProjectRootPath& rootPath)
if (beacon.magic != HECLfcc || if (beacon.magic != HECLfcc ||
SBig(beacon.version) != DATA_VERSION) SBig(beacon.version) != DATA_VERSION)
{ {
LogModule.report(LogVisor::FatalError, "incompatible project version"); LogModule.report(logvisor::Fatal, "incompatible project version");
return; return;
} }
@ -285,7 +285,7 @@ bool Project::removePaths(const std::vector<ProjectPath>& paths, bool recursive)
return m_paths.unlockAndCommit(); return m_paths.unlockAndCommit();
} }
bool Project::addGroup(const HECL::ProjectPath& path) bool Project::addGroup(const hecl::ProjectPath& path)
{ {
m_groups.lockAndRead(); m_groups.lockAndRead();
m_groups.addLine(path.getRelativePathUTF8()); m_groups.addLine(path.getRelativePathUTF8());
@ -305,9 +305,9 @@ void Project::rescanDataSpecs()
m_specs.lockAndRead(); m_specs.lockAndRead();
for (const DataSpecEntry* spec : DATA_SPEC_REGISTRY) for (const DataSpecEntry* spec : DATA_SPEC_REGISTRY)
{ {
HECL::SystemString specStr(spec->m_name); hecl::SystemString specStr(spec->m_name);
SystemUTF8View specUTF8(specStr); SystemUTF8View specUTF8(specStr);
m_compiledSpecs.push_back({*spec, ProjectPath(m_cookedRoot, HECL::SystemString(spec->m_name) + _S(".spec")), m_compiledSpecs.push_back({*spec, ProjectPath(m_cookedRoot, hecl::SystemString(spec->m_name) + _S(".spec")),
m_specs.checkForLine(specUTF8) ? true : false}); m_specs.checkForLine(specUTF8) ? true : false});
} }
m_specs.unlockAndDiscard(); m_specs.unlockAndDiscard();

View File

@ -1,4 +1,4 @@
add_library(HECLFrontend add_library(hecl-frontend
Parser.cpp Parser.cpp
Lexer.cpp Lexer.cpp
Diagnostics.cpp) Diagnostics.cpp)

View File

@ -1,5 +1,5 @@
#include "HECL/HECL.hpp" #include "hecl/hecl.hpp"
#include "HECL/Frontend.hpp" #include "hecl/Frontend.hpp"
#include <stdarg.h> #include <stdarg.h>
@ -12,7 +12,7 @@
#define BOLD "\x1b[1m" #define BOLD "\x1b[1m"
#define NORMAL "\x1b[0m" #define NORMAL "\x1b[0m"
namespace HECL namespace hecl
{ {
namespace Frontend namespace Frontend
{ {
@ -56,11 +56,11 @@ void Diagnostics::reportParserErr(const SourceLocation& l, const char* fmt, ...)
vasprintf(&result, fmt, ap); vasprintf(&result, fmt, ap);
#endif #endif
va_end(ap); va_end(ap);
if (LogVisor::XtermColor) if (logvisor::XtermColor)
LogModule.report(LogVisor::FatalError, CYAN "[Parser]" NORMAL " %s " YELLOW "@%d:%d " NORMAL "\n%s\n%s", LogModule.report(logvisor::Fatal, CYAN "[Parser]" NORMAL " %s " YELLOW "@%d:%d " NORMAL "\n%s\n%s",
m_name.c_str(), l.line, l.col, result, sourceDiagString(l, true).c_str()); m_name.c_str(), l.line, l.col, result, sourceDiagString(l, true).c_str());
else else
LogModule.report(LogVisor::FatalError, "[Parser] %s @%d:%d\n%s\n%s", LogModule.report(logvisor::Fatal, "[Parser] %s @%d:%d\n%s\n%s",
m_name.c_str(), l.line, l.col, result, sourceDiagString(l, false).c_str()); m_name.c_str(), l.line, l.col, result, sourceDiagString(l, false).c_str());
free(result); free(result);
} }
@ -78,11 +78,11 @@ void Diagnostics::reportLexerErr(const SourceLocation& l, const char* fmt, ...)
vasprintf(&result, fmt, ap); vasprintf(&result, fmt, ap);
#endif #endif
va_end(ap); va_end(ap);
if (LogVisor::XtermColor) if (logvisor::XtermColor)
LogModule.report(LogVisor::FatalError, CYAN "[Lexer]" NORMAL " %s " YELLOW "@%d:%d " NORMAL "\n%s\n%s", LogModule.report(logvisor::Fatal, CYAN "[Lexer]" NORMAL " %s " YELLOW "@%d:%d " NORMAL "\n%s\n%s",
m_name.c_str(), l.line, l.col, result, sourceDiagString(l, true).c_str()); m_name.c_str(), l.line, l.col, result, sourceDiagString(l, true).c_str());
else else
LogModule.report(LogVisor::FatalError, "[Lexer] %s @%d:%d\n%s\n%s", LogModule.report(logvisor::Fatal, "[Lexer] %s @%d:%d\n%s\n%s",
m_name.c_str(), l.line, l.col, result, sourceDiagString(l, false).c_str()); m_name.c_str(), l.line, l.col, result, sourceDiagString(l, false).c_str());
free(result); free(result);
} }
@ -100,11 +100,11 @@ void Diagnostics::reportCompileErr(const SourceLocation& l, const char* fmt, ...
vasprintf(&result, fmt, ap); vasprintf(&result, fmt, ap);
#endif #endif
va_end(ap); va_end(ap);
if (LogVisor::XtermColor) if (logvisor::XtermColor)
LogModule.report(LogVisor::FatalError, CYAN "[Compiler]" NORMAL " %s " YELLOW "@%d:%d " NORMAL "\n%s\n%s", LogModule.report(logvisor::Fatal, CYAN "[Compiler]" NORMAL " %s " YELLOW "@%d:%d " NORMAL "\n%s\n%s",
m_name.c_str(), l.line, l.col, result, sourceDiagString(l, true).c_str()); m_name.c_str(), l.line, l.col, result, sourceDiagString(l, true).c_str());
else else
LogModule.report(LogVisor::FatalError, "[Compiler] %s @%d:%d\n%s\n%s", LogModule.report(logvisor::Fatal, "[Compiler] %s @%d:%d\n%s\n%s",
m_name.c_str(), l.line, l.col, result, sourceDiagString(l, false).c_str()); m_name.c_str(), l.line, l.col, result, sourceDiagString(l, false).c_str());
free(result); free(result);
} }
@ -122,11 +122,11 @@ void Diagnostics::reportBackendErr(const SourceLocation& l, const char* fmt, ...
vasprintf(&result, fmt, ap); vasprintf(&result, fmt, ap);
#endif #endif
va_end(ap); va_end(ap);
if (LogVisor::XtermColor) if (logvisor::XtermColor)
LogModule.report(LogVisor::FatalError, CYAN "[%s]" NORMAL " %s " YELLOW "@%d:%d " NORMAL "\n%s\n%s", LogModule.report(logvisor::Fatal, CYAN "[%s]" NORMAL " %s " YELLOW "@%d:%d " NORMAL "\n%s\n%s",
m_backend.c_str(), m_name.c_str(), l.line, l.col, result, sourceDiagString(l, true).c_str()); m_backend.c_str(), m_name.c_str(), l.line, l.col, result, sourceDiagString(l, true).c_str());
else else
LogModule.report(LogVisor::FatalError, "[%s] %s @%d:%d\n%s\n%s", LogModule.report(logvisor::Fatal, "[%s] %s @%d:%d\n%s\n%s",
m_backend.c_str(), m_name.c_str(), l.line, l.col, result, sourceDiagString(l, false).c_str()); m_backend.c_str(), m_name.c_str(), l.line, l.col, result, sourceDiagString(l, false).c_str());
free(result); free(result);
} }

View File

@ -1,9 +1,9 @@
#include "HECL/HECL.hpp" #include "hecl/hecl.hpp"
#include "HECL/Frontend.hpp" #include "hecl/Frontend.hpp"
/* Combined lexer and semantic analysis system */ /* Combined lexer and semantic analysis system */
namespace HECL namespace hecl
{ {
namespace Frontend namespace Frontend
{ {
@ -343,7 +343,7 @@ void Lexer::consumeAllTokens(Parser& parser)
} }
} }
if (HECL::VerbosityLevel > 1) if (hecl::VerbosityLevel > 1)
{ {
printf("%s\n", m_diag.getSource().c_str()); printf("%s\n", m_diag.getSource().c_str());
PrintTree(firstNode); PrintTree(firstNode);

View File

@ -1,9 +1,9 @@
#include "HECL/HECL.hpp" #include "hecl/hecl.hpp"
#include "HECL/Frontend.hpp" #include "hecl/Frontend.hpp"
/* Syntatical token parsing system */ /* Syntatical token parsing system */
namespace HECL namespace hecl
{ {
namespace Frontend namespace Frontend
{ {

View File

@ -1,5 +1,5 @@
#include "HECL/HECL.hpp" #include "hecl/hecl.hpp"
#include <LogVisor/LogVisor.hpp> #include "logvisor/logvisor.hpp"
/* /*
* Copyright (c) 1997, 1998, 1999, 2002 The NetBSD Foundation, Inc. * Copyright (c) 1997, 1998, 1999, 2002 The NetBSD Foundation, Inc.
@ -32,9 +32,9 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
namespace HECL namespace hecl
{ {
static LogVisor::LogModule Log("HECL::HumanizeNumber"); static logvisor::Module Log("hecl::HumanizeNumber");
static const int maxscale = 7; static const int maxscale = 7;
@ -50,7 +50,7 @@ std::string HumanizeNumber(int64_t quotient, size_t len, const char* suffix, int
if (suffix == nullptr) if (suffix == nullptr)
suffix = ""; suffix = "";
if ((flags & HNFlags::Divisor1000) != HNFlags::None && (flags & HNFlags::IECPrefixes) != HNFlags::None) if ((flags & HNFlags::Divisor1000) != HNFlags::None && (flags & HNFlags::IECPrefixes) != HNFlags::None)
Log.report(LogVisor::FatalError, "invalid flags combo"); Log.report(logvisor::Fatal, "invalid flags combo");
/* setup parameters */ /* setup parameters */
remainder = 0; remainder = 0;
@ -111,7 +111,7 @@ std::string HumanizeNumber(int64_t quotient, size_t len, const char* suffix, int
/* Check if enough room for `x y' + suffix */ /* Check if enough room for `x y' + suffix */
if (len < baselen) if (len < baselen)
Log.report(LogVisor::FatalError, Log.report(logvisor::Fatal,
"buffer size %" PRISize "insufficient for minimum size %" PRISize, "buffer size %" PRISize "insufficient for minimum size %" PRISize,
len, baselen); len, baselen);
std::string ret(len, '\0'); std::string ret(len, '\0');

View File

@ -1,8 +1,8 @@
#include "HECL/HECL.hpp" #include "hecl/hecl.hpp"
#include "HECL/Database.hpp" #include "hecl/Database.hpp"
#include <regex> #include <regex>
namespace HECL namespace hecl
{ {
static const SystemRegex regGLOB(_S("\\*"), SystemRegex::ECMAScript|SystemRegex::optimize); static const SystemRegex regGLOB(_S("\\*"), SystemRegex::ECMAScript|SystemRegex::optimize);
static const SystemRegex regPATHCOMP(_S("[/\\\\]*([^/\\\\]+)"), SystemRegex::ECMAScript|SystemRegex::optimize); static const SystemRegex regPATHCOMP(_S("[/\\\\]*([^/\\\\]+)"), SystemRegex::ECMAScript|SystemRegex::optimize);
@ -12,7 +12,7 @@ static SystemString CanonRelPath(const SystemString& path)
{ {
/* Tokenize Path */ /* Tokenize Path */
std::vector<SystemString> comps; std::vector<SystemString> comps;
HECL::SystemRegexMatch matches; hecl::SystemRegexMatch matches;
SystemString in = path; SystemString in = path;
SanitizePath(in); SanitizePath(in);
for (; std::regex_search(in, matches, regPATHCOMP) ; in = matches.suffix()) for (; std::regex_search(in, matches, regPATHCOMP) ; in = matches.suffix())
@ -25,7 +25,7 @@ static SystemString CanonRelPath(const SystemString& path)
if (comps.empty()) if (comps.empty())
{ {
/* Unable to resolve outside project */ /* Unable to resolve outside project */
LogModule.report(LogVisor::FatalError, _S("Unable to resolve outside project root in %s"), path.c_str()); LogModule.report(logvisor::Fatal, _S("Unable to resolve outside project root in %s"), path.c_str());
return _S("."); return _S(".");
} }
comps.pop_back(); comps.pop_back();
@ -131,7 +131,7 @@ ProjectPath::Type ProjectPath::getPathType() const
if (std::regex_search(m_absPath, regGLOB)) if (std::regex_search(m_absPath, regGLOB))
return Type::Glob; return Type::Glob;
Sstat theStat; Sstat theStat;
if (HECL::Stat(m_absPath.c_str(), &theStat)) if (hecl::Stat(m_absPath.c_str(), &theStat))
return Type::None; return Type::None;
if (S_ISDIR(theStat.st_mode)) if (S_ISDIR(theStat.st_mode))
return Type::Directory; return Type::Directory;
@ -150,14 +150,14 @@ Time ProjectPath::getModtime() const
getGlobResults(globResults); getGlobResults(globResults);
for (ProjectPath& path : globResults) for (ProjectPath& path : globResults)
{ {
if (!HECL::Stat(path.getAbsolutePath().c_str(), &theStat)) if (!hecl::Stat(path.getAbsolutePath().c_str(), &theStat))
{ {
if (S_ISREG(theStat.st_mode) && theStat.st_mtime > latestTime) if (S_ISREG(theStat.st_mode) && theStat.st_mtime > latestTime)
latestTime = theStat.st_mtime; latestTime = theStat.st_mtime;
} }
} }
} }
if (!HECL::Stat(m_absPath.c_str(), &theStat)) if (!hecl::Stat(m_absPath.c_str(), &theStat))
{ {
if (S_ISREG(theStat.st_mode)) if (S_ISREG(theStat.st_mode))
{ {
@ -165,10 +165,10 @@ Time ProjectPath::getModtime() const
} }
else if (S_ISDIR(theStat.st_mode)) else if (S_ISDIR(theStat.st_mode))
{ {
HECL::DirectoryEnumerator de(m_absPath); hecl::DirectoryEnumerator de(m_absPath);
for (const HECL::DirectoryEnumerator::Entry& ent : de) for (const hecl::DirectoryEnumerator::Entry& ent : de)
{ {
if (!HECL::Stat(ent.m_path.c_str(), &theStat)) if (!hecl::Stat(ent.m_path.c_str(), &theStat))
{ {
if (S_ISREG(theStat.st_mode) && theStat.st_mtime > latestTime) if (S_ISREG(theStat.st_mode) && theStat.st_mtime > latestTime)
latestTime = theStat.st_mtime; latestTime = theStat.st_mtime;
@ -177,7 +177,7 @@ Time ProjectPath::getModtime() const
return Time(latestTime); return Time(latestTime);
} }
} }
LogModule.report(LogVisor::FatalError, _S("invalid path type for computing modtime in '%s'"), m_absPath.c_str()); LogModule.report(logvisor::Fatal, _S("invalid path type for computing modtime in '%s'"), m_absPath.c_str());
return Time(); return Time();
} }
@ -205,8 +205,8 @@ static void _recursiveGlob(Database::Project& proj,
/* Compile component into regex */ /* Compile component into regex */
SystemRegex regComp(comp, SystemRegex::ECMAScript); SystemRegex regComp(comp, SystemRegex::ECMAScript);
HECL::DirectoryEnumerator de(itStr); hecl::DirectoryEnumerator de(itStr);
for (const HECL::DirectoryEnumerator::Entry& ent : de) for (const hecl::DirectoryEnumerator::Entry& ent : de)
{ {
if (std::regex_search(ent.m_name, regComp)) if (std::regex_search(ent.m_name, regComp))
{ {
@ -215,7 +215,7 @@ static void _recursiveGlob(Database::Project& proj,
nextItStr += '/'; nextItStr += '/';
nextItStr += ent.m_name; nextItStr += ent.m_name;
HECL::Sstat theStat; hecl::Sstat theStat;
if (Stat(nextItStr.c_str(), &theStat)) if (Stat(nextItStr.c_str(), &theStat))
continue; continue;
@ -229,14 +229,14 @@ static void _recursiveGlob(Database::Project& proj,
void ProjectPath::getDirChildren(std::map<SystemString, ProjectPath>& outPaths) const void ProjectPath::getDirChildren(std::map<SystemString, ProjectPath>& outPaths) const
{ {
HECL::DirectoryEnumerator de(m_absPath); hecl::DirectoryEnumerator de(m_absPath);
for (const HECL::DirectoryEnumerator::Entry& ent : de) for (const hecl::DirectoryEnumerator::Entry& ent : de)
outPaths[ent.m_name] = ProjectPath(*this, ent.m_name); outPaths[ent.m_name] = ProjectPath(*this, ent.m_name);
} }
HECL::DirectoryEnumerator ProjectPath::enumerateDir() const hecl::DirectoryEnumerator ProjectPath::enumerateDir() const
{ {
return HECL::DirectoryEnumerator(m_absPath); return hecl::DirectoryEnumerator(m_absPath);
} }
void ProjectPath::getGlobResults(std::vector<ProjectPath>& outPaths) const void ProjectPath::getGlobResults(std::vector<ProjectPath>& outPaths) const
@ -268,11 +268,11 @@ ProjectRootPath SearchForProject(const SystemString& path)
SystemString testPath(begin, end); SystemString testPath(begin, end);
SystemString testIndexPath = testPath + _S("/.hecl/beacon"); SystemString testIndexPath = testPath + _S("/.hecl/beacon");
Sstat theStat; Sstat theStat;
if (!HECL::Stat(testIndexPath.c_str(), &theStat)) if (!hecl::Stat(testIndexPath.c_str(), &theStat))
{ {
if (S_ISREG(theStat.st_mode)) if (S_ISREG(theStat.st_mode))
{ {
FILE* fp = HECL::Fopen(testIndexPath.c_str(), _S("rb")); FILE* fp = hecl::Fopen(testIndexPath.c_str(), _S("rb"));
if (!fp) if (!fp)
continue; continue;
char magic[4]; char magic[4];
@ -280,8 +280,8 @@ ProjectRootPath SearchForProject(const SystemString& path)
fclose(fp); fclose(fp);
if (readSize != 4) if (readSize != 4)
continue; continue;
static const HECL::FourCC hecl("HECL"); static const hecl::FourCC hecl("HECL");
if (HECL::FourCC(magic) != hecl) if (hecl::FourCC(magic) != hecl)
continue; continue;
return ProjectRootPath(testPath); return ProjectRootPath(testPath);
} }
@ -305,11 +305,11 @@ ProjectRootPath SearchForProject(const SystemString& path, SystemString& subpath
SystemString testPath(begin, end); SystemString testPath(begin, end);
SystemString testIndexPath = testPath + _S("/.hecl/beacon"); SystemString testIndexPath = testPath + _S("/.hecl/beacon");
Sstat theStat; Sstat theStat;
if (!HECL::Stat(testIndexPath.c_str(), &theStat)) if (!hecl::Stat(testIndexPath.c_str(), &theStat))
{ {
if (S_ISREG(theStat.st_mode)) if (S_ISREG(theStat.st_mode))
{ {
FILE* fp = HECL::Fopen(testIndexPath.c_str(), _S("rb")); FILE* fp = hecl::Fopen(testIndexPath.c_str(), _S("rb"));
if (!fp) if (!fp)
continue; continue;
char magic[4]; char magic[4];
@ -317,7 +317,7 @@ ProjectRootPath SearchForProject(const SystemString& path, SystemString& subpath
fclose(fp); fclose(fp);
if (readSize != 4) if (readSize != 4)
continue; continue;
if (HECL::FourCC(magic) != FOURCC('HECL')) if (hecl::FourCC(magic) != FOURCC('HECL'))
continue; continue;
ProjectRootPath newRootPath = ProjectRootPath(testPath); ProjectRootPath newRootPath = ProjectRootPath(testPath);
SystemString::const_iterator origEnd = testRoot.getAbsolutePath().end(); SystemString::const_iterator origEnd = testRoot.getAbsolutePath().end();

View File

@ -1,4 +1,4 @@
add_library(HECLRuntime add_library(hecl-runtime
FileStoreManager.cpp FileStoreManager.cpp
ShaderCacheManager.cpp ShaderCacheManager.cpp
HMDL.cpp) HMDL.cpp)

View File

@ -1,14 +1,14 @@
#include "HECL/Runtime.hpp" #include "hecl/Runtime.hpp"
#include <LogVisor/LogVisor.hpp> #include "logvisor/logvisor.hpp"
#if _WIN32 #if _WIN32
#include <ShlObj.h> #include <ShlObj.h>
#endif #endif
namespace HECL namespace hecl
{ {
namespace Runtime namespace Runtime
{ {
static LogVisor::LogModule Log("FileStoreManager"); static logvisor::Module Log("FileStoreManager");
FileStoreManager::FileStoreManager(const SystemString& domain) FileStoreManager::FileStoreManager(const SystemString& domain)
: m_domain(domain) : m_domain(domain)
@ -16,28 +16,28 @@ FileStoreManager::FileStoreManager(const SystemString& domain)
#if _WIN32 #if _WIN32
WCHAR home[MAX_PATH]; WCHAR home[MAX_PATH];
if (!SUCCEEDED(SHGetFolderPathW(NULL, CSIDL_PROFILE, NULL, 0, home))) if (!SUCCEEDED(SHGetFolderPathW(NULL, CSIDL_PROFILE, NULL, 0, home)))
Log.report(LogVisor::FatalError, _S("unable to locate profile for file store")); Log.report(logvisor::Fatal, _S("unable to locate profile for file store"));
SystemString path(home); SystemString path(home);
path += _S("/.heclrun"); path += _S("/.heclrun");
HECL::MakeDir(path.c_str()); hecl::MakeDir(path.c_str());
path += _S('/') + domain; path += _S('/') + domain;
HECL::MakeDir(path.c_str()); hecl::MakeDir(path.c_str());
m_storeRoot = path; m_storeRoot = path;
#else #else
const char* home = getenv("HOME"); const char* home = getenv("HOME");
if (!home) if (!home)
Log.report(LogVisor::FatalError, "unable to locate $HOME for file store"); Log.report(logvisor::Fatal, "unable to locate $HOME for file store");
std::string path(home); std::string path(home);
path += "/.heclrun"; path += "/.heclrun";
if (mkdir(path.c_str(), 0755) && errno != EEXIST) if (mkdir(path.c_str(), 0755) && errno != EEXIST)
Log.report(LogVisor::FatalError, "unable to mkdir at %s", path.c_str()); Log.report(logvisor::Fatal, "unable to mkdir at %s", path.c_str());
path += '/' + domain; path += '/' + domain;
if (mkdir(path.c_str(), 0755) && errno != EEXIST) if (mkdir(path.c_str(), 0755) && errno != EEXIST)
Log.report(LogVisor::FatalError, "unable to mkdir at %s", path.c_str()); Log.report(logvisor::Fatal, "unable to mkdir at %s", path.c_str());
m_storeRoot = path; m_storeRoot = path;
#endif #endif
} }

View File

@ -1,23 +1,23 @@
#include "HECL/HMDLMeta.hpp" #include "hecl/HMDLMeta.hpp"
#include "HECL/Runtime.hpp" #include "hecl/Runtime.hpp"
#include <Athena/MemoryReader.hpp> #include <athena/MemoryReader.hpp>
namespace HECL namespace hecl
{ {
namespace Runtime namespace Runtime
{ {
static LogVisor::LogModule Log("HMDL"); static logvisor::Module Log("HMDL");
HMDLData::HMDLData(boo::IGraphicsDataFactory* factory, HMDLData::HMDLData(boo::IGraphicsDataFactory* factory,
const void* metaData, const void* vbo, const void* ibo) const void* metaData, const void* vbo, const void* ibo)
{ {
HMDLMeta meta; HMDLMeta meta;
{ {
Athena::io::MemoryReader r((atUint8*)metaData, HECL_HMDL_META_SZ); athena::io::MemoryReader r((atUint8*)metaData, HECL_HMDL_META_SZ);
meta.read(r); meta.read(r);
} }
if (meta.magic != 'TACO') if (meta.magic != 'TACO')
Log.report(LogVisor::FatalError, "invalid HMDL magic"); Log.report(logvisor::Fatal, "invalid HMDL magic");
m_vbo = factory->newStaticBuffer(boo::BufferUse::Vertex, vbo, meta.vertStride, meta.vertCount); m_vbo = factory->newStaticBuffer(boo::BufferUse::Vertex, vbo, meta.vertStride, meta.vertCount);
m_ibo = factory->newStaticBuffer(boo::BufferUse::Index, ibo, 4, meta.indexCount); m_ibo = factory->newStaticBuffer(boo::BufferUse::Index, ibo, 4, meta.indexCount);

View File

@ -1,14 +1,14 @@
#include "HECL/Runtime.hpp" #include "hecl/Runtime.hpp"
#include <Athena/FileReader.hpp> #include <athena/FileReader.hpp>
#include <Athena/FileWriter.hpp> #include <athena/FileWriter.hpp>
#include <zlib.h> #include <zlib.h>
#include <algorithm> #include <algorithm>
#include <ctime> #include <ctime>
#include "HECL/Backend/GLSL.hpp" #include "hecl/Backend/GLSL.hpp"
#include "HECL/Backend/Metal.hpp" #include "hecl/Backend/Metal.hpp"
namespace HECL namespace hecl
{ {
namespace Runtime namespace Runtime
{ {
@ -23,7 +23,7 @@ IShaderBackendFactory* _NewMetalBackendFactory(boo::IGraphicsDataFactory* gfxFac
IShaderBackendFactory* _NewSPIRVBackendFactory(boo::IGraphicsDataFactory* gfxFactory); IShaderBackendFactory* _NewSPIRVBackendFactory(boo::IGraphicsDataFactory* gfxFactory);
#endif #endif
static LogVisor::LogModule Log("ShaderCacheManager"); static logvisor::Module Log("ShaderCacheManager");
static uint64_t IDX_MAGIC = SBig(uint64_t(0xDEADFEEDC001D00D)); static uint64_t IDX_MAGIC = SBig(uint64_t(0xDEADFEEDC001D00D));
static uint64_t DAT_MAGIC = SBig(uint64_t(0xC001D00DDEADBABE)); static uint64_t DAT_MAGIC = SBig(uint64_t(0xC001D00DDEADBABE));
static uint64_t ZERO64 = 0; static uint64_t ZERO64 = 0;
@ -72,9 +72,9 @@ void ShaderCacheManager::bootstrapIndex()
SystemString idxFilename = m_idxFr.filename(); SystemString idxFilename = m_idxFr.filename();
#endif #endif
FILE* idxFp = HECL::Fopen(idxFilename.c_str(), _S("wb")); FILE* idxFp = hecl::Fopen(idxFilename.c_str(), _S("wb"));
if (!idxFp) if (!idxFp)
Log.report(LogVisor::FatalError, _S("unable to write shader cache index at %s"), Log.report(logvisor::Fatal, _S("unable to write shader cache index at %s"),
idxFilename.c_str()); idxFilename.c_str());
fwrite(&IDX_MAGIC, 1, 8, idxFp); fwrite(&IDX_MAGIC, 1, 8, idxFp);
fwrite(&m_timeHash, 1, 8, idxFp); fwrite(&m_timeHash, 1, 8, idxFp);
@ -87,9 +87,9 @@ void ShaderCacheManager::bootstrapIndex()
SystemString datFilename = m_datFr.filename(); SystemString datFilename = m_datFr.filename();
#endif #endif
FILE* datFp = HECL::Fopen(datFilename.c_str(), _S("wb")); FILE* datFp = hecl::Fopen(datFilename.c_str(), _S("wb"));
if (!datFp) if (!datFp)
Log.report(LogVisor::FatalError, _S("unable to write shader cache data at %s"), Log.report(logvisor::Fatal, _S("unable to write shader cache data at %s"),
datFilename.c_str()); datFilename.c_str());
fwrite(&DAT_MAGIC, 1, 8, datFp); fwrite(&DAT_MAGIC, 1, 8, datFp);
fwrite(&m_timeHash, 1, 8, datFp); fwrite(&m_timeHash, 1, 8, datFp);
@ -109,7 +109,7 @@ ShaderCacheManager::ShaderCacheManager(const FileStoreManager& storeMgr,
{ {
boo::IGraphicsDataFactory::Platform plat = gfxFactory->platform(); boo::IGraphicsDataFactory::Platform plat = gfxFactory->platform();
if (m_extensions && m_extensions.m_plat != plat) if (m_extensions && m_extensions.m_plat != plat)
Log.report(LogVisor::FatalError, "ShaderCacheExtension backend mismatch (should be %s)", Log.report(logvisor::Fatal, "ShaderCacheExtension backend mismatch (should be %s)",
gfxFactory->platformName()); gfxFactory->platformName());
m_extensionsHash = m_extensions.hashExtensions(); m_extensionsHash = m_extensions.hashExtensions();
@ -135,7 +135,7 @@ ShaderCacheManager::ShaderCacheManager(const FileStoreManager& storeMgr,
break; break;
#endif #endif
default: default:
Log.report(LogVisor::FatalError, _S("unsupported backend %s"), gfxFactory->platformName()); Log.report(logvisor::Fatal, _S("unsupported backend %s"), gfxFactory->platformName());
} }
reload(); reload();
@ -148,8 +148,8 @@ void ShaderCacheManager::reload()
m_timeHash = 0; m_timeHash = 0;
/* Attempt to open existing index */ /* Attempt to open existing index */
m_idxFr.seek(0, Athena::Begin); m_idxFr.seek(0, athena::Begin);
m_datFr.seek(0, Athena::Begin); m_datFr.seek(0, athena::Begin);
if (m_idxFr.hasError() || m_datFr.hasError()) if (m_idxFr.hasError() || m_datFr.hasError())
{ {
bootstrapIndex(); bootstrapIndex();
@ -223,12 +223,12 @@ ShaderCachedData ShaderCacheManager::lookupData(const Hash& hash)
const IndexEntry& ent = m_entries[search->second]; const IndexEntry& ent = m_entries[search->second];
if (ent.m_compOffset + ent.m_compSize > m_datFr.length()) if (ent.m_compOffset + ent.m_compSize > m_datFr.length())
{ {
Log.report(LogVisor::Warning, "shader cache not long enough to read entry, might be corrupt"); Log.report(logvisor::Warning, "shader cache not long enough to read entry, might be corrupt");
return ShaderCachedData(); return ShaderCachedData();
} }
/* File-streamed decompression */ /* File-streamed decompression */
m_datFr.seek(ent.m_compOffset, Athena::Begin); m_datFr.seek(ent.m_compOffset, athena::Begin);
ShaderCachedData ret(ShaderTag(ent.m_hash, ent.m_meta), ent.m_decompSize); ShaderCachedData ret(ShaderTag(ent.m_hash, ent.m_meta), ent.m_decompSize);
uint8_t compDat[2048]; uint8_t compDat[2048];
z_stream z = {}; z_stream z = {};
@ -255,18 +255,18 @@ bool ShaderCacheManager::addData(const ShaderCachedData& data)
uLong cBound = compressBound(data.m_sz); uLong cBound = compressBound(data.m_sz);
void* compBuf = malloc(cBound); void* compBuf = malloc(cBound);
if (compress((Bytef*)compBuf, &cBound, (Bytef*)data.m_data.get(), data.m_sz) != Z_OK) if (compress((Bytef*)compBuf, &cBound, (Bytef*)data.m_data.get(), data.m_sz) != Z_OK)
Log.report(LogVisor::FatalError, "unable to deflate data"); Log.report(logvisor::Fatal, "unable to deflate data");
/* Open index for writing (non overwriting) */ /* Open index for writing (non overwriting) */
Athena::io::FileWriter idxFw(m_idxFr.filename(), false); athena::io::FileWriter idxFw(m_idxFr.filename(), false);
if (idxFw.hasError()) if (idxFw.hasError())
Log.report(LogVisor::FatalError, _S("unable to append shader cache index at %s"), Log.report(logvisor::Fatal, _S("unable to append shader cache index at %s"),
m_idxFr.filename().c_str()); m_idxFr.filename().c_str());
/* Open data for writing (non overwriting) */ /* Open data for writing (non overwriting) */
Athena::io::FileWriter datFw(m_datFr.filename(), false); athena::io::FileWriter datFw(m_datFr.filename(), false);
if (datFw.hasError()) if (datFw.hasError())
Log.report(LogVisor::FatalError, _S("unable to append shader cache data at %s"), Log.report(logvisor::Fatal, _S("unable to append shader cache data at %s"),
m_datFr.filename().c_str()); m_datFr.filename().c_str());
size_t targetOffset = 0; size_t targetOffset = 0;
@ -316,10 +316,10 @@ bool ShaderCacheManager::addData(const ShaderCachedData& data)
if (!targetOffset) if (!targetOffset)
{ {
/* New index entry at end */ /* New index entry at end */
idxFw.seek(24, Athena::Begin); idxFw.seek(24, athena::Begin);
idxFw.writeUint64Big(m_entries.size() + 1); idxFw.writeUint64Big(m_entries.size() + 1);
idxFw.seek(m_entries.size() * 32 + 32, Athena::Begin); idxFw.seek(m_entries.size() * 32 + 32, athena::Begin);
datFw.seek(0, Athena::End); datFw.seek(0, athena::End);
m_entryLookup[data.m_tag] = m_entries.size(); m_entryLookup[data.m_tag] = m_entries.size();
m_entries.emplace_back(); m_entries.emplace_back();
@ -336,7 +336,7 @@ bool ShaderCacheManager::addData(const ShaderCachedData& data)
else else
{ {
/* Reusing index entry and data space */ /* Reusing index entry and data space */
datFw.seek(targetOffset, Athena::Begin); datFw.seek(targetOffset, athena::Begin);
datFw.writeUBytes((atUint8*)compBuf, cBound); datFw.writeUBytes((atUint8*)compBuf, cBound);
} }
@ -364,12 +364,12 @@ ShaderCacheManager::buildShader(const ShaderTag& tag, const std::string& source,
ShaderCachedData foundData = lookupData(tag); ShaderCachedData foundData = lookupData(tag);
if (foundData) if (foundData)
return buildFromCache(foundData); return buildFromCache(foundData);
HECL::Frontend::IR ir = FE.compileSource(source, diagName); hecl::Frontend::IR ir = FE.compileSource(source, diagName);
return buildShader(tag, ir, diagName); return buildShader(tag, ir, diagName);
} }
boo::IShaderPipeline* boo::IShaderPipeline*
ShaderCacheManager::buildShader(const ShaderTag& tag, const HECL::Frontend::IR& ir, ShaderCacheManager::buildShader(const ShaderTag& tag, const hecl::Frontend::IR& ir,
const std::string& diagName) const std::string& diagName)
{ {
ShaderCachedData foundData = lookupData(tag); ShaderCachedData foundData = lookupData(tag);
@ -389,7 +389,7 @@ ShaderCacheManager::buildExtendedFromCache(const ShaderCachedData& foundData)
m_factory->buildExtendedShaderFromCache(foundData, m_extensions.m_extensionSlots, m_factory->buildExtendedShaderFromCache(foundData, m_extensions.m_extensionSlots,
[&](boo::IShaderPipeline* shader){shaders.push_back(shader);}); [&](boo::IShaderPipeline* shader){shaders.push_back(shader);});
if (shaders.size() != m_extensions.m_extensionSlots.size()) if (shaders.size() != m_extensions.m_extensionSlots.size())
Log.report(LogVisor::FatalError, "buildShaderFromCache returned %" PRISize " times, expected %" PRISize, Log.report(logvisor::Fatal, "buildShaderFromCache returned %" PRISize " times, expected %" PRISize,
shaders.size(), m_extensions.m_extensionSlots.size()); shaders.size(), m_extensions.m_extensionSlots.size());
return shaders; return shaders;
} }
@ -401,12 +401,12 @@ ShaderCacheManager::buildExtendedShader(const ShaderTag& tag, const std::string&
ShaderCachedData foundData = lookupData(tag); ShaderCachedData foundData = lookupData(tag);
if (foundData) if (foundData)
return buildExtendedFromCache(foundData); return buildExtendedFromCache(foundData);
HECL::Frontend::IR ir = FE.compileSource(source, diagName); hecl::Frontend::IR ir = FE.compileSource(source, diagName);
return buildExtendedShader(tag, ir, diagName); return buildExtendedShader(tag, ir, diagName);
} }
std::vector<boo::IShaderPipeline*> std::vector<boo::IShaderPipeline*>
ShaderCacheManager::buildExtendedShader(const ShaderTag& tag, const HECL::Frontend::IR& ir, ShaderCacheManager::buildExtendedShader(const ShaderTag& tag, const hecl::Frontend::IR& ir,
const std::string& diagName) const std::string& diagName)
{ {
ShaderCachedData foundData = lookupData(tag); ShaderCachedData foundData = lookupData(tag);
@ -419,7 +419,7 @@ ShaderCacheManager::buildExtendedShader(const ShaderTag& tag, const HECL::Fronte
m_factory->buildExtendedShaderFromIR(tag, ir, FE.getDiagnostics(), m_extensions.m_extensionSlots, m_factory->buildExtendedShaderFromIR(tag, ir, FE.getDiagnostics(), m_extensions.m_extensionSlots,
[&](boo::IShaderPipeline* shader){shaders.push_back(shader);}); [&](boo::IShaderPipeline* shader){shaders.push_back(shader);});
if (shaders.size() != m_extensions.m_extensionSlots.size()) if (shaders.size() != m_extensions.m_extensionSlots.size())
Log.report(LogVisor::FatalError, "buildShaderFromIR returned %" PRISize " times, expected %" PRISize, Log.report(logvisor::Fatal, "buildShaderFromIR returned %" PRISize " times, expected %" PRISize,
shaders.size(), m_extensions.m_extensionSlots.size()); shaders.size(), m_extensions.m_extensionSlots.size());
addData(data); addData(data);
return shaders; return shaders;

View File

@ -1,7 +1,7 @@
#include <utf8proc.h> #include <utf8proc.h>
#include "HECL/HECL.hpp" #include "hecl/hecl.hpp"
namespace HECL namespace hecl
{ {
std::string WideToUTF8(const std::wstring& src) std::string WideToUTF8(const std::wstring& src)
@ -14,7 +14,7 @@ std::string WideToUTF8(const std::wstring& 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"); LogModule.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);
@ -33,7 +33,7 @@ std::wstring UTF8ToWide(const std::string& 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"); LogModule.report(logvisor::Warning, "invalid UTF-8 character while decoding");
return retval; return retval;
} }
buf += len; buf += len;

View File

@ -1,4 +1,4 @@
#include "HECL/HECL.hpp" #include "hecl/hecl.hpp"
#ifdef WIN32 #ifdef WIN32
#include <windows.h> #include <windows.h>
@ -16,10 +16,10 @@
#include <mntent.h> #include <mntent.h>
#endif #endif
namespace HECL namespace hecl
{ {
unsigned VerbosityLevel = 0; unsigned VerbosityLevel = 0;
LogVisor::LogModule LogModule("HECL"); logvisor::Module LogModule("hecl");
void SanitizePath(std::string& path) void SanitizePath(std::string& path)
{ {
@ -83,9 +83,9 @@ void SanitizePath(std::wstring& path)
}); });
} }
bool IsPathPNG(const HECL::ProjectPath& path) bool IsPathPNG(const hecl::ProjectPath& path)
{ {
FILE* fp = HECL::Fopen(path.getAbsolutePath().c_str(), _S("rb")); FILE* fp = hecl::Fopen(path.getAbsolutePath().c_str(), _S("rb"));
if (!fp) if (!fp)
return false; return false;
uint32_t buf; uint32_t buf;
@ -95,18 +95,18 @@ bool IsPathPNG(const HECL::ProjectPath& path)
return false; return false;
} }
fclose(fp); fclose(fp);
buf = HECL::SBig(buf); buf = hecl::SBig(buf);
if (buf == 0x89504e47) if (buf == 0x89504e47)
return true; return true;
return false; return false;
} }
bool IsPathBlend(const HECL::ProjectPath& path) bool IsPathBlend(const hecl::ProjectPath& path)
{ {
const SystemChar* lastCompExt = path.getLastComponentExt(); const SystemChar* lastCompExt = path.getLastComponentExt();
if (!lastCompExt || HECL::StrCmp(lastCompExt, _S("blend"))) if (!lastCompExt || hecl::StrCmp(lastCompExt, _S("blend")))
return false; return false;
FILE* fp = HECL::Fopen(path.getAbsolutePath().c_str(), _S("rb")); FILE* fp = hecl::Fopen(path.getAbsolutePath().c_str(), _S("rb"));
if (!fp) if (!fp)
return false; return false;
uint32_t buf; uint32_t buf;
@ -116,32 +116,32 @@ bool IsPathBlend(const HECL::ProjectPath& path)
return false; return false;
} }
fclose(fp); fclose(fp);
buf = HECL::SLittle(buf); buf = hecl::SLittle(buf);
if (buf == 0x4e454c42 || buf == 0x88b1f) if (buf == 0x4e454c42 || buf == 0x88b1f)
return true; return true;
return false; return false;
} }
bool IsPathYAML(const HECL::ProjectPath& path) bool IsPathYAML(const hecl::ProjectPath& path)
{ {
const SystemChar* lastCompExt = path.getLastComponentExt(); const SystemChar* lastCompExt = path.getLastComponentExt();
if (!lastCompExt) if (!lastCompExt)
return false; return false;
if (!HECL::StrCmp(lastCompExt, _S("yaml")) || if (!hecl::StrCmp(lastCompExt, _S("yaml")) ||
!HECL::StrCmp(lastCompExt, _S("yml"))) !hecl::StrCmp(lastCompExt, _S("yml")))
return true; return true;
return false; return false;
} }
HECL::DirectoryEnumerator::DirectoryEnumerator(const HECL::SystemChar* path, Mode mode, hecl::DirectoryEnumerator::DirectoryEnumerator(const hecl::SystemChar* path, Mode mode,
bool sizeSort, bool reverse, bool noHidden) bool sizeSort, bool reverse, bool noHidden)
{ {
HECL::Sstat theStat; hecl::Sstat theStat;
if (HECL::Stat(path, &theStat) || !S_ISDIR(theStat.st_mode)) if (hecl::Stat(path, &theStat) || !S_ISDIR(theStat.st_mode))
return; return;
#if _WIN32 #if _WIN32
HECL::SystemString wc(path); hecl::SystemString wc(path);
wc += _S("/*"); wc += _S("/*");
WIN32_FIND_DATAW d; WIN32_FIND_DATAW d;
HANDLE dir = FindFirstFileW(wc.c_str(), &d); HANDLE dir = FindFirstFileW(wc.c_str(), &d);
@ -156,11 +156,11 @@ HECL::DirectoryEnumerator::DirectoryEnumerator(const HECL::SystemChar* path, Mod
continue; continue;
if (noHidden && (d.cFileName[0] == L'.' || (d.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) != 0)) if (noHidden && (d.cFileName[0] == L'.' || (d.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) != 0))
continue; continue;
HECL::SystemString fp(path); hecl::SystemString fp(path);
fp += _S('/'); fp += _S('/');
fp += d.cFileName; fp += d.cFileName;
HECL::Sstat st; hecl::Sstat st;
if (HECL::Stat(fp.c_str(), &st)) if (hecl::Stat(fp.c_str(), &st))
continue; continue;
size_t sz = 0; size_t sz = 0;
@ -178,18 +178,18 @@ HECL::DirectoryEnumerator::DirectoryEnumerator(const HECL::SystemChar* path, Mod
case Mode::DirsThenFilesSorted: case Mode::DirsThenFilesSorted:
case Mode::DirsSorted: case Mode::DirsSorted:
{ {
std::map<HECL::SystemString, Entry, CaseInsensitiveCompare> sort; std::map<hecl::SystemString, Entry, CaseInsensitiveCompare> sort;
do do
{ {
if (!wcscmp(d.cFileName, _S(".")) || !wcscmp(d.cFileName, _S(".."))) if (!wcscmp(d.cFileName, _S(".")) || !wcscmp(d.cFileName, _S("..")))
continue; continue;
if (noHidden && (d.cFileName[0] == L'.' || (d.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) != 0)) if (noHidden && (d.cFileName[0] == L'.' || (d.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) != 0))
continue; continue;
HECL::SystemString fp(path); hecl::SystemString fp(path);
fp +=_S('/'); fp +=_S('/');
fp += d.cFileName; fp += d.cFileName;
HECL::Sstat st; hecl::Sstat st;
if (HECL::Stat(fp.c_str(), &st) || !S_ISDIR(st.st_mode)) if (hecl::Stat(fp.c_str(), &st) || !S_ISDIR(st.st_mode))
continue; continue;
sort.emplace(std::make_pair(d.cFileName, Entry(std::move(fp), d.cFileName, 0, true))); sort.emplace(std::make_pair(d.cFileName, Entry(std::move(fp), d.cFileName, 0, true)));
} while (FindNextFileW(dir, &d)); } while (FindNextFileW(dir, &d));
@ -220,11 +220,11 @@ HECL::DirectoryEnumerator::DirectoryEnumerator(const HECL::SystemChar* path, Mod
continue; continue;
if (noHidden && (d.cFileName[0] == L'.' || (d.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) != 0)) if (noHidden && (d.cFileName[0] == L'.' || (d.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) != 0))
continue; continue;
HECL::SystemString fp(path); hecl::SystemString fp(path);
fp += _S('/'); fp += _S('/');
fp += d.cFileName; fp += d.cFileName;
HECL::Sstat st; hecl::Sstat st;
if (HECL::Stat(fp.c_str(), &st) || !S_ISREG(st.st_mode)) if (hecl::Stat(fp.c_str(), &st) || !S_ISREG(st.st_mode))
continue; continue;
sort.emplace(std::make_pair(st.st_size, Entry(std::move(fp), d.cFileName, st.st_size, false))); sort.emplace(std::make_pair(st.st_size, Entry(std::move(fp), d.cFileName, st.st_size, false)));
} while (FindNextFileW(dir, &d)); } while (FindNextFileW(dir, &d));
@ -238,18 +238,18 @@ HECL::DirectoryEnumerator::DirectoryEnumerator(const HECL::SystemChar* path, Mod
} }
else else
{ {
std::map<HECL::SystemString, Entry, CaseInsensitiveCompare> sort; std::map<hecl::SystemString, Entry, CaseInsensitiveCompare> sort;
do do
{ {
if (!wcscmp(d.cFileName, _S(".")) || !wcscmp(d.cFileName, _S(".."))) if (!wcscmp(d.cFileName, _S(".")) || !wcscmp(d.cFileName, _S("..")))
continue; continue;
if (noHidden && (d.cFileName[0] == L'.' || (d.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) != 0)) if (noHidden && (d.cFileName[0] == L'.' || (d.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) != 0))
continue; continue;
HECL::SystemString fp(path); hecl::SystemString fp(path);
fp += _S('/'); fp += _S('/');
fp += d.cFileName; fp += d.cFileName;
HECL::Sstat st; hecl::Sstat st;
if (HECL::Stat(fp.c_str(), &st) || !S_ISREG(st.st_mode)) if (hecl::Stat(fp.c_str(), &st) || !S_ISREG(st.st_mode))
continue; continue;
sort.emplace(std::make_pair(d.cFileName, Entry(std::move(fp), d.cFileName, st.st_size, false))); sort.emplace(std::make_pair(d.cFileName, Entry(std::move(fp), d.cFileName, st.st_size, false)));
} while (FindNextFileW(dir, &d)); } while (FindNextFileW(dir, &d));
@ -282,11 +282,11 @@ HECL::DirectoryEnumerator::DirectoryEnumerator(const HECL::SystemChar* path, Mod
continue; continue;
if (noHidden && d->d_name[0] == '.') if (noHidden && d->d_name[0] == '.')
continue; continue;
HECL::SystemString fp(path); hecl::SystemString fp(path);
fp += '/'; fp += '/';
fp += d->d_name; fp += d->d_name;
HECL::Sstat st; hecl::Sstat st;
if (HECL::Stat(fp.c_str(), &st)) if (hecl::Stat(fp.c_str(), &st))
continue; continue;
size_t sz = 0; size_t sz = 0;
@ -304,18 +304,18 @@ HECL::DirectoryEnumerator::DirectoryEnumerator(const HECL::SystemChar* path, Mod
case Mode::DirsThenFilesSorted: case Mode::DirsThenFilesSorted:
case Mode::DirsSorted: case Mode::DirsSorted:
{ {
std::map<HECL::SystemString, Entry, CaseInsensitiveCompare> sort; std::map<hecl::SystemString, Entry, CaseInsensitiveCompare> sort;
while ((d = readdir(dir))) while ((d = readdir(dir)))
{ {
if (!strcmp(d->d_name, ".") || !strcmp(d->d_name, "..")) if (!strcmp(d->d_name, ".") || !strcmp(d->d_name, ".."))
continue; continue;
if (noHidden && d->d_name[0] == '.') if (noHidden && d->d_name[0] == '.')
continue; continue;
HECL::SystemString fp(path); hecl::SystemString fp(path);
fp += '/'; fp += '/';
fp += d->d_name; fp += d->d_name;
HECL::Sstat st; hecl::Sstat st;
if (HECL::Stat(fp.c_str(), &st) || !S_ISDIR(st.st_mode)) if (hecl::Stat(fp.c_str(), &st) || !S_ISDIR(st.st_mode))
continue; continue;
sort.emplace(std::make_pair(d->d_name, Entry(std::move(fp), d->d_name, 0, true))); sort.emplace(std::make_pair(d->d_name, Entry(std::move(fp), d->d_name, 0, true)));
} }
@ -345,11 +345,11 @@ HECL::DirectoryEnumerator::DirectoryEnumerator(const HECL::SystemChar* path, Mod
continue; continue;
if (noHidden && d->d_name[0] == '.') if (noHidden && d->d_name[0] == '.')
continue; continue;
HECL::SystemString fp(path); hecl::SystemString fp(path);
fp += '/'; fp += '/';
fp += d->d_name; fp += d->d_name;
HECL::Sstat st; hecl::Sstat st;
if (HECL::Stat(fp.c_str(), &st) || !S_ISREG(st.st_mode)) if (hecl::Stat(fp.c_str(), &st) || !S_ISREG(st.st_mode))
continue; continue;
sort.emplace(std::make_pair(st.st_size, Entry(std::move(fp), d->d_name, st.st_size, false))); sort.emplace(std::make_pair(st.st_size, Entry(std::move(fp), d->d_name, st.st_size, false)));
} }
@ -363,18 +363,18 @@ HECL::DirectoryEnumerator::DirectoryEnumerator(const HECL::SystemChar* path, Mod
} }
else else
{ {
std::map<HECL::SystemString, Entry, CaseInsensitiveCompare> sort; std::map<hecl::SystemString, Entry, CaseInsensitiveCompare> sort;
while ((d = readdir(dir))) while ((d = readdir(dir)))
{ {
if (!strcmp(d->d_name, ".") || !strcmp(d->d_name, "..")) if (!strcmp(d->d_name, ".") || !strcmp(d->d_name, ".."))
continue; continue;
if (noHidden && d->d_name[0] == '.') if (noHidden && d->d_name[0] == '.')
continue; continue;
HECL::SystemString fp(path); hecl::SystemString fp(path);
fp += '/'; fp += '/';
fp += d->d_name; fp += d->d_name;
HECL::Sstat st; hecl::Sstat st;
if (HECL::Stat(fp.c_str(), &st) || !S_ISREG(st.st_mode)) if (hecl::Stat(fp.c_str(), &st) || !S_ISREG(st.st_mode))
continue; continue;
sort.emplace(std::make_pair(d->d_name, Entry(std::move(fp), d->d_name, st.st_size, false))); sort.emplace(std::make_pair(d->d_name, Entry(std::move(fp), d->d_name, st.st_size, false)));
} }
@ -397,10 +397,10 @@ HECL::DirectoryEnumerator::DirectoryEnumerator(const HECL::SystemChar* path, Mod
#define FILE_MAXDIR 768 #define FILE_MAXDIR 768
static std::pair<HECL::SystemString, std::string> static std::pair<hecl::SystemString, std::string>
NameFromPath(const HECL::SystemString& path) NameFromPath(const hecl::SystemString& path)
{ {
HECL::SystemUTF8View utf8(path); hecl::SystemUTF8View utf8(path);
if (utf8.str().size() == 1 && utf8.str()[0] == '/') if (utf8.str().size() == 1 && utf8.str()[0] == '/')
return {path, "/"}; return {path, "/"};
size_t lastSlash = utf8.str().rfind('/'); size_t lastSlash = utf8.str().rfind('/');
@ -410,9 +410,9 @@ NameFromPath(const HECL::SystemString& path)
return {path, utf8.str()}; return {path, utf8.str()};
} }
std::vector<std::pair<HECL::SystemString, std::string>> GetSystemLocations() std::vector<std::pair<hecl::SystemString, std::string>> GetSystemLocations()
{ {
std::vector<std::pair<HECL::SystemString, std::string>> ret; std::vector<std::pair<hecl::SystemString, std::string>> ret;
#ifdef WIN32 #ifdef WIN32
/* Add the drive names to the listing (as queried by blender) */ /* Add the drive names to the listing (as queried by blender) */
{ {
@ -447,7 +447,7 @@ std::vector<std::pair<HECL::SystemString, std::string>> GetSystemLocations()
wline[2] = L'\0'; wline[2] = L'\0';
if (name) if (name)
ret.emplace_back(wline, HECL::WideToUTF8(name)); ret.emplace_back(wline, hecl::WideToUTF8(name));
else else
ret.push_back(NameFromPath(wline)); ret.push_back(NameFromPath(wline));
} }
@ -467,7 +467,7 @@ std::vector<std::pair<HECL::SystemString, std::string>> GetSystemLocations()
#else #else
#ifdef __APPLE__ #ifdef __APPLE__
{ {
HECL::Sstat theStat; hecl::Sstat theStat;
const char* home = getenv("HOME"); const char* home = getenv("HOME");
if (home) if (home)
@ -475,7 +475,7 @@ std::vector<std::pair<HECL::SystemString, std::string>> GetSystemLocations()
ret.push_back(NameFromPath(home)); ret.push_back(NameFromPath(home));
std::string desktop(home); std::string desktop(home);
desktop += "/Desktop"; desktop += "/Desktop";
if (!HECL::Stat(desktop.c_str(), &theStat)) if (!hecl::Stat(desktop.c_str(), &theStat))
ret.push_back(NameFromPath(desktop)); ret.push_back(NameFromPath(desktop));
} }
@ -504,7 +504,7 @@ std::vector<std::pair<HECL::SystemString, std::string>> GetSystemLocations()
#else #else
/* unix */ /* unix */
{ {
HECL::Sstat theStat; hecl::Sstat theStat;
const char* home = getenv("HOME"); const char* home = getenv("HOME");
if (home) if (home)
@ -512,7 +512,7 @@ std::vector<std::pair<HECL::SystemString, std::string>> GetSystemLocations()
ret.push_back(NameFromPath(home)); ret.push_back(NameFromPath(home));
std::string desktop(home); std::string desktop(home);
desktop += "/Desktop"; desktop += "/Desktop";
if (!HECL::Stat(desktop.c_str(), &theStat)) if (!hecl::Stat(desktop.c_str(), &theStat))
ret.push_back(NameFromPath(desktop)); ret.push_back(NameFromPath(desktop));
} }

View File

@ -2,7 +2,7 @@
#include <stdint.h> #include <stdint.h>
#include <string.h> #include <string.h>
#include <string> #include <string>
#include "HECL/winsupport.hpp" #include "hecl/winsupport.hpp"
/* /*
* The memmem() function finds the start of the first occurrence of the * The memmem() function finds the start of the first occurrence of the

View File

@ -1,4 +1,4 @@
add_executable(heclTest WIN32 main.cpp) add_executable(heclTest WIN32 main.cpp)
target_link_libraries(heclTest target_link_libraries(heclTest
HECLDatabase HECLRuntime HECLBackend HECLFrontend HECLBlender HECLCommon AthenaCore xxhash hecl-database hecl-runtime hecl-backend hecl-frontend hecl-blender hecl-common athena-core xxhash
LogVisor Boo ${ZLIB_LIBRARIES} ${BOO_SYS_LIBS}) logvisor boo ${ZLIB_LIBRARIES} ${BOO_SYS_LIBS})

View File

@ -1,8 +1,8 @@
#include <boo/boo.hpp> #include <boo/boo.hpp>
#include <LogVisor/LogVisor.hpp> #include "logvisor/logvisor.hpp"
#include <Athena/MemoryWriter.hpp> #include <athena/MemoryWriter.hpp>
#include "HECL/Runtime.hpp" #include "hecl/Runtime.hpp"
#include "HECL/HMDLMeta.hpp" #include "hecl/HMDLMeta.hpp"
#include <math.h> #include <math.h>
#include <thread> #include <thread>
@ -78,18 +78,18 @@ struct HECLApplicationCallback : boo::IApplicationCallback
renderTex = gfxF->newRenderTexture(mainWindowRect.size[0], mainWindowRect.size[1], false, false); renderTex = gfxF->newRenderTexture(mainWindowRect.size[0], mainWindowRect.size[1], false, false);
/* HECL managers */ /* HECL managers */
HECL::Runtime::FileStoreManager fileMgr(app->getUniqueName()); hecl::Runtime::FileStoreManager fileMgr(app->getUniqueName());
HECL::Runtime::ShaderCacheManager shaderMgr(fileMgr, gfxF); hecl::Runtime::ShaderCacheManager shaderMgr(fileMgr, gfxF);
/* Compile HECL shader */ /* Compile HECL shader */
static std::string testShader = "HECLOpaque(Texture(0, UV(0)))"; static std::string testShader = "HECLOpaque(Texture(0, UV(0)))";
HECL::Runtime::ShaderTag testShaderTag(testShader, 0, 1, 0, 0, 0, false, false, false); hecl::Runtime::ShaderTag testShaderTag(testShader, 0, 1, 0, 0, 0, false, false, false);
boo::IShaderPipeline* testShaderObj = boo::IShaderPipeline* testShaderObj =
shaderMgr.buildShader(testShaderTag, testShader, "testShader"); shaderMgr.buildShader(testShaderTag, testShader, "testShader");
/* Generate meta structure (usually statically serialized) */ /* Generate meta structure (usually statically serialized) */
HECL::HMDLMeta testMeta; hecl::HMDLMeta testMeta;
testMeta.topology = HECL::HMDLTopology::TriStrips; testMeta.topology = hecl::HMDLTopology::TriStrips;
testMeta.vertStride = 32; testMeta.vertStride = 32;
testMeta.vertCount = 4; testMeta.vertCount = 4;
testMeta.indexCount = 4; testMeta.indexCount = 4;
@ -99,7 +99,7 @@ struct HECLApplicationCallback : boo::IApplicationCallback
/* Binary form of meta structure */ /* Binary form of meta structure */
atUint8 testMetaBuf[HECL_HMDL_META_SZ]; atUint8 testMetaBuf[HECL_HMDL_META_SZ];
Athena::io::MemoryWriter testMetaWriter(testMetaBuf, HECL_HMDL_META_SZ); athena::io::MemoryWriter testMetaWriter(testMetaBuf, HECL_HMDL_META_SZ);
testMeta.write(testMetaWriter); testMeta.write(testMetaWriter);
/* Make Tri-strip VBO */ /* Make Tri-strip VBO */
@ -121,7 +121,7 @@ struct HECLApplicationCallback : boo::IApplicationCallback
static const uint32_t ibo[4] = {0,1,2,3}; static const uint32_t ibo[4] = {0,1,2,3};
/* Construct quad mesh against boo factory */ /* Construct quad mesh against boo factory */
HECL::Runtime::HMDLData testData(gfxF, testMetaBuf, quad, ibo); hecl::Runtime::HMDLData testData(gfxF, testMetaBuf, quad, ibo);
/* Make ramp texture */ /* Make ramp texture */
using Pixel = uint8_t[4]; using Pixel = uint8_t[4];
@ -217,14 +217,14 @@ struct HECLApplicationCallback : boo::IApplicationCallback
} }
}; };
void AthenaExcHandler(Athena::error::Level level, void AthenaExcHandler(athena::error::Level level,
const char* file, const char* function, const char* file, const char* function,
int line, const char* fmt, ...) int line, const char* fmt, ...)
{ {
static LogVisor::LogModule Log("heclTest::AthenaExcHandler"); static logvisor::Module Log("heclTest::AthenaExcHandler");
va_list ap; va_list ap;
va_start(ap, fmt); va_start(ap, fmt);
Log.reportSource(LogVisor::Level(level), file, line, fmt, ap); Log.reportSource(logvisor::Level(level), file, line, fmt, ap);
va_end(ap); va_end(ap);
} }
@ -235,7 +235,7 @@ int main(int argc, const boo::SystemChar** argv)
#endif #endif
{ {
atSetExceptionHandler(AthenaExcHandler); atSetExceptionHandler(AthenaExcHandler);
LogVisor::RegisterConsoleLogger(); logvisor::RegisterConsoleLogger();
HECLApplicationCallback appCb; HECLApplicationCallback appCb;
int ret = boo::ApplicationRun(boo::IApplication::EPlatformType::Auto, int ret = boo::ApplicationRun(boo::IApplication::EPlatformType::Auto,
appCb, _S("heclTest"), _S("HECL Test"), argc, argv); appCb, _S("heclTest"), _S("HECL Test"), argc, argv);
@ -255,7 +255,7 @@ int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE, LPWSTR lpCmdLine, int)
for (int i=0 ; i<argc ; ++i) for (int i=0 ; i<argc ; ++i)
booArgv[i+1] = argv[i]; booArgv[i+1] = argv[i];
LogVisor::CreateWin32Console(); logvisor::CreateWin32Console();
return wmain(argc+1, booArgv); return wmain(argc+1, booArgv);
} }
#endif #endif