Merge branch 'gl-fixes'

This commit is contained in:
Jack Andersen 2017-11-05 20:58:43 -10:00
commit ff5c7321c7
161 changed files with 2497 additions and 1588 deletions

View File

@ -204,8 +204,8 @@ void ViewManager::init(boo::IApplication* app)
m_mainWindow->setTitle(_S("URDE [") + hecl::SystemString(m_mainPlatformName) + _S("]")); m_mainWindow->setTitle(_S("URDE [") + hecl::SystemString(m_mainPlatformName) + _S("]"));
m_mainCommandQueue = m_mainWindow->getCommandQueue(); m_mainCommandQueue = m_mainWindow->getCommandQueue();
m_viewResources.init(m_mainBooFactory, &m_fontCache, &m_themeData, pixelFactor); m_viewResources.init(m_mainBooFactory, &m_fontCache, &m_themeData, pixelFactor);
m_iconsToken = InitializeIcons(m_viewResources); InitializeIcons(m_viewResources);
m_badgeToken = InitializeBadging(m_viewResources); InitializeBadging(m_viewResources);
m_viewResources.prepFontCacheAsync(m_mainWindow.get()); m_viewResources.prepFontCacheAsync(m_mainWindow.get());
specter::RootView* root = SetupRootView(); specter::RootView* root = SetupRootView();
m_showSplash = true; m_showSplash = true;
@ -292,7 +292,8 @@ void ViewManager::stop()
m_videoVoice.reset(); m_videoVoice.reset();
m_projManager.shutdown(); m_projManager.shutdown();
CDvdFile::Shutdown(); CDvdFile::Shutdown();
m_iconsToken.doDestroy(); DestroyIcons();
DestroyBadging();
m_viewResources.destroyResData(); m_viewResources.destroyResData();
m_fontCache.destroyAtlases(); m_fontCache.destroyAtlases();
m_mainWindow->getCommandQueue()->stopRenderer(); m_mainWindow->getCommandQueue()->stopRenderer();

View File

@ -37,12 +37,10 @@ class ViewManager : public specter::IViewManager
specter::FontCache m_fontCache; specter::FontCache m_fontCache;
specter::DefaultThemeData m_themeData; specter::DefaultThemeData m_themeData;
specter::ViewResources m_viewResources; specter::ViewResources m_viewResources;
boo::GraphicsDataToken m_iconsToken;
boo::GraphicsDataToken m_badgeToken;
specter::Translator m_translator; specter::Translator m_translator;
boo::IGraphicsDataFactory* m_mainBooFactory = nullptr; boo::IGraphicsDataFactory* m_mainBooFactory = nullptr;
boo::IGraphicsCommandQueue* m_mainCommandQueue = nullptr; boo::IGraphicsCommandQueue* m_mainCommandQueue = nullptr;
boo::ITextureR* m_renderTex = nullptr; boo::ObjToken<boo::ITextureR> m_renderTex;
const boo::SystemChar* m_mainPlatformName; const boo::SystemChar* m_mainPlatformName;
std::unique_ptr<specter::RootView> m_rootView; std::unique_ptr<specter::RootView> m_rootView;

View File

@ -10,7 +10,7 @@ namespace urde
static logvisor::Module Log("URDE::badging"); static logvisor::Module Log("URDE::badging");
static specter::Icon g_BadgeIcon; static specter::Icon g_BadgeIcon;
boo::GraphicsDataToken InitializeBadging(specter::ViewResources& viewRes) void InitializeBadging(specter::ViewResources& viewRes)
{ {
athena::io::MemoryReader r(URDE_BADGE, URDE_BADGE_SZ); athena::io::MemoryReader r(URDE_BADGE, URDE_BADGE_SZ);
@ -28,7 +28,7 @@ boo::GraphicsDataToken InitializeBadging(specter::ViewResources& viewRes)
if (uncompress(texels.get(), &destSz, URDE_BADGE + pos, URDE_BADGE_SZ - pos) != Z_OK) if (uncompress(texels.get(), &destSz, URDE_BADGE + pos, URDE_BADGE_SZ - pos) != Z_OK)
Log.report(logvisor::Fatal, "unable to decompress badge"); Log.report(logvisor::Fatal, "unable to decompress badge");
return viewRes.m_factory->commitTransaction([&](boo::IGraphicsDataFactory::Context& ctx) -> bool viewRes.m_factory->commitTransaction([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
{ {
specter::IconAtlas<1, 1> atlas; specter::IconAtlas<1, 1> atlas;
@ -40,6 +40,11 @@ boo::GraphicsDataToken InitializeBadging(specter::ViewResources& viewRes)
}); });
} }
void DestroyBadging()
{
g_BadgeIcon.m_tex.reset();
}
specter::Icon& GetBadge() specter::Icon& GetBadge()
{ {
return g_BadgeIcon; return g_BadgeIcon;

View File

@ -5,7 +5,8 @@
namespace urde namespace urde
{ {
boo::GraphicsDataToken InitializeBadging(specter::ViewResources& viewRes); void InitializeBadging(specter::ViewResources& viewRes);
void DestroyBadging();
specter::Icon& GetBadge(); specter::Icon& GetBadge();
} }

View File

@ -11,7 +11,7 @@ static logvisor::Module Log("URDE::icons");
specter::IconAtlas<8,8> g_IconAtlas; specter::IconAtlas<8,8> g_IconAtlas;
boo::GraphicsDataToken InitializeIcons(specter::ViewResources& viewRes) void InitializeIcons(specter::ViewResources& viewRes)
{ {
athena::io::MemoryReader r(URDE_ICONS, URDE_ICONS_SZ); athena::io::MemoryReader r(URDE_ICONS, URDE_ICONS_SZ);
size_t fmt = r.readUint32Big(); size_t fmt = r.readUint32Big();
@ -28,7 +28,7 @@ boo::GraphicsDataToken InitializeIcons(specter::ViewResources& viewRes)
if (uncompress(texels.get(), &destSz, URDE_ICONS + pos, URDE_ICONS_SZ - pos) != Z_OK) if (uncompress(texels.get(), &destSz, URDE_ICONS + pos, URDE_ICONS_SZ - pos) != Z_OK)
Log.report(logvisor::Fatal, "unable to decompress icons"); Log.report(logvisor::Fatal, "unable to decompress icons");
return viewRes.m_factory->commitTransaction([&](boo::IGraphicsDataFactory::Context& ctx) -> bool viewRes.m_factory->commitTransaction([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
{ {
g_IconAtlas.initializeAtlas(ctx.newStaticTexture(width, height, mips, g_IconAtlas.initializeAtlas(ctx.newStaticTexture(width, height, mips,
boo::TextureFormat::RGBA8, boo::TextureFormat::RGBA8,
@ -38,6 +38,11 @@ boo::GraphicsDataToken InitializeIcons(specter::ViewResources& viewRes)
}); });
} }
void DestroyIcons()
{
g_IconAtlas.destroyAtlas();
}
specter::Icon& GetIcon(SpaceIcon icon) specter::Icon& GetIcon(SpaceIcon icon)
{ {
switch (icon) switch (icon)

View File

@ -6,7 +6,8 @@
namespace urde namespace urde
{ {
boo::GraphicsDataToken InitializeIcons(specter::ViewResources& viewRes); void InitializeIcons(specter::ViewResources& viewRes);
void DestroyIcons();
enum class SpaceIcon enum class SpaceIcon
{ {

View File

@ -54,7 +54,7 @@ void CMapArea::PostConstruct()
m_surfaces.back().PostConstruct(x44_buf.get(), index); m_surfaces.back().PostConstruct(x44_buf.get(), index);
} }
m_gfxToken = CGraphics::CommitResources([this, &index](boo::IGraphicsDataFactory::Context& ctx) CGraphics::CommitResources([this, &index](boo::IGraphicsDataFactory::Context& ctx)
{ {
m_vbo = ctx.newStaticBuffer(boo::BufferUse::Vertex, x3c_vertexStart, 12, x2c_vertexCount); m_vbo = ctx.newStaticBuffer(boo::BufferUse::Vertex, x3c_vertexStart, 12, x2c_vertexCount);
m_ibo = ctx.newStaticBuffer(boo::BufferUse::Index, index.data(), 4, index.size()); m_ibo = ctx.newStaticBuffer(boo::BufferUse::Index, index.data(), 4, index.size());

View File

@ -29,8 +29,12 @@ public:
{ {
CMapSurfaceShader m_surfacePrims; CMapSurfaceShader m_surfacePrims;
std::vector<CLineRenderer> m_linePrims; std::vector<CLineRenderer> m_linePrims;
Instance(boo::IGraphicsDataFactory::Context& ctx, boo::IGraphicsBufferS* vbo, boo::IGraphicsBufferS* ibo) Instance(boo::IGraphicsDataFactory::Context& ctx,
const boo::ObjToken<boo::IGraphicsBufferS>& vbo,
const boo::ObjToken<boo::IGraphicsBufferS>& ibo)
: m_surfacePrims(ctx, vbo, ibo) {} : m_surfacePrims(ctx, vbo, ibo) {}
Instance(Instance&&) = default;
Instance& operator=(Instance&&) = default;
}; };
std::vector<Instance> m_instances; std::vector<Instance> m_instances;
public: public:
@ -67,9 +71,8 @@ private:
u8* x40_surfaceStart; u8* x40_surfaceStart;
std::vector<CMapAreaSurface> m_surfaces; std::vector<CMapAreaSurface> m_surfaces;
std::unique_ptr<u8[]> x44_buf; std::unique_ptr<u8[]> x44_buf;
boo::GraphicsDataToken m_gfxToken; boo::ObjToken<boo::IGraphicsBufferS> m_vbo;
boo::IGraphicsBufferS* m_vbo; boo::ObjToken<boo::IGraphicsBufferS> m_ibo;
boo::IGraphicsBufferS* m_ibo;
public: public:
CMapArea(CInputStream& in, u32 size); CMapArea(CInputStream& in, u32 size);

View File

@ -278,9 +278,8 @@ bool CMappableObject::IsVisibleToAutoMapper(bool worldVis, const CMapWorldInfo&
} }
} }
boo::GraphicsDataToken CMappableObject::g_gfxToken = {}; boo::ObjToken<boo::IGraphicsBufferS> CMappableObject::g_doorVbo;
boo::IGraphicsBufferS* CMappableObject::g_doorVbo; boo::ObjToken<boo::IGraphicsBufferS> CMappableObject::g_doorIbo;
boo::IGraphicsBufferS* CMappableObject::g_doorIbo;
void CMappableObject::ReadAutoMapperTweaks(const ITweakAutoMapper& tweaks) void CMappableObject::ReadAutoMapperTweaks(const ITweakAutoMapper& tweaks)
{ {
@ -296,7 +295,7 @@ void CMappableObject::ReadAutoMapperTweaks(const ITweakAutoMapper& tweaks)
doorVerts[6].assign(.2f * -center.z, center.y, 0.f); doorVerts[6].assign(.2f * -center.z, center.y, 0.f);
doorVerts[7].assign(.2f * -center.z, center.y, 2.f * center.x); doorVerts[7].assign(.2f * -center.z, center.y, 2.f * center.x);
g_gfxToken = CGraphics::CommitResources([](boo::IGraphicsDataFactory::Context& ctx) CGraphics::CommitResources([](boo::IGraphicsDataFactory::Context& ctx)
{ {
g_doorVbo = ctx.newStaticBuffer(boo::BufferUse::Vertex, skDoorVerts, 16, 8); g_doorVbo = ctx.newStaticBuffer(boo::BufferUse::Vertex, skDoorVerts, 16, 8);
g_doorIbo = ctx.newStaticBuffer(boo::BufferUse::Index, DoorIndices, 4, 24); g_doorIbo = ctx.newStaticBuffer(boo::BufferUse::Index, DoorIndices, 4, 24);
@ -306,6 +305,7 @@ void CMappableObject::ReadAutoMapperTweaks(const ITweakAutoMapper& tweaks)
void CMappableObject::Shutdown() void CMappableObject::Shutdown()
{ {
g_gfxToken.doDestroy(); g_doorVbo.reset();
g_doorIbo.reset();
} }
} }

View File

@ -17,9 +17,8 @@ class CMapWorldInfo;
class CMappableObject class CMappableObject
{ {
friend class CMapArea; friend class CMapArea;
static boo::GraphicsDataToken g_gfxToken; static boo::ObjToken<boo::IGraphicsBufferS> g_doorVbo;
static boo::IGraphicsBufferS* g_doorVbo; static boo::ObjToken<boo::IGraphicsBufferS> g_doorIbo;
static boo::IGraphicsBufferS* g_doorIbo;
public: public:
enum class EMappableObjectType enum class EMappableObjectType

View File

@ -672,7 +672,7 @@ CBooRenderer::CBooRenderer(IObjectStore& store, IFactory& resFac)
m_staticEntropy = store.GetObj("RandomStaticEntropy"); m_staticEntropy = store.GetObj("RandomStaticEntropy");
m_gfxToken = CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
{ {
GenerateFogVolumeRampTex(ctx); GenerateFogVolumeRampTex(ctx);
GenerateSphereRampTex(ctx); GenerateSphereRampTex(ctx);

View File

@ -97,7 +97,6 @@ class CBooRenderer : public IRenderer
IFactory& x8_factory; IFactory& x8_factory;
IObjectStore& xc_store; IObjectStore& xc_store;
TLockedToken<CTexture> m_staticEntropy; TLockedToken<CTexture> m_staticEntropy;
boo::GraphicsDataToken m_gfxToken;
// CFont x10_fnt; // CFont x10_fnt;
u32 x18_ = 0; u32 x18_ = 0;
std::list<CAreaListItem> x1c_areaListItems; std::list<CAreaListItem> x1c_areaListItems;
@ -120,17 +119,17 @@ class CBooRenderer : public IRenderer
//boo::ITextureS* xe4_blackTex = nullptr; //boo::ITextureS* xe4_blackTex = nullptr;
bool xee_24_ : 1; bool xee_24_ : 1;
boo::ITextureR* x14c_reflectionTex = nullptr; boo::ObjToken<boo::ITextureR> x14c_reflectionTex;
//boo::ITextureS* x150_mirrorRamp = nullptr; //boo::ITextureS* x150_mirrorRamp = nullptr;
boo::ITextureS* x1b8_fogVolumeRamp = nullptr; boo::ObjToken<boo::ITextureS> x1b8_fogVolumeRamp;
boo::ITextureS* x220_sphereRamp = nullptr; boo::ObjToken<boo::ITextureS> x220_sphereRamp;
TLockedToken<CTexture> m_thermoPaletteTex; TLockedToken<CTexture> m_thermoPaletteTex;
boo::ITexture* x288_thermoPalette = nullptr; boo::ObjToken<boo::ITexture> x288_thermoPalette;
TLockedToken<CTexture> m_ballFadeTex; TLockedToken<CTexture> m_ballFadeTex;
boo::ITexture* m_ballFade = nullptr; boo::ObjToken<boo::ITexture> m_ballFade;
boo::ITextureR* m_ballShadowId = nullptr; boo::ObjToken<boo::ITextureR> m_ballShadowId;
boo::IGraphicsBufferS* m_scanLinesEvenVBO = nullptr; boo::ObjToken<boo::IGraphicsBufferS> m_scanLinesEvenVBO;
boo::IGraphicsBufferS* m_scanLinesOddVBO = nullptr; boo::ObjToken<boo::IGraphicsBufferS> m_scanLinesOddVBO;
int m_ballShadowIdW = 64; int m_ballShadowIdW = 64;
int m_ballShadowIdH = 64; int m_ballShadowIdH = 64;
@ -275,11 +274,11 @@ public:
void ReallyRenderFogVolume(const zeus::CColor& color, const zeus::CAABox& aabb, void ReallyRenderFogVolume(const zeus::CColor& color, const zeus::CAABox& aabb,
const CModel* model, const CSkinnedModel* sModel); const CModel* model, const CSkinnedModel* sModel);
boo::ITexture* GetThermoPalette() {return x288_thermoPalette;} const boo::ObjToken<boo::ITexture>& GetThermoPalette() {return x288_thermoPalette;}
boo::ITextureS* GetFogRampTex() {return x1b8_fogVolumeRamp;} const boo::ObjToken<boo::ITextureS>& GetFogRampTex() {return x1b8_fogVolumeRamp;}
boo::ITexture* GetRandomStaticEntropyTex() const {return m_staticEntropy->GetBooTexture();} const boo::ObjToken<boo::ITexture>& GetRandomStaticEntropyTex() const {return m_staticEntropy->GetBooTexture();}
boo::IGraphicsBuffer* GetScanLinesEvenVBO() const {return m_scanLinesEvenVBO;} const boo::ObjToken<boo::IGraphicsBufferS>& GetScanLinesEvenVBO() const {return m_scanLinesEvenVBO;}
boo::IGraphicsBuffer* GetScanLinesOddVBO() const {return m_scanLinesOddVBO;} const boo::ObjToken<boo::IGraphicsBufferS>& GetScanLinesOddVBO() const {return m_scanLinesOddVBO;}
static void BindMainDrawTarget() {CGraphics::g_BooMainCommandQueue->setRenderTarget(CGraphics::g_SpareTexture);} static void BindMainDrawTarget() {CGraphics::g_BooMainCommandQueue->setRenderTarget(CGraphics::g_SpareTexture);}
void BindReflectionDrawTarget() {CGraphics::g_BooMainCommandQueue->setRenderTarget(x14c_reflectionTex);} void BindReflectionDrawTarget() {CGraphics::g_BooMainCommandQueue->setRenderTarget(x14c_reflectionTex);}

View File

@ -515,7 +515,7 @@ void CGraphics::TickRenderTimings()
boo::IGraphicsDataFactory::Platform CGraphics::g_BooPlatform = boo::IGraphicsDataFactory::Platform::Null; boo::IGraphicsDataFactory::Platform CGraphics::g_BooPlatform = boo::IGraphicsDataFactory::Platform::Null;
boo::IGraphicsDataFactory* CGraphics::g_BooFactory = nullptr; boo::IGraphicsDataFactory* CGraphics::g_BooFactory = nullptr;
boo::IGraphicsCommandQueue* CGraphics::g_BooMainCommandQueue = nullptr; boo::IGraphicsCommandQueue* CGraphics::g_BooMainCommandQueue = nullptr;
boo::ITextureR* CGraphics::g_SpareTexture = nullptr; boo::ObjToken<boo::ITextureR> CGraphics::g_SpareTexture;
const boo::SystemChar* CGraphics::g_BooPlatformName = nullptr; const boo::SystemChar* CGraphics::g_BooPlatformName = nullptr;
} }

View File

@ -300,11 +300,11 @@ public:
static const boo::SystemChar* g_BooPlatformName; static const boo::SystemChar* g_BooPlatformName;
static boo::IGraphicsDataFactory* g_BooFactory; static boo::IGraphicsDataFactory* g_BooFactory;
static boo::IGraphicsCommandQueue* g_BooMainCommandQueue; static boo::IGraphicsCommandQueue* g_BooMainCommandQueue;
static boo::ITextureR* g_SpareTexture; static boo::ObjToken<boo::ITextureR> g_SpareTexture;
static void InitializeBoo(boo::IGraphicsDataFactory* factory, static void InitializeBoo(boo::IGraphicsDataFactory* factory,
boo::IGraphicsCommandQueue* cc, boo::IGraphicsCommandQueue* cc,
boo::ITextureR* spareTex) const boo::ObjToken<boo::ITextureR>& spareTex)
{ {
g_BooPlatform = factory->platform(); g_BooPlatform = factory->platform();
g_BooPlatformName = factory->platformName(); g_BooPlatformName = factory->platformName();
@ -313,16 +313,16 @@ public:
g_SpareTexture = spareTex; g_SpareTexture = spareTex;
} }
const boo::SystemChar* PlatformName() static const boo::SystemChar* PlatformName()
{ {
return g_BooPlatformName; return g_BooPlatformName;
} }
static boo::GraphicsDataToken CommitResources(const boo::FactoryCommitFunc& commitFunc) static void CommitResources(const boo::FactoryCommitFunc& commitFunc)
{ {
return g_BooFactory->commitTransaction(commitFunc); g_BooFactory->commitTransaction(commitFunc);
} }
static void SetShaderDataBinding(boo::IShaderDataBinding* binding) static void SetShaderDataBinding(const boo::ObjToken<boo::IShaderDataBinding>& binding)
{ {
g_BooMainCommandQueue->setShaderDataBinding(binding); g_BooMainCommandQueue->setShaderDataBinding(binding);
} }

View File

@ -23,7 +23,8 @@ hecl::VertexBufferPool<CLineRenderer::SDrawVertNoTex> CLineRenderer::s_vertPoolN
hecl::UniformBufferPool<CLineRenderer::SDrawUniform> CLineRenderer::s_uniformPool = {}; hecl::UniformBufferPool<CLineRenderer::SDrawUniform> CLineRenderer::s_uniformPool = {};
CLineRenderer::CLineRenderer(boo::IGraphicsDataFactory::Context& ctx, CLineRenderer::CLineRenderer(boo::IGraphicsDataFactory::Context& ctx,
EPrimitiveMode mode, u32 maxVerts, boo::ITexture* texture, bool additive) EPrimitiveMode mode, u32 maxVerts,
const boo::ObjToken<boo::ITexture>& texture, bool additive)
: m_mode(mode), m_maxVerts(maxVerts) : m_mode(mode), m_maxVerts(maxVerts)
{ {
if (maxVerts < 2) if (maxVerts < 2)
@ -31,7 +32,7 @@ CLineRenderer::CLineRenderer(boo::IGraphicsDataFactory::Context& ctx,
LineRendererLog.report(logvisor::Fatal, _S("maxVerts < 2, maxVerts = %i"), maxVerts); LineRendererLog.report(logvisor::Fatal, _S("maxVerts < 2, maxVerts = %i"), maxVerts);
return; return;
} }
m_textured = texture != nullptr; m_textured = texture;
u32 maxTriVerts; u32 maxTriVerts;
switch (mode) switch (mode)
@ -57,7 +58,8 @@ CLineRenderer::CLineRenderer(boo::IGraphicsDataFactory::Context& ctx,
CLineRendererShaders::BuildShaderDataBinding(ctx, *this, texture, additive); CLineRendererShaders::BuildShaderDataBinding(ctx, *this, texture, additive);
} }
CLineRenderer::CLineRenderer(EPrimitiveMode mode, u32 maxVerts, boo::ITexture* texture, bool additive) CLineRenderer::CLineRenderer(EPrimitiveMode mode, u32 maxVerts,
const boo::ObjToken<boo::ITexture>& texture, bool additive)
: m_mode(mode), m_maxVerts(maxVerts) : m_mode(mode), m_maxVerts(maxVerts)
{ {
if (maxVerts < 2) if (maxVerts < 2)
@ -65,7 +67,7 @@ CLineRenderer::CLineRenderer(EPrimitiveMode mode, u32 maxVerts, boo::ITexture* t
LineRendererLog.report(logvisor::Fatal, _S("maxVerts < 2, maxVerts = %i"), maxVerts); LineRendererLog.report(logvisor::Fatal, _S("maxVerts < 2, maxVerts = %i"), maxVerts);
return; return;
} }
m_textured = texture != nullptr; m_textured = texture;
u32 maxTriVerts; u32 maxTriVerts;
switch (mode) switch (mode)
@ -88,7 +90,7 @@ CLineRenderer::CLineRenderer(EPrimitiveMode mode, u32 maxVerts, boo::ITexture* t
m_uniformBuf = s_uniformPool.allocateBlock(CGraphics::g_BooFactory); m_uniformBuf = s_uniformPool.allocateBlock(CGraphics::g_BooFactory);
m_gfxToken = CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
{ {
CLineRendererShaders::BuildShaderDataBinding(ctx, *this, texture, additive); CLineRendererShaders::BuildShaderDataBinding(ctx, *this, texture, additive);
return true; return true;

View File

@ -67,15 +67,14 @@ private:
static hecl::UniformBufferPool<SDrawUniform> s_uniformPool; static hecl::UniformBufferPool<SDrawUniform> s_uniformPool;
public: public:
boo::GraphicsDataToken m_gfxToken;
hecl::VertexBufferPool<SDrawVertTex>::Token m_vertBufTex; hecl::VertexBufferPool<SDrawVertTex>::Token m_vertBufTex;
hecl::VertexBufferPool<SDrawVertNoTex>::Token m_vertBufNoTex; hecl::VertexBufferPool<SDrawVertNoTex>::Token m_vertBufNoTex;
hecl::UniformBufferPool<SDrawUniform>::Token m_uniformBuf; hecl::UniformBufferPool<SDrawUniform>::Token m_uniformBuf;
boo::IShaderDataBinding* m_shaderBind = nullptr; boo::ObjToken<boo::IShaderDataBinding> m_shaderBind;
CLineRenderer(boo::IGraphicsDataFactory::Context& ctx, CLineRenderer(boo::IGraphicsDataFactory::Context& ctx,
EPrimitiveMode mode, u32 maxVerts, boo::ITexture* texture, bool additive); EPrimitiveMode mode, u32 maxVerts, const boo::ObjToken<boo::ITexture>& texture, bool additive);
CLineRenderer(EPrimitiveMode mode, u32 maxVerts, boo::ITexture* texture, bool additive); CLineRenderer(EPrimitiveMode mode, u32 maxVerts, const boo::ObjToken<boo::ITexture>& texture, bool additive);
CLineRenderer(CLineRenderer&&) = default; CLineRenderer(CLineRenderer&&) = default;
void Reset(); void Reset();

View File

@ -134,24 +134,23 @@ private:
size_t m_uniformDataSize = 0; size_t m_uniformDataSize = 0;
struct ModelInstance struct ModelInstance
{ {
boo::GraphicsDataToken m_gfxToken; boo::ObjToken<boo::IGraphicsBufferD> m_uniformBuffer;
boo::IGraphicsBufferD* m_uniformBuffer; std::vector<std::vector<boo::ObjToken<boo::IShaderDataBinding>>> m_shaderDataBindings;
std::vector<std::vector<boo::IShaderDataBinding*>> m_shaderDataBindings; boo::ObjToken<boo::IVertexFormat> m_dynamicVtxFmt;
boo::IVertexFormat* m_dynamicVtxFmt = nullptr; boo::ObjToken<boo::IGraphicsBufferD> m_dynamicVbo;
boo::IGraphicsBufferD* m_dynamicVbo = nullptr;
boo::IGraphicsBuffer* GetBooVBO(const CBooModel& model, boo::IGraphicsDataFactory::Context& ctx); boo::ObjToken<boo::IGraphicsBuffer> GetBooVBO(const CBooModel& model, boo::IGraphicsDataFactory::Context& ctx);
boo::IVertexFormat* GetBooVtxFmt(const CBooModel& model, boo::IGraphicsDataFactory::Context& ctx); boo::ObjToken<boo::IVertexFormat> GetBooVtxFmt(const CBooModel& model, boo::IGraphicsDataFactory::Context& ctx);
}; };
std::vector<ModelInstance> m_instances; std::vector<ModelInstance> m_instances;
boo::IVertexFormat* m_staticVtxFmt = nullptr; boo::ObjToken<boo::IVertexFormat> m_staticVtxFmt;
boo::IGraphicsBufferS* m_staticVbo = nullptr; boo::ObjToken<boo::IGraphicsBufferS> m_staticVbo;
boo::IGraphicsBufferS* m_staticIbo = nullptr; boo::ObjToken<boo::IGraphicsBufferS> m_staticIbo;
boo::ITexture* m_txtrOverrides[8] = {}; boo::ObjToken<boo::ITexture> m_txtrOverrides[8];
boo::ITexture* m_lastDrawnShadowMap = nullptr; boo::ObjToken<boo::ITexture> m_lastDrawnShadowMap;
ModelInstance* PushNewModelInstance(); ModelInstance* PushNewModelInstance();
void DrawAlphaSurfaces(const CModelFlags& flags) const; void DrawAlphaSurfaces(const CModelFlags& flags) const;
@ -172,9 +171,9 @@ private:
public: public:
~CBooModel(); ~CBooModel();
CBooModel(TToken<CModel>& token, CModel* parent, std::vector<CBooSurface>* surfaces, SShader& shader, CBooModel(TToken<CModel>& token, CModel* parent, std::vector<CBooSurface>* surfaces, SShader& shader,
boo::IVertexFormat* vtxFmt, boo::IGraphicsBufferS* vbo, boo::IGraphicsBufferS* ibo, const boo::ObjToken<boo::IVertexFormat>& vtxFmt, const boo::ObjToken<boo::IGraphicsBufferS>& vbo,
const zeus::CAABox& aabb, u8 renderMask, const boo::ObjToken<boo::IGraphicsBufferS>& ibo, const zeus::CAABox& aabb, u8 renderMask,
int numInsts, boo::ITexture* txtrOverrides[8]); int numInsts, const boo::ObjToken<boo::ITexture> txtrOverrides[8]);
static void MakeTexturesFromMats(const MaterialSet& matSet, static void MakeTexturesFromMats(const MaterialSet& matSet,
std::vector<TCachedToken<CTexture>>& toksOut, std::vector<TCachedToken<CTexture>>& toksOut,
@ -193,7 +192,7 @@ public:
void SyncLoadTextures() const; void SyncLoadTextures() const;
void Touch(int shaderIdx) const; void Touch(int shaderIdx) const;
void VerifyCurrentShader(int shaderIdx); void VerifyCurrentShader(int shaderIdx);
boo::IGraphicsBufferD* UpdateUniformData(const CModelFlags& flags, boo::ObjToken<boo::IGraphicsBufferD> UpdateUniformData(const CModelFlags& flags,
const CSkinRules* cskr, const CSkinRules* cskr,
const CPoseAsTransforms* pose) const; const CPoseAsTransforms* pose) const;
void DrawAlpha(const CModelFlags& flags, void DrawAlpha(const CModelFlags& flags,
@ -229,9 +228,9 @@ public:
static void EnsureViewDepStateCached(const CBooModel& model, const CBooSurface* surf, static void EnsureViewDepStateCached(const CBooModel& model, const CBooSurface* surf,
zeus::CMatrix4f* mtxsOut, float& alphaOut); zeus::CMatrix4f* mtxsOut, float& alphaOut);
static boo::ITexture* g_shadowMap; static boo::ObjToken<boo::ITexture> g_shadowMap;
static zeus::CTransform g_shadowTexXf; static zeus::CTransform g_shadowTexXf;
static void EnableShadowMaps(boo::ITexture* map, const zeus::CTransform& texXf); static void EnableShadowMaps(const boo::ObjToken<boo::ITexture>& map, const zeus::CTransform& texXf);
static void DisableShadowMaps(); static void DisableShadowMaps();
static void SetDummyTextures(bool b) { g_DummyTextures = true; } static void SetDummyTextures(bool b) { g_DummyTextures = true; }
@ -253,12 +252,11 @@ class CModel
int x38_lastFrame; int x38_lastFrame;
/* urde addition: boo! */ /* urde addition: boo! */
boo::GraphicsDataToken m_gfxToken; boo::ObjToken<boo::IVertexFormat> m_staticVtxFmt;
boo::IVertexFormat* m_staticVtxFmt = nullptr; boo::ObjToken<boo::IGraphicsBufferS> m_staticVbo;
boo::IGraphicsBufferS* m_staticVbo = nullptr;
hecl::HMDLMeta m_hmdlMeta; hecl::HMDLMeta m_hmdlMeta;
std::unique_ptr<uint8_t[]> m_dynamicVertexData; std::unique_ptr<uint8_t[]> m_dynamicVertexData;
boo::IGraphicsBufferS* m_ibo = nullptr; boo::ObjToken<boo::IGraphicsBufferS> m_ibo;
public: public:
using MaterialSet = DataSpec::DNAMP1::HMDLMaterialSet; using MaterialSet = DataSpec::DNAMP1::HMDLMaterialSet;
@ -274,7 +272,7 @@ public:
CBooModel& GetInstance() {return *x28_modelInst;} CBooModel& GetInstance() {return *x28_modelInst;}
const CBooModel& GetInstance() const {return *x28_modelInst;} const CBooModel& GetInstance() const {return *x28_modelInst;}
std::unique_ptr<CBooModel> MakeNewInstance(int shaderIdx, int subInsts, std::unique_ptr<CBooModel> MakeNewInstance(int shaderIdx, int subInsts,
boo::ITexture* txtrOverrides[8] = nullptr, const boo::ObjToken<boo::ITexture> txtrOverrides[8] = nullptr,
bool lockParent = true); bool lockParent = true);
void UpdateLastFrame() const { const_cast<CModel&>(*this).x38_lastFrame = CGraphics::GetFrameCounter(); } void UpdateLastFrame() const { const_cast<CModel&>(*this).x38_lastFrame = CGraphics::GetFrameCounter(); }
@ -282,7 +280,7 @@ public:
zeus::CVector3f GetPoolVertex(size_t idx) const; zeus::CVector3f GetPoolVertex(size_t idx) const;
size_t GetPoolNormalOffset(size_t idx) const; size_t GetPoolNormalOffset(size_t idx) const;
zeus::CVector3f GetPoolNormal(size_t idx) const; zeus::CVector3f GetPoolNormal(size_t idx) const;
void ApplyVerticesCPU(boo::IGraphicsBufferD* vertBuf, void ApplyVerticesCPU(const boo::ObjToken<boo::IGraphicsBufferD>& vertBuf,
const std::vector<std::pair<zeus::CVector3f, zeus::CVector3f>>& vn) const; const std::vector<std::pair<zeus::CVector3f, zeus::CVector3f>>& vn) const;
void _WarmupShaders(); void _WarmupShaders();

View File

@ -125,10 +125,10 @@ void CBooModel::EnsureViewDepStateCached(const CBooModel& model, const CBooSurfa
} }
} }
boo::ITexture* CBooModel::g_shadowMap = nullptr; boo::ObjToken<boo::ITexture> CBooModel::g_shadowMap;
zeus::CTransform CBooModel::g_shadowTexXf; zeus::CTransform CBooModel::g_shadowTexXf;
void CBooModel::EnableShadowMaps(boo::ITexture* map, const zeus::CTransform& texXf) void CBooModel::EnableShadowMaps(const boo::ObjToken<boo::ITexture>& map, const zeus::CTransform& texXf)
{ {
g_shadowMap = map; g_shadowMap = map;
g_shadowTexXf = texXf; g_shadowTexXf = texXf;
@ -149,9 +149,9 @@ CBooModel::~CBooModel()
} }
CBooModel::CBooModel(TToken<CModel>& token, CModel* parent, std::vector<CBooSurface>* surfaces, SShader& shader, CBooModel::CBooModel(TToken<CModel>& token, CModel* parent, std::vector<CBooSurface>* surfaces, SShader& shader,
boo::IVertexFormat* vtxFmt, boo::IGraphicsBufferS* vbo, boo::IGraphicsBufferS* ibo, const boo::ObjToken<boo::IVertexFormat>& vtxFmt, const boo::ObjToken<boo::IGraphicsBufferS>& vbo,
const zeus::CAABox& aabb, u8 renderMask, const boo::ObjToken<boo::IGraphicsBufferS>& ibo, const zeus::CAABox& aabb, u8 renderMask,
int numInsts, boo::ITexture* txtrOverrides[8]) int numInsts, const boo::ObjToken<boo::ITexture> txtrOverrides[8])
: m_modelTok(token), m_model(parent), x0_surfaces(surfaces), x4_matSet(&shader.m_matSet), : m_modelTok(token), m_model(parent), x0_surfaces(surfaces), x4_matSet(&shader.m_matSet),
m_matSetIdx(shader.m_matSetIdx), m_pipelines(&shader.m_shaders), x1c_textures(shader.x0_textures), m_matSetIdx(shader.m_matSetIdx), m_pipelines(&shader.m_shaders), x1c_textures(shader.x0_textures),
x20_aabb(aabb), x40_24_texturesLoaded(false), x40_25_modelVisible(0), x41_mask(renderMask), x20_aabb(aabb), x40_24_texturesLoaded(false), x40_25_modelVisible(0), x41_mask(renderMask),
@ -194,11 +194,12 @@ CBooModel::CBooModel(TToken<CModel>& token, CModel* parent, std::vector<CBooSurf
PushNewModelInstance(); PushNewModelInstance();
} }
boo::IGraphicsBuffer* CBooModel::ModelInstance::GetBooVBO(const CBooModel& model, boo::ObjToken<boo::IGraphicsBuffer>
CBooModel::ModelInstance::GetBooVBO(const CBooModel& model,
boo::IGraphicsDataFactory::Context& ctx) boo::IGraphicsDataFactory::Context& ctx)
{ {
if (model.m_staticVbo) if (model.m_staticVbo)
return model.m_staticVbo; return model.m_staticVbo.get();
if (!m_dynamicVbo && model.m_model) if (!m_dynamicVbo && model.m_model)
{ {
const CModel& parent = *model.m_model; const CModel& parent = *model.m_model;
@ -207,10 +208,11 @@ boo::IGraphicsBuffer* CBooModel::ModelInstance::GetBooVBO(const CBooModel& model
m_dynamicVbo->load(parent.m_dynamicVertexData.get(), m_dynamicVbo->load(parent.m_dynamicVertexData.get(),
parent.m_hmdlMeta.vertStride * parent.m_hmdlMeta.vertCount); parent.m_hmdlMeta.vertStride * parent.m_hmdlMeta.vertCount);
} }
return m_dynamicVbo; return m_dynamicVbo.get();
} }
boo::IVertexFormat* CBooModel::ModelInstance::GetBooVtxFmt(const CBooModel& model, boo::ObjToken<boo::IVertexFormat>
CBooModel::ModelInstance::GetBooVtxFmt(const CBooModel& model,
boo::IGraphicsDataFactory::Context& ctx) boo::IGraphicsDataFactory::Context& ctx)
{ {
if (model.m_staticVtxFmt) if (model.m_staticVtxFmt)
@ -219,7 +221,7 @@ boo::IVertexFormat* CBooModel::ModelInstance::GetBooVtxFmt(const CBooModel& mode
{ {
const CModel& parent = *model.m_model; const CModel& parent = *model.m_model;
m_dynamicVtxFmt = hecl::Runtime::HMDLData::NewVertexFormat(ctx, parent.m_hmdlMeta, m_dynamicVtxFmt = hecl::Runtime::HMDLData::NewVertexFormat(ctx, parent.m_hmdlMeta,
GetBooVBO(model, ctx), parent.m_ibo); GetBooVBO(model, ctx), parent.m_ibo.get());
} }
return m_dynamicVtxFmt; return m_dynamicVtxFmt;
} }
@ -241,8 +243,7 @@ CBooModel::ModelInstance* CBooModel::PushNewModelInstance()
weightVecCount = model->m_hmdlMeta.weightCount; weightVecCount = model->m_hmdlMeta.weightCount;
} }
newInst.m_gfxToken = CGraphics::CommitResources( CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
[&](boo::IGraphicsDataFactory::Context& ctx) -> bool
{ {
/* Determine space required by uniform buffer */ /* Determine space required by uniform buffer */
std::vector<size_t> skinOffs; std::vector<size_t> skinOffs;
@ -311,18 +312,22 @@ CBooModel::ModelInstance* CBooModel::PushNewModelInstance()
m_uniformDataSize = uniBufSize; m_uniformDataSize = uniBufSize;
newInst.m_uniformBuffer = ctx.newDynamicBuffer(boo::BufferUse::Uniform, uniBufSize, 1); newInst.m_uniformBuffer = ctx.newDynamicBuffer(boo::BufferUse::Uniform, uniBufSize, 1);
boo::IGraphicsBuffer* bufs[] = {newInst.m_uniformBuffer, boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {newInst.m_uniformBuffer.get(),
newInst.m_uniformBuffer, newInst.m_uniformBuffer.get(),
newInst.m_uniformBuffer, newInst.m_uniformBuffer.get(),
newInst.m_uniformBuffer}; newInst.m_uniformBuffer.get()};
/* Binding for each surface */ /* Binding for each surface */
newInst.m_shaderDataBindings.reserve(x0_surfaces->size()); newInst.m_shaderDataBindings.reserve(x0_surfaces->size());
boo::ITexture* texs[8] = {}; boo::ObjToken<boo::ITexture> mbShadowTexs[8] = {g_Renderer->m_ballShadowId.get(),
boo::ITexture* mbShadowTexs[] = {g_Renderer->m_ballShadowId, g_Renderer->x220_sphereRamp.get(),
g_Renderer->x220_sphereRamp, g_Renderer->m_ballFade.get(),
g_Renderer->m_ballFade}; g_Renderer->x220_sphereRamp.get(),
g_Renderer->x220_sphereRamp.get(),
g_Renderer->x220_sphereRamp.get(),
g_Renderer->x220_sphereRamp.get(),
g_Renderer->x220_sphereRamp.get()};
size_t thisOffs[4]; size_t thisOffs[4];
size_t thisSizes[4]; size_t thisSizes[4];
@ -337,21 +342,30 @@ CBooModel::ModelInstance* CBooModel::PushNewModelInstance()
{ {
const MaterialSet::Material& mat = x4_matSet->materials.at(surf.m_data.matIdx); const MaterialSet::Material& mat = x4_matSet->materials.at(surf.m_data.matIdx);
boo::ObjToken<boo::ITexture> texs[8] = {g_Renderer->x220_sphereRamp.get(),
g_Renderer->x220_sphereRamp.get(),
g_Renderer->x220_sphereRamp.get(),
g_Renderer->x220_sphereRamp.get(),
g_Renderer->x220_sphereRamp.get(),
g_Renderer->x220_sphereRamp.get(),
g_Renderer->x220_sphereRamp.get(),
g_Renderer->x220_sphereRamp.get()};
u32 texCount = 0; u32 texCount = 0;
for (atUint32 idx : mat.textureIdxs) for (atUint32 idx : mat.textureIdxs)
{ {
if (boo::ITexture* overtex = m_txtrOverrides[texCount]) if (boo::ObjToken<boo::ITexture> overtex = m_txtrOverrides[texCount])
{ {
texs[texCount++] = overtex; texs[texCount++] = overtex;
} }
else if (g_DummyTextures) else if (g_DummyTextures)
{ {
texs[texCount++] = g_Renderer->x220_sphereRamp; texs[texCount++] = g_Renderer->x220_sphereRamp.get();
} }
else else
{ {
TCachedToken<CTexture>& tex = x1c_textures[idx]; TCachedToken<CTexture>& tex = x1c_textures[idx];
texs[texCount++] = tex.GetObj()->GetBooTexture(); if (boo::ObjToken<boo::ITexture> btex = tex.GetObj()->GetBooTexture())
texs[texCount++] = btex;
} }
} }
@ -375,7 +389,10 @@ CBooModel::ModelInstance* CBooModel::PushNewModelInstance()
bool useReflection = mat.flags.samusReflection() || mat.flags.samusReflectionSurfaceEye(); bool useReflection = mat.flags.samusReflection() || mat.flags.samusReflectionSurfaceEye();
if (useReflection) if (useReflection)
{ {
texs[texCount] = g_Renderer->x14c_reflectionTex; if (g_Renderer->x14c_reflectionTex)
texs[texCount] = g_Renderer->x14c_reflectionTex.get();
else
texs[texCount] = g_Renderer->x220_sphereRamp.get();
thisOffs[3] = curReflect; thisOffs[3] = curReflect;
curReflect += 256; curReflect += 256;
} }
@ -388,45 +405,42 @@ CBooModel::ModelInstance* CBooModel::PushNewModelInstance()
const std::shared_ptr<hecl::Runtime::ShaderPipelines>& pipelines = m_pipelines->at(surf.m_data.matIdx); const std::shared_ptr<hecl::Runtime::ShaderPipelines>& pipelines = m_pipelines->at(surf.m_data.matIdx);
newInst.m_shaderDataBindings.emplace_back(); newInst.m_shaderDataBindings.emplace_back();
std::vector<boo::IShaderDataBinding*>& extendeds = newInst.m_shaderDataBindings.back(); std::vector<boo::ObjToken<boo::IShaderDataBinding>>& extendeds = newInst.m_shaderDataBindings.back();
extendeds.reserve(pipelines->m_pipelines.size()); extendeds.reserve(pipelines->m_pipelines.size());
int idx = 0; int idx = 0;
for (boo::IShaderPipeline* pipeline : pipelines->m_pipelines) for (const boo::ObjToken<boo::IShaderPipeline>& pipeline : pipelines->m_pipelines)
{ {
size_t texCount; boo::ObjToken<boo::ITexture>* ltexs;
boo::ITexture** ltexs;
if (idx == EExtendedShader::Thermal) if (idx == EExtendedShader::Thermal)
{ {
texCount = 8; texs[7] = g_Renderer->x220_sphereRamp.get();
texs[7] = g_Renderer->x220_sphereRamp;
ltexs = texs; ltexs = texs;
} }
else if (idx == EExtendedShader::MorphBallShadow) else if (idx == EExtendedShader::MorphBallShadow)
{ {
texCount = 3;
ltexs = mbShadowTexs; ltexs = mbShadowTexs;
} }
else if (idx == EExtendedShader::WorldShadow) else if (idx == EExtendedShader::WorldShadow)
{ {
texCount = 8; if (g_shadowMap)
texs[7] = g_shadowMap; texs[7] = g_shadowMap;
else
texs[7] = g_Renderer->x220_sphereRamp.get();
ltexs = texs; ltexs = texs;
} }
else if (useReflection) else if (useReflection)
{ {
texCount = mat.textureIdxs.size() + 1;
ltexs = texs; ltexs = texs;
} }
else else
{ {
texCount = mat.textureIdxs.size();
ltexs = texs; ltexs = texs;
} }
extendeds.push_back( extendeds.push_back(
ctx.newShaderDataBinding(pipeline, newInst.GetBooVtxFmt(*this, ctx), ctx.newShaderDataBinding(pipeline, newInst.GetBooVtxFmt(*this, ctx),
newInst.GetBooVBO(*this, ctx), nullptr, m_staticIbo, 4, bufs, newInst.GetBooVBO(*this, ctx), nullptr, m_staticIbo.get(), 4, bufs,
stages, thisOffs, thisSizes, texCount, ltexs, nullptr, nullptr)); stages, thisOffs, thisSizes, 8, ltexs, nullptr, nullptr));
++idx; ++idx;
} }
} }
@ -600,8 +614,8 @@ void CBooModel::DrawSurface(const CBooSurface& surf, const CModelFlags& flags) c
if (data.flags.shadowOccluderMesh() && !g_DrawingOccluders) if (data.flags.shadowOccluderMesh() && !g_DrawingOccluders)
return; return;
const std::vector<boo::IShaderDataBinding*>& extendeds = inst.m_shaderDataBindings[surf.selfIdx]; const std::vector<boo::ObjToken<boo::IShaderDataBinding>>& extendeds = inst.m_shaderDataBindings[surf.selfIdx];
boo::IShaderDataBinding* binding = extendeds[0]; boo::ObjToken<boo::IShaderDataBinding> binding = extendeds[0];
if (flags.m_extendedShader < extendeds.size()) if (flags.m_extendedShader < extendeds.size())
binding = extendeds[flags.m_extendedShader]; binding = extendeds[flags.m_extendedShader];
@ -632,11 +646,15 @@ void CBooModel::WarmupDrawSurface(const CBooSurface& surf) const
return; return;
const ModelInstance& inst = m_instances[m_uniUpdateCount-1]; const ModelInstance& inst = m_instances[m_uniUpdateCount-1];
for (boo::IShaderDataBinding* binding : inst.m_shaderDataBindings[surf.selfIdx]) // Only warmup normal lighting and thermal visor
#if 0
for (int i=1 ; i<=2 ; ++i)
{ {
boo::IShaderDataBinding* binding = inst.m_shaderDataBindings[surf.selfIdx][i];
CGraphics::SetShaderDataBinding(binding); CGraphics::SetShaderDataBinding(binding);
CGraphics::DrawArrayIndexed(surf.m_data.idxStart, std::min(u32(3), surf.m_data.idxCount)); CGraphics::DrawArrayIndexed(surf.m_data.idxStart, std::min(u32(3), surf.m_data.idxCount));
} }
#endif
} }
void CBooModel::UVAnimationBuffer::ProcessAnimation(u8*& bufOut, const UVAnimation& anim) void CBooModel::UVAnimationBuffer::ProcessAnimation(u8*& bufOut, const UVAnimation& anim)
@ -825,7 +843,7 @@ void CBooModel::UVAnimationBuffer::Update(u8*& bufOut, const MaterialSet* matSet
} }
} }
boo::IGraphicsBufferD* CBooModel::UpdateUniformData(const CModelFlags& flags, boo::ObjToken<boo::IGraphicsBufferD> CBooModel::UpdateUniformData(const CModelFlags& flags,
const CSkinRules* cskr, const CSkinRules* cskr,
const CPoseAsTransforms* pose) const const CPoseAsTransforms* pose) const
{ {
@ -1040,7 +1058,7 @@ static const u8* MemoryFromPartData(const u8*& dataCur, const u32*& secSizeCur)
} }
std::unique_ptr<CBooModel> CModel::MakeNewInstance(int shaderIdx, int subInsts, std::unique_ptr<CBooModel> CModel::MakeNewInstance(int shaderIdx, int subInsts,
boo::ITexture* txtrOverrides[8], const boo::ObjToken<boo::ITexture> txtrOverrides[8],
bool lockParent) bool lockParent)
{ {
if (shaderIdx >= x18_matSets.size()) if (shaderIdx >= x18_matSets.size())
@ -1120,7 +1138,7 @@ CModel::CModel(std::unique_ptr<u8[]>&& in, u32 /* dataLen */, IObjectStore* stor
for (CBooModel::SShader& matSet : x18_matSets) for (CBooModel::SShader& matSet : x18_matSets)
matSet.BuildShaders(m_hmdlMeta); matSet.BuildShaders(m_hmdlMeta);
m_gfxToken = CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
{ {
/* Index buffer is always static */ /* Index buffer is always static */
if (m_hmdlMeta.indexCount) if (m_hmdlMeta.indexCount)
@ -1132,7 +1150,7 @@ CModel::CModel(std::unique_ptr<u8[]>&& in, u32 /* dataLen */, IObjectStore* stor
if (m_hmdlMeta.vertCount) if (m_hmdlMeta.vertCount)
m_staticVbo = ctx.newStaticBuffer(boo::BufferUse::Vertex, vboData, m_staticVbo = ctx.newStaticBuffer(boo::BufferUse::Vertex, vboData,
m_hmdlMeta.vertStride, m_hmdlMeta.vertCount); m_hmdlMeta.vertStride, m_hmdlMeta.vertCount);
m_staticVtxFmt = hecl::Runtime::HMDLData::NewVertexFormat(ctx, m_hmdlMeta, m_staticVbo, m_ibo); m_staticVtxFmt = hecl::Runtime::HMDLData::NewVertexFormat(ctx, m_hmdlMeta, m_staticVbo.get(), m_ibo.get());
} }
else else
{ {
@ -1241,7 +1259,7 @@ zeus::CVector3f CModel::GetPoolNormal(size_t idx) const
return {floats[0], floats[1], floats[2]}; return {floats[0], floats[1], floats[2]};
} }
void CModel::ApplyVerticesCPU(boo::IGraphicsBufferD* vertBuf, void CModel::ApplyVerticesCPU(const boo::ObjToken<boo::IGraphicsBufferD>& vertBuf,
const std::vector<std::pair<zeus::CVector3f, zeus::CVector3f>>& vn) const const std::vector<std::pair<zeus::CVector3f, zeus::CVector3f>>& vn) const
{ {
u8* data = reinterpret_cast<u8*>(vertBuf->map(m_hmdlMeta.vertStride * m_hmdlMeta.vertCount)); u8* data = reinterpret_cast<u8*>(vertBuf->map(m_hmdlMeta.vertStride * m_hmdlMeta.vertCount));
@ -1262,7 +1280,7 @@ void CModel::ApplyVerticesCPU(boo::IGraphicsBufferD* vertBuf,
void CModel::_WarmupShaders() void CModel::_WarmupShaders()
{ {
CBooModel::SetDummyTextures(true); CBooModel::SetDummyTextures(true);
CBooModel::EnableShadowMaps(g_Renderer->x220_sphereRamp, zeus::CTransform::Identity()); CBooModel::EnableShadowMaps(g_Renderer->x220_sphereRamp.get(), zeus::CTransform::Identity());
CGraphics::CProjectionState backupProj = CGraphics::GetProjectionState(); CGraphics::CProjectionState backupProj = CGraphics::GetProjectionState();
zeus::CTransform backupViewPoint = CGraphics::g_ViewMatrix; zeus::CTransform backupViewPoint = CGraphics::g_ViewMatrix;
zeus::CTransform backupModel = CGraphics::g_GXModelMatrix; zeus::CTransform backupModel = CGraphics::g_GXModelMatrix;

View File

@ -176,9 +176,8 @@ static const u16 StaticVolumeLookup[] =
}; };
/* shared boo resources */ /* shared boo resources */
static boo::GraphicsDataToken GraphicsData; static boo::ObjToken<boo::IVertexFormat> YUVVTXFmt;
static boo::IVertexFormat* YUVVTXFmt = nullptr; static boo::ObjToken<boo::IShaderPipeline> YUVShaderPipeline;
static boo::IShaderPipeline* YUVShaderPipeline = nullptr;
static tjhandle TjHandle = nullptr; static tjhandle TjHandle = nullptr;
/* RSF audio state */ /* RSF audio state */
@ -199,7 +198,7 @@ static const char* TexNames[] = {"texY", "texU", "texV"};
void CMoviePlayer::Initialize() void CMoviePlayer::Initialize()
{ {
GraphicsData = CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
{ {
if (!ctx.bindingNeedsVertexFormat()) if (!ctx.bindingNeedsVertexFormat())
{ {
@ -231,7 +230,7 @@ void CMoviePlayer::Initialize()
#if BOO_HAS_METAL #if BOO_HAS_METAL
case boo::IGraphicsDataFactory::Platform::Metal: case boo::IGraphicsDataFactory::Platform::Metal:
YUVShaderPipeline = static_cast<boo::MetalDataFactory::Context&>(ctx).newShaderPipeline YUVShaderPipeline = static_cast<boo::MetalDataFactory::Context&>(ctx).newShaderPipeline
(VS_METAL_YUV, FS_METAL_YUV, YUVVTXFmt, 1, (VS_METAL_YUV, FS_METAL_YUV, nullptr, nullptr, YUVVTXFmt, 1,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha, boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
boo::Primitive::TriStrips, boo::ZTest::None, false, true, false, boo::CullMode::None); boo::Primitive::TriStrips, boo::ZTest::None, false, true, false, boo::CullMode::None);
break; break;
@ -254,7 +253,8 @@ void CMoviePlayer::Initialize()
void CMoviePlayer::Shutdown() void CMoviePlayer::Shutdown()
{ {
GraphicsData.doDestroy(); YUVVTXFmt.reset();
YUVShaderPipeline.reset();
tjDestroy(TjHandle); tjDestroy(TjHandle);
} }
@ -424,18 +424,18 @@ CMoviePlayer::CMoviePlayer(const char* path, float preLoadSeconds, bool loop, bo
xa0_bufferQueue.reserve(xf0_preLoadFrames); xa0_bufferQueue.reserve(xf0_preLoadFrames);
/* All set for GPU resources */ /* All set for GPU resources */
m_token = CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
{ {
m_blockBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(m_viewVertBlock), 1); m_blockBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(m_viewVertBlock), 1);
m_vertBuf = ctx.newDynamicBuffer(boo::BufferUse::Vertex, sizeof(specter::View::TexShaderVert), 4); m_vertBuf = ctx.newDynamicBuffer(boo::BufferUse::Vertex, sizeof(specter::View::TexShaderVert), 4);
boo::IVertexFormat* vtxFmt = YUVVTXFmt; boo::ObjToken<boo::IVertexFormat> vtxFmt = YUVVTXFmt;
if (ctx.bindingNeedsVertexFormat()) if (ctx.bindingNeedsVertexFormat())
{ {
boo::VertexElementDescriptor texvdescs[] = boo::VertexElementDescriptor texvdescs[] =
{ {
{m_vertBuf, nullptr, boo::VertexSemantic::Position4}, {m_vertBuf.get(), nullptr, boo::VertexSemantic::Position4},
{m_vertBuf, nullptr, boo::VertexSemantic::UV4} {m_vertBuf.get(), nullptr, boo::VertexSemantic::UV4}
}; };
vtxFmt = ctx.newVertexFormat(2, texvdescs); vtxFmt = ctx.newVertexFormat(2, texvdescs);
} }
@ -458,11 +458,11 @@ CMoviePlayer::CMoviePlayer(const char* path, float preLoadSeconds, bool loop, bo
set.V = ctx.newDynamicTexture(x6c_videoInfo.width / 2, x6c_videoInfo.height / 2, set.V = ctx.newDynamicTexture(x6c_videoInfo.width / 2, x6c_videoInfo.height / 2,
boo::TextureFormat::I8, boo::TextureClampMode::Repeat); boo::TextureFormat::I8, boo::TextureClampMode::Repeat);
boo::IGraphicsBuffer* bufs[] = {m_blockBuf}; boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {m_blockBuf.get()};
for (int j=0 ; j<2 ; ++j) for (int j=0 ; j<2 ; ++j)
{ {
boo::ITexture* texs[] = {set.Y[j], set.U, set.V}; boo::ObjToken<boo::ITexture> texs[] = {set.Y[j].get(), set.U.get(), set.V.get()};
set.binding[j] = ctx.newShaderDataBinding(YUVShaderPipeline, vtxFmt, m_vertBuf, set.binding[j] = ctx.newShaderDataBinding(YUVShaderPipeline, vtxFmt, m_vertBuf.get(),
nullptr, nullptr, 1, bufs, nullptr, nullptr, nullptr, 1, bufs, nullptr,
3, texs, nullptr, nullptr); 3, texs, nullptr, nullptr);
} }
@ -477,9 +477,9 @@ CMoviePlayer::CMoviePlayer(const char* path, float preLoadSeconds, bool loop, bo
set.V = ctx.newDynamicTexture(x6c_videoInfo.width / 2, x6c_videoInfo.height / 2, set.V = ctx.newDynamicTexture(x6c_videoInfo.width / 2, x6c_videoInfo.height / 2,
boo::TextureFormat::I8, boo::TextureClampMode::Repeat); boo::TextureFormat::I8, boo::TextureClampMode::Repeat);
boo::IGraphicsBuffer* bufs[] = {m_blockBuf}; boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {m_blockBuf.get()};
boo::ITexture* texs[] = {set.Y[0], set.U, set.V}; boo::ObjToken<boo::ITexture> texs[] = {set.Y[0].get(), set.U.get(), set.V.get()};
set.binding[0] = ctx.newShaderDataBinding(YUVShaderPipeline, vtxFmt, m_vertBuf, set.binding[0] = ctx.newShaderDataBinding(YUVShaderPipeline, vtxFmt, m_vertBuf.get(),
nullptr, nullptr, 1, bufs, nullptr, nullptr, nullptr, 1, bufs, nullptr,
3, texs, nullptr, nullptr); 3, texs, nullptr, nullptr);
} }
@ -686,9 +686,9 @@ void CMoviePlayer::DrawFrame()
/* draw appropriate field */ /* draw appropriate field */
CTHPTextureSet& tex = x80_textures[xd0_drawTexSlot]; CTHPTextureSet& tex = x80_textures[xd0_drawTexSlot];
CGraphics::g_BooMainCommandQueue->setShaderDataBinding CGraphics::SetShaderDataBinding
(tex.binding[m_deinterlace ? (xfc_fieldIndex != 0) : 0]); (tex.binding[m_deinterlace ? (xfc_fieldIndex != 0) : 0]);
CGraphics::g_BooMainCommandQueue->draw(0, 4); CGraphics::DrawArray(0, 4);
/* ensure second field is being displayed by VI to signal advance /* ensure second field is being displayed by VI to signal advance
* (faked in urde with continuous xor) */ * (faked in urde with continuous xor) */

View File

@ -83,13 +83,13 @@ private:
struct CTHPTextureSet struct CTHPTextureSet
{ {
boo::ITextureD* Y[2] = {}; boo::ObjToken<boo::ITextureD> Y[2];
boo::ITextureD* U = nullptr; boo::ObjToken<boo::ITextureD> U;
boo::ITextureD* V = nullptr; boo::ObjToken<boo::ITextureD> V;
u32 playedSamples = 0; u32 playedSamples = 0;
u32 audioSamples = 0; u32 audioSamples = 0;
std::unique_ptr<s16[]> audioBuf; std::unique_ptr<s16[]> audioBuf;
boo::IShaderDataBinding* binding[2] = {}; boo::ObjToken<boo::IShaderDataBinding> binding[2];
}; };
std::vector<CTHPTextureSet> x80_textures; std::vector<CTHPTextureSet> x80_textures;
std::unique_ptr<uint8_t[]> x90_requestBuf; std::unique_ptr<uint8_t[]> x90_requestBuf;
@ -116,7 +116,6 @@ private:
u32 xf8_ = 0; u32 xf8_ = 0;
u32 xfc_fieldIndex = 0; u32 xfc_fieldIndex = 0;
boo::GraphicsDataToken m_token;
std::unique_ptr<uint8_t[]> m_yuvBuf; std::unique_ptr<uint8_t[]> m_yuvBuf;
union union
@ -130,8 +129,8 @@ private:
}; };
specter::View::ViewBlock m_viewVertBlock; specter::View::ViewBlock m_viewVertBlock;
boo::IGraphicsBufferD* m_blockBuf; boo::ObjToken<boo::IGraphicsBufferD> m_blockBuf;
boo::IGraphicsBufferD* m_vertBuf; boo::ObjToken<boo::IGraphicsBufferD> m_vertBuf;
specter::View::TexShaderVert m_frame[4]; specter::View::TexShaderVert m_frame[4];

View File

@ -14,7 +14,7 @@ CRainSplashGenerator::CRainSplashGenerator(const zeus::CVector3f& scale, u32 max
x48_24 = false; x48_24 = false;
x48_25_raining = true; x48_25_raining = true;
x0_rainSplashes.reserve(maxSplashes); x0_rainSplashes.reserve(maxSplashes);
m_gfxTok = CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx)
{ {
for (int i=0 ; i<maxSplashes ; ++i) for (int i=0 ; i<maxSplashes ; ++i)
x0_rainSplashes.emplace_back(ctx); x0_rainSplashes.emplace_back(ctx);

View File

@ -58,7 +58,6 @@ class CRainSplashGenerator
u32 x44_genRate; u32 x44_genRate;
bool x48_24 : 1; bool x48_24 : 1;
bool x48_25_raining : 1; bool x48_25_raining : 1;
boo::GraphicsDataToken m_gfxTok;
void UpdateRainSplashRange(CStateManager& mgr, int start, int end, float dt); void UpdateRainSplashRange(CStateManager& mgr, int start, int end, float dt);
void UpdateRainSplashes(CStateManager& mgr, float magnitude, float dt); void UpdateRainSplashes(CStateManager& mgr, float magnitude, float dt);
void DoDraw(const zeus::CTransform& xf) const; void DoDraw(const zeus::CTransform& xf) const;

View File

@ -38,7 +38,7 @@ void CSkinnedModel::Calculate(const CPoseAsTransforms& pose,
{ {
if (morphEffect || g_PointGenFunc) if (morphEffect || g_PointGenFunc)
{ {
boo::IGraphicsBufferD* vertBuf = m_modelInst->UpdateUniformData(drawFlags, nullptr, nullptr); boo::ObjToken<boo::IGraphicsBufferD> vertBuf = m_modelInst->UpdateUniformData(drawFlags, nullptr, nullptr);
x10_skinRules->TransformVerticesCPU(m_vertWorkspace, pose, *x4_model); x10_skinRules->TransformVerticesCPU(m_vertWorkspace, pose, *x4_model);
if (morphEffect) if (morphEffect)
morphEffect->MorphVertices(m_vertWorkspace, morphMagnitudes, x10_skinRules, pose); morphEffect->MorphVertices(m_vertWorkspace, morphMagnitudes, x10_skinRules, pose);

View File

@ -31,9 +31,8 @@ private:
u16 x4_w; u16 x4_w;
u16 x6_h; u16 x6_h;
u32 x8_mips; u32 x8_mips;
boo::GraphicsDataToken m_booToken; boo::ObjToken<boo::ITexture> m_booTex;
boo::ITexture* m_booTex; boo::ObjToken<boo::ITexture> m_paletteTex;
boo::ITexture* m_paletteTex;
std::unique_ptr<u8[]> m_otex; std::unique_ptr<u8[]> m_otex;
EFontType m_ftype = EFontType::None; EFontType m_ftype = EFontType::None;
@ -69,11 +68,11 @@ public:
u16 GetHeight() const {return x6_h;} u16 GetHeight() const {return x6_h;}
u32 GetNumMips() const {return x8_mips;} u32 GetNumMips() const {return x8_mips;}
void Load(int slot, EClampMode clamp) const; void Load(int slot, EClampMode clamp) const;
boo::ITexture* GetBooTexture() const {return m_booTex;} const boo::ObjToken<boo::ITexture>& GetBooTexture() const {return m_booTex;}
boo::ITexture* GetPaletteTexture() const {return m_paletteTex;} const boo::ObjToken<boo::ITexture>& GetPaletteTexture() const {return m_paletteTex;}
std::unique_ptr<u8[]> BuildMemoryCardTex(u32& sizeOut, ETexelFormat& fmtOut, std::unique_ptr<u8[]> BuildMemoryCardTex(u32& sizeOut, ETexelFormat& fmtOut,
std::unique_ptr<u8[]>& paletteOut) const; std::unique_ptr<u8[]>& paletteOut) const;
boo::ITexture* GetFontTexture(EFontType tp); const boo::ObjToken<boo::ITexture>& GetFontTexture(EFontType tp);
}; };
CFactoryFnReturn FTextureFactory(const urde::SObjectTag& tag, CFactoryFnReturn FTextureFactory(const urde::SObjectTag& tag,

View File

@ -112,10 +112,10 @@ void CTexture::BuildI4FromGCN(CInputStream& in)
h /= 2; h /= 2;
} }
m_booToken = CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
{ {
m_booTex = ctx.newStaticTexture(x4_w, x6_h, x8_mips, boo::TextureFormat::RGBA8, m_booTex = ctx.newStaticTexture(x4_w, x6_h, x8_mips, boo::TextureFormat::RGBA8,
boo::TextureClampMode::Repeat, buf.get(), texelCount * 4); boo::TextureClampMode::Repeat, buf.get(), texelCount * 4).get();
return true; return true;
}); });
} }
@ -160,10 +160,10 @@ void CTexture::BuildI8FromGCN(CInputStream& in)
h /= 2; h /= 2;
} }
m_booToken = CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
{ {
m_booTex = ctx.newStaticTexture(x4_w, x6_h, x8_mips, boo::TextureFormat::RGBA8, m_booTex = ctx.newStaticTexture(x4_w, x6_h, x8_mips, boo::TextureFormat::RGBA8,
boo::TextureClampMode::Repeat, buf.get(), texelCount * 4); boo::TextureClampMode::Repeat, buf.get(), texelCount * 4).get();
return true; return true;
}); });
} }
@ -209,10 +209,10 @@ void CTexture::BuildIA4FromGCN(CInputStream& in)
h /= 2; h /= 2;
} }
m_booToken = CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
{ {
m_booTex = ctx.newStaticTexture(x4_w, x6_h, x8_mips, boo::TextureFormat::RGBA8, m_booTex = ctx.newStaticTexture(x4_w, x6_h, x8_mips, boo::TextureFormat::RGBA8,
boo::TextureClampMode::Repeat, buf.get(), texelCount * 4); boo::TextureClampMode::Repeat, buf.get(), texelCount * 4).get();
return true; return true;
}); });
} }
@ -258,10 +258,10 @@ void CTexture::BuildIA8FromGCN(CInputStream& in)
h /= 2; h /= 2;
} }
m_booToken = CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
{ {
m_booTex = ctx.newStaticTexture(x4_w, x6_h, x8_mips, boo::TextureFormat::RGBA8, m_booTex = ctx.newStaticTexture(x4_w, x6_h, x8_mips, boo::TextureFormat::RGBA8,
boo::TextureClampMode::Repeat, buf.get(), texelCount * 4); boo::TextureClampMode::Repeat, buf.get(), texelCount * 4).get();
return true; return true;
}); });
} }
@ -366,10 +366,10 @@ void CTexture::BuildC4FromGCN(CInputStream& in)
h /= 2; h /= 2;
} }
m_booToken = CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
{ {
m_booTex = ctx.newStaticTexture(x4_w, x6_h, x8_mips, boo::TextureFormat::RGBA8, m_booTex = ctx.newStaticTexture(x4_w, x6_h, x8_mips, boo::TextureFormat::RGBA8,
boo::TextureClampMode::Repeat, buf.get(), texelCount * 4); boo::TextureClampMode::Repeat, buf.get(), texelCount * 4).get();
return true; return true;
}); });
} }
@ -410,10 +410,10 @@ void CTexture::BuildC8FromGCN(CInputStream& in)
h /= 2; h /= 2;
} }
m_booToken = CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
{ {
m_booTex = ctx.newStaticTexture(x4_w, x6_h, x8_mips, boo::TextureFormat::RGBA8, m_booTex = ctx.newStaticTexture(x4_w, x6_h, x8_mips, boo::TextureFormat::RGBA8,
boo::TextureClampMode::Repeat, buf.get(), texelCount * 4); boo::TextureClampMode::Repeat, buf.get(), texelCount * 4).get();
return true; return true;
}); });
} }
@ -462,10 +462,10 @@ void CTexture::BuildRGB565FromGCN(CInputStream& in)
h /= 2; h /= 2;
} }
m_booToken = CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
{ {
m_booTex = ctx.newStaticTexture(x4_w, x6_h, x8_mips, boo::TextureFormat::RGBA8, m_booTex = ctx.newStaticTexture(x4_w, x6_h, x8_mips, boo::TextureFormat::RGBA8,
boo::TextureClampMode::Repeat, buf.get(), texelCount * 4); boo::TextureClampMode::Repeat, buf.get(), texelCount * 4).get();
return true; return true;
}); });
} }
@ -519,10 +519,10 @@ void CTexture::BuildRGB5A3FromGCN(CInputStream& in)
h /= 2; h /= 2;
} }
m_booToken = CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
{ {
m_booTex = ctx.newStaticTexture(x4_w, x6_h, x8_mips, boo::TextureFormat::RGBA8, m_booTex = ctx.newStaticTexture(x4_w, x6_h, x8_mips, boo::TextureFormat::RGBA8,
boo::TextureClampMode::Repeat, buf.get(), texelCount * 4); boo::TextureClampMode::Repeat, buf.get(), texelCount * 4).get();
return true; return true;
}); });
} }
@ -576,10 +576,10 @@ void CTexture::BuildRGBA8FromGCN(CInputStream& in)
h /= 2; h /= 2;
} }
m_booToken = CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
{ {
m_booTex = ctx.newStaticTexture(x4_w, x6_h, x8_mips, boo::TextureFormat::RGBA8, m_booTex = ctx.newStaticTexture(x4_w, x6_h, x8_mips, boo::TextureFormat::RGBA8,
boo::TextureClampMode::Repeat, buf.get(), texelCount * 4); boo::TextureClampMode::Repeat, buf.get(), texelCount * 4).get();
return true; return true;
}); });
} }
@ -640,10 +640,10 @@ void CTexture::BuildDXT1FromGCN(CInputStream& in)
h /= 2; h /= 2;
} }
m_booToken = CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
{ {
m_booTex = ctx.newStaticTexture(x4_w, x6_h, x8_mips, boo::TextureFormat::DXT1, m_booTex = ctx.newStaticTexture(x4_w, x6_h, x8_mips, boo::TextureFormat::DXT1,
boo::TextureClampMode::Repeat, buf.get(), blockCount * 8); boo::TextureClampMode::Repeat, buf.get(), blockCount * 8).get();
return true; return true;
}); });
} }
@ -656,10 +656,10 @@ void CTexture::BuildRGBA8(const void* data, size_t length)
Log.report(logvisor::Fatal, "insufficient TXTR length (%" PRISize "/%" PRISize ")", Log.report(logvisor::Fatal, "insufficient TXTR length (%" PRISize "/%" PRISize ")",
length, expectedSize); length, expectedSize);
m_booToken = CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
{ {
m_booTex = ctx.newStaticTexture(x4_w, x6_h, x8_mips, boo::TextureFormat::RGBA8, m_booTex = ctx.newStaticTexture(x4_w, x6_h, x8_mips, boo::TextureFormat::RGBA8,
boo::TextureClampMode::Repeat, data, expectedSize); boo::TextureClampMode::Repeat, data, expectedSize).get();
return true; return true;
}); });
} }
@ -671,15 +671,15 @@ void CTexture::BuildC8(const void* data, size_t length)
Log.report(logvisor::Fatal, "insufficient TXTR length (%" PRISize "/%" PRISize ")", Log.report(logvisor::Fatal, "insufficient TXTR length (%" PRISize "/%" PRISize ")",
length, texelCount); length, texelCount);
m_booToken = CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
{ {
uint32_t nentries = hecl::SBig(*reinterpret_cast<const uint32_t*>(data)); uint32_t nentries = hecl::SBig(*reinterpret_cast<const uint32_t*>(data));
const u8* paletteTexels = reinterpret_cast<const u8*>(data) + 4; const u8* paletteTexels = reinterpret_cast<const u8*>(data) + 4;
const u8* texels = reinterpret_cast<const u8*>(data) + 4 + nentries * 4; const u8* texels = reinterpret_cast<const u8*>(data) + 4 + nentries * 4;
m_paletteTex = ctx.newStaticTexture(nentries, 1, 1, boo::TextureFormat::RGBA8, m_paletteTex = ctx.newStaticTexture(nentries, 1, 1, boo::TextureFormat::RGBA8,
boo::TextureClampMode::Repeat, paletteTexels, nentries * 4); boo::TextureClampMode::Repeat, paletteTexels, nentries * 4).get();
m_booTex = ctx.newStaticTexture(x4_w, x6_h, x8_mips, boo::TextureFormat::I8, m_booTex = ctx.newStaticTexture(x4_w, x6_h, x8_mips, boo::TextureFormat::I8,
boo::TextureClampMode::Repeat, texels, texelCount); boo::TextureClampMode::Repeat, texels, texelCount).get();
return true; return true;
}); });
} }
@ -778,10 +778,10 @@ void CTexture::BuildC8Font(const void* data, EFontType ftype)
h /= 2; h /= 2;
} }
m_booToken = CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
{ {
m_booTex = ctx.newStaticArrayTexture(x4_w, x6_h, layerCount, x8_mips, boo::TextureFormat::RGBA8, m_booTex = ctx.newStaticArrayTexture(x4_w, x6_h, layerCount, x8_mips, boo::TextureFormat::RGBA8,
boo::TextureClampMode::Repeat, buf.get(), texelCount * layerCount * 4); boo::TextureClampMode::Repeat, buf.get(), texelCount * layerCount * 4).get();
return true; return true;
}); });
} }
@ -977,7 +977,7 @@ std::unique_ptr<u8[]> CTexture::BuildMemoryCardTex(u32& sizeOut, ETexelFormat& f
return ret; return ret;
} }
boo::ITexture* CTexture::GetFontTexture(EFontType tp) const boo::ObjToken<boo::ITexture>& CTexture::GetFontTexture(EFontType tp)
{ {
if (m_ftype != tp && x0_fmt == ETexelFormat::C8PC) if (m_ftype != tp && x0_fmt == ETexelFormat::C8PC)
{ {

View File

@ -6,7 +6,7 @@ namespace urde
CAABoxShader::CAABoxShader(bool zOnly) CAABoxShader::CAABoxShader(bool zOnly)
: m_zOnly(zOnly) : m_zOnly(zOnly)
{ {
m_token = CGraphics::g_BooFactory->commitTransaction([&](boo::IGraphicsDataFactory::Context& ctx) CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx)
{ {
m_vbo = ctx.newDynamicBuffer(boo::BufferUse::Vertex, sizeof(zeus::CVector3f), 34); m_vbo = ctx.newDynamicBuffer(boo::BufferUse::Vertex, sizeof(zeus::CVector3f), 34);
m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1); m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1);
@ -69,12 +69,10 @@ void CAABoxShader::draw(const zeus::CColor& color)
m_uniform.m_color = color; m_uniform.m_color = color;
m_uniBuf->load(&m_uniform, sizeof(Uniform)); m_uniBuf->load(&m_uniform, sizeof(Uniform));
CGraphics::g_BooMainCommandQueue->setShaderDataBinding(m_dataBind); CGraphics::SetShaderDataBinding(m_dataBind);
CGraphics::g_BooMainCommandQueue->draw(0, 34); CGraphics::DrawArray(0, 34);
} }
void CAABoxShader::Shutdown() {}
URDE_SPECIALIZE_SHADER(CAABoxShader) URDE_SPECIALIZE_SHADER(CAABoxShader)
} }

View File

@ -21,10 +21,9 @@ class CAABoxShader
zeus::CMatrix4f m_xf; zeus::CMatrix4f m_xf;
zeus::CColor m_color; zeus::CColor m_color;
}; };
boo::GraphicsDataToken m_token; boo::ObjToken<boo::IGraphicsBufferD> m_vbo;
boo::IGraphicsBufferD* m_vbo; boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf;
boo::IGraphicsBufferD* m_uniBuf; boo::ObjToken<boo::IShaderDataBinding> m_dataBind;
boo::IShaderDataBinding* m_dataBind = nullptr;
Uniform m_uniform; Uniform m_uniform;
bool m_zOnly; bool m_zOnly;

View File

@ -44,25 +44,25 @@ BOO_GLSL_BINDING_HEAD
URDE_DECL_SPECIALIZE_SHADER(CAABoxShader) URDE_DECL_SPECIALIZE_SHADER(CAABoxShader)
static boo::IVertexFormat* s_VtxFmt = nullptr; static boo::ObjToken<boo::IVertexFormat> s_VtxFmt;
static boo::IShaderPipeline* s_Pipeline = nullptr; static boo::ObjToken<boo::IShaderPipeline> s_Pipeline;
static boo::IShaderPipeline* s_zOnlyPipeline = nullptr; static boo::ObjToken<boo::IShaderPipeline> s_zOnlyPipeline;
struct CAABoxShaderGLDataBindingFactory : TShader<CAABoxShader>::IDataBindingFactory struct CAABoxShaderGLDataBindingFactory : TShader<CAABoxShader>::IDataBindingFactory
{ {
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
CAABoxShader& filter) CAABoxShader& filter)
{ {
boo::GLDataFactory::Context& cctx = static_cast<boo::GLDataFactory::Context&>(ctx); boo::GLDataFactory::Context& cctx = static_cast<boo::GLDataFactory::Context&>(ctx);
const boo::VertexElementDescriptor VtxVmt[] = const boo::VertexElementDescriptor VtxVmt[] =
{ {
{filter.m_vbo, nullptr, boo::VertexSemantic::Position4}, {filter.m_vbo.get(), nullptr, boo::VertexSemantic::Position4},
}; };
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf}; boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {filter.m_uniBuf.get()};
boo::PipelineStage stages[] = {boo::PipelineStage::Vertex}; boo::PipelineStage stages[] = {boo::PipelineStage::Vertex};
return cctx.newShaderDataBinding(filter.m_zOnly ? s_zOnlyPipeline : s_Pipeline, return cctx.newShaderDataBinding(filter.m_zOnly ? s_zOnlyPipeline : s_Pipeline,
ctx.newVertexFormat(1, VtxVmt), filter.m_vbo, nullptr, nullptr, ctx.newVertexFormat(1, VtxVmt), filter.m_vbo.get(), nullptr, nullptr,
1, bufs, stages, nullptr, nullptr, 0, nullptr, nullptr, nullptr); 1, bufs, stages, nullptr, nullptr, 0, nullptr, nullptr, nullptr);
} }
}; };
@ -70,14 +70,15 @@ struct CAABoxShaderGLDataBindingFactory : TShader<CAABoxShader>::IDataBindingFac
#if BOO_HAS_VULKAN #if BOO_HAS_VULKAN
struct CAABoxShaderVulkanDataBindingFactory : TShader<CAABoxShader>::IDataBindingFactory struct CAABoxShaderVulkanDataBindingFactory : TShader<CAABoxShader>::IDataBindingFactory
{ {
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, boo::ObjToken<boo::IShaderDataBinding>
BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
CAABoxShader& filter) CAABoxShader& filter)
{ {
boo::VulkanDataFactory::Context& cctx = static_cast<boo::VulkanDataFactory::Context&>(ctx); boo::VulkanDataFactory::Context& cctx = static_cast<boo::VulkanDataFactory::Context&>(ctx);
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf}; boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {filter.m_uniBuf.get()};
return cctx.newShaderDataBinding(filter.m_zOnly ? s_zOnlyPipeline : s_Pipeline, s_VtxFmt, return cctx.newShaderDataBinding(filter.m_zOnly ? s_zOnlyPipeline : s_Pipeline, s_VtxFmt,
filter.m_vbo, nullptr, nullptr, 1, bufs, filter.m_vbo.get(), nullptr, nullptr, 1, bufs,
nullptr, nullptr, nullptr, 0, nullptr, nullptr, nullptr); nullptr, nullptr, nullptr, 0, nullptr, nullptr, nullptr);
} }
}; };
@ -95,6 +96,13 @@ TShader<CAABoxShader>::IDataBindingFactory* CAABoxShader::Initialize(boo::GLData
return new CAABoxShaderGLDataBindingFactory; return new CAABoxShaderGLDataBindingFactory;
} }
template <>
void CAABoxShader::Shutdown<boo::GLDataFactory>()
{
s_Pipeline.reset();
s_zOnlyPipeline.reset();
}
#if BOO_HAS_VULKAN #if BOO_HAS_VULKAN
TShader<CAABoxShader>::IDataBindingFactory* CAABoxShader::Initialize(boo::VulkanDataFactory::Context& ctx) TShader<CAABoxShader>::IDataBindingFactory* CAABoxShader::Initialize(boo::VulkanDataFactory::Context& ctx)
{ {
@ -111,6 +119,14 @@ TShader<CAABoxShader>::IDataBindingFactory* CAABoxShader::Initialize(boo::Vulkan
boo::ZTest::LEqual, true, false, false, boo::CullMode::None); boo::ZTest::LEqual, true, false, false, boo::CullMode::None);
return new CAABoxShaderVulkanDataBindingFactory; return new CAABoxShaderVulkanDataBindingFactory;
} }
template <>
void CAABoxShader::Shutdown<boo::VulkanDataFactory>()
{
s_VtxFmt.reset();
s_Pipeline.reset();
s_zOnlyPipeline.reset();
}
#endif #endif
} }

View File

@ -44,20 +44,21 @@ static const char* FS =
URDE_DECL_SPECIALIZE_SHADER(CAABoxShader) URDE_DECL_SPECIALIZE_SHADER(CAABoxShader)
static boo::IVertexFormat* s_VtxFmt = nullptr; static boo::ObjToken<boo::IVertexFormat> s_VtxFmt;
static boo::IShaderPipeline* s_Pipeline = nullptr; static boo::ObjToken<boo::IShaderPipeline> s_Pipeline;
static boo::IShaderPipeline* s_zOnlyPipeline = nullptr; static boo::ObjToken<boo::IShaderPipeline> s_zOnlyPipeline;
struct CAABoxShaderD3DDataBindingFactory : TShader<CAABoxShader>::IDataBindingFactory struct CAABoxShaderD3DDataBindingFactory : TShader<CAABoxShader>::IDataBindingFactory
{ {
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, boo::ObjToken<boo::IShaderDataBinding>
BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
CAABoxShader& filter) CAABoxShader& filter)
{ {
boo::ID3DDataFactory::Context& cctx = static_cast<boo::ID3DDataFactory::Context&>(ctx); boo::ID3DDataFactory::Context& cctx = static_cast<boo::ID3DDataFactory::Context&>(ctx);
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf}; boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {filter.m_uniBuf.get()};
return cctx.newShaderDataBinding(filter.m_zOnly ? s_zOnlyPipeline : s_Pipeline, s_VtxFmt, return cctx.newShaderDataBinding(filter.m_zOnly ? s_zOnlyPipeline : s_Pipeline, s_VtxFmt,
filter.m_vbo, nullptr, nullptr, 1, bufs, filter.m_vbo.get(), nullptr, nullptr, 1, bufs,
nullptr, nullptr, nullptr, 0, nullptr, nullptr, nullptr); nullptr, nullptr, nullptr, 0, nullptr, nullptr, nullptr);
} }
}; };
@ -78,4 +79,12 @@ TShader<CAABoxShader>::IDataBindingFactory* CAABoxShader::Initialize(boo::ID3DDa
return new CAABoxShaderD3DDataBindingFactory; return new CAABoxShaderD3DDataBindingFactory;
} }
template <>
void CAABoxShader::Shutdown<boo::ID3DDataFactory>()
{
s_VtxFmt.reset();
s_Pipeline.reset();
s_zOnlyPipeline.reset();
}
} }

View File

@ -48,20 +48,20 @@ static const char* FS =
URDE_DECL_SPECIALIZE_SHADER(CAABoxShader) URDE_DECL_SPECIALIZE_SHADER(CAABoxShader)
static boo::IVertexFormat* s_VtxFmt = nullptr; static boo::ObjToken<boo::IVertexFormat> s_VtxFmt;
static boo::IShaderPipeline* s_Pipeline = nullptr; static boo::ObjToken<boo::IShaderPipeline> s_Pipeline;
static boo::IShaderPipeline* s_zOnlyPipeline = nullptr; static boo::ObjToken<boo::IShaderPipeline> s_zOnlyPipeline;
struct CAABoxShaderMetalDataBindingFactory : TShader<CAABoxShader>::IDataBindingFactory struct CAABoxShaderMetalDataBindingFactory : TShader<CAABoxShader>::IDataBindingFactory
{ {
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
CAABoxShader& filter) CAABoxShader& filter)
{ {
boo::MetalDataFactory::Context& cctx = static_cast<boo::MetalDataFactory::Context&>(ctx); boo::MetalDataFactory::Context& cctx = static_cast<boo::MetalDataFactory::Context&>(ctx);
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf}; boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {filter.m_uniBuf.get()};
return cctx.newShaderDataBinding(filter.m_zOnly ? s_zOnlyPipeline : s_Pipeline, s_VtxFmt, return cctx.newShaderDataBinding(filter.m_zOnly ? s_zOnlyPipeline : s_Pipeline, s_VtxFmt,
filter.m_vbo, nullptr, nullptr, 1, bufs, filter.m_vbo.get(), nullptr, nullptr, 1, bufs,
nullptr, nullptr, nullptr, 0, nullptr, nullptr, nullptr); nullptr, nullptr, nullptr, 0, nullptr, nullptr, nullptr);
} }
}; };
@ -73,13 +73,23 @@ TShader<CAABoxShader>::IDataBindingFactory* CAABoxShader::Initialize(boo::MetalD
{nullptr, nullptr, boo::VertexSemantic::Position4}, {nullptr, nullptr, boo::VertexSemantic::Position4},
}; };
s_VtxFmt = ctx.newVertexFormat(1, VtxVmt); s_VtxFmt = ctx.newVertexFormat(1, VtxVmt);
s_Pipeline = ctx.newShaderPipeline(VS, FS, s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha, s_Pipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr,
s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips,
boo::ZTest::LEqual, true, true, false, boo::CullMode::None); boo::ZTest::LEqual, true, true, false, boo::CullMode::None);
s_zOnlyPipeline = ctx.newShaderPipeline(VS, FS, s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha, s_zOnlyPipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr,
s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips,
boo::ZTest::LEqual, true, false, false, boo::CullMode::None); boo::ZTest::LEqual, true, false, false, boo::CullMode::None);
return new CAABoxShaderMetalDataBindingFactory; return new CAABoxShaderMetalDataBindingFactory;
} }
template <>
void CAABoxShader::Shutdown<boo::MetalDataFactory>()
{
s_VtxFmt.reset();
s_Pipeline.reset();
s_zOnlyPipeline.reset();
}
} }

View File

@ -5,7 +5,7 @@ namespace urde
CCameraBlurFilter::CCameraBlurFilter() CCameraBlurFilter::CCameraBlurFilter()
{ {
m_token = CGraphics::g_BooFactory->commitTransaction([&](boo::IGraphicsDataFactory::Context& ctx) -> bool CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
{ {
m_vbo = ctx.newDynamicBuffer(boo::BufferUse::Vertex, 32, 4); m_vbo = ctx.newDynamicBuffer(boo::BufferUse::Vertex, 32, 4);
m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1); m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1);
@ -55,12 +55,10 @@ void CCameraBlurFilter::draw(float amount)
m_uniform.m_opacity = std::min(amount / 2.f, 1.f); m_uniform.m_opacity = std::min(amount / 2.f, 1.f);
m_uniBuf->load(&m_uniform, sizeof(m_uniform)); m_uniBuf->load(&m_uniform, sizeof(m_uniform));
CGraphics::g_BooMainCommandQueue->setShaderDataBinding(m_dataBind); CGraphics::SetShaderDataBinding(m_dataBind);
CGraphics::g_BooMainCommandQueue->draw(0, 4); CGraphics::DrawArray(0, 4);
} }
void CCameraBlurFilter::Shutdown() {}
URDE_SPECIALIZE_SHADER(CCameraBlurFilter) URDE_SPECIALIZE_SHADER(CCameraBlurFilter)
} }

View File

@ -26,10 +26,9 @@ class CCameraBlurFilter
zeus::CVector4f m_uv[6]; zeus::CVector4f m_uv[6];
float m_opacity = 1.f; float m_opacity = 1.f;
}; };
boo::GraphicsDataToken m_token; boo::ObjToken<boo::IGraphicsBufferD> m_vbo;
boo::IGraphicsBufferD* m_vbo; boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf;
boo::IGraphicsBufferD* m_uniBuf; boo::ObjToken<boo::IShaderDataBinding> m_dataBind;
boo::IShaderDataBinding* m_dataBind = nullptr;
Uniform m_uniform; Uniform m_uniform;
public: public:

View File

@ -79,26 +79,26 @@ BOO_GLSL_BINDING_HEAD
URDE_DECL_SPECIALIZE_SHADER(CCameraBlurFilter) URDE_DECL_SPECIALIZE_SHADER(CCameraBlurFilter)
static boo::IVertexFormat* s_VtxFmt = nullptr; static boo::ObjToken<boo::IVertexFormat> s_VtxFmt;
static boo::IShaderPipeline* s_Pipeline = nullptr; static boo::ObjToken<boo::IShaderPipeline> s_Pipeline;
struct CCameraBlurFilterGLDataBindingFactory : TShader<CCameraBlurFilter>::IDataBindingFactory struct CCameraBlurFilterGLDataBindingFactory : TShader<CCameraBlurFilter>::IDataBindingFactory
{ {
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
CCameraBlurFilter& filter) CCameraBlurFilter& filter)
{ {
boo::GLDataFactory::Context& cctx = static_cast<boo::GLDataFactory::Context&>(ctx); boo::GLDataFactory::Context& cctx = static_cast<boo::GLDataFactory::Context&>(ctx);
const boo::VertexElementDescriptor VtxVmt[] = const boo::VertexElementDescriptor VtxVmt[] =
{ {
{filter.m_vbo, nullptr, boo::VertexSemantic::Position4}, {filter.m_vbo.get(), nullptr, boo::VertexSemantic::Position4},
{filter.m_vbo, nullptr, boo::VertexSemantic::UV4} {filter.m_vbo.get(), nullptr, boo::VertexSemantic::UV4}
}; };
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf}; boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {filter.m_uniBuf.get()};
boo::PipelineStage stages[] = {boo::PipelineStage::Vertex}; boo::PipelineStage stages[] = {boo::PipelineStage::Vertex};
boo::ITexture* texs[] = {CGraphics::g_SpareTexture}; boo::ObjToken<boo::ITexture> texs[] = {CGraphics::g_SpareTexture.get()};
return cctx.newShaderDataBinding(s_Pipeline, return cctx.newShaderDataBinding(s_Pipeline,
ctx.newVertexFormat(2, VtxVmt), filter.m_vbo, nullptr, nullptr, ctx.newVertexFormat(2, VtxVmt), filter.m_vbo.get(), nullptr, nullptr,
1, bufs, stages, nullptr, nullptr, 1, texs, nullptr, nullptr); 1, bufs, stages, nullptr, nullptr, 1, texs, nullptr, nullptr);
} }
}; };
@ -106,15 +106,16 @@ struct CCameraBlurFilterGLDataBindingFactory : TShader<CCameraBlurFilter>::IData
#if BOO_HAS_VULKAN #if BOO_HAS_VULKAN
struct CCameraBlurFilterVulkanDataBindingFactory : TShader<CCameraBlurFilter>::IDataBindingFactory struct CCameraBlurFilterVulkanDataBindingFactory : TShader<CCameraBlurFilter>::IDataBindingFactory
{ {
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, boo::ObjToken<boo::IShaderDataBinding>
BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
CCameraBlurFilter& filter) CCameraBlurFilter& filter)
{ {
boo::VulkanDataFactory::Context& cctx = static_cast<boo::VulkanDataFactory::Context&>(ctx); boo::VulkanDataFactory::Context& cctx = static_cast<boo::VulkanDataFactory::Context&>(ctx);
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf}; boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {filter.m_uniBuf.get()};
boo::ITexture* texs[] = {CGraphics::g_SpareTexture}; boo::ObjToken<boo::ITexture> texs[] = {CGraphics::g_SpareTexture.get()};
return cctx.newShaderDataBinding(s_Pipeline, s_VtxFmt, return cctx.newShaderDataBinding(s_Pipeline, s_VtxFmt,
filter.m_vbo, nullptr, nullptr, 1, bufs, filter.m_vbo.get(), nullptr, nullptr, 1, bufs,
nullptr, nullptr, nullptr, 1, texs, nullptr, nullptr); nullptr, nullptr, nullptr, 1, texs, nullptr, nullptr);
} }
}; };
@ -130,6 +131,12 @@ TShader<CCameraBlurFilter>::IDataBindingFactory* CCameraBlurFilter::Initialize(b
return new CCameraBlurFilterGLDataBindingFactory; return new CCameraBlurFilterGLDataBindingFactory;
} }
template <>
void CCameraBlurFilter::Shutdown<boo::GLDataFactory>()
{
s_Pipeline.reset();
}
#if BOO_HAS_VULKAN #if BOO_HAS_VULKAN
TShader<CCameraBlurFilter>::IDataBindingFactory* CCameraBlurFilter::Initialize(boo::VulkanDataFactory::Context& ctx) TShader<CCameraBlurFilter>::IDataBindingFactory* CCameraBlurFilter::Initialize(boo::VulkanDataFactory::Context& ctx)
{ {
@ -144,6 +151,13 @@ TShader<CCameraBlurFilter>::IDataBindingFactory* CCameraBlurFilter::Initialize(b
boo::ZTest::None, false, true, false, boo::CullMode::None); boo::ZTest::None, false, true, false, boo::CullMode::None);
return new CCameraBlurFilterVulkanDataBindingFactory; return new CCameraBlurFilterVulkanDataBindingFactory;
} }
template <>
void CCameraBlurFilter::Shutdown<boo::VulkanDataFactory>()
{
s_VtxFmt.reset();
s_Pipeline.reset();
}
#endif #endif
} }

View File

@ -87,20 +87,21 @@ static const char* FS =
URDE_DECL_SPECIALIZE_SHADER(CCameraBlurFilter) URDE_DECL_SPECIALIZE_SHADER(CCameraBlurFilter)
static boo::IVertexFormat* s_VtxFmt = nullptr; static boo::ObjToken<boo::IVertexFormat> s_VtxFmt;
static boo::IShaderPipeline* s_Pipeline = nullptr; static boo::ObjToken<boo::IShaderPipeline> s_Pipeline;
struct CCameraBlurFilterD3DDataBindingFactory : TShader<CCameraBlurFilter>::IDataBindingFactory struct CCameraBlurFilterD3DDataBindingFactory : TShader<CCameraBlurFilter>::IDataBindingFactory
{ {
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, boo::ObjToken<boo::IShaderDataBinding>
BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
CCameraBlurFilter& filter) CCameraBlurFilter& filter)
{ {
boo::ID3DDataFactory::Context& cctx = static_cast<boo::ID3DDataFactory::Context&>(ctx); boo::ID3DDataFactory::Context& cctx = static_cast<boo::ID3DDataFactory::Context&>(ctx);
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf}; boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {filter.m_uniBuf.get()};
boo::ITexture* texs[] = {CGraphics::g_SpareTexture}; boo::ObjToken<boo::ITexture> texs[] = {CGraphics::g_SpareTexture.get()};
return cctx.newShaderDataBinding(s_Pipeline, s_VtxFmt, return cctx.newShaderDataBinding(s_Pipeline, s_VtxFmt,
filter.m_vbo, nullptr, nullptr, 1, bufs, filter.m_vbo.get(), nullptr, nullptr, 1, bufs,
nullptr, nullptr, nullptr, 1, texs, nullptr, nullptr); nullptr, nullptr, nullptr, 1, texs, nullptr, nullptr);
} }
}; };
@ -120,4 +121,11 @@ TShader<CCameraBlurFilter>::IDataBindingFactory* CCameraBlurFilter::Initialize(b
return new CCameraBlurFilterD3DDataBindingFactory; return new CCameraBlurFilterD3DDataBindingFactory;
} }
template <>
void CCameraBlurFilter::Shutdown<boo::ID3DDataFactory>()
{
s_VtxFmt.reset();
s_Pipeline.reset();
}
} }

View File

@ -90,20 +90,20 @@ static const char* FS =
URDE_DECL_SPECIALIZE_SHADER(CCameraBlurFilter) URDE_DECL_SPECIALIZE_SHADER(CCameraBlurFilter)
static boo::IVertexFormat* s_VtxFmt = nullptr; static boo::ObjToken<boo::IVertexFormat> s_VtxFmt;
static boo::IShaderPipeline* s_Pipeline = nullptr; static boo::ObjToken<boo::IShaderPipeline> s_Pipeline;
struct CCameraBlurFilterMetalDataBindingFactory : TShader<CCameraBlurFilter>::IDataBindingFactory struct CCameraBlurFilterMetalDataBindingFactory : TShader<CCameraBlurFilter>::IDataBindingFactory
{ {
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
CCameraBlurFilter& filter) CCameraBlurFilter& filter)
{ {
boo::MetalDataFactory::Context& cctx = static_cast<boo::MetalDataFactory::Context&>(ctx); boo::MetalDataFactory::Context& cctx = static_cast<boo::MetalDataFactory::Context&>(ctx);
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf}; boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {filter.m_uniBuf.get()};
boo::ITexture* texs[] = {CGraphics::g_SpareTexture}; boo::ObjToken<boo::ITexture> texs[] = {CGraphics::g_SpareTexture.get()};
return cctx.newShaderDataBinding(s_Pipeline, s_VtxFmt, return cctx.newShaderDataBinding(s_Pipeline, s_VtxFmt,
filter.m_vbo, nullptr, nullptr, 1, bufs, filter.m_vbo.get(), nullptr, nullptr, 1, bufs,
nullptr, nullptr, nullptr, 1, texs, nullptr, nullptr); nullptr, nullptr, nullptr, 1, texs, nullptr, nullptr);
} }
}; };
@ -116,10 +116,18 @@ TShader<CCameraBlurFilter>::IDataBindingFactory* CCameraBlurFilter::Initialize(b
{nullptr, nullptr, boo::VertexSemantic::UV4} {nullptr, nullptr, boo::VertexSemantic::UV4}
}; };
s_VtxFmt = ctx.newVertexFormat(2, VtxVmt); s_VtxFmt = ctx.newVertexFormat(2, VtxVmt);
s_Pipeline = ctx.newShaderPipeline(VS, FS, s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha, s_Pipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr,
s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips,
boo::ZTest::None, false, true, true, boo::CullMode::None); boo::ZTest::None, false, true, true, boo::CullMode::None);
return new CCameraBlurFilterMetalDataBindingFactory; return new CCameraBlurFilterMetalDataBindingFactory;
} }
template <>
void CCameraBlurFilter::Shutdown<boo::MetalDataFactory>()
{
s_VtxFmt.reset();
s_Pipeline.reset();
}
} }

View File

@ -5,7 +5,7 @@ namespace urde
CColoredQuadFilter::CColoredQuadFilter(EFilterType type) CColoredQuadFilter::CColoredQuadFilter(EFilterType type)
{ {
m_token = CGraphics::g_BooFactory->commitTransaction([&](boo::IGraphicsDataFactory::Context& ctx) -> bool CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
{ {
struct Vert struct Vert
{ {
@ -88,8 +88,6 @@ void CWideScreenFilter::SetViewportToFull()
CGraphics::g_BooMainCommandQueue->setViewport(rect); CGraphics::g_BooMainCommandQueue->setViewport(rect);
} }
void CColoredQuadFilter::Shutdown() {}
const zeus::CRectangle CColoredQuadFilter::DefaultRect = {0.f, 0.f, 1.f, 1.f}; const zeus::CRectangle CColoredQuadFilter::DefaultRect = {0.f, 0.f, 1.f, 1.f};
URDE_SPECIALIZE_MULTI_BLEND_SHADER(CColoredQuadFilter) URDE_SPECIALIZE_MULTI_BLEND_SHADER(CColoredQuadFilter)

View File

@ -22,10 +22,9 @@ class CColoredQuadFilter
zeus::CMatrix4f m_matrix; zeus::CMatrix4f m_matrix;
zeus::CColor m_color; zeus::CColor m_color;
}; };
boo::GraphicsDataToken m_token; boo::ObjToken<boo::IGraphicsBufferS> m_vbo;
boo::IGraphicsBufferS* m_vbo; boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf;
boo::IGraphicsBufferD* m_uniBuf; boo::ObjToken<boo::IShaderDataBinding> m_dataBind;
boo::IShaderDataBinding* m_dataBind = nullptr;
Uniform m_uniform; Uniform m_uniform;
public: public:

View File

@ -43,12 +43,12 @@ BOO_GLSL_BINDING_HEAD
URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(CColoredQuadFilter) URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(CColoredQuadFilter)
static boo::IVertexFormat* s_VtxFmt = nullptr; static boo::ObjToken<boo::IVertexFormat> s_VtxFmt;
static boo::IShaderPipeline* s_AlphaPipeline = nullptr; static boo::ObjToken<boo::IShaderPipeline> s_AlphaPipeline;
static boo::IShaderPipeline* s_AddPipeline = nullptr; static boo::ObjToken<boo::IShaderPipeline> s_AddPipeline;
static boo::IShaderPipeline* s_MultPipeline = nullptr; static boo::ObjToken<boo::IShaderPipeline> s_MultPipeline;
static boo::IShaderPipeline* SelectPipeline(EFilterType type) static boo::ObjToken<boo::IShaderPipeline> SelectPipeline(EFilterType type)
{ {
switch (type) switch (type)
{ {
@ -59,26 +59,25 @@ static boo::IShaderPipeline* SelectPipeline(EFilterType type)
case EFilterType::Multiply: case EFilterType::Multiply:
return s_MultPipeline; return s_MultPipeline;
default: default:
return nullptr; return {};
} }
} }
struct CColoredQuadFilterGLDataBindingFactory : TMultiBlendShader<CColoredQuadFilter>::IDataBindingFactory struct CColoredQuadFilterGLDataBindingFactory : TMultiBlendShader<CColoredQuadFilter>::IDataBindingFactory
{ {
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
EFilterType type, EFilterType type, CColoredQuadFilter& filter)
CColoredQuadFilter& filter)
{ {
boo::GLDataFactory::Context& cctx = static_cast<boo::GLDataFactory::Context&>(ctx); boo::GLDataFactory::Context& cctx = static_cast<boo::GLDataFactory::Context&>(ctx);
const boo::VertexElementDescriptor VtxVmt[] = const boo::VertexElementDescriptor VtxVmt[] =
{ {
{filter.m_vbo, nullptr, boo::VertexSemantic::Position4} {filter.m_vbo.get(), nullptr, boo::VertexSemantic::Position4}
}; };
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf}; boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {filter.m_uniBuf.get()};
boo::PipelineStage stages[] = {boo::PipelineStage::Vertex}; boo::PipelineStage stages[] = {boo::PipelineStage::Vertex};
return cctx.newShaderDataBinding(SelectPipeline(type), return cctx.newShaderDataBinding(SelectPipeline(type),
ctx.newVertexFormat(1, VtxVmt), filter.m_vbo, nullptr, nullptr, ctx.newVertexFormat(1, VtxVmt), filter.m_vbo.get(), nullptr, nullptr,
1, bufs, stages, nullptr, nullptr, 0, nullptr, nullptr, nullptr); 1, bufs, stages, nullptr, nullptr, 0, nullptr, nullptr, nullptr);
} }
}; };
@ -86,15 +85,15 @@ struct CColoredQuadFilterGLDataBindingFactory : TMultiBlendShader<CColoredQuadFi
#if BOO_HAS_VULKAN #if BOO_HAS_VULKAN
struct CColoredQuadFilterVulkanDataBindingFactory : TMultiBlendShader<CColoredQuadFilter>::IDataBindingFactory struct CColoredQuadFilterVulkanDataBindingFactory : TMultiBlendShader<CColoredQuadFilter>::IDataBindingFactory
{ {
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, boo::ObjToken<boo::IShaderDataBinding>
EFilterType type, BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
CColoredQuadFilter& filter) EFilterType type, CColoredQuadFilter& filter)
{ {
boo::VulkanDataFactory::Context& cctx = static_cast<boo::VulkanDataFactory::Context&>(ctx); boo::VulkanDataFactory::Context& cctx = static_cast<boo::VulkanDataFactory::Context&>(ctx);
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf}; boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {filter.m_uniBuf.get()};
return cctx.newShaderDataBinding(SelectPipeline(type), s_VtxFmt, return cctx.newShaderDataBinding(SelectPipeline(type), s_VtxFmt,
filter.m_vbo, nullptr, nullptr, 1, bufs, filter.m_vbo.get(), nullptr, nullptr, 1, bufs,
nullptr, nullptr, nullptr, 0, nullptr, nullptr, nullptr); nullptr, nullptr, nullptr, 0, nullptr, nullptr, nullptr);
} }
}; };
@ -116,6 +115,14 @@ CColoredQuadFilter::Initialize(boo::GLDataFactory::Context& ctx)
return new CColoredQuadFilterGLDataBindingFactory; return new CColoredQuadFilterGLDataBindingFactory;
} }
template <>
void CColoredQuadFilter::Shutdown<boo::GLDataFactory>()
{
s_AlphaPipeline.reset();
s_AddPipeline.reset();
s_MultPipeline.reset();
}
#if BOO_HAS_VULKAN #if BOO_HAS_VULKAN
TMultiBlendShader<CColoredQuadFilter>::IDataBindingFactory* TMultiBlendShader<CColoredQuadFilter>::IDataBindingFactory*
CColoredQuadFilter::Initialize(boo::VulkanDataFactory::Context& ctx) CColoredQuadFilter::Initialize(boo::VulkanDataFactory::Context& ctx)
@ -136,6 +143,15 @@ CColoredQuadFilter::Initialize(boo::VulkanDataFactory::Context& ctx)
boo::ZTest::None, false, true, false, boo::CullMode::None); boo::ZTest::None, false, true, false, boo::CullMode::None);
return new CColoredQuadFilterVulkanDataBindingFactory; return new CColoredQuadFilterVulkanDataBindingFactory;
} }
template <>
void CColoredQuadFilter::Shutdown<boo::VulkanDataFactory>()
{
s_VtxFmt.reset();
s_AlphaPipeline.reset();
s_AddPipeline.reset();
s_MultPipeline.reset();
}
#endif #endif
} }

View File

@ -43,12 +43,12 @@ static const char* FS =
URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(CColoredQuadFilter) URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(CColoredQuadFilter)
static boo::IVertexFormat* s_VtxFmt = nullptr; static boo::ObjToken<boo::IVertexFormat> s_VtxFmt;
static boo::IShaderPipeline* s_AlphaPipeline = nullptr; static boo::ObjToken<boo::IShaderPipeline> s_AlphaPipeline;
static boo::IShaderPipeline* s_AddPipeline = nullptr; static boo::ObjToken<boo::IShaderPipeline> s_AddPipeline;
static boo::IShaderPipeline* s_MultPipeline = nullptr; static boo::ObjToken<boo::IShaderPipeline> s_MultPipeline;
static boo::IShaderPipeline* SelectPipeline(EFilterType type) static boo::ObjToken<boo::IShaderPipeline> SelectPipeline(EFilterType type)
{ {
switch (type) switch (type)
{ {
@ -59,21 +59,21 @@ static boo::IShaderPipeline* SelectPipeline(EFilterType type)
case EFilterType::Multiply: case EFilterType::Multiply:
return s_MultPipeline; return s_MultPipeline;
default: default:
return nullptr; return {};
} }
} }
struct CColoredQuadFilterD3DDataBindingFactory : TMultiBlendShader<CColoredQuadFilter>::IDataBindingFactory struct CColoredQuadFilterD3DDataBindingFactory : TMultiBlendShader<CColoredQuadFilter>::IDataBindingFactory
{ {
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, boo::ObjToken<boo::IShaderDataBinding>
EFilterType type, BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
CColoredQuadFilter& filter) EFilterType type, CColoredQuadFilter& filter)
{ {
boo::ID3DDataFactory::Context& cctx = static_cast<boo::ID3DDataFactory::Context&>(ctx); boo::ID3DDataFactory::Context& cctx = static_cast<boo::ID3DDataFactory::Context&>(ctx);
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf}; boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {filter.m_uniBuf.get()};
return cctx.newShaderDataBinding(SelectPipeline(type), s_VtxFmt, return cctx.newShaderDataBinding(SelectPipeline(type), s_VtxFmt,
filter.m_vbo, nullptr, nullptr, 1, bufs, filter.m_vbo.get(), nullptr, nullptr, 1, bufs,
nullptr, nullptr, nullptr, 0, nullptr, nullptr, nullptr); nullptr, nullptr, nullptr, 0, nullptr, nullptr, nullptr);
} }
}; };
@ -101,4 +101,13 @@ CColoredQuadFilter::Initialize(boo::ID3DDataFactory::Context& ctx)
return new CColoredQuadFilterD3DDataBindingFactory; return new CColoredQuadFilterD3DDataBindingFactory;
} }
template <>
void CColoredQuadFilter::Shutdown<boo::ID3DDataFactory>()
{
s_VtxFmt.reset();
s_AlphaPipeline.reset();
s_AddPipeline.reset();
s_MultPipeline.reset();
}
} }

View File

@ -47,12 +47,12 @@ static const char* FS =
URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(CColoredQuadFilter) URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(CColoredQuadFilter)
static boo::IVertexFormat* s_VtxFmt = nullptr; static boo::ObjToken<boo::IVertexFormat> s_VtxFmt;
static boo::IShaderPipeline* s_AlphaPipeline = nullptr; static boo::ObjToken<boo::IShaderPipeline> s_AlphaPipeline;
static boo::IShaderPipeline* s_AddPipeline = nullptr; static boo::ObjToken<boo::IShaderPipeline> s_AddPipeline;
static boo::IShaderPipeline* s_MultPipeline = nullptr; static boo::ObjToken<boo::IShaderPipeline> s_MultPipeline;
static boo::IShaderPipeline* SelectPipeline(EFilterType type) static boo::ObjToken<boo::IShaderPipeline> SelectPipeline(EFilterType type)
{ {
switch (type) switch (type)
{ {
@ -63,21 +63,20 @@ static boo::IShaderPipeline* SelectPipeline(EFilterType type)
case EFilterType::Multiply: case EFilterType::Multiply:
return s_MultPipeline; return s_MultPipeline;
default: default:
return nullptr; return {};
} }
} }
struct CColoredQuadFilterMetalDataBindingFactory : TMultiBlendShader<CColoredQuadFilter>::IDataBindingFactory struct CColoredQuadFilterMetalDataBindingFactory : TMultiBlendShader<CColoredQuadFilter>::IDataBindingFactory
{ {
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
EFilterType type, EFilterType type, CColoredQuadFilter& filter)
CColoredQuadFilter& filter)
{ {
boo::MetalDataFactory::Context& cctx = static_cast<boo::MetalDataFactory::Context&>(ctx); boo::MetalDataFactory::Context& cctx = static_cast<boo::MetalDataFactory::Context&>(ctx);
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf}; boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {filter.m_uniBuf.get()};
return cctx.newShaderDataBinding(SelectPipeline(type), s_VtxFmt, return cctx.newShaderDataBinding(SelectPipeline(type), s_VtxFmt,
filter.m_vbo, nullptr, nullptr, 1, bufs, filter.m_vbo.get(), nullptr, nullptr, 1, bufs,
nullptr, nullptr, nullptr, 0, nullptr, nullptr, nullptr); nullptr, nullptr, nullptr, 0, nullptr, nullptr, nullptr);
} }
}; };
@ -90,16 +89,28 @@ CColoredQuadFilter::Initialize(boo::MetalDataFactory::Context& ctx)
{nullptr, nullptr, boo::VertexSemantic::Position4} {nullptr, nullptr, boo::VertexSemantic::Position4}
}; };
s_VtxFmt = ctx.newVertexFormat(1, VtxVmt); s_VtxFmt = ctx.newVertexFormat(1, VtxVmt);
s_AlphaPipeline = ctx.newShaderPipeline(VS, FS, s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha, s_AlphaPipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr,
s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips,
boo::ZTest::None, false, true, true, boo::CullMode::None); boo::ZTest::None, false, true, true, boo::CullMode::None);
s_AddPipeline = ctx.newShaderPipeline(VS, FS, s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha, s_AddPipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr,
s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::One, boo::Primitive::TriStrips, boo::BlendFactor::One, boo::Primitive::TriStrips,
boo::ZTest::None, false, true, true, boo::CullMode::None); boo::ZTest::None, false, true, true, boo::CullMode::None);
s_MultPipeline = ctx.newShaderPipeline(VS, FS, s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcColor, s_MultPipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr,
s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcColor,
boo::BlendFactor::DstColor, boo::Primitive::TriStrips, boo::BlendFactor::DstColor, boo::Primitive::TriStrips,
boo::ZTest::None, false, true, true, boo::CullMode::None); boo::ZTest::None, false, true, true, boo::CullMode::None);
return new CColoredQuadFilterMetalDataBindingFactory; return new CColoredQuadFilterMetalDataBindingFactory;
} }
template <>
void CColoredQuadFilter::Shutdown<boo::MetalDataFactory>()
{
s_VtxFmt.reset();
s_AlphaPipeline.reset();
s_AddPipeline.reset();
s_MultPipeline.reset();
}
} }

View File

@ -4,37 +4,37 @@
namespace urde namespace urde
{ {
boo::IShaderPipeline* CElementGenShaders::m_texZTestZWrite = nullptr; boo::ObjToken<boo::IShaderPipeline> CElementGenShaders::m_texZTestZWrite;
boo::IShaderPipeline* CElementGenShaders::m_texNoZTestZWrite = nullptr; boo::ObjToken<boo::IShaderPipeline> CElementGenShaders::m_texNoZTestZWrite;
boo::IShaderPipeline* CElementGenShaders::m_texZTestNoZWrite = nullptr; boo::ObjToken<boo::IShaderPipeline> CElementGenShaders::m_texZTestNoZWrite;
boo::IShaderPipeline* CElementGenShaders::m_texNoZTestNoZWrite = nullptr; boo::ObjToken<boo::IShaderPipeline> CElementGenShaders::m_texNoZTestNoZWrite;
boo::IShaderPipeline* CElementGenShaders::m_texAdditiveZTest = nullptr; boo::ObjToken<boo::IShaderPipeline> CElementGenShaders::m_texAdditiveZTest;
boo::IShaderPipeline* CElementGenShaders::m_texAdditiveNoZTest = nullptr; boo::ObjToken<boo::IShaderPipeline> CElementGenShaders::m_texAdditiveNoZTest;
boo::IShaderPipeline* CElementGenShaders::m_texRedToAlphaZTest = nullptr; boo::ObjToken<boo::IShaderPipeline> CElementGenShaders::m_texRedToAlphaZTest;
boo::IShaderPipeline* CElementGenShaders::m_texRedToAlphaNoZTest = nullptr; boo::ObjToken<boo::IShaderPipeline> CElementGenShaders::m_texRedToAlphaNoZTest;
boo::IShaderPipeline* CElementGenShaders::m_texZTestNoZWriteSub = nullptr; boo::ObjToken<boo::IShaderPipeline> CElementGenShaders::m_texZTestNoZWriteSub;
boo::IShaderPipeline* CElementGenShaders::m_texNoZTestNoZWriteSub = nullptr; boo::ObjToken<boo::IShaderPipeline> CElementGenShaders::m_texNoZTestNoZWriteSub;
boo::IShaderPipeline* CElementGenShaders::m_texRedToAlphaZTestSub = nullptr; boo::ObjToken<boo::IShaderPipeline> CElementGenShaders::m_texRedToAlphaZTestSub;
boo::IShaderPipeline* CElementGenShaders::m_texRedToAlphaNoZTestSub = nullptr; boo::ObjToken<boo::IShaderPipeline> CElementGenShaders::m_texRedToAlphaNoZTestSub;
boo::IShaderPipeline* CElementGenShaders::m_indTexZWrite = nullptr; boo::ObjToken<boo::IShaderPipeline> CElementGenShaders::m_indTexZWrite;
boo::IShaderPipeline* CElementGenShaders::m_indTexNoZWrite = nullptr; boo::ObjToken<boo::IShaderPipeline> CElementGenShaders::m_indTexNoZWrite;
boo::IShaderPipeline* CElementGenShaders::m_indTexAdditive = nullptr; boo::ObjToken<boo::IShaderPipeline> CElementGenShaders::m_indTexAdditive;
boo::IShaderPipeline* CElementGenShaders::m_cindTexZWrite = nullptr; boo::ObjToken<boo::IShaderPipeline> CElementGenShaders::m_cindTexZWrite;
boo::IShaderPipeline* CElementGenShaders::m_cindTexNoZWrite = nullptr; boo::ObjToken<boo::IShaderPipeline> CElementGenShaders::m_cindTexNoZWrite;
boo::IShaderPipeline* CElementGenShaders::m_cindTexAdditive = nullptr; boo::ObjToken<boo::IShaderPipeline> CElementGenShaders::m_cindTexAdditive;
boo::IShaderPipeline* CElementGenShaders::m_noTexZTestZWrite = nullptr; boo::ObjToken<boo::IShaderPipeline> CElementGenShaders::m_noTexZTestZWrite;
boo::IShaderPipeline* CElementGenShaders::m_noTexNoZTestZWrite = nullptr; boo::ObjToken<boo::IShaderPipeline> CElementGenShaders::m_noTexNoZTestZWrite;
boo::IShaderPipeline* CElementGenShaders::m_noTexZTestNoZWrite = nullptr; boo::ObjToken<boo::IShaderPipeline> CElementGenShaders::m_noTexZTestNoZWrite;
boo::IShaderPipeline* CElementGenShaders::m_noTexNoZTestNoZWrite = nullptr; boo::ObjToken<boo::IShaderPipeline> CElementGenShaders::m_noTexNoZTestNoZWrite;
boo::IShaderPipeline* CElementGenShaders::m_noTexAdditiveZTest = nullptr; boo::ObjToken<boo::IShaderPipeline> CElementGenShaders::m_noTexAdditiveZTest;
boo::IShaderPipeline* CElementGenShaders::m_noTexAdditiveNoZTest = nullptr; boo::ObjToken<boo::IShaderPipeline> CElementGenShaders::m_noTexAdditiveNoZTest;
boo::IVertexFormat* CElementGenShaders::m_vtxFormatTex = nullptr; boo::ObjToken<boo::IVertexFormat> CElementGenShaders::m_vtxFormatTex;
boo::IVertexFormat* CElementGenShaders::m_vtxFormatIndTex = nullptr; boo::ObjToken<boo::IVertexFormat> CElementGenShaders::m_vtxFormatIndTex;
boo::IVertexFormat* CElementGenShaders::m_vtxFormatNoTex = nullptr; boo::ObjToken<boo::IVertexFormat> CElementGenShaders::m_vtxFormatNoTex;
CElementGenShaders::EShaderClass CElementGenShaders::GetShaderClass(CElementGen& gen) CElementGenShaders::EShaderClass CElementGenShaders::GetShaderClass(CElementGen& gen)
{ {
@ -54,12 +54,12 @@ CElementGenShaders::EShaderClass CElementGenShaders::GetShaderClass(CElementGen&
void CElementGenShaders::BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, CElementGen& gen) void CElementGenShaders::BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, CElementGen& gen)
{ {
CGenDescription* desc = gen.x1c_genDesc.GetObj(); CGenDescription* desc = gen.x1c_genDesc.GetObj();
boo::IShaderPipeline* regPipeline = nullptr; boo::ObjToken<boo::IShaderPipeline> regPipeline;
boo::IShaderPipeline* regPipelineSub = nullptr; boo::ObjToken<boo::IShaderPipeline> regPipelineSub;
boo::IShaderPipeline* redToAlphaPipeline = nullptr; boo::ObjToken<boo::IShaderPipeline> redToAlphaPipeline;
boo::IShaderPipeline* redToAlphaPipelineSub = nullptr; boo::ObjToken<boo::IShaderPipeline> redToAlphaPipelineSub;
boo::IShaderPipeline* regPipelinePmus = nullptr; boo::ObjToken<boo::IShaderPipeline> regPipelinePmus;
boo::IShaderPipeline* redToAlphaPipelinePmus = nullptr; boo::ObjToken<boo::IShaderPipeline> redToAlphaPipelinePmus;
if (desc->x54_x40_TEXR) if (desc->x54_x40_TEXR)
{ {
@ -183,8 +183,6 @@ void CElementGenShaders::BuildShaderDataBinding(boo::IGraphicsDataFactory::Conte
TShader<CElementGenShaders>::BuildShaderDataBinding(ctx, shad); TShader<CElementGenShaders>::BuildShaderDataBinding(ctx, shad);
} }
void CElementGenShaders::Shutdown() {}
URDE_SPECIALIZE_SHADER(CElementGenShaders) URDE_SPECIALIZE_SHADER(CElementGenShaders)
} }

View File

@ -27,52 +27,52 @@ public:
}; };
private: private:
static boo::IShaderPipeline* m_texZTestZWrite; static boo::ObjToken<boo::IShaderPipeline> m_texZTestZWrite;
static boo::IShaderPipeline* m_texNoZTestZWrite; static boo::ObjToken<boo::IShaderPipeline> m_texNoZTestZWrite;
static boo::IShaderPipeline* m_texZTestNoZWrite; static boo::ObjToken<boo::IShaderPipeline> m_texZTestNoZWrite;
static boo::IShaderPipeline* m_texNoZTestNoZWrite; static boo::ObjToken<boo::IShaderPipeline> m_texNoZTestNoZWrite;
static boo::IShaderPipeline* m_texAdditiveZTest; static boo::ObjToken<boo::IShaderPipeline> m_texAdditiveZTest;
static boo::IShaderPipeline* m_texAdditiveNoZTest; static boo::ObjToken<boo::IShaderPipeline> m_texAdditiveNoZTest;
static boo::IShaderPipeline* m_texRedToAlphaZTest; static boo::ObjToken<boo::IShaderPipeline> m_texRedToAlphaZTest;
static boo::IShaderPipeline* m_texRedToAlphaNoZTest; static boo::ObjToken<boo::IShaderPipeline> m_texRedToAlphaNoZTest;
static boo::IShaderPipeline* m_texZTestNoZWriteSub; static boo::ObjToken<boo::IShaderPipeline> m_texZTestNoZWriteSub;
static boo::IShaderPipeline* m_texNoZTestNoZWriteSub; static boo::ObjToken<boo::IShaderPipeline> m_texNoZTestNoZWriteSub;
static boo::IShaderPipeline* m_texRedToAlphaZTestSub; static boo::ObjToken<boo::IShaderPipeline> m_texRedToAlphaZTestSub;
static boo::IShaderPipeline* m_texRedToAlphaNoZTestSub; static boo::ObjToken<boo::IShaderPipeline> m_texRedToAlphaNoZTestSub;
static boo::IShaderPipeline* m_indTexZWrite; static boo::ObjToken<boo::IShaderPipeline> m_indTexZWrite;
static boo::IShaderPipeline* m_indTexNoZWrite; static boo::ObjToken<boo::IShaderPipeline> m_indTexNoZWrite;
static boo::IShaderPipeline* m_indTexAdditive; static boo::ObjToken<boo::IShaderPipeline> m_indTexAdditive;
static boo::IShaderPipeline* m_cindTexZWrite; static boo::ObjToken<boo::IShaderPipeline> m_cindTexZWrite;
static boo::IShaderPipeline* m_cindTexNoZWrite; static boo::ObjToken<boo::IShaderPipeline> m_cindTexNoZWrite;
static boo::IShaderPipeline* m_cindTexAdditive; static boo::ObjToken<boo::IShaderPipeline> m_cindTexAdditive;
static boo::IShaderPipeline* m_noTexZTestZWrite; static boo::ObjToken<boo::IShaderPipeline> m_noTexZTestZWrite;
static boo::IShaderPipeline* m_noTexNoZTestZWrite; static boo::ObjToken<boo::IShaderPipeline> m_noTexNoZTestZWrite;
static boo::IShaderPipeline* m_noTexZTestNoZWrite; static boo::ObjToken<boo::IShaderPipeline> m_noTexZTestNoZWrite;
static boo::IShaderPipeline* m_noTexNoZTestNoZWrite; static boo::ObjToken<boo::IShaderPipeline> m_noTexNoZTestNoZWrite;
static boo::IShaderPipeline* m_noTexAdditiveZTest; static boo::ObjToken<boo::IShaderPipeline> m_noTexAdditiveZTest;
static boo::IShaderPipeline* m_noTexAdditiveNoZTest; static boo::ObjToken<boo::IShaderPipeline> m_noTexAdditiveNoZTest;
static boo::IVertexFormat* m_vtxFormatTex; /* No OpenGL */ static boo::ObjToken<boo::IVertexFormat> m_vtxFormatTex; /* No OpenGL */
static boo::IVertexFormat* m_vtxFormatIndTex; /* No OpenGL */ static boo::ObjToken<boo::IVertexFormat> m_vtxFormatIndTex; /* No OpenGL */
static boo::IVertexFormat* m_vtxFormatNoTex; /* No OpenGL */ static boo::ObjToken<boo::IVertexFormat> m_vtxFormatNoTex; /* No OpenGL */
CElementGen& m_gen; CElementGen& m_gen;
boo::IShaderPipeline* m_regPipeline; boo::ObjToken<boo::IShaderPipeline> m_regPipeline;
boo::IShaderPipeline* m_regPipelineSub; boo::ObjToken<boo::IShaderPipeline> m_regPipelineSub;
boo::IShaderPipeline* m_redToAlphaPipeline; boo::ObjToken<boo::IShaderPipeline> m_redToAlphaPipeline;
boo::IShaderPipeline* m_redToAlphaPipelineSub; boo::ObjToken<boo::IShaderPipeline> m_redToAlphaPipelineSub;
boo::IShaderPipeline* m_regPipelinePmus; boo::ObjToken<boo::IShaderPipeline> m_regPipelinePmus;
boo::IShaderPipeline* m_redToAlphaPipelinePmus; boo::ObjToken<boo::IShaderPipeline> m_redToAlphaPipelinePmus;
CElementGenShaders(CElementGen& gen, CElementGenShaders(CElementGen& gen,
boo::IShaderPipeline* regPipeline, const boo::ObjToken<boo::IShaderPipeline>& regPipeline,
boo::IShaderPipeline* regPipelineSub, const boo::ObjToken<boo::IShaderPipeline>& regPipelineSub,
boo::IShaderPipeline* redToAlphaPipeline, const boo::ObjToken<boo::IShaderPipeline>& redToAlphaPipeline,
boo::IShaderPipeline* redToAlphaPipelineSub, const boo::ObjToken<boo::IShaderPipeline>& redToAlphaPipelineSub,
boo::IShaderPipeline* regPipelinePmus, const boo::ObjToken<boo::IShaderPipeline>& regPipelinePmus,
boo::IShaderPipeline* redToAlphaPipelinePmus) const boo::ObjToken<boo::IShaderPipeline>& redToAlphaPipelinePmus)
: m_gen(gen), m_regPipeline(regPipeline), m_regPipelineSub(regPipelineSub), : m_gen(gen), m_regPipeline(regPipeline), m_regPipelineSub(regPipelineSub),
m_redToAlphaPipeline(redToAlphaPipeline), m_redToAlphaPipelineSub(redToAlphaPipelineSub), m_redToAlphaPipeline(redToAlphaPipeline), m_redToAlphaPipelineSub(redToAlphaPipelineSub),
m_regPipelinePmus(regPipelinePmus), m_redToAlphaPipelinePmus(redToAlphaPipelinePmus) {} m_regPipelinePmus(regPipelinePmus), m_redToAlphaPipelinePmus(redToAlphaPipelinePmus) {}

View File

@ -192,18 +192,18 @@ BOO_GLSL_BINDING_HEAD
struct OGLElementDataBindingFactory : TShader<CElementGenShaders>::IDataBindingFactory struct OGLElementDataBindingFactory : TShader<CElementGenShaders>::IDataBindingFactory
{ {
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
CElementGenShaders& shaders) CElementGenShaders& shaders)
{ {
CElementGen& gen = shaders.m_gen; CElementGen& gen = shaders.m_gen;
CGenDescription* desc = gen.GetDesc(); CGenDescription* desc = gen.GetDesc();
boo::IVertexFormat* vtxFmt = nullptr; boo::ObjToken<boo::IVertexFormat> vtxFmt;
boo::IVertexFormat* vtxFmtPmus = nullptr; boo::ObjToken<boo::IVertexFormat> vtxFmtPmus;
CUVElement* texr = desc->x54_x40_TEXR.get(); CUVElement* texr = desc->x54_x40_TEXR.get();
CUVElement* tind = desc->x58_x44_TIND.get(); CUVElement* tind = desc->x58_x44_TIND.get();
int texCount = 0; int texCount = 0;
boo::ITexture* textures[3]; boo::ObjToken<boo::ITexture> textures[3];
if (texr) if (texr)
{ {
@ -213,22 +213,22 @@ struct OGLElementDataBindingFactory : TShader<CElementGenShaders>::IDataBindingF
{ {
if (tind) if (tind)
{ {
textures[1] = CGraphics::g_SpareTexture; textures[1] = CGraphics::g_SpareTexture.get();
textures[2] = tind->GetValueTexture(0).GetObj()->GetBooTexture(); textures[2] = tind->GetValueTexture(0).GetObj()->GetBooTexture();
texCount = 3; texCount = 3;
const boo::VertexElementDescriptor TexFmtIndTex[] = const boo::VertexElementDescriptor TexFmtIndTex[] =
{ {
{gen.m_instBuf, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 0}, {gen.m_instBuf.get(), nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 0},
{gen.m_instBuf, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 1}, {gen.m_instBuf.get(), nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 1},
{gen.m_instBuf, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 2}, {gen.m_instBuf.get(), nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 2},
{gen.m_instBuf, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 3}, {gen.m_instBuf.get(), nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 3},
{gen.m_instBuf, nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced}, {gen.m_instBuf.get(), nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced},
{gen.m_instBuf, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 0}, {gen.m_instBuf.get(), nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 0},
{gen.m_instBuf, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 1}, {gen.m_instBuf.get(), nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 1},
{gen.m_instBuf, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 2}, {gen.m_instBuf.get(), nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 2},
{gen.m_instBuf, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 3}, {gen.m_instBuf.get(), nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 3},
{gen.m_instBuf, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 4}, {gen.m_instBuf.get(), nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 4},
}; };
vtxFmt = ctx.newVertexFormat(10, TexFmtIndTex); vtxFmt = ctx.newVertexFormat(10, TexFmtIndTex);
} }
@ -236,15 +236,15 @@ struct OGLElementDataBindingFactory : TShader<CElementGenShaders>::IDataBindingF
{ {
const boo::VertexElementDescriptor TexFmtTex[] = const boo::VertexElementDescriptor TexFmtTex[] =
{ {
{gen.m_instBuf, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 0}, {gen.m_instBuf.get(), nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 0},
{gen.m_instBuf, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 1}, {gen.m_instBuf.get(), nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 1},
{gen.m_instBuf, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 2}, {gen.m_instBuf.get(), nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 2},
{gen.m_instBuf, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 3}, {gen.m_instBuf.get(), nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 3},
{gen.m_instBuf, nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced}, {gen.m_instBuf.get(), nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced},
{gen.m_instBuf, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 0}, {gen.m_instBuf.get(), nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 0},
{gen.m_instBuf, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 1}, {gen.m_instBuf.get(), nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 1},
{gen.m_instBuf, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 2}, {gen.m_instBuf.get(), nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 2},
{gen.m_instBuf, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 3} {gen.m_instBuf.get(), nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 3}
}; };
vtxFmt = ctx.newVertexFormat(9, TexFmtTex); vtxFmt = ctx.newVertexFormat(9, TexFmtTex);
} }
@ -253,15 +253,15 @@ struct OGLElementDataBindingFactory : TShader<CElementGenShaders>::IDataBindingF
{ {
const boo::VertexElementDescriptor TexFmtTex[] = const boo::VertexElementDescriptor TexFmtTex[] =
{ {
{gen.m_instBufPmus, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 0}, {gen.m_instBufPmus.get(), nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 0},
{gen.m_instBufPmus, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 1}, {gen.m_instBufPmus.get(), nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 1},
{gen.m_instBufPmus, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 2}, {gen.m_instBufPmus.get(), nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 2},
{gen.m_instBufPmus, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 3}, {gen.m_instBufPmus.get(), nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 3},
{gen.m_instBufPmus, nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced}, {gen.m_instBufPmus.get(), nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced},
{gen.m_instBufPmus, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 0}, {gen.m_instBufPmus.get(), nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 0},
{gen.m_instBufPmus, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 1}, {gen.m_instBufPmus.get(), nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 1},
{gen.m_instBufPmus, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 2}, {gen.m_instBufPmus.get(), nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 2},
{gen.m_instBufPmus, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 3} {gen.m_instBufPmus.get(), nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 3}
}; };
vtxFmtPmus = ctx.newVertexFormat(9, TexFmtTex); vtxFmtPmus = ctx.newVertexFormat(9, TexFmtTex);
} }
@ -272,11 +272,11 @@ struct OGLElementDataBindingFactory : TShader<CElementGenShaders>::IDataBindingF
{ {
const boo::VertexElementDescriptor TexFmtNoTex[] = const boo::VertexElementDescriptor TexFmtNoTex[] =
{ {
{gen.m_instBuf, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 0}, {gen.m_instBuf.get(), nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 0},
{gen.m_instBuf, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 1}, {gen.m_instBuf.get(), nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 1},
{gen.m_instBuf, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 2}, {gen.m_instBuf.get(), nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 2},
{gen.m_instBuf, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 3}, {gen.m_instBuf.get(), nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 3},
{gen.m_instBuf, nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced} {gen.m_instBuf.get(), nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced}
}; };
vtxFmt = ctx.newVertexFormat(5, TexFmtNoTex); vtxFmt = ctx.newVertexFormat(5, TexFmtNoTex);
} }
@ -284,11 +284,11 @@ struct OGLElementDataBindingFactory : TShader<CElementGenShaders>::IDataBindingF
{ {
const boo::VertexElementDescriptor TexFmtNoTex[] = const boo::VertexElementDescriptor TexFmtNoTex[] =
{ {
{gen.m_instBufPmus, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 0}, {gen.m_instBufPmus.get(), nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 0},
{gen.m_instBufPmus, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 1}, {gen.m_instBufPmus.get(), nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 1},
{gen.m_instBufPmus, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 2}, {gen.m_instBufPmus.get(), nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 2},
{gen.m_instBufPmus, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 3}, {gen.m_instBufPmus.get(), nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 3},
{gen.m_instBufPmus, nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced} {gen.m_instBufPmus.get(), nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced}
}; };
vtxFmtPmus = ctx.newVertexFormat(5, TexFmtNoTex); vtxFmtPmus = ctx.newVertexFormat(5, TexFmtNoTex);
} }
@ -296,38 +296,38 @@ struct OGLElementDataBindingFactory : TShader<CElementGenShaders>::IDataBindingF
if (gen.m_instBuf) if (gen.m_instBuf)
{ {
boo::IGraphicsBuffer* uniforms[] = {gen.m_uniformBuf}; boo::ObjToken<boo::IGraphicsBuffer> uniforms[] = {gen.m_uniformBuf.get()};
if (shaders.m_regPipeline) if (shaders.m_regPipeline)
gen.m_normalDataBind = ctx.newShaderDataBinding(shaders.m_regPipeline, vtxFmt, nullptr, gen.m_normalDataBind = ctx.newShaderDataBinding(shaders.m_regPipeline, vtxFmt, nullptr,
gen.m_instBuf, nullptr, 1, uniforms, gen.m_instBuf.get(), nullptr, 1, uniforms,
nullptr, texCount, textures, nullptr, nullptr); nullptr, texCount, textures, nullptr, nullptr);
if (shaders.m_regPipelineSub) if (shaders.m_regPipelineSub)
gen.m_normalSubDataBind = ctx.newShaderDataBinding(shaders.m_regPipelineSub, vtxFmt, nullptr, gen.m_normalSubDataBind = ctx.newShaderDataBinding(shaders.m_regPipelineSub, vtxFmt, nullptr,
gen.m_instBuf, nullptr, 1, uniforms, gen.m_instBuf.get(), nullptr, 1, uniforms,
nullptr, texCount, textures, nullptr, nullptr); nullptr, texCount, textures, nullptr, nullptr);
if (shaders.m_redToAlphaPipeline) if (shaders.m_redToAlphaPipeline)
gen.m_redToAlphaDataBind = ctx.newShaderDataBinding(shaders.m_redToAlphaPipeline, vtxFmt, nullptr, gen.m_redToAlphaDataBind = ctx.newShaderDataBinding(shaders.m_redToAlphaPipeline, vtxFmt, nullptr,
gen.m_instBuf, nullptr, 1, uniforms, gen.m_instBuf.get(), nullptr, 1, uniforms,
nullptr, texCount, textures, nullptr, nullptr); nullptr, texCount, textures, nullptr, nullptr);
if (shaders.m_redToAlphaPipelineSub) if (shaders.m_redToAlphaPipelineSub)
gen.m_redToAlphaSubDataBind = ctx.newShaderDataBinding(shaders.m_redToAlphaPipelineSub, vtxFmt, nullptr, gen.m_redToAlphaSubDataBind = ctx.newShaderDataBinding(shaders.m_redToAlphaPipelineSub, vtxFmt, nullptr,
gen.m_instBuf, nullptr, 1, uniforms, gen.m_instBuf.get(), nullptr, 1, uniforms,
nullptr, texCount, textures, nullptr, nullptr); nullptr, texCount, textures, nullptr, nullptr);
} }
if (gen.m_instBufPmus) if (gen.m_instBufPmus)
{ {
boo::IGraphicsBuffer* uniforms[] = {gen.m_uniformBufPmus}; boo::ObjToken<boo::IGraphicsBuffer> uniforms[] = {gen.m_uniformBufPmus.get()};
texCount = std::min(texCount, 1); texCount = std::min(texCount, 1);
if (shaders.m_regPipelinePmus) if (shaders.m_regPipelinePmus)
gen.m_normalDataBindPmus = ctx.newShaderDataBinding(shaders.m_regPipelinePmus, vtxFmtPmus, nullptr, gen.m_normalDataBindPmus = ctx.newShaderDataBinding(shaders.m_regPipelinePmus, vtxFmtPmus, nullptr,
gen.m_instBufPmus, nullptr, 1, uniforms, gen.m_instBufPmus.get(), nullptr, 1, uniforms,
nullptr, texCount, textures, nullptr, nullptr); nullptr, texCount, textures, nullptr, nullptr);
if (shaders.m_redToAlphaPipelinePmus) if (shaders.m_redToAlphaPipelinePmus)
gen.m_redToAlphaDataBindPmus = ctx.newShaderDataBinding(shaders.m_redToAlphaPipelinePmus, vtxFmtPmus, nullptr, gen.m_redToAlphaDataBindPmus = ctx.newShaderDataBinding(shaders.m_redToAlphaPipelinePmus, vtxFmtPmus, nullptr,
gen.m_instBufPmus, nullptr, 1, uniforms, gen.m_instBufPmus.get(), nullptr, 1, uniforms,
nullptr, texCount, textures, nullptr, nullptr); nullptr, texCount, textures, nullptr, nullptr);
} }
@ -449,10 +449,43 @@ TShader<CElementGenShaders>::IDataBindingFactory* CElementGenShaders::Initialize
return new struct OGLElementDataBindingFactory; return new struct OGLElementDataBindingFactory;
} }
template <>
void CElementGenShaders::Shutdown<boo::GLDataFactory>()
{
m_texZTestZWrite.reset();
m_texNoZTestZWrite.reset();
m_texZTestNoZWrite.reset();
m_texNoZTestNoZWrite.reset();
m_texAdditiveZTest.reset();
m_texAdditiveNoZTest.reset();
m_texRedToAlphaZTest.reset();
m_texRedToAlphaNoZTest.reset();
m_texZTestNoZWriteSub.reset();
m_texNoZTestNoZWriteSub.reset();
m_texRedToAlphaZTestSub.reset();
m_texRedToAlphaNoZTestSub.reset();
m_indTexZWrite.reset();
m_indTexNoZWrite.reset();
m_indTexAdditive.reset();
m_cindTexZWrite.reset();
m_cindTexNoZWrite.reset();
m_cindTexAdditive.reset();
m_noTexZTestZWrite.reset();
m_noTexNoZTestZWrite.reset();
m_noTexZTestNoZWrite.reset();
m_noTexNoZTestNoZWrite.reset();
m_noTexAdditiveZTest.reset();
m_noTexAdditiveNoZTest.reset();
}
#if BOO_HAS_VULKAN #if BOO_HAS_VULKAN
struct VulkanElementDataBindingFactory : TShader<CElementGenShaders>::IDataBindingFactory struct VulkanElementDataBindingFactory : TShader<CElementGenShaders>::IDataBindingFactory
{ {
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, boo::ObjToken<boo::IShaderDataBinding>
BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
CElementGenShaders& shaders) CElementGenShaders& shaders)
{ {
CElementGen& gen = shaders.m_gen; CElementGen& gen = shaders.m_gen;
@ -461,7 +494,7 @@ struct VulkanElementDataBindingFactory : TShader<CElementGenShaders>::IDataBindi
CUVElement* texr = desc->x54_x40_TEXR.get(); CUVElement* texr = desc->x54_x40_TEXR.get();
CUVElement* tind = desc->x58_x44_TIND.get(); CUVElement* tind = desc->x58_x44_TIND.get();
int texCount = 0; int texCount = 0;
boo::ITexture* textures[3]; boo::ObjToken<boo::ITexture> textures[3];
if (texr) if (texr)
{ {
@ -469,7 +502,7 @@ struct VulkanElementDataBindingFactory : TShader<CElementGenShaders>::IDataBindi
texCount = 1; texCount = 1;
if (tind) if (tind)
{ {
textures[1] = CGraphics::g_SpareTexture; textures[1] = CGraphics::g_SpareTexture.get();
textures[2] = tind->GetValueTexture(0).GetObj()->GetBooTexture(); textures[2] = tind->GetValueTexture(0).GetObj()->GetBooTexture();
texCount = 3; texCount = 3;
} }
@ -477,39 +510,39 @@ struct VulkanElementDataBindingFactory : TShader<CElementGenShaders>::IDataBindi
if (gen.m_instBuf) if (gen.m_instBuf)
{ {
boo::IGraphicsBuffer* uniforms[] = {gen.m_uniformBuf}; boo::ObjToken<boo::IGraphicsBuffer> uniforms[] = {gen.m_uniformBuf.get()};
if (shaders.m_regPipeline) if (shaders.m_regPipeline)
gen.m_normalDataBind = ctx.newShaderDataBinding(shaders.m_regPipeline, nullptr, nullptr, gen.m_normalDataBind = ctx.newShaderDataBinding(shaders.m_regPipeline, nullptr, nullptr,
gen.m_instBuf, nullptr, 1, uniforms, gen.m_instBuf.get(), nullptr, 1, uniforms,
nullptr, texCount, textures, nullptr, nullptr); nullptr, texCount, textures, nullptr, nullptr);
if (shaders.m_regPipelineSub) if (shaders.m_regPipelineSub)
gen.m_normalSubDataBind = ctx.newShaderDataBinding(shaders.m_regPipelineSub, nullptr, nullptr, gen.m_normalSubDataBind = ctx.newShaderDataBinding(shaders.m_regPipelineSub, nullptr, nullptr,
gen.m_instBuf, nullptr, 1, uniforms, gen.m_instBuf.get(), nullptr, 1, uniforms,
nullptr, texCount, textures, nullptr, nullptr); nullptr, texCount, textures, nullptr, nullptr);
if (shaders.m_redToAlphaPipeline) if (shaders.m_redToAlphaPipeline)
gen.m_redToAlphaDataBind = ctx.newShaderDataBinding(shaders.m_redToAlphaPipeline, nullptr, nullptr, gen.m_redToAlphaDataBind = ctx.newShaderDataBinding(shaders.m_redToAlphaPipeline, nullptr, nullptr,
gen.m_instBuf, nullptr, 1, uniforms, gen.m_instBuf.get(), nullptr, 1, uniforms,
nullptr, texCount, textures, nullptr, nullptr); nullptr, texCount, textures, nullptr, nullptr);
if (shaders.m_redToAlphaPipelineSub) if (shaders.m_redToAlphaPipelineSub)
gen.m_redToAlphaSubDataBind = ctx.newShaderDataBinding(shaders.m_redToAlphaPipelineSub, nullptr, nullptr, gen.m_redToAlphaSubDataBind = ctx.newShaderDataBinding(shaders.m_redToAlphaPipelineSub, nullptr, nullptr,
gen.m_instBuf, nullptr, 1, uniforms, gen.m_instBuf.get(), nullptr, 1, uniforms,
nullptr, texCount, textures, nullptr, nullptr); nullptr, texCount, textures, nullptr, nullptr);
} }
if (gen.m_instBufPmus) if (gen.m_instBufPmus)
{ {
boo::IGraphicsBuffer* uniforms[] = {gen.m_uniformBufPmus}; boo::ObjToken<boo::IGraphicsBuffer> uniforms[] = {gen.m_uniformBufPmus.get()};
texCount = std::min(texCount, 1); texCount = std::min(texCount, 1);
if (shaders.m_regPipelinePmus) if (shaders.m_regPipelinePmus)
gen.m_normalDataBindPmus = ctx.newShaderDataBinding(shaders.m_regPipelinePmus, nullptr, nullptr, gen.m_normalDataBindPmus = ctx.newShaderDataBinding(shaders.m_regPipelinePmus, nullptr, nullptr,
gen.m_instBufPmus, nullptr, 1, uniforms, gen.m_instBufPmus.get(), nullptr, 1, uniforms,
nullptr, texCount, textures, nullptr, nullptr); nullptr, texCount, textures, nullptr, nullptr);
if (shaders.m_redToAlphaPipelinePmus) if (shaders.m_redToAlphaPipelinePmus)
gen.m_redToAlphaDataBindPmus = ctx.newShaderDataBinding(shaders.m_redToAlphaPipelinePmus, nullptr, nullptr, gen.m_redToAlphaDataBindPmus = ctx.newShaderDataBinding(shaders.m_redToAlphaPipelinePmus, nullptr, nullptr,
gen.m_instBufPmus, nullptr, 1, uniforms, gen.m_instBufPmus.get(), nullptr, 1, uniforms,
nullptr, texCount, textures, nullptr, nullptr); nullptr, texCount, textures, nullptr, nullptr);
} }
@ -668,6 +701,42 @@ TShader<CElementGenShaders>::IDataBindingFactory* CElementGenShaders::Initialize
return new struct VulkanElementDataBindingFactory; return new struct VulkanElementDataBindingFactory;
} }
template <>
void CElementGenShaders::Shutdown<boo::VulkanDataFactory>()
{
m_vtxFormatTex.reset();
m_vtxFormatIndTex.reset();
m_vtxFormatNoTex.reset();
m_texZTestZWrite.reset();
m_texNoZTestZWrite.reset();
m_texZTestNoZWrite.reset();
m_texNoZTestNoZWrite.reset();
m_texAdditiveZTest.reset();
m_texAdditiveNoZTest.reset();
m_texRedToAlphaZTest.reset();
m_texRedToAlphaNoZTest.reset();
m_texZTestNoZWriteSub.reset();
m_texNoZTestNoZWriteSub.reset();
m_texRedToAlphaZTestSub.reset();
m_texRedToAlphaNoZTestSub.reset();
m_indTexZWrite.reset();
m_indTexNoZWrite.reset();
m_indTexAdditive.reset();
m_cindTexZWrite.reset();
m_cindTexNoZWrite.reset();
m_cindTexAdditive.reset();
m_noTexZTestZWrite.reset();
m_noTexNoZTestZWrite.reset();
m_noTexZTestNoZWrite.reset();
m_noTexNoZTestNoZWrite.reset();
m_noTexAdditiveZTest.reset();
m_noTexAdditiveNoZTest.reset();
}
#endif #endif
} }

View File

@ -189,7 +189,8 @@ static const char* FS_HLSL_NOTEX =
struct D3DElementDataBindingFactory : TShader<CElementGenShaders>::IDataBindingFactory struct D3DElementDataBindingFactory : TShader<CElementGenShaders>::IDataBindingFactory
{ {
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, boo::ObjToken<boo::IShaderDataBinding>
BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
CElementGenShaders& shaders) CElementGenShaders& shaders)
{ {
CElementGen& gen = shaders.m_gen; CElementGen& gen = shaders.m_gen;
@ -198,7 +199,7 @@ struct D3DElementDataBindingFactory : TShader<CElementGenShaders>::IDataBindingF
CUVElement* texr = desc->x54_x40_TEXR.get(); CUVElement* texr = desc->x54_x40_TEXR.get();
CUVElement* tind = desc->x58_x44_TIND.get(); CUVElement* tind = desc->x58_x44_TIND.get();
int texCount = 0; int texCount = 0;
boo::ITexture* textures[3]; boo::ObjToken<boo::ITexture> textures[3];
if (texr) if (texr)
{ {
@ -206,7 +207,7 @@ struct D3DElementDataBindingFactory : TShader<CElementGenShaders>::IDataBindingF
texCount = 1; texCount = 1;
if (tind) if (tind)
{ {
textures[1] = CGraphics::g_SpareTexture; textures[1] = CGraphics::g_SpareTexture.get();
textures[2] = tind->GetValueTexture(0).GetObj()->GetBooTexture(); textures[2] = tind->GetValueTexture(0).GetObj()->GetBooTexture();
texCount = 3; texCount = 3;
} }
@ -214,43 +215,43 @@ struct D3DElementDataBindingFactory : TShader<CElementGenShaders>::IDataBindingF
if (gen.m_instBuf) if (gen.m_instBuf)
{ {
boo::IGraphicsBuffer* uniforms[] = {gen.m_uniformBuf}; boo::ObjToken<boo::IGraphicsBuffer> uniforms[] = {gen.m_uniformBuf.get()};
if (shaders.m_regPipeline) if (shaders.m_regPipeline)
gen.m_normalDataBind = ctx.newShaderDataBinding(shaders.m_regPipeline, nullptr, nullptr, gen.m_normalDataBind = ctx.newShaderDataBinding(shaders.m_regPipeline, nullptr, nullptr,
gen.m_instBuf, nullptr, 1, uniforms, gen.m_instBuf.get(), nullptr, 1, uniforms,
nullptr, texCount, textures, nullptr, texCount, textures,
nullptr, nullptr); nullptr, nullptr);
if (shaders.m_regPipelineSub) if (shaders.m_regPipelineSub)
gen.m_normalSubDataBind = ctx.newShaderDataBinding(shaders.m_regPipelineSub, nullptr, nullptr, gen.m_normalSubDataBind = ctx.newShaderDataBinding(shaders.m_regPipelineSub, nullptr, nullptr,
gen.m_instBuf, nullptr, 1, uniforms, gen.m_instBuf.get(), nullptr, 1, uniforms,
nullptr, texCount, textures, nullptr, texCount, textures,
nullptr, nullptr); nullptr, nullptr);
if (shaders.m_redToAlphaPipeline) if (shaders.m_redToAlphaPipeline)
gen.m_redToAlphaDataBind = ctx.newShaderDataBinding(shaders.m_redToAlphaPipeline, nullptr, nullptr, gen.m_redToAlphaDataBind = ctx.newShaderDataBinding(shaders.m_redToAlphaPipeline, nullptr, nullptr,
gen.m_instBuf, nullptr, 1, uniforms, gen.m_instBuf.get(), nullptr, 1, uniforms,
nullptr, texCount, textures, nullptr, texCount, textures,
nullptr, nullptr); nullptr, nullptr);
if (shaders.m_redToAlphaPipelineSub) if (shaders.m_redToAlphaPipelineSub)
gen.m_redToAlphaSubDataBind = ctx.newShaderDataBinding(shaders.m_redToAlphaPipelineSub, nullptr, nullptr, gen.m_redToAlphaSubDataBind = ctx.newShaderDataBinding(shaders.m_redToAlphaPipelineSub, nullptr, nullptr,
gen.m_instBuf, nullptr, 1, uniforms, gen.m_instBuf.get(), nullptr, 1, uniforms,
nullptr, texCount, textures, nullptr, texCount, textures,
nullptr, nullptr); nullptr, nullptr);
} }
if (gen.m_instBufPmus) if (gen.m_instBufPmus)
{ {
boo::IGraphicsBuffer* uniforms[] = {gen.m_uniformBufPmus}; boo::ObjToken<boo::IGraphicsBuffer> uniforms[] = {gen.m_uniformBufPmus.get()};
texCount = std::min(texCount, 1); texCount = std::min(texCount, 1);
if (shaders.m_regPipelinePmus) if (shaders.m_regPipelinePmus)
gen.m_normalDataBindPmus = ctx.newShaderDataBinding(shaders.m_regPipelinePmus, nullptr, nullptr, gen.m_normalDataBindPmus = ctx.newShaderDataBinding(shaders.m_regPipelinePmus, nullptr, nullptr,
gen.m_instBuf, nullptr, 1, uniforms, gen.m_instBuf.get(), nullptr, 1, uniforms,
nullptr, texCount, textures, nullptr, texCount, textures,
nullptr, nullptr); nullptr, nullptr);
if (shaders.m_redToAlphaPipelinePmus) if (shaders.m_redToAlphaPipelinePmus)
gen.m_redToAlphaDataBindPmus = ctx.newShaderDataBinding(shaders.m_redToAlphaPipelinePmus, nullptr, nullptr, gen.m_redToAlphaDataBindPmus = ctx.newShaderDataBinding(shaders.m_redToAlphaPipelinePmus, nullptr, nullptr,
gen.m_instBuf, nullptr, 1, uniforms, gen.m_instBuf.get(), nullptr, 1, uniforms,
nullptr, texCount, textures, nullptr, texCount, textures,
nullptr, nullptr); nullptr, nullptr);
} }
@ -432,4 +433,40 @@ TShader<CElementGenShaders>::IDataBindingFactory* CElementGenShaders::Initialize
return new struct D3DElementDataBindingFactory; return new struct D3DElementDataBindingFactory;
} }
template <>
void CElementGenShaders::Shutdown<boo::ID3DDataFactory>()
{
m_vtxFormatTex.reset();
m_vtxFormatIndTex.reset();
m_vtxFormatNoTex.reset();
m_texZTestZWrite.reset();
m_texNoZTestZWrite.reset();
m_texZTestNoZWrite.reset();
m_texNoZTestNoZWrite.reset();
m_texAdditiveZTest.reset();
m_texAdditiveNoZTest.reset();
m_texRedToAlphaZTest.reset();
m_texRedToAlphaNoZTest.reset();
m_texZTestNoZWriteSub.reset();
m_texNoZTestNoZWriteSub.reset();
m_texRedToAlphaZTestSub.reset();
m_texRedToAlphaNoZTestSub.reset();
m_indTexZWrite.reset();
m_indTexNoZWrite.reset();
m_indTexAdditive.reset();
m_cindTexZWrite.reset();
m_cindTexNoZWrite.reset();
m_cindTexAdditive.reset();
m_noTexZTestZWrite.reset();
m_noTexNoZTestZWrite.reset();
m_noTexZTestNoZWrite.reset();
m_noTexNoZTestNoZWrite.reset();
m_noTexAdditiveZTest.reset();
m_noTexAdditiveNoZTest.reset();
}
} }

View File

@ -210,7 +210,7 @@ static const char* FS_METAL_NOTEX =
struct MetalElementDataBindingFactory : TShader<CElementGenShaders>::IDataBindingFactory struct MetalElementDataBindingFactory : TShader<CElementGenShaders>::IDataBindingFactory
{ {
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
CElementGenShaders& shader) CElementGenShaders& shader)
{ {
CElementGen& gen = shader.m_gen; CElementGen& gen = shader.m_gen;
@ -219,7 +219,7 @@ struct MetalElementDataBindingFactory : TShader<CElementGenShaders>::IDataBindin
CUVElement* texr = desc->x54_x40_TEXR.get(); CUVElement* texr = desc->x54_x40_TEXR.get();
CUVElement* tind = desc->x58_x44_TIND.get(); CUVElement* tind = desc->x58_x44_TIND.get();
int texCount = 0; int texCount = 0;
boo::ITexture* textures[3]; boo::ObjToken<boo::ITexture> textures[3];
if (texr) if (texr)
{ {
@ -227,7 +227,7 @@ struct MetalElementDataBindingFactory : TShader<CElementGenShaders>::IDataBindin
texCount = 1; texCount = 1;
if (tind) if (tind)
{ {
textures[1] = CGraphics::g_SpareTexture; textures[1] = CGraphics::g_SpareTexture.get();
textures[2] = tind->GetValueTexture(0).GetObj()->GetBooTexture(); textures[2] = tind->GetValueTexture(0).GetObj()->GetBooTexture();
texCount = 3; texCount = 3;
} }
@ -235,42 +235,42 @@ struct MetalElementDataBindingFactory : TShader<CElementGenShaders>::IDataBindin
if (gen.m_instBuf) if (gen.m_instBuf)
{ {
boo::IGraphicsBuffer* uniforms[] = {gen.m_uniformBuf}; boo::ObjToken<boo::IGraphicsBuffer> uniforms[] = {gen.m_uniformBuf.get()};
if (shader.m_regPipeline) if (shader.m_regPipeline)
gen.m_normalDataBind = ctx.newShaderDataBinding(shader.m_regPipeline, nullptr, nullptr, gen.m_normalDataBind = ctx.newShaderDataBinding(shader.m_regPipeline, nullptr, nullptr,
gen.m_instBuf, nullptr, 1, uniforms, gen.m_instBuf.get(), nullptr, 1, uniforms,
nullptr, texCount, textures, nullptr, nullptr); nullptr, texCount, textures, nullptr, nullptr);
if (shader.m_regPipelineSub) if (shader.m_regPipelineSub)
gen.m_normalSubDataBind = ctx.newShaderDataBinding(shader.m_regPipelineSub, nullptr, nullptr, gen.m_normalSubDataBind = ctx.newShaderDataBinding(shader.m_regPipelineSub, nullptr, nullptr,
gen.m_instBuf, nullptr, 1, uniforms, gen.m_instBuf.get(), nullptr, 1, uniforms,
nullptr, texCount, textures, nullptr, nullptr); nullptr, texCount, textures, nullptr, nullptr);
if (shader.m_redToAlphaPipeline) if (shader.m_redToAlphaPipeline)
gen.m_redToAlphaDataBind = ctx.newShaderDataBinding(shader.m_redToAlphaPipeline, nullptr, nullptr, gen.m_redToAlphaDataBind = ctx.newShaderDataBinding(shader.m_redToAlphaPipeline, nullptr, nullptr,
gen.m_instBuf, nullptr, 1, uniforms, gen.m_instBuf.get(), nullptr, 1, uniforms,
nullptr, texCount, textures, nullptr, nullptr); nullptr, texCount, textures, nullptr, nullptr);
if (shader.m_redToAlphaPipelineSub) if (shader.m_redToAlphaPipelineSub)
gen.m_redToAlphaSubDataBind = ctx.newShaderDataBinding(shader.m_redToAlphaPipelineSub, nullptr, nullptr, gen.m_redToAlphaSubDataBind = ctx.newShaderDataBinding(shader.m_redToAlphaPipelineSub, nullptr, nullptr,
gen.m_instBuf, nullptr, 1, uniforms, gen.m_instBuf.get(), nullptr, 1, uniforms,
nullptr, texCount, textures, nullptr, nullptr); nullptr, texCount, textures, nullptr, nullptr);
} }
if (gen.m_instBufPmus) if (gen.m_instBufPmus)
{ {
boo::IGraphicsBuffer* uniforms[] = {gen.m_uniformBufPmus}; boo::ObjToken<boo::IGraphicsBuffer> uniforms[] = {gen.m_uniformBufPmus.get()};
texCount = std::min(texCount, 1); texCount = std::min(texCount, 1);
if (shader.m_regPipelinePmus) if (shader.m_regPipelinePmus)
gen.m_normalDataBindPmus = ctx.newShaderDataBinding(shader.m_regPipelinePmus, nullptr, nullptr, gen.m_normalDataBindPmus = ctx.newShaderDataBinding(shader.m_regPipelinePmus, nullptr, nullptr,
gen.m_instBufPmus, nullptr, 1, uniforms, gen.m_instBufPmus.get(), nullptr, 1, uniforms,
nullptr, texCount, textures, nullptr, nullptr); nullptr, texCount, textures, nullptr, nullptr);
if (shader.m_redToAlphaPipelinePmus) if (shader.m_redToAlphaPipelinePmus)
gen.m_redToAlphaDataBindPmus = ctx.newShaderDataBinding(shader.m_redToAlphaPipelinePmus, nullptr, nullptr, gen.m_redToAlphaDataBindPmus = ctx.newShaderDataBinding(shader.m_redToAlphaPipelinePmus, nullptr, nullptr,
gen.m_instBufPmus, nullptr, 1, uniforms, gen.m_instBufPmus.get(), nullptr, 1, uniforms,
nullptr, texCount, textures, nullptr, nullptr); nullptr, texCount, textures, nullptr, nullptr);
} }
return nullptr; return {};
} }
}; };
@ -315,116 +315,152 @@ TShader<CElementGenShaders>::IDataBindingFactory* CElementGenShaders::Initialize
}; };
m_vtxFormatNoTex = ctx.newVertexFormat(5, TexFmtNoTex); m_vtxFormatNoTex = ctx.newVertexFormat(5, TexFmtNoTex);
m_texZTestZWrite = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX, m_vtxFormatTex, m_texZTestZWrite = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX, nullptr, nullptr,
CGraphics::g_ViewportSamples, m_vtxFormatTex, CGraphics::g_ViewportSamples,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha, boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
boo::Primitive::TriStrips, boo::ZTest::LEqual, true, true, true, boo::CullMode::None); boo::Primitive::TriStrips, boo::ZTest::LEqual, true, true, true, boo::CullMode::None);
m_texNoZTestZWrite = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX, m_vtxFormatTex, m_texNoZTestZWrite = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX, nullptr, nullptr,
CGraphics::g_ViewportSamples, m_vtxFormatTex, CGraphics::g_ViewportSamples,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha, boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
boo::Primitive::TriStrips, boo::ZTest::None, true, true, true, boo::CullMode::None); boo::Primitive::TriStrips, boo::ZTest::None, true, true, true, boo::CullMode::None);
m_texZTestNoZWrite = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX, m_vtxFormatTex, m_texZTestNoZWrite = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX, nullptr, nullptr,
CGraphics::g_ViewportSamples, m_vtxFormatTex, CGraphics::g_ViewportSamples,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha, boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
boo::Primitive::TriStrips, boo::ZTest::LEqual, false, true, true, boo::CullMode::None); boo::Primitive::TriStrips, boo::ZTest::LEqual, false, true, true, boo::CullMode::None);
m_texNoZTestNoZWrite = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX, m_vtxFormatTex, m_texNoZTestNoZWrite = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX, nullptr, nullptr,
CGraphics::g_ViewportSamples, m_vtxFormatTex, CGraphics::g_ViewportSamples,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha, boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
boo::Primitive::TriStrips, boo::ZTest::None, false, true, true, boo::CullMode::None); boo::Primitive::TriStrips, boo::ZTest::None, false, true, true, boo::CullMode::None);
m_texAdditiveZTest = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX, m_vtxFormatTex, m_texAdditiveZTest = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX, nullptr, nullptr,
CGraphics::g_ViewportSamples, m_vtxFormatTex, CGraphics::g_ViewportSamples,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One, boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
boo::Primitive::TriStrips, boo::ZTest::LEqual, false, true, true, boo::CullMode::None); boo::Primitive::TriStrips, boo::ZTest::LEqual, false, true, true, boo::CullMode::None);
m_texAdditiveNoZTest = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX, m_vtxFormatTex, m_texAdditiveNoZTest = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX, nullptr, nullptr,
CGraphics::g_ViewportSamples, m_vtxFormatTex, CGraphics::g_ViewportSamples,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One, boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
boo::Primitive::TriStrips, boo::ZTest::None, false, true, true, boo::CullMode::None); boo::Primitive::TriStrips, boo::ZTest::None, false, true, true, boo::CullMode::None);
m_texRedToAlphaZTest = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX_REDTOALPHA, m_vtxFormatTex, m_texRedToAlphaZTest = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX_REDTOALPHA, nullptr, nullptr,
CGraphics::g_ViewportSamples, m_vtxFormatTex, CGraphics::g_ViewportSamples,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha, boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
boo::Primitive::TriStrips, boo::ZTest::LEqual, false, true, true, boo::CullMode::None); boo::Primitive::TriStrips, boo::ZTest::LEqual, false, true, true, boo::CullMode::None);
m_texRedToAlphaNoZTest = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX_REDTOALPHA, m_vtxFormatTex, m_texRedToAlphaNoZTest = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX_REDTOALPHA, nullptr, nullptr,
CGraphics::g_ViewportSamples, m_vtxFormatTex, CGraphics::g_ViewportSamples,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha, boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
boo::Primitive::TriStrips, boo::ZTest::None, false, true, true, boo::CullMode::None); boo::Primitive::TriStrips, boo::ZTest::None, false, true, true, boo::CullMode::None);
m_texZTestNoZWriteSub = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX, m_vtxFormatTex, m_texZTestNoZWriteSub = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX, nullptr, nullptr,
CGraphics::g_ViewportSamples, m_vtxFormatTex, CGraphics::g_ViewportSamples,
boo::BlendFactor::Subtract, boo::BlendFactor::Subtract, boo::BlendFactor::Subtract, boo::BlendFactor::Subtract,
boo::Primitive::TriStrips, boo::ZTest::LEqual, false, boo::Primitive::TriStrips, boo::ZTest::LEqual, false,
true, false, boo::CullMode::None); true, false, boo::CullMode::None);
m_texNoZTestNoZWriteSub = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX, m_vtxFormatTex, m_texNoZTestNoZWriteSub = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX, nullptr, nullptr,
CGraphics::g_ViewportSamples, m_vtxFormatTex, CGraphics::g_ViewportSamples,
boo::BlendFactor::Subtract, boo::BlendFactor::Subtract, boo::BlendFactor::Subtract, boo::BlendFactor::Subtract,
boo::Primitive::TriStrips, boo::ZTest::None, false, boo::Primitive::TriStrips, boo::ZTest::None, false,
true, false, boo::CullMode::None); true, false, boo::CullMode::None);
m_texRedToAlphaZTestSub = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX_REDTOALPHA, m_vtxFormatTex, m_texRedToAlphaZTestSub = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX_REDTOALPHA, nullptr, nullptr,
CGraphics::g_ViewportSamples, m_vtxFormatTex, CGraphics::g_ViewportSamples,
boo::BlendFactor::Subtract, boo::BlendFactor::Subtract, boo::BlendFactor::Subtract, boo::BlendFactor::Subtract,
boo::Primitive::TriStrips, boo::ZTest::LEqual, false, boo::Primitive::TriStrips, boo::ZTest::LEqual, false,
true, false, boo::CullMode::None); true, false, boo::CullMode::None);
m_texRedToAlphaNoZTestSub = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX_REDTOALPHA, m_vtxFormatTex, m_texRedToAlphaNoZTestSub = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX_REDTOALPHA, nullptr, nullptr,
CGraphics::g_ViewportSamples, m_vtxFormatTex, CGraphics::g_ViewportSamples,
boo::BlendFactor::Subtract, boo::BlendFactor::Subtract, boo::BlendFactor::Subtract, boo::BlendFactor::Subtract,
boo::Primitive::TriStrips, boo::ZTest::None, false, boo::Primitive::TriStrips, boo::ZTest::None, false,
true, false, boo::CullMode::None); true, false, boo::CullMode::None);
m_indTexZWrite = ctx.newShaderPipeline(VS_METAL_INDTEX, FS_METAL_INDTEX, m_vtxFormatIndTex, m_indTexZWrite = ctx.newShaderPipeline(VS_METAL_INDTEX, FS_METAL_INDTEX, nullptr, nullptr,
CGraphics::g_ViewportSamples, m_vtxFormatIndTex, CGraphics::g_ViewportSamples,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha, boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
boo::Primitive::TriStrips, boo::ZTest::None, true, true, true, boo::CullMode::None); boo::Primitive::TriStrips, boo::ZTest::None, true, true, true, boo::CullMode::None);
m_indTexNoZWrite = ctx.newShaderPipeline(VS_METAL_INDTEX, FS_METAL_INDTEX, m_vtxFormatIndTex, m_indTexNoZWrite = ctx.newShaderPipeline(VS_METAL_INDTEX, FS_METAL_INDTEX, nullptr, nullptr,
CGraphics::g_ViewportSamples, m_vtxFormatIndTex, CGraphics::g_ViewportSamples,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha, boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
boo::Primitive::TriStrips, boo::ZTest::None, false, true, true, boo::CullMode::None); boo::Primitive::TriStrips, boo::ZTest::None, false, true, true, boo::CullMode::None);
m_indTexAdditive = ctx.newShaderPipeline(VS_METAL_INDTEX, FS_METAL_INDTEX, m_vtxFormatIndTex, m_indTexAdditive = ctx.newShaderPipeline(VS_METAL_INDTEX, FS_METAL_INDTEX, nullptr, nullptr,
CGraphics::g_ViewportSamples, m_vtxFormatIndTex, CGraphics::g_ViewportSamples,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One, boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
boo::Primitive::TriStrips, boo::ZTest::None, true, true, true, boo::CullMode::None); boo::Primitive::TriStrips, boo::ZTest::None, true, true, true, boo::CullMode::None);
m_cindTexZWrite = ctx.newShaderPipeline(VS_METAL_INDTEX, FS_METAL_CINDTEX, m_vtxFormatIndTex, m_cindTexZWrite = ctx.newShaderPipeline(VS_METAL_INDTEX, FS_METAL_CINDTEX, nullptr, nullptr,
CGraphics::g_ViewportSamples, m_vtxFormatIndTex, CGraphics::g_ViewportSamples,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha, boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
boo::Primitive::TriStrips, boo::ZTest::None, true, true, true, boo::CullMode::None); boo::Primitive::TriStrips, boo::ZTest::None, true, true, true, boo::CullMode::None);
m_cindTexNoZWrite = ctx.newShaderPipeline(VS_METAL_INDTEX, FS_METAL_CINDTEX, m_vtxFormatIndTex, m_cindTexNoZWrite = ctx.newShaderPipeline(VS_METAL_INDTEX, FS_METAL_CINDTEX, nullptr, nullptr,
CGraphics::g_ViewportSamples, m_vtxFormatIndTex, CGraphics::g_ViewportSamples,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha, boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
boo::Primitive::TriStrips, boo::ZTest::None, false, true, true, boo::CullMode::None); boo::Primitive::TriStrips, boo::ZTest::None, false, true, true, boo::CullMode::None);
m_cindTexAdditive = ctx.newShaderPipeline(VS_METAL_INDTEX, FS_METAL_CINDTEX, m_vtxFormatIndTex, m_cindTexAdditive = ctx.newShaderPipeline(VS_METAL_INDTEX, FS_METAL_CINDTEX, nullptr, nullptr,
CGraphics::g_ViewportSamples, m_vtxFormatIndTex, CGraphics::g_ViewportSamples,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One, boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
boo::Primitive::TriStrips, boo::ZTest::None, true, true, true, boo::CullMode::None); boo::Primitive::TriStrips, boo::ZTest::None, true, true, true, boo::CullMode::None);
m_noTexZTestZWrite = ctx.newShaderPipeline(VS_METAL_NOTEX, FS_METAL_NOTEX, m_vtxFormatNoTex, m_noTexZTestZWrite = ctx.newShaderPipeline(VS_METAL_NOTEX, FS_METAL_NOTEX, nullptr, nullptr,
CGraphics::g_ViewportSamples, m_vtxFormatNoTex, CGraphics::g_ViewportSamples,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha, boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
boo::Primitive::TriStrips, boo::ZTest::LEqual, true, true, true, boo::CullMode::None); boo::Primitive::TriStrips, boo::ZTest::LEqual, true, true, true, boo::CullMode::None);
m_noTexNoZTestZWrite = ctx.newShaderPipeline(VS_METAL_NOTEX, FS_METAL_NOTEX, m_vtxFormatNoTex, m_noTexNoZTestZWrite = ctx.newShaderPipeline(VS_METAL_NOTEX, FS_METAL_NOTEX, nullptr, nullptr,
CGraphics::g_ViewportSamples, m_vtxFormatNoTex, CGraphics::g_ViewportSamples,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha, boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
boo::Primitive::TriStrips, boo::ZTest::None, true, true, true, boo::CullMode::None); boo::Primitive::TriStrips, boo::ZTest::None, true, true, true, boo::CullMode::None);
m_noTexZTestNoZWrite = ctx.newShaderPipeline(VS_METAL_NOTEX, FS_METAL_NOTEX, m_vtxFormatNoTex, m_noTexZTestNoZWrite = ctx.newShaderPipeline(VS_METAL_NOTEX, FS_METAL_NOTEX, nullptr, nullptr,
CGraphics::g_ViewportSamples, m_vtxFormatNoTex, CGraphics::g_ViewportSamples,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha, boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
boo::Primitive::TriStrips, boo::ZTest::LEqual, false, true, true, boo::CullMode::None); boo::Primitive::TriStrips, boo::ZTest::LEqual, false, true, true, boo::CullMode::None);
m_noTexNoZTestNoZWrite = ctx.newShaderPipeline(VS_METAL_NOTEX, FS_METAL_NOTEX, m_vtxFormatNoTex, m_noTexNoZTestNoZWrite = ctx.newShaderPipeline(VS_METAL_NOTEX, FS_METAL_NOTEX, nullptr, nullptr,
CGraphics::g_ViewportSamples, m_vtxFormatNoTex, CGraphics::g_ViewportSamples,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha, boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
boo::Primitive::TriStrips, boo::ZTest::None, false, true, true, boo::CullMode::None); boo::Primitive::TriStrips, boo::ZTest::None, false, true, true, boo::CullMode::None);
m_noTexAdditiveZTest = ctx.newShaderPipeline(VS_METAL_NOTEX, FS_METAL_NOTEX, m_vtxFormatNoTex, m_noTexAdditiveZTest = ctx.newShaderPipeline(VS_METAL_NOTEX, FS_METAL_NOTEX, nullptr, nullptr,
CGraphics::g_ViewportSamples, m_vtxFormatNoTex, CGraphics::g_ViewportSamples,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One, boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
boo::Primitive::TriStrips, boo::ZTest::LEqual, false, true, true, boo::CullMode::None); boo::Primitive::TriStrips, boo::ZTest::LEqual, false, true, true, boo::CullMode::None);
m_noTexAdditiveNoZTest = ctx.newShaderPipeline(VS_METAL_NOTEX, FS_METAL_NOTEX, m_vtxFormatNoTex, m_noTexAdditiveNoZTest = ctx.newShaderPipeline(VS_METAL_NOTEX, FS_METAL_NOTEX, nullptr, nullptr,
CGraphics::g_ViewportSamples, m_vtxFormatNoTex, CGraphics::g_ViewportSamples,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One, boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
boo::Primitive::TriStrips, boo::ZTest::None, false, true, true, boo::CullMode::None); boo::Primitive::TriStrips, boo::ZTest::None, false, true, true, boo::CullMode::None);
return new struct MetalElementDataBindingFactory; return new struct MetalElementDataBindingFactory;
} }
template <>
void CElementGenShaders::Shutdown<boo::MetalDataFactory>()
{
m_texZTestZWrite.reset();
m_texNoZTestZWrite.reset();
m_texZTestNoZWrite.reset();
m_texNoZTestNoZWrite.reset();
m_texAdditiveZTest.reset();
m_texAdditiveNoZTest.reset();
m_texRedToAlphaZTest.reset();
m_texRedToAlphaNoZTest.reset();
m_texZTestNoZWriteSub.reset();
m_texNoZTestNoZWriteSub.reset();
m_texRedToAlphaZTestSub.reset();
m_texRedToAlphaNoZTestSub.reset();
m_indTexZWrite.reset();
m_indTexNoZWrite.reset();
m_indTexAdditive.reset();
m_cindTexZWrite.reset();
m_cindTexNoZWrite.reset();
m_cindTexAdditive.reset();
m_noTexZTestZWrite.reset();
m_noTexNoZTestZWrite.reset();
m_noTexZTestNoZWrite.reset();
m_noTexNoZTestNoZWrite.reset();
m_noTexAdditiveZTest.reset();
m_noTexAdditiveNoZTest.reset();
m_vtxFormatTex.reset();
m_vtxFormatIndTex.reset();
m_vtxFormatNoTex.reset();
}
} }

View File

@ -21,7 +21,7 @@ void CEnergyBarShader::draw(const zeus::CColor& color0, const std::vector<Vertex
{ {
m_maxVerts = totalVerts; m_maxVerts = totalVerts;
m_tex = tex; m_tex = tex;
m_token = CGraphics::CommitResources([this](boo::IGraphicsDataFactory::Context& ctx) CGraphics::CommitResources([this](boo::IGraphicsDataFactory::Context& ctx)
{ {
m_vbo = ctx.newDynamicBuffer(boo::BufferUse::Vertex, sizeof(Vertex), m_maxVerts); m_vbo = ctx.newDynamicBuffer(boo::BufferUse::Vertex, sizeof(Vertex), m_maxVerts);
for (int i=0 ; i<3 ; ++i) for (int i=0 ; i<3 ; ++i)
@ -77,6 +77,4 @@ void CEnergyBarShader::draw(const zeus::CColor& color0, const std::vector<Vertex
URDE_SPECIALIZE_SHADER(CEnergyBarShader) URDE_SPECIALIZE_SHADER(CEnergyBarShader)
void CEnergyBarShader::Shutdown() {}
} }

View File

@ -30,10 +30,9 @@ private:
zeus::CMatrix4f m_matrix; zeus::CMatrix4f m_matrix;
zeus::CColor m_color; zeus::CColor m_color;
}; };
boo::GraphicsDataToken m_token; boo::ObjToken<boo::IGraphicsBufferD> m_vbo;
boo::IGraphicsBufferD* m_vbo; boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf[3];
boo::IGraphicsBufferD* m_uniBuf[3]; boo::ObjToken<boo::IShaderDataBinding> m_dataBind[3];
boo::IShaderDataBinding* m_dataBind[3];
Uniform m_uniform; Uniform m_uniform;
const CTexture* m_tex = nullptr; const CTexture* m_tex = nullptr;
size_t m_maxVerts = 0; size_t m_maxVerts = 0;

View File

@ -50,30 +50,30 @@ BOO_GLSL_BINDING_HEAD
URDE_DECL_SPECIALIZE_SHADER(CEnergyBarShader) URDE_DECL_SPECIALIZE_SHADER(CEnergyBarShader)
static boo::IVertexFormat* s_VtxFmt = nullptr; static boo::ObjToken<boo::IVertexFormat> s_VtxFmt;
static boo::IShaderPipeline* s_Pipeline = nullptr; static boo::ObjToken<boo::IShaderPipeline> s_Pipeline;
struct CEnergyBarShaderGLDataBindingFactory : TShader<CEnergyBarShader>::IDataBindingFactory struct CEnergyBarShaderGLDataBindingFactory : TShader<CEnergyBarShader>::IDataBindingFactory
{ {
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
CEnergyBarShader& filter) CEnergyBarShader& filter)
{ {
boo::GLDataFactory::Context& cctx = static_cast<boo::GLDataFactory::Context&>(ctx); boo::GLDataFactory::Context& cctx = static_cast<boo::GLDataFactory::Context&>(ctx);
const boo::VertexElementDescriptor VtxVmt[] = const boo::VertexElementDescriptor VtxVmt[] =
{ {
{filter.m_vbo, nullptr, boo::VertexSemantic::Position4}, {filter.m_vbo.get(), nullptr, boo::VertexSemantic::Position4},
{filter.m_vbo, nullptr, boo::VertexSemantic::UV4} {filter.m_vbo.get(), nullptr, boo::VertexSemantic::UV4}
}; };
boo::IVertexFormat* vtxFmt = ctx.newVertexFormat(2, VtxVmt); boo::ObjToken<boo::IVertexFormat> vtxFmt = ctx.newVertexFormat(2, VtxVmt);
boo::IGraphicsBuffer* bufs[1]; boo::ObjToken<boo::IGraphicsBuffer> bufs[1];
boo::PipelineStage stages[] = {boo::PipelineStage::Vertex}; boo::PipelineStage stages[] = {boo::PipelineStage::Vertex};
boo::ITexture* texs[] = {filter.m_tex->GetBooTexture()}; boo::ObjToken<boo::ITexture> texs[] = {filter.m_tex->GetBooTexture()};
for (int i=0 ; i<3 ; ++i) for (int i=0 ; i<3 ; ++i)
{ {
bufs[0] = filter.m_uniBuf[i]; bufs[0] = filter.m_uniBuf[i].get();
filter.m_dataBind[i] = cctx.newShaderDataBinding(s_Pipeline, filter.m_dataBind[i] = cctx.newShaderDataBinding(s_Pipeline,
vtxFmt, filter.m_vbo, nullptr, nullptr, vtxFmt, filter.m_vbo.get(), nullptr, nullptr,
1, bufs, stages, nullptr, nullptr, 1, texs, nullptr, nullptr); 1, bufs, stages, nullptr, nullptr, 1, texs, nullptr, nullptr);
} }
return filter.m_dataBind[0]; return filter.m_dataBind[0];
@ -83,18 +83,18 @@ struct CEnergyBarShaderGLDataBindingFactory : TShader<CEnergyBarShader>::IDataBi
#if BOO_HAS_VULKAN #if BOO_HAS_VULKAN
struct CEnergyBarShaderVulkanDataBindingFactory : TShader<CEnergyBarShader>::IDataBindingFactory struct CEnergyBarShaderVulkanDataBindingFactory : TShader<CEnergyBarShader>::IDataBindingFactory
{ {
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
CEnergyBarShader& filter) CEnergyBarShader& filter)
{ {
boo::VulkanDataFactory::Context& cctx = static_cast<boo::VulkanDataFactory::Context&>(ctx); boo::VulkanDataFactory::Context& cctx = static_cast<boo::VulkanDataFactory::Context&>(ctx);
boo::IGraphicsBuffer* bufs[1]; boo::ObjToken<boo::IGraphicsBuffer> bufs[1];
boo::ITexture* texs[] = {filter.m_tex->GetBooTexture()}; boo::ObjToken<boo::ITexture> texs[] = {filter.m_tex->GetBooTexture()};
for (int i=0 ; i<3 ; ++i) for (int i=0 ; i<3 ; ++i)
{ {
bufs[0] = filter.m_uniBuf[i]; bufs[0] = filter.m_uniBuf[i].get();
filter.m_dataBind[i] = cctx.newShaderDataBinding(s_Pipeline, s_VtxFmt, filter.m_dataBind[i] = cctx.newShaderDataBinding(s_Pipeline, s_VtxFmt,
filter.m_vbo, nullptr, nullptr, 1, bufs, filter.m_vbo.get(), nullptr, nullptr, 1, bufs,
nullptr, nullptr, nullptr, 1, texs, nullptr, nullptr); nullptr, nullptr, nullptr, 1, texs, nullptr, nullptr);
} }
return filter.m_dataBind[0]; return filter.m_dataBind[0];
@ -113,6 +113,12 @@ CEnergyBarShader::Initialize(boo::GLDataFactory::Context& ctx)
return new CEnergyBarShaderGLDataBindingFactory; return new CEnergyBarShaderGLDataBindingFactory;
} }
template <>
void CEnergyBarShader::Shutdown<boo::GLDataFactory>()
{
s_Pipeline.reset();
}
#if BOO_HAS_VULKAN #if BOO_HAS_VULKAN
TShader<CEnergyBarShader>::IDataBindingFactory* TShader<CEnergyBarShader>::IDataBindingFactory*
CEnergyBarShader::Initialize(boo::VulkanDataFactory::Context& ctx) CEnergyBarShader::Initialize(boo::VulkanDataFactory::Context& ctx)
@ -128,6 +134,13 @@ CEnergyBarShader::Initialize(boo::VulkanDataFactory::Context& ctx)
boo::ZTest::LEqual, false, true, false, boo::CullMode::None); boo::ZTest::LEqual, false, true, false, boo::CullMode::None);
return new CEnergyBarShaderVulkanDataBindingFactory; return new CEnergyBarShaderVulkanDataBindingFactory;
} }
template <>
void CEnergyBarShader::Shutdown<boo::VulkanDataFactory>()
{
s_VtxFmt.reset();
s_Pipeline.reset();
}
#endif #endif
} }

View File

@ -52,23 +52,24 @@ static const char* FS =
URDE_DECL_SPECIALIZE_SHADER(CEnergyBarShader) URDE_DECL_SPECIALIZE_SHADER(CEnergyBarShader)
static boo::IVertexFormat* s_VtxFmt = nullptr; static boo::ObjToken<boo::IVertexFormat> s_VtxFmt;
static boo::IShaderPipeline* s_Pipeline = nullptr; static boo::ObjToken<boo::IShaderPipeline> s_Pipeline;
struct CEnergyBarShaderD3DDataBindingFactory : TShader<CEnergyBarShader>::IDataBindingFactory struct CEnergyBarShaderD3DDataBindingFactory : TShader<CEnergyBarShader>::IDataBindingFactory
{ {
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, boo::ObjToken<boo::IShaderDataBinding>
BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
CEnergyBarShader& filter) CEnergyBarShader& filter)
{ {
boo::ID3DDataFactory::Context& cctx = static_cast<boo::ID3DDataFactory::Context&>(ctx); boo::ID3DDataFactory::Context& cctx = static_cast<boo::ID3DDataFactory::Context&>(ctx);
boo::IGraphicsBuffer* bufs[1]; boo::ObjToken<boo::IGraphicsBuffer> bufs[1];
boo::ITexture* texs[] = {filter.m_tex->GetBooTexture()}; boo::ObjToken<boo::ITexture> texs[] = {filter.m_tex->GetBooTexture()};
for (int i=0 ; i<3 ; ++i) for (int i=0 ; i<3 ; ++i)
{ {
bufs[0] = filter.m_uniBuf[i]; bufs[0] = filter.m_uniBuf[i].get();
filter.m_dataBind[i] = cctx.newShaderDataBinding(s_Pipeline, s_VtxFmt, filter.m_dataBind[i] = cctx.newShaderDataBinding(s_Pipeline, s_VtxFmt,
filter.m_vbo, nullptr, nullptr, 1, bufs, filter.m_vbo.get(), nullptr, nullptr, 1, bufs,
nullptr, nullptr, nullptr, 1, texs, nullptr, nullptr); nullptr, nullptr, nullptr, 1, texs, nullptr, nullptr);
} }
return filter.m_dataBind[0]; return filter.m_dataBind[0];
@ -90,4 +91,11 @@ CEnergyBarShader::Initialize(boo::ID3DDataFactory::Context& ctx)
boo::ZTest::LEqual, false, true, false, boo::CullMode::None); boo::ZTest::LEqual, false, true, false, boo::CullMode::None);
return new CEnergyBarShaderD3DDataBindingFactory; return new CEnergyBarShaderD3DDataBindingFactory;
} }
template <>
void CEnergyBarShader::Shutdown<boo::ID3DDataFactory>()
{
s_VtxFmt.reset();
s_Pipeline.reset();
}
} }

View File

@ -54,23 +54,23 @@ static const char* FS =
URDE_DECL_SPECIALIZE_SHADER(CEnergyBarShader) URDE_DECL_SPECIALIZE_SHADER(CEnergyBarShader)
static boo::IVertexFormat* s_VtxFmt = nullptr; static boo::ObjToken<boo::IVertexFormat> s_VtxFmt;
static boo::IShaderPipeline* s_Pipeline = nullptr; static boo::ObjToken<boo::IShaderPipeline> s_Pipeline;
struct CEnergyBarShaderMetalDataBindingFactory : TShader<CEnergyBarShader>::IDataBindingFactory struct CEnergyBarShaderMetalDataBindingFactory : TShader<CEnergyBarShader>::IDataBindingFactory
{ {
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
CEnergyBarShader& filter) CEnergyBarShader& filter)
{ {
boo::MetalDataFactory::Context& cctx = static_cast<boo::MetalDataFactory::Context&>(ctx); boo::MetalDataFactory::Context& cctx = static_cast<boo::MetalDataFactory::Context&>(ctx);
boo::IGraphicsBuffer* bufs[1]; boo::ObjToken<boo::IGraphicsBuffer> bufs[1];
boo::ITexture* texs[] = {filter.m_tex->GetBooTexture()}; boo::ObjToken<boo::ITexture> texs[] = {filter.m_tex->GetBooTexture()};
for (int i=0 ; i<3 ; ++i) for (int i=0 ; i<3 ; ++i)
{ {
bufs[0] = filter.m_uniBuf[i]; bufs[0] = filter.m_uniBuf[i].get();
filter.m_dataBind[i] = cctx.newShaderDataBinding(s_Pipeline, s_VtxFmt, filter.m_dataBind[i] = cctx.newShaderDataBinding(s_Pipeline, s_VtxFmt,
filter.m_vbo, nullptr, nullptr, 1, bufs, filter.m_vbo.get(), nullptr, nullptr, 1, bufs,
nullptr, nullptr, nullptr, 1, texs, nullptr, nullptr); nullptr, nullptr, nullptr, 1, texs, nullptr, nullptr);
} }
return filter.m_dataBind[0]; return filter.m_dataBind[0];
@ -86,11 +86,19 @@ CEnergyBarShader::Initialize(boo::MetalDataFactory::Context& ctx)
{nullptr, nullptr, boo::VertexSemantic::UV4} {nullptr, nullptr, boo::VertexSemantic::UV4}
}; };
s_VtxFmt = ctx.newVertexFormat(2, VtxVmt); s_VtxFmt = ctx.newVertexFormat(2, VtxVmt);
s_Pipeline = ctx.newShaderPipeline(VS, FS, s_VtxFmt, CGraphics::g_ViewportSamples, s_Pipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr,
s_VtxFmt, CGraphics::g_ViewportSamples,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One, boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
boo::Primitive::TriStrips, boo::ZTest::LEqual, boo::Primitive::TriStrips, boo::ZTest::LEqual,
false, true, false, boo::CullMode::None); false, true, false, boo::CullMode::None);
return new CEnergyBarShaderMetalDataBindingFactory; return new CEnergyBarShaderMetalDataBindingFactory;
} }
template <>
void CEnergyBarShader::Shutdown<boo::MetalDataFactory>()
{
s_VtxFmt.reset();
s_Pipeline.reset();
}
} }

View File

@ -89,38 +89,38 @@ u16 CFluidPlaneShader::Cache::MakeCacheKey(const SFluidPlaneDoorShaderInfo& info
} }
template<class T> template<class T>
boo::IShaderPipeline* CFluidPlaneShader::Cache::GetOrBuildShader(const T& info) boo::ObjToken<boo::IShaderPipeline> CFluidPlaneShader::Cache::GetOrBuildShader(const T& info)
{ {
u16 key = MakeCacheKey(info); u16 key = MakeCacheKey(info);
auto& slot = CacheSlot(info, key); auto& slot = CacheSlot(info, key);
if (slot.second != nullptr) if (slot)
return slot.second; return slot;
if (CGraphics::g_BooFactory == nullptr) if (CGraphics::g_BooFactory == nullptr)
return nullptr; return nullptr;
slot.first = CGraphics::CommitResources( CGraphics::CommitResources(
[&](boo::IGraphicsDataFactory::Context& ctx) [&](boo::IGraphicsDataFactory::Context& ctx)
{ {
switch (ctx.platform()) switch (ctx.platform())
{ {
case boo::IGraphicsDataFactory::Platform::OpenGL: case boo::IGraphicsDataFactory::Platform::OpenGL:
slot.second = BuildShader(static_cast<boo::GLDataFactory::Context&>(ctx), info); slot = BuildShader(static_cast<boo::GLDataFactory::Context&>(ctx), info);
break; break;
#if _WIN32 #if _WIN32
case boo::IGraphicsDataFactory::Platform::D3D11: case boo::IGraphicsDataFactory::Platform::D3D11:
case boo::IGraphicsDataFactory::Platform::D3D12: case boo::IGraphicsDataFactory::Platform::D3D12:
slot.second = BuildShader(static_cast<boo::ID3DDataFactory::Context&>(ctx), info); slot = BuildShader(static_cast<boo::ID3DDataFactory::Context&>(ctx), info);
break; break;
#endif #endif
#if BOO_HAS_METAL #if BOO_HAS_METAL
case boo::IGraphicsDataFactory::Platform::Metal: case boo::IGraphicsDataFactory::Platform::Metal:
slot.second = BuildShader(static_cast<boo::MetalDataFactory::Context&>(ctx), info); slot = BuildShader(static_cast<boo::MetalDataFactory::Context&>(ctx), info);
break; break;
#endif #endif
#if BOO_HAS_VULKAN #if BOO_HAS_VULKAN
case boo::IGraphicsDataFactory::Platform::Vulkan: case boo::IGraphicsDataFactory::Platform::Vulkan:
slot.second = BuildShader(static_cast<boo::VulkanDataFactory::Context&>(ctx), info); slot = BuildShader(static_cast<boo::VulkanDataFactory::Context&>(ctx), info);
break; break;
#endif #endif
default: break; default: break;
@ -128,31 +128,25 @@ boo::IShaderPipeline* CFluidPlaneShader::Cache::GetOrBuildShader(const T& info)
return true; return true;
}); });
return slot.second; return slot;
} }
template boo::IShaderPipeline* template boo::ObjToken<boo::IShaderPipeline>
CFluidPlaneShader::Cache::GetOrBuildShader<SFluidPlaneShaderInfo>(const SFluidPlaneShaderInfo& info); CFluidPlaneShader::Cache::GetOrBuildShader<SFluidPlaneShaderInfo>(const SFluidPlaneShaderInfo& info);
template boo::IShaderPipeline* template boo::ObjToken<boo::IShaderPipeline>
CFluidPlaneShader::Cache::GetOrBuildShader<SFluidPlaneDoorShaderInfo>(const SFluidPlaneDoorShaderInfo& info); CFluidPlaneShader::Cache::GetOrBuildShader<SFluidPlaneDoorShaderInfo>(const SFluidPlaneDoorShaderInfo& info);
void CFluidPlaneShader::Cache::Clear() void CFluidPlaneShader::Cache::Clear()
{ {
for (auto& p : m_cache) for (auto& p : m_cache)
{ p.reset();
p.first.doDestroy();
p.second = nullptr;
}
for (auto& p : m_doorCache) for (auto& p : m_doorCache)
{ p.reset();
p.first.doDestroy();
p.second = nullptr;
}
} }
void CFluidPlaneShader::PrepareBinding(boo::IShaderPipeline* pipeline, u32 maxVertCount, bool door) void CFluidPlaneShader::PrepareBinding(const boo::ObjToken<boo::IShaderPipeline>& pipeline, u32 maxVertCount, bool door)
{ {
m_gfxTok = CGraphics::CommitResources( CGraphics::CommitResources(
[&](boo::IGraphicsDataFactory::Context& ctx) [&](boo::IGraphicsDataFactory::Context& ctx)
{ {
m_vbo = ctx.newDynamicBuffer(boo::BufferUse::Vertex, sizeof(Vertex), maxVertCount); m_vbo = ctx.newDynamicBuffer(boo::BufferUse::Vertex, sizeof(Vertex), maxVertCount);
@ -211,7 +205,7 @@ CFluidPlaneShader::CFluidPlaneShader(CFluidPlane::EFluidType type,
m_envBumpMap.operator bool(), m_envBumpMap.operator bool(),
m_lightmap.operator bool(), m_lightmap.operator bool(),
doubleLightmapBlend, additive); doubleLightmapBlend, additive);
boo::IShaderPipeline* pipeline = _cache.GetOrBuildShader(shaderInfo); boo::ObjToken<boo::IShaderPipeline> pipeline = _cache.GetOrBuildShader(shaderInfo);
PrepareBinding(pipeline, maxVertCount, false); PrepareBinding(pipeline, maxVertCount, false);
} }
@ -226,7 +220,7 @@ CFluidPlaneShader::CFluidPlaneShader(const std::experimental::optional<TLockedTo
SFluidPlaneDoorShaderInfo shaderInfo(m_patternTex1.operator bool(), SFluidPlaneDoorShaderInfo shaderInfo(m_patternTex1.operator bool(),
m_patternTex2.operator bool(), m_patternTex2.operator bool(),
m_colorTex.operator bool()); m_colorTex.operator bool());
boo::IShaderPipeline* pipeline = _cache.GetOrBuildShader(shaderInfo); boo::ObjToken<boo::IShaderPipeline> pipeline = _cache.GetOrBuildShader(shaderInfo);
PrepareBinding(pipeline, maxVertCount, true); PrepareBinding(pipeline, maxVertCount, true);
} }

View File

@ -82,17 +82,17 @@ public:
private: private:
class Cache class Cache
{ {
std::pair<boo::GraphicsDataToken, boo::IShaderPipeline*> m_cache[1024] = {}; boo::ObjToken<boo::IShaderPipeline> m_cache[1024] = {};
std::pair<boo::GraphicsDataToken, boo::IShaderPipeline*> m_doorCache[8] = {}; boo::ObjToken<boo::IShaderPipeline> m_doorCache[8] = {};
std::pair<boo::GraphicsDataToken, boo::IShaderPipeline*>& boo::ObjToken<boo::IShaderPipeline>&
CacheSlot(const SFluidPlaneShaderInfo& info, int i) { return m_cache[i]; } CacheSlot(const SFluidPlaneShaderInfo& info, int i) { return m_cache[i]; }
std::pair<boo::GraphicsDataToken, boo::IShaderPipeline*>& boo::ObjToken<boo::IShaderPipeline>&
CacheSlot(const SFluidPlaneDoorShaderInfo& info, int i) { return m_doorCache[i]; } CacheSlot(const SFluidPlaneDoorShaderInfo& info, int i) { return m_doorCache[i]; }
static u16 MakeCacheKey(const SFluidPlaneShaderInfo& info); static u16 MakeCacheKey(const SFluidPlaneShaderInfo& info);
static u16 MakeCacheKey(const SFluidPlaneDoorShaderInfo& info); static u16 MakeCacheKey(const SFluidPlaneDoorShaderInfo& info);
public: public:
template<class T> template<class T>
boo::IShaderPipeline* GetOrBuildShader(const T& info); boo::ObjToken<boo::IShaderPipeline> GetOrBuildShader(const T& info);
void Clear(); void Clear();
}; };
static Cache _cache; static Cache _cache;
@ -113,31 +113,42 @@ private:
std::experimental::optional<TLockedToken<CTexture>> m_envMap; std::experimental::optional<TLockedToken<CTexture>> m_envMap;
std::experimental::optional<TLockedToken<CTexture>> m_envBumpMap; std::experimental::optional<TLockedToken<CTexture>> m_envBumpMap;
std::experimental::optional<TLockedToken<CTexture>> m_lightmap; std::experimental::optional<TLockedToken<CTexture>> m_lightmap;
boo::GraphicsDataToken m_gfxTok; boo::ObjToken<boo::IGraphicsBufferD> m_vbo;
boo::IGraphicsBufferD* m_vbo; boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf;
boo::IGraphicsBufferD* m_uniBuf; boo::ObjToken<boo::IShaderDataBinding> m_dataBind;
boo::IShaderDataBinding* m_dataBind;
static boo::IShaderPipeline* BuildShader(boo::GLDataFactory::Context& ctx, const SFluidPlaneShaderInfo& info); static boo::ObjToken<boo::IShaderPipeline> BuildShader(boo::GLDataFactory::Context& ctx,
static boo::IShaderPipeline* BuildShader(boo::GLDataFactory::Context& ctx, const SFluidPlaneDoorShaderInfo& info); const SFluidPlaneShaderInfo& info);
boo::IShaderDataBinding* BuildBinding(boo::GLDataFactory::Context& ctx, boo::IShaderPipeline* pipeline, bool door); static boo::ObjToken<boo::IShaderPipeline> BuildShader(boo::GLDataFactory::Context& ctx,
const SFluidPlaneDoorShaderInfo& info);
boo::ObjToken<boo::IShaderDataBinding> BuildBinding(boo::GLDataFactory::Context& ctx,
const boo::ObjToken<boo::IShaderPipeline>& pipeline, bool door);
#if _WIN32 #if _WIN32
static boo::IShaderPipeline* BuildShader(boo::ID3DDataFactory::Context& ctx, const SFluidPlaneShaderInfo& info); static boo::ObjToken<boo::IShaderPipeline> BuildShader(boo::ID3DDataFactory::Context& ctx,
static boo::IShaderPipeline* BuildShader(boo::ID3DDataFactory::Context& ctx, const SFluidPlaneDoorShaderInfo& info); const SFluidPlaneShaderInfo& info);
boo::IShaderDataBinding* BuildBinding(boo::ID3DDataFactory::Context& ctx, boo::IShaderPipeline* pipeline, bool door); static boo::ObjToken<boo::IShaderPipeline> BuildShader(boo::ID3DDataFactory::Context& ctx,
const SFluidPlaneDoorShaderInfo& info);
boo::ObjToken<boo::IShaderDataBinding> BuildBinding(boo::ID3DDataFactory::Context& ctx,
const boo::ObjToken<boo::IShaderPipeline>& pipeline, bool door);
#endif #endif
#if BOO_HAS_METAL #if BOO_HAS_METAL
static boo::IShaderPipeline* BuildShader(boo::MetalDataFactory::Context& ctx, const SFluidPlaneShaderInfo& info); static boo::ObjToken<boo::IShaderPipeline> BuildShader(boo::MetalDataFactory::Context& ctx,
static boo::IShaderPipeline* BuildShader(boo::MetalDataFactory::Context& ctx, const SFluidPlaneDoorShaderInfo& info); const SFluidPlaneShaderInfo& info);
boo::IShaderDataBinding* BuildBinding(boo::MetalDataFactory::Context& ctx, boo::IShaderPipeline* pipeline, bool door); static boo::ObjToken<boo::IShaderPipeline> BuildShader(boo::MetalDataFactory::Context& ctx,
const SFluidPlaneDoorShaderInfo& info);
boo::ObjToken<boo::IShaderDataBinding> BuildBinding(boo::MetalDataFactory::Context& ctx,
const boo::ObjToken<boo::IShaderPipeline>& pipeline, bool door);
#endif #endif
#if BOO_HAS_VULKAN #if BOO_HAS_VULKAN
static boo::IShaderPipeline* BuildShader(boo::VulkanDataFactory::Context& ctx, const SFluidPlaneShaderInfo& info); static boo::ObjToken<boo::IShaderPipeline> BuildShader(boo::VulkanDataFactory::Context& ctx,
static boo::IShaderPipeline* BuildShader(boo::VulkanDataFactory::Context& ctx, const SFluidPlaneDoorShaderInfo& info); const SFluidPlaneShaderInfo& info);
boo::IShaderDataBinding* BuildBinding(boo::VulkanDataFactory::Context& ctx, boo::IShaderPipeline* pipeline, bool door); static boo::ObjToken<boo::IShaderPipeline> BuildShader(boo::VulkanDataFactory::Context& ctx,
const SFluidPlaneDoorShaderInfo& info);
boo::ObjToken<boo::IShaderDataBinding> BuildBinding(boo::VulkanDataFactory::Context& ctx,
const boo::ObjToken<boo::IShaderPipeline>& pipeline, bool door);
#endif #endif
void PrepareBinding(boo::IShaderPipeline* pipeline, u32 maxVertCount, bool door); void PrepareBinding(const boo::ObjToken<boo::IShaderPipeline>& pipeline, u32 maxVertCount, bool door);
public: public:
CFluidPlaneShader(CFluidPlane::EFluidType type, CFluidPlaneShader(CFluidPlane::EFluidType type,
const std::experimental::optional<TLockedToken<CTexture>>& patternTex1, const std::experimental::optional<TLockedToken<CTexture>>& patternTex1,

View File

@ -509,7 +509,7 @@ static void _BuildShader(std::string& finalVS, std::string& finalFS, int& nextTe
finalFS = hecl::Format(FSDoor, textures.c_str(), combiner.c_str()); finalFS = hecl::Format(FSDoor, textures.c_str(), combiner.c_str());
} }
boo::IShaderPipeline* boo::ObjToken<boo::IShaderPipeline>
CFluidPlaneShader::BuildShader(boo::GLDataFactory::Context& ctx, const SFluidPlaneShaderInfo& info) CFluidPlaneShader::BuildShader(boo::GLDataFactory::Context& ctx, const SFluidPlaneShaderInfo& info)
{ {
int nextTex = 0; int nextTex = 0;
@ -524,7 +524,7 @@ CFluidPlaneShader::BuildShader(boo::GLDataFactory::Context& ctx, const SFluidPla
boo::CullMode::None); boo::CullMode::None);
} }
boo::IShaderPipeline* boo::ObjToken<boo::IShaderPipeline>
CFluidPlaneShader::BuildShader(boo::GLDataFactory::Context& ctx, const SFluidPlaneDoorShaderInfo& info) CFluidPlaneShader::BuildShader(boo::GLDataFactory::Context& ctx, const SFluidPlaneDoorShaderInfo& info)
{ {
int nextTex = 0; int nextTex = 0;
@ -539,12 +539,12 @@ CFluidPlaneShader::BuildShader(boo::GLDataFactory::Context& ctx, const SFluidPla
} }
#if BOO_HAS_VULKAN #if BOO_HAS_VULKAN
static boo::IVertexFormat* s_vtxFmt = nullptr; static boo::ObjToken<boo::IVertexFormat> s_vtxFmt;
boo::IShaderPipeline* boo::ObjToken<boo::IShaderPipeline>
CFluidPlaneShader::BuildShader(boo::VulkanDataFactory::Context& ctx, const SFluidPlaneShaderInfo& info) CFluidPlaneShader::BuildShader(boo::VulkanDataFactory::Context& ctx, const SFluidPlaneShaderInfo& info)
{ {
if (s_vtxFmt == nullptr) if (!s_vtxFmt)
{ {
boo::VertexElementDescriptor elements[] = boo::VertexElementDescriptor elements[] =
{ {
@ -568,10 +568,10 @@ CFluidPlaneShader::BuildShader(boo::VulkanDataFactory::Context& ctx, const SFlui
boo::CullMode::None); boo::CullMode::None);
} }
boo::IShaderPipeline* boo::ObjToken<boo::IShaderPipeline>
CFluidPlaneShader::BuildShader(boo::VulkanDataFactory::Context& ctx, const SFluidPlaneDoorShaderInfo& info) CFluidPlaneShader::BuildShader(boo::VulkanDataFactory::Context& ctx, const SFluidPlaneDoorShaderInfo& info)
{ {
if (s_vtxFmt == nullptr) if (!s_vtxFmt)
{ {
boo::VertexElementDescriptor elements[] = boo::VertexElementDescriptor elements[] =
{ {
@ -595,25 +595,26 @@ CFluidPlaneShader::BuildShader(boo::VulkanDataFactory::Context& ctx, const SFlui
} }
#endif #endif
boo::IShaderDataBinding* CFluidPlaneShader::BuildBinding(boo::GLDataFactory::Context& ctx, boo::ObjToken<boo::IShaderDataBinding>
boo::IShaderPipeline* pipeline, bool door) CFluidPlaneShader::BuildBinding(boo::GLDataFactory::Context& ctx,
const boo::ObjToken<boo::IShaderPipeline>& pipeline, bool door)
{ {
boo::VertexElementDescriptor elements[] = boo::VertexElementDescriptor elements[] =
{ {
{m_vbo, nullptr, boo::VertexSemantic::Position4}, {m_vbo.get(), nullptr, boo::VertexSemantic::Position4},
{m_vbo, nullptr, boo::VertexSemantic::Normal4, 0}, {m_vbo.get(), nullptr, boo::VertexSemantic::Normal4, 0},
{m_vbo, nullptr, boo::VertexSemantic::Normal4, 1}, {m_vbo.get(), nullptr, boo::VertexSemantic::Normal4, 1},
{m_vbo, nullptr, boo::VertexSemantic::Normal4, 2}, {m_vbo.get(), nullptr, boo::VertexSemantic::Normal4, 2},
{m_vbo, nullptr, boo::VertexSemantic::Color} {m_vbo.get(), nullptr, boo::VertexSemantic::Color}
}; };
boo::IVertexFormat* vtxFmt = ctx.newVertexFormat(5, elements); boo::ObjToken<boo::IVertexFormat> vtxFmt = ctx.newVertexFormat(5, elements);
boo::IGraphicsBuffer* ubufs[] = { m_uniBuf, m_uniBuf, m_uniBuf }; boo::ObjToken<boo::IGraphicsBuffer> ubufs[] = { m_uniBuf.get(), m_uniBuf.get(), m_uniBuf.get() };
boo::PipelineStage ubufStages[] = { boo::PipelineStage::Vertex, boo::PipelineStage::Vertex, boo::PipelineStage ubufStages[] = { boo::PipelineStage::Vertex, boo::PipelineStage::Vertex,
boo::PipelineStage::Fragment }; boo::PipelineStage::Fragment };
size_t ubufOffs[] = {0, 0, 768}; size_t ubufOffs[] = {0, 0, 768};
size_t ubufSizes[] = {768, 768, 256}; size_t ubufSizes[] = {768, 768, 256};
size_t texCount = 0; size_t texCount = 0;
boo::ITexture* texs[7] = {}; boo::ObjToken<boo::ITexture> texs[7];
if (m_patternTex1) if (m_patternTex1)
texs[texCount++] = (*m_patternTex1)->GetBooTexture(); texs[texCount++] = (*m_patternTex1)->GetBooTexture();
if (m_patternTex2) if (m_patternTex2)
@ -628,21 +629,22 @@ boo::IShaderDataBinding* CFluidPlaneShader::BuildBinding(boo::GLDataFactory::Con
texs[texCount++] = (*m_envBumpMap)->GetBooTexture(); texs[texCount++] = (*m_envBumpMap)->GetBooTexture();
if (m_lightmap) if (m_lightmap)
texs[texCount++] = (*m_lightmap)->GetBooTexture(); texs[texCount++] = (*m_lightmap)->GetBooTexture();
return ctx.newShaderDataBinding(pipeline, vtxFmt, m_vbo, nullptr, nullptr, door ? 1 : 3, return ctx.newShaderDataBinding(pipeline, vtxFmt, m_vbo.get(), nullptr, nullptr, door ? 1 : 3,
ubufs, ubufStages, ubufOffs, ubufSizes, texCount, texs, nullptr, nullptr); ubufs, ubufStages, ubufOffs, ubufSizes, texCount, texs, nullptr, nullptr);
} }
#if BOO_HAS_VULKAN #if BOO_HAS_VULKAN
boo::IShaderDataBinding* CFluidPlaneShader::BuildBinding(boo::VulkanDataFactory::Context& ctx, boo::ObjToken<boo::IShaderDataBinding>
boo::IShaderPipeline* pipeline, bool door) CFluidPlaneShader::BuildBinding(boo::VulkanDataFactory::Context& ctx,
const boo::ObjToken<boo::IShaderPipeline>& pipeline, bool door)
{ {
boo::IGraphicsBuffer* ubufs[] = { m_uniBuf, m_uniBuf, m_uniBuf }; boo::ObjToken<boo::IGraphicsBuffer> ubufs[] = { m_uniBuf.get(), m_uniBuf.get(), m_uniBuf.get() };
boo::PipelineStage ubufStages[] = { boo::PipelineStage::Vertex, boo::PipelineStage::Vertex, boo::PipelineStage ubufStages[] = { boo::PipelineStage::Vertex, boo::PipelineStage::Vertex,
boo::PipelineStage::Fragment }; boo::PipelineStage::Fragment };
size_t ubufOffs[] = {0, 0, 768}; size_t ubufOffs[] = {0, 0, 768};
size_t ubufSizes[] = {768, 768, 256}; size_t ubufSizes[] = {768, 768, 256};
size_t texCount = 0; size_t texCount = 0;
boo::ITexture* texs[7] = {}; boo::ObjToken<boo::ITexture> texs[7] = {};
if (m_patternTex1) if (m_patternTex1)
texs[texCount++] = (*m_patternTex1)->GetBooTexture(); texs[texCount++] = (*m_patternTex1)->GetBooTexture();
if (m_patternTex2) if (m_patternTex2)
@ -657,7 +659,7 @@ boo::IShaderDataBinding* CFluidPlaneShader::BuildBinding(boo::VulkanDataFactory:
texs[texCount++] = (*m_envBumpMap)->GetBooTexture(); texs[texCount++] = (*m_envBumpMap)->GetBooTexture();
if (m_lightmap) if (m_lightmap)
texs[texCount++] = (*m_lightmap)->GetBooTexture(); texs[texCount++] = (*m_lightmap)->GetBooTexture();
return ctx.newShaderDataBinding(pipeline, s_vtxFmt, m_vbo, nullptr, nullptr, door ? 1 : 3, return ctx.newShaderDataBinding(pipeline, s_vtxFmt, m_vbo.get(), nullptr, nullptr, door ? 1 : 3,
ubufs, ubufStages, ubufOffs, ubufSizes, texCount, texs, nullptr, nullptr); ubufs, ubufStages, ubufOffs, ubufSizes, texCount, texs, nullptr, nullptr);
} }
#endif #endif

View File

@ -3,7 +3,7 @@
namespace urde namespace urde
{ {
static boo::IVertexFormat* s_vtxFmt = nullptr; static boo::ObjToken<boo::IVertexFormat> s_vtxFmt;
static const char* VS = static const char* VS =
"struct VertData\n" "struct VertData\n"
@ -140,10 +140,10 @@ static const char* FSDoor =
" return colorOut;\n" " return colorOut;\n"
"}\n"; "}\n";
boo::IShaderPipeline* boo::ObjToken<boo::IShaderPipeline>
CFluidPlaneShader::BuildShader(boo::ID3DDataFactory::Context& ctx, const SFluidPlaneShaderInfo& info) CFluidPlaneShader::BuildShader(boo::ID3DDataFactory::Context& ctx, const SFluidPlaneShaderInfo& info)
{ {
if (s_vtxFmt == nullptr) if (!s_vtxFmt)
{ {
boo::VertexElementDescriptor elements[] = boo::VertexElementDescriptor elements[] =
{ {
@ -466,10 +466,10 @@ CFluidPlaneShader::BuildShader(boo::ID3DDataFactory::Context& ctx, const SFluidP
boo::CullMode::None); boo::CullMode::None);
} }
boo::IShaderPipeline* boo::ObjToken<boo::IShaderPipeline>
CFluidPlaneShader::BuildShader(boo::ID3DDataFactory::Context& ctx, const SFluidPlaneDoorShaderInfo& info) CFluidPlaneShader::BuildShader(boo::ID3DDataFactory::Context& ctx, const SFluidPlaneDoorShaderInfo& info)
{ {
if (s_vtxFmt == nullptr) if (!s_vtxFmt)
{ {
boo::VertexElementDescriptor elements[] = boo::VertexElementDescriptor elements[] =
{ {
@ -521,16 +521,17 @@ CFluidPlaneShader::BuildShader(boo::ID3DDataFactory::Context& ctx, const SFluidP
boo::CullMode::None); boo::CullMode::None);
} }
boo::IShaderDataBinding* CFluidPlaneShader::BuildBinding(boo::ID3DDataFactory::Context& ctx, boo::ObjToken<boo::IShaderDataBinding>
boo::IShaderPipeline* pipeline, bool door) CFluidPlaneShader::BuildBinding(boo::ID3DDataFactory::Context& ctx,
const boo::ObjToken<boo::IShaderPipeline>& pipeline, bool door)
{ {
boo::IGraphicsBuffer* ubufs[] = { m_uniBuf, m_uniBuf, m_uniBuf }; boo::ObjToken<boo::IGraphicsBuffer> ubufs[] = { m_uniBuf.get(), m_uniBuf.get(), m_uniBuf.get() };
boo::PipelineStage ubufStages[] = { boo::PipelineStage::Vertex, boo::PipelineStage::Vertex, boo::PipelineStage ubufStages[] = { boo::PipelineStage::Vertex, boo::PipelineStage::Vertex,
boo::PipelineStage::Fragment }; boo::PipelineStage::Fragment };
size_t ubufOffs[] = {0, 0, 768}; size_t ubufOffs[] = {0, 0, 768};
size_t ubufSizes[] = {768, 768, 256}; size_t ubufSizes[] = {768, 768, 256};
size_t texCount = 0; size_t texCount = 0;
boo::ITexture* texs[7] = {}; boo::ObjToken<boo::ITexture> texs[7] = {};
if (m_patternTex1) if (m_patternTex1)
texs[texCount++] = (*m_patternTex1)->GetBooTexture(); texs[texCount++] = (*m_patternTex1)->GetBooTexture();
if (m_patternTex2) if (m_patternTex2)
@ -545,7 +546,7 @@ boo::IShaderDataBinding* CFluidPlaneShader::BuildBinding(boo::ID3DDataFactory::C
texs[texCount++] = (*m_envBumpMap)->GetBooTexture(); texs[texCount++] = (*m_envBumpMap)->GetBooTexture();
if (m_lightmap) if (m_lightmap)
texs[texCount++] = (*m_lightmap)->GetBooTexture(); texs[texCount++] = (*m_lightmap)->GetBooTexture();
return ctx.newShaderDataBinding(pipeline, s_vtxFmt, m_vbo, nullptr, nullptr, door ? 1 : 3, return ctx.newShaderDataBinding(pipeline, s_vtxFmt, m_vbo.get(), nullptr, nullptr, door ? 1 : 3,
ubufs, ubufStages, ubufOffs, ubufSizes, texCount, texs, nullptr, nullptr); ubufs, ubufStages, ubufOffs, ubufSizes, texCount, texs, nullptr, nullptr);
} }

View File

@ -3,7 +3,7 @@
namespace urde namespace urde
{ {
static boo::IVertexFormat* s_vtxFmt = nullptr; static boo::ObjToken<boo::IVertexFormat> s_vtxFmt;
static const char* VS = static const char* VS =
"#include <metal_stdlib>\n" "#include <metal_stdlib>\n"
@ -148,10 +148,10 @@ static const char* FSDoor =
" return colorOut;\n" " return colorOut;\n"
"}\n"; "}\n";
boo::IShaderPipeline* boo::ObjToken<boo::IShaderPipeline>
CFluidPlaneShader::BuildShader(boo::MetalDataFactory::Context& ctx, const SFluidPlaneShaderInfo& info) CFluidPlaneShader::BuildShader(boo::MetalDataFactory::Context& ctx, const SFluidPlaneShaderInfo& info)
{ {
if (s_vtxFmt == nullptr) if (!s_vtxFmt)
{ {
boo::VertexElementDescriptor elements[] = boo::VertexElementDescriptor elements[] =
{ {
@ -467,17 +467,18 @@ CFluidPlaneShader::BuildShader(boo::MetalDataFactory::Context& ctx, const SFluid
std::string finalVS = hecl::Format(VS, additionalTCGs.c_str()); std::string finalVS = hecl::Format(VS, additionalTCGs.c_str());
std::string finalFS = hecl::Format(FS, textures.c_str(), combiner.c_str()); std::string finalFS = hecl::Format(FS, textures.c_str(), combiner.c_str());
return ctx.newShaderPipeline(finalVS.c_str(), finalFS.c_str(), s_vtxFmt, CGraphics::g_ViewportSamples, return ctx.newShaderPipeline(finalVS.c_str(), finalFS.c_str(), nullptr, nullptr,
s_vtxFmt, CGraphics::g_ViewportSamples,
info.m_additive ? boo::BlendFactor::One : boo::BlendFactor::SrcAlpha, info.m_additive ? boo::BlendFactor::One : boo::BlendFactor::SrcAlpha,
info.m_additive ? boo::BlendFactor::One : boo::BlendFactor::InvSrcAlpha, info.m_additive ? boo::BlendFactor::One : boo::BlendFactor::InvSrcAlpha,
boo::Primitive::TriStrips, boo::ZTest::LEqual, false, true, false, boo::Primitive::TriStrips, boo::ZTest::LEqual, false, true, false,
boo::CullMode::None); boo::CullMode::None);
} }
boo::IShaderPipeline* boo::ObjToken<boo::IShaderPipeline>
CFluidPlaneShader::BuildShader(boo::MetalDataFactory::Context& ctx, const SFluidPlaneDoorShaderInfo& info) CFluidPlaneShader::BuildShader(boo::MetalDataFactory::Context& ctx, const SFluidPlaneDoorShaderInfo& info)
{ {
if (s_vtxFmt == nullptr) if (!s_vtxFmt)
{ {
boo::VertexElementDescriptor elements[] = boo::VertexElementDescriptor elements[] =
{ {
@ -523,22 +524,23 @@ CFluidPlaneShader::BuildShader(boo::MetalDataFactory::Context& ctx, const SFluid
std::string finalVS = hecl::Format(VS, additionalTCGs.c_str()); std::string finalVS = hecl::Format(VS, additionalTCGs.c_str());
std::string finalFS = hecl::Format(FSDoor, textures.c_str(), combiner.c_str()); std::string finalFS = hecl::Format(FSDoor, textures.c_str(), combiner.c_str());
return ctx.newShaderPipeline(finalVS.c_str(), finalFS.c_str(), s_vtxFmt, CGraphics::g_ViewportSamples, return ctx.newShaderPipeline(finalVS.c_str(), finalFS.c_str(), nullptr, nullptr,
s_vtxFmt, CGraphics::g_ViewportSamples,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha, boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
boo::Primitive::TriStrips, boo::ZTest::LEqual, false, true, false, boo::Primitive::TriStrips, boo::ZTest::LEqual, false, true, false,
boo::CullMode::None); boo::CullMode::None);
} }
boo::IShaderDataBinding* CFluidPlaneShader::BuildBinding(boo::MetalDataFactory::Context& ctx, boo::ObjToken<boo::IShaderDataBinding> CFluidPlaneShader::BuildBinding(boo::MetalDataFactory::Context& ctx,
boo::IShaderPipeline* pipeline, bool door) const boo::ObjToken<boo::IShaderPipeline>& pipeline, bool door)
{ {
boo::IGraphicsBuffer* ubufs[] = { m_uniBuf, m_uniBuf, m_uniBuf }; boo::ObjToken<boo::IGraphicsBuffer> ubufs[] = { m_uniBuf.get(), m_uniBuf.get(), m_uniBuf.get() };
boo::PipelineStage ubufStages[] = { boo::PipelineStage::Vertex, boo::PipelineStage::Vertex, boo::PipelineStage ubufStages[] = { boo::PipelineStage::Vertex, boo::PipelineStage::Vertex,
boo::PipelineStage::Fragment }; boo::PipelineStage::Fragment };
size_t ubufOffs[] = {0, 0, 768}; size_t ubufOffs[] = {0, 0, 768};
size_t ubufSizes[] = {768, 768, 256}; size_t ubufSizes[] = {768, 768, 256};
size_t texCount = 0; size_t texCount = 0;
boo::ITexture* texs[7] = {}; boo::ObjToken<boo::ITexture> texs[7];
if (m_patternTex1) if (m_patternTex1)
texs[texCount++] = (*m_patternTex1)->GetBooTexture(); texs[texCount++] = (*m_patternTex1)->GetBooTexture();
if (m_patternTex2) if (m_patternTex2)
@ -553,7 +555,7 @@ boo::IShaderDataBinding* CFluidPlaneShader::BuildBinding(boo::MetalDataFactory::
texs[texCount++] = (*m_envBumpMap)->GetBooTexture(); texs[texCount++] = (*m_envBumpMap)->GetBooTexture();
if (m_lightmap) if (m_lightmap)
texs[texCount++] = (*m_lightmap)->GetBooTexture(); texs[texCount++] = (*m_lightmap)->GetBooTexture();
return ctx.newShaderDataBinding(pipeline, s_vtxFmt, m_vbo, nullptr, nullptr, door ? 1 : 3, return ctx.newShaderDataBinding(pipeline, s_vtxFmt, m_vbo.get(), nullptr, nullptr, door ? 1 : 3,
ubufs, ubufStages, ubufOffs, ubufSizes, texCount, texs, nullptr, nullptr); ubufs, ubufStages, ubufOffs, ubufSizes, texCount, texs, nullptr, nullptr);
} }

View File

@ -5,7 +5,7 @@ namespace urde
CFogVolumeFilter::CFogVolumeFilter() CFogVolumeFilter::CFogVolumeFilter()
{ {
m_token = CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
{ {
struct Vert struct Vert
{ {
@ -39,8 +39,6 @@ void CFogVolumeFilter::draw1WayPass(const zeus::CColor& color)
CGraphics::DrawArray(0, 4); CGraphics::DrawArray(0, 4);
} }
void CFogVolumeFilter::Shutdown() {}
URDE_SPECIALIZE_SHADER(CFogVolumeFilter) URDE_SPECIALIZE_SHADER(CFogVolumeFilter)
} }

View File

@ -16,11 +16,10 @@ class CFogVolumeFilter
friend struct CFogVolumeFilterMetalDataBindingFactory; friend struct CFogVolumeFilterMetalDataBindingFactory;
friend struct CFogVolumeFilterD3DDataBindingFactory; friend struct CFogVolumeFilterD3DDataBindingFactory;
boo::GraphicsDataToken m_token; boo::ObjToken<boo::IGraphicsBufferS> m_vbo;
boo::IGraphicsBufferS* m_vbo; boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf;
boo::IGraphicsBufferD* m_uniBuf; boo::ObjToken<boo::IShaderDataBinding> m_dataBind1Way;
boo::IShaderDataBinding* m_dataBind1Way; boo::ObjToken<boo::IShaderDataBinding> m_dataBind2Way;
boo::IShaderDataBinding* m_dataBind2Way;
public: public:
CFogVolumeFilter(); CFogVolumeFilter();

View File

@ -86,34 +86,34 @@ BOO_GLSL_BINDING_HEAD
URDE_DECL_SPECIALIZE_SHADER(CFogVolumeFilter) URDE_DECL_SPECIALIZE_SHADER(CFogVolumeFilter)
static boo::IVertexFormat* s_VtxFmt = nullptr; static boo::ObjToken<boo::IVertexFormat> s_VtxFmt;
static boo::IShaderPipeline* s_1WayPipeline = nullptr; static boo::ObjToken<boo::IShaderPipeline> s_1WayPipeline;
static boo::IShaderPipeline* s_2WayPipeline = nullptr; static boo::ObjToken<boo::IShaderPipeline> s_2WayPipeline;
struct CFogVolumeFilterGLDataBindingFactory : TShader<CFogVolumeFilter>::IDataBindingFactory struct CFogVolumeFilterGLDataBindingFactory : TShader<CFogVolumeFilter>::IDataBindingFactory
{ {
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
CFogVolumeFilter& filter) CFogVolumeFilter& filter)
{ {
boo::GLDataFactory::Context& cctx = static_cast<boo::GLDataFactory::Context&>(ctx); boo::GLDataFactory::Context& cctx = static_cast<boo::GLDataFactory::Context&>(ctx);
const boo::VertexElementDescriptor VtxVmt[] = const boo::VertexElementDescriptor VtxVmt[] =
{ {
{filter.m_vbo, nullptr, boo::VertexSemantic::Position4}, {filter.m_vbo.get(), nullptr, boo::VertexSemantic::Position4},
{filter.m_vbo, nullptr, boo::VertexSemantic::UV4} {filter.m_vbo.get(), nullptr, boo::VertexSemantic::UV4}
}; };
boo::IVertexFormat* VtxVmtObj = cctx.newVertexFormat(2, VtxVmt); boo::ObjToken<boo::IVertexFormat> VtxVmtObj = cctx.newVertexFormat(2, VtxVmt);
boo::ITexture* texs[] = { CGraphics::g_SpareTexture, CGraphics::g_SpareTexture, boo::ObjToken<boo::ITexture> texs[] = { CGraphics::g_SpareTexture.get(), CGraphics::g_SpareTexture.get(),
g_Renderer->GetFogRampTex() }; g_Renderer->GetFogRampTex().get() };
int bindIdxs[] = {0, 1, 0}; int bindIdxs[] = {0, 1, 0};
bool bindDepth[] = {true, true, false}; bool bindDepth[] = {true, true, false};
boo::IGraphicsBuffer* ubufs[] = {filter.m_uniBuf}; boo::ObjToken<boo::IGraphicsBuffer> ubufs[] = {filter.m_uniBuf.get()};
filter.m_dataBind1Way = cctx.newShaderDataBinding(s_1WayPipeline, VtxVmtObj, filter.m_dataBind1Way = cctx.newShaderDataBinding(s_1WayPipeline, VtxVmtObj,
filter.m_vbo, nullptr, nullptr, 1, ubufs, filter.m_vbo.get(), nullptr, nullptr, 1, ubufs,
nullptr, nullptr, nullptr, 3, texs, bindIdxs, bindDepth); nullptr, nullptr, nullptr, 3, texs, bindIdxs, bindDepth);
filter.m_dataBind2Way = cctx.newShaderDataBinding(s_2WayPipeline, VtxVmtObj, filter.m_dataBind2Way = cctx.newShaderDataBinding(s_2WayPipeline, VtxVmtObj,
filter.m_vbo, nullptr, nullptr, 1, ubufs, filter.m_vbo.get(), nullptr, nullptr, 1, ubufs,
nullptr, nullptr, nullptr, 3, texs, bindIdxs, bindDepth); nullptr, nullptr, nullptr, 3, texs, bindIdxs, bindDepth);
return filter.m_dataBind1Way; return filter.m_dataBind1Way;
} }
@ -122,21 +122,22 @@ struct CFogVolumeFilterGLDataBindingFactory : TShader<CFogVolumeFilter>::IDataBi
#if BOO_HAS_VULKAN #if BOO_HAS_VULKAN
struct CFogVolumeFilterVulkanDataBindingFactory : TShader<CFogVolumeFilter>::IDataBindingFactory struct CFogVolumeFilterVulkanDataBindingFactory : TShader<CFogVolumeFilter>::IDataBindingFactory
{ {
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, boo::ObjToken<boo::IShaderDataBinding>
BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
CFogVolumeFilter& filter) CFogVolumeFilter& filter)
{ {
boo::VulkanDataFactory::Context& cctx = static_cast<boo::VulkanDataFactory::Context&>(ctx); boo::VulkanDataFactory::Context& cctx = static_cast<boo::VulkanDataFactory::Context&>(ctx);
boo::ITexture* texs[] = { CGraphics::g_SpareTexture, CGraphics::g_SpareTexture, boo::ObjToken<boo::ITexture> texs[] = { CGraphics::g_SpareTexture.get(), CGraphics::g_SpareTexture.get(),
g_Renderer->GetFogRampTex() }; g_Renderer->GetFogRampTex().get() };
int bindIdxs[] = {0, 1, 0}; int bindIdxs[] = {0, 1, 0};
bool bindDepth[] = {true, true, false}; bool bindDepth[] = {true, true, false};
boo::IGraphicsBuffer* ubufs[] = {filter.m_uniBuf}; boo::ObjToken<boo::IGraphicsBuffer> ubufs[] = {filter.m_uniBuf.get()};
filter.m_dataBind1Way = cctx.newShaderDataBinding(s_1WayPipeline, s_VtxFmt, filter.m_dataBind1Way = cctx.newShaderDataBinding(s_1WayPipeline, s_VtxFmt,
filter.m_vbo, nullptr, nullptr, 1, ubufs, filter.m_vbo.get(), nullptr, nullptr, 1, ubufs,
nullptr, nullptr, nullptr, 3, texs, bindIdxs, bindDepth); nullptr, nullptr, nullptr, 3, texs, bindIdxs, bindDepth);
filter.m_dataBind2Way = cctx.newShaderDataBinding(s_2WayPipeline, s_VtxFmt, filter.m_dataBind2Way = cctx.newShaderDataBinding(s_2WayPipeline, s_VtxFmt,
filter.m_vbo, nullptr, nullptr, 1, ubufs, filter.m_vbo.get(), nullptr, nullptr, 1, ubufs,
nullptr, nullptr, nullptr, 3, texs, bindIdxs, bindDepth); nullptr, nullptr, nullptr, 3, texs, bindIdxs, bindDepth);
return filter.m_dataBind1Way; return filter.m_dataBind1Way;
} }
@ -157,6 +158,13 @@ CFogVolumeFilter::Initialize(boo::GLDataFactory::Context& ctx)
return new CFogVolumeFilterGLDataBindingFactory; return new CFogVolumeFilterGLDataBindingFactory;
} }
template <>
void CFogVolumeFilter::Shutdown<boo::GLDataFactory>()
{
s_1WayPipeline.reset();
s_2WayPipeline.reset();
}
#if BOO_HAS_VULKAN #if BOO_HAS_VULKAN
TShader<CFogVolumeFilter>::IDataBindingFactory* TShader<CFogVolumeFilter>::IDataBindingFactory*
CFogVolumeFilter::Initialize(boo::VulkanDataFactory::Context& ctx) CFogVolumeFilter::Initialize(boo::VulkanDataFactory::Context& ctx)
@ -175,6 +183,14 @@ CFogVolumeFilter::Initialize(boo::VulkanDataFactory::Context& ctx)
boo::ZTest::None, false, true, false, boo::CullMode::None); boo::ZTest::None, false, true, false, boo::CullMode::None);
return new CFogVolumeFilterVulkanDataBindingFactory; return new CFogVolumeFilterVulkanDataBindingFactory;
} }
template <>
void CFogVolumeFilter::Shutdown<boo::VulkanDataFactory>()
{
s_VtxFmt.reset();
s_1WayPipeline.reset();
s_2WayPipeline.reset();
}
#endif #endif
} }

View File

@ -83,27 +83,28 @@ static const char* FS2Way =
URDE_DECL_SPECIALIZE_SHADER(CFogVolumeFilter) URDE_DECL_SPECIALIZE_SHADER(CFogVolumeFilter)
static boo::IVertexFormat* s_VtxFmt = nullptr; static boo::ObjToken<boo::IVertexFormat> s_VtxFmt;
static boo::IShaderPipeline* s_1WayPipeline = nullptr; static boo::ObjToken<boo::IShaderPipeline> s_1WayPipeline;
static boo::IShaderPipeline* s_2WayPipeline = nullptr; static boo::ObjToken<boo::IShaderPipeline> s_2WayPipeline;
struct CFogVolumeFilterD3DDataBindingFactory : TShader<CFogVolumeFilter>::IDataBindingFactory struct CFogVolumeFilterD3DDataBindingFactory : TShader<CFogVolumeFilter>::IDataBindingFactory
{ {
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, boo::ObjToken<boo::IShaderDataBinding>
BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
CFogVolumeFilter& filter) CFogVolumeFilter& filter)
{ {
boo::ID3DDataFactory::Context& cctx = static_cast<boo::ID3DDataFactory::Context&>(ctx); boo::ID3DDataFactory::Context& cctx = static_cast<boo::ID3DDataFactory::Context&>(ctx);
boo::ITexture* texs[] = { CGraphics::g_SpareTexture, CGraphics::g_SpareTexture, boo::ObjToken<boo::ITexture> texs[] = { CGraphics::g_SpareTexture.get(), CGraphics::g_SpareTexture.get(),
g_Renderer->GetFogRampTex() }; g_Renderer->GetFogRampTex().get() };
int bindIdxs[] = {0, 1, 0}; int bindIdxs[] = {0, 1, 0};
bool bindDepth[] = {true, true, false}; bool bindDepth[] = {true, true, false};
boo::IGraphicsBuffer* ubufs[] = {filter.m_uniBuf}; boo::ObjToken<boo::IGraphicsBuffer> ubufs[] = {filter.m_uniBuf.get()};
filter.m_dataBind1Way = cctx.newShaderDataBinding(s_1WayPipeline, s_VtxFmt, filter.m_dataBind1Way = cctx.newShaderDataBinding(s_1WayPipeline, s_VtxFmt,
filter.m_vbo, nullptr, nullptr, 1, ubufs, filter.m_vbo.get(), nullptr, nullptr, 1, ubufs,
nullptr, nullptr, nullptr, 3, texs, bindIdxs, bindDepth); nullptr, nullptr, nullptr, 3, texs, bindIdxs, bindDepth);
filter.m_dataBind2Way = cctx.newShaderDataBinding(s_2WayPipeline, s_VtxFmt, filter.m_dataBind2Way = cctx.newShaderDataBinding(s_2WayPipeline, s_VtxFmt,
filter.m_vbo, nullptr, nullptr, 1, ubufs, filter.m_vbo.get(), nullptr, nullptr, 1, ubufs,
nullptr, nullptr, nullptr, 3, texs, bindIdxs, bindDepth); nullptr, nullptr, nullptr, 3, texs, bindIdxs, bindDepth);
return filter.m_dataBind1Way; return filter.m_dataBind1Way;
} }
@ -127,4 +128,12 @@ CFogVolumeFilter::Initialize(boo::ID3DDataFactory::Context& ctx)
return new CFogVolumeFilterD3DDataBindingFactory; return new CFogVolumeFilterD3DDataBindingFactory;
} }
template <>
void CFogVolumeFilter::Shutdown<boo::ID3DDataFactory>()
{
s_VtxFmt.reset();
s_1WayPipeline.reset();
s_2WayPipeline.reset();
}
} }

View File

@ -90,27 +90,27 @@ static const char* FS2Way =
URDE_DECL_SPECIALIZE_SHADER(CFogVolumeFilter) URDE_DECL_SPECIALIZE_SHADER(CFogVolumeFilter)
static boo::IVertexFormat* s_VtxFmt = nullptr; static boo::ObjToken<boo::IVertexFormat> s_VtxFmt;
static boo::IShaderPipeline* s_1WayPipeline = nullptr; static boo::ObjToken<boo::IShaderPipeline> s_1WayPipeline;
static boo::IShaderPipeline* s_2WayPipeline = nullptr; static boo::ObjToken<boo::IShaderPipeline> s_2WayPipeline;
struct CFogVolumeFilterMetalDataBindingFactory : TShader<CFogVolumeFilter>::IDataBindingFactory struct CFogVolumeFilterMetalDataBindingFactory : TShader<CFogVolumeFilter>::IDataBindingFactory
{ {
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
CFogVolumeFilter& filter) CFogVolumeFilter& filter)
{ {
boo::MetalDataFactory::Context& cctx = static_cast<boo::MetalDataFactory::Context&>(ctx); boo::MetalDataFactory::Context& cctx = static_cast<boo::MetalDataFactory::Context&>(ctx);
boo::ITexture* texs[] = { CGraphics::g_SpareTexture, CGraphics::g_SpareTexture, boo::ObjToken<boo::ITexture> texs[] = { CGraphics::g_SpareTexture.get(), CGraphics::g_SpareTexture.get(),
g_Renderer->GetFogRampTex() }; g_Renderer->GetFogRampTex().get() };
int bindIdxs[] = {0, 1, 0}; int bindIdxs[] = {0, 1, 0};
bool bindDepth[] = {true, true, false}; bool bindDepth[] = {true, true, false};
boo::IGraphicsBuffer* ubufs[] = {filter.m_uniBuf}; boo::ObjToken<boo::IGraphicsBuffer> ubufs[] = {filter.m_uniBuf.get()};
filter.m_dataBind1Way = cctx.newShaderDataBinding(s_1WayPipeline, s_VtxFmt, filter.m_dataBind1Way = cctx.newShaderDataBinding(s_1WayPipeline, s_VtxFmt,
filter.m_vbo, nullptr, nullptr, 1, ubufs, filter.m_vbo.get(), nullptr, nullptr, 1, ubufs,
nullptr, nullptr, nullptr, 3, texs, bindIdxs, bindDepth); nullptr, nullptr, nullptr, 3, texs, bindIdxs, bindDepth);
filter.m_dataBind2Way = cctx.newShaderDataBinding(s_2WayPipeline, s_VtxFmt, filter.m_dataBind2Way = cctx.newShaderDataBinding(s_2WayPipeline, s_VtxFmt,
filter.m_vbo, nullptr, nullptr, 1, ubufs, filter.m_vbo.get(), nullptr, nullptr, 1, ubufs,
nullptr, nullptr, nullptr, 3, texs, bindIdxs, bindDepth); nullptr, nullptr, nullptr, 3, texs, bindIdxs, bindDepth);
return filter.m_dataBind1Way; return filter.m_dataBind1Way;
} }
@ -125,13 +125,23 @@ CFogVolumeFilter::Initialize(boo::MetalDataFactory::Context& ctx)
{nullptr, nullptr, boo::VertexSemantic::UV4} {nullptr, nullptr, boo::VertexSemantic::UV4}
}; };
s_VtxFmt = ctx.newVertexFormat(2, VtxVmt); s_VtxFmt = ctx.newVertexFormat(2, VtxVmt);
s_1WayPipeline = ctx.newShaderPipeline(VS, FS1Way, s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::DstAlpha, s_1WayPipeline = ctx.newShaderPipeline(VS, FS1Way, nullptr, nullptr,
s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::DstAlpha,
boo::BlendFactor::One, boo::Primitive::TriStrips, boo::BlendFactor::One, boo::Primitive::TriStrips,
boo::ZTest::None, false, true, false, boo::CullMode::None); boo::ZTest::None, false, true, false, boo::CullMode::None);
s_2WayPipeline = ctx.newShaderPipeline(VS, FS2Way, s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha, s_2WayPipeline = ctx.newShaderPipeline(VS, FS2Way, nullptr, nullptr,
s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::One, boo::Primitive::TriStrips, boo::BlendFactor::One, boo::Primitive::TriStrips,
boo::ZTest::None, false, true, false, boo::CullMode::None); boo::ZTest::None, false, true, false, boo::CullMode::None);
return new CFogVolumeFilterMetalDataBindingFactory; return new CFogVolumeFilterMetalDataBindingFactory;
} }
template <>
void CFogVolumeFilter::Shutdown<boo::MetalDataFactory>()
{
s_VtxFmt.reset();
s_1WayPipeline.reset();
s_2WayPipeline.reset();
}
} }

View File

@ -6,7 +6,7 @@ namespace urde
void CFogVolumePlaneShader::CommitResources(size_t capacity) void CFogVolumePlaneShader::CommitResources(size_t capacity)
{ {
m_vertCapacity = capacity; m_vertCapacity = capacity;
m_token = CGraphics::CommitResources([this, capacity](boo::IGraphicsDataFactory::Context& ctx) CGraphics::CommitResources([this, capacity](boo::IGraphicsDataFactory::Context& ctx)
{ {
m_vbo = ctx.newDynamicBuffer(boo::BufferUse::Vertex, sizeof(zeus::CVector4f), capacity); m_vbo = ctx.newDynamicBuffer(boo::BufferUse::Vertex, sizeof(zeus::CVector4f), capacity);
TShader<CFogVolumePlaneShader>::BuildShaderDataBinding(ctx, *this); TShader<CFogVolumePlaneShader>::BuildShaderDataBinding(ctx, *this);
@ -60,8 +60,6 @@ void CFogVolumePlaneShader::draw(int pass)
CGraphics::DrawArray(0, m_verts.size()); CGraphics::DrawArray(0, m_verts.size());
} }
void CFogVolumePlaneShader::Shutdown() {}
URDE_SPECIALIZE_SHADER(CFogVolumePlaneShader) URDE_SPECIALIZE_SHADER(CFogVolumePlaneShader)
} }

View File

@ -17,9 +17,8 @@ class CFogVolumePlaneShader
friend struct CFogVolumePlaneShaderMetalDataBindingFactory; friend struct CFogVolumePlaneShaderMetalDataBindingFactory;
friend struct CFogVolumePlaneShaderD3DDataBindingFactory; friend struct CFogVolumePlaneShaderD3DDataBindingFactory;
boo::GraphicsDataToken m_token; boo::ObjToken<boo::IGraphicsBufferD> m_vbo;
boo::IGraphicsBufferD* m_vbo; boo::ObjToken<boo::IShaderDataBinding> m_dataBinds[4];
boo::IShaderDataBinding* m_dataBinds[4];
std::vector<zeus::CVector4f> m_verts; std::vector<zeus::CVector4f> m_verts;
size_t m_vertCapacity = 0; size_t m_vertCapacity = 0;

View File

@ -26,24 +26,24 @@ BOO_GLSL_BINDING_HEAD
URDE_DECL_SPECIALIZE_SHADER(CFogVolumePlaneShader) URDE_DECL_SPECIALIZE_SHADER(CFogVolumePlaneShader)
static boo::IVertexFormat* s_VtxFmt = nullptr; static boo::ObjToken<boo::IVertexFormat> s_VtxFmt;
static boo::IShaderPipeline* s_Pipelines[4] = {}; static boo::ObjToken<boo::IShaderPipeline> s_Pipelines[4];
struct CFogVolumePlaneShaderGLDataBindingFactory : TShader<CFogVolumePlaneShader>::IDataBindingFactory struct CFogVolumePlaneShaderGLDataBindingFactory : TShader<CFogVolumePlaneShader>::IDataBindingFactory
{ {
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
CFogVolumePlaneShader& filter) CFogVolumePlaneShader& filter)
{ {
boo::GLDataFactory::Context& cctx = static_cast<boo::GLDataFactory::Context&>(ctx); boo::GLDataFactory::Context& cctx = static_cast<boo::GLDataFactory::Context&>(ctx);
const boo::VertexElementDescriptor VtxVmt[] = const boo::VertexElementDescriptor VtxVmt[] =
{ {
{filter.m_vbo, nullptr, boo::VertexSemantic::Position4} {filter.m_vbo.get(), nullptr, boo::VertexSemantic::Position4}
}; };
boo::IVertexFormat* VtxVmtObj = cctx.newVertexFormat(1, VtxVmt); boo::ObjToken<boo::IVertexFormat> VtxVmtObj = cctx.newVertexFormat(1, VtxVmt);
for (int i=0 ; i<4 ; ++i) for (int i=0 ; i<4 ; ++i)
filter.m_dataBinds[i] = cctx.newShaderDataBinding(s_Pipelines[i], VtxVmtObj, filter.m_dataBinds[i] = cctx.newShaderDataBinding(s_Pipelines[i], VtxVmtObj,
filter.m_vbo, nullptr, nullptr, 0, nullptr, filter.m_vbo.get(), nullptr, nullptr, 0, nullptr,
nullptr, nullptr, nullptr, 0, nullptr, nullptr, nullptr); nullptr, nullptr, nullptr, 0, nullptr, nullptr, nullptr);
return filter.m_dataBinds[0]; return filter.m_dataBinds[0];
} }
@ -52,14 +52,15 @@ struct CFogVolumePlaneShaderGLDataBindingFactory : TShader<CFogVolumePlaneShader
#if BOO_HAS_VULKAN #if BOO_HAS_VULKAN
struct CFogVolumePlaneShaderVulkanDataBindingFactory : TShader<CFogVolumePlaneShader>::IDataBindingFactory struct CFogVolumePlaneShaderVulkanDataBindingFactory : TShader<CFogVolumePlaneShader>::IDataBindingFactory
{ {
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, boo::ObjToken<boo::IShaderDataBinding>
BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
CFogVolumePlaneShader& filter) CFogVolumePlaneShader& filter)
{ {
boo::VulkanDataFactory::Context& cctx = static_cast<boo::VulkanDataFactory::Context&>(ctx); boo::VulkanDataFactory::Context& cctx = static_cast<boo::VulkanDataFactory::Context&>(ctx);
for (int i=0 ; i<4 ; ++i) for (int i=0 ; i<4 ; ++i)
filter.m_dataBinds[i] = cctx.newShaderDataBinding(s_Pipelines[i], s_VtxFmt, filter.m_dataBinds[i] = cctx.newShaderDataBinding(s_Pipelines[i], s_VtxFmt,
filter.m_vbo, nullptr, nullptr, 0, nullptr, filter.m_vbo.get(), nullptr, nullptr, 0, nullptr,
nullptr, nullptr, nullptr, 0, nullptr, nullptr, nullptr); nullptr, nullptr, nullptr, 0, nullptr, nullptr, nullptr);
return filter.m_dataBinds[0]; return filter.m_dataBinds[0];
} }
@ -84,6 +85,15 @@ CFogVolumePlaneShader::Initialize(boo::GLDataFactory::Context& ctx)
return new CFogVolumePlaneShaderGLDataBindingFactory; return new CFogVolumePlaneShaderGLDataBindingFactory;
} }
template <>
void CFogVolumePlaneShader::Shutdown<boo::GLDataFactory>()
{
s_Pipelines[0].reset();
s_Pipelines[1].reset();
s_Pipelines[2].reset();
s_Pipelines[3].reset();
}
#if BOO_HAS_VULKAN #if BOO_HAS_VULKAN
TShader<CFogVolumePlaneShader>::IDataBindingFactory* TShader<CFogVolumePlaneShader>::IDataBindingFactory*
CFogVolumePlaneShader::Initialize(boo::VulkanDataFactory::Context& ctx) CFogVolumePlaneShader::Initialize(boo::VulkanDataFactory::Context& ctx)
@ -107,6 +117,16 @@ CFogVolumePlaneShader::Initialize(boo::VulkanDataFactory::Context& ctx)
boo::ZTest::Greater, false, false, false, boo::CullMode::Backface); boo::ZTest::Greater, false, false, false, boo::CullMode::Backface);
return new CFogVolumePlaneShaderVulkanDataBindingFactory; return new CFogVolumePlaneShaderVulkanDataBindingFactory;
} }
template <>
void CFogVolumePlaneShader::Shutdown<boo::VulkanDataFactory>()
{
s_VtxFmt.reset();
s_Pipelines[0].reset();
s_Pipelines[1].reset();
s_Pipelines[2].reset();
s_Pipelines[3].reset();
}
#endif #endif
} }

View File

@ -23,19 +23,20 @@ static const char* FS =
URDE_DECL_SPECIALIZE_SHADER(CFogVolumePlaneShader) URDE_DECL_SPECIALIZE_SHADER(CFogVolumePlaneShader)
static boo::IVertexFormat* s_VtxFmt = nullptr; static boo::ObjToken<boo::IVertexFormat> s_VtxFmt;
static boo::IShaderPipeline* s_Pipelines[4] = {}; static boo::ObjToken<boo::IShaderPipeline> s_Pipelines[4];
struct CFogVolumePlaneShaderD3DDataBindingFactory : TShader<CFogVolumePlaneShader>::IDataBindingFactory struct CFogVolumePlaneShaderD3DDataBindingFactory : TShader<CFogVolumePlaneShader>::IDataBindingFactory
{ {
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, boo::ObjToken<boo::IShaderDataBinding>
BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
CFogVolumePlaneShader& filter) CFogVolumePlaneShader& filter)
{ {
boo::ID3DDataFactory::Context& cctx = static_cast<boo::ID3DDataFactory::Context&>(ctx); boo::ID3DDataFactory::Context& cctx = static_cast<boo::ID3DDataFactory::Context&>(ctx);
for (int i=0 ; i<4 ; ++i) for (int i=0 ; i<4 ; ++i)
filter.m_dataBinds[i] = cctx.newShaderDataBinding(s_Pipelines[i], s_VtxFmt, filter.m_dataBinds[i] = cctx.newShaderDataBinding(s_Pipelines[i], s_VtxFmt,
filter.m_vbo, nullptr, nullptr, 0, nullptr, filter.m_vbo.get(), nullptr, nullptr, 0, nullptr,
nullptr, nullptr, nullptr, 0, nullptr, nullptr, nullptr); nullptr, nullptr, nullptr, 0, nullptr, nullptr, nullptr);
return filter.m_dataBinds[0]; return filter.m_dataBinds[0];
} }
@ -64,4 +65,14 @@ CFogVolumePlaneShader::Initialize(boo::ID3DDataFactory::Context& ctx)
return new CFogVolumePlaneShaderD3DDataBindingFactory; return new CFogVolumePlaneShaderD3DDataBindingFactory;
} }
template <>
void CFogVolumePlaneShader::Shutdown<boo::ID3DDataFactory>()
{
s_VtxFmt.reset();
s_Pipelines[0].reset();
s_Pipelines[1].reset();
s_Pipelines[2].reset();
s_Pipelines[3].reset();
}
} }

View File

@ -39,19 +39,19 @@ static const char* FS =
URDE_DECL_SPECIALIZE_SHADER(CFogVolumePlaneShader) URDE_DECL_SPECIALIZE_SHADER(CFogVolumePlaneShader)
static boo::IVertexFormat* s_VtxFmt = nullptr; static boo::ObjToken<boo::IVertexFormat> s_VtxFmt;
static boo::IShaderPipeline* s_Pipelines[4] = {}; static boo::ObjToken<boo::IShaderPipeline> s_Pipelines[4];
struct CFogVolumePlaneShaderMetalDataBindingFactory : TShader<CFogVolumePlaneShader>::IDataBindingFactory struct CFogVolumePlaneShaderMetalDataBindingFactory : TShader<CFogVolumePlaneShader>::IDataBindingFactory
{ {
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
CFogVolumePlaneShader& filter) CFogVolumePlaneShader& filter)
{ {
boo::MetalDataFactory::Context& cctx = static_cast<boo::MetalDataFactory::Context&>(ctx); boo::MetalDataFactory::Context& cctx = static_cast<boo::MetalDataFactory::Context&>(ctx);
for (int i=0 ; i<4 ; ++i) for (int i=0 ; i<4 ; ++i)
filter.m_dataBinds[i] = cctx.newShaderDataBinding(s_Pipelines[i], s_VtxFmt, filter.m_dataBinds[i] = cctx.newShaderDataBinding(s_Pipelines[i], s_VtxFmt,
filter.m_vbo, nullptr, nullptr, 0, nullptr, filter.m_vbo.get(), nullptr, nullptr, 0, nullptr,
nullptr, nullptr, nullptr, 0, nullptr, nullptr, nullptr); nullptr, nullptr, nullptr, 0, nullptr, nullptr, nullptr);
return filter.m_dataBinds[0]; return filter.m_dataBinds[0];
} }
@ -65,19 +65,33 @@ CFogVolumePlaneShader::Initialize(boo::MetalDataFactory::Context& ctx)
{nullptr, nullptr, boo::VertexSemantic::Position4} {nullptr, nullptr, boo::VertexSemantic::Position4}
}; };
s_VtxFmt = ctx.newVertexFormat(1, VtxVmt); s_VtxFmt = ctx.newVertexFormat(1, VtxVmt);
s_Pipelines[0] = ctx.newShaderPipeline(VS, FS, s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::Zero, s_Pipelines[0] = ctx.newShaderPipeline(VS, FS, nullptr, nullptr,
s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::Zero,
boo::BlendFactor::Zero, boo::Primitive::TriStrips, boo::BlendFactor::Zero, boo::Primitive::TriStrips,
boo::ZTest::LEqual, true, false, false, boo::CullMode::Frontface); boo::ZTest::LEqual, true, false, false, boo::CullMode::Frontface);
s_Pipelines[1] = ctx.newShaderPipeline(VS, FS, s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::Zero, s_Pipelines[1] = ctx.newShaderPipeline(VS, FS, nullptr, nullptr,
s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::Zero,
boo::BlendFactor::Zero, boo::Primitive::TriStrips, boo::BlendFactor::Zero, boo::Primitive::TriStrips,
boo::ZTest::None, false, false, false, boo::CullMode::Frontface); boo::ZTest::None, false, false, false, boo::CullMode::Frontface);
s_Pipelines[2] = ctx.newShaderPipeline(VS, FS, s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::Zero, s_Pipelines[2] = ctx.newShaderPipeline(VS, FS, nullptr, nullptr,
s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::Zero,
boo::BlendFactor::Zero, boo::Primitive::TriStrips, boo::BlendFactor::Zero, boo::Primitive::TriStrips,
boo::ZTest::LEqual, true, false, false, boo::CullMode::Backface); boo::ZTest::LEqual, true, false, false, boo::CullMode::Backface);
s_Pipelines[3] = ctx.newShaderPipeline(VS, FS, s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::Zero, s_Pipelines[3] = ctx.newShaderPipeline(VS, FS, nullptr, nullptr,
s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::Zero,
boo::BlendFactor::Zero, boo::Primitive::TriStrips, boo::BlendFactor::Zero, boo::Primitive::TriStrips,
boo::ZTest::Greater, false, false, false, boo::CullMode::Backface); boo::ZTest::Greater, false, false, false, boo::CullMode::Backface);
return new CFogVolumePlaneShaderMetalDataBindingFactory; return new CFogVolumePlaneShaderMetalDataBindingFactory;
} }
template <>
void CFogVolumePlaneShader::Shutdown<boo::MetalDataFactory>()
{
s_VtxFmt.reset();
s_Pipelines[0].reset();
s_Pipelines[1].reset();
s_Pipelines[2].reset();
s_Pipelines[3].reset();
}
} }

View File

@ -3,24 +3,23 @@
namespace urde namespace urde
{ {
boo::IShaderPipeline* CLineRendererShaders::m_texAlpha = nullptr; boo::ObjToken<boo::IShaderPipeline> CLineRendererShaders::m_texAlpha;
boo::IShaderPipeline* CLineRendererShaders::m_texAdditive = nullptr; boo::ObjToken<boo::IShaderPipeline> CLineRendererShaders::m_texAdditive;
boo::IShaderPipeline* CLineRendererShaders::m_noTexAlpha = nullptr; boo::ObjToken<boo::IShaderPipeline> CLineRendererShaders::m_noTexAlpha;
boo::IShaderPipeline* CLineRendererShaders::m_noTexAdditive = nullptr; boo::ObjToken<boo::IShaderPipeline> CLineRendererShaders::m_noTexAdditive;
boo::IVertexFormat* CLineRendererShaders::m_texVtxFmt = nullptr; boo::ObjToken<boo::IVertexFormat> CLineRendererShaders::m_texVtxFmt;
boo::IVertexFormat* CLineRendererShaders::m_noTexVtxFmt = nullptr; boo::ObjToken<boo::IVertexFormat> CLineRendererShaders::m_noTexVtxFmt;
std::unique_ptr<CLineRendererShaders::IDataBindingFactory> CLineRendererShaders::m_bindFactory; std::unique_ptr<CLineRendererShaders::IDataBindingFactory> CLineRendererShaders::m_bindFactory;
boo::GraphicsDataToken CLineRendererShaders::m_gfxToken;
void CLineRendererShaders::Initialize() void CLineRendererShaders::Initialize()
{ {
if (!CGraphics::g_BooFactory) if (!CGraphics::g_BooFactory)
return; return;
m_gfxToken = CGraphics::CommitResources( CGraphics::CommitResources(
[&](boo::IGraphicsDataFactory::Context& ctx) -> bool [&](boo::IGraphicsDataFactory::Context& ctx) -> bool
{ {
switch (ctx.platform()) switch (ctx.platform())
@ -52,15 +51,20 @@ void CLineRendererShaders::Initialize()
void CLineRendererShaders::Shutdown() void CLineRendererShaders::Shutdown()
{ {
m_gfxToken.doDestroy(); m_texAlpha.reset();
m_texAdditive.reset();
m_noTexAlpha.reset();
m_noTexAdditive.reset();
m_texVtxFmt.reset();
m_noTexVtxFmt.reset();
} }
void CLineRendererShaders::BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, void CLineRendererShaders::BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
CLineRenderer& renderer, CLineRenderer& renderer,
boo::ITexture* texture, const boo::ObjToken<boo::ITexture>& texture,
bool additive) bool additive)
{ {
boo::IShaderPipeline* pipeline = nullptr; boo::ObjToken<boo::IShaderPipeline> pipeline;
if (texture) if (texture)
{ {
if (additive) if (additive)

View File

@ -18,22 +18,21 @@ public:
{ {
virtual void BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, virtual void BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
CLineRenderer& renderer, CLineRenderer& renderer,
boo::IShaderPipeline* pipeline, const boo::ObjToken<boo::IShaderPipeline>& pipeline,
boo::ITexture* texture)=0; const boo::ObjToken<boo::ITexture>& texture)=0;
}; };
private: private:
static boo::IShaderPipeline* m_texAlpha; static boo::ObjToken<boo::IShaderPipeline> m_texAlpha;
static boo::IShaderPipeline* m_texAdditive; static boo::ObjToken<boo::IShaderPipeline> m_texAdditive;
static boo::IShaderPipeline* m_noTexAlpha; static boo::ObjToken<boo::IShaderPipeline> m_noTexAlpha;
static boo::IShaderPipeline* m_noTexAdditive; static boo::ObjToken<boo::IShaderPipeline> m_noTexAdditive;
static boo::IVertexFormat* m_texVtxFmt; static boo::ObjToken<boo::IVertexFormat> m_texVtxFmt;
static boo::IVertexFormat* m_noTexVtxFmt; static boo::ObjToken<boo::IVertexFormat> m_noTexVtxFmt;
static std::unique_ptr<IDataBindingFactory> m_bindFactory; static std::unique_ptr<IDataBindingFactory> m_bindFactory;
static boo::GraphicsDataToken m_gfxToken;
public: public:
static IDataBindingFactory* Initialize(boo::GLDataFactory::Context& ctx); static IDataBindingFactory* Initialize(boo::GLDataFactory::Context& ctx);
@ -50,7 +49,7 @@ public:
static void Initialize(); static void Initialize();
static void Shutdown(); static void Shutdown();
static void BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, CLineRenderer& renderer, static void BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, CLineRenderer& renderer,
boo::ITexture* texture, bool additive); const boo::ObjToken<boo::ITexture>& texture, bool additive);
}; };
} }

View File

@ -88,15 +88,19 @@ BOO_GLSL_BINDING_HEAD
struct OGLLineDataBindingFactory : CLineRendererShaders::IDataBindingFactory struct OGLLineDataBindingFactory : CLineRendererShaders::IDataBindingFactory
{ {
void BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, CLineRenderer& renderer, void BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
boo::IShaderPipeline* pipeline, boo::ITexture* texture) CLineRenderer& renderer,
const boo::ObjToken<boo::IShaderPipeline>& pipeline,
const boo::ObjToken<boo::ITexture>& texture)
{ {
boo::IVertexFormat* vtxFmt = nullptr; boo::ObjToken<boo::IVertexFormat> vtxFmt;
int texCount = 0; int texCount = 0;
boo::ITexture* textures[1]; boo::ObjToken<boo::ITexture> textures[1];
std::pair<boo::IGraphicsBufferD*, hecl::VertexBufferPool<CLineRenderer::SDrawVertTex>::IndexTp> vbufInfo; std::pair<boo::ObjToken<boo::IGraphicsBufferD>,
std::pair<boo::IGraphicsBufferD*, hecl::UniformBufferPool<CLineRenderer::SDrawUniform>::IndexTp> ubufInfo = hecl::VertexBufferPool<CLineRenderer::SDrawVertTex>::IndexTp> vbufInfo;
std::pair<boo::ObjToken<boo::IGraphicsBufferD>,
hecl::UniformBufferPool<CLineRenderer::SDrawUniform>::IndexTp> ubufInfo =
renderer.m_uniformBuf.getBufferInfo(); renderer.m_uniformBuf.getBufferInfo();
if (texture) if (texture)
{ {
@ -105,9 +109,9 @@ struct OGLLineDataBindingFactory : CLineRendererShaders::IDataBindingFactory
texCount = 1; texCount = 1;
const boo::VertexElementDescriptor TexFmtTex[] = const boo::VertexElementDescriptor TexFmtTex[] =
{ {
{vbufInfo.first, nullptr, boo::VertexSemantic::Position4}, {vbufInfo.first.get(), nullptr, boo::VertexSemantic::Position4},
{vbufInfo.first, nullptr, boo::VertexSemantic::Color}, {vbufInfo.first.get(), nullptr, boo::VertexSemantic::Color},
{vbufInfo.first, nullptr, boo::VertexSemantic::UV4} {vbufInfo.first.get(), nullptr, boo::VertexSemantic::UV4}
}; };
vtxFmt = ctx.newVertexFormat(3, TexFmtTex); vtxFmt = ctx.newVertexFormat(3, TexFmtTex);
} }
@ -116,18 +120,18 @@ struct OGLLineDataBindingFactory : CLineRendererShaders::IDataBindingFactory
vbufInfo = renderer.m_vertBufNoTex.getBufferInfo(); vbufInfo = renderer.m_vertBufNoTex.getBufferInfo();
const boo::VertexElementDescriptor TexFmtNoTex[] = const boo::VertexElementDescriptor TexFmtNoTex[] =
{ {
{vbufInfo.first, nullptr, boo::VertexSemantic::Position4}, {vbufInfo.first.get(), nullptr, boo::VertexSemantic::Position4},
{vbufInfo.first, nullptr, boo::VertexSemantic::Color} {vbufInfo.first.get(), nullptr, boo::VertexSemantic::Color}
}; };
vtxFmt = ctx.newVertexFormat(2, TexFmtNoTex); vtxFmt = ctx.newVertexFormat(2, TexFmtNoTex);
} }
boo::IGraphicsBuffer* uniforms[] = {ubufInfo.first}; boo::ObjToken<boo::IGraphicsBuffer> uniforms[] = {ubufInfo.first.get()};
boo::PipelineStage stages[] = {boo::PipelineStage::Vertex}; boo::PipelineStage stages[] = {boo::PipelineStage::Vertex};
size_t ubufOffs[] = {size_t(ubufInfo.second)}; size_t ubufOffs[] = {size_t(ubufInfo.second)};
size_t ubufSizes[] = {sizeof(CLineRenderer::SDrawUniform)}; size_t ubufSizes[] = {sizeof(CLineRenderer::SDrawUniform)};
renderer.m_shaderBind = ctx.newShaderDataBinding(pipeline, vtxFmt, vbufInfo.first, renderer.m_shaderBind = ctx.newShaderDataBinding(pipeline, vtxFmt, vbufInfo.first.get(),
nullptr, nullptr, 1, uniforms, stages, nullptr, nullptr, 1, uniforms, stages,
ubufOffs, ubufSizes, texCount, textures, ubufOffs, ubufSizes, texCount, textures,
nullptr, nullptr, vbufInfo.second); nullptr, nullptr, vbufInfo.second);
@ -147,11 +151,11 @@ CLineRendererShaders::IDataBindingFactory* CLineRendererShaders::Initialize(boo:
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One, boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
boo::Primitive::TriStrips, boo::ZTest::None, boo::Primitive::TriStrips, boo::ZTest::None,
false, true, false, boo::CullMode::None); false, true, false, boo::CullMode::None);
m_noTexAlpha = ctx.newShaderPipeline(VS_GLSL_NOTEX, FS_GLSL_NOTEX, 1, nullptr, 1, UniNames, m_noTexAlpha = ctx.newShaderPipeline(VS_GLSL_NOTEX, FS_GLSL_NOTEX, 0, nullptr, 1, UniNames,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha, boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
boo::Primitive::TriStrips, boo::ZTest::None, boo::Primitive::TriStrips, boo::ZTest::None,
false, true, false, boo::CullMode::None); false, true, false, boo::CullMode::None);
m_noTexAdditive = ctx.newShaderPipeline(VS_GLSL_NOTEX, FS_GLSL_NOTEX, 1, nullptr, 1, UniNames, m_noTexAdditive = ctx.newShaderPipeline(VS_GLSL_NOTEX, FS_GLSL_NOTEX, 0, nullptr, 1, UniNames,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One, boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
boo::Primitive::TriStrips, boo::ZTest::None, boo::Primitive::TriStrips, boo::ZTest::None,
false, true, false, boo::CullMode::None); false, true, false, boo::CullMode::None);
@ -163,13 +167,16 @@ CLineRendererShaders::IDataBindingFactory* CLineRendererShaders::Initialize(boo:
struct VulkanLineDataBindingFactory : CLineRendererShaders::IDataBindingFactory struct VulkanLineDataBindingFactory : CLineRendererShaders::IDataBindingFactory
{ {
void BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, CLineRenderer& renderer, void BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, CLineRenderer& renderer,
boo::IShaderPipeline* pipeline, boo::ITexture* texture) const boo::ObjToken<boo::IShaderPipeline>& pipeline,
const boo::ObjToken<boo::ITexture>& texture)
{ {
int texCount = 0; int texCount = 0;
boo::ITexture* textures[1]; boo::ObjToken<boo::ITexture> textures[1];
std::pair<boo::IGraphicsBufferD*, hecl::VertexBufferPool<CLineRenderer::SDrawVertTex>::IndexTp> vbufInfo; std::pair<boo::ObjToken<boo::IGraphicsBufferD>,
std::pair<boo::IGraphicsBufferD*, hecl::UniformBufferPool<CLineRenderer::SDrawUniform>::IndexTp> ubufInfo = hecl::VertexBufferPool<CLineRenderer::SDrawVertTex>::IndexTp> vbufInfo;
std::pair<boo::ObjToken<boo::IGraphicsBufferD>,
hecl::UniformBufferPool<CLineRenderer::SDrawUniform>::IndexTp> ubufInfo =
renderer.m_uniformBuf.getBufferInfo(); renderer.m_uniformBuf.getBufferInfo();
if (texture) if (texture)
{ {
@ -182,12 +189,12 @@ struct VulkanLineDataBindingFactory : CLineRendererShaders::IDataBindingFactory
vbufInfo = renderer.m_vertBufNoTex.getBufferInfo(); vbufInfo = renderer.m_vertBufNoTex.getBufferInfo();
} }
boo::IGraphicsBuffer* uniforms[] = {ubufInfo.first}; boo::ObjToken<boo::IGraphicsBuffer> uniforms[] = {ubufInfo.first.get()};
boo::PipelineStage stages[] = {boo::PipelineStage::Vertex}; boo::PipelineStage stages[] = {boo::PipelineStage::Vertex};
size_t ubufOffs[] = {size_t(ubufInfo.second)}; size_t ubufOffs[] = {size_t(ubufInfo.second)};
size_t ubufSizes[] = {sizeof(CLineRenderer::SDrawUniform)}; size_t ubufSizes[] = {sizeof(CLineRenderer::SDrawUniform)};
renderer.m_shaderBind = ctx.newShaderDataBinding(pipeline, nullptr, vbufInfo.first, renderer.m_shaderBind = ctx.newShaderDataBinding(pipeline, nullptr, vbufInfo.first.get(),
nullptr, nullptr, 1, uniforms, nullptr, nullptr, 1, uniforms,
stages, ubufOffs, ubufSizes, texCount, textures, stages, ubufOffs, ubufSizes, texCount, textures,
nullptr, nullptr, vbufInfo.second); nullptr, nullptr, vbufInfo.second);

View File

@ -89,13 +89,16 @@ static const char* FS_HLSL_NOTEX =
struct HLSLLineDataBindingFactory : CLineRendererShaders::IDataBindingFactory struct HLSLLineDataBindingFactory : CLineRendererShaders::IDataBindingFactory
{ {
void BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, CLineRenderer& renderer, void BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, CLineRenderer& renderer,
boo::IShaderPipeline* pipeline, boo::ITexture* texture) const boo::ObjToken<boo::IShaderPipeline>& pipeline,
const boo::ObjToken<boo::ITexture>& texture)
{ {
int texCount = 0; int texCount = 0;
boo::ITexture* textures[1]; boo::ObjToken<boo::ITexture> textures[1];
std::pair<boo::IGraphicsBufferD*, hecl::VertexBufferPool<CLineRenderer::SDrawVertTex>::IndexTp> vbufInfo; std::pair<boo::ObjToken<boo::IGraphicsBufferD>,
std::pair<boo::IGraphicsBufferD*, hecl::UniformBufferPool<CLineRenderer::SDrawUniform>::IndexTp> ubufInfo = hecl::VertexBufferPool<CLineRenderer::SDrawVertTex>::IndexTp> vbufInfo;
std::pair<boo::ObjToken<boo::IGraphicsBufferD>,
hecl::UniformBufferPool<CLineRenderer::SDrawUniform>::IndexTp> ubufInfo =
renderer.m_uniformBuf.getBufferInfo(); renderer.m_uniformBuf.getBufferInfo();
if (texture) if (texture)
{ {
@ -108,12 +111,12 @@ struct HLSLLineDataBindingFactory : CLineRendererShaders::IDataBindingFactory
vbufInfo = renderer.m_vertBufNoTex.getBufferInfo(); vbufInfo = renderer.m_vertBufNoTex.getBufferInfo();
} }
boo::IGraphicsBuffer* uniforms[] = {ubufInfo.first}; boo::ObjToken<boo::IGraphicsBuffer> uniforms[] = {ubufInfo.first.get()};
boo::PipelineStage stages[] = {boo::PipelineStage::Vertex}; boo::PipelineStage stages[] = {boo::PipelineStage::Vertex};
size_t ubufOffs[] = {size_t(ubufInfo.second)}; size_t ubufOffs[] = {size_t(ubufInfo.second)};
size_t ubufSizes[] = {sizeof(CLineRenderer::SDrawUniform)}; size_t ubufSizes[] = {sizeof(CLineRenderer::SDrawUniform)};
renderer.m_shaderBind = ctx.newShaderDataBinding(pipeline, nullptr, vbufInfo.first, renderer.m_shaderBind = ctx.newShaderDataBinding(pipeline, nullptr, vbufInfo.first.get(),
nullptr, nullptr, 1, uniforms, stages, nullptr, nullptr, 1, uniforms, stages,
ubufOffs, ubufSizes, texCount, textures, ubufOffs, ubufSizes, texCount, textures,
nullptr, nullptr, vbufInfo.second); nullptr, nullptr, vbufInfo.second);

View File

@ -103,14 +103,18 @@ static const char* FS_METAL_NOTEX =
struct MetalLineDataBindingFactory : CLineRendererShaders::IDataBindingFactory struct MetalLineDataBindingFactory : CLineRendererShaders::IDataBindingFactory
{ {
void BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, CLineRenderer& renderer, void BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
boo::IShaderPipeline* pipeline, boo::ITexture* texture) CLineRenderer& renderer,
const boo::ObjToken<boo::IShaderPipeline>& pipeline,
const boo::ObjToken<boo::ITexture>& texture)
{ {
int texCount = 0; int texCount = 0;
boo::ITexture* textures[1]; boo::ObjToken<boo::ITexture> textures[1];
std::pair<boo::IGraphicsBufferD*, hecl::VertexBufferPool<CLineRenderer::SDrawVertTex>::IndexTp> vbufInfo; std::pair<boo::ObjToken<boo::IGraphicsBufferD>,
std::pair<boo::IGraphicsBufferD*, hecl::UniformBufferPool<CLineRenderer::SDrawUniform>::IndexTp> ubufInfo = hecl::VertexBufferPool<CLineRenderer::SDrawVertTex>::IndexTp> vbufInfo;
std::pair<boo::ObjToken<boo::IGraphicsBufferD>,
hecl::UniformBufferPool<CLineRenderer::SDrawUniform>::IndexTp> ubufInfo =
renderer.m_uniformBuf.getBufferInfo(); renderer.m_uniformBuf.getBufferInfo();
if (texture) if (texture)
{ {
@ -123,12 +127,12 @@ struct MetalLineDataBindingFactory : CLineRendererShaders::IDataBindingFactory
vbufInfo = renderer.m_vertBufNoTex.getBufferInfo(); vbufInfo = renderer.m_vertBufNoTex.getBufferInfo();
} }
boo::IGraphicsBuffer* uniforms[] = {ubufInfo.first}; boo::ObjToken<boo::IGraphicsBuffer> uniforms[] = {ubufInfo.first.get()};
boo::PipelineStage stages[] = {boo::PipelineStage::Vertex}; boo::PipelineStage stages[] = {boo::PipelineStage::Vertex};
size_t ubufOffs[] = {ubufInfo.second}; size_t ubufOffs[] = {ubufInfo.second};
size_t ubufSizes[] = {sizeof(CLineRenderer::SDrawUniform)}; size_t ubufSizes[] = {sizeof(CLineRenderer::SDrawUniform)};
renderer.m_shaderBind = ctx.newShaderDataBinding(pipeline, nullptr, vbufInfo.first, renderer.m_shaderBind = ctx.newShaderDataBinding(pipeline, nullptr, vbufInfo.first.get(),
nullptr, nullptr, 1, uniforms, stages, nullptr, nullptr, 1, uniforms, stages,
ubufOffs, ubufSizes, texCount, textures, ubufOffs, ubufSizes, texCount, textures,
nullptr, nullptr, vbufInfo.second); nullptr, nullptr, vbufInfo.second);
@ -152,19 +156,19 @@ CLineRendererShaders::IDataBindingFactory* CLineRendererShaders::Initialize(boo:
}; };
m_noTexVtxFmt = ctx.newVertexFormat(2, VtxFmtNoTex); m_noTexVtxFmt = ctx.newVertexFormat(2, VtxFmtNoTex);
m_texAlpha = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX, m_texVtxFmt, m_texAlpha = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX, nullptr, nullptr, m_texVtxFmt,
CGraphics::g_ViewportSamples, CGraphics::g_ViewportSamples,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha, boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
boo::Primitive::TriStrips, boo::ZTest::None, true, true, true, boo::CullMode::None); boo::Primitive::TriStrips, boo::ZTest::None, true, true, true, boo::CullMode::None);
m_texAdditive = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX, m_texVtxFmt, m_texAdditive = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX, nullptr, nullptr, m_texVtxFmt,
CGraphics::g_ViewportSamples, CGraphics::g_ViewportSamples,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One, boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
boo::Primitive::TriStrips, boo::ZTest::None, false, true, true, boo::CullMode::None); boo::Primitive::TriStrips, boo::ZTest::None, false, true, true, boo::CullMode::None);
m_noTexAlpha = ctx.newShaderPipeline(VS_METAL_NOTEX, FS_METAL_NOTEX, m_noTexVtxFmt, m_noTexAlpha = ctx.newShaderPipeline(VS_METAL_NOTEX, FS_METAL_NOTEX, nullptr, nullptr, m_noTexVtxFmt,
CGraphics::g_ViewportSamples, CGraphics::g_ViewportSamples,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha, boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
boo::Primitive::TriStrips, boo::ZTest::None, true, true, true, boo::CullMode::None); boo::Primitive::TriStrips, boo::ZTest::None, true, true, true, boo::CullMode::None);
m_noTexAdditive = ctx.newShaderPipeline(VS_METAL_NOTEX, FS_METAL_NOTEX, m_noTexVtxFmt, m_noTexAdditive = ctx.newShaderPipeline(VS_METAL_NOTEX, FS_METAL_NOTEX, nullptr, nullptr, m_noTexVtxFmt,
CGraphics::g_ViewportSamples, CGraphics::g_ViewportSamples,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One, boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
boo::Primitive::TriStrips, boo::ZTest::None, false, true, true, boo::CullMode::None); boo::Primitive::TriStrips, boo::ZTest::None, false, true, true, boo::CullMode::None);

View File

@ -4,8 +4,8 @@ namespace urde
{ {
CMapSurfaceShader::CMapSurfaceShader(boo::IGraphicsDataFactory::Context& ctx, CMapSurfaceShader::CMapSurfaceShader(boo::IGraphicsDataFactory::Context& ctx,
boo::IGraphicsBufferS* vbo, const boo::ObjToken<boo::IGraphicsBufferS>& vbo,
boo::IGraphicsBufferS* ibo) const boo::ObjToken<boo::IGraphicsBufferS>& ibo)
: m_vbo(vbo), m_ibo(ibo) : m_vbo(vbo), m_ibo(ibo)
{ {
m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1); m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1);
@ -24,6 +24,4 @@ void CMapSurfaceShader::draw(const zeus::CColor& color, u32 start, u32 count)
URDE_SPECIALIZE_SHADER(CMapSurfaceShader) URDE_SPECIALIZE_SHADER(CMapSurfaceShader)
void CMapSurfaceShader::Shutdown() {}
} }

View File

@ -19,14 +19,14 @@ class CMapSurfaceShader
zeus::CColor color; zeus::CColor color;
}; };
boo::IGraphicsBufferD* m_uniBuf; boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf;
boo::IGraphicsBufferS* m_vbo; boo::ObjToken<boo::IGraphicsBufferS> m_vbo;
boo::IGraphicsBufferS* m_ibo; boo::ObjToken<boo::IGraphicsBufferS> m_ibo;
boo::IShaderDataBinding* m_dataBind; boo::ObjToken<boo::IShaderDataBinding> m_dataBind;
public: public:
CMapSurfaceShader(boo::IGraphicsDataFactory::Context& ctx, boo::IGraphicsBufferS* vbo, CMapSurfaceShader(boo::IGraphicsDataFactory::Context& ctx, const boo::ObjToken<boo::IGraphicsBufferS>& vbo,
boo::IGraphicsBufferS* ibo); const boo::ObjToken<boo::IGraphicsBufferS>& ibo);
void draw(const zeus::CColor& color, u32 start, u32 count); void draw(const zeus::CColor& color, u32 start, u32 count);
using _CLS = CMapSurfaceShader; using _CLS = CMapSurfaceShader;

View File

@ -44,25 +44,25 @@ BOO_GLSL_BINDING_HEAD
URDE_DECL_SPECIALIZE_SHADER(CMapSurfaceShader) URDE_DECL_SPECIALIZE_SHADER(CMapSurfaceShader)
static boo::IVertexFormat* s_VtxFmt = nullptr; static boo::ObjToken<boo::IVertexFormat> s_VtxFmt;
static boo::IShaderPipeline* s_Pipeline = nullptr; static boo::ObjToken<boo::IShaderPipeline> s_Pipeline;
struct CMapSurfaceShaderGLDataBindingFactory : TShader<CMapSurfaceShader>::IDataBindingFactory struct CMapSurfaceShaderGLDataBindingFactory : TShader<CMapSurfaceShader>::IDataBindingFactory
{ {
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
CMapSurfaceShader& filter) CMapSurfaceShader& filter)
{ {
boo::GLDataFactory::Context& cctx = static_cast<boo::GLDataFactory::Context&>(ctx); boo::GLDataFactory::Context& cctx = static_cast<boo::GLDataFactory::Context&>(ctx);
const boo::VertexElementDescriptor VtxVmt[] = const boo::VertexElementDescriptor VtxVmt[] =
{ {
{filter.m_vbo, filter.m_ibo, boo::VertexSemantic::Position4} {filter.m_vbo.get(), filter.m_ibo.get(), boo::VertexSemantic::Position4}
}; };
boo::IVertexFormat* vtxFmt = ctx.newVertexFormat(1, VtxVmt); boo::ObjToken<boo::IVertexFormat> vtxFmt = ctx.newVertexFormat(1, VtxVmt);
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf}; boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {filter.m_uniBuf.get()};
boo::PipelineStage stages[] = {boo::PipelineStage::Vertex}; boo::PipelineStage stages[] = {boo::PipelineStage::Vertex};
filter.m_dataBind = cctx.newShaderDataBinding(s_Pipeline, filter.m_dataBind = cctx.newShaderDataBinding(s_Pipeline,
vtxFmt, filter.m_vbo, nullptr, filter.m_ibo, vtxFmt, filter.m_vbo.get(), nullptr, filter.m_ibo.get(),
1, bufs, stages, nullptr, nullptr, 0, nullptr, nullptr, nullptr); 1, bufs, stages, nullptr, nullptr, 0, nullptr, nullptr, nullptr);
return filter.m_dataBind; return filter.m_dataBind;
} }
@ -71,14 +71,15 @@ struct CMapSurfaceShaderGLDataBindingFactory : TShader<CMapSurfaceShader>::IData
#if BOO_HAS_VULKAN #if BOO_HAS_VULKAN
struct CMapSurfaceShaderVulkanDataBindingFactory : TShader<CMapSurfaceShader>::IDataBindingFactory struct CMapSurfaceShaderVulkanDataBindingFactory : TShader<CMapSurfaceShader>::IDataBindingFactory
{ {
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, boo::ObjToken<boo::IShaderDataBinding>
BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
CMapSurfaceShader& filter) CMapSurfaceShader& filter)
{ {
boo::VulkanDataFactory::Context& cctx = static_cast<boo::VulkanDataFactory::Context&>(ctx); boo::VulkanDataFactory::Context& cctx = static_cast<boo::VulkanDataFactory::Context&>(ctx);
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf}; boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {filter.m_uniBuf.get()};
filter.m_dataBind = cctx.newShaderDataBinding(s_Pipeline, s_VtxFmt, filter.m_dataBind = cctx.newShaderDataBinding(s_Pipeline, s_VtxFmt,
filter.m_vbo, nullptr, filter.m_ibo, 1, bufs, filter.m_vbo.get(), nullptr, filter.m_ibo.get(), 1, bufs,
nullptr, nullptr, nullptr, 0, nullptr, nullptr, nullptr); nullptr, nullptr, nullptr, 0, nullptr, nullptr, nullptr);
return filter.m_dataBind; return filter.m_dataBind;
} }
@ -96,6 +97,12 @@ CMapSurfaceShader::Initialize(boo::GLDataFactory::Context& ctx)
return new CMapSurfaceShaderGLDataBindingFactory; return new CMapSurfaceShaderGLDataBindingFactory;
} }
template <>
void CMapSurfaceShader::Shutdown<boo::GLDataFactory>()
{
s_Pipeline.reset();
}
#if BOO_HAS_VULKAN #if BOO_HAS_VULKAN
TShader<CMapSurfaceShader>::IDataBindingFactory* TShader<CMapSurfaceShader>::IDataBindingFactory*
CMapSurfaceShader::Initialize(boo::VulkanDataFactory::Context& ctx) CMapSurfaceShader::Initialize(boo::VulkanDataFactory::Context& ctx)
@ -110,6 +117,13 @@ CMapSurfaceShader::Initialize(boo::VulkanDataFactory::Context& ctx)
boo::ZTest::LEqual, false, true, false, boo::CullMode::Backface); boo::ZTest::LEqual, false, true, false, boo::CullMode::Backface);
return new CMapSurfaceShaderVulkanDataBindingFactory; return new CMapSurfaceShaderVulkanDataBindingFactory;
} }
template <>
void CMapSurfaceShader::Shutdown<boo::VulkanDataFactory>()
{
s_VtxFmt.reset();
s_Pipeline.reset();
}
#endif #endif
} }

View File

@ -44,19 +44,20 @@ static const char* FS =
URDE_DECL_SPECIALIZE_SHADER(CMapSurfaceShader) URDE_DECL_SPECIALIZE_SHADER(CMapSurfaceShader)
static boo::IVertexFormat* s_VtxFmt = nullptr; static boo::ObjToken<boo::IVertexFormat> s_VtxFmt;
static boo::IShaderPipeline* s_Pipeline = nullptr; static boo::ObjToken<boo::IShaderPipeline> s_Pipeline;
struct CMapSurfaceShaderD3DDataBindingFactory : TShader<CMapSurfaceShader>::IDataBindingFactory struct CMapSurfaceShaderD3DDataBindingFactory : TShader<CMapSurfaceShader>::IDataBindingFactory
{ {
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, boo::ObjToken<boo::IShaderDataBinding>
BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
CMapSurfaceShader& filter) CMapSurfaceShader& filter)
{ {
boo::ID3DDataFactory::Context& cctx = static_cast<boo::ID3DDataFactory::Context&>(ctx); boo::ID3DDataFactory::Context& cctx = static_cast<boo::ID3DDataFactory::Context&>(ctx);
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf}; boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {filter.m_uniBuf.get()};
filter.m_dataBind = cctx.newShaderDataBinding(s_Pipeline, s_VtxFmt, filter.m_dataBind = cctx.newShaderDataBinding(s_Pipeline, s_VtxFmt,
filter.m_vbo, nullptr, filter.m_ibo, 1, bufs, filter.m_vbo.get(), nullptr, filter.m_ibo.get(), 1, bufs,
nullptr, nullptr, nullptr, 0, nullptr, nullptr, nullptr); nullptr, nullptr, nullptr, 0, nullptr, nullptr, nullptr);
return filter.m_dataBind; return filter.m_dataBind;
} }
@ -76,4 +77,11 @@ CMapSurfaceShader::Initialize(boo::ID3DDataFactory::Context& ctx)
return new CMapSurfaceShaderD3DDataBindingFactory; return new CMapSurfaceShaderD3DDataBindingFactory;
} }
template <>
void CMapSurfaceShader::Shutdown<boo::ID3DDataFactory>()
{
s_VtxFmt.reset();
s_Pipeline.reset();
}
} }

View File

@ -48,19 +48,19 @@ static const char* FS =
URDE_DECL_SPECIALIZE_SHADER(CMapSurfaceShader) URDE_DECL_SPECIALIZE_SHADER(CMapSurfaceShader)
static boo::IVertexFormat* s_VtxFmt = nullptr; static boo::ObjToken<boo::IVertexFormat> s_VtxFmt;
static boo::IShaderPipeline* s_Pipeline = nullptr; static boo::ObjToken<boo::IShaderPipeline> s_Pipeline;
struct CMapSurfaceShaderMetalDataBindingFactory : TShader<CMapSurfaceShader>::IDataBindingFactory struct CMapSurfaceShaderMetalDataBindingFactory : TShader<CMapSurfaceShader>::IDataBindingFactory
{ {
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
CMapSurfaceShader& filter) CMapSurfaceShader& filter)
{ {
boo::MetalDataFactory::Context& cctx = static_cast<boo::MetalDataFactory::Context&>(ctx); boo::MetalDataFactory::Context& cctx = static_cast<boo::MetalDataFactory::Context&>(ctx);
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf}; boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {filter.m_uniBuf.get()};
filter.m_dataBind = cctx.newShaderDataBinding(s_Pipeline, s_VtxFmt, filter.m_dataBind = cctx.newShaderDataBinding(s_Pipeline, s_VtxFmt,
filter.m_vbo, nullptr, filter.m_ibo, 1, bufs, filter.m_vbo.get(), nullptr, filter.m_ibo.get(), 1, bufs,
nullptr, nullptr, nullptr, 0, nullptr, nullptr, nullptr); nullptr, nullptr, nullptr, 0, nullptr, nullptr, nullptr);
return filter.m_dataBind; return filter.m_dataBind;
} }
@ -74,10 +74,18 @@ CMapSurfaceShader::Initialize(boo::MetalDataFactory::Context& ctx)
{nullptr, nullptr, boo::VertexSemantic::Position4} {nullptr, nullptr, boo::VertexSemantic::Position4}
}; };
s_VtxFmt = ctx.newVertexFormat(1, VtxVmt); s_VtxFmt = ctx.newVertexFormat(1, VtxVmt);
s_Pipeline = ctx.newShaderPipeline(VS, FS, s_VtxFmt, CGraphics::g_ViewportSamples, s_Pipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr,
s_VtxFmt, CGraphics::g_ViewportSamples,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips,
boo::ZTest::LEqual, false, true, false, boo::CullMode::Backface); boo::ZTest::LEqual, false, true, false, boo::CullMode::Backface);
return new CMapSurfaceShaderMetalDataBindingFactory; return new CMapSurfaceShaderMetalDataBindingFactory;
} }
template <>
void CMapSurfaceShader::Shutdown<boo::MetalDataFactory>()
{
s_VtxFmt.reset();
s_Pipeline.reset();
}
} }

View File

@ -5,17 +5,17 @@
namespace urde namespace urde
{ {
boo::IShaderPipeline* CParticleSwooshShaders::m_texZWrite = nullptr; boo::ObjToken<boo::IShaderPipeline> CParticleSwooshShaders::m_texZWrite;
boo::IShaderPipeline* CParticleSwooshShaders::m_texNoZWrite = nullptr; boo::ObjToken<boo::IShaderPipeline> CParticleSwooshShaders::m_texNoZWrite;
boo::IShaderPipeline* CParticleSwooshShaders::m_texAdditiveZWrite = nullptr; boo::ObjToken<boo::IShaderPipeline> CParticleSwooshShaders::m_texAdditiveZWrite;
boo::IShaderPipeline* CParticleSwooshShaders::m_texAdditiveNoZWrite = nullptr; boo::ObjToken<boo::IShaderPipeline> CParticleSwooshShaders::m_texAdditiveNoZWrite;
boo::IShaderPipeline* CParticleSwooshShaders::m_noTexZWrite = nullptr; boo::ObjToken<boo::IShaderPipeline> CParticleSwooshShaders::m_noTexZWrite;
boo::IShaderPipeline* CParticleSwooshShaders::m_noTexNoZWrite = nullptr; boo::ObjToken<boo::IShaderPipeline> CParticleSwooshShaders::m_noTexNoZWrite;
boo::IShaderPipeline* CParticleSwooshShaders::m_noTexAdditiveZWrite = nullptr; boo::ObjToken<boo::IShaderPipeline> CParticleSwooshShaders::m_noTexAdditiveZWrite;
boo::IShaderPipeline* CParticleSwooshShaders::m_noTexAdditiveNoZWrite = nullptr; boo::ObjToken<boo::IShaderPipeline> CParticleSwooshShaders::m_noTexAdditiveNoZWrite;
boo::IVertexFormat* CParticleSwooshShaders::m_vtxFormat = nullptr; boo::ObjToken<boo::IVertexFormat> CParticleSwooshShaders::m_vtxFormat;
CParticleSwooshShaders::EShaderClass CParticleSwooshShaders::GetShaderClass(CParticleSwoosh& gen) CParticleSwooshShaders::EShaderClass CParticleSwooshShaders::GetShaderClass(CParticleSwoosh& gen)
{ {
@ -30,7 +30,7 @@ CParticleSwooshShaders::EShaderClass CParticleSwooshShaders::GetShaderClass(CPar
void CParticleSwooshShaders::BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, CParticleSwoosh& gen) void CParticleSwooshShaders::BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, CParticleSwoosh& gen)
{ {
CSwooshDescription* desc = gen.GetDesc(); CSwooshDescription* desc = gen.GetDesc();
boo::IShaderPipeline* pipeline = nullptr; boo::ObjToken<boo::IShaderPipeline> pipeline;
if (desc->x3c_TEXR) if (desc->x3c_TEXR)
{ {
@ -71,8 +71,6 @@ void CParticleSwooshShaders::BuildShaderDataBinding(boo::IGraphicsDataFactory::C
TShader<CParticleSwooshShaders>::BuildShaderDataBinding(ctx, shad); TShader<CParticleSwooshShaders>::BuildShaderDataBinding(ctx, shad);
} }
void CParticleSwooshShaders::Shutdown() {}
URDE_SPECIALIZE_SHADER(CParticleSwooshShaders) URDE_SPECIALIZE_SHADER(CParticleSwooshShaders)
} }

View File

@ -33,21 +33,21 @@ public:
}; };
private: private:
static boo::IShaderPipeline* m_texZWrite; static boo::ObjToken<boo::IShaderPipeline> m_texZWrite;
static boo::IShaderPipeline* m_texNoZWrite; static boo::ObjToken<boo::IShaderPipeline> m_texNoZWrite;
static boo::IShaderPipeline* m_texAdditiveZWrite; static boo::ObjToken<boo::IShaderPipeline> m_texAdditiveZWrite;
static boo::IShaderPipeline* m_texAdditiveNoZWrite; static boo::ObjToken<boo::IShaderPipeline> m_texAdditiveNoZWrite;
static boo::IShaderPipeline* m_noTexZWrite; static boo::ObjToken<boo::IShaderPipeline> m_noTexZWrite;
static boo::IShaderPipeline* m_noTexNoZWrite; static boo::ObjToken<boo::IShaderPipeline> m_noTexNoZWrite;
static boo::IShaderPipeline* m_noTexAdditiveZWrite; static boo::ObjToken<boo::IShaderPipeline> m_noTexAdditiveZWrite;
static boo::IShaderPipeline* m_noTexAdditiveNoZWrite; static boo::ObjToken<boo::IShaderPipeline> m_noTexAdditiveNoZWrite;
static boo::IVertexFormat* m_vtxFormat; /* No OpenGL */ static boo::ObjToken<boo::IVertexFormat> m_vtxFormat; /* No OpenGL */
CParticleSwoosh& m_gen; CParticleSwoosh& m_gen;
boo::IShaderPipeline* m_pipeline; boo::ObjToken<boo::IShaderPipeline> m_pipeline;
CParticleSwooshShaders(CParticleSwoosh& gen, boo::IShaderPipeline* pipeline) CParticleSwooshShaders(CParticleSwoosh& gen, const boo::ObjToken<boo::IShaderPipeline>& pipeline)
: m_gen(gen), m_pipeline(pipeline) {} : m_gen(gen), m_pipeline(pipeline) {}
public: public:

View File

@ -66,25 +66,25 @@ BOO_GLSL_BINDING_HEAD
struct OGLParticleSwooshDataBindingFactory : TShader<CParticleSwooshShaders>::IDataBindingFactory struct OGLParticleSwooshDataBindingFactory : TShader<CParticleSwooshShaders>::IDataBindingFactory
{ {
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
CParticleSwooshShaders& shaders) CParticleSwooshShaders& shaders)
{ {
CParticleSwoosh& gen = shaders.m_gen; CParticleSwoosh& gen = shaders.m_gen;
CSwooshDescription* desc = gen.GetDesc(); CSwooshDescription* desc = gen.GetDesc();
CUVElement* texr = desc->x3c_TEXR.get(); CUVElement* texr = desc->x3c_TEXR.get();
boo::ITexture* textures[] = {texr ? texr->GetValueTexture(0).GetObj()->GetBooTexture() : nullptr}; boo::ObjToken<boo::ITexture> textures[] = {texr ? texr->GetValueTexture(0).GetObj()->GetBooTexture() : nullptr};
const boo::VertexElementDescriptor VtxFmt[] = const boo::VertexElementDescriptor VtxFmt[] =
{ {
{gen.m_vertBuf, nullptr, boo::VertexSemantic::Position4}, {gen.m_vertBuf.get(), nullptr, boo::VertexSemantic::Position4},
{gen.m_vertBuf, nullptr, boo::VertexSemantic::UV4}, {gen.m_vertBuf.get(), nullptr, boo::VertexSemantic::UV4},
{gen.m_vertBuf, nullptr, boo::VertexSemantic::Color}, {gen.m_vertBuf.get(), nullptr, boo::VertexSemantic::Color},
}; };
boo::IVertexFormat* vtxFmt = ctx.newVertexFormat(3, VtxFmt); boo::ObjToken<boo::IVertexFormat> vtxFmt = ctx.newVertexFormat(3, VtxFmt);
boo::IGraphicsBuffer* uniforms[] = {gen.m_uniformBuf}; boo::ObjToken<boo::IGraphicsBuffer> uniforms[] = {gen.m_uniformBuf.get()};
gen.m_dataBind = ctx.newShaderDataBinding(shaders.m_pipeline, vtxFmt, gen.m_vertBuf, gen.m_dataBind = ctx.newShaderDataBinding(shaders.m_pipeline, vtxFmt, gen.m_vertBuf.get(),
nullptr, nullptr, 1, uniforms, nullptr, nullptr, 1, uniforms,
nullptr, texr ? 1 : 0, textures, nullptr, nullptr); nullptr, texr ? 1 : 0, textures, nullptr, nullptr);
return nullptr; return nullptr;
@ -133,21 +133,36 @@ TShader<CParticleSwooshShaders>::IDataBindingFactory* CParticleSwooshShaders::In
return new struct OGLParticleSwooshDataBindingFactory; return new struct OGLParticleSwooshDataBindingFactory;
} }
template <>
void CParticleSwooshShaders::Shutdown<boo::GLDataFactory>()
{
m_texZWrite.reset();
m_texNoZWrite.reset();
m_texAdditiveZWrite.reset();
m_texAdditiveNoZWrite.reset();
m_noTexZWrite.reset();
m_noTexNoZWrite.reset();
m_noTexAdditiveZWrite.reset();
m_noTexAdditiveNoZWrite.reset();
}
#if BOO_HAS_VULKAN #if BOO_HAS_VULKAN
struct VulkanParticleSwooshDataBindingFactory : TShader<CParticleSwooshShaders>::IDataBindingFactory struct VulkanParticleSwooshDataBindingFactory : TShader<CParticleSwooshShaders>::IDataBindingFactory
{ {
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, boo::ObjToken<boo::IShaderDataBinding>
BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
CParticleSwooshShaders& shaders) CParticleSwooshShaders& shaders)
{ {
CParticleSwoosh& gen = shaders.m_gen; CParticleSwoosh& gen = shaders.m_gen;
CSwooshDescription* desc = gen.GetDesc(); CSwooshDescription* desc = gen.GetDesc();
CUVElement* texr = desc->x3c_TEXR.get(); CUVElement* texr = desc->x3c_TEXR.get();
boo::ITexture* textures[] = {texr->GetValueTexture(0).GetObj()->GetBooTexture()}; boo::ObjToken<boo::ITexture> textures[] = {texr ? texr->GetValueTexture(0).GetObj()->GetBooTexture() : nullptr};
boo::IGraphicsBuffer* uniforms[] = {gen.m_uniformBuf}; boo::ObjToken<boo::IGraphicsBuffer> uniforms[] = {gen.m_uniformBuf.get()};
gen.m_dataBind = ctx.newShaderDataBinding(shaders.m_pipeline, CParticleSwooshShaders::m_vtxFormat, gen.m_dataBind = ctx.newShaderDataBinding(shaders.m_pipeline, CParticleSwooshShaders::m_vtxFormat,
gen.m_vertBuf, nullptr, nullptr, 1, uniforms, gen.m_vertBuf.get(), nullptr, nullptr, 1, uniforms,
nullptr, texr ? 1 : 0, textures, nullptr, nullptr); nullptr, texr ? 1 : 0, textures, nullptr, nullptr);
return nullptr; return nullptr;
} }
@ -199,6 +214,22 @@ TShader<CParticleSwooshShaders>::IDataBindingFactory* CParticleSwooshShaders::In
return new struct VulkanParticleSwooshDataBindingFactory; return new struct VulkanParticleSwooshDataBindingFactory;
} }
template <>
void CParticleSwooshShaders::Shutdown<boo::VulkanDataFactory>()
{
m_vtxFormat.reset();
m_texZWrite.reset();
m_texNoZWrite.reset();
m_texAdditiveZWrite.reset();
m_texAdditiveNoZWrite.reset();
m_noTexZWrite.reset();
m_noTexNoZWrite.reset();
m_noTexAdditiveZWrite.reset();
m_noTexAdditiveNoZWrite.reset();
}
#endif #endif
} }

View File

@ -64,18 +64,19 @@ static const char* FS_NOTEX =
struct D3DParticleSwooshDataBindingFactory : TShader<CParticleSwooshShaders>::IDataBindingFactory struct D3DParticleSwooshDataBindingFactory : TShader<CParticleSwooshShaders>::IDataBindingFactory
{ {
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, boo::ObjToken<boo::IShaderDataBinding>
BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
CParticleSwooshShaders& shaders) CParticleSwooshShaders& shaders)
{ {
CParticleSwoosh& gen = shaders.m_gen; CParticleSwoosh& gen = shaders.m_gen;
CSwooshDescription* desc = gen.GetDesc(); CSwooshDescription* desc = gen.GetDesc();
CUVElement* texr = desc->x3c_TEXR.get(); CUVElement* texr = desc->x3c_TEXR.get();
boo::ITexture* textures[] = {texr ? texr->GetValueTexture(0).GetObj()->GetBooTexture() : nullptr}; boo::ObjToken<boo::ITexture> textures[] = {texr ? texr->GetValueTexture(0).GetObj()->GetBooTexture() : nullptr};
boo::IGraphicsBuffer* uniforms[] = {gen.m_uniformBuf}; boo::ObjToken<boo::IGraphicsBuffer> uniforms[] = {gen.m_uniformBuf.get()};
gen.m_dataBind = ctx.newShaderDataBinding(shaders.m_pipeline, CParticleSwooshShaders::m_vtxFormat, gen.m_dataBind = ctx.newShaderDataBinding(shaders.m_pipeline, CParticleSwooshShaders::m_vtxFormat,
gen.m_vertBuf, nullptr, nullptr, 1, uniforms, gen.m_vertBuf.get(), nullptr, nullptr, 1, uniforms,
nullptr, texr ? 1 : 0, textures, nullptr, nullptr); nullptr, texr ? 1 : 0, textures, nullptr, nullptr);
return nullptr; return nullptr;
} }
@ -128,4 +129,19 @@ TShader<CParticleSwooshShaders>::IDataBindingFactory* CParticleSwooshShaders::In
return new struct D3DParticleSwooshDataBindingFactory; return new struct D3DParticleSwooshDataBindingFactory;
} }
template <>
void CParticleSwooshShaders::Shutdown<boo::ID3DDataFactory>()
{
m_vtxFormat.reset();
m_texZWrite.reset();
m_texNoZWrite.reset();
m_texAdditiveZWrite.reset();
m_texAdditiveNoZWrite.reset();
m_noTexZWrite.reset();
m_noTexNoZWrite.reset();
m_noTexAdditiveZWrite.reset();
m_noTexAdditiveNoZWrite.reset();
}
} }

View File

@ -70,18 +70,18 @@ static const char* FS_NOTEX =
struct MetalParticleSwooshDataBindingFactory : TShader<CParticleSwooshShaders>::IDataBindingFactory struct MetalParticleSwooshDataBindingFactory : TShader<CParticleSwooshShaders>::IDataBindingFactory
{ {
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
CParticleSwooshShaders& shaders) CParticleSwooshShaders& shaders)
{ {
CParticleSwoosh& gen = shaders.m_gen; CParticleSwoosh& gen = shaders.m_gen;
CSwooshDescription* desc = gen.GetDesc(); CSwooshDescription* desc = gen.GetDesc();
CUVElement* texr = desc->x3c_TEXR.get(); CUVElement* texr = desc->x3c_TEXR.get();
boo::ITexture* textures[] = {texr ? texr->GetValueTexture(0).GetObj()->GetBooTexture() : nullptr}; boo::ObjToken<boo::ITexture> textures[] = {texr ? texr->GetValueTexture(0).GetObj()->GetBooTexture() : nullptr};
boo::IGraphicsBuffer* uniforms[] = {gen.m_uniformBuf}; boo::ObjToken<boo::IGraphicsBuffer> uniforms[] = {gen.m_uniformBuf.get()};
gen.m_dataBind = ctx.newShaderDataBinding(shaders.m_pipeline, CParticleSwooshShaders::m_vtxFormat, gen.m_dataBind = ctx.newShaderDataBinding(shaders.m_pipeline, CParticleSwooshShaders::m_vtxFormat,
gen.m_vertBuf, nullptr, nullptr, 1, uniforms, gen.m_vertBuf.get(), nullptr, nullptr, 1, uniforms,
nullptr, texr ? 1 : 0, textures, nullptr, nullptr); nullptr, texr ? 1 : 0, textures, nullptr, nullptr);
return nullptr; return nullptr;
} }
@ -97,36 +97,44 @@ TShader<CParticleSwooshShaders>::IDataBindingFactory* CParticleSwooshShaders::In
}; };
m_vtxFormat = ctx.newVertexFormat(3, VtxFmt); m_vtxFormat = ctx.newVertexFormat(3, VtxFmt);
m_texZWrite = ctx.newShaderPipeline(VS, FS_TEX, m_vtxFormat, CGraphics::g_ViewportSamples, m_texZWrite = ctx.newShaderPipeline(VS, FS_TEX, nullptr, nullptr,
m_vtxFormat, CGraphics::g_ViewportSamples,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha, boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
boo::Primitive::TriStrips, boo::ZTest::LEqual, true, boo::Primitive::TriStrips, boo::ZTest::LEqual, true,
true, false, boo::CullMode::None); true, false, boo::CullMode::None);
m_texNoZWrite = ctx.newShaderPipeline(VS, FS_TEX, m_vtxFormat, CGraphics::g_ViewportSamples, m_texNoZWrite = ctx.newShaderPipeline(VS, FS_TEX, nullptr, nullptr,
m_vtxFormat, CGraphics::g_ViewportSamples,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha, boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
boo::Primitive::TriStrips, boo::ZTest::LEqual, false, boo::Primitive::TriStrips, boo::ZTest::LEqual, false,
true, false, boo::CullMode::None); true, false, boo::CullMode::None);
m_texAdditiveZWrite = ctx.newShaderPipeline(VS, FS_TEX, m_vtxFormat, CGraphics::g_ViewportSamples, m_texAdditiveZWrite = ctx.newShaderPipeline(VS, FS_TEX, nullptr, nullptr,
m_vtxFormat, CGraphics::g_ViewportSamples,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One, boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
boo::Primitive::TriStrips, boo::ZTest::LEqual, true, boo::Primitive::TriStrips, boo::ZTest::LEqual, true,
true, false, boo::CullMode::None); true, false, boo::CullMode::None);
m_texAdditiveNoZWrite = ctx.newShaderPipeline(VS, FS_TEX, m_vtxFormat, CGraphics::g_ViewportSamples, m_texAdditiveNoZWrite = ctx.newShaderPipeline(VS, FS_TEX, nullptr, nullptr,
m_vtxFormat, CGraphics::g_ViewportSamples,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One, boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
boo::Primitive::TriStrips, boo::ZTest::LEqual, false, boo::Primitive::TriStrips, boo::ZTest::LEqual, false,
true, false, boo::CullMode::None); true, false, boo::CullMode::None);
m_noTexZWrite = ctx.newShaderPipeline(VS, FS_NOTEX, m_vtxFormat, CGraphics::g_ViewportSamples, m_noTexZWrite = ctx.newShaderPipeline(VS, FS_NOTEX, nullptr, nullptr,
m_vtxFormat, CGraphics::g_ViewportSamples,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha, boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
boo::Primitive::TriStrips, boo::ZTest::LEqual, true, boo::Primitive::TriStrips, boo::ZTest::LEqual, true,
true, false, boo::CullMode::None); true, false, boo::CullMode::None);
m_noTexNoZWrite = ctx.newShaderPipeline(VS, FS_NOTEX, m_vtxFormat, CGraphics::g_ViewportSamples, m_noTexNoZWrite = ctx.newShaderPipeline(VS, FS_NOTEX, nullptr, nullptr,
m_vtxFormat, CGraphics::g_ViewportSamples,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha, boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
boo::Primitive::TriStrips, boo::ZTest::LEqual, false, boo::Primitive::TriStrips, boo::ZTest::LEqual, false,
true, false, boo::CullMode::None); true, false, boo::CullMode::None);
m_noTexAdditiveZWrite = ctx.newShaderPipeline(VS, FS_NOTEX, m_vtxFormat, CGraphics::g_ViewportSamples, m_noTexAdditiveZWrite = ctx.newShaderPipeline(VS, FS_NOTEX, nullptr, nullptr,
m_vtxFormat, CGraphics::g_ViewportSamples,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One, boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
boo::Primitive::TriStrips, boo::ZTest::LEqual, true, boo::Primitive::TriStrips, boo::ZTest::LEqual, true,
true, false, boo::CullMode::None); true, false, boo::CullMode::None);
m_noTexAdditiveNoZWrite = ctx.newShaderPipeline(VS, FS_NOTEX, m_vtxFormat, CGraphics::g_ViewportSamples, m_noTexAdditiveNoZWrite = ctx.newShaderPipeline(VS, FS_NOTEX, nullptr, nullptr,
m_vtxFormat, CGraphics::g_ViewportSamples,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One, boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
boo::Primitive::TriStrips, boo::ZTest::LEqual, false, boo::Primitive::TriStrips, boo::ZTest::LEqual, false,
true, false, boo::CullMode::None); true, false, boo::CullMode::None);
@ -134,4 +142,20 @@ TShader<CParticleSwooshShaders>::IDataBindingFactory* CParticleSwooshShaders::In
return new struct MetalParticleSwooshDataBindingFactory; return new struct MetalParticleSwooshDataBindingFactory;
} }
template <>
void CParticleSwooshShaders::Shutdown<boo::MetalDataFactory>()
{
m_texZWrite.reset();
m_texNoZWrite.reset();
m_texAdditiveZWrite.reset();
m_texAdditiveNoZWrite.reset();
m_noTexZWrite.reset();
m_noTexNoZWrite.reset();
m_noTexAdditiveZWrite.reset();
m_noTexAdditiveNoZWrite.reset();
m_vtxFormat.reset();
}
} }

View File

@ -8,8 +8,7 @@ void CPhazonSuitFilter::drawBlurPasses(float radius, const CTexture* indTex)
if (!m_dataBind || indTex != m_indTex) if (!m_dataBind || indTex != m_indTex)
{ {
m_indTex = indTex; m_indTex = indTex;
m_gfxTok = CGraphics::CommitResources( CGraphics::CommitResources([this](boo::IGraphicsDataFactory::Context& ctx)
[this](boo::IGraphicsDataFactory::Context& ctx)
{ {
m_uniBufBlurX = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(zeus::CVector4f), 1); m_uniBufBlurX = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(zeus::CVector4f), 1);
m_uniBufBlurY = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(zeus::CVector4f), 1); m_uniBufBlurY = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(zeus::CVector4f), 1);
@ -89,8 +88,6 @@ void CPhazonSuitFilter::draw(const zeus::CColor& color,
CGraphics::DrawArray(0, 4); CGraphics::DrawArray(0, 4);
} }
void CPhazonSuitFilter::Shutdown() {}
URDE_SPECIALIZE_SHADER(CPhazonSuitFilter) URDE_SPECIALIZE_SHADER(CPhazonSuitFilter)
} }

View File

@ -14,16 +14,15 @@ class CPhazonSuitFilter
friend struct CPhazonSuitFilterMetalDataBindingFactory; friend struct CPhazonSuitFilterMetalDataBindingFactory;
friend struct CPhazonSuitFilterD3DDataBindingFactory; friend struct CPhazonSuitFilterD3DDataBindingFactory;
boo::GraphicsDataToken m_gfxTok; boo::ObjToken<boo::IGraphicsBufferD> m_uniBufBlurX;
boo::IGraphicsBufferD* m_uniBufBlurX; boo::ObjToken<boo::IGraphicsBufferD> m_uniBufBlurY;
boo::IGraphicsBufferD* m_uniBufBlurY; boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf;
boo::IGraphicsBufferD* m_uniBuf; boo::ObjToken<boo::IGraphicsBufferS> m_blurVbo;
boo::IGraphicsBufferS* m_blurVbo; boo::ObjToken<boo::IGraphicsBufferS> m_vbo;
boo::IGraphicsBufferS* m_vbo;
const CTexture* m_indTex = nullptr; const CTexture* m_indTex = nullptr;
boo::IShaderDataBinding* m_dataBindBlurX = nullptr; boo::ObjToken<boo::IShaderDataBinding> m_dataBindBlurX;
boo::IShaderDataBinding* m_dataBindBlurY = nullptr; boo::ObjToken<boo::IShaderDataBinding> m_dataBindBlurY;
boo::IShaderDataBinding* m_dataBind = nullptr; boo::ObjToken<boo::IShaderDataBinding> m_dataBind;
public: public:
void drawBlurPasses(float radius, const CTexture* indTex); void drawBlurPasses(float radius, const CTexture* indTex);

View File

@ -149,80 +149,80 @@ BOO_GLSL_BINDING_HEAD
URDE_DECL_SPECIALIZE_SHADER(CPhazonSuitFilter) URDE_DECL_SPECIALIZE_SHADER(CPhazonSuitFilter)
static boo::IVertexFormat* s_VtxFmt = nullptr; static boo::ObjToken<boo::IVertexFormat> s_VtxFmt;
static boo::IVertexFormat* s_BlurVtxFmt = nullptr; static boo::ObjToken<boo::IVertexFormat> s_BlurVtxFmt;
static boo::IShaderPipeline* s_IndPipeline = nullptr; static boo::ObjToken<boo::IShaderPipeline> s_IndPipeline;
static boo::IShaderPipeline* s_Pipeline = nullptr; static boo::ObjToken<boo::IShaderPipeline> s_Pipeline;
static boo::IShaderPipeline* s_BlurPipeline = nullptr; static boo::ObjToken<boo::IShaderPipeline> s_BlurPipeline;
struct CPhazonSuitFilterGLDataBindingFactory : TShader<CPhazonSuitFilter>::IDataBindingFactory struct CPhazonSuitFilterGLDataBindingFactory : TShader<CPhazonSuitFilter>::IDataBindingFactory
{ {
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
CPhazonSuitFilter& filter) CPhazonSuitFilter& filter)
{ {
boo::GLDataFactory::Context& cctx = static_cast<boo::GLDataFactory::Context&>(ctx); boo::GLDataFactory::Context& cctx = static_cast<boo::GLDataFactory::Context&>(ctx);
const boo::VertexElementDescriptor BlurVtxVmt[] = const boo::VertexElementDescriptor BlurVtxVmt[] =
{ {
{filter.m_blurVbo, nullptr, boo::VertexSemantic::Position4}, {filter.m_blurVbo.get(), nullptr, boo::VertexSemantic::Position4},
{filter.m_blurVbo, nullptr, boo::VertexSemantic::UV4} {filter.m_blurVbo.get(), nullptr, boo::VertexSemantic::UV4}
}; };
boo::IVertexFormat* blurVtxFmt = ctx.newVertexFormat(2, BlurVtxVmt); boo::ObjToken<boo::IVertexFormat> blurVtxFmt = ctx.newVertexFormat(2, BlurVtxVmt);
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBufBlurX}; boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {filter.m_uniBufBlurX.get()};
boo::PipelineStage stages[] = {boo::PipelineStage::Vertex}; boo::PipelineStage stages[] = {boo::PipelineStage::Vertex};
boo::ITexture* texs[4]; boo::ObjToken<boo::ITexture> texs[4];
int texBindIdxs[4]; int texBindIdxs[4];
texs[0] = CGraphics::g_SpareTexture; texs[0] = CGraphics::g_SpareTexture.get();
texBindIdxs[0] = 1; texBindIdxs[0] = 1;
filter.m_dataBindBlurX = cctx.newShaderDataBinding(s_BlurPipeline, filter.m_dataBindBlurX = cctx.newShaderDataBinding(s_BlurPipeline,
blurVtxFmt, filter.m_blurVbo, nullptr, nullptr, blurVtxFmt, filter.m_blurVbo.get(), nullptr, nullptr,
1, bufs, stages, nullptr, nullptr, 1, texs, texBindIdxs, nullptr); 1, bufs, stages, nullptr, nullptr, 1, texs, texBindIdxs, nullptr);
bufs[0] = filter.m_uniBufBlurY; bufs[0] = filter.m_uniBufBlurY.get();
texs[0] = CGraphics::g_SpareTexture; texs[0] = CGraphics::g_SpareTexture.get();
texBindIdxs[0] = 2; texBindIdxs[0] = 2;
filter.m_dataBindBlurY = cctx.newShaderDataBinding(s_BlurPipeline, filter.m_dataBindBlurY = cctx.newShaderDataBinding(s_BlurPipeline,
blurVtxFmt, filter.m_blurVbo, nullptr, nullptr, blurVtxFmt, filter.m_blurVbo.get(), nullptr, nullptr,
1, bufs, stages, nullptr, nullptr, 1, texs, texBindIdxs, nullptr); 1, bufs, stages, nullptr, nullptr, 1, texs, texBindIdxs, nullptr);
const boo::VertexElementDescriptor VtxVmt[] = const boo::VertexElementDescriptor VtxVmt[] =
{ {
{filter.m_vbo, nullptr, boo::VertexSemantic::Position4}, {filter.m_vbo.get(), nullptr, boo::VertexSemantic::Position4},
{filter.m_vbo, nullptr, boo::VertexSemantic::UV4, 0}, {filter.m_vbo.get(), nullptr, boo::VertexSemantic::UV4, 0},
{filter.m_vbo, nullptr, boo::VertexSemantic::UV4, 1}, {filter.m_vbo.get(), nullptr, boo::VertexSemantic::UV4, 1},
{filter.m_vbo, nullptr, boo::VertexSemantic::UV4, 2} {filter.m_vbo.get(), nullptr, boo::VertexSemantic::UV4, 2}
}; };
boo::IVertexFormat* vtxFmt = ctx.newVertexFormat(4, VtxVmt); boo::ObjToken<boo::IVertexFormat> vtxFmt = ctx.newVertexFormat(4, VtxVmt);
bufs[0] = filter.m_uniBuf; bufs[0] = filter.m_uniBuf.get();
size_t texCount; size_t texCount;
if (filter.m_indTex) if (filter.m_indTex)
{ {
texs[0] = CGraphics::g_SpareTexture; texs[0] = CGraphics::g_SpareTexture.get();
texBindIdxs[0] = 0; texBindIdxs[0] = 0;
texs[1] = filter.m_indTex->GetBooTexture(); texs[1] = filter.m_indTex->GetBooTexture();
texBindIdxs[1] = 0; texBindIdxs[1] = 0;
texs[2] = CGraphics::g_SpareTexture; texs[2] = CGraphics::g_SpareTexture.get();
texBindIdxs[2] = 1; texBindIdxs[2] = 1;
texs[3] = CGraphics::g_SpareTexture; texs[3] = CGraphics::g_SpareTexture.get();
texBindIdxs[3] = 2; texBindIdxs[3] = 2;
texCount = 4; texCount = 4;
} }
else else
{ {
texs[0] = CGraphics::g_SpareTexture; texs[0] = CGraphics::g_SpareTexture.get();
texBindIdxs[0] = 0; texBindIdxs[0] = 0;
texs[1] = CGraphics::g_SpareTexture; texs[1] = CGraphics::g_SpareTexture.get();
texBindIdxs[1] = 1; texBindIdxs[1] = 1;
texs[2] = CGraphics::g_SpareTexture; texs[2] = CGraphics::g_SpareTexture.get();
texBindIdxs[2] = 2; texBindIdxs[2] = 2;
texCount = 3; texCount = 3;
} }
return cctx.newShaderDataBinding(filter.m_indTex ? s_IndPipeline : s_Pipeline, return cctx.newShaderDataBinding(filter.m_indTex ? s_IndPipeline : s_Pipeline,
vtxFmt, filter.m_vbo, nullptr, nullptr, vtxFmt, filter.m_vbo.get(), nullptr, nullptr,
1, bufs, stages, nullptr, nullptr, texCount, texs, texBindIdxs, nullptr); 1, bufs, stages, nullptr, nullptr, texCount, texs, texBindIdxs, nullptr);
} }
}; };
@ -230,56 +230,57 @@ struct CPhazonSuitFilterGLDataBindingFactory : TShader<CPhazonSuitFilter>::IData
#if BOO_HAS_VULKAN #if BOO_HAS_VULKAN
struct CPhazonSuitFilterVulkanDataBindingFactory : TShader<CPhazonSuitFilter>::IDataBindingFactory struct CPhazonSuitFilterVulkanDataBindingFactory : TShader<CPhazonSuitFilter>::IDataBindingFactory
{ {
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, boo::ObjToken<boo::IShaderDataBinding>
BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
CPhazonSuitFilter& filter) CPhazonSuitFilter& filter)
{ {
boo::VulkanDataFactory::Context& cctx = static_cast<boo::VulkanDataFactory::Context&>(ctx); boo::VulkanDataFactory::Context& cctx = static_cast<boo::VulkanDataFactory::Context&>(ctx);
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBufBlurX}; boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {filter.m_uniBufBlurX.get()};
boo::PipelineStage stages[] = {boo::PipelineStage::Vertex}; boo::PipelineStage stages[] = {boo::PipelineStage::Vertex};
boo::ITexture* texs[4]; boo::ObjToken<boo::ITexture> texs[4];
int texBindIdxs[4]; int texBindIdxs[4];
texs[0] = CGraphics::g_SpareTexture; texs[0] = CGraphics::g_SpareTexture.get();
texBindIdxs[0] = 1; texBindIdxs[0] = 1;
filter.m_dataBindBlurX = cctx.newShaderDataBinding(s_BlurPipeline, filter.m_dataBindBlurX = cctx.newShaderDataBinding(s_BlurPipeline,
s_BlurVtxFmt, filter.m_blurVbo, nullptr, nullptr, s_BlurVtxFmt, filter.m_blurVbo.get(), nullptr, nullptr,
1, bufs, stages, nullptr, nullptr, 1, texs, texBindIdxs, nullptr); 1, bufs, stages, nullptr, nullptr, 1, texs, texBindIdxs, nullptr);
bufs[0] = filter.m_uniBufBlurY; bufs[0] = filter.m_uniBufBlurY.get();
texs[0] = CGraphics::g_SpareTexture; texs[0] = CGraphics::g_SpareTexture.get();
texBindIdxs[0] = 2; texBindIdxs[0] = 2;
filter.m_dataBindBlurY = cctx.newShaderDataBinding(s_BlurPipeline, filter.m_dataBindBlurY = cctx.newShaderDataBinding(s_BlurPipeline,
s_BlurVtxFmt, filter.m_blurVbo, nullptr, nullptr, s_BlurVtxFmt, filter.m_blurVbo.get(), nullptr, nullptr,
1, bufs, stages, nullptr, nullptr, 1, texs, texBindIdxs, nullptr); 1, bufs, stages, nullptr, nullptr, 1, texs, texBindIdxs, nullptr);
bufs[0] = filter.m_uniBuf; bufs[0] = filter.m_uniBuf.get();
size_t texCount; size_t texCount;
if (filter.m_indTex) if (filter.m_indTex)
{ {
texs[0] = CGraphics::g_SpareTexture; texs[0] = CGraphics::g_SpareTexture.get();
texBindIdxs[0] = 0; texBindIdxs[0] = 0;
texs[1] = filter.m_indTex->GetBooTexture(); texs[1] = filter.m_indTex->GetBooTexture();
texBindIdxs[1] = 0; texBindIdxs[1] = 0;
texs[2] = CGraphics::g_SpareTexture; texs[2] = CGraphics::g_SpareTexture.get();
texBindIdxs[2] = 1; texBindIdxs[2] = 1;
texs[3] = CGraphics::g_SpareTexture; texs[3] = CGraphics::g_SpareTexture.get();
texBindIdxs[3] = 2; texBindIdxs[3] = 2;
texCount = 4; texCount = 4;
} }
else else
{ {
texs[0] = CGraphics::g_SpareTexture; texs[0] = CGraphics::g_SpareTexture.get();
texBindIdxs[0] = 0; texBindIdxs[0] = 0;
texs[1] = CGraphics::g_SpareTexture; texs[1] = CGraphics::g_SpareTexture.get();
texBindIdxs[1] = 1; texBindIdxs[1] = 1;
texs[2] = CGraphics::g_SpareTexture; texs[2] = CGraphics::g_SpareTexture.get();
texBindIdxs[2] = 2; texBindIdxs[2] = 2;
texCount = 3; texCount = 3;
} }
return cctx.newShaderDataBinding(filter.m_indTex ? s_IndPipeline : s_Pipeline, return cctx.newShaderDataBinding(filter.m_indTex ? s_IndPipeline : s_Pipeline,
s_VtxFmt, filter.m_vbo, nullptr, nullptr, s_VtxFmt, filter.m_vbo.get(), nullptr, nullptr,
1, bufs, stages, nullptr, nullptr, texCount, texs, texBindIdxs, nullptr); 1, bufs, stages, nullptr, nullptr, texCount, texs, texBindIdxs, nullptr);
} }
}; };
@ -306,6 +307,14 @@ CPhazonSuitFilter::Initialize(boo::GLDataFactory::Context& ctx)
return new CPhazonSuitFilterGLDataBindingFactory; return new CPhazonSuitFilterGLDataBindingFactory;
} }
template <>
void CPhazonSuitFilter::Shutdown<boo::GLDataFactory>()
{
s_IndPipeline.reset();
s_Pipeline.reset();
s_BlurPipeline.reset();
}
#if BOO_HAS_VULKAN #if BOO_HAS_VULKAN
TShader<CPhazonSuitFilter>::IDataBindingFactory* TShader<CPhazonSuitFilter>::IDataBindingFactory*
CPhazonSuitFilter::Initialize(boo::VulkanDataFactory::Context& ctx) CPhazonSuitFilter::Initialize(boo::VulkanDataFactory::Context& ctx)
@ -335,6 +344,17 @@ CPhazonSuitFilter::Initialize(boo::VulkanDataFactory::Context& ctx)
boo::ZTest::None, false, false, true, boo::CullMode::None); boo::ZTest::None, false, false, true, boo::CullMode::None);
return new CPhazonSuitFilterVulkanDataBindingFactory; return new CPhazonSuitFilterVulkanDataBindingFactory;
} }
template <>
void CPhazonSuitFilter::Shutdown<boo::VulkanDataFactory>()
{
s_VtxFmt.reset();
s_BlurVtxFmt.reset();
s_IndPipeline.reset();
s_Pipeline.reset();
s_BlurPipeline.reset();
}
#endif #endif
} }

View File

@ -147,64 +147,65 @@ static const char* BlurFS =
URDE_DECL_SPECIALIZE_SHADER(CPhazonSuitFilter) URDE_DECL_SPECIALIZE_SHADER(CPhazonSuitFilter)
static boo::IVertexFormat* s_VtxFmt = nullptr; static boo::ObjToken<boo::IVertexFormat> s_VtxFmt;
static boo::IVertexFormat* s_BlurVtxFmt = nullptr; static boo::ObjToken<boo::IVertexFormat> s_BlurVtxFmt;
static boo::IShaderPipeline* s_IndPipeline = nullptr; static boo::ObjToken<boo::IShaderPipeline> s_IndPipeline;
static boo::IShaderPipeline* s_Pipeline = nullptr; static boo::ObjToken<boo::IShaderPipeline> s_Pipeline;
static boo::IShaderPipeline* s_BlurPipeline = nullptr; static boo::ObjToken<boo::IShaderPipeline> s_BlurPipeline;
struct CPhazonSuitFilterD3DDataBindingFactory : TShader<CPhazonSuitFilter>::IDataBindingFactory struct CPhazonSuitFilterD3DDataBindingFactory : TShader<CPhazonSuitFilter>::IDataBindingFactory
{ {
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, boo::ObjToken<boo::IShaderDataBinding>
BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
CPhazonSuitFilter& filter) CPhazonSuitFilter& filter)
{ {
boo::ID3DDataFactory::Context& cctx = static_cast<boo::ID3DDataFactory::Context&>(ctx); boo::ID3DDataFactory::Context& cctx = static_cast<boo::ID3DDataFactory::Context&>(ctx);
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBufBlurX}; boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {filter.m_uniBufBlurX.get()};
boo::PipelineStage stages[] = {boo::PipelineStage::Vertex}; boo::PipelineStage stages[] = {boo::PipelineStage::Vertex};
boo::ITexture* texs[4]; boo::ObjToken<boo::ITexture> texs[4];
int texBindIdxs[4]; int texBindIdxs[4];
texs[0] = CGraphics::g_SpareTexture; texs[0] = CGraphics::g_SpareTexture.get();
texBindIdxs[0] = 1; texBindIdxs[0] = 1;
filter.m_dataBindBlurX = cctx.newShaderDataBinding(s_BlurPipeline, filter.m_dataBindBlurX = cctx.newShaderDataBinding(s_BlurPipeline,
s_BlurVtxFmt, filter.m_blurVbo, nullptr, nullptr, s_BlurVtxFmt, filter.m_blurVbo.get(), nullptr, nullptr,
1, bufs, stages, nullptr, nullptr, 1, texs, texBindIdxs, nullptr); 1, bufs, stages, nullptr, nullptr, 1, texs, texBindIdxs, nullptr);
bufs[0] = filter.m_uniBufBlurY; bufs[0] = filter.m_uniBufBlurY.get();
texs[0] = CGraphics::g_SpareTexture; texs[0] = CGraphics::g_SpareTexture.get();
texBindIdxs[0] = 2; texBindIdxs[0] = 2;
filter.m_dataBindBlurY = cctx.newShaderDataBinding(s_BlurPipeline, filter.m_dataBindBlurY = cctx.newShaderDataBinding(s_BlurPipeline,
s_BlurVtxFmt, filter.m_blurVbo, nullptr, nullptr, s_BlurVtxFmt, filter.m_blurVbo.get(), nullptr, nullptr,
1, bufs, stages, nullptr, nullptr, 1, texs, texBindIdxs, nullptr); 1, bufs, stages, nullptr, nullptr, 1, texs, texBindIdxs, nullptr);
bufs[0] = filter.m_uniBuf; bufs[0] = filter.m_uniBuf.get();
size_t texCount; size_t texCount;
if (filter.m_indTex) if (filter.m_indTex)
{ {
texs[0] = CGraphics::g_SpareTexture; texs[0] = CGraphics::g_SpareTexture.get();
texBindIdxs[0] = 0; texBindIdxs[0] = 0;
texs[1] = filter.m_indTex->GetBooTexture(); texs[1] = filter.m_indTex->GetBooTexture();
texBindIdxs[1] = 0; texBindIdxs[1] = 0;
texs[2] = CGraphics::g_SpareTexture; texs[2] = CGraphics::g_SpareTexture.get();
texBindIdxs[2] = 1; texBindIdxs[2] = 1;
texs[3] = CGraphics::g_SpareTexture; texs[3] = CGraphics::g_SpareTexture.get();
texBindIdxs[3] = 2; texBindIdxs[3] = 2;
texCount = 4; texCount = 4;
} }
else else
{ {
texs[0] = CGraphics::g_SpareTexture; texs[0] = CGraphics::g_SpareTexture.get();
texBindIdxs[0] = 0; texBindIdxs[0] = 0;
texs[1] = CGraphics::g_SpareTexture; texs[1] = CGraphics::g_SpareTexture.get();
texBindIdxs[1] = 1; texBindIdxs[1] = 1;
texs[2] = CGraphics::g_SpareTexture; texs[2] = CGraphics::g_SpareTexture.get();
texBindIdxs[2] = 2; texBindIdxs[2] = 2;
texCount = 3; texCount = 3;
} }
return cctx.newShaderDataBinding(filter.m_indTex ? s_IndPipeline : s_Pipeline, return cctx.newShaderDataBinding(filter.m_indTex ? s_IndPipeline : s_Pipeline,
s_VtxFmt, filter.m_vbo, nullptr, nullptr, s_VtxFmt, filter.m_vbo.get(), nullptr, nullptr,
1, bufs, stages, nullptr, nullptr, texCount, texs, texBindIdxs, nullptr); 1, bufs, stages, nullptr, nullptr, texCount, texs, texBindIdxs, nullptr);
} }
}; };
@ -238,4 +239,14 @@ CPhazonSuitFilter::Initialize(boo::ID3DDataFactory::Context& ctx)
return new CPhazonSuitFilterD3DDataBindingFactory; return new CPhazonSuitFilterD3DDataBindingFactory;
} }
template <>
void CPhazonSuitFilter::Shutdown<boo::ID3DDataFactory>()
{
s_VtxFmt.reset();
s_BlurVtxFmt.reset();
s_IndPipeline.reset();
s_Pipeline.reset();
s_BlurPipeline.reset();
}
} }

View File

@ -158,64 +158,64 @@ static const char* BlurFS =
URDE_DECL_SPECIALIZE_SHADER(CPhazonSuitFilter) URDE_DECL_SPECIALIZE_SHADER(CPhazonSuitFilter)
static boo::IVertexFormat* s_VtxFmt = nullptr; static boo::ObjToken<boo::IVertexFormat> s_VtxFmt;
static boo::IVertexFormat* s_BlurVtxFmt = nullptr; static boo::ObjToken<boo::IVertexFormat> s_BlurVtxFmt;
static boo::IShaderPipeline* s_IndPipeline = nullptr; static boo::ObjToken<boo::IShaderPipeline> s_IndPipeline;
static boo::IShaderPipeline* s_Pipeline = nullptr; static boo::ObjToken<boo::IShaderPipeline> s_Pipeline;
static boo::IShaderPipeline* s_BlurPipeline = nullptr; static boo::ObjToken<boo::IShaderPipeline> s_BlurPipeline;
struct CPhazonSuitFilterMetalDataBindingFactory : TShader<CPhazonSuitFilter>::IDataBindingFactory struct CPhazonSuitFilterMetalDataBindingFactory : TShader<CPhazonSuitFilter>::IDataBindingFactory
{ {
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
CPhazonSuitFilter& filter) CPhazonSuitFilter& filter)
{ {
boo::MetalDataFactory::Context& cctx = static_cast<boo::MetalDataFactory::Context&>(ctx); boo::MetalDataFactory::Context& cctx = static_cast<boo::MetalDataFactory::Context&>(ctx);
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBufBlurX}; boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {filter.m_uniBufBlurX.get()};
boo::PipelineStage stages[] = {boo::PipelineStage::Vertex}; boo::PipelineStage stages[] = {boo::PipelineStage::Vertex};
boo::ITexture* texs[4]; boo::ObjToken<boo::ITexture> texs[4];
int texBindIdxs[4]; int texBindIdxs[4];
texs[0] = CGraphics::g_SpareTexture; texs[0] = CGraphics::g_SpareTexture.get();
texBindIdxs[0] = 1; texBindIdxs[0] = 1;
filter.m_dataBindBlurX = cctx.newShaderDataBinding(s_BlurPipeline, filter.m_dataBindBlurX = cctx.newShaderDataBinding(s_BlurPipeline,
s_BlurVtxFmt, filter.m_blurVbo, nullptr, nullptr, s_BlurVtxFmt, filter.m_blurVbo.get(), nullptr, nullptr,
1, bufs, stages, nullptr, nullptr, 1, texs, texBindIdxs, nullptr); 1, bufs, stages, nullptr, nullptr, 1, texs, texBindIdxs, nullptr);
bufs[0] = filter.m_uniBufBlurY; bufs[0] = filter.m_uniBufBlurY.get();
texs[0] = CGraphics::g_SpareTexture; texs[0] = CGraphics::g_SpareTexture.get();
texBindIdxs[0] = 2; texBindIdxs[0] = 2;
filter.m_dataBindBlurY = cctx.newShaderDataBinding(s_BlurPipeline, filter.m_dataBindBlurY = cctx.newShaderDataBinding(s_BlurPipeline,
s_BlurVtxFmt, filter.m_blurVbo, nullptr, nullptr, s_BlurVtxFmt, filter.m_blurVbo.get(), nullptr, nullptr,
1, bufs, stages, nullptr, nullptr, 1, texs, texBindIdxs, nullptr); 1, bufs, stages, nullptr, nullptr, 1, texs, texBindIdxs, nullptr);
bufs[0] = filter.m_uniBuf; bufs[0] = filter.m_uniBuf.get();
size_t texCount; size_t texCount;
if (filter.m_indTex) if (filter.m_indTex)
{ {
texs[0] = CGraphics::g_SpareTexture; texs[0] = CGraphics::g_SpareTexture.get();
texBindIdxs[0] = 0; texBindIdxs[0] = 0;
texs[1] = filter.m_indTex->GetBooTexture(); texs[1] = filter.m_indTex->GetBooTexture();
texBindIdxs[1] = 0; texBindIdxs[1] = 0;
texs[2] = CGraphics::g_SpareTexture; texs[2] = CGraphics::g_SpareTexture.get();
texBindIdxs[2] = 1; texBindIdxs[2] = 1;
texs[3] = CGraphics::g_SpareTexture; texs[3] = CGraphics::g_SpareTexture.get();
texBindIdxs[3] = 2; texBindIdxs[3] = 2;
texCount = 4; texCount = 4;
} }
else else
{ {
texs[0] = CGraphics::g_SpareTexture; texs[0] = CGraphics::g_SpareTexture.get();
texBindIdxs[0] = 0; texBindIdxs[0] = 0;
texs[1] = CGraphics::g_SpareTexture; texs[1] = CGraphics::g_SpareTexture.get();
texBindIdxs[1] = 1; texBindIdxs[1] = 1;
texs[2] = CGraphics::g_SpareTexture; texs[2] = CGraphics::g_SpareTexture.get();
texBindIdxs[2] = 2; texBindIdxs[2] = 2;
texCount = 3; texCount = 3;
} }
return cctx.newShaderDataBinding(filter.m_indTex ? s_IndPipeline : s_Pipeline, return cctx.newShaderDataBinding(filter.m_indTex ? s_IndPipeline : s_Pipeline,
s_VtxFmt, filter.m_vbo, nullptr, nullptr, s_VtxFmt, filter.m_vbo.get(), nullptr, nullptr,
1, bufs, stages, nullptr, nullptr, texCount, texs, texBindIdxs, nullptr); 1, bufs, stages, nullptr, nullptr, texCount, texs, texBindIdxs, nullptr);
} }
}; };
@ -237,19 +237,29 @@ CPhazonSuitFilter::Initialize(boo::MetalDataFactory::Context& ctx)
{nullptr, nullptr, boo::VertexSemantic::UV4} {nullptr, nullptr, boo::VertexSemantic::UV4}
}; };
s_BlurVtxFmt = ctx.newVertexFormat(2, BlurVtxVmt); s_BlurVtxFmt = ctx.newVertexFormat(2, BlurVtxVmt);
s_IndPipeline = ctx.newShaderPipeline(VS, IndFS, s_VtxFmt, s_IndPipeline = ctx.newShaderPipeline(VS, IndFS, nullptr, nullptr, s_VtxFmt,
CGraphics::g_ViewportSamples, boo::BlendFactor::One, CGraphics::g_ViewportSamples, boo::BlendFactor::One,
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips,
boo::ZTest::None, false, true, false, boo::CullMode::None); boo::ZTest::None, false, true, false, boo::CullMode::None);
s_Pipeline = ctx.newShaderPipeline(VS, FS, s_VtxFmt, s_Pipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr, s_VtxFmt,
CGraphics::g_ViewportSamples, boo::BlendFactor::One, CGraphics::g_ViewportSamples, boo::BlendFactor::One,
boo::BlendFactor::One, boo::Primitive::TriStrips, boo::BlendFactor::One, boo::Primitive::TriStrips,
boo::ZTest::None, false, true, false, boo::CullMode::None); boo::ZTest::None, false, true, false, boo::CullMode::None);
s_BlurPipeline = ctx.newShaderPipeline(BlurVS, BlurFS, s_BlurVtxFmt, s_BlurPipeline = ctx.newShaderPipeline(BlurVS, BlurFS, nullptr, nullptr, s_BlurVtxFmt,
CGraphics::g_ViewportSamples, boo::BlendFactor::One, CGraphics::g_ViewportSamples, boo::BlendFactor::One,
boo::BlendFactor::Zero, boo::Primitive::TriStrips, boo::BlendFactor::Zero, boo::Primitive::TriStrips,
boo::ZTest::None, false, false, true, boo::CullMode::None); boo::ZTest::None, false, false, true, boo::CullMode::None);
return new CPhazonSuitFilterMetalDataBindingFactory; return new CPhazonSuitFilterMetalDataBindingFactory;
} }
template <>
void CPhazonSuitFilter::Shutdown<boo::MetalDataFactory>()
{
s_VtxFmt.reset();
s_BlurVtxFmt.reset();
s_IndPipeline.reset();
s_Pipeline.reset();
s_BlurPipeline.reset();
}
} }

View File

@ -12,7 +12,7 @@ void CRadarPaintShader::draw(const std::vector<Instance>& instances, const CText
{ {
m_maxInsts = instances.size(); m_maxInsts = instances.size();
m_tex = tex; m_tex = tex;
m_token = CGraphics::CommitResources([this](boo::IGraphicsDataFactory::Context& ctx) CGraphics::CommitResources([this](boo::IGraphicsDataFactory::Context& ctx)
{ {
m_vbo = ctx.newDynamicBuffer(boo::BufferUse::Vertex, sizeof(Instance), m_maxInsts); m_vbo = ctx.newDynamicBuffer(boo::BufferUse::Vertex, sizeof(Instance), m_maxInsts);
m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(zeus::CMatrix4f), 1); m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(zeus::CMatrix4f), 1);
@ -35,6 +35,4 @@ void CRadarPaintShader::draw(const std::vector<Instance>& instances, const CText
URDE_SPECIALIZE_SHADER(CRadarPaintShader) URDE_SPECIALIZE_SHADER(CRadarPaintShader)
void CRadarPaintShader::Shutdown() {}
} }

View File

@ -26,10 +26,9 @@ public:
}; };
private: private:
boo::GraphicsDataToken m_token; boo::ObjToken<boo::IGraphicsBufferD> m_vbo;
boo::IGraphicsBufferD* m_vbo; boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf;
boo::IGraphicsBufferD* m_uniBuf; boo::ObjToken<boo::IShaderDataBinding> m_dataBind;
boo::IShaderDataBinding* m_dataBind;
const CTexture* m_tex = nullptr; const CTexture* m_tex = nullptr;
size_t m_maxInsts = 0; size_t m_maxInsts = 0;

View File

@ -50,34 +50,34 @@ BOO_GLSL_BINDING_HEAD
URDE_DECL_SPECIALIZE_SHADER(CRadarPaintShader) URDE_DECL_SPECIALIZE_SHADER(CRadarPaintShader)
static boo::IVertexFormat* s_VtxFmt = nullptr; static boo::ObjToken<boo::IVertexFormat> s_VtxFmt;
static boo::IShaderPipeline* s_Pipeline = nullptr; static boo::ObjToken<boo::IShaderPipeline> s_Pipeline;
struct CRadarPaintShaderGLDataBindingFactory : TShader<CRadarPaintShader>::IDataBindingFactory struct CRadarPaintShaderGLDataBindingFactory : TShader<CRadarPaintShader>::IDataBindingFactory
{ {
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
CRadarPaintShader& filter) CRadarPaintShader& filter)
{ {
boo::GLDataFactory::Context& cctx = static_cast<boo::GLDataFactory::Context&>(ctx); boo::GLDataFactory::Context& cctx = static_cast<boo::GLDataFactory::Context&>(ctx);
const boo::VertexElementDescriptor VtxVmt[] = const boo::VertexElementDescriptor VtxVmt[] =
{ {
{filter.m_vbo, nullptr, boo::VertexSemantic::Position4, 0}, {filter.m_vbo.get(), nullptr, boo::VertexSemantic::Position4, 0},
{filter.m_vbo, nullptr, boo::VertexSemantic::Position4, 1}, {filter.m_vbo.get(), nullptr, boo::VertexSemantic::Position4, 1},
{filter.m_vbo, nullptr, boo::VertexSemantic::Position4, 2}, {filter.m_vbo.get(), nullptr, boo::VertexSemantic::Position4, 2},
{filter.m_vbo, nullptr, boo::VertexSemantic::Position4, 3}, {filter.m_vbo.get(), nullptr, boo::VertexSemantic::Position4, 3},
{filter.m_vbo, nullptr, boo::VertexSemantic::UV4, 0}, {filter.m_vbo.get(), nullptr, boo::VertexSemantic::UV4, 0},
{filter.m_vbo, nullptr, boo::VertexSemantic::UV4, 1}, {filter.m_vbo.get(), nullptr, boo::VertexSemantic::UV4, 1},
{filter.m_vbo, nullptr, boo::VertexSemantic::UV4, 2}, {filter.m_vbo.get(), nullptr, boo::VertexSemantic::UV4, 2},
{filter.m_vbo, nullptr, boo::VertexSemantic::UV4, 3}, {filter.m_vbo.get(), nullptr, boo::VertexSemantic::UV4, 3},
{filter.m_vbo, nullptr, boo::VertexSemantic::Color} {filter.m_vbo.get(), nullptr, boo::VertexSemantic::Color}
}; };
boo::IVertexFormat* vtxFmt = ctx.newVertexFormat(9, VtxVmt); boo::ObjToken<boo::IVertexFormat> vtxFmt = ctx.newVertexFormat(9, VtxVmt);
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf}; boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {filter.m_uniBuf.get()};
boo::PipelineStage stages[] = {boo::PipelineStage::Vertex}; boo::PipelineStage stages[] = {boo::PipelineStage::Vertex};
boo::ITexture* texs[] = {filter.m_tex->GetBooTexture()}; boo::ObjToken<boo::ITexture> texs[] = {filter.m_tex->GetBooTexture()};
return cctx.newShaderDataBinding(s_Pipeline, return cctx.newShaderDataBinding(s_Pipeline,
vtxFmt, nullptr, filter.m_vbo, nullptr, vtxFmt, nullptr, filter.m_vbo.get(), nullptr,
1, bufs, stages, nullptr, nullptr, 1, texs, nullptr, nullptr); 1, bufs, stages, nullptr, nullptr, 1, texs, nullptr, nullptr);
} }
}; };
@ -85,15 +85,16 @@ struct CRadarPaintShaderGLDataBindingFactory : TShader<CRadarPaintShader>::IData
#if BOO_HAS_VULKAN #if BOO_HAS_VULKAN
struct CRadarPaintShaderVulkanDataBindingFactory : TShader<CRadarPaintShader>::IDataBindingFactory struct CRadarPaintShaderVulkanDataBindingFactory : TShader<CRadarPaintShader>::IDataBindingFactory
{ {
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, boo::ObjToken<boo::IShaderDataBinding>
BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
CRadarPaintShader& filter) CRadarPaintShader& filter)
{ {
boo::VulkanDataFactory::Context& cctx = static_cast<boo::VulkanDataFactory::Context&>(ctx); boo::VulkanDataFactory::Context& cctx = static_cast<boo::VulkanDataFactory::Context&>(ctx);
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf}; boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {filter.m_uniBuf.get()};
boo::ITexture* texs[] = {filter.m_tex->GetBooTexture()}; boo::ObjToken<boo::ITexture> texs[] = {filter.m_tex->GetBooTexture()};
return cctx.newShaderDataBinding(s_Pipeline, s_VtxFmt, return cctx.newShaderDataBinding(s_Pipeline, s_VtxFmt,
nullptr, filter.m_vbo, nullptr, 1, bufs, nullptr, filter.m_vbo.get(), nullptr, 1, bufs,
nullptr, nullptr, nullptr, 1, texs, nullptr, nullptr); nullptr, nullptr, nullptr, 1, texs, nullptr, nullptr);
} }
}; };
@ -110,6 +111,12 @@ CRadarPaintShader::Initialize(boo::GLDataFactory::Context& ctx)
return new CRadarPaintShaderGLDataBindingFactory; return new CRadarPaintShaderGLDataBindingFactory;
} }
template <>
void CRadarPaintShader::Shutdown<boo::GLDataFactory>()
{
s_Pipeline.reset();
}
#if BOO_HAS_VULKAN #if BOO_HAS_VULKAN
TShader<CRadarPaintShader>::IDataBindingFactory* TShader<CRadarPaintShader>::IDataBindingFactory*
CRadarPaintShader::Initialize(boo::VulkanDataFactory::Context& ctx) CRadarPaintShader::Initialize(boo::VulkanDataFactory::Context& ctx)
@ -132,6 +139,13 @@ CRadarPaintShader::Initialize(boo::VulkanDataFactory::Context& ctx)
boo::ZTest::None, false, true, false, boo::CullMode::None); boo::ZTest::None, false, true, false, boo::CullMode::None);
return new CRadarPaintShaderVulkanDataBindingFactory; return new CRadarPaintShaderVulkanDataBindingFactory;
} }
template <>
void CRadarPaintShader::Shutdown<boo::VulkanDataFactory>()
{
s_VtxFmt.reset();
s_Pipeline.reset();
}
#endif #endif
} }

View File

@ -51,20 +51,21 @@ static const char* FS =
URDE_DECL_SPECIALIZE_SHADER(CRadarPaintShader) URDE_DECL_SPECIALIZE_SHADER(CRadarPaintShader)
static boo::IVertexFormat* s_VtxFmt = nullptr; static boo::ObjToken<boo::IVertexFormat> s_VtxFmt;
static boo::IShaderPipeline* s_Pipeline = nullptr; static boo::ObjToken<boo::IShaderPipeline> s_Pipeline;
struct CRadarPaintShaderD3DDataBindingFactory : TShader<CRadarPaintShader>::IDataBindingFactory struct CRadarPaintShaderD3DDataBindingFactory : TShader<CRadarPaintShader>::IDataBindingFactory
{ {
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, boo::ObjToken<boo::IShaderDataBinding>
BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
CRadarPaintShader& filter) CRadarPaintShader& filter)
{ {
boo::ID3DDataFactory::Context& cctx = static_cast<boo::ID3DDataFactory::Context&>(ctx); boo::ID3DDataFactory::Context& cctx = static_cast<boo::ID3DDataFactory::Context&>(ctx);
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf}; boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {filter.m_uniBuf.get()};
boo::ITexture* texs[] = {filter.m_tex->GetBooTexture()}; boo::ObjToken<boo::ITexture> texs[] = {filter.m_tex->GetBooTexture()};
return cctx.newShaderDataBinding(s_Pipeline, s_VtxFmt, return cctx.newShaderDataBinding(s_Pipeline, s_VtxFmt,
nullptr, filter.m_vbo, nullptr, 1, bufs, nullptr, filter.m_vbo.get(), nullptr, 1, bufs,
nullptr, nullptr, nullptr, 1, texs, nullptr, nullptr); nullptr, nullptr, nullptr, 1, texs, nullptr, nullptr);
} }
}; };
@ -92,4 +93,10 @@ CRadarPaintShader::Initialize(boo::ID3DDataFactory::Context& ctx)
return new CRadarPaintShaderD3DDataBindingFactory; return new CRadarPaintShaderD3DDataBindingFactory;
} }
template <>
void CRadarPaintShader::Shutdown<boo::ID3DDataFactory>()
{
s_VtxFmt.reset();
s_Pipeline.reset();
}
} }

View File

@ -58,20 +58,20 @@ static const char* FS =
URDE_DECL_SPECIALIZE_SHADER(CRadarPaintShader) URDE_DECL_SPECIALIZE_SHADER(CRadarPaintShader)
static boo::IVertexFormat* s_VtxFmt = nullptr; static boo::ObjToken<boo::IVertexFormat> s_VtxFmt;
static boo::IShaderPipeline* s_Pipeline = nullptr; static boo::ObjToken<boo::IShaderPipeline> s_Pipeline;
struct CRadarPaintShaderMetalDataBindingFactory : TShader<CRadarPaintShader>::IDataBindingFactory struct CRadarPaintShaderMetalDataBindingFactory : TShader<CRadarPaintShader>::IDataBindingFactory
{ {
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
CRadarPaintShader& filter) CRadarPaintShader& filter)
{ {
boo::MetalDataFactory::Context& cctx = static_cast<boo::MetalDataFactory::Context&>(ctx); boo::MetalDataFactory::Context& cctx = static_cast<boo::MetalDataFactory::Context&>(ctx);
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf}; boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {filter.m_uniBuf.get()};
boo::ITexture* texs[] = {filter.m_tex->GetBooTexture()}; boo::ObjToken<boo::ITexture> texs[] = {filter.m_tex->GetBooTexture()};
return cctx.newShaderDataBinding(s_Pipeline, s_VtxFmt, return cctx.newShaderDataBinding(s_Pipeline, s_VtxFmt,
nullptr, filter.m_vbo, nullptr, 1, bufs, nullptr, filter.m_vbo.get(), nullptr, 1, bufs,
nullptr, nullptr, nullptr, 1, texs, nullptr, nullptr); nullptr, nullptr, nullptr, 1, texs, nullptr, nullptr);
} }
}; };
@ -92,11 +92,19 @@ CRadarPaintShader::Initialize(boo::MetalDataFactory::Context& ctx)
{nullptr, nullptr, boo::VertexSemantic::Color} {nullptr, nullptr, boo::VertexSemantic::Color}
}; };
s_VtxFmt = ctx.newVertexFormat(9, VtxVmt); s_VtxFmt = ctx.newVertexFormat(9, VtxVmt);
s_Pipeline = ctx.newShaderPipeline(VS, FS, s_VtxFmt, CGraphics::g_ViewportSamples, s_Pipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr,
s_VtxFmt, CGraphics::g_ViewportSamples,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::One, boo::Primitive::TriStrips, boo::BlendFactor::One, boo::Primitive::TriStrips,
boo::ZTest::None, false, true, false, boo::CullMode::None); boo::ZTest::None, false, true, false, boo::CullMode::None);
return new CRadarPaintShaderMetalDataBindingFactory; return new CRadarPaintShaderMetalDataBindingFactory;
} }
template <>
void CRadarPaintShader::Shutdown<boo::MetalDataFactory>()
{
s_VtxFmt.reset();
s_Pipeline.reset();
}
} }

View File

@ -9,7 +9,7 @@ namespace urde
CRandomStaticFilter::CRandomStaticFilter(EFilterType type, bool cookieCutter) CRandomStaticFilter::CRandomStaticFilter(EFilterType type, bool cookieCutter)
: m_cookieCutter(cookieCutter) : m_cookieCutter(cookieCutter)
{ {
m_token = CGraphics::g_BooFactory->commitTransaction([&](boo::IGraphicsDataFactory::Context& ctx) -> bool CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
{ {
struct Vert struct Vert
{ {
@ -41,8 +41,6 @@ void CRandomStaticFilter::draw(const zeus::CColor& color, float t)
CGraphics::DrawArray(0, 4); CGraphics::DrawArray(0, 4);
} }
void CRandomStaticFilter::Shutdown() {}
URDE_SPECIALIZE_MULTI_BLEND_SHADER(CRandomStaticFilter) URDE_SPECIALIZE_MULTI_BLEND_SHADER(CRandomStaticFilter)
} }

View File

@ -23,10 +23,9 @@ class CRandomStaticFilter
float randOff; float randOff;
float discardThres; float discardThres;
}; };
boo::GraphicsDataToken m_token; boo::ObjToken<boo::IGraphicsBufferS> m_vbo;
boo::IGraphicsBufferS* m_vbo; boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf;
boo::IGraphicsBufferD* m_uniBuf; boo::ObjToken<boo::IShaderDataBinding> m_dataBind;
boo::IShaderDataBinding* m_dataBind = nullptr;
Uniform m_uniform; Uniform m_uniform;
bool m_cookieCutter; bool m_cookieCutter;

View File

@ -106,13 +106,13 @@ BOO_GLSL_BINDING_HEAD
URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(CRandomStaticFilter) URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(CRandomStaticFilter)
static boo::IVertexFormat* s_VtxFmt = nullptr; static boo::ObjToken<boo::IVertexFormat> s_VtxFmt;
static boo::IShaderPipeline* s_AlphaPipeline = nullptr; static boo::ObjToken<boo::IShaderPipeline> s_AlphaPipeline;
static boo::IShaderPipeline* s_AddPipeline = nullptr; static boo::ObjToken<boo::IShaderPipeline> s_AddPipeline;
static boo::IShaderPipeline* s_MultPipeline = nullptr; static boo::ObjToken<boo::IShaderPipeline> s_MultPipeline;
static boo::IShaderPipeline* s_CookieCutterPipeline = nullptr; static boo::ObjToken<boo::IShaderPipeline> s_CookieCutterPipeline;
static boo::IShaderPipeline* SelectPipeline(EFilterType type) static boo::ObjToken<boo::IShaderPipeline> SelectPipeline(EFilterType type)
{ {
switch (type) switch (type)
{ {
@ -123,28 +123,27 @@ static boo::IShaderPipeline* SelectPipeline(EFilterType type)
case EFilterType::Multiply: case EFilterType::Multiply:
return s_MultPipeline; return s_MultPipeline;
default: default:
return nullptr; return {};
} }
} }
struct CRandomStaticFilterGLDataBindingFactory : TMultiBlendShader<CRandomStaticFilter>::IDataBindingFactory struct CRandomStaticFilterGLDataBindingFactory : TMultiBlendShader<CRandomStaticFilter>::IDataBindingFactory
{ {
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
EFilterType type, EFilterType type, CRandomStaticFilter& filter)
CRandomStaticFilter& filter)
{ {
boo::GLDataFactory::Context& cctx = static_cast<boo::GLDataFactory::Context&>(ctx); boo::GLDataFactory::Context& cctx = static_cast<boo::GLDataFactory::Context&>(ctx);
const boo::VertexElementDescriptor VtxVmt[] = const boo::VertexElementDescriptor VtxVmt[] =
{ {
{filter.m_vbo, nullptr, boo::VertexSemantic::Position4}, {filter.m_vbo.get(), nullptr, boo::VertexSemantic::Position4},
{filter.m_vbo, nullptr, boo::VertexSemantic::UV4} {filter.m_vbo.get(), nullptr, boo::VertexSemantic::UV4}
}; };
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf}; boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {filter.m_uniBuf.get()};
boo::PipelineStage stages[] = {boo::PipelineStage::Vertex}; boo::PipelineStage stages[] = {boo::PipelineStage::Vertex};
boo::ITexture* texs[] = {g_Renderer->GetRandomStaticEntropyTex()}; boo::ObjToken<boo::ITexture> texs[] = {g_Renderer->GetRandomStaticEntropyTex()};
return cctx.newShaderDataBinding(filter.m_cookieCutter ? s_CookieCutterPipeline : SelectPipeline(type), return cctx.newShaderDataBinding(filter.m_cookieCutter ? s_CookieCutterPipeline : SelectPipeline(type),
ctx.newVertexFormat(2, VtxVmt), filter.m_vbo, nullptr, nullptr, ctx.newVertexFormat(2, VtxVmt), filter.m_vbo.get(), nullptr, nullptr,
1, bufs, stages, nullptr, nullptr, 1, texs, nullptr, nullptr); 1, bufs, stages, nullptr, nullptr, 1, texs, nullptr, nullptr);
} }
}; };
@ -152,16 +151,16 @@ struct CRandomStaticFilterGLDataBindingFactory : TMultiBlendShader<CRandomStatic
#if BOO_HAS_VULKAN #if BOO_HAS_VULKAN
struct CRandomStaticFilterVulkanDataBindingFactory : TMultiBlendShader<CRandomStaticFilter>::IDataBindingFactory struct CRandomStaticFilterVulkanDataBindingFactory : TMultiBlendShader<CRandomStaticFilter>::IDataBindingFactory
{ {
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, boo::ObjToken<boo::IShaderDataBinding>
EFilterType type, BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
CRandomStaticFilter& filter) EFilterType type, CRandomStaticFilter& filter)
{ {
boo::VulkanDataFactory::Context& cctx = static_cast<boo::VulkanDataFactory::Context&>(ctx); boo::VulkanDataFactory::Context& cctx = static_cast<boo::VulkanDataFactory::Context&>(ctx);
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf}; boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {filter.m_uniBuf.get()};
boo::ITexture* texs[] = {g_Renderer->GetRandomStaticEntropyTex()}; boo::ObjToken<boo::ITexture> texs[] = {g_Renderer->GetRandomStaticEntropyTex().get()};
return cctx.newShaderDataBinding(filter.m_cookieCutter ? s_CookieCutterPipeline : SelectPipeline(type), return cctx.newShaderDataBinding(filter.m_cookieCutter ? s_CookieCutterPipeline : SelectPipeline(type),
s_VtxFmt, filter.m_vbo, nullptr, nullptr, 1, bufs, s_VtxFmt, filter.m_vbo.get(), nullptr, nullptr, 1, bufs,
nullptr, nullptr, nullptr, 1, texs, nullptr, nullptr); nullptr, nullptr, nullptr, 1, texs, nullptr, nullptr);
} }
}; };
@ -187,6 +186,15 @@ CRandomStaticFilter::Initialize(boo::GLDataFactory::Context& ctx)
return new CRandomStaticFilterGLDataBindingFactory; return new CRandomStaticFilterGLDataBindingFactory;
} }
template <>
void CRandomStaticFilter::Shutdown<boo::GLDataFactory>()
{
s_AlphaPipeline.reset();
s_AddPipeline.reset();
s_MultPipeline.reset();
s_CookieCutterPipeline.reset();
}
#if BOO_HAS_VULKAN #if BOO_HAS_VULKAN
TMultiBlendShader<CRandomStaticFilter>::IDataBindingFactory* TMultiBlendShader<CRandomStaticFilter>::IDataBindingFactory*
CRandomStaticFilter::Initialize(boo::VulkanDataFactory::Context& ctx) CRandomStaticFilter::Initialize(boo::VulkanDataFactory::Context& ctx)
@ -211,6 +219,16 @@ CRandomStaticFilter::Initialize(boo::VulkanDataFactory::Context& ctx)
boo::ZTest::LEqual, true, false, false, boo::CullMode::None); boo::ZTest::LEqual, true, false, false, boo::CullMode::None);
return new CRandomStaticFilterVulkanDataBindingFactory; return new CRandomStaticFilterVulkanDataBindingFactory;
} }
template <>
void CRandomStaticFilter::Shutdown<boo::VulkanDataFactory>()
{
s_VtxFmt.reset();
s_AlphaPipeline.reset();
s_AddPipeline.reset();
s_MultPipeline.reset();
s_CookieCutterPipeline.reset();
}
#endif #endif
} }

View File

@ -105,13 +105,13 @@ static const char* FSCookieCutter =
URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(CRandomStaticFilter) URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(CRandomStaticFilter)
static boo::IVertexFormat* s_VtxFmt = nullptr; static boo::ObjToken<boo::IVertexFormat> s_VtxFmt;
static boo::IShaderPipeline* s_AlphaPipeline = nullptr; static boo::ObjToken<boo::IShaderPipeline> s_AlphaPipeline;
static boo::IShaderPipeline* s_AddPipeline = nullptr; static boo::ObjToken<boo::IShaderPipeline> s_AddPipeline;
static boo::IShaderPipeline* s_MultPipeline = nullptr; static boo::ObjToken<boo::IShaderPipeline> s_MultPipeline;
static boo::IShaderPipeline* s_CookieCutterPipeline = nullptr; static boo::ObjToken<boo::IShaderPipeline> s_CookieCutterPipeline;
static boo::IShaderPipeline* SelectPipeline(EFilterType type) static boo::ObjToken<boo::IShaderPipeline> SelectPipeline(EFilterType type)
{ {
switch (type) switch (type)
{ {
@ -122,22 +122,22 @@ static boo::IShaderPipeline* SelectPipeline(EFilterType type)
case EFilterType::Multiply: case EFilterType::Multiply:
return s_MultPipeline; return s_MultPipeline;
default: default:
return nullptr; return {};
} }
} }
struct CRandomStaticFilterD3DDataBindingFactory : TMultiBlendShader<CRandomStaticFilter>::IDataBindingFactory struct CRandomStaticFilterD3DDataBindingFactory : TMultiBlendShader<CRandomStaticFilter>::IDataBindingFactory
{ {
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, boo::ObjToken<boo::IShaderDataBinding>
EFilterType type, BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
CRandomStaticFilter& filter) EFilterType type, CRandomStaticFilter& filter)
{ {
boo::ID3DDataFactory::Context& cctx = static_cast<boo::ID3DDataFactory::Context&>(ctx); boo::ID3DDataFactory::Context& cctx = static_cast<boo::ID3DDataFactory::Context&>(ctx);
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf}; boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {filter.m_uniBuf.get()};
boo::ITexture* texs[] = {g_Renderer->GetRandomStaticEntropyTex()}; boo::ObjToken<boo::ITexture> texs[] = {g_Renderer->GetRandomStaticEntropyTex().get()};
return cctx.newShaderDataBinding(filter.m_cookieCutter ? s_CookieCutterPipeline : SelectPipeline(type), return cctx.newShaderDataBinding(filter.m_cookieCutter ? s_CookieCutterPipeline : SelectPipeline(type),
s_VtxFmt, filter.m_vbo, nullptr, nullptr, 1, bufs, s_VtxFmt, filter.m_vbo.get(), nullptr, nullptr, 1, bufs,
nullptr, nullptr, nullptr, 1, texs, nullptr, nullptr); nullptr, nullptr, nullptr, 1, texs, nullptr, nullptr);
} }
}; };
@ -170,4 +170,13 @@ CRandomStaticFilter::Initialize(boo::ID3DDataFactory::Context& ctx)
return new CRandomStaticFilterD3DDataBindingFactory; return new CRandomStaticFilterD3DDataBindingFactory;
} }
template <>
void CRandomStaticFilter::Shutdown<boo::ID3DDataFactory>()
{
s_VtxFmt.reset();
s_AlphaPipeline.reset();
s_AddPipeline.reset();
s_MultPipeline.reset();
s_CookieCutterPipeline.reset();
}
} }

View File

@ -112,13 +112,13 @@ static const char* FSCookieCutter =
URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(CRandomStaticFilter) URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(CRandomStaticFilter)
static boo::IVertexFormat* s_VtxFmt = nullptr; static boo::ObjToken<boo::IVertexFormat> s_VtxFmt;
static boo::IShaderPipeline* s_AlphaPipeline = nullptr; static boo::ObjToken<boo::IShaderPipeline> s_AlphaPipeline;
static boo::IShaderPipeline* s_AddPipeline = nullptr; static boo::ObjToken<boo::IShaderPipeline> s_AddPipeline;
static boo::IShaderPipeline* s_MultPipeline = nullptr; static boo::ObjToken<boo::IShaderPipeline> s_MultPipeline;
static boo::IShaderPipeline* s_CookieCutterPipeline = nullptr; static boo::ObjToken<boo::IShaderPipeline> s_CookieCutterPipeline;
static boo::IShaderPipeline* SelectPipeline(EFilterType type) static boo::ObjToken<boo::IShaderPipeline> SelectPipeline(EFilterType type)
{ {
switch (type) switch (type)
{ {
@ -129,22 +129,21 @@ static boo::IShaderPipeline* SelectPipeline(EFilterType type)
case EFilterType::Multiply: case EFilterType::Multiply:
return s_MultPipeline; return s_MultPipeline;
default: default:
return nullptr; return {};
} }
} }
struct CRandomStaticFilterMetalDataBindingFactory : TMultiBlendShader<CRandomStaticFilter>::IDataBindingFactory struct CRandomStaticFilterMetalDataBindingFactory : TMultiBlendShader<CRandomStaticFilter>::IDataBindingFactory
{ {
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
EFilterType type, EFilterType type, CRandomStaticFilter& filter)
CRandomStaticFilter& filter)
{ {
boo::MetalDataFactory::Context& cctx = static_cast<boo::MetalDataFactory::Context&>(ctx); boo::MetalDataFactory::Context& cctx = static_cast<boo::MetalDataFactory::Context&>(ctx);
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf}; boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {filter.m_uniBuf.get()};
boo::ITexture* texs[] = {g_Renderer->GetRandomStaticEntropyTex()}; boo::ObjToken<boo::ITexture> texs[] = {g_Renderer->GetRandomStaticEntropyTex()};
return cctx.newShaderDataBinding(filter.m_cookieCutter ? s_CookieCutterPipeline : SelectPipeline(type), return cctx.newShaderDataBinding(filter.m_cookieCutter ? s_CookieCutterPipeline : SelectPipeline(type),
s_VtxFmt, filter.m_vbo, nullptr, nullptr, 1, bufs, s_VtxFmt, filter.m_vbo.get(), nullptr, nullptr, 1, bufs,
nullptr, nullptr, nullptr, 1, texs, nullptr, nullptr); nullptr, nullptr, nullptr, 1, texs, nullptr, nullptr);
} }
}; };
@ -158,23 +157,37 @@ CRandomStaticFilter::Initialize(boo::MetalDataFactory::Context& ctx)
{nullptr, nullptr, boo::VertexSemantic::UV4} {nullptr, nullptr, boo::VertexSemantic::UV4}
}; };
s_VtxFmt = ctx.newVertexFormat(2, VtxVmt); s_VtxFmt = ctx.newVertexFormat(2, VtxVmt);
s_AlphaPipeline = ctx.newShaderPipeline(VS, FS, s_VtxFmt, CGraphics::g_ViewportSamples, s_AlphaPipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr,
s_VtxFmt, CGraphics::g_ViewportSamples,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips,
boo::ZTest::None, false, true, false, boo::CullMode::None); boo::ZTest::None, false, true, false, boo::CullMode::None);
s_AddPipeline = ctx.newShaderPipeline(VS, FS, s_VtxFmt, CGraphics::g_ViewportSamples, s_AddPipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr,
s_VtxFmt, CGraphics::g_ViewportSamples,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::One, boo::Primitive::TriStrips, boo::BlendFactor::One, boo::Primitive::TriStrips,
boo::ZTest::None, false, true, false, boo::CullMode::None); boo::ZTest::None, false, true, false, boo::CullMode::None);
s_MultPipeline = ctx.newShaderPipeline(VS, FS, s_VtxFmt, CGraphics::g_ViewportSamples, s_MultPipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr,
s_VtxFmt, CGraphics::g_ViewportSamples,
boo::BlendFactor::SrcColor, boo::BlendFactor::SrcColor,
boo::BlendFactor::DstColor, boo::Primitive::TriStrips, boo::BlendFactor::DstColor, boo::Primitive::TriStrips,
boo::ZTest::None, false, true, false, boo::CullMode::None); boo::ZTest::None, false, true, false, boo::CullMode::None);
s_CookieCutterPipeline = ctx.newShaderPipeline(VS, FSCookieCutter, s_VtxFmt, CGraphics::g_ViewportSamples, s_CookieCutterPipeline = ctx.newShaderPipeline(VS, FSCookieCutter, nullptr, nullptr,
s_VtxFmt, CGraphics::g_ViewportSamples,
boo::BlendFactor::SrcColor, boo::BlendFactor::SrcColor,
boo::BlendFactor::DstColor, boo::Primitive::TriStrips, boo::BlendFactor::DstColor, boo::Primitive::TriStrips,
boo::ZTest::LEqual, true, false, false, boo::CullMode::None); boo::ZTest::LEqual, true, false, false, boo::CullMode::None);
return new CRandomStaticFilterMetalDataBindingFactory; return new CRandomStaticFilterMetalDataBindingFactory;
} }
template <>
void CRandomStaticFilter::Shutdown<boo::MetalDataFactory>()
{
s_VtxFmt.reset();
s_AlphaPipeline.reset();
s_AddPipeline.reset();
s_MultPipeline.reset();
s_CookieCutterPipeline.reset();
}
} }

View File

@ -6,7 +6,7 @@ namespace urde
CScanLinesFilter::CScanLinesFilter(EFilterType type, bool even) CScanLinesFilter::CScanLinesFilter(EFilterType type, bool even)
: m_even(even) : m_even(even)
{ {
m_token = CGraphics::g_BooFactory->commitTransaction([&](boo::IGraphicsDataFactory::Context& ctx) -> bool CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
{ {
m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1); m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1);
m_dataBind = TMultiBlendShader<CScanLinesFilter>::BuildShaderDataBinding(ctx, type, *this); m_dataBind = TMultiBlendShader<CScanLinesFilter>::BuildShaderDataBinding(ctx, type, *this);
@ -23,8 +23,6 @@ void CScanLinesFilter::draw(const zeus::CColor& color)
CGraphics::DrawArray(0, 670); CGraphics::DrawArray(0, 670);
} }
void CScanLinesFilter::Shutdown() {}
URDE_SPECIALIZE_MULTI_BLEND_SHADER(CScanLinesFilter) URDE_SPECIALIZE_MULTI_BLEND_SHADER(CScanLinesFilter)
} }

View File

@ -21,9 +21,8 @@ class CScanLinesFilter
{ {
zeus::CColor color; zeus::CColor color;
}; };
boo::GraphicsDataToken m_token; boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf;
boo::IGraphicsBufferD* m_uniBuf; boo::ObjToken<boo::IShaderDataBinding> m_dataBind;
boo::IShaderDataBinding* m_dataBind = nullptr;
Uniform m_uniform; Uniform m_uniform;
bool m_even; bool m_even;

View File

@ -45,12 +45,12 @@ BOO_GLSL_BINDING_HEAD
URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(CScanLinesFilter) URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(CScanLinesFilter)
static boo::IVertexFormat* s_VtxFmt = nullptr; static boo::ObjToken<boo::IVertexFormat> s_VtxFmt;
static boo::IShaderPipeline* s_AlphaPipeline = nullptr; static boo::ObjToken<boo::IShaderPipeline> s_AlphaPipeline;
static boo::IShaderPipeline* s_AddPipeline = nullptr; static boo::ObjToken<boo::IShaderPipeline> s_AddPipeline;
static boo::IShaderPipeline* s_MultPipeline = nullptr; static boo::ObjToken<boo::IShaderPipeline> s_MultPipeline;
static boo::IShaderPipeline* SelectPipeline(EFilterType type) static boo::ObjToken<boo::IShaderPipeline> SelectPipeline(EFilterType type)
{ {
switch (type) switch (type)
{ {
@ -61,25 +61,24 @@ static boo::IShaderPipeline* SelectPipeline(EFilterType type)
case EFilterType::Multiply: case EFilterType::Multiply:
return s_MultPipeline; return s_MultPipeline;
default: default:
return nullptr; return {};
} }
} }
struct CScanLinesFilterGLDataBindingFactory : TMultiBlendShader<CScanLinesFilter>::IDataBindingFactory struct CScanLinesFilterGLDataBindingFactory : TMultiBlendShader<CScanLinesFilter>::IDataBindingFactory
{ {
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
EFilterType type, EFilterType type, CScanLinesFilter& filter)
CScanLinesFilter& filter)
{ {
boo::GLDataFactory::Context& cctx = static_cast<boo::GLDataFactory::Context&>(ctx); boo::GLDataFactory::Context& cctx = static_cast<boo::GLDataFactory::Context&>(ctx);
boo::IGraphicsBuffer* vbo = filter.m_even ? boo::ObjToken<boo::IGraphicsBuffer> vbo = filter.m_even ?
g_Renderer->GetScanLinesEvenVBO() : g_Renderer->GetScanLinesOddVBO(); g_Renderer->GetScanLinesEvenVBO().get() : g_Renderer->GetScanLinesOddVBO().get();
const boo::VertexElementDescriptor VtxVmt[] = const boo::VertexElementDescriptor VtxVmt[] =
{ {
{vbo, nullptr, boo::VertexSemantic::Position4} {vbo, nullptr, boo::VertexSemantic::Position4}
}; };
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf}; boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {filter.m_uniBuf.get()};
boo::PipelineStage stages[] = {boo::PipelineStage::Vertex}; boo::PipelineStage stages[] = {boo::PipelineStage::Vertex};
return cctx.newShaderDataBinding(SelectPipeline(type), return cctx.newShaderDataBinding(SelectPipeline(type),
ctx.newVertexFormat(1, VtxVmt), vbo, nullptr, nullptr, ctx.newVertexFormat(1, VtxVmt), vbo, nullptr, nullptr,
@ -90,15 +89,15 @@ struct CScanLinesFilterGLDataBindingFactory : TMultiBlendShader<CScanLinesFilter
#if BOO_HAS_VULKAN #if BOO_HAS_VULKAN
struct CScanLinesFilterVulkanDataBindingFactory : TMultiBlendShader<CScanLinesFilter>::IDataBindingFactory struct CScanLinesFilterVulkanDataBindingFactory : TMultiBlendShader<CScanLinesFilter>::IDataBindingFactory
{ {
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, boo::ObjToken<boo::IShaderDataBinding>
EFilterType type, BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
CScanLinesFilter& filter) EFilterType type, CScanLinesFilter& filter)
{ {
boo::VulkanDataFactory::Context& cctx = static_cast<boo::VulkanDataFactory::Context&>(ctx); boo::VulkanDataFactory::Context& cctx = static_cast<boo::VulkanDataFactory::Context&>(ctx);
boo::IGraphicsBuffer* vbo = filter.m_even ? boo::ObjToken<boo::IGraphicsBuffer> vbo = filter.m_even ?
g_Renderer->GetScanLinesEvenVBO() : g_Renderer->GetScanLinesOddVBO(); g_Renderer->GetScanLinesEvenVBO().get() : g_Renderer->GetScanLinesOddVBO().get();
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf}; boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {filter.m_uniBuf.get()};
return cctx.newShaderDataBinding(SelectPipeline(type), s_VtxFmt, return cctx.newShaderDataBinding(SelectPipeline(type), s_VtxFmt,
vbo, nullptr, nullptr, 1, bufs, vbo, nullptr, nullptr, 1, bufs,
nullptr, nullptr, nullptr, 0, nullptr, nullptr, nullptr); nullptr, nullptr, nullptr, 0, nullptr, nullptr, nullptr);
@ -122,6 +121,14 @@ CScanLinesFilter::Initialize(boo::GLDataFactory::Context& ctx)
return new CScanLinesFilterGLDataBindingFactory; return new CScanLinesFilterGLDataBindingFactory;
} }
template <>
void CScanLinesFilter::Shutdown<boo::GLDataFactory>()
{
s_AlphaPipeline.reset();
s_AddPipeline.reset();
s_MultPipeline.reset();
}
#if BOO_HAS_VULKAN #if BOO_HAS_VULKAN
TMultiBlendShader<CScanLinesFilter>::IDataBindingFactory* TMultiBlendShader<CScanLinesFilter>::IDataBindingFactory*
CScanLinesFilter::Initialize(boo::VulkanDataFactory::Context& ctx) CScanLinesFilter::Initialize(boo::VulkanDataFactory::Context& ctx)
@ -142,6 +149,15 @@ CScanLinesFilter::Initialize(boo::VulkanDataFactory::Context& ctx)
boo::ZTest::None, false, true, false, boo::CullMode::None); boo::ZTest::None, false, true, false, boo::CullMode::None);
return new CScanLinesFilterVulkanDataBindingFactory; return new CScanLinesFilterVulkanDataBindingFactory;
} }
template <>
void CScanLinesFilter::Shutdown<boo::VulkanDataFactory>()
{
s_VtxFmt.reset();
s_AlphaPipeline.reset();
s_AddPipeline.reset();
s_MultPipeline.reset();
}
#endif #endif
} }

View File

@ -46,12 +46,12 @@ static const char* FS =
URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(CScanLinesFilter) URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(CScanLinesFilter)
static boo::IVertexFormat* s_VtxFmt = nullptr; static boo::ObjToken<boo::IVertexFormat> s_VtxFmt;
static boo::IShaderPipeline* s_AlphaPipeline = nullptr; static boo::ObjToken<boo::IShaderPipeline> s_AlphaPipeline;
static boo::IShaderPipeline* s_AddPipeline = nullptr; static boo::ObjToken<boo::IShaderPipeline> s_AddPipeline;
static boo::IShaderPipeline* s_MultPipeline = nullptr; static boo::ObjToken<boo::IShaderPipeline> s_MultPipeline;
static boo::IShaderPipeline* SelectPipeline(EFilterType type) static boo::ObjToken<boo::IShaderPipeline> SelectPipeline(EFilterType type)
{ {
switch (type) switch (type)
{ {
@ -68,15 +68,15 @@ static boo::IShaderPipeline* SelectPipeline(EFilterType type)
struct CScanLinesFilterD3DDataBindingFactory : TMultiBlendShader<CScanLinesFilter>::IDataBindingFactory struct CScanLinesFilterD3DDataBindingFactory : TMultiBlendShader<CScanLinesFilter>::IDataBindingFactory
{ {
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, boo::ObjToken<boo::IShaderDataBinding>
EFilterType type, BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
CScanLinesFilter& filter) EFilterType type, CScanLinesFilter& filter)
{ {
boo::ID3DDataFactory::Context& cctx = static_cast<boo::ID3DDataFactory::Context&>(ctx); boo::ID3DDataFactory::Context& cctx = static_cast<boo::ID3DDataFactory::Context&>(ctx);
boo::IGraphicsBuffer* vbo = filter.m_even ? boo::ObjToken<boo::IGraphicsBuffer> vbo = filter.m_even ?
g_Renderer->GetScanLinesEvenVBO() : g_Renderer->GetScanLinesOddVBO(); g_Renderer->GetScanLinesEvenVBO().get() : g_Renderer->GetScanLinesOddVBO().get();
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf}; boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {filter.m_uniBuf.get()};
return cctx.newShaderDataBinding(SelectPipeline(type), s_VtxFmt, return cctx.newShaderDataBinding(SelectPipeline(type), s_VtxFmt,
vbo, nullptr, nullptr, 1, bufs, vbo, nullptr, nullptr, 1, bufs,
nullptr, nullptr, nullptr, 0, nullptr, nullptr, nullptr); nullptr, nullptr, nullptr, 0, nullptr, nullptr, nullptr);
@ -106,4 +106,13 @@ CScanLinesFilter::Initialize(boo::ID3DDataFactory::Context& ctx)
return new CScanLinesFilterD3DDataBindingFactory; return new CScanLinesFilterD3DDataBindingFactory;
} }
template <>
void CScanLinesFilter::Shutdown<boo::ID3DDataFactory>()
{
s_VtxFmt.reset();
s_AlphaPipeline.reset();
s_AddPipeline.reset();
s_MultPipeline.reset();
}
} }

View File

@ -49,12 +49,12 @@ static const char* FS =
URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(CScanLinesFilter) URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(CScanLinesFilter)
static boo::IVertexFormat* s_VtxFmt = nullptr; static boo::ObjToken<boo::IVertexFormat> s_VtxFmt;
static boo::IShaderPipeline* s_AlphaPipeline = nullptr; static boo::ObjToken<boo::IShaderPipeline> s_AlphaPipeline;
static boo::IShaderPipeline* s_AddPipeline = nullptr; static boo::ObjToken<boo::IShaderPipeline> s_AddPipeline;
static boo::IShaderPipeline* s_MultPipeline = nullptr; static boo::ObjToken<boo::IShaderPipeline> s_MultPipeline;
static boo::IShaderPipeline* SelectPipeline(EFilterType type) static boo::ObjToken<boo::IShaderPipeline> SelectPipeline(EFilterType type)
{ {
switch (type) switch (type)
{ {
@ -65,21 +65,20 @@ static boo::IShaderPipeline* SelectPipeline(EFilterType type)
case EFilterType::Multiply: case EFilterType::Multiply:
return s_MultPipeline; return s_MultPipeline;
default: default:
return nullptr; return {};
} }
} }
struct CScanLinesFilterMetalDataBindingFactory : TMultiBlendShader<CScanLinesFilter>::IDataBindingFactory struct CScanLinesFilterMetalDataBindingFactory : TMultiBlendShader<CScanLinesFilter>::IDataBindingFactory
{ {
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
EFilterType type, EFilterType type, CScanLinesFilter& filter)
CScanLinesFilter& filter)
{ {
boo::MetalDataFactory::Context& cctx = static_cast<boo::MetalDataFactory::Context&>(ctx); boo::MetalDataFactory::Context& cctx = static_cast<boo::MetalDataFactory::Context&>(ctx);
boo::IGraphicsBuffer* vbo = filter.m_even ? boo::ObjToken<boo::IGraphicsBuffer> vbo = filter.m_even ?
g_Renderer->GetScanLinesEvenVBO() : g_Renderer->GetScanLinesOddVBO(); g_Renderer->GetScanLinesEvenVBO().get() : g_Renderer->GetScanLinesOddVBO().get();
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf}; boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {filter.m_uniBuf.get()};
return cctx.newShaderDataBinding(SelectPipeline(type), s_VtxFmt, return cctx.newShaderDataBinding(SelectPipeline(type), s_VtxFmt,
vbo, nullptr, nullptr, 1, bufs, vbo, nullptr, nullptr, 1, bufs,
nullptr, nullptr, nullptr, 0, nullptr, nullptr, nullptr); nullptr, nullptr, nullptr, 0, nullptr, nullptr, nullptr);
@ -94,16 +93,28 @@ CScanLinesFilter::Initialize(boo::MetalDataFactory::Context& ctx)
{nullptr, nullptr, boo::VertexSemantic::Position4} {nullptr, nullptr, boo::VertexSemantic::Position4}
}; };
s_VtxFmt = ctx.newVertexFormat(1, VtxVmt); s_VtxFmt = ctx.newVertexFormat(1, VtxVmt);
s_AlphaPipeline = ctx.newShaderPipeline(VS, FS, s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha, s_AlphaPipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr,
s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips,
boo::ZTest::None, false, true, true, boo::CullMode::None); boo::ZTest::None, false, true, true, boo::CullMode::None);
s_AddPipeline = ctx.newShaderPipeline(VS, FS, s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha, s_AddPipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr,
s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::One, boo::Primitive::TriStrips, boo::BlendFactor::One, boo::Primitive::TriStrips,
boo::ZTest::None, false, true, true, boo::CullMode::None); boo::ZTest::None, false, true, true, boo::CullMode::None);
s_MultPipeline = ctx.newShaderPipeline(VS, FS, s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcColor, s_MultPipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr,
s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcColor,
boo::BlendFactor::DstColor, boo::Primitive::TriStrips, boo::BlendFactor::DstColor, boo::Primitive::TriStrips,
boo::ZTest::None, false, true, true, boo::CullMode::None); boo::ZTest::None, false, true, true, boo::CullMode::None);
return new CScanLinesFilterMetalDataBindingFactory; return new CScanLinesFilterMetalDataBindingFactory;
} }
template <>
void CScanLinesFilter::Shutdown<boo::MetalDataFactory>()
{
s_VtxFmt.reset();
s_AlphaPipeline.reset();
s_AddPipeline.reset();
s_MultPipeline.reset();
}
} }

Some files were not shown because too many files have changed in this diff Show More