shader: share directory lookups across proven same-page guest-load clusters #305

Manually merged
github merged 2 commits from github-bot/gh-305 into gh-pr/305/base 2026-12-03 17:14:00 +00:00 AGit
Owner

@⁠tommiehansen on GitHub · 2026-12-03 09:58 UTC · original
tommiehansen:perf/t01-global-load-clusters → main · +318 −8 · 5 files · 2 commits · merged 2026-12-03 17:11 UTC

Problem

Compatible guest-memory loads can repeatedly look up one 64 KiB directory page and select the same descriptor. These lookups and selections add dependent work before the actual loads.

Implementation and correctness

The first commit groups an eligible adjacent pair. The follow-up extends it to 2–8 consecutive compatible instructions spanning at most 256 bytes. A cluster needs the same SSA address base and available lane guard, a static same-page proof and non-overlapping destinations. Sparse groups share the descriptor but read only the requested contiguous runs. Every original instruction retains its fault note. Unsupported cases return to ordinary lowering before emitting cluster code. The revised opt-in cache key separates the generated translations from earlier variants.

Source and dependencies

The approach is inspired by ReVIctory 925ac0a3. This PR includes the one-commit extension reviewed in fork PR #2. It needs neither upstream #303 nor the native RayQuery stack. Test with the independent scalar uniform-handle optimization in #302 when evaluating the whole stack.

Quantified improvements — synthetic translation fixtures

For eligible consecutive loads sharing a proven 64 KiB page, the emitted descriptor-handle count scales as follows:

Compatible loads Original handles Clustered handles Reduction
2 2 1 50.0%
4 4 1 75.0%
7 7 1 85.7%
8 8 1 87.5%

These are emitted-handle counts, not measured GPU instruction counts or FPS gains. Rejected cases retain byte-identical DXIL in the reported fixtures.

ReVIctory 925ac0a3 identifies seven consecutive TLAS matrix loads as a real coalescing opportunity and describes reducing them to a single directory lookup and handle. Its implementation supports a runtime page-fit check; this PR instead requires a static proof and preserves each original fault note. The other fork reports successful DXIL validation and PSO compilation of five RT shaders on RX 9070 XT for its broader change, not isolated timings for load clustering.

Issue #14 reports low occupancy (typically 25–40%), GPU idle time of 4.35%, and long-lived small waves on RX 9070. Dependent accesses to system-memory-backed title data are a plausible explanation, not a proven attribution. Reducing repeated directory selection addresses one part of that dependency chain.

Why this should be merged

This offers a bounded, independently switchable way to reduce repeated guest-address lookup work without reading gaps or weakening page, guard or fault semantics. It is suitable for opt-in evaluation alongside #302 and #301. With #262 enabled, some software-traversal opportunities may disappear; measure remaining active builder and general rendering shaders before judging net benefit.

Validation

The extended standalone branch previously passed 283 portable shader tests, with two ignored, and the diagnostics Windows-target check. Synthetic translation fixtures emitted one descriptor handle for eligible groups of 2–8 loads and verified byte-identical DXIL for rejected page crossings, overlapping destinations and other rejected ranges. The Phase 2 combination passed 293 portable shader tests, with two ignored, and both Windows-target modes. These results were reused for this publication update.

Limits and testing

Hardware benchmarking was unavailable. Real shader coverage, driver validation, register pressure and frame-time impact remain unverified. Please compare the same RT-enabled route on RX 9060 XT 16 GB at native 1080p and RX 9070 XT at native 1440p with frame generation disabled. Collect compiler and GPU timings for the shaders this affects. Use VICTORY_CLUSTER_GUEST_LOADS=1 to opt in and unset it to restore ordinary lowering.

**@⁠tommiehansen** on GitHub · 2026-12-03 09:58 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/305) `tommiehansen:perf/t01-global-load-clusters` → `main` · +318 −8 · 5 files · 2 commits · merged 2026-12-03 17:11 UTC ## Problem Compatible guest-memory loads can repeatedly look up one 64 KiB directory page and select the same descriptor. These lookups and selections add dependent work before the actual loads. ## Implementation and correctness The first commit groups an eligible adjacent pair. The follow-up extends it to 2–8 consecutive compatible instructions spanning at most 256 bytes. A cluster needs the same SSA address base and available lane guard, a static same-page proof and non-overlapping destinations. Sparse groups share the descriptor but read only the requested contiguous runs. Every original instruction retains its fault note. Unsupported cases return to ordinary lowering before emitting cluster code. The revised opt-in cache key separates the generated translations from earlier variants. ## Source and dependencies The approach is inspired by [ReVIctory 925ac0a3](https://github.com/ReTerryDavis/ReVIctory/commit/925ac0a3). This PR includes the one-commit extension reviewed in [fork PR #2](https://github.com/tommiehansen/VIctory-xmem/pull/2). It needs neither upstream #303 nor the native RayQuery stack. Test with the independent scalar uniform-handle optimization in [#302](https://git.gtahub.st/github/lobomfz--VIctory-xmem/pulls/302) when evaluating the whole stack. ## Quantified improvements — synthetic translation fixtures For eligible consecutive loads sharing a proven 64 KiB page, the emitted descriptor-handle count scales as follows: | Compatible loads | Original handles | Clustered handles | Reduction | |---:|---:|---:|---:| | 2 | 2 | 1 | 50.0% | | 4 | 4 | 1 | 75.0% | | 7 | 7 | 1 | 85.7% | | 8 | 8 | 1 | **87.5%** | These are emitted-handle counts, not measured GPU instruction counts or FPS gains. Rejected cases retain byte-identical DXIL in the reported fixtures. ## Evidence from related implementations [ReVIctory 925ac0a3](https://github.com/ReTerryDavis/ReVIctory/commit/925ac0a32f6a05c31373a2843bc555f57afba4f7) identifies seven consecutive TLAS matrix loads as a real coalescing opportunity and describes reducing them to a single directory lookup and handle. Its implementation supports a runtime page-fit check; this PR instead requires a static proof and preserves each original fault note. The other fork reports successful DXIL validation and PSO compilation of five RT shaders on RX 9070 XT for its broader change, not isolated timings for load clustering. [Issue #14](https://git.gtahub.st/github/lobomfz--VIctory-xmem/issues/14) reports low occupancy (typically 25–40%), GPU idle time of 4.35%, and long-lived small waves on RX 9070. Dependent accesses to system-memory-backed title data are a plausible explanation, not a proven attribution. Reducing repeated directory selection addresses one part of that dependency chain. ## Why this should be merged This offers a bounded, independently switchable way to reduce repeated guest-address lookup work without reading gaps or weakening page, guard or fault semantics. It is suitable for opt-in evaluation alongside #302 and #301. With #262 enabled, some software-traversal opportunities may disappear; measure remaining active builder and general rendering shaders before judging net benefit. ## Validation The extended standalone branch previously passed 283 portable shader tests, with two ignored, and the diagnostics Windows-target check. Synthetic translation fixtures emitted one descriptor handle for eligible groups of 2–8 loads and verified byte-identical DXIL for rejected page crossings, overlapping destinations and other rejected ranges. The Phase 2 combination passed 293 portable shader tests, with two ignored, and both Windows-target modes. These results were reused for this publication update. ## Limits and testing Hardware benchmarking was unavailable. Real shader coverage, driver validation, register pressure and frame-time impact remain unverified. Please compare the same RT-enabled route on RX 9060 XT 16 GB at native 1080p and RX 9070 XT at native 1440p with frame generation disabled. Collect compiler and GPU timings for the shaders this affects. Use `VICTORY_CLUSTER_GUEST_LOADS=1` to opt in and unset it to restore ordinary lowering.
Group two adjacent, contiguous global loads only when they use the same SSA address, lane guard and provably the same directory page. Read exactly the requested dwords. Preserve one fault store per original load and fall back for page crossings, unproven alignment, cache flags, helper lanes, builders and tagged probes.

