[vulkan] Pass a data parameter to QFV_RunRenderPass

The parameter will be passed on to the pipeline tasks in their task
context, allowing for communication between the subsystem calling
QFV_RunRenderPass and the pipeline tasks (for the case of lighting,
passing the current matrix base index).
This commit is contained in:
Bill Currie 2023-07-30 11:22:22 +09:00
parent e83854a760
commit aac6fca2c5
4 changed files with 9 additions and 6 deletions

View file

@ -97,6 +97,7 @@ typedef struct light_renderer_s {
uint16_t layer;
uint8_t numLayers;
uint8_t mode;
uint16_t matrix_base;
} light_renderer_t;
typedef struct light_renderer_set_s

View file

@ -442,13 +442,14 @@ typedef struct qfv_taskctx_s {
qfv_pipeline_t *pipeline;
qfv_renderpass_t *renderpass;
VkCommandBuffer cmd;
void *data;
} qfv_taskctx_t;
VkCommandBuffer QFV_GetCmdBuffer (struct vulkan_ctx_s *ctx, bool secondary);
void QFV_AppendCmdBuffer (struct vulkan_ctx_s *ctx, VkCommandBuffer cmd);
void QFV_RunRenderPass (struct vulkan_ctx_s *ctx, qfv_renderpass_t *renderpass,
uint32_t width, uint32_t height);
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);

View file

@ -150,7 +150,7 @@ run_subpass (qfv_subpass_t *sp, qfv_taskctx_t *taskctx)
}
static void
run_renderpass (qfv_renderpass_t *rp, vulkan_ctx_t *ctx)
run_renderpass (qfv_renderpass_t *rp, vulkan_ctx_t *ctx, void *data)
{
qfv_device_t *device = ctx->device;
qfv_devfuncs_t *dfunc = device->funcs;
@ -175,6 +175,7 @@ run_renderpass (qfv_renderpass_t *rp, vulkan_ctx_t *ctx)
.ctx = ctx,
.renderpass = rp,
.cmd = QFV_GetCmdBuffer (ctx, true),
.data = data,
};
run_subpass (sp, &taskctx);
dfunc->vkCmdExecuteCommands (cmd, 1, &taskctx.cmd);
@ -258,7 +259,7 @@ run_process (qfv_process_t *proc, vulkan_ctx_t *ctx)
void
QFV_RunRenderPass (vulkan_ctx_t *ctx, qfv_renderpass_t *renderpass,
uint32_t width, uint32_t height)
uint32_t width, uint32_t height, void *data)
{
qfv_output_t output = {
.extent = {
@ -267,7 +268,7 @@ QFV_RunRenderPass (vulkan_ctx_t *ctx, qfv_renderpass_t *renderpass,
},
};
renderpass_update_viewport_sissor (renderpass, &output);
run_renderpass (renderpass, ctx);
run_renderpass (renderpass, ctx, data);
}
void
@ -285,7 +286,7 @@ QFV_RunRenderJob (vulkan_ctx_t *ctx)
// process for the step (the idea is the proces uses the compute
// and renderpass objects for its own purposes).
if (step->render) {
run_renderpass (step->render->active, ctx);
run_renderpass (step->render->active, ctx, 0);
}
if (step->compute) {
run_compute (step->compute, ctx, step);

View file

@ -274,7 +274,7 @@ lighting_draw_shadow_maps (const exprval_t **params, exprval_t *result,
auto bi = &renderpass->beginInfo;
auto fbuffer = create_framebuffer (ctx, r, view, bi->renderPass);
bi->framebuffer = fbuffer;
QFV_RunRenderPass (ctx, renderpass, r->size, r->size);
QFV_RunRenderPass (ctx, renderpass, r->size, r->size, &r->matrix_base);
DARRAY_APPEND (&lframe->views, view);
DARRAY_APPEND (&lframe->framebuffers, fbuffer);
bi->framebuffer = 0;