feat(renderer): port the OpenGL backend, shaders and size math

Ports the terminal-independent half of ZIG/src/renderer (OpenGL only):
- opengl/*: buffers, frames, pipelines, render passes, samplers,
  targets, textures and the OpenGL GraphicsAPI backend on top of glow;
  the GTK GLArea glue is replaced by a get_proc_address loader closure
- the GLSL shaders, copied verbatim and embedded; uniform/vertex structs
  as bytemuck Pod types with std140 offsets asserted in tests
- shadertoy custom shaders converted with naga (GLSL in -> validate ->
  GLSL 430 out) instead of glslang + spirv-cross
- size (screen/grid/cell/padding math), cursor style logic, backend
  health, options and message types

The crate opts into unsafe_code = "deny"; unsafe glow calls live only in
opengl/gl.rs. A headless EGL integration test builds every pipeline and
the converted shadertoy shaders on Mesa and reads back rendered pixels.

Note: Zig's shadertoy Uniforms order the selection background/foreground
colors opposite to the GLSL block (likely an upstream bug); kept as in
Zig for parity and recorded in the notes.

Deferred to the next renderer pass: generic, cell, image, link, row,
State, Thread, Overlay (need terminal render state).

Test Plan:
- cargo test -p ghostty-renderer (33 tests incl. tests/egl_headless.rs)
This commit is contained in:
ddidderr committed 2026-10-11 22:26:09 +02:00
1 parent 5a5fa7893b
commit 568ce784f9
35 files changed
+5477 -5

No files matched your search

+23
View File
@@ -0,0 +1,23 @@
//! The options that are used to configure a renderer (`renderer/Options.zig`).
use std::sync::Arc;
use ghostty_font::SharedGrid;
use crate::size::Size;
/// Options for constructing a renderer.
///
/// `config` is the derived renderer configuration (`Renderer.DerivedConfig`).
// TODO(integration): upstream also carries `surface_mailbox`, `rt_surface`
// and `thread` (apprt / Thread.zig types). They are added when the generic
// renderer and the apprt exist; the GL loader closure replaces `rt_surface`.
pub struct Options<C> {
/// The derived configuration for this renderer implementation.
pub config: C,
/// The font grid that should be used along with the key for deref-ing.
pub font_grid: Arc<SharedGrid>,
/// The size of everything.
pub size: Size,
}