Skip to content

feat(libSceAgc): support back-half constants in shader fusion - #19061

Merged
oneandonlydean merged 2 commits into
boykopovar:mainfrom
mjnhbg3:codex/agc-fusion-back-constants
Nov 21, 2026
Merged

oneandonlydean merged 2 commits into
boykopovar:mainfrom
mjnhbg3:codex/agc-fusion-back-constants

Conversation

@mjnhbg3

@mjnhbg3 mjnhbg3 commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

What

Allow geometry shader fusion when the back half has an embedded constant buffer. Previously both the size query and fusion threw before constructing this otherwise supported program. The back program is already copied in full, so its instructions and embedded data receive the same address translation and retain their PC-relative relationship. Front constants continue to move after that complete back span. Remove the rejection and the corresponding debt limitation; the rebuilt-program topology and the remaining front-PC restrictions stay documented.

The regression uses independently authored shader halves with back-only and simultaneous front/back constants. It checks first/last words, full back-byte preservation, unchanged input buffers, caller scratch bounds, header metadata, reuse of identical programs, different cached programs after constant changes, and operation after the source allocations are destroyed. Eight Vulkan compute dispatches of the fused scalar instruction streams check the output values and output canaries. This tests relocation and actual GPU readback, not geometry-stage rasterization.

Evidence: the user's local PPSA02530 PRAGMATA 01.300.000 libSceAgc.sprx, unwrapped SHA-256 124a637bb17080d4e754d07d73f3320531d3b5c6e384ae2a81c364c44d17abbd. sceAgcFuseShaderHalves_0200 (fd5Bp5tGTgo, VA 0xfd40) copies the back header and patches its register list without inspecting either program or the embedded constant count; sceAgcGetFusedShaderSize_0080 (dolOmWH+huQ, VA 0xf690) only checks the half types and reports the back SH-list bytes with alignment 4. PRAGMATA calls size/fuse at 0x492863/0x492899 and 0x49295e/0x49299a. These sites establish use of the function, not that a currently loaded game shader has back constants or that this change fixes its observed pipeline failure.

A local SDK probe executed the original export instructions: 720 synthetic cases / 1,440 API calls, zero mismatches. Front/back constant counts were 0, 1, 2, 17, 128 and UINT32_MAX, over GS/HS pairs, scratch and in-place register operation, mapped/unreadable/null code pointers, and invalid half/stage pairs. Full output headers, registers, scratch canaries, source preservation and size/alignment were checked. The harness supplied a memcpy import at GOT 0x28a58 and seven synthetic register-selector globals (0x459d8=0x8a, 0x459f0=0x8b, 0x45ca0=0xc8, 0x45f28=0x100, 0x459e0=0x10a, 0x459f8=0x10b, 0x45cd0=0x148). This is conditional local library verification, not console measurement or module-initialization verification. No dump, captured game shader, binary, or key is included.

Tested

Windows 11 ARM64 build 26200.9168; x64 Release binaries built with WinLibs GCC 15.2.0 r7. The implementation is shared code with no ARM-specific production path. GPU: Qualcomm Adreno X1-85, native Qualcomm Vulkan ICD qcvkarm64xum.dll file version 31.0.152.1. Khronos validation layer 1.4.363 from SDK 1.4.363.1, newer than the required 1.4.335 minimum.

Base: 1ddbd1550631c3ee73e41fdb5b1377b40c9e439b. Contribution: 631cfd1132db440331bc39e34f8eb5edaf0de3b6. git range-diff confirms the implementation patch is unchanged by the rebase.

  • The existing agc_shader_fusion test passes on the pinned main baseline. The new fixture against unchanged production code fails at the explicit back-constant rejection. With this contribution, agc_shader_fusion passes, including eight compute dispatches, 512 output-value comparisons and output canaries.
  • Fresh unchanged-SDK reference: sdk-fusion-constants calls=1440 mismatches=0 memcpy-calls=216. This is 720 synthetic cases / 1,440 export calls; the supplied selector globals and memcpy hook are described above. It is not a console measurement or full module-initialization validation.
  • Full libs and agc_shader_fusion_tests builds succeeded. Pre-test SHA-256 manifests verify test-side libc.prx, libkernel.prx, libSceAgc.prx and libSceAgcDriver.prx match their build outputs. Public-header, conventions and whitespace checks pass.

The same agc_shader_fusion test ran verbosely on main and the change, on the same machine/GPU, with ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, VK_LOADER_DEBUG=layer and the same SDK VK_LAYER_PATH. Both full logs contain Insert instance layer "VK_LAYER_KHRONOS_validation", neither reports a missing requested layer, and both contain zero VUID- errors. CTest JUnit XML reports the outcomes. This checks relocation and GPU compute readback, not geometry-stage rasterization.

