Files
retroDE_ps2/docs/hardware/ps2_feeder_zpersist_test.sh
thejayman77 ec82764bef Initial commit: retroDE_ps2 — first-of-its-kind PS2 GS FPGA core (DE25-Nano / Agilex 5)
RTL (GS rasterizer, EE core stub, platform bridge, LPDDR4B path), sim regression
(272 TBs), docs, and tooling. Copyrighted PS2 content (BIOS, game code, GS dumps,
and all dump-derived textures/traces) is excluded via .gitignore and stays local.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-29 20:10:50 -04:00

50 lines
6.6 KiB
Bash

#!/bin/sh
# retroDE_ps2 — Ch338 board acceptance: CROSS-BATCH Z ordering for >FIFO_DEPTH scenes.
#
# A NEAR (RED) and a FAR (BLUE) triangle occupy the SAME tile (tile 5 = the CENTER 16x16 block) but
# are SPLIT across FIFO batches. ZBUF clear=0x4000, TEST=GEQUAL (higher Z = nearer wins). With
# persistent cross-batch Z the NEAR (RED) triangle wins the overlap in BOTH orderings:
# stage 1 NEAR_FIRST (near RED batch0, far BLUE batch1): CENTER block must be RED (far Z-rejected)
# stage 2 FAR_FIRST (far BLUE batch0, near RED batch1): CENTER block must be RED (near wins)
# The CENTER staying RED in BOTH proves identical depth ordering regardless of the batch boundary.
# (Pre-Ch338 per-batch Z would show the CENTER BLUE in stage 1 — the later batch overwriting the
# nearer earlier prim.) Surrounding tiles: stage1 top-left RED / bottom rows BLUE; stage2 reversed.
set -u
BASE="${PS2_BRIDGE_BASE:-0x40000000}"
DEVMEM="${DEVMEM:-busybox devmem}"
OFF_STATUS=0x0D8; OFF_LO=0x0DC; OFF_HI=0x0E4; OFF_GO=0x0E8
w() { $DEVMEM $(printf "0x%X" $(( BASE + $1 ))) w "$2" >/dev/null; }
r() { $DEVMEM $(printf "0x%X" $(( BASE + $1 ))) w; }
NEAR_FIRST="000000000000000e 0000000000010000 0000000000000044 0000000000050000 0000000000000002 0000000088004060 0000000000000053 00000000ff0000ff 0000000000000000 0000700001100110 00000000ff0000ff 0000000000000030 00007000011001e0 00000000ff0000ff 00000000000c0000 0000700001e00110 00000000ff0000ff 0000000000000000 0000600000100010 00000000ff0000ff 0000000000000030 00006000001000e0 00000000ff0000ff 00000000000c0000 0000600000e00010 00000000ff0000ff 0000000000000000 0000600000100110 00000000ff0000ff 0000000000000030 00006000001001e0 00000000ff0000ff 00000000000c0000 0000600000e00110 00000000ff0000ff 0000000000000000 0000600000100210 00000000ff0000ff 0000000000000030 00006000001002e0 00000000ff0000ff 00000000000c0000 0000600000e00210 00000000ff0000ff 0000000000000000 0000600000100310 00000000ff0000ff 0000000000000030 00006000001003e0 00000000ff0000ff 00000000000c0000 0000600000e00310 00000000ff0000ff 0000000000000000 0000600001100010 00000000ff0000ff 0000000000000030 00006000011000e0 00000000ff0000ff 00000000000c0000 0000600001e00010 00000000ff0000ff 0000000000000000 0000600001100210 00000000ff0000ff 0000000000000030 00006000011002e0 00000000ff0000ff 00000000000c0000 0000600001e00210 00000000ff0000ff 0000000000000000 0000600001100310 00000000ff0000ff 0000000000000030 00006000011003e0 00000000ff0000ff 00000000000c0000 0000600001e00310 00000000ffff0000 0000000000000000 0000500001100110 00000000ffff0000 0000000000000030 00005000011001e0 00000000ffff0000 00000000000c0000 0000500001e00110 00000000ffff0000 0000000000000000 0000600002100010 00000000ffff0000 0000000000000030 00006000021000e0 00000000ffff0000 00000000000c0000 0000600002e00010 00000000ffff0000 0000000000000000 0000600002100110 00000000ffff0000 0000000000000030 00006000021001e0 00000000ffff0000 00000000000c0000 0000600002e00110 00000000ffff0000 0000000000000000 0000600002100210 00000000ffff0000 0000000000000030 00006000021002e0 00000000ffff0000 00000000000c0000 0000600002e00210 00000000ffff0000 0000000000000000 0000600002100310 00000000ffff0000 0000000000000030 00006000021003e0 00000000ffff0000 00000000000c0000 0000600002e00310 00000000ffff0000 0000000000000000 0000600003100010 00000000ffff0000 0000000000000030 00006000031000e0 00000000ffff0000 00000000000c0000 0000600003e00010"
FAR_FIRST="000000000000000e 0000000000010000 0000000000000044 0000000000050000 0000000000000002 0000000088004060 0000000000000053 00000000ffff0000 0000000000000000 0000500001100110 00000000ffff0000 0000000000000030 00005000011001e0 00000000ffff0000 00000000000c0000 0000500001e00110 00000000ffff0000 0000000000000000 0000600000100010 00000000ffff0000 0000000000000030 00006000001000e0 00000000ffff0000 00000000000c0000 0000600000e00010 00000000ffff0000 0000000000000000 0000600000100110 00000000ffff0000 0000000000000030 00006000001001e0 00000000ffff0000 00000000000c0000 0000600000e00110 00000000ffff0000 0000000000000000 0000600000100210 00000000ffff0000 0000000000000030 00006000001002e0 00000000ffff0000 00000000000c0000 0000600000e00210 00000000ffff0000 0000000000000000 0000600000100310 00000000ffff0000 0000000000000030 00006000001003e0 00000000ffff0000 00000000000c0000 0000600000e00310 00000000ffff0000 0000000000000000 0000600001100010 00000000ffff0000 0000000000000030 00006000011000e0 00000000ffff0000 00000000000c0000 0000600001e00010 00000000ffff0000 0000000000000000 0000600001100210 00000000ffff0000 0000000000000030 00006000011002e0 00000000ffff0000 00000000000c0000 0000600001e00210 00000000ffff0000 0000000000000000 0000600001100310 00000000ffff0000 0000000000000030 00006000011003e0 00000000ffff0000 00000000000c0000 0000600001e00310 00000000ff0000ff 0000000000000000 0000700001100110 00000000ff0000ff 0000000000000030 00007000011001e0 00000000ff0000ff 00000000000c0000 0000700001e00110 00000000ff0000ff 0000000000000000 0000600002100010 00000000ff0000ff 0000000000000030 00006000021000e0 00000000ff0000ff 00000000000c0000 0000600002e00010 00000000ff0000ff 0000000000000000 0000600002100110 00000000ff0000ff 0000000000000030 00006000021001e0 00000000ff0000ff 00000000000c0000 0000600002e00110 00000000ff0000ff 0000000000000000 0000600002100210 00000000ff0000ff 0000000000000030 00006000021002e0 00000000ff0000ff 00000000000c0000 0000600002e00210 00000000ff0000ff 0000000000000000 0000600002100310 00000000ff0000ff 0000000000000030 00006000021003e0 00000000ff0000ff 00000000000c0000 0000600002e00310 00000000ff0000ff 0000000000000000 0000600003100010 00000000ff0000ff 0000000000000030 00006000031000e0 00000000ff0000ff 00000000000c0000 0000600003e00010"
wait_ready() {
i=0
while [ $i -lt 300 ]; do st=$(r $OFF_STATUS); [ $(( st & 1 )) -eq 1 ] && return 0; i=$(( i + 1 )); sleep 0.01 2>/dev/null || true; done
echo " !! feeder never reported ready"; return 1
}
stage() { # $1=label $2=words
echo "--- $1 ---"
wait_ready || exit 1
w $OFF_STATUS 0x0; n=0
for word in $2; do
lo=$(printf '%s' "$word" | cut -c9-16); hi=$(printf '%s' "$word" | cut -c1-8)
w $OFF_LO 0x$lo; w $OFF_HI 0x$hi; n=$(( n + 1 ))
done
wait_ready || exit 1
w $OFF_GO 0x1
wait_ready || exit 1
echo " wrote $n words; records=$(( $(r $OFF_HI) )) (expect 14)"
}
echo "=== Ch338 cross-batch Z: CENTER block must stay RED in BOTH stages ==="
stage "stage 1 NEAR_FIRST (near RED b0, far BLUE b1)" "$NEAR_FIRST"
echo " -> CENTER should be RED now (far blue Z-rejected). Pre-Ch338 it would be BLUE."
stage "stage 2 FAR_FIRST (far BLUE b0, near RED b1)" "$FAR_FIRST"
echo " -> CENTER should be RED now (near wins on submit too)."
echo "=== PASS = CENTER block RED in BOTH stages (identical depth order regardless of batch). ==="