diff --git a/include/QF/Vulkan/render.h b/include/QF/Vulkan/render.h index 9c5f35ef6..418b019fa 100644 --- a/include/QF/Vulkan/render.h +++ b/include/QF/Vulkan/render.h @@ -6,6 +6,7 @@ #endif #include +#include "QF/cexpr.h" #include "QF/simd/types.h" typedef struct qfv_reference_s { @@ -66,8 +67,8 @@ typedef struct qfv_attachmentinfo_s { } qfv_attachmentinfo_t; typedef struct qfv_taskinfo_s { - struct exprfunc_s *func; - const struct exprval_s **params; + exprfunc_t *func; + const exprval_t **params; void *param_data; } qfv_taskinfo_t; @@ -134,7 +135,8 @@ typedef struct qfv_renderinfo_s { } qfv_renderinfo_t; typedef struct qfv_renderctx_s { - struct exprtab_s *task_functions; + struct hashctx_s *hashctx; + exprtab_t task_functions; } qfv_renderctx_t; typedef struct qfv_label_s { @@ -191,5 +193,6 @@ typedef struct qfv_renderpass_s_ { void QFV_RunRenderPass (qfv_renderpass_t_ *rp, struct vulkan_ctx_s *ctx); void QFV_LoadRenderPass (struct vulkan_ctx_s *ctx); +void QFV_Render_Init (struct vulkan_ctx_s *ctx); #endif//__QF_Vulkan_render_h diff --git a/include/vid_vulkan.h b/include/vid_vulkan.h index 2a9936a99..f5d406de4 100644 --- a/include/vid_vulkan.h +++ b/include/vid_vulkan.h @@ -46,6 +46,7 @@ typedef struct vulkan_ctx_s { uint32_t swapImageIndex; struct scriptctx_s *script_context; + struct qfv_renderctx_s *render_context; struct texturectx_s *texture_context; struct matrixctx_s *matrix_context; struct translucentctx_s *translucent_context; diff --git a/libs/video/renderer/vid_render_vulkan.c b/libs/video/renderer/vid_render_vulkan.c index 701b39031..696e550a3 100644 --- a/libs/video/renderer/vid_render_vulkan.c +++ b/libs/video/renderer/vid_render_vulkan.c @@ -91,6 +91,8 @@ vulkan_ParticleSystem (void) static void vulkan_R_Init (void) { + QFV_Render_Init (vulkan_ctx); + Vulkan_CreateStagingBuffers (vulkan_ctx); Vulkan_CreateFrames (vulkan_ctx); Vulkan_Texture_Init (vulkan_ctx); diff --git a/libs/video/renderer/vulkan/render.c b/libs/video/renderer/vulkan/render.c index eb5311c86..9299ef4d3 100644 --- a/libs/video/renderer/vulkan/render.c +++ b/libs/video/renderer/vulkan/render.c @@ -125,27 +125,24 @@ QFV_RunRenderPass (qfv_renderpass_t_ *rp, vulkan_ctx_t *ctx) QFV_CmdEndLabel (device, cmd); } -static exprsym_t qfv_renderpass_task_symbols[] = { - - {} -}; - void QFV_LoadRenderPass (vulkan_ctx_t *ctx) { - - exprtab_t task_tab = { qfv_renderpass_task_symbols, 0 }; - exprctx_t ectx = { - .symtab = &task_tab, - .hashctx = &ctx->script_context->hashctx, - }; - cexpr_init_symtab (&task_tab, &ectx); - - qfv_renderctx_t rctx = { .task_functions = &task_tab }; + __auto_type rctx = ctx->render_context; plitem_t *item = Vulkan_GetConfig (ctx, "main_def"); - __auto_type ri = QFV_ParseRenderInfo (ctx, item, &rctx); - printf ("%p\n", ri); - - Hash_DelTable (task_tab.tab); + QFV_ParseRenderInfo (ctx, item, rctx); +} + +void +QFV_Render_Init (vulkan_ctx_t *ctx) +{ + qfv_renderctx_t *rctx = calloc (1, sizeof (*rctx)); + ctx->render_context = rctx; + + exprctx_t ectx = { .hashctx = &rctx->hashctx }; + exprsym_t syms[] = { {} }; + rctx->task_functions.symbols = syms; + cexpr_init_symtab (&rctx->task_functions, &ectx); + rctx->task_functions.symbols = 0; } diff --git a/libs/video/renderer/vulkan/vkparse.c b/libs/video/renderer/vulkan/vkparse.c index 691325ee5..b0b256446 100644 --- a/libs/video/renderer/vulkan/vkparse.c +++ b/libs/video/renderer/vulkan/vkparse.c @@ -1087,7 +1087,7 @@ parse_task_function (const plitem_t *item, void **data, { qfv_renderctx_t *rctx = pctx->data; const char *fname = PL_String (item); - exprsym_t *fsym = Hash_Find (rctx->task_functions->tab, fname); + exprsym_t *fsym = Hash_Find (rctx->task_functions.tab, fname); if (!fsym) { PL_Message (messages, item, "undefined task function %s", fname); @@ -1145,6 +1145,10 @@ parse_task_params (const plitem_t *item, void **data, { exprfunc_t *func = *(exprfunc_t **) data[0]; exprval_t **params = *(exprval_t ***) data[1]; + if (!func) { + PL_Message (messages, item, "task function not set"); + return 0; + } if (PL_A_NumObjects (item) != func->num_params) { PL_Message (messages, item, "incorrect number of parameters"); return 0;