From 7888f44bb8361afd3c69a860af65019cf5ef1860 Mon Sep 17 00:00:00 2001 From: Nico de Poel Date: Fri, 10 Feb 2023 10:25:41 +0100 Subject: [PATCH] Revert "Intersperse GTE instructions with vertex lerping and quad building code to mask load/store delays." This reverts commit 4f886bd40c6955ff0e4390285b05e8938c1c3b18. Rolling back to simpler code to facilitate conversion to GTE interpolation. --- draw.h | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/draw.h b/draw.h index d224b86..adb2c2a 100644 --- a/draw.h +++ b/draw.h @@ -404,24 +404,34 @@ static INLINE void draw_quadstrip_tess2(const ps1bsp_vertex_t *vertices, const p copyVertFast(&tmp[6], pv2, v2); copyVertFast(&tmp[8], pv3, v3); - // Interpolate vertices and start loading them into GTE as soon as we're done with them - // This way we avoid waiting for the GTE load/store delays + // TODO Optimization: start loading vertices into GTE as soon as we're done with them lerpVert(&tmp[1], &tmp[0], &tmp[2]); lerpVert(&tmp[5], &tmp[2], &tmp[8]); // After this, 0 1 2 are ready for GTE + lerpVert(&tmp[3], &tmp[0], &tmp[6]); + lerpVert(&tmp[4], &tmp[3], &tmp[5]); // After this, 3 4 5 are ready for GTE + lerpVert(&tmp[7], &tmp[6], &tmp[8]); + + // Transform the vertices in groups of three gte_ldv3(&tmp[0], &tmp[1], &tmp[2]); gte_rtpt(); - lerpVert(&tmp[3], &tmp[0], &tmp[6]); gte_stsxy0(&tmp[0].vx); gte_stsxy1(&tmp[1].vx); gte_stsxy2(&tmp[2].vx); - lerpVert(&tmp[4], &tmp[3], &tmp[5]); // After this, 3 4 5 are ready for GTE + gte_ldv3(&tmp[3], &tmp[4], &tmp[5]); gte_rtpt(); - lerpVert(&tmp[7], &tmp[6], &tmp[8]); gte_stsxy0(&tmp[3].vx); gte_stsxy1(&tmp[4].vx); gte_stsxy2(&tmp[5].vx); + gte_ldv3(&tmp[6], &tmp[7], &tmp[8]); + gte_rtpt(); + gte_stsxy0(&tmp[6].vx); + gte_stsxy1(&tmp[7].vx); + gte_stsxy2(&tmp[8].vx); + + // TODO Optimization: interperse quad building instructions while waiting on GTE store/load delays + // Draw the first quad p0 = (POLY_GT4*)mem_prim(sizeof(POLY_GT4)); blitVert(p0, 0, tmp[0]); @@ -432,10 +442,6 @@ static INLINE void draw_quadstrip_tess2(const ps1bsp_vertex_t *vertices, const p blitVert(p0, 3, tmp[4]); setPolyGT4(p0); addPrim(ot, p0); - - // Transform the final three vertices, needed for the final two quads - gte_ldv3(&tmp[6], &tmp[7], &tmp[8]); - gte_rtpt(); // Second quad p1 = (POLY_GT4*)mem_prim(sizeof(POLY_GT4)); @@ -448,11 +454,6 @@ static INLINE void draw_quadstrip_tess2(const ps1bsp_vertex_t *vertices, const p setPolyGT4(p1); addPrim(ot, p1); - // Make sure the transformed vertices are loaded from GTE before we need them - gte_stsxy0(&tmp[6].vx); - gte_stsxy1(&tmp[7].vx); - gte_stsxy2(&tmp[8].vx); - // Third quad p2 = (POLY_GT4*)mem_prim(sizeof(POLY_GT4)); blitVert(p2, 0, tmp[3]);