[vulkan] Destroy frame buffers on shutdown

With this, the new render system, though not doing anything useful, at
least passes validation.
This commit is contained in:
Bill Currie 2023-06-21 17:58:15 +09:00
parent 25cfef18d6
commit 3de39f5408
3 changed files with 35 additions and 26 deletions

View file

@ -384,6 +384,7 @@ void QFV_Render_AddTasks (struct vulkan_ctx_s *ctx, exprsym_t *task_sys);
void QFV_CreateFramebuffer (struct vulkan_ctx_s *ctx, qfv_renderpass_t *rp);
qfv_step_t *QFV_GetStep (const exprval_t *param, qfv_job_t *job);
qfv_step_t *QFV_FindStep (const char *step, qfv_job_t *job) __attribute__((pure));
#endif//__QFCC__
#endif//__QF_Vulkan_render_h

View file

@ -280,24 +280,6 @@ QFV_RunRenderJob (vulkan_ctx_t *ctx)
dfunc->vkQueuePresentKHR (queue->queue, &presentInfo);
}
#if 0
void
QFV_DestroyFramebuffer (vulkan_ctx_t *ctx)
{
qfv_device_t *device = ctx->device;
qfv_devfuncs_t *dfunc = device->funcs;
__auto_type rctx = ctx->render_context;
__auto_type job = rctx->job;
__auto_type rp = &job->renderpasses[0];
if (rp->beginInfo.framebuffer) {
VkFramebuffer framebuffer = rp->beginInfo.framebuffer;
rp->beginInfo.framebuffer = 0;
dfunc->vkDestroyFramebuffer (device->dev, framebuffer, 0);
}
}
#endif
static VkImageView __attribute__((pure))
find_imageview (qfv_reference_t *ref, qfv_renderctx_t *rctx)
{
@ -485,6 +467,18 @@ QFV_Render_Shutdown (vulkan_ctx_t *ctx)
QFV_DestroyResource (ctx->device, job->resources);
free (job->resources);
}
for (uint32_t i = 0; i < job->num_steps; i++) {
if (job->steps[i].render) {
auto render = job->steps[i].render;
for (uint32_t j = 0; j < render->num_renderpasses; j++) {
auto bi = &render->renderpasses[j].beginInfo;
if (bi->framebuffer) {
dfunc->vkDestroyFramebuffer (device->dev,
bi->framebuffer, 0);
}
}
}
}
job->command_pool = 0;
DARRAY_CLEAR (&job->commands);
free (rctx->job);
@ -525,6 +519,18 @@ QFV_Render_AddTasks (vulkan_ctx_t *ctx, exprsym_t *task_syms)
}
}
qfv_step_t *
QFV_FindStep (const char *name, qfv_job_t *job)
{
for (uint32_t i = 0; i < job->num_steps; i++) {
auto step = &job->steps[i];
if (!strcmp (step->label.name, name)) {
return step;
}
}
return 0;
}
qfv_step_t *
QFV_GetStep (const exprval_t *param, qfv_job_t *job)
{
@ -540,14 +546,7 @@ QFV_GetStep (const exprval_t *param, qfv_job_t *job)
}
auto name = *(const char **)stepref->value;
stepref->type = &cexpr_voidptr;
*(void **)stepref->value = 0;
for (uint32_t i = 0; i < job->num_steps; i++) {
auto step = &job->steps[i];
if (!strcmp (step->label.name, name)) {
*(void **)stepref->value = step;
break;
}
}
*(qfv_step_t **)stepref->value = QFV_FindStep (name, job);
}
return *(qfv_step_t **)stepref->value;
}

View file

@ -442,6 +442,15 @@ Vulkan_Output_Shutdown (vulkan_ctx_t *ctx)
qfv_devfuncs_t *dfunc = device->funcs;
outputctx_t *octx = ctx->output_context;
for (uint32_t i = 0; i < ctx->swapchain->imageViews->size; i++) {
dfunc->vkDestroyFramebuffer (device->dev, octx->framebuffers[i], 0);
}
free (octx->framebuffers);
auto step = QFV_FindStep ("output", ctx->render_context->job);
auto render = step->render;
auto rp = &render->renderpasses[0];
rp->beginInfo.framebuffer = 0;
dfunc->vkDestroyPipeline (device->dev, octx->output, 0);
dfunc->vkDestroyPipeline (device->dev, octx->waterwarp, 0);
dfunc->vkDestroyPipeline (device->dev, octx->fisheye, 0);