Skip to content

sync(upstream): integrate Batch 38 ADX lowering, macOS exports, clear-key hand-over, and BDA fault masking - #562

Merged
RINNECODER merged 1 commit into
mainfrom
sync/upstream-sync-batch-38
Oct 18, 2026
Merged

RINNECODER merged 1 commit into
mainfrom
sync/upstream-sync-batch-38

Conversation

@RINNECODER

@RINNECODER RINNECODER commented Oct 18, 2026 •

Copy link
Copy Markdown
Owner

Summary

Upstream Sync Batch 38, based on main 90b390fa1 (Batch 37 + the #561 capture-format fix): 14 upstream PRs, 65 files, +2470 / -101.

Integrated upstream PRs

Merged upstream:

PR What
boykopovar#5804 terminate a pixel invocation on a BDA fault when SPV_KHR_terminate_invocation is available
boykopovar#7123 end guest thread, fiber and context frame chains at a zero record
boykopovar#7175 support polygon primitive type 21
boykopovar#7288 share unchanged shader registry chunks between published versions
boykopovar#7296 bind an unnormalized S# normalized when it samples only null images
boykopovar#7448 unmap released direct memory views before freeing the physical range

Open upstream PRs, applicable now:

PR What
boykopovar#6416 keep faulting invocations in their wave and mask their later writes (base of boykopovar#7392)
boykopovar#7173 lower ADCX and ADOX for Rosetta
boykopovar#7361 preserve executable exports in macOS output
boykopovar#7381 sample a 3D T# through DIM 2D_ARRAY as a volume
boykopovar#7392 mask writes after barrier-safe BDA faults
boykopovar#7427 hand pending results over to an image whose DCC keys are a clear code
boykopovar#7429 model ds_ordered_count swap
boykopovar#7431 insert patched SRT reads before their use without appending first

Fork adaptations (Metal path, not upstream)

Findings

Severity Finding Resolution
P1 Codex: MetalDriver::replaceBorrowedRanges assigned (*registry)[address] while iterating *registry; ShaderRegistry::writable can replace or split a chunk, invalidating the range-for iterator (undefined behaviour during a partial shader invalidation). Fixed: collect the replacements, then apply the assignments and erases after the iteration.
P1 Codex: sceKernelCheckedReleaseDirectMemory checked DirectMemoryAllocated and then freed after unmapping views, so a concurrent release + allocate of the same span let the final free release another thread's allocation (TOCTOU). Fixed: the span is now claimed under the pool lock (PhysicalMemoryPool::Claim) before the views are unmapped, and released with ReleaseClaim. A release of a claimed span is refused, so the pages cannot be freed and reused in between.
P1 boykopovar#7377 (fix(shader): end a pixel shader's failed BDA reads through one exit) wraps the pixel body in a second function. The fork's minimum-LOD shadow-sampler bank is an argument-buffer member, and CompilerMSL::to_name only emits the qualified alias inside the default entry point, so the generated MSL referenced minimumLodSamplers undeclared. anyps5_metal_guest_draw_replay failed on Public pixel LOD mode=0 floor=384 with use of undeclared identifier 'minimumLodSamplers'. Dropped boykopovar#7377 from this batch. The pre-boykopovar#7377 pixel-fault path (terminate/kill at the fault site) is what the tests expect and passes. Revisit once the fork's minimum-LOD bank emission works from non-entry-point functions.
P2 The live-map reference captures/agc-live-map/replay-ref-v2.png (2026-10-15) no longer matches current main. Not a Batch 38 regression; see the replay note below. Needs a separate reference refresh.

Gates

Gate Command Result
Conventions tools/check_conventions.py --base main pass, 0 findings
Rosetta build cmake --build build-rosetta --parallel 6 exit 0
Rosetta tests ctest --test-dir build-rosetta 25/25 passed, 66.6 s
Metal build cmake --build build-metal --parallel 6 exit 0
Metal tests ctest --test-dir build-metal 63/63 passed, 65.6 s
Live-map replay anyps5_agc_replay cap-live-map --repeat 3 --expect-png .../replay-ref-v2.png --max-diff-pixels 200 no regression vs main (see note)

Replay note: the 2026-10-15 reference is stale. On main (934f20620 + the #561 capture fix) the last repeat is 14257 px off that reference; on this branch 14258 px; repeat-to-repeat noise is 69-82 px. This branch's last repeat is 80 px from main's dumped frame, inside the frame's 66-98 px inherent race noise. Batch 38 therefore does not change the live-map image; the reference should be refreshed separately.

No engine release is published; one is ready after this merge.

@coderabbitai

coderabbitai Bot commented Oct 18, 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: b7ec08ae-e5ce-43b1-a611-b3574f1f9790
  • 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 commented Oct 18, 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 ⚠️ Failed 2026-10-18T22:24:53.470010Z 2ba620b Manual request
ℹ️ 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.

@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: 95ae26e755

ℹ️ 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".

if (remaining.empty()) {
emptyAddresses.push_back(address);
} else if (remaining.size() != headers.size()) {
(*registry)[address] = std::move(remaining);

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 Defer registry replacements until after iteration

When a mapping change removes only some shader headers at an address, this assignment calls ShaderRegistry::writable, which replaces the current shared chunk while the range loop's iterator still points into the old chunk. The iterator increment then compares that old map iterator with the new chunk's end(), which is undefined behavior and can walk past the old chunk or crash during a partial shader invalidation. Collect these replacements alongside emptyAddresses and apply them only after the traversal.

Useful? React with 👍 / 👎.

Comment on lines +412 to +415
if (!DirectMemoryAllocated(start, len)) return SCE_KERNEL_ERROR_ENOENT;
const auto views = DirectMemoryViews(start, len);
if (!DirectMemoryCheckedFree(start, len)) return SCE_KERNEL_ERROR_ENOENT;
UnmapDirectMemoryViews(views);
if (!DirectMemoryCheckedFree(start, len)) return SCE_KERNEL_ERROR_ENOENT;

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 Keep checked release atomic across view unmapping

If guest threads concurrently release and allocate direct memory, this new precheck introduces a TOCTOU window: after DirectMemoryAllocated succeeds, another thread can free and reallocate the same pages while this thread gathers/unmaps views, and the final DirectMemoryCheckedFree will then see the newly allocated pages as used and free the other thread's allocation. The physical span must be claimed under the pool lock before unmapping, or otherwise protected from allocation until the final free.

Useful? React with 👍 / 👎.

@RINNECODER
RINNECODER force-pushed the sync/upstream-sync-batch-38 branch from 95ae26e to 2ba620b Compare October 18, 2026 22:02
@RINNECODER

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@RINNECODER

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@RINNECODER
RINNECODER merged commit 29684ad into main Oct 18, 2026
1 check passed
@RINNECODER
RINNECODER deleted the sync/upstream-sync-batch-38 branch October 18, 2026 22:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant