From 52f012cc1132dc31b0e6a970610520a7fe822f66 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Tue, 16 Jan 2024 16:44:16 +0900 Subject: [PATCH] [console] Flush any pending draw data This takes care of a 5s hang when the engine aborts before the first frame is rendered (for vulkan). --- include/QF/Vulkan/qf_draw.h | 2 ++ include/QF/draw.h | 1 + include/QF/plugin/vid_render.h | 1 + libs/console/client.c | 2 ++ libs/video/renderer/r_draw.c | 8 ++++++++ libs/video/renderer/vid_render_vulkan.c | 7 +++++++ libs/video/renderer/vulkan/vulkan_draw.c | 6 ++++++ 7 files changed, 27 insertions(+) diff --git a/include/QF/Vulkan/qf_draw.h b/include/QF/Vulkan/qf_draw.h index 40a3326cc..94d80aeaf 100644 --- a/include/QF/Vulkan/qf_draw.h +++ b/include/QF/Vulkan/qf_draw.h @@ -88,5 +88,7 @@ void Vulkan_Draw_ResetClip (struct vulkan_ctx_s *ctx); 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); +void Vulkan_Draw_Flush (struct vulkan_ctx_s *ctx); + #endif//__QF_Vulkan_qf_draw_h diff --git a/include/QF/draw.h b/include/QF/draw.h index 10f60a6b5..34e2f655e 100644 --- a/include/QF/draw.h +++ b/include/QF/draw.h @@ -281,6 +281,7 @@ int Draw_AddFont (struct font_s *font); void Draw_Glyph (int x, int y, int fontid, int glyphid, int c); void Draw_SetClip (int x, int y, int w, int h); void Draw_ResetClip (void); +void Draw_Flush (void); ///@} diff --git a/include/QF/plugin/vid_render.h b/include/QF/plugin/vid_render.h index ef6e9d08a..fd24b78f9 100644 --- a/include/QF/plugin/vid_render.h +++ b/include/QF/plugin/vid_render.h @@ -113,6 +113,7 @@ typedef struct vid_render_funcs_s { void (*Draw_Glyph) (int x, int y, int fontid, int glyphid, int c); void (*Draw_SetClip) (int x, int y, int w, int h); void (*Draw_ResetClip) (void); + void (*Draw_Flush) (void); struct psystem_s *(*ParticleSystem) (void); struct psystem_s *(*TrailSystem) (void); diff --git a/libs/console/client.c b/libs/console/client.c index 9e3b05d41..067c76db3 100644 --- a/libs/console/client.c +++ b/libs/console/client.c @@ -1233,6 +1233,8 @@ C_Init (void) "file"); con_initialized = true; + + Draw_Flush (); } static void diff --git a/libs/video/renderer/r_draw.c b/libs/video/renderer/r_draw.c index f5537f629..65a4f1452 100644 --- a/libs/video/renderer/r_draw.c +++ b/libs/video/renderer/r_draw.c @@ -156,3 +156,11 @@ Draw_MaxScale (void) { return r_funcs->Draw_SetScale ? 20 : 1; } + +void +Draw_Flush (void) +{ + if (r_funcs->Draw_Flush) { + r_funcs->Draw_Flush (); + } +} diff --git a/libs/video/renderer/vid_render_vulkan.c b/libs/video/renderer/vid_render_vulkan.c index fadb764f8..a2619ea52 100644 --- a/libs/video/renderer/vid_render_vulkan.c +++ b/libs/video/renderer/vid_render_vulkan.c @@ -339,6 +339,12 @@ vulkan_Draw_ResetClip (void) Vulkan_Draw_ResetClip (vulkan_ctx); } +static void +vulkan_Draw_Flush (void) +{ + Vulkan_Draw_Flush (vulkan_ctx); +} + static void vulkan_set_2d (int scaled) { @@ -625,6 +631,7 @@ vid_render_funcs_t vulkan_vid_render_funcs = { .Draw_Glyph = vulkan_Draw_Glyph, .Draw_SetClip = vulkan_Draw_SetClip, .Draw_ResetClip = vulkan_Draw_ResetClip, + .Draw_Flush = vulkan_Draw_Flush, .ParticleSystem = vulkan_ParticleSystem, .R_Init = vulkan_R_Init, diff --git a/libs/video/renderer/vulkan/vulkan_draw.c b/libs/video/renderer/vulkan/vulkan_draw.c index fea1afb32..b333d9ba8 100644 --- a/libs/video/renderer/vulkan/vulkan_draw.c +++ b/libs/video/renderer/vulkan/vulkan_draw.c @@ -1867,3 +1867,9 @@ Vulkan_SetScrFuncs (SCR_Func *scr_funcs, vulkan_ctx_t *ctx) auto dctx = ctx->draw_context; dctx->scr_funcs = scr_funcs; } + +void +Vulkan_Draw_Flush (vulkan_ctx_t *ctx) +{ + flush_draw_scrap (ctx); +}