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 CWorldTransManager;
public:
struct ScanlinesVert {
hsh::float3 pos;
};
struct CAreaListItem {
const std::vector<CMetroidModelInstance>* x0_geometry;
const CAreaRenderOctTree* x4_octTree;
@ -84,6 +89,7 @@ class CBooRenderer final : public IRenderer {
}
};
private:
IFactory& x8_factory;
IObjectStore& xc_store;
TLockedToken<CTexture> m_staticEntropy;
@ -119,9 +125,6 @@ class CBooRenderer final : public IRenderer {
hsh::texture2d m_ballFade;
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_scanLinesOddVBO;

View File

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

View File

@ -1,49 +1,42 @@
#include "Runtime/Graphics/Shaders/CScanLinesFilter.hpp"
#include <array>
#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<boo::IShaderPipeline> 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 <EFilterType Type>
struct CScanLinesFilterPipeline : FilterPipeline<Type> {
CScanLinesFilterPipeline(hsh::vertex_buffer<CBooRenderer::ScanlinesVert> vbo,
hsh::uniform_buffer<CScanLinesFilter::Uniform> ubo) {
this->position = hsh::float4(vbo->pos, 1.f);
this->color_out[0] = ubo->color;
}
}
};
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) {
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) {
m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1);
boo::ObjToken<boo::IGraphicsBuffer> vbo =
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);
m_uniBuf = hsh::create_dynamic_uniform_buffer<Uniform>();
m_dataBind.hsh_bind(CScanLinesFilterPipeline<type>(
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

View File

@ -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<hsh::uniform_buffer<Uniform>> m_uniBuf;
hsh::binding m_dataBind;
Uniform m_uniform;