Repository navigation
fix(shader): bound SPIR-V scalar replacement - #4288
Conversation
|
Tested the patch at Applying only the new regression test to main gives: After applying the production change, I am investigating Demon's Souls on an i7-13700K / RX 6900 XT, RADV Mesa 26.2.4. Main previously approached exhaustion of 31 GiB RAM and 8 GiB swap during startup, but I have not yet established a title-level memory improvement or main-menu success from this patch. Separate descriptor-table failures are currently being investigated before another game launch. Testing performed with AI assistance. |
|
Linux follow-up for the tested head This was a combined integration stack: public-main snapshot The earlier failing-main/passing-fix scalar-replacement regression remains the isolated evidence for this PR. The title result below is a combined-stack result. Reproduction detail: the title run temporarily raised Linux |
|
Retest on Linux using updated #4456 head The title support stack remains #757/#758/#4288/#3991/#4402 plus the local grouped split-load correction. Five integration shader/graphics checks pass. Demon's Souls PPSA01342 rendered language/display settings and the online/offline prompt, then aborted with exit 134: This run did not verify main menu. The earlier c36-based integration did reach it. I have not isolated which rebased-stack change causes the descriptor failure, so this is not a regression attribution to this PR. No memory guard/OOM event stopped the run. One brief debugger snapshot was taken during startup, then detached. The temporary Linux udmabuf limit was again 2048 MiB for the title run and is now verified back at 64. Assets were read directly through an enforced read-only view of the Windows gaming drive, without copying the game. Original input hashes and timestamps are unchanged. AI-assisted testing/report. |
|
Is there a measurement that scalar replacement is what grows memory in #4166? Mouhand-Kaddo's runs show the new test failing on main, but no title memory with and without the limit, so |
…time CPU (#482) * perf(shader): rewrite high-fan-out IR uses in linear time Ported from upstream PR boykopovar#4035 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * perf(shader): index specialization tables by SPIR-V id Ported from upstream PR boykopovar#4772 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(shader): honor disabled optimization during specialization Ported from upstream PR boykopovar#4827 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * perf(shader): discard helper functions unreachable after specialization Ported from upstream PR boykopovar#5064 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(shader): drop module constants nothing references after specialization Ported from upstream PR boykopovar#5315 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(shader): cap SPIR-V scalar replacement Ported from upstream PR boykopovar#4288 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * perf(recompiler): iterate structurizer fixpoints in post-order and bound shared merge splitting growth Includes the stacked upstream commit that structurizes refused control flow with reach flags, which this change builds on. Ported from upstream PR boykopovar#5028 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * perf(shader): emit image_bvh_intersect_ray as one shared function per variant Ported from upstream PR boykopovar#5455 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * perf(shader): avoid redundancy traversal map copies Patches the bundled SPIRV-Tools redundancy elimination (only built with ANYPS5_ENABLE_SPIRV_TOOLS=ON). Ported from upstream PR boykopovar#5511 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(metal): accept a specialized BDA module that dropped one of its two BDA descriptors Specialization removes descriptor variables the final module no longer references. With helper functions now discarded after specialization, a compute module can drop its page-table variable while keeping the fault buffer, and the bridge then rejected the dispatch ("BDA ABI requires page-table and fault-buffer descriptor metadata"). Require at least one of the two roles instead of both; the module's own descriptors are still checked against the prepared plan. Not a port; needed by the port of upstream PR boykopovar#5064. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # core/libs/prx/libSceAgcDriver/tests/SpirvOptimizer.cpp
|
The 10-13 questions are still open: is there a measurement that scalar replacement is what grows memory in #4166 (the issue's memory table with and without the limit), or else please drop the |
9ca7532 to
6a880ab
Compare
|
Pushed an updated revision at Addressed the review points:
Validation on Ubuntu 24.04 under WSL2 with bundled SPIRV-Tools enabled:
No RTX 3080 or Demon’s Souls run was performed, and no title-level memory improvement is claimed. |
|
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
|
|
Thanks for flagging this. This is an insertion-point overlap in
The two PRs are independent, so |
|
That answers 10-13 and 10-14: |
What
CreateScalarReplacementPass(0)treats zero as unlimited. The default AnyPS5 SPIR-V pipeline registered that pass twice, allowing large function-scope arrays and nested composites to expand into an unbounded number of replacement variables while shaders were being optimized. This can cause excessive temporary IR growth during shader compilation.This changes both AnyPS5 registrations to a shared
ScalarReplacementLimitof 64. Smaller composites keep the existing scalar-replacement optimization; larger composites remain aggregate values instead of being expanded without a bound.64is a conservative power-of-two ceiling that preserves useful optimization for small composites while placing a predictable upper bound on per-composite expansion. It is an engineering guardrail, not a title-specific tuning result.The optimizer test now covers a valid 1,000-element function array passed through branching and a memory barrier. It validates the optimized result and bounds the resulting module size, so removing the limit regresses the test without requiring a GPU or a title dump.
This PR does not claim that scalar replacement is the root cause of #4166: no isolated title-level memory A/B measurement is available here. Accordingly, #4166 remains open.
Tested
Ubuntu 24.04 under WSL2, Release build, bundled SPIRV-Tools enabled:
cmake -S . -B build-wsl-4288 -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON -DANYPS5_ENABLE_SPIRV_TOOLS=ON.agc_spirv_optimizer_tests.ctest --test-dir build-wsl-4288 -R '^agc_spirv_optimizer$' --output-on-failure: passed (1/1).agc_spirv_optimizer_testswith the default optimizer,APS5_SPIRV_OPT=none, andAPS5_SPIRV_OPT=full: all passed.python tools/check_conventions.py --base d92a8dad390af1807cc91622b924252141816a5a --head HEAD --title 'fix(shader): bound SPIR-V scalar replacement': run against the updated PR body.git diff --check d92a8dad390af1807cc91622b924252141816a5a..HEAD: passed.No RTX 3080 or Demon’s Souls run was available here. The regression is exercised at the CPU-side optimizer boundary; no title-level memory improvement is claimed.
Checklist
main; no other open PR implements the scalar-replacement limitNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt (n/a).mdfiles or images added to the repository (attach them to this PR)