graphics: add experimental memory-pressure texture retention #902
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
GPU
GUI
help wanted
question
Shaders
Video
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/KytyPS5--KytyPS5!902
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-902"
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?
@gohansharma79-svg on GitHub · 2026-09-28 23:00 UTC · original
gohansharma79-svg:lost-crown-texture-retention→main· +456 −228 · 15 files · 3 commits · openProblem and scope
Prince of Persia: The Lost Crown profiling motivated an opt-in experiment to reduce texture eviction/recreation while GPU memory pressure is low. This PR adds the disabled-by-default Memory-pressure texture retention (experimental) Compatibility setting. No title IDs or game-specific behavior are embedded in the renderer.
The old screenshots below are contextual observations from earlier builds, not an isolated benchmark of this exact patch. A new gameplay A/B on this branch is still needed; this PR does not claim a measured FPS improvement.
Behavior
Refresh — 19 October 2026
Merged current main
099de8dewithout rewriting the original contribution and resolved renderer/settings conflicts. Corrected the missing-budget fallback called out in the earlier automated architecture review: the previous experiment used the longer retention ages even when it fell back to legacy thresholds. Removed its constructor threshold override, and use live-budget availability rather than merely the enabled toggle when selecting ages.The live-budget comparison now uses total budget and usage consistently on unified-memory devices too; it no longer subtracts usage from the denominator before comparing that same usage against it. Unavailable heap budget data selects the legacy path instead of substituting an unmeasured physical-capacity budget.
Validation
memory_pressure_policy_tests: entry/release boundaries, direct critical transitions, missing/restored budgets, legacy fallback ages, live-budget ages, over-budget usage and percentage overflow. Pass locally with GCC 15.2, C++20,-O2 -Wall -Wextra -Werroron Windows.experimental_settings_tests: default disabled, saved reload, effective-game copy, export/import and missing-key legacy settings.kyty_teststarget. Fresh head6b1f9a4CI passes on Windows, Linux and macOS: 15/15 selected tests on Windows and 17/17 each on Linux/macOS, including both new regressions. CI run. Whitespace and launcher XML parsing checks pass locally.ENOTFOUND); it was not a C++ compilation failure.Earlier screenshots (not an isolated benchmark)
@coderabbitai[bot] on GitHub · 2026-09-28 23:08 UTC · original · edited 2026-10-18 23:47 UTC
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
e6082b2f-0100-4665-8546-c7dd8f677215📥 Commits
Reviewing files that changed from the base of the PR and between
e32c83dc3dand6b1f9a4438.📒 Files selected for processing: 4
CMakeLists.txtsrc/graphics/host_gpu/renderer/cache/textureCache.cppsrc/graphics/host_gpu/vma.cppsrc/launcher/CMakeLists.txt🚧 Files skipped from review as they are similar to previous changes: 3
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 5 remain after this review.
📝 Walkthrough
The change adds GPU memory-budget reporting and a stateful pressure policy for texture collection. An experimental launcher setting controls whether the emulator uses live memory pressure to select collection behavior. The launcher persists the setting and passes it to the emulator process through an environment variable. New tests cover the setting and pressure policy, and build jobs run both test targets.
Suggested reviewers:
nmzikPriority: ⬇️ Low
Change: Feature
Merge Risk: ⚪ Minimal · up to
6b1f9The retention experiment is disabled by default, and existing collection behavior remains in use when live budget reporting is unavailable. No concrete current-head failure is established, so merge risk is minimal.
Security architecture risk: 🟡 Moderate · up to
2af1bThe experimental mode is off by default, but enabling it can weaken memory-pressure recovery when GPU budget data is unavailable: textures may remain eligible for collection much later than before. The observed change does not add a credential, network, or privilege boundary.
Retained concerns
Security review details
Security Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
Pre-merge checks:
4 ·
1
Full details: Docstring Coverage
Explanation
Docstring coverage is 5.45% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 55 functions across 11 files. (2 skipped: 2 unsupported.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share
Comment
@coderabbitai helpto get the list of available commands.@gohansharma79-svg on GitHub · 2026-09-29 03:33 UTC · original
@Nmzik
@gohansharma79-svg on GitHub · 2026-10-03 10:30 UTC · original
@Nmzik can you please check this
@gohansharma79-svg on GitHub · 2026-10-18 15:16 UTC · original
@Nmzik
@ -1959,0 +1986,4 @@live_pressure = m_pressure_policy.Update(m_total_used_memory, *live_budget);}if (live_pressure ? *live_pressure == MemoryPressurePolicy::Level::Critical: m_total_used_memory >= m_critical_gc_memory) {@coderabbitai[bot] on GitHub · 2026-10-18 23:28 UTC · original · edited 2026-10-18 23:31 UTC
🚀 Performance & Scalability | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 4812
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 8908
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 8178
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 4168
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 3202
Recompute live pressure before the aggressive pass.
collect(false)can free textures using the pressure age.live_pressurestill holds the pre-evictionCriticallevel, so the second pass can use the critical age and evict up to 40 more recently used textures. This can recur at each frame boundary while pressure remains critical.The mode is opt-in and disabled by default, so this is a minor performance issue. The fix is localized: recompute the level from
m_total_used_memoryafter the first pass, or sample the budget again before the second-pass gate.Suggested fix
✅ Addressed in commit
6b1f9a4@coderabbitai[bot] on GitHub · 2026-10-18 23:28 UTC · original · edited 2026-10-18 23:31 UTC
On
src/graphics/host_gpu/vma.cppline 164 (outdated):🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Exclude unusable heaps from texture-pressure calculations.
When a non-discrete GPU has separate device-local and non-device-local heaps, this code adds both budgets.
CreateImagerequires device-local memory. A large unused non-device-local budget can therefore keep the reported pressure belowCollectwhile the heap available to textures fills. Texture collection then stops before an image allocation fails. Calculate pressure against the heaps that can back these images.✅ Addressed in commit
6b1f9a4@ -227,1 +227,4 @@clang_tidy_check(launcher "" "${tidy_dirs}" "${inc_headers}")if(BUILD_TESTING)add_executable(experimental_settings_tests EXCLUDE_FROM_ALL@coderabbitai[bot] on GitHub · 2026-10-18 23:28 UTC · original · edited 2026-10-18 23:31 UTC
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 6343
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 10607
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 11386
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 5221
Add
experimental_settings_teststokyty_tests.The documented workflow builds
kyty_testsbefore running CTest.kyty_testsdoes not depend onexperimental_settings_tests, so CTest can attempt to run the registered test before its executable is built.Suggested fix
✅ Addressed in commit
6b1f9a4@coderabbitai[bot] on GitHub · 2026-10-18 23:28 UTC · original · reviewed
Actionable comments posted: 3
ℹ️ Review info
⚙️ Run configuration
f954ea63-09a1-448d-b329-0e3c470e06ab📥 Commits
Reviewing files that changed from the base of the PR and between
2af1b5d448ande32c83dc3d.📒 Files selected for processing: 15
.github/workflows/build.ymlCMakeLists.txtsrc/graphics/host_gpu/graphicContext.hsrc/graphics/host_gpu/renderer/cache/memoryPressurePolicy.hsrc/graphics/host_gpu/renderer/cache/textureCache.cppsrc/graphics/host_gpu/renderer/cache/textureCache.hsrc/graphics/host_gpu/vma.cppsrc/launcher/CMakeLists.txtsrc/launcher/forms/configuration_edit_dialog.uisrc/launcher/include/configuration.hsrc/launcher/src/configuration.cppsrc/launcher/src/configurationEditDialog.cppsrc/launcher/src/mainDialog.cpptests/ExperimentalSettingsTests.cpptests/MemoryPressurePolicyTests.cppIncluded review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.
@gohansharma79-svg on GitHub · 2026-10-18 23:48 UTC · original · edited 2026-10-18 23:54 UTC
@Nmzik, #902 and the related interrupt-batching PR #900 have been refreshed against main
099de8de, with the merge conflicts resolved and current launcher/per-game settings support retained.For #902, the update restores legacy thresholds and ages without live budgets, restricts live texture pressure to device-local heaps, and recomputes pressure before the aggressive pass. The new policy and settings regressions pass: 15/15 selected tests on Windows, 17/17 on Linux and 17/17 on macOS, with all three builds and packaging successful. Validation run.
For #900, the tested source at
b06a28fpasses 14/14 selected tests on Windows and 16/16 each on Linux/macOS, with all builds and packaging successful. Validation run. Its Windows CI GPU fixture also passes--gpu-command-lane-onlyin separate processes withKYTY_DEFER_RELEASE_MEM_INTERRUPTS=0and=1on an RTX 4070 SUPER, driver 616.64, Ryzen 7 5800X, Windows 11 Pro. Both modes pass the command lane, scalar leaf call, AGC system table, indirect control flow, wait/resume, rewind and CE completion checks.The latest #900 commit
314e710only places that executable beside its DLLs in the test artifact. The flattened package passed both modes again with only the Windows system directories on PATH. Its automatic packaging rerun is pending; no production or test source changed after the passing runs.Both features remain opt-in and disabled by default. The earlier screenshots came from combined builds; they do not isolate either PR's FPS contribution. The descriptions now make that limitation explicit.
Could you review whether these experiments fit the project's direction, and advise which additional title-specific traces or comparisons would be most useful before considering a merge?
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.