From ffaa9a3bea56bd8e82e32e187fd9dbe6ffa00993 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sat, 19 Aug 2017 11:08:09 -0400 Subject: SW NativeVertexFormat: Utilize std::array where applicable Gets rid of some hardcoded looping bounds, and also simplifies code in some places, sometimes allowing for removal of a loop altogether. --- Source/Core/VideoBackends/Software/SWVertexLoader.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'Source/Core/VideoBackends/Software/SWVertexLoader.cpp') diff --git a/Source/Core/VideoBackends/Software/SWVertexLoader.cpp b/Source/Core/VideoBackends/Software/SWVertexLoader.cpp index 3976eb7a2c..aec282da09 100644 --- a/Source/Core/VideoBackends/Software/SWVertexLoader.cpp +++ b/Source/Core/VideoBackends/Software/SWVertexLoader.cpp @@ -4,6 +4,7 @@ #include "VideoBackends/Software/SWVertexLoader.h" +#include #include #include "Common/Assert.h" @@ -97,7 +98,7 @@ void SWVertexLoader::vFlush() memset(&m_Vertex, 0, sizeof(m_Vertex)); // Super Mario Sunshine requires those to be zero for those debug boxes. - memset(&m_Vertex.color, 0, sizeof(m_Vertex.color)); + m_Vertex.color = {}; // parse the videocommon format to our own struct format (m_Vertex) SetFormat(g_main_cp_state.last_id, primitiveType); @@ -106,7 +107,7 @@ void SWVertexLoader::vFlush() // transform this vertex so that it can be used for rasterization (outVertex) OutputVertexData* outVertex = m_SetupUnit.GetVertex(); TransformUnit::TransformPosition(&m_Vertex, outVertex); - memset(&outVertex->normal, 0, sizeof(outVertex->normal)); + outVertex->normal = {}; if (VertexLoaderManager::g_current_components & VB_HAS_NRM0) { TransformUnit::TransformNormal( @@ -218,19 +219,19 @@ void SWVertexLoader::ParseVertex(const PortableVertexDeclaration& vdec, int inde ReadVertexAttribute(&m_Vertex.position[0], src, vdec.position, 0, 3, false); - for (int i = 0; i < 3; i++) + for (std::size_t i = 0; i < m_Vertex.normal.size(); i++) { ReadVertexAttribute(&m_Vertex.normal[i][0], src, vdec.normals[i], 0, 3, false); } - for (int i = 0; i < 2; i++) + for (std::size_t i = 0; i < m_Vertex.color.size(); i++) { - ReadVertexAttribute(m_Vertex.color[i], src, vdec.colors[i], 0, 4, true); + ReadVertexAttribute(m_Vertex.color[i].data(), src, vdec.colors[i], 0, 4, true); } - for (int i = 0; i < 8; i++) + for (std::size_t i = 0; i < m_Vertex.texCoords.size(); i++) { - ReadVertexAttribute(m_Vertex.texCoords[i], src, vdec.texcoords[i], 0, 2, false); + ReadVertexAttribute(m_Vertex.texCoords[i].data(), src, vdec.texcoords[i], 0, 2, false); // the texmtr is stored as third component of the texCoord if (vdec.texcoords[i].components >= 3) -- cgit v1.2.3