Structured buffers: runtime stride channel (design + anchors) #155

Open
opened 2026-11-26 03:52:28 +00:00 by github-bot · 3 comments
Owner

@⁠zebraso on GitHub · 2026-11-24 01:00 UTC · original

Structured-buffer accesses whose stride the shader analysis loses (buffer_load_dword ... idxen, buffer_store_dword ... idxen, atomics) currently fail translation (a structured buffer of unknown stride, 36 programs in the world run) or, under VICTORY_LOOSE_BUFFERS, read the wrong element (raw view at the instruction offset).

The descriptor's stride is known at bind time (D3D12_BUFFER_SRV.StructureByteStride, parsed today by descriptor/host.rs's element()) but there is no channel to the shader: the console S# is virtualized into a heap handle, so the emitted DXIL cannot compute index * stride.

Design (full note + anchors in docs/runtime-stride.md on branch sync):

  1. victory-shader: a stride-table root SRV (t0, space STRIDE_SPACE), one dword per host view-heap slot; at the three "unknown stride" sites emit slot = heap_index(load, first), stride = rawBufferLoad(table, slot * 4), address = index * stride + off. HostShader gains the table as a root SRV.
  2. signature.rs / pipeline/host.rs: declare and bind the table.
  3. descriptor/host.rs / draw.rs: keep slot -> StructureByteStride in sync with the heap (4 bytes per slot) and write it when a view is placed.

Success criterion: the 36 unknown stride translations disappear, and the AMD iGPU world run (VICTORY_D3D12_ADAPTER=amd, VICTORY_D3D12_DRED=1) no longer faults at 0x3598000 (or the fault moves to the next producer).

