Rune comes from app/vendor/rune now, a checkout of 63ad0209 on branch ported, carrying the four commits of upstream issues 1320 (a pause while a clip is layered holds the layer's picture and time) and 1325 (a video's sound is read ahead of the clock and leads it). Both were written against eb9f1104 and ported across the refactors since. The faults are the first two and the third in docs/rune-upstream.md; the app's workarounds in review.rs stay until the fixes arrive upstream.
48 KiB
04 — Language, GPU API, 2D Renderer Design & Input-to-Photon Latency
1. Executive Summary
Rune’s foundational bet is Rust + a thin custom GPU HAL (~1,800 LOC per native backend) over raw Metal (macOS/iOS) and wgpu (Linux/Windows/WebGPU), paired with a hybrid Core Animation compositor host (NSGlassEffectView/UIVisualEffectView + CAMetalLayer) and an uber-primitive instanced SDF + Sparse-Strips/Slug renderer.
- Language — Rust (with thin Swift/ObjC2 platform shims and Dioxus
subsecondhot-patching): Rust remains the only systems language in 2026 that simultaneously gives zero-GC deterministic frame times, production-grade text/layout/accessibility crates (taffy,parley,harfrust,fontations,swash,accesskit), fearless multi-threaded background work, and top-tier LLM/agent synthesis reliability (compiler diagnostics + strict type/borrow checking catch hallucinations before runtime). Its historical weakness—1–3 s incremental UI iteration—is solved in 2025–2026 by ThinLink + jump-table binary hot-patching (subsecond) (<200–500 ms stateful UI patches) plus-Zthreads=8,-Zshare-generics=y, andmold/wild/Appleld_prime. - GPU API — Custom Thin HAL (
RuneGpu) with First-Class Raw Metal on Apple +wgpu28+ Elsewhere: Neither purewgpueverywhere nor four hand-written native backends is optimal. On macOS/iOS, raw Metal (objc2-metal) combined with a shallowCALayerhost tree is mandatory for zero-copyIOSurfacevideo/camera surfaces,NSGlassEffectViewliquid glass backdrops,CATransaction-synchronized window resizing (presentsWithTransaction), programmable tile/framebuffer fetch, and EDR headroom. On Linux, Windows, and Web, Zed’s February 2026 migration fromblade-graphicstowgpu(zed#46758, cutting median CPU draw time from 301 µs to 236 µs) proveswgpuis now fast enough and eliminates thousands of lines of Vulkan/D3D12 driver-quirk maintenance while giving WebGPU for free. - 2D Renderer — Single-Pass Uber-SDF Primitives + Public-Domain
Slug(Large/Transformed Text & Icons) +vello_gpuSparse Strips (Complex Vector Art):- 95% of UI (rounded boxes, per-corner radii, elliptical inner borders, analytic 4-sample
erfGaussian drop/inner shadows, bevel/specular surface materials, Oklab gradients with Jimenez IGN triangular dithering, and analytic 4-edge soft-clip masks) renders in a single instanced uber-shader pass with zero geometry tessellation and zero intermediate passes. - Text uses a dual-path pipeline: crisp hinted grayscale/subpixel raster atlas (
R8Unorm/RGBA8Unorm) for body/code text (≤ 32 pxaxis-aligned), switching seamlessly to Eric Lengyel’s Slug algorithm (dedicated to the public domain in March 2026, EricLengyel/Slug, and already proven in Makepad’sdraw_text.rs) for zoomable canvas text, large headings, rotated/sheared labels, and monochrome vector icons. - Arbitrary vector paths (charts, complex SVGs, strokes) use Linebender’s 2026
vello_gpuSparse Strips pipeline (4×4 pixel blocks after SIMD CPU flattening) rather than heavyweight full-GPU computevelloor CPU triangle tessellation (lyon).
- 95% of UI (rounded boxes, per-corner radii, elliptical inner borders, analytic 4-sample
- Latency — Event-Driven Unthrottled Input Fast-Path +
CADisplayLinkAnimation Pacing (< 6 ms p50 on 120 Hz ProMotion): Waiting for a display link callback before processing input or acquiring a drawable adds 16–49 ms of pipeline lead (measured at 41.5 ms / 5 refreshes in windowedCAMetalDisplayLinkon 120 Hz macOS). Rune decouples discrete input fromCADisplayLink: keystrokes, clicks, and trackpad scrolls immediately wake the UI thread, update state, encode a <0.4 ms Metal pass into amaximumDrawableCount = 2ring, and present on the very next scanout (~4–8 ms input-to-photon on 120 Hz ProMotion), engagingCADisplayLink(preferredFrameRateRange) only while springs or timeline animations are in flight.
2. Detailed Findings by Topic
Topic 1: Programming Language Evaluation (2026 Landscape)
Comparative Matrix
| Dimension | Rust (2024 Ed. / 1.86+) | Swift 6.3 / 6.4 | Zig 0.15 / 0.16-dev | C++23 / C++26 | Odin / Jai / Mojo |
|---|---|---|---|---|---|
| Runtime Perf & Tail Latency | A+ (No GC, no pervasive ARC atomic traffic, SIMD via wide/std::simd) |
B+ (ARC retain/release traffic & existential boxing unless carefully annotated) | A+ (Manual allocators, @Vector SIMD, zero hidden control flow) |
A+ (Zero-cost abstractions, mature intrinsics) | A (Odin/Jai manual memory; Mojo focused on AI kernels) |
| Platform Reach (macOS, iOS, Win, Linux, Android, Web) | A+ (Tier-1 native everywhere + wasm32-unknown-unknown <1 MB) |
B (macOS/iOS A+; Android SDK added in 6.3; Wasm 6.2+ still bulky; Linux/Win GUI immature) | A (Cross-compiles everywhere; mobile/Web bindings require manual C glue) | A (Everywhere via CMake/Emscripten, painful packaging) | C (Odin/Jai weak on iOS/Android/Web; Mojo has no GUI targets) |
| UI Ecosystem (Text, Layout, A11y) | A+ (taffy, parley, harfrust, fontations, swash, accesskit, kurbo) |
C (Apple-only CoreText/NSAccessibility; zero cross-platform equivalents) |
C (Wraps C libraries: harfbuzz, freetype, stb_truetype; no accesskit) |
A- (HarfBuzz, Skia, DirectWrite, Yoga, ICU — heavy C++ deps) |
D (Must bind C libraries from scratch) |
| Incremental Compile Speed | B (0.8–2.5 s cold-ish crate rebuild; <0.4 s with subsecond ThinLink) |
B- (Swift Build 6.4 fast for small modules, slow on heavy generics/macros) | A+ on Linux x86_64 (<150 ms via Elf2); C+ on macOS arm64 (Mach-O incremental WIP) |
C (Header/module bloat; 2–10 s incremental link) | A+ (Odin ~0.3 s; Jai <0.2 s full builds) |
| Hot-Reload Friendliness | A- (subsecond jump-table binary patching + dylib state preservation) |
A- (@_dynamicReplacement + Mach-O -bundle_loader, ~100–300 ms on macOS) |
B+ (Clean C ABI dlopen state reload) |
B (Live++ on Windows; fragile dlopen on macOS) |
A (Odin/Jai trivial DLL reload) |
| Agent-Writability (LLM Synthesis) | A+ (Exhaustive rustc/Clippy errors guide autonomous self-repair; huge corpus) |
B+ (Swift 6 strict concurrency region errors frequently trip LLMs) | C+ (0.14→0.15→0.16 stdlib/build.zig churn causes stale LLM syntax) | B (Template SFINAE errors and UB escape compiler checks) | D (Small training corpus; Jai closed beta) |
| Memory & Thread Safety | A+ (Send/Sync compile-time race freedom; unsafe quarantined to FFI) |
A (Swift 6 data-race safety + ARC, but Reference Cycles leak) | C (Spatial checks in Debug, manual lifetime/thread discipline) | D (Use-after-free, iterator invalidation, data races) | C (Manual memory management) |
Deep Dive on the Contenders
-
Rust’s Compile-Time & Hot-Reload Reality in 2026:
- Compiler & Linker Gains: The 2025 Rust Compiler Performance Survey identified single-crate incremental rebuilds and
cargo check/cargo buildcache splitting as top pain points. In 2026, enabling the parallel frontend (-Zthreads=8),-Zshare-generics=y,-Cdebuginfo=line-tables-only, and fast linkers (ld_primeon macOS,moldor incrementalwildon Linux) cuts workspace incremental rebuilds by 30–45%. - Cranelift (
rustc_codegen_cranelift): Per the February 2026 Rust Project Goal, on a 16-core machine building Zed incrementally, Cranelift is currently 12% faster than LLVM with-Cdebug-info=line-tables-only(and 10–15% faster across therustcbenchmark suite), with an active 2026 roadmap for an in-memory machine-code caching daemon targeting a 2× backend speedup. - Subsecond (
subsecond0.7) Binary Hot-Patching: Built by Dioxus (docs.rs/subsecond/0.7.10),subsecondintroduces ThinLinking (automatic dynamic linking of workspace dependencies + object-file diffing + runtime jump tables). When a developer or agent edits a UI view function, only the modified functions are recompiled into a tiny patch object and redirected via jump tables without restarting the process or losing app state, shrinking Rust incremental UI iteration to < 500 ms (typically 150–350 ms for leaf view edits). - Architecture Discipline for Compile Times: GPUI’s slow compile times in Zed come primarily from monomorphizing massive view trees (
Div::child(impl IntoElement)) and putting 100k+ LOC inside single monolithic crates. Keeping Rune’s element tree type-erased at container boundaries (SmallVec<[AnyElement; 4]>) and splitting widget crates cleanly keeps standard incrementalcargo buildunder 1.2 s even without hot-patching.
- Compiler & Linker Gains: The 2025 Rust Compiler Performance Survey identified single-crate incremental rebuilds and
-
Zig (0.15 / 0.16-dev in 2026):
- Ghostty proved Zig + Metal + AppKit/SwiftUI (
libghostty) can ship a wonderful macOS/Linux terminal. - Why Zig loses for Rune: First, Zig’s flagship incremental compilation (
-fincremental+ in-place binary patching) works onx86_64-linux(Elf2), but onaarch64-macos(our primary target) the self-hostedaarch64backend and Mach-O incremental in-place linker remain incomplete in 2026 (ziglang/zig#21165). Second, Zig would force Rune to abandon the entire pure-Rust Linebender/AccessKit stack (taffy,parley,harfrust,fontations,accesskit) and revert to C FFI overHarfBuzz/FreeTypeplus writing a cross-platform accessibility tree from scratch. Third, LLMs routinely hallucinate Zigbuild.zigandstd.IoAPIs due to breaking changes between 0.13, 0.14, 0.15, and 0.16.
- Ghostty proved Zig + Metal + AppKit/SwiftUI (
-
Swift (Swift 6.3 / 6.4 in 2026):
- Swift has made real cross-platform strides: Swift 6.3 shipped an official Android SDK, Swift 6.4 defaulted to the unified
Swift Buildengine, andJavaScriptKitoptimized Wasm bridges. Kit’s ownhot-reload-kitdemonstrates 100–300 ms hot-reloading on macOS via@_dynamicReplacementand-bundle_loader. - Why Swift loses as core language (but wins as Apple host glue): Outside Apple platforms, Swift has no cross-platform GUI/text/accessibility ecosystem; Wasm binaries carry heavy runtime weight unless restricted to Embedded Swift; and pervasive ARC reference counting across dense retained/immediate UI trees introduces atomic retain/release traffic and accidental closure reference cycles. However, using ~500 lines of Swift/Objective-C via
objc2for macOS/iOS system integration (e.g.,NSGlassEffectView, menu bars,RPSystemBroadcastPickerView, share sheets, as done inlauncher/native/LauncherView.swift) is effortless and strongly recommended.
- Swift has made real cross-platform strides: Swift 6.3 shipped an official Android SDK, Swift 6.4 defaulted to the unified
-
C++23/26, Odin, Jai, Mojo:
- C++ lacks memory safety, suffers from header/build fragmentation, and makes fearless multi-threaded UI state scheduling hazardous.
- Odin and Jai compile fast and excel at standalone games, but have near-zero accessibility, international text shaping, or mobile/web platform infrastructure, and tiny LLM training corpora.
- Mojo is specialized for heterogeneous AI/tensor compute and has no desktop/mobile windowing or UI ecosystem.
Topic 2: GPU API & Compositor Integration
The Contenders Analyzed
-
Raw Metal (
objc2-metal) on macOS & iOS:- Evidence from GPUI, Scrawl, and Makepad:
- GPUI’s original macOS renderer (
kitlangton/gpui/src/platform/mac/metal_renderer.rs:1-850) is 850 lines of Rust. - Kit’s production recording pill renderer in Scrawl (
scrawl/src/native/pill/mod.rs:1-420+pill.metal:1-369) is ~790 lines total, directly driving a 3-pass separable Gaussian blur + SDF capsule pipeline on aCAMetalLayerover anNSGlassEffectView. - Makepad’s direct Metal backend (
makepad/platform/src/os/apple/metal.rs:1-1100) gives directIOSurfacecross-process texture sharing and exactMTLCommandBufferGPU start/end timestamps (GPUStartTime/GPUEndTime, lines 318–326).
- GPUI’s original macOS renderer (
- Capabilities
wgpuhides or complicates on Apple:- Programmable Framebuffer Fetch / Tile Memory (
[[color(0)]],[[imageblock_data]],[[raster_order_group(0)]]): Apple Silicon is a Tile-Based Deferred Renderer (TBDR). Rive’s Metal shaders (rive-runtime/renderer/src/shaders/metal.glsl:301-450) read and write 4 pixel-local planes (colorBuffer,clipBuffer,scratchColorBuffer,coverageCountBuffer) directly in on-chip tile SRAM ([[color(IDX)]]) at zero system memory bandwidth cost.wgpudoes not expose multi-plane tile memory / programmable blending on Metal. - Zero-Copy Video & Camera (
CVMetalTextureCache/IOSurface): GPUI’ssurface_fragment(shaders.metal:874-890) samples bi-planarY(R8Unorm) andCbCr(RG8Unorm)IOSurfaceplanes directly fromCVPixelBufferhardware decoders without CPU/GPU copies. - Live Resize Synchronization (
presentsWithTransaction): Both GPUI (zed/crates/gpui_macos/src/window.rs:3202,3328) and Scrawl (scrawl/src/native/pill/mod.rs:403-417) togglelayer.setPresentsWithTransaction(true)insideCATransactionduring window resize/frame changes so Metal content never lags behind the window border. - Precompiled
.metallibInstant Startup:xcrun metalcompiles.metalatbuild.rstime into a binary.metallib.newLibraryWithDataloads in < 0.5 ms at startup, versus 15–60 ms for runtime WGSL→Naga→MSL string translation +newLibraryWithSource.
- Programmable Framebuffer Fetch / Tile Memory (
- Evidence from GPUI, Scrawl, and Makepad:
-
wgpu(v28+ in 2026) vsblade-graphics:- Historically,
wgpuhad heavy state-tracking and validation overhead, prompting Zed to adopt Kvark’s lighterblade-graphicsfor Linux/Windows. - Crucial 2026 Update: In February 2026, Zed merged PR #46758 ("Migrate from blade-graphics to wgpu") (
zed/crates/gpui_wgpu/src/wgpu_renderer.rs). Benchmarks in that PR showedwgpureduced median CPU draw time from 301.29 µs to 235.67 µs (-21.8%) compared toblade-graphics, while addingwgpu::Features::DUAL_SOURCE_BLENDINGfor subpixel text AA (wgpu_renderer.rs:781-795), pipeline disk caching (PipelineCache), Vulkan/Wayland stability fixes, and a WebGPU/WebGL2 target. - Tradeoffs:
wgpu+nagaadds ~2.5–3.8 MB to stripped binary size and translates WGSL to backend shaders. That is an unacceptable tax on Apple-specific capabilities if used as the only backend on macOS/iOS, but an overwhelming win for Linux (Vulkan), Windows (D3D12/Vulkan), Android, and Web (WebGPU).
- Historically,
-
SDL3
SDL_gpu, GoogleDawn, and FlutterImpeller:SDL_gpu(shipped in SDL 3.2+): Clean C API, ~400 KB binary footprint, good for games, but lackswgpu’s Rust safety, storage buffer ergonomics, dual-source blending portable setup, and WebGPU browser integration.- Dawn: Powers Chromium’s WebGPU; C++ build (CMake/GN +
tint+spirv-tools) adds 8–15 MB to binaries and heavy C++ build times. - Flutter Impeller: Proves the value of 100% AOT-compiled shaders (
impellerc) to eliminate runtime PSO compilation hitching—a lesson Rune must steal via build-time.metallib/ SPIR-V / DXIL / WGSL validation.
-
Hybrid Core Animation (
CALayerTree + Custom Metal) vs Pure Single-Drawable:- How macOS/iOS actually works: The WindowServer compositor is already a hardware-accelerated
CALayertree evaluator with direct display-controller scanout planes. - What
CALayerdoes better than custom shaders:- System Materials & Liquid Glass (
NSGlassEffectView/NSVisualEffectView): Private WindowServer backdrop filters blur and refract windows behind the app at zero app-GPU cost. Both Zed (gpui_macos/src/window.rs:301,3810) and Scrawl (scrawl/src/native/pill/mod.rs:348-380) place anNSVisualEffectView/NSGlassEffectViewbehind a transparentCAMetalLayer. - Out-of-process HDR Video & WebViews (
AVSampleBufferDisplayLayer,WKWebView): Composited directly by WindowServer hardware planes without waking the UI render pass.
- System Materials & Liquid Glass (
- What
CALayerdoes poorly (Avoid 1-Layer-Per-Widget): Allocating hundreds ofCALayers for normal buttons/rows causes Core Animation IPC serialization overhead, layout-to-GPU desynchronization, and breaks cross-platform behavior. - The Sweet Spot ("Shallow Compositor Host"): 1 root
NSGlassEffectView/NSVisualEffectView+ 1 primaryCAMetalLayerfor all 2D UI + optional sibling nativeCALayers only for hardware video/camera/WebView cutouts.
- How macOS/iOS actually works: The WindowServer compositor is already a hardware-accelerated
Topic 3: 2D UI Renderer Design
3.1 Instanced SDF Primitives & Analytic Surface Shading
- GPUI’s Baseline (
kitlangton/gpui/src/platform/mac/shaders.metal:102-545):- Draws
Shadow,Quad, andUnderlineas instanced 4-vertex unit quads reading per-instance structs from storage/constant buffers ([[buffer(QuadInputIndex_Quads)]]). quad_fragmentevaluates an exact outer rounded-box SDF (quad_sdf_impl, line 1065) and an inner border SDF (quarter_ellipse_sdf, line 440) that handles non-uniform border widths (top != left), plus perimeter-parameterized dashed borders (dash_alpha, line 421).- Limitation in GPUI: Because
Shadow,Quad, andBorderare separate primitive batches inscene.rs(zed/crates/gpui/src/scene.rs:88-115), a button with a drop shadow, background fill, inner highlight, and border emits multiple draw instances or requires batch-breaking z-order sorts.
- Draws
- Makepad’s Analytic
MaterialBreakthrough (makepad/draw/src/shader/surface.rs:27-165):- Evaluates bevel profile & normal (
m_normal), wrapped Lambert diffuse + Blinn-Phong specular (m_lit), edge ambient occlusion (m_ao), rim lighting (m_rim), sky-box gloss (m_gloss), and 4-sampleerfGaussian inner/outer shadow (box_cov) purely as a function of the signed distancedinside a single fragment pass!
- Evaluates bevel profile & normal (
- Analytic Drop & Inner Shadows:
- Both GPUI (
shaders.metal:525-542,1087-1104) and Makepad (sdf.rs:10-76) use Evan Wallace’s separable formulation: exact closed-form 1D Gaussian integral along X via a polynomialerf()approximation (blur_along_x), integrated across Y with a 4-step midpoint quadrature clamped to[-3σ, +3σ]. - Crucial detail to steal from GPUI (
shaders.metal:541,1170-1177): 8-bitBGRA8Unormframebuffers visibly band in the[0.0, 0.02]alpha tail of soft shadows and Oklab gradients. GPUI adds Jimenez Interleaved Gradient Noise (IGN) with a 2-tap triangular PDF (±1/255amplitude) modulated bysmoothstep(0.0, 0.02, alpha) * smoothstep(1.0, 0.98, alpha), completely eliminating shadow and gradient mach banding at 3 ALU instructions per pixel.
- Both GPUI (
- Rune’s Uber-Primitive Upgrade:
- Combine Rounded/Squircle (G2 continuous
L^psuperellipse option) Box + Border + Inner Shadow/Bevel/Rim + Outer Shadow into a single 128-byteUberQuadinstance struct so an entire styled card renders in 1 instance with 1 SDF evaluation.
- Combine Rounded/Squircle (G2 continuous
3.2 Vector Paths & Curves: The 2026 Showdown
| Technique | Representative Engine | How It Works | CPU Cost | GPU Cost & Memory | Verdict for Rune |
|---|---|---|---|---|---|
| CPU Triangle Tessellation | lyon, Iced fallback, GPUI legacy |
Ear-clipping / sweep-line on CPU → indexed triangles | High (0.5–4 ms for complex paths; poor for animated morphs) | Low fragment, high vertex count, requires 4× MSAA | Avoid (CPU bottleneck on dynamic vector UI) |
| Loop-Blinn + 4× MSAA Intermediate | GPUI (shaders.metal:737-838) |
CPU triangulates hull; fragment shader solves u^2 - v into full-viewport 4× MSAA texture, then blits |
Medium (CPU earcut hull) | High (allocates full-window 4× MSAA texture + resolve + blit pass) | Avoid (Massive memory & bandwidth waste for small icons) |
| Full Compute Pipeline | vello (classic compute) |
9+ compute stages (pathtag, bbox, flatten, bin, tile, backdrop, coarse, fine) | Very Low | High baseline (~0.4–0.8 ms dispatch overhead even for 1 path; complex shaders) | Avoid (Linebender moved it to research/ in 2026) |
| Sparse Strips (Hybrid CPU+GPU) | vello_gpu / vello_hybrid (vello/ARCHITECTURE.md) |
SIMD CPU flattening + tiling into 4×4 pixel alpha strips; simple instanced GPU raster pass | Low (~50–200 µs via NEON/AVX) | Very Low (Simple vertex/fragment shader, zero compute dispatch overhead) | Steal for general vector art / charts / complex SVGs |
| Direct GPU Quadratic Bézier Winding | Slug (EricLengyel/Slug, makepad/.../draw_text.rs:42-350) |
Curves stored once in curve_texture + horizontal/vertical band_texture; fragment shader raycasts exact roots |
Zero per frame (static em-space upload once per glyph/icon) | Low (Exact analytical AA at any scale/rotation/perspective; zero atlas invalidation) | Steal for large/transformed text & vector icons! |
| PLS / Atomic Analytical Coverage | Rive (draw_raster_order_path.frag) |
Cubic tessellation in vertex shader + exact winding accumulation in tile memory ([[color(n)]]) |
Low | Ultra-fast for 10,000-path animations; requires tile-memory/ROV shader variants | Optional plugin for embedded .riv files |
- Why the March 2026 Slug Public-Domain Dedication Changes Everything:
- On March 17, 2026, Eric Lengyel dedicated US Patent
#10,373,352(Slug GPU Bézier rendering) to the public domain (github.com/EricLengyel/Slug). - Makepad immediately integrated Slug in
makepad/draw/src/text/slug_atlas.rs:1-200anddraw_text.rs:41-350. - In Slug, a glyph or SVG icon’s quadratic Bézier curves (cubics split once via
CUBIC_TO_QUAD_TOLERANCE = 0.05) are uploaded once in em-space into an append-onlyRGBA32F/RGBA16Fcurve_textureand indexed into horizontal and vertical spatial bands (band_texture). The vertex shader dilates the bounding quad by 0.5 px in screen space (slug_dilate), and the fragment shader scans only the curves intersecting the pixel’s horizontal/vertical band (scan_horizontal_list,scan_vertical_list), using Lengyel’s bit-shift root eligibility code(u32(11892) >> shift) & u32(257)(draw_text.rs:237) to avoid numerical edge dropouts. - Result: Infinite zoom, rotation, 3D perspective, and scale animations on text and UI icons with zero CPU re-rasterization and zero glyph-atlas thrashing.
- On March 17, 2026, Eric Lengyel dedicated US Patent
3.3 Text Rendering: Hybrid Raster Atlas + Slug
- Why not Slug for all text? At body sizes (
11–18 pxon 2× Retina =22–36device px), anR8Unormtexture sample costs 1 texture fetch (~2 GPU cycles) and preserves platform-specific stem darkening / optical hinting (CoreTexton macOS,DirectWriteon Windows,fontations+swashautohinting on Linux). Slug requires 4–10 texel fetches + quadratic root math per pixel. - Subpixel vs Grayscale AA on Retina (2026):
- On macOS, Apple removed subpixel LCD layout from CoreGraphics in Mojave, and all modern Macs/iPhones ship ≥2× Retina panels (many OLED or mini-LED with non-RGB-stripe subpixel layouts on iPad Pro M4 / iPhone). However, CoreText still applies font smoothing / stem darkening (
CGContextSetAllowsFontSmoothing). - As proven in
scrawl/src/native/pill/atlas.rs:133-201, rasterizing glyphs with CoreText into anR8Unormshelf-packed atlas (with 2×2 subpixel bin positioning for fractional X offsets) uses 4× less VRAM thanRGBA8and blends in a single pass. - For Windows/Linux 1× external monitors,
wgpu::Features::DUAL_SOURCE_BLENDING(as implemented inzed/crates/gpui_wgpu/src/wgpu_renderer.rs:781-795) enables proper per-channel RGB subpixel alpha blending in a single draw call.
- On macOS, Apple removed subpixel LCD layout from CoreGraphics in Mojave, and all modern Macs/iPhones ship ≥2× Retina panels (many OLED or mini-LED with non-RGB-stripe subpixel layouts on iPad Pro M4 / iPhone). However, CoreText still applies font smoothing / stem darkening (
- Rune’s Hybrid Text Rule:
- Axis-aligned text
≤ 32 ptwith static scale: Shelf-packedR8Unorm(macOS/iOS Retina) orRGBA8dual-source subpixel (1× Windows/Linux) glyph atlas, keyed by(FontId, GlyphId, FontSizeFixed, SubpixelBinX). - Text
> 32 pt, any rotated/skewed/3D-transformed text, or text undergoing continuous zoom/scale animation: Rendered directly via Slug (SlugAtlas), eliminating the infamous "blurry scaled atlas" or "100 MB atlas eviction storm during pinch-to-zoom".
- Axis-aligned text
3.4 Blur, Backdrop Filters & Peak-Alpha Legibility
- Window-Level Backdrop Blur (Zero App GPU Cost): Delegated to
NSGlassEffectView(macOS 26+) /NSVisualEffectView(macOS 14–15) /UIVisualEffectView(iOS) /DwmEnableBlurBehindWindow/Mica(Windows). - In-App Element Backdrop Blur (
backdrop-filter: blur()):- Dual Kawase Pyramid for large radii (
σ > 6 px): Downsample 2× per pass (4-tap bilinear offset(±1, ±1)) forNlevels (typically 2–3 levels down to 1/4 or 1/8 resolution), then upsample 2× per pass (8-tap tent filter) restricted strictly to the dirty/clipped bounding rect of the blurring element. At 1/4 resolution, blurring a 400×300 popover takes < 60 µs on Apple M-series GPUs. - Separable 1D Gaussian + Peak-Alpha Boost for animated morphs & small blurs (
σ ≤ 6 px): Steal directly from Kit’sscrawl/src/native/pill/pill.metal:208-360. When blurring UI elements (like morphing pill labels or crossfading icons), standard Gaussian blur reduces peak alpha and makes text look washed out. Scrawl’scomposite_fragment(pill.metal:326-349) computesboost = 1.0 + smoothstep(0.0, 0.35, b) * 2.5andpow(a, 1.0 / boost), keeping blurred text crisp and luminous throughout the transition.
- Dual Kawase Pyramid for large radii (
3.5 Cheap Soft-Edge Gradient Masks at Every Clip Edge
- The Problem: Traditional UI engines clip scroll views and containers using either hardware
glScissor/setScissorRect(hard pixel edge, axis-aligned only), hardware[[clip_distance]]planes (GPUIshaders.metal:56,80, hard edge), or an offscreen mask texture (expensive render pass switch). When content scrolls under a header or a pill morphs width, hard clips look abrupt; developers want a 6–16 px soft alpha fade at the top/bottom/left/right clip edge without allocating an offscreen layer. - The Zero-Pass Solution (Analytic Soft-Clip Mask + Room Gating):
- Per-Fragment Analytic Rounded-Clip & 4-Edge Feather: Every draw instance carries a
clip_index: u32indexing into a compactClipStackBufferon the GPU. EachClipNode(32 bytes) stores:bounds: float4(origin.xy, size.zw)corner_radii: float4(tl, tr, br, bl)edge_feather: half4(top, right, bottom, leftfeather distances in scaled pixels;0.0= crisp 1px antialiased SDF clip;> 0.0= smooth gradient mask fade overedge_featherpx!). In the fragment shader, evaluating the clip costs ~8 ALU instructions:
// Signed distance to the rounded clip rect (negative inside, positive outside) float clip_sdf = quad_sdf(frag_pos, clip.bounds, clip.corner_radii); float hard_aa = saturate(0.5 - clip_sdf); // Directional 4-edge soft gradient fade inside the clip rect float4 dist_to_edges = float4( frag_pos.y - clip.bounds.origin.y, // top (clip.bounds.origin.x + clip.bounds.size.x) - frag_pos.x, // right (clip.bounds.origin.y + clip.bounds.size.y) - frag_pos.y, // bottom frag_pos.x - clip.bounds.origin.x // left ); float4 edge_alpha = saturate(dist_to_edges / max(float4(clip.edge_feather), float4(1e-4))); // Hermite smoothstep across each feathered edge edge_alpha = edge_alpha * edge_alpha * (3.0 - 2.0 * edge_alpha); float clip_mask = hard_aa * edge_alpha.x * edge_alpha.y * edge_alpha.z * edge_alpha.w; color *= clip_mask; // Premultiplied alpha modulation - Per-Element SDF Room Gating (Steal from
scrawl/src/native/pill/model.rs:146-184): When an item sits inside a morphing container (e.g., a pill or collapsing sidebar), evaluatingbox_clearance(the container’s analytic SDF clearance around the child’s bounding box) on the CPU or vertex shader produces a continuouspresence = smoothstep((room + feather) / feather)multiplier that drives both opacity and subtle scale/blur before the child ever touches the border. - Result: Every scroll view, overflow container, rounded card, and morphing pill gets arbitrary rounded-corner clipping and independent top/right/bottom/left soft gradient fade masks with zero offscreen textures, zero stencil buffers, and zero render-pass breaks.
- Per-Fragment Analytic Rounded-Clip & 4-Edge Feather: Every draw instance carries a
3.6 Layers, Offscreen Caching & Group Opacity
- When Offscreen Passes Are Needed: Only for (a) true group opacity (
0.0 < opacity < 1.0on a container with overlapping children, where per-element alpha would show internal seams), (b) container-widebackdrop-filter/filter: blur(), or (c) explicitly cached complex subtrees (will_change/cache_layer). - Tile-Local Group Opacity Shortcut on Apple Silicon: When a group with
opacity < 1.0fits within a single pass and does not require blur, Metal programmable blending ([[color(0)]]scratch plane in tile memory, like Rive’sscratchColorBufferindraw_raster_order_path.frag:10) can composite the group in on-chip tile memory and blend it onto the main color plane without ever allocating or bandwidth-flushing an offscreen texture! - Transient Texture Pool: For effects that do cross pixel neighborhoods (blur), maintain a power-of-two / bucketed
MTLTexture/wgpu::Texturepool with frame-age eviction (evict after 120 idle frames).
3.7 Damage Tracking, Partial Present & 120 Hz Power Cost
- The 120 Hz Power Reality:
- Running a full-window 4K/5K Metal render pass at 120 Hz consumes 4–9 W of package power even if only a 2×18 px text cursor is blinking.
- At complete rest (zero dirty views, zero active springs), Rune must draw 0 frames/sec (0% CPU, 0% GPU).
- Partial Present & Damage Tracking on Metal vs D3D12/Vulkan:
- Metal’s
CAMetalLayerdoes not expose an equivalent toEGL_KHR_swap_buffers_with_damageorIDXGISwapChain1::Present1(DirtyRects)—when you present aCAMetalDrawable, WindowServer treats the drawable as a full surface, and becausenextDrawablecycles through a ring of 2–3 buffers (maximumDrawableCount), rendering only a dirty scissor rect directly intonextDrawable()leaves stale content from 2–3 frames ago outside the scissor rect! - How to Make Damage Tracking Actually Work on Metal:
- Persistent Backing Texture + Scissored Dirty Render: Render the UI scene into a single persistent
MTLTexture(StorageModePrivate,BGRA8Unorm/RGBA16Float) usingMTLLoadActionLoadandsetScissorRect(dirty_bbox)so Apple Silicon’s TBDR GPU only shades tiles overlappingdirty_bbox. Then encode a single hardware blit (MTLBlitCommandEncoder::copyFromTexture) or scissored copy into theCAMetalDrawable. On Apple Silicon unified memory, a tile-aligned blit of a 5K buffer takes ~80 µs while saving 95%+ of fragment shader execution on partial updates (like typing or cursor blink). - ProMotion Dynamic Frame Rate Scaling (
preferredFrameRateRange): UseCADisplayLink’sCAFrameRateRangeMake(min, max, preferred)(Apple ProMotion Docs):- Interactive scroll, drag, or fast spring velocity:
CAFrameRateRangeMake(80, 120, 120)(8.33 ms). - Settling spring tail (
velocity < threshold) or subtle spinner/pulse:CAFrameRateRangeMake(30, 60, 60)or24–48 Hz. - Cursor blink / static timer: Display link paused, scheduled via timer only on blink transitions.
- Interactive scroll, drag, or fast spring velocity:
- Persistent Backing Texture + Scissored Dirty Render: Render the UI scene into a single persistent
- Metal’s
3.8 Wide Color (Display P3), EDR/HDR, Linear Blending & Dithering
- Color Pipeline:
- Authoring colors in sRGB, Display P3, or Oklab / Oklch (perceptually uniform lightness/chroma).
- Gradients interpolate in Oklab (like GPUI
shaders.metal:950-988,1225) or linear Display P3, with Jimenez IGN triangular dithering (±1/255). - Surface Format: Default
MTLPixelFormatBGRA8UnormwithCGColorSpaceCreateWithName(kCGColorSpaceDisplayP3)on wide-gamut displays (50% less memory bandwidth thanRGBA16Float), upgrading dynamically toMTLPixelFormatRGBA16FloatwithwantsExtendedDynamicRangeContent = YESonly when an HDR/EDR surface or specular HDR highlight (> 1.0 headroom) is mounted in the scene.
Topic 4: Input-to-Photon Latency Architecture
4.1 Real-World Latency Measurements (macOS & iOS, 2025–2026)
| System / Benchmark | Display Rate | Measured Input-to-Photon (p50 / p99) | Architectural Cause |
|---|---|---|---|
| Hardware + OS Compositor Floor (Windowed macOS ProMotion) | 120 Hz (8.33 ms) | ~4.2–8.5 ms | USB/SPI keyboard scan (~1 ms) + AppKit event delivery (~0.5 ms) + GPU render (<0.5 ms) + WindowServer next scanout (0–8.33 ms) |
Blackbird Terminal (vtebench-2026-04-20.md) |
120 Hz ProMotion | p50 ≤ 6 ms, p99 ≤ 20 ms (CI-gated) | Direct event-triggered render without waiting for display-link lead |
Alacritty 0.17 (komsit37/ghostty-input-latency, Jul 2026) |
60 Hz (16.67 ms) | p50 17.9 ms (~4 ms above 14 ms capture floor) | Immediate redraw on PTY/key event; maximumDrawableCount = 2 |
Ghostty 1.3.2 (komsit37/ghostty-input-latency, Jul 2026) |
60 Hz (16.67 ms) | p50 58.6 ms (~40 ms slower than Alacritty) | Queued frame scheduling / multi-refresh display-link pipeline lead |
CAMetalDisplayLink Windowed (rrva/metal-display-link-pacing, 2026) |
60 Hz / 120 Hz | 66.5 ms (60 Hz) / 41.5 ms (120 Hz) callback → screen | Windowed CAMetalDisplayLink targets 3 refreshes (49.8 ms at 60 Hz) or 5 refreshes (41.5 ms at 120 Hz) ahead of its callback! |
Zed (gpui_macos) |
120 Hz ProMotion | ~12–20 ms | CVDisplayLink io-thread → GCD DispatchSource → main thread step() (display_link.rs:122-160), adds 1 refresh vs direct input draw |
4.2 Why CAMetalDisplayLink and CVDisplayLink Add Latency if Misused
- The
CAMetalDisplayLinkTrap: Apple introducedCAMetalDisplayLinkin macOS 14 / iOS 17 withpreferredFrameLatency(accepting only1.0or2.0). However, Apple’s documentation notes: "The final latency may be bigger if the system needs more time, such as for windowed modes on macOS." Independent 2026 empirical measurements (rrva/metal-display-link-pacing) prove that in windowed mode on macOS,CAMetalDisplayLinkschedules its callback 5 refreshes (41.5 ms) ahead of scanout on 120 Hz panels and 3 refreshes (49.8 ms) ahead on 60 Hz panels. That guarantees smooth 120 fps throughput for heavy 3D games, but adds 33–50 ms of input lag to a UI framework if input waits forCAMetalDisplayLinkUpdate! - The
CVDisplayLinkTrap: As documented in Zed’szed/crates/gpui_macos/src/display_link.rs:1-52,CVDisplayLinkruns on a separate high-priority CoreVideo I/O thread, has broken teardown semantics (CVDisplayLinkStopraces with in-flight callbacks, causing segfaults inCVHWTime::reset), lackspreferredFrameRateRangefor ProMotion power saving, and requires cross-thread signaling (dispatch_source_merge_data) to wake the main runloop.
4.3 Rune’s Zero-Wait Input-to-Photon Pipeline (< 6 ms p50 on 120 Hz)
To achieve sub-frame (~4–6 ms p50) input-to-photon latency while maintaining butter-smooth 120 Hz animations:
- Two Distinct Frame Triggers (Input-Immediate vs DisplayLink-Paced):
- Path A — Discrete Input Fast-Path (KeyDown, MouseDown, Trackpad Scroll phase, Direct Manipulation): When
NSEvent/UIEventarrives on the main runloop and no frame has been presented in the current VSync interval (now - last_present_time > 0.75 * refresh_period), do not wait for the nextCADisplayLinktick. Coalesce any pending events currently in the runloop queue, run incremental layout/paint (< 0.4 ms), acquirelayer.nextDrawable(), encode andcommit()immediately. Because a UI render pass takes ~0.2–0.4 ms on Apple Silicon, the drawable finishes rendering well before the compositor’s next VSync deadline and scans out on the immediately upcoming refresh (0–8.33 ms away, p50 ~4.8 ms). - Path B — Continuous Animation Pacing (
CADisplayLinkon MainNSRunLoop): When springs, physics scroll momentum, or shaders are actively animating,CADisplayLink(macOS 14+ / iOS) drives frame ticks onNSRunLoopCommonModesusingtargetTimestampto step analytical springs (model.rsexact closed-formspring(duration, bounce)) to the exact display presentation time, eliminating dt-jitter.
- Path A — Discrete Input Fast-Path (KeyDown, MouseDown, Trackpad Scroll phase, Direct Manipulation): When
- Double Buffering (
maximumDrawableCount = 2) with Completion Pacing:- Triple buffering (
maximumDrawableCount = 3) allows the CPU to run 2 full frames ahead of the display, adding 8.3–16.6 ms of latency during continuous trackpad dragging. - Set
CAMetalLayer.maximumDrawableCount = 2(or bound in-flight frames to 1 via anMTLSharedEvent/dispatch_semaphore_tsignaled incommandBuffer.addCompletedHandler), ensuringnextDrawable()never queues stale frames.
- Triple buffering (
- Live Window Resize Without Jitter (
presentsWithTransaction):- Keep
presentsWithTransaction = falseduring normal operation (so asynchronous commits never block the main thread). - Inside
setFrameSize:/displayLayer:(zed/crates/gpui_macos/src/window.rs:3327-3340,scrawl/src/native/pill/mod.rs:403-417), temporarily setpresentsWithTransaction = true, callcommandBuffer.commit(),commandBuffer.waitUntilScheduled(), anddrawable.present(), then restorepresentsWithTransaction = false.
- Keep
3. What to Steal vs. What to Avoid
What to Steal
- Zed (
gpui_macos&gpui_wgpu):- Oklab gradient interpolation + Jimenez IGN 2-tap triangular dithering (
±1/255) inkitlangton/gpui/src/platform/mac/shaders.metal:950-988,1170-1177to eliminate 8-bit banding in shadows and gradients. - Quarter-ellipse inner border SDF and perimeter-parameterized dashed borders (
shaders.metal:194-449). wgpubackend architecture for Linux/Windows/Web with storage buffers + dual-source subpixel blending (zed/crates/gpui_wgpu/src/wgpu_renderer.rs:781-795).- Zero-copy bi-planar
Y/CbCrIOSurfacevideo rendering (surface_fragmentinshaders.metal:874-890).
- Oklab gradient interpolation + Jimenez IGN 2-tap triangular dithering (
- Kit’s Scrawl (
scrawl/src/native/pill/):- Peak-alpha boost during Gaussian blur (
boost = 1.0 + smoothstep(0.0, 0.35, b) * 2.5,scrawl/src/native/pill/pill.metal:326-349) so morphing/blurring text stays crisp and legible. - Analytic SDF
box_clearanceroom gating (scrawl/src/native/pill/model.rs:146-184) to smoothly fade/scale child elements as container bounds morph. - Hybrid
NSGlassEffectView+CAMetalLayerhost (scrawl/src/native/pill/mod.rs:348-380).
- Peak-alpha boost during Gaussian blur (
- Makepad (
makepad/draw/src/shader/):- Public-domain Slug GPU Bézier text & icon renderer (
makepad/draw/src/shader/draw_text.rs:41-350andslug_atlas.rs:1-200). - Single-pass analytic SDF
Materialshading (bevel, wrapped Lambert diffuse, Blinn-Phong specular, rim light, inner shadow coverage,makepad/draw/src/shader/surface.rs:27-165).
- Public-domain Slug GPU Bézier text & icon renderer (
- Linebender (
vello_gpu/parley/harfrust/fontations):- Sparse Strips (
vello_gpu) 4×4 pixel alpha tile strips (vello/vello_gpu/src/render/wgpu/mod.rs) for complex multi-contour vector paths and strokes.
- Sparse Strips (
- Rive (
rive-runtime/renderer/src/shaders/):- Apple Silicon programmable framebuffer fetch (
[[color(IDX)]]) (rive-runtime/renderer/src/shaders/metal.glsl:396-450) for zero-bandwidth tile-local group opacity and blending.
- Apple Silicon programmable framebuffer fetch (
- Dioxus (
subsecond):- ThinLink + jump-table hot-patching (
docs.rs/subsecond) for <400 ms stateful Rust UI hot-reloading.
- ThinLink + jump-table hot-patching (
What to Avoid
- Avoid GPUI’s 4× MSAA Full-Window Intermediate Texture for Paths (
kitlangton/gpui/src/platform/mac/metal_renderer.rs:195-235): Allocating a full-window 4× MSAA texture and running a separate resolve + sprite-blit pass just to draw a few SVG icons wastes tens of megabytes of VRAM and breaks batching. Use Slug for icons/curves andvello_gpuSparse Strips for complex vector art. - Avoid
CVDisplayLinkon macOS 14+ (zed/crates/gpui_macos/src/display_link.rs:1-52): Deprecated, lacks ProMotionpreferredFrameRateRange, and has unsafe thread teardown races. UseCADisplayLinkon the mainNSRunLoopcombined with an immediate input-triggered draw fast-path. - Avoid Windowed
CAMetalDisplayLinkfor Latency-Critical Input: Its 3–5 refresh lead (41–50 ms on macOS windowed mode) makes typing and dragging feel sluggish. - Avoid Full Compute
vello: Moved toresearch/by Linebender in 2026 because its 9-stage compute pipeline has too high a baseline dispatch cost for low-latency 120 Hz UI frames. - Avoid Maintaining Custom Vulkan & D3D12 Backends (
blade-graphics/gpui_windows): Zed’s 2026 migration towgpuproved thatwgpuis faster on Linux/Windows while saving thousands of lines of driver-workaround code.
4. Decisive Recommendation & Renderer Architecture Sketch
Decisive Stack Choice
- Core Language: Rust (2024 Edition) with thin
objc2/ Swift 6 host shims on Apple platforms andsubsecondjump-table hot-patching in dev builds. - GPU Layer (
rune-gpu): A ~400-line internal trait (GpuDevice,RenderPass,BufferSlice,TextureHandle) with two backends:rune-metal(macOS & iOS): Directobjc2-metal(~1,600 LOC) with build-time.metallib,IOSurfacezero-copy textures, programmable framebuffer fetch ([[color(0..1)]]), andCAMetalLayer+NSGlassEffectViewhost integration.rune-wgpu(Linux, Windows, Android, WebGPU):wgpu28+ (~1,200 LOC) sharing the exact same scene buffer layout.
Threading & Latency Architecture
┌─────────────────────────────────────────────────────────────────────────┐
│ MAIN / UI THREAD (NSRunLoop / UIEventLoop) │
│ 1. Input Fast-Path (NSEvent/UIEvent) OR CADisplayLink(targetTimestamp) │
│ 2. Step analytical springs (exact closed-form at targetTimestamp) │
│ 3. Reactive view diff -> Taffy incremental layout -> SceneBuilder │
│ 4. Pack flat GPU instance buffers (UberQuad, GlyphRun, Slug, Strip) │
└───────────────────────────────┬─────────────────────────────────────────┘
│ Lock-free triple-buffered SceneArena
▼
┌─────────────────────────────────────────────────────────────────────────┐
│ GPU SUBMISSION (Inline on Main Thread <250 µs, or Dedicated Render Q) │
│ • Acquire persistent backing texture + dirty scissor bbox │
│ • Upload dirty glyph/Slug/strip pages via UMA mapped ring buffer │
│ • Encode RenderPass -> Blit to CAMetalDrawable -> commit() │
└─────────────────────────────────────────────────────────────────────────┘
▲
┌───────────────────────────────┴─────────────────────────────────────────┐
│ BACKGROUND WORKER POOL (Rayon / Async Executor) │
│ • Async image decoding -> staging ring buffer │
│ • Large text paragraph shaping (Parley + HarfRust) │
│ • Heavy SVG / chart flattening into vello_gpu Sparse Strips │
└─────────────────────────────────────────────────────────────────────────┘
Frame Graph (Typical Frame = 1 Render Pass + 1 Scissored Blit)
[Pass 0: Atlas Upload (Blit Encoder, only when new glyphs/icons/strips added)]
└── Append dirty R8/RGBA8 glyph tiles, Slug curve/band texels, or Sparse Strip alphas
[Pass 1: Backdrop Blur Pyramid (Only if scene contains active in-app BackdropBlur)]
└── Scissored Dual-Kawase 2x downsample (2 levels) -> 2x tent upsample
[Pass 2: Main UI Uber-Pass (Single RenderCommandEncoder, Scissored to Dirty Union)]
├── DrawBatch::UberQuad (Rounded/Squircle box, border, outer/inner erf shadow,
│ analytic surface material, Oklab gradient + IGN dither)
├── DrawBatch::AtlasSprite (Hinted body text R8/dual-source RGB + raster images)
├── DrawBatch::SlugVector (Large/rotated/zooming text + crisp SVG icons via Slug)
├── DrawBatch::SparseStrips (Complex multi-color vector paths via vello_gpu 4x4 strips)
└── DrawBatch::NativeSurface(Zero-copy YCbCr / RGBA IOSurface video & camera frames)
* Every primitive evaluates `ClipStackBuffer[instance.clip_id]` in-shader for
rounded-rect clipping + 4-edge analytic soft-gradient masks (zero mask passes!).
* On Apple Silicon, non-blurred group opacity uses tile-local `[[color(1)]]` scratch
plane without breaking Pass 2!
[Pass 3: Present]
└── Copy/present persistent backing texture to `CAMetalDrawable` (`maximumDrawableCount = 2`)
Core GPU Primitive Set (6 Primitives Total)
| Primitive | Instance Size | Responsibilities |
|---|---|---|
ClipNode (GPU Buffer Table) |
32 B | bounds, corner_radii, edge_feather (top, right, bottom, left), parent_clip_id, transform_id. Indexed by all primitives. |
UberQuad |
128 B | Fill (Solid / Linear/Radial/Angular Oklab Gradient / Noise), per-corner radii + squircle exponent, border widths/style/color, analytic 4-sample erf outer/inner shadow, optional Makepad-style Material (bevel/rim/gloss). |
AtlasSprite |
64 B | Monochrome (R8Unorm), Subpixel (RGBA8 dual-source), or Polychrome (RGBA8) atlas tile + tint + rounded corner radii + transformation ref. |
SlugInstance |
64 B | Em-space quad bounds, curve_offset, curve_count, band_offset, band_count, fill rule, color/gradient ref. |
SparseStripInstance |
32 B | vello_gpu 4×4 pixel strip header (x, y, width, alpha_offset, paint_id) for arbitrary stroked/filled vector art. |
BackdropEffect |
64 B | Kawase blur radius, saturation/contrast matrix, peak-alpha legibility boost (pill.metal), tint, and rounded-rect mask. |
5. Open Questions for Prototyping
- Uber-Shader Branching vs. Specialized PSOs on Low-End Integrated GPUs: On Apple M1–M4, evaluating the unified
UberQuadshader with uniform early-out branches (if (quad.shadow_sigma == 0 && quad.bevel == 0)) has near-zero divergence cost within 32-thread SIMD-groups. On older Intel/Qualcomm integrated GPUs viawgpu, shouldUberQuadsplit intoSimpleQuad(64 B, flat/rounded + border) andRichQuad(128 B, shadow + gradient + material) pipelines? - Slug Crossover Threshold on 2× vs 3× Retina: At what exact pixel size (
24 pxvs32 pxvs48 px) does Slug’s fragment raycasting match CoreText’s stem-darkened optical weight on macOS Retina displays without needing synthetic stem dilation in the Slug vertex shader? - Persistent Texture Blit vs. Direct Drawable Rendering Threshold: When >60% of the window area is dirty (e.g., full-window scrolling), rendering directly into
CAMetalDrawablesaves the 80 µs blit copy. What dirty-area ratio (e.g.,dirty_area / window_area > 0.35) is the optimal hysteresis threshold to switch between persistent-texture partial redraw and direct-drawable full redraw?