1
1
mirror of https://github.com/wez/wezterm.git synced 2024-11-27 12:23:46 +03:00
wezterm/wezterm-gui/src/glyph-frag.glsl
Wez Furlong 09081d2189 improve texture upload performance, part 2
Continuing along the same lines as the prior commit, the goal
of this commit is to remove the buffer transformation that was
part of uploading the texture to the GPU provided surface.

In order to do so:

* The sense of our local textures needs to change from bgra32 to rgba32.
  bgra32 was a hangover from earlier versions of our window crate that
  allowed direct-to-fb writes in software mode.  We had to pick bgra32
  for that for the broadest OS compatibility.  I believe that that
  constraint has been totally removed, although there is a chance that
  this will flip the colors on macos.
* There was an additional linear-to-srgb conversion inlined in that
  buffer transformation.  I have no idea where that is needed because
  the source data is carefully constructed as SRGB.  I don't yet know
  how to signal that, but for now I've moved that gamma correction
  into the shader when we sample the texture.

With this change, timg playback now has vtparse as the hottest
region of code.

refs: #537
2021-03-14 09:14:30 -07:00

37 lines
1.1 KiB
GLSL

// This is the Glyph fragment shader.
// It is the last stage in drawing, and is responsible
// for laying down the glyph graphics on top of the other layers.
// Note: fragment-common.glsl is automatically prepended!
uniform sampler2D atlas_nearest_sampler;
void main() {
if (o_has_color >= 2.0) {
// Don't render the background image on anything other than
// the window_bg_layer.
discard;
return;
}
color = sample_texture(atlas_nearest_sampler, o_tex);
if (o_has_color == 0.0) {
// if it's not a color emoji it will be grayscale
// and we need to tint with the fg_color
if (o_fg_color == o_bg_color) {
// However, if we're a monochrome glyph and the foreground and
// background colors are the same, just render a transparent pixel
// instead; this avoids generating shadowy anti-aliasing artifacts
// for something that should otherwise be invisible.
color = vec4(0.0, 0.0, 0.0, 0.0);
discard;
return;
} else {
color = colorize(color, o_fg_color, o_bg_color);
color = apply_hsv(color, foreground_text_hsb);
}
}
color = apply_hsv(color, o_hsv);
}