From 572fa01b03b070e8911db43ca1fb55e3a4f8bdd5 Mon Sep 17 00:00:00 2001 From: Luke Benstead Date: Sat, 6 Apr 2024 21:13:17 +0100 Subject: [PATCH] Fix edge case --- GL/platforms/sh4.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/GL/platforms/sh4.c b/GL/platforms/sh4.c index bfa8415..ba00148 100644 --- a/GL/platforms/sh4.c +++ b/GL/platforms/sh4.c @@ -221,7 +221,7 @@ void SceneListSubmit(Vertex* vertices, int n) { sq = SQ_BASE_ADDRESS; Vertex* v0 = vertices; - for(int i = 0; i < n - 2; ++i, ++v0) { + for(int i = 0; i < n - 1; ++i, ++v0) { if(is_header(v0)) { _glPushHeaderOrVertex(v0); visible_mask = 0; @@ -229,11 +229,13 @@ void SceneListSubmit(Vertex* vertices, int n) { } Vertex* v1 = v0 + 1; - Vertex* v2 = v0 + 2; + Vertex* v2 = (i < n - 2) ? v0 + 2 : NULL; assert(!is_header(v1)); - bool is_trailing = (v1->flags == GPU_CMD_VERTEX_EOL) || is_header(v2); + // We are trailing if we're on the penultimate vertex, or the next but one vertex is + // an EOL, or v1 is an EOL (FIXME: possibly unnecessary and coverted by the other case?) + bool is_trailing = (v1->flags == GPU_CMD_VERTEX_EOL) || ((v2) ? is_header(v2) : true); if(is_trailing) { // OK so we've hit a new context header