Minor VertexReader optimizations
This commit is contained in:
parent
423fa6d848
commit
d02f46cb27
2 changed files with 9 additions and 10 deletions
|
@ -205,6 +205,9 @@ void SoftwareTransform::Decode(int prim, u32 vertType, const DecVtxFormat &decVt
|
|||
|
||||
VertexReader reader(decoded, decVtxFormat, vertType);
|
||||
if (throughmode) {
|
||||
const u32 materialAmbientRGBA = gstate.getMaterialAmbientRGBA();
|
||||
const bool hasColor = reader.hasColor0();
|
||||
const bool hasUV = reader.hasUV();
|
||||
for (int index = 0; index < maxIndex; index++) {
|
||||
// Do not touch the coordinates or the colors. No lighting.
|
||||
reader.Goto(index);
|
||||
|
@ -213,7 +216,7 @@ void SoftwareTransform::Decode(int prim, u32 vertType, const DecVtxFormat &decVt
|
|||
reader.ReadPos(vert.pos);
|
||||
vert.pos_w = 1.0f;
|
||||
|
||||
if (reader.hasColor0()) {
|
||||
if (hasColor) {
|
||||
if (provokeIndOffset != 0 && index + provokeIndOffset < maxIndex) {
|
||||
reader.Goto(index + provokeIndOffset);
|
||||
reader.ReadColor0_8888(vert.color0);
|
||||
|
@ -222,10 +225,10 @@ void SoftwareTransform::Decode(int prim, u32 vertType, const DecVtxFormat &decVt
|
|||
reader.ReadColor0_8888(vert.color0);
|
||||
}
|
||||
} else {
|
||||
vert.color0_32 = gstate.getMaterialAmbientRGBA();
|
||||
vert.color0_32 = materialAmbientRGBA;
|
||||
}
|
||||
|
||||
if (reader.hasUV()) {
|
||||
if (hasUV) {
|
||||
reader.ReadUV(vert.uv);
|
||||
|
||||
vert.u *= uscale;
|
||||
|
@ -240,6 +243,7 @@ void SoftwareTransform::Decode(int prim, u32 vertType, const DecVtxFormat &decVt
|
|||
// The w of uv is also never used (hardcoded to 1.0.)
|
||||
}
|
||||
} else {
|
||||
const Vec4f materialAmbientRGBA = Vec4f::FromRGBA(gstate.getMaterialAmbientRGBA());
|
||||
// Okay, need to actually perform the full transform.
|
||||
for (int index = 0; index < maxIndex; index++) {
|
||||
reader.Goto(index);
|
||||
|
@ -267,7 +271,7 @@ void SoftwareTransform::Decode(int prim, u32 vertType, const DecVtxFormat &decVt
|
|||
if (reader.hasColor0())
|
||||
reader.ReadColor0(unlitColor.AsArray());
|
||||
else
|
||||
unlitColor = Vec4f::FromRGBA(gstate.getMaterialAmbientRGBA());
|
||||
unlitColor = materialAmbientRGBA;
|
||||
if (reader.hasNormal())
|
||||
reader.ReadNrm(normal.AsArray());
|
||||
|
||||
|
|
|
@ -166,7 +166,6 @@ public:
|
|||
}
|
||||
break;
|
||||
default:
|
||||
ERROR_LOG_REPORT_ONCE(fmtnrm, G3D, "Reader: Unsupported Nrm Format %d", decFmt_.nrmfmt);
|
||||
memset(nrm, 0, sizeof(float) * 3);
|
||||
break;
|
||||
}
|
||||
|
@ -188,7 +187,6 @@ public:
|
|||
memcpy(color, data_ + decFmt_.c0off, 16);
|
||||
break;
|
||||
default:
|
||||
ERROR_LOG_REPORT_ONCE(fmtc0, G3D, "Reader: Unsupported C0 Format %d", decFmt_.c0fmt);
|
||||
memset(color, 0, sizeof(float) * 4);
|
||||
break;
|
||||
}
|
||||
|
@ -199,8 +197,7 @@ public:
|
|||
case DEC_U8_4:
|
||||
{
|
||||
const u8 *b = (const u8 *)(data_ + decFmt_.c0off);
|
||||
for (int i = 0; i < 4; i++)
|
||||
color[i] = b[i];
|
||||
memcpy(color, b, 4);
|
||||
}
|
||||
break;
|
||||
case DEC_FLOAT_4:
|
||||
|
@ -211,7 +208,6 @@ public:
|
|||
}
|
||||
break;
|
||||
default:
|
||||
ERROR_LOG_REPORT_ONCE(fmtc0_8888, G3D, "Reader: Unsupported C0 Format %d", decFmt_.c0fmt);
|
||||
memset(color, 0, sizeof(u8) * 4);
|
||||
break;
|
||||
}
|
||||
|
@ -231,7 +227,6 @@ public:
|
|||
memcpy(color, data_ + decFmt_.c1off, 12);
|
||||
break;
|
||||
default:
|
||||
ERROR_LOG_REPORT_ONCE(fmtc1, G3D, "Reader: Unsupported C1 Format %d", decFmt_.c1fmt);
|
||||
memset(color, 0, sizeof(float) * 3);
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue