Skip to content

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

Open
tjthebigbearcat-hub wants to merge 1 commit into
Marvisak:mainfrom
tjthebigbearcat-hub:fix/starter-pr
Open

tjthebigbearcat-hub wants to merge 1 commit into
Marvisak:mainfrom
tjthebigbearcat-hub:fix/starter-pr

Conversation

@tjthebigbearcat-hub

Copy link
Copy Markdown
Contributor

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 DenRakEiw left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 catminou4 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

upipibi commented Nov 24, 2026

Copy link
Copy Markdown

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 Nov 25, 2026 •

Copy link
Copy Markdown
Owner

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

@Headache3318

Copy link
Copy Markdown

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

upipibi commented Nov 25, 2026

Copy link
Copy Markdown

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

Copy link
Copy Markdown
Contributor Author

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

Copy link
Copy Markdown
Contributor Author

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 Test report: RTX 5070 (Blackwell), Windows 11, 70564ae: 471 passed, 5 failed, 7 ignored (4 from the 1,000,000 view heap cap) #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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants