From 242cd76ee70d1e0b06aec6aeb0cce3108463c936 Mon Sep 17 00:00:00 2001 From: Niklas Haas Date: Sat, 23 Oct 2021 21:04:51 +0200 Subject: [PATCH] vo_gpu: vulkan: expose swapchain to mpvk_ctx So I can reuse it in vo_gpu_next. --- video/out/vulkan/common.h | 1 + video/out/vulkan/context.c | 15 +++++++-------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/video/out/vulkan/common.h b/video/out/vulkan/common.h index b085fb462c..523de8e66e 100644 --- a/video/out/vulkan/common.h +++ b/video/out/vulkan/common.h @@ -32,5 +32,6 @@ struct mpvk_ctx { const struct pl_vk_inst *vkinst; const struct pl_vulkan *vulkan; const struct pl_gpu *gpu; // points to vulkan->gpu for convenience + const struct pl_swapchain *swapchain; VkSurfaceKHR surface; }; diff --git a/video/out/vulkan/context.c b/video/out/vulkan/context.c index 7c9f2f6151..3e49435f14 100644 --- a/video/out/vulkan/context.c +++ b/video/out/vulkan/context.c @@ -115,7 +115,6 @@ struct priv { struct mpvk_ctx *vk; struct vulkan_opts *opts; struct ra_vk_ctx_params params; - const struct pl_swapchain *swapchain; struct ra_tex proxy_tex; }; @@ -140,7 +139,7 @@ void ra_vk_ctx_uninit(struct ra_ctx *ctx) if (ctx->ra) { pl_gpu_finish(vk->gpu); - pl_swapchain_destroy(&p->swapchain); + pl_swapchain_destroy(&vk->swapchain); ctx->ra->fns->destroy(ctx->ra); ctx->ra = NULL; } @@ -195,8 +194,8 @@ bool ra_vk_ctx_init(struct ra_ctx *ctx, struct mpvk_ctx *vk, if (p->opts->swap_mode >= 0) // user override pl_params.present_mode = p->opts->swap_mode; - p->swapchain = pl_vulkan_create_swapchain(vk->vulkan, &pl_params); - if (!p->swapchain) + vk->swapchain = pl_vulkan_create_swapchain(vk->vulkan, &pl_params); + if (!vk->swapchain) goto error; return true; @@ -210,7 +209,7 @@ bool ra_vk_ctx_resize(struct ra_ctx *ctx, int width, int height) { struct priv *p = ctx->swapchain->priv; - bool ok = pl_swapchain_resize(p->swapchain, &width, &height); + bool ok = pl_swapchain_resize(p->vk->swapchain, &width, &height); ctx->vo->dwidth = width; ctx->vo->dheight = height; @@ -245,7 +244,7 @@ static bool start_frame(struct ra_swapchain *sw, struct ra_fbo *out_fbo) start = p->params.start_frame(sw->ctx); if (!start) return false; - if (!pl_swapchain_start_frame(p->swapchain, &frame)) + if (!pl_swapchain_start_frame(p->vk->swapchain, &frame)) return false; if (!mppl_wrap_tex(sw->ctx->ra, frame.fbo, &p->proxy_tex)) return false; @@ -261,13 +260,13 @@ static bool start_frame(struct ra_swapchain *sw, struct ra_fbo *out_fbo) static bool submit_frame(struct ra_swapchain *sw, const struct vo_frame *frame) { struct priv *p = sw->priv; - return pl_swapchain_submit_frame(p->swapchain); + return pl_swapchain_submit_frame(p->vk->swapchain); } static void swap_buffers(struct ra_swapchain *sw) { struct priv *p = sw->priv; - pl_swapchain_swap_buffers(p->swapchain); + pl_swapchain_swap_buffers(p->vk->swapchain); if (p->params.swap_buffers) p->params.swap_buffers(sw->ctx); }