Uploads: reserve the ray tracing's address space at start (port of VIctory-NVIDIA; fixes Failed to allocate upload buffer) #189

Closed
github-bot wants to merge 0 commits from github-bot/gh-189 into main AGit
Owner

@⁠SleepyYui on GitHub · 2026-11-30 20:33 UTC · original
SleepyYui:fix/reserve-upload-space → main · +361 −43 · 6 files · 47 commits · closed without merging

What goes wrong

On an RTX 4090 PC (77.7 GB RAM, 157.7 GB commit limit, so not a page file limit), foxhound v0.8.2 ended twice as the world loaded:

title said: D3D12 XDXR Error:
title said: Failed to allocate upload buffer
VIctory: unhandled exception 0xe06d7363 at KERNELBASE.dll+0xc41ca (C++ .J = 0x80004005 thrown)
  #2  victory-image-<XboxBvhBuilder>.dll+0x210bc

The title's ray tracing (XboxBvhBuilder) asks for upload memory below 2^37. With the rest of the process allocating first, that window is already full by the first ray-traced frame. This looks like the crash in issue #9. The first of the two runs had no mods or host DLLs loaded.

VIctory-NVIDIA documented the same crash on RTX 4090/5080/5090 PCs and fixed it on 2026-11-27 by reserving that address space first thing. VIctory-NVIDIA never hit this crash on the same PC.

