Commit graph

4 commits

Author SHA1 Message Date
Kovid Goyal
f6d3b1e537
Vulkan: Create the swapchain with the right present mode the first time
The swapchain was created with the FIFO present mode and then recreated
on the first frame, because the swap interval of the window was set
only after the surface was created. Pass the initial swap interval to
the driver in GPUSurfaceConfig so the swapchain is created correctly
when the surface is created.
2026-11-19 07:35:32 +05:30
Kovid Goyal
a8fb53bca4
Add software rendering as a fallback GPU driver
On Linux and BSD, kitty now falls back to rendering on the CPU with the
Mesa lavapipe (Vulkan) or llvmpipe (OpenGL) software renderers when no
usable GPU is found, such as in virtual machines or with broken GPU
drivers. This is the new software value of the gpu_driver option, last
in the default list.

Drivers are now told which kind of renderer they may use. The software
candidates use only software renderers: Vulkan selects CPU devices and
OpenGL sets LIBGL_ALWAYS_SOFTWARE and __GLX_VENDOR_LIBRARY_NAME while
the renderer is chosen, restoring them afterwards so they are not passed
on to child programs. The other candidates reject software renderers,
unless they are last, so that a working GPU, even one usable only by a
later driver, is always preferred to the CPU. Previously, on systems
with a GPU usable only with OpenGL, kitty would use lavapipe. Drivers
report whether they render in software in their capabilities.

Failing to initialize the GPU driver for the first window is no longer
fatal: the window is recreated with the next driver, as is already done
for failures creating surfaces. OpenGL can only detect that it is using
llvmpipe once a context is current.

When software rendering is used, a message saying so is shown at the
top of every OS window for five seconds after it is first rendered.
2026-11-19 07:35:31 +05:30
Kovid Goyal
70ca44ae1d
Simplify is_selected buffer Metal compatibility 2026-11-19 07:35:31 +05:30
Kovid Goyal
8cbb366f4d
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-19 07:35:31 +05:30