Commit graph

641 commits

Author SHA1 Message Date
Kovid Goyal
14191bbbee
Read variable font data from WOFF and WOFF2 files in font selection
The C font selection code read font tables only from sfnt files, so
variable fonts in WOFF/WOFF2 files had no variable data, causing wrong
faces to be selected, for example, for FiraCode-VF.woff2.

Read WOFF tables using zlib and WOFF2 tables using brotli, decompressing
only the prefix of the stream containing the needed tables, in fixed
size chunks so that memory use does not depend on possibly corrupt
offsets. kitty now links against libbrotlidec on platforms other than
macOS.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 13:43:39 +05:30
Kovid Goyal
13de2c0660
Do not require AVX-512 VBMI2 for the AVX-512 SIMD code
VBMI2 was only used by the AVX-512 UTF-8 decoder, which has been
removed, so CPUs with AVX-512 F, BW and VL but not VBMI2, such as
Skylake-X, can now use the AVX-512 implementations of the remaining
functions.
2026-11-16 13:43:39 +05:30
Kovid Goyal
79e337822d
Fix freeze build failure 2026-11-16 13:43:38 +05:30
Kovid Goyal
b7ff047b76
macOS: Require macOS 14 and drop code for older versions
Increase the minimum supported macOS version from 12 to 14. Remove the
CVDisplayLink fallback, using only CADisplayLink. Since CADisplayLink fires
on the main thread, the display link locking and cross thread dispatch are no
longer needed. Also remove other code paths that were only used on macOS
versions older than 14.
2026-11-16 13:43:37 +05:30
Kovid Goyal
e21d7ce6de
macOS: CVDisplayLink -> CADisplayLink 2026-11-16 13:43:37 +05:30
Kovid Goyal
f372285d96
Get Metal driver working 2026-11-16 13:43:37 +05:30
Kovid Goyal
a6768a955c
Add a Metal GPU driver and an MSL shader target
On macOS, kitty now tries to render using Metal, falling back to OpenGL,
see the gpu_driver option. The driver has not yet been compiled or run
on macOS, it was written on Linux and only syntax checked against stub
headers.

Shader targets of the form msl-NN (for MSL N.N) compile each program to
a single MSL source file containing the entry points for all stages,
compiled by the driver at runtime, for the built-in and custom shaders.
slangc ignores [[vk::binding]] for Metal, so the program metadata keeps
the kitty binding slots and passes the argument table indices assigned
by slangc as native names. The push constant block, emitted as an
ordinary constant buffer, is recognized by the name of its type. As
Metal has y=1 at the top in NDC, the generated code is fixed up to
negate the y coordinate of the position output by vertex entry points.
Layouts that would differ because bool is a single byte in MSL are
rejected. The MSL is validated with the Metal compiler when available.
The MSL shaders are temporarily built on all platforms, for development.

The driver follows the design of the Vulkan driver: command buffers with
serials and at most three in flight, copy on write of buffer storage the
GPU may still use, private textures uploaded with blits from staging
memory, pipeline variants created when first used and a CAMetalLayer
per window. Vertex inputs whose offset or stride is not a multiple of
four bytes, as Metal requires, are repacked into a cached copy.
2026-11-16 13:43:37 +05:30
Kovid Goyal
4860f6b1a7
Add a Vulkan GPU driver
On Linux and BSD, kitty now renders using Vulkan 1.3, falling back to
OpenGL if Vulkan is not available, see the gpu_driver option. The driver
is built when the Vulkan headers are present, libvulkan is loaded at
runtime.

The driver implements the immediate mode GPU API on top of a small ring
of command buffers, submitted when windows are presented or when the CPU
needs results, such as when reading back pixels. It uses dynamic
rendering, synchronization2, push descriptors for textures and uniform
buffers and push constants for the uniform parameters of pipelines.
Buffers are host visible and written only by the CPU, with copy on write
of storage still in use by the GPU, which preserves the OpenGL semantics
the rest of kitty relies on without the CPU ever waiting for the GPU.
Pipelines have variants for each render target format, blend mode and
set of vertex input formats, created when first used. Vertex strides are
dynamic state.

Rendering is pixel identical to OpenGL in the screenshot comparisons,
with the validation layers reporting no errors.

Integer textures are now declared in the shaders with their actual
number of channels, as Vulkan requires the format of the image in the
SPIR-V to match the texture. Drivers that cannot determine the size of
uniform blocks, such as Vulkan without SPIR-V reflection, can now report
it as zero.
2026-11-16 13:43:37 +05:30
Kovid Goyal
a0d7bf110d
Make shader targets driver defined and program metadata reflection based
Each GPU driver now declares the shader target it consumes (glsl-140 for
the OpenGL driver), a fixed property available as soon as the driver is
loaded. setup.py compiles the built-in shaders for the targets of the
drivers it builds, into a directory per target, and custom shaders are
compiled at runtime for the target of the loaded driver. The GLSL_VERSION
constant is no longer exported to Python.

