From 3799759ca70585325151d2de82f38fdf5431d336 Mon Sep 17 00:00:00 2001 From: Luke Street Date: Sat, 3 Oct 2020 22:42:21 -0400 Subject: [PATCH] CScanLinesFilter: Convert to hsh pipeline --- Runtime/Graphics/CBooRenderer.hpp | 9 ++-- Runtime/Graphics/CMakeLists.txt | 1 + Runtime/Graphics/Shaders/CScanLinesFilter.cpp | 49 ++++++++----------- Runtime/Graphics/Shaders/CScanLinesFilter.hpp | 5 +- 4 files changed, 32 insertions(+), 32 deletions(-) diff --git a/Runtime/Graphics/CBooRenderer.hpp b/Runtime/Graphics/CBooRenderer.hpp index 96718ab12..3cd67be14 100644 --- a/Runtime/Graphics/CBooRenderer.hpp +++ b/Runtime/Graphics/CBooRenderer.hpp @@ -52,6 +52,11 @@ class CBooRenderer final : public IRenderer { friend class CMorphBallShadow; friend class CWorldTransManager; +public: + struct ScanlinesVert { + hsh::float3 pos; + }; + struct CAreaListItem { const std::vector* x0_geometry; const CAreaRenderOctTree* x4_octTree; @@ -84,6 +89,7 @@ class CBooRenderer final : public IRenderer { } }; +private: IFactory& x8_factory; IObjectStore& xc_store; TLockedToken m_staticEntropy; @@ -119,9 +125,6 @@ class CBooRenderer final : public IRenderer { hsh::texture2d m_ballFade; hsh::owner m_ballShadowId; - struct ScanlinesVert { - hsh::float3 pos; - }; hsh::owner> m_scanLinesEvenVBO; hsh::owner> m_scanLinesOddVBO; diff --git a/Runtime/Graphics/CMakeLists.txt b/Runtime/Graphics/CMakeLists.txt index c2f2c3a89..785ca6782 100644 --- a/Runtime/Graphics/CMakeLists.txt +++ b/Runtime/Graphics/CMakeLists.txt @@ -69,4 +69,5 @@ runtime_add_hsh(Graphics Shaders/CPhazonSuitFilter.cpp Shaders/CRadarPaintShader.cpp Shaders/CRandomStaticFilter.cpp + Shaders/CScanLinesFilter.cpp ) diff --git a/Runtime/Graphics/Shaders/CScanLinesFilter.cpp b/Runtime/Graphics/Shaders/CScanLinesFilter.cpp index e7e53c666..12ce0e6e2 100644 --- a/Runtime/Graphics/Shaders/CScanLinesFilter.cpp +++ b/Runtime/Graphics/Shaders/CScanLinesFilter.cpp @@ -1,49 +1,42 @@ #include "Runtime/Graphics/Shaders/CScanLinesFilter.hpp" -#include - #include "Runtime/GameGlobalObjects.hpp" #include "Runtime/Camera/CCameraFilter.hpp" #include "Runtime/Graphics/CBooRenderer.hpp" #include "Runtime/Graphics/CGraphics.hpp" -namespace urde { +#include "CScanLinesFilter.cpp.hshhead" -static boo::ObjToken SelectPipeline(EFilterType type) { - switch (type) { - case EFilterType::Blend: - return s_AlphaPipeline; - case EFilterType::Add: - return s_AddPipeline; - case EFilterType::Multiply: - return s_MultPipeline; - default: - return {}; +namespace urde { +using namespace hsh::pipeline; + +template +struct CScanLinesFilterPipeline : FilterPipeline { + CScanLinesFilterPipeline(hsh::vertex_buffer vbo, + hsh::uniform_buffer ubo) { + this->position = hsh::float4(vbo->pos, 1.f); + this->color_out[0] = ubo->color; } -} +}; +template struct CScanLinesFilterPipeline; +template struct CScanLinesFilterPipeline; +// TODO old shader sets #overwritealpha true +// but isn't implemented in FilterPipeline +template struct CScanLinesFilterPipeline; CScanLinesFilter::CScanLinesFilter(EFilterType type, bool even) : m_even(even) { - CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) { - m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1); - boo::ObjToken vbo = - m_even ? g_Renderer->GetScanLinesEvenVBO().get() : g_Renderer->GetScanLinesOddVBO().get(); - const std::array, 1> bufs{m_uniBuf.get()}; - constexpr std::array stages{boo::PipelineStage::Vertex}; - - m_dataBind = ctx.newShaderDataBinding(SelectPipeline(type), vbo, nullptr, nullptr, bufs.size(), bufs.data(), - stages.data(), nullptr, nullptr, 0, nullptr, nullptr, nullptr); - return true; - } BooTrace); + m_uniBuf = hsh::create_dynamic_uniform_buffer(); + m_dataBind.hsh_bind(CScanLinesFilterPipeline( + m_even ? g_Renderer->GetScanLinesEvenVBO() : g_Renderer->GetScanLinesOddVBO(), m_uniBuf.get())); } void CScanLinesFilter::draw(const zeus::CColor& color) { SCOPED_GRAPHICS_DEBUG_GROUP("CScanLinesFilter::draw", zeus::skMagenta); m_uniform.color = color; - m_uniBuf->load(&m_uniform, sizeof(Uniform)); + m_uniBuf.load(m_uniform); - CGraphics::SetShaderDataBinding(m_dataBind); - CGraphics::DrawArray(0, 670); + m_dataBind.draw(0, 670); } } // namespace urde diff --git a/Runtime/Graphics/Shaders/CScanLinesFilter.hpp b/Runtime/Graphics/Shaders/CScanLinesFilter.hpp index 59aca7dd6..2cc47f99e 100644 --- a/Runtime/Graphics/Shaders/CScanLinesFilter.hpp +++ b/Runtime/Graphics/Shaders/CScanLinesFilter.hpp @@ -11,9 +11,12 @@ enum class EFilterShape; enum class EFilterType; class CScanLinesFilter { +public: struct Uniform { - zeus::CColor color; + hsh::float4 color; }; + +private: hsh::dynamic_owner> m_uniBuf; hsh::binding m_dataBind; Uniform m_uniform;