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) #1192

Open
IxMxAMAR wants to merge 3 commits from upstream-pr/1195 into main
IxMxAMAR commented 2026-11-25 23:27:43 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by IxMxAMAR on 2026-11-25T23:27:43Z.


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 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

  • #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.
<!-- greyfinch-sync:fxceless/victory-fork:issue:5500972392 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/1195). Originally posted by [IxMxAMAR](https://github.com/IxMxAMAR) on 2026-11-25T23:27:43Z. --- 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 `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** - #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 commented 2026-11-26 02:08:44 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by IxMxAMAR on 2026-11-26T01:49:29Z.


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.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7180172275 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/1195#issuecomment-7180172275). Originally posted by [IxMxAMAR](https://github.com/IxMxAMAR) on 2026-11-26T01:49:29Z. --- 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.
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/1195:upstream-pr/1195'
git switch 'upstream-pr/1195'

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/1195'
git switch 'upstream-pr/1195'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1195'
git switch 'upstream-pr/1195'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1195'
git switch 'main'
git merge --squash 'upstream-pr/1195'
git switch 'main'
git merge --ff-only 'upstream-pr/1195'
git switch 'main'
git merge 'upstream-pr/1195'
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
fxceless/victory-fork!1192
No description provided.