From f254b34cca7215078a23272f49e4950ab0cb0b22 Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Wed, 30 Mar 2016 10:43:09 -1000 Subject: [PATCH] boo lambda D3D sync --- hecl/extern/boo | 2 +- hecl/lib/Backend/HLSL.cpp | 66 +++++++++++++++++++++------------------ 2 files changed, 36 insertions(+), 32 deletions(-) diff --git a/hecl/extern/boo b/hecl/extern/boo index bf6b4e37e..ecc65a9fd 160000 --- a/hecl/extern/boo +++ b/hecl/extern/boo @@ -1 +1 @@ -Subproject commit bf6b4e37e81b72532afe2b4a56201b3bea7d4c63 +Subproject commit ecc65a9fd531588b9679dc787624bea80272679b diff --git a/hecl/lib/Backend/HLSL.cpp b/hecl/lib/Backend/HLSL.cpp index 659976351..afd881207 100644 --- a/hecl/lib/Backend/HLSL.cpp +++ b/hecl/lib/Backend/HLSL.cpp @@ -240,14 +240,11 @@ namespace Runtime struct HLSLBackendFactory : IShaderBackendFactory { Backend::HLSL m_backend; - boo::ID3DDataFactory* m_gfxFactory; - - HLSLBackendFactory(boo::IGraphicsDataFactory* gfxFactory) - : m_gfxFactory(dynamic_cast(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); @@ -261,12 +258,13 @@ struct HLSLBackendFactory : IShaderBackendFactory ComPtr fragBlob; ComPtr pipelineBlob; objOut = - m_gfxFactory->newShaderPipeline(vertSource.c_str(), fragSource.c_str(), - vertBlob, fragBlob, pipelineBlob, - tag.newVertexFormat(m_gfxFactory), - m_backend.m_blendSrc, m_backend.m_blendDst, boo::Primitive::TriStrips, - tag.getDepthTest(), tag.getDepthWrite(), - tag.getBackfaceCulling()); + static_cast(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()); if (!objOut) Log.report(logvisor::Fatal, "unable to build shader"); @@ -314,7 +312,8 @@ struct HLSLBackendFactory : 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); @@ -346,12 +345,13 @@ struct HLSLBackendFactory : IShaderBackendFactory } boo::IShaderPipeline* ret = - m_gfxFactory->newShaderPipeline(nullptr, nullptr, - vertBlob, fragBlob, pipelineBlob, - tag.newVertexFormat(m_gfxFactory), - blendSrc, blendDst, boo::Primitive::TriStrips, - tag.getDepthTest(), tag.getDepthWrite(), - tag.getBackfaceCulling()); + static_cast(ctx). + newShaderPipeline(nullptr, nullptr, + vertBlob, fragBlob, pipelineBlob, + tag.newVertexFormat(ctx), + blendSrc, blendDst, boo::Primitive::TriStrips, + tag.getDepthTest(), tag.getDepthWrite(), + tag.getBackfaceCulling()); if (!ret) Log.report(logvisor::Fatal, "unable to build shader"); return ret; @@ -361,6 +361,7 @@ struct HLSLBackendFactory : IShaderBackendFactory const hecl::Frontend::IR& ir, hecl::Frontend::Diagnostics& diag, const std::vector& extensionSlots, + boo::IGraphicsDataFactory::Context& ctx, FReturnExtensionShader returnFunc) { m_backend.reset(ir, diag); @@ -380,12 +381,13 @@ struct HLSLBackendFactory : IShaderBackendFactory fragPipeBlobs.emplace_back(); std::pair, ComPtr>& fragPipeBlob = fragPipeBlobs.back(); boo::IShaderPipeline* ret = - m_gfxFactory->newShaderPipeline(vertSource.c_str(), fragSource.c_str(), - vertBlob, fragPipeBlob.first, fragPipeBlob.second, - tag.newVertexFormat(m_gfxFactory), - m_backend.m_blendSrc, m_backend.m_blendDst, boo::Primitive::TriStrips, - tag.getDepthTest(), tag.getDepthWrite(), - tag.getBackfaceCulling()); + static_cast(ctx). + newShaderPipeline(vertSource.c_str(), fragSource.c_str(), + vertBlob, fragPipeBlob.first, fragPipeBlob.second, + tag.newVertexFormat(ctx), + m_backend.m_blendSrc, m_backend.m_blendDst, boo::Primitive::TriStrips, + tag.getDepthTest(), tag.getDepthWrite(), + tag.getBackfaceCulling()); if (!ret) Log.report(logvisor::Fatal, "unable to build shader"); if (fragPipeBlob.first) @@ -434,6 +436,7 @@ struct HLSLBackendFactory : IShaderBackendFactory void buildExtendedShaderFromCache(const ShaderCachedData& data, const std::vector& extensionSlots, + boo::IGraphicsDataFactory::Context& ctx, FReturnExtensionShader returnFunc) { const ShaderTag& tag = data.m_tag; @@ -468,12 +471,13 @@ struct HLSLBackendFactory : IShaderBackendFactory } boo::IShaderPipeline* ret = - m_gfxFactory->newShaderPipeline(nullptr, nullptr, - vertBlob, fragBlob, pipelineBlob, - tag.newVertexFormat(m_gfxFactory), - blendSrc, blendDst, boo::Primitive::TriStrips, - tag.getDepthTest(), tag.getDepthWrite(), - tag.getBackfaceCulling()); + static_cast(ctx). + newShaderPipeline(nullptr, nullptr, + vertBlob, fragBlob, pipelineBlob, + tag.newVertexFormat(ctx), + blendSrc, blendDst, boo::Primitive::TriStrips, + tag.getDepthTest(), tag.getDepthWrite(), + tag.getBackfaceCulling()); if (!ret) Log.report(logvisor::Fatal, "unable to build shader"); returnFunc(ret); @@ -481,9 +485,9 @@ struct HLSLBackendFactory : IShaderBackendFactory } }; -IShaderBackendFactory* _NewHLSLBackendFactory(boo::IGraphicsDataFactory* gfxFactory) +IShaderBackendFactory* _NewHLSLBackendFactory() { - return new struct HLSLBackendFactory(gfxFactory); + return new struct HLSLBackendFactory(); } }