fix(agc): retain shader memory region vectors #7759
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/7759"
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 MarcZX10 on 2026-10-19T06:28:27Z.
What
Retain the vectors returned by
ShaderMemory::Regions()anywhere test requests store them inGuestContext::memory, which is a borrowed span. Fixes all 20 reported sites inShaderMemory.cpp, including reused request/lambda cases, and the same lifetime bug in theImageTableCachecapture helper. The store lambda now compiles a local request copy so an outer request cannot retain a view into a destroyed vector.Tested
python3 tools/check_conventions.py --base upstream/main,python3 tools/pr_overlap.py --branch codex/fix-shader-memory-region-lifetimes --base main --repo boykopovar/AnyPS5, andgit diff --checkpass. No open PR overlap was found.The focused Linux test build was not completed. The available
agc_shader_memory_testsbuild tree is based on an older branch; compiling the current-main test source against it fails on unrelatedSpirvTarget::float32FlushToZerofields absent from that older branch. The temporary source copies were restored immediately. No test pass is claimed.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 repositoryImported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-19T06:36:39Z.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppImported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-19T06:39:36Z.
Manual follow-up to the overlap report: I reviewed the flagged
ShaderMemory.cppdiffs. The serializer-related PRs change serializer/version fixtures; the remaining diffs add or adjust separate sRGB, wave-reduction, FMASK, extension-key, volume-array, pointer/image-table or device-table tests. None changes the requestRegions()ownership sites in this PR, and none of the flagged PRs changesImageTableCache.cpp. I found no direct hunk overlap or dependency. The PR is currently mergeable againstmain.Imported from boykopovar/AnyPS5. Originally posted by Amoenus on 2026-10-19T07:09:41Z.
Independent validation of exact head
55a3eeb074eae9d50db090ef3584b04ab1066c4d(actual parent/merge base63e4a63804c4570e5bd7b08b7ee03a780feeb0e6):agc_shader_memory_testsandagc_driver_image_table_cache_testssuccessfully.agc_shader_memoryandagc_driver_image_table_cache, serial, five repetitions each on each OS; shader cache disabled. No skips/timeouts. Longest test: Windows 1.97 s, Linux 1.48 s (30 s limit). These are CPU fixtures, not GPU or title results.danglingTemporaryLifetime/bugprone-dangling-handlediagnostics remain. The unchanged-main comparison atfeb74b65c2had 16 / 20 respectively inShaderMemory.cpp. Five unrelated advisories remain in that file (two Cppcheck, three clang-tidy);ImageTableCache.cpphas no selected diagnostics. No suppressions or auto-fixes; no whole-project static-clean claim.Source review: the reused store lambda uses a local request copy, so the outer request does not inherit its temporary region view. The image-table helper retains
TakeRecentRegions()inCaptured::regionsacrossRecompile; itsShaderMemorystarts empty for that capture. I independently reviewed the previously flagged shared-file patches and found no competing repair of these ownership sites.ASan limitation: I cannot claim a sanitizer pass. A separate ASan run on unmodified main
46f27623c2and our earlier one-file prototypee3b8707988aborts before these sites in SPIRV-Tools validation /std::stable_sortwithalloc-dealloc-mismatch (operator new vs free), reported as #7765. That is not a run of this exact PR head, and allocation-mismatch checking was not suppressed.Update: #7781 has since merged the fixture nothrow-allocation correction for #7765. The pinned sanitizer runs above predate it; we have not yet rerun the full combined fixture under ASan on that newer source.
Thanks for taking #7754 forward, including the additional image-table helper. Our one-file prototype remains preserved on the fork; we will use this PR rather than submit a duplicate.
AI-assisted review/report: yes, Codex. No workflow dispatch or merge performed.
Imported from boykopovar/AnyPS5. Originally posted by savvaniss on 2026-10-19T07:42:04Z.
Intel and AMD Windows data: the 16 tests this PR touches pass on an Intel UHD 770 and an AMD RX 9070 XT, with and without the change.
Windows 11 Pro 26300, WinLibs GCC 15.2.0 r7, Release, every execution test built,
ANYPS5_NO_SHADER_CACHE=1, serial CTest. Intel UHD Graphics 770 (8086:a780), driver 32.0.101.7088. AMD Radeon RX 9070 XT (1002:7550), driver 32.0.31041.1004, withVkCacheemptied first. This head55a3eeb07merged intomain6b8228b2b. "Without" means this PR's test files onmain6b8228b2b, with none of its other changes.agc_shader_memory,agc_driver_image_table_cache,agc_shader_bindlessand the other shader tests)So on these two GPUs the tests don't distinguish the change, and they show no regression.
AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-19T09:00:46Z.
Review: COMMENTED
macOS data point: Apple clang already flags these sites in a default build, so this shows up as compiler warnings on macOS. On the tree below without this PR, the build has 20
-Wdangling-assignment-gslwarnings intests/ShaderMemory.cppand 1 intests/execution/ImageTableCache.cpp(object backing the pointer 'request.context.memory' will be destroyed at the end of the full-expression). These are the 20 + 1 sites this PR changes. With the PR there are none, and both tests pass.Machine: Apple M2 Max, macOS 27.2, x86-64 build under Rosetta. Drivers: MoltenVK 1.4.2 (Vulkan SDK 1.4.363.0) and MoltenVK main + SPIRV-Cross #2704. Head
55a3eeb07, PR diff applied cleanly. Apple clang 21.0.0, Release, default warnings, no extra flags.Tested: the tree is
maina373e85e5+ mugurc's macOS series (ci/macos-series-2) + the PRs needed to build on macOS (#6667, #6668, #7524, #6969, and two files of #7332), not plainmain(it doesn't build on macOS yet). Applied together in the same build: #7371, #7535, #7684, #7746 and #7759, plus a test-only patch that lets nine AGC fixtures load the Vulkan loader on macOS (branchjotitadev:fix/agc-tests-vulkan-loader-macos). Base on that tree: 40^agcfailures with MoltenVK 1.4.2 and 26 with MoltenVK main + #2704, plusagc_driver_pooled_buffer_rangeandagc_performance_overlay, which only run because of the loader patch.agc_shader_memoryandagc_driver_image_table_cachepass 3 of 3 on both drivers with the PR. #7684's newShaderMemory.cppcases were in the same build and add no new warnings.^agcsuite with the stack has the base failures on both drivers. The only new failure,agc_driver_native_depth_clears, comes from #7371 / #7233. Nothing from this PR.GPUs tested: Apple M2 Max (MoltenVK 1.4.2; MoltenVK main + SPIRV-Cross #2704)
Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-19T16:52:08Z.
Thank you for the cross-platform checks. The Windows and Linux CPU fixture runs, static-analysis results, and AMD/Intel Windows runs show no regression in the tested cases. The 16 Windows tests pass both with and without the change, so those GPU results do not distinguish the fix; the independent 20 fresh-process CPU passes and the compiler warning results provide additional validation for the lifetime issue. I’ll describe those separately rather than treating them as GPU proof.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-20T13:49:49Z.
Rechecked against current main: no temporary
Regions()is assigned tocontext.memoryany more (all 21 sites retain the vector), the store lambda compiles a local copy, no logic changes; runs from @Amoenus, @savvaniss and @jotitadev confirm; merged.