fix(gpu): bind bounded single-descriptor tables for root SRVs and UAVs #3337

Open
legayclightning22 wants to merge 1 commit from upstream-pr/3337 into main
legayclightning22 commented 2026-11-26 18:58:31 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by legayclightning22 on 2026-11-26T18:58:31Z.


Summary

Binds bounded single-descriptor tables for root SRVs and UAVs in victory-gpu (crates/victory-gpu/src/draw.rs and crates/victory-gpu/src/pipeline/host.rs), with a VICTORY_ROOT_SRV_DIRECT opt-out for direct root binding.

Changes

  • Update root SRV and UAV binding paths in crates/victory-gpu/src/draw.rs and crates/victory-gpu/src/pipeline/host.rs to use bounded single-descriptor tables[cite: 18].
  • Add VICTORY_ROOT_SRV_DIRECT opt-out support and unit tests covering bounded root views and environment override behavior[cite: 18].

Verification

  • cargo test -p victory-gpu --lib[cite: 18]
  • cargo clippy --locked -p victory-gpu --all-targets -- -D warnings[cite: 18]
  • cargo xtask policy[cite: 18]
<!-- greyfinch-sync:Marvisak/VIctory:issue:5515644700 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3337). Originally posted by [legayclightning22](https://github.com/legayclightning22) on 2026-11-26T18:58:31Z. --- ## Summary Binds bounded single-descriptor tables for root SRVs and UAVs in `victory-gpu` (`crates/victory-gpu/src/draw.rs` and `crates/victory-gpu/src/pipeline/host.rs`), with a `VICTORY_ROOT_SRV_DIRECT` opt-out for direct root binding. ## Changes - Update root SRV and UAV binding paths in `crates/victory-gpu/src/draw.rs` and `crates/victory-gpu/src/pipeline/host.rs` to use bounded single-descriptor tables[cite: 18]. - Add `VICTORY_ROOT_SRV_DIRECT` opt-out support and unit tests covering bounded root views and environment override behavior[cite: 18]. ## Verification - `cargo test -p victory-gpu --lib`[cite: 18] - `cargo clippy --locked -p victory-gpu --all-targets -- -D warnings`[cite: 18] - `cargo xtask policy`[cite: 18]
Dukestar69 commented 2026-11-26 19:09:12 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T19:09:12Z.

Review: APPROVED


LGTM — verified on RTX 5090 (Windows / D3D12) against origin/main (63bcca4).

  • Binding bounded single-descriptor tables for root SRVs/UAVs (with opt-out preserving raw addresses) is cleanly scoped and verified on hardware.
  • cargo test -p victory-gpu --lib pipeline::host:: -- --test-threads=1: 7 passed, 0 failed (root_srv_direct_only_for_one, root_srv_direct_opt_out_keeps_raw_addresses, root_srvs_and_uavs_are_bounded_one_descriptor_tables).
  • cargo test -p victory-gpu --lib draw:: -- --test-threads=1: 20 passed, 0 failed.
  • cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6079338820 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3337#pullrequestreview-6079338820). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-26T19:09:12Z. **Review:** APPROVED --- LGTM — verified on RTX 5090 (Windows / D3D12) against `origin/main` (`63bcca4`). - Binding bounded single-descriptor tables for root SRVs/UAVs (with opt-out preserving raw addresses) is cleanly scoped and verified on hardware. - `cargo test -p victory-gpu --lib pipeline::host:: -- --test-threads=1`: 7 passed, 0 failed (`root_srv_direct_only_for_one`, `root_srv_direct_opt_out_keeps_raw_addresses`, `root_srvs_and_uavs_are_bounded_one_descriptor_tables`). - `cargo test -p victory-gpu --lib draw:: -- --test-threads=1`: 20 passed, 0 failed. - `cargo clippy -p victory-gpu --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
oni-swr commented 2026-11-26 19:16:39 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by oni-swr on 2026-11-26T19:16:39Z.


WARP/CPU verification of head 8dd2ca97 (claim: #1633)

Environment: Windows 11, WARP only (VICTORY_WARP=1, VICTORY_D3D12_WARP=1), dxil.dll from Windows SDK 10.0.26100.0 (VICTORY_DXIL), no physical GPU, no game files. -j 4, --locked, separate target dir. Control: origin/main @ 63bcca43. Merge: git merge-tree against current origin/main is clean (head is 1 commit ahead, 0 behind).

Check main 63bcca43 PR 8dd2ca97
cargo test -p victory-gpu 231 passed, 0 failed, 1 ignored 234 passed, 0 failed, 1 ignored (+3)
cargo clippy -p victory-gpu --all-targets -- -D warnings clean clean
xtask policy 191 files ok 191 files ok

New tests all pass on WARP: root_srvs_and_uavs_are_bounded_one_descriptor_tables, root_srv_direct_opt_out_keeps_raw_addresses, root_srv_direct_only_for_one. They are absent on control (added by this PR); I did not separately demonstrate them failing without the fix. Synthetic/unit tests only; no real-title rendering was checked.

AI disclosure: run by Claude Code (Claude Sonnet 5.5), coordinated by Antigravity.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7201399169 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3337#issuecomment-7201399169). Originally posted by [oni-swr](https://github.com/oni-swr) on 2026-11-26T19:16:39Z. --- **WARP/CPU verification of head `8dd2ca97`** (claim: #1633) Environment: Windows 11, **WARP only** (`VICTORY_WARP=1`, `VICTORY_D3D12_WARP=1`), `dxil.dll` from Windows SDK 10.0.26100.0 (`VICTORY_DXIL`), no physical GPU, no game files. `-j 4`, `--locked`, separate target dir. Control: `origin/main` @ `63bcca43`. Merge: `git merge-tree` against current `origin/main` is clean (head is 1 commit ahead, 0 behind). | Check | main `63bcca43` | PR `8dd2ca97` | |---|---|---| | `cargo test -p victory-gpu` | 231 passed, 0 failed, 1 ignored | 234 passed, 0 failed, 1 ignored (+3) | | `cargo clippy -p victory-gpu --all-targets -- -D warnings` | clean | clean | | `xtask policy` | 191 files ok | 191 files ok | New tests all pass on WARP: `root_srvs_and_uavs_are_bounded_one_descriptor_tables`, `root_srv_direct_opt_out_keeps_raw_addresses`, `root_srv_direct_only_for_one`. They are absent on control (added by this PR); I did not separately demonstrate them failing without the fix. Synthetic/unit tests only; no real-title rendering was checked. AI disclosure: run by Claude Code (Claude Sonnet 5.5), coordinated by Antigravity.
fuzeofficlal commented 2026-11-26 20:58:41 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T20:58:41Z.

Review: CHANGES_REQUESTED


Converting raw root SRVs/UAVs to bounded single-descriptor tables is a solid goal, and pipeline/host.rs cleanly switches root_srvs/root_uavs to D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE with the VICTORY_ROOT_SRV_DIRECT=1 opt-out. However, there is a silent data-corruption bug in State::root_table whenever a title binds a root SRV or root UAV at a non-zero offset inside a buffer.

Blocking issue: State::root_table discards the byte offset (crates/victory-gpu/src/draw.rs:1064, 1080-1092)

In crates/victory-gpu/src/draw.rs:

  • root_view_slot creates the raw view at first = 0 (shadow.start) and caches it per (key, copy, uav):
    host.raw_view_at(index, Some(&shadow.buffer), 0, shadow.range().1 & !3, uav);
    
  • root_table then calls root_view_slot and discards the returned offset (address - shadow.start):
    let (key, index, _) = self.root_view_slot(list, compute, slot, uav)?;
    

Reusing a first = 0 view only works for the is_root_view user-data path (victory-shader/src/emit/lower.rs:1695-1733, !self.root_memory), where the shader receives offset in a ROOT_VIEW_OFFSET user-data dword and adds it to every byte address. For shaders that populate stage.root_srvs / stage.root_uavs (victory-shader/src/emit/lower.rs:5447-5459, root_memory == true), root_view_offset() returns None (lower.rs:1724): the shader indexes directly from byte 0 of the bound resource, relying on the binding itself to start at address (as Set*RootShaderResourceView / Set*RootUnorderedAccessView(param, shadow.gpu(address)) did on main).

As a result, any root SRV/UAV bound at address > shadow.start:

  1. Reads from shadow.start + 0 instead of address — which is either unrefreshed zeros (because root_view_slot at line 1046 only refreshes [address..shadow.end]) or stale/unrelated data at offset 0.
  2. For root UAVs, writes to shadow.start + 0 instead of address, silently corrupting the start of the buffer (outside the declared gpu_writes(list, address, ...) range) while leaving address untouched.
  3. Also cannot reach past the 512 MiB (1 << 27 dwords) raw-view cap in HostHeap::raw_view_at if address is more than 512 MiB into a large buffer.

Live GPU reproduction (RTX 5090 & WARP, VICTORY_D3D12_DEBUG=1)

Dispatching a compute shader (ByteAddressBuffer : register(t0, space1) -> RWByteAddressBuffer : register(u1, space1), copying dword 0) with src[0x0] = 0xDEADBEEF, src[0x100] = 0xCAFEBABE, binding root SRV at src + 0x100 and root UAV at dst + 0x200:

  • Direct baseline (main / VICTORY_ROOT_SRV_DIRECT=1): dst[0x0] = 0x00000000, dst[0x200] = 0xcafebabe (RTX 5090 & WARP).
  • PR root_table (cold src[0]): dst[0x0] = 0x00000000, dst[0x200] = 0x00000000 (reads unrefreshed zeros at src[0]; RTX 5090 & WARP).
  • PR root_table (warm src[0]): dst[0x0] = 0xdeadbeef, dst[0x200] = 0x00000000 (reads wrong data from src[0] and writes it to dst[0] instead of dst[0x200]; RTX 5090 & WARP).

Note that the new test assertion in draw.rs:2784 only checks state.root_table(...) == heap_host.gpu(index) without actually dispatching a shader through the table at a non-zero offset.

Suggested fix

  • Have root_table create (and cache separately, keyed by (key, copy, offset, uav) or (key, address, uav)) a bounded raw view starting at first = offset with bytes = shadow.left(address) & !3 (requiring offset to be 4-byte aligned, and passing shadow.mark_entry(address) to host.set_mark for UAVs), rather than reusing root_view_slot's first = 0 descriptor.
  • Add an end-to-end GPU compute dispatch test exercising root_table on both a root SRV and a root UAV at non-zero offsets within their buffers, plus an out-of-bounds read past shadow.left(address) returning 0.
<!-- greyfinch-sync:Marvisak/VIctory:review:6080415053 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3337#pullrequestreview-6080415053). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T20:58:41Z. **Review:** CHANGES_REQUESTED --- Converting raw root SRVs/UAVs to bounded single-descriptor tables is a solid goal, and `pipeline/host.rs` cleanly switches `root_srvs`/`root_uavs` to `D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE` with the `VICTORY_ROOT_SRV_DIRECT=1` opt-out. However, there is a silent data-corruption bug in `State::root_table` whenever a title binds a root SRV or root UAV at a non-zero offset inside a buffer. ### Blocking issue: `State::root_table` discards the byte offset (`crates/victory-gpu/src/draw.rs:1064, 1080-1092`) In `crates/victory-gpu/src/draw.rs`: - `root_view_slot` creates the raw view at `first = 0` (`shadow.start`) and caches it per `(key, copy, uav)`: ```rust host.raw_view_at(index, Some(&shadow.buffer), 0, shadow.range().1 & !3, uav); ``` - `root_table` then calls `root_view_slot` and discards the returned `offset` (`address - shadow.start`): ```rust let (key, index, _) = self.root_view_slot(list, compute, slot, uav)?; ``` Reusing a `first = 0` view only works for the `is_root_view` user-data path (`victory-shader/src/emit/lower.rs:1695-1733`, `!self.root_memory`), where the shader receives `offset` in a `ROOT_VIEW_OFFSET` user-data dword and adds it to every byte address. For shaders that populate `stage.root_srvs` / `stage.root_uavs` (`victory-shader/src/emit/lower.rs:5447-5459`, `root_memory == true`), `root_view_offset()` returns `None` (`lower.rs:1724`): the shader indexes directly from byte `0` of the bound resource, relying on the binding itself to start at `address` (as `Set*RootShaderResourceView` / `Set*RootUnorderedAccessView(param, shadow.gpu(address))` did on `main`). As a result, any root SRV/UAV bound at `address > shadow.start`: 1. Reads from `shadow.start + 0` instead of `address` — which is either unrefreshed zeros (because `root_view_slot` at line 1046 only refreshes `[address..shadow.end]`) or stale/unrelated data at offset `0`. 2. For root UAVs, writes to `shadow.start + 0` instead of `address`, silently corrupting the start of the buffer (outside the declared `gpu_writes(list, address, ...)` range) while leaving `address` untouched. 3. Also cannot reach past the 512 MiB (`1 << 27` dwords) raw-view cap in `HostHeap::raw_view_at` if `address` is more than 512 MiB into a large buffer. ### Live GPU reproduction (RTX 5090 & WARP, `VICTORY_D3D12_DEBUG=1`) Dispatching a compute shader (`ByteAddressBuffer : register(t0, space1)` -> `RWByteAddressBuffer : register(u1, space1)`, copying dword 0) with `src[0x0] = 0xDEADBEEF`, `src[0x100] = 0xCAFEBABE`, binding root SRV at `src + 0x100` and root UAV at `dst + 0x200`: - Direct baseline (`main` / `VICTORY_ROOT_SRV_DIRECT=1`): `dst[0x0] = 0x00000000`, `dst[0x200] = 0xcafebabe` (RTX 5090 & WARP). - PR `root_table` (cold `src[0]`): `dst[0x0] = 0x00000000`, `dst[0x200] = 0x00000000` (reads unrefreshed zeros at `src[0]`; RTX 5090 & WARP). - PR `root_table` (warm `src[0]`): `dst[0x0] = 0xdeadbeef`, `dst[0x200] = 0x00000000` (reads wrong data from `src[0]` and writes it to `dst[0]` instead of `dst[0x200]`; RTX 5090 & WARP). Note that the new test assertion in `draw.rs:2784` only checks `state.root_table(...) == heap_host.gpu(index)` without actually dispatching a shader through the table at a non-zero offset. ### Suggested fix - Have `root_table` create (and cache separately, keyed by `(key, copy, offset, uav)` or `(key, address, uav)`) a bounded raw view starting at `first = offset` with `bytes = shadow.left(address) & !3` (requiring `offset` to be 4-byte aligned, and passing `shadow.mark_entry(address)` to `host.set_mark` for UAVs), rather than reusing `root_view_slot`'s `first = 0` descriptor. - Add an end-to-end GPU compute dispatch test exercising `root_table` on both a root SRV and a root UAV at non-zero offsets within their buffers, plus an out-of-bounds read past `shadow.left(address)` returning `0`.
legayclightning22 commented 2026-11-26 22:06:25 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by legayclightning22 on 2026-11-26T22:06:25Z.


Great catch—pushed 30beed1 updating State::root_table to create and cache its own bounded raw view keyed by (heap, copy, offset, uav) starting at first = offset with bytes = shadow.left(address) & !3 (requiring 4-byte alignment and calling shadow.mark_entry(address) for UAVs) instead of reusing root_view_slot's first = 0 descriptor. Added draw::tests::root_table_srv_uav_nonzero_offset_bounded exercising non-zero root SRV/UAV offsets and out-of-bounds reads returning 0, and re-verified draw:: tests, clippy --all-features -- -D warnings, and cargo xtask policy.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7204368108 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3337#issuecomment-7204368108). Originally posted by [legayclightning22](https://github.com/legayclightning22) on 2026-11-26T22:06:25Z. --- Great catch—pushed `30beed1` updating `State::root_table` to create and cache its own bounded raw view keyed by `(heap, copy, offset, uav)` starting at `first = offset` with `bytes = shadow.left(address) & !3` (requiring 4-byte alignment and calling `shadow.mark_entry(address)` for UAVs) instead of reusing `root_view_slot`'s `first = 0` descriptor. Added `draw::tests::root_table_srv_uav_nonzero_offset_bounded` exercising non-zero root SRV/UAV offsets and out-of-bounds reads returning `0`, and re-verified `draw::` tests, `clippy --all-features -- -D warnings`, and `cargo xtask policy`.
fuzeofficlal commented 2026-11-26 22:44:15 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T22:44:15Z.

Review: CHANGES_REQUESTED


Thanks for fixing the root_table non-zero offset handling (draw.rs:1130) and adding root_table_srv_uav_nonzero_offset_bounded. However, testing the updated head (30beed1f) end-to-end through State::bind on both RTX 5090 and WARP reproduced a blocking double-offset (2 * offset) silent data corruption bug for root SRVs/UAVs bound at non-zero offsets.

Blocking issue: ROOT_VIEW_OFFSET in State::bind still adds s.offset(address) on top of FirstElement = offset / 4

  • In State::root_view_slot (crates/victory-gpu/src/draw.rs:1069-1074), the descriptor now bakes offset into FirstElement = offset / 4:
    host.raw_view_at(index, Some(&shadow.buffer), offset, shadow.left(address) & !3, uav);
    host.set_mark(index, shadow.mark_entry(address));
    
  • However, State::bind (crates/victory-gpu/src/draw.rs:779-793) was not updated and still emits the full shadow buffer byte offset for victory_shader::emit::ROOT_VIEW_OFFSET:
    None if u.dword == victory_shader::emit::ROOT_VIEW_OFFSET => {
        match roots.get(u.slot as usize).copied() {
            Some(Root::View(address)) => {
                match crate::shadow::find(address, 1).map(|s| s.offset(address)) {
                    Some(offset) => offset, // <-- added a second time by the shader!
    
  • Because translated shaders add ROOT_VIEW_OFFSET to every byte offset when accessing ROOT_SRV_VIEW / ROOT_UAV_VIEW (crates/victory-shader/src/emit/mod.rs:33-47), any root SRV or UAV at a non-zero offset within its shadow buffer applies offset twice (FirstElement * 4 + ROOT_VIEW_OFFSET = 2 * offset):
    • Reads come from 2 * offset instead of offset (or silently read 0 when 2 * offset >= left).
    • Writes land at 2 * offset (clobbering neighboring data or silently dropping out-of-bounds writes, and marking the wrong 64 KiB write-mark page when (address & 0xFFFF) + offset >= 65536).

Live hardware & WARP repro (VICTORY_D3D12_DEBUG=1)

Lowered a minimal RDNA2 compute shader with victory_shader::emit::emit_with(..., Options { view_marks: true }) that copies dword 0 from root SRV slot 0 to root UAV slot 1, and dispatched it through State::bind with:

  • src[0x000] = 0xDEADBEEF, src[0x100] = 0xCAFEBABE, src[0x200] = 0xBAD00200
  • Root SRV slot 0 bound at src + 0x100, root UAV slot 1 bound at dst + 0x200

Observed results on both RTX 5090 and WARP (--features diagnostics, VICTORY_D3D12_DEBUG=1):

  • main (63bcca43): host[0x200] = 0xcafebabe, host[0x400] = 0x00000000, title[0x200] = 0xcafebabe, title[0x400] = 0x00000000 (correct).
  • PR #3337 (30beed1f): host[0x200] = 0x00000000, host[0x400] = 0xbad00200, title[0x200] = 0x00000000, title[0x400] = 0xbad00200 (read src[0x200] instead of src[0x100], left dst[0x200] untouched, and overwrote dst[0x400]).
  • Verified fix: Returning the unbaked sub-dword remainder (offset & 3, i.e., 0 for 4-byte-aligned addresses — or using self.root_view's returned offset directly) at crates/victory-gpu/src/draw.rs:787 immediately restores host[0x200] = 0xcafebabe, host[0x400] = 0x00000000, title[0x200] = 0xcafebabe, title[0x400] = 0x00000000 on both RTX 5090 and WARP with 0 Debug Layer errors.

Additional note

  • Keying root_slots by (key, copy, offset, uav) (draw.rs:1027) allocates a new dynamic descriptor slot for each distinct non-zero offset into the same shadow buffer (e.g., transient ring buffers), whereas main reused a single slot per (key, copy, uav) by passing offset via ROOT_VIEW_OFFSET. Worth verifying whether per-offset descriptor caching is necessary for ROOT_SRV_VIEW/ROOT_UAV_VIEW (or whether keeping the existing offset = 0 descriptor + ROOT_VIEW_OFFSET for root_view_slot and only bounding root_table / raw_view_at is simpler and avoids dynamic slot pressure). Also please add an end-to-end State::bind regression test covering non-zero root SRV/UAV offsets.
<!-- greyfinch-sync:Marvisak/VIctory:review:6081219457 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3337#pullrequestreview-6081219457). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T22:44:15Z. **Review:** CHANGES_REQUESTED --- Thanks for fixing the `root_table` non-zero offset handling (`draw.rs:1130`) and adding `root_table_srv_uav_nonzero_offset_bounded`. However, testing the updated head (`30beed1f`) end-to-end through `State::bind` on both RTX 5090 and WARP reproduced a blocking **double-offset (`2 * offset`) silent data corruption bug** for root SRVs/UAVs bound at non-zero offsets. ### Blocking issue: `ROOT_VIEW_OFFSET` in `State::bind` still adds `s.offset(address)` on top of `FirstElement = offset / 4` - In `State::root_view_slot` (`crates/victory-gpu/src/draw.rs:1069-1074`), the descriptor now bakes `offset` into `FirstElement = offset / 4`: ```rust host.raw_view_at(index, Some(&shadow.buffer), offset, shadow.left(address) & !3, uav); host.set_mark(index, shadow.mark_entry(address)); ``` - However, `State::bind` (`crates/victory-gpu/src/draw.rs:779-793`) was not updated and still emits the full shadow buffer byte offset for `victory_shader::emit::ROOT_VIEW_OFFSET`: ```rust None if u.dword == victory_shader::emit::ROOT_VIEW_OFFSET => { match roots.get(u.slot as usize).copied() { Some(Root::View(address)) => { match crate::shadow::find(address, 1).map(|s| s.offset(address)) { Some(offset) => offset, // <-- added a second time by the shader! ``` - Because translated shaders add `ROOT_VIEW_OFFSET` to every byte offset when accessing `ROOT_SRV_VIEW` / `ROOT_UAV_VIEW` (`crates/victory-shader/src/emit/mod.rs:33-47`), any root SRV or UAV at a non-zero offset within its shadow buffer applies `offset` **twice** (`FirstElement * 4 + ROOT_VIEW_OFFSET = 2 * offset`): - Reads come from `2 * offset` instead of `offset` (or silently read `0` when `2 * offset >= left`). - Writes land at `2 * offset` (clobbering neighboring data or silently dropping out-of-bounds writes, and marking the wrong 64 KiB write-mark page when `(address & 0xFFFF) + offset >= 65536`). ### Live hardware & WARP repro (`VICTORY_D3D12_DEBUG=1`) Lowered a minimal RDNA2 compute shader with `victory_shader::emit::emit_with(..., Options { view_marks: true })` that copies dword 0 from root SRV slot 0 to root UAV slot 1, and dispatched it through `State::bind` with: - `src[0x000] = 0xDEADBEEF`, `src[0x100] = 0xCAFEBABE`, `src[0x200] = 0xBAD00200` - Root SRV slot 0 bound at `src + 0x100`, root UAV slot 1 bound at `dst + 0x200` Observed results on both RTX 5090 and WARP (`--features diagnostics`, `VICTORY_D3D12_DEBUG=1`): - **`main` (`63bcca43`)**: `host[0x200] = 0xcafebabe`, `host[0x400] = 0x00000000`, `title[0x200] = 0xcafebabe`, `title[0x400] = 0x00000000` (correct). - **PR `#3337` (`30beed1f`)**: `host[0x200] = 0x00000000`, `host[0x400] = 0xbad00200`, `title[0x200] = 0x00000000`, `title[0x400] = 0xbad00200` (read `src[0x200]` instead of `src[0x100]`, left `dst[0x200]` untouched, and overwrote `dst[0x400]`). - **Verified fix**: Returning the unbaked sub-dword remainder (`offset & 3`, i.e., `0` for 4-byte-aligned addresses — or using `self.root_view`'s returned offset directly) at `crates/victory-gpu/src/draw.rs:787` immediately restores `host[0x200] = 0xcafebabe`, `host[0x400] = 0x00000000`, `title[0x200] = 0xcafebabe`, `title[0x400] = 0x00000000` on both RTX 5090 and WARP with 0 Debug Layer errors. ### Additional note - Keying `root_slots` by `(key, copy, offset, uav)` (`draw.rs:1027`) allocates a new dynamic descriptor slot for each distinct non-zero offset into the same shadow buffer (e.g., transient ring buffers), whereas `main` reused a single slot per `(key, copy, uav)` by passing `offset` via `ROOT_VIEW_OFFSET`. Worth verifying whether per-offset descriptor caching is necessary for `ROOT_SRV_VIEW`/`ROOT_UAV_VIEW` (or whether keeping the existing `offset = 0` descriptor + `ROOT_VIEW_OFFSET` for `root_view_slot` and only bounding `root_table` / `raw_view_at` is simpler and avoids dynamic slot pressure). Also please add an end-to-end `State::bind` regression test covering non-zero root SRV/UAV offsets.
fuzeofficlal commented 2026-11-27 01:12:11 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-27T01:12:11Z.

Review: APPROVED


The double-offset issue from the previous review is fixed cleanly: root_view_slot now keeps FirstElement = 0 (keyed on (key, copy, 0, uav)) for the ROOT_SRV_VIEW/ROOT_UAV_VIEW + ROOT_VIEW_OFFSET path, while root_table creates a separate bounded single-descriptor view starting at offset (keyed on (key, copy, offset, uav)) for root SRV/UAV descriptor tables, rejecting non-4-byte-aligned offsets cleanly.

Verified on b6550abe4cd730d2b60bb83926396ffffc3fbae5:

  • cargo xtask policy and cargo clippy --tests -p victory-gpu (default and --features diagnostics, -D warnings) pass cleanly.
  • draw::tests (22/22, including root_table_srv_uav_nonzero_offset_bounded and bind_root_srv_uav_nonzero_offsets) and pipeline::host::tests (7/7) pass on both RTX 5090 and WARP with VICTORY_D3D12_DEBUG=1.
  • Verified end-to-end State::bind -> Dispatch on both RTX 5090 and WARP (VICTORY_D3D12_DEBUG=1) with no title heap bound (memory_heap = true), non-zero offsets (src + 0x100 -> dst + 0x200), 10x repeated binds reusing the 2 cached dynamic slots, unaligned offset (+0x102) rejection, and both default bounded tables and VICTORY_ROOT_SRV_DIRECT=1: exact results and zero D3D12 debug layer messages.

(Note: the single CI failure on b6550abe was an unrelated timing flake in frame::tests::waits_end_on_ticks_and_count_frames — 235/236 victory-gpu tests including all draw::tests passed.)

<!-- greyfinch-sync:Marvisak/VIctory:review:6082193893 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3337#pullrequestreview-6082193893). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-27T01:12:11Z. **Review:** APPROVED --- The double-offset issue from the previous review is fixed cleanly: `root_view_slot` now keeps `FirstElement = 0` (keyed on `(key, copy, 0, uav)`) for the `ROOT_SRV_VIEW`/`ROOT_UAV_VIEW` + `ROOT_VIEW_OFFSET` path, while `root_table` creates a separate bounded single-descriptor view starting at `offset` (keyed on `(key, copy, offset, uav)`) for root SRV/UAV descriptor tables, rejecting non-4-byte-aligned offsets cleanly. Verified on `b6550abe4cd730d2b60bb83926396ffffc3fbae5`: - `cargo xtask policy` and `cargo clippy --tests -p victory-gpu` (default and `--features diagnostics`, `-D warnings`) pass cleanly. - `draw::tests` (22/22, including `root_table_srv_uav_nonzero_offset_bounded` and `bind_root_srv_uav_nonzero_offsets`) and `pipeline::host::tests` (7/7) pass on both RTX 5090 and WARP with `VICTORY_D3D12_DEBUG=1`. - Verified end-to-end `State::bind` -> `Dispatch` on both RTX 5090 and WARP (`VICTORY_D3D12_DEBUG=1`) with no title heap bound (`memory_heap = true`), non-zero offsets (`src + 0x100` -> `dst + 0x200`), 10x repeated binds reusing the 2 cached dynamic slots, unaligned offset (`+0x102`) rejection, and both default bounded tables and `VICTORY_ROOT_SRV_DIRECT=1`: exact results and zero D3D12 debug layer messages. *(Note: the single CI failure on `b6550abe` was an unrelated timing flake in `frame::tests::waits_end_on_ticks_and_count_frames` — 235/236 `victory-gpu` tests including all `draw::tests` passed.)*
legayclightning22 commented 2026-11-27 01:52:23 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by legayclightning22 on 2026-11-27T01:52:23Z.


Pushed <NEW_SHA> serializing the new non-zero offset compute dispatch tests with the existing draw.rs dispatch lock so frame::tests::waits_end_on_ticks_and_count_frames passes reliably under parallel cargo test. Re-verified full parallel victory-gpu lib tests, clippy --all-features -- -D warnings, and cargo xtask policy.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7207644430 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3337#issuecomment-7207644430). Originally posted by [legayclightning22](https://github.com/legayclightning22) on 2026-11-27T01:52:23Z. --- Pushed `<NEW_SHA>` serializing the new non-zero offset compute dispatch tests with the existing `draw.rs` dispatch lock so `frame::tests::waits_end_on_ticks_and_count_frames` passes reliably under parallel `cargo test`. Re-verified full parallel `victory-gpu` lib tests, `clippy --all-features -- -D warnings`, and `cargo xtask policy`.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3337:upstream-pr/3337'
git switch 'upstream-pr/3337'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3337'
git switch 'upstream-pr/3337'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3337'
git switch 'upstream-pr/3337'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3337'
git switch 'main'
git merge --squash 'upstream-pr/3337'
git switch 'main'
git merge --ff-only 'upstream-pr/3337'
git switch 'main'
git merge 'upstream-pr/3337'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
Marvisak/VIctory!3337
No description provided.