2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-08 15:04:56 +00:00

Changes to support new boo object tracker API

This commit is contained in:
Jack Andersen
2017-11-04 20:15:03 -10:00
parent f9a431d62c
commit d2fda8a373
10 changed files with 168 additions and 124 deletions

View File

@@ -23,12 +23,14 @@ HMDLData::HMDLData(boo::IGraphicsDataFactory::Context& ctx,
m_ibo = ctx.newStaticBuffer(boo::BufferUse::Index, ibo, 4, meta.indexCount);
if (ctx.bindingNeedsVertexFormat())
m_vtxFmt = NewVertexFormat(ctx, meta, m_vbo, m_ibo);
m_vtxFmt = NewVertexFormat(ctx, meta, m_vbo.get(), m_ibo.get());
}
/* For binding constructors that require vertex format up front (GLSL) */
boo::IVertexFormat* HMDLData::NewVertexFormat(boo::IGraphicsDataFactory::Context& ctx, const HMDLMeta& meta,
boo::IGraphicsBuffer* vbo, boo::IGraphicsBuffer* ibo)
boo::ObjToken<boo::IVertexFormat>
HMDLData::NewVertexFormat(boo::IGraphicsDataFactory::Context& ctx, const HMDLMeta& meta,
const boo::ObjToken<boo::IGraphicsBuffer>& vbo,
const boo::ObjToken<boo::IGraphicsBuffer>& ibo)
{
size_t elemCount = 2 + meta.colorCount + meta.uvCount + meta.weightCount;
std::unique_ptr<boo::VertexElementDescriptor[]> vdescs(new boo::VertexElementDescriptor[elemCount]);
@@ -64,7 +66,7 @@ boo::IVertexFormat* HMDLData::NewVertexFormat(boo::IGraphicsDataFactory::Context
}
/* For shader constructors that require vertex format up-front (HLSL/Metal/Vulkan) */
boo::IVertexFormat* ShaderTag::newVertexFormat(boo::IGraphicsDataFactory::Context& ctx) const
boo::ObjToken<boo::IVertexFormat> ShaderTag::newVertexFormat(boo::IGraphicsDataFactory::Context& ctx) const
{
size_t elemCount = 2 + m_colorCount + m_uvCount + m_weightCount;
std::unique_ptr<boo::VertexElementDescriptor[]> vdescs(new boo::VertexElementDescriptor[elemCount]);

View File

@@ -370,7 +370,7 @@ bool ShaderCacheManager::addData(const ShaderCachedData& data)
return true;
}
boo::IShaderPipeline*
boo::ObjToken<boo::IShaderPipeline>
ShaderCacheManager::buildFromCache(const ShaderCachedData& foundData,
boo::IGraphicsDataFactory::Context& ctx)
{
@@ -390,10 +390,10 @@ ShaderCacheManager::buildShader(const ShaderTag& tag, const std::string& source,
ShaderCachedData foundData = lookupData(tag);
if (foundData)
{
ret->m_token = factory.commitTransaction([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
factory.commitTransaction([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
{
Log.report(logvisor::Info, "building cached shader '%s' %016llX", diagName.c_str(), tag.val64());
boo::IShaderPipeline* build = buildFromCache(foundData, ctx);
boo::ObjToken<boo::IShaderPipeline> build = buildFromCache(foundData, ctx);
if (build)
{
ret->m_pipelines.push_back(build);
@@ -402,7 +402,7 @@ ShaderCacheManager::buildShader(const ShaderTag& tag, const std::string& source,
return false;
});
if (ret->m_token)
if (ret->m_pipelines.size())
{
m_pipelineLookup[tag] = ret;
return ret;
@@ -410,12 +410,12 @@ ShaderCacheManager::buildShader(const ShaderTag& tag, const std::string& source,
Log.report(logvisor::Warning, "invalid cache read, rebuilding shader '%s'", diagName.c_str());
}
ret->m_token = factory.commitTransaction([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
factory.commitTransaction([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
{
hecl::Frontend::IR ir = FE.compileSource(source, diagName);
Log.report(logvisor::Info, "building shader '%s' %016llX", diagName.c_str(), tag.val64());
FE.getDiagnostics().reset(diagName);
boo::IShaderPipeline* build;
boo::ObjToken<boo::IShaderPipeline> build;
addData(m_factory->buildShaderFromIR(tag, ir, FE.getDiagnostics(), ctx, build));
ret->m_pipelines.push_back(build);
return true;
@@ -437,10 +437,10 @@ ShaderCacheManager::buildShader(const ShaderTag& tag, const hecl::Frontend::IR&
ShaderCachedData foundData = lookupData(tag);
if (foundData)
{
ret->m_token = factory.commitTransaction([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
factory.commitTransaction([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
{
Log.report(logvisor::Info, "building cached shader '%s' %016llX", diagName.c_str(), tag.val64());
boo::IShaderPipeline* build = buildFromCache(foundData, ctx);
boo::ObjToken<boo::IShaderPipeline> build = buildFromCache(foundData, ctx);
if (build)
{
ret->m_pipelines.push_back(build);
@@ -449,7 +449,7 @@ ShaderCacheManager::buildShader(const ShaderTag& tag, const hecl::Frontend::IR&
return false;
});
if (ret->m_token)
if (ret->m_pipelines.size())
{
m_pipelineLookup[tag] = ret;
return ret;
@@ -457,11 +457,11 @@ ShaderCacheManager::buildShader(const ShaderTag& tag, const hecl::Frontend::IR&
Log.report(logvisor::Warning, "invalid cache read, rebuilding shader '%s'", diagName.c_str());
}
ret->m_token = factory.commitTransaction([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
factory.commitTransaction([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
{
Log.report(logvisor::Info, "building shader '%s' %016llX", diagName.c_str(), tag.val64());
FE.getDiagnostics().reset(diagName);
boo::IShaderPipeline* build;
boo::ObjToken<boo::IShaderPipeline> build;
addData(m_factory->buildShaderFromIR(tag, ir, FE.getDiagnostics(), ctx, build));
ret->m_pipelines.push_back(build);
return true;
@@ -470,14 +470,14 @@ ShaderCacheManager::buildShader(const ShaderTag& tag, const hecl::Frontend::IR&
return ret;
}
std::vector<boo::IShaderPipeline*>
std::vector<boo::ObjToken<boo::IShaderPipeline>>
ShaderCacheManager::buildExtendedFromCache(const ShaderCachedData& foundData,
boo::IGraphicsDataFactory::Context& ctx)
{
std::vector<boo::IShaderPipeline*> shaders;
std::vector<boo::ObjToken<boo::IShaderPipeline>> shaders;
shaders.reserve(m_extensions.m_extensionSlots.size());
if (!m_factory->buildExtendedShaderFromCache(foundData, m_extensions.m_extensionSlots, ctx,
[&](boo::IShaderPipeline* shader){shaders.push_back(shader);}))
[&](const boo::ObjToken<boo::IShaderPipeline>& shader){shaders.push_back(shader);}))
return {};
if (shaders.size() != m_extensions.m_extensionSlots.size())
Log.report(logvisor::Fatal, "buildShaderFromCache returned %" PRISize " times, expected %" PRISize,
@@ -498,16 +498,14 @@ ShaderCacheManager::buildExtendedShader(const ShaderTag& tag, const std::string&
ShaderCachedData foundData = lookupData(tag);
if (foundData)
{
ret->m_token = factory.commitTransaction([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
factory.commitTransaction([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
{
Log.report(logvisor::Info, "building cached shader '%s' %016llX", diagName.c_str(), tag.val64());
ret->m_pipelines = buildExtendedFromCache(foundData, ctx);
if (ret->m_pipelines.size())
return true;
return false;
return ret->m_pipelines.size() != 0;
});
if (ret->m_token)
if (ret->m_pipelines.size())
{
m_pipelineLookup[tag] = ret;
return ret;
@@ -517,14 +515,14 @@ ShaderCacheManager::buildExtendedShader(const ShaderTag& tag, const std::string&
hecl::Frontend::IR ir = FE.compileSource(source, diagName);
ret->m_token = factory.commitTransaction([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
factory.commitTransaction([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
{
ret->m_pipelines.reserve(m_extensions.m_extensionSlots.size());
FE.getDiagnostics().reset(diagName);
Log.report(logvisor::Info, "building shader '%s' %016llX", diagName.c_str(), tag.val64());
ShaderCachedData data =
m_factory->buildExtendedShaderFromIR(tag, ir, FE.getDiagnostics(), m_extensions.m_extensionSlots, ctx,
[&](boo::IShaderPipeline* shader){ret->m_pipelines.push_back(shader);});
[&](const boo::ObjToken<boo::IShaderPipeline>& shader){ret->m_pipelines.push_back(shader);});
if (ret->m_pipelines.size() != m_extensions.m_extensionSlots.size())
Log.report(logvisor::Fatal, "buildShaderFromIR returned %" PRISize " times, expected %" PRISize,
ret->m_pipelines.size(), m_extensions.m_extensionSlots.size());
@@ -548,16 +546,14 @@ ShaderCacheManager::buildExtendedShader(const ShaderTag& tag, const hecl::Fronte
ShaderCachedData foundData = lookupData(tag);
if (foundData)
{
ret->m_token = factory.commitTransaction([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
factory.commitTransaction([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
{
Log.report(logvisor::Info, "building cached shader '%s' %016llX", diagName.c_str(), tag.val64());
ret->m_pipelines = buildExtendedFromCache(foundData, ctx);
if (ret->m_pipelines.size())
return true;
return false;
return ret->m_pipelines.size() != 0;
});
if (ret->m_token)
if (ret->m_pipelines.size() != 0)
{
m_pipelineLookup[tag] = ret;
return ret;
@@ -565,14 +561,14 @@ ShaderCacheManager::buildExtendedShader(const ShaderTag& tag, const hecl::Fronte
Log.report(logvisor::Warning, "invalid cache read, rebuilding shader '%s'", diagName.c_str());
}
ret->m_token = factory.commitTransaction([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
factory.commitTransaction([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
{
ret->m_pipelines.reserve(m_extensions.m_extensionSlots.size());
FE.getDiagnostics().reset(diagName);
Log.report(logvisor::Info, "building shader '%s' %016llX", diagName.c_str(), tag.val64());
ShaderCachedData data =
m_factory->buildExtendedShaderFromIR(tag, ir, FE.getDiagnostics(), m_extensions.m_extensionSlots, ctx,
[&](boo::IShaderPipeline* shader){ret->m_pipelines.push_back(shader);});
[&](const boo::ObjToken<boo::IShaderPipeline>& shader){ret->m_pipelines.push_back(shader);});
if (ret->m_pipelines.size() != m_extensions.m_extensionSlots.size())
Log.report(logvisor::Fatal, "buildShaderFromIR returned %" PRISize " times, expected %" PRISize,
ret->m_pipelines.size(), m_extensions.m_extensionSlots.size());