shader: use uniform handles for proven scalar guest loads #302

Manually merged
github merged 1 commit from github-bot/gh-302 into main 2026-12-03 17:20:05 +00:00 AGit
Owner

@⁠tommiehansen on GitHub · 2026-12-03 09:42 UTC · original
tommiehansen:perf/t01-uniform-guest-loads → main · +85 −2 · 5 files · 1 commits · merged 2026-12-03 17:14 UTC

Problem

Scalar guest loads use nonuniform heap handles even for addresses derived entirely from constants and host user data. That can force unnecessary descriptor divergence in the backend.

Implementation

When VICTORY_UNIFORM_GUEST_LOADS=1, prove that both address words and the optional scalar offset are dispatch-uniform before selecting a uniform handle. Only proven literals, the shader's own user buffer, and bounded deterministic expressions enter the proof. Other paths preserve the nonuniform handle, including all vector accesses. Page lookup, read-only and missing-page behavior, fault stores, and guards remain the same. The option has a separate shader and pipeline cache identity.

The optimization was motivated by ReVIctory 925ac0a3. This PR implements the conservative scalar-handle portion independently of global-load clustering.

Quantified behavior — translator output, not GPU timings

Guest-load address provenance Original descriptor selection Opt-in selection
Proven constant or dispatch-invariant scalar expression Nonuniform Uniform
Unproven scalar expression Nonuniform Nonuniform
Vector guest access Existing path Unchanged

ReVIctory 925ac0a3 uses wave-uniform handles for scalar memory loads and reports validation of five RT shaders and PSO compilation on RX 9070 XT for its broader shader change. It does not report isolated FPS or GPU-time savings from uniform handles.

Issue #14 reports typically 25–40% occupancy and small waves lasting tens of microseconds on RX 9070. Avoiding unnecessary descriptor divergence is a plausible optimization for this workload; the compiler's actual handling and frequency of eligible loads must be measured.

Why this should be merged

The bounded proof avoids relying solely on the scalar opcode to establish uniformity. This is a narrow, opt-in translator optimization with a distinct cache key and a conservative fallback. It can be evaluated independently of #305 and the native RayQuery stack. Inspect final RADV ISA and shader timings to establish whether waterfalls or other unnecessary backend work actually disappear.

Validation

281 portable shader tests passed with 2 ignored. Windows-target checking with diagnostics and test targets passed on macOS using a check-only mimalloc override and pure Rust BLAKE3. Hardware benchmarking and RDNA ISA capture were unavailable.

Please compare the option on and off on RX 9060 XT 16 GB and RX 9070 XT, RT enabled, native Series X rendering at 1080p and 1440p respectively. Check the emitted descriptor code, shader GPU time, frame-time percentiles and image parity on the same scenes. The option is off by default.

**@⁠tommiehansen** on GitHub · 2026-12-03 09:42 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/302) `tommiehansen:perf/t01-uniform-guest-loads` → `main` · +85 −2 · 5 files · 1 commits · merged 2026-12-03 17:14 UTC ## Problem Scalar guest loads use nonuniform heap handles even for addresses derived entirely from constants and host user data. That can force unnecessary descriptor divergence in the backend. ## Implementation When `VICTORY_UNIFORM_GUEST_LOADS=1`, prove that both address words and the optional scalar offset are dispatch-uniform before selecting a uniform handle. Only proven literals, the shader's own user buffer, and bounded deterministic expressions enter the proof. Other paths preserve the nonuniform handle, including all vector accesses. Page lookup, read-only and missing-page behavior, fault stores, and guards remain the same. The option has a separate shader and pipeline cache identity. The optimization was motivated by [ReVIctory 925ac0a3](https://github.com/ReTerryDavis/ReVIctory/commit/925ac0a3). This PR implements the conservative scalar-handle portion independently of global-load clustering. ## Quantified behavior — translator output, not GPU timings | Guest-load address provenance | Original descriptor selection | Opt-in selection | |---|---|---| | Proven constant or dispatch-invariant scalar expression | Nonuniform | Uniform | | Unproven scalar expression | Nonuniform | Nonuniform | | Vector guest access | Existing path | Unchanged | ## Evidence from related implementations [ReVIctory 925ac0a3](https://github.com/ReTerryDavis/ReVIctory/commit/925ac0a32f6a05c31373a2843bc555f57afba4f7) uses wave-uniform handles for scalar memory loads and reports validation of five RT shaders and PSO compilation on RX 9070 XT for its broader shader change. It does not report isolated FPS or GPU-time savings from uniform handles. [Issue #14](https://git.gtahub.st/github/lobomfz--VIctory-xmem/issues/14) reports typically 25–40% occupancy and small waves lasting tens of microseconds on RX 9070. Avoiding unnecessary descriptor divergence is a plausible optimization for this workload; the compiler's actual handling and frequency of eligible loads must be measured. ## Why this should be merged The bounded proof avoids relying solely on the scalar opcode to establish uniformity. This is a narrow, opt-in translator optimization with a distinct cache key and a conservative fallback. It can be evaluated independently of #305 and the native RayQuery stack. Inspect final RADV ISA and shader timings to establish whether waterfalls or other unnecessary backend work actually disappear. ## Validation 281 portable shader tests passed with 2 ignored. Windows-target checking with diagnostics and test targets passed on macOS using a check-only mimalloc override and pure Rust BLAKE3. Hardware benchmarking and RDNA ISA capture were unavailable. Please compare the option on and off on RX 9060 XT 16 GB and RX 9070 XT, RT enabled, native Series X rendering at 1080p and 1440p respectively. Check the emitted descriptor code, shader GPU time, frame-time percentiles and image parity on the same scenes. The option is off by default.
Opt in to uniform descriptor selection when a bounded proof finds only literals or invariant user data in both address words and the optional scalar offset. Preserve the fault path, address arithmetic, and nonuniform fallback for every other access.

Keep an independent translation cache key for the enabled setting. The portable shader suite covers the proof and its fallback. Hardware ISA and performance are unmeasured.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-03 09:47:51 +00:00
github manually merged commit 2280f88dfb into main 2026-12-03 17:20:04 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.