From 04c06ec6616d6af31491e121db896d34a82914d9 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 20 Jun 2019 07:42:16 -0400 Subject: VideoCommon/Statistics: Use std::array for projection values Makes the members within the interface much nicer to look at, and also makes copying them over much nicer too. --- Source/Core/VideoCommon/VertexShaderManager.cpp | 45 +++---------------------- 1 file changed, 4 insertions(+), 41 deletions(-) (limited to 'Source/Core/VideoCommon/VertexShaderManager.cpp') diff --git a/Source/Core/VideoCommon/VertexShaderManager.cpp b/Source/Core/VideoCommon/VertexShaderManager.cpp index 0301795e10..4c93016e6e 100644 --- a/Source/Core/VideoCommon/VertexShaderManager.cpp +++ b/Source/Core/VideoCommon/VertexShaderManager.cpp @@ -349,12 +349,11 @@ void VertexShaderManager::SetConstants() { bProjectionChanged = false; - float* rawProjection = xfmem.projection.rawProjection; + const auto& rawProjection = xfmem.projection.rawProjection; switch (xfmem.projection.type) { case GX_PERSPECTIVE: - g_fProjectionMatrix[0] = rawProjection[0] * g_ActiveConfig.fAspectRatioHackW; g_fProjectionMatrix[1] = 0.0f; g_fProjectionMatrix[2] = rawProjection[1] * g_ActiveConfig.fAspectRatioHackW; @@ -376,26 +375,10 @@ void VertexShaderManager::SetConstants() g_fProjectionMatrix[14] = -1.0f; g_fProjectionMatrix[15] = 0.0f; - SETSTAT_FT(stats.gproj_0, g_fProjectionMatrix[0]); - SETSTAT_FT(stats.gproj_1, g_fProjectionMatrix[1]); - SETSTAT_FT(stats.gproj_2, g_fProjectionMatrix[2]); - SETSTAT_FT(stats.gproj_3, g_fProjectionMatrix[3]); - SETSTAT_FT(stats.gproj_4, g_fProjectionMatrix[4]); - SETSTAT_FT(stats.gproj_5, g_fProjectionMatrix[5]); - SETSTAT_FT(stats.gproj_6, g_fProjectionMatrix[6]); - SETSTAT_FT(stats.gproj_7, g_fProjectionMatrix[7]); - SETSTAT_FT(stats.gproj_8, g_fProjectionMatrix[8]); - SETSTAT_FT(stats.gproj_9, g_fProjectionMatrix[9]); - SETSTAT_FT(stats.gproj_10, g_fProjectionMatrix[10]); - SETSTAT_FT(stats.gproj_11, g_fProjectionMatrix[11]); - SETSTAT_FT(stats.gproj_12, g_fProjectionMatrix[12]); - SETSTAT_FT(stats.gproj_13, g_fProjectionMatrix[13]); - SETSTAT_FT(stats.gproj_14, g_fProjectionMatrix[14]); - SETSTAT_FT(stats.gproj_15, g_fProjectionMatrix[15]); + stats.gproj = g_fProjectionMatrix; break; case GX_ORTHOGRAPHIC: - g_fProjectionMatrix[0] = rawProjection[0]; g_fProjectionMatrix[1] = 0.0f; g_fProjectionMatrix[2] = 0.0f; @@ -417,28 +400,8 @@ void VertexShaderManager::SetConstants() g_fProjectionMatrix[14] = 0.0f; g_fProjectionMatrix[15] = 1.0f; - SETSTAT_FT(stats.g2proj_0, g_fProjectionMatrix[0]); - SETSTAT_FT(stats.g2proj_1, g_fProjectionMatrix[1]); - SETSTAT_FT(stats.g2proj_2, g_fProjectionMatrix[2]); - SETSTAT_FT(stats.g2proj_3, g_fProjectionMatrix[3]); - SETSTAT_FT(stats.g2proj_4, g_fProjectionMatrix[4]); - SETSTAT_FT(stats.g2proj_5, g_fProjectionMatrix[5]); - SETSTAT_FT(stats.g2proj_6, g_fProjectionMatrix[6]); - SETSTAT_FT(stats.g2proj_7, g_fProjectionMatrix[7]); - SETSTAT_FT(stats.g2proj_8, g_fProjectionMatrix[8]); - SETSTAT_FT(stats.g2proj_9, g_fProjectionMatrix[9]); - SETSTAT_FT(stats.g2proj_10, g_fProjectionMatrix[10]); - SETSTAT_FT(stats.g2proj_11, g_fProjectionMatrix[11]); - SETSTAT_FT(stats.g2proj_12, g_fProjectionMatrix[12]); - SETSTAT_FT(stats.g2proj_13, g_fProjectionMatrix[13]); - SETSTAT_FT(stats.g2proj_14, g_fProjectionMatrix[14]); - SETSTAT_FT(stats.g2proj_15, g_fProjectionMatrix[15]); - SETSTAT_FT(stats.proj_0, rawProjection[0]); - SETSTAT_FT(stats.proj_1, rawProjection[1]); - SETSTAT_FT(stats.proj_2, rawProjection[2]); - SETSTAT_FT(stats.proj_3, rawProjection[3]); - SETSTAT_FT(stats.proj_4, rawProjection[4]); - SETSTAT_FT(stats.proj_5, rawProjection[5]); + stats.g2proj = g_fProjectionMatrix; + stats.proj = rawProjection; break; default: -- cgit v1.2.3 From c1c52767290cdbfb06eed4180f19cc5fd5166977 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 20 Jun 2019 08:09:38 -0400 Subject: VideoCommon/VertexShaderManager: Use std::array where applicable We can use this to shorten up the initialization code a little bit. Despite being saved to savestates, this is a non-breaking change. --- Source/Core/VideoCommon/VertexShaderManager.cpp | 43 ++++++++++++------------- 1 file changed, 21 insertions(+), 22 deletions(-) (limited to 'Source/Core/VideoCommon/VertexShaderManager.cpp') diff --git a/Source/Core/VideoCommon/VertexShaderManager.cpp b/Source/Core/VideoCommon/VertexShaderManager.cpp index 4c93016e6e..2cfc19993f 100644 --- a/Source/Core/VideoCommon/VertexShaderManager.cpp +++ b/Source/Core/VideoCommon/VertexShaderManager.cpp @@ -29,13 +29,17 @@ alignas(16) static std::array g_fProjectionMatrix; // track changes -static bool bTexMatricesChanged[2], bPosNormalMatrixChanged, bProjectionChanged, bViewportChanged; -static bool bTexMtxInfoChanged, bLightingConfigChanged; +static std::array bTexMatricesChanged; +static bool bPosNormalMatrixChanged; +static bool bProjectionChanged; +static bool bViewportChanged; +static bool bTexMtxInfoChanged; +static bool bLightingConfigChanged; static BitSet32 nMaterialsChanged; -static int nTransformMatricesChanged[2]; // min,max -static int nNormalMatricesChanged[2]; // min,max -static int nPostTransformMatricesChanged[2]; // min,max -static int nLightsChanged[2]; // min,max +static std::array nTransformMatricesChanged; // min,max +static std::array nNormalMatricesChanged; // min,max +static std::array nPostTransformMatricesChanged; // min,max +static std::array nLightsChanged; // min,max static Common::Matrix44 s_viewportCorrection; static Common::Matrix44 s_freelook_matrix; @@ -95,17 +99,12 @@ static void ViewportCorrectionMatrix(Common::Matrix44& result) void VertexShaderManager::Init() { // Initialize state tracking variables - nTransformMatricesChanged[0] = -1; - nTransformMatricesChanged[1] = -1; - nNormalMatricesChanged[0] = -1; - nNormalMatricesChanged[1] = -1; - nPostTransformMatricesChanged[0] = -1; - nPostTransformMatricesChanged[1] = -1; - nLightsChanged[0] = -1; - nLightsChanged[1] = -1; + nTransformMatricesChanged.fill(-1); + nNormalMatricesChanged.fill(-1); + nPostTransformMatricesChanged.fill(-1); + nLightsChanged.fill(-1); nMaterialsChanged = BitSet32(0); - bTexMatricesChanged[0] = false; - bTexMatricesChanged[1] = false; + bTexMatricesChanged.fill(false); bPosNormalMatrixChanged = false; bProjectionChanged = true; bViewportChanged = false; @@ -672,17 +671,17 @@ void VertexShaderManager::TransformToClipSpace(const float* data, float* out, u3 void VertexShaderManager::DoState(PointerWrap& p) { - p.Do(g_fProjectionMatrix); + p.DoArray(g_fProjectionMatrix); p.Do(s_viewportCorrection); p.Do(s_freelook_matrix); - p.Do(nTransformMatricesChanged); - p.Do(nNormalMatricesChanged); - p.Do(nPostTransformMatricesChanged); - p.Do(nLightsChanged); + p.DoArray(nTransformMatricesChanged); + p.DoArray(nNormalMatricesChanged); + p.DoArray(nPostTransformMatricesChanged); + p.DoArray(nLightsChanged); p.Do(nMaterialsChanged); - p.Do(bTexMatricesChanged); + p.DoArray(bTexMatricesChanged); p.Do(bPosNormalMatrixChanged); p.Do(bProjectionChanged); p.Do(bViewportChanged); -- cgit v1.2.3