CScanLinesFilter: Convert to hsh pipeline

This commit is contained in:
Luke Street 2020-10-03 22:42:21 -04:00
parent 7b3783ddf9
commit 3799759ca7
4 changed files with 32 additions and 32 deletions

View File

@ -52,6 +52,11 @@ class CBooRenderer final : public IRenderer {
friend class CMorphBallShadow; friend class CMorphBallShadow;
friend class CWorldTransManager; friend class CWorldTransManager;
public:
struct ScanlinesVert {
hsh::float3 pos;
};
struct CAreaListItem { struct CAreaListItem {
const std::vector<CMetroidModelInstance>* x0_geometry; const std::vector<CMetroidModelInstance>* x0_geometry;
const CAreaRenderOctTree* x4_octTree; const CAreaRenderOctTree* x4_octTree;
@ -84,6 +89,7 @@ class CBooRenderer final : public IRenderer {
} }
}; };
private:
IFactory& x8_factory; IFactory& x8_factory;
IObjectStore& xc_store; IObjectStore& xc_store;
TLockedToken<CTexture> m_staticEntropy; TLockedToken<CTexture> m_staticEntropy;
@ -119,9 +125,6 @@ class CBooRenderer final : public IRenderer {
hsh::texture2d m_ballFade; hsh::texture2d m_ballFade;
hsh::owner<hsh::render_texture2d> m_ballShadowId; hsh::owner<hsh::render_texture2d> m_ballShadowId;
struct ScanlinesVert {
hsh::float3 pos;
};
hsh::owner<hsh::vertex_buffer<ScanlinesVert>> m_scanLinesEvenVBO; hsh::owner<hsh::vertex_buffer<ScanlinesVert>> m_scanLinesEvenVBO;
hsh::owner<hsh::vertex_buffer<ScanlinesVert>> m_scanLinesOddVBO; hsh::owner<hsh::vertex_buffer<ScanlinesVert>> m_scanLinesOddVBO;

View File

@ -69,4 +69,5 @@ runtime_add_hsh(Graphics
Shaders/CPhazonSuitFilter.cpp Shaders/CPhazonSuitFilter.cpp
Shaders/CRadarPaintShader.cpp Shaders/CRadarPaintShader.cpp
Shaders/CRandomStaticFilter.cpp Shaders/CRandomStaticFilter.cpp
Shaders/CScanLinesFilter.cpp
) )

View File

@ -1,49 +1,42 @@
#include "Runtime/Graphics/Shaders/CScanLinesFilter.hpp" #include "Runtime/Graphics/Shaders/CScanLinesFilter.hpp"
#include <array>
#include "Runtime/GameGlobalObjects.hpp" #include "Runtime/GameGlobalObjects.hpp"
#include "Runtime/Camera/CCameraFilter.hpp" #include "Runtime/Camera/CCameraFilter.hpp"
#include "Runtime/Graphics/CBooRenderer.hpp" #include "Runtime/Graphics/CBooRenderer.hpp"
#include "Runtime/Graphics/CGraphics.hpp" #include "Runtime/Graphics/CGraphics.hpp"
namespace urde { #include "CScanLinesFilter.cpp.hshhead"
static boo::ObjToken<boo::IShaderPipeline> SelectPipeline(EFilterType type) { namespace urde {
switch (type) { using namespace hsh::pipeline;
case EFilterType::Blend:
return s_AlphaPipeline; template <EFilterType Type>
case EFilterType::Add: struct CScanLinesFilterPipeline : FilterPipeline<Type> {
return s_AddPipeline; CScanLinesFilterPipeline(hsh::vertex_buffer<CBooRenderer::ScanlinesVert> vbo,
case EFilterType::Multiply: hsh::uniform_buffer<CScanLinesFilter::Uniform> ubo) {
return s_MultPipeline; this->position = hsh::float4(vbo->pos, 1.f);
default: this->color_out[0] = ubo->color;
return {};
}
} }
};
template struct CScanLinesFilterPipeline<EFilterType::Blend>;
template struct CScanLinesFilterPipeline<EFilterType::Add>;
// TODO old shader sets #overwritealpha true
// but isn't implemented in FilterPipeline
template struct CScanLinesFilterPipeline<EFilterType::Multiply>;
CScanLinesFilter::CScanLinesFilter(EFilterType type, bool even) : m_even(even) { CScanLinesFilter::CScanLinesFilter(EFilterType type, bool even) : m_even(even) {
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) { m_uniBuf = hsh::create_dynamic_uniform_buffer<Uniform>();
m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1); m_dataBind.hsh_bind(CScanLinesFilterPipeline<type>(
boo::ObjToken<boo::IGraphicsBuffer> vbo = m_even ? g_Renderer->GetScanLinesEvenVBO() : g_Renderer->GetScanLinesOddVBO(), m_uniBuf.get()));
m_even ? g_Renderer->GetScanLinesEvenVBO().get() : g_Renderer->GetScanLinesOddVBO().get();
const std::array<boo::ObjToken<boo::IGraphicsBuffer>, 1> bufs{m_uniBuf.get()};
constexpr std::array<boo::PipelineStage, 1> 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);
} }
void CScanLinesFilter::draw(const zeus::CColor& color) { void CScanLinesFilter::draw(const zeus::CColor& color) {
SCOPED_GRAPHICS_DEBUG_GROUP("CScanLinesFilter::draw", zeus::skMagenta); SCOPED_GRAPHICS_DEBUG_GROUP("CScanLinesFilter::draw", zeus::skMagenta);
m_uniform.color = color; m_uniform.color = color;
m_uniBuf->load(&m_uniform, sizeof(Uniform)); m_uniBuf.load(m_uniform);
CGraphics::SetShaderDataBinding(m_dataBind); m_dataBind.draw(0, 670);
CGraphics::DrawArray(0, 670);
} }
} // namespace urde } // namespace urde

View File

@ -11,9 +11,12 @@ enum class EFilterShape;
enum class EFilterType; enum class EFilterType;
class CScanLinesFilter { class CScanLinesFilter {
public:
struct Uniform { struct Uniform {
zeus::CColor color; hsh::float4 color;
}; };
private:
hsh::dynamic_owner<hsh::uniform_buffer<Uniform>> m_uniBuf; hsh::dynamic_owner<hsh::uniform_buffer<Uniform>> m_uniBuf;
hsh::binding m_dataBind; hsh::binding m_dataBind;
Uniform m_uniform; Uniform m_uniform;