Context: on the iGPU the world reaches 1178 draws/frame with native wave64 (host wave lanes min=32 max=64, compute refusals 0) and then faults with page fault at 0x3598000 and NaN CBV constants — the garbage comes from the passes whose shaders are dropped. On NVIDIA the same garbage ends in DEVICE_HUNG (see #71).

**@⁠zebraso** on GitHub · 2026-11-24 01:00 UTC · [original](https://github.com/Marvisak/VIctory/issues/155) Structured-buffer accesses whose stride the shader analysis loses (`buffer_load_dword ... idxen`, `buffer_store_dword ... idxen`, atomics) currently fail translation (`a structured buffer of unknown stride`, 36 programs in the world run) or, under `VICTORY_LOOSE_BUFFERS`, read the wrong element (raw view at the instruction offset). The descriptor's stride is known at bind time (`D3D12_BUFFER_SRV.StructureByteStride`, parsed today by `descriptor/host.rs`'s element()) but there is no channel to the shader: the console S# is virtualized into a heap handle, so the emitted DXIL cannot compute `index * stride`. Design (full note + anchors in `docs/runtime-stride.md` on branch `sync`): 1. `victory-shader`: a stride-table root SRV (`t0, space STRIDE_SPACE`), one dword per host view-heap slot; at the three "unknown stride" sites emit `slot = heap_index(load, first)`, `stride = rawBufferLoad(table, slot * 4)`, `address = index * stride + off`. `HostShader` gains the table as a root SRV. 2. `signature.rs` / `pipeline/host.rs`: declare and bind the table. 3. `descriptor/host.rs` / `draw.rs`: keep `slot -> StructureByteStride` in sync with the heap (4 bytes per slot) and write it when a view is placed. Success criterion: the 36 `unknown stride` translations disappear, and the AMD iGPU world run (`VICTORY_D3D12_ADAPTER=amd`, `VICTORY_D3D12_DRED=1`) no longer faults at `0x3598000` (or the fault moves to the next producer). Context: on the iGPU the world reaches 1178 draws/frame with native wave64 (`host wave lanes min=32 max=64`, compute refusals 0) and then faults with `page fault at 0x3598000` and NaN CBV constants — the garbage comes from the passes whose shaders are dropped. On NVIDIA the same garbage ends in `DEVICE_HUNG` (see #71).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:52:28 +00:00
Author
Owner

@⁠Mesrine67 on GitHub · 2026-11-24 01:21 UTC · original

Rechecked against the current upstream main (d2a4bae) using the local game shader archive and translate --validate --jobs 8 (CPU-only; no game executable or GPU pipeline was launched). This run found 26,503 containers / 26,084 programs, emitted 22,156 DXIL containers, and validated 21,971.

The refusal a structured buffer of unknown stride accounts for 117 programs in this archive. The three refusal sites are in crates/victory-shader/src/emit/lower.rs around lines 5908, 5991, and 6052. The descriptor index flows through heap_index; host heap mirroring is in crates/victory-gpu/src/descriptor/host.rs::HostHeap::mirror, and crates/victory-gpu/src/draw.rs::State::tables can remap descriptor tables into dynamic slots.

This gives an up-to-date corpus check for the proposed runtime stride channel. I am checking the raw-view and dynamic-slot semantics before sending an implementation PR, so the extra byte-address calculation does not silently change how structured, typed, or raw descriptors are interpreted.

**@⁠Mesrine67** on GitHub · 2026-11-24 01:21 UTC · [original](https://github.com/Marvisak/VIctory/issues/155#issuecomment-7119020867) Rechecked against the current upstream `main` (`d2a4bae`) using the local game shader archive and `translate --validate --jobs 8` (CPU-only; no game executable or GPU pipeline was launched). This run found 26,503 containers / 26,084 programs, emitted 22,156 DXIL containers, and validated 21,971. The refusal `a structured buffer of unknown stride` accounts for 117 programs in this archive. The three refusal sites are in `crates/victory-shader/src/emit/lower.rs` around lines 5908, 5991, and 6052. The descriptor index flows through `heap_index`; host heap mirroring is in `crates/victory-gpu/src/descriptor/host.rs::HostHeap::mirror`, and `crates/victory-gpu/src/draw.rs::State::tables` can remap descriptor tables into dynamic slots. This gives an up-to-date corpus check for the proposed runtime stride channel. I am checking the raw-view and dynamic-slot semantics before sending an implementation PR, so the extra byte-address calculation does not silently change how structured, typed, or raw descriptors are interpreted.
Author
Owner

@⁠zebraso on GitHub · 2026-11-24 02:58 UTC · original

Regression found while running the retail title on NVIDIA (RTX 5080, driver 32.0.16.1714):

  • branch sync at 3258644, upstream main d2a4bae merged;
  • with the runtime stride table on (default), the title is removed during the loading screen:
    DEVICE_HUNG, DRED stops at dispatch 128x64x1 [compute 42683eebec081520], right after a
    texture upload (128x72x1 f41 mips 7);
  • the same build with VICTORY_STRIDE_TABLE=0 reaches the intro cutscene (text, ~1 fps in the
    world-load, 4032 draws/frame, 942 dropped) and does not crash there;
  • the commit before the table (bef8bde) behaves like VICTORY_STRIDE_TABLE=0 (cutscene).

So the table itself (or the t0, space 2 root SRV binding it adds) is what kills the loading
screen. Verified the benefit is real though: with the table on, a structured buffer of unknown stride disappears from the log (was 36 programs).

Repro: VICTORY_D3D12_ADAPTER unset, VICTORY_D3D12_DRED=1, target\release\victory.exe run C:\GTA6\GTA6.Xbox.v1.0.2.1-CYBERLEEK\game_scarlett_master.exe --execute.

**@⁠zebraso** on GitHub · 2026-11-24 02:58 UTC · [original](https://github.com/Marvisak/VIctory/issues/155#issuecomment-7120655063) Regression found while running the retail title on NVIDIA (RTX 5080, driver 32.0.16.1714): - branch `sync` at `3258644`, upstream main `d2a4bae` merged; - with the runtime stride table **on** (default), the title is removed during the loading screen: `DEVICE_HUNG`, DRED stops at `dispatch 128x64x1 [compute 42683eebec081520]`, right after a texture upload (`128x72x1 f41 mips 7`); - the same build with **`VICTORY_STRIDE_TABLE=0`** reaches the intro cutscene (text, ~1 fps in the world-load, 4032 draws/frame, 942 dropped) and does not crash there; - the commit **before** the table (`bef8bde`) behaves like `VICTORY_STRIDE_TABLE=0` (cutscene). So the table itself (or the `t0, space 2` root SRV binding it adds) is what kills the loading screen. Verified the benefit is real though: with the table on, `a structured buffer of unknown stride` disappears from the log (was 36 programs). Repro: `VICTORY_D3D12_ADAPTER` unset, `VICTORY_D3D12_DRED=1`, `target\release\victory.exe run C:\GTA6\GTA6.Xbox.v1.0.2.1-CYBERLEEK\game_scarlett_master.exe --execute`.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 01:46 UTC · original

Automated triage for the maintainers.

Part of this design is now in main. Commit 0b35b7f ("... bindless strides", 2026-11-24) added a per-slot view-stride table, VIEW_STRIDES. crates/victory-gpu/src/descriptor/host.rs keeps the table and draw.rs binds it as a root SRV. In crates/victory-shader/src/emit/lower.rs, Lower::view_stride and Lower::stride_at read it, so a heap-indexed buffer load by element (buffer, the used.is_none() && !typed case) now computes element × stride from the host's table. Indexed stores and atomics still stop with "a structured buffer of unknown stride" when the resource tracking has no stride for them (the stride < 4 checks in the store and atomic paths). That remainder is what is left of this request.

The implementation here is on a fork branch (sync). Pull requests are open to everyone, so please open one against the current main for the part that is still missing. Rebase it onto the table that is already there, and include the loading-screen DEVICE_HUNG you saw with the table on, so that can be reviewed together. Whether the remaining store and atomic sites should use the table is for the maintainers to decide.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 01:46 UTC · [original](https://github.com/Marvisak/VIctory/issues/155#issuecomment-7149934652) <!-- victory-issue-triage v1 verdict=tracked seen=2026-11-24T02:58:38Z at=2026-11-25T01:46:01Z --> Automated triage for the maintainers. Part of this design is now in `main`. Commit 0b35b7f ("... bindless strides", 2026-11-24) added a per-slot view-stride table, `VIEW_STRIDES`. `crates/victory-gpu/src/descriptor/host.rs` keeps the table and `draw.rs` binds it as a root SRV. In `crates/victory-shader/src/emit/lower.rs`, `Lower::view_stride` and `Lower::stride_at` read it, so a heap-indexed buffer load by element (`buffer`, the `used.is_none() && !typed` case) now computes element × stride from the host's table. Indexed stores and atomics still stop with "a structured buffer of unknown stride" when the resource tracking has no stride for them (the `stride < 4` checks in the store and atomic paths). That remainder is what is left of this request. The implementation here is on a fork branch (`sync`). Pull requests are open to everyone, so please open one against the current `main` for the part that is still missing. Rebase it onto the table that is already there, and include the loading-screen `DEVICE_HUNG` you saw with the table on, so that can be reviewed together. Whether the remaining store and atomic sites should use the table is for the maintainers to decide. --- _Generated by [Claude Code](https://claude.ai/code)_
This discussion has been locked. Commenting is limited to contributors.
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#155
No description provided.