various: log memory events
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I6a6a69643b6d00277bb9bcfeb4cd01dc78d7cd3d
This commit is contained in:
parent
0bc2decb7c
commit
bc77b887ad
7 changed files with 280 additions and 47 deletions
29
src/render.c
29
src/render.c
|
|
@ -156,6 +156,15 @@ static int update_texture_from_image(chroma_output_t *output,
|
|||
|
||||
// Delete existing texture if it exists
|
||||
if (output->texture_id != 0) {
|
||||
// Estimate texture size for logging
|
||||
// FIXME: Unfortunately this only works if we have previous image info.
|
||||
// Could this b made more accurate?
|
||||
if (output->image && output->image->loaded) {
|
||||
size_t texture_size = (size_t)output->image->width *
|
||||
output->image->height * output->image->channels;
|
||||
chroma_log_resource_deallocation("gpu_texture", texture_size,
|
||||
"texture replacement");
|
||||
}
|
||||
glDeleteTextures(1, &output->texture_id);
|
||||
output->texture_id = 0;
|
||||
}
|
||||
|
|
@ -164,6 +173,10 @@ static int update_texture_from_image(chroma_output_t *output,
|
|||
glGenTextures(1, &output->texture_id);
|
||||
glBindTexture(GL_TEXTURE_2D, output->texture_id);
|
||||
|
||||
// Log GPU texture allocation
|
||||
size_t texture_size = (size_t)image->width * image->height * image->channels;
|
||||
chroma_log_resource_allocation("gpu_texture", texture_size, image->path);
|
||||
|
||||
// Set texture parameters
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
|
|
@ -207,6 +220,9 @@ static int update_texture_from_image(chroma_output_t *output,
|
|||
"GPU: %s",
|
||||
(double)freed_bytes / (1024.0 * 1024.0), total_using,
|
||||
image->path);
|
||||
chroma_log_resource_deallocation("image_data", freed_bytes,
|
||||
"post-gpu-upload");
|
||||
chroma_log_memory_stats("post-gpu-upload");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -222,6 +238,7 @@ static void cleanup_gl_resources(chroma_output_t *output) {
|
|||
}
|
||||
|
||||
if (output->texture_id != 0) {
|
||||
chroma_log_resource_deallocation("gpu_texture", 0, "cleanup");
|
||||
glDeleteTextures(1, &output->texture_id);
|
||||
output->texture_id = 0;
|
||||
}
|
||||
|
|
@ -296,6 +313,7 @@ int chroma_egl_init(chroma_state_t *state) {
|
|||
}
|
||||
|
||||
chroma_log("INFO", "EGL initialized: version %d.%d", major, minor);
|
||||
chroma_log_memory_stats("post-egl-init");
|
||||
|
||||
// Bind OpenGL API
|
||||
if (!eglBindAPI(EGL_OPENGL_API)) {
|
||||
|
|
@ -420,6 +438,11 @@ int chroma_surface_create(chroma_state_t *state, chroma_output_t *output) {
|
|||
chroma_log("INFO", "Created surface for output %u (%dx%d)", output->id,
|
||||
output->width, output->height);
|
||||
|
||||
// Log surface creation resource allocation
|
||||
size_t surface_size =
|
||||
(size_t)output->width * output->height * 4; // estimate RGBA surface
|
||||
chroma_log_resource_allocation("egl_surface", surface_size, "output surface");
|
||||
|
||||
return CHROMA_OK;
|
||||
}
|
||||
|
||||
|
|
@ -452,6 +475,12 @@ void chroma_surface_destroy(chroma_output_t *output) {
|
|||
output->surface = NULL;
|
||||
}
|
||||
|
||||
// Log surface destruction
|
||||
size_t surface_size =
|
||||
(size_t)output->width * output->height * 4; // estimate RGBA surface
|
||||
chroma_log_resource_deallocation("egl_surface", surface_size,
|
||||
"output surface cleanup");
|
||||
|
||||
chroma_log("DEBUG", "Destroyed surface for output %u", output->id);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue