| # 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 | |
|
|