Repository navigation
GPU: size the view heap clamp from what the host takes (NVIDIA 1,000,000 cap) - #1777
antoinerz1 wants to merge 5 commits into
Conversation
35a9319 to
3635e70
Compare
VIctory V2: community PRs, merged and testedOpen PRs sitting in the queue? V2 pulls them into one build, screens each one (binaries, build scripts, hooks, new deps) and runs tests after every batch. Where it stands today: launches, runs the menu at 30 fps, plays the intro video, reaches the start screen and loads the world (~50 s). Entering the world is the current blocker: rendering fails with a GPU "device removed" error (tracked in issue #1). Not playable yet, but every batch of merged fixes moves it closer. If you have a PR that's stuck, or a GPU to test on, I'd love your help: Unofficial community fork of Marvisak/VIctory, GPL-3.0. |
DenRakEiw
left a comment
There was a problem hiding this comment.
Verified locally merged onto origin/main (70564ae, Windows 11 x64, NVIDIA GeForce RTX 5090 + WARP, Rust 1.98.1 MSVC):
cargo test -p victory-gpu— 79 passed, 0 failed (1 ignored) on both RTX 5090 hardware andVICTORY_D3D12_WARP=1(includinga_capped_view_heap_keeps_the_null_buffer_views— directly resolves the 2 NVIDIAHEAP_VIEWStest failures onorigin/main70564ae!)cargo clippy -p victory-gpu -p victory-shader --all-targets— 0 warningscargo xtask policy— ok
Great fix dynamically sizing the view heap clamp from what the host adapter supports while preserving the null buffer views and shader cache keys. Confirmed green on NVIDIA RTX 5090.
AI-assisted (Gemini 4 Neon).
|
Overlap for the reviewers: two other open PRs change the same capped-heap path (NVIDIA's 1,000,000-descriptor cap, #1744).
This PR edits the same AI-assisted (Claude Code). |
catminou4
left a comment
There was a problem hiding this comment.
Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff.
View-heap clamp sized from what the host actually takes (NVIDIA 1,000,000-descriptor cap): 21K diff across gpu+shader. The clamp must never reject a title that worked before — worth a Windows run on a title with large descriptor tables.
|
AMD test report for this PR (the PR body asks for an AMD run). Hardware: AMD Radeon RX 9070 XT (device id 0x7550), driver 32.0.32015.16001; Windows 11 build 26300; Rust 1.98.1 MSVC. Branch tested: Command: Result: 288 passed, 0 failed, 3 ignored (victory-shader 209 passed / 2 ignored; victory-gpu 79 passed / 1 ignored). In particular, the new No regressions seen on AMD, and no game files were used. This is a test-only confirmation; I have not run the title. |
|
I found a boundary case on an RTX 5080 (621.14) at
The first row also skips creation of both null descriptors. I checked the allocation and mapped stride table directly. Follow-up commit with the fix and a two-threshold regression. It reserves the final three slots for either successful dynamic allocation size. All ten requests then gave a limit of 999,997 and strides of |
|
Tested on Ampere: RTX 3060 Ti, driver 617.42, Windows 11 (build 26300), Rust 1.98.1.
Same numbers as your RTX 4060 Ti run. The two that remain fail exactly as you describe:
So this isn't specific to Ada: Ampere behaves the same. Unit tests only, not tested in title. |
|
Automated triage for the maintainers. Merge candidate. The head is rebased and now merges cleanly. It addresses the open point from the previous review: Overlap: #1779 changes the same clamp and no longer merges cleanly. #1751 only widens the dynamic range in Generated by Claude Code |
The RTX 4060 Laptop accepts a million plus one slots but refuses the larger shader-visible heap. Use the full descriptor indexing range to select the existing heap map before the first translation. Related to Marvisak#1777.
The RTX 4060 Laptop accepts a million plus one slots but refuses the larger shader-visible heap. Use the full descriptor indexing range to select the existing heap map before the first translation. Related to Marvisak#1777.
318b877 to
bd76752
Compare
|
Rebased onto current RTX 4060 Ti: |
`emit::heap_views()` probed a device itself, in every process that translates: offline `victory translate` and the shader tests under `VICTORY_WARP=1` opened the default hardware adapter, and the clamp followed that adapter rather than the one the host draws on (r4tedx, tigre437 on Marvisak#1777). - `victory_shader::emit::set_heap_views` takes the size from the host; `heap_views()` is that, else 2^21 as before this PR. The translator probes nothing outside its own tests, whose probe follows the test host (WARP with `VICTORY_WARP=1`). `heap_views_on_warp` goes. - `victory_gpu::host::heap_views()` decides once, from the adapter the host device is made on (WARP under `VICTORY_D3D12_WARP`, else the default one), and tells the translator before any translation: the shader cache key, `host_shader` (with or without a cache), the pipeline library tag and the descriptor heaps all ask there. The cache warm-up (`victory translate --cache`) goes through it too, so its entries carry the host's key. - A translation made before the size was known with a larger clamp than the host takes is logged. RTX 4060 Ti: `cargo test --workspace` 778 passed, 2 failed (the two known NVIDIA-only shader tests), 9 ignored, with the access-violating `heap_direct_texture_reads_mark_their_heap_index` skipped (it crashes on `main` too). `VICTORY_WARP=1` stride tests: 8/8. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Follow-up for the open point from r4tedx and tigre437 (a61059f): the translator no longer probes a device. RTX 4060 Ti: |
…000 cap) Translated shaders clamped view heap indices below a fixed 2^21 and read the null buffer views at 2^21 - 2, but NVIDIA refuses shader-visible view heaps over 1,000,000 descriptors. On NVIDIA the clamp let indices past the heap through and the null buffer views were never made (Marvisak#1627, Marvisak#1620; 4 of the 5 test failures in Marvisak#1744). - `victory_shader::emit::heap_views()` replaces `HEAP_VIEWS`: 2^21 (`HEAP_VIEWS_MAX`) where the default adapter makes a heap that large, else 1,000,000 (`HEAP_VIEWS_PORTABLE`); `null_buffer_view()` follows it. - Host view heaps are at least `heap_views()` slots. A capped heap keeps the dynamic slots and the null buffer views below the clamped index, leaving out the title's slots past them, as before. - The shader cache key and the pipeline library tag include the value, so translations made for one heap size are not served on another. - New test: a capped view heap keeps the null buffer views. On an RTX 4060 Ti (driver 610.88): 475 passed, 2 failed, 7 ignored (was 471/5/7). The 2 left are NVIDIA-only and unrelated to the cap: the raw-annotated read of a structured view (a_heap_buffer_read_by_element_takes_the_views_stride) and the gather footprint (gathers_at_a_level_match_the_hardware). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… adapter
`heap_views()` asked the default adapter whether it takes a 2^21-slot view
heap. With the diagnostics build's `VICTORY_D3D12_WARP=1` on an NVIDIA
machine, the host device is WARP (whose heap holds all 1,245,184 title
slots) while the clamp came from NVIDIA's 1,000,000: shaders could not
reach title slots past 1,000,000, and the null buffer views fell among the
title's ("no room for the null buffer views" in the log).
- `takes_view_heap` probes WARP when told to.
- `victory_shader::emit::heap_views_on_warp()` tells it, before the size is
fixed; victory-gpu's `host::on_warp()` decides once and calls it from the
shader cache key and the device creation.
Checked on an RTX 4060 Ti with the title: the WARP run no longer caps the
clamp or warns about the null buffer views; the hardware run still caps it
at 1,000,000. `cargo test -p victory-gpu -p victory-shader --lib`: same
results as before (2 known NVIDIA-only failures, Marvisak#1744).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A heap of exactly `heap_views()` slots could hold title and dynamic slots up to its end: with 737,854 to 737,856 or 934,462 to 934,464 title slots on NVIDIA's 1,000,000 cap, `count + DYNAMIC` (or `MIN_DYNAMIC`) fits the heap but ends among the three slots kept for the null UAV, the null SRV and the clamped index, so neither null buffer view was made and their stride entries stayed 0. Such a heap now trims its title and dynamic range below them, keeping at least `MIN_DYNAMIC` dynamic slots. Reported, with the fix this follows, by AlanQiang0418 on an RTX 5080. New test: for both dynamic ranges, titles ending 0 to 3 slots short of the heap end leave strides [4, 4, 0] in the last three slots (fails without the fix on an RTX 4060 Ti). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`emit::heap_views()` probed a device itself, in every process that translates: offline `victory translate` and the shader tests under `VICTORY_WARP=1` opened the default hardware adapter, and the clamp followed that adapter rather than the one the host draws on (r4tedx, tigre437 on Marvisak#1777). - `victory_shader::emit::set_heap_views` takes the size from the host; `heap_views()` is that, else 2^21 as before this PR. The translator probes nothing outside its own tests, whose probe follows the test host (WARP with `VICTORY_WARP=1`). `heap_views_on_warp` goes. - `victory_gpu::host::heap_views()` decides once, from the adapter the host device is made on (WARP under `VICTORY_D3D12_WARP`, else the default one), and tells the translator before any translation: the shader cache key, `host_shader` (with or without a cache), the pipeline library tag and the descriptor heaps all ask there. The cache warm-up (`victory translate --cache`) goes through it too, so its entries carry the host's key. - A translation made before the size was known with a larger clamp than the host takes is logged. RTX 4060 Ti: `cargo test --workspace` 778 passed, 2 failed (the two known NVIDIA-only shader tests), 9 ignored, with the access-violating `heap_direct_texture_reads_mark_their_heap_index` skipped (it crashes on `main` too). `VICTORY_WARP=1` stride tests: 8/8. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
a61059f to
cbb9d78
Compare
|
Tested in title on Ada: RTX 4070 SUPER (12 GB), driver 617.42 (32.0.16.1742), Windows 11 26300, Ryzen 7 5700X3D, 32 GB RAM, Rust 1.98.1. Series 1.0.2.1 ( Unit tests.
The two fixed are In title it does not stop the world hang on this card. Each build with its own fresh
With this branch the log says Everything queued after it had not started. On AI-assisted (Claude Code); the runs are mine. |
LuvAbyss
left a comment
There was a problem hiding this comment.
Tested on Ampere: RTX 3080 (10 GB), driver 621.35, Windows 11 26300, Rust 1.98.1. Branch cbb9d78 merged locally onto current main (63bcca4); the merge is clean and builds.
Tests, cargo test --release --workspace --no-fail-fast:
| passed | failed | ignored | |
|---|---|---|---|
main (63bcca4) |
567 | 3 | 7 |
this branch on main |
570 | 2 | 7 |
dynamic_slots_are_held_until_released and lists_share_a_table_and_copies_keep_their_views pass; both new tests pass. victory-gpu --lib alone: 229/2 on main, 233/0 here, twice each. The remaining failures are the same on both sides and unrelated: victory-shader dies in heap_direct_texture_reads_mark_their_heap_index (#2571), and xtask's policy test caught a stray local file of mine.
One flake to note: shadow::tests::marked_pages_go_back_by_the_bytes_the_gpu_changed failed once in the full workspace run on this branch. It passed 3/3 alone and in two full victory-gpu runs, so I read it as contention, not this change.
Read through the change. Points I checked:
- The probe and the host device use the same adapter (
D3D12CreateDevice(None, …), or WARP in both), so a hybrid laptop can't size the clamp from the wrong GPU. - Every translation that feeds
runor the cache goes throughshader_cache::host_shader, which fixesheap_views()before translating. So theOnceLockcan't be set to 2^21 by an earlier translation in those paths. - The trimming for a heap of exactly
viewsslots:extra.min(end - count)keepscount + extra <= null - 1, so the null UAV, the null SRV and the clamped slot are always free. - The read-mark bitmap stays sized to
HEAP_VIEWS_MAX, which covers every index either clamp lets through.
Minor, not a regression: victory translate without --cache (the validator) calls emit::emit_with directly and never asks victory_gpu::host::heap_views(). On NVIDIA it still translates with 2^21, and from reading the code its validation Host would then ask for a 2^21 heap where a shader has View::NullBuffers (I didn't run that path). It was the same before this PR; it could call set_heap_views up front in a follow-up.
In title (Series 1.0.2.1, b99f876b74d4a77f; fresh translate --cache --pipelines on this branch, 17 min, 23,128 pipelines made): the size is detected (the host caps view heaps: shader heap indices clamped below it views=1000000), but the run ends after about 35 s, in the loading screens, exactly as #1808 reports:
title slot past the host heap index=1171238 count=934461 for_draw=false
... (943 of these, through index=1172180, one line each)
VIctory: unhandled exception 0xc0000005 at victory-image-b99f876b74d4a77f.dll+0x258b000 (write 0x0: nothing mapped there)
#1 victory-image-b99f876b74d4a77f.dll+0x2215c35
#2 victory-image-b99f876b74d4a77f.dll+0x2215eca
Memory wasn't the limit (the title's own crash report: 16 GB physical and 11.8 GB of paging file free). So on Ampere this PR makes the shaders' clamp and null views correct, but the title still writes its descriptors at about 1.17M, past the 934,461 slots kept, and the +0x258b000 null write remains. That needs the remapping the shortcut: comment mentions (or whatever #1763 does that made it go away on the 4090 in #1808). I'd describe this PR as fixing the tests and the shader side of #1808, not the crash.
fuzeofficlal
left a comment
There was a problem hiding this comment.
Tested merged onto origin/main (63bcca43) on an RTX 5090 (NVIDIA 1,000,000 shader-visible view heap cap) and on WARP (VICTORY_D3D12_WARP=1, 2,097,152 uncapped) with VICTORY_D3D12_DEBUG=1 and the SDK dxil.dll.
Blocking issue: host::create() latches victory_shader::emit::HEAP_VIEWS to 2_097_152 before host::heap_views() runs
Whenever victory_gpu::host::host() runs before crate::host::heap_views() (or shader_cache::use_shader_cache()), create() executes:
crates/victory-gpu/src/host.rs:242:victory_shader::emit::host::Host::from_device(device.clone()).fuses_fmad()crates/victory-shader/src/emit/host.rs:639->fmad_probe()(emit/host.rs:772) lowers a synthetic compute shader with a descriptor-table UAV, which callsShader::handle_from_heap(emit/shader.rs:584) ->victory_shader::emit::heap_views()(emit/shader.rs:52).- Because
victory-shaderis compiled without#[cfg(test)]when linked intovictory-gpu,victory_shader::emit::heap_views()permanently initializes itsOnceLocktoHEAP_VIEWS_MAX(2_097_152). - When
crate::host::heap_views()(crates/victory-gpu/src/host.rs:302-323) later probes the NVIDIA adapter (takes = 1_000_000),victory_shader::emit::set_heap_views(1_000_000)(host.rs:311) returns the already-latched2_097_152, andcrate::host::heap_views()caches2_097_152for the rest of the process. - In
HostHeap::new()(crates/victory-gpu/src/descriptor/host.rs:152-172), bothmake((count + DYNAMIC).max(views))andmake((count + MIN_DYNAMIC).max(views))then request2_097_152descriptors and fail on NVIDIA, while the cap branch atdescriptor/host.rs:161(count + MIN_DYNAMIC + 3 > views) isfalsefor every normal heap withcount <= 2_031_613, causingHostHeap::new()to returnNone.
Repro on RTX 5090 (masked on WARP because WARP accepts 2_097_152, and masked in victory run only because apps/victory/src/run.rs:80 happens to call use_shader_cache() first):
cargo test -p victory-gpu --lib bindless::tests::heap_views_are_currentfails 100% deterministically (panicked at crates�ictory-gpu\src�indless.rs:668:43: a host view heap), withtakes = 1_000_000vs latchedviews = 2_097_152.cargo test -p victory-gpu --lib -- --test-threads=1fails 20/233 tests (bindless::,descriptor::host::,descriptor::,draw::,host::) with the samea host view heapfailure.- Default parallel
cargo test -p victory-gpu --libis racy on NVIDIA (failed 20/233 wheneverhost::create()beat a test that calledhost::heap_views()directly).
Suggested fix:
Initialize heap_views in host::create() before the fuses_fmad() probe at crates/victory-gpu/src/host.rs:242 (ideally probing the already-created &device so create() does not need a second D3D12CreateDevice call). Verified locally on RTX 5090 that calling heap_views() right before fuses_fmad() flips bindless::tests::heap_views_are_current to passing and brings cargo test -p victory-gpu --lib -- --test-threads=1 from 20 failures to 233/233 passed.
What verified cleanly
- Clean merge onto
origin/main(63bcca43); mergedcrates/victory-shader/src/emit/lower.rsis520,567 B(3,721 Bunder the 512 KiB limit). cargo run -p xtask -- policy(191 files ok) andclippy(default and--all-features) pass cleanly.- On RTX 5090,
victory-shaderemit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zerosflips from failing (E_INVALIDARGonorigin/main) to passing (7/8stride_testspass on RTX 5090, leaving only the pre-existing NVIDIA structured-SRV failure ina_heap_buffer_read_by_element_takes_the_views_stride;8/8pass on WARP). - When
heap_views()initializes beforefuses_fmad(), all new boundary and cache-key tests (a_capped_view_heap_keeps_the_null_buffer_views,a_range_ending_at_the_heap_end_keeps_the_null_buffer_views,dynamic_slots_are_held_until_released,lists_share_a_table_and_copies_keep_their_views,shader_cache::,pipeline::library::) pass (47/47) on both RTX 5090 (1M cap) and WARP (2M uncapped) underVICTORY_D3D12_DEBUG=1, and the full WARP suite passes (248/248). - Note for maintainers: this PR coordinates shader clamping, null buffer views, and shader/pipeline cache keys with the host cap, going further than
#1751/#2461and superseding#1779.
`create()` checks whether the host fuses multiply-adds by translating a
shader (`fuses_fmad`). That translation asked
`victory_shader::emit::heap_views()` first, which fixed the translator's
clamp at `HEAP_VIEWS_MAX`; `host::heap_views()` then took that value, so
on NVIDIA every view heap asked for 2^21 slots and `HostHeap::new`
failed ("a host view heap"). `victory run` hid it by opening the shader
cache first; the GPU tests did not (20 of 233 failed run one at a time,
some in parallel). Reported by fuzeofficlal on an RTX 5090.
`create()` now fixes the size before the probe, asking the device it
just made instead of creating a second one.
RTX 4060 Ti: `cargo test -p victory-gpu --lib -- --test-threads=1`
233 passed (was 213 / 20 failed); in parallel 233 passed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@fuzeofficlal thanks, confirmed on an RTX 4060 Ti: |
Problem
Translated shaders clamp view heap indices below a fixed
HEAP_VIEWS = 1 << 21(2,097,152) and read the null buffer views atHEAP_VIEWS - 2. NVIDIA refuses shader-visible CBV/SRV/UAV heaps over 1,000,000 descriptors. So on NVIDIA:This is the in-title failure in #1627 and #1620. It also accounts for 4 of the 5 unit-test failures in #1744.
Change
victory_shader::emit::heap_views()replaces theHEAP_VIEWSconstant. It is 2^21 (HEAP_VIEWS_MAX) where the default adapter creates a heap that large, else 1,000,000 (HEAP_VIEWS_PORTABLE). The value is fixed for the process at first use.null_buffer_view()follows it.heap_views()slots. A capped heap keeps the dynamic slots and the null buffer views below the clamped index. As before, the title's slots past them are left out.a_capped_view_heap_keeps_the_null_buffer_views.AMD and other hosts that take a 2^21 heap get the same translation and layout as before. Only their cache key changes, so their cached shaders are translated once more.
Testing
RTX 4060 Ti, driver 610.88, Windows 11, Rust 1.98.1.
cargo test --workspace --no-fail-fast:main(70564ae)Now passing:
dynamic_slots_are_held_until_released,lists_share_a_table_and_copies_keep_their_views,a_heap_buffer_read_where_no_buffer_view_is_reads_zeros, plus the new test.Two failures remain. Both are NVIDIA-only and unrelated to the cap:
a_heap_buffer_read_by_element_takes_the_views_stride: Test report: RTX 5070 (Blackwell), Windows 11, 70564ae: 471 passed, 5 failed, 7 ignored (4 from the 1,000,000 view heap cap) #1744 attributed this one to the cap by elimination, but it still fails with the cap fixed. The shader reads a structured SRV (stride 12) through a raw-annotated handle (kind 11), which D3D12 leaves undefined. NVIDIA returns elementbyte_address / 4(got101 + 3l).gathers_at_a_level_match_the_hardware: the gather footprint rounds differently on this GPU.Clippy is clean.
cargo fmt --checkalready fails onmainin files this PR does not touch; the changed lines are formatted. Not tested in title: no game run, and no AMD run on my side.🤖 Generated with Claude Code