Skip to content

GPU: size the view heap clamp from what the host takes (NVIDIA 1,000,000 cap) - #1777

Open
antoinerz1 wants to merge 5 commits into
Marvisak:mainfrom
antoinerz1:fix/nvidia-view-heap-cap
Open

antoinerz1 wants to merge 5 commits into
Marvisak:mainfrom
antoinerz1:fix/nvidia-view-heap-cap

Conversation

@antoinerz1

Copy link
Copy Markdown

Problem

Translated shaders clamp view heap indices below a fixed HEAP_VIEWS = 1 << 21 (2,097,152) and read the null buffer views at HEAP_VIEWS - 2. NVIDIA refuses shader-visible CBV/SRV/UAV heaps over 1,000,000 descriptors. So on NVIDIA:

  • the host heap falls back to a smaller size, and the clamp lets indices past its end through, which faults the device;
  • the null buffer views at 2,097,150 are never made ("no room for the null buffer views").

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 the HEAP_VIEWS constant. 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.
  • Host view heaps always have at least 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.
  • The shader cache key and the pipeline library tag include the value, so a translation made for one heap size is never served on another.
  • New test 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:

passed failed ignored
main (70564ae) 471 5 7
this branch 475 2 7

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:

Clippy is clean. cargo fmt --check already fails on main in 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

@antoinerz1
antoinerz1 force-pushed the fix/nvidia-view-heap-cap branch from 35a9319 to 3635e70 Compare November 24, 2026 22:23
@DesertGamer

Copy link
Copy Markdown

VIctory V2: community PRs, merged and tested

Open 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).

⚠️ Entering the world on a real GPU can hang it and make Windows reset the driver. Try it at your own risk.

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:
https://DesertGamer/VIctory-V2

Unofficial community fork of Marvisak/VIctory, GPL-3.0.

@DenRakEiw DenRakEiw left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 and VICTORY_D3D12_WARP=1 (including a_capped_view_heap_keeps_the_null_buffer_views — directly resolves the 2 NVIDIA HEAP_VIEWS test failures on origin/main 70564ae!)
  • cargo clippy -p victory-gpu -p victory-shader --all-targets — 0 warnings
  • cargo 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).

@upipibi

upipibi commented Nov 24, 2026

Copy link
Copy Markdown

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 emit/shader.rs / shader_cache.rs clamp as #1779. From reading the file lists and descriptions; nothing built here.

AI-assisted (Claude Code).

@catminou4 catminou4 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@tdogghockey

Copy link
Copy Markdown

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: pull/1777/head at 3635e704e7d7037bc97227d6a196258bb464c8ee.

Command:

cargo test -p victory-shader -p victory-gpu --lib --no-fail-fast -- --test-threads=1

Result: 288 passed, 0 failed, 3 ignored (victory-shader 209 passed / 2 ignored; victory-gpu 79 passed / 1 ignored).

In particular, the new descriptor::host::tests::a_capped_view_heap_keeps_the_null_buffer_views, 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, gathers_at_a_level_match_the_hardware, and a_heap_buffer_read_by_element_takes_the_views_stride all pass on this RDNA4 host.

No regressions seen on AMD, and no game files were used. This is a test-only confirmation; I have not run the title.

@AlanQiang0418

Copy link
Copy Markdown
Contributor

I found a boundary case on an RTX 5080 (621.14) at 3635e70. A view heap can successfully allocate all 1,000,000 slots while the title and dynamic ranges extend into the three slots reserved for the null UAV, null SRV and clamp index.

Title slots requested Pair allocation limit Final three stride entries
737,854–737,856 or 934,462–934,464 1,000,000 [0, 0, 0]
737,853, 737,857, 934,461 or 934,465 999,997 [4, 4, 0]

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 [4, 4, 0]. The victory-gpu library suite passed (80 passed, 1 ignored), as did the existing shader empty-slot readback test and GPU all-targets Clippy.

@tigre437

Copy link
Copy Markdown

Tested on Ampere: RTX 3060 Ti, driver 617.42, Windows 11 (build 26300), Rust 1.98.1. cargo test --workspace --locked --no-fail-fast:

passed failed ignored
main (70564ae) 471 5 7
this branch (3635e70) 475 2 7

