diff options
| author | Lioncash <mathew1800@gmail.com> | 2019-06-01 07:55:09 -0400 |
|---|---|---|
| committer | Lioncash <mathew1800@gmail.com> | 2019-06-01 10:07:57 -0400 |
| commit | a9663669dc1037a04e37ae30efe18c0650547ac5 (patch) | |
| tree | b0bafacb909c3360951bb6b2781a94b97a9284be /Source/Core/VideoCommon/VertexShaderManager.cpp | |
| parent | a4837a5c5dc5d71f4b93dcb2fd5b80c5cfab381a (diff) | |
Common/CommonFuncs: Remove now-unneccessary ArraySize function
Since C++17, non-member std::size() is present in the standard library
which also operates on regular C arrays. Given that, we can just replace
usages of ArraySize with that where applicable.
In many cases, we can just change the actual C array ArraySize() was
called on into a std::array and just use its .size() member function
instead.
In some other cases, we can collapse the loops they were used in, into a
ranged-for loop, eliminating the need for en explicit bounds query.
Diffstat (limited to 'Source/Core/VideoCommon/VertexShaderManager.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/VertexShaderManager.cpp | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/Source/Core/VideoCommon/VertexShaderManager.cpp b/Source/Core/VideoCommon/VertexShaderManager.cpp index 58ecf198c8..0301795e10 100644 --- a/Source/Core/VideoCommon/VertexShaderManager.cpp +++ b/Source/Core/VideoCommon/VertexShaderManager.cpp @@ -2,15 +2,15 @@ // Licensed under GPLv2+ // Refer to the license.txt file included. -#include <cfloat> +#include "VideoCommon/VertexShaderManager.h" + +#include <array> #include <cmath> #include <cstring> -#include <sstream> -#include <string> +#include <iterator> #include "Common/BitSet.h" #include "Common/ChunkFile.h" -#include "Common/CommonFuncs.h" #include "Common/CommonTypes.h" #include "Common/Logging/Log.h" #include "Common/Matrix.h" @@ -22,7 +22,6 @@ #include "VideoCommon/RenderBase.h" #include "VideoCommon/Statistics.h" #include "VideoCommon/VertexManagerBase.h" -#include "VideoCommon/VertexShaderManager.h" #include "VideoCommon/VideoCommon.h" #include "VideoCommon/VideoConfig.h" #include "VideoCommon/XFMemory.h" @@ -251,13 +250,14 @@ void VertexShaderManager::SetConstants() if (bTexMatricesChanged[0]) { bTexMatricesChanged[0] = false; - const float* pos_matrix_ptrs[] = { + const std::array<const float*, 4> pos_matrix_ptrs{ &xfmem.posMatrices[g_main_cp_state.matrix_index_a.Tex0MtxIdx * 4], &xfmem.posMatrices[g_main_cp_state.matrix_index_a.Tex1MtxIdx * 4], &xfmem.posMatrices[g_main_cp_state.matrix_index_a.Tex2MtxIdx * 4], - &xfmem.posMatrices[g_main_cp_state.matrix_index_a.Tex3MtxIdx * 4]}; + &xfmem.posMatrices[g_main_cp_state.matrix_index_a.Tex3MtxIdx * 4], + }; - for (size_t i = 0; i < ArraySize(pos_matrix_ptrs); ++i) + for (size_t i = 0; i < pos_matrix_ptrs.size(); ++i) { memcpy(constants.texmatrices[3 * i].data(), pos_matrix_ptrs[i], 3 * sizeof(float4)); } @@ -267,13 +267,14 @@ void VertexShaderManager::SetConstants() if (bTexMatricesChanged[1]) { bTexMatricesChanged[1] = false; - const float* pos_matrix_ptrs[] = { + const std::array<const float*, 4> pos_matrix_ptrs{ &xfmem.posMatrices[g_main_cp_state.matrix_index_b.Tex4MtxIdx * 4], &xfmem.posMatrices[g_main_cp_state.matrix_index_b.Tex5MtxIdx * 4], &xfmem.posMatrices[g_main_cp_state.matrix_index_b.Tex6MtxIdx * 4], - &xfmem.posMatrices[g_main_cp_state.matrix_index_b.Tex7MtxIdx * 4]}; + &xfmem.posMatrices[g_main_cp_state.matrix_index_b.Tex7MtxIdx * 4], + }; - for (size_t i = 0; i < ArraySize(pos_matrix_ptrs); ++i) + for (size_t i = 0; i < pos_matrix_ptrs.size(); ++i) { memcpy(constants.texmatrices[3 * i + 12].data(), pos_matrix_ptrs[i], 3 * sizeof(float4)); } @@ -461,9 +462,9 @@ void VertexShaderManager::SetConstants() { bTexMtxInfoChanged = false; constants.xfmem_dualTexInfo = xfmem.dualTexTrans.enabled; - for (size_t i = 0; i < ArraySize(xfmem.texMtxInfo); i++) + for (size_t i = 0; i < std::size(xfmem.texMtxInfo); i++) constants.xfmem_pack1[i][0] = xfmem.texMtxInfo[i].hex; - for (size_t i = 0; i < ArraySize(xfmem.postMtxInfo); i++) + for (size_t i = 0; i < std::size(xfmem.postMtxInfo); i++) constants.xfmem_pack1[i][1] = xfmem.postMtxInfo[i].hex; dirty = true; |
