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)
48 lines
1.3 KiB
GLSL
48 lines
1.3 KiB
GLSL
#include "common.glsl"
|
|
|
|
layout(binding = 0) uniform sampler2D image;
|
|
|
|
layout(location = 0) in vec2 grid_pos;
|
|
layout(location = 1) in vec2 cell_offset;
|
|
layout(location = 2) in vec4 source_rect;
|
|
layout(location = 3) in vec2 dest_size;
|
|
|
|
out vec2 tex_coord;
|
|
|
|
void main() {
|
|
int vid = gl_VertexID;
|
|
|
|
// We use a triangle strip with 4 vertices to render quads,
|
|
// so we determine which corner of the cell this vertex is in
|
|
// based on the vertex ID.
|
|
//
|
|
// 0 --> 1
|
|
// | .'|
|
|
// | / |
|
|
// | L |
|
|
// 2 --> 3
|
|
//
|
|
// 0 = top-left (0, 0)
|
|
// 1 = top-right (1, 0)
|
|
// 2 = bot-left (0, 1)
|
|
// 3 = bot-right (1, 1)
|
|
vec2 corner;
|
|
corner.x = float(vid == 1 || vid == 3);
|
|
corner.y = float(vid == 2 || vid == 3);
|
|
|
|
// The texture coordinates start at our source x/y
|
|
// and add the width/height depending on the corner.
|
|
tex_coord = source_rect.xy;
|
|
tex_coord += source_rect.zw * corner;
|
|
|
|
// Normalize the coordinates.
|
|
tex_coord /= textureSize(image, 0);
|
|
|
|
// The position of our image starts at the top-left of the grid cell and
|
|
// adds the source rect width/height components.
|
|
vec2 image_pos = (cell_size * grid_pos) + cell_offset;
|
|
image_pos += dest_size * corner;
|
|
|
|
gl_Position = projection_matrix * vec4(image_pos.xy, 1.0, 1.0);
|
|
}
|