Fix wrong logic causing excessive software transform fallback if cull planes are missing. Minor cleanup.

This commit is contained in:
Henrik Rydgård committed 2026-05-31 13:31:16 +02:00
1 parent 702088c2d0
commit 847953fd31
5 files changed
+25 -19

No files matched your search

+17 -1
View File
@@ -438,6 +438,22 @@ inline bool IsInsideFarPlane(const TransformedVertex& v) {
return v.z <= v.pos_w;
}
// TODO: Use CrossSIMD, should help.
inline void LerpTransformedVertex(TransformedVertex *dest, TransformedVertex &a, TransformedVertex &b, float t) {
dest->x = a.x + (b.x - a.x) * t;
dest->y = a.y + (b.y - a.y) * t;
dest->z = a.z + (b.z - a.z) * t;
dest->pos_w = a.pos_w + (b.pos_w - a.pos_w) * t;
dest->u = a.u + (b.u - a.u) * t;
dest->v = a.v + (b.v - a.v) * t;
dest->uv_w = a.uv_w + (b.uv_w - a.uv_w) * t;
dest->fog = a.fog + (b.fog - a.fog) * t;
// note: colorBlend is backwards.
dest->color0_32 = colorBlend(b.color0_32, a.color0_32, t);
dest->color1_32 = colorBlend(b.color1_32, a.color1_32, t);
}
// Generated by Gemini, and adapted to fit.
void ClipTrianglesAgainstNearPlane(
TransformedVertex *transformed, int &transformedCount, int maxTransformed,
@@ -528,7 +544,7 @@ void ClipTrianglesAgainstNearPlane(
// Generate new vertex at the intersection point
TransformedVertex newVertex;
TransformedVertex::Lerp(&newVertex, const_cast<TransformedVertex&>(a), const_cast<TransformedVertex&>(b), t);
LerpTransformedVertex(&newVertex, const_cast<TransformedVertex&>(a), const_cast<TransformedVertex&>(b), t);
// Force exact intersection to eliminate precision creeping down the pipeline
newVertex.z = -newVertex.pos_w;