From 422aaf4bc6c2a72e8d61b3ecc857799c47a101f8 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Tue, 14 Feb 2023 00:55:22 +0900 Subject: [PATCH] [vulkan] Register task functions for the pipelines They're currently just stubs, but this gets the render info loading working without any errors. The next step is to connect up pipelines and create the image resources, then implementing the task functions will have meaning. --- include/QF/Vulkan/render.h | 1 + libs/video/renderer/vid_render_vulkan.c | 3 +- libs/video/renderer/vulkan/render.c | 18 ++++++ libs/video/renderer/vulkan/vulkan_alias.c | 16 +++++ libs/video/renderer/vulkan/vulkan_bsp.c | 60 +++++++++++++++++++ libs/video/renderer/vulkan/vulkan_compose.c | 16 +++++ libs/video/renderer/vulkan/vulkan_iqm.c | 16 +++++ libs/video/renderer/vulkan/vulkan_lighting.c | 16 +++++ libs/video/renderer/vulkan/vulkan_particles.c | 16 +++++ libs/video/renderer/vulkan/vulkan_sprite.c | 16 +++++ 10 files changed, 177 insertions(+), 1 deletion(-) diff --git a/include/QF/Vulkan/render.h b/include/QF/Vulkan/render.h index 418b019fa..e115e0b1b 100644 --- a/include/QF/Vulkan/render.h +++ b/include/QF/Vulkan/render.h @@ -194,5 +194,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); +void QFV_Render_AddTasks (struct vulkan_ctx_s *ctx, exprsym_t *task_sys); #endif//__QF_Vulkan_render_h diff --git a/libs/video/renderer/vid_render_vulkan.c b/libs/video/renderer/vid_render_vulkan.c index 696e550a3..7e80bc68d 100644 --- a/libs/video/renderer/vid_render_vulkan.c +++ b/libs/video/renderer/vid_render_vulkan.c @@ -101,7 +101,6 @@ vulkan_R_Init (void) Vulkan_CreateSwapchain (vulkan_ctx); Vulkan_CreateCapture (vulkan_ctx); - QFV_LoadRenderPass (vulkan_ctx); Vulkan_CreateRenderPasses (vulkan_ctx); Vulkan_Output_Init (vulkan_ctx); @@ -117,6 +116,8 @@ vulkan_R_Init (void) Vulkan_Translucent_Init (vulkan_ctx); Vulkan_Compose_Init (vulkan_ctx); + QFV_LoadRenderPass (vulkan_ctx); + Skin_Init (); SCR_Init (); diff --git a/libs/video/renderer/vulkan/render.c b/libs/video/renderer/vulkan/render.c index 9299ef4d3..d183016e3 100644 --- a/libs/video/renderer/vulkan/render.c +++ b/libs/video/renderer/vulkan/render.c @@ -146,3 +146,21 @@ QFV_Render_Init (vulkan_ctx_t *ctx) cexpr_init_symtab (&rctx->task_functions, &ectx); rctx->task_functions.symbols = 0; } + +void +QFV_Render_AddTasks (vulkan_ctx_t *ctx, exprsym_t *task_syms) +{ + __auto_type rctx = ctx->render_context; + exprctx_t ectx = { .hashctx = &rctx->hashctx }; + for (exprsym_t *sym = task_syms; sym->name; sym++) { + Hash_Add (rctx->task_functions.tab, sym); + for (exprfunc_t *f = sym->value; f->func; f++) { + for (int i = 0; i < f->num_params; i++) { + exprenum_t *e = f->param_types[i]->data; + if (e && !e->symtab->tab) { + cexpr_init_symtab (e->symtab, &ectx); + } + } + } + } +} diff --git a/libs/video/renderer/vulkan/vulkan_alias.c b/libs/video/renderer/vulkan/vulkan_alias.c index 9cf245fff..77634cfe8 100644 --- a/libs/video/renderer/vulkan/vulkan_alias.c +++ b/libs/video/renderer/vulkan/vulkan_alias.c @@ -48,6 +48,7 @@ #include "QF/Vulkan/debug.h" #include "QF/Vulkan/device.h" #include "QF/Vulkan/instance.h" +#include "QF/Vulkan/render.h" #include "r_internal.h" #include "vid_vulkan.h" @@ -295,12 +296,27 @@ Vulkan_AliasRemoveSkin (vulkan_ctx_t *ctx, qfv_alias_skin_t *skin) skin->descriptor = 0; } +static void +alias_draw (const exprval_t **params, exprval_t *result, exprctx_t *ectx) +{ +} + +static exprfunc_t alias_draw_func[] = { + { .func = alias_draw }, + {} +}; +static exprsym_t alias_task_syms[] = { + { "alias_draw", &cexpr_function, alias_draw_func }, + {} +}; + void Vulkan_Alias_Init (vulkan_ctx_t *ctx) { qfv_device_t *device = ctx->device; qfvPushDebug (ctx, "alias init"); + QFV_Render_AddTasks (ctx, alias_task_syms); aliasctx_t *actx = calloc (1, sizeof (aliasctx_t)); ctx->alias_context = actx; diff --git a/libs/video/renderer/vulkan/vulkan_bsp.c b/libs/video/renderer/vulkan/vulkan_bsp.c index 7a3ab9f99..76a782846 100644 --- a/libs/video/renderer/vulkan/vulkan_bsp.c +++ b/libs/video/renderer/vulkan/vulkan_bsp.c @@ -69,6 +69,7 @@ #include "QF/Vulkan/device.h" #include "QF/Vulkan/image.h" #include "QF/Vulkan/instance.h" +#include "QF/Vulkan/render.h" #include "QF/Vulkan/scrap.h" #include "QF/Vulkan/staging.h" @@ -1361,6 +1362,64 @@ create_notexture (vulkan_ctx_t *ctx) bctx->notexture.tex = Vulkan_LoadTexArray (ctx, tex, 2, 1, "notexture"); } +static void +bsp_draw_queue (const exprval_t **params, exprval_t *result, exprctx_t *ectx) +{ +} + +static exprenum_t bsp_stage_enum; +static exprtype_t bsp_stage_type = { + .name = "bsp_stage", + .size = sizeof (int), + .get_string = cexpr_enum_get_string, + .data = &bsp_stage_enum, +}; +static int bsp_stage_values[] = { 0, }; +static exprsym_t bsp_stage_symbols[] = { + {"main", &bsp_stage_type, bsp_stage_values + 0}, + {} +}; +static exprtab_t bsp_stage_symtab = { .symbols = bsp_stage_symbols }; +static exprenum_t bsp_stage_enum = { + &bsp_stage_type, + &bsp_stage_symtab, +}; + +static exprenum_t bsp_queue_enum; +static exprtype_t bsp_queue_type = { + .name = "bsp_queue", + .size = sizeof (int), + .get_string = cexpr_enum_get_string, + .data = &bsp_queue_enum, +}; +static int bsp_queue_values[] = { 0, 1, 2, 3, }; +static exprsym_t bsp_queue_symbols[] = { + {"solid", &bsp_queue_type, bsp_queue_values + 0}, + {"sky", &bsp_queue_type, bsp_queue_values + 1}, + {"translucent", &bsp_queue_type, bsp_queue_values + 2}, + {"turbulent", &bsp_queue_type, bsp_queue_values + 3}, + {} +}; +static exprtab_t bsp_queue_symtab = { .symbols = bsp_queue_symbols }; +static exprenum_t bsp_queue_enum = { + &bsp_queue_type, + &bsp_queue_symtab, +}; + +static exprtype_t *bsp_draw_queue_params[] = { + &bsp_queue_type, + &bsp_stage_type, +}; + +static exprfunc_t bsp_draw_queue_func[] = { + { 0, 2, bsp_draw_queue_params, bsp_draw_queue }, + {} +}; +static exprsym_t bsp_task_syms[] = { + { "bsp_draw_queue", &cexpr_function, bsp_draw_queue_func }, + {} +}; + void Vulkan_Bsp_Init (vulkan_ctx_t *ctx) { @@ -1368,6 +1427,7 @@ Vulkan_Bsp_Init (vulkan_ctx_t *ctx) qfv_devfuncs_t *dfunc = device->funcs; qfvPushDebug (ctx, "bsp init"); + QFV_Render_AddTasks (ctx, bsp_task_syms); bspctx_t *bctx = calloc (1, sizeof (bspctx_t)); ctx->bsp_context = bctx; diff --git a/libs/video/renderer/vulkan/vulkan_compose.c b/libs/video/renderer/vulkan/vulkan_compose.c index 172d69a0f..3d341ef35 100644 --- a/libs/video/renderer/vulkan/vulkan_compose.c +++ b/libs/video/renderer/vulkan/vulkan_compose.c @@ -52,6 +52,7 @@ #include "QF/Vulkan/device.h" #include "QF/Vulkan/image.h" #include "QF/Vulkan/instance.h" +#include "QF/Vulkan/render.h" #include "r_internal.h" #include "vid_vulkan.h" @@ -120,12 +121,27 @@ static VkWriteDescriptorSet base_image_write = { 0, 0, 0 }; +static void +compose_draw (const exprval_t **params, exprval_t *result, exprctx_t *ectx) +{ +} + +static exprfunc_t compose_draw_func[] = { + { .func = compose_draw }, + {} +}; +static exprsym_t compose_task_syms[] = { + { "compose_draw", &cexpr_function, compose_draw_func }, + {} +}; + void Vulkan_Compose_Init (vulkan_ctx_t *ctx) { qfv_device_t *device = ctx->device; qfvPushDebug (ctx, "compose init"); + QFV_Render_AddTasks (ctx, compose_task_syms); composectx_t *cctx = calloc (1, sizeof (composectx_t)); ctx->compose_context = cctx; diff --git a/libs/video/renderer/vulkan/vulkan_iqm.c b/libs/video/renderer/vulkan/vulkan_iqm.c index 467b4546d..42f1486ea 100644 --- a/libs/video/renderer/vulkan/vulkan_iqm.c +++ b/libs/video/renderer/vulkan/vulkan_iqm.c @@ -48,6 +48,7 @@ #include "QF/Vulkan/device.h" #include "QF/Vulkan/instance.h" #include "QF/Vulkan/resource.h" +#include "QF/Vulkan/render.h" #include "r_internal.h" #include "vid_vulkan.h" @@ -360,12 +361,27 @@ Vulkan_IQMRemoveSkin (vulkan_ctx_t *ctx, qfv_iqm_skin_t *skin) skin->descriptor = 0; } +static void +iqm_draw (const exprval_t **params, exprval_t *result, exprctx_t *ectx) +{ +} + +static exprfunc_t iqm_draw_func[] = { + { .func = iqm_draw }, + {} +}; +static exprsym_t iqm_task_syms[] = { + { "iqm_draw", &cexpr_function, iqm_draw_func }, + {} +}; + void Vulkan_IQM_Init (vulkan_ctx_t *ctx) { qfv_device_t *device = ctx->device; qfvPushDebug (ctx, "iqm init"); + QFV_Render_AddTasks (ctx, iqm_task_syms); iqmctx_t *ictx = calloc (1, sizeof (iqmctx_t)); ctx->iqm_context = ictx; diff --git a/libs/video/renderer/vulkan/vulkan_lighting.c b/libs/video/renderer/vulkan/vulkan_lighting.c index a113b3cb2..4439d1d32 100644 --- a/libs/video/renderer/vulkan/vulkan_lighting.c +++ b/libs/video/renderer/vulkan/vulkan_lighting.c @@ -66,6 +66,7 @@ #include "QF/Vulkan/image.h" #include "QF/Vulkan/instance.h" #include "QF/Vulkan/projection.h" +#include "QF/Vulkan/render.h" #include "QF/Vulkan/resource.h" #include "QF/Vulkan/staging.h" @@ -317,6 +318,20 @@ static VkWriteDescriptorSet base_image_write = { 0, 0, 0 }; +static void +lights_draw (const exprval_t **params, exprval_t *result, exprctx_t *ectx) +{ +} + +static exprfunc_t lights_draw_func[] = { + { .func = lights_draw }, + {} +}; +static exprsym_t lighting_task_syms[] = { + { "lights_draw", &cexpr_function, lights_draw_func }, + {} +}; + void Vulkan_Lighting_Init (vulkan_ctx_t *ctx) { @@ -324,6 +339,7 @@ Vulkan_Lighting_Init (vulkan_ctx_t *ctx) qfv_devfuncs_t *dfunc = device->funcs; qfvPushDebug (ctx, "lighting init"); + QFV_Render_AddTasks (ctx, lighting_task_syms); // lighting_context initialized in Vulkan_Lighting_CreateRenderPasses diff --git a/libs/video/renderer/vulkan/vulkan_particles.c b/libs/video/renderer/vulkan/vulkan_particles.c index 5ccdcfe3d..02770a229 100644 --- a/libs/video/renderer/vulkan/vulkan_particles.c +++ b/libs/video/renderer/vulkan/vulkan_particles.c @@ -47,6 +47,7 @@ #include "QF/Vulkan/descriptor.h" #include "QF/Vulkan/device.h" #include "QF/Vulkan/instance.h" +#include "QF/Vulkan/render.h" #include "QF/Vulkan/resource.h" #include "QF/Vulkan/staging.h" #include "QF/Vulkan/qf_matrices.h" @@ -272,6 +273,20 @@ create_buffers (vulkan_ctx_t *ctx) } } +static void +particles_draw (const exprval_t **params, exprval_t *result, exprctx_t *ectx) +{ +} + +static exprfunc_t particles_draw_func[] = { + { .func = particles_draw }, + {} +}; +static exprsym_t particles_task_syms[] = { + { "particles_draw", &cexpr_function, particles_draw_func }, + {} +}; + void Vulkan_Particles_Init (vulkan_ctx_t *ctx) { @@ -279,6 +294,7 @@ Vulkan_Particles_Init (vulkan_ctx_t *ctx) qfv_devfuncs_t *dfunc = device->funcs; qfvPushDebug (ctx, "particles init"); + QFV_Render_AddTasks (ctx, particles_task_syms); particlectx_t *pctx = calloc (1, sizeof (particlectx_t)); ctx->particle_context = pctx; diff --git a/libs/video/renderer/vulkan/vulkan_sprite.c b/libs/video/renderer/vulkan/vulkan_sprite.c index 95612b9b6..e33404806 100644 --- a/libs/video/renderer/vulkan/vulkan_sprite.c +++ b/libs/video/renderer/vulkan/vulkan_sprite.c @@ -63,6 +63,7 @@ #include "QF/Vulkan/descriptor.h" #include "QF/Vulkan/device.h" #include "QF/Vulkan/instance.h" +#include "QF/Vulkan/render.h" #include "r_internal.h" #include "vid_vulkan.h" @@ -284,12 +285,27 @@ Vulkan_Sprint_FreeDescriptors (vulkan_ctx_t *ctx, qfv_sprite_t *sprite) &sprite->descriptors); } +static void +sprite_draw (const exprval_t **params, exprval_t *result, exprctx_t *ectx) +{ +} + +static exprfunc_t sprite_draw_func[] = { + { .func = sprite_draw }, + {} +}; +static exprsym_t sprite_task_syms[] = { + { "sprite_draw", &cexpr_function, sprite_draw_func }, + {} +}; + void Vulkan_Sprite_Init (vulkan_ctx_t *ctx) { qfv_device_t *device = ctx->device; qfvPushDebug (ctx, "sprite init"); + QFV_Render_AddTasks (ctx, sprite_task_syms); spritectx_t *sctx = calloc (1, sizeof (spritectx_t)); ctx->sprite_context = sctx;