Commit Graph

19 Commits

Author SHA1 Message Date
Kirill Chibisov 546d5951aa
Optimize undercurl shader
This removes the if and lowers amount of operations.
2023-12-01 21:40:20 +04:00
Kirill Chibisov 54889fc4ff
Make AA stronger for undercurl
This improves undercurl rendering preserving its original thickness.
This also makes it look not out-of place when places next to other
lines.
2023-11-24 23:57:43 +04:00
Kirill Chibisov 5b1dd38806
Fix cursor and underlines always being black
Some old hardware doesn't like universal shader approach for all the
rectangle kinds leading to ALU instruction limits. This commit fixes
it by splitting the shader per rectangle kind.

Fixes #6417.
2022-10-21 22:19:42 +03:00
Vasily Khoruzhick 6dc670cde0
Support dual source blending in GLES2 renderer
GLES2 has GL_EXT_blend_func_extended extension that enables
dual-source blending, so essentially we can reuse fragment shader
from GLSL3 renderer and do 1 rendering pass instead of 3 for the
text.

Co-authored-by: Kirill Chibisov <contact@kchibisov.com>
Co-authored-by: Christian Duerr <contact@christianduerr.com>
2022-06-08 12:02:57 +03:00
Kirill Chibisov 589c1e9c6b
Use center of the pixel when aligning undercurl
Since `x` position in rect shader represents left side of the pixel we
should use the center of it when dealing with contiguous functions.
2022-03-14 08:52:53 +03:00
Kirill Chibisov dbccd7e30f
Use round instead of ceil for line position
Ceiling line position results in strikeout line being lower than
it should.
2022-03-06 19:34:12 +03:00
Kirill Chibisov d8113dc2b6
Fix gap calculation for dashed underline 2022-03-02 22:35:19 +03:00
Kirill Chibisov 1880522b64
Add fallback GLES2 renderer
Currently Alacritty only works on hardware which supports OpenGL 3.3 or
more, which can become problematic with older devices. This patch adds a
new GLES2 renderer, since it is much more widely supported, especially
on weaker hardware like phones or a Raspberry Pi.

While the GLES2 renderer is slower than the OpenGL 3.3+ version, it is
still significantly faster than software rendering. However because of
this performance difference it is only used when necessary and there
should be no difference for machines supporting OpenGL 3.3+.

The two renderers are largely independent and separated in the
`renderer/text/glsl3` and `renderer/text/gles2` modules. Separate
shaders are also required for text rendering. The rectangle rendering
for underlines and the visual bell works identically for both versions,
but does have some version-specific shader code.

Fixes #128.

Co-authored-by: Christian Duerr <contact@christianduerr.com>
2022-03-02 10:05:12 +00:00
Kirill Chibisov 36e981ad4b
Don't use 'origin_upper_left' in rect shaders 2022-02-22 13:57:04 +03:00
Kirill Chibisov ed5dbc1118
Add support for dashed and dotted underlines
This finishes implementation of underline styles provided by
`CSI 4 : [1-5] m` escape sequence.
2022-02-14 19:10:13 +03:00
Kirill Chibisov c35ccaf9b5
Make undercurls thickness close to underlines
Fixes #5873.
2022-02-10 15:29:03 +03:00
Kirill Chibisov 59f16f6b15
Fix alpha when using `colors.transparent_background_colors`
The alpha is expected to be premultiplied from the text shader, so
we should apply it to the background color.
2022-02-09 17:41:57 +03:00
Kirill Chibisov 73c3dd8628
Add support for drawing undercurls
Fixes #1628.
2022-02-08 20:47:31 +03:00
Kirill Chibisov c24d7dfd0d
Add option to apply opacity to all background colors
In some cases it could be desired to apply 'background_opacity'
to all background colors instead of just 'colors.primary.background',
thus adding an 'colors.opaque_background_colors' option to control that.

Fixes #741.
2021-08-16 14:49:14 +03:00
Ivan Avdeev 5ececc3105
Render underline and strikeout rects in batches
Currently Alacritty requires a separate `draw` call to OpenGL whenever a
new rectangle is rendered to the screen. With many rectangles visible,
this has a significant impact on rendering performance.

Instead of using separate draw calls, the new `RectRenderer` will build
a batch of rectangles for rendering. This makes sure that multiple
rectangles can be grouped together for single draw calls allowing a
reduced impact on rendering time.

Since this change is OpenGL 2 friendly, it should not make it more
complicated to transition away from the 3.3+ requirements like an
alternative instancing based implementation might have.
2020-12-10 05:42:03 +00:00
Kirill Chibisov 9724418d35
Fix wide characters being cut off
Fixes #791.
2020-11-17 17:49:05 +03:00
Kirill Chibisov ef7cb258b2
Remove copyright notice from files
This commit is a follow-up to 7aafbb757d485c5ff065324464dde8b5322cdd921
which was an effort to remove copyright notice from files.
2020-08-10 16:07:19 +03:00
Joe Wilm 99c34c7ce9
Reduce InstanceData footprint
The InstanceData type in the rendering subsystem was previously 17 f32s
plus one u8 which occupied a total of 72 bytes per instance. This meant
that for every character or background cell drawn, 72 bytes were sent to
the GPU. In the case of a 400x100 cell grid, a total of 2.9MB would be
sent.

This patch reduces InstanceData's size to 36 bytes, a 50% improvement!
Using the above example for comparison, a worst case of 1.44MB would be
transferred.

The motivation for this patch comes from macOS. Once the terminal grid
would reach a certain size, performance experienced a sharp and dramatic
drop (render times would go from ~3ms to ~16ms). I don't want to
speculate too much on the underlying issue, but suffice it to say that
this patch alleviates the problem in my testing.

While the performance impact was most significant on macOS, with
rendering times cut by more than 50% in some cases, this also results in
a measurable performance difference on other systems with high density
grids.

Co-authored-by: Christian Duerr <contact@christianduerr.com>
2020-08-05 00:24:51 +00:00
Christian Duerr 9167461eb3
Fix crates.io publishing restrictions
This works around the problem that crates pushed to crates.io cannot
reference files outside of their crate directory.
2020-08-01 01:11:24 +00:00