perf(shader): keep only evaluable branch conditions in resource plans #5181

Merged
ThatsLeo merged 3 commits from upstream-pr/5181 into main 2026-10-14 21:56:58 +00:00
ThatsLeo commented 2026-10-13 14:06:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ThatsLeo on 2026-10-13T14:06:46Z.


What

A cached shader keeps its IrResourcePlan for as long as it is registered. ExtractPlan copied into it every control-flow condition with all the values it depends on. In Stray (PPSA02101) those conditions are fed by the masked-lane code: over the 43 shaders it prepares before its first frame, the plans held 1,103,298 values. The branch conditions reach 1,101,770 of them; the descriptor sources and SRT reads reach 8,568. In the game, heaptrack put 3.2 GB of the driver's 8.6 GB heap peak in ownPlanValues.

The walk evaluates a condition with Evaluator, which refuses any vector register and any opcode it does not evaluate, and a refused condition takes both successors. Such a condition behaves the same whatever the runtime holds, so the plan does not need it:

  • Detail::Evaluator::MayEvaluate decides statically whether Evaluate can succeed for some runtime. It follows the evaluator's own rules: immediates, user data, the shader base and raw reads are leaves; the opcodes EvaluateInst evaluates from their arguments need all the arguments it reads; a phi is its invariant operand (ResolveInvariantPhi, structural only); an extract follows EvaluateExtract: its source for CompositeExtractU64, the selected component of a CompositeConstructU32x2 or both operands of an IAddCarry32 for CompositeExtractU32x2; a first-lane read and an SRT read count as evaluable without looking further.
  • ExtractPlan stores a condition MayEvaluate rejects as no condition, before copying values, so its operands are not copied.
  • The copied values live in one IrValueArena sized up front, with their operands set by IrValue::SetDetachedOperands, which keeps no use lists: the walk only follows arguments.
  • IrProgram::ReclaimUnusedValues (#4271) walks the arena's values the way it walked the vector of them.
  • ShaderDiskCache::EncodePlan and DecodePlan (#4883) walk the arena; a decoded plan's values are created in one arena and get detached operands, as ownPlanValues does. The check for an empty value slot is gone, since an arena has none.
  • Side effect: ComputePureFlatSlots and ComputeGuardedFlatSlots run after the conditions are dropped, so an SRT slot only a dropped condition read becomes pure, and a capture that differs only in that slot is reused. The walk never depended on such a slot, since the condition could not be evaluated whatever it held.
  • docs/dev/ARCHITECTURE.md gets a section on resource plans.

Tested

Fedora 44, GCC 16.2.1, Release, Intel Arc (Meteor Lake, Mesa 26.2.3 ANV), rebased onto main dd717442 (traces and Stray memory on 5b083445).

  • agc_shader_replay over Stray's 43 requests: the plans' share of the heap peak goes from 92.5 MB on main (73.1 MB with the arena alone) to 0.69 MB, and the plan values from 1,103,298 to 9,110 (counted on c13dc7e6). All 43 still compile. With the filter switched off by a local patch in the same binary, every request gives the same hash over its bindings (role, set, binding, count, guest descriptor words, written and depth-compare flags), push constants, SPIR-V words and poisoned SRT read count.
  • Stray on the same main, nothing else on top, 235 s on the brightness calibration screen: main holds 6.8 GB resident plus 5.6 GB swapped out with 1.4 GB of the 15 GB left available; this branch holds 4.4 GB plus 4.8 GB with 3.9 GB available.
  • Frame time does not change: traces of 30 s from 120 s on that screen, caches warm, log to /dev/null, give p50 794.8 ms (39 presents) on main and 739.2 ms (40 presents) on this branch. Traces and summary file: evidence/compact-resource-plans.
    {"commit":"5b083445852c","dirty":false,"env":{"APS5_LOCAL_SKIP_BARY":"1","APS5_TRACE_SECONDS":"120:30"},"gpu":"Intel(R) Arc(tm) Graphics (MTL)","driver":"Intel open-source Mesa driver Mesa 26.2.3","os":"Linux 7.2.8-200.fc44.x86_64","resolution":"3840x2160","window":{"spec":"seconds 120:30","first_present":109,"ms":30697.164},"presents":39,"frame_ms":{"p50":794.795,"p90":887.881,"p99":937.578,"max":937.578},"gpu_busy_ms_per_present":714.285,"worker_busy_pct":{"queue worker 0x0":99.932,"queue worker 0x20":99.097},"top_phases_ms_per_frame":{"Driver.Packet":1546.330,"Driver.Packet.draw":602.467,"Driver.Draw":602.402,"Driver.Draw.draw_and_resource_release":597.984,"Graphics.Draw":597.940,"Graphics.Draw.draw_and_resource_release":597.403,"Driver.Packet.dispatch":552.722,"Driver.Present":484.997},"trace_dropped":false,"trace":"aps5-trace-5b083445852c-1210248.json.gz"}
    {"commit":"fc138b9c8750","dirty":false,"env":{"APS5_LOCAL_SKIP_BARY":"1","APS5_TRACE_SECONDS":"120:30"},"gpu":"Intel(R) Arc(tm) Graphics (MTL)","driver":"Intel open-source Mesa driver Mesa 26.2.3","os":"Linux 7.2.8-200.fc44.x86_64","resolution":"3840x2160","window":{"spec":"seconds 120:30","first_present":115,"ms":30211.457},"presents":40,"frame_ms":{"p50":739.172,"p90":899.548,"p99":1407.513,"max":1407.513},"gpu_busy_ms_per_present":674.425,"worker_busy_pct":{"queue worker 0x0":99.954,"queue worker 0x20":99.093},"top_phases_ms_per_frame":{"Driver.Packet":1482.757,"Driver.Packet.draw":551.011,"Driver.Draw":550.947,"Driver.Draw.draw_and_resource_release":545.905,"Graphics.Draw":545.852,"Graphics.Draw.draw_and_resource_release":544.639,"Driver.Packet.dispatch":499.391,"Driver.Present":432.852},"trace_dropped":false,"trace":"aps5-trace-fc138b9c8750-1211809.json.gz"}
    
  • agc_shader_memory gains verifyMayEvaluate: constants, user data, comparisons of them and the low word of a carry add of user data are evaluable; a scalar loop counter's latch condition, a vector register read, a comparison or select arm on one, an opcode the evaluator does not evaluate and a phi whose operands differ are not; each verdict must match what Evaluator::Evaluate does. It also builds every IR opcode over constant arguments, except the ones MayEvaluate takes as evaluable without looking further, and requires the same answer from both, so an opcode taught to one and not the other fails the test (checked by dropping IAdd32 from MayEvaluate).
  • Full ctest on Intel Arc and lavapipe, rebased onto main dd717442: 1082 of 1083 pass on both, agc_ir_reclaim and agc_shader_disk_cache (plan round trips) included. The A/B hash comparison over the 43 requests was repeated on this head and is still identical. guest_ampr_cpp_error does not link with Fedora's toolchain (read-only segment has dynamic relocations), on main as well.

Overlap: #4883 serializes the plan graph into the disk cache and builds valueStorage the way ownPlanValues did; whichever lands second needs IrValueArena (or the other way round). Smaller plans also mean smaller disk entries there.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Unblocks: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4844474413 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5181). Originally posted by [ThatsLeo](https://github.com/ThatsLeo) on 2026-10-13T14:06:46Z. --- ### What A cached shader keeps its `IrResourcePlan` for as long as it is registered. `ExtractPlan` copied into it every control-flow condition with all the values it depends on. In Stray (PPSA02101) those conditions are fed by the masked-lane code: over the 43 shaders it prepares before its first frame, the plans held 1,103,298 values. The branch conditions reach 1,101,770 of them; the descriptor sources and SRT reads reach 8,568. In the game, `heaptrack` put 3.2 GB of the driver's 8.6 GB heap peak in `ownPlanValues`. The walk evaluates a condition with `Evaluator`, which refuses any vector register and any opcode it does not evaluate, and a refused condition takes both successors. Such a condition behaves the same whatever the runtime holds, so the plan does not need it: - `Detail::Evaluator::MayEvaluate` decides statically whether `Evaluate` can succeed for some runtime. It follows the evaluator's own rules: immediates, user data, the shader base and raw reads are leaves; the opcodes `EvaluateInst` evaluates from their arguments need all the arguments it reads; a phi is its invariant operand (`ResolveInvariantPhi`, structural only); an extract follows `EvaluateExtract`: its source for `CompositeExtractU64`, the selected component of a `CompositeConstructU32x2` or both operands of an `IAddCarry32` for `CompositeExtractU32x2`; a first-lane read and an SRT read count as evaluable without looking further. - `ExtractPlan` stores a condition `MayEvaluate` rejects as no condition, before copying values, so its operands are not copied. - The copied values live in one `IrValueArena` sized up front, with their operands set by `IrValue::SetDetachedOperands`, which keeps no use lists: the walk only follows arguments. - `IrProgram::ReclaimUnusedValues` (#4271) walks the arena's values the way it walked the vector of them. - `ShaderDiskCache::EncodePlan` and `DecodePlan` (#4883) walk the arena; a decoded plan's values are created in one arena and get detached operands, as `ownPlanValues` does. The check for an empty value slot is gone, since an arena has none. - Side effect: `ComputePureFlatSlots` and `ComputeGuardedFlatSlots` run after the conditions are dropped, so an SRT slot only a dropped condition read becomes pure, and a capture that differs only in that slot is reused. The walk never depended on such a slot, since the condition could not be evaluated whatever it held. - `docs/dev/ARCHITECTURE.md` gets a section on resource plans. ### Tested Fedora 44, GCC 16.2.1, Release, Intel Arc (Meteor Lake, Mesa 26.2.3 ANV), rebased onto `main` `dd717442` (traces and Stray memory on `5b083445`). - `agc_shader_replay` over Stray's 43 requests: the plans' share of the heap peak goes from 92.5 MB on `main` (73.1 MB with the arena alone) to 0.69 MB, and the plan values from 1,103,298 to 9,110 (counted on `c13dc7e6`). All 43 still compile. With the filter switched off by a local patch in the same binary, every request gives the same hash over its bindings (role, set, binding, count, guest descriptor words, written and depth-compare flags), push constants, SPIR-V words and poisoned SRT read count. - Stray on the same `main`, nothing else on top, 235 s on the brightness calibration screen: `main` holds 6.8 GB resident plus 5.6 GB swapped out with 1.4 GB of the 15 GB left available; this branch holds 4.4 GB plus 4.8 GB with 3.9 GB available. - Frame time does not change: traces of 30 s from 120 s on that screen, caches warm, log to `/dev/null`, give p50 794.8 ms (39 presents) on `main` and 739.2 ms (40 presents) on this branch. Traces and summary file: [`evidence/compact-resource-plans`](https://github.com/ThatsLeo/AnyPS5/tree/evidence/compact-resource-plans). ```json {"commit":"5b083445852c","dirty":false,"env":{"APS5_LOCAL_SKIP_BARY":"1","APS5_TRACE_SECONDS":"120:30"},"gpu":"Intel(R) Arc(tm) Graphics (MTL)","driver":"Intel open-source Mesa driver Mesa 26.2.3","os":"Linux 7.2.8-200.fc44.x86_64","resolution":"3840x2160","window":{"spec":"seconds 120:30","first_present":109,"ms":30697.164},"presents":39,"frame_ms":{"p50":794.795,"p90":887.881,"p99":937.578,"max":937.578},"gpu_busy_ms_per_present":714.285,"worker_busy_pct":{"queue worker 0x0":99.932,"queue worker 0x20":99.097},"top_phases_ms_per_frame":{"Driver.Packet":1546.330,"Driver.Packet.draw":602.467,"Driver.Draw":602.402,"Driver.Draw.draw_and_resource_release":597.984,"Graphics.Draw":597.940,"Graphics.Draw.draw_and_resource_release":597.403,"Driver.Packet.dispatch":552.722,"Driver.Present":484.997},"trace_dropped":false,"trace":"aps5-trace-5b083445852c-1210248.json.gz"} {"commit":"fc138b9c8750","dirty":false,"env":{"APS5_LOCAL_SKIP_BARY":"1","APS5_TRACE_SECONDS":"120:30"},"gpu":"Intel(R) Arc(tm) Graphics (MTL)","driver":"Intel open-source Mesa driver Mesa 26.2.3","os":"Linux 7.2.8-200.fc44.x86_64","resolution":"3840x2160","window":{"spec":"seconds 120:30","first_present":115,"ms":30211.457},"presents":40,"frame_ms":{"p50":739.172,"p90":899.548,"p99":1407.513,"max":1407.513},"gpu_busy_ms_per_present":674.425,"worker_busy_pct":{"queue worker 0x0":99.954,"queue worker 0x20":99.093},"top_phases_ms_per_frame":{"Driver.Packet":1482.757,"Driver.Packet.draw":551.011,"Driver.Draw":550.947,"Driver.Draw.draw_and_resource_release":545.905,"Graphics.Draw":545.852,"Graphics.Draw.draw_and_resource_release":544.639,"Driver.Packet.dispatch":499.391,"Driver.Present":432.852},"trace_dropped":false,"trace":"aps5-trace-fc138b9c8750-1211809.json.gz"} ``` - `agc_shader_memory` gains `verifyMayEvaluate`: constants, user data, comparisons of them and the low word of a carry add of user data are evaluable; a scalar loop counter's latch condition, a vector register read, a comparison or select arm on one, an opcode the evaluator does not evaluate and a phi whose operands differ are not; each verdict must match what `Evaluator::Evaluate` does. It also builds every IR opcode over constant arguments, except the ones `MayEvaluate` takes as evaluable without looking further, and requires the same answer from both, so an opcode taught to one and not the other fails the test (checked by dropping `IAdd32` from `MayEvaluate`). - Full `ctest` on Intel Arc and lavapipe, rebased onto `main` `dd717442`: 1082 of 1083 pass on both, `agc_ir_reclaim` and `agc_shader_disk_cache` (plan round trips) included. The A/B hash comparison over the 43 requests was repeated on this head and is still identical. `guest_ampr_cpp_error` does not link with Fedora's toolchain (`read-only segment has dynamic relocations`), on `main` as well. Overlap: #4883 serializes the plan graph into the disk cache and builds `valueStorage` the way `ownPlanValues` did; whichever lands second needs `IrValueArena` (or the other way round). Smaller plans also mean smaller disk entries there. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Unblocks: none - [x] AI-assisted: yes
EagleBearerYS commented 2026-10-13 15:13:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-13T15:13:26Z.


A Windows data point and a second title. Setup: Windows 11, MinGW-w64 GCC 15.2.0 (WinLibs r7), Release, RTX 3070 Laptop GPU, 16 GB of RAM.

Build on current main. This PR merges into main b478fbbb1 without conflicts, but it doesn't build there. #4271's reclaim pass (57b2dc858) iterates resourcePlan.valueStorage as the old std::vector<std::unique_ptr<IrValue>> in two places:

  • IrProgram.cpp:225: for (const auto& value : resourcePlan.valueStorage) keep(value.get());
  • tests/IrReclaim.cpp:58 (agc_ir_reclaim_tests): resources.valueStorage.push_back(std::move(external));

To test, I gave IrValueArena a begin()/end() over the created values, and changed the first loop to for (auto& value : resourcePlan.valueStorage) keep(&value);. The test needs its own change, since an arena can't adopt an external value.

Tests. With that, on main b478fbbb1, agc_shader_memory (with verifyMayEvaluate), agc_shader_bindless, agc_shader_srt_read_patching, agc_shader_frontend_pair, agc_shader_frontend_pair_off and agc_shader_disk_cache pass.

Resident Evil Village (PPSA01556). It registers about 6,000 shaders at boot while it creates its PSO cache, behind a black screen, and its plans hit the same wall. This was measured on main b478fbbb1 plus #4949's register change (the title stops at its first frame without it), cold shader cache, each 300 s:

without this PR with it
private memory at about 2,000 shaders 5,970 MB (2,015 shaders, 101 s) 4,062 MB (2,070 shaders, 82 s)
private memory at about 2,950 shaders 11,115 MB (2,966 shaders, 285 s) 5,763 MB (2,955 shaders, 210 s)
growth per shader, from about 1,200 shaders on 4.0 MB 1.6 MB
shaders created in 300 s 3,003 3,318

These are single runs, so the difference in shaders created is within this PC's run-to-run noise. The memory difference is not.

A side effect to mention in the description. ComputePureFlatSlots still runs after the conditions are dropped. An SRT slot that only a dropped condition read becomes pure, so captures that differ only in that slot are reused. That's correct, because the walk never depended on the slot, but it changes capture reuse. I had the same idea locally (dropping never-evaluable conditions before ownPlanValues). On Planet of Lana (PPSA19450) it made no consistent difference to memory 90 s into gameplay: 7,913 and 7,917 MB private in two runs and 8,268 MB in a third, against 7,942-7,997 MB on main in three.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6148775886 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5181#issuecomment-6148775886). Originally posted by [EagleBearerYS](https://github.com/EagleBearerYS) on 2026-10-13T15:13:26Z. --- A Windows data point and a second title. Setup: Windows 11, MinGW-w64 GCC 15.2.0 (WinLibs r7), Release, RTX 3070 Laptop GPU, 16 GB of RAM. **Build on current `main`.** This PR merges into `main` b478fbbb1 without conflicts, but it doesn't build there. #4271's reclaim pass (57b2dc858) iterates `resourcePlan.valueStorage` as the old `std::vector<std::unique_ptr<IrValue>>` in two places: - `IrProgram.cpp:225`: `for (const auto& value : resourcePlan.valueStorage) keep(value.get());` - `tests/IrReclaim.cpp:58` (`agc_ir_reclaim_tests`): `resources.valueStorage.push_back(std::move(external));` To test, I gave `IrValueArena` a `begin()`/`end()` over the created values, and changed the first loop to `for (auto& value : resourcePlan.valueStorage) keep(&value);`. The test needs its own change, since an arena can't adopt an external value. **Tests.** With that, on `main` b478fbbb1, `agc_shader_memory` (with `verifyMayEvaluate`), `agc_shader_bindless`, `agc_shader_srt_read_patching`, `agc_shader_frontend_pair`, `agc_shader_frontend_pair_off` and `agc_shader_disk_cache` pass. **Resident Evil Village (PPSA01556).** It registers about 6,000 shaders at boot while it creates its PSO cache, behind a black screen, and its plans hit the same wall. This was measured on `main` b478fbbb1 plus #4949's register change (the title stops at its first frame without it), cold shader cache, each 300 s: | | without this PR | with it | |---|---|---| | private memory at about 2,000 shaders | 5,970 MB (2,015 shaders, 101 s) | 4,062 MB (2,070 shaders, 82 s) | | private memory at about 2,950 shaders | 11,115 MB (2,966 shaders, 285 s) | 5,763 MB (2,955 shaders, 210 s) | | growth per shader, from about 1,200 shaders on | 4.0 MB | 1.6 MB | | shaders created in 300 s | 3,003 | 3,318 | These are single runs, so the difference in shaders created is within this PC's run-to-run noise. The memory difference is not. **A side effect to mention in the description.** `ComputePureFlatSlots` still runs after the conditions are dropped. An SRT slot that only a dropped condition read becomes pure, so captures that differ only in that slot are reused. That's correct, because the walk never depended on the slot, but it changes capture reuse. I had the same idea locally (dropping never-evaluable conditions before `ownPlanValues`). On Planet of Lana (PPSA19450) it made no consistent difference to memory 90 s into gameplay: 7,913 and 7,917 MB private in two runs and 8,268 MB in a third, against 7,942-7,997 MB on `main` in three.
ThatsLeo commented 2026-10-13 15:25:13 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ThatsLeo on 2026-10-13T15:25:13Z.


@EagleBearerYS thanks for the Resident Evil Village numbers, and for the build break.

Rebased onto main 5a76fd71 (16bd6505):

  • IrValueArena has begin()/end() over the values it created, and ReclaimUnusedValues walks them as you did.
  • agc_ir_reclaim creates its external owner in the plan's arena (Reserve(1), then Create), since an arena can't adopt a value.
  • The description now notes the pure-slot side effect.

Full ctest on Intel Arc and lavapipe: 1060 of 1061 pass, agc_ir_reclaim included. guest_ampr_cpp_error doesn't link with Fedora's toolchain, on main too.

Planet of Lana fits what I saw: the gain depends on how much of a shader's IR its branch conditions reach. That's most of it in Stray and Resident Evil Village, and little in a title whose branches don't depend on lane-masked values.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6149012767 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5181#issuecomment-6149012767). Originally posted by [ThatsLeo](https://github.com/ThatsLeo) on 2026-10-13T15:25:13Z. --- @EagleBearerYS thanks for the Resident Evil Village numbers, and for the build break. Rebased onto `main` `5a76fd71` (`16bd6505`): - `IrValueArena` has `begin()`/`end()` over the values it created, and `ReclaimUnusedValues` walks them as you did. - `agc_ir_reclaim` creates its external owner in the plan's arena (`Reserve(1)`, then `Create`), since an arena can't adopt a value. - The description now notes the pure-slot side effect. Full `ctest` on Intel Arc and lavapipe: 1060 of 1061 pass, `agc_ir_reclaim` included. `guest_ampr_cpp_error` doesn't link with Fedora's toolchain, on `main` too. Planet of Lana fits what I saw: the gain depends on how much of a shader's IR its branch conditions reach. That's most of it in Stray and Resident Evil Village, and little in a title whose branches don't depend on lane-masked values. AI-assisted: yes.
nikowolf123 commented 2026-10-13 17:34:17 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by nikowolf123 on 2026-10-13T17:34:17Z.


A small gap in MayEvaluate, found while checking how this interacts with #4883. It costs some efficiency, but it doesn't affect correctness.

What. evaluableAlone returns true for CompositeExtractU64 and CompositeExtractU32x2 without looking at their source (SrtEvaluator.cpp:253-254 on 16bd6505e), as the description says. But EvaluateExtract (SrtEvaluator.cpp:80) succeeds only if the source evaluates: for CompositeExtractU32x2, that means a CompositeConstructU32x2 or an IAddCarry32 whose operands evaluate. And every s_add_u32 translates to CompositeExtractU32x2(IAddCarry32(a, b), 0) (addU32, ControlFlowInstructions.cpp:131-132). So a scalar loop counter i = phi(start, i + 1) gives the latch condition i + 1 < n, which MayEvaluate accepts even though the phi is not invariant and no runtime can evaluate it. ExtractPlan keeps that condition (ResourceMaterializer.cpp:989) and copies its cone, the walk tries it on every capture that reads specialization memory and fails (SrtDescriptorEvaluation.cpp:99), and ComputePureFlatSlots marks every slot in its cone as impure (SrtFlatSlotClasses.cpp:52).

Repro, on 16bd6505e alone (scratch code in agc_shader_memory, WSL2 Ubuntu 26.04, GCC 15.2, Release):

  • Hand-built IR, in the style of verifyMayEvaluate: counter = Phi(0, next), next = CompositeExtractU32x2(IAddCarry32(counter, 1), 0), condition = ULessThan32(next, 4). MayEvaluate returns 0 for the phi, 1 for the extract and 1 for the condition. Evaluator::Evaluate(condition) fails.
  • A compute shader that takes the loop start from the SRT and stores after the loop: s_load_dword s40, s[0:1], 0x40 / s_load_dwordx4 s[4:7], s[0:1], 0x0 / s_waitcnt / loop: s_add_u32 s40, s40, 1, s_cmp_lt_u32 s40, 4, s_cbranch_scc1 loop / buffer_store_dword v0, off, s[4:7], 0 (words f4000a00 fa000040 f4080100 fa000000 bf8cc07f 80288128 bf0a8428 bf85fffd e0700000 80010000 bf810000). GetResourcePlan keeps the latch condition with a 10-value cone that holds the phi and the slot-4 read. The plan has 45 values and pure flat slots 0 0 0 0 0. Over 1000 random SRT runtimes with readSpecializationMemory set, the condition was evaluated 1000 times and failed every time.
  • With extracts checked through their source (below): the condition is dropped, the plan has 35 values, and the pure flat slots are 0 0 0 0 1. Slot 4, the loop start that only the dropped condition reads, becomes pure, which is the side effect your description promises for dropped conditions. Across the same 1000 runtimes, the snapshots, errors, poison and null-root counts are identical. The only change in the read trace is that slot 4's read is recorded as its leaf instead of among the other reads.

So the consequence is efficiency only. A plan with control flow can keep the latch condition of a scalar loop counter, which can never be evaluated, together with that condition's cone. An SRT slot that feeds only the counter stays impure, so a capture that differs only in that slot is not reused.

Suggested fix. Treat the extracts the way SrtRuntimeValidator already does (SrtRuntimeValidator.cpp:117-126). Remove them from evaluableAlone. CompositeExtractU64 requires its argument 0. CompositeExtractU32x2 requires the operands of a CompositeConstructU32x2 or IAddCarry32 source, and any other source is not evaluable. Then the two opcodes can leave takenAsEvaluable in verifyMayEvaluate (ShaderMemory.cpp:438), so the over-constants sweep covers them too. With that change, agc_shader_memory passes, including the sweep over both extract opcodes.

AI-assisted: written with Claude Code; I checked the code paths and ran what is described above.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6151418784 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5181#issuecomment-6151418784). Originally posted by [nikowolf123](https://github.com/nikowolf123) on 2026-10-13T17:34:17Z. --- A small gap in `MayEvaluate`, found while checking how this interacts with #4883. It costs some efficiency, but it doesn't affect correctness. **What.** `evaluableAlone` returns `true` for `CompositeExtractU64` and `CompositeExtractU32x2` without looking at their source (`SrtEvaluator.cpp:253-254` on 16bd6505e), as the description says. But `EvaluateExtract` (`SrtEvaluator.cpp:80`) succeeds only if the source evaluates: for `CompositeExtractU32x2`, that means a `CompositeConstructU32x2` or an `IAddCarry32` whose operands evaluate. And every `s_add_u32` translates to `CompositeExtractU32x2(IAddCarry32(a, b), 0)` (`addU32`, `ControlFlowInstructions.cpp:131-132`). So a scalar loop counter `i = phi(start, i + 1)` gives the latch condition `i + 1 < n`, which `MayEvaluate` accepts even though the phi is not invariant and no runtime can evaluate it. `ExtractPlan` keeps that condition (`ResourceMaterializer.cpp:989`) and copies its cone, the walk tries it on every capture that reads specialization memory and fails (`SrtDescriptorEvaluation.cpp:99`), and `ComputePureFlatSlots` marks every slot in its cone as impure (`SrtFlatSlotClasses.cpp:52`). **Repro, on 16bd6505e alone** (scratch code in `agc_shader_memory`, WSL2 Ubuntu 26.04, GCC 15.2, Release): - Hand-built IR, in the style of `verifyMayEvaluate`: `counter = Phi(0, next)`, `next = CompositeExtractU32x2(IAddCarry32(counter, 1), 0)`, `condition = ULessThan32(next, 4)`. `MayEvaluate` returns 0 for the phi, 1 for the extract and 1 for the condition. `Evaluator::Evaluate(condition)` fails. - A compute shader that takes the loop start from the SRT and stores after the loop: `s_load_dword s40, s[0:1], 0x40` / `s_load_dwordx4 s[4:7], s[0:1], 0x0` / `s_waitcnt` / loop: `s_add_u32 s40, s40, 1`, `s_cmp_lt_u32 s40, 4`, `s_cbranch_scc1 loop` / `buffer_store_dword v0, off, s[4:7], 0` (words `f4000a00 fa000040 f4080100 fa000000 bf8cc07f 80288128 bf0a8428 bf85fffd e0700000 80010000 bf810000`). `GetResourcePlan` keeps the latch condition with a 10-value cone that holds the phi and the slot-4 read. The plan has 45 values and pure flat slots `0 0 0 0 0`. Over 1000 random SRT runtimes with `readSpecializationMemory` set, the condition was evaluated 1000 times and failed every time. - With extracts checked through their source (below): the condition is dropped, the plan has 35 values, and the pure flat slots are `0 0 0 0 1`. Slot 4, the loop start that only the dropped condition reads, becomes pure, which is the side effect your description promises for dropped conditions. Across the same 1000 runtimes, the snapshots, errors, poison and null-root counts are identical. The only change in the read trace is that slot 4's read is recorded as its leaf instead of among the other reads. So the consequence is efficiency only. A plan with control flow can keep the latch condition of a scalar loop counter, which can never be evaluated, together with that condition's cone. An SRT slot that feeds only the counter stays impure, so a capture that differs only in that slot is not reused. **Suggested fix.** Treat the extracts the way `SrtRuntimeValidator` already does (`SrtRuntimeValidator.cpp:117-126`). Remove them from `evaluableAlone`. `CompositeExtractU64` requires its argument 0. `CompositeExtractU32x2` requires the operands of a `CompositeConstructU32x2` or `IAddCarry32` source, and any other source is not evaluable. Then the two opcodes can leave `takenAsEvaluable` in `verifyMayEvaluate` (`ShaderMemory.cpp:438`), so the over-constants sweep covers them too. With that change, `agc_shader_memory` passes, including the sweep over both extract opcodes. AI-assisted: written with Claude Code; I checked the code paths and ran what is described above.
ThatsLeo commented 2026-10-13 18:17:41 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ThatsLeo on 2026-10-13T18:17:41Z.


@nikowolf123 good catch, thanks for the repro. Taken as you suggested, in 9dd03fa4 on top of a rebase onto main 18c438b1:

  • The extracts left evaluableAlone. Both need an immediate U32 index below 2. CompositeExtractU64 requires its argument 0. CompositeExtractU32x2 requires the selected component of a CompositeConstructU32x2 or both operands of an IAddCarry32, and with any other source it is not evaluable, as in EvaluateExtract.
  • They left takenAsEvaluable, so the sweep over every opcode covers them too. verifyMayEvaluate also gains your loop counter (Phi(0, next), next = CompositeExtractU32x2(IAddCarry32(counter, 1), 0), latch ULessThan32(next, 4)), which must not be evaluable, and the low word of a carry add of user data, which must be. With the old extract rule put back, the test fails on the latch condition.

Full ctest on Intel Arc and lavapipe: 1070 of 1071 pass (guest_ampr_cpp_error doesn't link with Fedora's toolchain, on main too). The A/B hash comparison over Stray's 43 requests is still identical.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6152191118 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5181#issuecomment-6152191118). Originally posted by [ThatsLeo](https://github.com/ThatsLeo) on 2026-10-13T18:17:41Z. --- @nikowolf123 good catch, thanks for the repro. Taken as you suggested, in `9dd03fa4` on top of a rebase onto `main` `18c438b1`: - The extracts left `evaluableAlone`. Both need an immediate U32 index below 2. `CompositeExtractU64` requires its argument 0. `CompositeExtractU32x2` requires the selected component of a `CompositeConstructU32x2` or both operands of an `IAddCarry32`, and with any other source it is not evaluable, as in `EvaluateExtract`. - They left `takenAsEvaluable`, so the sweep over every opcode covers them too. `verifyMayEvaluate` also gains your loop counter (`Phi(0, next)`, `next = CompositeExtractU32x2(IAddCarry32(counter, 1), 0)`, latch `ULessThan32(next, 4)`), which must not be evaluable, and the low word of a carry add of user data, which must be. With the old extract rule put back, the test fails on the latch condition. Full `ctest` on Intel Arc and lavapipe: 1070 of 1071 pass (`guest_ampr_cpp_error` doesn't link with Fedora's toolchain, on `main` too). The A/B hash comparison over Stray's 43 requests is still identical. AI-assisted: yes.
eljackjoestar-cmd commented 2026-10-14 02:57:19 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by eljackjoestar-cmd on 2026-10-14T02:57:19Z.


Additional Windows title measurement for Lost Soul Aside (PPSA26358): this PR reduced memory substantially at the warm title screen.

Process counter (six-sample mean) Baseline With this PR Reduction
Private commit (PrivateMemorySize64) 8.73 GiB 5.10 GiB 3.63 GiB / 41.6%
Resident working set (WorkingSet64) 13.34 GiB 9.83 GiB 3.52 GiB / 26.4%

This compares the same local title integration based on main ee9037d85, with its existing #4715, #4806, #5049, #5198, #5461 and #5472 fixes in both runs. Baseline local head was 61e07e200; adding only this PR's unchanged three commits at dc0ca9d57 produced 325dc40e1. This is an integration A/B, not current main alone versus current main plus this PR. Only libSceAgcDriver.prx was replaced between runs.

Both runs stayed at the title screen. Six samples were taken five seconds apart starting around rendered frame 8963 (baseline first frame 8963; changed first frame 8991). Same machine, resolution and launch settings: Windows 11 Pro 10.0.26300, NVIDIA RTX 5070 driver 617.14; guest display 3840x2160, presented window 1536x864; file-backed SPIR-V enabled, host import budget 8192 MiB, texture cache budget 1024 MiB, shader disk cache disabled, and r.AllowOcclusionQueries=0. No forced working-set trim. Working-set totals include shared aliases and are not unique physical-RAM counts.

Validation: full Windows Release build passed; 19 focused shader/resource/rendering checks passed in 12.40 s on the NVIDIA setup, including shader memory, IR reclamation, disk-cache round trips and prepared-shader paths. Seven focused Vulkan checks also passed in 3.57 s on AMD Radeon integrated gfx1036, driver 32.0.21036.18. Title captures retained the blue crystal terrain and floor; the tester confirmed graphics and audio remained correct. Gameplay memory is not measured, and this report makes no speed claim.

Raw process samples (MiB)
run,frame,private_commit_MiB,resident_working_set_MiB
baseline,8963,8933.24609375,13652.91015625
baseline,9068,8942.890625,13662.33203125
baseline,9180,8939.8984375,13661.8046875
baseline,9293,8943.21484375,13662.88671875
baseline,9409,8950.23828125,13670.01171875
baseline,9513,8952.66796875,13672.32421875
optimized,8991,5223.26171875,10059.1796875
optimized,9116,5225.88671875,10059.80078125
optimized,9245,5227.203125,10061.08203125
optimized,9365,5227.76953125,10061.74609375
optimized,9490,5228.45703125,10062.3203125
optimized,9618,5231.08203125,10062.94921875
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6159864822 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5181#issuecomment-6159864822). Originally posted by [eljackjoestar-cmd](https://github.com/eljackjoestar-cmd) on 2026-10-14T02:57:19Z. --- Additional Windows title measurement for **Lost Soul Aside (PPSA26358)**: this PR reduced memory substantially at the warm title screen. | Process counter (six-sample mean) | Baseline | With this PR | Reduction | |---|---:|---:|---:| | Private commit (`PrivateMemorySize64`) | 8.73 GiB | 5.10 GiB | **3.63 GiB / 41.6%** | | Resident working set (`WorkingSet64`) | 13.34 GiB | 9.83 GiB | **3.52 GiB / 26.4%** | This compares the same local title integration based on main `ee9037d85`, with its existing #4715, #4806, #5049, #5198, #5461 and #5472 fixes in both runs. Baseline local head was `61e07e200`; adding only this PR's unchanged three commits at `dc0ca9d57` produced `325dc40e1`. **This is an integration A/B, not current main alone versus current main plus this PR.** Only `libSceAgcDriver.prx` was replaced between runs. Both runs stayed at the title screen. Six samples were taken five seconds apart starting around rendered frame 8963 (baseline first frame 8963; changed first frame 8991). Same machine, resolution and launch settings: Windows 11 Pro 10.0.26300, NVIDIA RTX 5070 driver 617.14; guest display 3840x2160, presented window 1536x864; file-backed SPIR-V enabled, host import budget 8192 MiB, texture cache budget 1024 MiB, shader disk cache disabled, and `r.AllowOcclusionQueries=0`. No forced working-set trim. Working-set totals include shared aliases and are not unique physical-RAM counts. Validation: full Windows Release build passed; 19 focused shader/resource/rendering checks passed in 12.40 s on the NVIDIA setup, including shader memory, IR reclamation, disk-cache round trips and prepared-shader paths. Seven focused Vulkan checks also passed in 3.57 s on AMD Radeon integrated gfx1036, driver 32.0.21036.18. Title captures retained the blue crystal terrain and floor; the tester confirmed graphics and audio remained correct. Gameplay memory is not measured, and this report makes no speed claim. <details> <summary>Raw process samples (MiB)</summary> ```csv run,frame,private_commit_MiB,resident_working_set_MiB baseline,8963,8933.24609375,13652.91015625 baseline,9068,8942.890625,13662.33203125 baseline,9180,8939.8984375,13661.8046875 baseline,9293,8943.21484375,13662.88671875 baseline,9409,8950.23828125,13670.01171875 baseline,9513,8952.66796875,13672.32421875 optimized,8991,5223.26171875,10059.1796875 optimized,9116,5225.88671875,10059.80078125 optimized,9245,5227.203125,10061.08203125 optimized,9365,5227.76953125,10061.74609375 optimized,9490,5228.45703125,10062.3203125 optimized,9618,5231.08203125,10062.94921875 ``` </details>
fisherjoey commented 2026-10-14 03:16:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fisherjoey on 2026-10-14T03:16:56Z.


A Linux NVIDIA data point from Demon's Souls (PPSA01341 v1.07), where main now runs out of memory before the level loads.

Setup: Linux, RTX 5070 Ti, NVIDIA 595.91, GCC Release, ANYPS5_ENABLE_SPIRV_TOOLS=OFF. Base main 7a0c838ca, with this PR's ceda63b9c and b130903c8 applied (dc0ca9d57 isn't needed on that base, since #4883 isn't in it yet). Same 150 s run from boot to the title each time:

build anon + swap at t+150
main 7a0c838ca 20.9 GiB
+ this PR 10.8 GiB
main with #3952 (7ac3f460e) reverted 10.3 GiB

On main the growth goes on at about 0.1 GiB/s. A cold run reached ~60 GiB of RAM plus swap at about t+850 and was killed by the OOM killer while the level was still loading. An older base from 10-12 ran 2400 s without this. APS5_NO_GPL=1 doesn't change it.

An LD_PRELOAD heap profile on main at t+145 puts 8.5 GiB in the resource plans held by the static sources map, which is never trimmed. Most of that is the IR copied in behind branch conditions since #3952's PlanResourceControlFlow. A further ~5.7 GiB is compiled SPIR-V in SourceEntry::variants, which levels off.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6160087569 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5181#issuecomment-6160087569). Originally posted by [fisherjoey](https://github.com/fisherjoey) on 2026-10-14T03:16:56Z. --- A Linux NVIDIA data point from Demon's Souls (PPSA01341 v1.07), where `main` now runs out of memory before the level loads. Setup: Linux, RTX 5070 Ti, NVIDIA 595.91, GCC Release, `ANYPS5_ENABLE_SPIRV_TOOLS=OFF`. Base `main` 7a0c838ca, with this PR's ceda63b9c and b130903c8 applied (dc0ca9d57 isn't needed on that base, since #4883 isn't in it yet). Same 150 s run from boot to the title each time: | build | anon + swap at t+150 | |---|---| | `main` 7a0c838ca | 20.9 GiB | | + this PR | 10.8 GiB | | `main` with #3952 (7ac3f460e) reverted | 10.3 GiB | On `main` the growth goes on at about 0.1 GiB/s. A cold run reached ~60 GiB of RAM plus swap at about t+850 and was killed by the OOM killer while the level was still loading. An older base from 10-12 ran 2400 s without this. `APS5_NO_GPL=1` doesn't change it. An LD_PRELOAD heap profile on `main` at t+145 puts 8.5 GiB in the resource plans held by the static `sources` map, which is never trimmed. Most of that is the IR copied in behind branch conditions since #3952's `PlanResourceControlFlow`. A further ~5.7 GiB is compiled SPIR-V in `SourceEntry::variants`, which levels off. AI-assisted: yes
johnmaia commented 2026-10-14 04:19:40 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by johnmaia on 2026-10-14T04:19:40Z.


Test on another UE4 title: Epic Mickey: Rebrushed (PPSA15657), Dark Beauty Castle, from the save to about 5 minutes in the level. Linux, RX 7600 (RADV, Mesa 25.2.8), Release. main 00f4b3351 + #5030 + #5232 (both needed for this level to render correctly), with and without this PR, two runs each, alternated. VmHWM/RssAnon of the process sampled every 10 s:

peak RSS (VmHWM) RssAnon at the end in-level FPS
without this PR 17.5 / 17.2 GiB 13.6 / 13.8 GiB 4.61 / 4.66
with this PR 13.8 / 13.7 GiB 10.3 / 10.1 GiB 4.28 / 4.97

About 3.6 GiB less, a quarter of the anonymous memory, in every sample from the level load on. FPS stays within run-to-run noise. All four runs reached the level and played to the end. Frames from the same spots look the same with and without the PR.

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6160801420 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5181#issuecomment-6160801420). Originally posted by [johnmaia](https://github.com/johnmaia) on 2026-10-14T04:19:40Z. --- Test on another UE4 title: Epic Mickey: Rebrushed (PPSA15657), Dark Beauty Castle, from the save to about 5 minutes in the level. Linux, RX 7600 (RADV, Mesa 25.2.8), Release. `main` 00f4b3351 + #5030 + #5232 (both needed for this level to render correctly), with and without this PR, two runs each, alternated. `VmHWM`/`RssAnon` of the process sampled every 10 s: | | peak RSS (VmHWM) | RssAnon at the end | in-level FPS | |---|---|---|---| | without this PR | 17.5 / 17.2 GiB | 13.6 / 13.8 GiB | 4.61 / 4.66 | | with this PR | 13.8 / 13.7 GiB | 10.3 / 10.1 GiB | 4.28 / 4.97 | About 3.6 GiB less, a quarter of the anonymous memory, in every sample from the level load on. FPS stays within run-to-run noise. All four runs reached the level and played to the end. Frames from the same spots look the same with and without the PR. AI-assisted (Claude Code).
fdfawef324 commented 2026-10-14 09:39:15 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fdfawef324 on 2026-10-14T09:39:15Z.


I prepared a follow-up against dc0ca9d57 that keeps the original arena and disk-cache changes intact. It bounds MayEvaluate dependency cycles, retains malformed conditions for the existing runtime failure path, and conservatively retains conditions whose evaluated dependencies may read runtime memory. This last guard preserves read callbacks, their failures, and the read ordering/trace in the tested cases. An unsupported opcode still drops operands the evaluator never reads.

The matching public-source CPU checks passed on Windows Server 2025 with GCC15.2, -O3, one compile job and affinity0xF. They cover all-op evaluator dispatch parity, the typed first-lane active-mask case, source destruction/moves and actual IR reclamation. The original cycle analysis times out; the malformed and memory-prefix regressions fail without their guards. Actual BuildPlan/ExtractPlan/walk controls preserve callback counts, trace entries and failures for condition-only dynamic reads and retained constant SRT slots. The generic pure unsupported graph still retains7 values instead of50009. This is an arena-owned CPU example, not a title RAM/FPS claim. The full disk-cache codec test target was not run.

GPUs tested: none (CPU-only contribution).
AI-assisted: yes.

Co-Authored-By: Codex [email protected]

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6165418992 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5181#issuecomment-6165418992). Originally posted by [fdfawef324](https://github.com/fdfawef324) on 2026-10-14T09:39:15Z. --- I prepared a [follow-up against dc0ca9d57](https://github.com/fdfawef324/AnyPS5/compare/dc0ca9d5769a9858c4991cd1bc83ba5e26cb9139...codex/resource-plan-conservative-contribution) that keeps the original arena and disk-cache changes intact. It bounds MayEvaluate dependency cycles, retains malformed conditions for the existing runtime failure path, and conservatively retains conditions whose evaluated dependencies may read runtime memory. This last guard preserves read callbacks, their failures, and the read ordering/trace in the tested cases. An unsupported opcode still drops operands the evaluator never reads. The matching public-source CPU checks passed on Windows Server 2025 with GCC15.2, -O3, one compile job and affinity0xF. They cover all-op evaluator dispatch parity, the typed first-lane active-mask case, source destruction/moves and actual IR reclamation. The original cycle analysis times out; the malformed and memory-prefix regressions fail without their guards. Actual BuildPlan/ExtractPlan/walk controls preserve callback counts, trace entries and failures for condition-only dynamic reads and retained constant SRT slots. The generic pure unsupported graph still retains7 values instead of50009. This is an arena-owned CPU example, not a title RAM/FPS claim. The full disk-cache codec test target was not run. GPUs tested: none (CPU-only contribution). AI-assisted: yes. Co-Authored-By: Codex <[email protected]>
AnthonyClemens commented 2026-10-14 19:12:13 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by AnthonyClemens on 2026-10-14T19:12:13Z.


Windows 11, MinGW-w64 GCC 15.2.0, AMD R5 5600x, AMD Radeon RX 9070 XT.
Ran this on Resident Evil 2 (PPSA04288) on top of main 93d69edcc. Thanks for it, memory is a lot better. One thing I noticed: with a warm cache the decoded plans still held about 5.6 GB (ShaderDiskCache::DecodePlan, ~6,000 plans).

It looks like evaluableAlone() returns true for ReadFirstLane without checking its argument, so a condition behind a first-lane read is kept along with everything it depends on. I tried a second pass that also follows ReadFirstLane's argument (and ReadConst through its SRT read slot) and the plans went down to about 0.43 GB, with the game booting to the menu the same way. I haven't split out which of those two accounts for most of it, so take the numbers as a pointer rather than a measurement of one change.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6176256232 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5181#issuecomment-6176256232). Originally posted by [AnthonyClemens](https://github.com/AnthonyClemens) on 2026-10-14T19:12:13Z. --- Windows 11, MinGW-w64 GCC 15.2.0, AMD R5 5600x, AMD Radeon RX 9070 XT. Ran this on Resident Evil 2 (PPSA04288) on top of main 93d69edcc. Thanks for it, memory is a lot better. One thing I noticed: with a warm cache the decoded plans still held about 5.6 GB (ShaderDiskCache::DecodePlan, ~6,000 plans). It looks like evaluableAlone() returns true for ReadFirstLane without checking its argument, so a condition behind a first-lane read is kept along with everything it depends on. I tried a second pass that also follows ReadFirstLane's argument (and ReadConst through its SRT read slot) and the plans went down to about 0.43 GB, with the game booting to the menu the same way. I haven't split out which of those two accounts for most of it, so take the numbers as a pointer rather than a measurement of one change.
oneandonlydean commented 2026-10-14 19:22:50 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T19:22:50Z.


Rebased onto main: only an include in ResourcePlan.hpp conflicted. @AnthonyClemens's point about ReadFirstLane/ReadConst counting as evaluable without their arguments is right; it only costs memory, so it can be a follow-up.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6176466750 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5181#issuecomment-6176466750). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-14T19:22:50Z. --- Rebased onto main: only an include in `ResourcePlan.hpp` conflicted. @AnthonyClemens's point about `ReadFirstLane`/`ReadConst` counting as evaluable without their arguments is right; it only costs memory, so it can be a follow-up.
github-actions[bot] commented 2026-10-14 21:50:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-14T21:50:57Z.


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.

Pull request Conflicting files (lines on main) Same exports Same new files
#6095 core/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/ResourcePlan.hpp L13, L79
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6179276212 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5181#issuecomment-6179276212). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-14T21:50:57Z. --- <!-- pr-overlap --> 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**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | #6095 | `core/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/ResourcePlan.hpp` [L13](https://github.com/boykopovar/AnyPS5/blob/e5592f01925072833716d1895d7734a5d90ada96/core/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/ResourcePlan.hpp#L13), [L79](https://github.com/boykopovar/AnyPS5/blob/e5592f01925072833716d1895d7734a5d90ada96/core/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/ResourcePlan.hpp#L79) | | |
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!5181
No description provided.