render/gles2: destroy textures on renderer teardown
This commit is contained in:
parent
9901d49fa5
commit
661ba49564
|
@ -67,6 +67,7 @@ struct wlr_gles2_renderer {
|
|||
} shaders;
|
||||
|
||||
struct wl_list buffers; // wlr_gles2_buffer.link
|
||||
struct wl_list textures; // wlr_gles2_texture.link
|
||||
|
||||
struct wlr_gles2_buffer *current_buffer;
|
||||
uint32_t viewport_width, viewport_height;
|
||||
|
@ -87,6 +88,7 @@ struct wlr_gles2_buffer {
|
|||
struct wlr_gles2_texture {
|
||||
struct wlr_texture wlr_texture;
|
||||
struct wlr_gles2_renderer *renderer;
|
||||
struct wl_list link; // wlr_gles2_renderer.textures
|
||||
|
||||
// Basically:
|
||||
// GL_TEXTURE_2D == mutable
|
||||
|
|
|
@ -542,6 +542,11 @@ static void gles2_destroy(struct wlr_renderer *wlr_renderer) {
|
|||
destroy_buffer(buffer);
|
||||
}
|
||||
|
||||
struct wlr_gles2_texture *tex, *tex_tmp;
|
||||
wl_list_for_each_safe(tex, tex_tmp, &renderer->textures, link) {
|
||||
wlr_texture_destroy(&tex->wlr_texture);
|
||||
}
|
||||
|
||||
push_gles2_debug(renderer);
|
||||
glDeleteProgram(renderer->shaders.quad.program);
|
||||
glDeleteProgram(renderer->shaders.tex_rgba.program);
|
||||
|
@ -763,6 +768,7 @@ struct wlr_renderer *wlr_gles2_renderer_create(struct wlr_egl *egl) {
|
|||
wlr_renderer_init(&renderer->wlr_renderer, &renderer_impl);
|
||||
|
||||
wl_list_init(&renderer->buffers);
|
||||
wl_list_init(&renderer->textures);
|
||||
|
||||
renderer->egl = egl;
|
||||
renderer->exts_str = exts_str;
|
||||
|
|
|
@ -105,6 +105,8 @@ static void gles2_texture_destroy(struct wlr_texture *wlr_texture) {
|
|||
|
||||
struct wlr_gles2_texture *texture = gles2_get_texture(wlr_texture);
|
||||
|
||||
wl_list_remove(&texture->link);
|
||||
|
||||
struct wlr_egl_context prev_ctx;
|
||||
wlr_egl_save_context(&prev_ctx);
|
||||
wlr_egl_make_current(texture->renderer->egl);
|
||||
|
@ -181,6 +183,8 @@ struct wlr_texture *gles2_texture_from_pixels(struct wlr_renderer *wlr_renderer,
|
|||
|
||||
wlr_egl_restore_context(&prev_ctx);
|
||||
|
||||
wl_list_insert(&renderer->textures, &texture->link);
|
||||
|
||||
return &texture->wlr_texture;
|
||||
}
|
||||
|
||||
|
@ -248,6 +252,8 @@ struct wlr_texture *gles2_texture_from_wl_drm(struct wlr_renderer *wlr_renderer,
|
|||
|
||||
wlr_egl_restore_context(&prev_ctx);
|
||||
|
||||
wl_list_insert(&renderer->textures, &texture->link);
|
||||
|
||||
return &texture->wlr_texture;
|
||||
|
||||
error_texture:
|
||||
|
@ -316,6 +322,8 @@ struct wlr_texture *gles2_texture_from_dmabuf(struct wlr_renderer *wlr_renderer,
|
|||
|
||||
wlr_egl_restore_context(&prev_ctx);
|
||||
|
||||
wl_list_insert(&renderer->textures, &texture->link);
|
||||
|
||||
return &texture->wlr_texture;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue