mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-10 00:27:43 +00:00
Huge shader infrastructure refactor
This commit is contained in:
@@ -20,83 +20,32 @@ HMDLData::HMDLData(boo::IGraphicsDataFactory::Context& ctx,
|
||||
m_vbo = ctx.newStaticBuffer(boo::BufferUse::Vertex, vbo, meta.vertStride, meta.vertCount);
|
||||
m_ibo = ctx.newStaticBuffer(boo::BufferUse::Index, ibo, 4, meta.indexCount);
|
||||
|
||||
if (ctx.bindingNeedsVertexFormat())
|
||||
m_vtxFmt = NewVertexFormat(ctx, meta, m_vbo.get(), m_ibo.get());
|
||||
}
|
||||
|
||||
/* For binding constructors that require vertex format up front (GLSL) */
|
||||
boo::ObjToken<boo::IVertexFormat>
|
||||
HMDLData::NewVertexFormat(boo::IGraphicsDataFactory::Context& ctx, const HMDLMeta& meta,
|
||||
const boo::ObjToken<boo::IGraphicsBuffer>& vbo,
|
||||
const boo::ObjToken<boo::IGraphicsBuffer>& ibo)
|
||||
{
|
||||
size_t elemCount = 2 + meta.colorCount + meta.uvCount + meta.weightCount;
|
||||
std::unique_ptr<boo::VertexElementDescriptor[]> vdescs(new boo::VertexElementDescriptor[elemCount]);
|
||||
for (size_t i=0 ; i<elemCount ; ++i)
|
||||
{
|
||||
vdescs[i].vertBuffer = vbo;
|
||||
vdescs[i].indexBuffer = ibo;
|
||||
}
|
||||
m_vtxFmtData.reset(new boo::VertexElementDescriptor[elemCount]);
|
||||
|
||||
vdescs[0].semantic = boo::VertexSemantic::Position3;
|
||||
vdescs[1].semantic = boo::VertexSemantic::Normal3;
|
||||
m_vtxFmtData[0].semantic = boo::VertexSemantic::Position3;
|
||||
m_vtxFmtData[1].semantic = boo::VertexSemantic::Normal3;
|
||||
size_t e = 2;
|
||||
|
||||
for (size_t i=0 ; i<meta.colorCount ; ++i, ++e)
|
||||
{
|
||||
vdescs[e].semantic = boo::VertexSemantic::ColorUNorm;
|
||||
vdescs[e].semanticIdx = i;
|
||||
m_vtxFmtData[e].semantic = boo::VertexSemantic::ColorUNorm;
|
||||
m_vtxFmtData[e].semanticIdx = i;
|
||||
}
|
||||
|
||||
for (size_t i=0 ; i<meta.uvCount ; ++i, ++e)
|
||||
{
|
||||
vdescs[e].semantic = boo::VertexSemantic::UV2;
|
||||
vdescs[e].semanticIdx = i;
|
||||
m_vtxFmtData[e].semantic = boo::VertexSemantic::UV2;
|
||||
m_vtxFmtData[e].semanticIdx = i;
|
||||
}
|
||||
|
||||
for (size_t i=0 ; i<meta.weightCount ; ++i, ++e)
|
||||
{
|
||||
vdescs[e].semantic = boo::VertexSemantic::Weight;
|
||||
vdescs[e].semanticIdx = i;
|
||||
m_vtxFmtData[e].semantic = boo::VertexSemantic::Weight;
|
||||
m_vtxFmtData[e].semanticIdx = i;
|
||||
}
|
||||
|
||||
return ctx.newVertexFormat(elemCount, vdescs.get());
|
||||
}
|
||||
|
||||
/* For shader constructors that require vertex format up-front (HLSL/Metal/Vulkan) */
|
||||
boo::ObjToken<boo::IVertexFormat> ShaderTag::newVertexFormat(boo::IGraphicsDataFactory::Context& ctx) const
|
||||
{
|
||||
size_t elemCount = 2 + m_colorCount + m_uvCount + m_weightCount;
|
||||
std::unique_ptr<boo::VertexElementDescriptor[]> vdescs(new boo::VertexElementDescriptor[elemCount]);
|
||||
for (size_t i=0 ; i<elemCount ; ++i)
|
||||
{
|
||||
vdescs[i].vertBuffer = nullptr;
|
||||
vdescs[i].indexBuffer = nullptr;
|
||||
}
|
||||
|
||||
vdescs[0].semantic = boo::VertexSemantic::Position3;
|
||||
vdescs[1].semantic = boo::VertexSemantic::Normal3;
|
||||
size_t e = 2;
|
||||
|
||||
for (size_t i=0 ; i<m_colorCount ; ++i, ++e)
|
||||
{
|
||||
vdescs[e].semantic = boo::VertexSemantic::ColorUNorm;
|
||||
vdescs[e].semanticIdx = i;
|
||||
}
|
||||
|
||||
for (size_t i=0 ; i<m_uvCount ; ++i, ++e)
|
||||
{
|
||||
vdescs[e].semantic = boo::VertexSemantic::UV2;
|
||||
vdescs[e].semanticIdx = i;
|
||||
}
|
||||
|
||||
for (size_t i=0 ; i<m_weightCount ; ++i, ++e)
|
||||
{
|
||||
vdescs[e].semantic = boo::VertexSemantic::Weight;
|
||||
vdescs[e].semanticIdx = i;
|
||||
}
|
||||
|
||||
return ctx.newVertexFormat(elemCount, vdescs.get());
|
||||
m_vtxFmt = boo::VertexFormatInfo(elemCount, m_vtxFmtData.get());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user