Skip to content

feat(metal): sync upstream batch 18 and optimize scanout caching & shader bindings - #535

Merged
RINNECODER merged 4 commits into
mainfrom
sync/batch-18
Oct 17, 2026
Merged

RINNECODER merged 4 commits into
mainfrom
sync/batch-18

Conversation

@RINNECODER

Copy link
Copy Markdown
Owner

Summary

This PR merges Upstream Batch 18 and applies four targeted Metal performance optimizations for Apple Silicon / Civilization VII:

  1. Upstream Batch 18 Sync:
  2. Metal Presentation Scanout Texture Caching (MetalPresentation.mm):
    • Pool and reuse the scanout MTLTexture across frames via replaceRegion:withBytes:, eliminating 500 MB/s - 2 GB/s of transient VRAM allocation churn.
  3. Zero-Allocation Descriptor Binding Lookup (MetalShaderPipeline.mm):
    • Replaced node-allocating std::map with an inline stack-backed flat array lookup table in prepare(), eliminating ~30,000 heap allocations per frame at 60 FPS.
    • Pre-reserved PreparedBindings vectors (buffers, textures, samplers) up front.
  4. Parallel Render Command Encoder Push Constant Elision (MetalDraw.mm):
    • Added push constant state tracking to elide redundant setVertexBytes and setFragmentBytes across consecutive draws sharing identical push payloads.

thuanquang and others added 4 commits October 17, 2026 04:28
v_floor_f64, v_ceil_f64, v_fract_f64, v_frexp_mant_f64 and
v_frexp_exp_i32_f64 ignored the FLOAT_MODE f16/f64 denormal field. On
RDNA2 (gfx1031) bit 6 clear flushes a denormal input to a zero of its
sign, so v_ceil_f64 of 2^-1074 is 0 instead of 1, and bit 7 clear
flushes the denormal result v_fract_f64 gives for a positive denormal.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
v_add_f64 and v_mul_f64 ignored the FLOAT_MODE f16/f64 denormal field.
On RDNA2 (gfx1031) bit 6 clear flushes both inputs to a zero of their
sign, and bit 7 clear flushes a sum below 2^-1022 and a product whose
exact value rounded to 53 significant bits with an unbounded exponent
is below 2^-1022. The product test scales one source by 2^64 and
compares the host product with 2^-958.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

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-17T09:31:57.204169Z 5359d7a 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.

@RINNECODER
RINNECODER merged commit cfee4f1 into main Oct 17, 2026
@RINNECODER
RINNECODER deleted the sync/batch-18 branch October 17, 2026 09:32
@coderabbitai

coderabbitai Bot commented Oct 17, 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: 05c74b87-f99c-44ab-a470-695f83bb30e6
  • 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

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.

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.

3 participants