mirror of
https://github.com/Ed94/pikuma_ps1.git
synced 2026-08-25 02:20:33 +00:00
remove outdated comments.
This commit is contained in:
+2
-30
@@ -51,9 +51,7 @@ FI_ Slice_MipsCode ac_gte_store_g4_p012(AtomBuilder_R ab, Reg r_primitive_cursor
|
||||
FI_ Slice_MipsCode ac_gte_store_g4_p3(AtomBuilder_R ab, U4 r_primitive_cursor) atom_dbg_skip MipsAtomComp_Proc_(ab, { gte_sw(C2_SXY2, r_primitive_cursor, O_(Poly_G4,p3)) })
|
||||
|
||||
/* ─── STAGE 1 of normalize: SQR + mfc2 MAC1/2/3 ───
|
||||
* Emits squared magnitude per component (in MAC1/2/3) into caller-provided scratch regs.
|
||||
* Stage 2 of normalize consumes these directly.
|
||||
* Words: 8. Clobbers: IR1/2/3, MAC1/2/3. Uses gte_cmdw_sqr (sf=0, lm=1). */
|
||||
* Emits squared magnitude per component (in MAC1/2/3) into caller-provided scratch regs. */
|
||||
FI_ Slice_MipsCode ac_gte_sqr_v3(AtomBuilder_R ab, U4 r_sx, U4 r_sy, U4 r_sz, U4 r_sq_x, U4 r_sq_y, U4 r_sq_z) atom_dbg_skip MipsAtomComp_Proc_(ab, {
|
||||
mac_gte_sqr_v3s4(r_sx, r_sy, r_sz, nop),
|
||||
gte_mv_from_data_r(r_sq_x, C2_MAC1),
|
||||
@@ -61,10 +59,7 @@ FI_ Slice_MipsCode ac_gte_sqr_v3(AtomBuilder_R ab, U4 r_sx, U4 r_sy, U4 r_sz, U4
|
||||
gte_mv_from_data_r(r_sq_z, C2_MAC3),
|
||||
})
|
||||
|
||||
/* ─── SQR FIRE — mtc2 3 GPRs into IR1/IR2/IR3, then fire SQR. ───
|
||||
* The SQR command always squares IR1/IR2/IR3 — those C2 registers are fixed.
|
||||
* The GPRs holding the source vector are caller-determined.
|
||||
* Words: 5 (3 mtc2 + 1 nop hazard + 1 cmd). */
|
||||
/* ─── SQR FIRE — mtc2 3 GPRs into IR1/IR2/IR3, then fire SQR. ─── */
|
||||
FI_ Slice_MipsCode ac_gte_sqr_v3s4(AtomBuilder_R ab, Reg r_sx, Reg r_sy, Reg r_sz, MipsCode delay_slot)
|
||||
atom_dbg_skip MipsAtomComp_Proc_(ab, {
|
||||
gte_mv_to_data_r(r_sx, C2_IR1),
|
||||
@@ -255,29 +250,6 @@ typedef Struct_(RegUse_build_normalize_v3s4) {
|
||||
/* ─── Full normalize (all 4 stages inline) ───
|
||||
* Generic 4-stage GTE normalize (SQR → sum+LZCR → align+sqrtbl → GPF+srav).
|
||||
*
|
||||
* Parameterized by caller-provided scratch base + src/dst offsets.
|
||||
* The caller passes r_src_offset and r_dst_offset as compile-time constants
|
||||
* (typically derived from O_ macros in the caller's struct schema, e.g., `O_(CallerBundleScratch, fwd)`).
|
||||
*
|
||||
* This design lets any caller (with a scratch base + struct schema) use `normalize_v3s4_proc`
|
||||
* without putting magic offsets in the C-side bundle helper — the offsets come from O_ macros at the call site.
|
||||
*
|
||||
* Body uses 9 GPRs (r_src_ptr..r_branch_tmp):
|
||||
* r_src_ptr, r_dst_ptr : src/dst pointers (computed from r_scratch + caller offsets)
|
||||
* r_tmp : src.x PRESERVED across stages 1-2 (NOT clobbered by mfc2 MAC2) → fed to IR1 in stage 4
|
||||
* r_mac1_scratch : MAC1 result scratch (also holds aligned |v|² in stage 3)
|
||||
* r_mac2_scratch : MAC2 result scratch → result.x after stage 4 sra
|
||||
* r_recip_est : src.y PRESERVED across stages 1-2 → fed to IR2 in stage 4 → result.y
|
||||
* r_norm : |v|² sum (stage 2) → half-shift (stage 3) → 1/|v| (stage 4 IR0)
|
||||
* r_shift : shift count SAVED in stage 3 → consumed by stage 4 srav
|
||||
* r_branch_tmp : src.z PRESERVED across stages 1-2 → fed to IR3 in stage 4 → result.z (also sqrtbl base addr)
|
||||
*
|
||||
* Atom_labels are srav_path / aligned_done
|
||||
* (NOT namespaced — they're internal to this proc;
|
||||
* the metaprogram's per-atom-name enum emission handles any collision across different atoms/files that share the same labels).
|
||||
*
|
||||
* Pool cost: 11 GPRs (well within the 9-10 caller-trash GPR budget when r_scratch is a wave-context carrier).
|
||||
*
|
||||
* Direct port of PSYQ libgte msc02.rel.text VectorNormal disassembly (0x800160a0..0x8001615c).
|
||||
* Words: ~59 (matches libgte 0x800160a0..0x8001615c at +/- 0-2 words for BD-slot reshuffling).
|
||||
* Sqrtbl: hardcoded to 0x800185B4 (libgte msc02.rel.data). Note: swapped to local.
|
||||
|
||||
@@ -77,8 +77,7 @@ enum {
|
||||
|
||||
// Reserved Registers (Callee-saved):
|
||||
// - R_T9: Holds the Tape Ptr which we need to increment
|
||||
// If we hit a wall with register allocations we can clobber V0 & V1 (return values), defering as opt-in by user.
|
||||
// - R_RA: Not sure??
|
||||
// - R_RA: Return address register
|
||||
// Needed by ac_yield but can be used as atom scratch:
|
||||
// - R_T8: Will be used as the atom jump register.
|
||||
|
||||
@@ -144,6 +143,7 @@ typedef Slice_(MipsAtom);
|
||||
// Inline-only callers (the generated `mac_<name>` aliases) skip the `ab` arg via metaprogram filtering; escape callers (ac_<name> invoked as a function) pass a long-lived builder.
|
||||
#define MipsAtomComp_Proc_(ab, ...) { MipsCode atom_comp_code[] align_(4) = __VA_ARGS__; atombuilder_push(ab, slice_from_array(MipsCode, atom_comp_code)); }
|
||||
|
||||
// Used for trivial mappings from one atom component proc to the command of a more baser (meant for type-mapping)
|
||||
#define MipsAtomComp_ProcMap_(ab, base_command) atom_dbg_skip MipsAtomComp_Proc_(ab, {base_command })
|
||||
|
||||
/* Line-table anchor: gcc only adds a file to the .debug_line file table when the contains line-numbered content.
|
||||
|
||||
@@ -140,9 +140,9 @@ typedef Struct_(ResolveLookAtScratch) {
|
||||
};
|
||||
|
||||
typedef Struct_(Binds_ResolveLookAtSub) {
|
||||
P3_S4* target; /* U4 (C-side P3_S4* — read by atom 0 directly; NOT a scratchpad address) */
|
||||
P3_S4* eye; /* U4 (C-side P3_S4* — read by atom 0 directly; staged into scratchpad by atom 0) */
|
||||
V3_S4* up_in; /* U4 (C-side V3_S4* — read by atom 0 directly; staged into scratchpad by atom 0) */
|
||||
P3_S4* target;
|
||||
P3_S4* eye;
|
||||
V3_S4* up_in;
|
||||
ResolveLookAtScratch* scratchpad;
|
||||
};
|
||||
typedef Struct_(RegUse_resolve_look_at_input_and_sub) {
|
||||
@@ -150,25 +150,7 @@ typedef Struct_(RegUse_resolve_look_at_input_and_sub) {
|
||||
Reg target; Reg eye; Reg up_in;
|
||||
Reg t0; Reg t1; Reg t2; Reg t3; Reg t4;
|
||||
};
|
||||
/* Atom 0 in the bundle: input_and_sub. Stages C-side inputs into the scratchpad and computes fwd = target - eye.
|
||||
* Staging work:
|
||||
* * Stage eye.x/y/z → scratch (for atom 6's translation column)
|
||||
* * Stage up_in.x/y/z → scratch (for atom 2's outer-product operand)
|
||||
* * Compute fwd = target - eye, store fwd.x/y/z → scratch+0/+4/+8 (for atom 1)
|
||||
* GPR codes (assigned by resolve_look_at_init):
|
||||
* r_target_ptr : R_T0
|
||||
* r_eye_ptr : R_T1
|
||||
* r_up_in_ptr : R_T2
|
||||
* r_scratch : R_T4 (R_ResolveScratch; wave-context carrier)
|
||||
* r_tmp0 : R_T3 (stage eye/up_in + load eye.y)
|
||||
* r_tmp1 : R_T5 (stage eye/up_in + load eye.z)
|
||||
* r_tmp2 : R_T6 (stage eye/up_in + load target.x)
|
||||
* r_tmp3 : R_T7 (stage eye/up_in + load target.y)
|
||||
* R_AT : hardcoded (load eye.y / eye.z / target.z)
|
||||
* R_V0 : hardcoded (load eye.z / target.z)
|
||||
* Pool cost: 8 GPRs + R_T4 (carrier) + R_AT + R_V0 (hardcoded) = 11 GPRs.
|
||||
*/
|
||||
// internal MipsAtom* resolve_look_at_input_and_sub(AtomArena_R aa, RegUse_resolve_look_at_input_and_sub r)
|
||||
/* Atom 0 in the bundle: input_and_sub. Stages C-side inputs into the scratchpad and computes fwd = target - eye. */
|
||||
internal MipsAtom* AtomBundleEntry_(resolve_look_at,input_and_sub)(AtomArena_R aa, RegUse_resolve_look_at_input_and_sub r)
|
||||
atom_info(atom_bind(Binds_ResolveLookAtSub)) MipsAtom_Proc_(aa, {
|
||||
load_word(r.target, R_TapePtr, O_(Binds_ResolveLookAtSub,target)),
|
||||
@@ -238,14 +220,14 @@ internal MipsAtom* resolve_look_at_cross_uz_up_into_right(AtomArena_R aa,
|
||||
gte_mv_to_ctrl_r(r.c, gte_cr_RT22), /* $4 = r_c = a.z. RT22=a.z.low, RT33=a.z.high. */
|
||||
|
||||
/* Load uz into the RT diagonal. */
|
||||
gte_mv_to_ctrl_r(r.a, gte_cr_RT11), /* D1 = RT11 = uz.x (low 16 of $0, sign-extended by OP). */
|
||||
GteDelay_ nop2, /* CTC2 retirement (CPU→COP2 2-slot delay) */
|
||||
gte_mv_to_ctrl_r(r.a, gte_cr_RT11), /* D1 = RT11 = uz.x. */
|
||||
GteDelay_ nop2, /* CTC2 retirement */
|
||||
|
||||
/* Load up_in into IR (the second operand for OP). */
|
||||
gte_mv_to_data_r(r.d, C2_IR1), /* IR1 = up_in.x */
|
||||
gte_mv_to_data_r(R_AT, C2_IR2), /* IR2 = up_in.y */
|
||||
gte_mv_to_data_r(r.t0, C2_IR3), /* IR3 = up_in.z */
|
||||
GteDelay_ nop2, /* MTC2 retirement (CPU→COP2 2-slot delay) */
|
||||
GteDelay_ nop2, /* MTC2 retirement */
|
||||
|
||||
gte_cmdw_cross, /* OP: MAC1/2/3 = uz × up_in
|
||||
* MAC1 = IR3*D2 - IR2*D3 = up_in.z*uz.y.high - up_in.y*uz.z.high
|
||||
|
||||
@@ -263,11 +263,7 @@ internal void compile_resolve_look_at(void) {
|
||||
});
|
||||
regfile_reset_to_mask(& rf, pin_mask);
|
||||
|
||||
/* === ATOM 6a.5: set_gte_mt3s2s4 (BAKED — ctc2 RT matrix) ===
|
||||
* This is a BAKED atom from gte.atom.c. Its body hardcodes R_T3 as
|
||||
* the matrix pointer (popped from tape). It does NOT need GPR
|
||||
* assignment from us — it has its own internal GPR usage.
|
||||
* We just take its address. */
|
||||
/* === ATOM 6a.5: set_gte_mt3s2s4 (BAKED — ctc2 RT matrix) === */
|
||||
smem.resolve_look_at_bundle[7] = (MipsAtom*) & set_gte_mt3s2s4;
|
||||
|
||||
/* === ATOM 6b: matrix_vector (RT * (-eye) >> 12) === */
|
||||
@@ -292,17 +288,7 @@ internal void compile_resolve_look_at(void) {
|
||||
#undef ralloc
|
||||
}
|
||||
|
||||
/* Emit the resolve_look_at bundle into the tape. Called once per frame from update().
|
||||
* The 7 chain atoms are pre-built at init time (resolve_look_at_init) and referenced by address via smem.resolve_look_at_atom_addrs[].
|
||||
* Per-frame work: 7 tb_emit (atom pointer emissions) + 5 tb_data (C-side pointers for atom 0 + look_at for atom 6).
|
||||
*
|
||||
* Binds_ contract (the field-name labels are for human readability):
|
||||
* Atom 0 input_and_sub target(4) eye(4) up_in(4) scratch_base(4) = 4 words
|
||||
* Atoms 1-5 (no tape data — atom uses r_scratch + offset internally)
|
||||
* Atom 6 populate_and_translate look_at(4) = 1 word
|
||||
* ----
|
||||
* 5 tb_data words total per frame.
|
||||
*/
|
||||
/* Emit the resolve_look_at bundle into the tape. Called once per frame from update(). */
|
||||
I_ void resolve_look_at(TapeBuilder_R tb
|
||||
, MT3_S2S4* look_at
|
||||
, P3_S4* eye
|
||||
|
||||
Reference in New Issue
Block a user