perf(recompiler): add a window-select form for register windows behind a runtime switch #23243
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/23243"
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 muhmuhkuh on 2026-11-18T20:54:37Z.
What
Adds an opt-in second form for the register window of a compute program (the
v_movrels/v_movreldwindow that the recompiler emits as a function-storage array today), and builds it in the background so a dispatch never waits for it.SpirvTarget::windowSelects, a program whose window has at most 128 slots, and whose every window index is a constant below the window size or aUMin32with a constant below the window size, keeps each slot in its own function variable. A read with a variable index loads every slot and selects the one whose number equals the index; a write stores the value into the slot it names and each other slot's own value back into it. Constant indices address their slot directly. The form is taken only while the number of dynamic accesses times the window size times the lane count stays at or below 32768 select cases, and never for the mesh window buffer; any other program keeps the array. Without the flag the module is unchanged.APS5_WINDOW_SELECTS(runtime switch, also switchable throughAPS5_AB) requests the form for compute dispatches. While the pipeline of the select form is not built, the dispatch recompiles and runs the array form, uncached, and the select pipeline is built on the compute prebuild threads; a[staged-form]line logs the start and the result. OnceVulkanDevice::ComputePipelineReadyreports the pipeline, dispatches switch to it. The dispatch key mixes the flag.windowSelectsin the artifact), cache key includes the flag.tests/execution/WindowSelects.cpp(agc_driver_window_selects_forms,agc_driver_window_selects_dispatch);RequestSerializerTestscovers version 65 and the read of version 64.Correctness for every input: the index of a variable access is the result of
UMin32(x, c)withcbelow the window size, or a constant below it, so it always names exactly one slot. A read returns the value of that slot, because the chain starts from slot 0 and replaces the value only whereindex == slot. A write changes only that slot; every other slot stores its own loaded value back. The slots start at 0 like the array. Programs outside these bounds keep the array form.Tested
Windows 11 Pro 10.0.26200, NVIDIA GeForce RTX 3080 Ti, driver 610.88.
main(6286d36449) and on this branch withANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1andVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, from the same machine and GPU, 206 recompiler, AGC driver, frame capture and shader cache tests:main205 of 206, this branch 206 of 206, plus the threeagc_driver_window_selectstests on the branch. The one failure onmainis the timing check ofagc_driver_pm4_order_signal(a held submission started 0.138 ms after the wait began) while other builds loaded the machine; it passed on the branch.VUID-0 on both,was not found but was requested0 on both, the validation layer was inserted on both.agc_driver_window_selects_forms: a program without a register window compiles to the same module with the flag requested; the register-window program compiles the select form only when requested.agc_driver_window_selects_dispatch: the register-window program gives the same output with the switch unset, at the first dispatch with the switch set (array form, while the select pipeline builds), after the background build (select form, counted) and after the switch is unset again; a program without a window never runs the select form.agc_driver_window_selectswithout arguments runs both checks.agc_vector_windowandagc_shader_disk_cachetests (7): passed onmainand on this branch.agc_shader_memoryandagc_shader_memory_coherent_atomic_loads(CPU only, they open no Vulkan device), run with the same environment: passed onmainand on this branch. The legacy fixtures that cut a current request down to versions 54 and 49 now remove the 7-byte tail of version 63 (maxImageArrayLayers,fixedPushSlots,spannedAnySubgroup,windowSelects); with the 6-byte cut the test failed withunexpected trailing data.python3 tools/check_conventions.py --base origin/main: passed.python3 tools/pr_overlap.py --branch crew/f2/window-selects: exit 2, open pull requests change neighbouring lines; none implements a register-window form or a staged build.Dispatch.cpp, where this change adds two.VulkanDevice::HasComputePipelineand the compute pipeline counters, where this change addsComputePipelineReadyandWindowSelectDispatches.Driver::dispatch, where this change setswindowSelects, and inVulkanDevice::recordDispatch, where this change counts select-form dispatches.ShaderDiskCache.hpp), the request serialization version and its tail (RequestSerializer.cpp,RequestSerializerTests.cpp,tests/ShaderMemory.cpp) and the last runtime switch (RuntimeSwitches.hpp/.cpp).SpirvAluEmitterRegisters.cpporSpirvModuleSetup.cppbecause they do not merge withmain(#7642, #9356, #9387, #9508, #10193, #10867, #11483, #13928, #13929, #15548, #17611); their diffs of these files were read and none touches the register window.tools/trace_digest.pysummaries of the same build with the switch unset and set (APS5_ABarms), on the same machine and in the same scene of a title, in alternating phases of one run with a warm shader cache.mainalone does not reach that scene, so the measured build also carries other open changes; the switch turns only this change on and off, and the arms alternate within the same run. The GPU time of the program that takes the select form fell by about a quarter. The frame time of the scene moved by less than the variation between phases, so this change alone gives no clear frame-time result there; together with other pending changes, including the split of multi-wave workgroups, the frame time fell clearly.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
APS5_WINDOW_SELECTS.APS5_AB.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T08:06:37Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the points below are optional.
What I ran
Reviewed head
ff676cbd73881d0bd86e1a8876f53b5c9f777664. No commands or tests were run. Read the prepared description, commits, manifest, and diff, then inspected the changed code and targeted context withrepo_read.py.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The changed files
core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppandcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppwere excluded from the review folder for size; I read only their changed ranges throughrepo_read.py. All other changed files listed inmanifest.jsonwere included and reviewed. Tests, build, and console behavior were not independently verified; reported test results are from the PR description.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T18:42:34Z.
Review: DISMISSED
Reviewed — changes requested
Changes are required before merge: correct the Base64 decoder’s
/mapping to 63.What I ran
eddca79129d3ea41ced5b479152b290a67845b54using the prepared diff andrepo_read.pyreader.Results
Findings
Blocking
core/shader/recompiler/ControlFlow/src/RequestSerializer.cpp:558: the changed decoder returns 64 for/, but Base64 sextets range from 0 to 63 and/must map to 63. Any serialized request containing/is decoded with corrupted data, breaking deserialization of valid requests (and legacy fixtures). Restore the mapping to 63.Non-blocking
Not verified
core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppandcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp; the changedVulkanDevice.cppranges were read through the pinned reader, whileShaderMemory.cppwas reviewed only through its diff.To get this to a good state
/to Base64 value 63 and run the request serialization tests.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-23T09:06:08Z.
Review: COMMENTED
Reviewed — no blocking findings
The changed compiler, dispatch, cache, and serialization paths inspected at head
5a08b30b2acb01874f7d38bd8aa46e26d99c6756show no verified blocking defect; I did not run checks.What I ran
No commands or tests were run. I read the supplied review bundle and used
repo_read.pyto inspect selected repository files at the pinned head.Results
Findings
Blocking
None found in the files read.
Non-blocking
None.
Not verified
I did not read the full text of
core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpporcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp, which the manifest excludes for size. I read selected ranges from the other changed files, not every file listed as reviewed. No tests, build, or precheck were run; the test and performance results in the description are author-reported.To get this to a good state
Nothing is required.
Reviewed bundle documents:
description.md,commits.md,manifest.json, anddiff.patch. Repository files read: selected ranges ofDispatch.cpp,VulkanDevice.cpp,SpirvAluEmitterRegisters.cpp,SpirvModuleSetup.cpp,SpirvEmitter.cpp,RequestSerializer.cpp,Recompiler.hpp, andShaderDiskCache.hpp. Excluded by the bundle:VulkanDevice.cppandShaderMemory.cpp; other changed files were not read in full.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-25T07:15:50Z.
Review: COMMENTED
Reviewed — no blocking findings
The reviewed code shows no verified blocking defect, but this review is incomplete because some changed files were not read and tests were not run.
What I ran
Reviewed head
6c609c8254574b1c3cb0c5651ad7cb2db4586bfa. No commands or tests were run; the author-reported test results were not independently verified.Results
Findings
Blocking
None verified in the code read.
Non-blocking
None.
Not verified
The bundle lists 21 changed files, of which 19 have full text included and 2 were excluded as too large. I read the description, commits, manifest, and full diff, and targeted source ranges in
Dispatch.cpp,VulkanDevice.cpp,SpirvModuleSetup.cpp,SpirvAluEmitterRegisters.cpp,RequestSerializer.cpp, andShaderDiskCache.cpp. I did not read the excludedVulkanDevice.cppandShaderMemory.cppin full, nor all other changed files in full. No tests or builds were run; author-reported checks and hardware results remain unverified.To get this to a good state
Nothing is required. Optional: complete review of the unread changed files and run the focused tests before making a formal approval decision.
Sources
Behavior reviewed against the supplied diff and source at the pinned head: Dispatch.cpp, SpirvModuleSetup.cpp, SpirvAluEmitterRegisters.cpp, and RequestSerializer.cpp.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-25T17:55:39Z.
Review: COMMENTED
Reviewed — no blocking findings
The inspected code shows no verified blocking defect, but this review is incomplete because tests were not run and not all changed files were read at the pinned head.
What I ran
Inspected the prepared diff and targeted source at head
d8ad6980ebcfb56a11b077458b2e9876f0df9172. No shell commands or tests were run; the reader was used to inspect source. No merged-preview check was performed.Results
Negative Control
Could not run a negative control because tests were not executed.
Findings
Blocking
None verified in the inspected code.
Non-blocking
None.
Sources
Not verified
The changed files were represented in the prepared diff, but only 9 of 22 changed files were read directly at the head. In particular, the full changed portions of
ShaderMemory.cppandVulkanDevice.cppwere not reviewed; only targeted ranges were read. The other 11 changed files were not read directly at the head. The two files excluded from the review folder wereVulkanDevice.cppandShaderMemory.cpp; they were accessed only through targeted reader ranges. Reported author test results were not independently verified.To get this to a good state
Nothing is required. Optional: complete source review of the unread changed files and run the focused tests on this head before making a formal decision.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-27T20:20:13Z.
Review: COMMENTED
Actionable comments posted: 1
ed2bda7c-9a3d-4cda-a7e4-52f9ffffca4cReviewing files that changed from the base of the PR and between
fdf873a7d2and2787553462.core/libs/prx/libSceAgcDriver/Execution/include/VulkanDevice.hppcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Dispatch/Dispatch.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Graphics/include/RuntimeSwitches.hppcore/libs/prx/libSceAgcDriver/Graphics/src/RuntimeSwitches.cppcore/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_window_selects_tests.cmakecore/libs/prx/libSceAgcDriver/tests/execution/WindowSelects.cppcore/shader/recompiler/CacheKey.hppcore/shader/recompiler/ControlFlow/src/RequestSerializer.cppcore/shader/recompiler/Recompiler.cppcore/shader/recompiler/Recompiler.hppcore/shader/recompiler/ShaderDiskCache.cppcore/shader/recompiler/ShaderDiskCache.hppcore/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitter.hppcore/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hppcore/shader/recompiler/SpirvBackend/src/SpirvAlu/SpirvAluEmitterRegisters.cppcore/shader/recompiler/SpirvBackend/src/SpirvEmitter.cppcore/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvModuleSetup.cppcore/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cppcore/shader/recompiler/tests/RequestSerializerTests.cppdocs/dev/ENVIRONMENT.mdIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-27T20:26:29Z.
Review: APPROVED
Reviewed — looks good
The reviewed change is sound at head
27875534624edf6aaa31bd5cfc402001ac271dae; the focused code paths and compatibility updates support merging, though I did not run checks in this review.What I ran
No build or tests were run. I inspected the prepared diff and targeted source ranges at the exact head. The author reports Windows 11 and NVIDIA RTX 3080 Ti testing in the PR description; those runs were not performed by me.
Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
I read the description, commits, manifest, and complete diff, plus targeted ranges from
Dispatch.cpp,VulkanDevice.cpp,SpirvModuleSetup.cpp,SpirvAluEmitterRegisters.cpp,SpirvModuleEmitter.cpp,RequestSerializer.cpp,ShaderDiskCache.cpp,RequestSerializerTests.cpp, andRuntimeSwitches.cpp. The full text was not included forVulkanDevice.cppandShaderMemory.cpp; I read only the relevantVulkanDevice.cpprange. Other included changed files were not read in full. No commands, build, tests, or physical-console behavior were verified.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-29T08:23:43Z.
Review: COMMENTED
Reviewed — no blocking findings
The inspected changes show no verified blocking defect, but two changed files were unavailable in the review folder and the reported checks were not run here.
What I ran
No tests or build commands were run. I inspected the prepared diff and targeted source ranges at head
45b4aa6d9e7e793b19bffa5e3df777c177f16544usingrepo_read.py.Read:
description.md,commits.md,manifest.json, anddiff.patch, plus the changed source context for the staged dispatch path, pipeline readiness, and select-form window setup and access. The diff covered the other changed files. Excluded from full text:core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppandcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp.Results
Findings
Blocking
None identified in the inspected changes.
Non-blocking
None.
Sources
Behavior assessment is based on the prepared diff and source at the pinned head. No commit permalink was available through the review reader.
Not verified
The full text and surrounding callers for the excluded
VulkanDevice.cppandShaderMemory.cppchanges were not inspected. Tests, build, and console behavior were not independently verified; the Windows and GPU results in the description are author-reported.To get this to a good state
Nothing is required. This is a comment rather than an approval because the two excluded files and reported checks leave material review uncertainty.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-30T17:49:20Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this; the points below are optional.
What I ran
Reviewed head
594fe0936a5b6ef0e6e62772deed00aae627982cusing targeted reads fromrepo_read.py. I ran no tests or build commands.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The reported test runs, mutation checks, performance measurements, and GPU behavior were not independently reproduced. All 23 changed files listed in the manifest were reviewed;
VulkanDevice.cppandShaderMemory.cppwere read through the pinned reader because their full text was not included in the review folder. No files were excluded by rule.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-30T17:52:08Z.
Review: COMMENTED
Architecture findings (2)
Advisory architecture findings (2)
599774e1-fd1a-4499-95d0-98e807e0f1a2Reviewing files that changed from the base of the PR and between
45b4aa6d9eand594fe0936a.core/libs/prx/libSceAgcDriver/Execution/include/VulkanDevice.hppcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Dispatch/Dispatch.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Graphics/include/RuntimeSwitches.hppcore/libs/prx/libSceAgcDriver/Graphics/src/RuntimeSwitches.cppcore/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cppdocs/dev/ENVIRONMENT.mdIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-12-01T08:56:43Z.
Review: COMMENTED
🏛️ Architecture findings (3)
Advisory architecture findings (3)
595b8f34-1d73-4ad0-bc13-9441c949d621Reviewing files that changed from the base of the PR and between
594fe0936aand0407cee416.core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T19:04:05Z.
Review: COMMENTED
StartStagedBuildkeeps each pipeline identity in its staticstartedmap for the lifetime of the process. The weak key lets Vulkan destroy the device, but neither the key's control block nor its set of pipeline identities is reclaimed when the device expires. A session that replaces devices or opens and closes several titles therefore accumulates staged identities from every past device. Could the in-flight and failure state belong to the device's existing compute-pipeline bookkeeping so it shares the device's lifetime?This finding is from source inspection at
0407cee416.AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-12-03T22:07:21Z.
Review: COMMENTED
Actionable comments
48ca08ea-0713-4699-9575-3f4cbf5b5e9eReviewing files that changed from the base of the PR and between
0407cee416and7c2f308304.core/libs/prx/libSceAgcDriver/Execution/include/VulkanDevice.hppcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Dispatch/Dispatch.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/tests/execution/WindowSelects.cppcore/shader/recompiler/CacheKey.hppcore/shader/recompiler/ShaderDiskCache.hppcore/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvModuleSetup.cppdocs/dev/ENVIRONMENT.mdIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T22:13:22Z.
Review: COMMENTED
I reviewed the updated head
7c2f308304and trial-merged it cleanly ontoa1b75b0947. Moving staged-pipeline tracking to the device and adding the lifetime assertion addresses the scope covered by the new fixture.On the prior head
0407cee416, all three shared controls passed on main and the change with the validation layer loaded and no VUIDs. The branch-only forms case passed and the dispatch case failed when switching off without a register window: word 8 was0x00080008, expected0x00000008. Those results apply to the prior head. The new head still needs the dispatch and forms run.I compiled the updated request serializer and verified that it reads its own version 65 capture. It rejected a version 65 mesh capture produced by #23818 as truncated. Please reconcile the version assignment so saved window-select and mesh requests have distinct layouts.
AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-04T01:34:13Z.
Review: APPROVED
Reviewed — looks good
The change at head
9b1bceeb8712e3eec64fca952128b0e0308f9261is sound on the reviewed paths, with no verified blocking findings.What I ran
repo_read.pyat the pinned head to read changed hunks and relevant source context.Results
Findings
Blocking
None.
Non-blocking
None.
Sources
Not verified
Builds, tests, and hardware behavior were not independently run. The two files omitted from the prepared full-text bundle (
VulkanDevice.cppandShaderMemory.cpp) were read at their changed ranges through the pinned reader.files.jsonlists no excluded paths.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-04T12:12:57Z.
Review: APPROVED
Reviewed — looks good
The bounded register-window form preserves the existing array behavior outside its supported cases, and dispatches use the array variant until the alternate pipeline is ready.
What I ran
Reviewed head
424db56f0e510b720da9ff5196e6a127a30bd392against basemain; no merged-preview check was run. I usedrepo_read.pyto inspect the prepared diff and targeted source ranges. No test, build, or other execution commands were run.Results
Negative control
Not run by me. The author reports that five mutations made the focused tests fail; this was not independently verified.
Findings
Blocking
None.
Non-blocking
None.
Sources
Not verified
No tests, builds, hardware behavior, or performance measurements were run. The author-reported Windows/GPU test and performance results remain unverified. All changed files were reviewed; 22 were available in the review folder, and the changed ranges of the two oversized files (
VulkanDevice.cppandShaderMemory.cpp) were read throughrepo_read.py.files.jsonlisted no rule-based exclusions.To get this to a good state
No follow-up is required.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.