d3d12: rebuild a grown scene in the storage it already has #566

Closed
NickStallman wants to merge 1 commit from upstream-pr/566 into main
NickStallman commented 2026-11-30 03:51:08 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-11-30T03:51:08Z.


Fixes a crash in ProjectScarlett, announced on #533 and #382 (3kynox has the same one). Overlaps #406 (same functions, which already conflicts with main alone) and possibly @3kynox's unpublished #382 wiring.

Problem. A list captures a scene (a ray-tracing structure in title memory). A later list rebuilds that scene larger at the same guest address. guest_memory::target finds the storage too small and gives the rebuild new storage, so the first list holds a native address the scene no longer has. Submitted after the rebuild, it is refused ("inline ray scene or geometry changed after recording, rejecting submission"), and everything after it on that queue is dropped: its labels never land and the title crashes (access violation at game_scarlett_master.exe+0x23CF683, exit code 5). On a console the first list reads the rebuilt scene at the same address.

Change. A top-level build in title memory that needs new storage gets room for 4 times its instances, at least 2,048 (capped at the host's maximum). Bottom-level structures reserve nothing. If that allocation fails, the exact size is used. A scene that outgrows its room is still moved and refused, as now, and logs "outgrew its storage". I left out running such a list on the old storage: its pins can be retired before that list completes, so it could read freed memory.

Cost: I have no measured bytes per instance. If it's 200 B, five scenes at the floor cost about 2 MB and a 3,058-instance scene 2.4 MB. Copies of a scene grow with their source's storage. One more host size query per top-level build.

Tested

  • A device test: capture a one-instance scene, record a 2,000-instance rebuild at the same address, trace through the captured scene. Without the change it fails ("the scene must not move"); with it the query returns the rebuilt scene's instance. Fails and passes on an AMD iGPU (1002:13c0, RADV) and an RTX 5090 (10de:2b85, 620.70.10). The recorded builds aren't executed; the rebuilt contents are built natively into the storage they chose.
  • A pure test on the storage choice fails without the reserve, passes with it.
  • Full python tuxbox.py check of 53c0c6ba (rebased onto e5d2e913; main's reformat only, range-diff in the PR's history): RTX 5090 (10de:2b85, 620.70.10) 200 pass, 0 fail; AMD iGPU (1002:13c0, RADV) 199 pass, 0 fail. GE-Proton11-14.

Game (RTX 5090, integration builds of f482572a with our open PRs, plus a log-only trace): the five runs before it (78b, 79a, 79c, 80a, 81a) ended in this refusal within about 2 minutes of the story loading; the six with it (82a, 83a, 83b, 84a, 84b, 85a; up to 19 minutes in the world, one never got there) had none, and no "outgrew" line. They ended in other ways: four in a GPU loss (Xid 13, MMU fault in a shader), one in the private-views alias fault of #472, one in a MangoHud crash. I have no reason to think this change causes the losses, and no proof that it doesn't; #232.

The three scene_publication device tests, the new one included, pass on 53c0c6ba on both cards (they need a hardware device and aren't in the suite).

@3kynox's three crashed runs on an RTX 4070 Ti SUPER each have the refusal line, and with this change (fa287c8e on their base) one run of 20 minutes, 11 in the story, had no refusal, no stalled label and no crash (#382). Their unpublished wiring doesn't touch the functions changed here.

Not run: a second card of other kinds in the game, a scene that outgrows its room (by game), a title-memory scene copy under load.

Evidence: TuxBox check of 53c0c6ba6f, no uncommitted changes, GPU 10de:2b85: 16 passed, 0 failed, 0 not run
Evidence: TuxBox check of 53c0c6ba6f, no uncommitted changes, GPU 1002:13c0: 16 passed, 0 failed, 0 not run

🤖 Generated with Claude Code

<!-- greyfinch-sync:brcly/TuxBox:issue:5558644875 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/566). Originally posted by [NickStallman](https://github.com/NickStallman) on 2026-11-30T03:51:08Z. --- Fixes a crash in ProjectScarlett, announced on #533 and #382 (3kynox has the same one). **Overlaps #406** (same functions, which already conflicts with main alone) and possibly @3kynox's unpublished #382 wiring. **Problem.** A list captures a scene (a ray-tracing structure in title memory). A later list rebuilds that scene larger at the same guest address. `guest_memory::target` finds the storage too small and gives the rebuild new storage, so the first list holds a native address the scene no longer has. Submitted after the rebuild, it is refused ("inline ray scene or geometry changed after recording, rejecting submission"), and everything after it on that queue is dropped: its labels never land and the title crashes (access violation at `game_scarlett_master.exe+0x23CF683`, exit code 5). On a console the first list reads the rebuilt scene at the same address. **Change.** A top-level build in title memory that needs new storage gets room for 4 times its instances, at least 2,048 (capped at the host's maximum). Bottom-level structures reserve nothing. If that allocation fails, the exact size is used. A scene that outgrows its room is still moved and refused, as now, and logs "outgrew its storage". I left out running such a list on the old storage: its pins can be retired before that list completes, so it could read freed memory. **Cost:** I have no measured bytes per instance. If it's 200 B, five scenes at the floor cost about 2 MB and a 3,058-instance scene 2.4 MB. Copies of a scene grow with their source's storage. One more host size query per top-level build. ## Tested - A device test: capture a one-instance scene, record a 2,000-instance rebuild at the same address, trace through the captured scene. Without the change it fails ("the scene must not move"); with it the query returns the rebuilt scene's instance. Fails and passes on an AMD iGPU (`1002:13c0`, RADV) and an RTX 5090 (`10de:2b85`, 620.70.10). The recorded builds aren't executed; the rebuilt contents are built natively into the storage they chose. - A pure test on the storage choice fails without the reserve, passes with it. - Full `python tuxbox.py check` of 53c0c6ba (rebased onto e5d2e913; main's reformat only, range-diff in the PR's history): RTX 5090 (`10de:2b85`, 620.70.10) 200 pass, 0 fail; AMD iGPU (`1002:13c0`, RADV) 199 pass, 0 fail. GE-Proton11-14. **Game** (RTX 5090, integration builds of f482572a with our open PRs, plus a log-only trace): the five runs before it (78b, 79a, 79c, 80a, 81a) ended in this refusal within about 2 minutes of the story loading; the six with it (82a, 83a, 83b, 84a, 84b, 85a; up to 19 minutes in the world, one never got there) had none, and no "outgrew" line. They ended in other ways: four in a GPU loss (Xid 13, MMU fault in a shader), one in the private-views alias fault of #472, one in a MangoHud crash. I have no reason to think this change causes the losses, and no proof that it doesn't; #232. The three `scene_publication` device tests, the new one included, pass on 53c0c6ba on both cards (they need a hardware device and aren't in the suite). @3kynox's three crashed runs on an RTX 4070 Ti SUPER each have the refusal line, and with this change (fa287c8e on their base) one run of 20 minutes, 11 in the story, had no refusal, no stalled label and no crash (#382). Their unpublished wiring doesn't touch the functions changed here. **Not run:** a second card of other kinds in the game, a scene that outgrows its room (by game), a title-memory scene copy under load. Evidence: TuxBox check of 53c0c6ba6f1e, no uncommitted changes, GPU 10de:2b85: 16 passed, 0 failed, 0 not run Evidence: TuxBox check of 53c0c6ba6f1e, no uncommitted changes, GPU 1002:13c0: 16 passed, 0 failed, 0 not run 🤖 Generated with [Claude Code](https://claude.com/claude-code)
brcly commented 2026-11-30 04:12:05 +00:00 (Migrated from github.com)

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


Heads-up: main just landed a large cleanup (up to e5d2e913), so this PR needs a rebase.

  • Formatting: the whole workspace is now formatted with rustfmt (see the new rustfmt.toml).
  • Lints: every crate denies unwrap(), lossy as casts and undocumented unsafe outside tests.
  • CI: it now also runs cargo fmt --check, rustdoc with warnings denied, and Miri on the providers' unit tests.

The least painful way is to format your branch first, so the rebase only shows real changes:

git fetch origin
git checkout origin/main -- rustfmt.toml
cargo fmt --all && git commit -am "rustfmt"
git rebase origin/main

Then run python tuxbox.py check --no-gpu, which now includes the format step.

If clippy flags something new:

  • A cast: use From for widening, TryFrom for narrowing, and a mask for bit fields.
  • An unwrap(): use ?, or expect with the reason it can't fail.
  • An unsafe block: it needs a // SAFETY: comment.

CONTRIBUTING's "Code checks" section lists the commands. Thanks!

<!-- greyfinch-sync:brcly/TuxBox:comment:7268558499 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/566#issuecomment-7268558499). Originally posted by [brcly](https://github.com/brcly) on 2026-11-30T04:12:05Z. --- Heads-up: main just landed a large cleanup (up to e5d2e913), so this PR needs a rebase. - **Formatting:** the whole workspace is now formatted with rustfmt (see the new `rustfmt.toml`). - **Lints:** every crate denies `unwrap()`, lossy `as` casts and undocumented `unsafe` outside tests. - **CI:** it now also runs `cargo fmt --check`, rustdoc with warnings denied, and Miri on the providers' unit tests. The least painful way is to format your branch first, so the rebase only shows real changes: ```sh git fetch origin git checkout origin/main -- rustfmt.toml cargo fmt --all && git commit -am "rustfmt" git rebase origin/main ``` Then run `python tuxbox.py check --no-gpu`, which now includes the format step. If clippy flags something new: - **A cast:** use `From` for widening, `TryFrom` for narrowing, and a mask for bit fields. - **An `unwrap()`:** use `?`, or `expect` with the reason it can't fail. - **An `unsafe` block:** it needs a `// SAFETY:` comment. CONTRIBUTING's "Code checks" section lists the commands. Thanks!
brcly commented 2026-11-30 09:32:45 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by brcly on 2026-11-30T09:32:45Z.


Merged into main as daea4d76 (squashed and credited to you), thanks! The before-and-after game runs (five crashes, then six runs without one, plus @3kynox's run) are what decided it.

On the squashed result, d3d12's unit tests pass under Wine except the three scene_publication tests, which need a hardware device there; you ran those on both cards. Clippy and formatting are clean.

This overlaps #406, which will need to rebase onto it.

<!-- greyfinch-sync:brcly/TuxBox:comment:7274354107 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/566#issuecomment-7274354107). Originally posted by [brcly](https://github.com/brcly) on 2026-11-30T09:32:45Z. --- Merged into main as daea4d76 (squashed and credited to you), thanks! The before-and-after game runs (five crashes, then six runs without one, plus @3kynox's run) are what decided it. On the squashed result, d3d12's unit tests pass under Wine except the three `scene_publication` tests, which need a hardware device there; you ran those on both cards. Clippy and formatting are clean. This overlaps #406, which will need to rebase onto it.

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!566
No description provided.