Same numbers as your RTX 4060 Ti run. a_capped_view_heap_keeps_the_null_buffer_views passes, and so do dynamic_slots_are_held_until_released, lists_share_a_table_and_copies_keep_their_views and a_heap_buffer_read_where_no_buffer_view_is_reads_zeros. On main, that last one failed with "dispatch failed: the parameter is incorrect".

The two that remain fail exactly as you describe:

  • a_heap_buffer_read_by_element_takes_the_views_stride: got [101, 104, 107, …, 131, 0, …], expected [200, 201, …], which is 101 + 3l.
  • gathers_at_a_level_match_the_hardware: lane 0 got [0.0, 1.0, 0.0, 0.0], expected all zeros.

So this isn't specific to Ada: Ampere behaves the same. Unit tests only, not tested in title.

Marvisak commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

Automated triage for the maintainers.

Merge candidate. The head is rebased and now merges cleanly. It addresses the open point from the previous review: victory-shader no longer opens a device outside its own tests. victory_gpu::host::heap_views probes the adapter that create uses (WARP under VICTORY_D3D12_WARP, otherwise the default adapter) and passes the result to the translator with emit::set_heap_views. shader_cache::host_shader calls it before translating. If a translation ran first, it logs a warning. The shader-cache key and the pipeline-library tag both include the value. In HostHeap::new, a capped heap now has views slots with views - MIN_DYNAMIC - 3 title slots. A heap of exactly views slots keeps its last three for the null UAV, null SRV and clamped index, which covers AlanQiang0418's boundary case. The read-mark bitmaps in shadow.rs stay sized at HEAP_VIEWS_MAX, so they cover every clamped index. CI (check) passes on this head.

Overlap: #1779 changes the same clamp and no longer merges cleanly. #1751 only widens the dynamic range in descriptor/host.rs. This PR is the more complete of the three.


Generated by Claude Code

Xeltax pushed a commit to Xeltax/VIcky that referenced this pull request Nov 25, 2026
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.
Xeltax pushed a commit to Xeltax/VIcky that referenced this pull request Nov 25, 2026
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.
@antoinerz1

Copy link
Copy Markdown
Author

Rebased onto current main (bd76752) and added a fix for the boundary case AlanQiang0418 found: a heap of exactly heap_views() slots now trims the title and dynamic range below the last three slots, following their suggested approach (thanks!). New regression test a_range_ending_at_the_heap_end_keeps_the_null_buffer_views covers both dynamic ranges; it fails without the fix.

RTX 4060 Ti: victory-gpu lib 197 passed / 0 failed; victory-shader lib 267 passed / 2 failed (the two known NVIDIA-only ones, vs 3 on main). Note: memory_tests::heap_direct_texture_reads_mark_their_heap_index crashes with an access violation on this card on main too, so it is unrelated to this PR.

antoinerz1 added a commit to antoinerz1/VIctory that referenced this pull request Nov 25, 2026
`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>
@antoinerz1

Copy link
Copy Markdown
Author

Follow-up for the open point from r4tedx and tigre437 (a61059f): the translator no longer probes a device. victory-gpu decides the view heap size once, from the adapter its device is made on (WARP under VICTORY_D3D12_WARP, else the default one), and hands it to the translator with emit::set_heap_views before any translation; the shader cache key, host_shader, the pipeline library tag and the descriptor heaps all go through host::heap_views(). Without a host the translator uses 2^21 as before, and its own tests probe their test host's adapter (WARP with VICTORY_WARP=1). The cache warm-up (victory translate --cache) still asks the host's adapter, since its entries must carry the runtime's key; plain offline translation opens no device.

RTX 4060 Ti: cargo test --workspace 778 passed / 2 failed (the two known NVIDIA-only shader tests) / 9 ignored, with heap_direct_texture_reads_mark_their_heap_index skipped (crashes on main too); VICTORY_WARP=1 stride tests 8/8.

antoinerz1 and others added 4 commits November 25, 2026 23:54
…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>
@Luqueze

Luqueze commented Nov 26, 2026

Copy link
Copy Markdown

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 (b99f876b74d4a77f), Series X profile, default TdrDelay.

Unit tests. cargo test -p victory-gpu --lib:

passed failed
main (63bcca4) 229 2
this branch (cbb9d78) 233 0

The two fixed are dynamic_slots_are_held_until_released and lists_share_a_table_and_copies_keep_their_views. victory-shader still dies in heap_direct_texture_reads_mark_their_heap_index (#2571) on both, unrelated.

In title it does not stop the world hang on this card. Each build with its own fresh translate --cache --pipelines (same counts on both: 25,756 programs translated, 23,113 pipelines made, 397 refused by the host, so those are not about the heap).

Build Lasted End
main, release 5.9 min 0x887A0004 / 0x887A0006 after 28 lists, ~1.5 min of world at 0.1-0.3 fps first
main, diag, VICTORY_D3D12_DRED=1 3.9 min device removed after 28 lists
this branch, diag, VICTORY_D3D12_DRED=1 3.4 min device removed after 34 lists, 35 s after world loading started, before a world frame was reported

With this branch the log says the host caps view heaps: shader heap indices clamped below it views=1000000 and host view heap capped at 1000000 ... count=1245184 kept=934461, then still 310,723 title slot past the host heap. The last submission took 5,213 ms, and DRED stops at the same dispatch as on main:

a list stopped at command 143 of 146 (op 6), commands 142..145 between its barriers:
command 143 (op 6): dispatch 16x16x16 [compute 00167d58cc5a78d7]

Everything queued after it had not started. On main (run 2) it was command 8 of 11 of the same shader. So here the clamp keeps out-of-range indices away from the device, but 00167d58cc5a78d7 still runs past the TDR with the title's slots above 934,461 left out (the stall #1760 removed with P = 140, not tried here). This differs from the 35 min RTX 3050 result in #1760; one run per build, so I can't rule out run-to-run variance.

AI-assisted (Claude Code); the runs are mine.

@LuvAbyss LuvAbyss left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 run or the cache goes through shader_cache::host_shader, which fixes heap_views() before translating. So the OnceLock can't be set to 2^21 by an earlier translation in those paths.
  • The trimming for a heap of exactly views slots: extra.min(end - count) keeps count + 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 fuzeofficlal left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 calls Shader::handle_from_heap (emit/shader.rs:584) -> victory_shader::emit::heap_views() (emit/shader.rs:52).
  • Because victory-shader is compiled without #[cfg(test)] when linked into victory-gpu, victory_shader::emit::heap_views() permanently initializes its OnceLock to HEAP_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-latched 2_097_152, and crate::host::heap_views() caches 2_097_152 for the rest of the process.
  • In HostHeap::new() (crates/victory-gpu/src/descriptor/host.rs:152-172), both make((count + DYNAMIC).max(views)) and make((count + MIN_DYNAMIC).max(views)) then request 2_097_152 descriptors and fail on NVIDIA, while the cap branch at descriptor/host.rs:161 (count + MIN_DYNAMIC + 3 > views) is false for every normal heap with count <= 2_031_613, causing HostHeap::new() to return None.

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_current fails 100% deterministically (panicked at crates�ictory-gpu\src�indless.rs:668:43: a host view heap), with takes = 1_000_000 vs latched views = 2_097_152.
  • cargo test -p victory-gpu --lib -- --test-threads=1 fails 20/233 tests (bindless::, descriptor::host::, descriptor::, draw::, host::) with the same a host view heap failure.
  • Default parallel cargo test -p victory-gpu --lib is racy on NVIDIA (failed 20/233 whenever host::create() beat a test that called host::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); merged crates/victory-shader/src/emit/lower.rs is 520,567 B (3,721 B under the 512 KiB limit).
  • cargo run -p xtask -- policy (191 files ok) and clippy (default and --all-features) pass cleanly.
  • On RTX 5090, victory-shader emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros flips from failing (E_INVALIDARG on origin/main) to passing (7/8 stride_tests pass on RTX 5090, leaving only the pre-existing NVIDIA structured-SRV failure in a_heap_buffer_read_by_element_takes_the_views_stride; 8/8 pass on WARP).
  • When heap_views() initializes before fuses_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) under VICTORY_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/#2461 and 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>
@antoinerz1

Copy link
Copy Markdown
Author

@fuzeofficlal thanks, confirmed on an RTX 4060 Ti: cargo test -p victory-gpu --lib -- --test-threads=1 failed 20/233 with "a host view heap". Fixed in f2e48a9 as you suggested: create() now fixes the view heap size before the fuses_fmad() probe, asking the device it just made (no second device). Now 233/233 both one at a time and in parallel; the rest of the workspace (minus victory-shader, which this doesn't touch) 569 passed / 0 failed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.