Skip to content

Port upstream AGC driver shared slice (U5) - #475

Merged
RINNECODER merged 10 commits into
mainfrom
upr1/agc-driver-shared
Oct 13, 2026
Merged

RINNECODER merged 10 commits into
mainfrom
upr1/agc-driver-shared

Conversation

@RINNECODER

@RINNECODER RINNECODER commented Oct 13, 2026 •

Copy link
Copy Markdown
Owner

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

Skipped

Evidence

  • Metal tests added in the final commit: anyps5_metal_pm4_compute_replay submits 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_tests checks that NullImageDescriptor treats a type-0 descriptor with a nonzero base as null (fails without the MetalSampler.hpp change). 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).
  • Metal bridge + guest replay build (arm64, -DANYPS5_METAL_SHADER_BRIDGE=ON -DANYPS5_METAL_GUEST_REPLAY=ON, with the bridge tests): ctest 36/36 pass, excluding the gui anyps5_metal_presentation_replay.
  • Rosetta x86_64 build (rosetta_libs rosetta_engine) compiles with no failures.
  • The Vulkan-device test targets (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.
  • One game smoke (240 s wall, eboot lock, plugged in, read-only private image clone) on the final head: guest entry at ~0.5 s, ran to the wall with no fault, no shader conversion failures, no skipped draws or dispatches, 0 disk-cache load failures. It stayed in the intro movie, as main does within this window, so no 3D map and no fps figure.

Refs upstream-batch-1 / upstream-pr-batch-1.

🤖 Generated with Claude Code

https://claude.ai/code/session_01DgW4n3qYgi5jAAohEmXRQj

Kikoarl and others added 8 commits October 13, 2026 17:15
…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 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)
@RINNECODER RINNECODER added the upstream-sync Upstream boykopovar/AnyPS5 intake label Oct 13, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-13T23:15:03.212151Z 32d0106 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: dff0945a-33d2-42ff-9d99-d2a150bb076f
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +843 to +845
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());

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Comment on lines +53 to +57
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;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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; }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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
@RINNECODER
RINNECODER merged commit 5b7c5a5 into main Oct 13, 2026
5 checks passed
@RINNECODER
RINNECODER deleted the upr1/agc-driver-shared branch October 13, 2026 23:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc docs upstream-sync Upstream boykopovar/AnyPS5 intake

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants