From 828dacc10b742d8aa25ef6c4b4c6b8f6a36ca3d3 Mon Sep 17 00:00:00 2001 From: zhibin wang Date: Mon, 5 Dec 2022 14:44:53 +0000 Subject: [PATCH] c/client: Fix eglDestroyImageKHR error and add AHB buffer release --- .../compositor/client/comp_gl_eglimage_swapchain.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/xrt/compositor/client/comp_gl_eglimage_swapchain.c b/src/xrt/compositor/client/comp_gl_eglimage_swapchain.c index c51451464..f4a3b702a 100644 --- a/src/xrt/compositor/client/comp_gl_eglimage_swapchain.c +++ b/src/xrt/compositor/client/comp_gl_eglimage_swapchain.c @@ -17,6 +17,7 @@ #include "util/u_misc.h" #include "util/u_logging.h" #include "util/u_debug.h" +#include "util/u_handles.h" #include #include @@ -73,9 +74,11 @@ client_gl_eglimage_swapchain_teardown_storage(struct client_gl_eglimage_swapchai glDeleteTextures(image_count, &sc->base.base.images[0]); U_ZERO_ARRAY(sc->base.base.images); for (uint32_t i = 0; i < image_count; ++i) { - if (sc->egl_images[i] != NULL) { - eglDestroyImageKHR(sc->display, &(sc->egl_images[i])); + if (sc->egl_images[i] == EGL_NO_IMAGE_KHR) { + continue; } + eglDestroyImageKHR(sc->display, sc->egl_images[i]); + sc->egl_images[i] = EGL_NO_IMAGE_KHR; } U_ZERO_ARRAY(sc->egl_images); } @@ -85,8 +88,12 @@ static void client_gl_eglimage_swapchain_destroy(struct xrt_swapchain *xsc) { struct client_gl_eglimage_swapchain *sc = client_gl_eglimage_swapchain(xsc); + uint32_t image_count = sc->base.base.base.image_count; client_gl_eglimage_swapchain_teardown_storage(sc); + for (uint32_t i = 0; i < image_count; i++) { + u_graphics_buffer_unref(&sc->base.xscn->images[i].handle); + } sc->base.base.base.image_count = 0; // Drop our reference, does NULL checking.