Current manual overlap review against main bc84729655062c68fa58d41c19fadaa869cb7f2c inspected the original merge-base diffs of all four peers reported by the overlap bot. None changes the embedded-constant debt entry or implements back-half constant support. There is no dependency or required merge order; no author agreement is claimed.

PR Reviewed head Scope
#17742 1c3c2f0f90e2d2d5c5e03adf9f5fd2bc7a17d9ca Suspend validation and fused-size output order/alignment.
#19194 6d5410a5eb130d030d1b2a8f67abe8867467335d Index-buffer packet encoding.
#19196 3e06266b31c84b5c0deca07a3c9c812480f9aba4 CB semaphore fields/alignment.
#20294 8ce683e07d56fb87094bbb4d24f52b7dcda91d61 Flip/rendering waits for unopened outputs.

No Linux/macOS, console, title-boot, gameplay or performance result is claimed. Proprietary modules, captured title data and private reference harness artifacts are excluded from the PR. The local GPU results remain pinned to the baseline and contribution commits listed above; this is not geometry-stage rasterization validation.

Full build/test logs, JUnit XML, binary hashes and exact-head review data are retained locally. The debt change uses docs/dev/debt/changes/codex-agc-fusion-back-constants.md, as current contribution rules require. The fragment validator passes, folding it reproduces the previous PR debt text exactly, and it applies to current main without colliding with a pending fragment. All core/ implementation and test blobs are unchanged from the GPU-tested head 631cfd1132db440331bc39e34f8eb5edaf0de3b6; the documentation-only follow-up does not claim another GPU run. Current-main conventions and whitespace checks pass.

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 and the licence notice of code adapted from upstream (see AGENTS.md)
  • 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
  • Fixes: none
  • Unblocks: none
  • GPUs tested: Qualcomm Adreno X1-85, Qualcomm Vulkan ICD 31.0.152.1, Windows 11 ARM64 build 26200.9168 (main and change with Khronos validation 1.4.363)
  • AI-assisted: yes

@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

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.

Pull request Shared files not compared
PR 17742 core/libs/prx/libSceAgc/Misc/src/ShaderFusion.cpp

@github-actions github-actions Bot added docs agc libSceAgc* labels Nov 12, 2026
@relativespace2K

Copy link
Copy Markdown
Contributor

Windows/AMD validation: the extended fusion case passes on a desktop device.

  • AMD Radeon RX 6800 XT (gfx1030, subgroup 64), AMD proprietary driver 26.10.1, Windows 11 IoT Enterprise LTSC 26100, head 631cfd1132, Release, WinLibs GCC 15.2.
  • ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation.
  • agc_shader_fusion passes in 1.08 s, including the new back-half constant cases; no VUID- line and the layer loaded.

The PR's run is on a Qualcomm Adreno X1-85; this adds an AMD one.

@JJenkx

JJenkx commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

Windows check of head 631cfd1132. Setup: Windows 11 Enterprise 22621, AMD RX 6700 XT, AMD driver 26.10.1, MinGW-w64 GCC 15.2 UCRT, Release.

agc_shader_fusion:

  • GPU, through the shared Windows GPU FIFO with ANYPS5_REQUIRE_VULKAN=1, merged onto main a221a742da (merge cc998eeefd): passed in 3 of 3 runs. The binary matched the hash recorded at preparation, and the receipt shows exit 0 and app_count=0.
  • CPU, Vulkan hidden (merge a7a9233f7c): skipped (it needs a device), 0 failed.

AI-assisted: yes.

@domx4q

domx4q commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

NVIDIA Linux run with the Khronos validation layer of the current head 492bf418ed; the runs above are AMD on Windows.

Setup: Arch Linux (kernel 7.3.4), GCC 16.2.1, Release, NVIDIA GeForce RTX 4090 (vendor 0x10de, device 0x2684, Ada), proprietary driver 620.70.06, Vulkan 1.4.357, Khronos validation layer 1.4.363.1. Head 492bf418ed merged onto main e1ab104e0a with --no-ff (clean, as cb9e27a243). Main baseline is a Release build of e1ab104e0a on the same machine.

ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer \
ctest --test-dir build -R '^agc_shader_fusion' -V
main e1ab104e0a this PR
Result 1 of 1 passed 1 of 1 passed
Insert instance layer "VK_LAYER_KHRONOS_validation" 2 2
was not found but was requested by env var VK_INSTANCE_LAYERS 0 0
VUID- none none

agc_shader_fusion runs this PR's extended version on the PR side (the back-half constant case is not in main's test).

Negative control: this PR's test with Misc/src/ShaderFusion.cpp from main fails:

sceAgcGetFusedShaderSize_0080: fusing a back half with an embedded constant buffer is not implemented

No new VUID- errors; the focused test passes on Ada, and it fails without the ShaderFusion.cpp change.

AI-assisted: yes (Claude Code)

@oneandonlydean
oneandonlydean merged commit 0a2393f into boykopovar:main Nov 21, 2026
14 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* docs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants