GPU: make a structured buffer view off its host copy's elements a raw view #206

Closed
github-bot wants to merge 1 commit from gh-pr/206/head into gh-pr/206/base
Owner

@⁠AnoHunted on GitHub · 2026-11-24 01:25 UTC · original
AnoHunted:structured-view-raw-fallback → main · +254 −5 · 1 files · 1 commits · closed without merging

What

buffer_srv and buffer_uav (crates/victory-gpu/src/descriptor/host.rs) now make a structured buffer view
whose start in its host copy is not on an element as the raw view of the same bytes (R32_TYPELESS, raw flag,
first element and count in dwords), when that start is 16-byte aligned. Views on an element are made as before.
Everything else (typed views, strides that are not a multiple of 4, starts that are not 16-byte aligned) is still
refused with the same log line. The math is in a small raw_window helper, with a unit test and a host GPU test.

Why

A title buffer view is made on the host copy of the innermost title buffer that holds it, with its first element
moved by its offset in that copy (FirstElement += offset / stride). A view of memory inside a bigger title buffer
can start anywhere in it. The log in #16 already has buffer view not on an element of its host copy with
element=32 on the way to the menus: a 32-byte-stride view 16 bytes past an element. D3D12 puts structured
element i at byte i * stride of the resource, so that start cannot be written as a structured view of the copy.
The slot stayed null: shaders read zeros through it and their writes were lost.

Why a raw view and not a host copy of its own starting at the view: such a copy would be a second buffer for the
same memory. Writes through it would not reach readers of the shared copy in the same submission (and the other
way round), and the refresh and copy-back steps only know the shared copy (shadow::find). The raw view is a
view of the shared copy, so readable's refresh and gpu_writes/copy-back keep working unchanged. They use
buffer_range, which gives the same bytes. What a UAV writes lands where every other view of that memory reads,
and goes back to title memory after the submission.

How shaders see it: the emitter declares heap buffer views raw for dword loads and stores, atomics and
typed-format loads without an index, and structured only when the shader indexes them
(victory-shader/src/emit/mod.rs, "Buffer views in the heap"). A raw reader is served exactly. A shader that
indexes the view declares it structured (stride 32) over a raw descriptor. D3D12 leaves that undefined, so it is
marked as a shortcut. On the RTX 5080 and on WARP such reads and writes got the right bytes (probe below, not
part of the PR). AMD is not known.

The 16-byte rule is D3D12_RAW_UAV_SRV_BYTE_ALIGNMENT. It is not optional. In a probe run, a raw SRV or UAV at
byte 4 or 8 of a buffer removed the device (DXGI_ERROR_INVALID_CALL) on both the NVIDIA GPU and WARP. At byte 16
the device stayed up.

#123 is the same rule for the title's own raw views: it refuses one that lands off 16 bytes in its copy. This PR
covers structured views that land off an element. The two touch neighbouring lines in buffer_srv and
buffer_uav and fit together: the views this one makes are always 16-byte aligned.

Tested

Windows 11, NVIDIA GeForce RTX 5080, Rust 1.98.1; also
WARP (VICTORY_D3D12_WARP=1, diagnostics build).

New tests in descriptor/host.rs:

  • structured_views_off_an_element_are_raw_views_of_the_same_bytes: the raw view covers exactly the structured
    view's bytes, and the cases it must refuse (not 16-byte aligned, stride 6, stride 0, more than u32::MAX
    dwords).
  • structured_views_off_an_element_read_and_write_their_bytes (host GPU): a 1 KiB title buffer of numbered
    dwords. A structured SRV (stride 32, 4 elements) starts at byte 16 and a structured UAV at byte 272, both made
    by buffer_srv/buffer_uav. A cs_5_1 shader (system compiler) copies the SRV into a buffer of ours and
    writes marks through the UAV. It runs through HostList and Host::execute, so the refresh and copy-back steps
    are the real ones. Checks: what it read is title bytes 16..144; after copy-back, title bytes 272..400 hold the
    marks; no other byte changed.
    • The same test on main's code (test only, without the fix): fails. The read gives 32 zeros (the null view), on
      the RTX 5080 and on WARP.
    • Branch: passes on the RTX 5080 and on WARP.

Whole runs, main (d2a4bae) and branch side by side in one job:

  • cargo test --workspace (RTX 5080): main 264 passed, 0 failed, 4 ignored; branch 266 passed, 0 failed,
    4 ignored (the two new tests).
  • cargo test -p victory-gpu --features diagnostics on WARP: main 45 passed, 0 failed, 1 ignored; branch 47
    passed, 0 failed, 1 ignored.
  • cargo clippy -p victory-gpu --all-targets: one warning on both, the same one, in host.rs (not touched
    here).
  • cargo xtask policy: 151 files ok on both.
  • rustfmt --check on descriptor/host.rs: none of the reported spots are lines this change adds (the file
    was not rustfmt-clean before).

Probe (not part of the PR):

  • StructuredBuffer<E>/RWStructuredBuffer<E> with a 32-byte E, over the raw fallback views: right bytes read
    and written, RTX 5080 and WARP.
  • Raw SRV and UAV at byte 4 or 8 removed the device; at byte 16 they did not.
  • The test machine had no D3D12 debug layer installed (0x887A002D), so there was no debug-layer or GPU-based validation check.

Not tested

  • The title. Whether this view's readers index it, and what the menus look like with it filled.
  • AMD and Intel GPUs, especially shaders that index the view (structured declaration over a raw view).
  • SM 6.6 heap-indexed DXIL as the translator emits it (the probe used SM 5.1 descriptor tables).
  • The D3D12 debug layer and GPU-based validation (not installed on the test machine).

AI-assisted (Claude Code, Claude Opus 5.5). No game files were used.

**@⁠AnoHunted** on GitHub · 2026-11-24 01:25 UTC · [original](https://github.com/Marvisak/VIctory/pull/206) `AnoHunted:structured-view-raw-fallback` → `main` · +254 −5 · 1 files · 1 commits · closed without merging ## What `buffer_srv` and `buffer_uav` (`crates/victory-gpu/src/descriptor/host.rs`) now make a structured buffer view whose start in its host copy is not on an element as the raw view of the same bytes (`R32_TYPELESS`, raw flag, first element and count in dwords), when that start is 16-byte aligned. Views on an element are made as before. Everything else (typed views, strides that are not a multiple of 4, starts that are not 16-byte aligned) is still refused with the same log line. The math is in a small `raw_window` helper, with a unit test and a host GPU test. ## Why A title buffer view is made on the host copy of the innermost title buffer that holds it, with its first element moved by its offset in that copy (`FirstElement += offset / stride`). A view of memory inside a bigger title buffer can start anywhere in it. The log in #16 already has `buffer view not on an element of its host copy` with `element=32` on the way to the menus: a 32-byte-stride view 16 bytes past an element. D3D12 puts structured element `i` at byte `i * stride` of the resource, so that start cannot be written as a structured view of the copy. The slot stayed null: shaders read zeros through it and their writes were lost. Why a raw view and not a host copy of its own starting at the view: such a copy would be a second buffer for the same memory. Writes through it would not reach readers of the shared copy in the same submission (and the other way round), and the refresh and copy-back steps only know the shared copy (`shadow::find`). The raw view is a view of the shared copy, so `readable`'s refresh and `gpu_writes`/copy-back keep working unchanged. They use `buffer_range`, which gives the same bytes. What a UAV writes lands where every other view of that memory reads, and goes back to title memory after the submission. How shaders see it: the emitter declares heap buffer views raw for dword loads and stores, atomics and typed-format loads without an index, and structured only when the shader indexes them (`victory-shader/src/emit/mod.rs`, "Buffer views in the heap"). A raw reader is served exactly. A shader that indexes the view declares it structured (stride 32) over a raw descriptor. D3D12 leaves that undefined, so it is marked as a shortcut. On the RTX 5080 and on WARP such reads and writes got the right bytes (probe below, not part of the PR). AMD is not known. The 16-byte rule is `D3D12_RAW_UAV_SRV_BYTE_ALIGNMENT`. It is not optional. In a probe run, a raw SRV or UAV at byte 4 or 8 of a buffer removed the device (`DXGI_ERROR_INVALID_CALL`) on both the NVIDIA GPU and WARP. At byte 16 the device stayed up. #123 is the same rule for the title's own raw views: it refuses one that lands off 16 bytes in its copy. This PR covers structured views that land off an element. The two touch neighbouring lines in `buffer_srv` and `buffer_uav` and fit together: the views this one makes are always 16-byte aligned. ## Tested Windows 11, NVIDIA GeForce RTX 5080, Rust 1.98.1; also WARP (`VICTORY_D3D12_WARP=1`, diagnostics build). New tests in `descriptor/host.rs`: - `structured_views_off_an_element_are_raw_views_of_the_same_bytes`: the raw view covers exactly the structured view's bytes, and the cases it must refuse (not 16-byte aligned, stride 6, stride 0, more than `u32::MAX` dwords). - `structured_views_off_an_element_read_and_write_their_bytes` (host GPU): a 1 KiB title buffer of numbered dwords. A structured SRV (stride 32, 4 elements) starts at byte 16 and a structured UAV at byte 272, both made by `buffer_srv`/`buffer_uav`. A `cs_5_1` shader (system compiler) copies the SRV into a buffer of ours and writes marks through the UAV. It runs through `HostList` and `Host::execute`, so the refresh and copy-back steps are the real ones. Checks: what it read is title bytes 16..144; after copy-back, title bytes 272..400 hold the marks; no other byte changed. - The same test on main's code (test only, without the fix): fails. The read gives 32 zeros (the null view), on the RTX 5080 and on WARP. - Branch: passes on the RTX 5080 and on WARP. Whole runs, main (`d2a4bae`) and branch side by side in one job: - `cargo test --workspace` (RTX 5080): main 264 passed, 0 failed, 4 ignored; branch 266 passed, 0 failed, 4 ignored (the two new tests). - `cargo test -p victory-gpu --features diagnostics` on WARP: main 45 passed, 0 failed, 1 ignored; branch 47 passed, 0 failed, 1 ignored. - `cargo clippy -p victory-gpu --all-targets`: one warning on both, the same one, in `host.rs` (not touched here). - `cargo xtask policy`: 151 files ok on both. - `rustfmt --check` on `descriptor/host.rs`: none of the reported spots are lines this change adds (the file was not rustfmt-clean before). Probe (not part of the PR): - `StructuredBuffer<E>`/`RWStructuredBuffer<E>` with a 32-byte `E`, over the raw fallback views: right bytes read and written, RTX 5080 and WARP. - Raw SRV and UAV at byte 4 or 8 removed the device; at byte 16 they did not. - The test machine had no D3D12 debug layer installed (`0x887A002D`), so there was no debug-layer or GPU-based validation check. ## Not tested - The title. Whether this view's readers index it, and what the menus look like with it filled. - AMD and Intel GPUs, especially shaders that index the view (structured declaration over a raw view). - SM 6.6 heap-indexed DXIL as the translator emits it (the probe used SM 5.1 descriptor tables). - The D3D12 debug layer and GPU-based validation (not installed on the test machine). AI-assisted (Claude Code, Claude Opus 5.5). No game files were used.
A title buffer view becomes a view of its host copy with the first element
moved by the view's offset in the copy (offset / stride). A structured view
whose start in the copy is not a multiple of its stride (a 32-byte stride,
16 bytes past an element: logged as "buffer view not on an element of its
host copy" on the way to the menus) cannot be expressed there, so its slot
was left null: shaders read zeros through it and their writes were lost.

Such a view is now made as the raw view of the same bytes (R32_TYPELESS,
raw flag, first element and count in dwords) when its start is 16-byte
aligned; the host removes the device for raw views that are not, so other
starts stay refused. It is a view of the same shared host copy, so what
shaders write through it lands where the other views of that memory read,
and is copied back to title memory as before. Translated shaders read heap
buffer views raw unless they index them; one that indexes it declares it
structured, which D3D12 leaves undefined over a raw view (an RTX 5080 and
WARP read and write the right bytes).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:54:38 +00:00
github-bot closed this pull request 2026-11-26 03:54:38 +00:00
Author
Owner

@⁠jeremygold02 on GitHub · 2026-11-24 04:48 UTC · original

Thanks @⁠AnoHunted for the structured-view fix. I tested the open PR at head 05981dd53b338ef0dabf30d4b728ccb41b0772d9 with:

cargo test --locked -p victory-gpu --lib structured_views_off_an_element -- --test-threads=1

Result: 2 passed, 0 failed. structured_views_off_an_element_are_raw_views_of_the_same_bytes checks that a view derived from an element exposes the expected raw byte span, and structured_views_off_an_element_read_and_write_their_bytes checks reads and writes through that view. This exercises the CPU-side descriptor/span logic; it does not execute a GPU shader. The tests are in descriptor/host.rs.

**@⁠jeremygold02** on GitHub · 2026-11-24 04:48 UTC · [original](https://github.com/Marvisak/VIctory/pull/206#issuecomment-7122356063) Thanks @⁠AnoHunted for the structured-view fix. I tested the open PR at head `05981dd53b338ef0dabf30d4b728ccb41b0772d9` with: ``` cargo test --locked -p victory-gpu --lib structured_views_off_an_element -- --test-threads=1 ``` Result: 2 passed, 0 failed. `structured_views_off_an_element_are_raw_views_of_the_same_bytes` checks that a view derived from an element exposes the expected raw byte span, and `structured_views_off_an_element_read_and_write_their_bytes` checks reads and writes through that view. This exercises the CPU-side descriptor/span logic; it does not execute a GPU shader. The tests are in [descriptor/host.rs](https://github.com/Marvisak/VIctory/blob/05981dd53b338ef0dabf30d4b728ccb41b0772d9/crates/victory-gpu/src/descriptor/host.rs).
Author
Owner

@⁠SantannaCarlos on GitHub · 2026-11-24 06:55 UTC · original

Tested on an RTX 4070 (Windows 11, driver 621.01), diag build of d2a4bae + #136 #173 #176 #164 #180 #179 #177 #138 #116 #145 #135 #100 and two local fixes. With this PR both runs stopped early: 3 s into the world, and once during loading, in a pre-skinning simulation compute pass (50 groups) whose structured SRV (336-byte stride) starts off an element of its host copy. Before this PR that view was null; with it, it is a raw view. Without this PR the same stack ran 116 s and 131 s and stopped elsewhere.

My reading, not verified in that pass's DXIL: the translator declares a heap buffer view structured, with the entry's stride, when the shader reads it with an index, so a raw host view may not match that declaration. The raw window may need to depend on how the shader declares the slot. Two runs; details in #71 (section 6).

**@⁠SantannaCarlos** on GitHub · 2026-11-24 06:55 UTC · [original](https://github.com/Marvisak/VIctory/pull/206#issuecomment-7124430895) Tested on an RTX 4070 (Windows 11, driver 621.01), diag build of `d2a4bae` + #136 #173 #176 #164 #180 #179 #177 #138 #116 #145 #135 #100 and two local fixes. With this PR both runs stopped early: 3 s into the world, and once during loading, in a pre-skinning simulation compute pass (50 groups) whose structured SRV (336-byte stride) starts off an element of its host copy. Before this PR that view was null; with it, it is a raw view. Without this PR the same stack ran 116 s and 131 s and stopped elsewhere. My reading, not verified in that pass's DXIL: the translator declares a heap buffer view structured, with the entry's stride, when the shader reads it with an index, so a raw host view may not match that declaration. The raw window may need to depend on how the shader declares the slot. Two runs; details in https://git.gtahub.st/github/Marvisak--VIctory/issues/71 (section 6).
Author
Owner

@⁠AnoHunted on GitHub · 2026-11-24 10:21 UTC · original

@⁠SantannaCarlos thank you, that's exactly the case this needed. You're right. When the shader indexes the view, the translator declares the slot structured with the entry's stride. The raw fallback then puts a raw descriptor under a structured declaration, which D3D12 leaves undefined. My synthetic probe passed on NVIDIA and WARP, but your 336-byte-stride compute pass shows it isn't safe in the title: it is worse than the null view main leaves there.

I'm turning this into a draft so it isn't merged as is. A correct version needs one of two things:

  • a raw window only for slots the shader declares raw, which means the descriptor layer must know how each slot is declared;
  • or a view the declaration actually matches, such as the separate raw-alias binding being worked out on #193/#704.

I'll come back to it on top of that work rather than keep this fallback.

**@⁠AnoHunted** on GitHub · 2026-11-24 10:21 UTC · [original](https://github.com/Marvisak/VIctory/pull/206#issuecomment-7128662860) @⁠SantannaCarlos thank you, that's exactly the case this needed. You're right. When the shader indexes the view, the translator declares the slot structured with the entry's stride. The raw fallback then puts a raw descriptor under a structured declaration, which D3D12 leaves undefined. My synthetic probe passed on NVIDIA and WARP, but your 336-byte-stride compute pass shows it isn't safe in the title: it is worse than the null view main leaves there. I'm turning this into a draft so it isn't merged as is. A correct version needs one of two things: - a raw window only for slots the shader declares raw, which means the descriptor layer must know how each slot is declared; - or a view the declaration actually matches, such as the separate raw-alias binding being worked out on #193/#704. I'll come back to it on top of that work rather than keep this fallback.
Author
Owner

@⁠hashdev512 on GitHub · 2026-11-24 13:20 UTC · original

Test report from an RX 9070 XT (RDNA4): this PR removes a world fault I could reproduce three times out of three without it.

Setup: Ryzen 7 5700X3D, RX 9070 XT, driver 32.0.32029.2010 (Adrenalin 26.11.2), Windows 11 build 26300. main at ffe310e, diag build with --features diagnostics, VICTORY_D3D12_DRED=1, Series X mode, package v1.0.2.1. This PR merged locally: no conflicts, 52 victory-gpu tests pass.

The fault it fixes

On this card every run that got past about 5 minutes in the world ended in dispatch 12x1x1 [compute eeed82b877b44b5f], with a page fault that DRED places past the end of the view heap (the heap has 1,507,328 slots; the faulting reads were at slots 50,274,304, 52,804,864, 88,692,224, 102,340,992 and 125,829,120, some of them in several runs).

That program takes two descriptors at heap indices it computes from data (ResourceHeap). The chain starts with a dword read through a structured buffer view the title places inside a much bigger title buffer: 112 bytes, stride 56. buffer_srv refuses that view whenever its offset in the host copy is not a multiple of 56, the slot stays null, the program reads 0 there and ends up taking its "indices" from unrelated data at the start of another view.

I checked this with a local probe (not part of any PR). At submission, after the refreshes are flushed, it re-reads on the CPU what the program reads, from title memory and from the host copy, and looks at which host resource the slot holds:

Run (without this PR) View offset in its host copy, mod 56 Slot The compute
1 0 holds the host copy runs 38 s without a fault (the run ends on another fault)
2 48 null faults in the first submission that has it
3 32 null faults in the first submission that has it
4 16 null faults in the first submission that has it

In all four runs the data itself was right: title memory and host copy were identical and held valid indices. The slot was null because the view was refused. All four offsets are 16-byte aligned, so they are in the case this PR handles.

One thing that hides it: buffer view not on an element of its host copy is logged with once!. In every run it fires about 30 s in for another view (element=32), so this view never shows up in the log.

With this PR

One run, offset 48 mod 56 (the failing case):

  • the probe finds the slot holding the host copy;
  • the compute is first dispatched 3 min 48 s in and runs for 42 more minutes without a fault;
  • the run lasts 45 min 46 s and ends because the window was closed: no device removal. Over 4,096 frames at about 1 fps, 8.4 million draws issued and 5.6 million executed, 2,219 shaders translated and 481 refused. The picture is still almost all black.

For comparison, plain main on this card lasted between 2 and 7 minutes today (8e79c80: 2 min 21 s; ffe310e: 6 min 20 s and 6 min 45 s).

What else was in that build

So that the freed-texture fault (#557, #575, #609) did not end the run first, the build also kept alive, for the whole run, the resource a slot held before HostHeap::keep replaced it and the host copy of every released title texture. That is a local diagnostic switch standing in for a lifetime fix; it never frees, so memory grows (about 9 GB after 45 minutes). I have not yet run this PR together with a real lifetime fix.

It is one run with the PR, so treat the 45 minutes as indicative. I can repeat it, or run it on top of another PR, if that helps.

No game data here: hashes, sizes, offsets, slot numbers and timings from VIctory's own log and the probe's comparison results.

AI-assisted (Claude Fable 5.2): the probe was written and the runs launched and summarised by the model on my machine; figures taken from the logs.

**@⁠hashdev512** on GitHub · 2026-11-24 13:20 UTC · [original](https://github.com/Marvisak/VIctory/pull/206#issuecomment-7132692877) Test report from an RX 9070 XT (RDNA4): this PR removes a world fault I could reproduce three times out of three without it. **Setup:** Ryzen 7 5700X3D, RX 9070 XT, driver 32.0.32029.2010 (Adrenalin 26.11.2), Windows 11 build 26300. `main` at `ffe310e`, `diag` build with `--features diagnostics`, `VICTORY_D3D12_DRED=1`, Series X mode, package v1.0.2.1. This PR merged locally: no conflicts, 52 `victory-gpu` tests pass. ## The fault it fixes On this card every run that got past about 5 minutes in the world ended in `dispatch 12x1x1 [compute eeed82b877b44b5f]`, with a page fault that DRED places past the end of the view heap (the heap has 1,507,328 slots; the faulting reads were at slots 50,274,304, 52,804,864, 88,692,224, 102,340,992 and 125,829,120, some of them in several runs). That program takes two descriptors at heap indices it computes from data (`ResourceHeap`). The chain starts with a dword read through a structured buffer view the title places inside a much bigger title buffer: 112 bytes, **stride 56**. `buffer_srv` refuses that view whenever its offset in the host copy is not a multiple of 56, the slot stays null, the program reads 0 there and ends up taking its "indices" from unrelated data at the start of another view. I checked this with a local probe (not part of any PR). At submission, after the refreshes are flushed, it re-reads on the CPU what the program reads, from title memory and from the host copy, and looks at which host resource the slot holds: | Run (without this PR) | View offset in its host copy, mod 56 | Slot | The compute | |---|---|---|---| | 1 | 0 | holds the host copy | runs 38 s without a fault (the run ends on another fault) | | 2 | 48 | null | faults in the first submission that has it | | 3 | 32 | null | faults in the first submission that has it | | 4 | 16 | null | faults in the first submission that has it | In all four runs the data itself was right: title memory and host copy were identical and held valid indices. The slot was null because the view was refused. All four offsets are 16-byte aligned, so they are in the case this PR handles. One thing that hides it: `buffer view not on an element of its host copy` is logged with `once!`. In every run it fires about 30 s in for another view (`element=32`), so this view never shows up in the log. ## With this PR One run, offset **48 mod 56** (the failing case): - the probe finds the slot holding the host copy; - the compute is first dispatched 3 min 48 s in and runs for 42 more minutes without a fault; - the run lasts **45 min 46 s** and ends because the window was closed: no device removal. Over 4,096 frames at about 1 fps, 8.4 million draws issued and 5.6 million executed, 2,219 shaders translated and 481 refused. The picture is still almost all black. For comparison, plain `main` on this card lasted between 2 and 7 minutes today (`8e79c80`: 2 min 21 s; `ffe310e`: 6 min 20 s and 6 min 45 s). ## What else was in that build So that the freed-texture fault (#557, #575, #609) did not end the run first, the build also kept alive, for the whole run, the resource a slot held before `HostHeap::keep` replaced it and the host copy of every released title texture. That is a local diagnostic switch standing in for a lifetime fix; it never frees, so memory grows (about 9 GB after 45 minutes). I have not yet run this PR together with a real lifetime fix. It is one run with the PR, so treat the 45 minutes as indicative. I can repeat it, or run it on top of another PR, if that helps. No game data here: hashes, sizes, offsets, slot numbers and timings from VIctory's own log and the probe's comparison results. _AI-assisted (Claude Fable 5.2): the probe was written and the runs launched and summarised by the model on my machine; figures taken from the logs._
Author
Owner

@⁠bunbeans2-arch on GitHub · 2026-11-24 14:21 UTC · original

Test report from an AMD card for the raw-declared case, in case it helps the reworked version.

Setup: AMD Radeon RX 9070 XT, driver 32.0.32015.7029, Windows 11 Pro build 22631. Diagnostics build of main d2a4bae with #493, #454, #346, #435, #483 and #459 merged, with and without this PR (head 05981dd, merged cleanly, no other change between the two builds). Title 1.0.2.1, the same saved state loaded in every run, default VICTORY_SHADER_LOOP_LIMIT.

Without this PR the load loses the host GPU device: 13 of 13 runs at the default limit, 16 to 69 s after one pixel pipeline is created, and 2 more runs with only a log added (43 s and 52 s). Details are in #597. The log in buffer_srv showed why: all 243 logged views of one 2044-byte buffer were structured with a single 2044-byte element, at 95 different offsets in a heap's host copy, none a multiple of 2044 and all multiples of 16. So every one was refused and the slot read zeros. A pixel shader reads a loop count from that slot with a scalar (raw) load, gets 0, and the loop runs to the limit. So the null view main leaves there is not harmless in this case.

With this PR: no device loss. The run went on in the world until my stop, 215 s after that pipeline was created (1 run).

The narrower variant (a local change: a raw view for that one buffer only, every other refused view left null as on main): same result, no loss, 183 s to my stop (1 run). So for this hang a raw window only for slots the shader declares raw, the first option above, would be enough.

Limits: one run each, and nothing here about indexed reads of a raw view on AMD: I saw no fault in those 215 s but did not check what any such read returned. The picture was still a flat fill with no scene in it, and world frames still took seconds (9566.4 ms/frame in the last fps line).

AI-assisted: written with Claude from my own run logs; the hardware and the runs are mine.

**@⁠bunbeans2-arch** on GitHub · 2026-11-24 14:21 UTC · [original](https://github.com/Marvisak/VIctory/pull/206#issuecomment-7134243407) Test report from an AMD card for the raw-declared case, in case it helps the reworked version. **Setup:** AMD Radeon RX 9070 XT, driver 32.0.32015.7029, Windows 11 Pro build 22631. Diagnostics build of `main` d2a4bae with #493, #454, #346, #435, #483 and #459 merged, with and without this PR (head 05981dd, merged cleanly, no other change between the two builds). Title 1.0.2.1, the same saved state loaded in every run, default `VICTORY_SHADER_LOOP_LIMIT`. **Without this PR** the load loses the host GPU device: 13 of 13 runs at the default limit, 16 to 69 s after one pixel pipeline is created, and 2 more runs with only a log added (43 s and 52 s). Details are in #597. The log in `buffer_srv` showed why: all 243 logged views of one 2044-byte buffer were structured with a single 2044-byte element, at 95 different offsets in a heap's host copy, none a multiple of 2044 and all multiples of 16. So every one was refused and the slot read zeros. A pixel shader reads a loop count from that slot with a scalar (raw) load, gets 0, and the loop runs to the limit. So the null view `main` leaves there is not harmless in this case. **With this PR:** no device loss. The run went on in the world until my stop, 215 s after that pipeline was created (1 run). **The narrower variant** (a local change: a raw view for that one buffer only, every other refused view left null as on `main`): same result, no loss, 183 s to my stop (1 run). So for this hang a raw window only for slots the shader declares raw, the first option above, would be enough. Limits: one run each, and nothing here about indexed reads of a raw view on AMD: I saw no fault in those 215 s but did not check what any such read returned. The picture was still a flat fill with no scene in it, and world frames still took seconds (9566.4 ms/frame in the last fps line). AI-assisted: written with Claude from my own run logs; the hardware and the runs are mine.
Author
Owner

@⁠SantannaCarlos on GitHub · 2026-11-24 15:17 UTC · original

@⁠hashdev512 @⁠bunbeans2-arch both cases you describe are views the title placed off an element of their buffer's host copy: the 112-byte, stride-56 view eeed82b877b44b5f reads, and the 2044-byte single-element views at offsets that are multiples of 16. #1019 keeps such a view structured and gives it a copy of just its bytes, starting at the view, so the declaration matches and the shader reads the title's data (unordered views of the same kind write their own copy, which goes back to title memory). That also covers the 336-byte case from my earlier comment here, which the raw fallback broke. It ran 10 minutes in the world on an RTX 4070 with the hit-detection pass running throughout; if you can run your RX 9070 XT setups on it, that would show whether it removes the faults you reproduced. #984 fixes a separate read in the same pass (a scalar load past the first element of that view), which mattered on NVIDIA.

**@⁠SantannaCarlos** on GitHub · 2026-11-24 15:17 UTC · [original](https://github.com/Marvisak/VIctory/pull/206#issuecomment-7135776040) @⁠hashdev512 @⁠bunbeans2-arch both cases you describe are views the title placed off an element of their buffer's host copy: the 112-byte, stride-56 view `eeed82b877b44b5f` reads, and the 2044-byte single-element views at offsets that are multiples of 16. #1019 keeps such a view structured and gives it a copy of just its bytes, starting at the view, so the declaration matches and the shader reads the title's data (unordered views of the same kind write their own copy, which goes back to title memory). That also covers the 336-byte case from my earlier comment here, which the raw fallback broke. It ran 10 minutes in the world on an RTX 4070 with the hit-detection pass running throughout; if you can run your RX 9070 XT setups on it, that would show whether it removes the faults you reproduced. #984 fixes a separate read in the same pass (a scalar load past the first element of that view), which mattered on NVIDIA.
Author
Owner

@⁠Yaekai on GitHub · 2026-11-24 16:19 UTC · original

Independent verification on Windows 11 + NVIDIA RTX 3070 (8 GB, Rust 1.98.1) at head 05981dd:

  • cargo test -p victory-gpu --lib: 45 passed, 0 failed (including live D3D12 structured_views_off_an_element_read_and_write_their_bytes on RTX 3070).
  • cargo clippy -p victory-gpu -- -D warnings: 0 warnings.
  • Live GTA VI (1.0.2.1, --console series-s, 19-min world run): confirmed off-element 16-byte-aligned structured SRVs/UAVs are cleanly promoted to raw views with zero GPU faults. Ready to merge!
**@⁠Yaekai** on GitHub · 2026-11-24 16:19 UTC · [original](https://github.com/Marvisak/VIctory/pull/206#issuecomment-7137477920) Independent verification on Windows 11 + NVIDIA RTX 3070 (8 GB, Rust 1.98.1) at head `05981dd`: - `cargo test -p victory-gpu --lib`: 45 passed, 0 failed (including live D3D12 `structured_views_off_an_element_read_and_write_their_bytes` on RTX 3070). - `cargo clippy -p victory-gpu -- -D warnings`: 0 warnings. - Live GTA VI (`1.0.2.1`, `--console series-s`, 19-min world run): confirmed off-element 16-byte-aligned structured SRVs/UAVs are cleanly promoted to raw views with zero GPU faults. Ready to merge!
Author
Owner

@⁠jamesn-xt on GitHub · 2026-11-24 16:39 UTC · original

Verified head 05981dd in an integrated Windows 11 / RTX 4080 build (NVIDIA 617.42, Ryzen 5 5600, 32 GiB RAM, Rust 1.98.1).

The previous hardware run logged a structured-buffer view offset off its 32-byte element. With this PR in the stack, that warning no longer appeared in the bounded hardware run. Both added raw-window/read-write tests passed on the RTX 4080; diagnostics GPU suite: 66 passed, 1 ignored. All-target/all-feature GPU Clippy, diagnostics build and asset policy passed.

Stack also contains #211, #89, #492, #985 and #1146 on main ffe310e: https://github.com/jamesn-xt/VIctory/tree/test/rtx4080-target-formats (abe05a3). Character loading artwork rendered at 30 fps; mesh/pixel pipelines began binding later, but a 2 GiB free-commit guard stopped the run before a visible world was confirmed. This does not prove this PR alone fixes title rendering, and I have not verified structured declarations over the raw view on other GPU vendors.

No game captures, retail files or raw logs attached.

**@⁠jamesn-xt** on GitHub · 2026-11-24 16:39 UTC · [original](https://github.com/Marvisak/VIctory/pull/206#issuecomment-7138004273) Verified head `05981dd` in an integrated Windows 11 / RTX 4080 build (NVIDIA 617.42, Ryzen 5 5600, 32 GiB RAM, Rust 1.98.1). The previous hardware run logged a structured-buffer view offset off its 32-byte element. With this PR in the stack, that warning no longer appeared in the bounded hardware run. Both added raw-window/read-write tests passed on the RTX 4080; diagnostics GPU suite: 66 passed, 1 ignored. All-target/all-feature GPU Clippy, diagnostics build and asset policy passed. Stack also contains #211, #89, #492, #985 and #1146 on main `ffe310e`: https://github.com/jamesn-xt/VIctory/tree/test/rtx4080-target-formats (`abe05a3`). Character loading artwork rendered at 30 fps; mesh/pixel pipelines began binding later, but a 2 GiB free-commit guard stopped the run before a visible world was confirmed. This does not prove this PR alone fixes title rendering, and I have not verified structured declarations over the raw view on other GPU vendors. No game captures, retail files or raw logs attached.
Author
Owner

@⁠ThomasHFWright on GitHub · 2026-11-24 18:15 UTC · original

Tested exact head 05981dd53b338ef0dabf30d4b728ccb41b0772d9 on Linux / RTX 5090. This restores previously null buffer inputs in the title path on this setup; the default-loop-limit run still stalls.

Integration: Slaktarn700 proton-fixes 993dff8, #852 handle-cache fix ae7e0be, #454 watchdog diagnostic d2c93fa (local base 436b3dbce181f0e6c940770596fc2a500ed39050), then this PR's exact file delta merged against its parent. Local binding/timestamp probes retained; no other semantic patch added. CachyOS 7.3.6, Wine 11.22, RTX 5090 / NVIDIA 620.73.04, vkd3d-proton 3.2.0 30b0eb9bc12dc9f. Wine with these DLLs, not a Steam Proton runtime test.

Observed bindings: before this PR, compute 72f552f4553fb5f9 had null raw SRVs at inputs expecting structured buffers of stride 176 and, on some dispatches, 336. With the PR, those inputs receive non-null raw SRVs over the shared buffer. No descriptor-record changes were detected between command recording, pre/post heap refresh and timeout in the examined submissions. This samples descriptor records, not all GPU memory contents or transient races.

Tests:

  • Diagnostics GPU suite with Microsoft's native d3dcompiler_47: 58 passed, 0 failed, 1 ignored, including both added tests. Probes enabled.
  • With Wine's built-in compiler: 57 passed, 1 failed, 1 ignored. The added GPU test fails at CreateRootSignature (0x80004005), before dispatch; the native compiler resolves that harness limitation.
  • Full Windows workspace: 347 passed, 2 unchanged Wine harness failures, 7 ignored across 14 executables. Failures are the nested Linux cargo launch and git-based policy invocation from Wine. The extra ignored item is a local opt-in diagnostic test, exercised separately below.
  • All-target/all-feature Clippy with warnings denied and native asset policy pass.
  • Separate synthetic PC-DXC/SM6.6 heap-indexing test on the actual RTX 5090: 20 cases spanning strides 12/16/24/176/336, raw and structured SRVs, null raw SRVs, and raw views starting at byte 16. Both raw and structured handles read the expected bytes in these cases; null views return zero. This does not establish portable D3D12 behavior or validate arbitrary translated shaders/stores.

Runtime: the default-limit run ends after 108.1 s, exit 5. Our bounded fence probe reports submission 5209/completed 5208. The last resolved pre-command marker is 62, preceding a 34x1x1 dispatch of the same 72f552f4553fb5f9; the next marker is absent. Kernel reports Xid 109 / CTX SWITCH TIMEOUT, where the preceding controls reported Xid 13 / MMU Fault. All 983 captured SPIR-V modules validate. Thus restored views are confirmed, but this run does not establish that the GPU stall is fixed. Earlier producer/dataflow errors remain possible; marker instrumentation can alter scheduling.

Prior isolation and shader-exclusion controls: #71 .

A second controlled run used the same application binary, only adding VICTORY_SHADER_LOOP_LIMIT=32 (confirmed active; the cache keys on this setting). It also failed: 103.1 s, exit 5, submission 4764/completed 4763. Last resolved marker 53 precedes the same shader, now 421x1x1; kernel Xid 13 / MMU Fault. No descriptor-record change detected; all 988 captured SPIR-V modules validate. The global loop cap does not avoid the fault in this test and can truncate shader work; it is not a correctness fix.

All runs were offline and app-muted. No game files, shader code, dumps or captures attached. No controllable visible gameplay confirmed. AI-assisted testing with Codex on the user's hardware.

**@⁠ThomasHFWright** on GitHub · 2026-11-24 18:15 UTC · [original](https://github.com/Marvisak/VIctory/pull/206#issuecomment-7140395332) Tested exact head `05981dd53b338ef0dabf30d4b728ccb41b0772d9` on Linux / RTX 5090. This restores previously null buffer inputs in the title path on this setup; the default-loop-limit run still stalls. **Integration:** Slaktarn700 `proton-fixes` `993dff8`, #852 handle-cache fix `ae7e0be`, #454 watchdog diagnostic `d2c93fa` (local base `436b3dbce181f0e6c940770596fc2a500ed39050`), then this PR's exact file delta merged against its parent. Local binding/timestamp probes retained; no other semantic patch added. CachyOS 7.3.6, Wine 11.22, RTX 5090 / NVIDIA 620.73.04, vkd3d-proton 3.2.0 `30b0eb9bc12dc9f`. Wine with these DLLs, not a Steam Proton runtime test. **Observed bindings:** before this PR, compute `72f552f4553fb5f9` had null raw SRVs at inputs expecting structured buffers of stride 176 and, on some dispatches, 336. With the PR, those inputs receive non-null raw SRVs over the shared buffer. No descriptor-record changes were detected between command recording, pre/post heap refresh and timeout in the examined submissions. This samples descriptor records, not all GPU memory contents or transient races. **Tests:** - Diagnostics GPU suite with Microsoft's native `d3dcompiler_47`: **58 passed, 0 failed, 1 ignored**, including both added tests. Probes enabled. - With Wine's built-in compiler: **57 passed, 1 failed, 1 ignored**. The added GPU test fails at `CreateRootSignature` (`0x80004005`), before dispatch; the native compiler resolves that harness limitation. - Full Windows workspace: **347 passed, 2 unchanged Wine harness failures, 7 ignored** across 14 executables. Failures are the nested Linux cargo launch and git-based policy invocation from Wine. The extra ignored item is a local opt-in diagnostic test, exercised separately below. - All-target/all-feature Clippy with warnings denied and native asset policy pass. - Separate synthetic PC-DXC/SM6.6 heap-indexing test on the actual RTX 5090: 20 cases spanning strides 12/16/24/176/336, raw and structured SRVs, null raw SRVs, and raw views starting at byte 16. Both raw and structured handles read the expected bytes in these cases; null views return zero. This does not establish portable D3D12 behavior or validate arbitrary translated shaders/stores. **Runtime:** the default-limit run ends after 108.1 s, exit 5. Our bounded fence probe reports submission 5209/completed 5208. The last resolved pre-command marker is 62, preceding a 34x1x1 dispatch of the same `72f552f4553fb5f9`; the next marker is absent. Kernel reports **Xid 109 / CTX SWITCH TIMEOUT**, where the preceding controls reported Xid 13 / MMU Fault. All 983 captured SPIR-V modules validate. Thus restored views are confirmed, but this run does not establish that the GPU stall is fixed. Earlier producer/dataflow errors remain possible; marker instrumentation can alter scheduling. Prior isolation and shader-exclusion controls: https://git.gtahub.st/github/Marvisak--VIctory/issues/71 . A second controlled run used the **same application binary**, only adding `VICTORY_SHADER_LOOP_LIMIT=32` (confirmed active; the cache keys on this setting). It also failed: 103.1 s, exit 5, submission 4764/completed 4763. Last resolved marker 53 precedes the same shader, now 421x1x1; kernel **Xid 13 / MMU Fault**. No descriptor-record change detected; all 988 captured SPIR-V modules validate. The global loop cap does not avoid the fault in this test and can truncate shader work; it is not a correctness fix. All runs were offline and app-muted. No game files, shader code, dumps or captures attached. No controllable visible gameplay confirmed. AI-assisted testing with Codex on the user's hardware.

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