Shaders, GPU: a buffer picked from the view heap where the slot holds no buffer view reads a null view of its class (the _Prev meshlet-cull page faults) #1195

Open
github-bot wants to merge 3 commits from github-bot/gh-1195 into main AGit
Owner

@⁠IxMxAMAR on GitHub · 2026-11-25 23:27 UTC · original
IxMxAMAR:gpu/descriptor-type-safety → main · +758 −31 · 7 files · 3 commits · open

Refs #3: the device removals in CS_BatchCullMeshlets_Prev (fc5e66f8f873d3bb) and CS_BatchCullPreSkinnedMeshlets_Prev (0452fc2d2e2fc4c3) when work is sent ahead.

Cause

  • The culls pick their records' descriptors from the whole view heap.
  • The table of strides by slot (t255 space1) said 0 for anything that was not a buffer view, a texture's slot included, and the scalar path reads 0 as a constant buffer.
  • On AMD, a texture's descriptor read as a buffer's points at the image address shifted right by 8. 13 of the 16 recorded _Prev fault addresses decode that way (table in #3).
  • The entry was also written before the slot changed.

Change

  • Table entries: the stride for a buffer view, 0 for a constant buffer view, SLOT_STRIDES_SKIP (all bits set) for anything else.
    • A new heap's table starts all SKIP.
    • note_buffer writes SKIP, and mirror writes the real entry only once the slot holds its view, behind a fence.
  • Translator: a scalar read through a SKIP slot reads nothing.
    • Any other buffer access picked from the heap (loads, stores, atomics; typed, raw, structured, constant) reads the null view of its own class instead.
    • The host now keeps those null views just below the null slot: a raw buffer SRV, a raw buffer UAV and a CBV.
    • Same idea as upstream's guard in Marvisak/VIctory@d71c388, which uses a null raw buffer view.

Tests

  • New heap_tests: GFX10 programs lowered, validated, and run on the hardware GPU and on WARP.
    • SKIP reads give 0 and reach the buffer view below the null slot.
    • SKIP stores are dropped and reach the UAV below it.
    • One- and four-dword scalar reads through SKIP read nothing.
    • Buffer and constant-buffer slots still give their data.
  • victory-gpu: the stride table's states and write order; title and dynamic slots end below the null views, with a capped heap or not.
  • Suites, as CI runs them, on 58de9bf: both clippy passes are clean; victory-gpu 222 passed; victory-shader 232 passed and 1 failed, valu_tests::legacy_mad_fuses_its_product_and_flushes_its_sources (hardware case 0 gives 0 on this card), which fails the same way on main. xtask's repository_passes_policy fails here as it does on main's own CI: lower.rs was already 526,968 bytes at 58de9bf, over the 524,288-byte limit, and this change adds 1,477.

In game (RX 9070 XT, both _Prev culls bound, relay on)

  • With this change's first version (SKIP slots sent to the null 2D slot), the culls ran 17 min 17 s without a device removal. Before it, every such run lost the device within about 10 minutes.
  • That run then ended inside AMD's compiler (amdxc64.dll+0x861b9f) on compute f16876929fa64f9f (bvh_skinning:CSComputeSkinningTreeAnimVelocity). That crash is unrelated to this change: victory translate --pipelines reproduces it on main without this change, with any VICTORY_SHADER_OPT.

Relation to #1095

  • #1095 bounds heap indices past the title's slots and keeps a typed null guard per resource kind. It does not change what an in-range slot holding a texture reads as; this PR does, for in-range slots the stride table marks SKIP, along with the table's write order.
  • The two overlap in one place: both keep typed null views (here three, below the null slot; there 21, at the end of the dynamic slots).
  • Whichever lands second should use the other's views. If #1095 lands first, I'll rebase this onto it and send SKIP slots to its guard + heap_guard(kind) instead.
**@⁠IxMxAMAR** on GitHub · 2026-11-25 23:27 UTC · [original](https://github.com/fxceless/victory-fork/pull/1195) `IxMxAMAR:gpu/descriptor-type-safety` → `main` · +758 −31 · 7 files · 3 commits · open Refs #3: the device removals in `CS_BatchCullMeshlets_Prev` (`fc5e66f8f873d3bb`) and `CS_BatchCullPreSkinnedMeshlets_Prev` (`0452fc2d2e2fc4c3`) when work is sent ahead. **Cause** - The culls pick their records' descriptors from the whole view heap. - The table of strides by slot (`t255 space1`) said 0 for anything that was not a buffer view, a texture's slot included, and the scalar path reads 0 as a constant buffer. - On AMD, a texture's descriptor read as a buffer's points at the image address shifted right by 8. 13 of the 16 recorded `_Prev` fault addresses decode that way (table in #3). - The entry was also written before the slot changed. **Change** - **Table entries:** the stride for a buffer view, 0 for a constant buffer view, `SLOT_STRIDES_SKIP` (all bits set) for anything else. - A new heap's table starts all SKIP. - `note_buffer` writes SKIP, and `mirror` writes the real entry only once the slot holds its view, behind a fence. - **Translator:** a scalar read through a SKIP slot reads nothing. - Any other buffer access picked from the heap (loads, stores, atomics; typed, raw, structured, constant) reads the null view of its own class instead. - The host now keeps those null views just below the null slot: a raw buffer SRV, a raw buffer UAV and a CBV. - Same idea as upstream's guard in Marvisak/VIctory@d71c388, which uses a null raw buffer view. **Tests** - **New `heap_tests`:** GFX10 programs lowered, validated, and run on the hardware GPU and on WARP. - SKIP reads give 0 and reach the buffer view below the null slot. - SKIP stores are dropped and reach the UAV below it. - One- and four-dword scalar reads through SKIP read nothing. - Buffer and constant-buffer slots still give their data. - **victory-gpu:** the stride table's states and write order; title and dynamic slots end below the null views, with a capped heap or not. - **Suites**, as CI runs them, on `58de9bf`: both clippy passes are clean; victory-gpu 222 passed; victory-shader 232 passed and 1 failed, `valu_tests::legacy_mad_fuses_its_product_and_flushes_its_sources` (hardware case 0 gives 0 on this card), which fails the same way on `main`. `xtask`'s `repository_passes_policy` fails here as it does on `main`'s own CI: `lower.rs` was already 526,968 bytes at `58de9bf`, over the 524,288-byte limit, and this change adds 1,477. **In game** (RX 9070 XT, both `_Prev` culls bound, relay on) - With this change's first version (SKIP slots sent to the null 2D slot), the culls ran 17 min 17 s without a device removal. Before it, every such run lost the device within about 10 minutes. - That run then ended inside AMD's compiler (`amdxc64.dll+0x861b9f`) on compute `f16876929fa64f9f` (`bvh_skinning:CSComputeSkinningTreeAnimVelocity`). That crash is unrelated to this change: `victory translate --pipelines` reproduces it on `main` without this change, with any `VICTORY_SHADER_OPT`. **Relation to #1095** - #1095 bounds heap indices past the title's slots and keeps a typed null guard per resource kind. It does not change what an in-range slot holding a texture reads as; this PR does, for in-range slots the stride table marks SKIP, along with the table's write order. - The two overlap in one place: both keep typed null views (here three, below the null slot; there 21, at the end of the dynamic slots). - Whichever lands second should use the other's views. If #1095 lands first, I'll rebase this onto it and send SKIP slots to its `guard + heap_guard(kind)` instead.
The meshlet culls read their records through descriptors they pick from the whole view heap (an
s_buffer_load through a V# loaded at an index the program computes). The host's table of strides by
slot (t255 space1) told a buffer view (its stride) from anything else (0), and anything else was read
as a constant buffer: a slot that holds a texture too. On AMD a constant buffer view is a buffer
descriptor, and a texture's descriptor read as one points at its image address shifted right by 8:
13 of the 16 page faults recorded for CS_BatchCullMeshlets_Prev and
CS_BatchCullPreSkinnedMeshlets_Prev, with work sent ahead, are such addresses.

The table gets a third value, SLOT_STRIDES_SKIP (all bits set), for a slot that holds no buffer view
and no constant buffer view. A scalar read through such a slot runs neither load (the buffer load now
takes a positive stride) and gives 0. Every other buffer access through a descriptor picked from the
heap (typed, raw, structured, constant; loads, stores, atomics) reads the null view of its class the
host keeps just below the heap's null slot instead: a raw buffer SRV for reads, a raw buffer UAV for
writes, a constant buffer view (NULL_BUFFER_SRV_BELOW, NULL_BUFFER_UAV_BELOW, NULL_CBV_BELOW). The null
slot's own view is a 2D texture's, and a 2D view read or written as a buffer is a mismatch not every
GPU survives.
Textures, samplers and descriptors with no table entry are left as they were.

The host writes no SKIP yet and keeps no such views yet (next commit), so nothing changes until then.
New heap_tests, on the hardware GPU and on WARP: a scalar read through a slot marked SKIP gives 0, even
with data in the slots below the null slot; a vector read there reads the buffer view one slot below
the null slot (0 from a null one), and a store there lands in the UAV two slots below it (dropped by a
null one); a buffer slot and a constant buffer slot still give their data, and a store through a
buffer slot lands.
The table of strides by view heap slot, which shaders that pick buffers from the heap read (previous
commit), said 0 for anything that was not a buffer view, a texture's slot too, and those shaders read
0 as a constant buffer. A slot's entry is now its buffer view's stride, 0 for a constant buffer view,
and SLOT_STRIDES_SKIP for anything else (a texture's view, nothing, the dynamic slots), which they read
as nothing. The table starts all SKIP.

The entry also changed before the slot did: note_buffer wrote the new stride before mirror wrote the
slot (made, or null for a buffer view left for its draw), and for that while the new stride sat beside
the slot's old descriptor. note_buffer now writes SKIP, and mirror writes the entry once the slot holds
its view or a null view of its kind, each behind a full fence (the table's upload memory is
write-combined). A buffer view left for a draw still reads its own null buffer view, as before. A
record that names no view any more is skipped before its slot is made null.

A view heap keeps the null views those shaders read for a SKIP slot (previous commit) just below its
null slot: a raw buffer SRV, a raw buffer UAV and a constant buffer view. The title's slots and the
dynamic ones end below them, also on a host that caps the heap.

Tests: a new heap's table is all SKIP; a slot mirrored with a stride of 16 and then noted with another
view reads SKIP until mirror writes it; mirror publishes 16 for a placed structured buffer, 0 for a
constant buffer view, SKIP for a placed texture and for a record that names no view; the title's
slots end below the null buffer views, capped heap or not.
A shader or unordered view made without a description of a buffer object (the buffer's own view)
told the table of strides SLOT_STRIDES_SKIP, "no buffer view", so a shader that picked it from the
heap read nothing there. Before this pull request such slots had 0, like every buffer view whose
element size the host does not know; they have 0 again.

Test: a buffer's own shader view and unordered view give the entry 0 (they gave SKIP).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:59:18 +00:00
Author
Owner

@⁠IxMxAMAR on GitHub · 2026-11-26 01:49 UTC · original

In game since this opened, on an RX 9070 XT (driver 32.0.32029.2010), relay on, both _Prev culls running, only 42683eebec081520 skipped:

  • run 23 (this PR's first version, on 3973179 with five other open PRs): both culls ran 17 min with no device removal. The run then ended in AMD's compiler on f16876929fa64f9f, which #1213 fixes.
  • run 24 (f180b26 + dd7a703 on 32b31f7, with #1213): culls 14 min, closed normally.
  • run 25 (the same plus a local experiment): culls 20 min, into the next mission, closed normally.

Before this, every run here that sent work ahead with both culls running lost the device within about 10 minutes, as did all 15 of GamingRipperDoc's on #3.

1208282 came after those runs: a buffer's own view (made without a description) now keeps the table's entry 0, element size unknown, instead of SKIP, which made heap picks of it read zeros. Not run in game yet.

#1216 (@⁠GamingRipperDoc) fixes the same _Prev read the other way round: constant buffer slots are marked, and any other non-buffer slot reads zeros. Two differences:

  • there, a slot whose stride the host doesn't know (a buffer's own view, a typed buffer of unknown element size) also gets 0, so its reads become zeros, where main and this PR read it through the constant buffer path;
  • this PR also sends vector loads, stores and atomics that pick a texture's slot to a null view of their own class.

Either landing is fine with me: I can rebase this onto #1216's marking, or close it and send those two parts as a follow-up to #1216.

**@⁠IxMxAMAR** on GitHub · 2026-11-26 01:49 UTC · [original](https://github.com/fxceless/victory-fork/pull/1195#issuecomment-7180172275) In game since this opened, on an RX 9070 XT (driver 32.0.32029.2010), relay on, both `_Prev` culls running, only `42683eebec081520` skipped: - run 23 (this PR's first version, on 3973179 with five other open PRs): both culls ran 17 min with no device removal. The run then ended in AMD's compiler on `f16876929fa64f9f`, which #1213 fixes. - run 24 (f180b26 + dd7a703 on 32b31f7, with #1213): culls 14 min, closed normally. - run 25 (the same plus a local experiment): culls 20 min, into the next mission, closed normally. Before this, every run here that sent work ahead with both culls running lost the device within about 10 minutes, as did all 15 of GamingRipperDoc's on #3. 1208282 came after those runs: a buffer's own view (made without a description) now keeps the table's entry 0, element size unknown, instead of SKIP, which made heap picks of it read zeros. Not run in game yet. #1216 (@⁠GamingRipperDoc) fixes the same `_Prev` read the other way round: constant buffer slots are marked, and any other non-buffer slot reads zeros. Two differences: - there, a slot whose stride the host doesn't know (a buffer's own view, a typed buffer of unknown element size) also gets 0, so its reads become zeros, where main and this PR read it through the constant buffer path; - this PR also sends vector loads, stores and atomics that pick a texture's slot to a null view of their own class. Either landing is fine with me: I can rebase this onto #1216's marking, or close it and send those two parts as a follow-up to #1216.
github-bot force-pushed github-bot/gh-1195 from 12082820ed to 7d30344bcc 2026-11-26 15:02:08 +00:00 Compare
This pull request has changes conflicting with the target branch.
  • crates/victory-shader/src/emit/mod.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1195/head:github-bot/gh-1195'
git switch 'github-bot/gh-1195'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1195'
git switch 'github-bot/gh-1195'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1195'
git switch 'github-bot/gh-1195'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1195'
git switch 'main'
git merge --squash 'github-bot/gh-1195'
git switch 'main'
git merge --ff-only 'github-bot/gh-1195'
git switch 'main'
git merge 'github-bot/gh-1195'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.