mirror of https://github.com/AxioDL/metaforce.git
Resource tracing and memory leak fixes
This commit is contained in:
parent
33d9ce1638
commit
d0d330062f
|
@ -1 +1 @@
|
||||||
Subproject commit 7eb10885ad7b9d135e06511dc9c2aab41e41d08d
|
Subproject commit 578432eb2f61c176ab41c2a3b758816034d07892
|
|
@ -41,6 +41,7 @@ enum class ZTest : uint8_t
|
||||||
LEqual,
|
LEqual,
|
||||||
Greater,
|
Greater,
|
||||||
Equal,
|
Equal,
|
||||||
|
GEqual,
|
||||||
Original = 0xff
|
Original = 0xff
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -21,13 +21,11 @@ class CVarManager final
|
||||||
template <typename T>
|
template <typename T>
|
||||||
CVar* _newCVar(std::string_view name, std::string_view help, const T& value, CVar::EFlags flags)
|
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 (CVar* ret = registerCVar(std::make_unique<CVar>(name, value, help, flags, *this)))
|
||||||
if (registerCVar(ret))
|
|
||||||
{
|
{
|
||||||
deserialize(ret);
|
deserialize(ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
delete ret;
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,7 +51,7 @@ public:
|
||||||
CVar* newCVar(std::string_view name, std::string_view help, int value, CVar::EFlags flags)
|
CVar* newCVar(std::string_view name, std::string_view help, int value, CVar::EFlags flags)
|
||||||
{ return _newCVar<int>(name, help, value, flags); }
|
{ return _newCVar<int>(name, help, value, flags); }
|
||||||
|
|
||||||
bool registerCVar(CVar* cvar);
|
CVar* registerCVar(std::unique_ptr<CVar>&& cvar);
|
||||||
|
|
||||||
CVar* findCVar(std::string_view name);
|
CVar* findCVar(std::string_view name);
|
||||||
template<class... _Args>
|
template<class... _Args>
|
||||||
|
@ -85,7 +83,7 @@ private:
|
||||||
bool suppressDeveloper();
|
bool suppressDeveloper();
|
||||||
void restoreDeveloper(bool oldDeveloper);
|
void restoreDeveloper(bool oldDeveloper);
|
||||||
|
|
||||||
std::unordered_map<std::string, CVar*> m_cvars;
|
std::unordered_map<std::string, std::unique_ptr<CVar>> m_cvars;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,8 +80,8 @@ private:
|
||||||
void increment(UniformBufferPool& pool)
|
void increment(UniformBufferPool& pool)
|
||||||
{
|
{
|
||||||
if (useCount.fetch_add(1) == 0)
|
if (useCount.fetch_add(1) == 0)
|
||||||
buffer = pool.m_factory->newPoolBuffer(boo::BufferUse::Uniform,
|
buffer = pool.m_factory->BooNewPoolBuffer(boo::BufferUse::Uniform,
|
||||||
pool.m_stride, pool.m_countPerBucket);
|
pool.m_stride, pool.m_countPerBucket);
|
||||||
}
|
}
|
||||||
|
|
||||||
void decrement(UniformBufferPool& pool)
|
void decrement(UniformBufferPool& pool)
|
||||||
|
|
|
@ -80,8 +80,8 @@ private:
|
||||||
void increment(VertexBufferPool& pool)
|
void increment(VertexBufferPool& pool)
|
||||||
{
|
{
|
||||||
if (useCount.fetch_add(1) == 0)
|
if (useCount.fetch_add(1) == 0)
|
||||||
buffer = pool.m_factory->newPoolBuffer(boo::BufferUse::Vertex,
|
buffer = pool.m_factory->BooNewPoolBuffer(boo::BufferUse::Vertex,
|
||||||
pool.m_stride, pool.m_countPerBucket);
|
pool.m_stride, pool.m_countPerBucket);
|
||||||
}
|
}
|
||||||
|
|
||||||
void decrement(VertexBufferPool& pool)
|
void decrement(VertexBufferPool& pool)
|
||||||
|
|
|
@ -529,6 +529,9 @@ struct GLSLBackendFactory : IShaderBackendFactory
|
||||||
case hecl::Backend::ZTest::Equal:
|
case hecl::Backend::ZTest::Equal:
|
||||||
zTest = boo::ZTest::Equal;
|
zTest = boo::ZTest::Equal;
|
||||||
break;
|
break;
|
||||||
|
case hecl::Backend::ZTest::GEqual:
|
||||||
|
zTest = boo::ZTest::GEqual;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* ExtTexnames[8];
|
const char* ExtTexnames[8];
|
||||||
|
@ -618,6 +621,9 @@ struct GLSLBackendFactory : IShaderBackendFactory
|
||||||
case hecl::Backend::ZTest::Equal:
|
case hecl::Backend::ZTest::Equal:
|
||||||
zTest = boo::ZTest::Equal;
|
zTest = boo::ZTest::Equal;
|
||||||
break;
|
break;
|
||||||
|
case hecl::Backend::ZTest::GEqual:
|
||||||
|
zTest = boo::ZTest::GEqual;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* ExtTexnames[8];
|
const char* ExtTexnames[8];
|
||||||
|
@ -919,6 +925,9 @@ struct SPIRVBackendFactory : IShaderBackendFactory
|
||||||
case hecl::Backend::ZTest::Equal:
|
case hecl::Backend::ZTest::Equal:
|
||||||
zTest = boo::ZTest::Equal;
|
zTest = boo::ZTest::Equal;
|
||||||
break;
|
break;
|
||||||
|
case hecl::Backend::ZTest::GEqual:
|
||||||
|
zTest = boo::ZTest::GEqual;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
boo::ObjToken<boo::IShaderPipeline> ret =
|
boo::ObjToken<boo::IShaderPipeline> ret =
|
||||||
|
|
|
@ -531,6 +531,9 @@ struct HLSLBackendFactory : IShaderBackendFactory
|
||||||
case hecl::Backend::ZTest::Equal:
|
case hecl::Backend::ZTest::Equal:
|
||||||
zTest = boo::ZTest::Equal;
|
zTest = boo::ZTest::Equal;
|
||||||
break;
|
break;
|
||||||
|
case hecl::Backend::ZTest::GEqual:
|
||||||
|
zTest = boo::ZTest::GEqual;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
boo::ObjToken<boo::IShaderPipeline> ret =
|
boo::ObjToken<boo::IShaderPipeline> ret =
|
||||||
|
@ -652,6 +655,9 @@ struct HLSLBackendFactory : IShaderBackendFactory
|
||||||
case hecl::Backend::ZTest::Equal:
|
case hecl::Backend::ZTest::Equal:
|
||||||
zTest = boo::ZTest::Equal;
|
zTest = boo::ZTest::Equal;
|
||||||
break;
|
break;
|
||||||
|
case hecl::Backend::ZTest::GEqual:
|
||||||
|
zTest = boo::ZTest::GEqual;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
boo::ObjToken<boo::IShaderPipeline> ret =
|
boo::ObjToken<boo::IShaderPipeline> ret =
|
||||||
|
|
|
@ -562,6 +562,9 @@ struct MetalBackendFactory : IShaderBackendFactory
|
||||||
case hecl::Backend::ZTest::Equal:
|
case hecl::Backend::ZTest::Equal:
|
||||||
zTest = boo::ZTest::Equal;
|
zTest = boo::ZTest::Equal;
|
||||||
break;
|
break;
|
||||||
|
case hecl::Backend::ZTest::GEqual:
|
||||||
|
zTest = boo::ZTest::GEqual;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
blobs.emplace_back();
|
blobs.emplace_back();
|
||||||
|
@ -652,6 +655,9 @@ struct MetalBackendFactory : IShaderBackendFactory
|
||||||
case hecl::Backend::ZTest::Equal:
|
case hecl::Backend::ZTest::Equal:
|
||||||
zTest = boo::ZTest::Equal;
|
zTest = boo::ZTest::Equal;
|
||||||
break;
|
break;
|
||||||
|
case hecl::Backend::ZTest::GEqual:
|
||||||
|
zTest = boo::ZTest::GEqual;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto ret =
|
auto ret =
|
||||||
|
|
|
@ -32,15 +32,16 @@ CVarManager::~CVarManager()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CVarManager::registerCVar(CVar* cvar)
|
CVar* CVarManager::registerCVar(std::unique_ptr<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 nullptr;
|
||||||
|
|
||||||
m_cvars[tmp] = cvar;
|
CVar* ret = cvar.get();
|
||||||
return true;
|
m_cvars[tmp] = std::move(cvar);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
CVar* CVarManager::findCVar(std::string_view name)
|
CVar* CVarManager::findCVar(std::string_view name)
|
||||||
|
@ -51,15 +52,15 @@ CVar* CVarManager::findCVar(std::string_view name)
|
||||||
if (search == m_cvars.end())
|
if (search == m_cvars.end())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
return search->second;
|
return search->second.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<CVar*> CVarManager::archivedCVars() const
|
std::vector<CVar*> CVarManager::archivedCVars() const
|
||||||
{
|
{
|
||||||
std::vector<CVar*> ret;
|
std::vector<CVar*> ret;
|
||||||
for (const std::pair<std::string, CVar*>& pair : m_cvars)
|
for (const auto& pair : m_cvars)
|
||||||
if (pair.second->isArchive())
|
if (pair.second->isArchive())
|
||||||
ret.push_back(pair.second);
|
ret.push_back(pair.second.get());
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -67,8 +68,8 @@ std::vector<CVar*> CVarManager::archivedCVars() const
|
||||||
std::vector<CVar*> CVarManager::cvars() const
|
std::vector<CVar*> CVarManager::cvars() const
|
||||||
{
|
{
|
||||||
std::vector<CVar*> ret;
|
std::vector<CVar*> ret;
|
||||||
for (const std::pair<std::string, CVar*>& pair : m_cvars)
|
for (const auto& pair : m_cvars)
|
||||||
ret.push_back(pair.second);
|
ret.push_back(pair.second.get());
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -159,7 +160,7 @@ void CVarManager::serialize()
|
||||||
if (m_useBinary)
|
if (m_useBinary)
|
||||||
{
|
{
|
||||||
CVarContainer container;
|
CVarContainer container;
|
||||||
for (const std::pair<std::string, CVar*>& pair : m_cvars)
|
for (const auto& pair : m_cvars)
|
||||||
if (pair.second->isArchive() || (pair.second->isInternalArchivable() &&
|
if (pair.second->isArchive() || (pair.second->isInternalArchivable() &&
|
||||||
pair.second->wasDeserialized() && !pair.second->hasDefaultValue()))
|
pair.second->wasDeserialized() && !pair.second->hasDefaultValue()))
|
||||||
container.cvars.push_back(*pair.second);
|
container.cvars.push_back(*pair.second);
|
||||||
|
@ -179,7 +180,7 @@ void CVarManager::serialize()
|
||||||
r.close();
|
r.close();
|
||||||
|
|
||||||
docWriter.setStyle(athena::io::YAMLNodeStyle::Block);
|
docWriter.setStyle(athena::io::YAMLNodeStyle::Block);
|
||||||
for (const std::pair<std::string, CVar*>& pair : m_cvars)
|
for (const auto& pair : m_cvars)
|
||||||
if (pair.second->isArchive() || (pair.second->isInternalArchivable() &&
|
if (pair.second->isArchive() || (pair.second->isInternalArchivable() &&
|
||||||
pair.second->wasDeserialized() && !pair.second->hasDefaultValue()))
|
pair.second->wasDeserialized() && !pair.second->hasDefaultValue()))
|
||||||
docWriter.writeString(pair.second->name().data(), pair.second->toLiteral());
|
docWriter.writeString(pair.second->name().data(), pair.second->toLiteral());
|
||||||
|
@ -220,7 +221,7 @@ void CVarManager::setCVar(Console* con, const std::vector<std::string> &args)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CVar* cv = m_cvars[cvName];
|
const auto& cv = m_cvars[cvName];
|
||||||
std::string value = args[1];
|
std::string value = args[1];
|
||||||
auto it = args.begin() + 2;
|
auto it = args.begin() + 2;
|
||||||
for (; it != args.end(); ++it)
|
for (; it != args.end(); ++it)
|
||||||
|
@ -246,7 +247,7 @@ void CVarManager::getCVar(Console* con, const std::vector<std::string> &args)
|
||||||
return;
|
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());
|
con->report(Console::Level::Info, "'%s' = '%s'", cv->name().data(), cv->value().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -399,7 +399,7 @@ ShaderCacheManager::buildShader(const ShaderTag& tag, std::string_view source,
|
||||||
ShaderCachedData foundData = lookupData(tag);
|
ShaderCachedData foundData = lookupData(tag);
|
||||||
if (foundData)
|
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());
|
SCM_Log.report(logvisor::Info, "building cached shader '%s' %016llX", diagName.data(), tag.val64());
|
||||||
boo::ObjToken<boo::IShaderPipeline> build = buildFromCache(foundData, ctx);
|
boo::ObjToken<boo::IShaderPipeline> 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());
|
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);
|
hecl::Frontend::IR ir = FE.compileSource(source, diagName);
|
||||||
SCM_Log.report(logvisor::Info, "building shader '%s' %016llX", diagName.data(), tag.val64());
|
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);
|
ShaderCachedData foundData = lookupData(tag);
|
||||||
if (foundData)
|
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());
|
SCM_Log.report(logvisor::Info, "building cached shader '%s' %016llX", diagName.data(), tag.val64());
|
||||||
boo::ObjToken<boo::IShaderPipeline> build = buildFromCache(foundData, ctx);
|
boo::ObjToken<boo::IShaderPipeline> 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());
|
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());
|
SCM_Log.report(logvisor::Info, "building shader '%s' %016llX", diagName.data(), tag.val64());
|
||||||
FE.getDiagnostics().reset(diagName);
|
FE.getDiagnostics().reset(diagName);
|
||||||
|
@ -507,7 +507,7 @@ ShaderCacheManager::buildExtendedShader(const ShaderTag& tag, std::string_view s
|
||||||
ShaderCachedData foundData = lookupData(tag);
|
ShaderCachedData foundData = lookupData(tag);
|
||||||
if (foundData)
|
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());
|
SCM_Log.report(logvisor::Info, "building cached shader '%s' %016llX", diagName.data(), tag.val64());
|
||||||
ret->m_pipelines = buildExtendedFromCache(foundData, ctx);
|
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);
|
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());
|
ret->m_pipelines.reserve(m_extensions.m_extensionSlots.size());
|
||||||
FE.getDiagnostics().reset(diagName);
|
FE.getDiagnostics().reset(diagName);
|
||||||
|
@ -555,7 +555,7 @@ ShaderCacheManager::buildExtendedShader(const ShaderTag& tag, const hecl::Fronte
|
||||||
ShaderCachedData foundData = lookupData(tag);
|
ShaderCachedData foundData = lookupData(tag);
|
||||||
if (foundData)
|
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());
|
SCM_Log.report(logvisor::Info, "building cached shader '%s' %016llX", diagName.data(), tag.val64());
|
||||||
ret->m_pipelines = buildExtendedFromCache(foundData, ctx);
|
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());
|
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());
|
ret->m_pipelines.reserve(m_extensions.m_extensionSlots.size());
|
||||||
FE.getDiagnostics().reset(diagName);
|
FE.getDiagnostics().reset(diagName);
|
||||||
|
|
Loading…
Reference in New Issue