This commit is contained in:
Jack Andersen 2015-11-14 13:41:06 -10:00
commit a37a300be0
12 changed files with 63 additions and 45 deletions

3
hecl/.gitmodules vendored
View File

@ -4,9 +4,6 @@
[submodule "extern/libSquish"] [submodule "extern/libSquish"]
path = extern/libSquish path = extern/libSquish
url = https://github.com/jackoalan/libSquish.git url = https://github.com/jackoalan/libSquish.git
[submodule "extern/LogVisor"]
path = extern/LogVisor
url = https://github.com/AxioDL/LogVisor.git
[submodule "extern/libBoo"] [submodule "extern/libBoo"]
path = extern/libBoo path = extern/libBoo
url = https://github.com/AxioDL/libBoo.git url = https://github.com/AxioDL/libBoo.git

View File

@ -15,18 +15,17 @@ 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)
list(APPEND HECL_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR}/blender) set(HECL_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR}/blender CACHE PATH "HECL include path" FORCE)
set(HECL_INCLUDE_DIR ${HECL_INCLUDE_DIR} PARENT_SCOPE)
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(LOG_VISOR_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/extern/LogVisor/include)
set(LOG_VISOR_INCLUDE_DIR ${LOG_VISOR_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/libBoo/include)
add_subdirectory(bintoc) add_subdirectory(bintoc)
add_subdirectory(extern) add_subdirectory(extern)
include_directories(include ${LOG_VISOR_INCLUDE_DIR} ${ATHENA_INCLUDE_DIR} ${BOO_INCLUDE_DIR}) include_directories(include ${LOG_VISOR_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)

View File

@ -78,7 +78,7 @@ HMDLBuffers BlenderConnection::DataStream::Mesh::getHMDLBuffers() const
vboW.writeVec3fLittle(pos[v.iPos]); vboW.writeVec3fLittle(pos[v.iPos]);
vboW.writeVec3fLittle(norm[v.iNorm]); vboW.writeVec3fLittle(norm[v.iNorm]);
for (int i=0 ; i<colorLayerCount ; ++i) for (size_t i=0 ; i<colorLayerCount ; ++i)
{ {
const Vector3f& c = color[v.iColor[i]]; const Vector3f& c = color[v.iColor[i]];
vboW.writeUByte(std::max(0, std::min(255, int(c.val.vec[0] * 255)))); vboW.writeUByte(std::max(0, std::min(255, int(c.val.vec[0] * 255))));
@ -87,7 +87,7 @@ HMDLBuffers BlenderConnection::DataStream::Mesh::getHMDLBuffers() const
vboW.writeUByte(255); vboW.writeUByte(255);
} }
for (int i=0 ; i<uvLayerCount ; ++i) for (size_t i=0 ; i<uvLayerCount ; ++i)
vboW.writeVec2fLittle(uv[v.iUv[i]]); vboW.writeVec2fLittle(uv[v.iUv[i]]);
if (weightVecCount) if (weightVecCount)
@ -95,10 +95,10 @@ HMDLBuffers BlenderConnection::DataStream::Mesh::getHMDLBuffers() const
const SkinBanks::Bank& bank = skinBanks.banks[s.skinBankIdx]; const SkinBanks::Bank& bank = skinBanks.banks[s.skinBankIdx];
const std::vector<SkinBind>& binds = skins[v.iSkin]; const std::vector<SkinBind>& binds = skins[v.iSkin];
auto it = bank.m_boneIdxs.cbegin(); auto it = bank.m_boneIdxs.cbegin();
for (int i=0 ; i<weightVecCount ; ++i) for (size_t i=0 ; i<weightVecCount ; ++i)
{ {
atVec4f vec = {}; atVec4f vec = {};
for (int j=0 ; j<4 ; ++j) for (size_t j=0 ; j<4 ; ++j)
{ {
if (it == bank.m_boneIdxs.cend()) if (it == bank.m_boneIdxs.cend())
break; break;

View File

@ -1,13 +1,5 @@
#disable libBoo for FreeBSD for the time being
if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
add_subdirectory(libBoo) add_subdirectory(libBoo)
set(BOO_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/libBoo/include)
endif()
add_subdirectory(libSquish) add_subdirectory(libSquish)
add_subdirectory(xxhash) add_subdirectory(xxhash)
if (NOT TARGET LogVisor)
add_subdirectory(LogVisor)
endif()
add_subdirectory(Athena) add_subdirectory(Athena)
add_subdirectory(libpng) add_subdirectory(libpng)

@ -1 +0,0 @@
Subproject commit 189e047977b138b711259ad84d94471f5d006ffb

2
hecl/extern/libBoo vendored

@ -1 +1 @@
Subproject commit 83475b4b092af4941924385083cff9c2ecb1f567 Subproject commit ddcbc102bab8cda86c0d93a859f6e2c1d8db0bd7

View File

@ -86,7 +86,7 @@ class ShaderCacheManager
}; };
std::vector<IndexEntry> m_entries; std::vector<IndexEntry> m_entries;
std::unordered_map<Hash, size_t> m_entryLookup; std::unordered_map<Hash, size_t> m_entryLookup;
uint64_t m_loadedRand = 0; uint64_t m_timeHash = 0;
void BootstrapIndex(); void BootstrapIndex();
public: public:
ShaderCacheManager(const FileStoreManager& storeMgr) ShaderCacheManager(const FileStoreManager& storeMgr)

View File

@ -114,7 +114,7 @@ std::string GLSL::makeVert(const char* glslVer, unsigned col, unsigned uv, unsig
/* skinned */ /* skinned */
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 (int i=0 ; i<skinSlots ; ++i) for (size_t i=0 ; i<skinSlots ; ++i)
retval += HECL::Format(" posAccum += (vu.mv[%u] * vec4(posIn, 1.0)) * weightIn[%u][%u]\n" retval += HECL::Format(" posAccum += (vu.mv[%u] * vec4(posIn, 1.0)) * weightIn[%u][%u]\n"
" normAccum += (vu.mvInv[%u] * vec4(normIn, 1.0)) * weightIn[%u][%u]\n", " normAccum += (vu.mvInv[%u] * vec4(normIn, 1.0)) * weightIn[%u][%u]\n",
i, i/4, i%4, i, i/4, i%4); i, i/4, i%4, i, i/4, i%4);

View File

@ -1,5 +1,8 @@
#include "HECL/Runtime.hpp" #include "HECL/Runtime.hpp"
#include <LogVisor/LogVisor.hpp> #include <LogVisor/LogVisor.hpp>
#if _WIN32
#include <ShlObj.h>
#endif
namespace HECL namespace HECL
{ {
@ -11,6 +14,19 @@ FileStoreManager::FileStoreManager(const SystemString& domain)
: m_domain(domain) : m_domain(domain)
{ {
#if _WIN32 #if _WIN32
WCHAR home[MAX_PATH];
if (!SUCCEEDED(SHGetFolderPathW(NULL, CSIDL_PROFILE, NULL, 0, home)))
Log.report(LogVisor::FatalError, _S("unable to locate profile for file store"));
SystemString path(home);
path += _S("/.heclrun");
HECL::MakeDir(path.c_str());
path += _S('/') + domain;
HECL::MakeDir(path.c_str());
m_storeRoot = path;
#elif __APPLE__ #elif __APPLE__
#else #else
const char* home = getenv("HOME"); const char* home = getenv("HOME");

View File

@ -3,50 +3,64 @@
#include <Athena/FileWriter.hpp> #include <Athena/FileWriter.hpp>
#include <zlib.h> #include <zlib.h>
#include <algorithm> #include <algorithm>
#include <ctime>
namespace HECL namespace HECL
{ {
namespace Runtime namespace Runtime
{ {
static LogVisor::LogModule Log("ShaderCacheManager"); static LogVisor::LogModule Log("ShaderCacheManager");
static uint64_t IDX_MAGIC = SBIG(0xDEADFEEDC001D00D); static uint64_t IDX_MAGIC = SBig(0xDEADFEEDC001D00D);
static uint64_t DAT_MAGIC = SBIG(0xC001D00DDEADBABE); static uint64_t DAT_MAGIC = SBig(0xC001D00DDEADBABE);
static uint64_t ZERO64 = 0; static uint64_t ZERO64 = 0;
static uint64_t Random64() static uint64_t timeHash()
{ {
uint64_t ret; char buf[80];
#if _WIN32 time_t now;
#else struct tm* timeinfo;
FILE* fp = fopen("/dev/urandom", "rb");
fread(&ret, 1, 8, fp); time(&now);
fclose(fp); timeinfo = localtime(&now);
#endif strftime(buf, 80, "%Y-%m-%dT%H:%M:%S+%H:%M", timeinfo);
return ret; Hash tmp(buf, 80);
return tmp.val64();
} }
void ShaderCacheManager::BootstrapIndex() void ShaderCacheManager::BootstrapIndex()
{ {
m_loadedRand = Random64(); m_timeHash = timeHash();
m_idxFr.close(); m_idxFr.close();
m_datFr.close(); m_datFr.close();
FILE* idxFp = HECL::Fopen(m_idxFr.filename().c_str(), _S("wb")); #if _WIN32
SystemString idxFilename = m_idxFr.wfilename();
#else
SystemString idxFilename = m_idxFr.filename();
#endif
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::FatalError, _S("unable to write shader cache index at %s"),
m_idxFr.filename().c_str()); idxFilename.c_str());
fwrite(&IDX_MAGIC, 1, 8, idxFp); fwrite(&IDX_MAGIC, 1, 8, idxFp);
fwrite(&m_loadedRand, 1, 8, idxFp); fwrite(&m_timeHash, 1, 8, idxFp);
fwrite(&ZERO64, 1, 8, idxFp); fwrite(&ZERO64, 1, 8, idxFp);
fwrite(&ZERO64, 1, 8, idxFp); fwrite(&ZERO64, 1, 8, idxFp);
fclose(idxFp); fclose(idxFp);
FILE* datFp = HECL::Fopen(m_datFr.filename().c_str(), _S("wb")); #if _WIN32
SystemString datFilename = m_datFr.wfilename();
#else
SystemString datFilename = m_datFr.filename();
#endif
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::FatalError, _S("unable to write shader cache data at %s"),
m_datFr.filename().c_str()); idxFilename.c_str());
fwrite(&DAT_MAGIC, 1, 8, datFp); fwrite(&DAT_MAGIC, 1, 8, datFp);
fwrite(&m_loadedRand, 1, 8, datFp); fwrite(&m_timeHash, 1, 8, datFp);
fclose(datFp); fclose(datFp);
m_idxFr.open(); m_idxFr.open();
@ -57,7 +71,7 @@ void ShaderCacheManager::reload()
{ {
m_entries.clear(); m_entries.clear();
m_entryLookup.clear(); m_entryLookup.clear();
m_loadedRand = 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);
@ -93,7 +107,7 @@ void ShaderCacheManager::reload()
BootstrapIndex(); BootstrapIndex();
return; return;
} }
m_loadedRand = idxRand; m_timeHash = idxRand;
} }
/* Read existing entries */ /* Read existing entries */

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 HECLDatabase HECLRuntime HECLBackend HECLFrontend HECLBlender HECLCommon AthenaCore xxhash
LogVisor Boo ${ZLIB_LIBRARIES} ${BOO_SYS_LIBS}) LogVisor Boo ${ZLIB_LIBRARIES} ${BOO_SYS_LIBS})

View File

@ -31,6 +31,7 @@ struct HECLApplicationCallback : boo::IApplicationCallback
m_mainWindow = app->newWindow(_S("HECL Test")); m_mainWindow = app->newWindow(_S("HECL Test"));
m_mainWindow->setCallback(&m_windowCb); m_mainWindow->setCallback(&m_windowCb);
m_mainWindow->showWindow();
boo::IGraphicsCommandQueue* gfxQ = m_mainWindow->getCommandQueue(); boo::IGraphicsCommandQueue* gfxQ = m_mainWindow->getCommandQueue();
boo::IGraphicsDataFactory* gfxF = m_mainWindow->getLoadContextDataFactory(); boo::IGraphicsDataFactory* gfxF = m_mainWindow->getLoadContextDataFactory();
boo::SWindowRect mainWindowRect = m_mainWindow->getWindowFrame(); boo::SWindowRect mainWindowRect = m_mainWindow->getWindowFrame();