Repository navigation
Port upstream AGC driver shared slice (U5) - #475
Conversation
(cherry picked from commit 139bf04) Ported from upstream PR boykopovar#5481
…th COPY_DATA A dispatch now leaves its initiator and, for DISPATCH_DIRECT, its group counts in the shader registers, where the CP puts them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 5e36c08) Ported from upstream PR boykopovar#5477
(cherry picked from commit 632331d) Ported from upstream PR boykopovar#4341
(cherry picked from commit 85e0d98bba896002539365bb29a7a39a8e43f501) (cherry picked from commit 13dca48) Ported from upstream PR boykopovar#5347
(cherry picked from commit d4b59ce) Ported from upstream PR boykopovar#4715
(cherry picked from commit 7e1e1ce) Ported from upstream PR boykopovar#4779
Pointer-shaped NID kW3GLb7QfPg calls from public homebrew succeed on console; returning an error left those titles failing init after boykopovar#4835. (cherry picked from commit 939f784) Ported from upstream PR boykopovar#5163 (debt-doc hunk dropped: file absent on main)
(cherry picked from commit 0cc5102) Ported from upstream PR boykopovar#5163 (second commit)
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. |
|
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 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 32d01060a9
ℹ️ 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".
| void NoteDispatchRegisters(std::span<const std::uint32_t> packet, QueueState& queue) { | ||
| const bool direct = ((packet[0] >> 8u) & 0xffu) == 0x15u; | ||
| queue.shader.insert_or_assign(0x200, packet.back()); |
There was a problem hiding this comment.
Use dispatch-register tracking in the Metal executor
When the Metal backend is enabled, Execution/Metal/MetalPacketExecution.mm:828-836 handles direct and indirect dispatches without calling this new helper. A subsequent source-register COPY_DATA from COMPUTE_DISPATCH_INITIATOR or the direct group-count registers therefore reaches copyDataSource with those queue entries absent or stale and throws instead of copying the dispatched values; invoke NoteDispatchRegisters after both Metal dispatch paths as the shared executor now does.
Useful? React with 👍 / 👎.
| bool IsNullTextureResource(std::span<const std::uint32_t> words) { | ||
| Require(words.size() == 8, "guest texture descriptor must contain 8 dwords"); | ||
| const auto base40 = (static_cast<std::uint64_t>(words[0]) | (static_cast<std::uint64_t>(words[1]) << 32u)) & 0xffffffffffull; | ||
| const auto type = (words[3] >> 28u) & 0xfu; | ||
| return base40 == 0 || type == 0; |
There was a problem hiding this comment.
Reuse null-texture detection in the Metal backend
For Metal draws containing a type-0 texture descriptor with a nonzero base, Graphics/Metal/MetalSampler.hpp:30-31 still recognizes only zero-base descriptors as null. The Metal binding paths consequently pass this descriptor to DecodeTextureResource, which rejects image type 0, while the Vulkan/shared paths now leave it unbound; make NullImageDescriptor delegate to this shared predicate so the fix applies to Metal too.
Useful? React with 👍 / 👎.
| // A PM4 type-2 packet is a one-dword filler (command-buffer padding); type 3 and type 0 carry a | ||
| // dword count in bits 29:16. Type 1 is undefined. | ||
| inline bool FillerPacket(std::uint32_t header) { return (header >> 30u) == 2u || header == 0xffff1000u; } | ||
| inline bool PureNopPacket(std::uint32_t header) { return (header & 0xc000ffffu) == 0xc0001000u && header != 0xffff1000u; } |
There was a problem hiding this comment.
Skip pure NOPs in the Metal packet loop
On Metal, Execution/Metal/MetalPacketExecution.mm:739-745 still sends every counted NOP through Pm4::Validate and later Pm4::Execute instead of checking this predicate. Besides missing the intended fast path, a pure NOP whose ignored payload begins with 0x6875 still triggers the typed-user-data rejection in Validate, so command streams accepted by the shared executor can fail on Metal; apply PureNopPacket before Metal validation as well.
Useful? React with 👍 / 👎.
- skip pure PM4 NOP packets in the Metal packet loop (upstream PR boykopovar#5481) - note the dispatch registers after direct and indirect Metal dispatch so COPY_DATA from a shader register works there (upstream PR boykopovar#5477) - NullImageDescriptor delegates to IsNullTextureResource (upstream PR boykopovar#4779) - tests: pm4 compute replay reads the dispatch initiator and group counts back through COPY_DATA; metal utility tests cover a type-0 image descriptor Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DgW4n3qYgi5jAAohEmXRQj
Ports open upstream PRs (shared AGC driver slice) into the Metal/Rosetta fork. Each PR is its own commit with "Ported from upstream PR #N" in the body.
Ported
Pm4::PureNopPacket; Metal adaptation in the final commit: theMetalPacketExecution.mmpacket loop skips them before validation and locking)Pm4.cpp; Metal adaptation in the final commit:NoteDispatchRegistersafter direct and indirect dispatch inMetalPacketExecution.mm)QueueState.hpp; debt-doc conflict resolved, game name/title id dropped from the note)State.cpp)State.cpp; resolved against our layered-export decode, kept our test hunk and added the new test function; the Vulkan-device execution test comes along unchanged, it is not built on macOS; game name/title id dropped from the debt note)GuestTextureResource; Metal adaptation in the final commit:NullImageDescriptorinMetalSampler.hppnow delegates toIsNullTextureResource)sceAgcInitversions fall back to table 13 (both upstream commits; thedocs/dev/debt/libSceAgc.mdhunk is dropped, the file does not exist on main)Skipped
Driver/Shaders/ShaderRegistry.*and the Vulkan registration/preparation path. The Metal backend keeps no prepared-shader state (MetalHostExports.cppreturns a null preparation scope) and does not compile ShaderRegistry.cpp, so there is nothing to port; perf(agc): resolve static shader ABIs on the background pool boykopovar/AnyPS5#2589 and [HOLD] perf(agc): pre-warm deferred shaders on SET_SH_REG packet execution boykopovar/AnyPS5#5115 also conflict heavily with the Vulkan prebuild machinery.Driver/Lifecycle.cppis Vulkan-driver only and conflicts; Metal failure reporting is separate.DepthSurface/Dispatch(depends on unmerged fix(agc): copy a depth surface's plane through the texture's padded linear slices boykopovar/AnyPS5#4873/fix(agc): store a written storage image over a depth plane into the surface boykopovar/AnyPS5#5113) and Metal has no HTILE consumer. Conflicts in four files.Evidence
anyps5_metal_pm4_compute_replaysubmits a direct and an indirect dispatch through the Metal driver and reads the dispatch initiator and group count back with COPY_DATA from shader registers (fails on the previous head with "COPY_DATA source register 0x2e00 has no known value");metal_utility_testschecks thatNullImageDescriptortreats a type-0 descriptor with a nonzero base as null (fails without theMetalSampler.hppchange). The Metal NOP skip is a pure fast path: the same replay runs plain NOPs between state and dispatch as a regression guard, but no test can fail without it (capture-time validation already runs and a skipped NOP has no observable effect).-DANYPS5_METAL_SHADER_BRIDGE=ON -DANYPS5_METAL_GUEST_REPLAY=ON, with the bridge tests): ctest 36/36 pass, excluding the guianyps5_metal_presentation_replay.rosetta_libs rosetta_engine) compiles with no failures.tests/Pm4.cpp,tests/Graphics.cpp,tests/execution/*) are not built on macOS, so the upstream test hunks for these are carried but not run here.Refs upstream-batch-1 / upstream-pr-batch-1.
🤖 Generated with Claude Code
https://claude.ai/code/session_01DgW4n3qYgi5jAAohEmXRQj