From e0cff83a4183c817e6886466bd719da1bb3cae48 Mon Sep 17 00:00:00 2001 From: Phillip Date: Fri, 13 Nov 2015 22:39:27 -0800 Subject: [PATCH 1/5] Squash MSVC warnings --- hecl/CMakeLists.txt | 2 +- hecl/blender/HMDL.cpp | 8 ++--- hecl/extern/Athena | 2 +- hecl/extern/LogVisor | 2 +- hecl/extern/libBoo | 2 +- hecl/include/HECL/Runtime.hpp | 2 +- hecl/lib/Backend/GLSL.cpp | 2 +- hecl/lib/Runtime/ShaderCacheManager.cpp | 44 +++++++++++++++---------- hecl/test/CMakeLists.txt | 2 +- 9 files changed, 37 insertions(+), 29 deletions(-) diff --git a/hecl/CMakeLists.txt b/hecl/CMakeLists.txt index ef0f91039..ebba17c3c 100644 --- a/hecl/CMakeLists.txt +++ b/hecl/CMakeLists.txt @@ -22,7 +22,7 @@ set(SQUISH_INCLUDE_DIR ${SQUISH_INCLUDE_DIR} PARENT_SCOPE) set(BOO_INCLUDE_DIR extern/libBoo/include) add_subdirectory(bintoc) 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(blender) add_subdirectory(driver) diff --git a/hecl/blender/HMDL.cpp b/hecl/blender/HMDL.cpp index df991fb24..635c4f8db 100644 --- a/hecl/blender/HMDL.cpp +++ b/hecl/blender/HMDL.cpp @@ -78,7 +78,7 @@ HMDLBuffers BlenderConnection::DataStream::Mesh::getHMDLBuffers() const vboW.writeVec3fLittle(pos[v.iPos]); vboW.writeVec3fLittle(norm[v.iNorm]); - for (int i=0 ; i& binds = skins[v.iSkin]; auto it = bank.m_boneIdxs.cbegin(); - for (int i=0 ; i m_entries; std::unordered_map m_entryLookup; - uint64_t m_loadedRand = 0; + uint64_t m_timeHash = 0; void BootstrapIndex(); public: ShaderCacheManager(const FileStoreManager& storeMgr) diff --git a/hecl/lib/Backend/GLSL.cpp b/hecl/lib/Backend/GLSL.cpp index 65c6c046e..c2b577d7c 100644 --- a/hecl/lib/Backend/GLSL.cpp +++ b/hecl/lib/Backend/GLSL.cpp @@ -114,7 +114,7 @@ std::string GLSL::makeVert(const char* glslVer, unsigned col, unsigned uv, unsig /* skinned */ 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"; - for (int i=0 ; i #include #include +#include namespace HECL { @@ -13,40 +14,47 @@ static uint64_t IDX_MAGIC = SBIG(0xDEADFEEDC001D00D); static uint64_t DAT_MAGIC = SBIG(0xC001D00DDEADBABE); static uint64_t ZERO64 = 0; -static uint64_t Random64() +static uint64_t timeHash() { - uint64_t ret; -#if _WIN32 -#else - FILE* fp = fopen("/dev/urandom", "rb"); - fread(&ret, 1, 8, fp); - fclose(fp); -#endif - return ret; + char buf[80]; + time_t now; + struct tm* timeinfo; + + time(&now); + timeinfo = localtime(&now); + strftime(buf, 80, "%Y-%m-%dT%H:%M:%S+%H:%M", timeinfo); + Hash tmp(buf, 80); + return tmp.val64(); } void ShaderCacheManager::BootstrapIndex() { - m_loadedRand = Random64(); + m_timeHash = timeHash(); m_idxFr.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) 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(&m_loadedRand, 1, 8, idxFp); + fwrite(&m_timeHash, 1, 8, idxFp); fwrite(&ZERO64, 1, 8, idxFp); fwrite(&ZERO64, 1, 8, idxFp); fclose(idxFp); - FILE* datFp = HECL::Fopen(m_datFr.filename().c_str(), _S("wb")); + FILE* datFp = HECL::Fopen(idxFilename.c_str(), _S("wb")); if (!datFp) 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(&m_loadedRand, 1, 8, datFp); + fwrite(&m_timeHash, 1, 8, datFp); fclose(datFp); m_idxFr.open(); @@ -57,7 +65,7 @@ void ShaderCacheManager::reload() { m_entries.clear(); m_entryLookup.clear(); - m_loadedRand = 0; + m_timeHash = 0; /* Attempt to open existing index */ m_idxFr.seek(0, Athena::Begin); @@ -93,7 +101,7 @@ void ShaderCacheManager::reload() BootstrapIndex(); return; } - m_loadedRand = idxRand; + m_timeHash = idxRand; } /* Read existing entries */ diff --git a/hecl/test/CMakeLists.txt b/hecl/test/CMakeLists.txt index f16842515..f5ed21693 100644 --- a/hecl/test/CMakeLists.txt +++ b/hecl/test/CMakeLists.txt @@ -1,4 +1,4 @@ add_executable(heclTest WIN32 main.cpp) 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}) From 7606bf840fc0a555f3756695fd8548df01623306 Mon Sep 17 00:00:00 2001 From: Phillip Date: Fri, 13 Nov 2015 22:49:09 -0800 Subject: [PATCH 2/5] Remove LogVisor (it's in extern/libBoo anyway) --- hecl/.gitmodules | 3 --- hecl/extern/CMakeLists.txt | 3 --- hecl/extern/LogVisor | 1 - 3 files changed, 7 deletions(-) delete mode 160000 hecl/extern/LogVisor diff --git a/hecl/.gitmodules b/hecl/.gitmodules index 96015cd59..77be7628f 100644 --- a/hecl/.gitmodules +++ b/hecl/.gitmodules @@ -4,9 +4,6 @@ [submodule "extern/libSquish"] path = extern/libSquish url = https://github.com/jackoalan/libSquish.git -[submodule "extern/LogVisor"] - path = extern/LogVisor - url = https://github.com/AxioDL/LogVisor.git [submodule "extern/libBoo"] path = extern/libBoo url = https://github.com/AxioDL/libBoo.git diff --git a/hecl/extern/CMakeLists.txt b/hecl/extern/CMakeLists.txt index ff35928c8..b72ae7750 100644 --- a/hecl/extern/CMakeLists.txt +++ b/hecl/extern/CMakeLists.txt @@ -6,8 +6,5 @@ endif() add_subdirectory(libSquish) add_subdirectory(xxhash) -if (NOT TARGET LogVisor) -add_subdirectory(LogVisor) -endif() add_subdirectory(Athena) add_subdirectory(libpng) diff --git a/hecl/extern/LogVisor b/hecl/extern/LogVisor deleted file mode 160000 index 4c2442df2..000000000 --- a/hecl/extern/LogVisor +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 4c2442df2d800fc25339d3d301d7d3691da7bafb From 363090fddb0261dd03f03b4d8e5c52f1040de025 Mon Sep 17 00:00:00 2001 From: Phillip Date: Fri, 13 Nov 2015 23:37:20 -0800 Subject: [PATCH 3/5] Cache paths --- hecl/CMakeLists.txt | 6 +++--- hecl/extern/CMakeLists.txt | 5 ----- hecl/extern/libBoo | 2 +- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/hecl/CMakeLists.txt b/hecl/CMakeLists.txt index ebba17c3c..471752112 100644 --- a/hecl/CMakeLists.txt +++ b/hecl/CMakeLists.txt @@ -12,14 +12,14 @@ endif() 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 ${HECL_INCLUDE_DIR} PARENT_SCOPE) +set(HECL_INCLUDE_DIR ${HECL_INCLUDE_DIR} CACHE PATH "HECL include path" FORCE) set(ATHENA_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/extern/Athena/include) 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 ${SQUISH_INCLUDE_DIR} PARENT_SCOPE) + set(BOO_INCLUDE_DIR extern/libBoo/include) + add_subdirectory(bintoc) add_subdirectory(extern) include_directories(include ${LOG_VISOR_INCLUDE_DIR} ${ATHENA_INCLUDE_DIR} ${BOO_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR}) diff --git a/hecl/extern/CMakeLists.txt b/hecl/extern/CMakeLists.txt index b72ae7750..884466e44 100644 --- a/hecl/extern/CMakeLists.txt +++ b/hecl/extern/CMakeLists.txt @@ -1,9 +1,4 @@ -#disable libBoo for FreeBSD for the time being -if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") add_subdirectory(libBoo) -set(BOO_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/libBoo/include) -endif() - add_subdirectory(libSquish) add_subdirectory(xxhash) add_subdirectory(Athena) diff --git a/hecl/extern/libBoo b/hecl/extern/libBoo index fe061b8d0..ddcbc102b 160000 --- a/hecl/extern/libBoo +++ b/hecl/extern/libBoo @@ -1 +1 @@ -Subproject commit fe061b8d0a393e4a68d084503872b551e08ac91c +Subproject commit ddcbc102bab8cda86c0d93a859f6e2c1d8db0bd7 From 214841966b44bcdca033aef02c282cfb75eeb8c4 Mon Sep 17 00:00:00 2001 From: Phillip Date: Fri, 13 Nov 2015 23:47:19 -0800 Subject: [PATCH 4/5] Fix path duplication in CMakeCache.txt --- hecl/CMakeLists.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/hecl/CMakeLists.txt b/hecl/CMakeLists.txt index 471752112..8e7f0eb15 100644 --- a/hecl/CMakeLists.txt +++ b/hecl/CMakeLists.txt @@ -11,8 +11,7 @@ endif() 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 ${HECL_INCLUDE_DIR} CACHE PATH "HECL include path" FORCE) +set(HECL_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR}/blender CACHE PATH "HECL include path" FORCE) set(ATHENA_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/extern/Athena/include) set(ATHENA_INCLUDE_DIR ${ATHENA_INCLUDE_DIR} PARENT_SCOPE) set(SQUISH_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/extern/libSquish) From 013046ad65c362a17169c5d5e27d78794e7d9b7b Mon Sep 17 00:00:00 2001 From: Phillip Date: Sat, 14 Nov 2015 00:48:31 -0800 Subject: [PATCH 5/5] Fix magics (needs proper fix) Implement windows profile directory retrieval --- hecl/extern/Athena | 2 +- hecl/lib/Runtime/FileStoreManager.cpp | 16 ++++++++++++++++ hecl/lib/Runtime/ShaderCacheManager.cpp | 12 +++++++++--- hecl/test/main.cpp | 1 + 4 files changed, 27 insertions(+), 4 deletions(-) diff --git a/hecl/extern/Athena b/hecl/extern/Athena index ab86e2195..64f34cc90 160000 --- a/hecl/extern/Athena +++ b/hecl/extern/Athena @@ -1 +1 @@ -Subproject commit ab86e2195fceab0fcfddfe2795922609c87ff714 +Subproject commit 64f34cc9030145dc8ddeadc80d90f42ed3162675 diff --git a/hecl/lib/Runtime/FileStoreManager.cpp b/hecl/lib/Runtime/FileStoreManager.cpp index 6b6ccc41e..a897ee835 100644 --- a/hecl/lib/Runtime/FileStoreManager.cpp +++ b/hecl/lib/Runtime/FileStoreManager.cpp @@ -1,5 +1,8 @@ #include "HECL/Runtime.hpp" #include +#if _WIN32 +#include +#endif namespace HECL { @@ -11,6 +14,19 @@ FileStoreManager::FileStoreManager(const SystemString& domain) : m_domain(domain) { #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__ #else const char* home = getenv("HOME"); diff --git a/hecl/lib/Runtime/ShaderCacheManager.cpp b/hecl/lib/Runtime/ShaderCacheManager.cpp index 0aa0e65bf..b32b5c0f8 100644 --- a/hecl/lib/Runtime/ShaderCacheManager.cpp +++ b/hecl/lib/Runtime/ShaderCacheManager.cpp @@ -10,8 +10,8 @@ namespace HECL namespace Runtime { static LogVisor::LogModule Log("ShaderCacheManager"); -static uint64_t IDX_MAGIC = SBIG(0xDEADFEEDC001D00D); -static uint64_t DAT_MAGIC = SBIG(0xC001D00DDEADBABE); +static uint64_t IDX_MAGIC = SBig(0xDEADFEEDC001D00D); +static uint64_t DAT_MAGIC = SBig(0xC001D00DDEADBABE); static uint64_t ZERO64 = 0; static uint64_t timeHash() @@ -49,7 +49,13 @@ void ShaderCacheManager::BootstrapIndex() fwrite(&ZERO64, 1, 8, idxFp); fclose(idxFp); - FILE* datFp = HECL::Fopen(idxFilename.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) Log.report(LogVisor::FatalError, _S("unable to write shader cache data at %s"), idxFilename.c_str()); diff --git a/hecl/test/main.cpp b/hecl/test/main.cpp index 342c538a8..da2964612 100644 --- a/hecl/test/main.cpp +++ b/hecl/test/main.cpp @@ -31,6 +31,7 @@ struct HECLApplicationCallback : boo::IApplicationCallback m_mainWindow = app->newWindow(_S("HECL Test")); m_mainWindow->setCallback(&m_windowCb); + m_mainWindow->showWindow(); boo::IGraphicsCommandQueue* gfxQ = m_mainWindow->getCommandQueue(); boo::IGraphicsDataFactory* gfxF = m_mainWindow->getLoadContextDataFactory(); boo::SWindowRect mainWindowRect = m_mainWindow->getWindowFrame();