[vulkan] Add a function to config render output

It just moves the already existing code from vulkan_main.c.
This commit is contained in:
Bill Currie 2023-02-19 12:38:46 +09:00
parent fc06547dd9
commit 1ef658a260
3 changed files with 20 additions and 10 deletions

View file

@ -80,6 +80,10 @@ void Vulkan_Init_Common (struct vulkan_ctx_s *ctx);
void Vulkan_Shutdown_Common (struct vulkan_ctx_s *ctx); void Vulkan_Shutdown_Common (struct vulkan_ctx_s *ctx);
void Vulkan_CreateStagingBuffers (struct vulkan_ctx_s *ctx); void Vulkan_CreateStagingBuffers (struct vulkan_ctx_s *ctx);
struct qfv_output_s;
void Vulkan_ConfigOutput (struct vulkan_ctx_s *ctx,
struct qfv_output_s *output);
VkPipeline Vulkan_CreateComputePipeline (struct vulkan_ctx_s *ctx, VkPipeline Vulkan_CreateComputePipeline (struct vulkan_ctx_s *ctx,
const char *name); const char *name);
VkPipeline Vulkan_CreateGraphicsPipeline (struct vulkan_ctx_s *ctx, VkPipeline Vulkan_CreateGraphicsPipeline (struct vulkan_ctx_s *ctx,

View file

@ -177,16 +177,7 @@ void
Vulkan_Main_CreateRenderPasses (vulkan_ctx_t *ctx) Vulkan_Main_CreateRenderPasses (vulkan_ctx_t *ctx)
{ {
__auto_type rp = QFV_RenderPass_New (ctx, "deferred", main_draw); __auto_type rp = QFV_RenderPass_New (ctx, "deferred", main_draw);
rp->output = (qfv_output_t) { Vulkan_ConfigOutput (ctx, &rp->output);
.extent = ctx->swapchain->extent,
.frames = ctx->swapchain->numImages,
};
if (vulkan_frame_width > 0) {
rp->output.extent.width = vulkan_frame_width;
}
if (vulkan_frame_height > 0) {
rp->output.extent.height = vulkan_frame_height;
}
QFV_RenderPass_CreateAttachments (rp); QFV_RenderPass_CreateAttachments (rp);
QFV_RenderPass_CreateRenderPass (rp); QFV_RenderPass_CreateRenderPass (rp);
QFV_RenderPass_CreateFramebuffer (rp); QFV_RenderPass_CreateFramebuffer (rp);

View file

@ -280,3 +280,18 @@ Vulkan_BeginEntityLabel (vulkan_ctx_t *ctx, VkCommandBuffer cmd, entity_t ent)
va (ctx->va_ctx, "ent %03x.%05x [%g, %g, %g]", va (ctx->va_ctx, "ent %03x.%05x [%g, %g, %g]",
entgen, entind, VectorExpand (pos)), color); entgen, entind, VectorExpand (pos)), color);
} }
void
Vulkan_ConfigOutput (vulkan_ctx_t *ctx, qfv_output_t *output)
{
*output = (qfv_output_t) {
.extent = ctx->swapchain->extent,
.frames = ctx->swapchain->numImages,
};
if (vulkan_frame_width > 0) {
output->extent.width = vulkan_frame_width;
}
if (vulkan_frame_height > 0) {
output->extent.height = vulkan_frame_height;
}
}