0
0
mirror of https://github.com/mpv-player/mpv.git synced 2024-09-20 12:02:23 +02:00
mpv/video/out/vulkan/utils.c
Christoph Reiter 96773f39e1 vulkan: fix build error for 32bit builds with clang
vk->surface is a handle and not a pointer, so assign VK_NULL_HANDLE.
This fixes the following build error on 32bit Windows when using clang for example,
which errors out when assigning a 32bit pointer to a 64bit integer:

  ../mpv-0.35.0/video/out/vulkan/utils.c:37:21:
    error: incompatible pointer to integer conversion assigning to 'VkSurfaceKHR' (aka 'unsigned long long') from 'void *' [-Wint-conversion]
          vk->surface = NULL;
                      ^ ~~~~
2023-01-08 16:09:01 +01:00

43 lines
994 B
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->pllog = mppl_log_create(ctx, ctx->vo->log);
if (!vk->pllog)
goto error;
const char *exts[] = {
VK_KHR_SURFACE_EXTENSION_NAME,
surface_ext,
};
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;
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 = VK_NULL_HANDLE;
}
pl_vk_inst_destroy(&vk->vkinst);
pl_log_destroy(&vk->pllog);
}