mirror of https://github.com/AxioDL/metaforce.git
Changes to support boo object tracker API
This commit is contained in:
parent
d301491bd6
commit
3894749675
|
@ -204,8 +204,8 @@ void ViewManager::init(boo::IApplication* app)
|
|||
m_mainWindow->setTitle(_S("URDE [") + hecl::SystemString(m_mainPlatformName) + _S("]"));
|
||||
m_mainCommandQueue = m_mainWindow->getCommandQueue();
|
||||
m_viewResources.init(m_mainBooFactory, &m_fontCache, &m_themeData, pixelFactor);
|
||||
m_iconsToken = InitializeIcons(m_viewResources);
|
||||
m_badgeToken = InitializeBadging(m_viewResources);
|
||||
InitializeIcons(m_viewResources);
|
||||
InitializeBadging(m_viewResources);
|
||||
m_viewResources.prepFontCacheAsync(m_mainWindow.get());
|
||||
specter::RootView* root = SetupRootView();
|
||||
m_showSplash = true;
|
||||
|
@ -292,7 +292,8 @@ void ViewManager::stop()
|
|||
m_videoVoice.reset();
|
||||
m_projManager.shutdown();
|
||||
CDvdFile::Shutdown();
|
||||
m_iconsToken.doDestroy();
|
||||
DestroyIcons();
|
||||
DestroyBadging();
|
||||
m_viewResources.destroyResData();
|
||||
m_fontCache.destroyAtlases();
|
||||
m_mainWindow->getCommandQueue()->stopRenderer();
|
||||
|
|
|
@ -37,12 +37,10 @@ class ViewManager : public specter::IViewManager
|
|||
specter::FontCache m_fontCache;
|
||||
specter::DefaultThemeData m_themeData;
|
||||
specter::ViewResources m_viewResources;
|
||||
boo::GraphicsDataToken m_iconsToken;
|
||||
boo::GraphicsDataToken m_badgeToken;
|
||||
specter::Translator m_translator;
|
||||
boo::IGraphicsDataFactory* m_mainBooFactory = nullptr;
|
||||
boo::IGraphicsCommandQueue* m_mainCommandQueue = nullptr;
|
||||
boo::ITextureR* m_renderTex = nullptr;
|
||||
boo::ObjToken<boo::ITextureR> m_renderTex;
|
||||
const boo::SystemChar* m_mainPlatformName;
|
||||
|
||||
std::unique_ptr<specter::RootView> m_rootView;
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace urde
|
|||
static logvisor::Module Log("URDE::badging");
|
||||
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);
|
||||
|
||||
|
@ -28,7 +28,7 @@ boo::GraphicsDataToken InitializeBadging(specter::ViewResources& viewRes)
|
|||
if (uncompress(texels.get(), &destSz, URDE_BADGE + pos, URDE_BADGE_SZ - pos) != Z_OK)
|
||||
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;
|
||||
|
||||
|
@ -40,6 +40,11 @@ boo::GraphicsDataToken InitializeBadging(specter::ViewResources& viewRes)
|
|||
});
|
||||
}
|
||||
|
||||
void DestroyBadging()
|
||||
{
|
||||
g_BadgeIcon.m_tex.reset();
|
||||
}
|
||||
|
||||
specter::Icon& GetBadge()
|
||||
{
|
||||
return g_BadgeIcon;
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
|
||||
namespace urde
|
||||
{
|
||||
boo::GraphicsDataToken InitializeBadging(specter::ViewResources& viewRes);
|
||||
void InitializeBadging(specter::ViewResources& viewRes);
|
||||
void DestroyBadging();
|
||||
|
||||
specter::Icon& GetBadge();
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ static logvisor::Module Log("URDE::icons");
|
|||
|
||||
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);
|
||||
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)
|
||||
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,
|
||||
boo::TextureFormat::RGBA8,
|
||||
|
@ -38,6 +38,11 @@ boo::GraphicsDataToken InitializeIcons(specter::ViewResources& viewRes)
|
|||
});
|
||||
}
|
||||
|
||||
void DestroyIcons()
|
||||
{
|
||||
g_IconAtlas.destroyAtlas();
|
||||
}
|
||||
|
||||
specter::Icon& GetIcon(SpaceIcon icon)
|
||||
{
|
||||
switch (icon)
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
|
||||
namespace urde
|
||||
{
|
||||
boo::GraphicsDataToken InitializeIcons(specter::ViewResources& viewRes);
|
||||
void InitializeIcons(specter::ViewResources& viewRes);
|
||||
void DestroyIcons();
|
||||
|
||||
enum class SpaceIcon
|
||||
{
|
||||
|
|
|
@ -54,7 +54,7 @@ void CMapArea::PostConstruct()
|
|||
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_ibo = ctx.newStaticBuffer(boo::BufferUse::Index, index.data(), 4, index.size());
|
||||
|
|
|
@ -29,8 +29,12 @@ public:
|
|||
{
|
||||
CMapSurfaceShader m_surfacePrims;
|
||||
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) {}
|
||||
Instance(Instance&&) = default;
|
||||
Instance& operator=(Instance&&) = default;
|
||||
};
|
||||
std::vector<Instance> m_instances;
|
||||
public:
|
||||
|
@ -67,9 +71,8 @@ private:
|
|||
u8* x40_surfaceStart;
|
||||
std::vector<CMapAreaSurface> m_surfaces;
|
||||
std::unique_ptr<u8[]> x44_buf;
|
||||
boo::GraphicsDataToken m_gfxToken;
|
||||
boo::IGraphicsBufferS* m_vbo;
|
||||
boo::IGraphicsBufferS* m_ibo;
|
||||
boo::ObjToken<boo::IGraphicsBufferS> m_vbo;
|
||||
boo::ObjToken<boo::IGraphicsBufferS> m_ibo;
|
||||
|
||||
public:
|
||||
CMapArea(CInputStream& in, u32 size);
|
||||
|
|
|
@ -278,9 +278,8 @@ bool CMappableObject::IsVisibleToAutoMapper(bool worldVis, const CMapWorldInfo&
|
|||
}
|
||||
}
|
||||
|
||||
boo::GraphicsDataToken CMappableObject::g_gfxToken = {};
|
||||
boo::IGraphicsBufferS* CMappableObject::g_doorVbo;
|
||||
boo::IGraphicsBufferS* CMappableObject::g_doorIbo;
|
||||
boo::ObjToken<boo::IGraphicsBufferS> CMappableObject::g_doorVbo;
|
||||
boo::ObjToken<boo::IGraphicsBufferS> CMappableObject::g_doorIbo;
|
||||
|
||||
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[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_doorIbo = ctx.newStaticBuffer(boo::BufferUse::Index, DoorIndices, 4, 24);
|
||||
|
@ -306,6 +305,7 @@ void CMappableObject::ReadAutoMapperTweaks(const ITweakAutoMapper& tweaks)
|
|||
|
||||
void CMappableObject::Shutdown()
|
||||
{
|
||||
g_gfxToken.doDestroy();
|
||||
g_doorVbo.reset();
|
||||
g_doorIbo.reset();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,9 +17,8 @@ class CMapWorldInfo;
|
|||
class CMappableObject
|
||||
{
|
||||
friend class CMapArea;
|
||||
static boo::GraphicsDataToken g_gfxToken;
|
||||
static boo::IGraphicsBufferS* g_doorVbo;
|
||||
static boo::IGraphicsBufferS* g_doorIbo;
|
||||
static boo::ObjToken<boo::IGraphicsBufferS> g_doorVbo;
|
||||
static boo::ObjToken<boo::IGraphicsBufferS> g_doorIbo;
|
||||
|
||||
public:
|
||||
enum class EMappableObjectType
|
||||
|
|
|
@ -672,7 +672,7 @@ CBooRenderer::CBooRenderer(IObjectStore& store, IFactory& resFac)
|
|||
|
||||
m_staticEntropy = store.GetObj("RandomStaticEntropy");
|
||||
|
||||
m_gfxToken = CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
|
||||
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
|
||||
{
|
||||
GenerateFogVolumeRampTex(ctx);
|
||||
GenerateSphereRampTex(ctx);
|
||||
|
|
|
@ -97,7 +97,6 @@ class CBooRenderer : public IRenderer
|
|||
IFactory& x8_factory;
|
||||
IObjectStore& xc_store;
|
||||
TLockedToken<CTexture> m_staticEntropy;
|
||||
boo::GraphicsDataToken m_gfxToken;
|
||||
// CFont x10_fnt;
|
||||
u32 x18_ = 0;
|
||||
std::list<CAreaListItem> x1c_areaListItems;
|
||||
|
@ -120,17 +119,17 @@ class CBooRenderer : public IRenderer
|
|||
//boo::ITextureS* xe4_blackTex = nullptr;
|
||||
bool xee_24_ : 1;
|
||||
|
||||
boo::ITextureR* x14c_reflectionTex = nullptr;
|
||||
boo::ObjToken<boo::ITextureR> x14c_reflectionTex;
|
||||
//boo::ITextureS* x150_mirrorRamp = nullptr;
|
||||
boo::ITextureS* x1b8_fogVolumeRamp = nullptr;
|
||||
boo::ITextureS* x220_sphereRamp = nullptr;
|
||||
boo::ObjToken<boo::ITextureS> x1b8_fogVolumeRamp;
|
||||
boo::ObjToken<boo::ITextureS> x220_sphereRamp;
|
||||
TLockedToken<CTexture> m_thermoPaletteTex;
|
||||
boo::ITexture* x288_thermoPalette = nullptr;
|
||||
boo::ObjToken<boo::ITexture> x288_thermoPalette;
|
||||
TLockedToken<CTexture> m_ballFadeTex;
|
||||
boo::ITexture* m_ballFade = nullptr;
|
||||
boo::ITextureR* m_ballShadowId = nullptr;
|
||||
boo::IGraphicsBufferS* m_scanLinesEvenVBO = nullptr;
|
||||
boo::IGraphicsBufferS* m_scanLinesOddVBO = nullptr;
|
||||
boo::ObjToken<boo::ITexture> m_ballFade;
|
||||
boo::ObjToken<boo::ITextureR> m_ballShadowId;
|
||||
boo::ObjToken<boo::IGraphicsBufferS> m_scanLinesEvenVBO;
|
||||
boo::ObjToken<boo::IGraphicsBufferS> m_scanLinesOddVBO;
|
||||
int m_ballShadowIdW = 64;
|
||||
int m_ballShadowIdH = 64;
|
||||
|
||||
|
@ -275,11 +274,11 @@ public:
|
|||
void ReallyRenderFogVolume(const zeus::CColor& color, const zeus::CAABox& aabb,
|
||||
const CModel* model, const CSkinnedModel* sModel);
|
||||
|
||||
boo::ITexture* GetThermoPalette() {return x288_thermoPalette;}
|
||||
boo::ITextureS* GetFogRampTex() {return x1b8_fogVolumeRamp;}
|
||||
boo::ITexture* GetRandomStaticEntropyTex() const {return m_staticEntropy->GetBooTexture();}
|
||||
boo::IGraphicsBuffer* GetScanLinesEvenVBO() const {return m_scanLinesEvenVBO;}
|
||||
boo::IGraphicsBuffer* GetScanLinesOddVBO() const {return m_scanLinesOddVBO;}
|
||||
const boo::ObjToken<boo::ITexture>& GetThermoPalette() {return x288_thermoPalette;}
|
||||
const boo::ObjToken<boo::ITextureS>& GetFogRampTex() {return x1b8_fogVolumeRamp;}
|
||||
const boo::ObjToken<boo::ITexture>& GetRandomStaticEntropyTex() const {return m_staticEntropy->GetBooTexture();}
|
||||
const boo::ObjToken<boo::IGraphicsBufferS>& GetScanLinesEvenVBO() const {return m_scanLinesEvenVBO;}
|
||||
const boo::ObjToken<boo::IGraphicsBufferS>& GetScanLinesOddVBO() const {return m_scanLinesOddVBO;}
|
||||
|
||||
static void BindMainDrawTarget() {CGraphics::g_BooMainCommandQueue->setRenderTarget(CGraphics::g_SpareTexture);}
|
||||
void BindReflectionDrawTarget() {CGraphics::g_BooMainCommandQueue->setRenderTarget(x14c_reflectionTex);}
|
||||
|
|
|
@ -515,7 +515,7 @@ void CGraphics::TickRenderTimings()
|
|||
boo::IGraphicsDataFactory::Platform CGraphics::g_BooPlatform = boo::IGraphicsDataFactory::Platform::Null;
|
||||
boo::IGraphicsDataFactory* CGraphics::g_BooFactory = 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;
|
||||
|
||||
}
|
||||
|
|
|
@ -300,11 +300,11 @@ public:
|
|||
static const boo::SystemChar* g_BooPlatformName;
|
||||
static boo::IGraphicsDataFactory* g_BooFactory;
|
||||
static boo::IGraphicsCommandQueue* g_BooMainCommandQueue;
|
||||
static boo::ITextureR* g_SpareTexture;
|
||||
static boo::ObjToken<boo::ITextureR> g_SpareTexture;
|
||||
|
||||
static void InitializeBoo(boo::IGraphicsDataFactory* factory,
|
||||
boo::IGraphicsCommandQueue* cc,
|
||||
boo::ITextureR* spareTex)
|
||||
const boo::ObjToken<boo::ITextureR>& spareTex)
|
||||
{
|
||||
g_BooPlatform = factory->platform();
|
||||
g_BooPlatformName = factory->platformName();
|
||||
|
@ -313,16 +313,16 @@ public:
|
|||
g_SpareTexture = spareTex;
|
||||
}
|
||||
|
||||
const boo::SystemChar* PlatformName()
|
||||
static const boo::SystemChar* PlatformName()
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -23,7 +23,8 @@ hecl::VertexBufferPool<CLineRenderer::SDrawVertNoTex> CLineRenderer::s_vertPoolN
|
|||
hecl::UniformBufferPool<CLineRenderer::SDrawUniform> CLineRenderer::s_uniformPool = {};
|
||||
|
||||
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)
|
||||
{
|
||||
if (maxVerts < 2)
|
||||
|
@ -31,7 +32,7 @@ CLineRenderer::CLineRenderer(boo::IGraphicsDataFactory::Context& ctx,
|
|||
LineRendererLog.report(logvisor::Fatal, _S("maxVerts < 2, maxVerts = %i"), maxVerts);
|
||||
return;
|
||||
}
|
||||
m_textured = texture != nullptr;
|
||||
m_textured = texture;
|
||||
|
||||
u32 maxTriVerts;
|
||||
switch (mode)
|
||||
|
@ -57,7 +58,8 @@ CLineRenderer::CLineRenderer(boo::IGraphicsDataFactory::Context& ctx,
|
|||
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)
|
||||
{
|
||||
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);
|
||||
return;
|
||||
}
|
||||
m_textured = texture != nullptr;
|
||||
m_textured = texture;
|
||||
|
||||
u32 maxTriVerts;
|
||||
switch (mode)
|
||||
|
@ -88,7 +90,7 @@ CLineRenderer::CLineRenderer(EPrimitiveMode mode, u32 maxVerts, boo::ITexture* t
|
|||
|
||||
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);
|
||||
return true;
|
||||
|
|
|
@ -67,15 +67,14 @@ private:
|
|||
static hecl::UniformBufferPool<SDrawUniform> s_uniformPool;
|
||||
|
||||
public:
|
||||
boo::GraphicsDataToken m_gfxToken;
|
||||
hecl::VertexBufferPool<SDrawVertTex>::Token m_vertBufTex;
|
||||
hecl::VertexBufferPool<SDrawVertNoTex>::Token m_vertBufNoTex;
|
||||
hecl::UniformBufferPool<SDrawUniform>::Token m_uniformBuf;
|
||||
boo::IShaderDataBinding* m_shaderBind = nullptr;
|
||||
boo::ObjToken<boo::IShaderDataBinding> m_shaderBind;
|
||||
|
||||
CLineRenderer(boo::IGraphicsDataFactory::Context& ctx,
|
||||
EPrimitiveMode mode, u32 maxVerts, boo::ITexture* texture, bool additive);
|
||||
CLineRenderer(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, const boo::ObjToken<boo::ITexture>& texture, bool additive);
|
||||
CLineRenderer(CLineRenderer&&) = default;
|
||||
|
||||
void Reset();
|
||||
|
|
|
@ -134,24 +134,23 @@ private:
|
|||
size_t m_uniformDataSize = 0;
|
||||
struct ModelInstance
|
||||
{
|
||||
boo::GraphicsDataToken m_gfxToken;
|
||||
boo::IGraphicsBufferD* m_uniformBuffer;
|
||||
std::vector<std::vector<boo::IShaderDataBinding*>> m_shaderDataBindings;
|
||||
boo::IVertexFormat* m_dynamicVtxFmt = nullptr;
|
||||
boo::IGraphicsBufferD* m_dynamicVbo = nullptr;
|
||||
boo::ObjToken<boo::IGraphicsBufferD> m_uniformBuffer;
|
||||
std::vector<std::vector<boo::ObjToken<boo::IShaderDataBinding>>> m_shaderDataBindings;
|
||||
boo::ObjToken<boo::IVertexFormat> m_dynamicVtxFmt;
|
||||
boo::ObjToken<boo::IGraphicsBufferD> m_dynamicVbo;
|
||||
|
||||
boo::IGraphicsBuffer* GetBooVBO(const CBooModel& model, boo::IGraphicsDataFactory::Context& ctx);
|
||||
boo::IVertexFormat* GetBooVtxFmt(const CBooModel& model, boo::IGraphicsDataFactory::Context& ctx);
|
||||
boo::ObjToken<boo::IGraphicsBuffer> GetBooVBO(const CBooModel& model, boo::IGraphicsDataFactory::Context& ctx);
|
||||
boo::ObjToken<boo::IVertexFormat> GetBooVtxFmt(const CBooModel& model, boo::IGraphicsDataFactory::Context& ctx);
|
||||
};
|
||||
std::vector<ModelInstance> m_instances;
|
||||
|
||||
boo::IVertexFormat* m_staticVtxFmt = nullptr;
|
||||
boo::IGraphicsBufferS* m_staticVbo = nullptr;
|
||||
boo::IGraphicsBufferS* m_staticIbo = nullptr;
|
||||
boo::ObjToken<boo::IVertexFormat> m_staticVtxFmt;
|
||||
boo::ObjToken<boo::IGraphicsBufferS> m_staticVbo;
|
||||
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();
|
||||
void DrawAlphaSurfaces(const CModelFlags& flags) const;
|
||||
|
@ -172,9 +171,9 @@ private:
|
|||
public:
|
||||
~CBooModel();
|
||||
CBooModel(TToken<CModel>& token, CModel* parent, std::vector<CBooSurface>* surfaces, SShader& shader,
|
||||
boo::IVertexFormat* vtxFmt, boo::IGraphicsBufferS* vbo, boo::IGraphicsBufferS* ibo,
|
||||
const zeus::CAABox& aabb, u8 renderMask,
|
||||
int numInsts, boo::ITexture* txtrOverrides[8]);
|
||||
const boo::ObjToken<boo::IVertexFormat>& vtxFmt, const boo::ObjToken<boo::IGraphicsBufferS>& vbo,
|
||||
const boo::ObjToken<boo::IGraphicsBufferS>& ibo, const zeus::CAABox& aabb, u8 renderMask,
|
||||
int numInsts, const boo::ObjToken<boo::ITexture> txtrOverrides[8]);
|
||||
|
||||
static void MakeTexturesFromMats(const MaterialSet& matSet,
|
||||
std::vector<TCachedToken<CTexture>>& toksOut,
|
||||
|
@ -193,7 +192,7 @@ public:
|
|||
void SyncLoadTextures() const;
|
||||
void Touch(int shaderIdx) const;
|
||||
void VerifyCurrentShader(int shaderIdx);
|
||||
boo::IGraphicsBufferD* UpdateUniformData(const CModelFlags& flags,
|
||||
boo::ObjToken<boo::IGraphicsBufferD> UpdateUniformData(const CModelFlags& flags,
|
||||
const CSkinRules* cskr,
|
||||
const CPoseAsTransforms* pose) const;
|
||||
void DrawAlpha(const CModelFlags& flags,
|
||||
|
@ -229,9 +228,9 @@ public:
|
|||
static void EnsureViewDepStateCached(const CBooModel& model, const CBooSurface* surf,
|
||||
zeus::CMatrix4f* mtxsOut, float& alphaOut);
|
||||
|
||||
static boo::ITexture* g_shadowMap;
|
||||
static boo::ObjToken<boo::ITexture> g_shadowMap;
|
||||
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 SetDummyTextures(bool b) { g_DummyTextures = true; }
|
||||
|
@ -253,12 +252,11 @@ class CModel
|
|||
int x38_lastFrame;
|
||||
|
||||
/* urde addition: boo! */
|
||||
boo::GraphicsDataToken m_gfxToken;
|
||||
boo::IVertexFormat* m_staticVtxFmt = nullptr;
|
||||
boo::IGraphicsBufferS* m_staticVbo = nullptr;
|
||||
boo::ObjToken<boo::IVertexFormat> m_staticVtxFmt;
|
||||
boo::ObjToken<boo::IGraphicsBufferS> m_staticVbo;
|
||||
hecl::HMDLMeta m_hmdlMeta;
|
||||
std::unique_ptr<uint8_t[]> m_dynamicVertexData;
|
||||
boo::IGraphicsBufferS* m_ibo = nullptr;
|
||||
boo::ObjToken<boo::IGraphicsBufferS> m_ibo;
|
||||
|
||||
public:
|
||||
using MaterialSet = DataSpec::DNAMP1::HMDLMaterialSet;
|
||||
|
@ -274,7 +272,7 @@ public:
|
|||
CBooModel& GetInstance() {return *x28_modelInst;}
|
||||
const CBooModel& GetInstance() const {return *x28_modelInst;}
|
||||
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);
|
||||
void UpdateLastFrame() const { const_cast<CModel&>(*this).x38_lastFrame = CGraphics::GetFrameCounter(); }
|
||||
|
||||
|
@ -282,7 +280,7 @@ public:
|
|||
zeus::CVector3f GetPoolVertex(size_t idx) const;
|
||||
size_t GetPoolNormalOffset(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;
|
||||
|
||||
void _WarmupShaders();
|
||||
|
|
|
@ -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;
|
||||
|
||||
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_shadowTexXf = texXf;
|
||||
|
@ -149,9 +149,9 @@ CBooModel::~CBooModel()
|
|||
}
|
||||
|
||||
CBooModel::CBooModel(TToken<CModel>& token, CModel* parent, std::vector<CBooSurface>* surfaces, SShader& shader,
|
||||
boo::IVertexFormat* vtxFmt, boo::IGraphicsBufferS* vbo, boo::IGraphicsBufferS* ibo,
|
||||
const zeus::CAABox& aabb, u8 renderMask,
|
||||
int numInsts, boo::ITexture* txtrOverrides[8])
|
||||
const boo::ObjToken<boo::IVertexFormat>& vtxFmt, const boo::ObjToken<boo::IGraphicsBufferS>& vbo,
|
||||
const boo::ObjToken<boo::IGraphicsBufferS>& ibo, const zeus::CAABox& aabb, u8 renderMask,
|
||||
int numInsts, const boo::ObjToken<boo::ITexture> txtrOverrides[8])
|
||||
: 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),
|
||||
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();
|
||||
}
|
||||
|
||||
boo::IGraphicsBuffer* CBooModel::ModelInstance::GetBooVBO(const CBooModel& model,
|
||||
boo::ObjToken<boo::IGraphicsBuffer>
|
||||
CBooModel::ModelInstance::GetBooVBO(const CBooModel& model,
|
||||
boo::IGraphicsDataFactory::Context& ctx)
|
||||
{
|
||||
if (model.m_staticVbo)
|
||||
return model.m_staticVbo;
|
||||
return model.m_staticVbo.get();
|
||||
if (!m_dynamicVbo && 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(),
|
||||
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)
|
||||
{
|
||||
if (model.m_staticVtxFmt)
|
||||
|
@ -219,7 +221,7 @@ boo::IVertexFormat* CBooModel::ModelInstance::GetBooVtxFmt(const CBooModel& mode
|
|||
{
|
||||
const CModel& parent = *model.m_model;
|
||||
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;
|
||||
}
|
||||
|
@ -241,8 +243,7 @@ CBooModel::ModelInstance* CBooModel::PushNewModelInstance()
|
|||
weightVecCount = model->m_hmdlMeta.weightCount;
|
||||
}
|
||||
|
||||
newInst.m_gfxToken = CGraphics::CommitResources(
|
||||
[&](boo::IGraphicsDataFactory::Context& ctx) -> bool
|
||||
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
|
||||
{
|
||||
/* Determine space required by uniform buffer */
|
||||
std::vector<size_t> skinOffs;
|
||||
|
@ -311,22 +312,22 @@ CBooModel::ModelInstance* CBooModel::PushNewModelInstance()
|
|||
m_uniformDataSize = uniBufSize;
|
||||
newInst.m_uniformBuffer = ctx.newDynamicBuffer(boo::BufferUse::Uniform, uniBufSize, 1);
|
||||
|
||||
boo::IGraphicsBuffer* bufs[] = {newInst.m_uniformBuffer,
|
||||
newInst.m_uniformBuffer,
|
||||
newInst.m_uniformBuffer,
|
||||
newInst.m_uniformBuffer};
|
||||
boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {newInst.m_uniformBuffer.get(),
|
||||
newInst.m_uniformBuffer.get(),
|
||||
newInst.m_uniformBuffer.get(),
|
||||
newInst.m_uniformBuffer.get()};
|
||||
|
||||
/* Binding for each surface */
|
||||
newInst.m_shaderDataBindings.reserve(x0_surfaces->size());
|
||||
|
||||
boo::ITexture* mbShadowTexs[8] = {g_Renderer->m_ballShadowId,
|
||||
g_Renderer->x220_sphereRamp,
|
||||
g_Renderer->m_ballFade,
|
||||
g_Renderer->x220_sphereRamp,
|
||||
g_Renderer->x220_sphereRamp,
|
||||
g_Renderer->x220_sphereRamp,
|
||||
g_Renderer->x220_sphereRamp,
|
||||
g_Renderer->x220_sphereRamp};
|
||||
boo::ObjToken<boo::ITexture> mbShadowTexs[8] = {g_Renderer->m_ballShadowId.get(),
|
||||
g_Renderer->x220_sphereRamp.get(),
|
||||
g_Renderer->m_ballFade.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()};
|
||||
size_t thisOffs[4];
|
||||
size_t thisSizes[4];
|
||||
|
||||
|
@ -341,29 +342,29 @@ CBooModel::ModelInstance* CBooModel::PushNewModelInstance()
|
|||
{
|
||||
const MaterialSet::Material& mat = x4_matSet->materials.at(surf.m_data.matIdx);
|
||||
|
||||
boo::ITexture* texs[8] = {g_Renderer->x220_sphereRamp,
|
||||
g_Renderer->x220_sphereRamp,
|
||||
g_Renderer->x220_sphereRamp,
|
||||
g_Renderer->x220_sphereRamp,
|
||||
g_Renderer->x220_sphereRamp,
|
||||
g_Renderer->x220_sphereRamp,
|
||||
g_Renderer->x220_sphereRamp,
|
||||
g_Renderer->x220_sphereRamp};
|
||||
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;
|
||||
for (atUint32 idx : mat.textureIdxs)
|
||||
{
|
||||
if (boo::ITexture* overtex = m_txtrOverrides[texCount])
|
||||
if (boo::ObjToken<boo::ITexture> overtex = m_txtrOverrides[texCount])
|
||||
{
|
||||
texs[texCount++] = overtex;
|
||||
}
|
||||
else if (g_DummyTextures)
|
||||
{
|
||||
texs[texCount++] = g_Renderer->x220_sphereRamp;
|
||||
texs[texCount++] = g_Renderer->x220_sphereRamp.get();
|
||||
}
|
||||
else
|
||||
{
|
||||
TCachedToken<CTexture>& tex = x1c_textures[idx];
|
||||
if (boo::ITexture* btex = tex.GetObj()->GetBooTexture())
|
||||
if (boo::ObjToken<boo::ITexture> btex = tex.GetObj()->GetBooTexture())
|
||||
texs[texCount++] = btex;
|
||||
}
|
||||
}
|
||||
|
@ -389,9 +390,9 @@ CBooModel::ModelInstance* CBooModel::PushNewModelInstance()
|
|||
if (useReflection)
|
||||
{
|
||||
if (g_Renderer->x14c_reflectionTex)
|
||||
texs[texCount] = g_Renderer->x14c_reflectionTex;
|
||||
texs[texCount] = g_Renderer->x14c_reflectionTex.get();
|
||||
else
|
||||
texs[texCount] = g_Renderer->x220_sphereRamp;
|
||||
texs[texCount] = g_Renderer->x220_sphereRamp.get();
|
||||
thisOffs[3] = curReflect;
|
||||
curReflect += 256;
|
||||
}
|
||||
|
@ -404,16 +405,16 @@ CBooModel::ModelInstance* CBooModel::PushNewModelInstance()
|
|||
const std::shared_ptr<hecl::Runtime::ShaderPipelines>& pipelines = m_pipelines->at(surf.m_data.matIdx);
|
||||
|
||||
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());
|
||||
|
||||
int idx = 0;
|
||||
for (boo::IShaderPipeline* pipeline : pipelines->m_pipelines)
|
||||
for (const boo::ObjToken<boo::IShaderPipeline>& pipeline : pipelines->m_pipelines)
|
||||
{
|
||||
boo::ITexture** ltexs;
|
||||
boo::ObjToken<boo::ITexture>* ltexs;
|
||||
if (idx == EExtendedShader::Thermal)
|
||||
{
|
||||
texs[7] = g_Renderer->x220_sphereRamp;
|
||||
texs[7] = g_Renderer->x220_sphereRamp.get();
|
||||
ltexs = texs;
|
||||
}
|
||||
else if (idx == EExtendedShader::MorphBallShadow)
|
||||
|
@ -425,7 +426,7 @@ CBooModel::ModelInstance* CBooModel::PushNewModelInstance()
|
|||
if (g_shadowMap)
|
||||
texs[7] = g_shadowMap;
|
||||
else
|
||||
texs[7] = g_Renderer->x220_sphereRamp;
|
||||
texs[7] = g_Renderer->x220_sphereRamp.get();
|
||||
ltexs = texs;
|
||||
}
|
||||
else if (useReflection)
|
||||
|
@ -438,7 +439,7 @@ CBooModel::ModelInstance* CBooModel::PushNewModelInstance()
|
|||
}
|
||||
extendeds.push_back(
|
||||
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, 8, ltexs, nullptr, nullptr));
|
||||
++idx;
|
||||
}
|
||||
|
@ -613,8 +614,8 @@ void CBooModel::DrawSurface(const CBooSurface& surf, const CModelFlags& flags) c
|
|||
if (data.flags.shadowOccluderMesh() && !g_DrawingOccluders)
|
||||
return;
|
||||
|
||||
const std::vector<boo::IShaderDataBinding*>& extendeds = inst.m_shaderDataBindings[surf.selfIdx];
|
||||
boo::IShaderDataBinding* binding = extendeds[0];
|
||||
const std::vector<boo::ObjToken<boo::IShaderDataBinding>>& extendeds = inst.m_shaderDataBindings[surf.selfIdx];
|
||||
boo::ObjToken<boo::IShaderDataBinding> binding = extendeds[0];
|
||||
if (flags.m_extendedShader < extendeds.size())
|
||||
binding = extendeds[flags.m_extendedShader];
|
||||
|
||||
|
@ -842,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 CPoseAsTransforms* pose) const
|
||||
{
|
||||
|
@ -1057,7 +1058,7 @@ static const u8* MemoryFromPartData(const u8*& dataCur, const u32*& secSizeCur)
|
|||
}
|
||||
|
||||
std::unique_ptr<CBooModel> CModel::MakeNewInstance(int shaderIdx, int subInsts,
|
||||
boo::ITexture* txtrOverrides[8],
|
||||
const boo::ObjToken<boo::ITexture> txtrOverrides[8],
|
||||
bool lockParent)
|
||||
{
|
||||
if (shaderIdx >= x18_matSets.size())
|
||||
|
@ -1137,7 +1138,7 @@ CModel::CModel(std::unique_ptr<u8[]>&& in, u32 /* dataLen */, IObjectStore* stor
|
|||
for (CBooModel::SShader& matSet : x18_matSets)
|
||||
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 */
|
||||
if (m_hmdlMeta.indexCount)
|
||||
|
@ -1149,7 +1150,7 @@ CModel::CModel(std::unique_ptr<u8[]>&& in, u32 /* dataLen */, IObjectStore* stor
|
|||
if (m_hmdlMeta.vertCount)
|
||||
m_staticVbo = ctx.newStaticBuffer(boo::BufferUse::Vertex, vboData,
|
||||
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
|
||||
{
|
||||
|
@ -1258,7 +1259,7 @@ zeus::CVector3f CModel::GetPoolNormal(size_t idx) const
|
|||
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
|
||||
{
|
||||
u8* data = reinterpret_cast<u8*>(vertBuf->map(m_hmdlMeta.vertStride * m_hmdlMeta.vertCount));
|
||||
|
@ -1279,7 +1280,7 @@ void CModel::ApplyVerticesCPU(boo::IGraphicsBufferD* vertBuf,
|
|||
void CModel::_WarmupShaders()
|
||||
{
|
||||
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();
|
||||
zeus::CTransform backupViewPoint = CGraphics::g_ViewMatrix;
|
||||
zeus::CTransform backupModel = CGraphics::g_GXModelMatrix;
|
||||
|
|
|
@ -176,9 +176,8 @@ static const u16 StaticVolumeLookup[] =
|
|||
};
|
||||
|
||||
/* shared boo resources */
|
||||
static boo::GraphicsDataToken GraphicsData;
|
||||
static boo::IVertexFormat* YUVVTXFmt = nullptr;
|
||||
static boo::IShaderPipeline* YUVShaderPipeline = nullptr;
|
||||
static boo::ObjToken<boo::IVertexFormat> YUVVTXFmt;
|
||||
static boo::ObjToken<boo::IShaderPipeline> YUVShaderPipeline;
|
||||
static tjhandle TjHandle = nullptr;
|
||||
|
||||
/* RSF audio state */
|
||||
|
@ -199,7 +198,7 @@ static const char* TexNames[] = {"texY", "texU", "texV"};
|
|||
|
||||
void CMoviePlayer::Initialize()
|
||||
{
|
||||
GraphicsData = CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
|
||||
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
|
||||
{
|
||||
if (!ctx.bindingNeedsVertexFormat())
|
||||
{
|
||||
|
@ -231,7 +230,7 @@ void CMoviePlayer::Initialize()
|
|||
#if BOO_HAS_METAL
|
||||
case boo::IGraphicsDataFactory::Platform::Metal:
|
||||
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::Primitive::TriStrips, boo::ZTest::None, false, true, false, boo::CullMode::None);
|
||||
break;
|
||||
|
@ -254,7 +253,8 @@ void CMoviePlayer::Initialize()
|
|||
|
||||
void CMoviePlayer::Shutdown()
|
||||
{
|
||||
GraphicsData.doDestroy();
|
||||
YUVVTXFmt.reset();
|
||||
YUVShaderPipeline.reset();
|
||||
tjDestroy(TjHandle);
|
||||
}
|
||||
|
||||
|
@ -424,18 +424,18 @@ CMoviePlayer::CMoviePlayer(const char* path, float preLoadSeconds, bool loop, bo
|
|||
xa0_bufferQueue.reserve(xf0_preLoadFrames);
|
||||
|
||||
/* 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_vertBuf = ctx.newDynamicBuffer(boo::BufferUse::Vertex, sizeof(specter::View::TexShaderVert), 4);
|
||||
|
||||
boo::IVertexFormat* vtxFmt = YUVVTXFmt;
|
||||
boo::ObjToken<boo::IVertexFormat> vtxFmt = YUVVTXFmt;
|
||||
if (ctx.bindingNeedsVertexFormat())
|
||||
{
|
||||
boo::VertexElementDescriptor texvdescs[] =
|
||||
{
|
||||
{m_vertBuf, nullptr, boo::VertexSemantic::Position4},
|
||||
{m_vertBuf, nullptr, boo::VertexSemantic::UV4}
|
||||
{m_vertBuf.get(), nullptr, boo::VertexSemantic::Position4},
|
||||
{m_vertBuf.get(), nullptr, boo::VertexSemantic::UV4}
|
||||
};
|
||||
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,
|
||||
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)
|
||||
{
|
||||
boo::ITexture* texs[] = {set.Y[j], set.U, set.V};
|
||||
set.binding[j] = ctx.newShaderDataBinding(YUVShaderPipeline, vtxFmt, m_vertBuf,
|
||||
boo::ObjToken<boo::ITexture> texs[] = {set.Y[j].get(), set.U.get(), set.V.get()};
|
||||
set.binding[j] = ctx.newShaderDataBinding(YUVShaderPipeline, vtxFmt, m_vertBuf.get(),
|
||||
nullptr, nullptr, 1, bufs, 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,
|
||||
boo::TextureFormat::I8, boo::TextureClampMode::Repeat);
|
||||
|
||||
boo::IGraphicsBuffer* bufs[] = {m_blockBuf};
|
||||
boo::ITexture* texs[] = {set.Y[0], set.U, set.V};
|
||||
set.binding[0] = ctx.newShaderDataBinding(YUVShaderPipeline, vtxFmt, m_vertBuf,
|
||||
boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {m_blockBuf.get()};
|
||||
boo::ObjToken<boo::ITexture> texs[] = {set.Y[0].get(), set.U.get(), set.V.get()};
|
||||
set.binding[0] = ctx.newShaderDataBinding(YUVShaderPipeline, vtxFmt, m_vertBuf.get(),
|
||||
nullptr, nullptr, 1, bufs, nullptr,
|
||||
3, texs, nullptr, nullptr);
|
||||
}
|
||||
|
@ -686,9 +686,9 @@ void CMoviePlayer::DrawFrame()
|
|||
|
||||
/* draw appropriate field */
|
||||
CTHPTextureSet& tex = x80_textures[xd0_drawTexSlot];
|
||||
CGraphics::g_BooMainCommandQueue->setShaderDataBinding
|
||||
CGraphics::SetShaderDataBinding
|
||||
(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
|
||||
* (faked in urde with continuous xor) */
|
||||
|
|
|
@ -83,13 +83,13 @@ private:
|
|||
|
||||
struct CTHPTextureSet
|
||||
{
|
||||
boo::ITextureD* Y[2] = {};
|
||||
boo::ITextureD* U = nullptr;
|
||||
boo::ITextureD* V = nullptr;
|
||||
boo::ObjToken<boo::ITextureD> Y[2];
|
||||
boo::ObjToken<boo::ITextureD> U;
|
||||
boo::ObjToken<boo::ITextureD> V;
|
||||
u32 playedSamples = 0;
|
||||
u32 audioSamples = 0;
|
||||
std::unique_ptr<s16[]> audioBuf;
|
||||
boo::IShaderDataBinding* binding[2] = {};
|
||||
boo::ObjToken<boo::IShaderDataBinding> binding[2];
|
||||
};
|
||||
std::vector<CTHPTextureSet> x80_textures;
|
||||
std::unique_ptr<uint8_t[]> x90_requestBuf;
|
||||
|
@ -116,7 +116,6 @@ private:
|
|||
u32 xf8_ = 0;
|
||||
u32 xfc_fieldIndex = 0;
|
||||
|
||||
boo::GraphicsDataToken m_token;
|
||||
std::unique_ptr<uint8_t[]> m_yuvBuf;
|
||||
|
||||
union
|
||||
|
@ -130,8 +129,8 @@ private:
|
|||
};
|
||||
|
||||
specter::View::ViewBlock m_viewVertBlock;
|
||||
boo::IGraphicsBufferD* m_blockBuf;
|
||||
boo::IGraphicsBufferD* m_vertBuf;
|
||||
boo::ObjToken<boo::IGraphicsBufferD> m_blockBuf;
|
||||
boo::ObjToken<boo::IGraphicsBufferD> m_vertBuf;
|
||||
|
||||
specter::View::TexShaderVert m_frame[4];
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ CRainSplashGenerator::CRainSplashGenerator(const zeus::CVector3f& scale, u32 max
|
|||
x48_24 = false;
|
||||
x48_25_raining = true;
|
||||
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)
|
||||
x0_rainSplashes.emplace_back(ctx);
|
||||
|
|
|
@ -58,7 +58,6 @@ class CRainSplashGenerator
|
|||
u32 x44_genRate;
|
||||
bool x48_24 : 1;
|
||||
bool x48_25_raining : 1;
|
||||
boo::GraphicsDataToken m_gfxTok;
|
||||
void UpdateRainSplashRange(CStateManager& mgr, int start, int end, float dt);
|
||||
void UpdateRainSplashes(CStateManager& mgr, float magnitude, float dt);
|
||||
void DoDraw(const zeus::CTransform& xf) const;
|
||||
|
|
|
@ -38,7 +38,7 @@ void CSkinnedModel::Calculate(const CPoseAsTransforms& pose,
|
|||
{
|
||||
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);
|
||||
if (morphEffect)
|
||||
morphEffect->MorphVertices(m_vertWorkspace, morphMagnitudes, x10_skinRules, pose);
|
||||
|
|
|
@ -31,9 +31,8 @@ private:
|
|||
u16 x4_w;
|
||||
u16 x6_h;
|
||||
u32 x8_mips;
|
||||
boo::GraphicsDataToken m_booToken;
|
||||
boo::ITexture* m_booTex;
|
||||
boo::ITexture* m_paletteTex;
|
||||
boo::ObjToken<boo::ITexture> m_booTex;
|
||||
boo::ObjToken<boo::ITexture> m_paletteTex;
|
||||
std::unique_ptr<u8[]> m_otex;
|
||||
EFontType m_ftype = EFontType::None;
|
||||
|
||||
|
@ -69,11 +68,11 @@ public:
|
|||
u16 GetHeight() const {return x6_h;}
|
||||
u32 GetNumMips() const {return x8_mips;}
|
||||
void Load(int slot, EClampMode clamp) const;
|
||||
boo::ITexture* GetBooTexture() const {return m_booTex;}
|
||||
boo::ITexture* GetPaletteTexture() const {return m_paletteTex;}
|
||||
const boo::ObjToken<boo::ITexture>& GetBooTexture() const {return m_booTex;}
|
||||
const boo::ObjToken<boo::ITexture>& GetPaletteTexture() const {return m_paletteTex;}
|
||||
std::unique_ptr<u8[]> BuildMemoryCardTex(u32& sizeOut, ETexelFormat& fmtOut,
|
||||
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,
|
||||
|
|
|
@ -112,10 +112,10 @@ void CTexture::BuildI4FromGCN(CInputStream& in)
|
|||
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,
|
||||
boo::TextureClampMode::Repeat, buf.get(), texelCount * 4);
|
||||
boo::TextureClampMode::Repeat, buf.get(), texelCount * 4).get();
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
@ -160,10 +160,10 @@ void CTexture::BuildI8FromGCN(CInputStream& in)
|
|||
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,
|
||||
boo::TextureClampMode::Repeat, buf.get(), texelCount * 4);
|
||||
boo::TextureClampMode::Repeat, buf.get(), texelCount * 4).get();
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
@ -209,10 +209,10 @@ void CTexture::BuildIA4FromGCN(CInputStream& in)
|
|||
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,
|
||||
boo::TextureClampMode::Repeat, buf.get(), texelCount * 4);
|
||||
boo::TextureClampMode::Repeat, buf.get(), texelCount * 4).get();
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
@ -258,10 +258,10 @@ void CTexture::BuildIA8FromGCN(CInputStream& in)
|
|||
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,
|
||||
boo::TextureClampMode::Repeat, buf.get(), texelCount * 4);
|
||||
boo::TextureClampMode::Repeat, buf.get(), texelCount * 4).get();
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
@ -366,10 +366,10 @@ void CTexture::BuildC4FromGCN(CInputStream& in)
|
|||
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,
|
||||
boo::TextureClampMode::Repeat, buf.get(), texelCount * 4);
|
||||
boo::TextureClampMode::Repeat, buf.get(), texelCount * 4).get();
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
@ -410,10 +410,10 @@ void CTexture::BuildC8FromGCN(CInputStream& in)
|
|||
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,
|
||||
boo::TextureClampMode::Repeat, buf.get(), texelCount * 4);
|
||||
boo::TextureClampMode::Repeat, buf.get(), texelCount * 4).get();
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
@ -462,10 +462,10 @@ void CTexture::BuildRGB565FromGCN(CInputStream& in)
|
|||
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,
|
||||
boo::TextureClampMode::Repeat, buf.get(), texelCount * 4);
|
||||
boo::TextureClampMode::Repeat, buf.get(), texelCount * 4).get();
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
@ -519,10 +519,10 @@ void CTexture::BuildRGB5A3FromGCN(CInputStream& in)
|
|||
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,
|
||||
boo::TextureClampMode::Repeat, buf.get(), texelCount * 4);
|
||||
boo::TextureClampMode::Repeat, buf.get(), texelCount * 4).get();
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
@ -576,10 +576,10 @@ void CTexture::BuildRGBA8FromGCN(CInputStream& in)
|
|||
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,
|
||||
boo::TextureClampMode::Repeat, buf.get(), texelCount * 4);
|
||||
boo::TextureClampMode::Repeat, buf.get(), texelCount * 4).get();
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
@ -640,10 +640,10 @@ void CTexture::BuildDXT1FromGCN(CInputStream& in)
|
|||
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,
|
||||
boo::TextureClampMode::Repeat, buf.get(), blockCount * 8);
|
||||
boo::TextureClampMode::Repeat, buf.get(), blockCount * 8).get();
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
@ -656,10 +656,10 @@ void CTexture::BuildRGBA8(const void* data, size_t length)
|
|||
Log.report(logvisor::Fatal, "insufficient TXTR length (%" PRISize "/%" PRISize ")",
|
||||
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,
|
||||
boo::TextureClampMode::Repeat, data, expectedSize);
|
||||
boo::TextureClampMode::Repeat, data, expectedSize).get();
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
@ -671,15 +671,15 @@ void CTexture::BuildC8(const void* data, size_t length)
|
|||
Log.report(logvisor::Fatal, "insufficient TXTR length (%" PRISize "/%" PRISize ")",
|
||||
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));
|
||||
const u8* paletteTexels = reinterpret_cast<const u8*>(data) + 4;
|
||||
const u8* texels = reinterpret_cast<const u8*>(data) + 4 + nentries * 4;
|
||||
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,
|
||||
boo::TextureClampMode::Repeat, texels, texelCount);
|
||||
boo::TextureClampMode::Repeat, texels, texelCount).get();
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
@ -778,10 +778,10 @@ void CTexture::BuildC8Font(const void* data, EFontType ftype)
|
|||
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,
|
||||
boo::TextureClampMode::Repeat, buf.get(), texelCount * layerCount * 4);
|
||||
boo::TextureClampMode::Repeat, buf.get(), texelCount * layerCount * 4).get();
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
@ -977,7 +977,7 @@ std::unique_ptr<u8[]> CTexture::BuildMemoryCardTex(u32& sizeOut, ETexelFormat& f
|
|||
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)
|
||||
{
|
||||
|
|
|
@ -6,7 +6,7 @@ namespace urde
|
|||
CAABoxShader::CAABoxShader(bool 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_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_uniBuf->load(&m_uniform, sizeof(Uniform));
|
||||
|
||||
CGraphics::g_BooMainCommandQueue->setShaderDataBinding(m_dataBind);
|
||||
CGraphics::g_BooMainCommandQueue->draw(0, 34);
|
||||
CGraphics::SetShaderDataBinding(m_dataBind);
|
||||
CGraphics::DrawArray(0, 34);
|
||||
}
|
||||
|
||||
void CAABoxShader::Shutdown() {}
|
||||
|
||||
URDE_SPECIALIZE_SHADER(CAABoxShader)
|
||||
|
||||
}
|
||||
|
|
|
@ -21,10 +21,9 @@ class CAABoxShader
|
|||
zeus::CMatrix4f m_xf;
|
||||
zeus::CColor m_color;
|
||||
};
|
||||
boo::GraphicsDataToken m_token;
|
||||
boo::IGraphicsBufferD* m_vbo;
|
||||
boo::IGraphicsBufferD* m_uniBuf;
|
||||
boo::IShaderDataBinding* m_dataBind = nullptr;
|
||||
boo::ObjToken<boo::IGraphicsBufferD> m_vbo;
|
||||
boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf;
|
||||
boo::ObjToken<boo::IShaderDataBinding> m_dataBind;
|
||||
Uniform m_uniform;
|
||||
bool m_zOnly;
|
||||
|
||||
|
|
|
@ -44,25 +44,25 @@ BOO_GLSL_BINDING_HEAD
|
|||
|
||||
URDE_DECL_SPECIALIZE_SHADER(CAABoxShader)
|
||||
|
||||
static boo::IVertexFormat* s_VtxFmt = nullptr;
|
||||
static boo::IShaderPipeline* s_Pipeline = nullptr;
|
||||
static boo::IShaderPipeline* s_zOnlyPipeline = nullptr;
|
||||
static boo::ObjToken<boo::IVertexFormat> s_VtxFmt;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_Pipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_zOnlyPipeline;
|
||||
|
||||
struct CAABoxShaderGLDataBindingFactory : TShader<CAABoxShader>::IDataBindingFactory
|
||||
{
|
||||
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
CAABoxShader& filter)
|
||||
{
|
||||
boo::GLDataFactory::Context& cctx = static_cast<boo::GLDataFactory::Context&>(ctx);
|
||||
|
||||
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};
|
||||
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);
|
||||
}
|
||||
};
|
||||
|
@ -95,6 +95,13 @@ TShader<CAABoxShader>::IDataBindingFactory* CAABoxShader::Initialize(boo::GLData
|
|||
return new CAABoxShaderGLDataBindingFactory;
|
||||
}
|
||||
|
||||
template <>
|
||||
void CAABoxShader::Shutdown<boo::GLDataFactory>()
|
||||
{
|
||||
s_Pipeline.reset();
|
||||
s_zOnlyPipeline.reset();
|
||||
}
|
||||
|
||||
#if BOO_HAS_VULKAN
|
||||
TShader<CAABoxShader>::IDataBindingFactory* CAABoxShader::Initialize(boo::VulkanDataFactory::Context& ctx)
|
||||
{
|
||||
|
|
|
@ -48,20 +48,20 @@ static const char* FS =
|
|||
|
||||
URDE_DECL_SPECIALIZE_SHADER(CAABoxShader)
|
||||
|
||||
static boo::IVertexFormat* s_VtxFmt = nullptr;
|
||||
static boo::IShaderPipeline* s_Pipeline = nullptr;
|
||||
static boo::IShaderPipeline* s_zOnlyPipeline = nullptr;
|
||||
static boo::ObjToken<boo::IVertexFormat> s_VtxFmt;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_Pipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_zOnlyPipeline;
|
||||
|
||||
struct CAABoxShaderMetalDataBindingFactory : TShader<CAABoxShader>::IDataBindingFactory
|
||||
{
|
||||
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
CAABoxShader& filter)
|
||||
{
|
||||
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,
|
||||
filter.m_vbo, nullptr, nullptr, 1, bufs,
|
||||
filter.m_vbo.get(), nullptr, nullptr, 1, bufs,
|
||||
nullptr, nullptr, nullptr, 0, nullptr, nullptr, nullptr);
|
||||
}
|
||||
};
|
||||
|
@ -73,13 +73,23 @@ TShader<CAABoxShader>::IDataBindingFactory* CAABoxShader::Initialize(boo::MetalD
|
|||
{nullptr, nullptr, boo::VertexSemantic::Position4},
|
||||
};
|
||||
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::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::ZTest::LEqual, true, false, false, boo::CullMode::None);
|
||||
return new CAABoxShaderMetalDataBindingFactory;
|
||||
}
|
||||
|
||||
template <>
|
||||
void CAABoxShader::Shutdown<boo::MetalDataFactory>()
|
||||
{
|
||||
s_VtxFmt.reset();
|
||||
s_Pipeline.reset();
|
||||
s_zOnlyPipeline.reset();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ namespace urde
|
|||
|
||||
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_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_uniBuf->load(&m_uniform, sizeof(m_uniform));
|
||||
|
||||
CGraphics::g_BooMainCommandQueue->setShaderDataBinding(m_dataBind);
|
||||
CGraphics::g_BooMainCommandQueue->draw(0, 4);
|
||||
CGraphics::SetShaderDataBinding(m_dataBind);
|
||||
CGraphics::DrawArray(0, 4);
|
||||
}
|
||||
|
||||
void CCameraBlurFilter::Shutdown() {}
|
||||
|
||||
URDE_SPECIALIZE_SHADER(CCameraBlurFilter)
|
||||
|
||||
}
|
||||
|
|
|
@ -26,10 +26,9 @@ class CCameraBlurFilter
|
|||
zeus::CVector4f m_uv[6];
|
||||
float m_opacity = 1.f;
|
||||
};
|
||||
boo::GraphicsDataToken m_token;
|
||||
boo::IGraphicsBufferD* m_vbo;
|
||||
boo::IGraphicsBufferD* m_uniBuf;
|
||||
boo::IShaderDataBinding* m_dataBind = nullptr;
|
||||
boo::ObjToken<boo::IGraphicsBufferD> m_vbo;
|
||||
boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf;
|
||||
boo::ObjToken<boo::IShaderDataBinding> m_dataBind;
|
||||
Uniform m_uniform;
|
||||
|
||||
public:
|
||||
|
|
|
@ -79,26 +79,26 @@ BOO_GLSL_BINDING_HEAD
|
|||
|
||||
URDE_DECL_SPECIALIZE_SHADER(CCameraBlurFilter)
|
||||
|
||||
static boo::IVertexFormat* s_VtxFmt = nullptr;
|
||||
static boo::IShaderPipeline* s_Pipeline = nullptr;
|
||||
static boo::ObjToken<boo::IVertexFormat> s_VtxFmt;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_Pipeline;
|
||||
|
||||
struct CCameraBlurFilterGLDataBindingFactory : TShader<CCameraBlurFilter>::IDataBindingFactory
|
||||
{
|
||||
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
CCameraBlurFilter& filter)
|
||||
{
|
||||
boo::GLDataFactory::Context& cctx = static_cast<boo::GLDataFactory::Context&>(ctx);
|
||||
|
||||
const boo::VertexElementDescriptor VtxVmt[] =
|
||||
{
|
||||
{filter.m_vbo, nullptr, boo::VertexSemantic::Position4},
|
||||
{filter.m_vbo, nullptr, boo::VertexSemantic::UV4}
|
||||
{filter.m_vbo.get(), nullptr, boo::VertexSemantic::Position4},
|
||||
{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::ITexture* texs[] = {CGraphics::g_SpareTexture};
|
||||
boo::ObjToken<boo::ITexture> texs[] = {CGraphics::g_SpareTexture.get()};
|
||||
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);
|
||||
}
|
||||
};
|
||||
|
@ -130,6 +130,12 @@ TShader<CCameraBlurFilter>::IDataBindingFactory* CCameraBlurFilter::Initialize(b
|
|||
return new CCameraBlurFilterGLDataBindingFactory;
|
||||
}
|
||||
|
||||
template <>
|
||||
void CCameraBlurFilter::Shutdown<boo::GLDataFactory>()
|
||||
{
|
||||
s_Pipeline.reset();
|
||||
}
|
||||
|
||||
#if BOO_HAS_VULKAN
|
||||
TShader<CCameraBlurFilter>::IDataBindingFactory* CCameraBlurFilter::Initialize(boo::VulkanDataFactory::Context& ctx)
|
||||
{
|
||||
|
|
|
@ -90,20 +90,20 @@ static const char* FS =
|
|||
|
||||
URDE_DECL_SPECIALIZE_SHADER(CCameraBlurFilter)
|
||||
|
||||
static boo::IVertexFormat* s_VtxFmt = nullptr;
|
||||
static boo::IShaderPipeline* s_Pipeline = nullptr;
|
||||
static boo::ObjToken<boo::IVertexFormat> s_VtxFmt;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_Pipeline;
|
||||
|
||||
struct CCameraBlurFilterMetalDataBindingFactory : TShader<CCameraBlurFilter>::IDataBindingFactory
|
||||
{
|
||||
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
CCameraBlurFilter& filter)
|
||||
{
|
||||
boo::MetalDataFactory::Context& cctx = static_cast<boo::MetalDataFactory::Context&>(ctx);
|
||||
|
||||
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf};
|
||||
boo::ITexture* texs[] = {CGraphics::g_SpareTexture};
|
||||
boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {filter.m_uniBuf.get()};
|
||||
boo::ObjToken<boo::ITexture> texs[] = {CGraphics::g_SpareTexture.get()};
|
||||
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);
|
||||
}
|
||||
};
|
||||
|
@ -116,10 +116,18 @@ TShader<CCameraBlurFilter>::IDataBindingFactory* CCameraBlurFilter::Initialize(b
|
|||
{nullptr, nullptr, boo::VertexSemantic::UV4}
|
||||
};
|
||||
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::ZTest::None, false, true, true, boo::CullMode::None);
|
||||
return new CCameraBlurFilterMetalDataBindingFactory;
|
||||
}
|
||||
|
||||
template <>
|
||||
void CCameraBlurFilter::Shutdown<boo::MetalDataFactory>()
|
||||
{
|
||||
s_VtxFmt.reset();
|
||||
s_Pipeline.reset();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ namespace urde
|
|||
|
||||
CColoredQuadFilter::CColoredQuadFilter(EFilterType type)
|
||||
{
|
||||
m_token = CGraphics::g_BooFactory->commitTransaction([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
|
||||
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
|
||||
{
|
||||
struct Vert
|
||||
{
|
||||
|
@ -88,8 +88,6 @@ void CWideScreenFilter::SetViewportToFull()
|
|||
CGraphics::g_BooMainCommandQueue->setViewport(rect);
|
||||
}
|
||||
|
||||
void CColoredQuadFilter::Shutdown() {}
|
||||
|
||||
const zeus::CRectangle CColoredQuadFilter::DefaultRect = {0.f, 0.f, 1.f, 1.f};
|
||||
|
||||
URDE_SPECIALIZE_MULTI_BLEND_SHADER(CColoredQuadFilter)
|
||||
|
|
|
@ -22,10 +22,9 @@ class CColoredQuadFilter
|
|||
zeus::CMatrix4f m_matrix;
|
||||
zeus::CColor m_color;
|
||||
};
|
||||
boo::GraphicsDataToken m_token;
|
||||
boo::IGraphicsBufferS* m_vbo;
|
||||
boo::IGraphicsBufferD* m_uniBuf;
|
||||
boo::IShaderDataBinding* m_dataBind = nullptr;
|
||||
boo::ObjToken<boo::IGraphicsBufferS> m_vbo;
|
||||
boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf;
|
||||
boo::ObjToken<boo::IShaderDataBinding> m_dataBind;
|
||||
Uniform m_uniform;
|
||||
|
||||
public:
|
||||
|
|
|
@ -43,12 +43,12 @@ BOO_GLSL_BINDING_HEAD
|
|||
|
||||
URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(CColoredQuadFilter)
|
||||
|
||||
static boo::IVertexFormat* s_VtxFmt = nullptr;
|
||||
static boo::IShaderPipeline* s_AlphaPipeline = nullptr;
|
||||
static boo::IShaderPipeline* s_AddPipeline = nullptr;
|
||||
static boo::IShaderPipeline* s_MultPipeline = nullptr;
|
||||
static boo::ObjToken<boo::IVertexFormat> s_VtxFmt;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_AlphaPipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_AddPipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_MultPipeline;
|
||||
|
||||
static boo::IShaderPipeline* SelectPipeline(EFilterType type)
|
||||
static boo::ObjToken<boo::IShaderPipeline> SelectPipeline(EFilterType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
|
@ -59,26 +59,25 @@ static boo::IShaderPipeline* SelectPipeline(EFilterType type)
|
|||
case EFilterType::Multiply:
|
||||
return s_MultPipeline;
|
||||
default:
|
||||
return nullptr;
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
struct CColoredQuadFilterGLDataBindingFactory : TMultiBlendShader<CColoredQuadFilter>::IDataBindingFactory
|
||||
{
|
||||
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
EFilterType type,
|
||||
CColoredQuadFilter& filter)
|
||||
boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
EFilterType type, CColoredQuadFilter& filter)
|
||||
{
|
||||
boo::GLDataFactory::Context& cctx = static_cast<boo::GLDataFactory::Context&>(ctx);
|
||||
|
||||
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};
|
||||
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);
|
||||
}
|
||||
};
|
||||
|
@ -116,6 +115,14 @@ CColoredQuadFilter::Initialize(boo::GLDataFactory::Context& ctx)
|
|||
return new CColoredQuadFilterGLDataBindingFactory;
|
||||
}
|
||||
|
||||
template <>
|
||||
void CColoredQuadFilter::Shutdown<boo::GLDataFactory>()
|
||||
{
|
||||
s_AlphaPipeline.reset();
|
||||
s_AddPipeline.reset();
|
||||
s_MultPipeline.reset();
|
||||
}
|
||||
|
||||
#if BOO_HAS_VULKAN
|
||||
TMultiBlendShader<CColoredQuadFilter>::IDataBindingFactory*
|
||||
CColoredQuadFilter::Initialize(boo::VulkanDataFactory::Context& ctx)
|
||||
|
|
|
@ -47,12 +47,12 @@ static const char* FS =
|
|||
|
||||
URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(CColoredQuadFilter)
|
||||
|
||||
static boo::IVertexFormat* s_VtxFmt = nullptr;
|
||||
static boo::IShaderPipeline* s_AlphaPipeline = nullptr;
|
||||
static boo::IShaderPipeline* s_AddPipeline = nullptr;
|
||||
static boo::IShaderPipeline* s_MultPipeline = nullptr;
|
||||
static boo::ObjToken<boo::IVertexFormat> s_VtxFmt;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_AlphaPipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_AddPipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_MultPipeline;
|
||||
|
||||
static boo::IShaderPipeline* SelectPipeline(EFilterType type)
|
||||
static boo::ObjToken<boo::IShaderPipeline> SelectPipeline(EFilterType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
|
@ -63,21 +63,20 @@ static boo::IShaderPipeline* SelectPipeline(EFilterType type)
|
|||
case EFilterType::Multiply:
|
||||
return s_MultPipeline;
|
||||
default:
|
||||
return nullptr;
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
struct CColoredQuadFilterMetalDataBindingFactory : TMultiBlendShader<CColoredQuadFilter>::IDataBindingFactory
|
||||
{
|
||||
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
EFilterType type,
|
||||
CColoredQuadFilter& filter)
|
||||
boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
EFilterType type, CColoredQuadFilter& filter)
|
||||
{
|
||||
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,
|
||||
filter.m_vbo, nullptr, nullptr, 1, bufs,
|
||||
filter.m_vbo.get(), nullptr, nullptr, 1, bufs,
|
||||
nullptr, nullptr, nullptr, 0, nullptr, nullptr, nullptr);
|
||||
}
|
||||
};
|
||||
|
@ -90,16 +89,28 @@ CColoredQuadFilter::Initialize(boo::MetalDataFactory::Context& ctx)
|
|||
{nullptr, nullptr, boo::VertexSemantic::Position4}
|
||||
};
|
||||
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::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::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::ZTest::None, false, true, true, boo::CullMode::None);
|
||||
return new CColoredQuadFilterMetalDataBindingFactory;
|
||||
}
|
||||
|
||||
template <>
|
||||
void CColoredQuadFilter::Shutdown<boo::MetalDataFactory>()
|
||||
{
|
||||
s_VtxFmt.reset();
|
||||
s_AlphaPipeline.reset();
|
||||
s_AddPipeline.reset();
|
||||
s_MultPipeline.reset();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,37 +4,37 @@
|
|||
namespace urde
|
||||
{
|
||||
|
||||
boo::IShaderPipeline* CElementGenShaders::m_texZTestZWrite = nullptr;
|
||||
boo::IShaderPipeline* CElementGenShaders::m_texNoZTestZWrite = nullptr;
|
||||
boo::IShaderPipeline* CElementGenShaders::m_texZTestNoZWrite = nullptr;
|
||||
boo::IShaderPipeline* CElementGenShaders::m_texNoZTestNoZWrite = nullptr;
|
||||
boo::IShaderPipeline* CElementGenShaders::m_texAdditiveZTest = nullptr;
|
||||
boo::IShaderPipeline* CElementGenShaders::m_texAdditiveNoZTest = nullptr;
|
||||
boo::IShaderPipeline* CElementGenShaders::m_texRedToAlphaZTest = nullptr;
|
||||
boo::IShaderPipeline* CElementGenShaders::m_texRedToAlphaNoZTest = nullptr;
|
||||
boo::IShaderPipeline* CElementGenShaders::m_texZTestNoZWriteSub = nullptr;
|
||||
boo::IShaderPipeline* CElementGenShaders::m_texNoZTestNoZWriteSub = nullptr;
|
||||
boo::IShaderPipeline* CElementGenShaders::m_texRedToAlphaZTestSub = nullptr;
|
||||
boo::IShaderPipeline* CElementGenShaders::m_texRedToAlphaNoZTestSub = nullptr;
|
||||
boo::ObjToken<boo::IShaderPipeline> CElementGenShaders::m_texZTestZWrite;
|
||||
boo::ObjToken<boo::IShaderPipeline> CElementGenShaders::m_texNoZTestZWrite;
|
||||
boo::ObjToken<boo::IShaderPipeline> CElementGenShaders::m_texZTestNoZWrite;
|
||||
boo::ObjToken<boo::IShaderPipeline> CElementGenShaders::m_texNoZTestNoZWrite;
|
||||
boo::ObjToken<boo::IShaderPipeline> CElementGenShaders::m_texAdditiveZTest;
|
||||
boo::ObjToken<boo::IShaderPipeline> CElementGenShaders::m_texAdditiveNoZTest;
|
||||
boo::ObjToken<boo::IShaderPipeline> CElementGenShaders::m_texRedToAlphaZTest;
|
||||
boo::ObjToken<boo::IShaderPipeline> CElementGenShaders::m_texRedToAlphaNoZTest;
|
||||
boo::ObjToken<boo::IShaderPipeline> CElementGenShaders::m_texZTestNoZWriteSub;
|
||||
boo::ObjToken<boo::IShaderPipeline> CElementGenShaders::m_texNoZTestNoZWriteSub;
|
||||
boo::ObjToken<boo::IShaderPipeline> CElementGenShaders::m_texRedToAlphaZTestSub;
|
||||
boo::ObjToken<boo::IShaderPipeline> CElementGenShaders::m_texRedToAlphaNoZTestSub;
|
||||
|
||||
boo::IShaderPipeline* CElementGenShaders::m_indTexZWrite = nullptr;
|
||||
boo::IShaderPipeline* CElementGenShaders::m_indTexNoZWrite = nullptr;
|
||||
boo::IShaderPipeline* CElementGenShaders::m_indTexAdditive = nullptr;
|
||||
boo::ObjToken<boo::IShaderPipeline> CElementGenShaders::m_indTexZWrite;
|
||||
boo::ObjToken<boo::IShaderPipeline> CElementGenShaders::m_indTexNoZWrite;
|
||||
boo::ObjToken<boo::IShaderPipeline> CElementGenShaders::m_indTexAdditive;
|
||||
|
||||
boo::IShaderPipeline* CElementGenShaders::m_cindTexZWrite = nullptr;
|
||||
boo::IShaderPipeline* CElementGenShaders::m_cindTexNoZWrite = nullptr;
|
||||
boo::IShaderPipeline* CElementGenShaders::m_cindTexAdditive = nullptr;
|
||||
boo::ObjToken<boo::IShaderPipeline> CElementGenShaders::m_cindTexZWrite;
|
||||
boo::ObjToken<boo::IShaderPipeline> CElementGenShaders::m_cindTexNoZWrite;
|
||||
boo::ObjToken<boo::IShaderPipeline> CElementGenShaders::m_cindTexAdditive;
|
||||
|
||||
boo::IShaderPipeline* CElementGenShaders::m_noTexZTestZWrite = nullptr;
|
||||
boo::IShaderPipeline* CElementGenShaders::m_noTexNoZTestZWrite = nullptr;
|
||||
boo::IShaderPipeline* CElementGenShaders::m_noTexZTestNoZWrite = nullptr;
|
||||
boo::IShaderPipeline* CElementGenShaders::m_noTexNoZTestNoZWrite = nullptr;
|
||||
boo::IShaderPipeline* CElementGenShaders::m_noTexAdditiveZTest = nullptr;
|
||||
boo::IShaderPipeline* CElementGenShaders::m_noTexAdditiveNoZTest = nullptr;
|
||||
boo::ObjToken<boo::IShaderPipeline> CElementGenShaders::m_noTexZTestZWrite;
|
||||
boo::ObjToken<boo::IShaderPipeline> CElementGenShaders::m_noTexNoZTestZWrite;
|
||||
boo::ObjToken<boo::IShaderPipeline> CElementGenShaders::m_noTexZTestNoZWrite;
|
||||
boo::ObjToken<boo::IShaderPipeline> CElementGenShaders::m_noTexNoZTestNoZWrite;
|
||||
boo::ObjToken<boo::IShaderPipeline> CElementGenShaders::m_noTexAdditiveZTest;
|
||||
boo::ObjToken<boo::IShaderPipeline> CElementGenShaders::m_noTexAdditiveNoZTest;
|
||||
|
||||
boo::IVertexFormat* CElementGenShaders::m_vtxFormatTex = nullptr;
|
||||
boo::IVertexFormat* CElementGenShaders::m_vtxFormatIndTex = nullptr;
|
||||
boo::IVertexFormat* CElementGenShaders::m_vtxFormatNoTex = nullptr;
|
||||
boo::ObjToken<boo::IVertexFormat> CElementGenShaders::m_vtxFormatTex;
|
||||
boo::ObjToken<boo::IVertexFormat> CElementGenShaders::m_vtxFormatIndTex;
|
||||
boo::ObjToken<boo::IVertexFormat> CElementGenShaders::m_vtxFormatNoTex;
|
||||
|
||||
CElementGenShaders::EShaderClass CElementGenShaders::GetShaderClass(CElementGen& gen)
|
||||
{
|
||||
|
@ -54,12 +54,12 @@ CElementGenShaders::EShaderClass CElementGenShaders::GetShaderClass(CElementGen&
|
|||
void CElementGenShaders::BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, CElementGen& gen)
|
||||
{
|
||||
CGenDescription* desc = gen.x1c_genDesc.GetObj();
|
||||
boo::IShaderPipeline* regPipeline = nullptr;
|
||||
boo::IShaderPipeline* regPipelineSub = nullptr;
|
||||
boo::IShaderPipeline* redToAlphaPipeline = nullptr;
|
||||
boo::IShaderPipeline* redToAlphaPipelineSub = nullptr;
|
||||
boo::IShaderPipeline* regPipelinePmus = nullptr;
|
||||
boo::IShaderPipeline* redToAlphaPipelinePmus = nullptr;
|
||||
boo::ObjToken<boo::IShaderPipeline> regPipeline;
|
||||
boo::ObjToken<boo::IShaderPipeline> regPipelineSub;
|
||||
boo::ObjToken<boo::IShaderPipeline> redToAlphaPipeline;
|
||||
boo::ObjToken<boo::IShaderPipeline> redToAlphaPipelineSub;
|
||||
boo::ObjToken<boo::IShaderPipeline> regPipelinePmus;
|
||||
boo::ObjToken<boo::IShaderPipeline> redToAlphaPipelinePmus;
|
||||
|
||||
if (desc->x54_x40_TEXR)
|
||||
{
|
||||
|
@ -183,8 +183,6 @@ void CElementGenShaders::BuildShaderDataBinding(boo::IGraphicsDataFactory::Conte
|
|||
TShader<CElementGenShaders>::BuildShaderDataBinding(ctx, shad);
|
||||
}
|
||||
|
||||
void CElementGenShaders::Shutdown() {}
|
||||
|
||||
URDE_SPECIALIZE_SHADER(CElementGenShaders)
|
||||
|
||||
}
|
||||
|
|
|
@ -27,52 +27,52 @@ public:
|
|||
};
|
||||
|
||||
private:
|
||||
static boo::IShaderPipeline* m_texZTestZWrite;
|
||||
static boo::IShaderPipeline* m_texNoZTestZWrite;
|
||||
static boo::IShaderPipeline* m_texZTestNoZWrite;
|
||||
static boo::IShaderPipeline* m_texNoZTestNoZWrite;
|
||||
static boo::IShaderPipeline* m_texAdditiveZTest;
|
||||
static boo::IShaderPipeline* m_texAdditiveNoZTest;
|
||||
static boo::IShaderPipeline* m_texRedToAlphaZTest;
|
||||
static boo::IShaderPipeline* m_texRedToAlphaNoZTest;
|
||||
static boo::IShaderPipeline* m_texZTestNoZWriteSub;
|
||||
static boo::IShaderPipeline* m_texNoZTestNoZWriteSub;
|
||||
static boo::IShaderPipeline* m_texRedToAlphaZTestSub;
|
||||
static boo::IShaderPipeline* m_texRedToAlphaNoZTestSub;
|
||||
static boo::ObjToken<boo::IShaderPipeline> m_texZTestZWrite;
|
||||
static boo::ObjToken<boo::IShaderPipeline> m_texNoZTestZWrite;
|
||||
static boo::ObjToken<boo::IShaderPipeline> m_texZTestNoZWrite;
|
||||
static boo::ObjToken<boo::IShaderPipeline> m_texNoZTestNoZWrite;
|
||||
static boo::ObjToken<boo::IShaderPipeline> m_texAdditiveZTest;
|
||||
static boo::ObjToken<boo::IShaderPipeline> m_texAdditiveNoZTest;
|
||||
static boo::ObjToken<boo::IShaderPipeline> m_texRedToAlphaZTest;
|
||||
static boo::ObjToken<boo::IShaderPipeline> m_texRedToAlphaNoZTest;
|
||||
static boo::ObjToken<boo::IShaderPipeline> m_texZTestNoZWriteSub;
|
||||
static boo::ObjToken<boo::IShaderPipeline> m_texNoZTestNoZWriteSub;
|
||||
static boo::ObjToken<boo::IShaderPipeline> m_texRedToAlphaZTestSub;
|
||||
static boo::ObjToken<boo::IShaderPipeline> m_texRedToAlphaNoZTestSub;
|
||||
|
||||
static boo::IShaderPipeline* m_indTexZWrite;
|
||||
static boo::IShaderPipeline* m_indTexNoZWrite;
|
||||
static boo::IShaderPipeline* m_indTexAdditive;
|
||||
static boo::ObjToken<boo::IShaderPipeline> m_indTexZWrite;
|
||||
static boo::ObjToken<boo::IShaderPipeline> m_indTexNoZWrite;
|
||||
static boo::ObjToken<boo::IShaderPipeline> m_indTexAdditive;
|
||||
|
||||
static boo::IShaderPipeline* m_cindTexZWrite;
|
||||
static boo::IShaderPipeline* m_cindTexNoZWrite;
|
||||
static boo::IShaderPipeline* m_cindTexAdditive;
|
||||
static boo::ObjToken<boo::IShaderPipeline> m_cindTexZWrite;
|
||||
static boo::ObjToken<boo::IShaderPipeline> m_cindTexNoZWrite;
|
||||
static boo::ObjToken<boo::IShaderPipeline> m_cindTexAdditive;
|
||||
|
||||
static boo::IShaderPipeline* m_noTexZTestZWrite;
|
||||
static boo::IShaderPipeline* m_noTexNoZTestZWrite;
|
||||
static boo::IShaderPipeline* m_noTexZTestNoZWrite;
|
||||
static boo::IShaderPipeline* m_noTexNoZTestNoZWrite;
|
||||
static boo::IShaderPipeline* m_noTexAdditiveZTest;
|
||||
static boo::IShaderPipeline* m_noTexAdditiveNoZTest;
|
||||
static boo::ObjToken<boo::IShaderPipeline> m_noTexZTestZWrite;
|
||||
static boo::ObjToken<boo::IShaderPipeline> m_noTexNoZTestZWrite;
|
||||
static boo::ObjToken<boo::IShaderPipeline> m_noTexZTestNoZWrite;
|
||||
static boo::ObjToken<boo::IShaderPipeline> m_noTexNoZTestNoZWrite;
|
||||
static boo::ObjToken<boo::IShaderPipeline> m_noTexAdditiveZTest;
|
||||
static boo::ObjToken<boo::IShaderPipeline> m_noTexAdditiveNoZTest;
|
||||
|
||||
static boo::IVertexFormat* m_vtxFormatTex; /* No OpenGL */
|
||||
static boo::IVertexFormat* m_vtxFormatIndTex; /* No OpenGL */
|
||||
static boo::IVertexFormat* m_vtxFormatNoTex; /* No OpenGL */
|
||||
static boo::ObjToken<boo::IVertexFormat> m_vtxFormatTex; /* No OpenGL */
|
||||
static boo::ObjToken<boo::IVertexFormat> m_vtxFormatIndTex; /* No OpenGL */
|
||||
static boo::ObjToken<boo::IVertexFormat> m_vtxFormatNoTex; /* No OpenGL */
|
||||
|
||||
CElementGen& m_gen;
|
||||
boo::IShaderPipeline* m_regPipeline;
|
||||
boo::IShaderPipeline* m_regPipelineSub;
|
||||
boo::IShaderPipeline* m_redToAlphaPipeline;
|
||||
boo::IShaderPipeline* m_redToAlphaPipelineSub;
|
||||
boo::IShaderPipeline* m_regPipelinePmus;
|
||||
boo::IShaderPipeline* m_redToAlphaPipelinePmus;
|
||||
boo::ObjToken<boo::IShaderPipeline> m_regPipeline;
|
||||
boo::ObjToken<boo::IShaderPipeline> m_regPipelineSub;
|
||||
boo::ObjToken<boo::IShaderPipeline> m_redToAlphaPipeline;
|
||||
boo::ObjToken<boo::IShaderPipeline> m_redToAlphaPipelineSub;
|
||||
boo::ObjToken<boo::IShaderPipeline> m_regPipelinePmus;
|
||||
boo::ObjToken<boo::IShaderPipeline> m_redToAlphaPipelinePmus;
|
||||
CElementGenShaders(CElementGen& gen,
|
||||
boo::IShaderPipeline* regPipeline,
|
||||
boo::IShaderPipeline* regPipelineSub,
|
||||
boo::IShaderPipeline* redToAlphaPipeline,
|
||||
boo::IShaderPipeline* redToAlphaPipelineSub,
|
||||
boo::IShaderPipeline* regPipelinePmus,
|
||||
boo::IShaderPipeline* redToAlphaPipelinePmus)
|
||||
const boo::ObjToken<boo::IShaderPipeline>& regPipeline,
|
||||
const boo::ObjToken<boo::IShaderPipeline>& regPipelineSub,
|
||||
const boo::ObjToken<boo::IShaderPipeline>& redToAlphaPipeline,
|
||||
const boo::ObjToken<boo::IShaderPipeline>& redToAlphaPipelineSub,
|
||||
const boo::ObjToken<boo::IShaderPipeline>& regPipelinePmus,
|
||||
const boo::ObjToken<boo::IShaderPipeline>& redToAlphaPipelinePmus)
|
||||
: m_gen(gen), m_regPipeline(regPipeline), m_regPipelineSub(regPipelineSub),
|
||||
m_redToAlphaPipeline(redToAlphaPipeline), m_redToAlphaPipelineSub(redToAlphaPipelineSub),
|
||||
m_regPipelinePmus(regPipelinePmus), m_redToAlphaPipelinePmus(redToAlphaPipelinePmus) {}
|
||||
|
|
|
@ -192,18 +192,18 @@ BOO_GLSL_BINDING_HEAD
|
|||
|
||||
struct OGLElementDataBindingFactory : TShader<CElementGenShaders>::IDataBindingFactory
|
||||
{
|
||||
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
CElementGenShaders& shaders)
|
||||
{
|
||||
CElementGen& gen = shaders.m_gen;
|
||||
CGenDescription* desc = gen.GetDesc();
|
||||
|
||||
boo::IVertexFormat* vtxFmt = nullptr;
|
||||
boo::IVertexFormat* vtxFmtPmus = nullptr;
|
||||
boo::ObjToken<boo::IVertexFormat> vtxFmt;
|
||||
boo::ObjToken<boo::IVertexFormat> vtxFmtPmus;
|
||||
CUVElement* texr = desc->x54_x40_TEXR.get();
|
||||
CUVElement* tind = desc->x58_x44_TIND.get();
|
||||
int texCount = 0;
|
||||
boo::ITexture* textures[3];
|
||||
boo::ObjToken<boo::ITexture> textures[3];
|
||||
|
||||
if (texr)
|
||||
{
|
||||
|
@ -213,22 +213,22 @@ struct OGLElementDataBindingFactory : TShader<CElementGenShaders>::IDataBindingF
|
|||
{
|
||||
if (tind)
|
||||
{
|
||||
textures[1] = CGraphics::g_SpareTexture;
|
||||
textures[1] = CGraphics::g_SpareTexture.get();
|
||||
textures[2] = tind->GetValueTexture(0).GetObj()->GetBooTexture();
|
||||
texCount = 3;
|
||||
|
||||
const boo::VertexElementDescriptor TexFmtIndTex[] =
|
||||
{
|
||||
{gen.m_instBuf, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 0},
|
||||
{gen.m_instBuf, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 1},
|
||||
{gen.m_instBuf, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 2},
|
||||
{gen.m_instBuf, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 3},
|
||||
{gen.m_instBuf, nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced},
|
||||
{gen.m_instBuf, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 0},
|
||||
{gen.m_instBuf, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 1},
|
||||
{gen.m_instBuf, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 2},
|
||||
{gen.m_instBuf, 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::Position4 | boo::VertexSemantic::Instanced, 0},
|
||||
{gen.m_instBuf.get(), nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 1},
|
||||
{gen.m_instBuf.get(), nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 2},
|
||||
{gen.m_instBuf.get(), nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 3},
|
||||
{gen.m_instBuf.get(), nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced},
|
||||
{gen.m_instBuf.get(), nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 0},
|
||||
{gen.m_instBuf.get(), nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 1},
|
||||
{gen.m_instBuf.get(), nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 2},
|
||||
{gen.m_instBuf.get(), nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 3},
|
||||
{gen.m_instBuf.get(), nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 4},
|
||||
};
|
||||
vtxFmt = ctx.newVertexFormat(10, TexFmtIndTex);
|
||||
}
|
||||
|
@ -236,15 +236,15 @@ struct OGLElementDataBindingFactory : TShader<CElementGenShaders>::IDataBindingF
|
|||
{
|
||||
const boo::VertexElementDescriptor TexFmtTex[] =
|
||||
{
|
||||
{gen.m_instBuf, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 0},
|
||||
{gen.m_instBuf, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 1},
|
||||
{gen.m_instBuf, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 2},
|
||||
{gen.m_instBuf, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 3},
|
||||
{gen.m_instBuf, nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced},
|
||||
{gen.m_instBuf, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 0},
|
||||
{gen.m_instBuf, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 1},
|
||||
{gen.m_instBuf, 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::Position4 | boo::VertexSemantic::Instanced, 0},
|
||||
{gen.m_instBuf.get(), nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 1},
|
||||
{gen.m_instBuf.get(), nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 2},
|
||||
{gen.m_instBuf.get(), nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 3},
|
||||
{gen.m_instBuf.get(), nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced},
|
||||
{gen.m_instBuf.get(), nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 0},
|
||||
{gen.m_instBuf.get(), nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 1},
|
||||
{gen.m_instBuf.get(), nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 2},
|
||||
{gen.m_instBuf.get(), nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 3}
|
||||
};
|
||||
vtxFmt = ctx.newVertexFormat(9, TexFmtTex);
|
||||
}
|
||||
|
@ -253,15 +253,15 @@ struct OGLElementDataBindingFactory : TShader<CElementGenShaders>::IDataBindingF
|
|||
{
|
||||
const boo::VertexElementDescriptor TexFmtTex[] =
|
||||
{
|
||||
{gen.m_instBufPmus, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 0},
|
||||
{gen.m_instBufPmus, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 1},
|
||||
{gen.m_instBufPmus, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 2},
|
||||
{gen.m_instBufPmus, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 3},
|
||||
{gen.m_instBufPmus, nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced},
|
||||
{gen.m_instBufPmus, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 0},
|
||||
{gen.m_instBufPmus, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 1},
|
||||
{gen.m_instBufPmus, 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::Position4 | boo::VertexSemantic::Instanced, 0},
|
||||
{gen.m_instBufPmus.get(), nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 1},
|
||||
{gen.m_instBufPmus.get(), nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 2},
|
||||
{gen.m_instBufPmus.get(), nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 3},
|
||||
{gen.m_instBufPmus.get(), nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced},
|
||||
{gen.m_instBufPmus.get(), nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 0},
|
||||
{gen.m_instBufPmus.get(), nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 1},
|
||||
{gen.m_instBufPmus.get(), nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 2},
|
||||
{gen.m_instBufPmus.get(), nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 3}
|
||||
};
|
||||
vtxFmtPmus = ctx.newVertexFormat(9, TexFmtTex);
|
||||
}
|
||||
|
@ -272,11 +272,11 @@ struct OGLElementDataBindingFactory : TShader<CElementGenShaders>::IDataBindingF
|
|||
{
|
||||
const boo::VertexElementDescriptor TexFmtNoTex[] =
|
||||
{
|
||||
{gen.m_instBuf, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 0},
|
||||
{gen.m_instBuf, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 1},
|
||||
{gen.m_instBuf, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 2},
|
||||
{gen.m_instBuf, 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::Position4 | boo::VertexSemantic::Instanced, 0},
|
||||
{gen.m_instBuf.get(), nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 1},
|
||||
{gen.m_instBuf.get(), nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 2},
|
||||
{gen.m_instBuf.get(), nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 3},
|
||||
{gen.m_instBuf.get(), nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced}
|
||||
};
|
||||
vtxFmt = ctx.newVertexFormat(5, TexFmtNoTex);
|
||||
}
|
||||
|
@ -284,11 +284,11 @@ struct OGLElementDataBindingFactory : TShader<CElementGenShaders>::IDataBindingF
|
|||
{
|
||||
const boo::VertexElementDescriptor TexFmtNoTex[] =
|
||||
{
|
||||
{gen.m_instBufPmus, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 0},
|
||||
{gen.m_instBufPmus, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 1},
|
||||
{gen.m_instBufPmus, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 2},
|
||||
{gen.m_instBufPmus, 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::Position4 | boo::VertexSemantic::Instanced, 0},
|
||||
{gen.m_instBufPmus.get(), nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 1},
|
||||
{gen.m_instBufPmus.get(), nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 2},
|
||||
{gen.m_instBufPmus.get(), nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 3},
|
||||
{gen.m_instBufPmus.get(), nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced}
|
||||
};
|
||||
vtxFmtPmus = ctx.newVertexFormat(5, TexFmtNoTex);
|
||||
}
|
||||
|
@ -296,38 +296,38 @@ struct OGLElementDataBindingFactory : TShader<CElementGenShaders>::IDataBindingF
|
|||
|
||||
if (gen.m_instBuf)
|
||||
{
|
||||
boo::IGraphicsBuffer* uniforms[] = {gen.m_uniformBuf};
|
||||
boo::ObjToken<boo::IGraphicsBuffer> uniforms[] = {gen.m_uniformBuf.get()};
|
||||
|
||||
if (shaders.m_regPipeline)
|
||||
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);
|
||||
if (shaders.m_regPipelineSub)
|
||||
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);
|
||||
if (shaders.m_redToAlphaPipeline)
|
||||
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);
|
||||
if (shaders.m_redToAlphaPipelineSub)
|
||||
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);
|
||||
}
|
||||
|
||||
if (gen.m_instBufPmus)
|
||||
{
|
||||
boo::IGraphicsBuffer* uniforms[] = {gen.m_uniformBufPmus};
|
||||
boo::ObjToken<boo::IGraphicsBuffer> uniforms[] = {gen.m_uniformBufPmus.get()};
|
||||
texCount = std::min(texCount, 1);
|
||||
|
||||
if (shaders.m_regPipelinePmus)
|
||||
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);
|
||||
if (shaders.m_redToAlphaPipelinePmus)
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -449,6 +449,38 @@ TShader<CElementGenShaders>::IDataBindingFactory* CElementGenShaders::Initialize
|
|||
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
|
||||
struct VulkanElementDataBindingFactory : TShader<CElementGenShaders>::IDataBindingFactory
|
||||
{
|
||||
|
|
|
@ -210,7 +210,7 @@ static const char* FS_METAL_NOTEX =
|
|||
|
||||
struct MetalElementDataBindingFactory : TShader<CElementGenShaders>::IDataBindingFactory
|
||||
{
|
||||
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
CElementGenShaders& shader)
|
||||
{
|
||||
CElementGen& gen = shader.m_gen;
|
||||
|
@ -219,7 +219,7 @@ struct MetalElementDataBindingFactory : TShader<CElementGenShaders>::IDataBindin
|
|||
CUVElement* texr = desc->x54_x40_TEXR.get();
|
||||
CUVElement* tind = desc->x58_x44_TIND.get();
|
||||
int texCount = 0;
|
||||
boo::ITexture* textures[3];
|
||||
boo::ObjToken<boo::ITexture> textures[3];
|
||||
|
||||
if (texr)
|
||||
{
|
||||
|
@ -227,7 +227,7 @@ struct MetalElementDataBindingFactory : TShader<CElementGenShaders>::IDataBindin
|
|||
texCount = 1;
|
||||
if (tind)
|
||||
{
|
||||
textures[1] = CGraphics::g_SpareTexture;
|
||||
textures[1] = CGraphics::g_SpareTexture.get();
|
||||
textures[2] = tind->GetValueTexture(0).GetObj()->GetBooTexture();
|
||||
texCount = 3;
|
||||
}
|
||||
|
@ -235,42 +235,42 @@ struct MetalElementDataBindingFactory : TShader<CElementGenShaders>::IDataBindin
|
|||
|
||||
if (gen.m_instBuf)
|
||||
{
|
||||
boo::IGraphicsBuffer* uniforms[] = {gen.m_uniformBuf};
|
||||
boo::ObjToken<boo::IGraphicsBuffer> uniforms[] = {gen.m_uniformBuf.get()};
|
||||
|
||||
if (shader.m_regPipeline)
|
||||
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);
|
||||
if (shader.m_regPipelineSub)
|
||||
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);
|
||||
if (shader.m_redToAlphaPipeline)
|
||||
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);
|
||||
if (shader.m_redToAlphaPipelineSub)
|
||||
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);
|
||||
}
|
||||
|
||||
if (gen.m_instBufPmus)
|
||||
{
|
||||
boo::IGraphicsBuffer* uniforms[] = {gen.m_uniformBufPmus};
|
||||
boo::ObjToken<boo::IGraphicsBuffer> uniforms[] = {gen.m_uniformBufPmus.get()};
|
||||
texCount = std::min(texCount, 1);
|
||||
|
||||
if (shader.m_regPipelinePmus)
|
||||
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);
|
||||
if (shader.m_redToAlphaPipelinePmus)
|
||||
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);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
return {};
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -315,116 +315,152 @@ TShader<CElementGenShaders>::IDataBindingFactory* CElementGenShaders::Initialize
|
|||
};
|
||||
m_vtxFormatNoTex = ctx.newVertexFormat(5, TexFmtNoTex);
|
||||
|
||||
m_texZTestZWrite = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX, m_vtxFormatTex,
|
||||
CGraphics::g_ViewportSamples,
|
||||
m_texZTestZWrite = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX, nullptr, nullptr,
|
||||
m_vtxFormatTex, CGraphics::g_ViewportSamples,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, true, true, true, boo::CullMode::None);
|
||||
m_texNoZTestZWrite = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX, m_vtxFormatTex,
|
||||
CGraphics::g_ViewportSamples,
|
||||
m_texNoZTestZWrite = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX, nullptr, nullptr,
|
||||
m_vtxFormatTex, CGraphics::g_ViewportSamples,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::None, true, true, true, boo::CullMode::None);
|
||||
m_texZTestNoZWrite = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX, m_vtxFormatTex,
|
||||
CGraphics::g_ViewportSamples,
|
||||
m_texZTestNoZWrite = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX, nullptr, nullptr,
|
||||
m_vtxFormatTex, CGraphics::g_ViewportSamples,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, false, true, true, boo::CullMode::None);
|
||||
m_texNoZTestNoZWrite = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX, m_vtxFormatTex,
|
||||
CGraphics::g_ViewportSamples,
|
||||
m_texNoZTestNoZWrite = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX, nullptr, nullptr,
|
||||
m_vtxFormatTex, CGraphics::g_ViewportSamples,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::None, false, true, true, boo::CullMode::None);
|
||||
|
||||
m_texAdditiveZTest = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX, m_vtxFormatTex,
|
||||
CGraphics::g_ViewportSamples,
|
||||
m_texAdditiveZTest = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX, nullptr, nullptr,
|
||||
m_vtxFormatTex, CGraphics::g_ViewportSamples,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, false, true, true, boo::CullMode::None);
|
||||
m_texAdditiveNoZTest = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX, m_vtxFormatTex,
|
||||
CGraphics::g_ViewportSamples,
|
||||
m_texAdditiveNoZTest = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX, nullptr, nullptr,
|
||||
m_vtxFormatTex, CGraphics::g_ViewportSamples,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
|
||||
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,
|
||||
CGraphics::g_ViewportSamples,
|
||||
m_texRedToAlphaZTest = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX_REDTOALPHA, nullptr, nullptr,
|
||||
m_vtxFormatTex, CGraphics::g_ViewportSamples,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
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,
|
||||
CGraphics::g_ViewportSamples,
|
||||
m_texRedToAlphaNoZTest = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX_REDTOALPHA, nullptr, nullptr,
|
||||
m_vtxFormatTex, CGraphics::g_ViewportSamples,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::None, false, true, true, boo::CullMode::None);
|
||||
|
||||
m_texZTestNoZWriteSub = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX, m_vtxFormatTex,
|
||||
CGraphics::g_ViewportSamples,
|
||||
m_texZTestNoZWriteSub = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX, nullptr, nullptr,
|
||||
m_vtxFormatTex, CGraphics::g_ViewportSamples,
|
||||
boo::BlendFactor::Subtract, boo::BlendFactor::Subtract,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, false,
|
||||
true, false, boo::CullMode::None);
|
||||
m_texNoZTestNoZWriteSub = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX, m_vtxFormatTex,
|
||||
CGraphics::g_ViewportSamples,
|
||||
m_texNoZTestNoZWriteSub = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX, nullptr, nullptr,
|
||||
m_vtxFormatTex, CGraphics::g_ViewportSamples,
|
||||
boo::BlendFactor::Subtract, boo::BlendFactor::Subtract,
|
||||
boo::Primitive::TriStrips, boo::ZTest::None, false,
|
||||
true, false, boo::CullMode::None);
|
||||
|
||||
m_texRedToAlphaZTestSub = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX_REDTOALPHA, m_vtxFormatTex,
|
||||
CGraphics::g_ViewportSamples,
|
||||
m_texRedToAlphaZTestSub = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX_REDTOALPHA, nullptr, nullptr,
|
||||
m_vtxFormatTex, CGraphics::g_ViewportSamples,
|
||||
boo::BlendFactor::Subtract, boo::BlendFactor::Subtract,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, false,
|
||||
true, false, boo::CullMode::None);
|
||||
m_texRedToAlphaNoZTestSub = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX_REDTOALPHA, m_vtxFormatTex,
|
||||
CGraphics::g_ViewportSamples,
|
||||
m_texRedToAlphaNoZTestSub = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX_REDTOALPHA, nullptr, nullptr,
|
||||
m_vtxFormatTex, CGraphics::g_ViewportSamples,
|
||||
boo::BlendFactor::Subtract, boo::BlendFactor::Subtract,
|
||||
boo::Primitive::TriStrips, boo::ZTest::None, false,
|
||||
true, false, boo::CullMode::None);
|
||||
|
||||
m_indTexZWrite = ctx.newShaderPipeline(VS_METAL_INDTEX, FS_METAL_INDTEX, m_vtxFormatIndTex,
|
||||
CGraphics::g_ViewportSamples,
|
||||
m_indTexZWrite = ctx.newShaderPipeline(VS_METAL_INDTEX, FS_METAL_INDTEX, nullptr, nullptr,
|
||||
m_vtxFormatIndTex, CGraphics::g_ViewportSamples,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::None, true, true, true, boo::CullMode::None);
|
||||
m_indTexNoZWrite = ctx.newShaderPipeline(VS_METAL_INDTEX, FS_METAL_INDTEX, m_vtxFormatIndTex,
|
||||
CGraphics::g_ViewportSamples,
|
||||
m_indTexNoZWrite = ctx.newShaderPipeline(VS_METAL_INDTEX, FS_METAL_INDTEX, nullptr, nullptr,
|
||||
m_vtxFormatIndTex, CGraphics::g_ViewportSamples,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::None, false, true, true, boo::CullMode::None);
|
||||
m_indTexAdditive = ctx.newShaderPipeline(VS_METAL_INDTEX, FS_METAL_INDTEX, m_vtxFormatIndTex,
|
||||
CGraphics::g_ViewportSamples,
|
||||
m_indTexAdditive = ctx.newShaderPipeline(VS_METAL_INDTEX, FS_METAL_INDTEX, nullptr, nullptr,
|
||||
m_vtxFormatIndTex, CGraphics::g_ViewportSamples,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
|
||||
boo::Primitive::TriStrips, boo::ZTest::None, true, true, true, boo::CullMode::None);
|
||||
|
||||
m_cindTexZWrite = ctx.newShaderPipeline(VS_METAL_INDTEX, FS_METAL_CINDTEX, m_vtxFormatIndTex,
|
||||
CGraphics::g_ViewportSamples,
|
||||
m_cindTexZWrite = ctx.newShaderPipeline(VS_METAL_INDTEX, FS_METAL_CINDTEX, nullptr, nullptr,
|
||||
m_vtxFormatIndTex, CGraphics::g_ViewportSamples,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::None, true, true, true, boo::CullMode::None);
|
||||
m_cindTexNoZWrite = ctx.newShaderPipeline(VS_METAL_INDTEX, FS_METAL_CINDTEX, m_vtxFormatIndTex,
|
||||
CGraphics::g_ViewportSamples,
|
||||
m_cindTexNoZWrite = ctx.newShaderPipeline(VS_METAL_INDTEX, FS_METAL_CINDTEX, nullptr, nullptr,
|
||||
m_vtxFormatIndTex, CGraphics::g_ViewportSamples,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::None, false, true, true, boo::CullMode::None);
|
||||
m_cindTexAdditive = ctx.newShaderPipeline(VS_METAL_INDTEX, FS_METAL_CINDTEX, m_vtxFormatIndTex,
|
||||
CGraphics::g_ViewportSamples,
|
||||
m_cindTexAdditive = ctx.newShaderPipeline(VS_METAL_INDTEX, FS_METAL_CINDTEX, nullptr, nullptr,
|
||||
m_vtxFormatIndTex, CGraphics::g_ViewportSamples,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
|
||||
boo::Primitive::TriStrips, boo::ZTest::None, true, true, true, boo::CullMode::None);
|
||||
|
||||
m_noTexZTestZWrite = ctx.newShaderPipeline(VS_METAL_NOTEX, FS_METAL_NOTEX, m_vtxFormatNoTex,
|
||||
CGraphics::g_ViewportSamples,
|
||||
m_noTexZTestZWrite = ctx.newShaderPipeline(VS_METAL_NOTEX, FS_METAL_NOTEX, nullptr, nullptr,
|
||||
m_vtxFormatNoTex, CGraphics::g_ViewportSamples,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, true, true, true, boo::CullMode::None);
|
||||
m_noTexNoZTestZWrite = ctx.newShaderPipeline(VS_METAL_NOTEX, FS_METAL_NOTEX, m_vtxFormatNoTex,
|
||||
CGraphics::g_ViewportSamples,
|
||||
m_noTexNoZTestZWrite = ctx.newShaderPipeline(VS_METAL_NOTEX, FS_METAL_NOTEX, nullptr, nullptr,
|
||||
m_vtxFormatNoTex, CGraphics::g_ViewportSamples,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::None, true, true, true, boo::CullMode::None);
|
||||
m_noTexZTestNoZWrite = ctx.newShaderPipeline(VS_METAL_NOTEX, FS_METAL_NOTEX, m_vtxFormatNoTex,
|
||||
CGraphics::g_ViewportSamples,
|
||||
m_noTexZTestNoZWrite = ctx.newShaderPipeline(VS_METAL_NOTEX, FS_METAL_NOTEX, nullptr, nullptr,
|
||||
m_vtxFormatNoTex, CGraphics::g_ViewportSamples,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, false, true, true, boo::CullMode::None);
|
||||
m_noTexNoZTestNoZWrite = ctx.newShaderPipeline(VS_METAL_NOTEX, FS_METAL_NOTEX, m_vtxFormatNoTex,
|
||||
CGraphics::g_ViewportSamples,
|
||||
m_noTexNoZTestNoZWrite = ctx.newShaderPipeline(VS_METAL_NOTEX, FS_METAL_NOTEX, nullptr, nullptr,
|
||||
m_vtxFormatNoTex, CGraphics::g_ViewportSamples,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::None, false, true, true, boo::CullMode::None);
|
||||
|
||||
m_noTexAdditiveZTest = ctx.newShaderPipeline(VS_METAL_NOTEX, FS_METAL_NOTEX, m_vtxFormatNoTex,
|
||||
CGraphics::g_ViewportSamples,
|
||||
m_noTexAdditiveZTest = ctx.newShaderPipeline(VS_METAL_NOTEX, FS_METAL_NOTEX, nullptr, nullptr,
|
||||
m_vtxFormatNoTex, CGraphics::g_ViewportSamples,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, false, true, true, boo::CullMode::None);
|
||||
m_noTexAdditiveNoZTest = ctx.newShaderPipeline(VS_METAL_NOTEX, FS_METAL_NOTEX, m_vtxFormatNoTex,
|
||||
CGraphics::g_ViewportSamples,
|
||||
m_noTexAdditiveNoZTest = ctx.newShaderPipeline(VS_METAL_NOTEX, FS_METAL_NOTEX, nullptr, nullptr,
|
||||
m_vtxFormatNoTex, CGraphics::g_ViewportSamples,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
|
||||
boo::Primitive::TriStrips, boo::ZTest::None, false, true, true, boo::CullMode::None);
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ void CEnergyBarShader::draw(const zeus::CColor& color0, const std::vector<Vertex
|
|||
{
|
||||
m_maxVerts = totalVerts;
|
||||
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);
|
||||
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)
|
||||
|
||||
void CEnergyBarShader::Shutdown() {}
|
||||
|
||||
}
|
||||
|
|
|
@ -30,10 +30,9 @@ private:
|
|||
zeus::CMatrix4f m_matrix;
|
||||
zeus::CColor m_color;
|
||||
};
|
||||
boo::GraphicsDataToken m_token;
|
||||
boo::IGraphicsBufferD* m_vbo;
|
||||
boo::IGraphicsBufferD* m_uniBuf[3];
|
||||
boo::IShaderDataBinding* m_dataBind[3];
|
||||
boo::ObjToken<boo::IGraphicsBufferD> m_vbo;
|
||||
boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf[3];
|
||||
boo::ObjToken<boo::IShaderDataBinding> m_dataBind[3];
|
||||
Uniform m_uniform;
|
||||
const CTexture* m_tex = nullptr;
|
||||
size_t m_maxVerts = 0;
|
||||
|
|
|
@ -50,30 +50,30 @@ BOO_GLSL_BINDING_HEAD
|
|||
|
||||
URDE_DECL_SPECIALIZE_SHADER(CEnergyBarShader)
|
||||
|
||||
static boo::IVertexFormat* s_VtxFmt = nullptr;
|
||||
static boo::IShaderPipeline* s_Pipeline = nullptr;
|
||||
static boo::ObjToken<boo::IVertexFormat> s_VtxFmt;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_Pipeline;
|
||||
|
||||
struct CEnergyBarShaderGLDataBindingFactory : TShader<CEnergyBarShader>::IDataBindingFactory
|
||||
{
|
||||
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
CEnergyBarShader& filter)
|
||||
{
|
||||
boo::GLDataFactory::Context& cctx = static_cast<boo::GLDataFactory::Context&>(ctx);
|
||||
|
||||
const boo::VertexElementDescriptor VtxVmt[] =
|
||||
{
|
||||
{filter.m_vbo, nullptr, boo::VertexSemantic::Position4},
|
||||
{filter.m_vbo, nullptr, boo::VertexSemantic::UV4}
|
||||
{filter.m_vbo.get(), nullptr, boo::VertexSemantic::Position4},
|
||||
{filter.m_vbo.get(), nullptr, boo::VertexSemantic::UV4}
|
||||
};
|
||||
boo::IVertexFormat* vtxFmt = ctx.newVertexFormat(2, VtxVmt);
|
||||
boo::IGraphicsBuffer* bufs[1];
|
||||
boo::ObjToken<boo::IVertexFormat> vtxFmt = ctx.newVertexFormat(2, VtxVmt);
|
||||
boo::ObjToken<boo::IGraphicsBuffer> bufs[1];
|
||||
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)
|
||||
{
|
||||
bufs[0] = filter.m_uniBuf[i];
|
||||
bufs[0] = filter.m_uniBuf[i].get();
|
||||
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);
|
||||
}
|
||||
return filter.m_dataBind[0];
|
||||
|
@ -113,6 +113,12 @@ CEnergyBarShader::Initialize(boo::GLDataFactory::Context& ctx)
|
|||
return new CEnergyBarShaderGLDataBindingFactory;
|
||||
}
|
||||
|
||||
template <>
|
||||
void CEnergyBarShader::Shutdown<boo::GLDataFactory>()
|
||||
{
|
||||
s_Pipeline.reset();
|
||||
}
|
||||
|
||||
#if BOO_HAS_VULKAN
|
||||
TShader<CEnergyBarShader>::IDataBindingFactory*
|
||||
CEnergyBarShader::Initialize(boo::VulkanDataFactory::Context& ctx)
|
||||
|
|
|
@ -54,23 +54,23 @@ static const char* FS =
|
|||
|
||||
URDE_DECL_SPECIALIZE_SHADER(CEnergyBarShader)
|
||||
|
||||
static boo::IVertexFormat* s_VtxFmt = nullptr;
|
||||
static boo::IShaderPipeline* s_Pipeline = nullptr;
|
||||
static boo::ObjToken<boo::IVertexFormat> s_VtxFmt;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_Pipeline;
|
||||
|
||||
struct CEnergyBarShaderMetalDataBindingFactory : TShader<CEnergyBarShader>::IDataBindingFactory
|
||||
{
|
||||
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
CEnergyBarShader& filter)
|
||||
{
|
||||
boo::MetalDataFactory::Context& cctx = static_cast<boo::MetalDataFactory::Context&>(ctx);
|
||||
|
||||
boo::IGraphicsBuffer* bufs[1];
|
||||
boo::ITexture* texs[] = {filter.m_tex->GetBooTexture()};
|
||||
boo::ObjToken<boo::IGraphicsBuffer> bufs[1];
|
||||
boo::ObjToken<boo::ITexture> texs[] = {filter.m_tex->GetBooTexture()};
|
||||
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_vbo, nullptr, nullptr, 1, bufs,
|
||||
filter.m_vbo.get(), nullptr, nullptr, 1, bufs,
|
||||
nullptr, nullptr, nullptr, 1, texs, nullptr, nullptr);
|
||||
}
|
||||
return filter.m_dataBind[0];
|
||||
|
@ -86,11 +86,19 @@ CEnergyBarShader::Initialize(boo::MetalDataFactory::Context& ctx)
|
|||
{nullptr, nullptr, boo::VertexSemantic::UV4}
|
||||
};
|
||||
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::Primitive::TriStrips, boo::ZTest::LEqual,
|
||||
false, true, false, boo::CullMode::None);
|
||||
return new CEnergyBarShaderMetalDataBindingFactory;
|
||||
}
|
||||
|
||||
template <>
|
||||
void CEnergyBarShader::Shutdown<boo::MetalDataFactory>()
|
||||
{
|
||||
s_VtxFmt.reset();
|
||||
s_Pipeline.reset();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -89,38 +89,38 @@ u16 CFluidPlaneShader::Cache::MakeCacheKey(const SFluidPlaneDoorShaderInfo& info
|
|||
}
|
||||
|
||||
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);
|
||||
auto& slot = CacheSlot(info, key);
|
||||
if (slot.second != nullptr)
|
||||
return slot.second;
|
||||
if (slot)
|
||||
return slot;
|
||||
|
||||
if (CGraphics::g_BooFactory == nullptr)
|
||||
return nullptr;
|
||||
|
||||
slot.first = CGraphics::CommitResources(
|
||||
CGraphics::CommitResources(
|
||||
[&](boo::IGraphicsDataFactory::Context& ctx)
|
||||
{
|
||||
switch (ctx.platform())
|
||||
{
|
||||
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;
|
||||
#if _WIN32
|
||||
case boo::IGraphicsDataFactory::Platform::D3D11:
|
||||
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;
|
||||
#endif
|
||||
#if BOO_HAS_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;
|
||||
#endif
|
||||
#if BOO_HAS_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;
|
||||
#endif
|
||||
default: break;
|
||||
|
@ -128,31 +128,25 @@ boo::IShaderPipeline* CFluidPlaneShader::Cache::GetOrBuildShader(const T& info)
|
|||
return true;
|
||||
});
|
||||
|
||||
return slot.second;
|
||||
return slot;
|
||||
}
|
||||
|
||||
template boo::IShaderPipeline*
|
||||
template boo::ObjToken<boo::IShaderPipeline>
|
||||
CFluidPlaneShader::Cache::GetOrBuildShader<SFluidPlaneShaderInfo>(const SFluidPlaneShaderInfo& info);
|
||||
template boo::IShaderPipeline*
|
||||
template boo::ObjToken<boo::IShaderPipeline>
|
||||
CFluidPlaneShader::Cache::GetOrBuildShader<SFluidPlaneDoorShaderInfo>(const SFluidPlaneDoorShaderInfo& info);
|
||||
|
||||
void CFluidPlaneShader::Cache::Clear()
|
||||
{
|
||||
for (auto& p : m_cache)
|
||||
{
|
||||
p.first.doDestroy();
|
||||
p.second = nullptr;
|
||||
}
|
||||
p.reset();
|
||||
for (auto& p : m_doorCache)
|
||||
{
|
||||
p.first.doDestroy();
|
||||
p.second = nullptr;
|
||||
}
|
||||
p.reset();
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
m_vbo = ctx.newDynamicBuffer(boo::BufferUse::Vertex, sizeof(Vertex), maxVertCount);
|
||||
|
@ -211,7 +205,7 @@ CFluidPlaneShader::CFluidPlaneShader(CFluidPlane::EFluidType type,
|
|||
m_envBumpMap.operator bool(),
|
||||
m_lightmap.operator bool(),
|
||||
doubleLightmapBlend, additive);
|
||||
boo::IShaderPipeline* pipeline = _cache.GetOrBuildShader(shaderInfo);
|
||||
boo::ObjToken<boo::IShaderPipeline> pipeline = _cache.GetOrBuildShader(shaderInfo);
|
||||
PrepareBinding(pipeline, maxVertCount, false);
|
||||
}
|
||||
|
||||
|
@ -226,7 +220,7 @@ CFluidPlaneShader::CFluidPlaneShader(const std::experimental::optional<TLockedTo
|
|||
SFluidPlaneDoorShaderInfo shaderInfo(m_patternTex1.operator bool(),
|
||||
m_patternTex2.operator bool(),
|
||||
m_colorTex.operator bool());
|
||||
boo::IShaderPipeline* pipeline = _cache.GetOrBuildShader(shaderInfo);
|
||||
boo::ObjToken<boo::IShaderPipeline> pipeline = _cache.GetOrBuildShader(shaderInfo);
|
||||
PrepareBinding(pipeline, maxVertCount, true);
|
||||
}
|
||||
|
||||
|
|
|
@ -82,17 +82,17 @@ public:
|
|||
private:
|
||||
class Cache
|
||||
{
|
||||
std::pair<boo::GraphicsDataToken, boo::IShaderPipeline*> m_cache[1024] = {};
|
||||
std::pair<boo::GraphicsDataToken, boo::IShaderPipeline*> m_doorCache[8] = {};
|
||||
std::pair<boo::GraphicsDataToken, boo::IShaderPipeline*>&
|
||||
boo::ObjToken<boo::IShaderPipeline> m_cache[1024] = {};
|
||||
boo::ObjToken<boo::IShaderPipeline> m_doorCache[8] = {};
|
||||
boo::ObjToken<boo::IShaderPipeline>&
|
||||
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]; }
|
||||
static u16 MakeCacheKey(const SFluidPlaneShaderInfo& info);
|
||||
static u16 MakeCacheKey(const SFluidPlaneDoorShaderInfo& info);
|
||||
public:
|
||||
template<class T>
|
||||
boo::IShaderPipeline* GetOrBuildShader(const T& info);
|
||||
boo::ObjToken<boo::IShaderPipeline> GetOrBuildShader(const T& info);
|
||||
void Clear();
|
||||
};
|
||||
static Cache _cache;
|
||||
|
@ -113,23 +113,28 @@ private:
|
|||
std::experimental::optional<TLockedToken<CTexture>> m_envMap;
|
||||
std::experimental::optional<TLockedToken<CTexture>> m_envBumpMap;
|
||||
std::experimental::optional<TLockedToken<CTexture>> m_lightmap;
|
||||
boo::GraphicsDataToken m_gfxTok;
|
||||
boo::IGraphicsBufferD* m_vbo;
|
||||
boo::IGraphicsBufferD* m_uniBuf;
|
||||
boo::IShaderDataBinding* m_dataBind;
|
||||
boo::ObjToken<boo::IGraphicsBufferD> m_vbo;
|
||||
boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf;
|
||||
boo::ObjToken<boo::IShaderDataBinding> m_dataBind;
|
||||
|
||||
static boo::IShaderPipeline* BuildShader(boo::GLDataFactory::Context& ctx, const SFluidPlaneShaderInfo& info);
|
||||
static boo::IShaderPipeline* BuildShader(boo::GLDataFactory::Context& ctx, const SFluidPlaneDoorShaderInfo& info);
|
||||
boo::IShaderDataBinding* BuildBinding(boo::GLDataFactory::Context& ctx, boo::IShaderPipeline* pipeline, bool door);
|
||||
static boo::ObjToken<boo::IShaderPipeline> BuildShader(boo::GLDataFactory::Context& ctx,
|
||||
const SFluidPlaneShaderInfo& info);
|
||||
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
|
||||
static boo::IShaderPipeline* BuildShader(boo::ID3DDataFactory::Context& ctx, const SFluidPlaneShaderInfo& info);
|
||||
static boo::IShaderPipeline* BuildShader(boo::ID3DDataFactory::Context& ctx, const SFluidPlaneDoorShaderInfo& info);
|
||||
boo::IShaderDataBinding* BuildBinding(boo::ID3DDataFactory::Context& ctx, boo::IShaderPipeline* pipeline, bool door);
|
||||
#endif
|
||||
#if BOO_HAS_METAL
|
||||
static boo::IShaderPipeline* BuildShader(boo::MetalDataFactory::Context& ctx, const SFluidPlaneShaderInfo& info);
|
||||
static boo::IShaderPipeline* BuildShader(boo::MetalDataFactory::Context& ctx, const SFluidPlaneDoorShaderInfo& info);
|
||||
boo::IShaderDataBinding* BuildBinding(boo::MetalDataFactory::Context& ctx, boo::IShaderPipeline* pipeline, bool door);
|
||||
static boo::ObjToken<boo::IShaderPipeline> BuildShader(boo::MetalDataFactory::Context& ctx,
|
||||
const SFluidPlaneShaderInfo& info);
|
||||
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
|
||||
#if BOO_HAS_VULKAN
|
||||
static boo::IShaderPipeline* BuildShader(boo::VulkanDataFactory::Context& ctx, const SFluidPlaneShaderInfo& info);
|
||||
|
@ -137,7 +142,7 @@ private:
|
|||
boo::IShaderDataBinding* BuildBinding(boo::VulkanDataFactory::Context& ctx, boo::IShaderPipeline* pipeline, bool door);
|
||||
#endif
|
||||
|
||||
void PrepareBinding(boo::IShaderPipeline* pipeline, u32 maxVertCount, bool door);
|
||||
void PrepareBinding(const boo::ObjToken<boo::IShaderPipeline>& pipeline, u32 maxVertCount, bool door);
|
||||
public:
|
||||
CFluidPlaneShader(CFluidPlane::EFluidType type,
|
||||
const std::experimental::optional<TLockedToken<CTexture>>& patternTex1,
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
||||
boo::IShaderPipeline*
|
||||
boo::ObjToken<boo::IShaderPipeline>
|
||||
CFluidPlaneShader::BuildShader(boo::GLDataFactory::Context& ctx, const SFluidPlaneShaderInfo& info)
|
||||
{
|
||||
int nextTex = 0;
|
||||
|
@ -524,7 +524,7 @@ CFluidPlaneShader::BuildShader(boo::GLDataFactory::Context& ctx, const SFluidPla
|
|||
boo::CullMode::None);
|
||||
}
|
||||
|
||||
boo::IShaderPipeline*
|
||||
boo::ObjToken<boo::IShaderPipeline>
|
||||
CFluidPlaneShader::BuildShader(boo::GLDataFactory::Context& ctx, const SFluidPlaneDoorShaderInfo& info)
|
||||
{
|
||||
int nextTex = 0;
|
||||
|
@ -595,25 +595,26 @@ CFluidPlaneShader::BuildShader(boo::VulkanDataFactory::Context& ctx, const SFlui
|
|||
}
|
||||
#endif
|
||||
|
||||
boo::IShaderDataBinding* CFluidPlaneShader::BuildBinding(boo::GLDataFactory::Context& ctx,
|
||||
boo::IShaderPipeline* pipeline, bool door)
|
||||
boo::ObjToken<boo::IShaderDataBinding>
|
||||
CFluidPlaneShader::BuildBinding(boo::GLDataFactory::Context& ctx,
|
||||
const boo::ObjToken<boo::IShaderPipeline>& pipeline, bool door)
|
||||
{
|
||||
boo::VertexElementDescriptor elements[] =
|
||||
{
|
||||
{m_vbo, nullptr, boo::VertexSemantic::Position4},
|
||||
{m_vbo, nullptr, boo::VertexSemantic::Normal4, 0},
|
||||
{m_vbo, nullptr, boo::VertexSemantic::Normal4, 1},
|
||||
{m_vbo, nullptr, boo::VertexSemantic::Normal4, 2},
|
||||
{m_vbo, nullptr, boo::VertexSemantic::Color}
|
||||
{m_vbo.get(), nullptr, boo::VertexSemantic::Position4},
|
||||
{m_vbo.get(), nullptr, boo::VertexSemantic::Normal4, 0},
|
||||
{m_vbo.get(), nullptr, boo::VertexSemantic::Normal4, 1},
|
||||
{m_vbo.get(), nullptr, boo::VertexSemantic::Normal4, 2},
|
||||
{m_vbo.get(), nullptr, boo::VertexSemantic::Color}
|
||||
};
|
||||
boo::IVertexFormat* vtxFmt = ctx.newVertexFormat(5, elements);
|
||||
boo::IGraphicsBuffer* ubufs[] = { m_uniBuf, m_uniBuf, m_uniBuf };
|
||||
boo::ObjToken<boo::IVertexFormat> vtxFmt = ctx.newVertexFormat(5, elements);
|
||||
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::Fragment };
|
||||
size_t ubufOffs[] = {0, 0, 768};
|
||||
size_t ubufSizes[] = {768, 768, 256};
|
||||
size_t texCount = 0;
|
||||
boo::ITexture* texs[7] = {};
|
||||
boo::ObjToken<boo::ITexture> texs[7];
|
||||
if (m_patternTex1)
|
||||
texs[texCount++] = (*m_patternTex1)->GetBooTexture();
|
||||
if (m_patternTex2)
|
||||
|
@ -628,7 +629,7 @@ boo::IShaderDataBinding* CFluidPlaneShader::BuildBinding(boo::GLDataFactory::Con
|
|||
texs[texCount++] = (*m_envBumpMap)->GetBooTexture();
|
||||
if (m_lightmap)
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
namespace urde
|
||||
{
|
||||
|
||||
static boo::IVertexFormat* s_vtxFmt = nullptr;
|
||||
static boo::ObjToken<boo::IVertexFormat> s_vtxFmt;
|
||||
|
||||
static const char* VS =
|
||||
"#include <metal_stdlib>\n"
|
||||
|
@ -148,10 +148,10 @@ static const char* FSDoor =
|
|||
" return colorOut;\n"
|
||||
"}\n";
|
||||
|
||||
boo::IShaderPipeline*
|
||||
boo::ObjToken<boo::IShaderPipeline>
|
||||
CFluidPlaneShader::BuildShader(boo::MetalDataFactory::Context& ctx, const SFluidPlaneShaderInfo& info)
|
||||
{
|
||||
if (s_vtxFmt == nullptr)
|
||||
if (!s_vtxFmt)
|
||||
{
|
||||
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 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::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, false, true, false,
|
||||
boo::CullMode::None);
|
||||
}
|
||||
|
||||
boo::IShaderPipeline*
|
||||
boo::ObjToken<boo::IShaderPipeline>
|
||||
CFluidPlaneShader::BuildShader(boo::MetalDataFactory::Context& ctx, const SFluidPlaneDoorShaderInfo& info)
|
||||
{
|
||||
if (s_vtxFmt == nullptr)
|
||||
if (!s_vtxFmt)
|
||||
{
|
||||
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 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::Primitive::TriStrips, boo::ZTest::LEqual, false, true, false,
|
||||
boo::CullMode::None);
|
||||
}
|
||||
|
||||
boo::IShaderDataBinding* CFluidPlaneShader::BuildBinding(boo::MetalDataFactory::Context& ctx,
|
||||
boo::IShaderPipeline* pipeline, bool door)
|
||||
boo::ObjToken<boo::IShaderDataBinding> CFluidPlaneShader::BuildBinding(boo::MetalDataFactory::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::Fragment };
|
||||
size_t ubufOffs[] = {0, 0, 768};
|
||||
size_t ubufSizes[] = {768, 768, 256};
|
||||
size_t texCount = 0;
|
||||
boo::ITexture* texs[7] = {};
|
||||
boo::ObjToken<boo::ITexture> texs[7];
|
||||
if (m_patternTex1)
|
||||
texs[texCount++] = (*m_patternTex1)->GetBooTexture();
|
||||
if (m_patternTex2)
|
||||
|
@ -553,7 +555,7 @@ boo::IShaderDataBinding* CFluidPlaneShader::BuildBinding(boo::MetalDataFactory::
|
|||
texs[texCount++] = (*m_envBumpMap)->GetBooTexture();
|
||||
if (m_lightmap)
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ namespace urde
|
|||
|
||||
CFogVolumeFilter::CFogVolumeFilter()
|
||||
{
|
||||
m_token = CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
|
||||
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
|
||||
{
|
||||
struct Vert
|
||||
{
|
||||
|
@ -39,8 +39,6 @@ void CFogVolumeFilter::draw1WayPass(const zeus::CColor& color)
|
|||
CGraphics::DrawArray(0, 4);
|
||||
}
|
||||
|
||||
void CFogVolumeFilter::Shutdown() {}
|
||||
|
||||
URDE_SPECIALIZE_SHADER(CFogVolumeFilter)
|
||||
|
||||
}
|
||||
|
|
|
@ -16,11 +16,10 @@ class CFogVolumeFilter
|
|||
friend struct CFogVolumeFilterMetalDataBindingFactory;
|
||||
friend struct CFogVolumeFilterD3DDataBindingFactory;
|
||||
|
||||
boo::GraphicsDataToken m_token;
|
||||
boo::IGraphicsBufferS* m_vbo;
|
||||
boo::IGraphicsBufferD* m_uniBuf;
|
||||
boo::IShaderDataBinding* m_dataBind1Way;
|
||||
boo::IShaderDataBinding* m_dataBind2Way;
|
||||
boo::ObjToken<boo::IGraphicsBufferS> m_vbo;
|
||||
boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf;
|
||||
boo::ObjToken<boo::IShaderDataBinding> m_dataBind1Way;
|
||||
boo::ObjToken<boo::IShaderDataBinding> m_dataBind2Way;
|
||||
|
||||
public:
|
||||
CFogVolumeFilter();
|
||||
|
|
|
@ -86,34 +86,34 @@ BOO_GLSL_BINDING_HEAD
|
|||
|
||||
URDE_DECL_SPECIALIZE_SHADER(CFogVolumeFilter)
|
||||
|
||||
static boo::IVertexFormat* s_VtxFmt = nullptr;
|
||||
static boo::IShaderPipeline* s_1WayPipeline = nullptr;
|
||||
static boo::IShaderPipeline* s_2WayPipeline = nullptr;
|
||||
static boo::ObjToken<boo::IVertexFormat> s_VtxFmt;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_1WayPipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_2WayPipeline;
|
||||
|
||||
struct CFogVolumeFilterGLDataBindingFactory : TShader<CFogVolumeFilter>::IDataBindingFactory
|
||||
{
|
||||
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
CFogVolumeFilter& filter)
|
||||
{
|
||||
boo::GLDataFactory::Context& cctx = static_cast<boo::GLDataFactory::Context&>(ctx);
|
||||
|
||||
const boo::VertexElementDescriptor VtxVmt[] =
|
||||
{
|
||||
{filter.m_vbo, nullptr, boo::VertexSemantic::Position4},
|
||||
{filter.m_vbo, nullptr, boo::VertexSemantic::UV4}
|
||||
{filter.m_vbo.get(), nullptr, boo::VertexSemantic::Position4},
|
||||
{filter.m_vbo.get(), nullptr, boo::VertexSemantic::UV4}
|
||||
};
|
||||
boo::IVertexFormat* VtxVmtObj = cctx.newVertexFormat(2, VtxVmt);
|
||||
boo::ITexture* texs[] = { CGraphics::g_SpareTexture, CGraphics::g_SpareTexture,
|
||||
g_Renderer->GetFogRampTex() };
|
||||
boo::ObjToken<boo::IVertexFormat> VtxVmtObj = cctx.newVertexFormat(2, VtxVmt);
|
||||
boo::ObjToken<boo::ITexture> texs[] = { CGraphics::g_SpareTexture.get(), CGraphics::g_SpareTexture.get(),
|
||||
g_Renderer->GetFogRampTex().get() };
|
||||
int bindIdxs[] = {0, 1, 0};
|
||||
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_vbo, nullptr, nullptr, 1, ubufs,
|
||||
filter.m_vbo.get(), nullptr, nullptr, 1, ubufs,
|
||||
nullptr, nullptr, nullptr, 3, texs, bindIdxs, bindDepth);
|
||||
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);
|
||||
return filter.m_dataBind1Way;
|
||||
}
|
||||
|
@ -157,6 +157,13 @@ CFogVolumeFilter::Initialize(boo::GLDataFactory::Context& ctx)
|
|||
return new CFogVolumeFilterGLDataBindingFactory;
|
||||
}
|
||||
|
||||
template <>
|
||||
void CFogVolumeFilter::Shutdown<boo::GLDataFactory>()
|
||||
{
|
||||
s_1WayPipeline.reset();
|
||||
s_2WayPipeline.reset();
|
||||
}
|
||||
|
||||
#if BOO_HAS_VULKAN
|
||||
TShader<CFogVolumeFilter>::IDataBindingFactory*
|
||||
CFogVolumeFilter::Initialize(boo::VulkanDataFactory::Context& ctx)
|
||||
|
|
|
@ -90,27 +90,27 @@ static const char* FS2Way =
|
|||
|
||||
URDE_DECL_SPECIALIZE_SHADER(CFogVolumeFilter)
|
||||
|
||||
static boo::IVertexFormat* s_VtxFmt = nullptr;
|
||||
static boo::IShaderPipeline* s_1WayPipeline = nullptr;
|
||||
static boo::IShaderPipeline* s_2WayPipeline = nullptr;
|
||||
static boo::ObjToken<boo::IVertexFormat> s_VtxFmt;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_1WayPipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_2WayPipeline;
|
||||
|
||||
struct CFogVolumeFilterMetalDataBindingFactory : TShader<CFogVolumeFilter>::IDataBindingFactory
|
||||
{
|
||||
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
CFogVolumeFilter& filter)
|
||||
{
|
||||
boo::MetalDataFactory::Context& cctx = static_cast<boo::MetalDataFactory::Context&>(ctx);
|
||||
boo::ITexture* texs[] = { CGraphics::g_SpareTexture, CGraphics::g_SpareTexture,
|
||||
g_Renderer->GetFogRampTex() };
|
||||
boo::ObjToken<boo::ITexture> texs[] = { CGraphics::g_SpareTexture.get(), CGraphics::g_SpareTexture.get(),
|
||||
g_Renderer->GetFogRampTex().get() };
|
||||
int bindIdxs[] = {0, 1, 0};
|
||||
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_vbo, nullptr, nullptr, 1, ubufs,
|
||||
filter.m_vbo.get(), nullptr, nullptr, 1, ubufs,
|
||||
nullptr, nullptr, nullptr, 3, texs, bindIdxs, bindDepth);
|
||||
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);
|
||||
return filter.m_dataBind1Way;
|
||||
}
|
||||
|
@ -125,13 +125,23 @@ CFogVolumeFilter::Initialize(boo::MetalDataFactory::Context& ctx)
|
|||
{nullptr, nullptr, boo::VertexSemantic::UV4}
|
||||
};
|
||||
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::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::ZTest::None, false, true, false, boo::CullMode::None);
|
||||
return new CFogVolumeFilterMetalDataBindingFactory;
|
||||
}
|
||||
|
||||
template <>
|
||||
void CFogVolumeFilter::Shutdown<boo::MetalDataFactory>()
|
||||
{
|
||||
s_VtxFmt.reset();
|
||||
s_1WayPipeline.reset();
|
||||
s_2WayPipeline.reset();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ namespace urde
|
|||
void CFogVolumePlaneShader::CommitResources(size_t 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);
|
||||
TShader<CFogVolumePlaneShader>::BuildShaderDataBinding(ctx, *this);
|
||||
|
@ -60,8 +60,6 @@ void CFogVolumePlaneShader::draw(int pass)
|
|||
CGraphics::DrawArray(0, m_verts.size());
|
||||
}
|
||||
|
||||
void CFogVolumePlaneShader::Shutdown() {}
|
||||
|
||||
URDE_SPECIALIZE_SHADER(CFogVolumePlaneShader)
|
||||
|
||||
}
|
||||
|
|
|
@ -17,9 +17,8 @@ class CFogVolumePlaneShader
|
|||
friend struct CFogVolumePlaneShaderMetalDataBindingFactory;
|
||||
friend struct CFogVolumePlaneShaderD3DDataBindingFactory;
|
||||
|
||||
boo::GraphicsDataToken m_token;
|
||||
boo::IGraphicsBufferD* m_vbo;
|
||||
boo::IShaderDataBinding* m_dataBinds[4];
|
||||
boo::ObjToken<boo::IGraphicsBufferD> m_vbo;
|
||||
boo::ObjToken<boo::IShaderDataBinding> m_dataBinds[4];
|
||||
std::vector<zeus::CVector4f> m_verts;
|
||||
size_t m_vertCapacity = 0;
|
||||
|
||||
|
|
|
@ -26,24 +26,24 @@ BOO_GLSL_BINDING_HEAD
|
|||
|
||||
URDE_DECL_SPECIALIZE_SHADER(CFogVolumePlaneShader)
|
||||
|
||||
static boo::IVertexFormat* s_VtxFmt = nullptr;
|
||||
static boo::IShaderPipeline* s_Pipelines[4] = {};
|
||||
static boo::ObjToken<boo::IVertexFormat> s_VtxFmt;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_Pipelines[4];
|
||||
|
||||
struct CFogVolumePlaneShaderGLDataBindingFactory : TShader<CFogVolumePlaneShader>::IDataBindingFactory
|
||||
{
|
||||
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
CFogVolumePlaneShader& filter)
|
||||
{
|
||||
boo::GLDataFactory::Context& cctx = static_cast<boo::GLDataFactory::Context&>(ctx);
|
||||
|
||||
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)
|
||||
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);
|
||||
return filter.m_dataBinds[0];
|
||||
}
|
||||
|
@ -84,6 +84,15 @@ CFogVolumePlaneShader::Initialize(boo::GLDataFactory::Context& ctx)
|
|||
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
|
||||
TShader<CFogVolumePlaneShader>::IDataBindingFactory*
|
||||
CFogVolumePlaneShader::Initialize(boo::VulkanDataFactory::Context& ctx)
|
||||
|
|
|
@ -39,19 +39,19 @@ static const char* FS =
|
|||
|
||||
URDE_DECL_SPECIALIZE_SHADER(CFogVolumePlaneShader)
|
||||
|
||||
static boo::IVertexFormat* s_VtxFmt = nullptr;
|
||||
static boo::IShaderPipeline* s_Pipelines[4] = {};
|
||||
static boo::ObjToken<boo::IVertexFormat> s_VtxFmt;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_Pipelines[4];
|
||||
|
||||
struct CFogVolumePlaneShaderMetalDataBindingFactory : TShader<CFogVolumePlaneShader>::IDataBindingFactory
|
||||
{
|
||||
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
CFogVolumePlaneShader& filter)
|
||||
{
|
||||
boo::MetalDataFactory::Context& cctx = static_cast<boo::MetalDataFactory::Context&>(ctx);
|
||||
|
||||
for (int i=0 ; i<4 ; ++i)
|
||||
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);
|
||||
return filter.m_dataBinds[0];
|
||||
}
|
||||
|
@ -65,19 +65,33 @@ CFogVolumePlaneShader::Initialize(boo::MetalDataFactory::Context& ctx)
|
|||
{nullptr, nullptr, boo::VertexSemantic::Position4}
|
||||
};
|
||||
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::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::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::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::ZTest::Greater, false, false, false, boo::CullMode::Backface);
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,24 +3,23 @@
|
|||
namespace urde
|
||||
{
|
||||
|
||||
boo::IShaderPipeline* CLineRendererShaders::m_texAlpha = nullptr;
|
||||
boo::IShaderPipeline* CLineRendererShaders::m_texAdditive = nullptr;
|
||||
boo::ObjToken<boo::IShaderPipeline> CLineRendererShaders::m_texAlpha;
|
||||
boo::ObjToken<boo::IShaderPipeline> CLineRendererShaders::m_texAdditive;
|
||||
|
||||
boo::IShaderPipeline* CLineRendererShaders::m_noTexAlpha = nullptr;
|
||||
boo::IShaderPipeline* CLineRendererShaders::m_noTexAdditive = nullptr;
|
||||
boo::ObjToken<boo::IShaderPipeline> CLineRendererShaders::m_noTexAlpha;
|
||||
boo::ObjToken<boo::IShaderPipeline> CLineRendererShaders::m_noTexAdditive;
|
||||
|
||||
boo::IVertexFormat* CLineRendererShaders::m_texVtxFmt = nullptr;
|
||||
boo::IVertexFormat* CLineRendererShaders::m_noTexVtxFmt = nullptr;
|
||||
boo::ObjToken<boo::IVertexFormat> CLineRendererShaders::m_texVtxFmt;
|
||||
boo::ObjToken<boo::IVertexFormat> CLineRendererShaders::m_noTexVtxFmt;
|
||||
|
||||
std::unique_ptr<CLineRendererShaders::IDataBindingFactory> CLineRendererShaders::m_bindFactory;
|
||||
boo::GraphicsDataToken CLineRendererShaders::m_gfxToken;
|
||||
|
||||
void CLineRendererShaders::Initialize()
|
||||
{
|
||||
if (!CGraphics::g_BooFactory)
|
||||
return;
|
||||
|
||||
m_gfxToken = CGraphics::CommitResources(
|
||||
CGraphics::CommitResources(
|
||||
[&](boo::IGraphicsDataFactory::Context& ctx) -> bool
|
||||
{
|
||||
switch (ctx.platform())
|
||||
|
@ -52,15 +51,20 @@ void CLineRendererShaders::Initialize()
|
|||
|
||||
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,
|
||||
CLineRenderer& renderer,
|
||||
boo::ITexture* texture,
|
||||
const boo::ObjToken<boo::ITexture>& texture,
|
||||
bool additive)
|
||||
{
|
||||
boo::IShaderPipeline* pipeline = nullptr;
|
||||
boo::ObjToken<boo::IShaderPipeline> pipeline;
|
||||
if (texture)
|
||||
{
|
||||
if (additive)
|
||||
|
|
|
@ -18,22 +18,21 @@ public:
|
|||
{
|
||||
virtual void BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
CLineRenderer& renderer,
|
||||
boo::IShaderPipeline* pipeline,
|
||||
boo::ITexture* texture)=0;
|
||||
const boo::ObjToken<boo::IShaderPipeline>& pipeline,
|
||||
const boo::ObjToken<boo::ITexture>& texture)=0;
|
||||
};
|
||||
|
||||
private:
|
||||
static boo::IShaderPipeline* m_texAlpha;
|
||||
static boo::IShaderPipeline* m_texAdditive;
|
||||
static boo::ObjToken<boo::IShaderPipeline> m_texAlpha;
|
||||
static boo::ObjToken<boo::IShaderPipeline> m_texAdditive;
|
||||
|
||||
static boo::IShaderPipeline* m_noTexAlpha;
|
||||
static boo::IShaderPipeline* m_noTexAdditive;
|
||||
static boo::ObjToken<boo::IShaderPipeline> m_noTexAlpha;
|
||||
static boo::ObjToken<boo::IShaderPipeline> m_noTexAdditive;
|
||||
|
||||
static boo::IVertexFormat* m_texVtxFmt;
|
||||
static boo::IVertexFormat* m_noTexVtxFmt;
|
||||
static boo::ObjToken<boo::IVertexFormat> m_texVtxFmt;
|
||||
static boo::ObjToken<boo::IVertexFormat> m_noTexVtxFmt;
|
||||
|
||||
static std::unique_ptr<IDataBindingFactory> m_bindFactory;
|
||||
static boo::GraphicsDataToken m_gfxToken;
|
||||
|
||||
public:
|
||||
static IDataBindingFactory* Initialize(boo::GLDataFactory::Context& ctx);
|
||||
|
@ -50,7 +49,7 @@ public:
|
|||
static void Initialize();
|
||||
static void Shutdown();
|
||||
static void BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, CLineRenderer& renderer,
|
||||
boo::ITexture* texture, bool additive);
|
||||
const boo::ObjToken<boo::ITexture>& texture, bool additive);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -88,15 +88,19 @@ BOO_GLSL_BINDING_HEAD
|
|||
|
||||
struct OGLLineDataBindingFactory : CLineRendererShaders::IDataBindingFactory
|
||||
{
|
||||
void BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, CLineRenderer& renderer,
|
||||
boo::IShaderPipeline* pipeline, boo::ITexture* texture)
|
||||
void BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
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;
|
||||
boo::ITexture* textures[1];
|
||||
boo::ObjToken<boo::ITexture> textures[1];
|
||||
|
||||
std::pair<boo::IGraphicsBufferD*, hecl::VertexBufferPool<CLineRenderer::SDrawVertTex>::IndexTp> vbufInfo;
|
||||
std::pair<boo::IGraphicsBufferD*, hecl::UniformBufferPool<CLineRenderer::SDrawUniform>::IndexTp> ubufInfo =
|
||||
std::pair<boo::ObjToken<boo::IGraphicsBufferD>,
|
||||
hecl::VertexBufferPool<CLineRenderer::SDrawVertTex>::IndexTp> vbufInfo;
|
||||
std::pair<boo::ObjToken<boo::IGraphicsBufferD>,
|
||||
hecl::UniformBufferPool<CLineRenderer::SDrawUniform>::IndexTp> ubufInfo =
|
||||
renderer.m_uniformBuf.getBufferInfo();
|
||||
if (texture)
|
||||
{
|
||||
|
@ -105,9 +109,9 @@ struct OGLLineDataBindingFactory : CLineRendererShaders::IDataBindingFactory
|
|||
texCount = 1;
|
||||
const boo::VertexElementDescriptor TexFmtTex[] =
|
||||
{
|
||||
{vbufInfo.first, nullptr, boo::VertexSemantic::Position4},
|
||||
{vbufInfo.first, nullptr, boo::VertexSemantic::Color},
|
||||
{vbufInfo.first, nullptr, boo::VertexSemantic::UV4}
|
||||
{vbufInfo.first.get(), nullptr, boo::VertexSemantic::Position4},
|
||||
{vbufInfo.first.get(), nullptr, boo::VertexSemantic::Color},
|
||||
{vbufInfo.first.get(), nullptr, boo::VertexSemantic::UV4}
|
||||
};
|
||||
vtxFmt = ctx.newVertexFormat(3, TexFmtTex);
|
||||
}
|
||||
|
@ -116,18 +120,18 @@ struct OGLLineDataBindingFactory : CLineRendererShaders::IDataBindingFactory
|
|||
vbufInfo = renderer.m_vertBufNoTex.getBufferInfo();
|
||||
const boo::VertexElementDescriptor TexFmtNoTex[] =
|
||||
{
|
||||
{vbufInfo.first, nullptr, boo::VertexSemantic::Position4},
|
||||
{vbufInfo.first, nullptr, boo::VertexSemantic::Color}
|
||||
{vbufInfo.first.get(), nullptr, boo::VertexSemantic::Position4},
|
||||
{vbufInfo.first.get(), nullptr, boo::VertexSemantic::Color}
|
||||
};
|
||||
vtxFmt = ctx.newVertexFormat(2, TexFmtNoTex);
|
||||
}
|
||||
|
||||
boo::IGraphicsBuffer* uniforms[] = {ubufInfo.first};
|
||||
boo::ObjToken<boo::IGraphicsBuffer> uniforms[] = {ubufInfo.first.get()};
|
||||
boo::PipelineStage stages[] = {boo::PipelineStage::Vertex};
|
||||
size_t ubufOffs[] = {size_t(ubufInfo.second)};
|
||||
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,
|
||||
ubufOffs, ubufSizes, texCount, textures,
|
||||
nullptr, nullptr, vbufInfo.second);
|
||||
|
|
|
@ -103,14 +103,18 @@ static const char* FS_METAL_NOTEX =
|
|||
|
||||
struct MetalLineDataBindingFactory : CLineRendererShaders::IDataBindingFactory
|
||||
{
|
||||
void BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, CLineRenderer& renderer,
|
||||
boo::IShaderPipeline* pipeline, boo::ITexture* texture)
|
||||
void BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
CLineRenderer& renderer,
|
||||
const boo::ObjToken<boo::IShaderPipeline>& pipeline,
|
||||
const boo::ObjToken<boo::ITexture>& texture)
|
||||
{
|
||||
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::IGraphicsBufferD*, hecl::UniformBufferPool<CLineRenderer::SDrawUniform>::IndexTp> ubufInfo =
|
||||
std::pair<boo::ObjToken<boo::IGraphicsBufferD>,
|
||||
hecl::VertexBufferPool<CLineRenderer::SDrawVertTex>::IndexTp> vbufInfo;
|
||||
std::pair<boo::ObjToken<boo::IGraphicsBufferD>,
|
||||
hecl::UniformBufferPool<CLineRenderer::SDrawUniform>::IndexTp> ubufInfo =
|
||||
renderer.m_uniformBuf.getBufferInfo();
|
||||
if (texture)
|
||||
{
|
||||
|
@ -123,12 +127,12 @@ struct MetalLineDataBindingFactory : CLineRendererShaders::IDataBindingFactory
|
|||
vbufInfo = renderer.m_vertBufNoTex.getBufferInfo();
|
||||
}
|
||||
|
||||
boo::IGraphicsBuffer* uniforms[] = {ubufInfo.first};
|
||||
boo::ObjToken<boo::IGraphicsBuffer> uniforms[] = {ubufInfo.first.get()};
|
||||
boo::PipelineStage stages[] = {boo::PipelineStage::Vertex};
|
||||
size_t ubufOffs[] = {ubufInfo.second};
|
||||
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,
|
||||
ubufOffs, ubufSizes, texCount, textures,
|
||||
nullptr, nullptr, vbufInfo.second);
|
||||
|
@ -152,19 +156,19 @@ CLineRendererShaders::IDataBindingFactory* CLineRendererShaders::Initialize(boo:
|
|||
};
|
||||
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,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
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,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
|
||||
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,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
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,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
|
||||
boo::Primitive::TriStrips, boo::ZTest::None, false, true, true, boo::CullMode::None);
|
||||
|
|
|
@ -4,8 +4,8 @@ namespace urde
|
|||
{
|
||||
|
||||
CMapSurfaceShader::CMapSurfaceShader(boo::IGraphicsDataFactory::Context& ctx,
|
||||
boo::IGraphicsBufferS* vbo,
|
||||
boo::IGraphicsBufferS* ibo)
|
||||
const boo::ObjToken<boo::IGraphicsBufferS>& vbo,
|
||||
const boo::ObjToken<boo::IGraphicsBufferS>& ibo)
|
||||
: m_vbo(vbo), m_ibo(ibo)
|
||||
{
|
||||
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)
|
||||
|
||||
void CMapSurfaceShader::Shutdown() {}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,14 +19,14 @@ class CMapSurfaceShader
|
|||
zeus::CColor color;
|
||||
};
|
||||
|
||||
boo::IGraphicsBufferD* m_uniBuf;
|
||||
boo::IGraphicsBufferS* m_vbo;
|
||||
boo::IGraphicsBufferS* m_ibo;
|
||||
boo::IShaderDataBinding* m_dataBind;
|
||||
boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf;
|
||||
boo::ObjToken<boo::IGraphicsBufferS> m_vbo;
|
||||
boo::ObjToken<boo::IGraphicsBufferS> m_ibo;
|
||||
boo::ObjToken<boo::IShaderDataBinding> m_dataBind;
|
||||
|
||||
public:
|
||||
CMapSurfaceShader(boo::IGraphicsDataFactory::Context& ctx, boo::IGraphicsBufferS* vbo,
|
||||
boo::IGraphicsBufferS* ibo);
|
||||
CMapSurfaceShader(boo::IGraphicsDataFactory::Context& ctx, const boo::ObjToken<boo::IGraphicsBufferS>& vbo,
|
||||
const boo::ObjToken<boo::IGraphicsBufferS>& ibo);
|
||||
void draw(const zeus::CColor& color, u32 start, u32 count);
|
||||
|
||||
using _CLS = CMapSurfaceShader;
|
||||
|
|
|
@ -44,25 +44,25 @@ BOO_GLSL_BINDING_HEAD
|
|||
|
||||
URDE_DECL_SPECIALIZE_SHADER(CMapSurfaceShader)
|
||||
|
||||
static boo::IVertexFormat* s_VtxFmt = nullptr;
|
||||
static boo::IShaderPipeline* s_Pipeline = nullptr;
|
||||
static boo::ObjToken<boo::IVertexFormat> s_VtxFmt;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_Pipeline;
|
||||
|
||||
struct CMapSurfaceShaderGLDataBindingFactory : TShader<CMapSurfaceShader>::IDataBindingFactory
|
||||
{
|
||||
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
CMapSurfaceShader& filter)
|
||||
{
|
||||
boo::GLDataFactory::Context& cctx = static_cast<boo::GLDataFactory::Context&>(ctx);
|
||||
|
||||
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::IGraphicsBuffer* bufs[] = {filter.m_uniBuf};
|
||||
boo::ObjToken<boo::IVertexFormat> vtxFmt = ctx.newVertexFormat(1, VtxVmt);
|
||||
boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {filter.m_uniBuf.get()};
|
||||
boo::PipelineStage stages[] = {boo::PipelineStage::Vertex};
|
||||
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);
|
||||
return filter.m_dataBind;
|
||||
}
|
||||
|
@ -96,6 +96,12 @@ CMapSurfaceShader::Initialize(boo::GLDataFactory::Context& ctx)
|
|||
return new CMapSurfaceShaderGLDataBindingFactory;
|
||||
}
|
||||
|
||||
template <>
|
||||
void CMapSurfaceShader::Shutdown<boo::GLDataFactory>()
|
||||
{
|
||||
s_Pipeline.reset();
|
||||
}
|
||||
|
||||
#if BOO_HAS_VULKAN
|
||||
TShader<CMapSurfaceShader>::IDataBindingFactory*
|
||||
CMapSurfaceShader::Initialize(boo::VulkanDataFactory::Context& ctx)
|
||||
|
|
|
@ -48,19 +48,19 @@ static const char* FS =
|
|||
|
||||
URDE_DECL_SPECIALIZE_SHADER(CMapSurfaceShader)
|
||||
|
||||
static boo::IVertexFormat* s_VtxFmt = nullptr;
|
||||
static boo::IShaderPipeline* s_Pipeline = nullptr;
|
||||
static boo::ObjToken<boo::IVertexFormat> s_VtxFmt;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_Pipeline;
|
||||
|
||||
struct CMapSurfaceShaderMetalDataBindingFactory : TShader<CMapSurfaceShader>::IDataBindingFactory
|
||||
{
|
||||
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
CMapSurfaceShader& filter)
|
||||
{
|
||||
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_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);
|
||||
return filter.m_dataBind;
|
||||
}
|
||||
|
@ -74,10 +74,18 @@ CMapSurfaceShader::Initialize(boo::MetalDataFactory::Context& ctx)
|
|||
{nullptr, nullptr, boo::VertexSemantic::Position4}
|
||||
};
|
||||
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::ZTest::LEqual, false, true, false, boo::CullMode::Backface);
|
||||
return new CMapSurfaceShaderMetalDataBindingFactory;
|
||||
}
|
||||
|
||||
template <>
|
||||
void CMapSurfaceShader::Shutdown<boo::MetalDataFactory>()
|
||||
{
|
||||
s_VtxFmt.reset();
|
||||
s_Pipeline.reset();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -5,17 +5,17 @@
|
|||
namespace urde
|
||||
{
|
||||
|
||||
boo::IShaderPipeline* CParticleSwooshShaders::m_texZWrite = nullptr;
|
||||
boo::IShaderPipeline* CParticleSwooshShaders::m_texNoZWrite = nullptr;
|
||||
boo::IShaderPipeline* CParticleSwooshShaders::m_texAdditiveZWrite = nullptr;
|
||||
boo::IShaderPipeline* CParticleSwooshShaders::m_texAdditiveNoZWrite = nullptr;
|
||||
boo::ObjToken<boo::IShaderPipeline> CParticleSwooshShaders::m_texZWrite;
|
||||
boo::ObjToken<boo::IShaderPipeline> CParticleSwooshShaders::m_texNoZWrite;
|
||||
boo::ObjToken<boo::IShaderPipeline> CParticleSwooshShaders::m_texAdditiveZWrite;
|
||||
boo::ObjToken<boo::IShaderPipeline> CParticleSwooshShaders::m_texAdditiveNoZWrite;
|
||||
|
||||
boo::IShaderPipeline* CParticleSwooshShaders::m_noTexZWrite = nullptr;
|
||||
boo::IShaderPipeline* CParticleSwooshShaders::m_noTexNoZWrite = nullptr;
|
||||
boo::IShaderPipeline* CParticleSwooshShaders::m_noTexAdditiveZWrite = nullptr;
|
||||
boo::IShaderPipeline* CParticleSwooshShaders::m_noTexAdditiveNoZWrite = nullptr;
|
||||
boo::ObjToken<boo::IShaderPipeline> CParticleSwooshShaders::m_noTexZWrite;
|
||||
boo::ObjToken<boo::IShaderPipeline> CParticleSwooshShaders::m_noTexNoZWrite;
|
||||
boo::ObjToken<boo::IShaderPipeline> CParticleSwooshShaders::m_noTexAdditiveZWrite;
|
||||
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)
|
||||
{
|
||||
|
@ -30,7 +30,7 @@ CParticleSwooshShaders::EShaderClass CParticleSwooshShaders::GetShaderClass(CPar
|
|||
void CParticleSwooshShaders::BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, CParticleSwoosh& gen)
|
||||
{
|
||||
CSwooshDescription* desc = gen.GetDesc();
|
||||
boo::IShaderPipeline* pipeline = nullptr;
|
||||
boo::ObjToken<boo::IShaderPipeline> pipeline;
|
||||
|
||||
if (desc->x3c_TEXR)
|
||||
{
|
||||
|
@ -71,8 +71,6 @@ void CParticleSwooshShaders::BuildShaderDataBinding(boo::IGraphicsDataFactory::C
|
|||
TShader<CParticleSwooshShaders>::BuildShaderDataBinding(ctx, shad);
|
||||
}
|
||||
|
||||
void CParticleSwooshShaders::Shutdown() {}
|
||||
|
||||
URDE_SPECIALIZE_SHADER(CParticleSwooshShaders)
|
||||
|
||||
}
|
||||
|
|
|
@ -33,21 +33,21 @@ public:
|
|||
};
|
||||
|
||||
private:
|
||||
static boo::IShaderPipeline* m_texZWrite;
|
||||
static boo::IShaderPipeline* m_texNoZWrite;
|
||||
static boo::IShaderPipeline* m_texAdditiveZWrite;
|
||||
static boo::IShaderPipeline* m_texAdditiveNoZWrite;
|
||||
static boo::ObjToken<boo::IShaderPipeline> m_texZWrite;
|
||||
static boo::ObjToken<boo::IShaderPipeline> m_texNoZWrite;
|
||||
static boo::ObjToken<boo::IShaderPipeline> m_texAdditiveZWrite;
|
||||
static boo::ObjToken<boo::IShaderPipeline> m_texAdditiveNoZWrite;
|
||||
|
||||
static boo::IShaderPipeline* m_noTexZWrite;
|
||||
static boo::IShaderPipeline* m_noTexNoZWrite;
|
||||
static boo::IShaderPipeline* m_noTexAdditiveZWrite;
|
||||
static boo::IShaderPipeline* m_noTexAdditiveNoZWrite;
|
||||
static boo::ObjToken<boo::IShaderPipeline> m_noTexZWrite;
|
||||
static boo::ObjToken<boo::IShaderPipeline> m_noTexNoZWrite;
|
||||
static boo::ObjToken<boo::IShaderPipeline> m_noTexAdditiveZWrite;
|
||||
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;
|
||||
boo::IShaderPipeline* m_pipeline;
|
||||
CParticleSwooshShaders(CParticleSwoosh& gen, boo::IShaderPipeline* pipeline)
|
||||
boo::ObjToken<boo::IShaderPipeline> m_pipeline;
|
||||
CParticleSwooshShaders(CParticleSwoosh& gen, const boo::ObjToken<boo::IShaderPipeline>& pipeline)
|
||||
: m_gen(gen), m_pipeline(pipeline) {}
|
||||
|
||||
public:
|
||||
|
|
|
@ -66,25 +66,25 @@ BOO_GLSL_BINDING_HEAD
|
|||
|
||||
struct OGLParticleSwooshDataBindingFactory : TShader<CParticleSwooshShaders>::IDataBindingFactory
|
||||
{
|
||||
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
CParticleSwooshShaders& shaders)
|
||||
{
|
||||
CParticleSwoosh& gen = shaders.m_gen;
|
||||
CSwooshDescription* desc = gen.GetDesc();
|
||||
|
||||
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[] =
|
||||
{
|
||||
{gen.m_vertBuf, nullptr, boo::VertexSemantic::Position4},
|
||||
{gen.m_vertBuf, nullptr, boo::VertexSemantic::UV4},
|
||||
{gen.m_vertBuf, nullptr, boo::VertexSemantic::Color},
|
||||
{gen.m_vertBuf.get(), nullptr, boo::VertexSemantic::Position4},
|
||||
{gen.m_vertBuf.get(), nullptr, boo::VertexSemantic::UV4},
|
||||
{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};
|
||||
gen.m_dataBind = ctx.newShaderDataBinding(shaders.m_pipeline, vtxFmt, gen.m_vertBuf,
|
||||
boo::ObjToken<boo::IGraphicsBuffer> uniforms[] = {gen.m_uniformBuf.get()};
|
||||
gen.m_dataBind = ctx.newShaderDataBinding(shaders.m_pipeline, vtxFmt, gen.m_vertBuf.get(),
|
||||
nullptr, nullptr, 1, uniforms,
|
||||
nullptr, texr ? 1 : 0, textures, nullptr, nullptr);
|
||||
return nullptr;
|
||||
|
@ -133,6 +133,20 @@ TShader<CParticleSwooshShaders>::IDataBindingFactory* CParticleSwooshShaders::In
|
|||
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
|
||||
struct VulkanParticleSwooshDataBindingFactory : TShader<CParticleSwooshShaders>::IDataBindingFactory
|
||||
{
|
||||
|
|
|
@ -70,18 +70,18 @@ static const char* FS_NOTEX =
|
|||
|
||||
struct MetalParticleSwooshDataBindingFactory : TShader<CParticleSwooshShaders>::IDataBindingFactory
|
||||
{
|
||||
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
CParticleSwooshShaders& shaders)
|
||||
{
|
||||
CParticleSwoosh& gen = shaders.m_gen;
|
||||
CSwooshDescription* desc = gen.GetDesc();
|
||||
|
||||
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_vertBuf, nullptr, nullptr, 1, uniforms,
|
||||
gen.m_vertBuf.get(), nullptr, nullptr, 1, uniforms,
|
||||
nullptr, texr ? 1 : 0, textures, nullptr, nullptr);
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -97,36 +97,44 @@ TShader<CParticleSwooshShaders>::IDataBindingFactory* CParticleSwooshShaders::In
|
|||
};
|
||||
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::Primitive::TriStrips, boo::ZTest::LEqual, true,
|
||||
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::Primitive::TriStrips, boo::ZTest::LEqual, false,
|
||||
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::Primitive::TriStrips, boo::ZTest::LEqual, true,
|
||||
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::Primitive::TriStrips, boo::ZTest::LEqual, false,
|
||||
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::Primitive::TriStrips, boo::ZTest::LEqual, true,
|
||||
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::Primitive::TriStrips, boo::ZTest::LEqual, false,
|
||||
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::Primitive::TriStrips, boo::ZTest::LEqual, true,
|
||||
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::Primitive::TriStrips, boo::ZTest::LEqual, false,
|
||||
true, false, boo::CullMode::None);
|
||||
|
@ -134,4 +142,20 @@ TShader<CParticleSwooshShaders>::IDataBindingFactory* CParticleSwooshShaders::In
|
|||
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();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,8 +8,7 @@ void CPhazonSuitFilter::drawBlurPasses(float radius, const CTexture* indTex)
|
|||
if (!m_dataBind || indTex != m_indTex)
|
||||
{
|
||||
m_indTex = indTex;
|
||||
m_gfxTok = CGraphics::CommitResources(
|
||||
[this](boo::IGraphicsDataFactory::Context& ctx)
|
||||
CGraphics::CommitResources([this](boo::IGraphicsDataFactory::Context& ctx)
|
||||
{
|
||||
m_uniBufBlurX = 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);
|
||||
}
|
||||
|
||||
void CPhazonSuitFilter::Shutdown() {}
|
||||
|
||||
URDE_SPECIALIZE_SHADER(CPhazonSuitFilter)
|
||||
|
||||
}
|
||||
|
|
|
@ -14,16 +14,15 @@ class CPhazonSuitFilter
|
|||
friend struct CPhazonSuitFilterMetalDataBindingFactory;
|
||||
friend struct CPhazonSuitFilterD3DDataBindingFactory;
|
||||
|
||||
boo::GraphicsDataToken m_gfxTok;
|
||||
boo::IGraphicsBufferD* m_uniBufBlurX;
|
||||
boo::IGraphicsBufferD* m_uniBufBlurY;
|
||||
boo::IGraphicsBufferD* m_uniBuf;
|
||||
boo::IGraphicsBufferS* m_blurVbo;
|
||||
boo::IGraphicsBufferS* m_vbo;
|
||||
boo::ObjToken<boo::IGraphicsBufferD> m_uniBufBlurX;
|
||||
boo::ObjToken<boo::IGraphicsBufferD> m_uniBufBlurY;
|
||||
boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf;
|
||||
boo::ObjToken<boo::IGraphicsBufferS> m_blurVbo;
|
||||
boo::ObjToken<boo::IGraphicsBufferS> m_vbo;
|
||||
const CTexture* m_indTex = nullptr;
|
||||
boo::IShaderDataBinding* m_dataBindBlurX = nullptr;
|
||||
boo::IShaderDataBinding* m_dataBindBlurY = nullptr;
|
||||
boo::IShaderDataBinding* m_dataBind = nullptr;
|
||||
boo::ObjToken<boo::IShaderDataBinding> m_dataBindBlurX;
|
||||
boo::ObjToken<boo::IShaderDataBinding> m_dataBindBlurY;
|
||||
boo::ObjToken<boo::IShaderDataBinding> m_dataBind;
|
||||
|
||||
public:
|
||||
void drawBlurPasses(float radius, const CTexture* indTex);
|
||||
|
|
|
@ -149,80 +149,80 @@ BOO_GLSL_BINDING_HEAD
|
|||
|
||||
URDE_DECL_SPECIALIZE_SHADER(CPhazonSuitFilter)
|
||||
|
||||
static boo::IVertexFormat* s_VtxFmt = nullptr;
|
||||
static boo::IVertexFormat* s_BlurVtxFmt = nullptr;
|
||||
static boo::IShaderPipeline* s_IndPipeline = nullptr;
|
||||
static boo::IShaderPipeline* s_Pipeline = nullptr;
|
||||
static boo::IShaderPipeline* s_BlurPipeline = nullptr;
|
||||
static boo::ObjToken<boo::IVertexFormat> s_VtxFmt;
|
||||
static boo::ObjToken<boo::IVertexFormat> s_BlurVtxFmt;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_IndPipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_Pipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_BlurPipeline;
|
||||
|
||||
struct CPhazonSuitFilterGLDataBindingFactory : TShader<CPhazonSuitFilter>::IDataBindingFactory
|
||||
{
|
||||
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
CPhazonSuitFilter& filter)
|
||||
{
|
||||
boo::GLDataFactory::Context& cctx = static_cast<boo::GLDataFactory::Context&>(ctx);
|
||||
|
||||
const boo::VertexElementDescriptor BlurVtxVmt[] =
|
||||
{
|
||||
{filter.m_blurVbo, nullptr, boo::VertexSemantic::Position4},
|
||||
{filter.m_blurVbo, nullptr, boo::VertexSemantic::UV4}
|
||||
{filter.m_blurVbo.get(), nullptr, boo::VertexSemantic::Position4},
|
||||
{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::ITexture* texs[4];
|
||||
boo::ObjToken<boo::ITexture> texs[4];
|
||||
int texBindIdxs[4];
|
||||
|
||||
texs[0] = CGraphics::g_SpareTexture;
|
||||
texs[0] = CGraphics::g_SpareTexture.get();
|
||||
texBindIdxs[0] = 1;
|
||||
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);
|
||||
|
||||
bufs[0] = filter.m_uniBufBlurY;
|
||||
texs[0] = CGraphics::g_SpareTexture;
|
||||
bufs[0] = filter.m_uniBufBlurY.get();
|
||||
texs[0] = CGraphics::g_SpareTexture.get();
|
||||
texBindIdxs[0] = 2;
|
||||
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);
|
||||
|
||||
const boo::VertexElementDescriptor VtxVmt[] =
|
||||
{
|
||||
{filter.m_vbo, nullptr, boo::VertexSemantic::Position4},
|
||||
{filter.m_vbo, nullptr, boo::VertexSemantic::UV4, 0},
|
||||
{filter.m_vbo, nullptr, boo::VertexSemantic::UV4, 1},
|
||||
{filter.m_vbo, nullptr, boo::VertexSemantic::UV4, 2}
|
||||
{filter.m_vbo.get(), nullptr, boo::VertexSemantic::Position4},
|
||||
{filter.m_vbo.get(), nullptr, boo::VertexSemantic::UV4, 0},
|
||||
{filter.m_vbo.get(), nullptr, boo::VertexSemantic::UV4, 1},
|
||||
{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;
|
||||
if (filter.m_indTex)
|
||||
{
|
||||
texs[0] = CGraphics::g_SpareTexture;
|
||||
texs[0] = CGraphics::g_SpareTexture.get();
|
||||
texBindIdxs[0] = 0;
|
||||
texs[1] = filter.m_indTex->GetBooTexture();
|
||||
texBindIdxs[1] = 0;
|
||||
texs[2] = CGraphics::g_SpareTexture;
|
||||
texs[2] = CGraphics::g_SpareTexture.get();
|
||||
texBindIdxs[2] = 1;
|
||||
texs[3] = CGraphics::g_SpareTexture;
|
||||
texs[3] = CGraphics::g_SpareTexture.get();
|
||||
texBindIdxs[3] = 2;
|
||||
texCount = 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
texs[0] = CGraphics::g_SpareTexture;
|
||||
texs[0] = CGraphics::g_SpareTexture.get();
|
||||
texBindIdxs[0] = 0;
|
||||
texs[1] = CGraphics::g_SpareTexture;
|
||||
texs[1] = CGraphics::g_SpareTexture.get();
|
||||
texBindIdxs[1] = 1;
|
||||
texs[2] = CGraphics::g_SpareTexture;
|
||||
texs[2] = CGraphics::g_SpareTexture.get();
|
||||
texBindIdxs[2] = 2;
|
||||
texCount = 3;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
};
|
||||
|
@ -306,6 +306,14 @@ CPhazonSuitFilter::Initialize(boo::GLDataFactory::Context& ctx)
|
|||
return new CPhazonSuitFilterGLDataBindingFactory;
|
||||
}
|
||||
|
||||
template <>
|
||||
void CPhazonSuitFilter::Shutdown<boo::GLDataFactory>()
|
||||
{
|
||||
s_IndPipeline.reset();
|
||||
s_Pipeline.reset();
|
||||
s_BlurPipeline.reset();
|
||||
}
|
||||
|
||||
#if BOO_HAS_VULKAN
|
||||
TShader<CPhazonSuitFilter>::IDataBindingFactory*
|
||||
CPhazonSuitFilter::Initialize(boo::VulkanDataFactory::Context& ctx)
|
||||
|
|
|
@ -158,64 +158,64 @@ static const char* BlurFS =
|
|||
|
||||
URDE_DECL_SPECIALIZE_SHADER(CPhazonSuitFilter)
|
||||
|
||||
static boo::IVertexFormat* s_VtxFmt = nullptr;
|
||||
static boo::IVertexFormat* s_BlurVtxFmt = nullptr;
|
||||
static boo::IShaderPipeline* s_IndPipeline = nullptr;
|
||||
static boo::IShaderPipeline* s_Pipeline = nullptr;
|
||||
static boo::IShaderPipeline* s_BlurPipeline = nullptr;
|
||||
static boo::ObjToken<boo::IVertexFormat> s_VtxFmt;
|
||||
static boo::ObjToken<boo::IVertexFormat> s_BlurVtxFmt;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_IndPipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_Pipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_BlurPipeline;
|
||||
|
||||
struct CPhazonSuitFilterMetalDataBindingFactory : TShader<CPhazonSuitFilter>::IDataBindingFactory
|
||||
{
|
||||
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
CPhazonSuitFilter& filter)
|
||||
{
|
||||
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::ITexture* texs[4];
|
||||
boo::ObjToken<boo::ITexture> texs[4];
|
||||
int texBindIdxs[4];
|
||||
|
||||
texs[0] = CGraphics::g_SpareTexture;
|
||||
texs[0] = CGraphics::g_SpareTexture.get();
|
||||
texBindIdxs[0] = 1;
|
||||
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);
|
||||
|
||||
bufs[0] = filter.m_uniBufBlurY;
|
||||
texs[0] = CGraphics::g_SpareTexture;
|
||||
bufs[0] = filter.m_uniBufBlurY.get();
|
||||
texs[0] = CGraphics::g_SpareTexture.get();
|
||||
texBindIdxs[0] = 2;
|
||||
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);
|
||||
|
||||
bufs[0] = filter.m_uniBuf;
|
||||
bufs[0] = filter.m_uniBuf.get();
|
||||
size_t texCount;
|
||||
if (filter.m_indTex)
|
||||
{
|
||||
texs[0] = CGraphics::g_SpareTexture;
|
||||
texs[0] = CGraphics::g_SpareTexture.get();
|
||||
texBindIdxs[0] = 0;
|
||||
texs[1] = filter.m_indTex->GetBooTexture();
|
||||
texBindIdxs[1] = 0;
|
||||
texs[2] = CGraphics::g_SpareTexture;
|
||||
texs[2] = CGraphics::g_SpareTexture.get();
|
||||
texBindIdxs[2] = 1;
|
||||
texs[3] = CGraphics::g_SpareTexture;
|
||||
texs[3] = CGraphics::g_SpareTexture.get();
|
||||
texBindIdxs[3] = 2;
|
||||
texCount = 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
texs[0] = CGraphics::g_SpareTexture;
|
||||
texs[0] = CGraphics::g_SpareTexture.get();
|
||||
texBindIdxs[0] = 0;
|
||||
texs[1] = CGraphics::g_SpareTexture;
|
||||
texs[1] = CGraphics::g_SpareTexture.get();
|
||||
texBindIdxs[1] = 1;
|
||||
texs[2] = CGraphics::g_SpareTexture;
|
||||
texs[2] = CGraphics::g_SpareTexture.get();
|
||||
texBindIdxs[2] = 2;
|
||||
texCount = 3;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
};
|
||||
|
@ -237,19 +237,29 @@ CPhazonSuitFilter::Initialize(boo::MetalDataFactory::Context& ctx)
|
|||
{nullptr, nullptr, boo::VertexSemantic::UV4}
|
||||
};
|
||||
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,
|
||||
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips,
|
||||
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,
|
||||
boo::BlendFactor::One, boo::Primitive::TriStrips,
|
||||
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,
|
||||
boo::BlendFactor::Zero, boo::Primitive::TriStrips,
|
||||
boo::ZTest::None, false, false, true, boo::CullMode::None);
|
||||
return new CPhazonSuitFilterMetalDataBindingFactory;
|
||||
}
|
||||
|
||||
template <>
|
||||
void CPhazonSuitFilter::Shutdown<boo::MetalDataFactory>()
|
||||
{
|
||||
s_VtxFmt.reset();
|
||||
s_BlurVtxFmt.reset();
|
||||
s_IndPipeline.reset();
|
||||
s_Pipeline.reset();
|
||||
s_BlurPipeline.reset();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ void CRadarPaintShader::draw(const std::vector<Instance>& instances, const CText
|
|||
{
|
||||
m_maxInsts = instances.size();
|
||||
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_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)
|
||||
|
||||
void CRadarPaintShader::Shutdown() {}
|
||||
|
||||
}
|
||||
|
|
|
@ -26,10 +26,9 @@ public:
|
|||
};
|
||||
|
||||
private:
|
||||
boo::GraphicsDataToken m_token;
|
||||
boo::IGraphicsBufferD* m_vbo;
|
||||
boo::IGraphicsBufferD* m_uniBuf;
|
||||
boo::IShaderDataBinding* m_dataBind;
|
||||
boo::ObjToken<boo::IGraphicsBufferD> m_vbo;
|
||||
boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf;
|
||||
boo::ObjToken<boo::IShaderDataBinding> m_dataBind;
|
||||
const CTexture* m_tex = nullptr;
|
||||
size_t m_maxInsts = 0;
|
||||
|
||||
|
|
|
@ -50,34 +50,34 @@ BOO_GLSL_BINDING_HEAD
|
|||
|
||||
URDE_DECL_SPECIALIZE_SHADER(CRadarPaintShader)
|
||||
|
||||
static boo::IVertexFormat* s_VtxFmt = nullptr;
|
||||
static boo::IShaderPipeline* s_Pipeline = nullptr;
|
||||
static boo::ObjToken<boo::IVertexFormat> s_VtxFmt;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_Pipeline;
|
||||
|
||||
struct CRadarPaintShaderGLDataBindingFactory : TShader<CRadarPaintShader>::IDataBindingFactory
|
||||
{
|
||||
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
CRadarPaintShader& filter)
|
||||
{
|
||||
boo::GLDataFactory::Context& cctx = static_cast<boo::GLDataFactory::Context&>(ctx);
|
||||
|
||||
const boo::VertexElementDescriptor VtxVmt[] =
|
||||
{
|
||||
{filter.m_vbo, nullptr, boo::VertexSemantic::Position4, 0},
|
||||
{filter.m_vbo, nullptr, boo::VertexSemantic::Position4, 1},
|
||||
{filter.m_vbo, nullptr, boo::VertexSemantic::Position4, 2},
|
||||
{filter.m_vbo, nullptr, boo::VertexSemantic::Position4, 3},
|
||||
{filter.m_vbo, nullptr, boo::VertexSemantic::UV4, 0},
|
||||
{filter.m_vbo, nullptr, boo::VertexSemantic::UV4, 1},
|
||||
{filter.m_vbo, nullptr, boo::VertexSemantic::UV4, 2},
|
||||
{filter.m_vbo, nullptr, boo::VertexSemantic::UV4, 3},
|
||||
{filter.m_vbo, nullptr, boo::VertexSemantic::Color}
|
||||
{filter.m_vbo.get(), nullptr, boo::VertexSemantic::Position4, 0},
|
||||
{filter.m_vbo.get(), nullptr, boo::VertexSemantic::Position4, 1},
|
||||
{filter.m_vbo.get(), nullptr, boo::VertexSemantic::Position4, 2},
|
||||
{filter.m_vbo.get(), nullptr, boo::VertexSemantic::Position4, 3},
|
||||
{filter.m_vbo.get(), nullptr, boo::VertexSemantic::UV4, 0},
|
||||
{filter.m_vbo.get(), nullptr, boo::VertexSemantic::UV4, 1},
|
||||
{filter.m_vbo.get(), nullptr, boo::VertexSemantic::UV4, 2},
|
||||
{filter.m_vbo.get(), nullptr, boo::VertexSemantic::UV4, 3},
|
||||
{filter.m_vbo.get(), nullptr, boo::VertexSemantic::Color}
|
||||
};
|
||||
boo::IVertexFormat* vtxFmt = ctx.newVertexFormat(9, VtxVmt);
|
||||
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf};
|
||||
boo::ObjToken<boo::IVertexFormat> vtxFmt = ctx.newVertexFormat(9, VtxVmt);
|
||||
boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {filter.m_uniBuf.get()};
|
||||
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,
|
||||
vtxFmt, nullptr, filter.m_vbo, nullptr,
|
||||
vtxFmt, nullptr, filter.m_vbo.get(), nullptr,
|
||||
1, bufs, stages, nullptr, nullptr, 1, texs, nullptr, nullptr);
|
||||
}
|
||||
};
|
||||
|
@ -110,6 +110,12 @@ CRadarPaintShader::Initialize(boo::GLDataFactory::Context& ctx)
|
|||
return new CRadarPaintShaderGLDataBindingFactory;
|
||||
}
|
||||
|
||||
template <>
|
||||
void CRadarPaintShader::Shutdown<boo::GLDataFactory>()
|
||||
{
|
||||
s_Pipeline.reset();
|
||||
}
|
||||
|
||||
#if BOO_HAS_VULKAN
|
||||
TShader<CRadarPaintShader>::IDataBindingFactory*
|
||||
CRadarPaintShader::Initialize(boo::VulkanDataFactory::Context& ctx)
|
||||
|
|
|
@ -58,20 +58,20 @@ static const char* FS =
|
|||
|
||||
URDE_DECL_SPECIALIZE_SHADER(CRadarPaintShader)
|
||||
|
||||
static boo::IVertexFormat* s_VtxFmt = nullptr;
|
||||
static boo::IShaderPipeline* s_Pipeline = nullptr;
|
||||
static boo::ObjToken<boo::IVertexFormat> s_VtxFmt;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_Pipeline;
|
||||
|
||||
struct CRadarPaintShaderMetalDataBindingFactory : TShader<CRadarPaintShader>::IDataBindingFactory
|
||||
{
|
||||
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
CRadarPaintShader& filter)
|
||||
{
|
||||
boo::MetalDataFactory::Context& cctx = static_cast<boo::MetalDataFactory::Context&>(ctx);
|
||||
|
||||
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf};
|
||||
boo::ITexture* texs[] = {filter.m_tex->GetBooTexture()};
|
||||
boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {filter.m_uniBuf.get()};
|
||||
boo::ObjToken<boo::ITexture> texs[] = {filter.m_tex->GetBooTexture()};
|
||||
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);
|
||||
}
|
||||
};
|
||||
|
@ -92,11 +92,19 @@ CRadarPaintShader::Initialize(boo::MetalDataFactory::Context& ctx)
|
|||
{nullptr, nullptr, boo::VertexSemantic::Color}
|
||||
};
|
||||
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::One, boo::Primitive::TriStrips,
|
||||
boo::ZTest::None, false, true, false, boo::CullMode::None);
|
||||
return new CRadarPaintShaderMetalDataBindingFactory;
|
||||
}
|
||||
|
||||
template <>
|
||||
void CRadarPaintShader::Shutdown<boo::MetalDataFactory>()
|
||||
{
|
||||
s_VtxFmt.reset();
|
||||
s_Pipeline.reset();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ namespace urde
|
|||
CRandomStaticFilter::CRandomStaticFilter(EFilterType type, bool cookieCutter)
|
||||
: m_cookieCutter(cookieCutter)
|
||||
{
|
||||
m_token = CGraphics::g_BooFactory->commitTransaction([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
|
||||
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
|
||||
{
|
||||
struct Vert
|
||||
{
|
||||
|
@ -41,8 +41,6 @@ void CRandomStaticFilter::draw(const zeus::CColor& color, float t)
|
|||
CGraphics::DrawArray(0, 4);
|
||||
}
|
||||
|
||||
void CRandomStaticFilter::Shutdown() {}
|
||||
|
||||
URDE_SPECIALIZE_MULTI_BLEND_SHADER(CRandomStaticFilter)
|
||||
|
||||
}
|
||||
|
|
|
@ -23,10 +23,9 @@ class CRandomStaticFilter
|
|||
float randOff;
|
||||
float discardThres;
|
||||
};
|
||||
boo::GraphicsDataToken m_token;
|
||||
boo::IGraphicsBufferS* m_vbo;
|
||||
boo::IGraphicsBufferD* m_uniBuf;
|
||||
boo::IShaderDataBinding* m_dataBind = nullptr;
|
||||
boo::ObjToken<boo::IGraphicsBufferS> m_vbo;
|
||||
boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf;
|
||||
boo::ObjToken<boo::IShaderDataBinding> m_dataBind;
|
||||
Uniform m_uniform;
|
||||
bool m_cookieCutter;
|
||||
|
||||
|
|
|
@ -106,13 +106,13 @@ BOO_GLSL_BINDING_HEAD
|
|||
|
||||
URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(CRandomStaticFilter)
|
||||
|
||||
static boo::IVertexFormat* s_VtxFmt = nullptr;
|
||||
static boo::IShaderPipeline* s_AlphaPipeline = nullptr;
|
||||
static boo::IShaderPipeline* s_AddPipeline = nullptr;
|
||||
static boo::IShaderPipeline* s_MultPipeline = nullptr;
|
||||
static boo::IShaderPipeline* s_CookieCutterPipeline = nullptr;
|
||||
static boo::ObjToken<boo::IVertexFormat> s_VtxFmt;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_AlphaPipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_AddPipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_MultPipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_CookieCutterPipeline;
|
||||
|
||||
static boo::IShaderPipeline* SelectPipeline(EFilterType type)
|
||||
static boo::ObjToken<boo::IShaderPipeline> SelectPipeline(EFilterType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
|
@ -123,28 +123,27 @@ static boo::IShaderPipeline* SelectPipeline(EFilterType type)
|
|||
case EFilterType::Multiply:
|
||||
return s_MultPipeline;
|
||||
default:
|
||||
return nullptr;
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
struct CRandomStaticFilterGLDataBindingFactory : TMultiBlendShader<CRandomStaticFilter>::IDataBindingFactory
|
||||
{
|
||||
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
EFilterType type,
|
||||
CRandomStaticFilter& filter)
|
||||
boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
EFilterType type, CRandomStaticFilter& filter)
|
||||
{
|
||||
boo::GLDataFactory::Context& cctx = static_cast<boo::GLDataFactory::Context&>(ctx);
|
||||
|
||||
const boo::VertexElementDescriptor VtxVmt[] =
|
||||
{
|
||||
{filter.m_vbo, nullptr, boo::VertexSemantic::Position4},
|
||||
{filter.m_vbo, nullptr, boo::VertexSemantic::UV4}
|
||||
{filter.m_vbo.get(), nullptr, boo::VertexSemantic::Position4},
|
||||
{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::ITexture* texs[] = {g_Renderer->GetRandomStaticEntropyTex()};
|
||||
boo::ObjToken<boo::ITexture> texs[] = {g_Renderer->GetRandomStaticEntropyTex()};
|
||||
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);
|
||||
}
|
||||
};
|
||||
|
@ -187,6 +186,15 @@ CRandomStaticFilter::Initialize(boo::GLDataFactory::Context& ctx)
|
|||
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
|
||||
TMultiBlendShader<CRandomStaticFilter>::IDataBindingFactory*
|
||||
CRandomStaticFilter::Initialize(boo::VulkanDataFactory::Context& ctx)
|
||||
|
|
|
@ -112,13 +112,13 @@ static const char* FSCookieCutter =
|
|||
|
||||
URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(CRandomStaticFilter)
|
||||
|
||||
static boo::IVertexFormat* s_VtxFmt = nullptr;
|
||||
static boo::IShaderPipeline* s_AlphaPipeline = nullptr;
|
||||
static boo::IShaderPipeline* s_AddPipeline = nullptr;
|
||||
static boo::IShaderPipeline* s_MultPipeline = nullptr;
|
||||
static boo::IShaderPipeline* s_CookieCutterPipeline = nullptr;
|
||||
static boo::ObjToken<boo::IVertexFormat> s_VtxFmt;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_AlphaPipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_AddPipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_MultPipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_CookieCutterPipeline;
|
||||
|
||||
static boo::IShaderPipeline* SelectPipeline(EFilterType type)
|
||||
static boo::ObjToken<boo::IShaderPipeline> SelectPipeline(EFilterType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
|
@ -129,22 +129,21 @@ static boo::IShaderPipeline* SelectPipeline(EFilterType type)
|
|||
case EFilterType::Multiply:
|
||||
return s_MultPipeline;
|
||||
default:
|
||||
return nullptr;
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
struct CRandomStaticFilterMetalDataBindingFactory : TMultiBlendShader<CRandomStaticFilter>::IDataBindingFactory
|
||||
{
|
||||
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
EFilterType type,
|
||||
CRandomStaticFilter& filter)
|
||||
boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
EFilterType type, CRandomStaticFilter& filter)
|
||||
{
|
||||
boo::MetalDataFactory::Context& cctx = static_cast<boo::MetalDataFactory::Context&>(ctx);
|
||||
|
||||
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf};
|
||||
boo::ITexture* texs[] = {g_Renderer->GetRandomStaticEntropyTex()};
|
||||
boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {filter.m_uniBuf.get()};
|
||||
boo::ObjToken<boo::ITexture> texs[] = {g_Renderer->GetRandomStaticEntropyTex()};
|
||||
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);
|
||||
}
|
||||
};
|
||||
|
@ -158,23 +157,37 @@ CRandomStaticFilter::Initialize(boo::MetalDataFactory::Context& ctx)
|
|||
{nullptr, nullptr, boo::VertexSemantic::UV4}
|
||||
};
|
||||
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::InvSrcAlpha, boo::Primitive::TriStrips,
|
||||
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::One, boo::Primitive::TriStrips,
|
||||
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::DstColor, boo::Primitive::TriStrips,
|
||||
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::DstColor, boo::Primitive::TriStrips,
|
||||
boo::ZTest::LEqual, true, false, false, boo::CullMode::None);
|
||||
return new CRandomStaticFilterMetalDataBindingFactory;
|
||||
}
|
||||
|
||||
template <>
|
||||
void CRandomStaticFilter::Shutdown<boo::MetalDataFactory>()
|
||||
{
|
||||
s_VtxFmt.reset();
|
||||
s_AlphaPipeline.reset();
|
||||
s_AddPipeline.reset();
|
||||
s_MultPipeline.reset();
|
||||
s_CookieCutterPipeline.reset();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ namespace urde
|
|||
CScanLinesFilter::CScanLinesFilter(EFilterType type, bool 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_dataBind = TMultiBlendShader<CScanLinesFilter>::BuildShaderDataBinding(ctx, type, *this);
|
||||
|
@ -23,8 +23,6 @@ void CScanLinesFilter::draw(const zeus::CColor& color)
|
|||
CGraphics::DrawArray(0, 670);
|
||||
}
|
||||
|
||||
void CScanLinesFilter::Shutdown() {}
|
||||
|
||||
URDE_SPECIALIZE_MULTI_BLEND_SHADER(CScanLinesFilter)
|
||||
|
||||
}
|
||||
|
|
|
@ -21,9 +21,8 @@ class CScanLinesFilter
|
|||
{
|
||||
zeus::CColor color;
|
||||
};
|
||||
boo::GraphicsDataToken m_token;
|
||||
boo::IGraphicsBufferD* m_uniBuf;
|
||||
boo::IShaderDataBinding* m_dataBind = nullptr;
|
||||
boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf;
|
||||
boo::ObjToken<boo::IShaderDataBinding> m_dataBind;
|
||||
Uniform m_uniform;
|
||||
bool m_even;
|
||||
|
||||
|
|
|
@ -45,12 +45,12 @@ BOO_GLSL_BINDING_HEAD
|
|||
|
||||
URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(CScanLinesFilter)
|
||||
|
||||
static boo::IVertexFormat* s_VtxFmt = nullptr;
|
||||
static boo::IShaderPipeline* s_AlphaPipeline = nullptr;
|
||||
static boo::IShaderPipeline* s_AddPipeline = nullptr;
|
||||
static boo::IShaderPipeline* s_MultPipeline = nullptr;
|
||||
static boo::ObjToken<boo::IVertexFormat> s_VtxFmt;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_AlphaPipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_AddPipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_MultPipeline;
|
||||
|
||||
static boo::IShaderPipeline* SelectPipeline(EFilterType type)
|
||||
static boo::ObjToken<boo::IShaderPipeline> SelectPipeline(EFilterType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
|
@ -61,25 +61,24 @@ static boo::IShaderPipeline* SelectPipeline(EFilterType type)
|
|||
case EFilterType::Multiply:
|
||||
return s_MultPipeline;
|
||||
default:
|
||||
return nullptr;
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
struct CScanLinesFilterGLDataBindingFactory : TMultiBlendShader<CScanLinesFilter>::IDataBindingFactory
|
||||
{
|
||||
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
EFilterType type,
|
||||
CScanLinesFilter& filter)
|
||||
boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
EFilterType type, CScanLinesFilter& filter)
|
||||
{
|
||||
boo::GLDataFactory::Context& cctx = static_cast<boo::GLDataFactory::Context&>(ctx);
|
||||
|
||||
boo::IGraphicsBuffer* vbo = filter.m_even ?
|
||||
g_Renderer->GetScanLinesEvenVBO() : g_Renderer->GetScanLinesOddVBO();
|
||||
boo::ObjToken<boo::IGraphicsBuffer> vbo = filter.m_even ?
|
||||
g_Renderer->GetScanLinesEvenVBO().get() : g_Renderer->GetScanLinesOddVBO().get();
|
||||
const boo::VertexElementDescriptor VtxVmt[] =
|
||||
{
|
||||
{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};
|
||||
return cctx.newShaderDataBinding(SelectPipeline(type),
|
||||
ctx.newVertexFormat(1, VtxVmt), vbo, nullptr, nullptr,
|
||||
|
@ -122,6 +121,14 @@ CScanLinesFilter::Initialize(boo::GLDataFactory::Context& ctx)
|
|||
return new CScanLinesFilterGLDataBindingFactory;
|
||||
}
|
||||
|
||||
template <>
|
||||
void CScanLinesFilter::Shutdown<boo::GLDataFactory>()
|
||||
{
|
||||
s_AlphaPipeline.reset();
|
||||
s_AddPipeline.reset();
|
||||
s_MultPipeline.reset();
|
||||
}
|
||||
|
||||
#if BOO_HAS_VULKAN
|
||||
TMultiBlendShader<CScanLinesFilter>::IDataBindingFactory*
|
||||
CScanLinesFilter::Initialize(boo::VulkanDataFactory::Context& ctx)
|
||||
|
|
|
@ -49,12 +49,12 @@ static const char* FS =
|
|||
|
||||
URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(CScanLinesFilter)
|
||||
|
||||
static boo::IVertexFormat* s_VtxFmt = nullptr;
|
||||
static boo::IShaderPipeline* s_AlphaPipeline = nullptr;
|
||||
static boo::IShaderPipeline* s_AddPipeline = nullptr;
|
||||
static boo::IShaderPipeline* s_MultPipeline = nullptr;
|
||||
static boo::ObjToken<boo::IVertexFormat> s_VtxFmt;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_AlphaPipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_AddPipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_MultPipeline;
|
||||
|
||||
static boo::IShaderPipeline* SelectPipeline(EFilterType type)
|
||||
static boo::ObjToken<boo::IShaderPipeline> SelectPipeline(EFilterType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
|
@ -65,21 +65,20 @@ static boo::IShaderPipeline* SelectPipeline(EFilterType type)
|
|||
case EFilterType::Multiply:
|
||||
return s_MultPipeline;
|
||||
default:
|
||||
return nullptr;
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
struct CScanLinesFilterMetalDataBindingFactory : TMultiBlendShader<CScanLinesFilter>::IDataBindingFactory
|
||||
{
|
||||
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
EFilterType type,
|
||||
CScanLinesFilter& filter)
|
||||
boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
EFilterType type, CScanLinesFilter& filter)
|
||||
{
|
||||
boo::MetalDataFactory::Context& cctx = static_cast<boo::MetalDataFactory::Context&>(ctx);
|
||||
|
||||
boo::IGraphicsBuffer* vbo = filter.m_even ?
|
||||
g_Renderer->GetScanLinesEvenVBO() : g_Renderer->GetScanLinesOddVBO();
|
||||
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf};
|
||||
boo::ObjToken<boo::IGraphicsBuffer> vbo = filter.m_even ?
|
||||
g_Renderer->GetScanLinesEvenVBO().get() : g_Renderer->GetScanLinesOddVBO().get();
|
||||
boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {filter.m_uniBuf.get()};
|
||||
return cctx.newShaderDataBinding(SelectPipeline(type), s_VtxFmt,
|
||||
vbo, nullptr, nullptr, 1, bufs,
|
||||
nullptr, nullptr, nullptr, 0, nullptr, nullptr, nullptr);
|
||||
|
@ -94,16 +93,28 @@ CScanLinesFilter::Initialize(boo::MetalDataFactory::Context& ctx)
|
|||
{nullptr, nullptr, boo::VertexSemantic::Position4}
|
||||
};
|
||||
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::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::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::ZTest::None, false, true, true, boo::CullMode::None);
|
||||
return new CScanLinesFilterMetalDataBindingFactory;
|
||||
}
|
||||
|
||||
template <>
|
||||
void CScanLinesFilter::Shutdown<boo::MetalDataFactory>()
|
||||
{
|
||||
s_VtxFmt.reset();
|
||||
s_AlphaPipeline.reset();
|
||||
s_AddPipeline.reset();
|
||||
s_MultPipeline.reset();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -28,12 +28,12 @@ void CSpaceWarpFilter::GenerateWarpRampTex(boo::IGraphicsDataFactory::Context& c
|
|||
}
|
||||
m_warpTex = ctx.newStaticTexture(WARP_RAMP_RES+1, WARP_RAMP_RES+1, 1,
|
||||
boo::TextureFormat::RGBA8, boo::TextureClampMode::Repeat,
|
||||
data[0], (WARP_RAMP_RES+1) * (WARP_RAMP_RES+1) * 4);
|
||||
data[0], (WARP_RAMP_RES+1) * (WARP_RAMP_RES+1) * 4).get();
|
||||
}
|
||||
|
||||
CSpaceWarpFilter::CSpaceWarpFilter()
|
||||
{
|
||||
m_token = CGraphics::g_BooFactory->commitTransaction([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
|
||||
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
|
||||
{
|
||||
GenerateWarpRampTex(ctx);
|
||||
struct Vert
|
||||
|
@ -148,12 +148,10 @@ void CSpaceWarpFilter::draw(const zeus::CVector3f& pt)
|
|||
m_uniform.m_strength.y = m_uniform.m_matrix[1][1] * m_strength * 0.5f;
|
||||
m_uniBuf->load(&m_uniform, sizeof(m_uniform));
|
||||
|
||||
CGraphics::g_BooMainCommandQueue->setShaderDataBinding(m_dataBind);
|
||||
CGraphics::g_BooMainCommandQueue->draw(0, 4);
|
||||
CGraphics::SetShaderDataBinding(m_dataBind);
|
||||
CGraphics::DrawArray(0, 4);
|
||||
}
|
||||
|
||||
void CSpaceWarpFilter::Shutdown() {}
|
||||
|
||||
URDE_SPECIALIZE_SHADER(CSpaceWarpFilter)
|
||||
|
||||
}
|
||||
|
|
|
@ -22,11 +22,10 @@ class CSpaceWarpFilter
|
|||
zeus::CVector3f m_strength;
|
||||
};
|
||||
u8 m_shiftTexture[4][8][4] = {};
|
||||
boo::GraphicsDataToken m_token;
|
||||
boo::ITexture* m_warpTex;
|
||||
boo::IGraphicsBufferS* m_vbo;
|
||||
boo::IGraphicsBufferD* m_uniBuf;
|
||||
boo::IShaderDataBinding* m_dataBind = nullptr;
|
||||
boo::ObjToken<boo::ITexture> m_warpTex;
|
||||
boo::ObjToken<boo::IGraphicsBufferS> m_vbo;
|
||||
boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf;
|
||||
boo::ObjToken<boo::IShaderDataBinding> m_dataBind;
|
||||
Uniform m_uniform;
|
||||
float m_strength = 1.f;
|
||||
|
||||
|
|
|
@ -53,26 +53,26 @@ BOO_GLSL_BINDING_HEAD
|
|||
|
||||
URDE_DECL_SPECIALIZE_SHADER(CSpaceWarpFilter)
|
||||
|
||||
static boo::IVertexFormat* s_VtxFmt = nullptr;
|
||||
static boo::IShaderPipeline* s_Pipeline = nullptr;
|
||||
static boo::ObjToken<boo::IVertexFormat> s_VtxFmt;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_Pipeline;
|
||||
|
||||
struct CSpaceWarpFilterGLDataBindingFactory : TShader<CSpaceWarpFilter>::IDataBindingFactory
|
||||
{
|
||||
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
CSpaceWarpFilter& filter)
|
||||
{
|
||||
boo::GLDataFactory::Context& cctx = static_cast<boo::GLDataFactory::Context&>(ctx);
|
||||
|
||||
const boo::VertexElementDescriptor VtxVmt[] =
|
||||
{
|
||||
{filter.m_vbo, nullptr, boo::VertexSemantic::Position4},
|
||||
{filter.m_vbo, nullptr, boo::VertexSemantic::UV4}
|
||||
{filter.m_vbo.get(), nullptr, boo::VertexSemantic::Position4},
|
||||
{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::ITexture* texs[] = {CGraphics::g_SpareTexture, filter.m_warpTex};
|
||||
boo::ObjToken<boo::ITexture> texs[] = {CGraphics::g_SpareTexture.get(), filter.m_warpTex.get()};
|
||||
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, 2, texs, nullptr, nullptr);
|
||||
}
|
||||
};
|
||||
|
@ -104,6 +104,12 @@ TShader<CSpaceWarpFilter>::IDataBindingFactory* CSpaceWarpFilter::Initialize(boo
|
|||
return new CSpaceWarpFilterGLDataBindingFactory;
|
||||
}
|
||||
|
||||
template <>
|
||||
void CSpaceWarpFilter::Shutdown<boo::GLDataFactory>()
|
||||
{
|
||||
s_Pipeline.reset();
|
||||
}
|
||||
|
||||
#if BOO_HAS_VULKAN
|
||||
TShader<CSpaceWarpFilter>::IDataBindingFactory* CSpaceWarpFilter::Initialize(boo::VulkanDataFactory::Context& ctx)
|
||||
{
|
||||
|
|
|
@ -57,20 +57,20 @@ static const char* FS =
|
|||
|
||||
URDE_DECL_SPECIALIZE_SHADER(CSpaceWarpFilter)
|
||||
|
||||
static boo::IVertexFormat* s_VtxFmt = nullptr;
|
||||
static boo::IShaderPipeline* s_Pipeline = nullptr;
|
||||
static boo::ObjToken<boo::IVertexFormat> s_VtxFmt;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_Pipeline;
|
||||
|
||||
struct CSpaceWarpFilterMetalDataBindingFactory : TShader<CSpaceWarpFilter>::IDataBindingFactory
|
||||
{
|
||||
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
CSpaceWarpFilter& filter)
|
||||
{
|
||||
boo::MetalDataFactory::Context& cctx = static_cast<boo::MetalDataFactory::Context&>(ctx);
|
||||
|
||||
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf};
|
||||
boo::ITexture* texs[] = {CGraphics::g_SpareTexture, filter.m_warpTex};
|
||||
boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {filter.m_uniBuf.get()};
|
||||
boo::ObjToken<boo::ITexture> texs[] = {CGraphics::g_SpareTexture.get(), filter.m_warpTex};
|
||||
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, 2, texs, nullptr, nullptr);
|
||||
}
|
||||
};
|
||||
|
@ -83,10 +83,18 @@ TShader<CSpaceWarpFilter>::IDataBindingFactory* CSpaceWarpFilter::Initialize(boo
|
|||
{nullptr, nullptr, boo::VertexSemantic::UV4}
|
||||
};
|
||||
s_VtxFmt = ctx.newVertexFormat(2, VtxVmt);
|
||||
s_Pipeline = ctx.newShaderPipeline(VS, FS, s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::One,
|
||||
s_Pipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr,
|
||||
s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::One,
|
||||
boo::BlendFactor::Zero, boo::Primitive::TriStrips,
|
||||
boo::ZTest::None, false, true, true, boo::CullMode::None);
|
||||
return new CSpaceWarpFilterMetalDataBindingFactory;
|
||||
}
|
||||
|
||||
template <>
|
||||
void CSpaceWarpFilter::Shutdown<boo::MetalDataFactory>()
|
||||
{
|
||||
s_VtxFmt.reset();
|
||||
s_Pipeline.reset();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,13 +4,13 @@
|
|||
namespace urde
|
||||
{
|
||||
|
||||
boo::IVertexFormat* CTextSupportShader::s_TextVtxFmt = nullptr;
|
||||
boo::IShaderPipeline* CTextSupportShader::s_TextAlphaPipeline = nullptr;
|
||||
boo::IShaderPipeline* CTextSupportShader::s_TextAddPipeline = nullptr;
|
||||
boo::ObjToken<boo::IVertexFormat> CTextSupportShader::s_TextVtxFmt;
|
||||
boo::ObjToken<boo::IShaderPipeline> CTextSupportShader::s_TextAlphaPipeline;
|
||||
boo::ObjToken<boo::IShaderPipeline> CTextSupportShader::s_TextAddPipeline;
|
||||
|
||||
boo::IVertexFormat* CTextSupportShader::s_ImageVtxFmt = nullptr;
|
||||
boo::IShaderPipeline* CTextSupportShader::s_ImageAlphaPipeline = nullptr;
|
||||
boo::IShaderPipeline* CTextSupportShader::s_ImageAddPipeline = nullptr;
|
||||
boo::ObjToken<boo::IVertexFormat> CTextSupportShader::s_ImageVtxFmt;
|
||||
boo::ObjToken<boo::IShaderPipeline> CTextSupportShader::s_ImageAlphaPipeline;
|
||||
boo::ObjToken<boo::IShaderPipeline> CTextSupportShader::s_ImageAddPipeline;
|
||||
|
||||
hecl::VertexBufferPool<CTextSupportShader::CharacterInstance> CTextSupportShader::s_CharInsts;
|
||||
hecl::VertexBufferPool<CTextSupportShader::ImageInstance> CTextSupportShader::s_ImgInsts;
|
||||
|
@ -61,6 +61,13 @@ void CTextSupportShader::ImageInstance::SetMetrics(const CFontImageDef& imgDef,
|
|||
|
||||
void CTextSupportShader::Shutdown()
|
||||
{
|
||||
s_TextVtxFmt.reset();
|
||||
s_TextAlphaPipeline.reset();
|
||||
s_TextAddPipeline.reset();
|
||||
s_ImageVtxFmt.reset();
|
||||
s_ImageAlphaPipeline.reset();
|
||||
s_ImageAddPipeline.reset();
|
||||
|
||||
s_CharInsts.doDestroy();
|
||||
s_ImgInsts.doDestroy();
|
||||
s_Uniforms.doDestroy();
|
||||
|
|
|
@ -20,13 +20,13 @@ class CTextSupportShader
|
|||
friend struct CTextSupportShaderD3DDataBindingFactory;
|
||||
friend class CTextRenderBuffer;
|
||||
|
||||
static boo::IVertexFormat* s_TextVtxFmt;
|
||||
static boo::IShaderPipeline* s_TextAlphaPipeline;
|
||||
static boo::IShaderPipeline* s_TextAddPipeline;
|
||||
static boo::ObjToken<boo::IVertexFormat> s_TextVtxFmt;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_TextAlphaPipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_TextAddPipeline;
|
||||
|
||||
static boo::IVertexFormat* s_ImageVtxFmt;
|
||||
static boo::IShaderPipeline* s_ImageAlphaPipeline;
|
||||
static boo::IShaderPipeline* s_ImageAddPipeline;
|
||||
static boo::ObjToken<boo::IVertexFormat> s_ImageVtxFmt;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_ImageAlphaPipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_ImageAddPipeline;
|
||||
|
||||
struct Uniform
|
||||
{
|
||||
|
@ -60,7 +60,7 @@ public:
|
|||
using _CLS = CTextSupportShader;
|
||||
#include "TMultiBlendShaderDecl.hpp"
|
||||
|
||||
static boo::IShaderPipeline* SelectTextPipeline(CGuiWidget::EGuiModelDrawFlags df)
|
||||
static boo::ObjToken<boo::IShaderPipeline> SelectTextPipeline(CGuiWidget::EGuiModelDrawFlags df)
|
||||
{
|
||||
switch (df)
|
||||
{
|
||||
|
@ -72,11 +72,11 @@ public:
|
|||
case CGuiWidget::EGuiModelDrawFlags::AlphaAdditiveOverdraw:
|
||||
return s_TextAddPipeline;
|
||||
default:
|
||||
return nullptr;
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
static boo::IShaderPipeline* SelectImagePipeline(CGuiWidget::EGuiModelDrawFlags df)
|
||||
static boo::ObjToken<boo::IShaderPipeline> SelectImagePipeline(CGuiWidget::EGuiModelDrawFlags df)
|
||||
{
|
||||
switch (df)
|
||||
{
|
||||
|
@ -88,7 +88,7 @@ public:
|
|||
case CGuiWidget::EGuiModelDrawFlags::AlphaAdditiveOverdraw:
|
||||
return s_ImageAddPipeline;
|
||||
default:
|
||||
return nullptr;
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -98,6 +98,8 @@ public:
|
|||
s_ImgInsts.updateBuffers();
|
||||
s_Uniforms.updateBuffers();
|
||||
}
|
||||
|
||||
static void Shutdown();
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -127,6 +127,15 @@ CTextSupportShader::Initialize(boo::GLDataFactory::Context& ctx)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
template <>
|
||||
void CTextSupportShader::Shutdown<boo::GLDataFactory>()
|
||||
{
|
||||
s_TextAlphaPipeline.reset();
|
||||
s_TextAddPipeline.reset();
|
||||
s_ImageAlphaPipeline.reset();
|
||||
s_ImageAddPipeline.reset();
|
||||
}
|
||||
|
||||
#if BOO_HAS_VULKAN
|
||||
TMultiBlendShader<CTextSupportShader>::IDataBindingFactory*
|
||||
CTextSupportShader::Initialize(boo::VulkanDataFactory::Context& ctx)
|
||||
|
|
|
@ -138,10 +138,12 @@ CTextSupportShader::Initialize(boo::MetalDataFactory::Context& ctx)
|
|||
{nullptr, nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced, 2},
|
||||
};
|
||||
s_TextVtxFmt = ctx.newVertexFormat(11, TextVtxVmt);
|
||||
s_TextAlphaPipeline = ctx.newShaderPipeline(TextVS, TextFS, s_TextVtxFmt, CGraphics::g_ViewportSamples,
|
||||
s_TextAlphaPipeline = ctx.newShaderPipeline(TextVS, TextFS, nullptr, nullptr,
|
||||
s_TextVtxFmt, CGraphics::g_ViewportSamples,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips,
|
||||
boo::ZTest::LEqual, false, true, true, boo::CullMode::None);
|
||||
s_TextAddPipeline = ctx.newShaderPipeline(TextVS, TextFS, s_TextVtxFmt, CGraphics::g_ViewportSamples,
|
||||
s_TextAddPipeline = ctx.newShaderPipeline(TextVS, TextFS, nullptr, nullptr,
|
||||
s_TextVtxFmt, CGraphics::g_ViewportSamples,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One, boo::Primitive::TriStrips,
|
||||
boo::ZTest::LEqual, false, true, true, boo::CullMode::None);
|
||||
|
||||
|
@ -158,14 +160,27 @@ CTextSupportShader::Initialize(boo::MetalDataFactory::Context& ctx)
|
|||
{nullptr, nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced, 0},
|
||||
};
|
||||
s_ImageVtxFmt = ctx.newVertexFormat(9, ImageVtxVmt);
|
||||
s_ImageAlphaPipeline = ctx.newShaderPipeline(ImgVS, ImgFS, s_ImageVtxFmt, CGraphics::g_ViewportSamples,
|
||||
s_ImageAlphaPipeline = ctx.newShaderPipeline(ImgVS, ImgFS, nullptr, nullptr,
|
||||
s_ImageVtxFmt, CGraphics::g_ViewportSamples,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips,
|
||||
boo::ZTest::LEqual, false, true, true, boo::CullMode::None);
|
||||
s_ImageAddPipeline = ctx.newShaderPipeline(ImgVS, ImgFS, s_ImageVtxFmt, CGraphics::g_ViewportSamples,
|
||||
s_ImageAddPipeline = ctx.newShaderPipeline(ImgVS, ImgFS, nullptr, nullptr,
|
||||
s_ImageVtxFmt, CGraphics::g_ViewportSamples,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One, boo::Primitive::TriStrips,
|
||||
boo::ZTest::LEqual, false, true, true, boo::CullMode::None);
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
template <>
|
||||
void CTextSupportShader::Shutdown<boo::MetalDataFactory>()
|
||||
{
|
||||
s_TextVtxFmt.reset();
|
||||
s_TextAlphaPipeline.reset();
|
||||
s_TextAddPipeline.reset();
|
||||
s_ImageVtxFmt.reset();
|
||||
s_ImageAlphaPipeline.reset();
|
||||
s_ImageAddPipeline.reset();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,15 +4,15 @@
|
|||
namespace urde
|
||||
{
|
||||
|
||||
CTexturedQuadFilter::CTexturedQuadFilter(boo::ITexture* tex)
|
||||
CTexturedQuadFilter::CTexturedQuadFilter(const boo::ObjToken<boo::ITexture>& tex)
|
||||
: m_booTex(tex)
|
||||
{
|
||||
}
|
||||
|
||||
CTexturedQuadFilter::CTexturedQuadFilter(EFilterType type, boo::ITexture* tex, bool gequal)
|
||||
CTexturedQuadFilter::CTexturedQuadFilter(EFilterType type, const boo::ObjToken<boo::ITexture>& tex, bool gequal)
|
||||
: m_booTex(tex), m_gequal(gequal)
|
||||
{
|
||||
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, 16);
|
||||
m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1);
|
||||
|
@ -138,14 +138,12 @@ void CTexturedQuadFilter::DrawFilter(EFilterShape shape, const zeus::CColor& col
|
|||
|
||||
const zeus::CRectangle CTexturedQuadFilter::DefaultRect = {0.f, 0.f, 1.f, 1.f};
|
||||
|
||||
void CTexturedQuadFilter::Shutdown() {}
|
||||
|
||||
URDE_SPECIALIZE_MULTI_BLEND_SHADER(CTexturedQuadFilter)
|
||||
|
||||
CTexturedQuadFilterAlpha::CTexturedQuadFilterAlpha(EFilterType type, boo::ITexture* tex)
|
||||
CTexturedQuadFilterAlpha::CTexturedQuadFilterAlpha(EFilterType type, const boo::ObjToken<boo::ITexture>& tex)
|
||||
: CTexturedQuadFilter(tex)
|
||||
{
|
||||
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_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1);
|
||||
|
@ -161,8 +159,6 @@ CTexturedQuadFilterAlpha::CTexturedQuadFilterAlpha(EFilterType type,
|
|||
m_tex = tex;
|
||||
}
|
||||
|
||||
void CTexturedQuadFilterAlpha::Shutdown() {}
|
||||
|
||||
URDE_SPECIALIZE_MULTI_BLEND_SHADER(CTexturedQuadFilterAlpha)
|
||||
|
||||
}
|
||||
|
|
|
@ -14,9 +14,13 @@ namespace urde
|
|||
class CTexturedQuadFilter
|
||||
{
|
||||
friend struct CTexturedQuadFilterGLDataBindingFactory;
|
||||
friend struct CTexturedQuadFilterAlphaGLDataBindingFactory;
|
||||
friend struct CTexturedQuadFilterVulkanDataBindingFactory;
|
||||
friend struct CTexturedQuadFilterAlphaVulkanDataBindingFactory;
|
||||
friend struct CTexturedQuadFilterMetalDataBindingFactory;
|
||||
friend struct CTexturedQuadFilterAlphaMetalDataBindingFactory;
|
||||
friend struct CTexturedQuadFilterD3DDataBindingFactory;
|
||||
friend struct CTexturedQuadFilterAlphaD3DDataBindingFactory;
|
||||
|
||||
protected:
|
||||
struct Uniform
|
||||
|
@ -26,15 +30,14 @@ protected:
|
|||
float m_lod = 0.f;
|
||||
};
|
||||
TLockedToken<CTexture> m_tex;
|
||||
boo::ITexture* m_booTex;
|
||||
boo::GraphicsDataToken m_token;
|
||||
boo::IGraphicsBufferD* m_vbo;
|
||||
boo::IGraphicsBufferD* m_uniBuf;
|
||||
boo::IShaderDataBinding* m_dataBind = nullptr;
|
||||
boo::ObjToken<boo::ITexture> m_booTex;
|
||||
boo::ObjToken<boo::IGraphicsBufferD> m_vbo;
|
||||
boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf;
|
||||
boo::ObjToken<boo::IShaderDataBinding> m_dataBind;
|
||||
Uniform m_uniform;
|
||||
bool m_gequal;
|
||||
|
||||
CTexturedQuadFilter(boo::ITexture* tex);
|
||||
CTexturedQuadFilter(const boo::ObjToken<boo::ITexture>& tex);
|
||||
|
||||
public:
|
||||
struct Vert
|
||||
|
@ -45,7 +48,7 @@ public:
|
|||
|
||||
static const zeus::CRectangle DefaultRect;
|
||||
CTexturedQuadFilter(EFilterType type, TLockedToken<CTexture> tex);
|
||||
CTexturedQuadFilter(EFilterType type, boo::ITexture* tex, bool gequal = false);
|
||||
CTexturedQuadFilter(EFilterType type, const boo::ObjToken<boo::ITexture>& tex, bool gequal = false);
|
||||
CTexturedQuadFilter(const CTexturedQuadFilter&) = delete;
|
||||
CTexturedQuadFilter& operator=(const CTexturedQuadFilter&) = delete;
|
||||
CTexturedQuadFilter(CTexturedQuadFilter&&) = default;
|
||||
|
@ -69,7 +72,7 @@ class CTexturedQuadFilterAlpha : public CTexturedQuadFilter
|
|||
|
||||
public:
|
||||
CTexturedQuadFilterAlpha(EFilterType type, TLockedToken<CTexture> tex);
|
||||
CTexturedQuadFilterAlpha(EFilterType type, boo::ITexture* tex);
|
||||
CTexturedQuadFilterAlpha(EFilterType type, const boo::ObjToken<boo::ITexture>& tex);
|
||||
using _CLS = CTexturedQuadFilterAlpha;
|
||||
#include "TMultiBlendShaderDecl.hpp"
|
||||
};
|
||||
|
|
|
@ -103,13 +103,13 @@ BOO_GLSL_BINDING_HEAD
|
|||
|
||||
URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(CTexturedQuadFilter)
|
||||
|
||||
static boo::IVertexFormat* s_VtxFmt = nullptr;
|
||||
static boo::IShaderPipeline* s_AlphaPipeline = nullptr;
|
||||
static boo::IShaderPipeline* s_AlphaGEqualPipeline = nullptr;
|
||||
static boo::IShaderPipeline* s_AddPipeline = nullptr;
|
||||
static boo::IShaderPipeline* s_MultPipeline = nullptr;
|
||||
static boo::ObjToken<boo::IVertexFormat> s_VtxFmt;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_AlphaPipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_AlphaGEqualPipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_AddPipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_MultPipeline;
|
||||
|
||||
static boo::IShaderPipeline* SelectPipeline(EFilterType type, bool gequal)
|
||||
static boo::ObjToken<boo::IShaderPipeline> SelectPipeline(EFilterType type, bool gequal)
|
||||
{
|
||||
if (gequal)
|
||||
return s_AlphaGEqualPipeline;
|
||||
|
@ -122,16 +122,16 @@ static boo::IShaderPipeline* SelectPipeline(EFilterType type, bool gequal)
|
|||
case EFilterType::Multiply:
|
||||
return s_MultPipeline;
|
||||
default:
|
||||
return nullptr;
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
static boo::IVertexFormat* s_AVtxFmt = nullptr;
|
||||
static boo::IShaderPipeline* s_AAlphaPipeline = nullptr;
|
||||
static boo::IShaderPipeline* s_AAddPipeline = nullptr;
|
||||
static boo::IShaderPipeline* s_AMultPipeline = nullptr;
|
||||
static boo::ObjToken<boo::IVertexFormat> s_AVtxFmt;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_AAlphaPipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_AAddPipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_AMultPipeline;
|
||||
|
||||
static boo::IShaderPipeline* SelectAlphaPipeline(EFilterType type)
|
||||
static boo::ObjToken<boo::IShaderPipeline> SelectAlphaPipeline(EFilterType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
|
@ -142,28 +142,27 @@ static boo::IShaderPipeline* SelectAlphaPipeline(EFilterType type)
|
|||
case EFilterType::Multiply:
|
||||
return s_AMultPipeline;
|
||||
default:
|
||||
return nullptr;
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
struct CTexturedQuadFilterGLDataBindingFactory : TMultiBlendShader<CTexturedQuadFilter>::IDataBindingFactory
|
||||
{
|
||||
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
EFilterType type,
|
||||
CTexturedQuadFilter& filter)
|
||||
boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
EFilterType type, CTexturedQuadFilter& filter)
|
||||
{
|
||||
boo::GLDataFactory::Context& cctx = static_cast<boo::GLDataFactory::Context&>(ctx);
|
||||
|
||||
const boo::VertexElementDescriptor VtxVmt[] =
|
||||
{
|
||||
{filter.m_vbo, nullptr, boo::VertexSemantic::Position4},
|
||||
{filter.m_vbo, nullptr, boo::VertexSemantic::UV4}
|
||||
{filter.m_vbo.get(), nullptr, boo::VertexSemantic::Position4},
|
||||
{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::ITexture* texs[] = {filter.m_booTex};
|
||||
boo::ObjToken<boo::ITexture> texs[] = {filter.m_booTex.get()};
|
||||
return cctx.newShaderDataBinding(SelectPipeline(type, filter.m_gequal),
|
||||
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);
|
||||
}
|
||||
};
|
||||
|
@ -206,6 +205,15 @@ CTexturedQuadFilter::Initialize(boo::GLDataFactory::Context& ctx)
|
|||
return new CTexturedQuadFilterGLDataBindingFactory;
|
||||
}
|
||||
|
||||
template <>
|
||||
void CTexturedQuadFilter::Shutdown<boo::GLDataFactory>()
|
||||
{
|
||||
s_AlphaPipeline.reset();
|
||||
s_AlphaGEqualPipeline.reset();
|
||||
s_AddPipeline.reset();
|
||||
s_MultPipeline.reset();
|
||||
}
|
||||
|
||||
#if BOO_HAS_VULKAN
|
||||
TMultiBlendShader<CTexturedQuadFilter>::IDataBindingFactory*
|
||||
CTexturedQuadFilter::Initialize(boo::VulkanDataFactory::Context& ctx)
|
||||
|
@ -236,22 +244,21 @@ URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(CTexturedQuadFilterAlpha)
|
|||
|
||||
struct CTexturedQuadFilterAlphaGLDataBindingFactory : TMultiBlendShader<CTexturedQuadFilterAlpha>::IDataBindingFactory
|
||||
{
|
||||
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
EFilterType type,
|
||||
CTexturedQuadFilterAlpha& filter)
|
||||
boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
EFilterType type, CTexturedQuadFilterAlpha& filter)
|
||||
{
|
||||
boo::GLDataFactory::Context& cctx = static_cast<boo::GLDataFactory::Context&>(ctx);
|
||||
|
||||
const boo::VertexElementDescriptor VtxVmt[] =
|
||||
{
|
||||
{filter.m_vbo, nullptr, boo::VertexSemantic::Position4},
|
||||
{filter.m_vbo, nullptr, boo::VertexSemantic::UV4}
|
||||
{filter.m_vbo.get(), nullptr, boo::VertexSemantic::Position4},
|
||||
{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::ITexture* texs[] = {filter.m_booTex};
|
||||
boo::ObjToken<boo::ITexture> texs[] = {filter.m_booTex.get()};
|
||||
return cctx.newShaderDataBinding(SelectAlphaPipeline(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);
|
||||
}
|
||||
};
|
||||
|
@ -291,6 +298,14 @@ CTexturedQuadFilterAlpha::Initialize(boo::GLDataFactory::Context& ctx)
|
|||
return new CTexturedQuadFilterAlphaGLDataBindingFactory;
|
||||
}
|
||||
|
||||
template <>
|
||||
void CTexturedQuadFilterAlpha::Shutdown<boo::GLDataFactory>()
|
||||
{
|
||||
s_AAlphaPipeline.reset();
|
||||
s_AAddPipeline.reset();
|
||||
s_AMultPipeline.reset();
|
||||
}
|
||||
|
||||
#if BOO_HAS_VULKAN
|
||||
TMultiBlendShader<CTexturedQuadFilterAlpha>::IDataBindingFactory*
|
||||
CTexturedQuadFilterAlpha::Initialize(boo::VulkanDataFactory::Context& ctx)
|
||||
|
|
|
@ -111,13 +111,13 @@ static const char* FSAlpha =
|
|||
|
||||
URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(CTexturedQuadFilter)
|
||||
|
||||
static boo::IVertexFormat* s_VtxFmt = nullptr;
|
||||
static boo::IShaderPipeline* s_AlphaPipeline = nullptr;
|
||||
static boo::IShaderPipeline* s_AlphaGEqualPipeline = nullptr;
|
||||
static boo::IShaderPipeline* s_AddPipeline = nullptr;
|
||||
static boo::IShaderPipeline* s_MultPipeline = nullptr;
|
||||
static boo::ObjToken<boo::IVertexFormat> s_VtxFmt;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_AlphaPipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_AlphaGEqualPipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_AddPipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_MultPipeline;
|
||||
|
||||
static boo::IShaderPipeline* SelectPipeline(EFilterType type, bool gequal)
|
||||
static boo::ObjToken<boo::IShaderPipeline> SelectPipeline(EFilterType type, bool gequal)
|
||||
{
|
||||
if (gequal)
|
||||
return s_AlphaGEqualPipeline;
|
||||
|
@ -130,22 +130,21 @@ static boo::IShaderPipeline* SelectPipeline(EFilterType type, bool gequal)
|
|||
case EFilterType::Multiply:
|
||||
return s_MultPipeline;
|
||||
default:
|
||||
return nullptr;
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
struct CTexturedQuadFilterMetalDataBindingFactory : TMultiBlendShader<CTexturedQuadFilter>::IDataBindingFactory
|
||||
{
|
||||
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
EFilterType type,
|
||||
CTexturedQuadFilter& filter)
|
||||
boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
EFilterType type, CTexturedQuadFilter& filter)
|
||||
{
|
||||
boo::MetalDataFactory::Context& cctx = static_cast<boo::MetalDataFactory::Context&>(ctx);
|
||||
|
||||
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf};
|
||||
boo::ITexture* texs[] = {filter.m_booTex};
|
||||
boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {filter.m_uniBuf.get()};
|
||||
boo::ObjToken<boo::ITexture> texs[] = {filter.m_booTex.get()};
|
||||
return cctx.newShaderDataBinding(SelectPipeline(type, filter.m_gequal), s_VtxFmt,
|
||||
filter.m_vbo, nullptr, nullptr, 1, bufs,
|
||||
filter.m_vbo.get(), nullptr, nullptr, 1, bufs,
|
||||
nullptr, nullptr, nullptr, 1, texs, nullptr, nullptr);
|
||||
}
|
||||
};
|
||||
|
@ -159,27 +158,41 @@ CTexturedQuadFilter::Initialize(boo::MetalDataFactory::Context& ctx)
|
|||
{nullptr, nullptr, boo::VertexSemantic::UV4}
|
||||
};
|
||||
s_VtxFmt = ctx.newVertexFormat(2, VtxVmt);
|
||||
s_AlphaPipeline = ctx.newShaderPipeline(VSNoFlip, FS, s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha,
|
||||
s_AlphaPipeline = ctx.newShaderPipeline(VSNoFlip, FS, nullptr, nullptr,
|
||||
s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha,
|
||||
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, boo::ZTest::None, false,
|
||||
true, false, boo::CullMode::None);
|
||||
s_AlphaGEqualPipeline = ctx.newShaderPipeline(VSNoFlip, FS, s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha,
|
||||
s_AlphaGEqualPipeline = ctx.newShaderPipeline(VSNoFlip, FS, nullptr, nullptr,
|
||||
s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha,
|
||||
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, boo::ZTest::GEqual, true,
|
||||
true, false, boo::CullMode::None);
|
||||
s_AddPipeline = ctx.newShaderPipeline(VSNoFlip, FS, s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha,
|
||||
s_AddPipeline = ctx.newShaderPipeline(VSNoFlip, FS, nullptr, nullptr,
|
||||
s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha,
|
||||
boo::BlendFactor::One, boo::Primitive::TriStrips, boo::ZTest::None, false,
|
||||
true, false, boo::CullMode::None);
|
||||
s_MultPipeline = ctx.newShaderPipeline(VSNoFlip, FS, s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcColor,
|
||||
s_MultPipeline = ctx.newShaderPipeline(VSNoFlip, FS, nullptr, nullptr,
|
||||
s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcColor,
|
||||
boo::BlendFactor::DstColor, boo::Primitive::TriStrips, boo::ZTest::None, false,
|
||||
true, false, boo::CullMode::None);
|
||||
return new CTexturedQuadFilterMetalDataBindingFactory;
|
||||
}
|
||||
|
||||
static boo::IVertexFormat* s_AVtxFmt = nullptr;
|
||||
static boo::IShaderPipeline* s_AAlphaPipeline = nullptr;
|
||||
static boo::IShaderPipeline* s_AAddPipeline = nullptr;
|
||||
static boo::IShaderPipeline* s_AMultPipeline = nullptr;
|
||||
template <>
|
||||
void CTexturedQuadFilter::Shutdown<boo::MetalDataFactory>()
|
||||
{
|
||||
s_VtxFmt.reset();
|
||||
s_AlphaPipeline.reset();
|
||||
s_AlphaGEqualPipeline.reset();
|
||||
s_AddPipeline.reset();
|
||||
s_MultPipeline.reset();
|
||||
}
|
||||
|
||||
static boo::IShaderPipeline* SelectAlphaPipeline(EFilterType type)
|
||||
static boo::ObjToken<boo::IVertexFormat> s_AVtxFmt;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_AAlphaPipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_AAddPipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_AMultPipeline;
|
||||
|
||||
static boo::ObjToken<boo::IShaderPipeline> SelectAlphaPipeline(EFilterType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
|
@ -190,22 +203,21 @@ static boo::IShaderPipeline* SelectAlphaPipeline(EFilterType type)
|
|||
case EFilterType::Multiply:
|
||||
return s_AMultPipeline;
|
||||
default:
|
||||
return nullptr;
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
struct CTexturedQuadFilterAlphaMetalDataBindingFactory : TMultiBlendShader<CTexturedQuadFilterAlpha>::IDataBindingFactory
|
||||
{
|
||||
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
EFilterType type,
|
||||
CTexturedQuadFilterAlpha& filter)
|
||||
boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
EFilterType type, CTexturedQuadFilterAlpha& filter)
|
||||
{
|
||||
boo::MetalDataFactory::Context& cctx = static_cast<boo::MetalDataFactory::Context&>(ctx);
|
||||
|
||||
boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf};
|
||||
boo::ITexture* texs[] = {filter.m_booTex};
|
||||
boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {filter.m_uniBuf.get()};
|
||||
boo::ObjToken<boo::ITexture> texs[] = {filter.m_booTex.get()};
|
||||
return cctx.newShaderDataBinding(SelectAlphaPipeline(type), s_AVtxFmt,
|
||||
filter.m_vbo, nullptr, nullptr, 1, bufs,
|
||||
filter.m_vbo.get(), nullptr, nullptr, 1, bufs,
|
||||
nullptr, nullptr, nullptr, 1, texs, nullptr, nullptr);
|
||||
}
|
||||
};
|
||||
|
@ -219,16 +231,28 @@ CTexturedQuadFilterAlpha::Initialize(boo::MetalDataFactory::Context& ctx)
|
|||
{nullptr, nullptr, boo::VertexSemantic::UV4}
|
||||
};
|
||||
s_AVtxFmt = ctx.newVertexFormat(2, VtxVmt);
|
||||
s_AAlphaPipeline = ctx.newShaderPipeline(VSFlip, FSAlpha, s_AVtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha,
|
||||
s_AAlphaPipeline = ctx.newShaderPipeline(VSFlip, FSAlpha, nullptr, nullptr,
|
||||
s_AVtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha,
|
||||
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips,
|
||||
boo::ZTest::None, false, true, false, boo::CullMode::None);
|
||||
s_AAddPipeline = ctx.newShaderPipeline(VSFlip, FSAlpha, s_AVtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha,
|
||||
s_AAddPipeline = ctx.newShaderPipeline(VSFlip, FSAlpha, nullptr, nullptr,
|
||||
s_AVtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha,
|
||||
boo::BlendFactor::One, boo::Primitive::TriStrips,
|
||||
boo::ZTest::None, false, true, false, boo::CullMode::None);
|
||||
s_AMultPipeline = ctx.newShaderPipeline(VSFlip, FSAlpha, s_AVtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcColor,
|
||||
s_AMultPipeline = ctx.newShaderPipeline(VSFlip, FSAlpha, nullptr, nullptr,
|
||||
s_AVtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcColor,
|
||||
boo::BlendFactor::DstColor, boo::Primitive::TriStrips,
|
||||
boo::ZTest::None, false, true, false, boo::CullMode::None);
|
||||
return new CTexturedQuadFilterAlphaMetalDataBindingFactory;
|
||||
}
|
||||
|
||||
template <>
|
||||
void CTexturedQuadFilterAlpha::Shutdown<boo::MetalDataFactory>()
|
||||
{
|
||||
s_AVtxFmt.reset();
|
||||
s_AAlphaPipeline.reset();
|
||||
s_AAddPipeline.reset();
|
||||
s_AMultPipeline.reset();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ namespace urde
|
|||
|
||||
CThermalColdFilter::CThermalColdFilter()
|
||||
{
|
||||
m_token = CGraphics::g_BooFactory->commitTransaction([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
|
||||
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
|
||||
{
|
||||
m_shiftTex = ctx.newDynamicTexture(8, 4, boo::TextureFormat::RGBA8, boo::TextureClampMode::Repeat);
|
||||
|
||||
|
@ -62,12 +62,10 @@ void CThermalColdFilter::draw()
|
|||
m_uniform.m_shiftTexScale[1] = 1.f / m_uniform.m_shiftTexMtx[1][1];
|
||||
m_uniBuf->load(&m_uniform, sizeof(m_uniform));
|
||||
|
||||
CGraphics::g_BooMainCommandQueue->setShaderDataBinding(m_dataBind);
|
||||
CGraphics::g_BooMainCommandQueue->draw(0, 4);
|
||||
CGraphics::SetShaderDataBinding(m_dataBind);
|
||||
CGraphics::DrawArray(0, 4);
|
||||
}
|
||||
|
||||
void CThermalColdFilter::Shutdown() {}
|
||||
|
||||
URDE_SPECIALIZE_SHADER(CThermalColdFilter)
|
||||
|
||||
}
|
||||
|
|
|
@ -23,11 +23,10 @@ class CThermalColdFilter
|
|||
zeus::CColor m_colorRegs[3];
|
||||
};
|
||||
u8 m_shiftTexture[4][8][4] = {};
|
||||
boo::GraphicsDataToken m_token;
|
||||
boo::ITextureD* m_shiftTex = nullptr;
|
||||
boo::IGraphicsBufferS* m_vbo;
|
||||
boo::IGraphicsBufferD* m_uniBuf;
|
||||
boo::IShaderDataBinding* m_dataBind = nullptr;
|
||||
boo::ObjToken<boo::ITextureD> m_shiftTex;
|
||||
boo::ObjToken<boo::IGraphicsBufferS> m_vbo;
|
||||
boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf;
|
||||
boo::ObjToken<boo::IShaderDataBinding> m_dataBind;
|
||||
Uniform m_uniform;
|
||||
|
||||
public:
|
||||
|
|
|
@ -75,26 +75,26 @@ BOO_GLSL_BINDING_HEAD
|
|||
|
||||
URDE_DECL_SPECIALIZE_SHADER(CThermalColdFilter)
|
||||
|
||||
static boo::IVertexFormat* s_VtxFmt = nullptr;
|
||||
static boo::IShaderPipeline* s_Pipeline = nullptr;
|
||||
static boo::ObjToken<boo::IVertexFormat> s_VtxFmt;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_Pipeline;
|
||||
|
||||
struct CThermalColdFilterGLDataBindingFactory : TShader<CThermalColdFilter>::IDataBindingFactory
|
||||
{
|
||||
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
CThermalColdFilter& filter)
|
||||
{
|
||||
boo::GLDataFactory::Context& cctx = static_cast<boo::GLDataFactory::Context&>(ctx);
|
||||
|
||||
const boo::VertexElementDescriptor VtxVmt[] =
|
||||
{
|
||||
{filter.m_vbo, nullptr, boo::VertexSemantic::Position4},
|
||||
{filter.m_vbo, nullptr, boo::VertexSemantic::UV4}
|
||||
{filter.m_vbo.get(), nullptr, boo::VertexSemantic::Position4},
|
||||
{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::ITexture* texs[] = {CGraphics::g_SpareTexture, filter.m_shiftTex};
|
||||
boo::ObjToken<boo::ITexture> texs[] = {CGraphics::g_SpareTexture.get(), filter.m_shiftTex.get()};
|
||||
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, 2, texs, nullptr, nullptr);
|
||||
}
|
||||
};
|
||||
|
@ -126,6 +126,12 @@ TShader<CThermalColdFilter>::IDataBindingFactory* CThermalColdFilter::Initialize
|
|||
return new CThermalColdFilterGLDataBindingFactory;
|
||||
}
|
||||
|
||||
template <>
|
||||
void CThermalColdFilter::Shutdown<boo::GLDataFactory>()
|
||||
{
|
||||
s_Pipeline.reset();
|
||||
}
|
||||
|
||||
#if BOO_HAS_VULKAN
|
||||
TShader<CThermalColdFilter>::IDataBindingFactory* CThermalColdFilter::Initialize(boo::VulkanDataFactory::Context& ctx)
|
||||
{
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue