Descriptors: clamp view indices past a capped host heap to a null slot #1133

Open
rivaldodev wants to merge 1 commit from upstream-pr/1133 into main
rivaldodev commented 2026-11-24 16:05:53 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by rivaldodev on 2026-11-24T16:05:53Z.


Detects hosts whose shader-visible view heaps are capped below the title's view heap size (1,245,184 slots — NVIDIA caps shader-visible view heaps at 1,000,000 slots, measured on RTX 4070 Ti SUPER / RTX 5060 / RTX 5070) and clamps translated view handle indices to a reserved null slot at the end of the capped heap. Hosts without a cap (e.g. AMD) translate as before.

What is in this PR

  • crates/victory-gpu/src/descriptor/host.rs: probes the host view heap cap (view_heap_cap), sizes small heaps to cover the same translated index range, and keeps the last capped slot null across title slots, dynamic slots, and copy-back view pairs (including dynamic ranges ending right at the cap).
  • crates/victory-gpu/src/host.rs: records the detected host cap via victory_shader::emit::set_view_heap_limit.
  • crates/victory-shader/src/emit/{mod.rs,bitcode.rs,shader.rs}: uses the smaller host cap for view handle clamps while leaving sampler and uncapped-host bounds intact.
  • crates/victory-gpu/src/shader_cache.rs: includes the host view heap cap in the shader cache fingerprint.
    • Note on side effect: shader_cache::build() (and therefore use_shader_cache) now initializes the host device (crate::host::host()) on first call if it does not exist yet, so the host's view heap cap is known before the cache key is fixed (e.g. in victory translate --cache). This is documented in shader_cache.rs.

Tests

  • victory-gpu: 144 passed, 0 failed (including a_capped_view_heap_keeps_its_last_slot_null, dynamic_slots_are_held_until_released, lists_share_a_table_and_copies_keep_their_views, and the_key_covers_translator_encoding_and_settings).
  • victory-shader: tests check emitted DXIL handle indices at and beyond both heap bounds.

