summaryrefslogtreecommitdiffstats
path: root/video/out
diff options
context:
space:
mode:
authorNiklas Haas <git@haasn.dev>2022-02-03 16:20:18 +0100
committerNiklas Haas <github-daiK1o@haasn.dev>2022-02-03 18:22:14 +0100
commit88c6c84b64f91bd1f532a62770ebf4615bda098e (patch)
treee2e56403a247a29a80e0e7b5f09a8405a9f26c3f /video/out
parente8e89fae3819c84068562201fe18cbe7ec180fd7 (diff)
downloadmpv-88c6c84b64f91bd1f532a62770ebf4615bda098e.tar.bz2
mpv-88c6c84b64f91bd1f532a62770ebf4615bda098e.tar.xz
libplacebo: update log helpers
Use the pl_log APIs introduced in libplacebo v4, replacing the deprecated pl_context concept.
Diffstat (limited to 'video/out')
-rw-r--r--video/out/gpu_next/context.c14
-rw-r--r--video/out/hwdec/hwdec_vaapi_vk.c7
-rw-r--r--video/out/placebo/utils.c19
-rw-r--r--video/out/placebo/utils.h3
-rw-r--r--video/out/vulkan/common.h4
-rw-r--r--video/out/vulkan/context.c4
-rw-r--r--video/out/vulkan/context_display.c2
-rw-r--r--video/out/vulkan/utils.c20
8 files changed, 35 insertions, 38 deletions
diff --git a/video/out/gpu_next/context.c b/video/out/gpu_next/context.c
index 7315355b59..53559161ae 100644
--- a/video/out/gpu_next/context.c
+++ b/video/out/gpu_next/context.c
@@ -89,8 +89,7 @@ static bool d3d11_pl_init(struct vo *vo, struct gpu_ctx *ctx, struct priv *p,
}
ctx->gpu = p->d3d11->gpu;
- mppl_ctx_set_log(ctx->pllog, ctx->log, false); // disable probing
-
+ mppl_log_set_probing(ctx->pllog, false);
ctx->swapchain = pl_d3d11_create_swapchain(p->d3d11,
pl_d3d11_swapchain_params(
.swapchain = swapchain,
@@ -128,20 +127,18 @@ struct gpu_ctx *gpu_ctx_create(struct vo *vo, struct gl_video_opts *gl_opts)
#if HAVE_VULKAN
struct mpvk_ctx *vkctx = ra_vk_ctx_get(ctx->ra_ctx);
if (vkctx) {
- ctx->pllog = vkctx->ctx;
+ ctx->pllog = vkctx->pllog;
ctx->gpu = vkctx->gpu;
ctx->swapchain = vkctx->swapchain;
return ctx;
}
#endif
- ctx->pllog = pl_log_create(PL_API_VER, NULL);
+ ctx->pllog = mppl_log_create(ctx->log);
if (!ctx->pllog)
goto err_out;
- mppl_ctx_set_log(ctx->pllog, ctx->log, vo->probing);
- mp_verbose(ctx->log, "Initialized libplacebo %s (API v%d)\n",
- PL_VERSION, PL_API_VER);
+ mppl_log_set_probing(ctx->pllog, vo->probing);
#if HAVE_D3D11
if (ra_is_d3d11(ctx->ra_ctx->ra)) {
@@ -162,8 +159,7 @@ struct gpu_ctx *gpu_ctx_create(struct vo *vo, struct gl_video_opts *gl_opts)
goto err_out;
ctx->gpu = p->opengl->gpu;
- mppl_ctx_set_log(ctx->pllog, ctx->log, false); // disable probing
-
+ mppl_log_set_probing(ctx->pllog, false);
ctx->swapchain = pl_opengl_create_swapchain(p->opengl, pl_opengl_swapchain_params(
.max_swapchain_depth = vo->opts->swapchain_depth,
));
diff --git a/video/out/hwdec/hwdec_vaapi_vk.c b/video/out/hwdec/hwdec_vaapi_vk.c
index b6af805e39..b6fd3f891f 100644
--- a/video/out/hwdec/hwdec_vaapi_vk.c
+++ b/video/out/hwdec/hwdec_vaapi_vk.c
@@ -81,12 +81,11 @@ static bool vaapi_vk_map(struct ra_hwdec_mapper *mapper, bool probing)
},
};
- mppl_ctx_set_log(gpu->ctx, mapper->ra->log, probing);
+ mppl_log_set_probing(gpu->log, probing);
const struct pl_tex *pltex = pl_tex_create(gpu, &tex_params);
- mppl_ctx_set_log(gpu->ctx, mapper->ra->log, false);
- if (!pltex) {
+ mppl_log_set_probing(gpu->log, false);
+ if (!pltex)
return false;
- }
struct ra_tex *ratex = talloc_ptrtype(NULL, ratex);
int ret = mppl_wrap_tex(mapper->ra, pltex, ratex);
diff --git a/video/out/placebo/utils.c b/video/out/placebo/utils.c
index f9f90ca1a1..dd873160c3 100644
--- a/video/out/placebo/utils.c
+++ b/video/out/placebo/utils.c
@@ -48,17 +48,22 @@ static void log_cb_probing(void *priv, enum pl_log_level level, const char *msg)
mp_msg(log, pl_log_to_msg_lev[probing_map(level)], "%s\n", msg);
}
-void mppl_ctx_set_log(struct pl_context *ctx, struct mp_log *log, bool probing)
+pl_log mppl_log_create(struct mp_log *log)
{
- assert(log);
-
- pl_context_update(ctx, &(struct pl_context_params) {
- .log_cb = probing ? log_cb_probing : log_cb,
- .log_level = msg_lev_to_pl_log[mp_msg_level(log)],
- .log_priv = log,
+ return pl_log_create(PL_API_VER, &(struct pl_log_params) {
+ .log_cb = log_cb,
+ .log_level = msg_lev_to_pl_log[mp_msg_level(log)],
+ .log_priv = log,
});
}
+void mppl_log_set_probing(pl_log log, bool probing)
+{
+ struct pl_log_params params = log->params;
+ params.log_cb = probing ? log_cb_probing : log_cb;
+ pl_log_update(log, &params);
+}
+
enum pl_color_primaries mp_prim_to_pl(enum mp_csp_prim prim)
{
switch (prim) {
diff --git a/video/out/placebo/utils.h b/video/out/placebo/utils.h
index 258f25086e..b00fe9cbd9 100644
--- a/video/out/placebo/utils.h
+++ b/video/out/placebo/utils.h
@@ -8,7 +8,8 @@
#include <libplacebo/context.h>
#include <libplacebo/colorspace.h>
-void mppl_ctx_set_log(struct pl_context *ctx, struct mp_log *log, bool probing);
+pl_log mppl_log_create(struct mp_log *log);
+void mppl_log_set_probing(pl_log log, bool probing);
static inline struct pl_rect2d mp_rect2d_to_pl(struct mp_rect rc)
{
diff --git a/video/out/vulkan/common.h b/video/out/vulkan/common.h
index 523de8e66e..4165ec10ee 100644
--- a/video/out/vulkan/common.h
+++ b/video/out/vulkan/common.h
@@ -27,8 +27,8 @@
// Shared struct used to hold vulkan context information
struct mpvk_ctx {
- struct mp_log *pl_log;
- struct pl_context *ctx;
+ struct mp_log *log;
+ pl_log pllog;
const struct pl_vk_inst *vkinst;
const struct pl_vulkan *vulkan;
const struct pl_gpu *gpu; // points to vulkan->gpu for convenience
diff --git a/video/out/vulkan/context.c b/video/out/vulkan/context.c
index 216e653c82..def2ee3901 100644
--- a/video/out/vulkan/context.c
+++ b/video/out/vulkan/context.c
@@ -162,9 +162,9 @@ bool ra_vk_ctx_init(struct ra_ctx *ctx, struct mpvk_ctx *vk,
p->params = params;
p->opts = mp_get_config_group(p, ctx->global, &vulkan_conf);
- assert(vk->ctx);
+ assert(vk->pllog);
assert(vk->vkinst);
- vk->vulkan = pl_vulkan_create(vk->ctx, &(struct pl_vulkan_params) {
+ vk->vulkan = pl_vulkan_create(vk->pllog, &(struct pl_vulkan_params) {
.instance = vk->vkinst->instance,
.surface = vk->surface,
.async_transfer = p->opts->async_transfer,
diff --git a/video/out/vulkan/context_display.c b/video/out/vulkan/context_display.c
index 956a3f2a2f..4568f1dc46 100644
--- a/video/out/vulkan/context_display.c
+++ b/video/out/vulkan/context_display.c
@@ -388,7 +388,7 @@ static bool display_init(struct ra_ctx *ctx)
.instance = vk->vkinst->instance,
.device_name = device_name,
};
- VkPhysicalDevice device = pl_vulkan_choose_device(vk->ctx, &vulkan_params);
+ VkPhysicalDevice device = pl_vulkan_choose_device(vk->pllog, &vulkan_params);
talloc_free(device_name);
if (!device) {
MP_MSG(ctx, msgl, "Failed to open physical device.\n");
diff --git a/video/out/vulkan/utils.c b/video/out/vulkan/utils.c
index f125962e5f..cd69334aa9 100644
--- a/video/out/vulkan/utils.c
+++ b/video/out/vulkan/utils.c
@@ -3,30 +3,26 @@
bool mpvk_init(struct mpvk_ctx *vk, struct ra_ctx *ctx, const char *surface_ext)
{
- vk->ctx = pl_context_create(PL_API_VER, NULL);
- if (!vk->ctx)
+ vk->log = mp_log_new(ctx, ctx->log, "libplacebo");
+ vk->pllog = mppl_log_create(vk->log);
+ if (!vk->pllog)
goto error;
- vk->pl_log = mp_log_new(ctx, ctx->log, "libplacebo");
- mppl_ctx_set_log(vk->ctx, vk->pl_log, true);
- mp_verbose(vk->pl_log, "Initialized libplacebo %s (API v%d)\n",
- PL_VERSION, PL_API_VER);
-
const char *exts[] = {
VK_KHR_SURFACE_EXTENSION_NAME,
surface_ext,
};
- vk->vkinst = pl_vk_inst_create(vk->ctx, &(struct pl_vk_inst_params) {
+ mppl_log_set_probing(vk->pllog, true);
+ vk->vkinst = pl_vk_inst_create(vk->pllog, &(struct pl_vk_inst_params) {
.debug = ctx->opts.debug,
.extensions = exts,
.num_extensions = MP_ARRAY_SIZE(exts),
});
-
+ mppl_log_set_probing(vk->pllog, false);
if (!vk->vkinst)
goto error;
- mppl_ctx_set_log(vk->ctx, vk->pl_log, false); // disable probing
return true;
error:
@@ -43,6 +39,6 @@ void mpvk_uninit(struct mpvk_ctx *vk)
}
pl_vk_inst_destroy(&vk->vkinst);
- pl_context_destroy(&vk->ctx);
- TA_FREEP(&vk->pl_log);
+ pl_log_destroy(&vk->pllog);
+ TA_FREEP(&vk->log);
}