Key the opt-in separately and verify emitted handle counts and page arithmetic in portable tests. Adapt the direction from ReVIctory 925ac0a3 without relying on the older translator’s directory ABI.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-03 09:58:32 +00:00
github-bot changed title from shader: share a directory lookup for proven guest load pairs to shader: share directory lookups across proven same-page guest-load clusters 2026-12-03 11:04:11 +00:00
Recognize up to eight adjacent guest-load instructions without mutating translator state. Reuse the directory lookup for a proven page, split sparse sequences into contiguous requested runs, and retain every fault note. Unsupported guards, page crossings and overlapping destinations use ordinary lowering.

Use a distinct opt-in cache key. Fixture tests cover group sizes, gaps, boundaries and byte-identical rejected DXIL. Standard hardware timing and real shader coverage remain unmeasured.
Author
Owner

@⁠lucamzanon on GitHub · 2026-12-03 13:02 UTC · original · edited 2026-12-03 13:25 UTC

Automated A/B/B/A Benchmark Feedback (RX 9070 XT / Linux RADV)

Test setup:

  • Hardware / OS: AMD Radeon RX 9070 XT 16 GB (RDNA4, RADV GFX1201), Ryzen 7 5700X, 46 GB RAM, Ubuntu 26.04.1 LTS (kernel 7.0.0-44-generic), repo-built Mesa 26.3.1 RADV + vkd3d-proton
  • Settings: VICTORY_BENCH=rt, VICTORY_BENCH_MINUTES=2 (first 60 s discarded, second 60 s measured), 2560x1440 → 4K FSR 4 Quality, no Frame Generation
  • Methodology: Interleaved A -> B -> B -> A (4 runs per scene), identical save restored before every run, shared warm pipeline cache (94,199 pipelines), clustered shaders pre-translated (./run.sh shaders VICTORY_CLUSTER_GUEST_LOADS=1, 25,694 shaders in 108 s)
    • A (baseline): main (842767a)
    • B (candidate): PR #305 (44f5b82), VICTORY_CLUSTER_GUEST_LOADS=1

Results:

Scene Baseline A (avg / 1% low) Candidate B (avg / 1% low) Delta Pair wins
Boat (2m x 4) 30.75 fps (31.0 / 30.5) / 10.45 30.45 fps (29.9* / 31.0) / 10.70 -0.98% avg (+1.64% warm B vs A2) / +2.39% 1% low 1/2
Prison (2m x 4) 21.25 fps (21.5 / 21.0) / 6.45 21.45 fps (21.4 / 21.5) / 6.20 +0.94% avg / -3.88% 1% low 1/2

*Boat Run 2 (B) took 248.9 s vs ~142 s due to first-time RADV pipeline compilation for the clustered shaders; Boat Run 3 (warm B, 144.2 s) hit 31.00 fps avg / 11.00 fps 1% low vs Run 4 (A) 30.50 fps / 10.50.

Per-run Prison breakdown (all warm):

  • Run 1 (A): 21.50 fps (1% low 6.10, peak 28.30)
  • Run 2 (B): 21.40 fps (1% low 6.20, peak 29.80)
  • Run 3 (B): 21.50 fps (1% low 6.20, peak 29.00)
  • Run 4 (A): 21.00 fps (1% low 6.80, peak 27.90)

Summary: Zero crashes or visual issues. On RX 9070 XT at 4K RT (heavily GPU-bound), warm performance is neutral to slightly positive (~+0.9% to +1.6% avg, higher peak FPS on Prison: 29.0–29.8 vs 27.9–28.3).

