Use the fact that GLSL supports multiple dispatch based on argument types
This commit is contained in:
parent
e21d2f5191
commit
da39257020
1 changed files with 6 additions and 5 deletions
|
|
@ -76,17 +76,18 @@ vec3 color_to_vec(uint c) {
|
|||
return vec3(gamma_lut[r], gamma_lut[g], gamma_lut[b]);
|
||||
}
|
||||
|
||||
#define one_if_equal_zero_otherwise(a, b) (1.0f - zero_or_one(abs(float(a) - float(b))))
|
||||
float one_if_equal_zero_otherwise(float a, float b) { return (1.0f - zero_or_one(abs(float(a) - float(b)))); }
|
||||
// Wee need an integer variant to accommodate GPU driver bugs, see
|
||||
// https://github.com/kovidgoyal/kitty/issues/9072
|
||||
#define one_if_equal_zero_otherwise_integer(a, b) (1u - uint(zero_or_one(abs(float(a) - float(b)))))
|
||||
uint one_if_equal_zero_otherwise(int a, int b) { return (1u - uint(zero_or_one(abs(float(a) - float(b))))); }
|
||||
uint one_if_equal_zero_otherwise(uint a, uint b) { return (1u - uint(zero_or_one(abs(float(a) - float(b))))); }
|
||||
|
||||
|
||||
uint resolve_color(uint c, uint defval) {
|
||||
// Convert a cell color to an actual color based on the color table
|
||||
int t = int(c & BYTE_MASK);
|
||||
uint is_one = one_if_equal_zero_otherwise_integer(t, 1);
|
||||
uint is_two = one_if_equal_zero_otherwise_integer(t, 2);
|
||||
uint is_one = one_if_equal_zero_otherwise(t, 1);
|
||||
uint is_two = one_if_equal_zero_otherwise(t, 2);
|
||||
uint is_neither_one_nor_two = 1u - is_one - is_two;
|
||||
return is_one * color_table[(c >> 8) & BYTE_MASK] + is_two * (c >> 8) + is_neither_one_nor_two * defval;
|
||||
}
|
||||
|
|
@ -191,7 +192,7 @@ uvec2 get_decorations_indices(uint in_url /* [0, 1] */, uint text_attrs) {
|
|||
uint is_cursor(uint x, uint y) {
|
||||
uint clamped_x = clamp(x, cursor_x1, cursor_x2);
|
||||
uint clamped_y = clamp(y, cursor_y1, cursor_y2);
|
||||
return one_if_equal_zero_otherwise_integer(x, clamped_x) * one_if_equal_zero_otherwise_integer(y, clamped_y);
|
||||
return one_if_equal_zero_otherwise(x, clamped_x) * one_if_equal_zero_otherwise(y, clamped_y);
|
||||
}
|
||||
// }}}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue