GPU: bind a sampler heap of our own when the title binds none #1777

Merged
fiestorra merged 1 commit from upstream-pr/1778 into main 2026-11-25 21:51:27 +00:00
fiestorra commented 2026-11-24 22:23:19 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fiestorra on 2026-11-24T22:23:19Z.


A sampler heap of our own for the lists that have none: the id 1419 error in #1754

Every root signature this runtime builds declares both directly-indexed heap flags, unconditionally (crates/victory-gpu/src/pipeline/host.rs):

                Flags: input
                    | D3D12_ROOT_SIGNATURE_FLAG_CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED
                    | D3D12_ROOT_SIGNATURE_FLAG_SAMPLER_HEAP_DIRECTLY_INDEXED,

D3D12 requires a heap of each kind to be bound before such a signature is set. The debug layer states it as id 1419, and NVIDIA removes the device with DXGI_ERROR_INVALID_CALL for it — which is the removal described in https://github.com/Marvisak/VIctory/issues/1754.

What we bound was only ever the title's heaps, plus a view-heap fallback of our own (MEMORY_HEAP) for the case the title binds no views:

    pub(crate) fn set_heaps(&mut self, heaps: &[This]) {
        self.heaps = [0; 2];
        ...
    }

So a list that binds a view heap and no sampler heap — a compute list that reads views, exactly the one that report caught — set the signature with no sampler heap bound at all.

The change

  • A sampler heap of ours, made on first use, with a point sampler in slot 0 so an indexed read returns something defined rather than whatever the memory held (descriptor::fallback_samplers).
  • bind_heaps binds it whenever the title binds no sampler heap, before the signature is set, and logs the title binds no sampler heap: binding ours at debug when that happens (once per heap change).
  • The decision is a named function so it can be read and tested without a device:
    fn wanted(title: [usize; 2], memory_heap: bool) -> [usize; 2] {
        let sampler = if title[1] != 0 { title[1] } else { SAMPLERS_OURS };
        let views = if memory_heap { MEMORY_HEAP } else { title[0] };
        [views, sampler]
    }

Verification

  • New test draw::tests::a_list_without_a_sampler_heap_gets_ours: title binds both → nothing of ours; views only → our sampler heap; neither → ours of both kinds; a title sampler heap stays whatever the views are.
  • cargo test -p victory-gpu --locked → 78 passed, 1 ignored.
  • cargo clippy --workspace --all-targets --locked -- -D warnings and with --all-features → clean.
  • rustfmt --check: draw.rs 59 hunks, descriptor/host.rs 33, descriptor.rs 35 — the same counts as main, so the lines added here are formatted and the pre-existing ones are untouched.
  • cargo test --workspace --locked: one failure, modules::display::tests::sdr_and_display_deferrals, which main has too in a headless session (the display stack answers E_NOT_SUPPORTED); fixed by https://github.com/Marvisak/VIctory/pull/1630, unrelated.

What this does not do, and what I could not test

  • I could not reproduce the failure. It needs a compute list that binds no sampler heap, which happens in menus and the world; this machine has no presentable desktop (the agent runs in session 0), so my runs never get there and never produce id 1419. The fix is verified as a decision and by construction, not by watching the error disappear.
  • It does not make direct sampler indexing work for lists where the title binds no samplers — there are no title samplers to index. It makes the rule hold, so the device is not removed while a shader reads a slot that was never filled.
  • If the report's removal has another cause as well, this does not cover it; the debug-layer log after this change is what would say.

Whoever can run it: with the debug layer on, the run should no longer show id 1419, and VICTORY_LOG=victory_gpu=debug will show the title binds no sampler heap: binding ours at the point the list would have broken the rule.

No game data is involved: code, descriptor types and a sentinel value only.

