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

Open
tjthebigbearcat-hub wants to merge 1 commit from upstream-pr/1693 into main
tjthebigbearcat-hub commented 2026-11-24 20:47:54 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by tjthebigbearcat-hub on 2026-11-24T20:47:54Z.


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.
<!-- greyfinch-sync:Marvisak/VIctory:issue:6591099718 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1693). Originally posted by [tjthebigbearcat-hub](https://github.com/tjthebigbearcat-hub) on 2026-11-24T20:47:54Z. --- ### 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**.
DenRakEiw commented 2026-11-24 21:03:14 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-24T20:57:00Z.

Review: APPROVED


Verified locally merged onto origin/main (Windows 11 x64, NVIDIA GeForce RTX 5090 + WARP, Rust 1.98.1 MSVC, with dxil.dll validator):

  • cargo test -p victory-shader --lib emit::tfe_tests:: — 7 passed, 0 failed on both RTX 5090 hardware and VICTORY_D3D12_WARP=1
  • cargo clippy -p victory-shader --all-targets — 0 warnings
  • cargo xtask policy — ok

Clean lowering of TFE image loads, samples, and gathers via CheckAccessFullyMapped with comprehensive end-to-end GPU+WARP test coverage in tfe_tests.rs. Looks good.

AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6047273038 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1693#pullrequestreview-6047273038). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-24T20:57:00Z. **Review:** APPROVED --- Verified locally merged onto `origin/main` (Windows 11 x64, NVIDIA GeForce RTX 5090 + WARP, Rust 1.98.1 MSVC, with `dxil.dll` validator): - `cargo test -p victory-shader --lib emit::tfe_tests::` — 7 passed, 0 failed on both RTX 5090 hardware and `VICTORY_D3D12_WARP=1` - `cargo clippy -p victory-shader --all-targets` — 0 warnings - `cargo xtask policy` — ok Clean lowering of TFE image loads, samples, and gathers via `CheckAccessFullyMapped` with comprehensive end-to-end GPU+WARP test coverage in `tfe_tests.rs`. Looks good. AI-assisted (Gemini 4 Neon).
catminou4 commented 2026-11-24 23:05:00 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T22:20:11Z.

Review: COMMENTED


Merge conflict with current main (70564ae) — needs a rebase. (Also note: this overlaps in scope with #1687's CheckAccessFullyMapped TFE work; whichever lands second will need to reconcile the two.)

<!-- greyfinch-sync:Marvisak/VIctory:review:6048314760 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1693#pullrequestreview-6048314760). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-24T22:20:11Z. **Review:** COMMENTED --- Merge conflict with current main (70564ae) — needs a rebase. (Also note: this overlaps in scope with #1687's CheckAccessFullyMapped TFE work; whichever lands second will need to reconcile the two.)
upipibi commented 2026-11-24 23:06:03 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by upipibi on 2026-11-24T22:52:54Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7146752977 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1693#issuecomment-7146752977). Originally posted by [upipibi](https://github.com/upipibi) on 2026-11-24T22:52:54Z. --- 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.
Marvisak commented 2026-11-25 02:06:12 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T01:34:35Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7149706222 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1693#issuecomment-7149706222). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T01:34:35Z. --- <!-- 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)_
Headache3318 commented 2026-11-25 02:06:18 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Headache3318 on 2026-11-25T01:45:33Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7149921886 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1693#issuecomment-7149921886). Originally posted by [Headache3318](https://github.com/Headache3318) on 2026-11-25T01:45:33Z. --- 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.
upipibi commented 2026-11-25 02:06:26 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by upipibi on 2026-11-25T01:50:43Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7150023456 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1693#issuecomment-7150023456). Originally posted by [upipibi](https://github.com/upipibi) on 2026-11-25T01:50:43Z. --- 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).
tjthebigbearcat-hub commented 2026-11-25 04:06:48 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by tjthebigbearcat-hub on 2026-11-25T03:19:46Z.


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).
<!-- greyfinch-sync:Marvisak/VIctory:comment:7151811394 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1693#issuecomment-7151811394). Originally posted by [tjthebigbearcat-hub](https://github.com/tjthebigbearcat-hub) on 2026-11-25T03:19:46Z. --- 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 commented 2026-11-26 03:05:08 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by tjthebigbearcat-hub on 2026-11-26T02:20:32Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7180710520 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1693#issuecomment-7180710520). Originally posted by [tjthebigbearcat-hub](https://github.com/tjthebigbearcat-hub) on 2026-11-26T02:20:32Z. --- 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 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/1693:upstream-pr/1693'
git switch 'upstream-pr/1693'

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/1693'
git switch 'upstream-pr/1693'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1693'
git switch 'upstream-pr/1693'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1693'
git switch 'main'
git merge --squash 'upstream-pr/1693'
git switch 'main'
git merge --ff-only 'upstream-pr/1693'
git switch 'main'
git merge 'upstream-pr/1693'
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
Marvisak/VIctory!1692
No description provided.