40 Commits

Author SHA1 Message Date
Qwerasd
ec20c455c7 renderer: remove all gpu-side glyph constraint logic
Now that it's done at the rasterization stage, we don't need to handle
it on the GPU. This also means that we can switch to nearest neighbor
interpolation in the Metal shader since we're guaranteed to be pixel
perfect. Accidentally, we were already nearest neighbor in the OpenGL
shaders because I used the Rectangle texture mode in the big renderer
rework, which doesn't support interpolation- anyway, that's no longer
problematic since we won't be scaling glyphs on the GPU anymore.
2025-07-04 15:47:35 -06:00
Qwerasd
da46a47726 renderer: add support for background images
Adds support for background images via the `background-image` config.

Resolves #3645, supersedes PRs #4226 and #5233.

See docs of added config keys for usage details.
2025-06-25 16:27:23 -04:00
Qwerasd
4c3ab14571 renderer: make shader pipeline prep code DRYer
In this format it will be a lot easier to iterate on this since adding
and removing pipelines only has to be done in a single place.

This commit also separates out the main background color from individual
cell background color drawing, because sometimes kitty images need to be
between the main background and individual cell backgrounds (kitty image
z-index seems to be entirely broken at the moment, I intend to fix it in
future commits).
2025-06-23 18:01:34 -06:00
Qwerasd
c7a7474be0 renderer: move custom shader uniforms out of frame state
These should not be independent per-frame, that makes the time
calculations all sorts of jank.

Also moves the uniforms struct layout in to `shadertoy.zig` and cleans
up the handling in general somewhat.
2025-06-21 23:07:18 -06:00
Qwerasd
371d62a82c renderer: big rework, graphics API abstraction layers, unified logic
This commit is very large, representing about a month of work with many
interdependent changes that don't separate cleanly in to atomic commits.

The main change here is unifying the renderer logic to a single generic
renderer, implemented on top of an abstraction layer over OpenGL/Metal.

I'll write a more complete summary of the changes in the description of
the PR.
2025-06-20 15:18:41 -06:00
Qwerasd
77c050c156 refactor(Metal): make pipeline handling DRYer 2025-06-20 15:18:41 -06:00
Mitchell Hashimoto
0f4d2bb237 Lots of 0.14 changes 2025-03-12 09:55:52 -07:00
Qwerasd
5c8f984ea1 renderer/Metal: improve linear blending correction
More mathematically sound approach, does a much better job of matching
the appearance of non-linear blending. Removed `experimental` from name
because it's not really an experiment anymore.
2025-01-27 19:15:18 -05:00
Qwerasd
fca336c32d Metal: blend in Display P3 color space, add option for linear blending
This commit is quite large because it's fairly interconnected and can't
be split up in a logical way. The main part of this commit is that alpha
blending is now always done in the Display P3 color space, and depending
on the configured `window-colorspace` colors will be converted from sRGB
or assumed to already be Display P3 colors. In addition, a config option
`text-blending` has been added which allows the user to configure linear
blending (AKA "gamma correction"). Linear alpha blending also applies to
images and makes custom shaders receive linear colors rather than sRGB.

In addition, an experimental option has been added which corrects linear
blending's tendency to make dark text look too thin and bright text look
too thick. Essentially it's a correction curve on the alpha channel that
depends on the luminance of the glyph being drawn.
2025-01-13 13:50:29 -08:00
Mitchell Hashimoto
7aa2e2b24f renderer: some tweaks 2024-10-02 15:44:06 -07:00
Qwerasd
dfc0894d5d fix(renderer): make all decorations and combining marks visible under cursor
Metal needed to be changed to account for wide chars having decorations
on the right half and OpenGL needed to account for multiple glyphs being
under the cursor at once (decorations and combining marks) as well as
wide chars.
2024-10-02 17:18:26 -04:00
Mitchell Hashimoto
861fe0379b metal: cell bg pipeline no longer has vertex data, needs no vertex desc
This happened to work in releases somehow but Xcode debug builds would
catch this as an assertion. Our cell bg pipeline now uses the "full
screen vertex shader" which takes no parameters, so we don't need a
vertex descriptor.
2024-08-09 15:10:58 -07:00
Qwerasd
d68906563e renderer/metal: properly support padding color = background (not extend) 2024-08-08 19:03:39 -04:00
Qwerasd
6339f9bae9 renderer: metal shaders rework
- Significant changes to optimize memory usage.
- Adjusted formatting of the metal shader code to improve readability.
- Normalized naming conventions in shader code.
- Abstracted repetitive code for attribute descriptors to a helper
function.
2024-08-07 17:39:31 -04:00
Mitchell Hashimoto
c116d147d6 build: build metal lib 2024-08-06 15:30:48 -07:00
Mitchell Hashimoto
14a42fcdb7 renderer/metal: load shaders from precompiled lib 2024-08-06 15:05:10 -07:00
Leah Amelia Chen
503dfae6ff renderer: exempt Powerline cells from minimum contrast requirements
With a minimum contrast set, the colored glyphs that Powerline uses
would sometimes be set to white or black while the surrounding background
colors remain unchanged, breaking up contiguous colors on segments of
the Powerline.

