GPU: the heap clamp bound must fit what D3D12 gives #2313

Closed
xiaotu030202 wants to merge 1 commit from upstream-pr/2315 into main
xiaotu030202 commented 2026-11-25 10:27:26 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by xiaotu030202 on 2026-11-25T10:27:26Z.


What this fixes

victory-shader clamps every heap index a translated shader computes to HEAP_VIEWS - 1, and victory-gpu has to give it a heap holding those slots. The two disagreed, and the gap removed the host device.

HEAP_VIEWS was 1 << 21 — 2,097,152. D3D12 takes 1,000,000 descriptors in a shader-visible CBV/SRV/UAV heap on every resource binding tier and refuses one more. Measured on an RTX 5070 Ti, creating a shader-visible view heap at each size:

view   1000 -> OK
view   10000 -> OK
view   65536 -> OK
view   100000 -> OK
view   262144 -> OK
view   500000 -> OK
view   524288 -> OK
view  1000000 -> OK
view  1048576 -> FAIL 0x8007000E  (E_OUTOFMEMORY)
view  1310720 -> FAIL 0x8007000E
view  2097152 -> FAIL 0x8007000E
sampler   2048 -> OK
sampler   4096 -> FAIL 0x8007025D

So the first request in HostHeap::new:

} else if let Ok(heap) = make((count + DYNAMIC).max(views)) {

could never succeed — on any device, from any vendor. Every host fell into the fallback, which asked for count + MIN_DYNAMIC (65,536 + the title's) and got it: a heap of 65,540 slots in the host() test heap. Translated shaders still clamped to 2^21 - 1, so a shader reading a computed index past what the heap held handed the GPU a descriptor that did not exist. That is 0x887A0005 (DXGI_ERROR_DEVICE_REMOVED), and once the device was gone every later test in the process failed — one of them then took the whole test binary down with STATUS_STACK_BUFFER_OVERRUN.

The fallback's comment blamed NVIDIA:

// shortcut: a host that caps its heaps below `HEAP_VIEWS` (NVIDIA)
// faults on an index past them, as before the clamp.

It was every vendor; the comment was written from an AMD card, where the fallback path also gets taken but the tests that exercise it are the ones gated on hardware this project was developed against. It is also the same shape as #59 (device removal while loading the world on an RX 9070 XT).

What changed

Three things, all where the heap geometry is decided:

crates/victory-shader/src/emit/shader.rs — HEAP_VIEWS is 1 << 19. The clamp bound cannot take the whole 1,000,000 ceiling: the slots kept past it need room too.

crates/victory-gpu/src/descriptor/host.rs

  • MIN_DYNAMIC becomes PAIR_RESERVE (1 << 16): the slots HostHeap::pair hands a host copy's two views. This was a real second bug the first fix exposed — with a heap that exactly reaches the clamp bound, every pair went to a dynamic slot, and memory::tests::lists_share_a_table_and_copies_keep_their_views caught it (pairs = (2, 4), wanting >= 1 << 18).
  • extra counts the dynamic slots alone, so pairs starts past them and has room to the end of the heap.
  • The branch chain asks for one size — max(clamp bound, title count) + PAIR_RESERVE + DYNAMIC, capped at PORTABLE_VIEWS — and falls back to the same size minus the dynamic range, never below the clamp bound.

A const assertion holds the invariant that was violated:

const {
    assert!(victory_shader::emit::HEAP_VIEWS <= PORTABLE_VIEWS);
    assert!(
        victory_shader::emit::HEAP_VIEWS as u64 + DYNAMIC as u64 + PAIR_RESERVE as u64
            <= PORTABLE_VIEWS as u64
    );
}

Tests

New: the_clamp_bound_fits_in_a_host_heap — asks the device for a real heap and asserts NumDescriptors >= HEAP_VIEWS. That is exactly the property that was false, and it fails on the old code.

Measured here (Windows 11, RTX 5070 Ti, Rust 1.98.1 pinned, --test-threads=1), before → after:

group before after
descriptor:: 9 passed, 1 FAILED 11 passed
memory:: 2 passed, 1 FAILED 3 passed
draw:: 1 passed, 4 FAILED 4 passed, 1 FAILED
victory-shader 245 passed, 2 failed 245 passed, 2 failed (unchanged)

indirect::, list::, host::, pipeline::, device::, queue::, query::, fence::, frame::, dxgi::, bindless::, object::, primitive::, resource:: are all green.

What is left, and why it is not here

Two failures remain and neither comes from this patch — I stashed it and re-ran to confirm:

  1. draw::tests::a_texture_written_in_one_format_reads_in_another_through_a_placed_view fails at CreateRootSignature with 0x887A0005 on its own, isolated, with the patch stashed as well. It does not touch the heap geometry (it builds its own Slots::new(4) and a fixed root signature).
  2. victory-shader's stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride and synthetic_tests::gathers_at_a_level_match_the_hardware compare shader output against RDNA2 hardware results. On a GeForce the first returns 11 of 32 lanes' worth (left: [101..131, 0, 0, ...], right: [200..231]). Both fail identically with the patch stashed. Judging them needs an AMD card, and they deserve their own issue rather than a patch from here.

I could not run the title (no game files), so this is not evidence that the world now renders. What it does establish is that a host heap can now hold every index the translator is allowed to name, and that the tests which check it pass — including on NVIDIA, where they could not before.

Environment

Windows 11, Ryzen 7 9800X3D, RTX 5070 Ti (driver 32.0.16.2140), MSVC 14.44.35207, Windows SDK 10.0.26100.0, VICTORY_DXIL pointed at that SDK's dxil.dll.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6602375735 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2315). Originally posted by [xiaotu030202](https://github.com/xiaotu030202) on 2026-11-25T10:27:26Z. --- ## What this fixes `victory-shader` clamps every heap index a translated shader computes to `HEAP_VIEWS - 1`, and `victory-gpu` has to give it a heap holding those slots. The two disagreed, and the gap removed the host device. `HEAP_VIEWS` was `1 << 21` — 2,097,152. D3D12 takes 1,000,000 descriptors in a shader-visible CBV/SRV/UAV heap on **every** resource binding tier and refuses one more. Measured on an RTX 5070 Ti, creating a shader-visible view heap at each size: ``` view 1000 -> OK view 10000 -> OK view 65536 -> OK view 100000 -> OK view 262144 -> OK view 500000 -> OK view 524288 -> OK view 1000000 -> OK view 1048576 -> FAIL 0x8007000E (E_OUTOFMEMORY) view 1310720 -> FAIL 0x8007000E view 2097152 -> FAIL 0x8007000E sampler 2048 -> OK sampler 4096 -> FAIL 0x8007025D ``` So the first request in `HostHeap::new`: ```rust } else if let Ok(heap) = make((count + DYNAMIC).max(views)) { ``` could never succeed — on any device, from any vendor. Every host fell into the fallback, which asked for `count + MIN_DYNAMIC` (65,536 + the title's) and got it: a heap of 65,540 slots in the `host()` test heap. Translated shaders still clamped to `2^21 - 1`, so a shader reading a computed index past what the heap held handed the GPU a descriptor that did not exist. That is `0x887A0005` (`DXGI_ERROR_DEVICE_REMOVED`), and once the device was gone every later test in the process failed — one of them then took the whole test binary down with `STATUS_STACK_BUFFER_OVERRUN`. The fallback's comment blamed NVIDIA: ```rust // shortcut: a host that caps its heaps below `HEAP_VIEWS` (NVIDIA) // faults on an index past them, as before the clamp. ``` It was every vendor; the comment was written from an AMD card, where the *fallback* path also gets taken but the tests that exercise it are the ones gated on hardware this project was developed against. It is also the same shape as #59 (device removal while loading the world on an RX 9070 XT). ## What changed Three things, all where the heap geometry is decided: **`crates/victory-shader/src/emit/shader.rs`** — `HEAP_VIEWS` is `1 << 19`. The clamp bound cannot take the whole 1,000,000 ceiling: the slots kept past it need room too. **`crates/victory-gpu/src/descriptor/host.rs`** - `MIN_DYNAMIC` becomes `PAIR_RESERVE` (`1 << 16`): the slots `HostHeap::pair` hands a host copy's two views. This was a real second bug the first fix exposed — with a heap that exactly reaches the clamp bound, every pair went to a dynamic slot, and `memory::tests::lists_share_a_table_and_copies_keep_their_views` caught it (`pairs = (2, 4)`, wanting `>= 1 << 18`). - `extra` counts the dynamic slots alone, so `pairs` starts past them and has room to the end of the heap. - The branch chain asks for one size — `max(clamp bound, title count) + PAIR_RESERVE + DYNAMIC`, capped at `PORTABLE_VIEWS` — and falls back to the same size minus the dynamic range, never below the clamp bound. **A `const` assertion** holds the invariant that was violated: ```rust const { assert!(victory_shader::emit::HEAP_VIEWS <= PORTABLE_VIEWS); assert!( victory_shader::emit::HEAP_VIEWS as u64 + DYNAMIC as u64 + PAIR_RESERVE as u64 <= PORTABLE_VIEWS as u64 ); } ``` ## Tests New: `the_clamp_bound_fits_in_a_host_heap` — asks the device for a real heap and asserts `NumDescriptors >= HEAP_VIEWS`. That is exactly the property that was false, and it fails on the old code. Measured here (Windows 11, RTX 5070 Ti, Rust 1.98.1 pinned, `--test-threads=1`), before → after: | group | before | after | |---|---|---| | `descriptor::` | 9 passed, 1 **FAILED** | **11 passed** | | `memory::` | 2 passed, 1 **FAILED** | **3 passed** | | `draw::` | 1 passed, 4 **FAILED** | **4 passed, 1 FAILED** | | `victory-shader` | 245 passed, 2 failed | 245 passed, 2 failed (unchanged) | `indirect::`, `list::`, `host::`, `pipeline::`, `device::`, `queue::`, `query::`, `fence::`, `frame::`, `dxgi::`, `bindless::`, `object::`, `primitive::`, `resource::` are all green. ## What is left, and why it is not here Two failures remain and neither comes from this patch — I stashed it and re-ran to confirm: 1. `draw::tests::a_texture_written_in_one_format_reads_in_another_through_a_placed_view` fails at `CreateRootSignature` with `0x887A0005` on its own, isolated, with the patch stashed as well. It does not touch the heap geometry (it builds its own `Slots::new(4)` and a fixed root signature). 2. `victory-shader`'s `stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride` and `synthetic_tests::gathers_at_a_level_match_the_hardware` compare shader output against RDNA2 hardware results. On a GeForce the first returns 11 of 32 lanes' worth (`left: [101..131, 0, 0, ...]`, `right: [200..231]`). Both fail identically with the patch stashed. Judging them needs an AMD card, and they deserve their own issue rather than a patch from here. I could not run the title (no game files), so this is not evidence that the world now renders. What it does establish is that a host heap can now hold every index the translator is allowed to name, and that the tests which check it pass — including on NVIDIA, where they could not before. ## Environment Windows 11, Ryzen 7 9800X3D, RTX 5070 Ti (driver 32.0.16.2140), MSVC 14.44.35207, Windows SDK 10.0.26100.0, `VICTORY_DXIL` pointed at that SDK's `dxil.dll`.
DenRakEiw commented 2026-11-25 11:04:50 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-25T10:43:10Z.

Review: COMMENTED


Verified against origin/main (940d32f) on Windows 11 + NVIDIA GeForce RTX 5090 and WARP:

  • Functionally fixes both pre-existing NVIDIA view-heap baseline failures (#1744): descriptor::host::tests 6/6 passed on RTX 5090 and 6/6 on WARP, and memory::tests 3/3 passed on RTX 5090.
  • cargo xtask policy: 183 files ok.
  • Clippy blocker (cargo clippy -p victory-gpu --all-targets -- -D warnings):
    error: this assertion has a constant value
        --> crates\victory-gpu\src\descriptor\host.rs:1532:9
         |
    1532 | /         assert!(
    1533 | |             victory_shader::emit::HEAP_VIEWS <= PORTABLE_VIEWS,
    1534 | |             "HEAP_VIEWS is past what D3D12 gives a shader-visible heap"
    1535 | |         );
         | |_________^
         |
         = help: consider moving this into a const block: `const { assert!(..) }`
         = note: `-D clippy::assertions-on-constants` implied by `-D warnings`
    
    Wrapping that assertion in const { assert!(...); } will make clippy --all-targets -- -D warnings pass cleanly.

AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6056070385 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2315#pullrequestreview-6056070385). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-25T10:43:10Z. **Review:** COMMENTED --- Verified against `origin/main` (`940d32f`) on Windows 11 + NVIDIA GeForce RTX 5090 and WARP: - Functionally fixes both pre-existing NVIDIA view-heap baseline failures (`#1744`): `descriptor::host::tests` 6/6 passed on RTX 5090 and 6/6 on WARP, and `memory::tests` 3/3 passed on RTX 5090. - `cargo xtask policy`: 183 files ok. - **Clippy blocker (`cargo clippy -p victory-gpu --all-targets -- -D warnings`):** ``` error: this assertion has a constant value --> crates\victory-gpu\src\descriptor\host.rs:1532:9 | 1532 | / assert!( 1533 | | victory_shader::emit::HEAP_VIEWS <= PORTABLE_VIEWS, 1534 | | "HEAP_VIEWS is past what D3D12 gives a shader-visible heap" 1535 | | ); | |_________^ | = help: consider moving this into a const block: `const { assert!(..) }` = note: `-D clippy::assertions-on-constants` implied by `-D warnings` ``` Wrapping that assertion in `const { assert!(...); }` will make `clippy --all-targets -- -D warnings` pass cleanly. AI-assisted (Gemini 4 Neon).
catminou4 commented 2026-11-25 11:04:50 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T10:53:58Z.

Review: APPROVED


Tested locally: merged into main 940d32f69b, cargo test -p victory-shader --locked on macOS arm64 — 144 passed, 0 failed, 2 ignored (Windows-gated hardware execution tests not run here). Approving the shader side — heap clamp bound fits what D3D12 gives. GPU side Windows-only, static.

<!-- greyfinch-sync:Marvisak/VIctory:review:6056241669 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2315#pullrequestreview-6056241669). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T10:53:58Z. **Review:** APPROVED --- Tested locally: merged into main 940d32f69b, `cargo test -p victory-shader --locked` on macOS arm64 — 144 passed, 0 failed, 2 ignored (Windows-gated hardware execution tests not run here). Approving the shader side — heap clamp bound fits what D3D12 gives. GPU side Windows-only, static.
andrewpozdnakov7-jpg commented 2026-11-25 11:05:31 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-25T10:42:50Z.


The NVIDIA ceiling is reproducible on the reported setup. Tier 3 also permits larger shader-visible view heaps when the driver accepts them, per the D3D12 Resource Binding specification.

I ran the same synthetic fixture on app-local WARP Tier 3. A direct CreateDescriptorHeap succeeded with 1,000,001 and 2,097,152 shader-visible CBV/SRV/UAV descriptors on all three heads. The VIctory entry point behaved differently:

Tree HostHeap::new(false, 4) HostHeap::new(false, 1_245_184)
upstream 940d32f 2,097,152 host slots 2,097,152 host slots, all title slots retained
this PR 43aa1b2 851,968 host slots None
#2177 1a3261f 2,097,152 host slots 2,097,152 host slots, all title slots retained

The same assertion passes on main and #2177 and fails on this PR. The early least > PORTABLE_VIEWS return replaces a successful larger allocation on this device. A capability probe with a capped fallback, as in #2177, addresses the NVIDIA ceiling while preserving the successful Tier 3 path here.

AI-assisted. Synthetic tests only.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7160072900 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2315#issuecomment-7160072900). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-25T10:42:50Z. --- The NVIDIA ceiling is reproducible on the reported setup. Tier 3 also permits larger shader-visible view heaps when the driver accepts them, per the [D3D12 Resource Binding specification](https://microsoft.github.io/DirectX-Specs/d3d/ResourceBinding.html#levels-of-hardware-support). I ran the same synthetic fixture on app-local WARP Tier 3. A direct `CreateDescriptorHeap` succeeded with 1,000,001 and 2,097,152 shader-visible CBV/SRV/UAV descriptors on all three heads. The VIctory entry point behaved differently: | Tree | `HostHeap::new(false, 4)` | `HostHeap::new(false, 1_245_184)` | | --- | ---: | --- | | upstream `940d32f` | 2,097,152 host slots | 2,097,152 host slots, all title slots retained | | this PR `43aa1b2` | 851,968 host slots | `None` | | #2177 `1a3261f` | 2,097,152 host slots | 2,097,152 host slots, all title slots retained | The same assertion passes on main and #2177 and fails on this PR. The early `least > PORTABLE_VIEWS` return replaces a successful larger allocation on this device. A capability probe with a capped fallback, as in #2177, addresses the NVIDIA ceiling while preserving the successful Tier 3 path here. AI-assisted. Synthetic tests only.
Dathinel commented 2026-11-25 15:04:33 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dathinel on 2026-11-25T14:55:39Z.


Hardware data point for the heap ceiling on NVIDIA Ampere, with the D3D12 debug layer on (--features diagnostics, VICTORY_D3D12_DEBUG=1; the probe required ID3D12InfoQueue). RTX 3050 Laptop, driver 610.62, resource binding tier 3, Windows 11 26200.

Direct shader-visible CreateDescriptorHeap: views 1,000,000 OK; 1,000,001 / 1,048,576 / 2,097,152 fail with 0x80070057, with the layer saying "the limit for shader visible view heaps is 1000000". Samplers 2,049 OK, 4,096 fail (layer: limit 4080). With the layer on, the code is E_INVALIDARG rather than the E_OUTOFMEMORY in the description; I did not run without it.

HostHeap::new on the same card, one synthetic probe per head:

head shader clamp bound new(false, 4) new(false, 1_245_184)
main 940d32f 2,097,152 65,540 slots 1,000,000 slots
this PR 43aa1b2 524,288 851,968 slots None
#2185 9518df8 1,000,000 (runtime) 1,000,000 1,000,000 (934,461 title slots kept)
#2177 d15c68b 1,000,000 (runtime) 1,000,000 1,000,000 (844,349 title slots kept)

So on NVIDIA hardware main's mismatch is real (clamp above the heap in both cases), and this PR closes it for small titles. But a title that declares more than the ceiling now gets no view heap at all, where main, #2185 and #2177 cap it at 1,000,000. That matches the WARP result above. I did not test a shader read past the cap on any head.

AI-assisted; synthetic probe only. Probe source available on request.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7166032577 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2315#issuecomment-7166032577). Originally posted by [Dathinel](https://github.com/Dathinel) on 2026-11-25T14:55:39Z. --- Hardware data point for the heap ceiling on NVIDIA Ampere, with the D3D12 debug layer on (`--features diagnostics`, `VICTORY_D3D12_DEBUG=1`; the probe required `ID3D12InfoQueue`). RTX 3050 Laptop, driver 610.62, resource binding tier 3, Windows 11 26200. Direct shader-visible `CreateDescriptorHeap`: views 1,000,000 OK; 1,000,001 / 1,048,576 / 2,097,152 fail with `0x80070057`, with the layer saying "the limit for shader visible view heaps is 1000000". Samplers 2,049 OK, 4,096 fail (layer: limit 4080). With the layer on, the code is E_INVALIDARG rather than the E_OUTOFMEMORY in the description; I did not run without it. `HostHeap::new` on the same card, one synthetic probe per head: | head | shader clamp bound | `new(false, 4)` | `new(false, 1_245_184)` | |---|---|---|---| | main `940d32f` | 2,097,152 | 65,540 slots | 1,000,000 slots | | this PR `43aa1b2` | 524,288 | 851,968 slots | `None` | | #2185 `9518df8` | 1,000,000 (runtime) | 1,000,000 | 1,000,000 (934,461 title slots kept) | | #2177 `d15c68b` | 1,000,000 (runtime) | 1,000,000 | 1,000,000 (844,349 title slots kept) | So on NVIDIA hardware main's mismatch is real (clamp above the heap in both cases), and this PR closes it for small titles. But a title that declares more than the ceiling now gets no view heap at all, where main, #2185 and #2177 cap it at 1,000,000. That matches the WARP result above. I did not test a shader read past the cap on any head. AI-assisted; synthetic probe only. Probe source available on request.
upstream-sync closed this pull request 2026-11-25 16:07:29 +00:00
Marvisak commented 2026-11-25 16:09:12 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T15:26:29Z.


Automated triage for the maintainers.

Proposed close. Thanks for the measurements; the mismatch on NVIDIA is real (the clamp bound is above the heap the host gives), but this fix makes things worse elsewhere:

  • HostHeap::new in descriptor/host.rs now returns None (no view heap at all) whenever max(count, HEAP_VIEWS) + PAIR_RESERVE > PORTABLE_VIEWS, i.e. for any title heap above about 934K slots, where main caps it at 1,000,000. The title is reported to use slots past 1,236,191 (#2185), so it would lose its heap entirely; two contributors reproduced this here, on WARP and an RTX 3050 (new(false, 1_245_184) gives None).
  • D3D12 does not give 1,000,000 on every binding tier: Tier 3 drivers may take more (WARP takes 2,097,152). Lowering HEAP_VIEWS to 1 << 19 for everyone clamps reachable title indices on hosts that work today.
  • The long rationale comments in shader.rs and host.rs go against the repo's short-docs rule.

#2177 and #2185 address the same ceiling with a runtime probe and a capped fallback that keeps the larger Tier 3 path; please continue there, or rework this to probe the host instead of fixing a smaller constant. CI: not run.

This PR will be closed in 48 hours unless the author pushes a change or a maintainer removes the label.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7166846929 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2315#issuecomment-7166846929). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T15:26:29Z. --- <!-- victory-triage v1 head=43aa1b2d80039432dbf052d00b87b86ff5de80dd verdict=proposed-close at=2026-11-25T15:26:00Z --> Automated triage for the maintainers. **Proposed close.** Thanks for the measurements; the mismatch on NVIDIA is real (the clamp bound is above the heap the host gives), but this fix makes things worse elsewhere: - `HostHeap::new` in `descriptor/host.rs` now returns `None` (no view heap at all) whenever `max(count, HEAP_VIEWS) + PAIR_RESERVE > PORTABLE_VIEWS`, i.e. for any title heap above about 934K slots, where `main` caps it at 1,000,000. The title is reported to use slots past 1,236,191 (#2185), so it would lose its heap entirely; two contributors reproduced this here, on WARP and an RTX 3050 (`new(false, 1_245_184)` gives `None`). - D3D12 does not give 1,000,000 on every binding tier: Tier 3 drivers may take more (WARP takes 2,097,152). Lowering `HEAP_VIEWS` to `1 << 19` for everyone clamps reachable title indices on hosts that work today. - The long rationale comments in `shader.rs` and `host.rs` go against the repo's short-docs rule. #2177 and #2185 address the same ceiling with a runtime probe and a capped fallback that keeps the larger Tier 3 path; please continue there, or rework this to probe the host instead of fixing a smaller constant. CI: not run. This PR will be closed in 48 hours unless the author pushes a change or a maintainer removes the label. --- _Generated by [Claude Code](https://claude.ai/code)_
xiaotu030202 commented 2026-11-25 16:09:16 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by xiaotu030202 on 2026-11-25T15:35:09Z.


The triage is right on all three points, and I am closing this rather than reworking it.

I checked each claim against the diff before agreeing:

  1. None instead of a heap. HostHeap::new in descriptor/host.rs does:

    let least = needed.saturating_add(pair_room);
    if least > PORTABLE_VIEWS {
        tracing::warn!(count, views, "title view heap needs more slots than the host allows");
        return None;
    }
    

    A title declaring 1,245,184 slots gets least = 1,245,184 + 65,536 > 1,000,000, so it takes that branch and the process runs with no view heap at all. main caps the heap at 1,000,000 and keeps going. The WARP result and @Dathinel's RTX 3050 result are both that branch, and I had not run either case.

  2. HEAP_VIEWS = 1 << 19 is a global loss. It was 1 << 21 = 2,097,152. On a Tier 3 driver that really does hand out 2,097,152 (WARP, per the table above), shaders can now name only a quarter of what the heap holds — so this "fix" clamps reachable indices on hosts that work today. That is worse than the mismatch it was aimed at.

  3. The comments. Fair. shader.rs and host.rs both carry multi-paragraph rationale that belongs in a PR description, not in the tree.

What I still think was worth measuring, and where it belongs.

The invariant this PR was trying to state is:

the index bound the translator clamps to must not exceed the number of title slots the host heap actually got

On main that is violated in both directions — new(false, 4) returns 65,540 slots against a bound of 2,097,152 — which is the NVIDIA fault I measured. But a fixed bound cannot satisfy it, because the number of slots is a runtime property of the driver and the binding tier. #2177 and #2185 set the bound from the heap at runtime, which is the only shape that satisfies it, and their own tables show a 1,000,000 heap with 934,461 and 844,349 title slots kept where mine returns None.

So I am not reworking this: a third runtime probe would duplicate #2177/#2185 rather than add to them, and that is the same mistake I made earlier on this account — opening a patch for something two other PRs had already covered.

Where the measurement goes. My original number (1,048,576 → E_OUTOFMEMORY 0x8007000E on an RTX 5070 Ti) is now confirmed three ways — @andrewpozdnakov7-jpg on WARP Tier 3, @Dathinel on Ampere with the debug layer naming the 1,000,000 limit explicitly, and this triage — so it needs no PR to be useful. I will put the invariant and the two-sided table on #2185 as a comment rather than a diff.

Thanks for reading it closely enough to find the regression; a synthetic-only patch that turns a clamp into a refusal should not have been opened without running the above-ceiling case, and I did not run it.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7167069500 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2315#issuecomment-7167069500). Originally posted by [xiaotu030202](https://github.com/xiaotu030202) on 2026-11-25T15:35:09Z. --- The triage is right on all three points, and I am closing this rather than reworking it. **I checked each claim against the diff before agreeing:** 1. **`None` instead of a heap.** `HostHeap::new` in `descriptor/host.rs` does: ```rust let least = needed.saturating_add(pair_room); if least > PORTABLE_VIEWS { tracing::warn!(count, views, "title view heap needs more slots than the host allows"); return None; } ``` A title declaring 1,245,184 slots gets `least = 1,245,184 + 65,536 > 1,000,000`, so it takes that branch and the process runs with **no view heap at all**. `main` caps the heap at 1,000,000 and keeps going. The WARP result and @Dathinel's RTX 3050 result are both that branch, and I had not run either case. 2. **`HEAP_VIEWS = 1 << 19` is a global loss.** It was `1 << 21` = 2,097,152. On a Tier 3 driver that really does hand out 2,097,152 (WARP, per the table above), shaders can now name only a quarter of what the heap holds — so this "fix" clamps reachable indices on hosts that work today. That is worse than the mismatch it was aimed at. 3. **The comments.** Fair. `shader.rs` and `host.rs` both carry multi-paragraph rationale that belongs in a PR description, not in the tree. **What I still think was worth measuring, and where it belongs.** The invariant this PR was trying to state is: > the index bound the translator clamps to must not exceed the number of title slots the host heap actually got On `main` that is violated in both directions — `new(false, 4)` returns 65,540 slots against a bound of 2,097,152 — which is the NVIDIA fault I measured. But a **fixed** bound cannot satisfy it, because the number of slots is a runtime property of the driver and the binding tier. #2177 and #2185 set the bound from the heap at runtime, which is the only shape that satisfies it, and their own tables show a 1,000,000 heap with 934,461 and 844,349 title slots kept where mine returns `None`. So I am not reworking this: a third runtime probe would duplicate #2177/#2185 rather than add to them, and that is the same mistake I made earlier on this account — opening a patch for something two other PRs had already covered. **Where the measurement goes.** My original number (1,048,576 → `E_OUTOFMEMORY` 0x8007000E on an RTX 5070 Ti) is now confirmed three ways — @andrewpozdnakov7-jpg on WARP Tier 3, @Dathinel on Ampere with the debug layer naming the 1,000,000 limit explicitly, and this triage — so it needs no PR to be useful. I will put the invariant and the two-sided table on #2185 as a comment rather than a diff. Thanks for reading it closely enough to find the regression; a synthetic-only patch that turns a clamp into a refusal should not have been opened without running the above-ceiling case, and I did not run it.

Pull request closed

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!2313
No description provided.