diff --git a/include/QF/Vulkan/qf_draw.h b/include/QF/Vulkan/qf_draw.h index 852a012be..7ef57dc82 100644 --- a/include/QF/Vulkan/qf_draw.h +++ b/include/QF/Vulkan/qf_draw.h @@ -28,6 +28,8 @@ #ifndef __QF_Vulkan_qf_draw_h #define __QF_Vulkan_qf_draw_h +#include "QF/screen.h" + typedef enum { QFV_draw2d, @@ -89,5 +91,6 @@ void Vulkan_Draw_Glyph (int x, int y, int fontid, int glyphid, int c, void Vulkan_LineGraph (int x, int y, int *h_vals, int count, int height, struct vulkan_ctx_s *ctx); +void Vulkan_SetScrFuncs (SCR_Func *scr_funcs, struct vulkan_ctx_s *ctx); #endif//__QF_Vulkan_qf_draw_h diff --git a/libs/video/renderer/vid_render_vulkan.c b/libs/video/renderer/vid_render_vulkan.c index cb81f7ddd..453132477 100644 --- a/libs/video/renderer/vid_render_vulkan.c +++ b/libs/video/renderer/vid_render_vulkan.c @@ -330,10 +330,7 @@ static void vulkan_UpdateScreen (transform_t camera, double realtime, SCR_Func *scr_funcs) { vulkan_set_2d (1);//FIXME - while (*scr_funcs) { - (*scr_funcs) (); - scr_funcs++; - } + Vulkan_SetScrFuncs (scr_funcs, vulkan_ctx); QFV_RunRenderJob (vulkan_ctx); } diff --git a/libs/video/renderer/vulkan/rp_main_def.plist b/libs/video/renderer/vulkan/rp_main_def.plist index 067daa460..56beb01ea 100644 --- a/libs/video/renderer/vulkan/rp_main_def.plist +++ b/libs/video/renderer/vulkan/rp_main_def.plist @@ -1407,6 +1407,7 @@ steps = { tasks = ( { func = wait_on_fence; }, { func = update_matrices; }, + { func = draw_scr_funcs; }, ); }; }; diff --git a/libs/video/renderer/vulkan/vulkan_draw.c b/libs/video/renderer/vulkan/vulkan_draw.c index be42640ee..d3b3d7411 100644 --- a/libs/video/renderer/vulkan/vulkan_draw.c +++ b/libs/video/renderer/vulkan/vulkan_draw.c @@ -207,6 +207,7 @@ typedef struct drawctx_s { VkDescriptorSet core_quad_set; drawframeset_t frames; drawfontset_t fonts; + SCR_Func *scr_funcs; } drawctx_t; #define MAX_QUADS (32768) @@ -229,7 +230,7 @@ get_dyn_descriptor (descpool_t *pool, qpic_t *pic, VkBufferView buffer_view, { qfv_device_t *device = ctx->device; qfv_devfuncs_t *dfunc = device->funcs; - __auto_type pd = (picdata_t *) pic->data; + auto pd = (picdata_t *) pic->data; uint32_t id = pd->descid; for (int i = 0; i < pool->in_use; i++) { if (pool->users[i] == id) { @@ -242,9 +243,9 @@ get_dyn_descriptor (descpool_t *pool, qpic_t *pic, VkBufferView buffer_view, int descid = pool->in_use++; pool->users[descid] = id; if (!pool->sets[descid]) { - __auto_type layout = QFV_AllocDescriptorSetLayoutSet (1, alloca); + auto layout = QFV_AllocDescriptorSetLayoutSet (1, alloca); layout->a[0] = pool->dctx->quad_data_set_layout; - __auto_type set = QFV_AllocateDescriptorSet (device, pool->pool, layout); + auto set = QFV_AllocateDescriptorSet (device, pool->pool, layout); pool->sets[descid] = set->a[0];; free (set);//FIXME allocation } @@ -999,6 +1000,23 @@ line_draw (const exprval_t **params, exprval_t *result, exprctx_t *ectx) dframe->line_verts.count = 0; } +static void +draw_scr_funcs (const exprval_t **params, exprval_t *result, exprctx_t *ectx) +{ + auto taskctx = (qfv_taskctx_t *) ectx; + auto ctx = taskctx->ctx; + auto dctx = ctx->draw_context; + auto scr_funcs = dctx->scr_funcs; + if (!scr_funcs) { + return; + } + while (*scr_funcs) { + (*scr_funcs) (); + scr_funcs++; + } + dctx->scr_funcs = 0; +} + static exprfunc_t flush_draw_func[] = { { .func = flush_draw }, {} @@ -1011,10 +1029,15 @@ static exprfunc_t line_draw_func[] = { { .func = line_draw }, {} }; +static exprfunc_t draw_scr_funcs_func[] = { + { .func = draw_scr_funcs }, + {} +}; static exprsym_t draw_task_syms[] = { { "flush_draw", &cexpr_function, flush_draw_func }, { "slice_draw", &cexpr_function, slice_draw_func }, { "line_draw", &cexpr_function, line_draw_func }, + { "draw_scr_funcs", &cexpr_function, draw_scr_funcs_func }, {} }; @@ -1737,3 +1760,10 @@ Vulkan_LineGraph (int x, int y, int *h_vals, int count, int height, x++; } } + +void +Vulkan_SetScrFuncs (SCR_Func *scr_funcs, vulkan_ctx_t *ctx) +{ + auto dctx = ctx->draw_context; + dctx->scr_funcs = scr_funcs; +}