From 8e3532d54323ecb5b7e917414a1933816cfbf547 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Sun, 28 Jan 2024 14:10:47 +0900 Subject: [PATCH] [vulkan] Add a cvar to select between deferred and forward Finally. However, it has effect only when no render config is provided. When a config is provided, things will break currently as nothing is done yet, but getting a config in will take some work in qwaq and also the render graph system as I want to make the startup functions configurable. --- include/QF/Vulkan/render.h | 4 ++-- libs/video/renderer/vid_render_vulkan.c | 21 +++++++++++++++++++-- libs/video/renderer/vulkan/render_load.c | 6 ++---- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/include/QF/Vulkan/render.h b/include/QF/Vulkan/render.h index e07677b7f..dfde03061 100644 --- a/include/QF/Vulkan/render.h +++ b/include/QF/Vulkan/render.h @@ -463,8 +463,8 @@ void QFV_RunRenderPassCmd (VkCommandBuffer cmd, struct vulkan_ctx_s *ctx, void QFV_RunRenderPass (struct vulkan_ctx_s *ctx, qfv_renderpass_t *renderpass, uint32_t width, uint32_t height, void *data); void QFV_RunRenderJob (struct vulkan_ctx_s *ctx); -void QFV_LoadRenderInfo (struct vulkan_ctx_s *ctx, const char *name); -void QFV_LoadSamplerInfo (struct vulkan_ctx_s *ctx, const char *name); +void QFV_LoadRenderInfo (struct vulkan_ctx_s *ctx, struct plitem_s *item); +void QFV_LoadSamplerInfo (struct vulkan_ctx_s *ctx, struct plitem_s *item); void QFV_BuildRender (struct vulkan_ctx_s *ctx); void QFV_Render_Init (struct vulkan_ctx_s *ctx); void QFV_Render_Shutdown (struct vulkan_ctx_s *ctx); diff --git a/libs/video/renderer/vid_render_vulkan.c b/libs/video/renderer/vid_render_vulkan.c index 2184ae670..bd4f37548 100644 --- a/libs/video/renderer/vid_render_vulkan.c +++ b/libs/video/renderer/vid_render_vulkan.c @@ -83,6 +83,16 @@ static vulkan_ctx_t *vulkan_ctx; +static int vulkan_render_mode; +static cvar_t vulkan_render_mode_cvar = { + .name = "vulkan_render_mode", + .description = + "Use deferred (1) or forward (0) rendering for quake.", + .default_value = "1", + .flags = CVAR_ROM, + .value = { .type = &cexpr_int, .value = &vulkan_render_mode }, +}; + static struct psystem_s * vulkan_ParticleSystem (void) { @@ -116,8 +126,14 @@ vulkan_R_Init (struct plitem_s *config) Vulkan_Translucent_Init (vulkan_ctx); Vulkan_Compose_Init (vulkan_ctx); - QFV_LoadRenderInfo (vulkan_ctx, "main_def"); - QFV_LoadSamplerInfo (vulkan_ctx, "smp_quake"); + if (config) { + } else { + const char *mode = vulkan_render_mode ? "main_def" : "main_fwd"; + auto render_graph = Vulkan_GetConfig (vulkan_ctx, mode); + auto samplers = Vulkan_GetConfig (vulkan_ctx, "smp_quake"); + QFV_LoadRenderInfo (vulkan_ctx, render_graph); + QFV_LoadSamplerInfo (vulkan_ctx, samplers); + } QFV_BuildRender (vulkan_ctx); Vulkan_Texture_Setup (vulkan_ctx); @@ -543,6 +559,7 @@ vulkan_vid_render_init (void) vulkan_ctx = vi->vulkan_context (vi); vulkan_ctx->load_vulkan (vulkan_ctx); + Cvar_Register (&vulkan_render_mode_cvar, 0, 0); Vulkan_Init_Common (vulkan_ctx); vi->set_palette = set_palette; diff --git a/libs/video/renderer/vulkan/render_load.c b/libs/video/renderer/vulkan/render_load.c index 0b068c77a..f7ec33189 100644 --- a/libs/video/renderer/vulkan/render_load.c +++ b/libs/video/renderer/vulkan/render_load.c @@ -73,11 +73,10 @@ get_output (vulkan_ctx_t *ctx, plitem_t *item) } void -QFV_LoadRenderInfo (vulkan_ctx_t *ctx, const char *name) +QFV_LoadRenderInfo (vulkan_ctx_t *ctx, plitem_t *item) { qfZoneScoped (true); auto rctx = ctx->render_context; - auto item = Vulkan_GetConfig (ctx, name); auto output = get_output (ctx, item); Vulkan_Script_SetOutput (ctx, &output); rctx->jobinfo = QFV_ParseJobInfo (ctx, item, rctx); @@ -87,11 +86,10 @@ QFV_LoadRenderInfo (vulkan_ctx_t *ctx, const char *name) } void -QFV_LoadSamplerInfo (vulkan_ctx_t *ctx, const char *name) +QFV_LoadSamplerInfo (vulkan_ctx_t *ctx, plitem_t *item) { qfZoneScoped (true); auto rctx = ctx->render_context; - auto item = Vulkan_GetConfig (ctx, name); rctx->samplerinfo = QFV_ParseSamplerInfo (ctx, item, rctx); if (rctx->samplerinfo) { rctx->samplerinfo->plitem = item;