acphal: room for SHAPE contexts on top of a title's non-cached heap, so ProjectScarlett starts #557

Closed
NickStallman wants to merge 1 commit from upstream-pr/557 into main
NickStallman commented 2026-11-29 23:16:52 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-11-29T23:16:52Z.


Refs #554 (and #556, my duplicate). It's @csj0oe's area; take it or replace it. #511 edits the same files and needs a rebase.

ProjectScarlett crashes at start-up since #527: it asks for a non-cached APU heap of 0x226e00 bytes, then takes 350 XMA contexts (0x5780) and a block of 0x222e00 at alignment 0x800. The ApuAlloc is refused, 0x1800 bytes short, and the title clears the null block it got (@glovepost's disassembly on #554). Before #527 both heaps were one region.

As @glovepost points out, the title leaves only 0x4000 bytes over, so it can't be counting the contexts in its size. This adds the default heap's 1 MiB on top of a title's own size. My first version rounded the size up to 64 KiB, which fails for a size that is already a multiple of it; thanks for catching that. The contexts stay in the non-cached heap, as the existing tests (from the header) say; ApuHeapGetState then reports the larger heap.

Tested:

  • A unit test with those calls and with a size that is a multiple of 64 KiB; it fails without the change, and with the rounding. The crate's tests pass (10).
  • python tuxbox.py check --no-gpu passes on this version (ac1cc0d3).
  • Full python tuxbox.py check of ac1cc0d3: RTX 5090 (10de:2b85, 620.70.10) 200 pass, 0 fail (a game was loading on it for part); AMD iGPU (1002:13c0, RADV) 199 pass, 0 fail. GE-Proton11-14.
  • @Kayotic1337 ran this version (with #535, #546 and #548) on an RX 9070 XT: past start-up in 2 of 2 runs.
  • Game, with the earlier rounding version only: on an RTX 5090 (10de:2b85, 620.70.10, GE-Proton11-14, Linux), plain main f482572a plus it ran until my 2-minute limit, where main 6bab5478, and f482572a with only logging added, crash at start-up. An integration build with it ran past start-up and for its full 40 minutes, still on loading screens, with no device loss. @1093i3511 ran the rounding version (with #501) on an RX 6600: through init, then 11 minutes to the world. This version (ac1cc0d3), in an integration build of f482572a on the same card, ran through start-up to the story's loading, about 10 minutes, and ended there in a different crash (a refused ray scene, under investigation).

Not known: where the console keeps the contexts. Not run: anything that shows audio works.

🤖 Generated with Claude Code

<!-- greyfinch-sync:brcly/TuxBox:issue:5556219761 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/557). Originally posted by [NickStallman](https://github.com/NickStallman) on 2026-11-29T23:16:52Z. --- Refs #554 (and #556, my duplicate). It's @csj0oe's area; take it or replace it. #511 edits the same files and needs a rebase. ProjectScarlett crashes at start-up since #527: it asks for a non-cached APU heap of 0x226e00 bytes, then takes 350 XMA contexts (0x5780) and a block of 0x222e00 at alignment 0x800. The `ApuAlloc` is refused, 0x1800 bytes short, and the title clears the null block it got (@glovepost's disassembly on #554). Before #527 both heaps were one region. As @glovepost points out, the title leaves only 0x4000 bytes over, so it can't be counting the contexts in its size. This adds the default heap's 1 MiB on top of a title's own size. My first version rounded the size up to 64 KiB, which fails for a size that is already a multiple of it; thanks for catching that. The contexts stay in the non-cached heap, as the existing tests (from the header) say; `ApuHeapGetState` then reports the larger heap. Tested: - A unit test with those calls and with a size that is a multiple of 64 KiB; it fails without the change, and with the rounding. The crate's tests pass (10). - `python tuxbox.py check --no-gpu` passes on this version (ac1cc0d3). - Full `python tuxbox.py check` of ac1cc0d3: RTX 5090 (`10de:2b85`, 620.70.10) 200 pass, 0 fail (a game was loading on it for part); AMD iGPU (`1002:13c0`, RADV) 199 pass, 0 fail. GE-Proton11-14. - @Kayotic1337 ran this version (with #535, #546 and #548) on an RX 9070 XT: past start-up in 2 of 2 runs. - **Game, with the earlier rounding version only:** on an RTX 5090 (`10de:2b85`, 620.70.10, GE-Proton11-14, Linux), plain `main` f482572a plus it ran until my 2-minute limit, where `main` 6bab5478, and f482572a with only logging added, crash at start-up. An integration build with it ran past start-up and for its full 40 minutes, still on loading screens, with no device loss. @1093i3511 ran the rounding version (with #501) on an RX 6600: through init, then 11 minutes to the world. This version (ac1cc0d3), in an integration build of f482572a on the same card, ran through start-up to the story's loading, about 10 minutes, and ended there in a different crash (a refused ray scene, under investigation). **Not known:** where the console keeps the contexts. **Not run:** anything that shows audio works. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
1093i3511 commented 2026-11-30 00:00:08 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by 1093i3511 on 2026-11-30T00:00:08Z.


Works on an RX 6600 (RDNA 2, RADV / Mesa 26.3.1, GE-Proton11-14). I tested f482572a + #557 (62c991d8) + #501 (cbb6a2df). The title got through init with no memset fault, and TuxBox xapu: software Opus connection ready is back. It then ran for 11 minutes and reached the world, where it ended on the title's watchdog (unrelated, #472). Before #557, the same base crashed at init in 2 of 2 runs.

@glovepost's caveat about already aligned sizes still applies; this run only shows that the 0x226e00 case works.

<!-- greyfinch-sync:brcly/TuxBox:comment:7264886576 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/557#issuecomment-7264886576). Originally posted by [1093i3511](https://github.com/1093i3511) on 2026-11-30T00:00:08Z. --- Works on an RX 6600 (RDNA 2, RADV / Mesa 26.3.1, GE-Proton11-14). I tested `f482572a` + #557 (`62c991d8`) + #501 (`cbb6a2df`). The title got through init with no `memset` fault, and `TuxBox xapu: software Opus connection ready` is back. It then ran for 11 minutes and reached the world, where it ended on the title's watchdog (unrelated, #472). Before #557, the same base crashed at init in 2 of 2 runs. @glovepost's caveat about already aligned sizes still applies; this run only shows that the `0x226e00` case works.
Kayotic1337 commented 2026-11-30 00:50:02 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by Kayotic1337 on 2026-11-30T00:50:02Z.


Game run on an RX 9070 XT (1002:7550, RDNA 4, RADV / Mesa 26.3.1, GE-Proton11-14, Linux 7.3.6), the same card I used to bisect #554 to #527.

Build: main f482572a + this PR (ac1cc0d3), with #546, #548 and #535 merged on top for a combined test. #527 is not reverted.

  • ProjectScarlett gets past Game Init in 2 of 2 runs. The VCRUNTIME140.dll + 0x1989 / game_scarlett_master.exe + 0x43AED60 crash from #554 is gone.
  • The menus work, and both runs reach the first in-game cutscene (int_prolo, frames 1208 and 2716).
  • Both runs end in the cutscene crash that main had before #527 (GPU TCP write fault 0x741041 in the warm run), so that crash isn't caused by this PR.

Until this lands I'll use it in place of my local revert of #527.

<!-- greyfinch-sync:brcly/TuxBox:comment:7265616039 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/557#issuecomment-7265616039). Originally posted by [Kayotic1337](https://github.com/Kayotic1337) on 2026-11-30T00:50:02Z. --- Game run on an RX 9070 XT (`1002:7550`, RDNA 4, RADV / Mesa 26.3.1, GE-Proton11-14, Linux 7.3.6), the same card I used to bisect #554 to #527. Build: `main` `f482572a` + this PR (`ac1cc0d3`), with #546, #548 and #535 merged on top for a combined test. #527 is **not** reverted. - ProjectScarlett gets past `Game Init` in 2 of 2 runs. The `VCRUNTIME140.dll + 0x1989` / `game_scarlett_master.exe + 0x43AED60` crash from #554 is gone. - The menus work, and both runs reach the first in-game cutscene (`int_prolo`, frames 1208 and 2716). - Both runs end in the cutscene crash that `main` had before #527 (GPU TCP write fault `0x741041` in the warm run), so that crash isn't caused by this PR. Until this lands I'll use it in place of my local revert of #527.
brcly commented 2026-11-30 04:11:47 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by brcly on 2026-11-30T04:11:47Z.


Merged into main as 70d7e137 (squashed and credited to you), so I'm closing this. It fixes #554: ProjectScarlett gets through init again. I confirmed it with a boot here: the xapu Opus connection comes up and shaders compile. Thanks, and thanks to everyone on #554 for the bisecting and the disassembly.

<!-- greyfinch-sync:brcly/TuxBox:comment:7268554168 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/557#issuecomment-7268554168). Originally posted by [brcly](https://github.com/brcly) on 2026-11-30T04:11:47Z. --- Merged into main as 70d7e137 (squashed and credited to you), so I'm closing this. It fixes #554: ProjectScarlett gets through init again. I confirmed it with a boot here: the xapu Opus connection comes up and shaders compile. Thanks, and thanks to everyone on #554 for the bisecting and the disassembly.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
brcly/TuxBox!557
No description provided.