Repository navigation
Port libSceAgcDriver imports and remaining libSceAgc rows to the Metal bridge - #373
Conversation
Ports upstream boykopovar/AnyPS5 open PRs into core/libs/prx (libs and their tests only; docs excluded): - boykopovar#2847 DCB/ACB marker span builders - boykopovar#2848 occlusion query size queries - boykopovar#2849 submit validation reported as unavailable - boykopovar#2850 disabled shader instrumentation accepted - boykopovar#2851 GPU capture reported as unavailable, shader debugging status - boykopovar#1060 sceAgcAcquireMemSetEngine Conflicts between the PRs (Unimplemented.cpp stubs and shared test files) were resolved by keeping every change from both sides. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… Metal bridge Binds the 35 libSceAgcDriver imports and 17 libSceAgc imports through SceAgcImports without dereferencing guest pointers on the host: - Driver leaf exports (resource registration, capture, submit validation, equeue queries) run the upstream bodies through prx bridge descriptors (upstream-prx/AgcDriver.cpp); the 7-argument registrations read user data from the caller stack. - ACB flip and rendering wait emit the Metal driver packets, as the DCB rows do. - Marker spans, occlusion sizes, shader instrumentation, AcquireMemSetEngine and branch _0300 patchers reuse upstream encoders on host copies. - GetRegisterDefaults2(+Internal) publish the upstream tables in a guest window above the gate table; Create/UpdatePrimState run on host copies of the stage type and special registers. New CTest anyps5_cpu_agc_driver_leaf is in NATIVE_REQUIRED_TESTS. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configuration
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5b5c519447
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| auto cx = registers<2>(guest, cxAt, false); | ||
| auto uc = registers<3>(guest, ucAt, false); | ||
| HostStage hs, gs; | ||
| const auto* hsShader = hs.Load(guest, arg(guest, 2)); |
There was a problem hiding this comment.
Skip shader reads when no primitive outputs are requested
When both cxAt and ucAt are null, upstream sceAgcCreatePrimState returns success before inspecting either shader, but this unconditional hs.Load still reads and validates the guest HS pointer. Consequently, a no-output call with an arbitrary non-null shader pointer faults in the bridge instead of preserving upstream's successful no-op behavior; return early before loading either shader when both output pointers are null.
Useful? React with 👍 / 👎.
Summary
Ports the 35 libSceAgcDriver imports and 17 of the 39 remaining libSceAgc imports the test title needs (52 rows). Every row resolves through
SceAgcImportsunder the target admissions; no guest pointer is dereferenced on the host.core/cpu/src/upstream-prx/AgcDriver.cpp,Marshal.hppslot kinds) that compile the upstream bodies: integer outputs are copied in and written back,KernelEventis copied from the guest, and pointers upstream discards are never read.RegisterResource/RegisterGdsResourcetake a seventh (stack) argument, so they get a hand thunk built from the same slots.SceAgcImportsowns the graphics scope, so it looks these rows up in the descriptor table (newUpstreamDrivercontract) instead of the generic bridge. None of these rows touches upstream's Vulkan driver. Submission, queues, labels and flips stay on the Metal path.AgcDriver::FlipPacketHeader/RenderingWaitPacketHeader) into the compute command buffer, the same encoding as the DCB rows. The Metal submission path reserves flips and checks the video-output registry for any queue.lengthbytes are copied from the guest, without reading past them), occlusion query sizes, shader instrumentation,AcquireMemSetEngine, andBranchPatchSet{Then,Else}Target_0300.GetRegisterDefaults2andGetRegisterDefaults2Internalstill call upstream to validate the version. Upstream returns host pointers, so the guest instead gets one stable copy of the same upstream tables per (version, internal) pair. That copy lives in a mapped window 4 MiB above the AGC gate table (core/cpu/agc/AgcRegisterDefaults.cpp, built from upstreamRegisterDefaultsData.hpp).CreatePrimStateandUpdatePrimStaterun upstream on host copies of the stagetypeand special registers. Every other Shader pointer is cleared, which is safe because the stage ABI resolver does nothing on Metal. The register pairs are written back only on success.Upstream sources
Synced main:
core/libs/prx/libSceAgcDriver/{Resource,State,Eq}andUnimplemented.cpp;core/libs/prx/libSceAgc/{Misc/src/RegisterDefaults.cpp, Shader/src/PrimState.cpp, Patch/src/Branch.cpp}.Open upstream PRs applied for functions that main still stubs (libs and their tests, no docs; commit 1):
AcquireMemSetEngine)Where these PRs conflicted, every change from both sides was kept.
Skipped (22)
dbOlWdppb4o,vieBRwlh1Lw,LtTouSCZjHM,zARR5aCmkoY.GetDefaultCxStateFlat,SetAmmSemaphoreMemory,DebugRaiseException,GetGsPrimPayload,CbMemsetExclusive,DcbSetIndexIndirectArgs(andGetSize),GetSemaphoreLabel, Dcb/AcbSetWorkloadsActive/SetWorkloadComplete/SetWorkloadStreamInactive(6),AcbAtomicGds_0900. The packet encodings are unknown, so these were not invented.GetFusedShaderSize_0080andFuseShaderHalves_0200need a deep copy of both halves (code, registers, semantics, user-data sharp tables). The fused result holds pointers into the scratch memory, its layout is aligned from the scratch address, and the front code's GPU address is encoded into registers, so every pointer would need relocating back to guest addresses.GetGsOversubscriptiontakes afloatin xmm0, andMachineexposes no vector registers.Evidence
anyps5_cpu_agc_driver_leafwas written first and failed withUnsupported SCE AGC service: 5CdQTZIQPxM. It now passes, including underMTL_DEBUG_LAYER=1 MTL_SHADER_VALIDATION=1 ANYPS5_NO_SHADER_CACHE=1 APS5_NO_SHADER_CACHE=1. It checks that:TargetAgcAdmissions()and are rejected in the other library scope;KernelEvent;NATIVE_REQUIRED_TESTSafteranyps5_cpu_agc_target_events, andpython3 -m unittest tools.tests.test_native_diagnostic_workflowpasses (8 tests).Smoke (test title, native runner,
--max-wall-ms 300000)sceKernelLoadStartModule(libkernel)sceKernelLoadStartModule(libkernel), unchanged🤖 Generated with Claude Code