Repository navigation
fix(agc): leave a stage the title's pipeline ABI cannot prepare to its first use - #6366
Merged
adriadam10 merged 8 commits intoOct 19, 2026
Conversation
…s first use sceAgcDriverResolveShaderAbi and sceAgcDriverResolveGraphicsStagesAbi prepare every stage when the title creates its pipeline, and threw when the recompiler could not: Resident Evil Village stops there on a pixel shader whose T# pointer is a phi of user data and a ballot, and a compute shader that calls user-data pointers stopped the same way although its dispatch links the callees. ResolveShaderAbi and PrepareGraphicsStages now catch the failure inside their own preparation transaction, so the ShaderPreparationScope that libSceAgc opens around the call still commits. The shader is logged once, marked deferred like a shader deferred at registration, and the ABI key is recorded, so a repeated call prepares nothing. The draw or dispatch that uses the stage prepares it as before and fails there if it cannot. ResolvePreparedGraphics skips the rectangles of a deferred stage that has no artifact yet, which also lets a stage deferred at registration through sceAgcDriverResolveGraphicsAbi. Driver failures, ProcessShutdown and a failure stored by the shader's registration preparation still propagate.
… prepare Four prepared-shader modes, run with the recompiler's failure memo off so a second preparation would show as a second front-end build: - compute: a shader that calls user-data pointers is resolved twice and prepared once, then its dispatch links the callees and every lane holds 3 * (5 + 64); a shader whose registration preparation failed still throws its stored failure from the ABI call. - pixel: a waterfall whose T# pointer is a phi of user data and a ballot is logged once with its reason, resolved again without a second preparation, and resolved for another state inside a ShaderPreparationScope that commits. A draw of it fails at use with the same reason, and the ABI call then throws the driver's failure. - stages: the same chain in a vertex shader that registration leaves alone, through ResolveShaderAbi inside a scope and through ResolveGraphicsStagesAbi. - rectangle: sceAgcDriverResolveGraphicsAbi with a pixel shader deferred at registration and with one deferred at its ABI call.
This was referenced Oct 15, 2026
Merged
…s not decode A fifth ABI deferral mode, abi_deferred_undecodable_state. A vertex shader whose specials route it through geometry (VGT_SHADER_STAGES_EN 0x2030), which registration leaves alone, is resolved through ResolveGraphicsStagesAbi with the context and primitive registers that sceAgcCreatePrimState passes for it. DecodeShaderStages refuses its VGT_GS_OUT_PRIM_TYPE of 1. The call must not throw and must log the stage once with the decode's reason, and a second call must neither prepare nor log it again. A draw that routes the stage through the vertex path then prepares it at its first use without reporting it as missing a registration artifact.
EagleBearerYS
added a commit
to EagleBearerYS/AnyPS5
that referenced
this pull request
Oct 15, 2026
…e ABI state deferral
…first use A failure stored by a shader's background registration preparation was rethrown by every pipeline ABI call that touched the stage. The ShaderPreparationScope that sceAgcLinkShaders, sceAgcCreatePrimState and sceAgcCreateInterpolantMapping open settled the stages and threw first, and ResolveShaderAbi, ResolveGraphicsStagesAbi and ResolveGraphicsAbi threw it again from their reads of the stage. A title that creates its pipelines ahead of drawing ended there, although the draw or dispatch that uses the stage rethrows the same stored failure. Settling a scope no longer rethrows. Each ABI call logs such a stage once with its stored reason, marks it deferred and prepares the other stages of the call as before. ResolveGraphicsStagesAbi keeps its ABI record on the first stage that did not fail, PrepareGraphicsStages skips a failed program, and ResolvePreparedGraphics records no rectangle for a failed stage and never adds a failed fragment to a front stage, where the rectangle draw of another fragment would meet it. The compute mode no longer expects the stored failure from the ABI call. A new mode registers a compute, a pixel and a vertex shader whose registration preparation fails, resolves them through every ABI entry point inside a scope twice, and expects three deferrals with the stored reason the first time and none the second, then the stored reason from the compute shader's dispatch.
…e to its first use PrepareGraphicsStages decodes each front-end stage's vertex inputs from its AGC header before it prepares the stage, outside the catch that defers a stage the recompiler cannot prepare. A header the decode refuses, such as a semantic with a statically bound vertex buffer, threw out of sceAgcDriverResolveGraphicsStagesAbi and ended a title that creates its pipelines ahead of drawing. Registration leaves such a stage alone when it is an NGG vertex shader that uses its workgroup, or a mesh, hull or domain stage, so the pipeline ABI is the first to decode it. A decode failure now defers the stage the same way a preparation failure does. The draw that uses it decodes the same header with the draw's own user data and fails there with the same reason. A new mode registers an NGG vertex shader with vertex buffer and attribute tables and one statically bound semantic, resolves its pipeline ABI twice inside a scope, and expects one deferral with the decode's reason and no front-end build, then the same reason from its first draw.
…eir first draw sceAgcLinkShaders resolves the rect-list pairing of a pipeline when the title creates it, and three cases ended the title there although the rect-list draw that uses the pipeline builds its pair itself: - a pipeline without a pixel shader reached ResolveGraphicsAbi with a null pixel, which required both stages, although the draw pairs the front stage with the null pixel program; - a stage with no artifact yet, such as a pixel shader that exports stencil on a device without VK_EXT_shader_stencil_export, failed the missing stage artifacts check; - a pair that BuildRectListShaders refuses, such as a pixel input with passthrough interpolation, threw from the builder. The ABI now skips the first two, and logs the third once as a deferral of the pixel shader without recording the pair, so the pair's draw builds it again and fails with the builder's reason. When a draw builds the rectangles of its front stage, only the pair of its own fragment can fail it; the pair of another fragment that has no artifact or that the builder refuses is left to that fragment's draw. A new mode resolves a front stage with a null pixel, with a pixel before it has an artifact, with a pixel that never gets one and with the first pixel's passthrough variant, and expects one deferral with the builder's reason. It then draws the front stage as a rect list with the null pixel program, which succeeds although the other two pairs cannot be built, and with the passthrough pixel, which fails with the builder's reason.
This was referenced Oct 16, 2026
12 tasks done
Brings boykopovar#5872 (shader preparation on first use), main's async driver log and its geometry subgroup checks. The prepared-shader modes are the union of both lists. With this branch, the pipeline ABI of a lazily registered shader it cannot prepare leaves the stage deferred instead of throwing, so LazyRegistration now requires the stage to stay deferred with no prepared entry after that call; its dispatch and shutdown failure checks are unchanged. StderrCapture flushes the async log when it starts and before it reads, since a deferral's log line can otherwise still be queued. The undecodable-state check now matches the decode's VGT_SHADER_STAGES_EN reason rather than one message, which main's subgroup output check now gives first.
12 tasks done
EagleBearerYS
added a commit
to EagleBearerYS/AnyPS5
that referenced
this pull request
Oct 17, 2026
11 tasks done
11 tasks done
Contributor
|
Windows cross-test on clean main324e0e48e found six of the new ABI-deferral modes aborting during logger initialization: the test's inline FlushAsyncLog call instantiates its own PE-local AsyncLog, then the driver attempts to register a different end-flush callback. All six reproduce without our 007 stack. Small two-file fix in #7709 moves the existing flush helper into the driver translation unit; unchanged fixtures, 29/29 prepared/logger/shutdown tests pass on88c8320e3. The same fix on our refreshed 007 stack passes114/114 focused native checks. No title/FPS claim. AI-assisted: Codex. |
This was referenced Oct 19, 2026
Closed
TheBlenDed
pushed a commit
to TheBlenDed/AnyPS5
that referenced
this pull request
Oct 25, 2026
…refusals Upstream's abi_deferred_* modes (boykopovar#6366) expect a draw of a deferred pixel shader that its static ABI cannot prepare to fail the queue (agc_driver_prepared_shaders_abi_deferred_pixel: "expected preparation failure"). Our e7fe39a skips such a draw by default and reports it; APS5_STRICT_SHADER_REFUSALS=1 restores the failure. The abi_deferred tests now set that switch, which selects the behaviour they check. AI-assisted: yes
TheBlenDed
pushed a commit
to TheBlenDed/AnyPS5
that referenced
this pull request
Oct 25, 2026
Our b18d883 test expected a domain program the recompiler refuses to fail ResolveGraphicsStagesAbi unless APS5_SKIP_REFUSED_SHADERS is set. Upstream boykopovar#6366 (in the merge) resolves the graphics stage ABI with deferUnprepared: an unpreparable stage is logged and prepared when it is used, and the call returns ("the refused domain program did not stop ABI resolution: it was prepared"). Without the switch the test now requires that deferral and idles the driver as with it. AI-assisted: yes
Pipodi
pushed a commit
to Pipodi/AnyPS5
that referenced
this pull request
Nov 14, 2026
…refusals Upstream's abi_deferred_* modes (boykopovar#6366) expect a draw of a deferred pixel shader that its static ABI cannot prepare to fail the queue (agc_driver_prepared_shaders_abi_deferred_pixel: "expected preparation failure"). Our e7fe39a skips such a draw by default and reports it; APS5_STRICT_SHADER_REFUSALS=1 restores the failure. The abi_deferred tests now set that switch, which selects the behaviour they check. AI-assisted: yes
Pipodi
pushed a commit
to Pipodi/AnyPS5
that referenced
this pull request
Nov 14, 2026
Our b18d883 test expected a domain program the recompiler refuses to fail ResolveGraphicsStagesAbi unless APS5_SKIP_REFUSED_SHADERS is set. Upstream boykopovar#6366 (in the merge) resolves the graphics stage ABI with deferUnprepared: an unpreparable stage is logged and prepared when it is used, and the call returns ("the refused domain program did not stop ABI resolution: it was prepared"). Without the switch the test now requires that deferral and idles the driver as with it. AI-assisted: yes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
When a title creates a pipeline,
sceAgcDriverResolveShaderAbi,sceAgcDriverResolveGraphicsStagesAbiandsceAgcDriverResolveGraphicsAbiprepare its stages. If the recompiler could not prepare a stage there, the call threw and the title stopped at pipeline creation. Two cases on main:GetImageResource dword 0 is not a valid runtime value).Such a stage is now left to its first use, like a stage registration cannot prepare:
ResolveShaderAbiandPrepareGraphicsStagescatch the failure inside their own preparation transaction. TheShaderPreparationScopethat libSceAgc opens around the call (sceAgcLinkShaders,sceAgcCreateInterpolantMapping,sceAgcCreatePrimState) still commits. A catch at the entry point would leave that scope aborted.ResolvePreparedGraphicsskips the rectangles of a deferred stage that has no artifact yet. This also letssceAgcDriverResolveGraphicsAbithrough for a stage deferred at registration, which threw "rectangle ABI has missing stage artifacts".The draw or dispatch that uses the stage prepares it as before, and fails there if it cannot. Resident Evil Village's pixel shader would still fail at a draw: the resource plan depends only on the code and the stage interface, so the draw builds the same plan.
Driver failures and
ProcessShutdownstill propagate.docs/dev/ARCHITECTURE.mdgets a line.A pipeline ABI whose state does not decode also leaves its stages to their first use (6bd8647). On our own test tree, which carries this PR and other open PRs (not
main), Resident Evil Village (PPSA01556) aborted 11 minutes into its save load, before control, withAGC graphics: VGT_SHADER_STAGES_EN=0x2030: unsupported geometry input or output assembly.sceAgcDriverResolveGraphicsStagesAbidecodes the stage routing and programs from the stages' registered state and the call's context and primitive registers before it prepares anything, andDecodeShaderStagesrefused that combined state outside the preparation this PR already guards. A refused decode now defers every stage of the call like a stage whose preparation fails: each is logged once with the decode's reason and prepared by the draw that uses it, which decodes its own state; a repeated call prepares and logs nothing. With this commit added (and one fix elsewhere that doesn't touch this path), the tree loaded that save to control with no driver failure and held control for about 8 minutes (Windows 11, RTX 3070 Laptop GPU, driver 617.42). That run prepares shaders lazily (#5872'sAPS5_LAZY_SHADER_PREPARE=1), which marks every stage deferred at registration, so the deferral itself logs nothing there.A completeness review of every path of the pipeline call found three more cases that could end a title before the stage's first use. No title has hit them yet.
A stage whose registration preparation failed is left to its first use too (19a3e07). The scope libSceAgc opens around a pipeline call (
sceAgcLinkShaders,sceAgcCreatePrimState,sceAgcCreateInterpolantMapping) no longer rethrows a failure the background registration preparation stored. The ABI calls log such a stage once with the stored reason and prepare the call's other stages, and the stage's first draw or dispatch rethrows the same exception. This replaces this PR's earlier choice that stored registration failures propagate at the pipeline call: that call cannot know whether the title will use the pipeline, and the abort now happens where the stage is used, with the same message.Vertex inputs and rect-list pairs (502085c, e986ee0). A stage whose vertex inputs the decode refuses at the pipeline call (NGG vertex shaders that use their workgroup, and mesh, hull and domain stages, which registration does not decode) is left to its first draw, which decodes the same header. A rect-list pair the pipeline call cannot build (no pixel shader, a pixel with no artifact, or one the rect-list builder refuses) is left to its draw, and a draw now builds only its own fragment's pair, so another fragment's refusal no longer fails an unrelated draw. Rect-list pairs are still built per pixel shader, not per variant: when a pixel's passthrough pair is refused, the rect-list draw of its normal variant fails with that reason. The pipeline call's abort hid that case before.
Overlap: #5872 (shader preparation on first use) is on
mainnow, and this branch mergesmainwith it. The prepared-shader modes are the union of both lists. With #5872's lazy mode on, every snapshot starts deferred, so this line doesn't print for such a stage, and the draw reports the failure as before. #5872'sLazyRegistrationcheck now requires that the pipeline ABI of a lazily registered shader it cannot prepare leaves the stage deferred with no prepared entry, where it used to throw; its dispatch and shutdown failure checks are unchanged. The merge also makes the tests' stderr capture flushmain's async driver log before reading it, and has the undecodable-state check match the decode'sVGT_SHADER_STAGES_EN=0x2030:reason, whichmain's geometry subgroup check now gives first.#6612 (tessellation followed by an NGG geometry stage) and #6639 (point lists with their point size) change the lines of
PrepareGraphicsStagesthat 19a3e07 and 502085c reorder, where the push offset now comes first and the vertex-input decode sits in atry. Whichever merges second keeps that order and puts #6612'swave = Graphics::StageWaveSize(...)and #6639'sGraphics::ApplyPointSize(decoded.state, *vertex)into theif (vertex)block after thetry.Related: #5884 (AnthonyClemens) draws line-strip output of NGG geometry programs as mesh lines, one of the states
VGT_SHADER_STAGES_EN=0x2030: unsupported geometry input or output assemblyrefuses, and merges cleanly with this PR. With it, such stages decode at the pipeline call and are prepared there instead of at first use. JJenkx's Cocoon (PPSA08766) report (#6651) passes that refusal at startup with #5884.Tested
Resident Evil Village (PPSA01556), Windows 11, NVIDIA GeForce RTX 3070 Laptop GPU (driver 617.42), on main 6ea62f9, before and with this branch's two commits (the same commits; the head is only rebased onto 71bd287). Both arms ran with the same env,
APS5_NO_GPL=1, which skips Vulkan graphics pipeline libraries and saves about 2.5 GB of host memory during Resident Evil Village's pipeline creation on this 16 GB machine. The title was relinked with main's relinker.shader 0x207e84c500 stage 5: ShaderRecompiler::Recompile: GetImageResource dword 0 is not a valid runtime value; chain: …, thenFATAL: abort()at pipeline creation, 5 min 48 s in.Shader 0x207e85cf00 could not be prepared when the title created its pipeline (shader 0x207e85cf00 stage 5: ShaderRecompiler::Recompile: GetImageResource dword 0 is not a valid runtime value; …); preparing it when it is used, once. Resident Evil Village then runs on to main's next stop at the intro video,mprotect of uncommitted memory outside the guest arena(fix(libkernel): commit a reserved host stack before protecting it #5703 fixes it). No other runtime-value line.the depth target's sample count differs from the rasterizer's; a separate fix for that is coming.Linux, GitHub runner with Mesa lavapipe, head 695ec6c on main 71bd287:
^agc: 601 tests, 0 failures.Windows:
s_swappc_b64 … is not statically resolvable;GetImageResource dword 0 is not a valid runtime valuefor the pixel and the vertex stage;rectangle ABI has missing stage artifacts). With them, all four pass 5 runs in a row.^agcpasses 594 of 595. The four new tests skip there (no Vulkan device).agc_driver_pm4_replay_toolfails the same way with main's sources in the same run (the tool exits 0xc0000139 on the runner).The undecodable-state follow-up (6bd8647, 661d3cb), Linux, GitHub runner with Mesa lavapipe (run): with
ShaderRegistry.cppreverted to 695ec6c's,agc_driver_prepared_shaders_abi_deferred_undecodable_statefails in all 3 runs withAGC graphics: VGT_SHADER_STAGES_EN=0x2030: unsupported geometry input or output assembly, and the other 12 prepared-shader modes pass. With it, all 13 pass 10 runs in a row. On the Windows runner the 13 skip (no Vulkan device). On a Linux cloud worker (Ubuntu 24.04, GCC 13.3, lavapipe) the whole^agcsweep passes, 561 tests there.The completeness follow-ups (19a3e07, 502085c, e986ee0), Linux, GitHub runner with Mesa lavapipe (run): with
ShaderRegistry.cppreverted to 661d3cb's, the three new modes (registration_failure,vertex_inputs,rectangle_pairs) fail in all 3 runs and the other prepared-shader modes andagc_driver_prepared_publicationpass. With it, all 17 pass 10 runs in a row. On the Windows runner they skip (no Vulkan device). On a Linux cloud worker, with these three and one more commit not in this PR, the whole^agcsweep passes (606 tests there) and CI's test-registration check passes.Eight new
agc_driver_prepared_shaders_abi_deferred_*modes. Each is red with the fix reverted:ResolveShaderAbithrows "s_swappc_b64 call target … is not statically resolvable"ShaderPreparationScopecommits; the draw fails at use with the same reason, and the next ABI call throws the stored driver failureResolveGraphicsStagesAbithrow the same reason for a vertex shaderResolveGraphicsStagesAbithrows "VGT_SHADER_STAGES_EN=0x2030: unsupported geometry input or output assembly" for a geometry-routed vertex shader, with the registerssceAgcCreatePrimStatepassesResolveGraphicsStagesAbithrows "statically bound vertex attributes are not implemented"Cost: I timed the success path of each entry point on main and on this branch (on a08de68): 5 and 6 interleaved runs, 7 × 20,000 resolved-key calls and 7 × 100 new keys each.
The merge of
main82ddae7 (with #5872, the async driver log and the geometry subgroup check), on GitHub's runners (run): the 19 prepared-shader modes and the async-log tests pass 5 runs in a row on Linux and Windows (the GPU modes skip on Windows). The run's other failures are libc'sprecise_waiton Linux, a timing test;guest_kqueueon Windows, which fails onmainthere; andguest_shader_linkon Windows, which timed out once in five. Onmain82ddae7 alone it times out the same way, on the ninth run after 8 passes (run).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)