VertexLoaderBase: Use std::array where applicable

This commit is contained in:
Lioncash 2017-03-26 22:12:20 -04:00
parent 76cece8157
commit 8033a72f0b
1 changed files with 23 additions and 21 deletions

View File

@ -2,6 +2,9 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include "VideoCommon/VertexLoaderBase.h"
#include <array>
#include <cinttypes>
#include <cstring>
#include <memory>
@ -15,7 +18,6 @@
#include "VideoCommon/DataReader.h"
#include "VideoCommon/VertexLoader.h"
#include "VideoCommon/VertexLoaderBase.h"
#ifdef _M_X86_64
#include "VideoCommon/VertexLoaderX64.h"
@ -77,45 +79,45 @@ void VertexLoaderBase::AppendToString(std::string* dest) const
dest->append(GetName());
dest->append(": ");
static const char* posMode[4] = {
static constexpr std::array<const char*, 4> pos_mode{{
"Inv", "Dir", "I8", "I16",
};
static const char* posFormats[8] = {
}};
static constexpr std::array<const char*, 8> pos_formats{{
"u8", "s8", "u16", "s16", "flt", "Inv", "Inv", "Inv",
};
static const char* colorFormat[8] = {
}};
static constexpr std::array<const char*, 8> color_format{{
"565", "888", "888x", "4444", "6666", "8888", "Inv", "Inv",
};
}};
dest->append(StringFromFormat("%ib skin: %i P: %i %s-%s ", m_VertexSize, (u32)m_VtxDesc.PosMatIdx,
m_VtxAttr.PosElements ? 3 : 2, posMode[m_VtxDesc.Position],
posFormats[m_VtxAttr.PosFormat]));
m_VtxAttr.PosElements ? 3 : 2, pos_mode[m_VtxDesc.Position],
pos_formats[m_VtxAttr.PosFormat]));
if (m_VtxDesc.Normal)
{
dest->append(StringFromFormat("Nrm: %i %s-%s ", m_VtxAttr.NormalElements,
posMode[m_VtxDesc.Normal], posFormats[m_VtxAttr.NormalFormat]));
pos_mode[m_VtxDesc.Normal], pos_formats[m_VtxAttr.NormalFormat]));
}
u64 color_mode[2] = {m_VtxDesc.Color0, m_VtxDesc.Color1};
for (int i = 0; i < 2; i++)
const std::array<u64, 2> color_mode{{m_VtxDesc.Color0, m_VtxDesc.Color1}};
for (size_t i = 0; i < color_mode.size(); i++)
{
if (color_mode[i])
{
dest->append(StringFromFormat("C%i: %i %s-%s ", i, m_VtxAttr.color[i].Elements,
posMode[color_mode[i]], colorFormat[m_VtxAttr.color[i].Comp]));
dest->append(StringFromFormat("C%zu: %i %s-%s ", i, m_VtxAttr.color[i].Elements,
pos_mode[color_mode[i]], color_format[m_VtxAttr.color[i].Comp]));
}
}
u64 tex_mode[8] = {m_VtxDesc.Tex0Coord, m_VtxDesc.Tex1Coord, m_VtxDesc.Tex2Coord,
m_VtxDesc.Tex3Coord, m_VtxDesc.Tex4Coord, m_VtxDesc.Tex5Coord,
m_VtxDesc.Tex6Coord, m_VtxDesc.Tex7Coord};
for (int i = 0; i < 8; i++)
const std::array<u64, 8> tex_mode{{m_VtxDesc.Tex0Coord, m_VtxDesc.Tex1Coord, m_VtxDesc.Tex2Coord,
m_VtxDesc.Tex3Coord, m_VtxDesc.Tex4Coord, m_VtxDesc.Tex5Coord,
m_VtxDesc.Tex6Coord, m_VtxDesc.Tex7Coord}};
for (size_t i = 0; i < tex_mode.size(); i++)
{
if (tex_mode[i])
{
dest->append(StringFromFormat("T%i: %i %s-%s ", i, m_VtxAttr.texCoord[i].Elements,
posMode[tex_mode[i]],
posFormats[m_VtxAttr.texCoord[i].Format]));
dest->append(StringFromFormat("T%zu: %i %s-%s ", i, m_VtxAttr.texCoord[i].Elements,
pos_mode[tex_mode[i]],
pos_formats[m_VtxAttr.texCoord[i].Format]));
}
}
dest->append(StringFromFormat(" - %i v", m_numLoadedVertices));