SW/Tev: Use EnumMap for scale/bias tables
This commit is contained in:
parent
b02992548e
commit
c9936f8c1c
|
@ -29,20 +29,6 @@
|
|||
|
||||
void Tev::Init()
|
||||
{
|
||||
m_BiasLUT[0] = 0;
|
||||
m_BiasLUT[1] = 128;
|
||||
m_BiasLUT[2] = -128;
|
||||
m_BiasLUT[3] = 0;
|
||||
|
||||
m_ScaleLShiftLUT[0] = 0;
|
||||
m_ScaleLShiftLUT[1] = 1;
|
||||
m_ScaleLShiftLUT[2] = 2;
|
||||
m_ScaleLShiftLUT[3] = 0;
|
||||
|
||||
m_ScaleRShiftLUT[0] = 0;
|
||||
m_ScaleRShiftLUT[1] = 0;
|
||||
m_ScaleRShiftLUT[2] = 0;
|
||||
m_ScaleRShiftLUT[3] = 1;
|
||||
}
|
||||
|
||||
static inline s16 Clamp255(s16 in)
|
||||
|
@ -110,15 +96,13 @@ void Tev::DrawColorRegular(const TevStageCombiner::ColorCombiner& cc, const Inpu
|
|||
const u16 c = InputReg.c + (InputReg.c >> 7);
|
||||
|
||||
s32 temp = InputReg.a * (256 - c) + (InputReg.b * c);
|
||||
temp <<= m_ScaleLShiftLUT[u32(cc.scale.Value())];
|
||||
temp <<= s_ScaleLShiftLUT[cc.scale];
|
||||
temp += (cc.scale == TevScale::Divide2) ? 0 : (cc.op == TevOp::Sub) ? 127 : 128;
|
||||
temp >>= 8;
|
||||
temp = cc.op == TevOp::Sub ? -temp : temp;
|
||||
|
||||
s32 result = ((InputReg.d + m_BiasLUT[u32(cc.bias.Value())])
|
||||
<< m_ScaleLShiftLUT[u32(cc.scale.Value())]) +
|
||||
temp;
|
||||
result = result >> m_ScaleRShiftLUT[u32(cc.scale.Value())];
|
||||
s32 result = ((InputReg.d + s_BiasLUT[cc.bias]) << s_ScaleLShiftLUT[cc.scale]) + temp;
|
||||
result = result >> s_ScaleRShiftLUT[cc.scale];
|
||||
|
||||
Reg[cc.dest][i] = result;
|
||||
}
|
||||
|
@ -170,14 +154,12 @@ void Tev::DrawAlphaRegular(const TevStageCombiner::AlphaCombiner& ac, const Inpu
|
|||
const u16 c = InputReg.c + (InputReg.c >> 7);
|
||||
|
||||
s32 temp = InputReg.a * (256 - c) + (InputReg.b * c);
|
||||
temp <<= m_ScaleLShiftLUT[u32(ac.scale.Value())];
|
||||
temp <<= s_ScaleLShiftLUT[ac.scale];
|
||||
temp += (ac.scale == TevScale::Divide2) ? 0 : (ac.op == TevOp::Sub) ? 127 : 128;
|
||||
temp = ac.op == TevOp::Sub ? (-temp >> 8) : (temp >> 8);
|
||||
|
||||
s32 result =
|
||||
((InputReg.d + m_BiasLUT[u32(ac.bias.Value())]) << m_ScaleLShiftLUT[u32(ac.scale.Value())]) +
|
||||
temp;
|
||||
result = result >> m_ScaleRShiftLUT[u32(ac.scale.Value())];
|
||||
s32 result = ((InputReg.d + s_BiasLUT[ac.bias]) << s_ScaleLShiftLUT[ac.scale]) + temp;
|
||||
result = result >> s_ScaleRShiftLUT[ac.scale];
|
||||
|
||||
Reg[ac.dest].a = result;
|
||||
}
|
||||
|
|
|
@ -189,9 +189,9 @@ class Tev
|
|||
TevKonstRef::Value(KonstantColors[2].a), // Konst 2 Alpha
|
||||
TevKonstRef::Value(KonstantColors[3].a), // Konst 3 Alpha
|
||||
};
|
||||
s16 m_BiasLUT[4];
|
||||
u8 m_ScaleLShiftLUT[4];
|
||||
u8 m_ScaleRShiftLUT[4];
|
||||
static constexpr Common::EnumMap<s16, TevBias::Compare> s_BiasLUT{0, 128, -128, 0};
|
||||
static constexpr Common::EnumMap<u8, TevScale::Divide2> s_ScaleLShiftLUT{0, 1, 2, 0};
|
||||
static constexpr Common::EnumMap<u8, TevScale::Divide2> s_ScaleRShiftLUT{0, 0, 0, 1};
|
||||
|
||||
enum BufferBase
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue