mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-23 05:19:56 +00:00
Use more accessors, simplify softgpu colortest.
This commit is contained in:
parent
5ab04a3076
commit
cd70250d8c
@ -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);
|
||||
|
@ -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); }
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user