mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-02 12:44:01 +02:00
Micro optimization: When sending cell uniform data dont even map the color table region in memory unless the color table is dirty
This commit is contained in:
10
kitty/gl.c
10
kitty/gl.c
@@ -391,6 +391,12 @@ map_buffer(ssize_t idx, GLenum access) {
|
||||
return ans;
|
||||
}
|
||||
|
||||
static void*
|
||||
map_buffer_range(ssize_t idx, GLbitfield access, int offset, unsigned size) {
|
||||
return glMapBufferRange(buffers[idx].usage, offset, size, access);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
unmap_buffer(ssize_t idx) {
|
||||
glUnmapBuffer(buffers[idx].usage);
|
||||
@@ -500,10 +506,10 @@ alloc_vao_buffer(ssize_t vao_idx, GLsizeiptr size, size_t bufnum, GLenum usage)
|
||||
}
|
||||
|
||||
void*
|
||||
map_vao_buffer(ssize_t vao_idx, size_t bufnum, GLenum access) {
|
||||
map_vao_buffer_for_write_only(ssize_t vao_idx, size_t bufnum, int offset, unsigned size) {
|
||||
ssize_t buf_idx = vaos[vao_idx].buffers[bufnum];
|
||||
bind_buffer(buf_idx);
|
||||
return map_buffer(buf_idx, access);
|
||||
return map_buffer_range(buf_idx, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_RANGE_BIT, offset, size);
|
||||
}
|
||||
|
||||
void*
|
||||
|
||||
@@ -55,6 +55,7 @@ ssize_t alloc_vao_buffer(ssize_t vao_idx, GLsizeiptr size, size_t bufnum, GLenum
|
||||
void* alloc_and_map_vao_buffer(ssize_t vao_idx, GLsizeiptr size, size_t bufnum, GLenum usage, GLenum access);
|
||||
void unmap_vao_buffer(ssize_t vao_idx, size_t bufnum);
|
||||
void* map_vao_buffer(ssize_t vao_idx, size_t bufnum, GLenum access);
|
||||
void* map_vao_buffer_for_write_only(ssize_t vao_idx, size_t bufnum, int offset, unsigned size);
|
||||
void bind_program(int program);
|
||||
void bind_vertex_array(ssize_t vao_idx);
|
||||
void bind_vao_uniform_buffer(ssize_t vao_idx, size_t bufnum, GLuint block_index);
|
||||
|
||||
@@ -450,9 +450,11 @@ cell_update_uniform_block(ssize_t vao_idx, Screen *screen, int uniform_buffer, c
|
||||
GLfloat bg_opacities0, bg_opacities1, bg_opacities2, bg_opacities3, bg_opacities4, bg_opacities5, bg_opacities6, bg_opacities7;
|
||||
};
|
||||
// Send the uniform data
|
||||
struct GPUCellRenderData *rd = (struct GPUCellRenderData*)map_vao_buffer(vao_idx, uniform_buffer, GL_WRITE_ONLY);
|
||||
ColorProfile *cp = screen->paused_rendering.expires_at ? &screen->paused_rendering.color_profile : screen->color_profile;
|
||||
if (UNLIKELY(cp->dirty || screen->reload_all_gpu_data)) {
|
||||
const bool color_table_needs_upload = cp->dirty || screen->reload_all_gpu_data;
|
||||
const unsigned sz = color_table_needs_upload ? cell_program_layouts[CELL_PROGRAM].render_data.size : cell_program_layouts[CELL_PROGRAM].color_table.offset;
|
||||
struct GPUCellRenderData *rd = (struct GPUCellRenderData*)map_vao_buffer_for_write_only(vao_idx, uniform_buffer, 0, sz);
|
||||
if (color_table_needs_upload) {
|
||||
copy_color_table_to_buffer(cp, (GLuint*)rd, cell_program_layouts[CELL_PROGRAM].color_table.offset / sizeof(GLuint), cell_program_layouts[CELL_PROGRAM].color_table.stride / sizeof(GLuint));
|
||||
}
|
||||
#define COLOR(name) colorprofile_to_color(cp, cp->overridden.name, cp->configured.name).rgb
|
||||
|
||||
Reference in New Issue
Block a user