diff --git a/libs/video/renderer/vid_render_vulkan.c b/libs/video/renderer/vid_render_vulkan.c index 419636f46..a6c7f9950 100644 --- a/libs/video/renderer/vid_render_vulkan.c +++ b/libs/video/renderer/vid_render_vulkan.c @@ -724,7 +724,7 @@ vulkan_vid_render_shutdown (void) VkDevice dev = device->dev; QFV_DeviceWaitIdle (device); - Mod_ClearAll (); + SCR_Shutdown (); Vulkan_Compose_Shutdown (vulkan_ctx); Vulkan_Translucent_Shutdown (vulkan_ctx); diff --git a/libs/video/renderer/vulkan/render.c b/libs/video/renderer/vulkan/render.c index 9dbeccc35..5b7a20753 100644 --- a/libs/video/renderer/vulkan/render.c +++ b/libs/video/renderer/vulkan/render.c @@ -966,6 +966,7 @@ QFV_Render_Shutdown (vulkan_ctx_t *ctx) if (rctx->task_functions.tab) { Hash_DelTable (rctx->task_functions.tab); } + Hash_DelContext (rctx->hashctx); } void diff --git a/libs/video/renderer/vulkan/vkparse.c b/libs/video/renderer/vulkan/vkparse.c index 6e43e2bb6..6779c7083 100644 --- a/libs/video/renderer/vulkan/vkparse.c +++ b/libs/video/renderer/vulkan/vkparse.c @@ -1226,6 +1226,13 @@ parser_getkey (const void *e, void *unused) static exprtab_t root_symtab = { .symbols = cexpr_lib_symbols, }; + +static void +root_symtab_shutdown (void *data) +{ + Hash_DelTable (root_symtab.tab); +} + static void __attribute__((constructor)) root_symtab_init (void) { @@ -1233,6 +1240,7 @@ root_symtab_init (void) // main and thus before any possibility of threading. exprctx_t root_context = { .symtab = &root_symtab }; cexpr_init_symtab (&root_symtab, &root_context); + Sys_RegisterShutdown (root_symtab_shutdown, 0); } exprenum_t * @@ -1966,6 +1974,17 @@ build_configs (scriptctx_t *sctx) cexpr_init_symtab (&builtin_configs, &ectx); } +static void +delete_configs (void) +{ + int num_plists = 0; + for (exprsym_t *sym = builtin_plist_syms; sym->name; sym++) { + PL_Free (builtin_plists[num_plists]); + num_plists++; + } + free (builtin_plists); +} + static plitem_t * qfv_load_pipeline (vulkan_ctx_t *ctx, const char *name) { @@ -2025,7 +2044,10 @@ void Vulkan_Script_Init (vulkan_ctx_t *ctx) exprctx_t ectx = {}; enum_symtab = Hash_NewTable (61, enum_symtab_getkey, 0, 0, &sctx->hashctx); parser_table = Hash_NewTable (61, parser_getkey, 0, 0, &sctx->hashctx); - ectx.hashctx = &sctx->hashctx; + //FIXME using the script context's hashctx causes the cvar system to access + //freed hash links due to shutdown order issues. The proper fix would be to + //create a symtabs shutdown (for thread safety), but this works for now. + ectx.hashctx = 0;//&sctx->hashctx; vkgen_init_symtabs (&ectx); cexpr_init_symtab (&qfv_output_t_symtab, &ectx); cexpr_init_symtab (&vulkan_frameset_t_symtab, &ectx); @@ -2055,13 +2077,16 @@ void Vulkan_Script_Shutdown (vulkan_ctx_t *ctx) { scriptctx_t *sctx = ctx->script_context; - PL_Free (sctx->pipelineDef); clear_table (&sctx->pipelineLayouts); clear_table (&sctx->setLayouts); clear_table (&sctx->shaderModules); clear_table (&sctx->descriptorPools); clear_table (&sctx->samplers); + delete_configs (); + + Hash_DelContext (sctx->hashctx); + free (sctx); } diff --git a/libs/video/renderer/vulkan/vulkan_renderpass.c b/libs/video/renderer/vulkan/vulkan_renderpass.c index 98a388a78..f490f8228 100644 --- a/libs/video/renderer/vulkan/vulkan_renderpass.c +++ b/libs/video/renderer/vulkan/vulkan_renderpass.c @@ -367,8 +367,6 @@ QFV_RenderPass_Delete (qfv_renderpass_t *renderpass) qfv_device_t *device = ctx->device; qfv_devfuncs_t *dfunc = device->funcs; - PL_Free (renderpass->renderpassDef); - destroy_attachments (ctx, renderpass); dfunc->vkDestroyRenderPass (device->dev, renderpass->renderpass, 0); destroy_renderframes (ctx, renderpass);