This no longer happens with this patch as Powerline glyphs are now
special-cased and exempt from the minimum contrast adjustment.
2024-08-06 15:28:50 +08:00
Mitchell Hashimoto
ea551990eb renderer: disable window-padding-color=extend in certain scenarios
There are scenarios where this configuration looks bad. This commit
introduces some heuristics to prevent it. Here are the heuristics:

  * Extension is always enabled on alt screen.
  * Extension is disabled if a row contains any default bg color. The
    thinking is that in this scenario, using the default bg color looks
    just fine.
  * Extension is disabled if a row is marked as a prompt (using semantic
    prompt sequences). The thinking here is that prompts often contain
    perfect fit glyphs such as Powerline glyphs and those look bad when
    extended.

This introduces some CPU cost to the extension feature but it should be
minimal and respects dirty tracking. This is unfortunate but the feature
makes many terminal scenarios look much better and the performance cost
is minimal so I believe it is worth it.

Further heuristics are likely warranted but this should be a good
starting set.
2024-08-03 21:56:19 -07:00
Mitchell Hashimoto
5309f4d080 renderer/metal: extend background color of grid border into padding 2024-08-03 15:39:02 -07:00
Mitchell Hashimoto
3a7dc355a0 renderer/metal: invert text under cursor again 2024-04-27 22:13:17 -07:00
Mitchell Hashimoto
3f16234f72 terminal: Coordinate uses CellCountInt 2024-04-26 20:52:08 -07:00
Mitchell Hashimoto
ced8776120 renderer/metal: grid pos for bg/text should be ushort2
This saves 50% memory per vertex.
2024-04-25 19:16:40 -07:00
Mitchell Hashimoto
d12e3db599 renderer/metal: dedicated cell fg shader 2024-04-22 10:58:23 -07:00
Mitchell Hashimoto
e8b623e829 renderer/metal: dedicated cell bg shader 2024-04-22 10:43:29 -07:00
Mitchell Hashimoto
ad08842e86 renderer/metal: remove strikethrough support from GPU 2024-04-22 10:26:51 -07:00
Mitchell Hashimoto
0b658c8217 renderer/metal: constrain PUA glyphs if they aren't next to space 2023-12-16 20:07:25 -08:00
Mitchell Hashimoto
7af4009f27 renderer/metal: minimum contrast ratio is configurable 2023-12-01 21:24:38 -08:00
Mitchell Hashimoto
6c859cca82 renderer/metal: minimum contrast experiment
This uses WCAG2 algorithms with a minimum ratio hardcoded of 3:1. This
is not shippable in its current state because we want the ratio to be
configurable and I'm not happy with the way data is being sent to the
shader.
2023-12-01 20:51:16 -08:00
Mitchell Hashimoto
5d7c47a469 renderer/metal: clean up some memory management 2023-11-17 21:51:06 -08:00
Mitchell Hashimoto
4742cd308d renderer: animation timer if we have custom shaders 2023-11-17 21:50:53 -08:00
Mitchell Hashimoto
c347148fd7 renderer/metal: CRT effect, ugly hacky code 2023-11-17 21:50:34 -08:00
Mitchell Hashimoto
28246a80b8 renderer/metal: release some of our shader initialization objects 2023-11-17 21:50:34 -08:00
Mitchell Hashimoto
3095dce685 renderer/metal: wip for loading custom shader pipelines 2023-11-17 21:50:34 -08:00
Mitchell Hashimoto
67dce5ce0e update zig-objc 2023-11-17 21:50:34 -08:00
Mitchell Hashimoto
7ff76ca00d terminal/kitty-gfx: respect display c/r params 2023-08-22 14:43:50 -07:00
Mitchell Hashimoto
3bbfee676b terminal/kitty-gfx: process source rectangle display params 2023-08-22 14:33:41 -07:00
Mitchell Hashimoto
84c72bbe46 renderer/metal: honor cell offset graphics command 2023-08-22 13:28:40 -07:00
Mitchell Hashimoto
5a9bbcbc2d renderer/metal: clip image if necessary off top of viewport (scrolling) 2023-08-22 11:32:45 -07:00
Mitchell Hashimoto
e665fc6741 renderer/metal: first pass at an image shader 2023-08-22 09:20:30 -07:00
Mitchell Hashimoto
5229cb93d2 renderer/metal: extract helpers for shaders/buffers 2023-08-22 08:49:34 -07:00