hwcontext_vulkan: dynamically load functions

This patch allows for alternative loader implementations.
pull/362/head
Lynne 4 years ago
parent ffeeff4fbc
commit 4a6581e968
  1. 5
      libavutil/hwcontext_cuda.c
  2. 512
      libavutil/hwcontext_vulkan.c
  3. 7
      libavutil/hwcontext_vulkan.h

@ -427,16 +427,19 @@ static int cuda_device_derive(AVHWDeviceContext *device_ctx,
switch (src_ctx->type) { switch (src_ctx->type) {
#if CONFIG_VULKAN #if CONFIG_VULKAN
#define TYPE PFN_vkGetPhysicalDeviceProperties2
case AV_HWDEVICE_TYPE_VULKAN: { case AV_HWDEVICE_TYPE_VULKAN: {
AVVulkanDeviceContext *vkctx = src_ctx->hwctx; AVVulkanDeviceContext *vkctx = src_ctx->hwctx;
TYPE prop_fn = (TYPE)vkctx->get_proc_addr(vkctx->inst, "vkGetPhysicalDeviceProperties2");
VkPhysicalDeviceProperties2 vk_dev_props = { VkPhysicalDeviceProperties2 vk_dev_props = {
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2, .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2,
.pNext = &vk_idp, .pNext = &vk_idp,
}; };
vkGetPhysicalDeviceProperties2(vkctx->phys_dev, &vk_dev_props); prop_fn(vkctx->phys_dev, &vk_dev_props);
src_uuid = vk_idp.deviceUUID; src_uuid = vk_idp.deviceUUID;
break; break;
} }
#undef TYPE
#endif #endif
default: default:
return AVERROR(ENOSYS); return AVERROR(ENOSYS);

File diff suppressed because it is too large Load Diff

@ -42,6 +42,13 @@ typedef struct AVVulkanDeviceContext {
*/ */
const VkAllocationCallbacks *alloc; const VkAllocationCallbacks *alloc;
/**
* Pointer to the instance-provided vkGetInstanceProcAddr loading function.
* If NULL, will pick either libvulkan or libvolk, depending on libavutil's
* compilation settings, and set this field.
*/
PFN_vkGetInstanceProcAddr get_proc_addr;
/** /**
* Vulkan instance. Must be at least version 1.1. * Vulkan instance. Must be at least version 1.1.
*/ */

Loading…
Cancel
Save