render: add OpenGL resource caching; optimize texture handling
Mildly improves rendering performance by caching OpenGL resources. Namely: - Cache shader program, VBO/EBO, and textures per output - Automatically free image data after GPU upload - Force RGBA format for consistent texture handling - Track texture state across output changes - Add texture invalidation on image changes This reduces the memory usage by a solid 30MB, but it's still not quite enough. I expect (or rather, hope) that we can cut it by half. Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I6a6a6964eebc783c5bc07b1fef7548a8d49f529c
This commit is contained in:
parent
3cbf6d5645
commit
d1116e7721
4 changed files with 221 additions and 114 deletions
|
@ -62,6 +62,14 @@ typedef struct {
|
|||
|
||||
// Associated wallpaper
|
||||
chroma_image_t *image;
|
||||
|
||||
// OpenGL resource cache
|
||||
GLuint texture_id;
|
||||
GLuint shader_program;
|
||||
GLuint vbo;
|
||||
GLuint ebo;
|
||||
bool gl_resources_initialized;
|
||||
bool texture_uploaded;
|
||||
} chroma_output_t;
|
||||
|
||||
// Config mapping structure
|
||||
|
@ -150,6 +158,7 @@ void chroma_egl_cleanup(chroma_state_t *state);
|
|||
int chroma_surface_create(chroma_state_t *state, chroma_output_t *output);
|
||||
void chroma_surface_destroy(chroma_output_t *output);
|
||||
int chroma_render_wallpaper(chroma_state_t *state, chroma_output_t *output);
|
||||
void chroma_output_invalidate_texture(chroma_output_t *output);
|
||||
|
||||
// Layer shell functions
|
||||
void chroma_layer_surface_configure(void *data,
|
||||
|
@ -219,4 +228,4 @@ extern const struct zwlr_layer_surface_v1_listener
|
|||
// Global state for signal handling
|
||||
extern volatile sig_atomic_t chroma_should_quit;
|
||||
|
||||
#endif // CHROMA_H
|
||||
#endif // CHROMA_H
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue