GPU: clamp every host view heap to a null slot, and key the shader cache by it #50

Open
Altorru wants to merge 1 commit from upstream-pr/50 into main
Altorru commented 2026-11-25 07:06:25 +00:00 (Migrated from github.com)
First-time contributor

Imported from Zettrox/ztrx. Originally posted by Altorru on 2026-11-25T06:07:57Z.


Ports the GPU half of fxceless/victory-fork@31714de; the patch applied cleanly to the current GPU code.

Why: a view index past a heap's end is undefined. NVIDIA hung on it (heap capped at 1,000,000 views), and AMD RDNA3 took a page fault and removed the device on entering the world: a compute program read view slot 16,777,088 of a 1,507,328-view heap.

What: probe_view_limit now picks a null slot at the end of every host view heap (2^21 views where the host takes them, else PORTABLE_VIEWS) and applies set_view_heap_limit from the first shader on. HostHeap::new sizes the heap to that slot, leaves descriptors past the limit reading null, and records the real size. The shader cache key now includes the limit (it differs by GPU), so a translation cached without the clamp is not served. Adds view_heap_limit() beside set_view_heap_limit.

Verification: cargo check -p victory-shader and cargo test -p victory-shader pass (170 tests). The GPU crate cannot be compiled on this macOS host (only aarch64-apple-darwin std is installed and the Rust download endpoint is unreachable; victory-gpu also has pre-existing macOS cfg errors), so Windows CI is the first build. Reviewed against the current HostHeap/probe_view_limit code: all referenced symbols exist and probe_view_limit is already called from pipeline.rs before translation.