The change (a port of VIctory-NVIDIA's fix)

foxhound's crates/victory-gpu/src/upload.rs was VIctory-NVIDIA's version from before the fix, line for line, so this brings it up to date and adds the few call sites:

  • upload.rs: taken from VIctory-NVIDIA as it is now. Original commits by Yorivel and contributors:
    • 30b979ee and e69e39c5: a pool of address space reserved in [4 GiB, 2^37) at start, plus early pieces reserved when the host device is ready.
    • 0dd6ed89: allocation failures keep their reservations.
    • 0925efdf: ray-tracing scans stay inside their allocation.
    • be846d2a: the pool stays below the page directory's last entry.
  • memory.rs (30b979ee): after an arena that could not be made, no other is tried before the next frame, and its reservation is given back. Without this, a full address range made every builder dispatch search again under the lock.
  • host.rs: upload::reserve_early() once the host device is ready.
  • main.rs: victory_hle::reserve_upload_space() before anything else, re-exported through victory-gpu and victory-hle.
  • VICTORY_UPLOAD_SPACE=0 turns the pool off, as in VIctory-NVIDIA.

Testing

  • cargo test --release -p victory-gpu --lib -- upload:: memory::: 11 passed, including the_pool_is_reserved_in_the_window_and_handed_out_once and a_failed_commit_can_retry_the_same_reservation.
  • cargo clippy --locked --no-deps -p victory-gpu -p victory-hle -p victory --all-targets -- -D warnings: clean.
  • cargo xtask policy: 289 files ok. cargo build --release --locked -p victory builds.
**@⁠SleepyYui** on GitHub · 2026-11-30 20:33 UTC · [original](https://github.com/readmet3xt-lab/foxhound/pull/189) `SleepyYui:fix/reserve-upload-space` → `main` · +361 −43 · 6 files · 47 commits · closed without merging ## What goes wrong On an RTX 4090 PC (77.7 GB RAM, 157.7 GB commit limit, so not a page file limit), foxhound v0.8.2 ended twice as the world loaded: ``` title said: D3D12 XDXR Error: title said: Failed to allocate upload buffer VIctory: unhandled exception 0xe06d7363 at KERNELBASE.dll+0xc41ca (C++ .J = 0x80004005 thrown) #2 victory-image-<XboxBvhBuilder>.dll+0x210bc ``` The title's ray tracing (XboxBvhBuilder) asks for upload memory below 2^37. With the rest of the process allocating first, that window is already full by the first ray-traced frame. This looks like the crash in issue #9. The first of the two runs had no mods or host DLLs loaded. VIctory-NVIDIA documented the same crash on RTX 4090/5080/5090 PCs and fixed it on 2026-11-27 by reserving that address space first thing. VIctory-NVIDIA never hit this crash on the same PC. ## The change (a port of VIctory-NVIDIA's fix) foxhound's `crates/victory-gpu/src/upload.rs` was VIctory-NVIDIA's version from before the fix, line for line, so this brings it up to date and adds the few call sites: - **`upload.rs`**: taken from VIctory-NVIDIA as it is now. Original commits by Yorivel and contributors: - `30b979ee` and `e69e39c5`: a pool of address space reserved in [4 GiB, 2^37) at start, plus early pieces reserved when the host device is ready. - `0dd6ed89`: allocation failures keep their reservations. - `0925efdf`: ray-tracing scans stay inside their allocation. - `be846d2a`: the pool stays below the page directory's last entry. - **`memory.rs`** (`30b979ee`): after an arena that could not be made, no other is tried before the next frame, and its reservation is given back. Without this, a full address range made every builder dispatch search again under the lock. - **`host.rs`**: `upload::reserve_early()` once the host device is ready. - **`main.rs`**: `victory_hle::reserve_upload_space()` before anything else, re-exported through `victory-gpu` and `victory-hle`. - `VICTORY_UPLOAD_SPACE=0` turns the pool off, as in VIctory-NVIDIA. ## Testing - `cargo test --release -p victory-gpu --lib -- upload:: memory::`: 11 passed, including `the_pool_is_reserved_in_the_window_and_handed_out_once` and `a_failed_commit_can_retry_the_same_reservation`. - `cargo clippy --locked --no-deps -p victory-gpu -p victory-hle -p victory --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 289 files ok. `cargo build --release --locked -p victory` builds.
The title's ray tracing asks for upload memory below 2^37. With the rest of
the process allocating first, that window was full by the first ray-traced
frame on an RTX 4090 PC: the title threw "D3D12 XDXR Error: Failed to
allocate upload buffer" (C++ exception 0xE06D7363) from XboxBvhBuilder and
the run ended, once after ~70 minutes and once 6 minutes in (2026-11-30;
77.7 GB RAM, 157.7 GB commit limit, so not a page file limit).

Port of VIctory-NVIDIA's fix, which never hit this on the same PC:
- upload.rs as in VIctory-NVIDIA (30b979ee, e69e39c5, 0dd6ed89, 0925efdf,
  be846d2a, by Yorivel and contributors): a pool of address space reserved
  in [4 GiB, 2^37) first thing in main, early pieces reserved when the host
  device is ready, allocation failures that keep their reservations, scans
  kept inside their allocation, and the pool kept below the page
  directory's last entry. foxhound's upload.rs was VIctory-NVIDIA's from
  before 30b979ee, line for line.
- memory.rs (30b979ee): after an arena that could not be made, none is
  tried again before the next frame, and its reservation is given back.
- host.rs: upload::reserve_early once the device is ready.
- main.rs: victory_hle::reserve_upload_space before anything else.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-30 20:35:52 +00:00
github-bot closed this pull request 2026-12-01 01:10:18 +00:00
Author
Owner

@⁠readmet3xt-lab on GitHub · 2026-12-01 01:36 UTC · original

A note on why this shows as closed: GitHub closed every open pull request by itself when main's history was rewritten on 2026-12-01 (text-only changes; every commit hash changed), and they cannot be reopened. This is not a rejection.

Your change is in the batch being tested for the next release, carried over as one commit with you as its author. Nothing is needed from you now; the result will be posted here.

**@⁠readmet3xt-lab** on GitHub · 2026-12-01 01:36 UTC · [original](https://github.com/readmet3xt-lab/foxhound/pull/189#issuecomment-7297690206) A note on why this shows as closed: GitHub closed every open pull request by itself when main's history was rewritten on 2026-12-01 (text-only changes; every commit hash changed), and they cannot be reopened. This is not a rejection. Your change is in the batch being tested for the next release, carried over as one commit with you as its author. Nothing is needed from you now; the result will be posted here.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.