Caveat: These runs used default VICTORY_BENCH=rt without scripted gameplay movement (VICTORY_KEYS / VICTORY_KEYS_WORLD), so they mostly measure stationary/cutscene frames. Updating our harness to inject scripted movement via diag + VICTORY_KEYS_WORLD and will follow up with moving-gameplay numbers.

**@⁠lucamzanon** on GitHub · 2026-12-03 13:02 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/305#issuecomment-7379225242) · edited 2026-12-03 13:25 UTC ### Automated A/B/B/A Benchmark Feedback (RX 9070 XT / Linux RADV) **Test setup:** - **Hardware / OS:** AMD Radeon RX 9070 XT 16 GB (RDNA4, `RADV GFX1201`), Ryzen 7 5700X, 46 GB RAM, Ubuntu 26.04.1 LTS (kernel `7.0.0-44-generic`), repo-built Mesa 26.3.1 RADV + vkd3d-proton - **Settings:** `VICTORY_BENCH=rt`, `VICTORY_BENCH_MINUTES=2` (first 60 s discarded, second 60 s measured), 2560x1440 → 4K FSR 4 Quality, no Frame Generation - **Methodology:** Interleaved `A -> B -> B -> A` (4 runs per scene), identical save restored before every run, shared warm pipeline cache (94,199 pipelines), clustered shaders pre-translated (`./run.sh shaders VICTORY_CLUSTER_GUEST_LOADS=1`, 25,694 shaders in 108 s) - **A (baseline):** `main` (`842767a`) - **B (candidate):** PR #305 (`44f5b82`), `VICTORY_CLUSTER_GUEST_LOADS=1` **Results:** | Scene | Baseline A (avg / 1% low) | Candidate B (avg / 1% low) | Delta | Pair wins | |---|---:|---:|---:|---:| | **Boat** (`2m x 4`) | `30.75 fps` (`31.0` / `30.5`) / `10.45` | `30.45 fps` (`29.9`* / `31.0`) / `10.70` | `-0.98%` avg (`+1.64%` warm B vs A2) / `+2.39%` 1% low | 1/2 | | **Prison** (`2m x 4`) | `21.25 fps` (`21.5` / `21.0`) / `6.45` | **`21.45 fps`** (`21.4` / `21.5`) / `6.20` | **`+0.94%`** avg / `-3.88%` 1% low | 1/2 | *\*Boat Run 2 (B) took 248.9 s vs ~142 s due to first-time RADV pipeline compilation for the clustered shaders; Boat Run 3 (warm B, 144.2 s) hit `31.00 fps` avg / `11.00 fps` 1% low vs Run 4 (A) `30.50 fps` / `10.50`.* **Per-run Prison breakdown (all warm):** - Run 1 (A): `21.50 fps` (1% low `6.10`, peak `28.30`) - Run 2 (B): `21.40 fps` (1% low `6.20`, peak `29.80`) - Run 3 (B): `21.50 fps` (1% low `6.20`, peak `29.00`) - Run 4 (A): `21.00 fps` (1% low `6.80`, peak `27.90`) **Summary:** Zero crashes or visual issues. On RX 9070 XT at 4K RT (heavily GPU-bound), warm performance is **neutral to slightly positive (~+0.9% to +1.6% avg, higher peak FPS on Prison: 29.0–29.8 vs 27.9–28.3)**. > **Caveat:** These runs used default `VICTORY_BENCH=rt` without scripted gameplay movement (`VICTORY_KEYS` / `VICTORY_KEYS_WORLD`), so they mostly measure stationary/cutscene frames. Updating our harness to inject scripted movement via `diag` + `VICTORY_KEYS_WORLD` and will follow up with moving-gameplay numbers.
github-bot changed target branch from main to gh-pr/305/base 2026-12-03 17:13:55 +00:00
github manually merged commit 44f5b82d2d into gh-pr/305/base 2026-12-03 17:14:00 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.