diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index 5abe1e020c..bd29113648 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -3213,6 +3213,8 @@ static void gl2_free(void *data) gl2_renderchain_deinit_hw_render(gl, (gl2_renderchain_data_t*)gl->renderchain_data); gl2_deinit_chain(gl); + if (gl->ctx_driver && gl->ctx_driver->destroy) + gl->ctx_driver->destroy(gl->ctx_data); video_context_driver_free(); gl2_destroy_resources(gl); diff --git a/gfx/drivers/gl1.c b/gfx/drivers/gl1.c index ad588852e1..1abec2ab41 100644 --- a/gfx/drivers/gl1.c +++ b/gfx/drivers/gl1.c @@ -1032,6 +1032,8 @@ static void gl1_gfx_free(void *data) gl1->extensions = NULL; font_driver_free_osd(); + if (gl1->ctx_driver && gl1->ctx_driver->destroy) + gl1->ctx_driver->destroy(gl1->ctx_data); video_context_driver_free(); free(gl1); } diff --git a/gfx/drivers/gl_core.c b/gfx/drivers/gl_core.c index a2aa2756ae..f71ce4869b 100644 --- a/gfx/drivers/gl_core.c +++ b/gfx/drivers/gl_core.c @@ -1539,6 +1539,8 @@ static void gl_core_free(void *data) gl_core_context_bind_hw_render(gl, false); font_driver_free_osd(); gl_core_destroy_resources(gl); + if (gl->ctx_driver && gl->ctx_driver->destroy) + gl->ctx_driver->destroy(gl->ctx_data); video_context_driver_free(); } diff --git a/gfx/drivers/vg.c b/gfx/drivers/vg.c index 689bd36e6c..20d705533d 100644 --- a/gfx/drivers/vg.c +++ b/gfx/drivers/vg.c @@ -309,6 +309,8 @@ static void vg_free(void *data) vgDestroyPaint(vg->mPaintBg); } + if (vg->ctx_driver && vg->ctx_driver->destroy) + vg->ctx_driver->destroy(vg->ctx_data); video_context_driver_free(); free(vg); diff --git a/gfx/drivers/vulkan.c b/gfx/drivers/vulkan.c index 07ac8238f9..c91ae1ba5d 100644 --- a/gfx/drivers/vulkan.c +++ b/gfx/drivers/vulkan.c @@ -972,6 +972,8 @@ static void vulkan_free(void *data) if (vk->filter_chain) vulkan_filter_chain_free((vulkan_filter_chain_t*)vk->filter_chain); + if (vk->ctx_driver && vk->ctx_driver->destroy) + vk->ctx_driver->destroy(vk->ctx_data); video_context_driver_free(); } diff --git a/retroarch.c b/retroarch.c index 2f8d75b43b..a1ab7e4221 100644 --- a/retroarch.c +++ b/retroarch.c @@ -33494,8 +33494,6 @@ const gfx_ctx_driver_t *video_context_driver_init_first(void *data, void video_context_driver_free(void) { struct rarch_state *p_rarch = &rarch_st; - if (p_rarch->current_video_context.destroy) - p_rarch->current_video_context.destroy(p_rarch->video_context_data); video_context_driver_destroy_internal(&p_rarch->current_video_context); p_rarch->video_context_data = NULL; }