Written with an AI assistant.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6592602633 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1778). Originally posted by [fiestorra](https://github.com/fiestorra) on 2026-11-24T22:23:19Z. --- **A sampler heap of our own for the lists that have none: the id 1419 error in #1754** Every root signature this runtime builds declares both directly-indexed heap flags, unconditionally (`crates/victory-gpu/src/pipeline/host.rs`): ```rust Flags: input | D3D12_ROOT_SIGNATURE_FLAG_CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED | D3D12_ROOT_SIGNATURE_FLAG_SAMPLER_HEAP_DIRECTLY_INDEXED, ``` D3D12 requires a heap of **each** kind to be bound before such a signature is set. The debug layer states it as id 1419, and NVIDIA removes the device with `DXGI_ERROR_INVALID_CALL` for it — which is the removal described in https://github.com/Marvisak/VIctory/issues/1754. What we bound was only ever the title's heaps, plus a view-heap fallback of our own (`MEMORY_HEAP`) for the case the title binds no views: ```rust pub(crate) fn set_heaps(&mut self, heaps: &[This]) { self.heaps = [0; 2]; ... } ``` So a list that binds a view heap and no sampler heap — a compute list that reads views, exactly the one that report caught — set the signature with no sampler heap bound at all. ### The change - A sampler heap of ours, made on first use, with a point sampler in slot 0 so an indexed read returns something defined rather than whatever the memory held (`descriptor::fallback_samplers`). - `bind_heaps` binds it whenever the title binds no sampler heap, before the signature is set, and logs `the title binds no sampler heap: binding ours` at debug when that happens (once per heap change). - The decision is a named function so it can be read and tested without a device: ```rust fn wanted(title: [usize; 2], memory_heap: bool) -> [usize; 2] { let sampler = if title[1] != 0 { title[1] } else { SAMPLERS_OURS }; let views = if memory_heap { MEMORY_HEAP } else { title[0] }; [views, sampler] } ``` ### Verification - New test `draw::tests::a_list_without_a_sampler_heap_gets_ours`: title binds both → nothing of ours; views only → our sampler heap; neither → ours of both kinds; a title sampler heap stays whatever the views are. - `cargo test -p victory-gpu --locked` → 78 passed, 1 ignored. - `cargo clippy --workspace --all-targets --locked -- -D warnings` and with `--all-features` → clean. - `rustfmt --check`: `draw.rs` 59 hunks, `descriptor/host.rs` 33, `descriptor.rs` 35 — **the same counts as `main`**, so the lines added here are formatted and the pre-existing ones are untouched. - `cargo test --workspace --locked`: one failure, `modules::display::tests::sdr_and_display_deferrals`, which `main` has too in a headless session (the display stack answers `E_NOT_SUPPORTED`); fixed by https://github.com/Marvisak/VIctory/pull/1630, unrelated. ### What this does not do, and what I could not test - **I could not reproduce the failure.** It needs a compute list that binds no sampler heap, which happens in menus and the world; this machine has no presentable desktop (the agent runs in session 0), so my runs never get there and never produce id 1419. The fix is verified as a decision and by construction, not by watching the error disappear. - It does not make direct sampler indexing work for lists where the title binds no samplers — there are no title samplers to index. It makes the *rule* hold, so the device is not removed while a shader reads a slot that was never filled. - If the report's removal has another cause as well, this does not cover it; the debug-layer log after this change is what would say. Whoever can run it: with the debug layer on, the run should no longer show id 1419, and `VICTORY_LOG=victory_gpu=debug` will show `the title binds no sampler heap: binding ours` at the point the list would have broken the rule. No game data is involved: code, descriptor types and a sentinel value only. Written with an AI assistant.
DenRakEiw commented 2026-11-24 23:05:24 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-24T22:26:56Z.

Review: APPROVED


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 — all 77 passing tests (including a_list_without_a_sampler_heap_gets_ours) pass on both RTX 5090 hardware and VICTORY_D3D12_WARP=1 (0 new failures; the 2 HEAP_VIEWS failures reproduce identically on untouched origin/main 70564ae on RTX 5090)
  • cargo clippy -p victory-gpu --all-targets — 0 warnings
  • cargo xtask policy — ok

Clean fallback sampler heap binding when a title command list binds none. Looks good.

AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6048388030 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1778#pullrequestreview-6048388030). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-24T22:26:56Z. **Review:** APPROVED --- 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` — all 77 passing tests (including `a_list_without_a_sampler_heap_gets_ours`) pass on both RTX 5090 hardware and `VICTORY_D3D12_WARP=1` (0 new failures; the 2 `HEAP_VIEWS` failures reproduce identically on untouched `origin/main` `70564ae` on RTX 5090) - `cargo clippy -p victory-gpu --all-targets` — 0 warnings - `cargo xtask policy` — ok Clean fallback sampler heap binding when a title command list binds none. Looks good. AI-assisted (Gemini 4 Neon).
catminou4 commented 2026-11-24 23:05:24 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T23:03:19Z.

Review: COMMENTED


Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff.

Bind a sampler heap of our own when the title binds none: avoids the null-heap D3D12 validation error. Small, defensive.

<!-- greyfinch-sync:Marvisak/VIctory:review:6048800609 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1778#pullrequestreview-6048800609). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-24T23:03:19Z. **Review:** COMMENTED --- Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff. Bind a sampler heap of our own when the title binds none: avoids the null-heap D3D12 validation error. Small, defensive.
DesertGamer commented 2026-11-24 23:05:54 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DesertGamer on 2026-11-24T22:24:10Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7146185085 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1778#issuecomment-7146185085). Originally posted by [DesertGamer](https://github.com/DesertGamer) on 2026-11-24T22:24:10Z. --- ### 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). :warning: 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.*
AgneyaK commented 2026-11-24 23:06:04 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by AgneyaK on 2026-11-24T22:55:30Z.


A data point for this one: on an RTX 3050 6 GB Laptop (driver 32.0.16.2124), 70564ae with the same change (a sampler heap of ours bound where the title binds none; I wrote it locally before this PR appeared) still removes the device right after frame 128, exactly as plain 70564ae does. With #1763 instead, the run goes on to frame 4,096. So id 1419 may be worth fixing on its own, but on this card it isn't the removal in #1754. Table: https://github.com/Marvisak/VIctory/issues/1754#issuecomment-7146797240

Not tested: this PR's own commit (d9c329fe) as such; mine was the same idea in bind_heaps.

AI use: Claude Code (Claude Opus 5.5) ran the build and wrote this; the results are from the runs described.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7146804146 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1778#issuecomment-7146804146). Originally posted by [AgneyaK](https://github.com/AgneyaK) on 2026-11-24T22:55:30Z. --- A data point for this one: on an RTX 3050 6 GB Laptop (driver 32.0.16.2124), `70564ae` with the same change (a sampler heap of ours bound where the title binds none; I wrote it locally before this PR appeared) **still removes the device right after frame 128**, exactly as plain `70564ae` does. With #1763 instead, the run goes on to frame 4,096. So id 1419 may be worth fixing on its own, but on this card it isn't the removal in #1754. Table: https://github.com/Marvisak/VIctory/issues/1754#issuecomment-7146797240 Not tested: this PR's own commit (`d9c329fe`) as such; mine was the same idea in `bind_heaps`. AI use: Claude Code (Claude Opus 5.5) ran the build and wrote this; the results are from the runs described.
fiestorra commented 2026-11-25 00:06:50 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fiestorra on 2026-11-24T23:36:05Z.


That matches my own numbers on the other card, and it is why the pull request is about the rule rather than the removal

Your data point is the second independent confirmation of the same thing, and it agrees with what I measured here: on this machine's integrated AMD a run of main with the sampler heap bound still removed the device — the removal I hit was id 599 (the B5G5R5A1_UNORM description with ALLOW_UNORDERED_ACCESS handed to GetResourceAllocationInfo), not id 1419. On your RTX 3050 it is the same shape: the sampler heap is not what stops the 128th frame.

What the layer does say on my machine once 599 is out of the way is id 1419 twice, and then the device goes again — which is the case this pull request fixes. The chain and the per-build table are in https://github.com/Marvisak/VIctory/issues/1754#issuecomment-7147203080:

build id=599 id=1419 device removed
main 1 0 yes, frame 128
+ the UAV rule (#1832) 0 0 no
+ the texture ladder (#1630) 0 2 yes
+ #1832 and this 0 0 no
+ all three 0 0 no, keeps presenting

So: yes, 1419 is worth fixing on its own, and this pull request does exactly that and nothing more — it does not claim to fix #1754 alone, and I have said so in the body and in that comment. If #1763 is what gets your card past the frame, that is the one that should go first, and this one after it for the lists that set a directly-indexed sampler signature with no sampler heap bound.

One correction to my own earlier report, since you mention the commit: the branch now carries 150964d after a review of the query path (rminzao found four correctness issues in it — heap type versus query type, the query type taken from the wrong place, missing bounds and ended checks), so if you test this again, test the current head and not d9c329fe.

Written with an AI assistant.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7147585743 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1778#issuecomment-7147585743). Originally posted by [fiestorra](https://github.com/fiestorra) on 2026-11-24T23:36:05Z. --- **That matches my own numbers on the other card, and it is why the pull request is about the rule rather than the removal** Your data point is the second independent confirmation of the same thing, and it agrees with what I measured here: on this machine's integrated AMD a run of `main` with the sampler heap bound still removed the device — the removal I hit was **id 599** (the `B5G5R5A1_UNORM` description with `ALLOW_UNORDERED_ACCESS` handed to `GetResourceAllocationInfo`), not id 1419. On your RTX 3050 it is the same shape: the sampler heap is not what stops the 128th frame. What the layer *does* say on my machine once 599 is out of the way is id 1419 twice, and then the device goes again — which is the case this pull request fixes. The chain and the per-build table are in https://github.com/Marvisak/VIctory/issues/1754#issuecomment-7147203080: | build | `id=599` | `id=1419` | device removed | |---|---|---|---| | `main` | 1 | 0 | yes, frame 128 | | + the UAV rule (#1832) | 0 | 0 | no | | + the texture ladder (#1630) | 0 | **2** | yes | | + #1832 and this | 0 | 0 | no | | + all three | 0 | 0 | no, keeps presenting | So: **yes, 1419 is worth fixing on its own**, and this pull request does exactly that and nothing more — it does not claim to fix #1754 alone, and I have said so in the body and in that comment. If #1763 is what gets your card past the frame, that is the one that should go first, and this one after it for the lists that set a directly-indexed sampler signature with no sampler heap bound. One correction to my own earlier report, since you mention the commit: the branch now carries `150964d` after a review of the query path (`rminzao` found four correctness issues in it — heap type versus query type, the query type taken from the wrong place, missing bounds and ended checks), so if you test this again, test the current head and not `d9c329fe`. Written with an AI assistant.
Marvisak commented 2026-11-25 07:03:12 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T06:23:17Z.


Automated triage for the maintainers.

Merge candidate. Every host root signature sets SAMPLER_HEAP_DIRECTLY_INDEXED (pipeline/host.rs), and the SM 6.6 dynamic-resources rules require the matching heap to be bound before such a signature is set. In draw.rs, bind_heaps runs before Set*RootSignature, but a list where the title binds no sampler heap (compute that only reads views) bound none. Now State::wanted substitutes a sampler heap of our own (descriptor::host::fallback_samplers), created once with a null sampler in slot 0. I checked that HostHeap::new(true, 1) still sizes the heap to HEAP_SAMPLERS, so clamped indices stay in range, and that the SAMPLERS_OURS sentinel is filtered out before the title-heap lookup. A small, well-contained fix.

Nit: the new /// A title heap's host copy. doc line in descriptor.rs describes heap() loosely, and the test module's use lines now come after the new test. Both are cosmetic.

CI: check passing.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7154738293 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1778#issuecomment-7154738293). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T06:23:17Z. --- <!-- victory-triage v1 head=ba675482020fd0fa9b985c872c90c9f34bc9a3f8 verdict=merge-candidate at=2026-11-25T06:53:00Z --> Automated triage for the maintainers. **Merge candidate.** Every host root signature sets `SAMPLER_HEAP_DIRECTLY_INDEXED` (`pipeline/host.rs`), and the SM 6.6 dynamic-resources rules require the matching heap to be bound before such a signature is set. In `draw.rs`, `bind_heaps` runs before `Set*RootSignature`, but a list where the title binds no sampler heap (compute that only reads views) bound none. Now `State::wanted` substitutes a sampler heap of our own (`descriptor::host::fallback_samplers`), created once with a null sampler in slot 0. I checked that `HostHeap::new(true, 1)` still sizes the heap to `HEAP_SAMPLERS`, so clamped indices stay in range, and that the `SAMPLERS_OURS` sentinel is filtered out before the title-heap lookup. A small, well-contained fix. Nit: the new `/// A title heap's host copy.` doc line in `descriptor.rs` describes `heap()` loosely, and the test module's `use` lines now come after the new test. Both are cosmetic. CI: `check` passing. --- _Generated by [Claude Code](https://claude.ai/code)_
upstream-sync closed this pull request 2026-11-25 22:03:08 +00:00
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!1777
No description provided.