feat(shader): keep direct VGPR accesses direct outside indexed-write slots #27862
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/27862"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by MauriceSirius on 2026-11-27T16:16:49Z.
What
Relative VGPR indexing put every access to a windowed register through the indexed window array as soon as any relative write existed, so a program whose lowest relative write sits at a high base register pays an array indirection for every direct access below it. Killzone: Liberation (PPSA11142) has 104 relative accesses over 154 registers with dynamic indices
UMin32(IAdd32(0x39 | 0x3a | 0, ReadFirstLane(<window register>)), 0x97), and its 1,730 constant-indexed VGPR accesses all went through a 152-registerOpVariablearray, costing ~6 FPS in its PSP vertex programs.The translation scan now records, beside the window base, the lowest base register each relative read and each relative write addresses as window slots (
vectorWindowIndexedReadSlot,vectorWindowIndexedWriteSlot). The register IR builder uses them as floors:Every relative access is still served by the window array, loops, branches and mixed direct/indexed accesses on aliased slots keep the load-merge-store semantics, and programs whose relative write starts at the window base keep the previous behaviour unchanged. This composes with the existing slot narrowing instead of replacing it.
Tested
agc_vector_window(recompiler SSA-shape tests, three new): an indexed write above the window base keeps direct accesses to lower registers in SSA values; direct accesses below a window's lowest relative write shrink its SPIR-V (fewerOpAccessChain, fewer words) against one whose relative write spans the window; a direct access under a relative write's base register stays in SSA inside the write's loop.agc_driver_vector_window_direct_access,agc_driver_vector_window_liveness,agc_driver_vector_window_narrowing,agc_driver_vector_window_region,agc_driver_relative_ancillary,agc_driver_relative_dpp,agc_driver_relative_indexing,agc_driver_relative_indexing_bounded_values,agc_driver_relative_indexing_known_bits,agc_driver_relative_stage_inputs— 12/12 passed wave32/wave64 with validation-layer runs on Intel Iris Xe.ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validationover-R agc_driver_vector_window -V): this PR and15a9e02acbcboth log the layer insert in all four test processes, zero "was not found", zeroVUID-messages.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Summary by CodeRabbit
Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-11-27T16:39:08Z.
Review: COMMENTED
I reproduced a failure in the new SPIR-V shape assertion at
489c05c43f02on Linux GCC 16.2.1 Release with bundled SPIRV-Tools enabled. The officialagc_vector_windowfixture reports 674 words and 4 access chains for the v6 write, versus 677 words and 4 chains for v4. It fails the strict access-chain comparison.Using identical inputs on its main parent
15a9e02acbc8, v6 produced 682 words and 4 chains. The v4 control produced 677 words and 4 chains on both builds. The optimized v6 program therefore does get smaller in this configuration. The stage-input test passed on both builds.Changing the shape check to require fewer words and no increase in access chains passes the full fixture against the same PR recompiler. The separate SSA tests still check the routing directly.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-27T16:50:59Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the inspected IR routing and window sync floors are consistent with the new per-access base slots, and the author reports GPU validation runs that I did not perform.
What I ran
Reviewed head
489c05c43f0235162dc426378b2c37932477d097. No tests or builds were run. I read all five changed files listed asreviewedin the manifest and inspected the relevant translation, control-flow, and SPIR-V emitter code. The author-reported test results are not my runs.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
I did not run the listed unit or GPU tests, validate the shaders, or capture a Killzone scene trace. No files were excluded according to the review manifest.
To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-28T14:06:07Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change based on the source and test additions reviewed; the submitted test results are author-reported and were not run here.
What I ran
Reviewed head
0550c95d45e0ff35bc6c6b391d8d51482b3c62f4usingrepo_read.py. I readdescription.md,commits.md,manifest.json,diff.patch, and all five changed files listed in the manifest. No tests or builds were run.Results
Findings
Blocking
None identified in the changed code reviewed.
Non-blocking
None.
Not verified
The reported recompiler and Vulkan test runs were not independently run or confirmed. No unchanged callers or other repository files were inspected.
files.jsonwas not available through the review reader, so I could not check for excluded files; the manifest lists five changed files, all marked included.To get this to a good state
Nothing is required.