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