victory-shader: lower TFE image loads/samples/gathers via CheckAccessFullyMapped #1693

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

@⁠tjthebigbearcat-hub on GitHub · 2026-11-24 20:47 UTC · original
tjthebigbearcat-hub:fix/starter-pr → main · +370 −2 · 4 files · 1 commits · open

Summary

Implements TFE (Texture Fetch Enable) sparse-residency status feedback for RDNA 2 image load, sample, and gather instructions (including d16 packing) in victory-shader:

  • Emits dx.op.checkAccessFullyMapped in emit/lower.rs and writes the residency status dword (0 resident, 1 non-resident) to the extra destination register.
  • Declares the tiled-resources shader flag (SFI0 bit 0x100 / shader-flags metadata) in emit/shader.rs when TFE status is checked.
  • Keeps lwe and TFE on stores, atomics, and size/LOD queries cleanly refused with clearer error messages.

Verification (Windows 11 + SDK dxil.dll + WARP/GPU)

  • Hand-encoded synthetic GFX10 instruction tests added in emit/tfe_tests.rs (zero game bytes; verified with xtask asset-policy check).
  • cargo test -p victory-shader --locked tfe: 7 passed, 0 failed (including all 4 Windows dxil.dll / WARP / hardware GPU tests).
  • cargo test --workspace --locked: 127 passed, 0 failed, 1 ignored in victory-shader; entire workspace green.
  • cargo clippy --workspace --all-targets --locked -- -D warnings: 0 warnings.
