Read a heap slot as a constant buffer only when it holds one #66

Open
github-bot wants to merge 1 commit from github-bot/gh-66 into main AGit
Owner

@⁠ExMoha on GitHub · 2026-11-26 03:43 UTC · original
ExMoha:heap-slot-kind → main · +30 −7 · 4 files · 1 commits · open

On an RX 9070 (RDNA 4), the device was removed with a GPU page fault at the same place in the first open-world area every time. The address changed between runs (0x3000_0270_3000, 0x9000_02d9_8000, 0x5c2d000). DRED put the fault in an indirect dispatch of a culling compute program, and the build before the latest merge faults there too, so the merge didn't cause it.

The cause: the program picks a buffer from the view heap by an index it reads from its own records. For such loads the translator branches on the host's table of strides by slot. A non-zero stride is read as a buffer view, and anything else was read as a constant buffer. A slot holding a texture, or nothing, has no stride either, so its descriptor was read as a constant buffer's. That gives the card an address it never mapped. Reading a texture's descriptor as a constant buffer is undefined on any card, so this is probably not RDNA 4 specific. I haven't established why the records name a non-buffer slot at that spot.

The fix:

  • The strides table marks constant buffer views with SLOT_CONSTANT_BUFFER (bit 31).
  • The constant buffer read runs only for such a slot, and the buffer read only for a non-zero stride. Any other slot reads zeros.
  • Element offsets use the stride bits alone (SLOT_STRIDE_BITS).
  • The shader cache key hashes the translator sources, so old translations are not served.

Tested on an RX 9070, Adrenalin 26.11.2 (32.0.32029.2010):

  • The affected program translates, and the translation passes the validator.
  • In game, play continued about 6 minutes past the spot that faulted in four runs before, then exited cleanly.
  • Tests pass: victory-shader 239, victory-gpu 219, victory-hle 115.
  • victory-gpu's lib tests sometimes end in an access violation when run in parallel (about 1 in 12 runs on main without this change). They always pass with --test-threads=1.

Not tested on RDNA 3 or NVIDIA hardware.

**@⁠ExMoha** on GitHub · 2026-11-26 03:43 UTC · [original](https://github.com/DexNom/VIctory/pull/66) `ExMoha:heap-slot-kind` → `main` · +30 −7 · 4 files · 1 commits · open On an RX 9070 (RDNA 4), the device was removed with a GPU page fault at the same place in the first open-world area every time. The address changed between runs (`0x3000_0270_3000`, `0x9000_02d9_8000`, `0x5c2d000`). DRED put the fault in an indirect dispatch of a culling compute program, and the build before the latest merge faults there too, so the merge didn't cause it. **The cause:** the program picks a buffer from the view heap by an index it reads from its own records. For such loads the translator branches on the host's table of strides by slot. A non-zero stride is read as a buffer view, and anything else was read as a constant buffer. A slot holding a texture, or nothing, has no stride either, so its descriptor was read as a constant buffer's. That gives the card an address it never mapped. Reading a texture's descriptor as a constant buffer is undefined on any card, so this is probably not RDNA 4 specific. I haven't established why the records name a non-buffer slot at that spot. **The fix:** - The strides table marks constant buffer views with `SLOT_CONSTANT_BUFFER` (bit 31). - The constant buffer read runs only for such a slot, and the buffer read only for a non-zero stride. Any other slot reads zeros. - Element offsets use the stride bits alone (`SLOT_STRIDE_BITS`). - The shader cache key hashes the translator sources, so old translations are not served. **Tested on an RX 9070, Adrenalin 26.11.2 (32.0.32029.2010):** - The affected program translates, and the translation passes the validator. - In game, play continued about 6 minutes past the spot that faulted in four runs before, then exited cleanly. - Tests pass: victory-shader 239, victory-gpu 219, victory-hle 115. - victory-gpu's lib tests sometimes end in an access violation when run in parallel (about 1 in 12 runs on `main` without this change). They always pass with `--test-threads=1`. Not tested on RDNA 3 or NVIDIA hardware.
A program that picks a buffer from the view heap by a computed index
branches on the host's table of strides by slot: a stride means a buffer
view, and anything else was read as a constant buffer. A slot holding a
texture (or nothing) has no stride either, so its descriptor was read as
a constant buffer's, and the card got an address it never mapped: page
faults and the device removed on an RX 9070, in a culling compute
program whose records name the slot it reads.

The table now marks constant buffer views (SLOT_CONSTANT_BUFFER, bit 31).
The constant buffer read runs only for such a slot, the buffer read only
for a stride, and any other slot reads zeros. Element offsets use the
stride bits alone.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:25:09 +00:00
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

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

Merge

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