Coalesce another couple of uniforms
This commit is contained in:
parent
51d037fb70
commit
14103db2ee
@ -1,9 +1,8 @@
|
|||||||
#version GLSL_VERSION
|
#version GLSL_VERSION
|
||||||
uniform uvec4 dimensions; // xnum, ynum, cursor.x, cursor.y
|
|
||||||
uniform float geom[6];
|
uniform float geom[6];
|
||||||
uniform ivec2 color_indices; // which color to use as fg and which as bg
|
uniform ivec2 color_indices;
|
||||||
uniform uint default_colors[6]; // The default colors
|
uniform uint default_colors[6];
|
||||||
uniform uvec4 url_range; // The range for the currently highlighted URL (start_x, end_x, start_y, end_y)
|
uniform uint dimensions[8];
|
||||||
uniform ColorTable {
|
uniform ColorTable {
|
||||||
uint color_table[256]; // The color table
|
uint color_table[256]; // The color table
|
||||||
};
|
};
|
||||||
@ -15,8 +14,13 @@ uniform ColorTable {
|
|||||||
#define highlight_bg default_colors[3]
|
#define highlight_bg default_colors[3]
|
||||||
#define cursor_color default_colors[4]
|
#define cursor_color default_colors[4]
|
||||||
#define url_color default_colors[5]
|
#define url_color default_colors[5]
|
||||||
|
#define xnum dimensions[0]
|
||||||
|
#define ynum dimensions[1]
|
||||||
#define cursor_x dimensions[2]
|
#define cursor_x dimensions[2]
|
||||||
#define cursor_y dimensions[3]
|
#define cursor_y dimensions[3]
|
||||||
|
#define url_y dimensions[5]
|
||||||
|
#define url_xl dimensions[4]
|
||||||
|
#define url_xr dimensions[6]
|
||||||
#define sprite_dx geom[4]
|
#define sprite_dx geom[4]
|
||||||
#define sprite_dy geom[5]
|
#define sprite_dy geom[5]
|
||||||
|
|
||||||
@ -90,8 +94,8 @@ vec3 mix_vecs(float q, vec3 a, vec3 b) {
|
|||||||
return q * a + (1.0 - q) * b;
|
return q * a + (1.0 - q) * b;
|
||||||
}
|
}
|
||||||
|
|
||||||
float in_range(uvec4 range, uint x, uint y) {
|
float in_range(uint x, uint y) {
|
||||||
if (range[2] == y && range[0] <= x && x <= range[1]) return 1.0;
|
if (url_y == y && url_xl <= x && x <= url_xr) return 1.0;
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,8 +107,8 @@ float is_cursor(uint x, uint y) {
|
|||||||
void main() {
|
void main() {
|
||||||
uint instance_id = uint(gl_InstanceID);
|
uint instance_id = uint(gl_InstanceID);
|
||||||
// The current cell being rendered
|
// The current cell being rendered
|
||||||
uint r = instance_id / dimensions.x;
|
uint r = instance_id / xnum;
|
||||||
uint c = instance_id - r * dimensions.x;
|
uint c = instance_id - r * xnum;
|
||||||
|
|
||||||
// The position of this vertex, at a corner of the cell
|
// The position of this vertex, at a corner of the cell
|
||||||
float left = xstart + c * dx;
|
float left = xstart + c * dx;
|
||||||
@ -129,7 +133,7 @@ void main() {
|
|||||||
background = cursor * color_to_vec(cursor_color) + (1.0 - cursor) * background;
|
background = cursor * color_to_vec(cursor_color) + (1.0 - cursor) * background;
|
||||||
|
|
||||||
// Underline and strike through (rendered via sprites)
|
// Underline and strike through (rendered via sprites)
|
||||||
float in_url = in_range(url_range, c, r);
|
float in_url = in_range(c, r);
|
||||||
decoration_fg = mix_vecs(in_url, color_to_vec(url_color), to_color(colors[2], resolved_fg));
|
decoration_fg = mix_vecs(in_url, color_to_vec(url_color), to_color(colors[2], resolved_fg));
|
||||||
underline_pos = mix_vecs(in_url, to_sprite_pos(pos, TWO, ZERO, ZERO), to_sprite_pos(pos, (text_attrs >> 2) & DECORATION_MASK, ZERO, ZERO));
|
underline_pos = mix_vecs(in_url, to_sprite_pos(pos, TWO, ZERO, ZERO), to_sprite_pos(pos, (text_attrs >> 2) & DECORATION_MASK, ZERO, ZERO));
|
||||||
strike_pos = to_sprite_pos(pos, ((text_attrs >> 7) & STRIKE_MASK) * THREE, ZERO, ZERO);
|
strike_pos = to_sprite_pos(pos, ((text_attrs >> 7) & STRIKE_MASK) * THREE, ZERO, ZERO);
|
||||||
|
|||||||
@ -1196,11 +1196,11 @@ screen_apply_selection(Screen *self, void *address, size_t size) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
screen_url_range(Screen *self, unsigned int *start_x, unsigned int *start_y, unsigned int *end_x, unsigned int *end_y) {
|
screen_url_range(Screen *self, uint32_t *data) {
|
||||||
SelectionBoundary start, end;
|
SelectionBoundary start, end;
|
||||||
selection_limits_(url_range, &start, &end);
|
selection_limits_(url_range, &start, &end);
|
||||||
if (is_selection_empty(self, start.x, start.y, end.x, end.y)) { *start_y = self->lines; *end_y = self->lines; *start_x = self->columns; *end_x = self->columns; }
|
if (is_selection_empty(self, start.x, start.y, end.x, end.y)) { *(data + 1) = self->lines; *(data + 3) = self->lines; *data = self->columns; *(data + 2) = self->columns; }
|
||||||
else { *start_x = start.x; *start_y = start.y; *end_x = end.x; *end_y = end.y; }
|
else { *data = start.x; *(data+1) = start.y; *(data + 2) = end.x; *(data + 3) = end.y; }
|
||||||
}
|
}
|
||||||
|
|
||||||
// }}}
|
// }}}
|
||||||
|
|||||||
@ -73,7 +73,7 @@ void screen_update_selection(Screen *self, index_type x, index_type y, bool ende
|
|||||||
bool screen_history_scroll(Screen *self, int amt, bool upwards);
|
bool screen_history_scroll(Screen *self, int amt, bool upwards);
|
||||||
Line* screen_visual_line(Screen *self, index_type y);
|
Line* screen_visual_line(Screen *self, index_type y);
|
||||||
unsigned long screen_current_char_width(Screen *self);
|
unsigned long screen_current_char_width(Screen *self);
|
||||||
void screen_url_range(Screen *self, unsigned int *start_x, unsigned int *start_y, unsigned int *limit_x, unsigned int *limit_y);
|
void screen_url_range(Screen *self, uint32_t *);
|
||||||
void screen_mark_url(Screen *self, index_type start_x, index_type start_y, index_type end_x, index_type end_y);
|
void screen_mark_url(Screen *self, index_type start_x, index_type start_y, index_type end_x, index_type end_y);
|
||||||
#define DECLARE_CH_SCREEN_HANDLER(name) void screen_##name(Screen *screen);
|
#define DECLARE_CH_SCREEN_HANDLER(name) void screen_##name(Screen *screen);
|
||||||
DECLARE_CH_SCREEN_HANDLER(bell)
|
DECLARE_CH_SCREEN_HANDLER(bell)
|
||||||
|
|||||||
@ -552,7 +552,7 @@ destroy_sprite_map() {
|
|||||||
|
|
||||||
// Cell {{{
|
// Cell {{{
|
||||||
|
|
||||||
enum CellUniforms { CELL_dimensions, CELL_default_colors, CELL_color_indices, CELL_sprites, CELL_geom, CELL_url_range, CELL_color_table, NUM_CELL_UNIFORMS };
|
enum CellUniforms { CELL_dimensions, CELL_default_colors, CELL_color_indices, CELL_sprites, CELL_geom, CELL_color_table, NUM_CELL_UNIFORMS };
|
||||||
static GLint cell_uniform_locations[NUM_CELL_UNIFORMS] = {0};
|
static GLint cell_uniform_locations[NUM_CELL_UNIFORMS] = {0};
|
||||||
static GLint cell_uniform_indices[NUM_CELL_UNIFORMS] = {0};
|
static GLint cell_uniform_indices[NUM_CELL_UNIFORMS] = {0};
|
||||||
static GLint cell_color_table_stride = 0, cell_color_table_offset = 0, cell_color_table_size = 0, cell_color_table_block_index = 0;
|
static GLint cell_color_table_stride = 0, cell_color_table_offset = 0, cell_color_table_size = 0, cell_color_table_block_index = 0;
|
||||||
@ -569,7 +569,6 @@ init_cell_program() {
|
|||||||
else SET_LOC(color_indices)
|
else SET_LOC(color_indices)
|
||||||
else SET_LOC(sprites)
|
else SET_LOC(sprites)
|
||||||
else SET_LOC(geom)
|
else SET_LOC(geom)
|
||||||
else SET_LOC(url_range)
|
|
||||||
else { fatal("Unknown uniform in cell program: %s", p->uniforms[i].name); }
|
else { fatal("Unknown uniform in cell program: %s", p->uniforms[i].name); }
|
||||||
}
|
}
|
||||||
if (left) { fatal("Left over uniforms in cell program"); }
|
if (left) { fatal("Left over uniforms in cell program"); }
|
||||||
@ -629,7 +628,10 @@ draw_cells_impl(ssize_t vao_idx, GLfloat xstart, GLfloat ystart, GLfloat dx, GLf
|
|||||||
#define UL(name) cell_uniform_locations[CELL_##name]
|
#define UL(name) cell_uniform_locations[CELL_##name]
|
||||||
bind_program(CELL_PROGRAM);
|
bind_program(CELL_PROGRAM);
|
||||||
bind_vao_uniform_buffer(vao_idx, 2, cell_color_table_block_index);
|
bind_vao_uniform_buffer(vao_idx, 2, cell_color_table_block_index);
|
||||||
glUniform4ui(UL(dimensions), screen->columns, screen->lines, cx, cy); check_gl();
|
static GLuint dimensions[8];
|
||||||
|
dimensions[0] = screen->columns; dimensions[1] = screen->lines; dimensions[2] = cx; dimensions[3] = cy;
|
||||||
|
screen_url_range(screen, dimensions + 4);
|
||||||
|
glUniform1uiv(UL(dimensions), sizeof(dimensions) / sizeof(dimensions[0]), dimensions);
|
||||||
static GLfloat geom[6];
|
static GLfloat geom[6];
|
||||||
unsigned int x, y, z;
|
unsigned int x, y, z;
|
||||||
sprite_map_current_layout(&x, &y, &z);
|
sprite_map_current_layout(&x, &y, &z);
|
||||||
@ -641,9 +643,6 @@ draw_cells_impl(ssize_t vao_idx, GLfloat xstart, GLfloat ystart, GLfloat dx, GLf
|
|||||||
colors[0] = COLOR(default_fg); colors[1] = COLOR(default_bg); colors[2] = COLOR(highlight_fg); colors[3] = COLOR(highlight_bg); colors[4] = cursor->color; colors[5] = OPT(url_color);
|
colors[0] = COLOR(default_fg); colors[1] = COLOR(default_bg); colors[2] = COLOR(highlight_fg); colors[3] = COLOR(highlight_bg); colors[4] = cursor->color; colors[5] = OPT(url_color);
|
||||||
glUniform1uiv(UL(default_colors), sizeof(colors)/sizeof(colors[0]), colors); check_gl();
|
glUniform1uiv(UL(default_colors), sizeof(colors)/sizeof(colors[0]), colors); check_gl();
|
||||||
#undef COLOR
|
#undef COLOR
|
||||||
GLuint start_x, start_y, end_x, end_y;
|
|
||||||
screen_url_range(screen, &start_x, &start_y, &end_x, &end_y);
|
|
||||||
glUniform4ui(UL(url_range), start_x, end_x, start_y, end_y); check_gl();
|
|
||||||
glUniform1i(UL(sprites), sprite_map_unit); check_gl();
|
glUniform1i(UL(sprites), sprite_map_unit); check_gl();
|
||||||
bind_vertex_array(vao_idx);
|
bind_vertex_array(vao_idx);
|
||||||
glDrawArraysInstanced(GL_TRIANGLE_FAN, 0, 4, screen->lines * screen->columns); check_gl();
|
glDrawArraysInstanced(GL_TRIANGLE_FAN, 0, 4, screen->lines * screen->columns); check_gl();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user