Split from the original combined PR per triage feedback; the narrow-wave barrier change has been moved to a separate PR.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6586076842 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1133). Originally posted by [rivaldodev](https://github.com/rivaldodev) on 2026-11-24T16:05:53Z. --- Detects hosts whose shader-visible view heaps are capped below the title's view heap size (1,245,184 slots — NVIDIA caps shader-visible view heaps at 1,000,000 slots, measured on RTX 4070 Ti SUPER / RTX 5060 / RTX 5070) and clamps translated view handle indices to a reserved null slot at the end of the capped heap. Hosts without a cap (e.g. AMD) translate as before. ### What is in this PR - `crates/victory-gpu/src/descriptor/host.rs`: probes the host view heap cap (`view_heap_cap`), sizes small heaps to cover the same translated index range, and keeps the last capped slot null across title slots, dynamic slots, and copy-back view pairs (including dynamic ranges ending right at the cap). - `crates/victory-gpu/src/host.rs`: records the detected host cap via `victory_shader::emit::set_view_heap_limit`. - `crates/victory-shader/src/emit/{mod.rs,bitcode.rs,shader.rs}`: uses the smaller host cap for view handle clamps while leaving sampler and uncapped-host bounds intact. - `crates/victory-gpu/src/shader_cache.rs`: includes the host view heap cap in the shader cache fingerprint. - **Note on side effect:** `shader_cache::build()` (and therefore `use_shader_cache`) now initializes the host device (`crate::host::host()`) on first call if it does not exist yet, so the host's view heap cap is known before the cache key is fixed (e.g. in `victory translate --cache`). This is documented in `shader_cache.rs`. ### Tests - `victory-gpu`: `144 passed, 0 failed` (including `a_capped_view_heap_keeps_its_last_slot_null`, `dynamic_slots_are_held_until_released`, `lists_share_a_table_and_copies_keep_their_views`, and `the_key_covers_translator_encoding_and_settings`). - `victory-shader`: tests check emitted DXIL handle indices at and beyond both heap bounds. --- *Split from the original combined PR per triage feedback; the narrow-wave barrier change has been moved to a separate PR.*
copilot-pull-request-reviewer[bot commented 2026-11-24 17:03:25 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by copilot-pull-request-reviewer[bot] on 2026-11-24T16:06:08Z.

Review: COMMENTED


Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

<!-- greyfinch-sync:Marvisak/VIctory:review:6042888545 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1133#pullrequestreview-6042888545). Originally posted by [copilot-pull-request-reviewer[bot]](https://github.com/copilot-pull-request-reviewer%5Bbot%5D) on 2026-11-24T16:06:08Z. **Review:** COMMENTED --- Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
DeerSilver commented 2026-11-24 18:05:57 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DeerSilver on 2026-11-24T17:48:05Z.


Tested head be0fe04 merged onto main ffe310e (clean merge) on NVIDIA GeForce RTX 5060 Laptop GPU (Blackwell), driver 621.24, Windows 11 26300, Rust 1.98.1. No game files: the test suite only. Pass.

  • The RTX 5060 caps shader-visible view heaps at 1,000,000 too, the same as your RTX 4070 Ti SUPER. With a temporary eprintln! in a_capped_view_heap_keeps_its_last_slot_null, view_heap_cap returned Some(1000000). So on Blackwell the test runs past its "the host takes larger heaps" early return and passes.
  • Both new tests pass:
    • a_capped_view_heap_keeps_its_last_slot_null
    • view_heap_indices_are_clamped_only_under_a_cap
  • cargo test --workspace --locked: 344 passed, 0 failed, 6 ignored, against 342 / 6 on main.
  • cargo clippy --workspace --all-targets --locked -- -D warnings: clean.

I can't check the in-world hang without the game.

AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7139723568 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1133#issuecomment-7139723568). Originally posted by [DeerSilver](https://github.com/DeerSilver) on 2026-11-24T17:48:05Z. --- Tested head `be0fe04` merged onto `main` `ffe310e` (clean merge) on **NVIDIA GeForce RTX 5060 Laptop GPU** (Blackwell), driver 621.24, Windows 11 26300, Rust 1.98.1. No game files: the test suite only. **Pass.** - **The RTX 5060 caps shader-visible view heaps at 1,000,000 too**, the same as your RTX 4070 Ti SUPER. With a temporary `eprintln!` in `a_capped_view_heap_keeps_its_last_slot_null`, `view_heap_cap` returned `Some(1000000)`. So on Blackwell the test runs past its "the host takes larger heaps" early return and passes. - Both new tests pass: - `a_capped_view_heap_keeps_its_last_slot_null` - `view_heap_indices_are_clamped_only_under_a_cap` - `cargo test --workspace --locked`: **344 passed, 0 failed, 6 ignored**, against 342 / 6 on `main`. - `cargo clippy --workspace --all-targets --locked -- -D warnings`: clean. I can't check the in-world hang without the game. AI-assisted (Claude Code).
Zipettte commented 2026-11-24 18:06:14 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Zipettte on 2026-11-24T18:01:30Z.


Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at be0fe04: cargo test -p victory-gpu -p victory-shader passes, 172 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed).

Tested with AI assistance (Claude).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7140046856 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1133#issuecomment-7140046856). Originally posted by [Zipettte](https://github.com/Zipettte) on 2026-11-24T18:01:30Z. --- Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at be0fe04: `cargo test -p victory-gpu -p victory-shader` passes, 172 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed). _Tested with AI assistance (Claude)._
Marvisak commented 2026-11-25 01:08:07 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T00:36:33Z.


Automated triage for the maintainers.

Proposed close: duplicate of a more complete open PR. It now merges cleanly into main. CI: check passing.

This PR detects a host that caps shader-visible view heaps at 1,000,000 (descriptor::host::view_heap_cap), records the cap in a new global (emit::set_view_heap_limit), clamps heap handles below it in Shader::heap_handle, and adds the cap to the shader-cache key. The open #1777, which also merges cleanly, fixes the same NVIDIA cap more completely. It also resizes the view-stride and view-mark tables and moves the null buffer views inside the capped heap (null_buffer_view). Here, NULL_BUFFER_VIEW stays at HEAP_VIEWS - 2, outside the capped heap, and write_stride/set_mark keep their HEAP_VIEWS bounds. This PR also makes shader_cache::build create the host device (crate::host::host()) as a side effect, so offline paths like victory translate --cache would open a D3D12 device.

If something here is missing from #1777, such as the DXIL handle-index test, a follow-up on top of #1777 would be welcome. This PR will be closed in 48 hours unless the author pushes a change or a maintainer removes the triage: proposed close label.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7148690281 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1133#issuecomment-7148690281). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T00:36:33Z. --- <!-- victory-triage v1 head=aeb7b105497443af62ce208bb8b81beedc5834c6 verdict=proposed-close at=2026-11-25T19:38:00Z --> Automated triage for the maintainers. **Proposed close: duplicate of a more complete open PR.** It now merges cleanly into `main`. CI: `check` passing. This PR detects a host that caps shader-visible view heaps at 1,000,000 (`descriptor::host::view_heap_cap`), records the cap in a new global (`emit::set_view_heap_limit`), clamps heap handles below it in `Shader::heap_handle`, and adds the cap to the shader-cache key. The open #1777, which also merges cleanly, fixes the same NVIDIA cap more completely. It also resizes the view-stride and view-mark tables and moves the null buffer views inside the capped heap (`null_buffer_view`). Here, `NULL_BUFFER_VIEW` stays at `HEAP_VIEWS - 2`, outside the capped heap, and `write_stride`/`set_mark` keep their `HEAP_VIEWS` bounds. This PR also makes `shader_cache::build` create the host device (`crate::host::host()`) as a side effect, so offline paths like `victory translate --cache` would open a D3D12 device. If something here is missing from #1777, such as the DXIL handle-index test, a follow-up on top of #1777 would be welcome. This PR will be closed in 48 hours unless the author pushes a change or a maintainer removes the `triage: proposed close` label. --- _Generated by [Claude Code](https://claude.ai/code)_
rivaldodev commented 2026-11-25 03:03:30 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by rivaldodev on 2026-11-25T02:28:43Z.


Rebased onto main (940d32f) and resolved the conflicts. Both CI Clippy configurations pass, along with the targeted regression tests. Four failures in the full test suite were also reproduced on unmodified main.

Ready for review.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7150774306 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1133#issuecomment-7150774306). Originally posted by [rivaldodev](https://github.com/rivaldodev) on 2026-11-25T02:28:43Z. --- Rebased onto main (940d32f) and resolved the conflicts. Both CI Clippy configurations pass, along with the targeted regression tests. Four failures in the full test suite were also reproduced on unmodified main. Ready for review.
welisonzika14-jpg commented 2026-11-25 03:03:43 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by welisonzika14-jpg on 2026-11-25T03:01:24Z.


RTX 5070 (Blackwell, driver 621.24), Ryzen 7 5700X, Windows 11, Rust 1.98.1 MSVC. No game files, unit tests only. Head 0d19c4c merged onto main 940d32f, cargo test -p victory-gpu -p victory-shader --lib --no-fail-fast.

victory-gpu victory-shader
main 141 ok, 2 fail 244 ok, 3 fail
this PR 144 ok, 0 fail 245 ok, 3 fail

The two view heap cap tests (dynamic_slots_are_held_until_released, lists_share_a_table_and_copies_keep_their_views) pass with it. The 3 victory-shader failures are the ones main already has on NVIDIA (#1744), so nothing new here.

Written with AI help (Claude/Kiro); the numbers are from runs on my machine.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7151512783 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1133#issuecomment-7151512783). Originally posted by [welisonzika14-jpg](https://github.com/welisonzika14-jpg) on 2026-11-25T03:01:24Z. --- RTX 5070 (Blackwell, driver 621.24), Ryzen 7 5700X, Windows 11, Rust 1.98.1 MSVC. No game files, unit tests only. Head `0d19c4c` merged onto `main` `940d32f`, `cargo test -p victory-gpu -p victory-shader --lib --no-fail-fast`. | | `victory-gpu` | `victory-shader` | |---|---|---| | `main` | 141 ok, 2 fail | 244 ok, 3 fail | | this PR | **144 ok, 0 fail** | 245 ok, 3 fail | The two view heap cap tests (`dynamic_slots_are_held_until_released`, `lists_share_a_table_and_copies_keep_their_views`) pass with it. The 3 `victory-shader` failures are the ones `main` already has on NVIDIA (#1744), so nothing new here. Written with AI help (Claude/Kiro); the numbers are from runs on my machine.
upstream-sync changed title from [PR #1133] Nvidia/heap cap and barriers to [PR #1133] Descriptors: clamp view indices past a capped host heap to a null slot 2026-11-25 04:04:59 +00:00
rivaldodev commented 2026-11-25 04:07:06 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by rivaldodev on 2026-11-25T03:50:04Z.


Split the two changes per triage feedback:

  • This PR now contains only the view heap cap change (\cae16e6), with the \shader_cache::build()\ side effect (initializing \crate::host::host()\ on first call so the host view heap cap is known before fixing the cache key) documented in \shader_cache.rs\ and the PR description.
  • The narrow-wave barrier change has been moved to a separate draft PR: #2035.

\ ictory-gpu\ lib tests pass (144 passed, 0 failed). Ready for re-review.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7152283712 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1133#issuecomment-7152283712). Originally posted by [rivaldodev](https://github.com/rivaldodev) on 2026-11-25T03:50:04Z. --- Split the two changes per triage feedback: - This PR now contains only the **view heap cap** change (\cae16e6\), with the \shader_cache::build()\ side effect (initializing \crate::host::host()\ on first call so the host view heap cap is known before fixing the cache key) documented in \shader_cache.rs\ and the PR description. - The **narrow-wave barrier** change has been moved to a separate draft PR: #2035. \ ictory-gpu\ lib tests pass (144 passed, 0 failed). Ready for re-review.
rivaldodev commented 2026-11-25 19:06:37 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by rivaldodev on 2026-11-25T18:50:51Z.


Rebased onto current main (13f91ca) and merged the mod tests block in crates/victory-shader/src/emit/shader.rs (aeb7b10).

  • cargo test -p victory-gpu --lib --locked: 196 passed, 0 failed, 1 ignored
  • cargo test -p victory-shader --lib --locked heap_handles_stay_inside_the_host_limits: passed
  • cargo clippy -p victory-gpu -p victory-shader --no-deps --all-targets --locked: clean on changed files.

Ready for re-triage.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7171484275 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1133#issuecomment-7171484275). Originally posted by [rivaldodev](https://github.com/rivaldodev) on 2026-11-25T18:50:51Z. --- Rebased onto current `main` (`13f91ca`) and merged the `mod tests` block in `crates/victory-shader/src/emit/shader.rs` (`aeb7b10`). - `cargo test -p victory-gpu --lib --locked`: **196 passed, 0 failed, 1 ignored** - `cargo test -p victory-shader --lib --locked heap_handles_stay_inside_the_host_limits`: **passed** - `cargo clippy -p victory-gpu -p victory-shader --no-deps --all-targets --locked`: clean on changed files. Ready for re-triage.
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/1133:upstream-pr/1133'
git switch 'upstream-pr/1133'

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/1133'
git switch 'upstream-pr/1133'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1133'
git switch 'upstream-pr/1133'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1133'
git switch 'main'
git merge --squash 'upstream-pr/1133'
git switch 'main'
git merge --ff-only 'upstream-pr/1133'
git switch 'main'
git merge 'upstream-pr/1133'
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
Marvisak/VIctory!1133
No description provided.