diff --git a/hecl/extern/boo b/hecl/extern/boo index 7eb10885a..578432eb2 160000 --- a/hecl/extern/boo +++ b/hecl/extern/boo @@ -1 +1 @@ -Subproject commit 7eb10885ad7b9d135e06511dc9c2aab41e41d08d +Subproject commit 578432eb2f61c176ab41c2a3b758816034d07892 diff --git a/hecl/include/hecl/Backend/Backend.hpp b/hecl/include/hecl/Backend/Backend.hpp index fb02820d4..e3d8e8fbd 100644 --- a/hecl/include/hecl/Backend/Backend.hpp +++ b/hecl/include/hecl/Backend/Backend.hpp @@ -41,6 +41,7 @@ enum class ZTest : uint8_t LEqual, Greater, Equal, + GEqual, Original = 0xff }; diff --git a/hecl/include/hecl/CVarManager.hpp b/hecl/include/hecl/CVarManager.hpp index ff92bfdd1..fcb804e0d 100755 --- a/hecl/include/hecl/CVarManager.hpp +++ b/hecl/include/hecl/CVarManager.hpp @@ -21,13 +21,11 @@ class CVarManager final template CVar* _newCVar(std::string_view name, std::string_view help, const T& value, CVar::EFlags flags) { - CVar* ret(new CVar(name, value, help, flags, *this)); - if (registerCVar(ret)) + if (CVar* ret = registerCVar(std::make_unique(name, value, help, flags, *this))) { deserialize(ret); return ret; } - delete ret; return nullptr; } @@ -53,7 +51,7 @@ public: CVar* newCVar(std::string_view name, std::string_view help, int value, CVar::EFlags flags) { return _newCVar(name, help, value, flags); } - bool registerCVar(CVar* cvar); + CVar* registerCVar(std::unique_ptr&& cvar); CVar* findCVar(std::string_view name); template @@ -85,7 +83,7 @@ private: bool suppressDeveloper(); void restoreDeveloper(bool oldDeveloper); - std::unordered_map m_cvars; + std::unordered_map> m_cvars; }; } diff --git a/hecl/include/hecl/UniformBufferPool.hpp b/hecl/include/hecl/UniformBufferPool.hpp index 50560a304..42e9cb7cf 100644 --- a/hecl/include/hecl/UniformBufferPool.hpp +++ b/hecl/include/hecl/UniformBufferPool.hpp @@ -80,8 +80,8 @@ private: void increment(UniformBufferPool& pool) { if (useCount.fetch_add(1) == 0) - buffer = pool.m_factory->newPoolBuffer(boo::BufferUse::Uniform, - pool.m_stride, pool.m_countPerBucket); + buffer = pool.m_factory->BooNewPoolBuffer(boo::BufferUse::Uniform, + pool.m_stride, pool.m_countPerBucket); } void decrement(UniformBufferPool& pool) diff --git a/hecl/include/hecl/VertexBufferPool.hpp b/hecl/include/hecl/VertexBufferPool.hpp index d18bffd41..917463909 100644 --- a/hecl/include/hecl/VertexBufferPool.hpp +++ b/hecl/include/hecl/VertexBufferPool.hpp @@ -80,8 +80,8 @@ private: void increment(VertexBufferPool& pool) { if (useCount.fetch_add(1) == 0) - buffer = pool.m_factory->newPoolBuffer(boo::BufferUse::Vertex, - pool.m_stride, pool.m_countPerBucket); + buffer = pool.m_factory->BooNewPoolBuffer(boo::BufferUse::Vertex, + pool.m_stride, pool.m_countPerBucket); } void decrement(VertexBufferPool& pool) diff --git a/hecl/lib/Backend/GLSL.cpp b/hecl/lib/Backend/GLSL.cpp index e5944f633..e43bbe964 100644 --- a/hecl/lib/Backend/GLSL.cpp +++ b/hecl/lib/Backend/GLSL.cpp @@ -529,6 +529,9 @@ struct GLSLBackendFactory : IShaderBackendFactory case hecl::Backend::ZTest::Equal: zTest = boo::ZTest::Equal; break; + case hecl::Backend::ZTest::GEqual: + zTest = boo::ZTest::GEqual; + break; } const char* ExtTexnames[8]; @@ -618,6 +621,9 @@ struct GLSLBackendFactory : IShaderBackendFactory case hecl::Backend::ZTest::Equal: zTest = boo::ZTest::Equal; break; + case hecl::Backend::ZTest::GEqual: + zTest = boo::ZTest::GEqual; + break; } const char* ExtTexnames[8]; @@ -919,6 +925,9 @@ struct SPIRVBackendFactory : IShaderBackendFactory case hecl::Backend::ZTest::Equal: zTest = boo::ZTest::Equal; break; + case hecl::Backend::ZTest::GEqual: + zTest = boo::ZTest::GEqual; + break; } boo::ObjToken ret = diff --git a/hecl/lib/Backend/HLSL.cpp b/hecl/lib/Backend/HLSL.cpp index 49d4c4b8a..e2f302e2d 100644 --- a/hecl/lib/Backend/HLSL.cpp +++ b/hecl/lib/Backend/HLSL.cpp @@ -531,6 +531,9 @@ struct HLSLBackendFactory : IShaderBackendFactory case hecl::Backend::ZTest::Equal: zTest = boo::ZTest::Equal; break; + case hecl::Backend::ZTest::GEqual: + zTest = boo::ZTest::GEqual; + break; } boo::ObjToken ret = @@ -652,6 +655,9 @@ struct HLSLBackendFactory : IShaderBackendFactory case hecl::Backend::ZTest::Equal: zTest = boo::ZTest::Equal; break; + case hecl::Backend::ZTest::GEqual: + zTest = boo::ZTest::GEqual; + break; } boo::ObjToken ret = diff --git a/hecl/lib/Backend/Metal.cpp b/hecl/lib/Backend/Metal.cpp index 7595fbe22..03bf40aa2 100644 --- a/hecl/lib/Backend/Metal.cpp +++ b/hecl/lib/Backend/Metal.cpp @@ -562,6 +562,9 @@ struct MetalBackendFactory : IShaderBackendFactory case hecl::Backend::ZTest::Equal: zTest = boo::ZTest::Equal; break; + case hecl::Backend::ZTest::GEqual: + zTest = boo::ZTest::GEqual; + break; } blobs.emplace_back(); @@ -652,6 +655,9 @@ struct MetalBackendFactory : IShaderBackendFactory case hecl::Backend::ZTest::Equal: zTest = boo::ZTest::Equal; break; + case hecl::Backend::ZTest::GEqual: + zTest = boo::ZTest::GEqual; + break; } auto ret = diff --git a/hecl/lib/CVarManager.cpp b/hecl/lib/CVarManager.cpp index 5ac9d5f0a..e60710a0e 100755 --- a/hecl/lib/CVarManager.cpp +++ b/hecl/lib/CVarManager.cpp @@ -32,15 +32,16 @@ CVarManager::~CVarManager() { } -bool CVarManager::registerCVar(CVar* cvar) +CVar* CVarManager::registerCVar(std::unique_ptr&& cvar) { std::string tmp(cvar->name()); athena::utility::tolower(tmp); if (m_cvars.find(tmp) != m_cvars.end()) - return false; + return nullptr; - m_cvars[tmp] = cvar; - return true; + CVar* ret = cvar.get(); + m_cvars[tmp] = std::move(cvar); + return ret; } CVar* CVarManager::findCVar(std::string_view name) @@ -51,15 +52,15 @@ CVar* CVarManager::findCVar(std::string_view name) if (search == m_cvars.end()) return nullptr; - return search->second; + return search->second.get(); } std::vector CVarManager::archivedCVars() const { std::vector ret; - for (const std::pair& pair : m_cvars) + for (const auto& pair : m_cvars) if (pair.second->isArchive()) - ret.push_back(pair.second); + ret.push_back(pair.second.get()); return ret; } @@ -67,8 +68,8 @@ std::vector CVarManager::archivedCVars() const std::vector CVarManager::cvars() const { std::vector ret; - for (const std::pair& pair : m_cvars) - ret.push_back(pair.second); + for (const auto& pair : m_cvars) + ret.push_back(pair.second.get()); return ret; } @@ -159,7 +160,7 @@ void CVarManager::serialize() if (m_useBinary) { CVarContainer container; - for (const std::pair& pair : m_cvars) + for (const auto& pair : m_cvars) if (pair.second->isArchive() || (pair.second->isInternalArchivable() && pair.second->wasDeserialized() && !pair.second->hasDefaultValue())) container.cvars.push_back(*pair.second); @@ -179,7 +180,7 @@ void CVarManager::serialize() r.close(); docWriter.setStyle(athena::io::YAMLNodeStyle::Block); - for (const std::pair& pair : m_cvars) + for (const auto& pair : m_cvars) if (pair.second->isArchive() || (pair.second->isInternalArchivable() && pair.second->wasDeserialized() && !pair.second->hasDefaultValue())) docWriter.writeString(pair.second->name().data(), pair.second->toLiteral()); @@ -220,7 +221,7 @@ void CVarManager::setCVar(Console* con, const std::vector &args) return; } - CVar* cv = m_cvars[cvName]; + const auto& cv = m_cvars[cvName]; std::string value = args[1]; auto it = args.begin() + 2; for (; it != args.end(); ++it) @@ -246,7 +247,7 @@ void CVarManager::getCVar(Console* con, const std::vector &args) return; } - const CVar* cv = m_cvars[cvName]; + const auto& cv = m_cvars[cvName]; con->report(Console::Level::Info, "'%s' = '%s'", cv->name().data(), cv->value().c_str()); } diff --git a/hecl/lib/Runtime/ShaderCacheManager.cpp b/hecl/lib/Runtime/ShaderCacheManager.cpp index f170fe481..7b895126b 100644 --- a/hecl/lib/Runtime/ShaderCacheManager.cpp +++ b/hecl/lib/Runtime/ShaderCacheManager.cpp @@ -399,7 +399,7 @@ ShaderCacheManager::buildShader(const ShaderTag& tag, std::string_view source, ShaderCachedData foundData = lookupData(tag); if (foundData) { - factory.commitTransaction([&](boo::IGraphicsDataFactory::Context& ctx) -> bool + factory.BooCommitTransaction([&](boo::IGraphicsDataFactory::Context& ctx) { SCM_Log.report(logvisor::Info, "building cached shader '%s' %016llX", diagName.data(), tag.val64()); boo::ObjToken build = buildFromCache(foundData, ctx); @@ -419,7 +419,7 @@ ShaderCacheManager::buildShader(const ShaderTag& tag, std::string_view source, SCM_Log.report(logvisor::Warning, "invalid cache read, rebuilding shader '%s'", diagName.data()); } - factory.commitTransaction([&](boo::IGraphicsDataFactory::Context& ctx) -> bool + factory.BooCommitTransaction([&](boo::IGraphicsDataFactory::Context& ctx) { hecl::Frontend::IR ir = FE.compileSource(source, diagName); SCM_Log.report(logvisor::Info, "building shader '%s' %016llX", diagName.data(), tag.val64()); @@ -446,7 +446,7 @@ ShaderCacheManager::buildShader(const ShaderTag& tag, const hecl::Frontend::IR& ShaderCachedData foundData = lookupData(tag); if (foundData) { - factory.commitTransaction([&](boo::IGraphicsDataFactory::Context& ctx) -> bool + factory.BooCommitTransaction([&](boo::IGraphicsDataFactory::Context& ctx) { SCM_Log.report(logvisor::Info, "building cached shader '%s' %016llX", diagName.data(), tag.val64()); boo::ObjToken build = buildFromCache(foundData, ctx); @@ -466,7 +466,7 @@ ShaderCacheManager::buildShader(const ShaderTag& tag, const hecl::Frontend::IR& SCM_Log.report(logvisor::Warning, "invalid cache read, rebuilding shader '%s'", diagName.data()); } - factory.commitTransaction([&](boo::IGraphicsDataFactory::Context& ctx) -> bool + factory.BooCommitTransaction([&](boo::IGraphicsDataFactory::Context& ctx) { SCM_Log.report(logvisor::Info, "building shader '%s' %016llX", diagName.data(), tag.val64()); FE.getDiagnostics().reset(diagName); @@ -507,7 +507,7 @@ ShaderCacheManager::buildExtendedShader(const ShaderTag& tag, std::string_view s ShaderCachedData foundData = lookupData(tag); if (foundData) { - factory.commitTransaction([&](boo::IGraphicsDataFactory::Context& ctx) -> bool + factory.BooCommitTransaction([&](boo::IGraphicsDataFactory::Context& ctx) { SCM_Log.report(logvisor::Info, "building cached shader '%s' %016llX", diagName.data(), tag.val64()); ret->m_pipelines = buildExtendedFromCache(foundData, ctx); @@ -524,7 +524,7 @@ ShaderCacheManager::buildExtendedShader(const ShaderTag& tag, std::string_view s hecl::Frontend::IR ir = FE.compileSource(source, diagName); - factory.commitTransaction([&](boo::IGraphicsDataFactory::Context& ctx) -> bool + factory.BooCommitTransaction([&](boo::IGraphicsDataFactory::Context& ctx) { ret->m_pipelines.reserve(m_extensions.m_extensionSlots.size()); FE.getDiagnostics().reset(diagName); @@ -555,7 +555,7 @@ ShaderCacheManager::buildExtendedShader(const ShaderTag& tag, const hecl::Fronte ShaderCachedData foundData = lookupData(tag); if (foundData) { - factory.commitTransaction([&](boo::IGraphicsDataFactory::Context& ctx) -> bool + factory.BooCommitTransaction([&](boo::IGraphicsDataFactory::Context& ctx) { SCM_Log.report(logvisor::Info, "building cached shader '%s' %016llX", diagName.data(), tag.val64()); ret->m_pipelines = buildExtendedFromCache(foundData, ctx); @@ -570,7 +570,7 @@ ShaderCacheManager::buildExtendedShader(const ShaderTag& tag, const hecl::Fronte SCM_Log.report(logvisor::Warning, "invalid cache read, rebuilding shader '%s'", diagName.data()); } - factory.commitTransaction([&](boo::IGraphicsDataFactory::Context& ctx) -> bool + factory.BooCommitTransaction([&](boo::IGraphicsDataFactory::Context& ctx) { ret->m_pipelines.reserve(m_extensions.m_extensionSlots.size()); FE.getDiagnostics().reset(diagName);