Skip to content

fix: wrap VIF MPG uploads within VU micro memory - #437

Open
Tzeentchnet wants to merge 1 commit into
ran-j:mainfrom
Tzeentchnet:upstream/vif1-mpg-wrap
Open

Tzeentchnet wants to merge 1 commit into
ran-j:mainfrom
Tzeentchnet:upstream/vif1-mpg-wrap

Conversation

@Tzeentchnet

@Tzeentchnet Tzeentchnet commented Nov 10, 2026 •

Copy link
Copy Markdown

Summary

  • Mask VIF0 and VIF1 MPG destinations to their micro-memory address ranges.
  • Wrap payload bytes that cross the end of VU micro memory back to address zero.
  • Validate the complete MPG payload before modifying micro memory.

Rationale

MPG addresses and payloads operate within fixed-size VU micro memory (4 KiB for VU0 and 16 KiB for VU1). The current interpreter truncates uploads at the end of either region and ignores VIF1 destinations outside the first 16 KiB instead of applying the address mask. A truncated packet can also partially update memory when its first segment reaches the end of the buffer.

The updated behavior matches PCSX2's VIF implementation: destination addresses are masked to the target VU's micro-memory size, and crossing uploads are split between the end and beginning of that memory.

Testing

Added focused VIF0 and VIF1 coverage for:

  • payloads crossing the micro-memory boundary;
  • immediate values 0x0200 (VIF0) and 0x0800 (VIF1) aliasing address zero;
  • incomplete crossing payloads leaving micro memory unchanged.

Windows Release builds:

  • MSVC 19.44: ps2x_tests — 448 passed, 0 failed.
  • ClangCL 19.1.5: ps2x_tests — 448 passed, 0 failed.

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.

1 participant