**@⁠tjthebigbearcat-hub** on GitHub · 2026-11-24 20:47 UTC · [original](https://github.com/Marvisak/VIctory/pull/1693) `tjthebigbearcat-hub:fix/starter-pr` → `main` · +370 −2 · 4 files · 1 commits · open ### Summary Implements TFE (Texture Fetch Enable) sparse-residency status feedback for RDNA 2 image `load`, `sample`, and `gather` instructions (including `d16` packing) in `victory-shader`: - Emits `dx.op.checkAccessFullyMapped` in `emit/lower.rs` and writes the residency status dword (`0` resident, `1` non-resident) to the extra destination register. - Declares the tiled-resources shader flag (`SFI0` bit `0x100` / shader-flags metadata) in `emit/shader.rs` when TFE status is checked. - Keeps `lwe` and TFE on stores, atomics, and size/LOD queries cleanly refused with clearer error messages. ### Verification (Windows 11 + SDK `dxil.dll` + WARP/GPU) - Hand-encoded synthetic GFX10 instruction tests added in `emit/tfe_tests.rs` (zero game bytes; verified with `xtask` asset-policy check). - `cargo test -p victory-shader --locked tfe`: **7 passed, 0 failed** (including all 4 Windows `dxil.dll` / WARP / hardware GPU tests). - `cargo test --workspace --locked`: **127 passed, 0 failed, 1 ignored** in `victory-shader`; entire workspace green. - `cargo clippy --workspace --all-targets --locked -- -D warnings`: **0 warnings**.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:41:47 +00:00
Author
Owner

@⁠upipibi on GitHub · 2026-11-24 22:52 UTC · original

NVIDIA run: RTX 3070 8 GB, driver 616.56, Windows 11, debug, at the PR head 77d21c6. Tests matching tfe (the new TFE load / sample / gather / D16 cases and the refusals): 7 passed, 0 failed.
It is based on ffe310e and GitHub shows conflicts with main 70564ae, so this is the head as it stands, not a merge.
AI-assisted (Claude Code). Synthetic tests only.

**@⁠upipibi** on GitHub · 2026-11-24 22:52 UTC · [original](https://github.com/Marvisak/VIctory/pull/1693#issuecomment-7146752977) NVIDIA run: RTX 3070 8 GB, driver 616.56, Windows 11, debug, at the PR head `77d21c6`. Tests matching `tfe` (the new TFE load / sample / gather / D16 cases and the refusals): 7 passed, 0 failed. It is based on `ffe310e` and GitHub shows conflicts with `main` `70564ae`, so this is the head as it stands, not a merge. AI-assisted (Claude Code). Synthetic tests only.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 01:34 UTC · original · edited 2026-11-26 03:20 UTC

Automated triage for the maintainers.

Thanks for the rebase; 39c440b still merges cleanly and CI (check) passes. It is the same head the previous verdict covered, and as your comment says, the substance is unchanged, so the verdict stays.

Still needed:

  • The status dword in emit/lower.rs is written 0 on every non-faulting access. The only hardware evidence in the thread (gfx1036) says the VGPR after the data keeps its old value on ordinary textures. Either leave the register unchanged where the host view cannot be non-resident, or cite a hardware or ISA source that says it is written 0.
  • Show the title needs it, e.g. how many programs a victory translate --list run on main refuses with "an image access with tfe or lwe".
  • Drop the date from the new emit/mod.rs bullet ("added 2026-11-24").

Verdict: needs work. CI: passing.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 01:34 UTC · [original](https://github.com/Marvisak/VIctory/pull/1693#issuecomment-7149706222) · edited 2026-11-26 03:20 UTC <!-- victory-triage v1 head=39c440b960cb9ea4dc63a7dea52419158ed595a9 verdict=needs-work at=2026-11-26T03:20:02Z --> Automated triage for the maintainers. Thanks for the rebase; `39c440b` still merges cleanly and CI (`check`) passes. It is the same head the previous verdict covered, and as your comment says, the substance is unchanged, so the verdict stays. Still needed: - The status dword in `emit/lower.rs` is written `0` on every non-faulting access. The only hardware evidence in the thread (gfx1036) says the VGPR after the data keeps its old value on ordinary textures. Either leave the register unchanged where the host view cannot be non-resident, or cite a hardware or ISA source that says it is written `0`. - Show the title needs it, e.g. how many programs a `victory translate --list` run on `main` refuses with "an image access with tfe or lwe". - Drop the date from the new `emit/mod.rs` bullet ("added 2026-11-24"). **Verdict: needs work.** CI: passing. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠Headache3318 on GitHub · 2026-11-25 01:45 UTC · original

Tested on Linux (Arch, kernel 7.3.5, 3× RTX 4090 driver 620.73.04), Rust 1.98.1 (pinned). PR head 77d21c6 applied cleanly onto current main ccfb029.

  • cargo test -p victory-shader --locked: 99 passed, 0 failed, 1 ignored. All tests pass, including the 3 TFE tests that run on Linux (the 4 dxil.dll/WARP/GPU tests are Windows-only).
  • cargo clippy -p victory-shader --all-targets -- -D warnings: 2 pre-existing unused-import errors in test code (fail identically on main ccfb029). The PR introduces no new clippy warnings.

Not tested: Windows MSVC build, the title itself. AI-assisted.

**@⁠Headache3318** on GitHub · 2026-11-25 01:45 UTC · [original](https://github.com/Marvisak/VIctory/pull/1693#issuecomment-7149921886) Tested on Linux (Arch, kernel 7.3.5, 3× RTX 4090 driver 620.73.04), Rust 1.98.1 (pinned). PR head `77d21c6` applied cleanly onto current `main` `ccfb029`. - `cargo test -p victory-shader --locked`: 99 passed, 0 failed, 1 ignored. All tests pass, including the 3 TFE tests that run on Linux (the 4 dxil.dll/WARP/GPU tests are Windows-only). - `cargo clippy -p victory-shader --all-targets -- -D warnings`: 2 pre-existing unused-import errors in test code (fail identically on main `ccfb029`). The PR introduces no new clippy warnings. Not tested: Windows MSVC build, the title itself. AI-assisted.
Author
Owner

@⁠upipibi on GitHub · 2026-11-25 01:50 UTC · original

A hardware data point for the status dword, from reading, not a run here: boykopovar/AnyPS5#24954 measured MIMG tfe / lwe on gfx1036 with their hardware oracle, in wave32 and wave64. On ordinary (non-sparse) textures, the VGPR after the data is never written; it keeps its old value. That holds for image_load, image_load_mip, image_sample_lz/_l, image_gather4_lz, also with d16, for in-bounds and out-of-bounds texels, mips past the last level, and a T# MIN_LOD_WARN above the LOD.

This PR writes 0 there. On a non-sparse texture that only differs if a shader reads the status without first setting it, so it's unlikely to matter in practice. Sparse (PRT) textures, where a residency value would actually come from, weren't part of that measurement. Keeping the old register value for non-tiled views (and writing the residency bit only where the host view is tiled) would match it exactly.

AI-assisted (Claude Code).

**@⁠upipibi** on GitHub · 2026-11-25 01:50 UTC · [original](https://github.com/Marvisak/VIctory/pull/1693#issuecomment-7150023456) A hardware data point for the status dword, from reading, not a run here: boykopovar/AnyPS5#24954 measured MIMG `tfe` / `lwe` on gfx1036 with their hardware oracle, in wave32 and wave64. On ordinary (non-sparse) textures, the VGPR after the data is **never written; it keeps its old value**. That holds for `image_load`, `image_load_mip`, `image_sample_lz`/`_l`, `image_gather4_lz`, also with `d16`, for in-bounds and out-of-bounds texels, mips past the last level, and a T# `MIN_LOD_WARN` above the LOD. This PR writes `0` there. On a non-sparse texture that only differs if a shader reads the status without first setting it, so it's unlikely to matter in practice. Sparse (PRT) textures, where a residency value would actually come from, weren't part of that measurement. Keeping the old register value for non-tiled views (and writing the residency bit only where the host view is tiled) would match it exactly. AI-assisted (Claude Code).
Author
Owner

@⁠tjthebigbearcat-hub on GitHub · 2026-11-25 03:19 UTC · original

Rebased cleanly onto current main (940d32f → 5d7fca5):

  • Reconciled lower.rs, mod.rs, and tfe_tests.rs with upstream's new rovs, BVH dispatch, 16-bit biased sample support (0b35b7f), and updated test struct fields.
  • Added image_bvh to the tfe refusal list so ray-tracing BVH instructions with tfe fail cleanly rather than translating silently without residency handling.
  • Re-verified cargo test -p victory-shader --locked tfe (7 passed, 0 failed) and cargo clippy (0 warnings).
**@⁠tjthebigbearcat-hub** on GitHub · 2026-11-25 03:19 UTC · [original](https://github.com/Marvisak/VIctory/pull/1693#issuecomment-7151811394) Rebased cleanly onto current `main` (`940d32f` → `5d7fca5`): - Reconciled `lower.rs`, `mod.rs`, and `tfe_tests.rs` with upstream's new `rovs`, BVH dispatch, 16-bit biased sample support (`0b35b7f`), and updated test struct fields. - Added `image_bvh` to the `tfe` refusal list so ray-tracing BVH instructions with `tfe` fail cleanly rather than translating silently without residency handling. - Re-verified `cargo test -p victory-shader --locked tfe` (7 passed, 0 failed) and `cargo clippy` (0 warnings).
Author
Owner

@⁠tjthebigbearcat-hub on GitHub · 2026-11-26 02:20 UTC · original

Rebased onto current main (63bcca4), new head 39c440b. It merges cleanly again.

  • The conflicts in lower.rs, mod.rs and shader.rs were both sides adding code in the same place, so I kept both. Upstream's uses_lane_index / has_half_wave_mask test fields sit next to tiled_resources, and its "Read marks" doc paragraph next to "Texel residency". The UAVS_EVERY_STAGE (0x4) and TILED_RESOURCES (0x100) feature bits are both kept, and no flag bits overlap.
  • cargo test -p victory-shader --locked --lib tfe: 7 passed, 0 failed.
  • cargo clippy -p victory-shader --all-targets --locked -- -D warnings: clean. cargo xtask policy: 192 files ok.
  • Full cargo test -p victory-shader --locked: 306 passed, 3 failed, 3 ignored. The three failures (stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride, stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros, synthetic_tests::gathers_at_a_level_match_the_hardware) fail the same way on a clean 63bcca4 on this machine. The stride ones look like the ones already tracked in #1744.
  • lower.rs is now 522,198 B, 2,090 B under the 512 KiB cap.

Not changed in this push: the TFE status dword still writes 0 on non-sparse textures (upipibi's note above). The overlap with #1687 still needs reconciling, whichever of the two lands second.

**@⁠tjthebigbearcat-hub** on GitHub · 2026-11-26 02:20 UTC · [original](https://github.com/Marvisak/VIctory/pull/1693#issuecomment-7180710520) Rebased onto current `main` (`63bcca4`), new head `39c440b`. It merges cleanly again. - The conflicts in `lower.rs`, `mod.rs` and `shader.rs` were both sides adding code in the same place, so I kept both. Upstream's `uses_lane_index` / `has_half_wave_mask` test fields sit next to `tiled_resources`, and its "Read marks" doc paragraph next to "Texel residency". The `UAVS_EVERY_STAGE` (`0x4`) and `TILED_RESOURCES` (`0x100`) feature bits are both kept, and no flag bits overlap. - `cargo test -p victory-shader --locked --lib tfe`: 7 passed, 0 failed. - `cargo clippy -p victory-shader --all-targets --locked -- -D warnings`: clean. `cargo xtask policy`: 192 files ok. - Full `cargo test -p victory-shader --locked`: 306 passed, 3 failed, 3 ignored. The three failures (`stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride`, `stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros`, `synthetic_tests::gathers_at_a_level_match_the_hardware`) fail the same way on a clean `63bcca4` on this machine. The stride ones look like the ones already tracked in #1744. - `lower.rs` is now 522,198 B, 2,090 B under the 512 KiB cap. Not changed in this push: the TFE status dword still writes `0` on non-sparse textures (upipibi's note above). The overlap with #1687 still needs reconciling, whichever of the two lands second.
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/1693/head:github-bot/gh-1693'
git switch 'github-bot/gh-1693'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1693'
git switch 'github-bot/gh-1693'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1693'
git switch 'github-bot/gh-1693'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1693'
git switch 'main'
git merge --squash 'github-bot/gh-1693'
git switch 'main'
git merge --ff-only 'github-bot/gh-1693'
git switch 'main'
git merge 'github-bot/gh-1693'
git push origin 'main'
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!1693
No description provided.