mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-30 17:53:42 +01:00
Very minor soft transform optimization
This commit is contained in:
1 parent
eec7853efe
commit
449e3e1360
3 files changed
+23
-8
No files matched your search
@@ -186,7 +186,7 @@ void SoftwareTransform::Transform(int prim, u32 vertType, const DecVtxFormat &de
|
||||
reader.Goto(index);
|
||||
// TODO: Write to a flexible buffer, we don't always need all four components.
|
||||
TransformedVertex &vert = transformed[index];
|
||||
reader.ReadPos(vert.pos);
|
||||
reader.ReadPosThrough(vert.pos);
|
||||
vert.pos_w = 1.0f;
|
||||
|
||||
if (hasColor) {
|
||||
@@ -225,7 +225,7 @@ void SoftwareTransform::Transform(int prim, u32 vertType, const DecVtxFormat &de
|
||||
float pos[3];
|
||||
Vec3f normal(0, 0, 1);
|
||||
Vec3f worldnormal(0, 0, 1);
|
||||
reader.ReadPos(pos);
|
||||
reader.ReadPosNonThrough(pos);
|
||||
|
||||
float ruv[2] = { 0.0f, 0.0f };
|
||||
if (reader.hasUV())
|
||||
@@ -984,7 +984,7 @@ u32 NormalizeVertices(SimpleVertex *sverts, u8 *bufPtr, const u8 *inPtr, int low
|
||||
nrm[1] = 0;
|
||||
nrm[2] = 1.0f;
|
||||
}
|
||||
reader.ReadPos(pos);
|
||||
reader.ReadPosAuto(pos);
|
||||
|
||||
// Apply skinning transform directly
|
||||
float weights[8];
|
||||
@@ -1029,7 +1029,7 @@ u32 NormalizeVertices(SimpleVertex *sverts, u8 *bufPtr, const u8 *inPtr, int low
|
||||
sv.nrm.y = 0.0f;
|
||||
sv.nrm.z = 1.0f;
|
||||
}
|
||||
reader.ReadPos((float *)&sv.pos);
|
||||
reader.ReadPosAuto((float *)&sv.pos);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -185,7 +185,7 @@ void PrintDecodedVertex(const VertexReader &vtx) {
|
||||
}
|
||||
// Etc..
|
||||
float pos[3];
|
||||
vtx.ReadPos(pos);
|
||||
vtx.ReadPosAuto(pos);
|
||||
printf("P: %f %f %f\n", pos[0], pos[1], pos[2]);
|
||||
}
|
||||
|
||||
@@ -1420,8 +1420,8 @@ static bool DecodedVertsAreSimilar(const VertexReader &vtx1, const VertexReader
|
||||
return false;
|
||||
}
|
||||
}
|
||||
vtx1.ReadPos(vec1.AsArray());
|
||||
vtx2.ReadPos(vec2.AsArray());
|
||||
vtx1.ReadPosAuto(vec1.AsArray());
|
||||
vtx2.ReadPosAuto(vec2.AsArray());
|
||||
float diff = LargestAbsDiff(vec1, vec2, 3);
|
||||
if (diff >= 1.0 / 512.0f) {
|
||||
WARN_LOG(Log::G3D, "Pos diff %f", diff);
|
||||
|
||||
@@ -124,7 +124,7 @@ class VertexReader {
|
||||
public:
|
||||
VertexReader(const u8 *base, const DecVtxFormat &decFmt, int vtype) : base_(base), data_(base), decFmt_(decFmt), vtype_(vtype) {}
|
||||
|
||||
void ReadPos(float pos[3]) const {
|
||||
void ReadPosAuto(float pos[3]) const {
|
||||
// Only DEC_FLOAT_3 is supported.
|
||||
const float *f = (const float *)(data_ + decFmt_.posoff);
|
||||
pos[0] = f[0];
|
||||
@@ -137,6 +137,21 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void ReadPosThrough(float pos[3]) const {
|
||||
// Only DEC_FLOAT_3 is supported.
|
||||
const float *f = (const float *)(data_ + decFmt_.posoff);
|
||||
pos[0] = f[0];
|
||||
pos[1] = f[1];
|
||||
// Integer value passed in a float. Clamped to 0, 65535.
|
||||
pos[2] = (int)f[2] * (1.0f / 65535.0f);
|
||||
}
|
||||
|
||||
void ReadPosNonThrough(float pos[3]) const {
|
||||
// Only DEC_FLOAT_3 is supported.
|
||||
const float *f = (const float *)(data_ + decFmt_.posoff);
|
||||
memcpy(pos, f, 12);
|
||||
}
|
||||
|
||||
void ReadPosThroughZ16(float pos[3]) const {
|
||||
// Only DEC_FLOAT_3 is supported.
|
||||
const float *f = (const float *)(data_ + decFmt_.posoff);
|
||||
|
||||
Reference in new issue
Block a user