fix(agc): accept unaligned shader headers in ABI resolution #4809
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4809"
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-12T22:36:21Z.
What
Carries the shader-header alignment fix from the second patch attached to #4782. ABI resolution and registered-header lookup now copy the fixed
Shaderfields into an aligned local object before reading them. This lets those paths handle guest headers whose addresses are not naturally aligned, while preserving the existing guest-memory range check.Extends
PreparedShaderswith a header address four bytes off its natural alignment and exercises ABI resolution through it. The unrelated exports/library patch from #4782 is not included.#4043 and #2589 also touch
ShaderRegistry.cppand/orPreparedShaders.cpp, but address relocated snapshots and background ABI compilation. This change has no dependency on either PR; the file overlap is disclosed for rebasing coordination.Tested
BUILD_TESTING=ON: builtagc_driver_prepared_shaders_tests, including the changedShaderRegistry.cppandPreparedShaders.cpp.mesa-vulkan-drivers22.3.6):agc_driver_prepared_shaderspassed (1/1).python3 tools/check_conventions.py --base upstream/mainandgit diff --check upstream/main...HEAD: passed.Checklist
main; no open PR implements the same alignment behaviorNotImplemented_nid_no_patch); no new silent stubs.mdfiles or images added to the repositoryImported from boykopovar/AnyPS5. Originally posted by GoodTimeclubs on 2026-10-12T22:58:12Z.
I had prepared the same fix on my own branch (not pushed), so I won't open a duplicate. While testing it I found two things that might be worth adding here:
alignof(ShaderRegister)and read through the pointer. This happens inResolveGraphicsStagesAbiwhenfields.type != snapshot.type(CheckRange(fields.sh_registers, ..., alignof(ShaderRegister)), thenfields.sh_registers[index]), and inFusedHullHeader(CheckRange(bound, bytes, alignof(ShaderRegister)), thenbound[index]). If a header sits at an address that is not 4-byte aligned, the registers that follow it are misaligned too. In that case these two paths still thrownull or misaligned address. In practice it only affects a fused hull header (type 3 against a registered type 7) at such an address, so it's narrow. Reading them withCheckRange(..., 1)plusmemcpy, as for the fixed fields, closes the gap:On
mainboth fail withAGC driver: null or misaligned address. On this branch both pass. I tested on Ubuntu 24.04 with GCC 14.2 and lavapipe.AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-12T23:07:23Z.
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.
main)core/libs/prx/libSceAgcDriver/tests/execution/PreparedShaders.cppL479-481Imported from boykopovar/AnyPS5. Originally posted by kr4y4 on 2026-10-13T01:38:16Z.
A run on GPU hardware, since the description and the comment above used lavapipe.
Setup: Windows 11 (26200), WinLibs GCC 15.2.0 r7, Release, CI configure flags, an RTX 4070 Laptop GPU and an Intel Raptor Lake-S iGPU. The head
198860740merged intomain284a1c334, which passes 1020 of 1020 on both GPUs.agc_driver_prepared_shaderspasses on both GPUs with--repeat until-fail:3. The full suite (ctest --timeout 120 --parallel 4) passes 1020 of 1020 on both.ShaderRegistry.cppas onmain,agc_driver_prepared_shadersfails on both GPUs withAGC driver: null or misaligned address.Written with AI assistance.