Skip to content

Review: preserve live DMA2 reads and restore word-cost timing - #20

Open
Alexbeav wants to merge 4 commits into
review-base/mstan-22fbbfcab962from
review/gpu-dma2-correctness-ff7
Open

Review: preserve live DMA2 reads and restore word-cost timing#20
Alexbeav wants to merge 4 commits into
review-base/mstan-22fbbfcab962from
review/gpu-dma2-correctness-ff7

Conversation

@Alexbeav

@Alexbeav Alexbeav commented Sep 2, 2026

Copy link
Copy Markdown
Owner

Summary This review branch combines the corrected GPU DMA2 linked-list state machine from #13 with the lower transfer cost demonstrated by RetroPortingToolKit#299 and resubmitted as RetroPortingToolKit#302. The change keeps DMA slicing. It reads each payload word at its own guest-cycle event, rejects stale widescreen-prepass metadata, consumes every elapsed event when service is late, and removes the obsolete polygon filter. It then charges one guest clock per transferred 32-bit word, including each node header, with no separate setup charge. ## Why PR RetroPortingToolKit#277 fixed Vampire Hunter D and Spot Goes to Hollywood by allowing the guest to change later ordering-table data while DMA remains active. Its 8-clock header and 5-clock setup charges also made large Final Fantasy VII ordering tables take about three times the prior runtime cost. FF7 then reached its stuck-channel path, canceled active walks, and lost battle geometry. The one-clock model is a validated compatibility model. This branch does not claim that it is a complete physical-bus arbitration model. ## Scope gate - Upstream base: 22fbbfcab962b25e010b1b8e94cb2fa140612f63 - Review head: 9dfb4174adea419c259b132eda512525cf9b8dea - Commit count: 4 - Changed-file count: 13 Commits: 1. f424a814 preserves live payload-word timing and prepass guards. 2. 99f775c8 closes the late-service, live-link, and polygon-filter review gaps. 3. bc88c06c restores one clock per transferred word.

  1. 9dfb4174 versions the larger DMA save-state wire and corrects the test record. Changed files: - docs/internal/FAITHFUL_TIMING_PLAN.md - runtime/CMakeLists.txt
  • runtime/include/boot_state.h - runtime/include/dma_gpu_ll.h - runtime/include/gpu.h - runtime/include/ws_prepass_guard.h - runtime/src/dma.c - runtime/src/dma_gpu_ll.c - runtime/src/gpu.c - runtime/src/main.cpp - runtime/tests/test_dma_gpu_linked_list_timing.c
  • runtime/tests/test_savestate_status_protocol.py - runtime/tests/test_ws_prepass_guard.c The diagnostic counters and synchronous A/B switch from dma: charge DMA2 linked-list walks what the validated model charged RetroPortingToolKit/psxrecomp#302 are intentionally not part of this review. They can receive separate review after the transfer behavior settles. ## Source tests - The runtime and oracle targets build with Clang 22.1.8. - dma_gpu_linked_list_timing_test passes 20 consecutive runs. - ws_prepass_guard_test passes 20 consecutive runs.
  • savestate_status_protocol_test passes 20 consecutive runs. - 61 of 62 enabled runtime tests pass. - sio_dualshock_rumble_test and spu_fidelity_test remain disabled upstream. - mod_runtime_test crashes on this branch and unchanged base 22fbbfca. - git diff --check passes. ## Remaining gate The exact review head still needs visible Vampire Hunter D, Spot Goes to Hollywood, and Final Fantasy VII routes before an upstream submission or update. ## Review focus Please review the zero-cost setup transition, the one-event-per-payload-word contract, late-service behavior, save-state fields, determinism data, and widescreen cache invalidation. Developed with AI assistance; validated as described (test evidence in PR body). AI writes the code and the PR, but I always test before I send something up. Happy to iterate on this process with your feedback. --- ## Summary by cubic Restores the one-clock-per-word GPU DMA2 timing model while keeping each payload word read at its own guest-cycle event, so guest rewrites during an active transfer still affect later words. - Charges one guest clock per transferred 32-bit word (header and payload) with no separate setup charge; the old model charged 8 clock cycles per header plus 5 per setup. - Removes the obsolete opt-in polygon-drop filter and its PSX_ND_SIB_FLAP_LAST / PSX_ND_OT_OPAQUE_LAST env vars. - Widescreen prepass now fingerprints cached nodes and commands; any live RAM mismatch invalidates the cached transform metadata. - Late service calls now consume every elapsed DMA boundary, not just one. - Bumps the save-state format to v6 to serialize payload_index; older save states are rejected at the header before any state is applied. - Adds unit tests for the prepass fingerprint guard and the v6 save-state wire. Written for commit 9dfb417. Summary will update on new commits. Review in cubic

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 11 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread runtime/src/dma.c
Comment thread docs/internal/FAITHFUL_TIMING_PLAN.md Outdated
@Alexbeav

Alexbeav commented Sep 2, 2026

Copy link
Copy Markdown
Owner Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Sep 2, 2026

Copy link
Copy Markdown

@cubic-dev-ai review this PR

@Alexbeav I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 13 files

Re-trigger cubic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants