Skip to content

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
IxMxAMAR wants to merge 3 commits into
fxceless:mainfrom
IxMxAMAR:gpu/descriptor-type-safety
Open

IxMxAMAR wants to merge 3 commits into
fxceless:mainfrom
IxMxAMAR:gpu/descriptor-type-safety

Conversation

@IxMxAMAR

@IxMxAMAR IxMxAMAR commented Nov 25, 2026 •

Copy link
Copy Markdown

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 Works on AMD RX 9070 XT (lit opening cutscene) with three AMD-specific pipeline skips #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 9a9091d: victory-gpu clippy is clean; victory-shader clippy stops on 7 lints in valu_tests.rs and wave64_after_loop.rs, which this change does not touch, and main reports the same 7 at the same lines. victory-shader 263 passed. The victory-gpu tests end in an access violation in tiles::tests::card_wrote_failure_does_not_poison_card_mask, on this branch and on main alike. xtask's repository_passes_policy fails as it does on main: lower.rs is 527,045 bytes on main, over the 524,288-byte limit, and this change adds 1,477; host.rs (571,758 bytes, untouched here) is over it on both.

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

@IxMxAMAR

Copy link
Copy Markdown
Author

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

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.

…ost's stride table says the slot holds no buffer view

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.
…extures and empty slots read as nothing

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.
…nown), not "no buffer view"

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).
@IxMxAMAR
IxMxAMAR force-pushed the gpu/descriptor-type-safety branch from 7d30344 to daf70f6 Compare November 27, 2026 06:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant