perf(opengl): remove long delay when destroying shader programs (#9037)

This commit is contained in:
Matt
2025-10-30 12:33:22 -04:00
committed by GitHub
parent 1a44487cba
commit 7533a45cd1
2 changed files with 16 additions and 1 deletions
@@ -213,6 +213,7 @@ lv_result_t lv_opengl_shader_manager_select_shader(lv_opengl_shader_manager_t *
GL_CALL(glGetShaderInfoLog(shader_map_key.id, sizeof(info_log), NULL, info_log));
LV_LOG_WARN("Failed to compile shader for glsl version '%s': %s", lv_opengles_glsl_version_to_string(glsl_version),
info_log);
GL_CALL(glDeleteShader(shader_map_key.id));
return LV_RESULT_INVALID;
}
@@ -269,6 +270,7 @@ lv_opengl_shader_manager_get_program(lv_opengl_shader_manager_t * manager,
GL_CALL(glGetProgramInfoLog(program_id, sizeof(info_log), NULL,
info_log));
LV_LOG_WARN("Failed to link program: %s", info_log);
GL_CALL(glDeleteProgram(program_id));
return NULL;
}
LV_LOG_TRACE("Linking program with shaders V: %d F:%d P: %d", vertex_shader_id, fragment_shader_id, program_id);
@@ -76,7 +76,20 @@ void lv_opengl_shader_program_destroy(lv_opengl_shader_program_t * program)
}
#endif
GL_CALL(glDeleteProgram(program->id));
/* We should be able to call the function below without issue at this point
* but because of subtle issues regarding lazy updates of shader resources
* this induces significant pause on some platforms. Since the shaders
* have already been detached, we can safely skip this function and leave
* the empty programs in OpenGL's cache until the app shuts down, it's a
* very small amount of memory.
*
* To-do: Consider setting a flag at this point and if that flag is true
* when the app finally shuts down, then perform the glDeleteProgram calls
* if necessary. That is not really necessary, OpenGL will do that anyways
* when it shuts down. */
/* GL_CALL(glDeleteProgram(program->id)); */
}
GLuint lv_opengl_shader_program_get_id(lv_opengl_shader_program_t * program)