<!-- greyfinch-sync:Zettrox/ztrx:issue:6598371678 --> Imported from [Zettrox/ztrx](https://github.com/Zettrox/ztrx/pull/50). Originally posted by [Altorru](https://github.com/Altorru) on 2026-11-25T06:07:57Z. --- Ports the GPU half of `fxceless/victory-fork@31714de`; the patch applied cleanly to the current GPU code. **Why:** a view index past a heap's end is undefined. NVIDIA hung on it (heap capped at 1,000,000 views), and AMD RDNA3 took a page fault and removed the device on entering the world: a compute program read view slot 16,777,088 of a 1,507,328-view heap. **What:** `probe_view_limit` now picks a null slot at the end of every host view heap (2^21 views where the host takes them, else PORTABLE_VIEWS) and applies `set_view_heap_limit` from the first shader on. `HostHeap::new` sizes the heap to that slot, leaves descriptors past the limit reading null, and records the real size. The shader cache key now includes the limit (it differs by GPU), so a translation cached without the clamp is not served. Adds `view_heap_limit()` beside `set_view_heap_limit`. **Verification:** `cargo check -p victory-shader` and `cargo test -p victory-shader` pass (170 tests). The GPU crate cannot be compiled on this macOS host (only `aarch64-apple-darwin` std is installed and the Rust download endpoint is unreachable; `victory-gpu` also has pre-existing macOS cfg errors), so Windows CI is the first build. Reviewed against the current `HostHeap`/`probe_view_limit` code: all referenced symbols exist and `probe_view_limit` is already called from `pipeline.rs` before translation.
ThomasHFWright commented 2026-11-25 09:08:57 +00:00 (Migrated from github.com)
Author
First-time contributor

Imported from Zettrox/ztrx. Originally posted by ThomasHFWright on 2026-11-25T08:40:33Z.


Tested the unmodified PR head 7a84f7d207c5a4d4e15374a11a3cb3e77b8931e5 on Linux/RTX 5090. The early clamp activates correctly, but this run still fails at world entry; no world geometry confirmed. Baseline/runtime comparison: https://github.com/Zettrox/ztrx/issues/62#issuecomment-7157043010

The probe change matters on this host: vkd3d accepts the old 1,000,001-view probe, but reports a maximum of 1,041,451 and rejects the subsequent 1,507,328-view heap. Here the new 2^21 probe is rejected and the 1,000,000-view/null-slot limit is established before the first shader translation. The startup log confirms that ordering.

Validation:

  • Offline, locked Rust 1.98.1 Windows MSVC release cross-build: PASS.
  • GPU/shader all-features test build and native repository policy: PASS.
  • GPU tests: 115 passed, 2 failed, 1 ignored. Shader tests: 209 passed, 1 failed, 2 ignored. Same three failures as the main/runtime baselines: a_mesh_pipeline_loads_from_the_library, a_rejected_blob_gives_an_empty_library, stub_pipeline_is_created. Tests ran separately on distro Wine 11.22 with native D3D12 DLLs, not under the full game launcher.

Game run: Ryzen 7 9800X3D, RTX 5090, NVIDIA 620.73.04, CachyOS Linux 7.3.6; GE-Proton11-14 host/umu 1.4.3 with the D3D12 pair from Proton Experimental experimental-11.0-20261112-x86_64. Loaded vkd3d 2576c0b4adfae4a verified. VK_NV_raw_access_chains disabled; otherwise plain release/default speed settings. Fresh prefix, cache and save data; offline network namespace and read-only game input.

Setup/legal screens worked, then the prologue title card. Kernel Xid 13/MMU fault recurred at 08:39:13 UTC on 2026-11-25. The app exited itself with code 5 after 558.11 seconds, before the 900-second bound. Three Wine thread-stack overflows and the same final title null-write exception (0xc0000005, offset 0x23cf683) remain. Four compute pipelines were refused, including 2cc4c197ee29e291; no mesh-pipeline refusal was logged. Last statistics were 0.6 fps, 2,028 draws/frame and 1,806 dropped without a pipeline (859 still compiling), plus 1,073 indirect drops. These are startup statistics, not gameplay performance.

Important limitation: same cgroup limits as the comparison runs (10 GiB high, 14 GiB max, 8 GiB swap). It reached the high threshold; peak swap was about 7.4 GiB and minimum host available memory about 1.5 GiB. No cgroup OOM or kill occurred, but memory pressure is still a confounder. This single run validates the probe/clamp behavior, not a general verdict on crash prevention. No other PRs were combined; no game assets, generated shaders, raw logs or captures attached.

<!-- greyfinch-sync:Zettrox/ztrx:comment:7157331070 --> Imported from [Zettrox/ztrx](https://github.com/Zettrox/ztrx/pull/50#issuecomment-7157331070). Originally posted by [ThomasHFWright](https://github.com/ThomasHFWright) on 2026-11-25T08:40:33Z. --- Tested the unmodified PR head `7a84f7d207c5a4d4e15374a11a3cb3e77b8931e5` on Linux/RTX 5090. **The early clamp activates correctly, but this run still fails at world entry; no world geometry confirmed.** Baseline/runtime comparison: https://github.com/Zettrox/ztrx/issues/62#issuecomment-7157043010 The probe change matters on this host: vkd3d accepts the old 1,000,001-view probe, but reports a maximum of 1,041,451 and rejects the subsequent 1,507,328-view heap. Here the new 2^21 probe is rejected and the 1,000,000-view/null-slot limit is established before the first shader translation. The startup log confirms that ordering. Validation: - Offline, locked Rust 1.98.1 Windows MSVC release cross-build: PASS. - GPU/shader all-features test build and native repository policy: PASS. - GPU tests: 115 passed, 2 failed, 1 ignored. Shader tests: 209 passed, 1 failed, 2 ignored. Same three failures as the main/runtime baselines: `a_mesh_pipeline_loads_from_the_library`, `a_rejected_blob_gives_an_empty_library`, `stub_pipeline_is_created`. Tests ran separately on distro Wine 11.22 with native D3D12 DLLs, not under the full game launcher. Game run: Ryzen 7 9800X3D, RTX 5090, NVIDIA 620.73.04, CachyOS Linux 7.3.6; GE-Proton11-14 host/umu 1.4.3 with the D3D12 pair from Proton Experimental `experimental-11.0-20261112-x86_64`. Loaded vkd3d `2576c0b4adfae4a` verified. `VK_NV_raw_access_chains` disabled; otherwise plain release/default speed settings. Fresh prefix, cache and save data; offline network namespace and read-only game input. Setup/legal screens worked, then the prologue title card. Kernel Xid 13/MMU fault recurred at 08:39:13 UTC on 2026-11-25. The app exited itself with code 5 after 558.11 seconds, before the 900-second bound. Three Wine thread-stack overflows and the same final title null-write exception (`0xc0000005`, offset `0x23cf683`) remain. Four compute pipelines were refused, including `2cc4c197ee29e291`; no mesh-pipeline refusal was logged. Last statistics were 0.6 fps, 2,028 draws/frame and 1,806 dropped without a pipeline (859 still compiling), plus 1,073 indirect drops. These are startup statistics, not gameplay performance. Important limitation: same cgroup limits as the comparison runs (10 GiB high, 14 GiB max, 8 GiB swap). It reached the high threshold; peak swap was about 7.4 GiB and minimum host available memory about 1.5 GiB. No cgroup OOM or kill occurred, but memory pressure is still a confounder. This single run validates the probe/clamp behavior, not a general verdict on crash prevention. No other PRs were combined; no game assets, generated shaders, raw logs or captures attached.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/50:upstream-pr/50'
git switch 'upstream-pr/50'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/50'
git switch 'upstream-pr/50'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/50'
git switch 'upstream-pr/50'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/50'
git switch 'main'
git merge --squash 'upstream-pr/50'
git switch 'main'
git merge --ff-only 'upstream-pr/50'
git switch 'main'
git merge 'upstream-pr/50'
git push origin 'main'
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
Zettrox/ztrx!50
No description provided.