diff options
| author | Markus Wick <degasus@users.noreply.github.com> | 2017-08-23 08:25:33 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-08-23 08:25:33 +0200 |
| commit | 24e919a26c39e76fdd3c66b8faf0847f322cf208 (patch) | |
| tree | 0078c0a14008c1fc48176c9489d7e20dd4222997 /Source/Core/VideoBackends/Software/NativeVertexFormat.h | |
| parent | c12418788a29dc54e4e98b12e2acf6bc93020e5d (diff) | |
| parent | bc57ab39231b9a6d9b5f1c31b520cdee9716d6df (diff) | |
Merge pull request #5944 from lioncash/sw
SW NativeVertexFormat: Utilize std::array where applicable
Diffstat (limited to 'Source/Core/VideoBackends/Software/NativeVertexFormat.h')
| -rw-r--r-- | Source/Core/VideoBackends/Software/NativeVertexFormat.h | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/Source/Core/VideoBackends/Software/NativeVertexFormat.h b/Source/Core/VideoBackends/Software/NativeVertexFormat.h index f1ee48fccf..00ebaf1fff 100644 --- a/Source/Core/VideoBackends/Software/NativeVertexFormat.h +++ b/Source/Core/VideoBackends/Software/NativeVertexFormat.h @@ -4,6 +4,9 @@ #pragma once +#include <array> +#include <cstddef> + #include "Common/CommonTypes.h" #include "VideoBackends/Software/Vec3.h" @@ -18,12 +21,12 @@ struct Vec4 struct InputVertexData { u8 posMtx; - u8 texMtx[8]; + std::array<u8, 8> texMtx; Vec3 position; - Vec3 normal[3]; - u8 color[2][4]; - float texCoords[8][2]; + std::array<Vec3, 3> normal; + std::array<std::array<u8, 4>, 2> color; + std::array<std::array<float, 2>, 8> texCoords; }; struct OutputVertexData @@ -40,9 +43,9 @@ struct OutputVertexData Vec3 mvPosition = {}; Vec4 projectedPosition = {}; Vec3 screenPosition = {}; - Vec3 normal[3] = {}; - u8 color[2][4] = {}; - Vec3 texCoords[8] = {}; + std::array<Vec3, 3> normal{}; + std::array<std::array<u8, 4>, 2> color{}; + std::array<Vec3, 8> texCoords{}; void Lerp(float t, const OutputVertexData* a, const OutputVertexData* b) { @@ -57,19 +60,19 @@ struct OutputVertexData projectedPosition.z = LINTERP(t, a->projectedPosition.z, b->projectedPosition.z); projectedPosition.w = LINTERP(t, a->projectedPosition.w, b->projectedPosition.w); - for (int i = 0; i < 3; ++i) + for (std::size_t i = 0; i < normal.size(); ++i) { normal[i] = LINTERP(t, a->normal[i], b->normal[i]); } - u16 t_int = (u16)(t * 256); - for (int i = 0; i < 4; ++i) + const u16 t_int = static_cast<u16>(t * 256); + for (std::size_t i = 0; i < color[0].size(); ++i) { color[0][i] = LINTERP_INT(t_int, a->color[0][i], b->color[0][i]); color[1][i] = LINTERP_INT(t_int, a->color[1][i], b->color[1][i]); } - for (int i = 0; i < 8; ++i) + for (std::size_t i = 0; i < texCoords.size(); ++i) { texCoords[i] = LINTERP(t, a->texCoords[i], b->texCoords[i]); } |
