feat(agc): add opt-in render-state overrides #7275
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/7275"
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 ivica00 on 2026-10-17T21:09:42Z.
What
Opt-in AGC render-state overrides and a shader reload trigger.
APS5_HOT_RELOADmust be set, non-empty, and not0.hotreload/render_state.txtcan setforce_wireframe,disable_cull,disable_depth_test,force_depth_write,disable_blend(alsodisable_blending), anddisable_dcc.force_wireframeselects line fill only when the device supportsfillModeNonSolid; otherwise the toggle is ignored and logged once.force_opaque_alphaandfallback_magentaare ignored: disabling blend does not write alpha 1, and placeholder images are created once, before the file is polled. Creatinghotreload/reload_shadersclears the Vulkan pipeline cache. With the switch off, draws do not lock, and a draw copiesStateonly when a cull, depth, or blend override is set. The proxied color write mask is unchanged from main. Libc trampolines and raw patches are not part of this change.Tested
Windows, MinGW g++ 16.2, the
render_overrideunit test: the enabled predicate treats unset, empty, and0as off, the parser applies and replaces flags, a file that contains onlyforce_opaque_alphaandfallback_magentasets nothing, and the shader-reload flag is one-shot. Not run against a title.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 repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-17T21:26:46Z.
Review: COMMENTED
The
force_opaque_alphaoption does not currently force alpha to 1.0. InDraw.cpp, it only sets every blend attachment’sblendEnabletoVK_FALSE;Pipeline.cppthen uses the shader output unchanged, so its alpha value is still written to the color attachment. That disables blending but leaves translucent source alpha intact. Could this override set the attachment alpha output to 1.0 (for example through an appropriate blend-constant path or shader/output override), or should the option and documentation be renamed to describe only disabling blending? A regression should use a shader that outputs alpha below 1 and verify the stored/presented alpha is opaque.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-17T21:27:09Z.
Review: COMMENTED
There is another platform mismatch in
LoadPatchModules. The directory scan accepts.sofiles on POSIX, but the POSIX branch only callsdlopenand never enumerates exports or callsPatchFunction;patchedTotalstays zero.HandleNotImplementedtherefore continues polling and ultimately returns false even though the module was loaded, and the source patch file is then removed. Could you either implement the export-patching path for ELF modules or restrict/describe this module feature as Windows-only and avoid consuming a.soas if it had been applied? The current test/report only covers Windows, so this path is unvalidated.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-17T21:32:24Z.
Code review location:
core/libs/prx/libc/src/HotReload.cpp; line 246On POSIX this only
dlopens the shadow module. Unlike the Windows branch above, it never enumerates exports or callsPatchFunction, sopatchedTotalremains zero; the original file is then removed at line 250. That makes the documented.sohot-reload path silently discard its patch without applying it. Could this either resolve/apply exported replacements on POSIX too, or retain the source and report the path as unsupported?Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-17T21:32:24Z.
Code review location:
core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp; line 2262Disabling blending does not force the fragment shader's alpha output to 1.0; it only prevents blending, so a shader that writes alpha 0 still stores alpha 0 in the attachment. The PR description and render-state guide currently promise
force_opaque_alpha. Could the override actually force the output alpha, or be renamed/documented as disabling blending so the diagnostic's effect is clear?Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-17T21:32:24Z.
Review: COMMENTED
I reviewed the newly added paths and left two focused comments on behavior that appears to differ from the documented feature. Both are scoped to the current head.
Imported from boykopovar/AnyPS5. Originally posted by ivica00 on 2026-10-17T21:41:28Z.
Code review location:
core/libs/prx/libc/src/HotReload.cpp; line 246Implemented in commit 6dfdba678e: On POSIX platforms, the loader now reads the ELF header and section table of the shadow .so to extract the dynamic symbol table (.dynsym / .dynstr). For each exported STT_FUNC symbol, it resolves both the patch address via dlsym(hPatch, symName) and the base process address via dlsym(RTLD_DEFAULT, symName) before calling PatchFunction to install the detour.
Imported from boykopovar/AnyPS5. Originally posted by ivica00 on 2026-10-17T21:41:33Z.
Code review location:
core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp; line 2262Addressed in commit 6dfdba678e: Renamed the diagnostic override to disableBlend / disable_blend across RenderStateOverride, HotReload.hpp, HotReload.cpp, and Draw.cpp, accurately reflecting that it sets lendEnable = VK_FALSE on attachment color blends. orce_opaque_alpha is retained as an alias in the configuration parser for backwards compatibility.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-17T21:45:27Z.
Code review location:
core/libs/prx/libc/src/HotReload.cpp; line 274Could this also require
ELF64_ST_TYPE(sym.st_info) == STT_FUNCbefore callingPatchFunction? The current loop checks only global/weak binding, so an exportedSTT_OBJECTor other non-function symbol with a matching base-process name also reachesPatchFunction. That writes the 14-byte code trampoline over the data object's storage and can corrupt the process. This API is intended to replace functions, so filtering to function symbols seems necessary.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-17T21:45:27Z.
Review: COMMENTED
Thanks for addressing the two earlier points. I reviewed the POSIX export loop at the updated head and found one additional correctness issue.
Imported from boykopovar/AnyPS5. Originally posted by ivica00 on 2026-10-17T21:55:58Z.
Code review location:
core/libs/prx/libc/src/HotReload.cpp; line 274The POSIX loader now requires
ELF64_ST_TYPE(sym.st_info) == STT_FUNCafter the global/weak binding check, so an exportedSTT_OBJECTor other non-function symbol is skipped andPatchFunctionis not called for it. Pushed in 3217ec1d1.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-17T22:09:50Z.
@ivica00 thanks for this. We'd like the live render-state toggles, but only those, so could you split them into an AGC-only PR?
In scope: the
hotreload/render_state.txtoverrides (wireframe, no cull, no depth test, forced depth writes, no blending, magenta fallback, no DCC) and the shader reload trigger.Out of scope for this PR: the libc parts, i.e. the module loader and trampolines (
LoadPatchModules,HandleNotImplemented) and the raw byte patches fromhotreload/patches.txt. Writing arbitrary bytes into the running process is a separate design question for the maintainers, and libc isn't the place for it. Please leave them out rather than moving them.Two changes for the AGC PR:
No cost when it's off. At 3217ec1d1 every draw calls
GetRenderStateOverride(), which takesg_overrideMutex, andDrawcopies the wholeState(State overriddenState = baseState;) whether or not an override is active. Please check a cached "enabled" flag first and return before any locking, and copyStateonly when at least one override is set. The same goes for the getter calls inPipeline.cppandPlaceholderImages.cpp. Also,Presentation.cpptreatsAPS5_HOT_RELOADas on whenever it's set, even to0; please use one definition of "enabled" everywhere.Restore the proxied write mask. The change in the proxied-target loop in
Draw.cppremovesmasked->blends.at(state.colors[index].exportIndex).colorWriteMask &= VK_COLOR_COMPONENT_R_BIT;. That changes rendering on the default path with hot reload off. Please keep that line exactly as on main.We'll test the new version on our side once it's up.
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-17T22:19:19Z.
Two more things on 3217ec1d1, in addition to the scope note above:
Presentation.cpp:230callsShaderRecompiler::ResetRecompilerCaches(), which doesn't exist anywhere in the tree (the PR-event CI doesn't build the AGC driver, so the checks show green). The AGC-only PR will need the reload path to call something that exists, or to clear only the pipeline cache.docs/dev/debt/libc.md. That file drops out once the libc half is gone, so a fresh AGC-only branch from current main avoids it.Imported from boykopovar/AnyPS5. Originally posted by ivica00 on 2026-10-17T22:32:15Z.
Thanks. The branch is now AGC-only, rebuilt on current main (
eabb717bb).The render_override unit test covers the enabled predicate, the render_state.txt parser (including the force_opaque_alpha alias), and the one-shot shader-reload flag. I have not run it against a title.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-17T22:48:51Z.
I built and ran the graphics validation suite at the current head
eabb717bb56ab97c196e7b8aca67d3afd44f1e15; it completed withGraphics validation tests passed(exit 0). This includes the newrender_overrideunit coverage, but is not a title/runtime validation.For this local Linux run I made two temporary, uncommitted environment-only workarounds: added the
templatekeyword to an unrelated existingSrtDescriptorEvaluation.cppcall so GCC could compile it, and bypassed the project’s old-host-CPU test guard (APS5_ALLOW_OLD_TEST_CPU=1) for this Xeon. Neither workaround is part of the PR or the reported test result.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-18T10:21:56Z.
Thanks, this is the scope we asked for: AGC only, the loader and byte patcher gone, the flag cached and the State copy only when an override is set, and the colorWriteMask line back. It compiles against current main. Two toggles don't work yet:
fallback_magenta:PlaceholderImagesreads the override in its constructor, which runs when the context is created, before the first Present has readhotreload/render_state.txt. Changing the file later doesn't rebuild the placeholder images, becauseHotReloadShadersonly clears pipelines. So the toggle never takes effect. Could you poll before creating them and recreate them when the toggle changes, or leave this toggle out?force_wireframesetsVK_POLYGON_MODE_LINE, but the device never enablesfillModeNonSolid, so this is invalid usage and the result depends on the driver. Please enable the feature when it's supported, and ignore the toggle with a log line when it isn't.Small things:
force_opaque_alphaonly disables blending (alpha isn't forced to 1), so it's clearer without that alias. Andstd::optional<State>would avoid default-constructing a State on every draw when overrides are off.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-18T10:52:04Z.
Windows CI fails at link time for the new test:
tests/render_override_tests.exehas an undefined reference to__gxx_personality_v0(from bothRenderOverride.cpp.objfiles). Linux is green and main is green, so this comes from the new target.Cause: on MinGW,
core/libs/CMakeLists.txtadds-fno-asynchronous-unwind-tablesto everything in that directory (line 44), so these objects use DWARF unwinding and need__gxx_personality_v0. In this tree that symbol comes fromlibc.prx. Every test there that callsconfigure_windows_unwindalso linkslibc.render_override_testsis a host-only test that doesn't linklibc, and the host libstdc++ (SEH) doesn't provide the DWARF personality.Host-only tests in the same file already handle this the way you'd expect (
nid_buffer_validation_tests,crash_text_tests). Something like:and drop
configure_windows_unwind(render_override_tests), since the test doesn't use the guest DWARF unwinder. Could you push that? We'll rerun full CI on the new head.Imported from boykopovar/AnyPS5. Originally posted by ivica00 on 2026-10-18T12:14:44Z.
Addressed on
2934c1bf9.fallback_magentais removed. Placeholder images are created with the device, before the first present readshotreload/render_state.txt, and later draws already hold those views. Rebuilding them when the file changes would leave those views behind, so the key is ignored. The unit test writes onlyforce_opaque_alphaandfallback_magentaand checks that no override is set.force_wireframesetsVK_POLYGON_MODE_LINEonly whenfillModeNonSolidis available. The device enables that feature when the hardware has it. Otherwise the pipeline stays filled and one line is logged:force_wireframe ignored: fillModeNonSolid is unavailable.force_opaque_alphais no longer an alias ofdisable_blend. Turning blend off does not write alpha 1.std::optional<State>and constructs it only when a cull, depth, or blend override is set.render_override_testsno longer callsconfigure_windows_unwind. On MinGW it compiles with-fasynchronous-unwind-tables, the same as the other host-only tests that do not linklibc.render_overridepassed here (MinGW g++ 16.2). Not run against a title.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-16T20:23:22Z.
Review: COMMENTED
Reviewed — comments
The added render overrides and reload trigger were inspected at head
4aff7f5047fc79c99ebf6cc7620f6ec0914338d9; no blocking defect was verified, and no checks were run.What I ran
No commands or tests were run. I inspected the prepared diff and targeted source context through
repo_read.py.Results
Negative Control
Not run; the new test was not executed.
Findings
Blocking
None.
Non-blocking
PollRenderOverriderecords the file timestamp before opening and parsing it. If opening fails transiently, that timestamp prevents another attempt until the file’s timestamp changes (core/libs/prx/libSceAgcDriver/Graphics/src/RenderOverride.cpp:56). Consider updatinglastOverrideWriteonly after a successful read so a transient access error can recover on its own.Sources
The findings and behavior above are based on the prepared diff and the changed source at the pinned head.
Not verified
The Windows/MinGW unit-test run described by the author was not independently verified. No build, automated checks, or title/game behavior were run. The changed files’ full head text was not available in
review/files/; added lines were inspected indiff.patch, and targeted repository source ranges were read for render-state polling, draw-state application, pipeline construction, cache clearing, presentation, and the added test.files.jsonwas not available through the reader; the changed-file inventory was taken frommanifest.json.To get this to a good state
Nothing is required. Optional: retry parsing after a transient file-open failure by recording the timestamp only after a successful read.
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.