Shaders, GPU: add runtime stride table for structured buffers #193

Closed
github-bot wants to merge 2 commits from gh-pr/193/head into gh-pr/193/base
Owner

@⁠n-romanovich on GitHub · 2026-11-24 01:17 UTC · original
n-romanovich:feat/runtime-stride-channel → main · +596 −76 · 10 files · 2 commits · closed without merging

Implements the runtime stride channel described in #155 so structured-buffer accesses whose element stride is not recovered statically fall back to a host-maintained per-slot stride table instead of failing translation (a structured buffer of unknown stride).

Changes

  • victory-shader:
    • Added STRIDE_SPACE = 2 (t0), Shader::stride_table_handle(), and HostShader::stride_table: bool.
    • Added Lower::runtime_stride_offset for Loaded and Phi heap descriptors, reading stride from t0 (STRIDE_SPACE) at slot * 4 and emitting index * stride + off at all three structured-buffer idxen sites (load, store, atomic).
    • Updated Host::root_signature_for so standalone shader tests can bind the stride table.
  • victory-gpu:
    • Added stride_table serialization to shader_cache (bumped MAGIC to VSH2).
    • Declared the STRIDE_SPACE root SRV in pipeline/host.rs when t.stride_table is set and bound it in draw.rs.
    • Added a mapped UPLOAD StrideTable buffer (4 bytes per view-heap slot) to HostHeap in descriptor/host.rs, kept in sync across make_at, make_null, constant_at, and mirror.

Testing & Hardware Note

  • Added emit::tests::structured_buffer_unknown_stride_uses_runtime_stride_table covering buffer_load_dword ... idxen, buffer_store_dword ... idxen, and buffer_atomic_add ... idxen with stride = 0 in UsedResource.
  • Validated emitted DXIL with dxil.dll and ran on D3D12:
    • Microsoft WARP (VICTORY_WARP=1): passes with both Structured(12) and Raw descriptors.
    • NVIDIA GeForce RTX 5060 Ti: passes with Raw descriptors (107, 20), whereas dxil_kind = 11 (ByteAddressBuffer) reading a Structured(12) descriptor returns 0 on NVIDIA D3D12 (unlike WARP/AMD).
  • cargo clippy -p victory-shader -p victory-gpu --lib -- -D warnings: passed (0 warnings).
  • cargo xtask policy: passed (asset policy: 151 files ok).
  • cargo test -p victory-shader: 70 passed, 0 failed.