The program metadata passed to the C code is now generated from the
reflection data produced by slangc and is backend neutral: vertex input
locations, uniform names, uniform block sizes and array layouts, all
identified by their names in the Slang source. Block sizes are verified
against the driver. The only target specific part is a map from Slang
names to the identifiers in the compiled code, which the OpenGL driver
needs to look up parameters by name and which is passed to the driver
when creating a pipeline. The driver no longer needs to be queried for
uniform array layouts.

The debug config output now uses the name reported by the driver.
2026-11-16 13:43:36 +05:30
Kovid Goyal
2c5155744d
Move OpenGL context creation from glfw into the GPU driver
glfw is now a windowing only library. It no longer creates OpenGL
contexts and contains no GLX, EGL, NSGL or OSMesa code. Instead it
exposes native window handles, and the GPU driver creates surfaces that
render into them, owning everything needed to render and present, such
as OpenGL contexts or, in future, Vulkan swapchains.

The GPU driver API (now version 2) gains surfaces: creation from native
X11, Wayland and Cocoa windows, making current, resizing, presenting,
swap interval, handling native view changes and recreation (macOS) and
choosing the X11 visual before window creation. The OpenGL driver
implements them with GLX on X11, EGL on Wayland and NSGL on macOS, all
ported from glfw, loading every library at runtime.

glfw gains a GLFW_X11_VISUAL_ID window hint, a native surface changed
callback (used on macOS where the NSOpenGLContext must be updated) and
glfwWindowContentsPresented(), which on Wayland commits surface state
after a frame is presented. The OpenGL context API, hints and the
share parameter of glfwCreateWindow() are removed.

The macOS (NSGL) code is untested as it could not be built.
2026-11-16 13:43:36 +05:30
Kovid Goyal
67b24f26a7
Move the kitty OpenGL code into a dynamically loaded GPU driver
All OpenGL calls now live in gpu/opengl, which is built as kitty/opengl.so,
next to the glfw backends. glfw_init() is passed the path to the driver and
loads it. The driver is initialized once the first OpenGL context is
current. fast_data_types no longer links against libGL.

kitty/gpu.c contains the driver loader and the higher level helpers
(programs and their metadata, vertex array objects, viewport stack) that
were previously in kitty/gl.c, implemented on top of the driver API.
shaders.c and the rest of kitty use only the driver API.

Also remove the unused GL_* constants and the unused bind_program,
create_vao, etc. functions exported to Python.
2026-11-16 13:43:36 +05:30
Kovid Goyal
02dd29ad14
Add nightly version to version string for nightly builds. Fixes #10751 2026-10-27 10:43:51 +05:30
Kovid Goyal
2dfaf0cc5e
Fix #10733 2026-10-25 08:07:41 +05:30
Kovid Goyal
8f0b7eff31
Encrypt sessions saved at logout with a key in the macOS Keychain
Every snapshot is encrypted with AES-256-GCM using a random key, stored
in the login keychain under a random id. The name of every file is
authenticated, so files cannot be swapped. The key is deleted before the
snapshot whenever it is removed, so copies of the snapshot left on disk
or in backups cannot be read.

The keychain is never allowed to show any UI. If storing the key fails
nothing is saved, if reading it fails the snapshot is deleted, with the
error logged in both cases.

