Skip to content

perf(gpui_apple): cut the cost of a filtered layer on metal - #53

Merged
nolight132 merged 2 commits into
masterfrom
perf/layer-passes
Nov 16, 2026
Merged

nolight132 merged 2 commits into
masterfrom
perf/layer-passes

Conversation

@nolight132

Copy link
Copy Markdown
Member

Summary

  • wipe only the part of a layer target that is read back instead of clearing the whole window-sized texture
  • composite a closing layer as the first draw of the pass that resumes its parent
  • share a layer target with a neighbour only when the neighbour lands inside the wiped part
  • read each open layer only where it was wiped when flattening it for a backdrop

@github-actions github-actions Bot added macos changes the macOS backend rendering changes the scene, shaders or a renderer labels Nov 16, 2026
@coderabbitai

coderabbitai Bot commented Nov 16, 2026

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Summary

This change reduces Metal filtered-layer cost by wiping only each layer's read-back region and compositing closing layers in the parent's pass. It touches metal_renderer.rs and adds a clear_fragment shader to shaders.metal.

Layer targets are cleared only within expanded source bounds. Adjacent effects merge only when their wipe bounds are covered. Layer compositing uses an encoder that remains open for parent drawing. Backdrop composition samples each open layer only within the intersection of its wiped region and the requested clip.

Merge Risk: Minimal · up to 8781a

This change limits the layer-target clears and the backdrop sampling in the Metal renderer to the regions that are actually read, which should reduce the cost of filtered layers. No concrete problems were found, so merge risk is minimal.

Security architecture risk: Minimal · up to 8781a

The optimization does not expand access or privileges. Inspection found no material regression in security, ownership or failure containment.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The supported exposure is the current renderer's image content: its filter pool feeds the displayed frame or feature-gated image capture. The inspected path does not introduce a separate service, tenant or credential authority.

Trust Boundaries and Controls

  • inferred — The inspected consumers do not establish a path from unwiped texels to visible output. Backdrops restrict reads to the wipe; final composites clamp samples to source bounds; and Gaussian separation limits the consumed source footprint to one kernel radius per axis. Extra horizontal-pass fringe reads are not themselves evidence of disclosure. Nested writes outside a parent's wipe likewise do not establish disclosure without a consumer that reads them.

Resilience and Maintainability Implications

  • observed — Encoder ownership remains within one command-buffer flow. Both close paths end the child encoder before obtaining the parent encoder, the parent pass loads existing contents, and scoped clear/composite draws restore the full-target scissor before subsequent parent draws.

Warning

Some tools did not complete. Review the errors below.

Clippy (1.99.1)

Clippy execution timed out

@nolight132
nolight132 merged commit 17c64ae into master Nov 16, 2026
4 checks passed
nolight132 added a commit to sonorahq/sonora that referenced this pull request Nov 16, 2026
nolight132 added a commit to sonorahq/sonora that referenced this pull request Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

macos changes the macOS backend rendering changes the scene, shaders or a renderer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant