diff options
Diffstat (limited to 'Source/Core/VideoCommon/VertexShaderManager.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/VertexShaderManager.cpp | 40 |
1 files changed, 11 insertions, 29 deletions
diff --git a/Source/Core/VideoCommon/VertexShaderManager.cpp b/Source/Core/VideoCommon/VertexShaderManager.cpp index 022bf7683d..93f969b0b5 100644 --- a/Source/Core/VideoCommon/VertexShaderManager.cpp +++ b/Source/Core/VideoCommon/VertexShaderManager.cpp @@ -5,6 +5,7 @@ #include <cmath> #include <sstream> +#include "Common/BitSet.h" #include "Common/CommonTypes.h" #include "Common/MathUtil.h" #include "VideoCommon/BPMemory.h" @@ -22,7 +23,7 @@ static float GC_ALIGNED16(g_fProjectionMatrix[16]); // track changes static bool bTexMatricesChanged[2], bPosNormalMatrixChanged, bProjectionChanged, bViewportChanged; -static int nMaterialsChanged; +static BitSet32 nMaterialsChanged; static int nTransformMatricesChanged[2]; // min,max static int nNormalMatricesChanged[2]; // min,max static int nPostTransformMatricesChanged[2]; // min,max @@ -202,7 +203,7 @@ void VertexShaderManager::Dirty() bProjectionChanged = true; - nMaterialsChanged = 15; + nMaterialsChanged = BitSet32::AllTrue(4); dirty = true; } @@ -295,35 +296,16 @@ void VertexShaderManager::SetConstants() nLightsChanged[0] = nLightsChanged[1] = -1; } - if (nMaterialsChanged) + for (int i : nMaterialsChanged) { - for (int i = 0; i < 2; ++i) - { - if (nMaterialsChanged & (1 << i)) - { - u32 data = xfmem.ambColor[i]; - constants.materials[i][0] = (data >> 24) & 0xFF; - constants.materials[i][1] = (data >> 16) & 0xFF; - constants.materials[i][2] = (data >> 8) & 0xFF; - constants.materials[i][3] = data & 0xFF; - } - } - - for (int i = 0; i < 2; ++i) - { - if (nMaterialsChanged & (1 << (i + 2))) - { - u32 data = xfmem.matColor[i]; - constants.materials[i+2][0] = (data >> 24) & 0xFF; - constants.materials[i+2][1] = (data >> 16) & 0xFF; - constants.materials[i+2][2] = (data >> 8) & 0xFF; - constants.materials[i+2][3] = data & 0xFF; - } - } + u32 data = i >= 2 ? xfmem.matColor[i - 2] : xfmem.ambColor[i]; + constants.materials[i][0] = (data >> 24) & 0xFF; + constants.materials[i][1] = (data >> 16) & 0xFF; + constants.materials[i][2] = (data >> 8) & 0xFF; + constants.materials[i][3] = data & 0xFF; dirty = true; - - nMaterialsChanged = 0; } + nMaterialsChanged = BitSet32(0); if (bPosNormalMatrixChanged) { @@ -660,7 +642,7 @@ void VertexShaderManager::SetProjectionChanged() void VertexShaderManager::SetMaterialColorChanged(int index, u32 color) { - nMaterialsChanged |= (1 << index); + nMaterialsChanged[index] = true; } void VertexShaderManager::TranslateView(float x, float y, float z) |