The key is generated, stored and read only in C, in mlocked memory that
is cleared when freed, via a new random_secret() and the Keychain
functions in cocoa_window.m.
2026-10-16 11:57:31 +05:30
Kovid Goyal
05f4024dcc
Fix pipeline files not being added when building package 2026-09-23 10:38:09 +05:30
zhaolei
c43f500c16 Revert "macos: explicitly enable modern window corners on macOS 26"
This reverts commit b16221a1d3.
2026-08-24 15:00:57 +08:00
Kovid Goyal
07ea7583ac
Improve performance of SIMD UTF-8 decoding
Optimise the AVX 2 implementation reducing number of operations per block
and also add an AVX-512 implementation used when the CPU supports it at
runtime.
2026-08-16 20:25:03 +05:30
Kovid Goyal
f5ae245f65
Switch to perf for profiling from gperftools 2026-08-16 11:24:41 +05:30
Hassan Raza
111cd86f61
Relink when linker commands change 2026-08-12 16:21:24 +05:00
Kovid Goyal
5fc4189cfd
Autodetect bundled slangc when from from a dev.sh build 2026-08-12 10:12:47 +05:30
Kovid Goyal
e862e5febd
Honor verbose flag when building shaders 2026-08-05 05:32:56 +05:30
Kovid Goyal
7f0b072f0d
autoformat 2026-08-05 05:32:56 +05:30
Kovid Goyal
3799ad76b4
pep8 2026-08-05 05:32:55 +05:30
Kovid Goyal
5802d35198
Switch over to the slang based shaders 2026-08-05 05:32:54 +05:30
Kovid Goyal
1612a23307
Get slangc working in macOS frozen build 2026-08-05 05:32:50 +05:30
Kovid Goyal
7cde77ef2c
Get freezing of slang on linux working 2026-08-05 05:32:50 +05:30
Kovid Goyal
676b838c0d
Move glfw build code into setup.py
This was on my TODO list for a long time and doing this allows the
setup.py module code to be re-used in slang.py
2026-08-05 05:32:50 +05:30
Kovid Goyal
5f082b1cee
Fix building of shaders under ASAN
We cant import fast_data_types.so into the system python in that case,
so build shaders by running the compiler under the kitty launcher.
2026-08-05 05:32:50 +05:30
Kovid Goyal
6008d09d25
Ensure shaders are built after fast_data_types.so 2026-08-05 05:32:50 +05:30
Kovid Goyal
c171ab8111
More work on slang compilation 2026-08-05 05:32:49 +05:30
Kovid Goyal
c8f74f7a56
More work on integrating slangc into the build pipeline 2026-08-05 05:32:49 +05:30
Kovid Goyal
0eb2d26a46
Setup location for compiled shaders 2026-08-05 05:32:49 +05:30
Kovid Goyal
b3781f4fa1
Use the slangc binary instead trying to get the C++ extension working everywhere is too fragile 2026-08-05 05:32:48 +05:30
Kovid Goyal
3a5b92af61
Get slangc building with clang 2026-08-05 05:32:48 +05:30
Kovid Goyal
9afa480de5
Move shaders into kitty package 2026-08-05 05:32:48 +05:30
Kovid Goyal
ca9945e547
Work on slang module compilation 2026-08-05 05:32:48 +05:30
Kovid Goyal
9f5339c6df
Stub slang module 2026-08-05 05:32:48 +05:30
Kovid Goyal
45a97ee5af
macOS: Disable macOS one time code autofill popups
Fixes #10250
2026-07-13 09:06:24 +05:30
Kovid Goyal
6614f402ee
...
Some checks are pending
CI / Linux (python=3.14 cc=clang sanitize=1) (push) Waiting to run
CI / Linux (python=3.12 cc=gcc sanitize=0) (push) Waiting to run
CI / Linux (python=3.13 cc=gcc sanitize=1) (push) Waiting to run
CI / Linux package (push) Waiting to run
CI / Bundle test (macos-latest) (push) Waiting to run
CI / Bundle test (ubuntu-latest) (push) Waiting to run
CI / macOS Brew (push) Waiting to run
CI / Test ./dev.sh and benchmark (push) Waiting to run
CodeQL / CodeQL-Build (actions, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, macos-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (go, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (python, ubuntu-latest) (push) Waiting to run
Depscan / Scan dependencies for vulnerabilities (push) Waiting to run
2026-07-05 20:03:36 +05:30
Kovid Goyal
a65b4c70a7
Migrate type checker to ty
Much faster than mypy. Matches usage of ruff from same developer.
2026-07-04 09:18:00 +05:30
Kovid Goyal
f6d1b11b29
Make arm64 binary deps available for dev.sh
Some checks are pending
CI / Linux (python=3.13 cc=clang sanitize=1) (push) Waiting to run
CI / Linux (python=3.11 cc=gcc sanitize=0) (push) Waiting to run
CI / Linux (python=3.12 cc=gcc sanitize=1) (push) Waiting to run
CI / Linux package (push) Waiting to run
CI / Bundle test (macos-latest) (push) Waiting to run
CI / Bundle test (ubuntu-latest) (push) Waiting to run
CI / macOS Brew (push) Waiting to run
CI / Test ./dev.sh and benchmark (push) Waiting to run
CodeQL / CodeQL-Build (actions, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, macos-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (go, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (python, ubuntu-latest) (push) Waiting to run
Depscan / Scan dependencies for vulnerabilities (push) Waiting to run
Fixes #10197
2026-06-27 17:29:31 +05:30
Kovid Goyal
2d18b88480
macOS: Switch to Tahoe style application icon 2026-04-18 13:28:22 +05:30
Kovid Goyal
c08409a981
Function to get machine ID on cocoa 2026-04-09 07:04:12 +05:30
Kovid Goyal
79cadf4a5f
... 2026-04-05 18:25:05 +05:30
Kovid Goyal
c977d1edcb
... 2026-03-17 08:22:45 +05:30
1024th
ffe8cef1a8 Fix font detection command on linux in setup.py 2026-03-13 01:03:20 +08:00
Kovid Goyal
a0709acdde
DRYer 2026-03-12 10:06:20 +05:30
Kovid Goyal
01104bac65
Fix a regression that broke `kitten update-self`
Fixes #9642
2026-03-12 08:33:20 +05:30
Kovid Goyal
c75bdc7620
Bump Go version for security vulnerabilities
Unfortunately means have to bump minimum macos version as well as Go
requires it.
2026-03-07 08:05:37 +05:30
Kovid Goyal
524fe6ae3b
Ignoring errors is the default behavior for os.walk 2026-01-31 08:28:10 +05:30