Skip to content
Snippets Groups Projects
Commit 46494038 authored by Niklas Haas's avatar Niklas Haas
Browse files

vulkan: build stubs unconditionally

To avoid users having to check for libplacebo vulkan support before
linking against libplacebo vulkan functions, and to provide a consistent
ABI regardless of build settings.

Fixes: #224
Fixes: https://github.com/mpv-player/mpv-build/issues/194
parent 9153914c
No related branches found
No related tags found
1 merge request!294Build stubs unconditionally (and bundle vulkan-headers)
......@@ -80,10 +80,7 @@
#include <libplacebo/tone_mapping.h>
#include <libplacebo/utils/frame_queue.h>
#include <libplacebo/utils/upload.h>
#ifdef PL_HAVE_VULKAN
#include <libplacebo/vulkan.h>
#endif
#ifdef PL_HAVE_OPENGL
#include <libplacebo/opengl.h>
#endif
......
......@@ -52,6 +52,7 @@ headers = [
'utils/libav.h',
'utils/libav_internal.h',
'utils/upload.h',
'vulkan.h',
]
sources = [
......
......@@ -16,20 +16,18 @@ elif fs.is_dir(thirdparty/'Vulkan-Headers')
registry_xml = thirdparty/'Vulkan-Headers/registry/vk.xml'
endif
if vulkan_build.enabled() and not vulkan_headers.found()
build_deps += vulkan_headers
if not vulkan_headers.found()
error('vulkan.h was not found on the system, nor inside ' +
'`3rdparty/Vulkan-Headers`. Please run `git submodule update --init` ' +
'followed by `meson --wipe`.')
endif
vulkan_build = vulkan_build.require(vulkan_headers.found())
vulkan_link = vulkan_link.require(vulkan_loader.found())
components.set('vulkan', vulkan_build.allowed())
components.set('vk-proc-addr', vulkan_link.allowed())
if vulkan_build.allowed()
build_deps += vulkan_headers
headers += 'vulkan.h'
sources += [
'vulkan/command.c',
'vulkan/context.c',
......@@ -55,4 +53,6 @@ if vulkan_build.allowed()
build_deps += vulkan_loader
tests += 'vulkan.c'
endif
else
sources += 'vulkan/stubs.c'
endif
/*
* This file is part of libplacebo.
*
* libplacebo is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* libplacebo is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with libplacebo. If not, see <http://www.gnu.org/licenses/>.
*/
#include "../common.h"
#include "log.h"
const struct pl_vk_inst_params pl_vk_inst_default_params = {0};
const struct pl_vulkan_params pl_vulkan_default_params = { PL_VULKAN_DEFAULTS };
pl_vk_inst pl_vk_inst_create(pl_log log, const struct pl_vk_inst_params *params)
{
pl_fatal(log, "libplacebo compiled without Vulkan support!");
return NULL;
}
void pl_vk_inst_destroy(pl_vk_inst *pinst)
{
pl_vk_inst inst = *pinst;
pl_assert(!inst);
}
pl_vulkan pl_vulkan_create(pl_log log, const struct pl_vulkan_params *params)
{
pl_fatal(log, "libplacebo compiled without Vulkan support!");
return NULL;
}
void pl_vulkan_destroy(pl_vulkan *pvk)
{
pl_vulkan vk = *pvk;
pl_assert(!vk);
}
pl_vulkan pl_vulkan_get(pl_gpu gpu)
{
return NULL;
}
VkPhysicalDevice pl_vulkan_choose_device(pl_log log,
const struct pl_vulkan_device_params *params)
{
pl_err(log, "libplacebo compiled without Vulkan support!");
return NULL;
}
pl_swapchain pl_vulkan_create_swapchain(pl_vulkan vk,
const struct pl_vulkan_swapchain_params *params)
{
pl_unreachable();
}
bool pl_vulkan_swapchain_suboptimal(pl_swapchain sw)
{
pl_unreachable();
}
pl_vulkan pl_vulkan_import(pl_log log, const struct pl_vulkan_import_params *params)
{
pl_fatal(log, "libplacebo compiled without Vulkan support!");
return NULL;
}
pl_tex pl_vulkan_wrap(pl_gpu gpu, const struct pl_vulkan_wrap_params *params)
{
pl_unreachable();
}
VkImage pl_vulkan_unwrap(pl_gpu gpu, pl_tex tex,
VkFormat *out_format, VkImageUsageFlags *out_flags)
{
pl_unreachable();
}
bool pl_vulkan_hold(pl_gpu gpu, pl_tex tex, VkImageLayout layout,
pl_vulkan_sem sem_out)
{
pl_unreachable();
}
bool pl_vulkan_hold_raw(pl_gpu gpu, pl_tex tex, VkImageLayout *layout,
pl_vulkan_sem sem_out)
{
pl_unreachable();
}
void pl_vulkan_release(pl_gpu gpu, pl_tex tex, VkImageLayout layout,
pl_vulkan_sem sem_in)
{
pl_unreachable();
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment