boo lambda-factory API refactor

This commit is contained in:
Jack Andersen 2016-03-30 09:15:08 -10:00
parent 5ed9af92a2
commit 72fc1e5754
6 changed files with 197 additions and 170 deletions

2
hecl/extern/boo vendored

@ -1 +1 @@
Subproject commit 6cbd086204bbe0bce4ad21c179c3e4cf8ea717b8
Subproject commit bf6b4e37e81b72532afe2b4a56201b3bea7d4c63

View File

@ -83,7 +83,7 @@ public:
uint64_t getMetaData() const {return m_meta;}
/* For shader constructors that require vertex format up-front (HLSL) */
boo::IVertexFormat* newVertexFormat(boo::IGraphicsDataFactory* factory) const;
boo::IVertexFormat* newVertexFormat(boo::IGraphicsDataFactory::Context& ctx) const;
};
/**
@ -159,15 +159,19 @@ protected:
virtual ShaderCachedData buildShaderFromIR(const ShaderTag& tag,
const hecl::Frontend::IR& ir,
hecl::Frontend::Diagnostics& diag,
boo::IGraphicsDataFactory::Context& ctx,
boo::IShaderPipeline*& objOut)=0;
virtual boo::IShaderPipeline* buildShaderFromCache(const ShaderCachedData& data)=0;
virtual boo::IShaderPipeline* buildShaderFromCache(const ShaderCachedData& data,
boo::IGraphicsDataFactory::Context& ctx)=0;
virtual ShaderCachedData buildExtendedShaderFromIR(const ShaderTag& tag,
const hecl::Frontend::IR& ir,
hecl::Frontend::Diagnostics& diag,
const std::vector<ShaderCacheExtensions::ExtensionSlot>& extensionSlots,
boo::IGraphicsDataFactory::Context& ctx,
FReturnExtensionShader returnFunc)=0;
virtual void buildExtendedShaderFromCache(const ShaderCachedData& data,
const std::vector<ShaderCacheExtensions::ExtensionSlot>& extensionSlots,
boo::IGraphicsDataFactory::Context& ctx,
FReturnExtensionShader returnFunc)=0;
public:
virtual ~IShaderBackendFactory() {}
@ -200,8 +204,10 @@ class ShaderCacheManager
void bootstrapIndex();
ShaderCachedData lookupData(const Hash& hash);
bool addData(const ShaderCachedData& data);
boo::IShaderPipeline* buildFromCache(const ShaderCachedData& foundData);
std::vector<boo::IShaderPipeline*> buildExtendedFromCache(const ShaderCachedData& foundData);
boo::IShaderPipeline* buildFromCache(const ShaderCachedData& foundData,
boo::IGraphicsDataFactory::Context& ctx);
std::vector<boo::IShaderPipeline*> buildExtendedFromCache(const ShaderCachedData& foundData,
boo::IGraphicsDataFactory::Context& ctx);
public:
ShaderCacheManager(const FileStoreManager& storeMgr,
boo::IGraphicsDataFactory* gfxFactory,
@ -216,13 +222,17 @@ public:
void setRenderTargetSamples(unsigned samps) {m_factory->m_rtHint = samps;}
boo::IShaderPipeline* buildShader(const ShaderTag& tag, const std::string& source,
const std::string& diagName);
const std::string& diagName,
boo::IGraphicsDataFactory::Context& ctx);
boo::IShaderPipeline* buildShader(const ShaderTag& tag, const hecl::Frontend::IR& ir,
const std::string& diagName);
const std::string& diagName,
boo::IGraphicsDataFactory::Context& ctx);
std::vector<boo::IShaderPipeline*> buildExtendedShader(const ShaderTag& tag, const std::string& source,
const std::string& diagName);
const std::string& diagName,
boo::IGraphicsDataFactory::Context& ctx);
std::vector<boo::IShaderPipeline*> buildExtendedShader(const ShaderTag& tag, const hecl::Frontend::IR& ir,
const std::string& diagName);
const std::string& diagName,
boo::IGraphicsDataFactory::Context& ctx);
};
/**
@ -234,19 +244,19 @@ struct HMDLData
boo::IGraphicsBufferS* m_ibo;
boo::IVertexFormat* m_vtxFmt = nullptr;
HMDLData(boo::IGraphicsDataFactory* factory,
HMDLData(boo::IGraphicsDataFactory::Context& ctx,
const void* metaData, const void* vbo, const void* ibo);
/* For binding constructors that require vertex format up front (GLSL) */
static boo::IVertexFormat* NewVertexFormat(boo::IGraphicsDataFactory* factory, const HMDLMeta& meta,
static boo::IVertexFormat* NewVertexFormat(boo::IGraphicsDataFactory::Context& ctx, const HMDLMeta& meta,
boo::IGraphicsBuffer* vbo=nullptr, boo::IGraphicsBuffer* ibo=nullptr);
boo::IShaderDataBinding* newShaderDataBindng(boo::IGraphicsDataFactory* factory,
boo::IShaderDataBinding* newShaderDataBindng(boo::IGraphicsDataFactory::Context& ctx,
boo::IShaderPipeline* shader,
size_t ubufCount, boo::IGraphicsBuffer** ubufs,
size_t texCount, boo::ITexture** texs)
{return factory->newShaderDataBinding(shader, m_vtxFmt, m_vbo, nullptr, m_ibo,
ubufCount, ubufs, texCount, texs);}
{return ctx.newShaderDataBinding(shader, m_vtxFmt, m_vbo, nullptr, m_ibo,
ubufCount, ubufs, nullptr, nullptr, texCount, texs);}
};
}

