From 8138b691868341aafb920004b5eb67aec6519d11 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Sat, 20 Jan 2024 23:36:12 +0900 Subject: [PATCH] [vulkan] Parameterize a few more forward vs deferred Just scene and config load to go. --- include/QF/Vulkan/qf_bsp.h | 1 + libs/video/renderer/vulkan/rp_main_def.plist | 4 +++- libs/video/renderer/vulkan/rp_main_fwd.plist | 13 ++++++------ libs/video/renderer/vulkan/vulkan_bsp.c | 21 +++++++++++++------- libs/video/renderer/vulkan/vulkan_compose.c | 14 ++++++++++--- 5 files changed, 36 insertions(+), 17 deletions(-) diff --git a/include/QF/Vulkan/qf_bsp.h b/include/QF/Vulkan/qf_bsp.h index c2119eb15..1979f96d8 100644 --- a/include/QF/Vulkan/qf_bsp.h +++ b/include/QF/Vulkan/qf_bsp.h @@ -328,6 +328,7 @@ typedef enum { typedef enum { QFV_bspMain, + QFV_bspLightmap, // same as main, but using lightmaps QFV_bspShadow, QFV_bspDebug, diff --git a/libs/video/renderer/vulkan/rp_main_def.plist b/libs/video/renderer/vulkan/rp_main_def.plist index 643717cd7..d27e061f5 100644 --- a/libs/video/renderer/vulkan/rp_main_def.plist +++ b/libs/video/renderer/vulkan/rp_main_def.plist @@ -570,6 +570,7 @@ properties = { descriptorSets = (matrix_set, texture_set, oit_set); pushConstants = { vertex = { Model = mat4; }; + fragment = { fog = vec4; }; }; }; physics = { @@ -1898,7 +1899,8 @@ renderpasses = { color = $color.compose; tasks = ( - { func = compose_draw; }, + { func = compose_draw; + params = (0); }, ); stages = ( diff --git a/libs/video/renderer/vulkan/rp_main_fwd.plist b/libs/video/renderer/vulkan/rp_main_fwd.plist index b9fc87264..29c60267a 100644 --- a/libs/video/renderer/vulkan/rp_main_fwd.plist +++ b/libs/video/renderer/vulkan/rp_main_fwd.plist @@ -1112,7 +1112,7 @@ renderpasses = { color = $color.bsp; tasks = ( { func = bsp_draw_queue; - params = (main, solid, 1); }, + params = (lightmap, solid, 1); }, ); stages = ( @@ -1191,7 +1191,7 @@ renderpasses = { tasks = ( // FIXME sky should not use OIT { func = bsp_draw_queue; - params = (main, sky, 1); }, + params = (lightmap, sky, 1); }, ); stages = ( @@ -1207,7 +1207,7 @@ renderpasses = { tasks = ( // FIXME sky should not use OIT { func = bsp_draw_queue; - params = (main, sky, 1); }, + params = (lightmap, sky, 1); }, ); stages = ( @@ -1222,9 +1222,9 @@ renderpasses = { color = $color.bsp; tasks = ( { func = bsp_draw_queue; - params = (main, translucent, 1); }, + params = (lightmap, translucent, 1); }, { func = bsp_draw_queue; - params = (main, turbulent, 1); }, + params = (lightmap, turbulent, 1); }, ); stages = ( $brush.shader.quake_vertex, @@ -1274,7 +1274,8 @@ renderpasses = { color = $color.compose; tasks = ( - { func = compose_draw; }, + { func = compose_draw; + params = (1); }, ); stages = ( $fstriangle.shader.vertex, diff --git a/libs/video/renderer/vulkan/vulkan_bsp.c b/libs/video/renderer/vulkan/vulkan_bsp.c index 7f6c89728..3d356255c 100644 --- a/libs/video/renderer/vulkan/vulkan_bsp.c +++ b/libs/video/renderer/vulkan/vulkan_bsp.c @@ -931,7 +931,8 @@ dynamic: } static void -queue_faces (bsp_pass_t *pass, const bspctx_t *bctx, bspframe_t *bframe) +queue_faces (bsp_pass_t *pass, QFV_BspPass pass_ind, + const bspctx_t *bctx, bspframe_t *bframe) { qfZoneScoped (true); uint32_t base = bframe->index_count; @@ -992,7 +993,7 @@ queue_faces (bsp_pass_t *pass, const bspctx_t *bctx, bspframe_t *bframe) draw->index_count += f.index_count; pass->index_count += f.index_count; - if (dq == QFV_bspSolid) { + if (pass_ind == QFV_bspLightmap && dq == QFV_bspSolid) { update_lightmap (pass, bctx, is); } } @@ -1265,6 +1266,7 @@ bsp_draw_queue (const exprval_t **params, exprval_t *result, exprctx_t *ectx) auto pass = (bsp_pass_t *[]) { [QFV_bspMain] = &bctx->main_pass, + [QFV_bspLightmap] = &bctx->main_pass, [QFV_bspShadow] = &bctx->shadow_pass, [QFV_bspDebug] = &bctx->debug_pass, } [pass_ind]; @@ -1304,7 +1306,7 @@ bsp_draw_queue (const exprval_t **params, exprval_t *result, exprctx_t *ectx) if (queue == QFV_bspSky) { vulktex_t skybox = { .descriptor = bctx->skybox_descriptor }; bind_texture (&skybox, SKYBOX_SET, layout, dfunc, cmd); - } else { + } else if (pass_ind == QFV_bspLightmap) { vulktex_t lightmap = { .descriptor = bctx->lightmap_descriptor }; bind_texture (&lightmap, LIGHTMAP_SET, layout, dfunc, cmd); } @@ -1324,11 +1326,12 @@ bsp_visit_world (const exprval_t **params, exprval_t *result, exprctx_t *ectx) auto pass = (bsp_pass_t *[]) { [QFV_bspMain] = &bctx->main_pass, + [QFV_bspLightmap] = &bctx->main_pass, [QFV_bspShadow] = &bctx->shadow_pass, [QFV_bspDebug] = &bctx->debug_pass, } [pass_ind]; - if (pass_ind == QFV_bspMain) { + if (pass_ind == QFV_bspMain || pass_ind == QFV_bspLightmap) { pass->entqueue = r_ent_queue; pass->position = r_refdef.frame.position; pass->vis_frame = r_visstate.visframecount; @@ -1361,6 +1364,7 @@ bsp_visit_world (const exprval_t **params, exprval_t *result, exprctx_t *ectx) } R_VisitWorldNodes (pass, ctx, (typeof(visit_node_bfcull)*[]) { [QFV_bspMain] = visit_node_bfcull, + [QFV_bspLightmap] = visit_node_bfcull, [QFV_bspShadow] = visit_node_no_bfcull, [QFV_bspDebug] = visit_node_no_bfcull, }[pass_ind]); @@ -1376,7 +1380,7 @@ bsp_visit_world (const exprval_t **params, exprval_t *result, exprctx_t *ectx) } } - queue_faces (pass, bctx, bframe); + queue_faces (pass, pass_ind, bctx, bframe); bframe->entid_count = pass->entid_count; @@ -1392,13 +1396,15 @@ static exprtype_t bsp_pass_type = { }; static int bsp_pass_values[] = { QFV_bspMain, + QFV_bspLightmap, QFV_bspShadow, QFV_bspDebug, }; static exprsym_t bsp_pass_symbols[] = { {"main", &bsp_pass_type, bsp_pass_values + 0}, - {"shadow", &bsp_pass_type, bsp_pass_values + 1}, - {"debug", &bsp_pass_type, bsp_pass_values + 2}, + {"lightmap", &bsp_pass_type, bsp_pass_values + 1}, + {"shadow", &bsp_pass_type, bsp_pass_values + 2}, + {"debug", &bsp_pass_type, bsp_pass_values + 3}, {} }; static exprtab_t bsp_pass_symtab = { .symbols = bsp_pass_symbols }; @@ -1698,6 +1704,7 @@ Vulkan_Bsp_GetPass (struct vulkan_ctx_s *ctx, QFV_BspPass pass_ind) } auto pass = (bsp_pass_t *[]) { [QFV_bspMain] = &bctx->main_pass, + [QFV_bspLightmap] = &bctx->main_pass, [QFV_bspShadow] = &bctx->shadow_pass, [QFV_bspDebug] = &bctx->debug_pass, }[pass_ind]; diff --git a/libs/video/renderer/vulkan/vulkan_compose.c b/libs/video/renderer/vulkan/vulkan_compose.c index 003c79349..4be2d3955 100644 --- a/libs/video/renderer/vulkan/vulkan_compose.c +++ b/libs/video/renderer/vulkan/vulkan_compose.c @@ -72,6 +72,8 @@ compose_draw (const exprval_t **params, exprval_t *result, exprctx_t *ectx) { qfZoneNamed (zone, true); auto taskctx = (qfv_taskctx_t *) ectx; + int color_only = *(int *) params[0]->value; + auto ctx = taskctx->ctx; auto device = ctx->device; auto dfunc = device->funcs; @@ -87,8 +89,10 @@ compose_draw (const exprval_t **params, exprval_t *result, exprctx_t *ectx) cframe->imageInfo[2].imageView = fb->views[QFV_attachEmission]; dfunc->vkUpdateDescriptorSets (device->dev, 1, cframe->descriptors, 0, 0); - //dfunc->vkUpdateDescriptorSets (device->dev, COMPOSE_IMAGE_INFOS, - // cframe->descriptors, 0, 0); + if (!color_only) { + dfunc->vkUpdateDescriptorSets (device->dev, COMPOSE_IMAGE_INFOS, + cframe->descriptors, 0, 0); + } VkDescriptorSet sets[] = { cframe->descriptors[0].dstSet, @@ -100,8 +104,12 @@ compose_draw (const exprval_t **params, exprval_t *result, exprctx_t *ectx) dfunc->vkCmdDraw (cmd, 3, 1, 0, 0); } +static exprtype_t *compose_draw_params[] = { + &cexpr_int, +}; static exprfunc_t compose_draw_func[] = { - { .func = compose_draw }, + { .func = compose_draw, .num_params = 1, + .param_types = compose_draw_params }, {} }; static exprsym_t compose_task_syms[] = {