[vulkan] Parameterize a few more forward vs deferred

Just scene and config load to go.
This commit is contained in:
Bill Currie 2024-01-20 23:36:12 +09:00
parent 778ffadd54
commit 8138b69186
5 changed files with 36 additions and 17 deletions

View file

@ -328,6 +328,7 @@ typedef enum {
typedef enum { typedef enum {
QFV_bspMain, QFV_bspMain,
QFV_bspLightmap, // same as main, but using lightmaps
QFV_bspShadow, QFV_bspShadow,
QFV_bspDebug, QFV_bspDebug,

View file

@ -570,6 +570,7 @@ properties = {
descriptorSets = (matrix_set, texture_set, oit_set); descriptorSets = (matrix_set, texture_set, oit_set);
pushConstants = { pushConstants = {
vertex = { Model = mat4; }; vertex = { Model = mat4; };
fragment = { fog = vec4; };
}; };
}; };
physics = { physics = {
@ -1898,7 +1899,8 @@ renderpasses = {
color = $color.compose; color = $color.compose;
tasks = ( tasks = (
{ func = compose_draw; }, { func = compose_draw;
params = (0); },
); );
stages = ( stages = (

View file

@ -1112,7 +1112,7 @@ renderpasses = {
color = $color.bsp; color = $color.bsp;
tasks = ( tasks = (
{ func = bsp_draw_queue; { func = bsp_draw_queue;
params = (main, solid, 1); }, params = (lightmap, solid, 1); },
); );
stages = ( stages = (
@ -1191,7 +1191,7 @@ renderpasses = {
tasks = ( tasks = (
// FIXME sky should not use OIT // FIXME sky should not use OIT
{ func = bsp_draw_queue; { func = bsp_draw_queue;
params = (main, sky, 1); }, params = (lightmap, sky, 1); },
); );
stages = ( stages = (
@ -1207,7 +1207,7 @@ renderpasses = {
tasks = ( tasks = (
// FIXME sky should not use OIT // FIXME sky should not use OIT
{ func = bsp_draw_queue; { func = bsp_draw_queue;
params = (main, sky, 1); }, params = (lightmap, sky, 1); },
); );
stages = ( stages = (
@ -1222,9 +1222,9 @@ renderpasses = {
color = $color.bsp; color = $color.bsp;
tasks = ( tasks = (
{ func = bsp_draw_queue; { func = bsp_draw_queue;
params = (main, translucent, 1); }, params = (lightmap, translucent, 1); },
{ func = bsp_draw_queue; { func = bsp_draw_queue;
params = (main, turbulent, 1); }, params = (lightmap, turbulent, 1); },
); );
stages = ( stages = (
$brush.shader.quake_vertex, $brush.shader.quake_vertex,
@ -1274,7 +1274,8 @@ renderpasses = {
color = $color.compose; color = $color.compose;
tasks = ( tasks = (
{ func = compose_draw; }, { func = compose_draw;
params = (1); },
); );
stages = ( stages = (
$fstriangle.shader.vertex, $fstriangle.shader.vertex,

View file

@ -931,7 +931,8 @@ dynamic:
} }
static void 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); qfZoneScoped (true);
uint32_t base = bframe->index_count; 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; draw->index_count += f.index_count;
pass->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); 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 *[]) { auto pass = (bsp_pass_t *[]) {
[QFV_bspMain] = &bctx->main_pass, [QFV_bspMain] = &bctx->main_pass,
[QFV_bspLightmap] = &bctx->main_pass,
[QFV_bspShadow] = &bctx->shadow_pass, [QFV_bspShadow] = &bctx->shadow_pass,
[QFV_bspDebug] = &bctx->debug_pass, [QFV_bspDebug] = &bctx->debug_pass,
} [pass_ind]; } [pass_ind];
@ -1304,7 +1306,7 @@ bsp_draw_queue (const exprval_t **params, exprval_t *result, exprctx_t *ectx)
if (queue == QFV_bspSky) { if (queue == QFV_bspSky) {
vulktex_t skybox = { .descriptor = bctx->skybox_descriptor }; vulktex_t skybox = { .descriptor = bctx->skybox_descriptor };
bind_texture (&skybox, SKYBOX_SET, layout, dfunc, cmd); bind_texture (&skybox, SKYBOX_SET, layout, dfunc, cmd);
} else { } else if (pass_ind == QFV_bspLightmap) {
vulktex_t lightmap = { .descriptor = bctx->lightmap_descriptor }; vulktex_t lightmap = { .descriptor = bctx->lightmap_descriptor };
bind_texture (&lightmap, LIGHTMAP_SET, layout, dfunc, cmd); 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 *[]) { auto pass = (bsp_pass_t *[]) {
[QFV_bspMain] = &bctx->main_pass, [QFV_bspMain] = &bctx->main_pass,
[QFV_bspLightmap] = &bctx->main_pass,
[QFV_bspShadow] = &bctx->shadow_pass, [QFV_bspShadow] = &bctx->shadow_pass,
[QFV_bspDebug] = &bctx->debug_pass, [QFV_bspDebug] = &bctx->debug_pass,
} [pass_ind]; } [pass_ind];
if (pass_ind == QFV_bspMain) { if (pass_ind == QFV_bspMain || pass_ind == QFV_bspLightmap) {
pass->entqueue = r_ent_queue; pass->entqueue = r_ent_queue;
pass->position = r_refdef.frame.position; pass->position = r_refdef.frame.position;
pass->vis_frame = r_visstate.visframecount; 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)*[]) { R_VisitWorldNodes (pass, ctx, (typeof(visit_node_bfcull)*[]) {
[QFV_bspMain] = visit_node_bfcull, [QFV_bspMain] = visit_node_bfcull,
[QFV_bspLightmap] = visit_node_bfcull,
[QFV_bspShadow] = visit_node_no_bfcull, [QFV_bspShadow] = visit_node_no_bfcull,
[QFV_bspDebug] = visit_node_no_bfcull, [QFV_bspDebug] = visit_node_no_bfcull,
}[pass_ind]); }[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; bframe->entid_count = pass->entid_count;
@ -1392,13 +1396,15 @@ static exprtype_t bsp_pass_type = {
}; };
static int bsp_pass_values[] = { static int bsp_pass_values[] = {
QFV_bspMain, QFV_bspMain,
QFV_bspLightmap,
QFV_bspShadow, QFV_bspShadow,
QFV_bspDebug, QFV_bspDebug,
}; };
static exprsym_t bsp_pass_symbols[] = { static exprsym_t bsp_pass_symbols[] = {
{"main", &bsp_pass_type, bsp_pass_values + 0}, {"main", &bsp_pass_type, bsp_pass_values + 0},
{"shadow", &bsp_pass_type, bsp_pass_values + 1}, {"lightmap", &bsp_pass_type, bsp_pass_values + 1},
{"debug", &bsp_pass_type, bsp_pass_values + 2}, {"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 }; 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 *[]) { auto pass = (bsp_pass_t *[]) {
[QFV_bspMain] = &bctx->main_pass, [QFV_bspMain] = &bctx->main_pass,
[QFV_bspLightmap] = &bctx->main_pass,
[QFV_bspShadow] = &bctx->shadow_pass, [QFV_bspShadow] = &bctx->shadow_pass,
[QFV_bspDebug] = &bctx->debug_pass, [QFV_bspDebug] = &bctx->debug_pass,
}[pass_ind]; }[pass_ind];

View file

@ -72,6 +72,8 @@ compose_draw (const exprval_t **params, exprval_t *result, exprctx_t *ectx)
{ {
qfZoneNamed (zone, true); qfZoneNamed (zone, true);
auto taskctx = (qfv_taskctx_t *) ectx; auto taskctx = (qfv_taskctx_t *) ectx;
int color_only = *(int *) params[0]->value;
auto ctx = taskctx->ctx; auto ctx = taskctx->ctx;
auto device = ctx->device; auto device = ctx->device;
auto dfunc = device->funcs; 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]; cframe->imageInfo[2].imageView = fb->views[QFV_attachEmission];
dfunc->vkUpdateDescriptorSets (device->dev, 1, dfunc->vkUpdateDescriptorSets (device->dev, 1,
cframe->descriptors, 0, 0); cframe->descriptors, 0, 0);
//dfunc->vkUpdateDescriptorSets (device->dev, COMPOSE_IMAGE_INFOS, if (!color_only) {
// cframe->descriptors, 0, 0); dfunc->vkUpdateDescriptorSets (device->dev, COMPOSE_IMAGE_INFOS,
cframe->descriptors, 0, 0);
}
VkDescriptorSet sets[] = { VkDescriptorSet sets[] = {
cframe->descriptors[0].dstSet, 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); dfunc->vkCmdDraw (cmd, 3, 1, 0, 0);
} }
static exprtype_t *compose_draw_params[] = {
&cexpr_int,
};
static exprfunc_t compose_draw_func[] = { 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[] = { static exprsym_t compose_task_syms[] = {