perf(shader): prepare table-image packed 32-bit unsigned modes at use #24523
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/24523"
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 Pipodi on 2026-11-20T18:46:41Z.
What
Image-table images (a T# fetched through a descriptor table) listed the 10_11_11 and 2_10_10_10 UInt and UNorm image modes (formats 37, 41, 44, 48) in every shader from the start, which adds the SPIR-V of those conversion modes to every table-image shader. The preparation now lists them only after a captured table column held one of those formats, read from the converted GCN words, and prepares the program again with them. The retry counter and the new per-image flag are part of the shader cache key and the disk-cache image record. Direct images and the older packed modes stay eager.
APS5_EAGER_UNSIGNED_PACKED32_MODESrestores the eager lists on every table image.Commits:
perf(shader)(change),test(shader)(nested column trigger, cache key, GCN table entries of the packed formats, retry for table images, run with and without the eager switch),docs(shader)(ENVIRONMENT.md row and debt fragment),test(agc)(_putenv_son Windows inUploadCacheReadOnlyFlush.cpp, main's test does not build on MinGW without it). After the second main merge:fix(shader)(theShaderDiskCache.cppImageResourcefield count, 53).Debt entries added in the fragment
docs/dev/debt/changes/perf-table-packed32-modes-at-use.md(shader.md, Functional, four entries):Both sides compile about 50-100 churned or first-seen compute shaders per warm run on background prepare threads (main's own behaviour; those prepares start before the capture window).
Tested
Windows 11, Ghost of Yōtei (PPSA26344), RTX 4090, NVIDIA 617.42, 3840x2160, i9-13900K. Main
7eb79b0c48fand then main0c2fee0b6fare merged into the branch (no rewrite of the pushed commits). The first merge kept both sides of two conflicts: main'sImageTableColumnSnapshot::pointerKeyednext to this PR'sunsignedPacked32, and main'sverifySpannedShuffleThroughMemorynext to this PR's packed32 tests intests/ShaderMemory.cpp. The second merge (9278f24312) kept both sides of the Windows test list intests/cmake/agc_shader_memory_tests.cmake; main'sImageResource::overwriteand this PR'sunsignedPacked32Modeshad each moved theShaderDiskCache.cppfield count to 52, so440da2025bsets it to 53. Build, ctest and the validation layer below are440da2025bagainst plain main0c2fee0b6f(the validation layer on main:7eb79b0c48f). The performance captures were taken earlier: A is plain mainabc3e4a6920, B is the branch atd659b60f2d3, the same four commits on that base, so the A/B pair is on the PR's own former base; every measurement below used mainabc3e4a6920, none was repeated on7eb79b0c48for0c2fee0b6f.git diff abc3e4a6920 d659b60f2d3 --statis the 19 files, 455 insertions, 7 deletions of this PR.Build and ctest (
440da2025b, MinGW Release): BUILD OK, 6878 tests, 2 failed:agc_driver_linear_target_import_creationandagc_driver_store_over_untracked. Both also fail on plain main0c2fee0b6frebuilt on the same machine. The two new tests (agc_shader_unsigned_packed32_modes,agc_shader_unsigned_packed32_modes_eager) pass. Before the second merge,6254c642f6bhad 6717 tests with 1 failed, and plain main7eb79b0c48f6715 with the same 1 failed (agc_storage_write_back_host_retile).Validation layer (
440da2025band6254c642f6b, plain main7eb79b0c48f), same machine,ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer,ctest -R <the 98 image and shader tests that touch tables or packed modes> -V:Insert instance layer "VK_LAYER_KHRONOS_validation" (C:\VulkanSDK\1.4.363.0\Bin\VkLayer_khronos_validation.dll)37 times in each log (including440da2025b), nowas not found but was requested by env var VK_INSTANCE_LAYERS. main: 96 of 96 passed (the same list without the tests main does not have), PR: 98 of 98 passed on both commits, includingagc_shader_unsigned_packed32_modesandagc_shader_unsigned_packed32_modes_eager.VUID-count 0 in both. The same run onabc3e4a6920,0a025bd3c6aandc8f72e905cc(each with this PR and plain) gave the same result.Performance, second warm set A1r/B1r/A2r on main
abc3e4a6920(2026-11-20 01:00, idle machine). Same builds, caches (m1119a,o2n1119, not refilled), scene, settings and window as the first set below; order A1r, B1r, A2r. No capture in this set has the longmemory_waitstall of the first set (longest frame 8.1-8.3 s in all three).abc3e4a692abc3e4a692In this set B1r is below both A runs on window length (32.6 s against 37.5 and 39.0 s, -13 % and -16 %), p90 and
shader_compile_and_link(1629 ms against 1879 and 3003 ms, -13 % and -46 %).Shader.PrepareArtifactinside the window still differs between runs (B1r lies between A1r and A2r), so part of the window gap can come from which programs are prepared in it. A2 is the slowest A run in both sets.Performance, first warm set A1/B1/A2 on main
abc3e4a6920(2026-11-19, idle machine). A = plain main buildabc3e4a6920(cachem1119a), B = this branchd659b60f2d3(cacheo2n1119), same title, scene, machine and settings,APS5_TRACE_FRAMES=250:60,APS5_PROFILE_DRAW=1, no other trace switches, window f250:60. The caches were filled by one cold run of each build to f330 before the captures; order A1, B1, A2.abc3e4a692abc3e4a692The window is one long frame (A1 49.8 s, B1 65.5 s, A2 8.2 s, a
Driver.Packet.memory_waiton queue worker 0x0 in every capture), so window length and p90 are dominated by that stall and do not separate A from B: B1 is slower than both A1 and A2 on window length and p90. OnDriver.Draw.shader_compile_and_link, the metric this PR targets, B1 (2786 ms) is 36 % above A1 (2046 ms) and 9 % below A2 (3050 ms), so one A run is better and one worse than B; these three captures do not show the PR reducing shader compile time or frame time, and I do not claim a runtime gain from them. The PR removes SPIR-V from table-image shaders (see the debt and the new tests); the captured window does not show it. B1 also contains a 57 sVulkan.ComputePipelinetotal (958 ms per present) that A1 and A2 do not have, and A1 and A2 carryShader.PrepareArtifacttotals of 42 s and 118 s that B1 does not (15 ms): which large compute programs are prepared inside the window differs between runs, and I have not isolated that from the effect of this change.tools/trace_digest.pyphase totals divided by the 60 presents of the window (sums over all threads, so they can exceed the frame time):Queue worker 0x0 (the hottest thread) is 97.1 / 97.8 / 92.0 % busy in A1 / B1 / A2; Earlier set on
d426f6a6d5(A3-A5 main, B3-B4 branch, 2026-11-18, different base):shader_compile_and_link1946-1989 ms on main, 1686-1703 ms on the branch, windows 39.6-42.3 s against 37.0-38.6 s; one more branch capture (B2) ran 15.1 s and is not explained. The 11-18 set and the 11-20 set point the same way as the hypothesis; the 11-19 first set, where A1 and B1 each carry one 50-65 s stall, does not separate A from B. A runtime reduction inshader_compile_and_linkor window time is a hypothesis, not a result: the 11-19 set is dominated by the stalls, the 11-20 set has one branch capture between two main captures with different in-windowShader.PrepareArtifacttotals, and no set isolates shader preparation and compilation. What the PR shows is the smaller SPIR-V of table-image shaders (new tests, and the cold word counts below). No compile-time number is claimed for this PR, so there are no raw compile timings or module SHA-256 lists; the SPIR-V word counts in the cold paragraph below are the only offline measurement, and they come from the branch alone.Summary lines (A1, B1, A2)
Summary lines, 2026-11-20 set (A1r, B1r, A2r)
The six traces are available on request.
Cold, not part of the claim: two cold runs of this branch with the switch unset and set (
APS5_EAGER_UNSIGNED_PACKED32_MODES), both stopped at the 3000 s cap before f850. The first large compute program in the unset run has 1.238M SPIR-V words and takes 112 s to prepare, with the switch set 1.581M words and 142 s (-22 % words, -30 s). Frame times were equal up to f640. These two runs differ only by the switch on one binary; main was measured only in the warm runs above.Checklist
main(0c2fee0b6fmerged in); no other open PR implements the same functions (tools/pr_overlap.py --branch HEADfails closed: it could not confirm overlap with the open PRs that touch the same files, mostlytests/ShaderMemory.cpp,CacheKey.hpp,Recompiler.hppanddocs/dev/ENVIRONMENT.md;gh search prsfor packed32, 10_11_11, unsigned packed and table image modes finds none that prepares table-image packed 32-bit unsigned modes at use)NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file (none added).mdfiles or images added to the repository (attach them to this PR)Depends on: none
AI-assisted: yes
🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T19:10:52Z.
Review: COMMENTED
Reviewed — comments
The change has no verified blocking defect, but the supplied performance evidence does not establish the stated likely runtime reduction, and one oversized changed test file was not fully reviewed.
What I ran
1f13675bc0faaabf73b6558732e55be19646fe76using the prepared diff andrepo_read.py.Results
Negative control
Not run; no independent test execution was available.
Findings
Blocking
None.
Non-blocking
docs/dev/debt/changes/perf-table-packed32-modes-at-use.md:8.Sources
Not verified
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppwas too large for the review folder; its added test diff was inspected, but the full head file was not read.To get this to a good state
Nothing is required. Optionally, provide matched captures that isolate the shader preparation and compilation effect before describing a runtime reduction.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T12:45:46Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the review supports merging, and the author-reported checks include the new packed mode tests.
What I ran
Reviewed head
6254c642f6b44ddf494c4fefa8935f6d5c3aa122against the prepared diff. I did not run commands or tests.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
Build, ctest, Vulkan validation and runtime performance were not independently verified. The description reports a successful build and 6,717 tests with one failure also present on main; the two new tests pass. It also reports 98/98 targeted validation tests passing with zero VUIDs. The performance captures do not establish a runtime improvement, as the description notes.
Read:
description.md,commits.md,manifest.json,diff.patch; changed source files listed below. Excluded:files.jsonwas unavailable through the review reader. No changed files were excluded by the manifest.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-25T04:29:29Z.
Review: COMMENTED
Reviewed — no blocking findings
The inspected implementation has no verified blocking defect, but the review is incomplete because not every changed file was read.
What I ran
Reviewed head
440da2025b8307ef077a37e9be9fb617df99d265usingrepo_read.pyto inspect the prepared description, commits, manifest, diff, changed-file listing, and selected source ranges. No build or tests were run.Results
Findings
Blocking
None in the code inspected.
Non-blocking
None.
Sources
Inspected changed code in
ResourceMaterializer.cpp,Recompiler.cpp,CacheKey.hpp, andRecompiler.hpp, along with relevant portions ofShaderMemory.cpp. The implementation records packed formats while materializing table columns, retries compilation when a supported table image needs those modes, and includes the retry state in cache keys.Not verified
The full text of
ShaderMemory.cppwas excluded from the review folder because it was too large; only targeted ranges were read throughrepo_read.py. Other changed files listed in the manifest were not read. No build, tests, or runtime behavior was independently verified. The author's description reports build, test, validation-layer, and performance results; those were not run here.To get this to a good state
Nothing is required. Optional: complete review of the remaining changed files and run the relevant checks before treating this as a complete review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-25T19:53:50Z.
Review: APPROVED
Reviewed — looks good
The reviewed change consistently defers packed 32-bit unsigned table-image modes until a captured table column contains one of the supported formats, and the author-reported tests pass on the stated revision; I found no verified blocking defect.
What I ran
Reviewed head
211ece964079578e27977e2622212d85573c74d6. I read the prepared description, commits, manifest, and patch, then usedrepo_read.pyto inspect changed code and relevant callers at the pinned head. No commands or tests were run by me.Files read:
core/libs/prx/libSceAgcDriver/Execution/include/Driver/Shaders/ShaderRegistry.hpp,core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp,core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp,core/libs/prx/libSceAgcDriver/tests/cmake/agc_shader_memory_tests.cmake,core/libs/prx/libSceAgcDriver/tests/execution/ImageTable.cpp,core/shader/recompiler/CMakeLists.txt,core/shader/recompiler/CacheKey.hpp,core/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/ResourcePlan.hpp,core/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/Resources.hpp,core/shader/recompiler/Optimization/include/Optimization/ResourceMaterializer.hpp,core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp,core/shader/recompiler/RdnaDecoder/include/RdnaDecoder/RdnaDescriptorFormat.hpp,core/shader/recompiler/RdnaDecoder/src/RdnaDescriptorFormat.cpp,core/shader/recompiler/Recompiler.cpp,core/shader/recompiler/Recompiler.hpp,core/shader/recompiler/ShaderDiskCache.cpp,docs/dev/ENVIRONMENT.md, anddocs/dev/debt/changes/perf-table-packed32-modes-at-use.md. All 19 changed files listed in the manifest as reviewed were read.files.jsonand the ruling file were not read; the manifest lists one changed file excluded by size, but its changed lines were read throughrepo_read.py.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
I did not independently reproduce the reported MinGW build, ctest, validation-layer runs, or performance captures. The description reports the two added tests passing and two pre-existing ctest failures also present on main. Runtime performance remains unverified by the supplied captures, which the author describes as inconclusive.
To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-26T10:27:41Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this; the points below are optional.
What I ran
Reviewed the prepared diff and changed code at head
153f91d1261621382d55d67c701ac5b34191bf36usingrepo_read.py. I ran no shell commands or tests. The description reports build, ctest, and validation-layer results from earlier commits; those results are author-reported, not verified here.Results
Findings
Blocking
None.
Non-blocking
None.
Sources
Not verified
No build, tests, or validation-layer checks were run in this review. The change description reports those checks on commit
440da2025b, not the reviewed head. The review folder omitted the full text ofShaderMemory.cppdue to size; I read its added range throughrepo_read.py. Other unchanged portions of changed files were not read.To get this to a good state
Nothing is required. Optional: confirm the targeted checks on the reviewed head before relying on the reported results.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T21:43:19Z.
Review: COMMENTED
The nested-column and memoized-column cases are useful here because the packed-mode trigger has to survive sealing and reuse. I traced the retry through the full shader key and the separate disk-cache representation. Please keep the eager control in the same correctness run as the default path so a cache-key regression is visible in both modes. The paired table tests and new packed-mode cases are queued on lavapipe. I did not repeat the title timing.
AI-assisted: yes.
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.