mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-20 11:39:13 +00:00
Tons of refactors and bug fixes
This commit is contained in:
@@ -10,21 +10,16 @@
|
||||
namespace urde
|
||||
{
|
||||
|
||||
template <class FilterImp>
|
||||
template <class ShaderImp>
|
||||
class TShader
|
||||
{
|
||||
public:
|
||||
struct IDataBindingFactory
|
||||
{
|
||||
virtual boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
boo::IShaderPipeline* pipeline,
|
||||
boo::IVertexFormat* vtxFmt,
|
||||
FilterImp& filter)=0;
|
||||
ShaderImp& filter)=0;
|
||||
};
|
||||
|
||||
static boo::IShaderPipeline* m_pipeline;
|
||||
static boo::IVertexFormat* m_vtxFmt; /* No OpenGL */
|
||||
|
||||
static std::unique_ptr<IDataBindingFactory> m_bindFactory;
|
||||
static boo::GraphicsDataToken m_gfxToken;
|
||||
|
||||
@@ -39,26 +34,22 @@ public:
|
||||
switch (ctx.platform())
|
||||
{
|
||||
case boo::IGraphicsDataFactory::Platform::OpenGL:
|
||||
m_bindFactory.reset(FilterImp::Initialize(static_cast<boo::GLDataFactory::Context&>(ctx),
|
||||
m_pipeline));
|
||||
m_bindFactory.reset(ShaderImp::Initialize(static_cast<boo::GLDataFactory::Context&>(ctx)));
|
||||
break;
|
||||
#if _WIN32
|
||||
case boo::IGraphicsDataFactory::Platform::D3D11:
|
||||
case boo::IGraphicsDataFactory::Platform::D3D12:
|
||||
m_bindFactory.reset(FilterImp::Initialize(static_cast<boo::ID3DDataFactory::Context&>(ctx),
|
||||
m_pipeline, m_vtxFmt));
|
||||
m_bindFactory.reset(FilterImp::Initialize(static_cast<boo::ID3DDataFactory::Context&>(ctx)));
|
||||
break;
|
||||
#endif
|
||||
#if BOO_HAS_METAL
|
||||
case boo::IGraphicsDataFactory::Platform::Metal:
|
||||
m_bindFactory.reset(FilterImp::Initialize(static_cast<boo::MetalDataFactory::Context&>(ctx),
|
||||
m_pipeline, m_vtxFmt));
|
||||
m_bindFactory.reset(ShaderImp::Initialize(static_cast<boo::MetalDataFactory::Context&>(ctx)));
|
||||
break;
|
||||
#endif
|
||||
#if BOO_HAS_VULKAN
|
||||
case boo::IGraphicsDataFactory::Platform::Vulkan:
|
||||
m_bindFactory.reset(FilterImp::Initialize(static_cast<boo::VulkanDataFactory::Context&>(ctx),
|
||||
m_pipeline, m_vtxFmt));
|
||||
m_bindFactory.reset(FilterImp::Initialize(static_cast<boo::VulkanDataFactory::Context&>(ctx)));
|
||||
break;
|
||||
#endif
|
||||
default: break;
|
||||
@@ -69,32 +60,23 @@ public:
|
||||
|
||||
static void Shutdown()
|
||||
{
|
||||
ShaderImp::Shutdown();
|
||||
m_gfxToken.doDestroy();
|
||||
}
|
||||
|
||||
static boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, FilterImp& filter)
|
||||
static boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, ShaderImp& filter)
|
||||
{
|
||||
return m_bindFactory->BuildShaderDataBinding(ctx, m_pipeline, m_vtxFmt, filter);
|
||||
return m_bindFactory->BuildShaderDataBinding(ctx, filter);
|
||||
}
|
||||
};
|
||||
|
||||
#define URDE_DECL_SPECIALIZE_SHADER(cls) \
|
||||
template <> boo::IShaderPipeline* \
|
||||
TShader<cls>::m_pipeline; \
|
||||
template <> boo::IVertexFormat* \
|
||||
TShader<cls>::m_vtxFmt; \
|
||||
\
|
||||
template <> std::unique_ptr<TShader<cls>::IDataBindingFactory> \
|
||||
TShader<cls>::m_bindFactory; \
|
||||
template <> boo::GraphicsDataToken \
|
||||
TShader<cls>::m_gfxToken; \
|
||||
|
||||
#define URDE_SPECIALIZE_SHADER(cls) \
|
||||
template <> boo::IShaderPipeline* \
|
||||
TShader<cls>::m_pipeline = nullptr; \
|
||||
template <> boo::IVertexFormat* \
|
||||
TShader<cls>::m_vtxFmt = nullptr; \
|
||||
\
|
||||
template <> std::unique_ptr<TShader<cls>::IDataBindingFactory> \
|
||||
TShader<cls>::m_bindFactory = {}; \
|
||||
template <> boo::GraphicsDataToken \
|
||||
|
||||
Reference in New Issue
Block a user