File size: 2,511 Bytes
671f03a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | # Spectral Terminal Emulator Architecture
## Design Philosophy
Spectral is designed to be the fastest terminal emulator while solving the font rendering problems that plague other GPU-accelerated terminals (especially Ghostty's "too thin" font issue on non-macOS platforms).
## Key Differentiators
1. **MSDF Font Rendering**: Multi-channel signed distance fields for GPU-native font rasterization with configurable per-pixel thickening across all platforms
2. **Compute Shader Glyph Generation**: Glyph rasterization happens on GPU, not CPU β eliminating the biggest bottleneck in existing terminals
3. **SIMD-Optimized Parser**: VT100/ANSI escape sequence parsing with SIMD byte scanning for CSI/OSC/DCS sequences
4. **Unified wgpu Backend**: Single Rust codebase renders via Metal on macOS, Vulkan on Linux, DirectX 12 on Windows
5. **Cross-Platform Font Thickening**: `font-thicken` and `font-thicken-strength` work identically on macOS, Linux, and Windows via MSDF threshold adjustment
## Crate Structure
```
spectral/
βββ spectral-core/ # Terminal grid, cell model, VT parser, damage tracking
βββ spectral-pty/ # PTY abstraction (Unix/Windows)
βββ spectral-font/ # Font discovery, MSDF atlas, metrics
βββ spectral-render/ # wgpu renderer, compute shaders, frame pacing
```
## Renderer Architecture
```
PTY bytes β SIMD VT Parser β Terminal Grid β Damage Tracker
β
Renderable Content Iterator
β
Font Shaper (HarfBuzz/swash)
β
Glyph Cache (HashMap<GlyphKey, AtlasSlot>)
β
MSDF Compute Pass (missing glyphs)
β
Texture Atlas Update
β
GPU Render Pass (Instanced Quads)
β
wgpu Surface Present
```
## Performance Targets
| Benchmark | Target |
|-----------|--------|
| ASCII cat /dev/urandom | >150 MB/s (faster than Kitty's 121) |
| Key-to-screen latency | <8ms (120Hz refresh, no batching) |
| Startup time | <100ms cold |
| Memory (100k scrollback lines) | <50MB |
| Font atlas (complete Unicode BMP) | <16MB GPU |
|