Reuse shader user-data loads by constant-buffer row #231

Manually merged
github merged 3 commits from github-bot/gh-231 into main 2026-12-03 17:20:14 +00:00 AGit
Owner

@⁠tommiehansen on GitHub · 2026-12-02 19:54 UTC · original
tommiehansen:perf/cache-user-data-rows → main · +76 −30 · 3 files · 3 commits · merged 2026-12-03 17:15 UTC

Change

Read each immutable 16-byte row of shader user data once in the entry block. Create only the components that the shader requests and reuse those values. The translation still records the original dword indices and buffer size, and the entry block dominates the uses. This applies to the host's root constants, including those used by native BVH tests.

The translator creates fewer redundant instructions. Some of those loads may already disappear in later compiler passes, so the change has a direct IR and translation benefit and needs hardware evidence for any frame-time effect.

Quantified translator fixture

Metric Original Updated
User-data requests 6 6
Constant-buffer rows touched 2 2
Emitted row loads in the fixture 6 2 (66.7% fewer)

The result describes emitted loads in the fixture, not final GPU ISA. Related shader optimizations #302 and #305 target guest-memory descriptor selection rather than user-data row reuse.

Validation

  • An instruction census verified two emitted loads for six requests spanning two rows.
  • The portable shader suite passed independently for this branch. Standard and diagnostic Windows-target Rust checking passed on the integrated checkout.
  • Hardware benchmarking was unavailable.

Please test shader cache and pipeline warm-up, image parity, and frame times with ray tracing at native 1080p on both the RX 9060 XT 16 GB and RX 9070 XT under Linux.

**@⁠tommiehansen** on GitHub · 2026-12-02 19:54 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/231) `tommiehansen:perf/cache-user-data-rows` → `main` · +76 −30 · 3 files · 3 commits · merged 2026-12-03 17:15 UTC ## Change Read each immutable 16-byte row of shader user data once in the entry block. Create only the components that the shader requests and reuse those values. The translation still records the original dword indices and buffer size, and the entry block dominates the uses. This applies to the host's root constants, including those used by native BVH tests. The translator creates fewer redundant instructions. Some of those loads may already disappear in later compiler passes, so the change has a direct IR and translation benefit and needs hardware evidence for any frame-time effect. ## Quantified translator fixture | Metric | Original | Updated | |---|---:|---:| | User-data requests | 6 | 6 | | Constant-buffer rows touched | 2 | 2 | | Emitted row loads in the fixture | 6 | 2 (66.7% fewer) | The result describes emitted loads in the fixture, not final GPU ISA. Related shader optimizations [#302](https://git.gtahub.st/github/lobomfz--VIctory-xmem/pulls/302) and [#305](https://git.gtahub.st/github/lobomfz--VIctory-xmem/pulls/305) target guest-memory descriptor selection rather than user-data row reuse. ## Validation - An instruction census verified two emitted loads for six requests spanning two rows. - The portable shader suite passed independently for this branch. Standard and diagnostic Windows-target Rust checking passed on the integrated checkout. - Hardware benchmarking was unavailable. Please test shader cache and pipeline warm-up, image parity, and frame times with ray tracing at native 1080p on both the RX 9060 XT 16 GB and RX 9070 XT under Linux.
The translator emits a fresh constant-buffer row load for each
requested user-data dword. Several requests may read the same row
or even the same component, including the native BVH constants.

Cache one entry-block load per row and extract used components on
demand. Reuse those SSA values even when requested from different
blocks. The host still binds the same indices and buffer extent.

An instruction census checks that six requests across two rows
emit two loads. The portable tests and Windows-target check passed.
Bump the translator cache key for the changed output.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-02 19:57:22 +00:00
The upstream merge retained both declarations and prevents the shader crate from compiling. Preserve cached user-data rows under their dedicated cache version.

Passed 282 portable shader tests and the diagnostics Windows-target check. Hardware benchmarking was unavailable.
github manually merged commit a7a417b9ca into main 2026-12-03 17:20:13 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.