Convert CPMemory to BitField and enum class

Additionally, VCacheEnhance has been added to UVAT_group1.  According to YAGCD, this field is always 1.

TVtxDesc also now has separate low and high fields whose hex values correspond with the proper registers, instead of having one 33-bit value.  This change was made in a way that should be backwards-compatible.
This commit is contained in:
Pokechu22
2021-02-08 15:22:10 -08:00
parent c27efb3f1f
commit f749fcfa9f
21 changed files with 705 additions and 603 deletions

View File

@ -81,64 +81,33 @@ std::string VertexLoaderBase::ToString() const
dest += GetName();
dest += ": ";
static constexpr std::array<const char*, 4> pos_mode{{
"Inv",
"Dir",
"I8",
"I16",
}};
static constexpr std::array<const char*, 8> pos_formats{{
"u8",
"s8",
"u16",
"s16",
"flt",
"Inv",
"Inv",
"Inv",
}};
static constexpr std::array<const char*, 8> color_format{{
"565",
"888",
"888x",
"4444",
"6666",
"8888",
"Inv",
"Inv",
}};
dest += fmt::format("{}b skin: {} P: {} {}-{} ", m_VertexSize, m_VtxDesc.low.PosMatIdx,
m_VtxAttr.PosElements, m_VtxDesc.low.Position, m_VtxAttr.PosFormat);
dest += fmt::format("{}b skin: {} P: {} {}-{} ", m_VertexSize, m_VtxDesc.PosMatIdx,
m_VtxAttr.PosElements ? 3 : 2, pos_mode[m_VtxDesc.Position],
pos_formats[m_VtxAttr.PosFormat]);
if (m_VtxDesc.Normal)
if (m_VtxDesc.low.Normal != VertexComponentFormat::NotPresent)
{
dest += fmt::format("Nrm: {} {}-{} ", m_VtxAttr.NormalElements, pos_mode[m_VtxDesc.Normal],
pos_formats[m_VtxAttr.NormalFormat]);
dest += fmt::format("Nrm: {} {}-{} ", m_VtxAttr.NormalElements, m_VtxDesc.low.Normal,
m_VtxAttr.NormalFormat);
}
const std::array<u64, 2> color_mode{{m_VtxDesc.Color0, m_VtxDesc.Color1}};
for (size_t i = 0; i < color_mode.size(); i++)
for (size_t i = 0; i < g_main_cp_state.vtx_desc.low.Color.Size(); i++)
{
if (color_mode[i] == 0)
if (g_main_cp_state.vtx_desc.low.Color[i] == VertexComponentFormat::NotPresent)
continue;
const auto& color = m_VtxAttr.color[i];
dest += fmt::format("C{}: {} {}-{} ", i, color.Elements, pos_mode[color_mode[i]],
color_format[color.Comp]);
dest += fmt::format("C{}: {} {}-{} ", i, color.Elements, g_main_cp_state.vtx_desc.low.Color[i],
color.Comp);
}
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++)
for (size_t i = 0; i < g_main_cp_state.vtx_desc.high.TexCoord.Size(); i++)
{
if (tex_mode[i] == 0)
if (g_main_cp_state.vtx_desc.high.TexCoord[i] == VertexComponentFormat::NotPresent)
continue;
const auto& tex_coord = m_VtxAttr.texCoord[i];
dest += fmt::format("T{}: {} {}-{} ", i, tex_coord.Elements, pos_mode[tex_mode[i]],
pos_formats[tex_coord.Format]);
dest += fmt::format("T{}: {} {}-{} ", i, tex_coord.Elements,
g_main_cp_state.vtx_desc.high.TexCoord[i], tex_coord.Format);
}
dest += fmt::format(" - {} v", m_numLoadedVertices);
return dest;
@ -200,8 +169,9 @@ public:
{
ERROR_LOG_FMT(VIDEO,
"The two vertex loaders have loaded different data "
"(guru meditation {:#018x}, {:#010x}, {:#010x}, {:#010x}).",
m_VtxDesc.Hex, m_vat.g0.Hex, m_vat.g1.Hex, m_vat.g2.Hex);
"(guru meditation {:#010x}, {:#010x}, {:#010x}, {:#010x}, {:#010x}).",
m_VtxDesc.low.Hex, m_VtxDesc.high.Hex, m_vat.g0.Hex, m_vat.g1.Hex,
m_vat.g2.Hex);
}
memcpy(dst.GetPointer(), buffer_a.data(), count_a * m_native_vtx_decl.stride);