1
1
mirror of https://github.com/wez/wezterm.git synced 2024-12-26 14:54:16 +03:00
wezterm/wezterm-gui/src/background-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

21 lines
587 B
GLSL

// This shader is responsible for coloring the window background.
// Note: fragment-common.glsl is automatically prepended!
uniform sampler2D atlas_linear_sampler;
void main() {
if (o_has_color == 2.0) {
// We're the window background image.
color = sample_texture(atlas_linear_sampler, o_tex);
// Apply window_background_image_opacity to the background image
color.a = o_bg_color.a;
} else if (o_has_color == 3.0) {
color = o_bg_color;
} else {
// Nothing else should render on the background layer
discard;
}
color = apply_hsv(color, o_hsv);
}