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:
raf 2025-09-29 18:40:39 +03:00
commit d1116e7721
Signed by: NotAShelf
GPG key ID: 29D95B64378DB4BF
4 changed files with 221 additions and 114 deletions

View file

@ -87,6 +87,14 @@ static int assign_wallpaper_to_output(chroma_state_t *state,
return CHROMA_ERROR_IMAGE;
}
// Check if image changed and invalidate texture cache if neceessary
bool image_changed = (output->image != image);
if (image_changed && output->image) {
chroma_output_invalidate_texture(output);
chroma_log("DEBUG", "Image changed for output %u, invalidated texture",
output->id);
}
// Assign image to output
output->image = image;