CModelBoo: Make use of std::array where applicable

Allows decoding some array sizes.
This commit is contained in:
Lioncash 2020-04-12 10:35:54 -04:00
parent c203a0de7c
commit e0c187c607
1 changed files with 23 additions and 15 deletions

View File

@ -309,29 +309,37 @@ CBooModel::ModelInstance* CBooModel::PushNewModelInstance(int sharedLayoutBuf) {
m_uniformDataSize = uniBufSize; m_uniformDataSize = uniBufSize;
newInst.m_uniformBuffer = ctx.newDynamicBuffer(boo::BufferUse::Uniform, uniBufSize, 1); newInst.m_uniformBuffer = ctx.newDynamicBuffer(boo::BufferUse::Uniform, uniBufSize, 1);
boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {geomUniformBuf.get(), geomUniformBuf.get(), const std::array<boo::ObjToken<boo::IGraphicsBuffer>, 4> bufs{
newInst.m_uniformBuffer.get(), newInst.m_uniformBuffer.get()}; geomUniformBuf.get(),
geomUniformBuf.get(),
newInst.m_uniformBuffer.get(),
newInst.m_uniformBuffer.get(),
};
/* Binding for each surface */ /* Binding for each surface */
newInst.m_shaderDataBindings.reserve(x0_surfaces->size()); newInst.m_shaderDataBindings.reserve(x0_surfaces->size());
size_t thisOffs[4]; std::array<size_t, 4> thisOffs;
size_t thisSizes[4]; std::array<size_t, 4> thisSizes;
static const boo::PipelineStage stages[4] = {boo::PipelineStage::Vertex, boo::PipelineStage::Vertex, static constexpr std::array stages{
boo::PipelineStage::Fragment, boo::PipelineStage::Vertex}; boo::PipelineStage::Vertex,
boo::PipelineStage::Vertex,
boo::PipelineStage::Fragment,
boo::PipelineStage::Vertex,
};
/* Enumerate surfaces and build data bindings */ /* Enumerate surfaces and build data bindings */
size_t curReflect = reflectOff + 256; size_t curReflect = reflectOff + 256;
for (const CBooSurface& surf : *x0_surfaces) { for (const CBooSurface& surf : *x0_surfaces) {
const MaterialSet::Material& mat = x4_matSet->materials.at(surf.m_data.matIdx); const MaterialSet::Material& mat = x4_matSet->materials.at(surf.m_data.matIdx);
boo::ObjToken<boo::ITexture> texs[12] = {g_Renderer->m_clearTexture.get(), g_Renderer->m_clearTexture.get(), std::array<boo::ObjToken<boo::ITexture>, 12> texs{
g_Renderer->m_clearTexture.get(), g_Renderer->m_clearTexture.get(), g_Renderer->m_clearTexture.get(), g_Renderer->m_clearTexture.get(), g_Renderer->m_clearTexture.get(),
g_Renderer->m_clearTexture.get(), g_Renderer->m_clearTexture.get(), g_Renderer->m_clearTexture.get(), g_Renderer->m_clearTexture.get(), g_Renderer->m_clearTexture.get(),
g_Renderer->m_clearTexture.get(), g_Renderer->m_clearTexture.get(), g_Renderer->m_clearTexture.get(), g_Renderer->m_clearTexture.get(), g_Renderer->x220_sphereRamp.get(),
g_Renderer->x220_sphereRamp.get(), g_Renderer->x220_sphereRamp.get(), g_Renderer->x220_sphereRamp.get(), g_Renderer->x220_sphereRamp.get(), g_Renderer->x220_sphereRamp.get(),
g_Renderer->x220_sphereRamp.get(), g_Renderer->x220_sphereRamp.get()}; };
if (!g_DummyTextures) { if (!g_DummyTextures) {
for (const auto& ch : mat.chunks) { for (const auto& ch : mat.chunks) {
if (auto pass = ch.get_if<MaterialSet::Material::PASS>()) { if (auto pass = ch.get_if<MaterialSet::Material::PASS>()) {
@ -401,9 +409,9 @@ CBooModel::ModelInstance* CBooModel::PushNewModelInstance(int sharedLayoutBuf) {
else else
texs[11] = g_Renderer->x220_sphereRamp.get(); texs[11] = g_Renderer->x220_sphereRamp.get();
} }
extendeds.push_back(ctx.newShaderDataBinding(pipeline, newInst.GetBooVBO(*this, ctx), nullptr, extendeds.push_back(ctx.newShaderDataBinding(
m_staticIbo.get(), 4, bufs, stages, thisOffs, thisSizes, 12, texs, pipeline, newInst.GetBooVBO(*this, ctx), nullptr, m_staticIbo.get(), bufs.size(), bufs.data(),
nullptr, nullptr)); stages.data(), thisOffs.data(), thisSizes.data(), texs.size(), texs.data(), nullptr, nullptr));
idx = EExtendedShader(size_t(idx) + 1); idx = EExtendedShader(size_t(idx) + 1);
} }
} }