View File

@ -251,14 +251,11 @@ static const char* STD_BLOCKNAMES[] = {"HECLVertUniform"};
struct GLSLBackendFactory : IShaderBackendFactory
{
Backend::GLSL m_backend;
boo::GLDataFactory* m_gfxFactory;
GLSLBackendFactory(boo::IGraphicsDataFactory* gfxFactory)
: m_gfxFactory(dynamic_cast<boo::GLDataFactory*>(gfxFactory)) {}
ShaderCachedData buildShaderFromIR(const ShaderTag& tag,
const hecl::Frontend::IR& ir,
hecl::Frontend::Diagnostics& diag,
boo::IGraphicsDataFactory::Context& ctx,
boo::IShaderPipeline*& objOut)
{
m_backend.reset(ir, diag);
@ -273,7 +270,8 @@ struct GLSLBackendFactory : IShaderBackendFactory
std::string fragSource = m_backend.makeFrag("#version 330");
cachedSz += fragSource.size() + 1;
objOut =
m_gfxFactory->newShaderPipeline(vertSource.c_str(), fragSource.c_str(),
static_cast<boo::GLDataFactory::Context&>(ctx).
newShaderPipeline(vertSource.c_str(), fragSource.c_str(),
m_backend.m_texMapEnd, "texs",
1, STD_BLOCKNAMES,
m_backend.m_blendSrc, m_backend.m_blendDst, boo::Primitive::TriStrips,
@ -293,7 +291,8 @@ struct GLSLBackendFactory : IShaderBackendFactory
return dataOut;
}
boo::IShaderPipeline* buildShaderFromCache(const ShaderCachedData& data)
boo::IShaderPipeline* buildShaderFromCache(const ShaderCachedData& data,
boo::IGraphicsDataFactory::Context& ctx)
{
const ShaderTag& tag = data.m_tag;
athena::io::MemoryReader r(data.m_data.get(), data.m_sz);
@ -303,7 +302,8 @@ struct GLSLBackendFactory : IShaderBackendFactory
std::string vertSource = r.readString();
std::string fragSource = r.readString();
boo::IShaderPipeline* ret =
m_gfxFactory->newShaderPipeline(vertSource.c_str(), fragSource.c_str(),
static_cast<boo::GLDataFactory::Context&>(ctx).
newShaderPipeline(vertSource.c_str(), fragSource.c_str(),
texMapEnd, "texs",
1, STD_BLOCKNAMES,
blendSrc, blendDst, boo::Primitive::TriStrips,
@ -318,6 +318,7 @@ struct GLSLBackendFactory : IShaderBackendFactory
const hecl::Frontend::IR& ir,
hecl::Frontend::Diagnostics& diag,
const std::vector<ShaderCacheExtensions::ExtensionSlot>& extensionSlots,
boo::IGraphicsDataFactory::Context& ctx,
FReturnExtensionShader returnFunc)
{
m_backend.reset(ir, diag);
@ -336,7 +337,8 @@ struct GLSLBackendFactory : IShaderBackendFactory
fragSources.push_back(m_backend.makeFrag("#version 330", slot.lighting, slot.post));
cachedSz += fragSources.back().size() + 1;
boo::IShaderPipeline* ret =
m_gfxFactory->newShaderPipeline(vertSource.c_str(), fragSources.back().c_str(),
static_cast<boo::GLDataFactory::Context&>(ctx).
newShaderPipeline(vertSource.c_str(), fragSources.back().c_str(),
m_backend.m_texMapEnd, "texs",
1, STD_BLOCKNAMES,
m_backend.m_blendSrc, m_backend.m_blendDst, boo::Primitive::TriStrips,
@ -361,6 +363,7 @@ struct GLSLBackendFactory : IShaderBackendFactory
void buildExtendedShaderFromCache(const ShaderCachedData& data,
const std::vector<ShaderCacheExtensions::ExtensionSlot>& extensionSlots,
boo::IGraphicsDataFactory::Context& ctx,
FReturnExtensionShader returnFunc)
{
const ShaderTag& tag = data.m_tag;
@ -373,7 +376,8 @@ struct GLSLBackendFactory : IShaderBackendFactory
{
std::string fragSource = r.readString();
boo::IShaderPipeline* ret =
m_gfxFactory->newShaderPipeline(vertSource.c_str(), fragSource.c_str(),
static_cast<boo::GLDataFactory::Context&>(ctx).
newShaderPipeline(vertSource.c_str(), fragSource.c_str(),
texMapEnd, "texs",
1, STD_BLOCKNAMES,
blendSrc, blendDst, boo::Primitive::TriStrips,
@ -386,9 +390,9 @@ struct GLSLBackendFactory : IShaderBackendFactory
}
};
IShaderBackendFactory* _NewGLSLBackendFactory(boo::IGraphicsDataFactory* gfxFactory)
IShaderBackendFactory* _NewGLSLBackendFactory()
{
return new struct GLSLBackendFactory(gfxFactory);
return new struct GLSLBackendFactory();
}
#if BOO_HAS_VULKAN
@ -396,14 +400,11 @@ IShaderBackendFactory* _NewGLSLBackendFactory(boo::IGraphicsDataFactory* gfxFact
struct SPIRVBackendFactory : IShaderBackendFactory
{
Backend::GLSL m_backend;
boo::VulkanDataFactory* m_gfxFactory;
SPIRVBackendFactory(boo::IGraphicsDataFactory* gfxFactory)
: m_gfxFactory(dynamic_cast<boo::VulkanDataFactory*>(gfxFactory)) {}
ShaderCachedData buildShaderFromIR(const ShaderTag& tag,
const hecl::Frontend::IR& ir,
hecl::Frontend::Diagnostics& diag,
boo::IGraphicsDataFactory::Context& ctx,
boo::IShaderPipeline*& objOut)
{
m_backend.reset(ir, diag);
@ -420,8 +421,9 @@ struct SPIRVBackendFactory : IShaderBackendFactory
std::vector<unsigned char> pipelineBlob;
objOut =
m_gfxFactory->newShaderPipeline(vertSource.c_str(), fragSource.c_str(),
vertBlob, fragBlob, pipelineBlob, tag.newVertexFormat(m_gfxFactory),
static_cast<boo::VulkanDataFactory::Context&>(ctx).
newShaderPipeline(vertSource.c_str(), fragSource.c_str(),
vertBlob, fragBlob, pipelineBlob, tag.newVertexFormat(ctx),
m_backend.m_blendSrc, m_backend.m_blendDst, boo::Primitive::TriStrips,
tag.getDepthTest(), tag.getDepthWrite(),
tag.getBackfaceCulling());
@ -468,7 +470,8 @@ struct SPIRVBackendFactory : IShaderBackendFactory
return dataOut;
}
boo::IShaderPipeline* buildShaderFromCache(const ShaderCachedData& data)
boo::IShaderPipeline* buildShaderFromCache(const ShaderCachedData& data,
boo::IGraphicsDataFactory::Context& ctx)
{
const ShaderTag& tag = data.m_tag;
athena::io::MemoryReader r(data.m_data.get(), data.m_sz);
@ -492,9 +495,10 @@ struct SPIRVBackendFactory : IShaderBackendFactory
r.readUBytesToBuf(pipelineBlob.data(), pipelineSz);
boo::IShaderPipeline* ret =
m_gfxFactory->newShaderPipeline(nullptr, nullptr,
static_cast<boo::VulkanDataFactory::Context&>(ctx).
newShaderPipeline(nullptr, nullptr,
vertBlob, fragBlob, pipelineBlob,
tag.newVertexFormat(m_gfxFactory),
tag.newVertexFormat(ctx),
blendSrc, blendDst, boo::Primitive::TriStrips,
tag.getDepthTest(), tag.getDepthWrite(),
tag.getBackfaceCulling());
@ -507,6 +511,7 @@ struct SPIRVBackendFactory : IShaderBackendFactory
const hecl::Frontend::IR& ir,
hecl::Frontend::Diagnostics& diag,
const std::vector<ShaderCacheExtensions::ExtensionSlot>& extensionSlots,
boo::IGraphicsDataFactory::Context& ctx,
FReturnExtensionShader returnFunc)
{
m_backend.reset(ir, diag);
@ -527,9 +532,10 @@ struct SPIRVBackendFactory : IShaderBackendFactory
fragPipeBlobs.emplace_back();
std::pair<std::vector<unsigned int>, std::vector<unsigned char>>& fragPipeBlob = fragPipeBlobs.back();
boo::IShaderPipeline* ret =
m_gfxFactory->newShaderPipeline(vertSource.c_str(), fragSource.c_str(),
static_cast<boo::VulkanDataFactory::Context&>(ctx).
newShaderPipeline(vertSource.c_str(), fragSource.c_str(),
vertBlob, fragPipeBlob.first, fragPipeBlob.second,
tag.newVertexFormat(m_gfxFactory),
tag.newVertexFormat(ctx),
m_backend.m_blendSrc, m_backend.m_blendDst, boo::Primitive::TriStrips,
tag.getDepthTest(), tag.getDepthWrite(),
tag.getBackfaceCulling());
@ -583,6 +589,7 @@ struct SPIRVBackendFactory : IShaderBackendFactory
void buildExtendedShaderFromCache(const ShaderCachedData& data,
const std::vector<ShaderCacheExtensions::ExtensionSlot>& extensionSlots,
boo::IGraphicsDataFactory::Context& ctx,
FReturnExtensionShader returnFunc)
{
const ShaderTag& tag = data.m_tag;
@ -609,9 +616,10 @@ struct SPIRVBackendFactory : IShaderBackendFactory
r.readUBytesToBuf(pipelineBlob.data(), pipelineSz);
boo::IShaderPipeline* ret =
m_gfxFactory->newShaderPipeline(nullptr, nullptr,
static_cast<boo::VulkanDataFactory::Context&>(ctx).
newShaderPipeline(nullptr, nullptr,
vertBlob, fragBlob, pipelineBlob,
tag.newVertexFormat(m_gfxFactory),
tag.newVertexFormat(ctx),
blendSrc, blendDst, boo::Primitive::TriStrips,
tag.getDepthTest(), tag.getDepthWrite(),
tag.getBackfaceCulling());
@ -622,9 +630,9 @@ struct SPIRVBackendFactory : IShaderBackendFactory
}
};
IShaderBackendFactory* _NewSPIRVBackendFactory(boo::IGraphicsDataFactory* gfxFactory)
IShaderBackendFactory* _NewSPIRVBackendFactory()
{
return new struct SPIRVBackendFactory(gfxFactory);
return new struct SPIRVBackendFactory();
}
#endif

View File

@ -8,7 +8,7 @@ namespace Runtime
{
static logvisor::Module Log("HMDL");
HMDLData::HMDLData(boo::IGraphicsDataFactory* factory,
HMDLData::HMDLData(boo::IGraphicsDataFactory::Context& ctx,
const void* metaData, const void* vbo, const void* ibo)
{
HMDLMeta meta;
@ -19,15 +19,15 @@ HMDLData::HMDLData(boo::IGraphicsDataFactory* factory,
if (meta.magic != 'TACO')
Log.report(logvisor::Fatal, "invalid HMDL magic");
m_vbo = factory->newStaticBuffer(boo::BufferUse::Vertex, vbo, meta.vertStride, meta.vertCount);
m_ibo = factory->newStaticBuffer(boo::BufferUse::Index, ibo, 4, meta.indexCount);
m_vbo = ctx.newStaticBuffer(boo::BufferUse::Vertex, vbo, meta.vertStride, meta.vertCount);
m_ibo = ctx.newStaticBuffer(boo::BufferUse::Index, ibo, 4, meta.indexCount);
if (factory->bindingNeedsVertexFormat())
m_vtxFmt = NewVertexFormat(factory, meta, m_vbo, m_ibo);
if (ctx.bindingNeedsVertexFormat())
m_vtxFmt = NewVertexFormat(ctx, meta, m_vbo, m_ibo);
}
/* For binding constructors that require vertex format up front (GLSL) */
boo::IVertexFormat* HMDLData::NewVertexFormat(boo::IGraphicsDataFactory* factory, const HMDLMeta& meta,
boo::IVertexFormat* HMDLData::NewVertexFormat(boo::IGraphicsDataFactory::Context& ctx, const HMDLMeta& meta,
boo::IGraphicsBuffer* vbo, boo::IGraphicsBuffer* ibo)
{
size_t elemCount = 2 + meta.colorCount + meta.uvCount + meta.weightCount;
@ -60,11 +60,11 @@ boo::IVertexFormat* HMDLData::NewVertexFormat(boo::IGraphicsDataFactory* factory
vdescs[e].semanticIdx = i;
}
return factory->newVertexFormat(elemCount, vdescs.get());
return ctx.newVertexFormat(elemCount, vdescs.get());
}
/* For shader constructors that require vertex format up-front (HLSL/Metal/Vulkan) */
boo::IVertexFormat* ShaderTag::newVertexFormat(boo::IGraphicsDataFactory *factory) const
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]);
@ -96,7 +96,7 @@ boo::IVertexFormat* ShaderTag::newVertexFormat(boo::IGraphicsDataFactory *factor
vdescs[e].semanticIdx = i;
}
return factory->newVertexFormat(elemCount, vdescs.get());
return ctx.newVertexFormat(elemCount, vdescs.get());
}
}

View File

@ -12,15 +12,15 @@ namespace hecl
{
namespace Runtime
{
IShaderBackendFactory* _NewGLSLBackendFactory(boo::IGraphicsDataFactory* gfxFactory);
IShaderBackendFactory* _NewGLSLBackendFactory();
#if _WIN32
IShaderBackendFactory* _NewHLSLBackendFactory(boo::IGraphicsDataFactory* gfxFactory);
IShaderBackendFactory* _NewHLSLBackendFactory();
#endif
#if BOO_HAS_METAL
IShaderBackendFactory* _NewMetalBackendFactory(boo::IGraphicsDataFactory* gfxFactory);
IShaderBackendFactory* _NewMetalBackendFactory();
#endif
#if BOO_HAS_VULKAN
IShaderBackendFactory* _NewSPIRVBackendFactory(boo::IGraphicsDataFactory* gfxFactory);
IShaderBackendFactory* _NewSPIRVBackendFactory();
#endif
static logvisor::Module Log("ShaderCacheManager");
@ -116,22 +116,22 @@ ShaderCacheManager::ShaderCacheManager(const FileStoreManager& storeMgr,
switch (plat)
{
case boo::IGraphicsDataFactory::Platform::OGL:
m_factory.reset(_NewGLSLBackendFactory(gfxFactory));
m_factory.reset(_NewGLSLBackendFactory());
break;
#if _WIN32
case boo::IGraphicsDataFactory::Platform::D3D11:
case boo::IGraphicsDataFactory::Platform::D3D12:
m_factory.reset(_NewHLSLBackendFactory(gfxFactory));
m_factory.reset(_NewHLSLBackendFactory());
break;
#endif
#if BOO_HAS_METAL
case boo::IGraphicsDataFactory::Platform::Metal:
m_factory.reset(_NewMetalBackendFactory(gfxFactory));
m_factory.reset(_NewMetalBackendFactory());
break;
#endif
#if BOO_HAS_VULKAN
case boo::IGraphicsDataFactory::Platform::Vulkan:
m_factory.reset(_NewSPIRVBackendFactory(gfxFactory));
m_factory.reset(_NewSPIRVBackendFactory());
break;
#endif
default:
@ -352,41 +352,45 @@ bool ShaderCacheManager::addData(const ShaderCachedData& data)
}
boo::IShaderPipeline*
ShaderCacheManager::buildFromCache(const ShaderCachedData& foundData)
ShaderCacheManager::buildFromCache(const ShaderCachedData& foundData,
boo::IGraphicsDataFactory::Context& ctx)
{
return m_factory->buildShaderFromCache(foundData);
return m_factory->buildShaderFromCache(foundData, ctx);
}
boo::IShaderPipeline*
ShaderCacheManager::buildShader(const ShaderTag& tag, const std::string& source,
const std::string& diagName)
const std::string& diagName,
boo::IGraphicsDataFactory::Context& ctx)
{
ShaderCachedData foundData = lookupData(tag);
if (foundData)
return buildFromCache(foundData);
return buildFromCache(foundData, ctx);
hecl::Frontend::IR ir = FE.compileSource(source, diagName);
return buildShader(tag, ir, diagName);
return buildShader(tag, ir, diagName, ctx);
}
boo::IShaderPipeline*
ShaderCacheManager::buildShader(const ShaderTag& tag, const hecl::Frontend::IR& ir,
const std::string& diagName)
const std::string& diagName,
boo::IGraphicsDataFactory::Context& ctx)
{
ShaderCachedData foundData = lookupData(tag);
if (foundData)
return buildFromCache(foundData);
return buildFromCache(foundData, ctx);
FE.getDiagnostics().reset(diagName);
boo::IShaderPipeline* ret;
addData(m_factory->buildShaderFromIR(tag, ir, FE.getDiagnostics(), ret));
addData(m_factory->buildShaderFromIR(tag, ir, FE.getDiagnostics(), ctx, ret));
return ret;
}
std::vector<boo::IShaderPipeline*>
ShaderCacheManager::buildExtendedFromCache(const ShaderCachedData& foundData)
ShaderCacheManager::buildExtendedFromCache(const ShaderCachedData& foundData,
boo::IGraphicsDataFactory::Context& ctx)
{
std::vector<boo::IShaderPipeline*> shaders;
shaders.reserve(m_extensions.m_extensionSlots.size());
m_factory->buildExtendedShaderFromCache(foundData, m_extensions.m_extensionSlots,
m_factory->buildExtendedShaderFromCache(foundData, m_extensions.m_extensionSlots, ctx,
[&](boo::IShaderPipeline* shader){shaders.push_back(shader);});
if (shaders.size() != m_extensions.m_extensionSlots.size())
Log.report(logvisor::Fatal, "buildShaderFromCache returned %" PRISize " times, expected %" PRISize,
@ -396,27 +400,29 @@ ShaderCacheManager::buildExtendedFromCache(const ShaderCachedData& foundData)
std::vector<boo::IShaderPipeline*>
ShaderCacheManager::buildExtendedShader(const ShaderTag& tag, const std::string& source,
const std::string& diagName)
const std::string& diagName,
boo::IGraphicsDataFactory::Context& ctx)
{
ShaderCachedData foundData = lookupData(tag);
if (foundData)
return buildExtendedFromCache(foundData);
return buildExtendedFromCache(foundData, ctx);
hecl::Frontend::IR ir = FE.compileSource(source, diagName);
return buildExtendedShader(tag, ir, diagName);
return buildExtendedShader(tag, ir, diagName, ctx);
}
std::vector<boo::IShaderPipeline*>
ShaderCacheManager::buildExtendedShader(const ShaderTag& tag, const hecl::Frontend::IR& ir,
const std::string& diagName)
const std::string& diagName,
boo::IGraphicsDataFactory::Context& ctx)
{
ShaderCachedData foundData = lookupData(tag);
if (foundData)
return buildExtendedFromCache(foundData);
return buildExtendedFromCache(foundData, ctx);
std::vector<boo::IShaderPipeline*> shaders;
shaders.reserve(m_extensions.m_extensionSlots.size());
FE.getDiagnostics().reset(diagName);
ShaderCachedData data =
m_factory->buildExtendedShaderFromIR(tag, ir, FE.getDiagnostics(), m_extensions.m_extensionSlots,
m_factory->buildExtendedShaderFromIR(tag, ir, FE.getDiagnostics(), m_extensions.m_extensionSlots, ctx,
[&](boo::IShaderPipeline* shader){shaders.push_back(shader);});
if (shaders.size() != m_extensions.m_extensionSlots.size())
Log.report(logvisor::Fatal, "buildShaderFromIR returned %" PRISize " times, expected %" PRISize,

View File

@ -74,8 +74,11 @@ struct HECLApplicationCallback : boo::IApplicationCallback
std::unique_lock<std::mutex> innerLk(initmt);
boo::IGraphicsDataFactory* gfxF = m_mainWindow->getLoadContextDataFactory();
boo::GraphicsDataToken data =
gfxF->commitTransaction([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
{
boo::SWindowRect mainWindowRect = m_mainWindow->getWindowFrame();
renderTex = gfxF->newRenderTexture(mainWindowRect.size[0], mainWindowRect.size[1], false, false);
renderTex = ctx.newRenderTexture(mainWindowRect.size[0], mainWindowRect.size[1], false, false);
/* HECL managers */
hecl::Runtime::FileStoreManager fileMgr(app->getUniqueName());
@ -85,7 +88,7 @@ struct HECLApplicationCallback : boo::IApplicationCallback
static std::string testShader = "HECLOpaque(Texture(0, UV(0)))";
hecl::Runtime::ShaderTag testShaderTag(testShader, 0, 1, 0, 0, 0, false, false, false);
boo::IShaderPipeline* testShaderObj =
shaderMgr.buildShader(testShaderTag, testShader, "testShader");
shaderMgr.buildShader(testShaderTag, testShader, "testShader", ctx);
/* Generate meta structure (usually statically serialized) */
hecl::HMDLMeta testMeta;
@ -121,7 +124,7 @@ struct HECLApplicationCallback : boo::IApplicationCallback
static const uint32_t ibo[4] = {0,1,2,3};
/* Construct quad mesh against boo factory */
hecl::Runtime::HMDLData testData(gfxF, testMetaBuf, quad, ibo);
hecl::Runtime::HMDLData testData(ctx, testMetaBuf, quad, ibo);
/* Make ramp texture */
using Pixel = uint8_t[4];
@ -135,15 +138,15 @@ struct HECLApplicationCallback : boo::IApplicationCallback
tex[i][j][3] = 0xff;
}
boo::ITexture* texture =
gfxF->newStaticTexture(256, 256, 1, boo::TextureFormat::RGBA8, tex, 256*256*4);
ctx.newStaticTexture(256, 256, 1, boo::TextureFormat::RGBA8, tex, 256*256*4);
/* Make vertex uniform buffer */
vubo = gfxF->newDynamicBuffer(boo::BufferUse::Uniform, sizeof(VertexUBO), 1);
vubo = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(VertexUBO), 1);
/* Assemble data binding */
binding = testData.newShaderDataBindng(gfxF, testShaderObj, 1, (boo::IGraphicsBuffer**)&vubo, 1, &texture);
boo::GraphicsDataToken data = gfxF->commit();
binding = testData.newShaderDataBindng(ctx, testShaderObj, 1, (boo::IGraphicsBuffer**)&vubo, 1, &texture);
return true;
});
/* Return control to main thread */
innerLk.unlock();