mirror of
https://github.com/mpv-player/mpv
synced 2025-01-10 00:49:32 +00:00
7006d6752d
This commit rips out the entire mpv vulkan implementation in favor of exposing lightweight wrappers on top of libplacebo instead, which provides much of the same except in a more up-to-date and polished form. This (finally) unifies the code base between mpv and libplacebo, which is something I've been hoping to do for a long time. Note: The ra_pl wrappers are abstract enough from the actual libplacebo device type that we can in theory re-use them for other devices like d3d11 or even opengl in the future, so I moved them to a separate directory for the time being. However, the rest of the code is still vulkan-specific, so I've kept the "vulkan" naming and file paths, rather than introducing a new `--gpu-api` type. (Which would have been ended up with significantly more code duplicaiton) Plus, the code and functionality is similar enough that for most users this should just be a straight-up drop-in replacement. Note: This commit excludes some changes; specifically, the updates to context_win and hwdec_cuda are deferred to separate commits for authorship reasons.
47 lines
1.1 KiB
C
47 lines
1.1 KiB
C
#include "video/out/placebo/utils.h"
|
|
#include "utils.h"
|
|
|
|
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)
|
|
goto error;
|
|
|
|
vk->pl_log = mp_log_new(ctx, ctx->log, "libplacebo");
|
|
mppl_ctx_set_log(vk->ctx, vk->pl_log, true);
|
|
|
|
const char *exts[] = {
|
|
VK_KHR_SURFACE_EXTENSION_NAME,
|
|
surface_ext,
|
|
};
|
|
|
|
vk->vkinst = pl_vk_inst_create(vk->ctx, &(struct pl_vk_inst_params) {
|
|
.debug = ctx->opts.debug,
|
|
.extensions = exts,
|
|
.num_extensions = MP_ARRAY_SIZE(exts),
|
|
});
|
|
|
|
if (!vk->vkinst)
|
|
goto error;
|
|
|
|
mppl_ctx_set_log(vk->ctx, vk->pl_log, false); // disable probing
|
|
return true;
|
|
|
|
error:
|
|
mpvk_uninit(vk);
|
|
return false;
|
|
}
|
|
|
|
void mpvk_uninit(struct mpvk_ctx *vk)
|
|
{
|
|
if (vk->surface) {
|
|
assert(vk->vkinst);
|
|
vkDestroySurfaceKHR(vk->vkinst->instance, vk->surface, NULL);
|
|
vk->surface = NULL;
|
|
}
|
|
|
|
pl_vk_inst_destroy(&vk->vkinst);
|
|
pl_context_destroy(&vk->ctx);
|
|
TA_FREEP(&vk->pl_log);
|
|
}
|