mirror of
https://github.com/Creased/RCM-Emulator.git
synced 2026-12-06 10:48:11 +01:00
- DC: a window's fetch starts at ADDR_V_OFFSET * LINE_STRIDE + ADDR_H_OFFSET (TRM 24.11.1). That is the window's top-left pixel, or top-right with H_DIRECTION, or bottom-left with V_DIRECTION, and the fetch walks away from it; before, the offsets were ignored and flips mirrored within the window. HOS's column-scan offset (0x13FF) and hekate's inverted-pitch offset (1279) both land where they should. Layer order is documented: the TRM sorts windows by depth without saying which way. - VIC: slot and output surfaces may be block linear (BlkKind 1, 2^BlkHeight GOBs per block) as well as pitch. - GOB addressing moves to t210/block_linear.h, shared by the scan-out and VIC. - tests/display: one bare-metal payload built per scenario (a pitch window, Nyx's VIC turn into pitch and into block-linear surfaces, a block-linear VIC source, the DC's own column scan with an address offset, a mirrored window with window D blended over). check.py compares every pixel of the frame the emulator shows with the picture drawn. It runs in make test and in CI. hwtest's frame is unchanged, and Nyx's differs only in its clock. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YYewwDPujjo5B2xRyC5Grb
77 lines
2.3 KiB
Python
Executable File
77 lines
2.3 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""Compare the emulator's frame snapshot with what a display scenario drew.
|
|
|
|
Usage: check.py <scenario> <last_fb.rgba> <last_fb.meta>
|
|
|
|
last_fb.rgba is the host view, ARGB8888 little-endian, as last_fb.meta's
|
|
"W H" gives it. The expected picture follows tests/display/payload.c.
|
|
"""
|
|
import sys
|
|
from array import array
|
|
|
|
|
|
def pat(x, y):
|
|
return 0xFF000000 | ((x * 7) & 0xFF) << 16 | ((y * 3) & 0xFF) << 8 | ((x ^ y) & 0xFF)
|
|
|
|
|
|
def patq(x, y):
|
|
return 0xFF000000 | ((x * 5 + y) & 0xFF) << 16 | 0x4000 | ((y * 9) & 0xFF)
|
|
|
|
|
|
def blend(s, d, k1):
|
|
# BLEND_MATCH_SELECT SRC K1, DST NEG_K1 (1 - K1), per channel, opaque.
|
|
out = 0xFF000000
|
|
for sh in (0, 8, 16):
|
|
c = (((s >> sh) & 0xFF) * k1 + ((d >> sh) & 0xFF) * (255 - k1)) // 255
|
|
out |= min(c, 255) << sh
|
|
return out
|
|
|
|
|
|
def expected(scenario, w, h):
|
|
if scenario == 1:
|
|
return (720, 1280), lambda x, y: pat(x, y)
|
|
if scenario in (2, 3, 4, 5):
|
|
# The picture was drawn landscape and turned on its way to the
|
|
# panel; the view turns it back.
|
|
return (1280, 720), lambda x, y: pat(x, y)
|
|
if scenario == 6:
|
|
def f(x, y):
|
|
a = pat(x, 1279 - y)
|
|
if 100 <= x < 300 and 200 <= y < 500:
|
|
return blend(patq(x - 100, y - 200), a, 128)
|
|
return a
|
|
return (720, 1280), f
|
|
raise SystemExit("unknown scenario %d" % scenario)
|
|
|
|
|
|
def main():
|
|
scenario = int(sys.argv[1])
|
|
w, h = map(int, open(sys.argv[3]).read().split())
|
|
frame = array("I")
|
|
with open(sys.argv[2], "rb") as fh:
|
|
frame.frombytes(fh.read())
|
|
(ew, eh), f = expected(scenario, w, h)
|
|
if (w, h) != (ew, eh):
|
|
print(" FAIL scenario %d: view is %dx%d, expected %dx%d" % (scenario, w, h, ew, eh))
|
|
return 1
|
|
bad = 0
|
|
first = None
|
|
for y in range(h):
|
|
row = y * w
|
|
for x in range(w):
|
|
want = f(x, y)
|
|
if frame[row + x] != want:
|
|
bad += 1
|
|
if first is None:
|
|
first = (x, y, frame[row + x], want)
|
|
if bad:
|
|
x, y, got, want = first
|
|
print(" FAIL scenario %d: %d of %d pixels differ; first at (%d,%d): %08X, expected %08X"
|
|
% (scenario, bad, w * h, x, y, got, want))
|
|
return 1
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|