From bba82d3da1e5e3de1b2123870630ef162e7cfc1b Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Thu, 22 Jun 2023 16:44:05 +0900 Subject: [PATCH] [vulkan] Move frames from vulkan_ctx to renderctx Part of the command buffer fix, but also a step towards cleaning up vulkan_ctx. --- include/QF/Vulkan/qf_alias.h | 10 ++-- include/QF/Vulkan/qf_bsp.h | 8 +-- include/QF/Vulkan/qf_compose.h | 4 +- include/QF/Vulkan/qf_iqm.h | 8 +-- include/QF/Vulkan/qf_lighting.h | 4 +- include/QF/Vulkan/qf_main.h | 6 +-- include/QF/Vulkan/qf_particles.h | 4 +- include/QF/Vulkan/qf_renderpass.h | 12 ++--- include/QF/Vulkan/qf_sprite.h | 8 +-- include/QF/Vulkan/qf_translucent.h | 4 +- include/QF/Vulkan/qf_vid.h | 2 - include/QF/Vulkan/render.h | 11 ++++ include/vid_vulkan.h | 12 ----- libs/video/renderer/vid_render_vulkan.c | 1 - libs/video/renderer/vulkan/render.c | 41 +++++++++++++-- libs/video/renderer/vulkan/render_load.c | 11 ---- libs/video/renderer/vulkan/vkparse.c | 21 ++++---- libs/video/renderer/vulkan/vulkan_alias.c | 15 +++--- libs/video/renderer/vulkan/vulkan_bsp.c | 17 +++--- libs/video/renderer/vulkan/vulkan_compose.c | 5 +- libs/video/renderer/vulkan/vulkan_draw.c | 6 ++- libs/video/renderer/vulkan/vulkan_iqm.c | 13 ++--- libs/video/renderer/vulkan/vulkan_lighting.c | 7 +-- libs/video/renderer/vulkan/vulkan_main.c | 6 +-- libs/video/renderer/vulkan/vulkan_matrices.c | 3 +- libs/video/renderer/vulkan/vulkan_output.c | 12 +++-- libs/video/renderer/vulkan/vulkan_particles.c | 14 ++--- .../video/renderer/vulkan/vulkan_renderpass.c | 4 +- libs/video/renderer/vulkan/vulkan_scene.c | 4 +- libs/video/renderer/vulkan/vulkan_sprite.c | 13 ++--- .../renderer/vulkan/vulkan_translucent.c | 7 +-- .../video/renderer/vulkan/vulkan_vid_common.c | 52 ++----------------- 32 files changed, 166 insertions(+), 179 deletions(-) diff --git a/include/QF/Vulkan/qf_alias.h b/include/QF/Vulkan/qf_alias.h index 5c64d00b8..c1326e82a 100644 --- a/include/QF/Vulkan/qf_alias.h +++ b/include/QF/Vulkan/qf_alias.h @@ -89,7 +89,7 @@ typedef struct aliasctx_s { } aliasctx_t; struct vulkan_ctx_s; -struct qfv_renderframe_s; +struct qfv_orenderframe_s; struct entity_s; struct mod_alias_ctx_s; @@ -106,13 +106,13 @@ void Vulkan_Mod_MakeAliasModelDisplayLists (struct mod_alias_ctx_s *alias_ctx, void Vulkan_AliasAddSkin (struct vulkan_ctx_s *ctx, qfv_alias_skin_t *skin); void Vulkan_AliasRemoveSkin (struct vulkan_ctx_s *ctx, qfv_alias_skin_t *skin); -void Vulkan_AliasBegin (struct qfv_renderframe_s *rFrame); -void Vulkan_DrawAlias (struct entity_s ent, struct qfv_renderframe_s *rFrame); -void Vulkan_AliasEnd (struct qfv_renderframe_s *rFrame); +void Vulkan_AliasBegin (struct qfv_orenderframe_s *rFrame); +void Vulkan_DrawAlias (struct entity_s ent, struct qfv_orenderframe_s *rFrame); +void Vulkan_AliasEnd (struct qfv_orenderframe_s *rFrame); void Vulkan_Alias_Init (struct vulkan_ctx_s *ctx); void Vulkan_Alias_Shutdown (struct vulkan_ctx_s *ctx); -void Vulkan_AliasDepthRange (struct qfv_renderframe_s *rFrame, float n, float f); +void Vulkan_AliasDepthRange (struct qfv_orenderframe_s *rFrame, float n, float f); #endif//__QF_Vulkan_qf_alias_h diff --git a/include/QF/Vulkan/qf_bsp.h b/include/QF/Vulkan/qf_bsp.h index 2e9441711..3e18774a6 100644 --- a/include/QF/Vulkan/qf_bsp.h +++ b/include/QF/Vulkan/qf_bsp.h @@ -386,10 +386,10 @@ typedef struct bspctx_s { } bspctx_t; struct vulkan_ctx_s; -struct qfv_renderframe_s; -void Vulkan_DrawWorld (struct qfv_renderframe_s *rFrame); -void Vulkan_DrawSky (struct qfv_renderframe_s *rFrame); -void Vulkan_DrawWaterSurfaces (struct qfv_renderframe_s *rFrame); +struct qfv_orenderframe_s; +void Vulkan_DrawWorld (struct qfv_orenderframe_s *rFrame); +void Vulkan_DrawSky (struct qfv_orenderframe_s *rFrame); +void Vulkan_DrawWaterSurfaces (struct qfv_orenderframe_s *rFrame); void Vulkan_Bsp_Flush (struct vulkan_ctx_s *ctx); void Vulkan_LoadSkys (const char *sky, struct vulkan_ctx_s *ctx); void Vulkan_RegisterTextures (model_t **models, int num_models, diff --git a/include/QF/Vulkan/qf_compose.h b/include/QF/Vulkan/qf_compose.h index 001ee3e5c..9b40c14d0 100644 --- a/include/QF/Vulkan/qf_compose.h +++ b/include/QF/Vulkan/qf_compose.h @@ -54,10 +54,10 @@ typedef struct composectx_s { } composectx_t; struct vulkan_ctx_s; -struct qfv_renderframe_s; +struct qfv_orenderframe_s; void Vulkan_Compose_Init (struct vulkan_ctx_s *ctx); void Vulkan_Compose_Shutdown (struct vulkan_ctx_s *ctx); -void Vulkan_Compose_Draw (struct qfv_renderframe_s *rFrame); +void Vulkan_Compose_Draw (struct qfv_orenderframe_s *rFrame); #endif//__QF_Vulkan_qf_compose_h diff --git a/include/QF/Vulkan/qf_iqm.h b/include/QF/Vulkan/qf_iqm.h index 2dde7cfb4..43c04302b 100644 --- a/include/QF/Vulkan/qf_iqm.h +++ b/include/QF/Vulkan/qf_iqm.h @@ -98,7 +98,7 @@ typedef struct iqmctx_s { } iqmctx_t; struct vulkan_ctx_s; -struct qfv_renderframe_s; +struct qfv_orenderframe_s; struct entity_s; struct mod_iqm_ctx_s; struct iqm_s; @@ -111,9 +111,9 @@ void Vulkan_IQMRemoveBones (struct vulkan_ctx_s *ctx, struct iqm_s *iqm); void Vulkan_IQMAddSkin (struct vulkan_ctx_s *ctx, qfv_iqm_skin_t *skin); void Vulkan_IQMRemoveSkin (struct vulkan_ctx_s *ctx, qfv_iqm_skin_t *skin); -void Vulkan_IQMBegin (struct qfv_renderframe_s *rFrame); -void Vulkan_DrawIQM (struct entity_s ent, struct qfv_renderframe_s *rFrame); -void Vulkan_IQMEnd (struct qfv_renderframe_s *rFrame); +void Vulkan_IQMBegin (struct qfv_orenderframe_s *rFrame); +void Vulkan_DrawIQM (struct entity_s ent, struct qfv_orenderframe_s *rFrame); +void Vulkan_IQMEnd (struct qfv_orenderframe_s *rFrame); void Vulkan_IQM_Init (struct vulkan_ctx_s *ctx); void Vulkan_IQM_Shutdown (struct vulkan_ctx_s *ctx); diff --git a/include/QF/Vulkan/qf_lighting.h b/include/QF/Vulkan/qf_lighting.h index 2cf7c7e81..703cbb251 100644 --- a/include/QF/Vulkan/qf_lighting.h +++ b/include/QF/Vulkan/qf_lighting.h @@ -117,12 +117,12 @@ typedef struct lightingctx_s { } lightingctx_t; struct vulkan_ctx_s; -struct qfv_renderframe_s; +struct qfv_orenderframe_s; void Vulkan_Lighting_CreateRenderPasses (struct vulkan_ctx_s *ctx); void Vulkan_Lighting_Init (struct vulkan_ctx_s *ctx); void Vulkan_Lighting_Shutdown (struct vulkan_ctx_s *ctx); -void Vulkan_Lighting_Draw (struct qfv_renderframe_s *rFrame); +void Vulkan_Lighting_Draw (struct qfv_orenderframe_s *rFrame); void Vulkan_LoadLights (struct scene_s *scene, struct vulkan_ctx_s *ctx); #endif//__QF_Vulkan_qf_lighting_h diff --git a/include/QF/Vulkan/qf_main.h b/include/QF/Vulkan/qf_main.h index b666ce017..ba6659086 100644 --- a/include/QF/Vulkan/qf_main.h +++ b/include/QF/Vulkan/qf_main.h @@ -29,14 +29,14 @@ #define __QF_Vulkan_qf_main_h struct vulkan_ctx_s; -struct qfv_renderframe_s; +struct qfv_orenderframe_s; struct entqueue_s; struct scene_s; void Vulkan_Main_CreateRenderPasses (struct vulkan_ctx_s *ctx); void Vulkan_NewScene (struct scene_s *scene, struct vulkan_ctx_s *ctx); -void Vulkan_RenderView (struct qfv_renderframe_s *rFrame); +void Vulkan_RenderView (struct qfv_orenderframe_s *rFrame); void Vulkan_RenderEntities (struct entqueue_s *queue, - struct qfv_renderframe_s *rFrame); + struct qfv_orenderframe_s *rFrame); #endif//__QF_Vulkan_qf_main_h diff --git a/include/QF/Vulkan/qf_particles.h b/include/QF/Vulkan/qf_particles.h index a805dfdd8..8cef3fec0 100644 --- a/include/QF/Vulkan/qf_particles.h +++ b/include/QF/Vulkan/qf_particles.h @@ -74,12 +74,12 @@ typedef struct particlectx_s { struct cvar_s; struct vulkan_ctx_s; -struct qfv_renderframe_s; +struct qfv_orenderframe_s; struct psystem_s *Vulkan_ParticleSystem (struct vulkan_ctx_s *ctx); void Vulkan_Particles_Init (struct vulkan_ctx_s *ctx); void Vulkan_Particles_Shutdown (struct vulkan_ctx_s *ctx); -void Vulkan_DrawParticles (struct qfv_renderframe_s *rFrame); +void Vulkan_DrawParticles (struct qfv_orenderframe_s *rFrame); void Vulkan_Particles_CreateRenderPasses (struct vulkan_ctx_s *ctx); #endif//__QF_Vulkan_qf_particles_h diff --git a/include/QF/Vulkan/qf_renderpass.h b/include/QF/Vulkan/qf_renderpass.h index b07b72d7a..41076d25c 100644 --- a/include/QF/Vulkan/qf_renderpass.h +++ b/include/QF/Vulkan/qf_renderpass.h @@ -25,7 +25,7 @@ typedef struct qfv_osubpass_s { typedef struct qfv_subpassset_s DARRAY_TYPE (qfv_osubpass_t) qfv_subpassset_t; -typedef struct qfv_renderframe_s { +typedef struct qfv_orenderframe_s { struct vulkan_ctx_s *vulkan_ctx; struct qfv_orenderpass_s *renderpass; VkSubpassContents subpassContents; @@ -33,15 +33,15 @@ typedef struct qfv_renderframe_s { int subpassCount; qfv_osubpass_t *subpassInfo; struct qfv_cmdbufferset_s *subpassCmdSets; -} qfv_renderframe_t; +} qfv_orenderframe_t; -typedef struct qfv_renderframeset_s - DARRAY_TYPE (qfv_renderframe_t) qfv_renderframeset_t; +typedef struct qfv_orenderframeset_s + DARRAY_TYPE (qfv_orenderframe_t) qfv_orenderframeset_t; typedef struct clearvalueset_s DARRAY_TYPE (VkClearValue) clearvalueset_t; -typedef void (*qfv_draw_t) (qfv_renderframe_t *rFrame); +typedef void (*qfv_draw_t) (qfv_orenderframe_t *rFrame); typedef struct qfv_orenderpass_s { struct vulkan_ctx_s *vulkan_ctx; @@ -64,7 +64,7 @@ typedef struct qfv_orenderpass_s { int primary_commands; size_t subpassCount; qfv_subpassset_t *subpass_info; - qfv_renderframeset_t frames; + qfv_orenderframeset_t frames; qfv_draw_t draw; } qfv_orenderpass_t; diff --git a/include/QF/Vulkan/qf_sprite.h b/include/QF/Vulkan/qf_sprite.h index 874cb0e3b..827c26216 100644 --- a/include/QF/Vulkan/qf_sprite.h +++ b/include/QF/Vulkan/qf_sprite.h @@ -77,7 +77,7 @@ typedef struct spritectx_s { } spritectx_t; struct vulkan_ctx_s; -struct qfv_renderframe_s; +struct qfv_orenderframe_s; struct entity_s; struct mod_sprite_ctx_s; @@ -88,9 +88,9 @@ void Vulkan_Sprite_DescriptorSet (struct vulkan_ctx_s *ctx, void Vulkan_Mod_SpriteLoadFrames (struct mod_sprite_ctx_s *sprite_ctx, struct vulkan_ctx_s *ctx); -void Vulkan_SpriteBegin (struct qfv_renderframe_s *rFrame); -void Vulkan_DrawSprite (struct entity_s ent, struct qfv_renderframe_s *rFrame); -void Vulkan_SpriteEnd (struct qfv_renderframe_s *rFrame); +void Vulkan_SpriteBegin (struct qfv_orenderframe_s *rFrame); +void Vulkan_DrawSprite (struct entity_s ent, struct qfv_orenderframe_s *rFrame); +void Vulkan_SpriteEnd (struct qfv_orenderframe_s *rFrame); void Vulkan_Sprite_Init (struct vulkan_ctx_s *ctx); void Vulkan_Sprite_Shutdown (struct vulkan_ctx_s *ctx); diff --git a/include/QF/Vulkan/qf_translucent.h b/include/QF/Vulkan/qf_translucent.h index 1c6f72fed..cd35dc6a0 100644 --- a/include/QF/Vulkan/qf_translucent.h +++ b/include/QF/Vulkan/qf_translucent.h @@ -46,11 +46,11 @@ typedef struct translucentctx_s { } translucentctx_t; struct vulkan_ctx_s; -struct qfv_renderframe_s; +struct qfv_orenderframe_s; void Vulkan_Translucent_Init (struct vulkan_ctx_s *ctx); void Vulkan_Translucent_Shutdown (struct vulkan_ctx_s *ctx); -void Vulkan_Translucent_Draw (struct qfv_renderframe_s *rFrame); +void Vulkan_Translucent_Draw (struct qfv_orenderframe_s *rFrame); VkDescriptorSet Vulkan_Translucent_Descriptors (struct vulkan_ctx_s *ctx, int frame)__attribute__((pure)); void Vulkan_Translucent_CreateBuffers (struct vulkan_ctx_s *ctx, diff --git a/include/QF/Vulkan/qf_vid.h b/include/QF/Vulkan/qf_vid.h index 7360bbdab..986bfc3a1 100644 --- a/include/QF/Vulkan/qf_vid.h +++ b/include/QF/Vulkan/qf_vid.h @@ -69,8 +69,6 @@ enum { }; struct vulkan_ctx_s; -void Vulkan_DestroyFrames (struct vulkan_ctx_s *ctx); -void Vulkan_CreateFrames (struct vulkan_ctx_s *ctx); void Vulkan_CreateCapture (struct vulkan_ctx_s *ctx); void Vulkan_CreateRenderPasses (struct vulkan_ctx_s *ctx); void Vulkan_DestroyRenderPasses (struct vulkan_ctx_s *ctx); diff --git a/include/QF/Vulkan/render.h b/include/QF/Vulkan/render.h index c8c843988..67ead2d9a 100644 --- a/include/QF/Vulkan/render.h +++ b/include/QF/Vulkan/render.h @@ -358,11 +358,22 @@ typedef struct qfv_job_s { VkCommandPool command_pool; } qfv_job_t; +typedef struct qfv_renderframe_s { + VkFence fence; + VkSemaphore imageAvailableSemaphore; + VkSemaphore renderDoneSemaphore; + VkCommandPool command_pool; +} qfv_renderframe_t; + +typedef struct qfv_renderframeset_s + DARRAY_TYPE (qfv_renderframe_t) qfv_renderframeset_t; + typedef struct qfv_renderctx_s { struct hashctx_s *hashctx; exprtab_t task_functions; qfv_jobinfo_t *jobinfo; qfv_job_t *job; + qfv_renderframeset_t frames; } qfv_renderctx_t; typedef struct qfv_taskctx_s { diff --git a/include/vid_vulkan.h b/include/vid_vulkan.h index e9e252511..9041ac23d 100644 --- a/include/vid_vulkan.h +++ b/include/vid_vulkan.h @@ -10,17 +10,6 @@ #include "QF/qtypes.h" #include "QF/simd/types.h" -typedef struct vulkan_frame_s { - VkFence fence; - VkSemaphore imageAvailableSemaphore; - VkSemaphore renderDoneSemaphore; - VkCommandBuffer cmdBuffer; - VkCommandPool command_pool; -} vulkan_frame_t; - -typedef struct vulkan_frameset_s - DARRAY_TYPE (vulkan_frame_t) vulkan_frameset_t; - typedef struct qfv_renderpassset_s DARRAY_TYPE (struct qfv_orenderpass_s *) qfv_renderpassset_t; @@ -66,7 +55,6 @@ typedef struct vulkan_ctx_s { VkCommandPool cmdpool; struct qfv_stagebuf_s *staging; uint32_t curFrame; - vulkan_frameset_t frames; qfv_renderpassset_t renderPasses; struct qfv_orenderpass_s *output_renderpass; diff --git a/libs/video/renderer/vid_render_vulkan.c b/libs/video/renderer/vid_render_vulkan.c index 88f46c0a4..8e06409ea 100644 --- a/libs/video/renderer/vid_render_vulkan.c +++ b/libs/video/renderer/vid_render_vulkan.c @@ -94,7 +94,6 @@ vulkan_R_Init (void) QFV_Render_Init (vulkan_ctx); Vulkan_CreateStagingBuffers (vulkan_ctx); - Vulkan_CreateFrames (vulkan_ctx); Vulkan_Texture_Init (vulkan_ctx); Vulkan_Palette_Init (vulkan_ctx, vid.palette); diff --git a/libs/video/renderer/vulkan/render.c b/libs/video/renderer/vulkan/render.c index 82015188b..cbd3cc168 100644 --- a/libs/video/renderer/vulkan/render.c +++ b/libs/video/renderer/vulkan/render.c @@ -257,7 +257,7 @@ QFV_RunRenderJob (vulkan_ctx_t *ctx) auto device = ctx->device; auto dfunc = device->funcs; auto queue = &device->queue; - auto frame = &ctx->frames.a[ctx->curFrame]; + auto frame = &rctx->frames.a[ctx->curFrame]; VkPipelineStageFlags waitStage = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT; VkSubmitInfo submitInfo = { @@ -354,7 +354,8 @@ wait_on_fence (const exprval_t **params, exprval_t *result, exprctx_t *ectx) auto dfunc = device->funcs; auto dev = device->dev; - __auto_type frame = &ctx->frames.a[ctx->curFrame]; + auto rctx = ctx->render_context; + auto frame = &rctx->frames.a[ctx->curFrame]; dfunc->vkWaitForFences (dev, 1, &frame->fence, VK_TRUE, 2000000000); @@ -443,6 +444,28 @@ QFV_Render_Init (vulkan_ctx_t *ctx) rctx->task_functions.symbols = 0; QFV_Render_AddTasks (ctx, render_task_syms); + + auto device = ctx->device; + size_t frames = vulkan_frame_count; + DARRAY_INIT (&rctx->frames, frames); + DARRAY_RESIZE (&rctx->frames, frames); + for (size_t i = 0; i < rctx->frames.size; i++) { + auto frame = &rctx->frames.a[i]; + frame->fence = QFV_CreateFence (device, 1); + frame->imageAvailableSemaphore = QFV_CreateSemaphore (device); + QFV_duSetObjectName (device, VK_OBJECT_TYPE_SEMAPHORE, + frame->imageAvailableSemaphore, + va (ctx->va_ctx, "sc image:%zd", i)); + frame->renderDoneSemaphore = QFV_CreateSemaphore (device); + VkCommandPoolCreateInfo poolCInfo = { + .sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO, + .flags = VK_COMMAND_POOL_CREATE_TRANSIENT_BIT, + .queueFamilyIndex = device->queue.queueFamily, + }; + auto dfunc = device->funcs; + dfunc->vkCreateCommandPool (device->dev, &poolCInfo, 0, + &frame->command_pool); + } } void @@ -483,10 +506,18 @@ QFV_Render_Shutdown (vulkan_ctx_t *ctx) DARRAY_CLEAR (&job->commands); free (rctx->job); } - for (uint32_t i = 0; i < ctx->frames.size; i++) { - auto frame = &ctx->frames.a[i]; - dfunc->vkDestroyCommandPool (device->dev, frame->command_pool, 0); + + for (uint32_t i = 0; i < rctx->frames.size; i++) { + auto dev = device->dev; + auto df = dfunc; + auto frame = &rctx->frames.a[i]; + df->vkDestroyFence (dev, frame->fence, 0); + df->vkDestroySemaphore (dev, frame->imageAvailableSemaphore, 0); + df->vkDestroySemaphore (dev, frame->renderDoneSemaphore, 0); + df->vkDestroyCommandPool (dev, frame->command_pool, 0); } + DARRAY_CLEAR (&rctx->frames); + if (rctx->jobinfo) { __auto_type jinfo = rctx->jobinfo; for (uint32_t i = 0; i < jinfo->num_descriptorsetlayouts; i++) { diff --git a/libs/video/renderer/vulkan/render_load.c b/libs/video/renderer/vulkan/render_load.c index 25b1abcfb..79bf1358b 100644 --- a/libs/video/renderer/vulkan/render_load.c +++ b/libs/video/renderer/vulkan/render_load.c @@ -1125,17 +1125,6 @@ create_objects (vulkan_ctx_t *ctx, objcount_t *counts) counts->num_descriptorsets = s.inds.num_descriptorsets; init_job (ctx, counts, s); - - for (uint32_t i = 0; i < ctx->frames.size; i++) { - VkCommandPoolCreateInfo poolCInfo = { - .sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO, - .flags = VK_COMMAND_POOL_CREATE_TRANSIENT_BIT, - .queueFamilyIndex = device->queue.queueFamily, - }; - auto frame = &ctx->frames.a[i]; - dfunc->vkCreateCommandPool (device->dev, &poolCInfo, 0, - &frame->command_pool); - } } void diff --git a/libs/video/renderer/vulkan/vkparse.c b/libs/video/renderer/vulkan/vkparse.c index 875796779..5c1b5ab5a 100644 --- a/libs/video/renderer/vulkan/vkparse.c +++ b/libs/video/renderer/vulkan/vkparse.c @@ -1187,19 +1187,19 @@ parse_task_params (const plitem_t *item, void **data, #include "libs/video/renderer/vulkan/vkparse.cinc" -static exprsym_t vulkan_frameset_t_symbols[] = { - {"size", &cexpr_size_t, (void *)field_offset (vulkan_frameset_t, size)}, +static exprsym_t qfv_renderframeset_t_symbols[] = { + {"size", &cexpr_size_t, (void *)field_offset (qfv_renderframeset_t, size)}, { } }; -static exprtab_t vulkan_frameset_t_symtab = { - vulkan_frameset_t_symbols, +static exprtab_t qfv_renderframeset_t_symtab = { + qfv_renderframeset_t_symbols, }; -exprtype_t vulkan_frameset_t_type = { +exprtype_t qfv_renderframeset_t_type = { .name = "frameset", - .size = sizeof (vulkan_frameset_t *), + .size = sizeof (qfv_renderframeset_t *), .binops = cexpr_struct_binops, .unops = 0, - .data = &vulkan_frameset_t_symtab, + .data = &qfv_renderframeset_t_symtab, }; static hashtab_t * @@ -1257,9 +1257,10 @@ parse_object (vulkan_ctx_t *ctx, memsuper_t *memsuper, plitem_t *plist, plitem_t *messages = PL_NewArray (); exprctx_t exprctx = { .symtab = &root_symtab }; parsectx_t parsectx = { &exprctx, ctx, properties }; + auto rctx = ctx->render_context; exprsym_t var_syms[] = { {"output", &qfv_output_t_type, &sctx->output}, - {"frames", &vulkan_frameset_t_type, &ctx->frames}, + {"frames", &qfv_renderframeset_t_type, &rctx->frames}, {"msaaSamples", &VkSampleCountFlagBits_type, &ctx->msaaSamples}, {"physDevLimits", &VkPhysicalDeviceLimits_type, &ctx->device->physDev->properties->limits }, @@ -2050,7 +2051,7 @@ void Vulkan_Script_Init (vulkan_ctx_t *ctx) ectx.hashctx = 0;//&sctx->hashctx; vkgen_init_symtabs (&ectx); cexpr_init_symtab (&qfv_output_t_symtab, &ectx); - cexpr_init_symtab (&vulkan_frameset_t_symtab, &ectx); + cexpr_init_symtab (&qfv_renderframeset_t_symtab, &ectx); cexpr_init_symtab (&data_array_symtab, &ectx); sctx->shaderModules = handlref_symtab (shaderModule_free, sctx); @@ -2336,7 +2337,7 @@ QFV_ParseJobInfo (vulkan_ctx_t *ctx, plitem_t *item, qfv_renderctx_t *rctx) }; exprsym_t var_syms[] = { {"render_output", &qfv_output_t_type, &sctx->output}, - {"frames", &vulkan_frameset_t_type, &ctx->frames}, + {"frames", &qfv_renderframeset_t_type, &rctx->frames}, {"msaaSamples", &VkSampleCountFlagBits_type, &ctx->msaaSamples}, {"physDevLimits", &VkPhysicalDeviceLimits_type, &ctx->device->physDev->properties->limits }, diff --git a/libs/video/renderer/vulkan/vulkan_alias.c b/libs/video/renderer/vulkan/vulkan_alias.c index 77634cfe8..c41461775 100644 --- a/libs/video/renderer/vulkan/vulkan_alias.c +++ b/libs/video/renderer/vulkan/vulkan_alias.c @@ -77,7 +77,7 @@ static void emit_commands (VkCommandBuffer cmd, int pose1, int pose2, qfv_alias_skin_t *skin, uint32_t numPC, qfv_push_constants_t *constants, - aliashdr_t *hdr, qfv_renderframe_t *rFrame, entity_t ent) + aliashdr_t *hdr, qfv_orenderframe_t *rFrame, entity_t ent) { vulkan_ctx_t *ctx = rFrame->vulkan_ctx; qfv_device_t *device = ctx->device; @@ -117,7 +117,7 @@ emit_commands (VkCommandBuffer cmd, int pose1, int pose2, } void -Vulkan_DrawAlias (entity_t ent, qfv_renderframe_t *rFrame) +Vulkan_DrawAlias (entity_t ent, qfv_orenderframe_t *rFrame) { vulkan_ctx_t *ctx = rFrame->vulkan_ctx; aliasctx_t *actx = ctx->alias_context; @@ -181,7 +181,7 @@ Vulkan_DrawAlias (entity_t ent, qfv_renderframe_t *rFrame) static void alias_begin_subpass (QFV_AliasSubpass subpass, VkPipeline pipeline, - qfv_renderframe_t *rFrame) + qfv_orenderframe_t *rFrame) { vulkan_ctx_t *ctx = rFrame->vulkan_ctx; qfv_device_t *device = ctx->device; @@ -234,7 +234,7 @@ alias_end_subpass (VkCommandBuffer cmd, vulkan_ctx_t *ctx) } void -Vulkan_AliasBegin (qfv_renderframe_t *rFrame) +Vulkan_AliasBegin (qfv_orenderframe_t *rFrame) { vulkan_ctx_t *ctx = rFrame->vulkan_ctx; aliasctx_t *actx = ctx->alias_context; @@ -251,7 +251,7 @@ Vulkan_AliasBegin (qfv_renderframe_t *rFrame) } void -Vulkan_AliasEnd (qfv_renderframe_t *rFrame) +Vulkan_AliasEnd (qfv_orenderframe_t *rFrame) { vulkan_ctx_t *ctx = rFrame->vulkan_ctx; aliasctx_t *actx = ctx->alias_context; @@ -262,7 +262,7 @@ Vulkan_AliasEnd (qfv_renderframe_t *rFrame) } void -Vulkan_AliasDepthRange (qfv_renderframe_t *rFrame, +Vulkan_AliasDepthRange (qfv_orenderframe_t *rFrame, float minDepth, float maxDepth) { vulkan_ctx_t *ctx = rFrame->vulkan_ctx; @@ -321,7 +321,8 @@ Vulkan_Alias_Init (vulkan_ctx_t *ctx) aliasctx_t *actx = calloc (1, sizeof (aliasctx_t)); ctx->alias_context = actx; - size_t frames = ctx->frames.size; + auto rctx = ctx->render_context; + size_t frames = rctx->frames.size; DARRAY_INIT (&actx->frames, frames); DARRAY_RESIZE (&actx->frames, frames); actx->frames.grow = 0; diff --git a/libs/video/renderer/vulkan/vulkan_bsp.c b/libs/video/renderer/vulkan/vulkan_bsp.c index 76a782846..ce021a5e0 100644 --- a/libs/video/renderer/vulkan/vulkan_bsp.c +++ b/libs/video/renderer/vulkan/vulkan_bsp.c @@ -773,7 +773,7 @@ push_fragconst (bsp_push_constants_t *constants, VkPipelineLayout layout, static void bsp_begin_subpass (QFV_BspSubpass subpass, VkPipeline pipeline, - VkPipelineLayout layout, qfv_renderframe_t *rFrame) + VkPipelineLayout layout, qfv_orenderframe_t *rFrame) { vulkan_ctx_t *ctx = rFrame->vulkan_ctx; qfv_device_t *device = ctx->device; @@ -834,7 +834,7 @@ bsp_end_subpass (VkCommandBuffer cmd, vulkan_ctx_t *ctx) } static void -bsp_begin (qfv_renderframe_t *rFrame) +bsp_begin (qfv_orenderframe_t *rFrame) { vulkan_ctx_t *ctx = rFrame->vulkan_ctx; bspctx_t *bctx = ctx->bsp_context; @@ -864,7 +864,7 @@ bsp_end (vulkan_ctx_t *ctx) } static void -turb_begin (qfv_renderframe_t *rFrame) +turb_begin (qfv_orenderframe_t *rFrame) { vulkan_ctx_t *ctx = rFrame->vulkan_ctx; bspctx_t *bctx = ctx->bsp_context; @@ -889,7 +889,7 @@ turb_end (vulkan_ctx_t *ctx) } static void -sky_begin (qfv_renderframe_t *rFrame) +sky_begin (qfv_orenderframe_t *rFrame) { vulkan_ctx_t *ctx = rFrame->vulkan_ctx; bspctx_t *bctx = ctx->bsp_context; @@ -1025,7 +1025,7 @@ ent_model_cmp (const void *_a, const void *_b) } void -Vulkan_DrawWorld (qfv_renderframe_t *rFrame) +Vulkan_DrawWorld (qfv_orenderframe_t *rFrame) { vulkan_ctx_t *ctx = rFrame->vulkan_ctx; qfv_device_t *device = ctx->device; @@ -1127,7 +1127,7 @@ Vulkan_Bsp_Flush (vulkan_ctx_t *ctx) } void -Vulkan_DrawWaterSurfaces (qfv_renderframe_t *rFrame) +Vulkan_DrawWaterSurfaces (qfv_orenderframe_t *rFrame) { vulkan_ctx_t *ctx = rFrame->vulkan_ctx; qfv_device_t *device = ctx->device; @@ -1163,7 +1163,7 @@ Vulkan_DrawWaterSurfaces (qfv_renderframe_t *rFrame) } void -Vulkan_DrawSky (qfv_renderframe_t *rFrame) +Vulkan_DrawSky (qfv_orenderframe_t *rFrame) { vulkan_ctx_t *ctx = rFrame->vulkan_ctx; qfv_device_t *device = ctx->device; @@ -1450,7 +1450,8 @@ Vulkan_Bsp_Init (vulkan_ctx_t *ctx) DARRAY_INIT (&bctx->main_pass.draw_queues[i], 64); } - size_t frames = ctx->frames.size; + auto rctx = ctx->render_context; + size_t frames = rctx->frames.size; DARRAY_INIT (&bctx->frames, frames); DARRAY_RESIZE (&bctx->frames, frames); bctx->frames.grow = 0; diff --git a/libs/video/renderer/vulkan/vulkan_compose.c b/libs/video/renderer/vulkan/vulkan_compose.c index 06d9240c3..550baade3 100644 --- a/libs/video/renderer/vulkan/vulkan_compose.c +++ b/libs/video/renderer/vulkan/vulkan_compose.c @@ -58,7 +58,7 @@ #include "vid_vulkan.h" void -Vulkan_Compose_Draw (qfv_renderframe_t *rFrame) +Vulkan_Compose_Draw (qfv_orenderframe_t *rFrame) { vulkan_ctx_t *ctx = rFrame->vulkan_ctx; qfv_device_t *device = ctx->device; @@ -146,7 +146,8 @@ Vulkan_Compose_Init (vulkan_ctx_t *ctx) composectx_t *cctx = calloc (1, sizeof (composectx_t)); ctx->compose_context = cctx; - size_t frames = ctx->frames.size; + auto rctx = ctx->render_context; + size_t frames = rctx->frames.size; DARRAY_INIT (&cctx->frames, frames); DARRAY_RESIZE (&cctx->frames, frames); cctx->frames.grow = 0; diff --git a/libs/video/renderer/vulkan/vulkan_draw.c b/libs/video/renderer/vulkan/vulkan_draw.c index 7539e9518..be42640ee 100644 --- a/libs/video/renderer/vulkan/vulkan_draw.c +++ b/libs/video/renderer/vulkan/vulkan_draw.c @@ -285,7 +285,8 @@ create_buffers (vulkan_ctx_t *ctx) qfv_device_t *device = ctx->device; qfv_devfuncs_t *dfunc = device->funcs; drawctx_t *dctx = ctx->draw_context; - size_t frames = ctx->frames.size; + auto rctx = ctx->render_context; + size_t frames = rctx->frames.size; dctx->draw_resource = malloc (2 * sizeof (qfv_resource_t) // index buffer @@ -1030,7 +1031,8 @@ Vulkan_Draw_Init (vulkan_ctx_t *ctx) drawctx_t *dctx = calloc (1, sizeof (drawctx_t)); ctx->draw_context = dctx; - size_t frames = ctx->frames.size; + auto rctx = ctx->render_context; + size_t frames = rctx->frames.size; DARRAY_INIT (&dctx->frames, frames); DARRAY_RESIZE (&dctx->frames, frames); dctx->frames.grow = 0; diff --git a/libs/video/renderer/vulkan/vulkan_iqm.c b/libs/video/renderer/vulkan/vulkan_iqm.c index 42f1486ea..92e3fd2e7 100644 --- a/libs/video/renderer/vulkan/vulkan_iqm.c +++ b/libs/video/renderer/vulkan/vulkan_iqm.c @@ -78,7 +78,7 @@ static void emit_commands (VkCommandBuffer cmd, int pose1, int pose2, qfv_iqm_skin_t *skins, uint32_t numPC, qfv_push_constants_t *constants, - iqm_t *iqm, qfv_renderframe_t *rFrame, entity_t ent) + iqm_t *iqm, qfv_orenderframe_t *rFrame, entity_t ent) { vulkan_ctx_t *ctx = rFrame->vulkan_ctx; qfv_device_t *device = ctx->device; @@ -127,7 +127,7 @@ emit_commands (VkCommandBuffer cmd, int pose1, int pose2, #define a(x) ((x) & ~0x3f) void -Vulkan_DrawIQM (entity_t ent, qfv_renderframe_t *rFrame) +Vulkan_DrawIQM (entity_t ent, qfv_orenderframe_t *rFrame) { vulkan_ctx_t *ctx = rFrame->vulkan_ctx; qfv_device_t *device = ctx->device; @@ -207,7 +207,7 @@ Vulkan_DrawIQM (entity_t ent, qfv_renderframe_t *rFrame) static void iqm_begin_subpass (QFV_IQMSubpass subpass, VkPipeline pipeline, - qfv_renderframe_t *rFrame) + qfv_orenderframe_t *rFrame) { vulkan_ctx_t *ctx = rFrame->vulkan_ctx; qfv_device_t *device = ctx->device; @@ -258,7 +258,7 @@ iqm_end_subpass (VkCommandBuffer cmd, vulkan_ctx_t *ctx) } void -Vulkan_IQMBegin (qfv_renderframe_t *rFrame) +Vulkan_IQMBegin (qfv_orenderframe_t *rFrame) { vulkan_ctx_t *ctx = rFrame->vulkan_ctx; iqmctx_t *ictx = ctx->iqm_context; @@ -275,7 +275,7 @@ Vulkan_IQMBegin (qfv_renderframe_t *rFrame) } void -Vulkan_IQMEnd (qfv_renderframe_t *rFrame) +Vulkan_IQMEnd (qfv_orenderframe_t *rFrame) { vulkan_ctx_t *ctx = rFrame->vulkan_ctx; iqmctx_t *ictx = ctx->iqm_context; @@ -386,7 +386,8 @@ Vulkan_IQM_Init (vulkan_ctx_t *ctx) iqmctx_t *ictx = calloc (1, sizeof (iqmctx_t)); ctx->iqm_context = ictx; - size_t frames = ctx->frames.size; + auto rctx = ctx->render_context; + size_t frames = rctx->frames.size; DARRAY_INIT (&ictx->frames, frames); DARRAY_RESIZE (&ictx->frames, frames); ictx->frames.grow = 0; diff --git a/libs/video/renderer/vulkan/vulkan_lighting.c b/libs/video/renderer/vulkan/vulkan_lighting.c index 90eae7ea7..e736f22ba 100644 --- a/libs/video/renderer/vulkan/vulkan_lighting.c +++ b/libs/video/renderer/vulkan/vulkan_lighting.c @@ -148,7 +148,7 @@ update_lights (vulkan_ctx_t *ctx) } void -Vulkan_Lighting_Draw (qfv_renderframe_t *rFrame) +Vulkan_Lighting_Draw (qfv_orenderframe_t *rFrame) { vulkan_ctx_t *ctx = rFrame->vulkan_ctx; qfv_device_t *device = ctx->device; @@ -220,7 +220,7 @@ Vulkan_Lighting_Draw (qfv_renderframe_t *rFrame) } static void -lighting_draw_maps (qfv_renderframe_t *rFrame) +lighting_draw_maps (qfv_orenderframe_t *rFrame) { vulkan_ctx_t *ctx = rFrame->vulkan_ctx; qfv_device_t *device = ctx->device; @@ -361,7 +361,8 @@ Vulkan_Lighting_Init (vulkan_ctx_t *ctx) DARRAY_INIT (&lctx->light_images, 16); DARRAY_INIT (&lctx->light_renderers, 16); - size_t frames = ctx->frames.size; + auto rctx = ctx->render_context; + size_t frames = rctx->frames.size; DARRAY_INIT (&lctx->frames, frames); DARRAY_RESIZE (&lctx->frames, frames); lctx->frames.grow = 0; diff --git a/libs/video/renderer/vulkan/vulkan_main.c b/libs/video/renderer/vulkan/vulkan_main.c index a4dbd0bfa..6ac19052d 100644 --- a/libs/video/renderer/vulkan/vulkan_main.c +++ b/libs/video/renderer/vulkan/vulkan_main.c @@ -69,7 +69,7 @@ #include "vid_vulkan.h" void -Vulkan_RenderEntities (entqueue_t *queue, qfv_renderframe_t *rFrame) +Vulkan_RenderEntities (entqueue_t *queue, qfv_orenderframe_t *rFrame) { if (!r_drawentities) return; @@ -123,7 +123,7 @@ Vulkan_DrawViewModel (vulkan_ctx_t *ctx) } void -Vulkan_RenderView (qfv_renderframe_t *rFrame) +Vulkan_RenderView (qfv_orenderframe_t *rFrame) { vulkan_ctx_t *ctx = rFrame->vulkan_ctx; @@ -165,7 +165,7 @@ Vulkan_NewScene (scene_t *scene, vulkan_ctx_t *ctx) } static void -main_draw (qfv_renderframe_t *rFrame) +main_draw (qfv_orenderframe_t *rFrame) { Vulkan_RenderView (rFrame); Vulkan_Lighting_Draw (rFrame); diff --git a/libs/video/renderer/vulkan/vulkan_matrices.c b/libs/video/renderer/vulkan/vulkan_matrices.c index 3fb0daf1e..48986a299 100644 --- a/libs/video/renderer/vulkan/vulkan_matrices.c +++ b/libs/video/renderer/vulkan/vulkan_matrices.c @@ -238,7 +238,8 @@ Vulkan_Matrix_Init (vulkan_ctx_t *ctx) matrixctx_t *mctx = calloc (1, sizeof (matrixctx_t)); ctx->matrix_context = mctx; - size_t frames = ctx->frames.size; + auto rctx = ctx->render_context; + size_t frames = rctx->frames.size; DARRAY_INIT (&mctx->frames, frames); DARRAY_RESIZE (&mctx->frames, frames); mctx->frames.grow = 0; diff --git a/libs/video/renderer/vulkan/vulkan_output.c b/libs/video/renderer/vulkan/vulkan_output.c index b84533b98..5581f78ec 100644 --- a/libs/video/renderer/vulkan/vulkan_output.c +++ b/libs/video/renderer/vulkan/vulkan_output.c @@ -63,12 +63,12 @@ #include "vkparse.h"//FIXME static void -preoutput_draw (qfv_renderframe_t *rFrame) +preoutput_draw (qfv_orenderframe_t *rFrame) { } static void -process_input (qfv_renderframe_t *rFrame) +process_input (qfv_orenderframe_t *rFrame) { return; vulkan_ctx_t *ctx = rFrame->vulkan_ctx; @@ -143,7 +143,7 @@ process_input (qfv_renderframe_t *rFrame) } static void -draw_output (qfv_renderframe_t *rFrame) +draw_output (qfv_orenderframe_t *rFrame) { process_input (rFrame); } @@ -181,7 +181,8 @@ acquire_output (const exprval_t **params, exprval_t *result, exprctx_t *ectx) auto ctx = taskctx->ctx; auto device = ctx->device; auto dfunc = device->funcs; - auto frame = &ctx->frames.a[ctx->curFrame]; + auto rctx = ctx->render_context; + auto frame = &rctx->frames.a[ctx->curFrame]; auto octx = ctx->output_context; auto sc = ctx->swapchain; @@ -321,7 +322,8 @@ Vulkan_Output_Init (vulkan_ctx_t *ctx) outputctx_t *octx = ctx->output_context; - size_t frames = ctx->frames.size; + auto rctx = ctx->render_context; + size_t frames = rctx->frames.size; DARRAY_INIT (&octx->frames, frames); DARRAY_RESIZE (&octx->frames, frames); octx->frames.grow = 0; diff --git a/libs/video/renderer/vulkan/vulkan_particles.c b/libs/video/renderer/vulkan/vulkan_particles.c index 8cd78b56f..1a9b26cda 100644 --- a/libs/video/renderer/vulkan/vulkan_particles.c +++ b/libs/video/renderer/vulkan/vulkan_particles.c @@ -72,7 +72,7 @@ static const char * __attribute__((used)) particle_pass_names[] = { }; static void -particle_begin_subpass (VkPipeline pipeline, qfv_renderframe_t *rFrame) +particle_begin_subpass (VkPipeline pipeline, qfv_orenderframe_t *rFrame) { vulkan_ctx_t *ctx = rFrame->vulkan_ctx; qfv_device_t *device = ctx->device; @@ -121,7 +121,7 @@ particle_end_subpass (VkCommandBuffer cmd, vulkan_ctx_t *ctx) } void -Vulkan_DrawParticles (qfv_renderframe_t *rFrame) +Vulkan_DrawParticles (qfv_orenderframe_t *rFrame) { vulkan_ctx_t *ctx = rFrame->vulkan_ctx; qfv_device_t *device = ctx->device; @@ -187,7 +187,8 @@ create_buffers (vulkan_ctx_t *ctx) qfv_devfuncs_t *dfunc = device->funcs; particlectx_t *pctx = ctx->particle_context; size_t mp = MaxParticles; - size_t frames = ctx->frames.size; + auto rctx = ctx->render_context; + size_t frames = rctx->frames.size; pctx->resources = malloc (sizeof (qfv_resource_t) // states buffer @@ -417,7 +418,8 @@ Vulkan_Particles_Init (vulkan_ctx_t *ctx) ctx->particle_context = pctx; pctx->psystem = &r_psystem; - size_t frames = ctx->frames.size; + auto rctx = ctx->render_context; + size_t frames = rctx->frames.size; DARRAY_INIT (&pctx->frames, frames); DARRAY_RESIZE (&pctx->frames, frames); pctx->frames.grow = 0; @@ -481,7 +483,7 @@ Vulkan_Particles_Shutdown (vulkan_ctx_t *ctx) qfv_device_t *device = ctx->device; qfv_devfuncs_t *dfunc = device->funcs; particlectx_t *pctx = ctx->particle_context; - size_t frames = ctx->frames.size; + size_t frames = pctx->frames.size; for (size_t i = 0; i < frames; i++) { __auto_type pframe = &pctx->frames.a[i]; @@ -507,7 +509,7 @@ Vulkan_ParticleSystem (vulkan_ctx_t *ctx) } static void -particles_update (qfv_renderframe_t *rFrame) +particles_update (qfv_orenderframe_t *rFrame) { vulkan_ctx_t *ctx = rFrame->vulkan_ctx; qfv_device_t *device = ctx->device; diff --git a/libs/video/renderer/vulkan/vulkan_renderpass.c b/libs/video/renderer/vulkan/vulkan_renderpass.c index 7fadceb8b..b911b1100 100644 --- a/libs/video/renderer/vulkan/vulkan_renderpass.c +++ b/libs/video/renderer/vulkan/vulkan_renderpass.c @@ -257,7 +257,7 @@ QFV_RenderPass_CreateFramebuffer (qfv_orenderpass_t *renderpass) static void init_renderframe (vulkan_ctx_t *ctx, qfv_orenderpass_t *rp, - qfv_renderframe_t *rFrame) + qfv_orenderframe_t *rFrame) { rFrame->vulkan_ctx = ctx; rFrame->renderpass = rp; @@ -353,7 +353,7 @@ QFV_RenderPass_New (vulkan_ctx_t *ctx, const char *name, qfv_draw_t function) } DARRAY_INIT (&rp->frames, 4); - DARRAY_RESIZE (&rp->frames, ctx->frames.size); + //DARRAY_RESIZE (&rp->frames, ctx->frames.size); for (size_t i = 0; i < rp->frames.size; i++) { init_renderframe (ctx, rp, &rp->frames.a[i]); } diff --git a/libs/video/renderer/vulkan/vulkan_scene.c b/libs/video/renderer/vulkan/vulkan_scene.c index 0fb6cf3a9..80d2976e4 100644 --- a/libs/video/renderer/vulkan/vulkan_scene.c +++ b/libs/video/renderer/vulkan/vulkan_scene.c @@ -44,6 +44,7 @@ #include "QF/Vulkan/descriptor.h" #include "QF/Vulkan/device.h" #include "QF/Vulkan/instance.h" +#include "QF/Vulkan/render.h" #include "QF/Vulkan/resource.h" #include "r_internal.h" @@ -143,7 +144,8 @@ Vulkan_Scene_Init (vulkan_ctx_t *ctx) ctx->scene_context = sctx; sctx->max_entities = qfv_max_entities; - size_t frames = ctx->frames.size; + auto rctx = ctx->render_context; + size_t frames = rctx->frames.size; DARRAY_INIT (&sctx->frames, frames); DARRAY_RESIZE (&sctx->frames, frames); sctx->frames.grow = 0; diff --git a/libs/video/renderer/vulkan/vulkan_sprite.c b/libs/video/renderer/vulkan/vulkan_sprite.c index e33404806..3f11f58e4 100644 --- a/libs/video/renderer/vulkan/vulkan_sprite.c +++ b/libs/video/renderer/vulkan/vulkan_sprite.c @@ -83,7 +83,7 @@ static QFV_Subpass subpass_map[] = { static void emit_commands (VkCommandBuffer cmd, qfv_sprite_t *sprite, int numPC, qfv_push_constants_t *constants, - qfv_renderframe_t *rFrame, entity_t ent) + qfv_orenderframe_t *rFrame, entity_t ent) { vulkan_ctx_t *ctx = rFrame->vulkan_ctx; qfv_device_t *device = ctx->device; @@ -104,7 +104,7 @@ emit_commands (VkCommandBuffer cmd, qfv_sprite_t *sprite, } void -Vulkan_DrawSprite (entity_t ent, qfv_renderframe_t *rFrame) +Vulkan_DrawSprite (entity_t ent, qfv_orenderframe_t *rFrame) { vulkan_ctx_t *ctx = rFrame->vulkan_ctx; spritectx_t *sctx = ctx->sprite_context; @@ -142,7 +142,7 @@ Vulkan_DrawSprite (entity_t ent, qfv_renderframe_t *rFrame) static void sprite_begin_subpass (QFV_SpriteSubpass subpass, VkPipeline pipeline, - qfv_renderframe_t *rFrame) + qfv_orenderframe_t *rFrame) { vulkan_ctx_t *ctx = rFrame->vulkan_ctx; qfv_device_t *device = ctx->device; @@ -193,7 +193,7 @@ sprite_end_subpass (VkCommandBuffer cmd, vulkan_ctx_t *ctx) } void -Vulkan_SpriteBegin (qfv_renderframe_t *rFrame) +Vulkan_SpriteBegin (qfv_orenderframe_t *rFrame) { vulkan_ctx_t *ctx = rFrame->vulkan_ctx; spritectx_t *sctx = ctx->sprite_context; @@ -210,7 +210,7 @@ Vulkan_SpriteBegin (qfv_renderframe_t *rFrame) } void -Vulkan_SpriteEnd (qfv_renderframe_t *rFrame) +Vulkan_SpriteEnd (qfv_orenderframe_t *rFrame) { vulkan_ctx_t *ctx = rFrame->vulkan_ctx; spritectx_t *sctx = ctx->sprite_context; @@ -310,7 +310,8 @@ Vulkan_Sprite_Init (vulkan_ctx_t *ctx) spritectx_t *sctx = calloc (1, sizeof (spritectx_t)); ctx->sprite_context = sctx; - size_t frames = ctx->frames.size; + auto rctx = ctx->render_context; + size_t frames = rctx->frames.size; DARRAY_INIT (&sctx->frames, frames); DARRAY_RESIZE (&sctx->frames, frames); sctx->frames.grow = 0; diff --git a/libs/video/renderer/vulkan/vulkan_translucent.c b/libs/video/renderer/vulkan/vulkan_translucent.c index f79bfccc6..fc89a3087 100644 --- a/libs/video/renderer/vulkan/vulkan_translucent.c +++ b/libs/video/renderer/vulkan/vulkan_translucent.c @@ -143,7 +143,8 @@ Vulkan_Translucent_Init (vulkan_ctx_t *ctx) translucentctx_t *tctx = calloc (1, sizeof (translucentctx_t)); ctx->translucent_context = tctx; - size_t frames = ctx->frames.size; + auto rctx = ctx->render_context; + size_t frames = rctx->frames.size; DARRAY_INIT (&tctx->frames, frames); DARRAY_RESIZE (&tctx->frames, frames); tctx->frames.grow = 0; @@ -211,7 +212,7 @@ Vulkan_Translucent_CreateBuffers (vulkan_ctx_t *ctx, VkExtent2D extent) qfv_device_t *device = ctx->device; qfv_devfuncs_t *dfunc = device->funcs; __auto_type tctx = ctx->translucent_context; - size_t frames = ctx->frames.size; + size_t frames = tctx->frames.size; if (tctx->resources) { QFV_DestroyResource (device, tctx->resources); @@ -314,7 +315,7 @@ Vulkan_Translucent_CreateBuffers (vulkan_ctx_t *ctx, VkExtent2D extent) } static void -translucent_clear (qfv_renderframe_t *rFrame) +translucent_clear (qfv_orenderframe_t *rFrame) { vulkan_ctx_t *ctx = rFrame->vulkan_ctx; qfv_device_t *device = ctx->device; diff --git a/libs/video/renderer/vulkan/vulkan_vid_common.c b/libs/video/renderer/vulkan/vulkan_vid_common.c index 43a74f918..a7bef9bae 100644 --- a/libs/video/renderer/vulkan/vulkan_vid_common.c +++ b/libs/video/renderer/vulkan/vulkan_vid_common.c @@ -125,9 +125,6 @@ Vulkan_Shutdown_Common (vulkan_ctx_t *ctx) if (ctx->capture) { QFV_DestroyCapture (ctx->capture); } - if (ctx->frames.size) { - Vulkan_DestroyFrames (ctx); - } if (ctx->swapchain) { QFV_DestroySwapchain (ctx->swapchain); } @@ -216,58 +213,15 @@ Vulkan_DestroyRenderPasses (vulkan_ctx_t *ctx) } } -void -Vulkan_CreateFrames (vulkan_ctx_t *ctx) -{ - qfv_device_t *device = ctx->device; - VkCommandPool cmdpool = ctx->cmdpool; - - if (!ctx->frames.grow) { - DARRAY_INIT (&ctx->frames, 4); - } - - DARRAY_RESIZE (&ctx->frames, vulkan_frame_count); - - __auto_type cmdBuffers = QFV_AllocCommandBufferSet (ctx->frames.size, - alloca); - QFV_AllocateCommandBuffers (device, cmdpool, 0, cmdBuffers); - - for (size_t i = 0; i < ctx->frames.size; i++) { - __auto_type frame = &ctx->frames.a[i]; - frame->fence = QFV_CreateFence (device, 1); - frame->imageAvailableSemaphore = QFV_CreateSemaphore (device); - QFV_duSetObjectName (device, VK_OBJECT_TYPE_SEMAPHORE, - frame->imageAvailableSemaphore, - va (ctx->va_ctx, "sc image:%zd", i)); - frame->renderDoneSemaphore = QFV_CreateSemaphore (device); - frame->cmdBuffer = cmdBuffers->a[i]; - } -} - void Vulkan_CreateCapture (vulkan_ctx_t *ctx) { - ctx->capture = QFV_CreateCapture (ctx->device, ctx->frames.size, + //FIXME this should be in render + auto rctx = ctx->render_context; + ctx->capture = QFV_CreateCapture (ctx->device, rctx->frames.size, ctx->swapchain, ctx->cmdpool); } -void -Vulkan_DestroyFrames (vulkan_ctx_t *ctx) -{ - qfv_device_t *device = ctx->device; - qfv_devfuncs_t *df = device->funcs; - VkDevice dev = device->dev; - - for (size_t i = 0; i < ctx->frames.size; i++) { - __auto_type frame = &ctx->frames.a[i]; - df->vkDestroyFence (dev, frame->fence, 0); - df->vkDestroySemaphore (dev, frame->imageAvailableSemaphore, 0); - df->vkDestroySemaphore (dev, frame->renderDoneSemaphore, 0); - } - - DARRAY_CLEAR (&ctx->frames); -} - void Vulkan_BeginEntityLabel (vulkan_ctx_t *ctx, VkCommandBuffer cmd, entity_t ent) {