Convert some VideoCommon stuff to BitSet.

Now with a minor performance improvement removed for no reason.
This commit is contained in:
comex
2014-10-21 20:42:55 -04:00
parent f51c233a08
commit b29e5146ec
4 changed files with 42 additions and 62 deletions

View File

@ -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)