2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-17 02:17:03 +00:00

CAABoxShader: Pull pipeline configuration from GX state

This commit is contained in:
2020-09-30 01:58:28 -04:00
parent 96ed5c7cee
commit 485e0afb43
9 changed files with 208 additions and 57 deletions

View File

@@ -9,19 +9,20 @@
namespace urde {
using namespace hsh::pipeline;
template <bool zOnly>
template <ERglCullMode CullMode, ERglEnum Compare, bool DepthWrite, ERglBlendMode Mode, ERglBlendFactor SrcFac,
ERglBlendFactor DstFac, ERglLogicOp Op, bool AlphaWrite>
struct CAABoxShaderPipeline
: pipeline<topology<hsh::TriangleStrip>, std::conditional_t<zOnly, NoColorAttachment<>, BlendAttachment<>>,
depth_compare<hsh::LEqual>> {
: pipeline<topology<hsh::TriangleStrip>, ERglBlendModeAttachment<Mode, SrcFac, DstFac, Op, AlphaWrite>,
ERglCullModeAttachment<CullMode>, ERglDepthCompareAttachment<Compare>, depth_write<DepthWrite>> {
CAABoxShaderPipeline(hsh::vertex_buffer<CAABoxShader::Vert> vbo, hsh::uniform_buffer<CAABoxShader::Uniform> uniBuf) {
this->position = uniBuf->m_xf * hsh::float4(vbo->m_pos, 1.f);
this->color_out[0] = uniBuf->m_color;
}
};
template struct CAABoxShaderPipeline<true>;
template struct CAABoxShaderPipeline<false>;
template struct CAABoxShaderPipeline<ERglCullMode::None, ERglEnum::Always, true, ERglBlendMode::Blend,
ERglBlendFactor::SrcAlpha, ERglBlendFactor::InvSrcAlpha, ERglLogicOp::Clear, true>;
CAABoxShader::CAABoxShader(const zeus::CAABox& aabb, bool zOnly) {
CAABoxShader::CAABoxShader(const zeus::CAABox& aabb) {
const std::array<Vert, 34> verts{{
{{aabb.max.x(), aabb.max.y(), aabb.min.z()}}, {{aabb.max.x(), aabb.min.y(), aabb.min.z()}},
{{aabb.max.x(), aabb.max.y(), aabb.max.z()}}, {{aabb.max.x(), aabb.min.y(), aabb.max.z()}},
@@ -50,8 +51,8 @@ CAABoxShader::CAABoxShader(const zeus::CAABox& aabb, bool zOnly) {
m_vbo = hsh::create_vertex_buffer(verts);
m_uniBuf = hsh::create_dynamic_uniform_buffer<Uniform>();
m_dataBind.hsh_bind(CAABoxShaderPipeline<zOnly>(m_vbo.get(), m_uniBuf.get()));
m_dataBind.hsh_bind(CAABoxShaderPipeline<gx_CullMode, gx_DepthTest, gx_DepthWrite, gx_BlendMode, gx_BlendSrcFac,
gx_BlendDstFac, gx_BlendOp, gx_AlphaWrite>(m_vbo.get(), m_uniBuf.get()));
}
void CAABoxShader::draw(const zeus::CColor& color) {

View File

@@ -25,7 +25,7 @@ private:
Uniform m_uniform{};
public:
CAABoxShader(const zeus::CAABox& aabb, bool zOnly = false);
CAABoxShader(const zeus::CAABox& aabb);
void draw(const zeus::CColor& color);
};