redundant nop reduction

This commit is contained in:
ed
2026-07-27 22:49:41 -04:00
parent e2eb74be19
commit 7421b32fd7
4 changed files with 16 additions and 27 deletions
+4 -9
View File
@@ -115,11 +115,8 @@ WORD_COUNT(mac_format_g4_color, 12)
/* Words: 3; Stores the 3 transformed (V2_S2 screen) vertices of the /* Words: 3; Stores the 3 transformed (V2_S2 screen) vertices of the
* G4 triangle portion to p0/p1/p2. * G4 triangle portion to p0/p1/p2.
* PIPELINE: post-RTPT, pre-RTPS (SXY0=v0.screen, SXY1=v1.screen, SXY2=v2.screen). * PIPELINE: post-RTPT, pre-RTPS (SXY0=v0.screen, SXY1=v1.screen, SXY2=v2.screen).
* MUST be called BEFORE V3-RTPS, otherwise SXY0/1/2 * MUST be called BEFORE V3-RTPS, otherwise SXY0/1/2 get overwritten with v3
* get overwritten with v3 (RTPS writes only to SXY2, but to keep the * (RTPS writes only to SXY2, but to keep the three registers aligned with v0/v1/v2 you must store before RTPS). */
* three registers aligned with v0/v1/v2 you must store before RTPS).
* The macro name declares the pipeline position; check #6 (GTE state-
* machine validation) verifies the call site matches the declaration. */
#define mac_gte_store_g4_p012_post_rtpt_pre_rtps(...) \ #define mac_gte_store_g4_p012_post_rtpt_pre_rtps(...) \
gte_sw(C2_SXY0, R_PrimCursor, O_(Poly_G4,p0)) \ gte_sw(C2_SXY0, R_PrimCursor, O_(Poly_G4,p0)) \
, gte_sw(C2_SXY1, R_PrimCursor, O_(Poly_G4,p1)) \ , gte_sw(C2_SXY1, R_PrimCursor, O_(Poly_G4,p1)) \
@@ -128,10 +125,8 @@ WORD_COUNT(mac_gte_store_g4_p012_post_rtpt_pre_rtps, 3)
/* atom_dbg_skip */ /* atom_dbg_skip */
/* Words: 1; Stores the V3 screen coord to the G4's p3 slot. /* Words: 1; Stores the V3 screen coord to the G4's p3 slot.
* PIPELINE: post-RTPS (SXY2 holds v3.screen because RTPS writes its * PIPELINE: post-RTPS (SXY2 holds v3.screen because RTPS writes its single-vertex result to SXY2;
* single-vertex result to SXY2; SXY0 still holds v0.screen from the * SXY0 still holds v0.screen from the earlier RTPT.
* earlier RTPT — DO NOT read SXY0 here, that's the bug this name
* prevents).
*/ */
#define mac_gte_store_g4_p3_post_rtps(...) \ #define mac_gte_store_g4_p3_post_rtps(...) \
gte_sw(C2_SXY2, R_PrimCursor, O_(Poly_G4,p3)) gte_sw(C2_SXY2, R_PrimCursor, O_(Poly_G4,p3))
+4 -9
View File
@@ -193,11 +193,8 @@ MipsAtomComp_Proc_(ac_format_g4_color, {
/* Words: 3; Stores the 3 transformed (V2_S2 screen) vertices of the /* Words: 3; Stores the 3 transformed (V2_S2 screen) vertices of the
* G4 triangle portion to p0/p1/p2. * G4 triangle portion to p0/p1/p2.
* PIPELINE: post-RTPT, pre-RTPS (SXY0=v0.screen, SXY1=v1.screen, SXY2=v2.screen). * PIPELINE: post-RTPT, pre-RTPS (SXY0=v0.screen, SXY1=v1.screen, SXY2=v2.screen).
* MUST be called BEFORE V3-RTPS, otherwise SXY0/1/2 * MUST be called BEFORE V3-RTPS, otherwise SXY0/1/2 get overwritten with v3
* get overwritten with v3 (RTPS writes only to SXY2, but to keep the * (RTPS writes only to SXY2, but to keep the three registers aligned with v0/v1/v2 you must store before RTPS). */
* three registers aligned with v0/v1/v2 you must store before RTPS).
* The macro name declares the pipeline position; check #6 (GTE state-
* machine validation) verifies the call site matches the declaration. */
atom_dbg_skip MipsAtomComp_(ac_gte_store_g4_p012_post_rtpt_pre_rtps) { atom_dbg_skip MipsAtomComp_(ac_gte_store_g4_p012_post_rtpt_pre_rtps) {
gte_sw(C2_SXY0, R_PrimCursor, O_(Poly_G4,p0)), gte_sw(C2_SXY0, R_PrimCursor, O_(Poly_G4,p0)),
gte_sw(C2_SXY1, R_PrimCursor, O_(Poly_G4,p1)), gte_sw(C2_SXY1, R_PrimCursor, O_(Poly_G4,p1)),
@@ -205,10 +202,8 @@ atom_dbg_skip MipsAtomComp_(ac_gte_store_g4_p012_post_rtpt_pre_rtps) {
}; };
/* Words: 1; Stores the V3 screen coord to the G4's p3 slot. /* Words: 1; Stores the V3 screen coord to the G4's p3 slot.
* PIPELINE: post-RTPS (SXY2 holds v3.screen because RTPS writes its * PIPELINE: post-RTPS (SXY2 holds v3.screen because RTPS writes its single-vertex result to SXY2;
* single-vertex result to SXY2; SXY0 still holds v0.screen from the * SXY0 still holds v0.screen from the earlier RTPT.
* earlier RTPT — DO NOT read SXY0 here, that's the bug this name
* prevents).
*/ */
atom_dbg_skip MipsAtomComp_(ac_gte_store_g4_p3_post_rtps) { gte_sw(C2_SXY2, R_PrimCursor, O_(Poly_G4,p3)) }; atom_dbg_skip MipsAtomComp_(ac_gte_store_g4_p3_post_rtps) { gte_sw(C2_SXY2, R_PrimCursor, O_(Poly_G4,p3)) };
+2 -2
View File
@@ -5,9 +5,9 @@
#pragma region hello_gte_tape #pragma region hello_gte_tape
// --- atom: cube_g4_face (87 words) --- // --- atom: cube_g4_face (79 words) ---
#define _atom_offset_cull_cube_g4_face_exit 48 #define _atom_offset_cull_cube_g4_face_exit 44
#define _atom_offset_bounds_chk_cube_g4_face_exit 12 #define _atom_offset_bounds_chk_cube_g4_face_exit 12
enum { enum {
+6 -7
View File
@@ -47,12 +47,11 @@ MipsAtom_(cube_g4_face) atom_info(atom_phase(cube_g4),
load_half_u(R_T3, R_FaceCursor, 3 * S_(S2)), load_half_u(R_T3, R_FaceCursor, 3 * S_(S2)),
mac_gte_load_tri_verts(R_T0, R_T1, R_T2), mac_gte_load_tri_verts(R_T0, R_T1, R_T2),
nop2, gte_cmdw_rotate_translate_perspective_triple, nop2, gte_cmdw_rotate_translate_perspective_triple, // required cpu -> gte delay slot
nop2, gte_cmdw_nclip, gte_cmdw_nclip,
nop2, gte_mv_from_data_r(R_T0, C2_MAC0), gte_mv_from_data_r(R_T0, C2_MAC0),
nop, nop, branch_le_zero(R_T0, atom_offset(cull, cube_g4_face_exit)), nop,
branch_le_zero(R_T0, atom_offset(cull, cube_g4_face_exit)), nop,
store_word(R_0, R_PrimCursor, O_(Poly_G4, tag)), store_word(R_0, R_PrimCursor, O_(Poly_G4, tag)),
mac_format_g4_color( mac_format_g4_color(
@@ -69,8 +68,8 @@ MipsAtom_(cube_g4_face) atom_info(atom_phase(cube_g4),
nop2, gte_cmdw_rotate_translate_perspective_single, nop2, gte_cmdw_rotate_translate_perspective_single,
mac_gte_store_g4_p3_post_rtps(), mac_gte_store_g4_p3_post_rtps(),
nop2, gte_cmdw_avg_sort_z4, gte_cmdw_avg_sort_z4,
nop2, gte_mv_from_data_r(R_T1, C2_OTZ), gte_mv_from_data_r(R_T1, C2_OTZ),
add_ui( R_AT, R_0, OrderingTbl_Len), add_ui( R_AT, R_0, OrderingTbl_Len),
set_lt_u( R_AT, R_T1, R_AT), set_lt_u( R_AT, R_T1, R_AT),