2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-09 06:27:43 +00:00

Huge shader refactor

This commit is contained in:
Jack Andersen
2018-10-06 16:59:17 -10:00
parent 0a0a581f2d
commit c307e354ca
184 changed files with 8777 additions and 14295 deletions

View File

@@ -70,34 +70,13 @@ void CTextRenderBuffer::CommitResources()
chs.m_instBuf = CTextSupportShader::s_CharInsts.allocateBlock(CGraphics::g_BooFactory, chs.m_charCount);
auto iBufInfo = chs.m_instBuf.getBufferInfo();
boo::ObjToken<boo::IVertexFormat> vFmt = CTextSupportShader::s_TextVtxFmt;
if (ctx.bindingNeedsVertexFormat())
{
boo::ObjToken<boo::IGraphicsBufferD> buf = iBufInfo.first;
boo::VertexElementDescriptor elems[] =
{
{buf.get(), nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 0},
{buf.get(), nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 1},
{buf.get(), nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 2},
{buf.get(), nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 3},
{buf.get(), nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 0},
{buf.get(), nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 1},
{buf.get(), nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 2},
{buf.get(), nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 3},
{buf.get(), nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced, 0},
{buf.get(), nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced, 1},
{buf.get(), nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced, 2},
};
vFmt = ctx.newVertexFormat(11, elems, 0, iBufInfo.second);
}
boo::ObjToken<boo::IGraphicsBuffer> uniforms[] = {uBufInfo.first.get()};
boo::PipelineStage unistages[] = {boo::PipelineStage::Vertex};
size_t unioffs[] = {size_t(uBufInfo.second)};
size_t unisizes[] = {sizeof(CTextSupportShader::Uniform)};
boo::ObjToken<boo::ITexture> texs[] = {chs.m_font->GetTexture()};
chs.m_dataBinding = ctx.newShaderDataBinding(CTextSupportShader::SelectTextPipeline(m_drawFlags),
vFmt, nullptr, iBufInfo.first.get(), nullptr,
nullptr, iBufInfo.first.get(), nullptr,
1, uniforms, unistages, unioffs,
unisizes, 1, texs, nullptr, nullptr, 0, iBufInfo.second);
@@ -106,7 +85,7 @@ void CTextRenderBuffer::CommitResources()
uniforms[0] = uBufInfo2.first.get();
unioffs[0] = size_t(uBufInfo2.second);
chs.m_dataBinding2 = ctx.newShaderDataBinding(CTextSupportShader::GetTextAdditiveOverdrawPipeline(),
vFmt, nullptr, iBufInfo.first.get(), nullptr,
nullptr, iBufInfo.first.get(), nullptr,
1, uniforms, unistages, unioffs,
unisizes, 1, texs, nullptr, nullptr, 0, iBufInfo.second);
}
@@ -117,25 +96,6 @@ void CTextRenderBuffer::CommitResources()
img.m_instBuf = CTextSupportShader::s_ImgInsts.allocateBlock(CGraphics::g_BooFactory, 1);
auto iBufInfo = img.m_instBuf.getBufferInfo();
boo::ObjToken<boo::IVertexFormat> vFmt = CTextSupportShader::s_ImageVtxFmt;
if (ctx.bindingNeedsVertexFormat())
{
boo::ObjToken<boo::IGraphicsBufferD> buf = iBufInfo.first;
boo::VertexElementDescriptor elems[] =
{
{buf.get(), nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 0},
{buf.get(), nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 1},
{buf.get(), nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 2},
{buf.get(), nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 3},
{buf.get(), nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 0},
{buf.get(), nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 1},
{buf.get(), nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 2},
{buf.get(), nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 3},
{buf.get(), nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced, 0},
};
vFmt = ctx.newVertexFormat(9, elems, 0, iBufInfo.second);
}
boo::ObjToken<boo::IGraphicsBuffer> uniforms[] = {uBufInfo.first.get()};
boo::PipelineStage unistages[] = {boo::PipelineStage::Vertex};
size_t unioffs[] = {size_t(uBufInfo.second)};
@@ -146,7 +106,7 @@ void CTextRenderBuffer::CommitResources()
boo::ObjToken<boo::ITexture> texs[] = {tex->GetBooTexture()};
texs[0]->setClampMode(boo::TextureClampMode::ClampToEdge);
img.m_dataBinding.push_back(ctx.newShaderDataBinding(CTextSupportShader::SelectImagePipeline(m_drawFlags),
vFmt, nullptr, iBufInfo.first.get(), nullptr,
nullptr, iBufInfo.first.get(), nullptr,
1, uniforms, unistages, unioffs,
unisizes, 1, texs, nullptr, nullptr, 0, iBufInfo.second));
}
@@ -160,7 +120,7 @@ void CTextRenderBuffer::CommitResources()
{
boo::ObjToken<boo::ITexture> texs[] = {tex->GetBooTexture()};
img.m_dataBinding2.push_back(ctx.newShaderDataBinding(CTextSupportShader::GetImageAdditiveOverdrawPipeline(),
vFmt, nullptr, iBufInfo.first.get(), nullptr,
nullptr, iBufInfo.first.get(), nullptr,
1, uniforms, unistages, unioffs,
unisizes, 1, texs, nullptr, nullptr, 0, iBufInfo.second));
}