From 0ecdd0e86be525de3f0d8620d440d81cd957d90f Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Mon, 26 Sep 2022 09:52:14 +0900 Subject: [PATCH] [vulkan] Rearrange init code in preparation for resizing I've found and mostly isolated the parts of the code that will be affected by window resizing, minus pipelines but they use dynamic viewport and scissor settings and thus shouldn't be affected so long as the swapchain format doesn't change (how does that happen?) --- include/QF/Vulkan/qf_renderpass.h | 2 ++ libs/video/renderer/vid_render_vulkan.c | 5 +++-- libs/video/renderer/vulkan/vulkan_renderpass.c | 9 +++++---- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/include/QF/Vulkan/qf_renderpass.h b/include/QF/Vulkan/qf_renderpass.h index 3cd50ae30..d459f8d99 100644 --- a/include/QF/Vulkan/qf_renderpass.h +++ b/include/QF/Vulkan/qf_renderpass.h @@ -64,5 +64,7 @@ qfv_renderpass_t *Vulkan_CreateRenderPass (struct vulkan_ctx_s *ctx, qfv_draw_t draw); void Vulkan_DestroyRenderPass (struct vulkan_ctx_s *ctx, qfv_renderpass_t *renderpass); +void Vulkan_CreateAttachments (struct vulkan_ctx_s *ctx, + qfv_renderpass_t *renderpass); #endif//__QF_Vulkan_renderpass_h diff --git a/libs/video/renderer/vid_render_vulkan.c b/libs/video/renderer/vid_render_vulkan.c index 6f9e2104d..59a038056 100644 --- a/libs/video/renderer/vid_render_vulkan.c +++ b/libs/video/renderer/vid_render_vulkan.c @@ -87,11 +87,12 @@ static void vulkan_R_Init (void) { Vulkan_CreateStagingBuffers (vulkan_ctx); - Vulkan_CreateSwapchain (vulkan_ctx); Vulkan_CreateFrames (vulkan_ctx); + Vulkan_Texture_Init (vulkan_ctx); + + Vulkan_CreateSwapchain (vulkan_ctx); Vulkan_CreateCapture (vulkan_ctx); Vulkan_CreateRenderPasses (vulkan_ctx); - Vulkan_Texture_Init (vulkan_ctx); Vulkan_Matrix_Init (vulkan_ctx); Vulkan_Scene_Init (vulkan_ctx); diff --git a/libs/video/renderer/vulkan/vulkan_renderpass.c b/libs/video/renderer/vulkan/vulkan_renderpass.c index 6ddf82136..2b53e83ae 100644 --- a/libs/video/renderer/vulkan/vulkan_renderpass.c +++ b/libs/video/renderer/vulkan/vulkan_renderpass.c @@ -74,10 +74,11 @@ get_image_size (VkImage image, qfv_device_t *device) return size; } -static void -create_attachements (vulkan_ctx_t *ctx, qfv_renderpass_t *rp) +void +Vulkan_CreateAttachments (vulkan_ctx_t *ctx, qfv_renderpass_t *renderpass) { qfv_device_t *device = ctx->device; + __auto_type rp = renderpass; plitem_t *item = get_rp_item (ctx, rp, "images"); if (!item) { @@ -252,13 +253,13 @@ Vulkan_CreateRenderPass (vulkan_ctx_t *ctx, const char *name, init_renderframe (ctx, rp, &rp->frames.a[i]); } - create_attachements (ctx, rp); - item = get_rp_item (ctx, rp, "clearValues"); rp->clearValues = QFV_ParseClearValues (ctx, item, rp->renderpassDef); rp->draw = draw; + Vulkan_CreateAttachments (ctx, rp); + return rp; }