From 906423db0832e39271e6b3b3d072d53da4e4ae2f Mon Sep 17 00:00:00 2001 From: Luke Benstead Date: Sun, 22 Mar 2020 21:09:18 +0000 Subject: [PATCH] Make sure we don't go beyond the bounds of PVR --- GL/draw.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/GL/draw.c b/GL/draw.c index 0448d19..b12fa08 100644 --- a/GL/draw.c +++ b/GL/draw.c @@ -1172,6 +1172,12 @@ GL_FORCE_INLINE void divide(SubmissionTarget* target) { vertex->xyz[0] *= f; vertex->xyz[1] *= f; vertex->xyz[2] = 1.0 - ((DEPTH_RANGE_MULTIPLIER_L * vertex->xyz[2] * f) + DEPTH_RANGE_MULTIPLIER_H); + + /* Passing a value > 1.0f will cause the polygon to be dropped by the + * PVR. Although we clip to the near plane, rounding errors can still + * cause this happen. This just ensures it doesn't */ + vertex->xyz[2] = MIN(1.0f, vertex->xyz[2]); + ++vertex; } }