mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-10 07:47:42 +00:00
Graphics/Shaders: Use std::array where applicable
Makes the arrays strongly typed and impervious to array->pointer decay. This also allows simplifying some operations (such as being able to call fill() instead of needing to use std::fill, etc).
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
#include "Runtime/Graphics/Shaders/CWorldShadowShader.hpp"
|
||||
|
||||
#include <array>
|
||||
|
||||
#include "Runtime/Camera/CCameraFilter.hpp"
|
||||
#include "Runtime/Graphics/CGraphics.hpp"
|
||||
|
||||
@@ -25,12 +27,14 @@ CWorldShadowShader::CWorldShadowShader(u32 w, u32 h) : m_w(w), m_h(h) {
|
||||
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) {
|
||||
m_vbo = ctx.newDynamicBuffer(boo::BufferUse::Vertex, 16, 4);
|
||||
m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1);
|
||||
boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {m_uniBuf.get()};
|
||||
boo::PipelineStage stages[] = {boo::PipelineStage::Vertex};
|
||||
m_dataBind = ctx.newShaderDataBinding(s_Pipeline, m_vbo.get(), nullptr, nullptr, 1, bufs, stages, nullptr, nullptr,
|
||||
0, nullptr, nullptr, nullptr);
|
||||
m_zDataBind = ctx.newShaderDataBinding(s_ZPipeline, m_vbo.get(), nullptr, nullptr, 1, bufs, stages, nullptr,
|
||||
nullptr, 0, nullptr, nullptr, nullptr);
|
||||
|
||||
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(s_Pipeline, m_vbo.get(), nullptr, nullptr, bufs.size(), bufs.data(),
|
||||
stages.data(), nullptr, nullptr, 0, nullptr, nullptr, nullptr);
|
||||
m_zDataBind = ctx.newShaderDataBinding(s_ZPipeline, m_vbo.get(), nullptr, nullptr, bufs.size(), bufs.data(),
|
||||
stages.data(), nullptr, nullptr, 0, nullptr, nullptr, nullptr);
|
||||
|
||||
m_tex = ctx.newRenderTexture(m_w, m_h, boo::TextureClampMode::ClampToWhite, 1, 0);
|
||||
return true;
|
||||
} BooTrace);
|
||||
@@ -41,9 +45,13 @@ void CWorldShadowShader::bindRenderTarget() { CGraphics::g_BooMainCommandQueue->
|
||||
void CWorldShadowShader::drawBase(float extent) {
|
||||
SCOPED_GRAPHICS_DEBUG_GROUP("CWorldShadowShader::drawBase", zeus::skMagenta);
|
||||
|
||||
zeus::CVector3f verts[] = {
|
||||
{-extent, 0.f, extent}, {extent, 0.f, extent}, {-extent, 0.f, -extent}, {extent, 0.f, -extent}};
|
||||
m_vbo->load(verts, sizeof(zeus::CVector3f) * 4);
|
||||
const std::array<zeus::CVector3f, 4> verts{{
|
||||
{-extent, 0.f, extent},
|
||||
{extent, 0.f, extent},
|
||||
{-extent, 0.f, -extent},
|
||||
{extent, 0.f, -extent},
|
||||
}};
|
||||
m_vbo->load(verts.data(), sizeof(verts));
|
||||
|
||||
m_uniform.m_matrix = CGraphics::GetPerspectiveProjectionMatrix(true) * CGraphics::g_GXModelView.toMatrix4f();
|
||||
m_uniform.m_color = zeus::skWhite;
|
||||
|
||||
Reference in New Issue
Block a user