**@⁠n-romanovich** on GitHub · 2026-11-24 01:17 UTC · [original](https://github.com/Marvisak/VIctory/pull/193) `n-romanovich:feat/runtime-stride-channel` → `main` · +596 −76 · 10 files · 2 commits · closed without merging Implements the runtime stride channel described in #155 so structured-buffer accesses whose element stride is not recovered statically fall back to a host-maintained per-slot stride table instead of failing translation (`a structured buffer of unknown stride`). ### Changes - **`victory-shader`**: - Added `STRIDE_SPACE = 2` (`t0`), `Shader::stride_table_handle()`, and `HostShader::stride_table: bool`. - Added `Lower::runtime_stride_offset` for `Loaded` and `Phi` heap descriptors, reading `stride` from `t0` (`STRIDE_SPACE`) at `slot * 4` and emitting `index * stride + off` at all three structured-buffer `idxen` sites (load, store, atomic). - Updated `Host::root_signature_for` so standalone shader tests can bind the stride table. - **`victory-gpu`**: - Added `stride_table` serialization to `shader_cache` (bumped `MAGIC` to `VSH2`). - Declared the `STRIDE_SPACE` root SRV in `pipeline/host.rs` when `t.stride_table` is set and bound it in `draw.rs`. - Added a mapped `UPLOAD` `StrideTable` buffer (4 bytes per view-heap slot) to `HostHeap` in `descriptor/host.rs`, kept in sync across `make_at`, `make_null`, `constant_at`, and `mirror`. ### Testing & Hardware Note - Added `emit::tests::structured_buffer_unknown_stride_uses_runtime_stride_table` covering `buffer_load_dword ... idxen`, `buffer_store_dword ... idxen`, and `buffer_atomic_add ... idxen` with `stride = 0` in `UsedResource`. - Validated emitted DXIL with `dxil.dll` and ran on D3D12: - **Microsoft WARP (`VICTORY_WARP=1`)**: passes with both `Structured(12)` and `Raw` descriptors. - **NVIDIA GeForce RTX 5060 Ti**: passes with `Raw` descriptors (`107`, `20`), whereas `dxil_kind = 11` (`ByteAddressBuffer`) reading a `Structured(12)` descriptor returns `0` on NVIDIA D3D12 (unlike WARP/AMD). - `cargo clippy -p victory-shader -p victory-gpu --lib -- -D warnings`: passed (0 warnings). - `cargo xtask policy`: passed (`asset policy: 151 files ok`). - `cargo test -p victory-shader`: 70 passed, 0 failed.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:54:03 +00:00
github-bot closed this pull request 2026-11-26 03:54:03 +00:00
Author
Owner

@⁠DaviTostes on GitHub · 2026-11-24 01:30 UTC · original

Tested 4322b61 on Arch Linux x86_64, rustc 1.98.1: pass.

  • cargo test -p victory-shader: 57 passed, 0 failed (2 test binaries), including the {adds} test{'s' if adds != 1 else ''} this PR adds.
  • The shader crate is green; the GPU half of this PR is not covered by this run (I will check it against the host GPU separately).
  • The full workspace still needs #112 for the victory-gpu E0425.

No game data used.

**@⁠DaviTostes** on GitHub · 2026-11-24 01:30 UTC · [original](https://github.com/Marvisak/VIctory/pull/193#issuecomment-7119174890) Tested `4322b61` on **Arch Linux x86_64, rustc 1.98.1**: **pass**. - `cargo test -p victory-shader`: **57 passed, 0 failed** (2 test binaries), including the {adds} test{'s' if adds != 1 else ''} this PR adds. - The shader crate is green; the GPU half of this PR is not covered by this run (I will check it against the host GPU separately). - The full workspace still needs #112 for the `victory-gpu` E0425. No game data used.
Author
Owner

@⁠DaviTostes on GitHub · 2026-11-24 01:31 UTC · original

Follow-up on the GPU half: the test build does not compile, so the host-GPU side cannot be validated yet.

error[E0428]: the name `tests` is defined multiple times
    --> crates/victory-gpu/src/host.rs:1974:1
 252 | mod tests { ... }
1974 | mod tests { ... }

The shader crate is green (57 passed, 1 new test — see above), but the victory-gpu test target fails on every platform until the new test module is merged into the existing one in host.rs. This is the same rebase issue as #134/#135/#161/#175.

No game data used.

**@⁠DaviTostes** on GitHub · 2026-11-24 01:31 UTC · [original](https://github.com/Marvisak/VIctory/pull/193#issuecomment-7119184992) Follow-up on the GPU half: the **test build does not compile**, so the host-GPU side cannot be validated yet. ``` error[E0428]: the name `tests` is defined multiple times --> crates/victory-gpu/src/host.rs:1974:1 252 | mod tests { ... } 1974 | mod tests { ... } ``` The shader crate is green (57 passed, 1 new test — see above), but the `victory-gpu` test target fails on every platform until the new test module is merged into the existing one in `host.rs`. This is the same rebase issue as #134/#135/#161/#175. No game data used.
Author
Owner

@⁠Mesrine67 on GitHub · 2026-11-24 02:03 UTC · original

I reviewed the current PR and agree this is a useful path for the unknown-stride failures. One failure path should be handled before dispatch: in crates/victory-gpu/src/draw.rs, when stage.stride_table is set but there is no host view heap or stride_table_gpu() returns None, the code logs and continues. The root SRV is then left unbound while the shader reads it; please make State::bind report failure and skip the draw/dispatch in that case.

I also ran an equivalent synthetic D3D12 implementation on PC-MIKE (Windows 11, Radeon RX 6750 XT) and WARP: an idxen store to element 1 of a structured UAV with stride 8 wrote to byte offset 8 on both. This was my local implementation based on d2a4bae, not a run of this PR's branch. The targeted test and workspace suite passed (265 passed, 0 failed, 4 ignored); the release build and strict library Clippy also passed. This confirms the offset logic on AMD/WARP but does not validate the game's rendered output or this exact diff.

**@⁠Mesrine67** on GitHub · 2026-11-24 02:03 UTC · [original](https://github.com/Marvisak/VIctory/pull/193#issuecomment-7119717645) I reviewed the current PR and agree this is a useful path for the unknown-stride failures. One failure path should be handled before dispatch: in `crates/victory-gpu/src/draw.rs`, when `stage.stride_table` is set but there is no host view heap or `stride_table_gpu()` returns `None`, the code logs and continues. The root SRV is then left unbound while the shader reads it; please make `State::bind` report failure and skip the draw/dispatch in that case. I also ran an equivalent synthetic D3D12 implementation on PC-MIKE (Windows 11, Radeon RX 6750 XT) and WARP: an `idxen` store to element 1 of a structured UAV with stride 8 wrote to byte offset 8 on both. This was my local implementation based on `d2a4bae`, not a run of this PR's branch. The targeted test and workspace suite passed (265 passed, 0 failed, 4 ignored); the release build and strict library Clippy also passed. This confirms the offset logic on AMD/WARP but does not validate the game's rendered output or this exact diff.
Author
Owner

@⁠gw1337x on GitHub · 2026-11-24 02:21 UTC · original

In-game test on an RX 7800 XT (Windows 11 26200), diag build with VICTORY_D3D12_DRED=1. Build: main d2a4bae + #135 + #242 + #230 + #124 + #130 + this PR. The merge conflicts were formatting only, plus the new strides field in HostHeap::new next to #135's dynamic: extra.

Result: the host device is removed with 0x887A0001 (invalid call) at the first world frame, about 40 s after start. The same build without this PR reaches the opening cutscene and runs about 177 s; on this PC it has never ended in an invalid call.

host GPU device removed after a submission of 1 lists; breadcrumbs (done/count, list) []; list 0 of 1, of its 6:
dispatch 23x1x1 [compute 91b10a73e48b2192] | 91b10a73e48b2192: u4=0x12fffc0 [heap 622590: Placed(true, [1, 0, 0, 0, 5772, 0, 1, 65537, ...
device removed: The application made a call that is invalid. ... (0x887A0001)

An invalid call (rather than a hang or page fault) suggests a view description the host refuses, possibly one of the structured views this PR now makes. I don't have the D3D12 debug layer installed, so I can't name the call. I can rerun with a diagnostics switch if you add one.

**@⁠gw1337x** on GitHub · 2026-11-24 02:21 UTC · [original](https://github.com/Marvisak/VIctory/pull/193#issuecomment-7120053956) In-game test on an RX 7800 XT (Windows 11 26200), `diag` build with `VICTORY_D3D12_DRED=1`. Build: `main` `d2a4bae` + #135 + #242 + #230 + #124 + #130 + this PR. The merge conflicts were formatting only, plus the new `strides` field in `HostHeap::new` next to #135's `dynamic: extra`. **Result:** the host device is removed with **`0x887A0001` (invalid call)** at the first world frame, about 40 s after start. The same build without this PR reaches the opening cutscene and runs about 177 s; on this PC it has never ended in an invalid call. ``` host GPU device removed after a submission of 1 lists; breadcrumbs (done/count, list) []; list 0 of 1, of its 6: dispatch 23x1x1 [compute 91b10a73e48b2192] | 91b10a73e48b2192: u4=0x12fffc0 [heap 622590: Placed(true, [1, 0, 0, 0, 5772, 0, 1, 65537, ... device removed: The application made a call that is invalid. ... (0x887A0001) ``` An invalid call (rather than a hang or page fault) suggests a view description the host refuses, possibly one of the structured views this PR now makes. I don't have the D3D12 debug layer installed, so I can't name the call. I can rerun with a diagnostics switch if you add one.
Author
Owner

@⁠r4tedx on GitHub · 2026-11-24 03:08 UTC · original

Review question on the fallback path. When the stride is not known statically, the three idxen sites now take a raw handle and compute the byte offset themselves:

let byte = self.runtime_stride_offset(src, index, off)?;
(self.handle(site, src, false, (11 | u, 0))?, [byte, iu, iu])

The heap slot that handle resolves to still holds the view the title created, which for a structured buffer is a structured view (descriptor/host.rs mirrors the title's view as given). The description says of exactly that combination:

dxil_kind = 11 (ByteAddressBuffer) reading a Structured(12) descriptor returns 0 on NVIDIA D3D12 (unlike WARP/AMD).

So as far as I can read it, on NVIDIA these accesses would now read zeros where they were refused before, which is harder to notice than a dropped draw. Is there a place where the host makes a raw view for slots that are read through this path (I did not find one in the diff), or could the fallback be limited to slots known to hold raw views?

a structured buffer of unknown stride is the third row of #293 (about 276 draws per frame), so a before/after from a tester on both an NVIDIA and an AMD card would settle it. From reading only; I have no copy of the title.

**@⁠r4tedx** on GitHub · 2026-11-24 03:08 UTC · [original](https://github.com/Marvisak/VIctory/pull/193#issuecomment-7120815582) Review question on the fallback path. When the stride is not known statically, the three `idxen` sites now take a raw handle and compute the byte offset themselves: ```rust let byte = self.runtime_stride_offset(src, index, off)?; (self.handle(site, src, false, (11 | u, 0))?, [byte, iu, iu]) ``` The heap slot that handle resolves to still holds the view the title created, which for a structured buffer is a structured view (`descriptor/host.rs` mirrors the title's view as given). The description says of exactly that combination: > `dxil_kind = 11` (`ByteAddressBuffer`) reading a `Structured(12)` descriptor returns `0` on NVIDIA D3D12 (unlike WARP/AMD). So as far as I can read it, on NVIDIA these accesses would now read zeros where they were refused before, which is harder to notice than a dropped draw. Is there a place where the host makes a raw view for slots that are read through this path (I did not find one in the diff), or could the fallback be limited to slots known to hold raw views? `a structured buffer of unknown stride` is the third row of #293 (about 276 draws per frame), so a before/after from a tester on both an NVIDIA and an AMD card would settle it. From reading only; I have no copy of the title.
Author
Owner

@⁠EduAzevedo on GitHub · 2026-11-24 03:52 UTC · original

Measured 4322b61 on the retail shaders (v1.0.2.1, Series X package), offline with victory translate --jobs 8 --list against main d2a4bae, same 26,148 programs:

  • a structured buffer of unknown stride: 117 → 0.
  • 71 of the 117 now translate (69 compute, 1 mesh, 1 pixel). The other 46 stop next at a lane-mask join of an untracked mask (22), a lane mask read as data (18), a descriptor read only as data (4) and a lane mask holding lanes elsewhere read as data (2).
  • No program that translated on main stopped translating.

This is translation only; it does not exercise the runtime stride table in a game run.

AI-assisted.

**@⁠EduAzevedo** on GitHub · 2026-11-24 03:52 UTC · [original](https://github.com/Marvisak/VIctory/pull/193#issuecomment-7121499547) Measured `4322b61` on the retail shaders (v1.0.2.1, Series X package), offline with `victory translate --jobs 8 --list` against `main` `d2a4bae`, same 26,148 programs: - `a structured buffer of unknown stride`: **117 → 0**. - **71 of the 117 now translate** (69 compute, 1 mesh, 1 pixel). The other 46 stop next at `a lane-mask join of an untracked mask` (22), `a lane mask read as data` (18), `a descriptor read only as data` (4) and `a lane mask holding lanes elsewhere read as data` (2). - No program that translated on `main` stopped translating. This is translation only; it does not exercise the runtime stride table in a game run. AI-assisted.
Author
Owner

@⁠AnoHunted on GitHub · 2026-11-24 04:35 UTC · original

Tested 4322b61 merged onto main d2a4bae on NVIDIA GeForce RTX 5080, Windows 11, Rust 1.98.1, with dxil.dll validation on: pass.

  • cargo test -p victory-shader -- --test-threads=1: main 69 passed / 0 failed; this PR 70 passed / 0 failed (new tests: emit::tests::structured_buffer_unknown_stride_uses_runtime_stride_table).
  • cargo test --workspace -- --test-threads=1: main 264 passed / 0 failed / 4 ignored; this PR 265 passed / 0 failed / 4 ignored.
  • The new test passes on the GPU, but it only binds raw views (Stride::Raw / RawUav) to the slots read through the fallback. The PR description says the same combination with a Structured(12) descriptor read as ByteAddressBuffer (dxil_kind = 11) returns 0 on NVIDIA. In the game the slot holds the structured view the title built (descriptor/host.rs mirrors it as given), so the fallback would read zeros on NVIDIA rather than being refused. This matches the question above; the test does not catch it because it never uses a structured view. (From reading the diff; I did not run a structured-view variant.)
  • Suggested fix, untested: give the fallback a raw alias of each structured slot instead of the title's view. In HostHeap::make_at/mirror, for a structured buffer view in slot i, also write a RAW view of the same bytes (DXGI_FORMAT_R32_TYPELESS, Flags = RAW, FirstElement = first * stride / 4, NumElements = count * stride / 4) into slot i + N (N = view heap size, heap allocated at 2 * N). In runtime_stride_offset's callers use heap_slot + N for the dxil_kind = 11 handle, while stride is still read from table[slot]. Then add a Structured(12) case to the test, so it covers what the game does.
  • Separately, as noted above: when stage.stride_table is set but stride_table_gpu() returns None, draw.rs logs and continues with the root SRV unbound; skipping the draw would be safer than reading garbage.

No game files used.

**@⁠AnoHunted** on GitHub · 2026-11-24 04:35 UTC · [original](https://github.com/Marvisak/VIctory/pull/193#issuecomment-7122159696) Tested `4322b61` merged onto `main` `d2a4bae` on **NVIDIA GeForce RTX 5080**, Windows 11, Rust 1.98.1, with `dxil.dll` validation on: **pass**. - `cargo test -p victory-shader -- --test-threads=1`: main 69 passed / 0 failed; this PR 70 passed / 0 failed (new tests: `emit::tests::structured_buffer_unknown_stride_uses_runtime_stride_table`). - `cargo test --workspace -- --test-threads=1`: main 264 passed / 0 failed / 4 ignored; this PR 265 passed / 0 failed / 4 ignored. - The new test passes on the GPU, but it only binds **raw** views (`Stride::Raw` / `RawUav`) to the slots read through the fallback. The PR description says the same combination with a `Structured(12)` descriptor read as `ByteAddressBuffer` (`dxil_kind = 11`) returns `0` on NVIDIA. In the game the slot holds the structured view the title built (`descriptor/host.rs` mirrors it as given), so the fallback would read zeros on NVIDIA rather than being refused. This matches the question above; the test does not catch it because it never uses a structured view. (From reading the diff; I did not run a structured-view variant.) - Suggested fix, untested: give the fallback a raw alias of each structured slot instead of the title's view. In `HostHeap::make_at`/`mirror`, for a structured buffer view in slot `i`, also write a RAW view of the same bytes (`DXGI_FORMAT_R32_TYPELESS`, `Flags = RAW`, `FirstElement = first * stride / 4`, `NumElements = count * stride / 4`) into slot `i + N` (`N` = view heap size, heap allocated at `2 * N`). In `runtime_stride_offset`'s callers use `heap_slot + N` for the `dxil_kind = 11` handle, while `stride` is still read from `table[slot]`. Then add a `Structured(12)` case to the test, so it covers what the game does. - Separately, as noted above: when `stage.stride_table` is set but `stride_table_gpu()` returns `None`, `draw.rs` logs and continues with the root SRV unbound; skipping the draw would be safer than reading garbage. No game files used.
Author
Owner

@⁠Mesrine67 on GitHub · 2026-11-24 04:50 UTC · original

AMD validation on PC-MIKE (PR head 4322b61)

Hardware: AMD Radeon RX 6750 XT, driver 32.0.21045.29003. VICTORY_WARP and VICTORY_D3D12_WARP were unset.

  • cargo test --locked -p victory-shader structured_buffer_unknown_stride_uses_runtime_stride_table -- --nocapture --test-threads=1 passed. I confirmed the test created a D3D12 device with shader model 6.6, then ran the dispatch and assertion on the default hardware adapter.
  • cargo test --locked -p victory-shader -- --test-threads=1 passed: 70 passed.
  • On the unmodified PR head, cargo test --locked -p victory-gpu --lib -- --test-threads=1 fails to compile: crates/victory-gpu/src/host.rs defines mod tests at lines 252 and 1974. This commit renames the existing mod batch at the latter location to mod tests. Renaming that second module back to batch locally allowed the suite to build and pass: 43 passed, 1 ignored.

Please restore a unique module name for the latter block before merge. These are synthetic D3D12 tests; they do not yet verify the in-game world render.

**@⁠Mesrine67** on GitHub · 2026-11-24 04:50 UTC · [original](https://github.com/Marvisak/VIctory/pull/193#issuecomment-7122390323) ### AMD validation on PC-MIKE (PR head 4322b61) Hardware: AMD Radeon RX 6750 XT, driver 32.0.21045.29003. `VICTORY_WARP` and `VICTORY_D3D12_WARP` were unset. - `cargo test --locked -p victory-shader structured_buffer_unknown_stride_uses_runtime_stride_table -- --nocapture --test-threads=1` passed. I confirmed the test created a D3D12 device with shader model 6.6, then ran the dispatch and assertion on the default hardware adapter. - `cargo test --locked -p victory-shader -- --test-threads=1` passed: 70 passed. - On the unmodified PR head, `cargo test --locked -p victory-gpu --lib -- --test-threads=1` fails to compile: `crates/victory-gpu/src/host.rs` defines `mod tests` at lines 252 and 1974. This commit renames the existing `mod batch` at the latter location to `mod tests`. Renaming that second module back to `batch` locally allowed the suite to build and pass: 43 passed, 1 ignored. Please restore a unique module name for the latter block before merge. These are synthetic D3D12 tests; they do not yet verify the in-game world render.
Author
Owner

@⁠marquezinii on GitHub · 2026-11-24 04:51 UTC · original

Ran 4322b61 merged with main (d2a4bae) on an NVIDIA RTX 5070 (driver 621.24), Windows 11, the SDK's dxil.dll validating: cargo test -p victory-shader 70 passed, cargo test -p victory-gpu 43 passed. Then a probe through the runtime-stride path: a compute program that loads [index, offset] from slot 0 and writes the loaded dword to a raw UAV, over data dwords 100..111, with the table entry and the bound view varied. Every module validates.

slot 0 view, table entry, index, offset RTX 5070 WARP console
raw view, 12, 2, 4 107 107 107
structured view (12), 12, 2, 4 0 107 107
typed RGBA32F view, 16 0 0 109
static path, structured (12), as on main 107 107 107
raw view, 0 101 101 101
raw view, 6, 1, 4 102 102 0x00670000

So the hardware confirms the concern raised above about the raw handle: the fallback's handle(..., (11|u, 0)) is a raw handle over whatever view the title put in the slot, and over a structured view NVIDIA returns 0 (WARP happens to return the data), over a typed view both return 0. The programs this lets translate would read zeros on NVIDIA instead of being refused. Limiting the fallback to slots that hold raw views, or a raw alias slot as suggested above, would avoid it. Stores and atomics through a structured UAV take the same handle; the test harness has no structured UAV, so I could not run that.

A second case, not raised yet: the condition now also lets a known stride that is not a multiple of 4 (2, 6, ...) take the runtime path, where it used to be refused. The runtime path issues a rawBufferLoad with alignment 4, which drops the low address bits, so stride 6, index 1, offset 4 reads dword 2 (102) instead of bytes 10..13. The table can hold such strides: view_stride falls back to the format size for typed views. Keeping the refusal for a nonzero static stride that is not a multiple of 4 would be safer.

Also: StrideTable::new returns None without a log line when it fails, which would make an unbound table (the point raised above about draw.rs) hard to see in a report.

An index whose index * stride passes 2^32 wraps on both GPUs, but the existing static structured path wraps the same way, so that is not new here.

Not covered: the title (no game data here).

**@⁠marquezinii** on GitHub · 2026-11-24 04:51 UTC · [original](https://github.com/Marvisak/VIctory/pull/193#issuecomment-7122402744) Ran `4322b61` merged with `main` (`d2a4bae`) on an NVIDIA RTX 5070 (driver 621.24), Windows 11, the SDK's `dxil.dll` validating: `cargo test -p victory-shader` 70 passed, `cargo test -p victory-gpu` 43 passed. Then a probe through the runtime-stride path: a compute program that loads `[index, offset]` from slot 0 and writes the loaded dword to a raw UAV, over data dwords 100..111, with the table entry and the bound view varied. Every module validates. | slot 0 view, table entry, index, offset | RTX 5070 | WARP | console | |---|---|---|---| | raw view, 12, 2, 4 | 107 | 107 | 107 | | **structured view (12), 12, 2, 4** | **0** | 107 | 107 | | **typed RGBA32F view, 16** | **0** | **0** | 109 | | static path, structured (12), as on `main` | 107 | 107 | 107 | | raw view, 0 | 101 | 101 | 101 | | **raw view, 6, 1, 4** | **102** | **102** | `0x00670000` | So the hardware confirms the concern raised above about the raw handle: the fallback's `handle(..., (11|u, 0))` is a raw handle over whatever view the title put in the slot, and over a structured view NVIDIA returns 0 (WARP happens to return the data), over a typed view both return 0. The programs this lets translate would read zeros on NVIDIA instead of being refused. Limiting the fallback to slots that hold raw views, or a raw alias slot as suggested above, would avoid it. Stores and atomics through a structured UAV take the same handle; the test harness has no structured UAV, so I could not run that. A second case, not raised yet: the condition now also lets a known stride that is not a multiple of 4 (2, 6, ...) take the runtime path, where it used to be refused. The runtime path issues a `rawBufferLoad` with alignment 4, which drops the low address bits, so stride 6, index 1, offset 4 reads dword 2 (102) instead of bytes 10..13. The table can hold such strides: `view_stride` falls back to the format size for typed views. Keeping the refusal for a nonzero static stride that is not a multiple of 4 would be safer. Also: `StrideTable::new` returns `None` without a log line when it fails, which would make an unbound table (the point raised above about `draw.rs`) hard to see in a report. An index whose `index * stride` passes 2^32 wraps on both GPUs, but the existing static structured path wraps the same way, so that is not new here. Not covered: the title (no game data here).
Author
Owner

@⁠upipibi on GitHub · 2026-11-24 05:51 UTC · original

Independent check of head 4322b61 merged onto main d2a4bae. I read the comments above first. The main problem is already stated (the fallback takes a raw handle over whatever view the title put in the slot); I can confirm it on a third NVIDIA card, and I have one correction and two smaller points that are not above.

Confirmed on an RTX 3070 (driver 616.56): the PR's own test structured_buffer_unknown_stride_uses_runtime_stride_table, with only the SRV in slot 0 changed:

slot 0 view value loaded (want 107) atomics (want 20)
raw (as in the PR) 107 20
structured, stride 12 0 20
typed RGBA32F 0 20

So on this card too the programs this lets translate would read zeros from the structured views the title creates. The test binds only raw views, so no run of it shows this; and per the table posted above WARP returns the data through a structured view anyway, so a WARP-only runner would not show it even with a structured case.

A correction on the stride-6 case raised above (stride 6, index 1, offset 4, where the runtime path reads dword 2). By the RDNA2 ISA (30-November-2020), 8.1, p. 64, that is what the hardware does in its default mode: "For Dword or larger reads or writes of non-formatted ops (such as BUFFER_LOAD_DWORD), the two LSBs of the byte-address are ignored, thus forcing Dword alignment." (It is configurable: SH_MEM_CONFIG.alignment_mode DWORD / DWORD_STRICT / STRICT / UNALIGNED, same page.) So rawBufferLoad at byte 10 reading dword 2 agrees with the ISA unless the console runs in UNALIGNED mode, which I cannot tell. I would not refuse strides that are not multiples of 4 on that ground alone.

Against the ISA otherwise

  • The offset itself is right: 8.1.8, p. 65, buffer resource, "linear (stride * index + offset)", with stride from the descriptor; the PR computes index * stride + off.
  • Bounds differ within an element. ISA 8.1, p. 62: OOB = (index >= NumRecords() || (offset+payload > stride)) when the stride is not 0, and "Reads that go out-of-range return zero ... Writes that are out-of-range do not write anything." Through a raw handle an off at or past the stride reads or writes the next element instead. Only programs that address past their element hit it; worth a shortcut: comment.
  • A slot whose table entry is 0 (a null or unmirrored view, a texture) gives index * 0 + off: every index reads element 0, silently.

Smaller points not raised above

  • Source::Phi is handled by heap_slot but no test reaches it; the three sites in the test all use a Loaded descriptor.
  • The victory-gpu part reformats whole files that main does not keep rustfmt-clean (cargo fmt --all --check on main reports diffs in them): most of the 43 lines removed from descriptor/host.rs, draw.rs and pipeline/host.rs are line wraps unrelated to the change. That is what made the merges reported above conflict; leaving those lines alone would make this much easier to stack.
  • Merged onto current main, cargo check -p victory-gpu --tests compiles here, so the duplicate mod tests reported above is a matter of rebasing onto d2a4bae.

Run on hardware. NVIDIA RTX 3070, driver 616.56, Windows 11, Rust 1.98.1, dxil.dll from the Windows SDK 10.0.26100 validating; cargo test -p victory-shader -- --test-threads=1: 70 passed, 0 failed (main: 69). The two extra view kinds in the table above are a local change to the PR's test, run once each.

Verdict from here: the stride table and the offset are right; the handle is the problem. As it stands this turns a refusal into zeros on NVIDIA, so it should not go in without the raw alias (or a fallback limited to raw slots) suggested above, and a structured-view case in the test.

Not checked: the title (no game files here), AMD hardware, stores and atomics through a structured UAV.

AI-assisted (Claude Code).

**@⁠upipibi** on GitHub · 2026-11-24 05:51 UTC · [original](https://github.com/Marvisak/VIctory/pull/193#issuecomment-7123338714) Independent check of head `4322b61` merged onto `main` `d2a4bae`. I read the comments above first. The main problem is already stated (the fallback takes a raw handle over whatever view the title put in the slot); I can confirm it on a third NVIDIA card, and I have one correction and two smaller points that are not above. **Confirmed on an RTX 3070** (driver 616.56): the PR's own test `structured_buffer_unknown_stride_uses_runtime_stride_table`, with only the SRV in slot 0 changed: | slot 0 view | value loaded (want 107) | atomics (want 20) | |---|---|---| | raw (as in the PR) | 107 | 20 | | structured, stride 12 | **0** | 20 | | typed RGBA32F | **0** | 20 | So on this card too the programs this lets translate would read zeros from the structured views the title creates. The test binds only raw views, so no run of it shows this; and per the table posted above WARP returns the data through a structured view anyway, so a WARP-only runner would not show it even with a structured case. **A correction on the stride-6 case** raised above (stride 6, index 1, offset 4, where the runtime path reads dword 2). By the RDNA2 ISA (30-November-2020), 8.1, p. 64, that is what the hardware does in its default mode: "For Dword or larger reads or writes of non-formatted ops (such as BUFFER_LOAD_DWORD), the two LSBs of the byte-address are ignored, thus forcing Dword alignment." (It is configurable: `SH_MEM_CONFIG.alignment_mode` DWORD / DWORD_STRICT / STRICT / UNALIGNED, same page.) So `rawBufferLoad` at byte 10 reading dword 2 agrees with the ISA unless the console runs in UNALIGNED mode, which I cannot tell. I would not refuse strides that are not multiples of 4 on that ground alone. **Against the ISA otherwise** - The offset itself is right: 8.1.8, p. 65, buffer resource, "linear (stride * index + offset)", with stride from the descriptor; the PR computes `index * stride + off`. - Bounds differ within an element. ISA 8.1, p. 62: `OOB = (index >= NumRecords() || (offset+payload > stride))` when the stride is not 0, and "Reads that go out-of-range return zero ... Writes that are out-of-range do not write anything." Through a raw handle an `off` at or past the stride reads or writes the next element instead. Only programs that address past their element hit it; worth a `shortcut:` comment. - A slot whose table entry is 0 (a null or unmirrored view, a texture) gives `index * 0 + off`: every index reads element 0, silently. **Smaller points not raised above** - `Source::Phi` is handled by `heap_slot` but no test reaches it; the three sites in the test all use a `Loaded` descriptor. - The victory-gpu part reformats whole files that `main` does not keep rustfmt-clean (`cargo fmt --all --check` on `main` reports diffs in them): most of the 43 lines removed from `descriptor/host.rs`, `draw.rs` and `pipeline/host.rs` are line wraps unrelated to the change. That is what made the merges reported above conflict; leaving those lines alone would make this much easier to stack. - Merged onto current `main`, `cargo check -p victory-gpu --tests` compiles here, so the duplicate `mod tests` reported above is a matter of rebasing onto `d2a4bae`. **Run on hardware.** NVIDIA RTX 3070, driver 616.56, Windows 11, Rust 1.98.1, `dxil.dll` from the Windows SDK 10.0.26100 validating; `cargo test -p victory-shader -- --test-threads=1`: **70 passed, 0 failed** (`main`: 69). The two extra view kinds in the table above are a local change to the PR's test, run once each. Verdict from here: the stride table and the offset are right; the handle is the problem. As it stands this turns a refusal into zeros on NVIDIA, so it should not go in without the raw alias (or a fallback limited to raw slots) suggested above, and a structured-view case in the test. Not checked: the title (no game files here), AMD hardware, stores and atomics through a structured UAV. AI-assisted (Claude Code).
Author
Owner

@⁠aycow on GitHub · 2026-11-24 06:34 UTC · original

@⁠n-romanovich I’m independently checking the descriptor-kind issue reported by @⁠marquezinii on AMD, NVIDIA and WARP. The original synthetic matrix will cover typed and structured SRVs, UAV stores and atomics, differing strides and bounds, and descriptor and stride-metadata lifetime across a fence. Are you already implementing a raw-view alias or versioned stride metadata? I’ll bring the results back here so the fixture or fix can support your PR.

**@⁠aycow** on GitHub · 2026-11-24 06:34 UTC · [original](https://github.com/Marvisak/VIctory/pull/193#issuecomment-7124072112) @⁠n-romanovich I’m independently checking the descriptor-kind issue reported by @⁠marquezinii on AMD, NVIDIA and WARP. The original synthetic matrix will cover typed and structured SRVs, UAV stores and atomics, differing strides and bounds, and descriptor and stride-metadata lifetime across a fence. Are you already implementing a raw-view alias or versioned stride metadata? I’ll bring the results back here so the fixture or fix can support your PR.
Author
Owner

@⁠aycow on GitHub · 2026-11-24 06:46 UTC · original

I ran an original fixture using DXIL generated by 4322b61. AMD Radeon Graphics, RTX 5070 Laptop and WARP matched the complete CPU readback with the debug layer and full GPU-based validation using both native structured views and separate view-bounded raw aliases. This covered 8/12/16/20/32-byte strides, mixed strides, a typed RGBA32F SRV, structured UAV stores and atomics, and unchanged sentinel words.

In a separate characterization of the original descriptor-kind mismatch, NVIDIA read zero through both structured and typed SRVs. WARP read the structured data and returned zero for the typed view. The fixture also showed that flat address calculation can cross an element boundary within the view. The stride-6 control dword-aligned the address on all three adapters, so the console reference depends on the instruction's alignment rule. A fence-gated run returned the right results with immutable descriptor and metadata pairs. A dispatch using mutable shared stride storage observed the replacement value.

The test-only branch is based on your head. Compile with cargo test --locked -p victory-shader --no-run, stage the Agility SDK 1.620.2 DLLs under the test executable's D3D12 directory, then run the ignored tests structured_stride_alias_matrix, structured_stride_bounds and structured_stride_fence_lifetime separately with --nocapture. Exact fixture

**@⁠aycow** on GitHub · 2026-11-24 06:46 UTC · [original](https://github.com/Marvisak/VIctory/pull/193#issuecomment-7124282704) I ran an original fixture using DXIL generated by `4322b61`. AMD Radeon Graphics, RTX 5070 Laptop and WARP matched the complete CPU readback with the debug layer and full GPU-based validation using both native structured views and separate view-bounded raw aliases. This covered 8/12/16/20/32-byte strides, mixed strides, a typed RGBA32F SRV, structured UAV stores and atomics, and unchanged sentinel words. In a separate characterization of the original descriptor-kind mismatch, NVIDIA read zero through both structured and typed SRVs. WARP read the structured data and returned zero for the typed view. The fixture also showed that flat address calculation can cross an element boundary within the view. The stride-6 control dword-aligned the address on all three adapters, so the console reference depends on the instruction's alignment rule. A fence-gated run returned the right results with immutable descriptor and metadata pairs. A dispatch using mutable shared stride storage observed the replacement value. The [test-only branch](https://github.com/aycow/VIctory/tree/test/structured-stride-validation) is based on your head. Compile with `cargo test --locked -p victory-shader --no-run`, stage the Agility SDK 1.620.2 DLLs under the test executable's `D3D12` directory, then run the ignored tests `structured_stride_alias_matrix`, `structured_stride_bounds` and `structured_stride_fence_lifetime` separately with `--nocapture`. [Exact fixture](https://github.com/aycow/VIctory/blob/19d5efb591b5840142debcd0451827b580d03894/crates/victory-shader/src/emit/stride_tests.rs)
Author
Owner

@⁠r4tedx on GitHub · 2026-11-24 07:08 UTC · original

@⁠n-romanovich @⁠aycow a fix for the view-kind problem discussed above is up as #704, stacked on this PR's head 4322b61 (merged with main). @⁠n-romanovich, you are welcome to take its three commits into this PR instead; it only makes sense on top of yours.

It is the raw-alias route aycow asked about: each table entry gains the heap slot of a raw view of the same bytes, the GPU side makes that view whenever it makes a structured or typed buffer view, and the shader makes its raw handle from the slot the entry names. The handle's kind then always matches the view.

Two things from the work that bear on the discussion here, measured on an RTX 5070, a Radeon integrated GPU and WARP with hand-assembled programs:

  • The "0" on NVIDIA is a wrong address, not a refused read. With a buffer larger than this PR's 12-dword test buffer, a raw handle over a structured SRV on the RTX 5070 reads byte B x 3 for a stride of 12 and B x 4 for a stride of 16 or an RGBA32F view, and byte B for a stride of 20: 121 for the expected 107, 136 for 109. With 12 dwords the wrong byte is past the end, hence 0.
  • Choosing a structured handle in the shader does not work either: the RTX 5070 addresses a structured load by the view's stride, the Radeon and WARP by the stride the shader declares.

What #704 does not fix, and it matters for the programs this is wanted for: a buffer view in a slot that a shader reaches only through an index loaded at run time is still a null view on the host (HostHeap::mirror makes buffer views only for the slots a dispatch names), so those reads still return zeros.

@⁠aycow your fixture covers more than my tests do (the debug layer, GPU-based validation, 8- and 32-byte strides, lifetime across a fence). If you run it against #704's head 30a93f9, the result belongs on that PR.

The title was not used in these tests. AI-assisted.

**@⁠r4tedx** on GitHub · 2026-11-24 07:08 UTC · [original](https://github.com/Marvisak/VIctory/pull/193#issuecomment-7124665520) @⁠n-romanovich @⁠aycow a fix for the view-kind problem discussed above is up as #704, stacked on this PR's head `4322b61` (merged with `main`). @⁠n-romanovich, you are welcome to take its three commits into this PR instead; it only makes sense on top of yours. It is the raw-alias route aycow asked about: each table entry gains the heap slot of a raw view of the same bytes, the GPU side makes that view whenever it makes a structured or typed buffer view, and the shader makes its raw handle from the slot the entry names. The handle's kind then always matches the view. Two things from the work that bear on the discussion here, measured on an RTX 5070, a Radeon integrated GPU and WARP with hand-assembled programs: - **The "0" on NVIDIA is a wrong address, not a refused read.** With a buffer larger than this PR's 12-dword test buffer, a raw handle over a structured SRV on the RTX 5070 reads byte B x 3 for a stride of 12 and B x 4 for a stride of 16 or an RGBA32F view, and byte B for a stride of 20: 121 for the expected 107, 136 for 109. With 12 dwords the wrong byte is past the end, hence 0. - **Choosing a structured handle in the shader does not work either:** the RTX 5070 addresses a structured load by the view's stride, the Radeon and WARP by the stride the shader declares. What #704 does not fix, and it matters for the programs this is wanted for: a buffer view in a slot that a shader reaches only through an index loaded at run time is still a null view on the host (`HostHeap::mirror` makes buffer views only for the slots a dispatch names), so those reads still return zeros. @⁠aycow your fixture covers more than my tests do (the debug layer, GPU-based validation, 8- and 32-byte strides, lifetime across a fence). If you run it against #704's head `30a93f9`, the result belongs on that PR. The title was not used in these tests. AI-assisted.
Author
Owner

@⁠Mesrine67 on GitHub · 2026-11-24 07:18 UTC · original

AMD and WARP reproduction of the stride fixture

I ran the three ignored D3D12 validation tests from aycow/VIctory commit 19d5efb591b5840142debcd0451827b580d03894, whose parent is this PR's current head 4322b61328e158b4f7619333a163148a92de22c8. The fixture used D3D12 Agility SDK 1.620.2 with the debug layer and GPU-based validation enabled on Windows 11, an AMD Radeon RX 6750 XT, and WARP (Microsoft Basic Render Driver). I narrowed the local adapter list to AMD and WARP. All three tests passed on both adapters.

  • structured_stride_alias_matrix: strides 8, 12, 16, 20, and 32, typed aliases, and mixed source/destination strides matched the expected output.
  • structured_stride_fence_lifetime: old and new descriptor/metadata generations produced the expected results; overwriting the shared mapped stride table before the queue fence released exposed the replacement stride, reproducing the lifetime race.
  • structured_stride_bounds: reproduced cross-record and zero-stride alias behavior; the descriptor extent remained enforced.

I did not run structured_stride_incompatible_descriptor_characterization; it disables validation and intentionally binds incompatible descriptor kinds. These are synthetic GPU tests only: they do not execute GTA VI or verify its in-game rendering.

**@⁠Mesrine67** on GitHub · 2026-11-24 07:18 UTC · [original](https://github.com/Marvisak/VIctory/pull/193#issuecomment-7124844486) ### AMD and WARP reproduction of the stride fixture I ran the three ignored D3D12 validation tests from `aycow/VIctory` commit `19d5efb591b5840142debcd0451827b580d03894`, whose parent is this PR's current head `4322b61328e158b4f7619333a163148a92de22c8`. The fixture used D3D12 Agility SDK 1.620.2 with the debug layer and GPU-based validation enabled on Windows 11, an AMD Radeon RX 6750 XT, and WARP (`Microsoft Basic Render Driver`). I narrowed the local adapter list to AMD and WARP. All three tests passed on both adapters. - `structured_stride_alias_matrix`: strides 8, 12, 16, 20, and 32, typed aliases, and mixed source/destination strides matched the expected output. - `structured_stride_fence_lifetime`: old and new descriptor/metadata generations produced the expected results; overwriting the shared mapped stride table before the queue fence released exposed the replacement stride, reproducing the lifetime race. - `structured_stride_bounds`: reproduced cross-record and zero-stride alias behavior; the descriptor extent remained enforced. I did not run `structured_stride_incompatible_descriptor_characterization`; it disables validation and intentionally binds incompatible descriptor kinds. These are synthetic GPU tests only: they do not execute GTA VI or verify its in-game rendering.
Author
Owner

@⁠aycow on GitHub · 2026-11-24 07:29 UTC · original

@⁠n-romanovich I have a working opt-in production binder on 4322b61, with VICTORY_RUNTIME_STRIDE_ALIASES=1. It keeps the original view and binds a separate raw alias plus immutable alias-index, stride, and record-count metadata per dispatch. The emitter guards record boundaries for loads, stores and atomics. With the flag unset, the pipeline refuses the runtime-stride path.

AMD, RTX 5070 Laptop and WARP each passed 12 actual translated dispatches through State::bind and title-buffer copyback with DXIL validation and full GBV. The fixture replaces descriptors and releases the title heap before submitting both recorded lists. The focused scope covers exact compute table entries, structured views, and aligned dword accesses. Typed, counter, computed-offset, and #206's off-element cases still need separate coverage. #185 and #562 can reuse the backing and lease invariants when composed; those compositions require their own validation. I'd like to contribute this as a follow-up to your PR. Exact implementation and reproduction

**@⁠aycow** on GitHub · 2026-11-24 07:29 UTC · [original](https://github.com/Marvisak/VIctory/pull/193#issuecomment-7125055307) @⁠n-romanovich I have a working opt-in production binder on `4322b61`, with `VICTORY_RUNTIME_STRIDE_ALIASES=1`. It keeps the original view and binds a separate raw alias plus immutable alias-index, stride, and record-count metadata per dispatch. The emitter guards record boundaries for loads, stores and atomics. With the flag unset, the pipeline refuses the runtime-stride path. AMD, RTX 5070 Laptop and WARP each passed 12 actual translated dispatches through `State::bind` and title-buffer copyback with DXIL validation and full GBV. The fixture replaces descriptors and releases the title heap before submitting both recorded lists. The focused scope covers exact compute table entries, structured views, and aligned dword accesses. Typed, counter, computed-offset, and #206's off-element cases still need separate coverage. #185 and #562 can reuse the backing and lease invariants when composed; those compositions require their own validation. I'd like to contribute this as a follow-up to your PR. [Exact implementation and reproduction](https://github.com/aycow/VIctory/blob/79e88c646ea858ff9b1e9762833990d6bed31c16/docs/runtime-stride-aliases.md)
Author
Owner

@⁠n-romanovich on GitHub · 2026-11-24 08:45 UTC · original

Thanks for the review! Addressed the feedback and resolved the compilation issue in the latest commit. All tests pass cleanly.

**@⁠n-romanovich** on GitHub · 2026-11-24 08:45 UTC · [original](https://github.com/Marvisak/VIctory/pull/193#issuecomment-7126533196) Thanks for the review! Addressed the feedback and resolved the compilation issue in the latest commit. All tests pass cleanly.
Author
Owner

@⁠upipibi on GitHub · 2026-11-24 10:25 UTC · original

Re-check of the new head f99b792, merged onto main ffe310e, same card as before (RTX 3070, driver 616.56, SDK 10.0.26100 dxil.dll validating).

The main problem is unchanged. The PR's own test with only the SRV in slot 0 changed:

slot 0 view value loaded (want 107) atomics (want 20)
raw (as in the PR) 107 20
structured, stride 12 0 20
typed RGBA32F 0 20

These are the numbers I had on 4322b61. f99b792 does not touch how the handle is made, so the runtime path still takes a raw handle over whatever view the title put in the slot, and on NVIDIA that reads zeros from a structured or typed view. The test still binds only raw views. @⁠aycow's raw-alias binder above is the kind of change that would move this row.

My three smaller points

point on f99b792 status
an offset at or past the stride (ISA 8.1: out of range, reads 0) stride 12, index 2: offset 12 loads 109 and offset 16 loads 110, the next element's dwords remains
a table entry of 0 entry 0 for the slot: index 2, offset 4 loads 101 (element 0), no refusal or log remains
Source::Phi reaching heap_slot still no test in the PR. I ran one locally: two table loads chosen by a branch, slots with strides 12 and 8. It loads 107 on one path and 205 on the other, both right works; still untested in the PR

What the new commit does fix (points others raised, read in the diff, not run by me): a dispatch or draw whose shader reads the stride table without a host view heap is now dropped instead of run; NumElements is clamped to what is left of the buffer; the duplicate mod tests in victory-gpu/src/host.rs is renamed as on main. It also refuses static strides that are not a multiple of 4. As in my first note, the ISA's default mode ignores the two low address bits, so that refusal is cautious rather than required; it costs nothing wrong.

It does not merge or build on main as it is.

  • Conflicts in emit/lower.rs (main has a new lane_heap_index where this adds heap_slot; both functions are wanted), victory-gpu/src/descriptor/host.rs, draw.rs and host.rs (main already has bind returning bool and mod batch).
  • After resolving, two test sites need a line each: the PR's test calls resource::track with three arguments (main takes the structure as a fourth), and waterfall_tests.rs on main builds a HostShader without stride_table.

With those resolved locally, cargo test -p victory-shader -- --test-threads=1: 121 passed, 0 failed, 1 ignored (main: 120), and cargo check -p victory-gpu --tests compiles.

Verdict unchanged: the table and the offset arithmetic are right and the phi path works, but this still turns a refusal into zeros for structured and typed views on NVIDIA. It needs the raw alias (or a fallback limited to slots known to hold raw views) and a structured-view case in its test before it goes in.

Not checked: the title (no game files here), AMD hardware, the victory-gpu changes at run time.

AI-assisted (Claude Code).

**@⁠upipibi** on GitHub · 2026-11-24 10:25 UTC · [original](https://github.com/Marvisak/VIctory/pull/193#issuecomment-7128755210) Re-check of the new head `f99b792`, merged onto `main` `ffe310e`, same card as before (RTX 3070, driver 616.56, SDK 10.0.26100 `dxil.dll` validating). **The main problem is unchanged.** The PR's own test with only the SRV in slot 0 changed: | slot 0 view | value loaded (want 107) | atomics (want 20) | |---|---|---| | raw (as in the PR) | 107 | 20 | | structured, stride 12 | **0** | 20 | | typed RGBA32F | **0** | 20 | These are the numbers I had on `4322b61`. `f99b792` does not touch how the handle is made, so the runtime path still takes a raw handle over whatever view the title put in the slot, and on NVIDIA that reads zeros from a structured or typed view. The test still binds only raw views. @⁠aycow's raw-alias binder above is the kind of change that would move this row. **My three smaller points** | point | on `f99b792` | status | |---|---|---| | an offset at or past the stride (ISA 8.1: out of range, reads 0) | stride 12, index 2: offset 12 loads 109 and offset 16 loads 110, the next element's dwords | remains | | a table entry of 0 | entry 0 for the slot: index 2, offset 4 loads 101 (element 0), no refusal or log | remains | | `Source::Phi` reaching `heap_slot` | still no test in the PR. I ran one locally: two table loads chosen by a branch, slots with strides 12 and 8. It loads 107 on one path and 205 on the other, both right | works; still untested in the PR | **What the new commit does fix** (points others raised, read in the diff, not run by me): a dispatch or draw whose shader reads the stride table without a host view heap is now dropped instead of run; `NumElements` is clamped to what is left of the buffer; the duplicate `mod tests` in `victory-gpu/src/host.rs` is renamed as on `main`. It also refuses static strides that are not a multiple of 4. As in my first note, the ISA's default mode ignores the two low address bits, so that refusal is cautious rather than required; it costs nothing wrong. **It does not merge or build on `main` as it is.** - Conflicts in `emit/lower.rs` (`main` has a new `lane_heap_index` where this adds `heap_slot`; both functions are wanted), `victory-gpu/src/descriptor/host.rs`, `draw.rs` and `host.rs` (`main` already has `bind` returning `bool` and `mod batch`). - After resolving, two test sites need a line each: the PR's test calls `resource::track` with three arguments (`main` takes the structure as a fourth), and `waterfall_tests.rs` on `main` builds a `HostShader` without `stride_table`. With those resolved locally, `cargo test -p victory-shader -- --test-threads=1`: **121 passed, 0 failed, 1 ignored** (`main`: 120), and `cargo check -p victory-gpu --tests` compiles. Verdict unchanged: the table and the offset arithmetic are right and the phi path works, but this still turns a refusal into zeros for structured and typed views on NVIDIA. It needs the raw alias (or a fallback limited to slots known to hold raw views) and a structured-view case in its test before it goes in. Not checked: the title (no game files here), AMD hardware, the `victory-gpu` changes at run time. AI-assisted (Claude Code).
Author
Owner

@⁠EduAzevedo on GitHub · 2026-11-24 13:06 UTC · original

Some in-game evidence for this PR, and a request.

On an RTX 2070 SUPER (Turing) I ran integration/testers (92bc27b) plus #638's diagnostics into the first playable section (VICTORY_SHOW_TARGET=busiest shows the G-buffer with people and objects; the final picture stays black). With VICTORY_PRODUCERS=1, 292 dropped programs had outputs that running draws then read (5,597 reader/producer pairs logged). The largest group with a known refusal is a structured buffer of unknown stride: 18 compute producers, 1,840 of those reads (about a third), among them the 7 most-read producers of the whole run. Offline this PR takes that refusal from 117 to 0 (my counts earlier in this thread).

The request: this branch's merge base is still 9aef3d9. Merging it here conflicts in 22 hunks with the integration tree (descriptor/host.rs, draw.rs, host.rs, pipeline/host.rs, emit/lower.rs) and in 8 with 8e79c80 + #493 + #189 + #206, so I can't test it in game without rewriting your code. A rebase on current main would let me run it into the world with those producers and report what changes.

AI-assisted.

**@⁠EduAzevedo** on GitHub · 2026-11-24 13:06 UTC · [original](https://github.com/Marvisak/VIctory/pull/193#issuecomment-7132369100) Some in-game evidence for this PR, and a request. On an RTX 2070 SUPER (Turing) I ran `integration/testers` (`92bc27b`) plus #638's diagnostics into the first playable section (`VICTORY_SHOW_TARGET=busiest` shows the G-buffer with people and objects; the final picture stays black). With `VICTORY_PRODUCERS=1`, 292 dropped programs had outputs that running draws then read (5,597 reader/producer pairs logged). The largest group with a known refusal is **`a structured buffer of unknown stride`: 18 compute producers, 1,840 of those reads (about a third)**, among them the 7 most-read producers of the whole run. Offline this PR takes that refusal from 117 to 0 (my counts earlier in this thread). The request: this branch's merge base is still `9aef3d9`. Merging it here conflicts in 22 hunks with the integration tree (`descriptor/host.rs`, `draw.rs`, `host.rs`, `pipeline/host.rs`, `emit/lower.rs`) and in 8 with `8e79c80` + #493 + #189 + #206, so I can't test it in game without rewriting your code. A rebase on current `main` would let me run it into the world with those producers and report what changes. AI-assisted.
Author
Owner

@⁠justlovett0 on GitHub · 2026-11-24 17:32 UTC · original

Runtime verification, Win10/RTX 3080 (driver 621.24), with #704 stacked: the "a structured buffer of unknown stride" class is gone at runtime (it was the dominant failure in our world computes before this). #704's raw-alias slots are what make it work on NVIDIA — without them the runtime-stride ByteAddressBuffer reads return 0 against the structured host views (the quirk noted here).

Build: main ffe310e + #175/#994/#302 + this + #704 + #309/#1067/#953 + copy fixes. The stride-table binding plus raw aliases let the culling/world computes run; combined with #1067 the in-game untranslated count fell 444 → 100.

One integration note: the capped-heap split interacts with #747 — with #704's alias region (2^16) and a full 2^18 dynamic pool, the mirrored title range is 1,000,000 − 262,144 − 65,536 = 672,320 slots, matching the #747 author's measured setup. The title writes ~1.1M slots, so high bindless indices still read the guard slot (the #747-part-2 / clamping work).

AI use: Qwen Code (underlying model name not disclosed by the tool); counts from run logs and a victory translate census of captured runtime containers.

**@⁠justlovett0** on GitHub · 2026-11-24 17:32 UTC · [original](https://github.com/Marvisak/VIctory/pull/193#issuecomment-7139346518) Runtime verification, Win10/RTX 3080 (driver 621.24), with #704 stacked: the "a structured buffer of unknown stride" class is **gone at runtime** (it was the dominant failure in our world computes before this). #704's raw-alias slots are what make it work on NVIDIA — without them the runtime-stride `ByteAddressBuffer` reads return 0 against the structured host views (the quirk noted here). Build: main `ffe310e` + #175/#994/#302 + this + #704 + #309/#1067/#953 + copy fixes. The stride-table binding plus raw aliases let the culling/world computes run; combined with #1067 the in-game untranslated count fell 444 → 100. One integration note: the capped-heap split interacts with #747 — with #704's alias region (2^16) and a full 2^18 dynamic pool, the mirrored title range is 1,000,000 − 262,144 − 65,536 = 672,320 slots, matching the #747 author's measured setup. The title writes ~1.1M slots, so high bindless indices still read the guard slot (the #747-part-2 / clamping work). AI use: Qwen Code (underlying model name not disclosed by the tool); counts from run logs and a `victory translate` census of captured runtime containers.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!193
No description provided.