Use more accessors, simplify softgpu colortest.

This commit is contained in:
Unknown W. Brackets 2013-08-24 11:11:34 -07:00
parent 5ab04a3076
commit cd70250d8c
4 changed files with 17 additions and 16 deletions

View File

@ -336,7 +336,7 @@ void VertexDecoder::Step_NormalS8() const
{
s8 *normal = (s8 *)(decoded_ + decFmt.nrmoff);
u8 xorval = 0;
if (gstate.reversenormals & 1)
if (gstate.areNormalsReversed())
xorval = 0xFF; // Using xor instead of - to handle -128
const s8 *sv = (const s8*)(ptr_ + nrmoff);
for (int j = 0; j < 3; j++)
@ -348,7 +348,7 @@ void VertexDecoder::Step_NormalS16() const
{
s16 *normal = (s16 *)(decoded_ + decFmt.nrmoff);
u16 xorval = 0;
if (gstate.reversenormals & 1)
if (gstate.areNormalsReversed())
xorval = 0xFFFF;
const s16 *sv = (const s16*)(ptr_ + nrmoff);
for (int j = 0; j < 3; j++)
@ -360,7 +360,7 @@ void VertexDecoder::Step_NormalFloat() const
{
float *normal = (float *)(decoded_ + decFmt.nrmoff);
float multiplier = 1.0f;
if (gstate.reversenormals & 1)
if (gstate.areNormalsReversed())
multiplier = -multiplier;
const float *fv = (const float*)(ptr_ + nrmoff);
for (int j = 0; j < 3; j++)
@ -374,7 +374,7 @@ void VertexDecoder::Step_NormalS8Morph() const
for (int n = 0; n < morphcount; n++)
{
float multiplier = gstate_c.morphWeights[n];
if (gstate.reversenormals & 1) {
if (gstate.areNormalsReversed()) {
multiplier = -multiplier;
}
const s8 *bv = (const s8*)(ptr_ + onesize_*n + nrmoff);
@ -391,7 +391,7 @@ void VertexDecoder::Step_NormalS16Morph() const
for (int n = 0; n < morphcount; n++)
{
float multiplier = gstate_c.morphWeights[n];
if (gstate.reversenormals & 1) {
if (gstate.areNormalsReversed()) {
multiplier = -multiplier;
}
const s16 *sv = (const s16 *)(ptr_ + onesize_*n + nrmoff);
@ -408,7 +408,7 @@ void VertexDecoder::Step_NormalFloatMorph() const
for (int n = 0; n < morphcount; n++)
{
float multiplier = gstate_c.morphWeights[n];
if (gstate.reversenormals & 1) {
if (gstate.areNormalsReversed()) {
multiplier = -multiplier;
}
const float *fv = (const float*)(ptr_ + onesize_*n + nrmoff);

View File

@ -358,6 +358,7 @@ struct GPUgstate
int getNumBoneWeights() const { return 1 + ((vertType & GE_VTYPE_WEIGHTCOUNT_MASK) >> GE_VTYPE_WEIGHTCOUNT_SHIFT); }
bool isSkinningEnabled() const { return ((vertType & GE_VTYPE_WEIGHT_MASK) != GE_VTYPE_WEIGHT_NONE); }
int getTexCoordMask() const { return vertType & GE_VTYPE_TC_MASK; }
bool areNormalsReversed() const { return reversenormals & 1; }
GEPatchPrimType getPatchPrimitiveType() const { return static_cast<GEPatchPrimType>(patchprimitive & 3); }

View File

@ -445,10 +445,10 @@ static inline Vec4<int> GetTextureFunctionOutput(const Vec3<int>& prim_color_rgb
static inline bool ColorTestPassed(Vec3<int> color)
{
u32 mask = gstate.colormask&0xFFFFFF;
color = Vec3<int>::FromRGB(color.ToRGB() & mask);
Vec3<int> ref = Vec3<int>::FromRGB(gstate.colorref & mask);
switch (gstate.colortest & 0x3) {
const u32 mask = gstate.getColorTestMask();
const u32 c = color.ToRGB() & mask;
const u32 ref = gstate.getColorTestRef() & mask;
switch (gstate.getColorTestFunction()) {
case GE_COMP_NEVER:
return false;
@ -456,21 +456,21 @@ static inline bool ColorTestPassed(Vec3<int> color)
return true;
case GE_COMP_EQUAL:
return (color.r() == ref.r() && color.g() == ref.g() && color.b() == ref.b());
return c == ref;
case GE_COMP_NOTEQUAL:
return (color.r() != ref.r() || color.g() != ref.g() || color.b() != ref.b());
return c != ref;
}
return true;
}
static inline bool AlphaTestPassed(int alpha)
{
u8 mask = (gstate.alphatest >> 16) & 0xFF;
u8 ref = (gstate.alphatest >> 8) & mask;
const u8 mask = gstate.getAlphaTestMask() & 0xFF;
const u8 ref = gstate.getAlphaTestRef() & mask;
alpha &= mask;
switch (gstate.alphatest & 0x7) {
switch (gstate.getAlphaTestFunction()) {
case GE_COMP_NEVER:
return false;

View File

@ -113,7 +113,7 @@ static VertexData ReadVertex(VertexReader& vreader)
vreader.ReadNrm(normal);
vertex.normal = Vec3<float>(normal[0], normal[1], normal[2]);
if (gstate.reversenormals & 1)
if (gstate.areNormalsReversed())
vertex.normal = -vertex.normal;
}