FFmpeg
Macros | Functions | Variables
vulkan.c File Reference
#include "config.h"
#include "avassert.h"
#include "mem.h"
#include "refstruct.h"
#include "vulkan.h"
#include "libavutil/vulkan_loader.h"

Go to the source code of this file.

Macros

#define CASE(VAL)   case VAL: return #VAL
 
#define FN_MAP_TO(dst_t, dst_name, src_t, src_name)
 
#define MAP_TO(flag1, flag2)   if (src & flag2) dst |= flag1;
 
#define MAP_TO(flag1, flag2)   if (src & flag1) dst |= flag2;
 
#define REPS_FMT(fmt)
 
#define REPS_FMT_PACK(fmt, num)
 

Functions

const char * ff_vk_ret2str (VkResult res)
 Converts Vulkan return values to strings. More...
 
static void load_enabled_qfs (FFVulkanContext *s)
 
static void reset_imageviews (AVRefStructOpaque unused, void *obj)
 
int ff_vk_load_props (FFVulkanContext *s)
 Loads props/mprops/driver_props. More...
 
AVVulkanDeviceQueueFamilyff_vk_qf_find (FFVulkanContext *s, VkQueueFlagBits dev_family, VkVideoCodecOperationFlagBitsKHR vid_ops)
 Chooses an appropriate QF. More...
 
void ff_vk_exec_pool_free (FFVulkanContext *s, FFVkExecPool *pool)
 
int ff_vk_exec_pool_init (FFVulkanContext *s, AVVulkanDeviceQueueFamily *qf, FFVkExecPool *pool, int nb_contexts, int nb_queries, VkQueryType query_type, int query_64bit, const void *query_create_pnext)
 Allocates/frees an execution pool. More...
 
VkResult ff_vk_exec_get_query (FFVulkanContext *s, FFVkExecContext *e, void **data, VkQueryResultFlagBits flags)
 Performs nb_queries queries and returns their results and statuses. More...
 
FFVkExecContextff_vk_exec_get (FFVulkanContext *s, FFVkExecPool *pool)
 Retrieve an execution pool. More...
 
void ff_vk_exec_wait (FFVulkanContext *s, FFVkExecContext *e)
 
int ff_vk_exec_start (FFVulkanContext *s, FFVkExecContext *e)
 Start/submit/wait an execution. More...
 
void ff_vk_exec_discard_deps (FFVulkanContext *s, FFVkExecContext *e)
 
void ff_vk_exec_add_dep_refstruct (FFVulkanContext *s, FFVkExecContext *e, void *obj)
 Execution dependency management. More...
 
void ff_vk_exec_move_dep_refstruct (FFVulkanContext *s, FFVkExecContext *e, void *obj)
 
void ff_vk_exec_add_dep_obj (FFVulkanContext *s, FFVkExecContext *e, VkObjectType type, uint64_t obj)
 
int ff_vk_exec_add_dep_sw_frame (FFVulkanContext *s, FFVkExecContext *e, AVFrame *f)
 
void ff_vk_exec_add_dep_wait_sem (FFVulkanContext *s, FFVkExecContext *e, VkSemaphore sem, uint64_t val, VkPipelineStageFlagBits2 stage)
 
void ff_vk_exec_add_dep_bool_sem (FFVulkanContext *s, FFVkExecContext *e, VkSemaphore *sem, int nb, VkPipelineStageFlagBits2 stage, int wait)
 
int ff_vk_exec_add_dep_frame (FFVulkanContext *s, FFVkExecContext *e, AVFrame *f, VkPipelineStageFlagBits2 wait_stage, VkPipelineStageFlagBits2 signal_stage)
 
void ff_vk_exec_update_frame (FFVulkanContext *s, FFVkExecContext *e, AVFrame *f, VkImageMemoryBarrier2 *bar, uint32_t *nb_img_bar)
 
int ff_vk_exec_mirror_sem_value (FFVulkanContext *s, FFVkExecContext *e, VkSemaphore *dst, uint64_t *dst_val, AVFrame *f)
 
int ff_vk_exec_submit (FFVulkanContext *s, FFVkExecContext *e)
 
int ff_vk_alloc_mem (FFVulkanContext *s, VkMemoryRequirements *req, VkMemoryPropertyFlagBits req_flags, void *alloc_extension, VkMemoryPropertyFlagBits *mem_flags, VkDeviceMemory *mem)
 Memory/buffer/image allocation helpers. More...
 
int ff_vk_create_buf (FFVulkanContext *s, FFVkBuffer *buf, size_t size, void *pNext, void *alloc_pNext, VkBufferUsageFlags usage, VkMemoryPropertyFlagBits flags)
 
int ff_vk_map_buffers (FFVulkanContext *s, FFVkBuffer **buf, uint8_t *mem[], int nb_buffers, int invalidate)
 Buffer management code. More...
 
int ff_vk_flush_buffer (FFVulkanContext *s, FFVkBuffer *buf, VkDeviceSize offset, VkDeviceSize mem_size, int flush)
 Flush or invalidate a single buffer, with a given size and offset. More...
 
int ff_vk_unmap_buffers (FFVulkanContext *s, FFVkBuffer **buf, int nb_buffers, int flush)
 
void ff_vk_free_buf (FFVulkanContext *s, FFVkBuffer *buf)
 
static void pooled_buf_free (AVRefStructOpaque opaque, void *obj)
 
int ff_vk_get_pooled_buffer (FFVulkanContext *ctx, AVRefStructPool **buf_pool, FFVkBuffer **buf, VkBufferUsageFlags usage, void *create_pNext, size_t size, VkMemoryPropertyFlagBits mem_props)
 Initialize a pool and create AVBufferRefs containing FFVkBuffer. More...
 
static int create_mapped_buffer (FFVulkanContext *s, FFVkBuffer *vkb, VkBufferUsageFlags usage, size_t size, VkExternalMemoryBufferCreateInfo *create_desc, VkImportMemoryHostPointerInfoEXT *import_desc, VkMemoryHostPointerPropertiesEXT props)
 
static void host_map_free (AVRefStructOpaque opaque, void *obj)
 
int ff_vk_host_map_buffer (FFVulkanContext *s, FFVkBuffer **dst, uint8_t *src_data, VkDeviceSize size, const AVBufferRef *src_buf, VkBufferUsageFlags usage)
 Maps a system RAM buffer into a Vulkan buffer. More...
 
int ff_vk_shader_add_push_const (FFVulkanShader *shd, int offset, int size, VkShaderStageFlagBits stage)
 Add/update push constants for execution. More...
 
int ff_vk_init_sampler (FFVulkanContext *s, VkSampler *sampler, int unnorm_coords, VkFilter filt)
 Create a sampler. More...
 
VkImageAspectFlags ff_vk_aspect_flag (AVFrame *f, int p)
 Get the aspect flag for a plane from an image. More...
 
int ff_vk_mt_is_np_rgb (enum AVPixelFormat pix_fmt)
 Returns 1 if pixfmt is a usable RGB format. More...
 
void ff_vk_set_perm (enum AVPixelFormat pix_fmt, int lut[4], int inv)
 Since storage images may not be swizzled, we have to do this in the shader itself. More...
 
const char * ff_vk_shader_rep_fmt (enum AVPixelFormat pix_fmt, enum FFVkShaderRepFormat rep_fmt)
 
FFVkImageViewsff_vk_imageviews_alloc (FFVulkanContext *s, int nb_views)
 Allocate a reference-counted set of image views, zero-initialized for the caller to create. More...
 
static VkFormat map_fmt_to_rep (VkFormat fmt, enum FFVkShaderRepFormat rep_fmt)
 
int ff_vk_create_imageview (FFVulkanContext *s, VkImageView *img_view, VkImageAspectFlags *aspect, AVFrame *f, int plane, enum FFVkShaderRepFormat rep_fmt)
 Create a single imageview for a given plane. More...
 
int ff_vk_create_imageviews (FFVulkanContext *s, FFVkExecContext *e, VkImageView views[AV_NUM_DATA_POINTERS], AVFrame *f, enum FFVkShaderRepFormat rep_fmt)
 Create an imageview and add it as a dependency to an execution. More...
 
void ff_vk_frame_barrier (FFVulkanContext *s, FFVkExecContext *e, AVFrame *pic, VkImageMemoryBarrier2 *bar, int *nb_bar, VkPipelineStageFlags2 src_stage, VkPipelineStageFlags2 dst_stage, VkAccessFlagBits2 new_access, VkImageLayout new_layout, uint32_t new_qf)
 
int ff_vk_shader_load (FFVulkanShader *shd, VkPipelineStageFlags stage, VkSpecializationInfo *spec, uint32_t wg_size[3], uint32_t required_subgroup_size)
 Initialize a shader object. More...
 
static int init_pipeline_layout (FFVulkanContext *s, FFVulkanShader *shd)
 
static int create_shader_module (FFVulkanContext *s, FFVulkanShader *shd, VkShaderModule *mod, const uint8_t *spirv, size_t spirv_len)
 
static int init_compute_pipeline (FFVulkanContext *s, FFVulkanShader *shd, VkShaderModule mod, const char *entrypoint)
 
static int create_shader_object (FFVulkanContext *s, FFVulkanShader *shd, const uint8_t *spirv, size_t spirv_len, size_t *binary_size, const char *entrypoint)
 
static int init_descriptors (FFVulkanContext *s, FFVulkanShader *shd)
 
int ff_vk_shader_link (FFVulkanContext *s, FFVulkanShader *shd, const char *spirv, size_t spirv_len, const char *entrypoint)
 Link a shader into an executable. More...
 
void ff_vk_shader_add_descriptor_set (FFVulkanContext *s, FFVulkanShader *shd, const FFVulkanDescriptorSetBinding *desc, int nb, int singular)
 Add descriptor to a shader. More...
 
int ff_vk_shader_register_exec (FFVulkanContext *s, FFVkExecPool *pool, FFVulkanShader *shd)
 Register a shader with an exec pool. More...
 
static const FFVulkanShaderDataget_shd_data (FFVkExecContext *e, const FFVulkanShader *shd)
 
static void update_set_pool_write (FFVulkanContext *s, FFVkExecContext *e, FFVulkanShader *shd, int set, VkWriteDescriptorSet *write_info)
 
int ff_vk_shader_update_img (FFVulkanContext *s, FFVkExecContext *e, FFVulkanShader *shd, int set, int bind, int offs, VkImageView view, VkImageLayout layout, VkSampler sampler)
 Sets an image descriptor for specified shader and binding. More...
 
void ff_vk_shader_update_img_array (FFVulkanContext *s, FFVkExecContext *e, FFVulkanShader *shd, AVFrame *f, VkImageView *views, int set, int binding, VkImageLayout layout, VkSampler sampler)
 Update a descriptor in a buffer with an image array. More...
 
int ff_vk_shader_update_desc_buffer (FFVulkanContext *s, FFVkExecContext *e, FFVulkanShader *shd, int set, int bind, int elem, FFVkBuffer *buf, VkDeviceSize offset, VkDeviceSize len, VkFormat fmt)
 Update a descriptor in a buffer with a buffer. More...
 
void ff_vk_shader_update_push_const (FFVulkanContext *s, FFVkExecContext *e, FFVulkanShader *shd, VkShaderStageFlagBits stage, int offset, size_t size, void *src)
 Update push constant in a shader. More...
 
void ff_vk_exec_bind_shader (FFVulkanContext *s, FFVkExecContext *e, const FFVulkanShader *shd)
 Bind a shader. More...
 
void ff_vk_shader_free (FFVulkanContext *s, FFVulkanShader *shd)
 Free a shader. More...
 
void ff_vk_uninit (FFVulkanContext *s)
 Frees main context. More...
 
int ff_vk_init (FFVulkanContext *s, void *log_parent, AVBufferRef *device_ref, AVBufferRef *frames_ref)
 Initializes the AVClass, in case this context is not used as the main user's context. More...
 

Variables

const VkComponentMapping ff_comp_identity_map
 

Macro Definition Documentation

◆ CASE

#define CASE (   VAL)    case VAL: return #VAL

◆ FN_MAP_TO

#define FN_MAP_TO (   dst_t,
  dst_name,
  src_t,
  src_name 
)
Value:
dst_t ff_vk_map_ ##src_name## _to_ ##dst_name(src_t src) \
{ \
dst_t dst = 0x0; \
MAP_TO(VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_BIT, \
VK_IMAGE_USAGE_SAMPLED_BIT); \
MAP_TO(VK_FORMAT_FEATURE_2_TRANSFER_SRC_BIT, \
VK_IMAGE_USAGE_TRANSFER_SRC_BIT); \
MAP_TO(VK_FORMAT_FEATURE_2_TRANSFER_DST_BIT, \
VK_IMAGE_USAGE_TRANSFER_DST_BIT); \
MAP_TO(VK_FORMAT_FEATURE_2_STORAGE_IMAGE_BIT, \
VK_IMAGE_USAGE_STORAGE_BIT); \
MAP_TO(VK_FORMAT_FEATURE_2_COLOR_ATTACHMENT_BIT, \
VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT); \
MAP_TO(VK_FORMAT_FEATURE_2_VIDEO_DECODE_OUTPUT_BIT_KHR, \
VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR); \
MAP_TO(VK_FORMAT_FEATURE_2_VIDEO_DECODE_DPB_BIT_KHR, \
VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR); \
MAP_TO(VK_FORMAT_FEATURE_2_VIDEO_ENCODE_DPB_BIT_KHR, \
VK_IMAGE_USAGE_VIDEO_ENCODE_DPB_BIT_KHR); \
MAP_TO(VK_FORMAT_FEATURE_2_VIDEO_ENCODE_INPUT_BIT_KHR, \
VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR); \
MAP_TO(VK_FORMAT_FEATURE_2_HOST_IMAGE_TRANSFER_BIT_EXT, \
VK_IMAGE_USAGE_HOST_TRANSFER_BIT_EXT); \
return dst; \
}

Definition at line 94 of file vulkan.c.

◆ MAP_TO [1/2]

#define MAP_TO (   flag1,
  flag2 
)    if (src & flag2) dst |= flag1;

Definition at line 124 of file vulkan.c.

◆ MAP_TO [2/2]

#define MAP_TO (   flag1,
  flag2 
)    if (src & flag1) dst |= flag2;

Definition at line 124 of file vulkan.c.

◆ REPS_FMT

#define REPS_FMT (   fmt)
Value:
[FF_VK_REP_NATIVE] = fmt ## _UINT, \
[FF_VK_REP_FLOAT] = fmt ## _UNORM, \
[FF_VK_REP_INT] = fmt ## _SINT, \
[FF_VK_REP_UINT] = fmt ## _UINT,

◆ REPS_FMT_PACK

#define REPS_FMT_PACK (   fmt,
  num 
)
Value:
[FF_VK_REP_NATIVE] = fmt ## _UINT_PACK ## num, \
[FF_VK_REP_FLOAT] = fmt ## _UNORM_PACK ## num, \
[FF_VK_REP_INT] = fmt ## _SINT_PACK ## num, \
[FF_VK_REP_UINT] = fmt ## _UINT_PACK ## num,

Function Documentation

◆ ff_vk_ret2str()

const char* ff_vk_ret2str ( VkResult  res)

◆ load_enabled_qfs()

static void load_enabled_qfs ( FFVulkanContext s)
static

Definition at line 129 of file vulkan.c.

Referenced by ff_vk_load_props().

◆ reset_imageviews()

static void reset_imageviews ( AVRefStructOpaque  unused,
void *  obj 
)
static

Definition at line 1777 of file vulkan.c.

Referenced by ff_vk_load_props().

◆ ff_vk_load_props()

int ff_vk_load_props ( FFVulkanContext s)

Loads props/mprops/driver_props.

Definition at line 150 of file vulkan.c.

Referenced by ff_vk_filter_init_context(), ff_vk_init(), ff_vulkan_encode_init(), and vulkan_device_init().

◆ ff_vk_qf_find()

AVVulkanDeviceQueueFamily* ff_vk_qf_find ( FFVulkanContext s,
VkQueueFlagBits  dev_family,
VkVideoCodecOperationFlagBitsKHR  vid_ops 
)

◆ ff_vk_exec_pool_free()

void ff_vk_exec_pool_free ( FFVulkanContext s,
FFVkExecPool pool 
)

◆ ff_vk_exec_pool_init()

int ff_vk_exec_pool_init ( FFVulkanContext s,
AVVulkanDeviceQueueFamily qf,
FFVkExecPool pool,
int  nb_contexts,
int  nb_queries,
VkQueryType  query_type,
int  query_64bit,
const void *  query_create_pnext 
)

Allocates/frees an execution pool.

If used in a multi-threaded context, there must be at least as many contexts as there are threads. ff_vk_exec_pool_init_desc() MUST be called if ff_vk_exec_descriptor_set_add() has been called.

Definition at line 357 of file vulkan.c.

Referenced by compile(), encode_init(), ff_vk_decode_init(), ff_vulkan_encode_init(), init_debayer(), init_filter(), init_vulkan(), vulkan_encode_apv_init(), vulkan_encode_ffv1_init(), and vulkan_frames_init().

◆ ff_vk_exec_get_query()

VkResult ff_vk_exec_get_query ( FFVulkanContext s,
FFVkExecContext e,
void **  data,
VkQueryResultFlagBits  flags 
)

Performs nb_queries queries and returns their results and statuses.

64_BIT and WITH_STATUS flags are ignored as 64_BIT must be specified via query_64bit in ff_vk_exec_pool_init() and WITH_STATUS is always enabled.

Definition at line 543 of file vulkan.c.

Referenced by vulkan_encode_output().

◆ ff_vk_exec_get()

FFVkExecContext* ff_vk_exec_get ( FFVulkanContext s,
FFVkExecPool pool 
)

◆ ff_vk_exec_wait()

void ff_vk_exec_wait ( FFVulkanContext s,
FFVkExecContext e 
)

◆ ff_vk_exec_start()

int ff_vk_exec_start ( FFVulkanContext s,
FFVkExecContext e 
)

◆ ff_vk_exec_discard_deps()

void ff_vk_exec_discard_deps ( FFVulkanContext s,
FFVkExecContext e 
)

◆ ff_vk_exec_add_dep_refstruct()

void ff_vk_exec_add_dep_refstruct ( FFVulkanContext s,
FFVkExecContext e,
void *  obj 
)

Execution dependency management.

Can attach buffers to executions that will only be unref'd once the buffer has finished executing. Adding a frame dep will lock the frame, until either the dependencies are discarded, the execution is submitted, or a failure happens. update_frame will update the frame's properties before it is unlocked, only if submission was successful.

Definition at line 687 of file vulkan.c.

Referenced by submit_frame(), vk_ffv1_end_frame(), vulkan_encode_ffv1_submit_frame(), vulkan_encode_issue(), vulkan_encode_prores_submit_frame(), and vulkan_transfer_frame().

◆ ff_vk_exec_move_dep_refstruct()

void ff_vk_exec_move_dep_refstruct ( FFVulkanContext s,
FFVkExecContext e,
void *  obj 
)

◆ ff_vk_exec_add_dep_obj()

void ff_vk_exec_add_dep_obj ( FFVulkanContext s,
FFVkExecContext e,
VkObjectType  type,
uint64_t  obj 
)

Definition at line 712 of file vulkan.c.

Referenced by ff_vk_create_imageviews(), and ff_vk_exec_add_dep_bool_sem().

◆ ff_vk_exec_add_dep_sw_frame()

int ff_vk_exec_add_dep_sw_frame ( FFVulkanContext s,
FFVkExecContext e,
AVFrame f 
)

Definition at line 719 of file vulkan.c.

Referenced by vulkan_transfer_frame().

◆ ff_vk_exec_add_dep_wait_sem()

void ff_vk_exec_add_dep_wait_sem ( FFVulkanContext s,
FFVkExecContext e,
VkSemaphore  sem,
uint64_t  val,
VkPipelineStageFlagBits2  stage 
)

Definition at line 735 of file vulkan.c.

Referenced by ff_vk_exec_add_dep_bool_sem(), and vk_ffv1_end_frame().

◆ ff_vk_exec_add_dep_bool_sem()

void ff_vk_exec_add_dep_bool_sem ( FFVulkanContext s,
FFVkExecContext e,
VkSemaphore *  sem,
int  nb,
VkPipelineStageFlagBits2  stage,
int  wait 
)

Definition at line 749 of file vulkan.c.

◆ ff_vk_exec_add_dep_frame()

int ff_vk_exec_add_dep_frame ( FFVulkanContext s,
FFVkExecContext e,
AVFrame f,
VkPipelineStageFlagBits2  wait_stage,
VkPipelineStageFlagBits2  signal_stage 
)

◆ ff_vk_exec_update_frame()

void ff_vk_exec_update_frame ( FFVulkanContext s,
FFVkExecContext e,
AVFrame f,
VkImageMemoryBarrier2 *  bar,
uint32_t *  nb_img_bar 
)

Definition at line 837 of file vulkan.c.

Referenced by ff_vk_frame_barrier(), and vulkan_encode_issue().

◆ ff_vk_exec_mirror_sem_value()

int ff_vk_exec_mirror_sem_value ( FFVulkanContext s,
FFVkExecContext e,
VkSemaphore *  dst,
uint64_t *  dst_val,
AVFrame f 
)

Definition at line 856 of file vulkan.c.

Referenced by vk_ffv1_end_frame().

◆ ff_vk_exec_submit()

int ff_vk_exec_submit ( FFVulkanContext s,
FFVkExecContext e 
)

◆ ff_vk_alloc_mem()

int ff_vk_alloc_mem ( FFVulkanContext s,
VkMemoryRequirements *  req,
VkMemoryPropertyFlagBits  req_flags,
void *  alloc_extension,
VkMemoryPropertyFlagBits *  mem_flags,
VkDeviceMemory *  mem 
)

Memory/buffer/image allocation helpers.

Definition at line 965 of file vulkan.c.

Referenced by create_mapped_buffer(), ff_vk_create_buf(), and ff_vk_video_common_init().

◆ ff_vk_create_buf()

int ff_vk_create_buf ( FFVulkanContext s,
FFVkBuffer buf,
size_t  size,
void *  pNext,
void *  alloc_pNext,
VkBufferUsageFlags  usage,
VkMemoryPropertyFlagBits  flags 
)

◆ ff_vk_map_buffers()

int ff_vk_map_buffers ( FFVulkanContext s,
FFVkBuffer **  buf,
uint8_t *  mem[],
int  nb_buffers,
int  invalidate 
)

Buffer management code.

Definition at line 1108 of file vulkan.c.

Referenced by ff_vk_map_buffer().

◆ ff_vk_flush_buffer()

int ff_vk_flush_buffer ( FFVulkanContext s,
FFVkBuffer buf,
VkDeviceSize  offset,
VkDeviceSize  mem_size,
int  flush 
)

Flush or invalidate a single buffer, with a given size and offset.

Definition at line 1157 of file vulkan.c.

Referenced by copy_buffer_data(), and vk_apv_end_frame().

◆ ff_vk_unmap_buffers()

int ff_vk_unmap_buffers ( FFVulkanContext s,
FFVkBuffer **  buf,
int  nb_buffers,
int  flush 
)

Definition at line 1188 of file vulkan.c.

Referenced by ff_vk_unmap_buffer().

◆ ff_vk_free_buf()

void ff_vk_free_buf ( FFVulkanContext s,
FFVkBuffer buf 
)

◆ pooled_buf_free()

static void pooled_buf_free ( AVRefStructOpaque  opaque,
void *  obj 
)
static

Definition at line 1251 of file vulkan.c.

Referenced by ff_vk_get_pooled_buffer().

◆ ff_vk_get_pooled_buffer()

int ff_vk_get_pooled_buffer ( FFVulkanContext ctx,
AVRefStructPool **  buf_pool,
FFVkBuffer **  buf,
VkBufferUsageFlags  usage,
void *  create_pNext,
size_t  size,
VkMemoryPropertyFlagBits  mem_props 
)

Initialize a pool and create AVBufferRefs containing FFVkBuffer.

Threadsafe to use. Buffers are automatically mapped on creation if VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT is set in mem_props. Users should synchronize access themselvesd. Mainly meant for device-local buffers.

Definition at line 1256 of file vulkan.c.

Referenced by blackdetect_vulkan_filter_frame(), ff_vk_decode_add_slice(), get_plane_buf(), nlmeans_vulkan_filter_frame(), scdet_vulkan_filter_frame(), submit_frame(), vk_apv_end_frame(), vk_apv_start_frame(), vk_ffv1_start_frame(), vk_prores_raw_start_frame(), vk_prores_start_frame(), vulkan_encode_ffv1_submit_frame(), vulkan_encode_issue(), and vulkan_encode_prores_submit_frame().

◆ create_mapped_buffer()

static int create_mapped_buffer ( FFVulkanContext s,
FFVkBuffer vkb,
VkBufferUsageFlags  usage,
size_t  size,
VkExternalMemoryBufferCreateInfo *  create_desc,
VkImportMemoryHostPointerInfoEXT *  import_desc,
VkMemoryHostPointerPropertiesEXT  props 
)
static

Definition at line 1301 of file vulkan.c.

Referenced by ff_vk_host_map_buffer().

◆ host_map_free()

static void host_map_free ( AVRefStructOpaque  opaque,
void *  obj 
)
static

Definition at line 1347 of file vulkan.c.

Referenced by ff_vk_host_map_buffer().

◆ ff_vk_host_map_buffer()

int ff_vk_host_map_buffer ( FFVulkanContext s,
FFVkBuffer **  dst,
uint8_t *  src_data,
VkDeviceSize  size,
const AVBufferRef src_buf,
VkBufferUsageFlags  usage 
)

Maps a system RAM buffer into a Vulkan buffer.

References the source buffer. Imports size bytes starting at src_data, rounded up to the host-pointer import alignment and clamped to the end of src_buf.

Definition at line 1352 of file vulkan.c.

Referenced by host_map_frame(), vk_apv_start_frame(), vk_dpx_start_frame(), vk_ffv1_start_frame(), vk_prores_raw_start_frame(), and vk_prores_start_frame().

◆ ff_vk_shader_add_push_const()

int ff_vk_shader_add_push_const ( FFVulkanShader shd,
int  offset,
int  size,
VkShaderStageFlagBits  stage 
)

◆ ff_vk_init_sampler()

int ff_vk_init_sampler ( FFVulkanContext s,
VkSampler *  sampler,
int  unnorm_coords,
VkFilter  filt 
)

Create a sampler.

Definition at line 1454 of file vulkan.c.

Referenced by init_filter(), and init_vulkan().

◆ ff_vk_aspect_flag()

VkImageAspectFlags ff_vk_aspect_flag ( AVFrame f,
int  p 
)

Get the aspect flag for a plane from an image.

Definition at line 1486 of file vulkan.c.

Referenced by ff_vk_create_imageview(), ff_vk_create_imageviews(), vulkan_transfer_frame(), and vulkan_transfer_host().

◆ ff_vk_mt_is_np_rgb()

int ff_vk_mt_is_np_rgb ( enum AVPixelFormat  pix_fmt)

Returns 1 if pixfmt is a usable RGB format.

Definition at line 1503 of file vulkan.c.

Referenced by ff_ffv1_vk_set_common_sl(), ff_vk_aspect_flag(), and scale_vulkan_config_output().

◆ ff_vk_set_perm()

void ff_vk_set_perm ( enum AVPixelFormat  pix_fmt,
int  lut[4],
int  inv 
)

Since storage images may not be swizzled, we have to do this in the shader itself.

This fills in a lookup table to do it.

Definition at line 1526 of file vulkan.c.

Referenced by init_filter(), vk_ffv1_end_frame(), and vulkan_encode_ffv1_submit_frame().

◆ ff_vk_shader_rep_fmt()

const char* ff_vk_shader_rep_fmt ( enum AVPixelFormat  pix_fmt,
enum FFVkShaderRepFormat  rep_fmt 
)

Definition at line 1580 of file vulkan.c.

◆ ff_vk_imageviews_alloc()

FFVkImageViews* ff_vk_imageviews_alloc ( FFVulkanContext s,
int  nb_views 
)

Allocate a reference-counted set of image views, zero-initialized for the caller to create.

Definition at line 1789 of file vulkan.c.

Referenced by ff_vk_decode_prepare_frame().

◆ map_fmt_to_rep()

static VkFormat map_fmt_to_rep ( VkFormat  fmt,
enum FFVkShaderRepFormat  rep_fmt 
)
static

Definition at line 1808 of file vulkan.c.

Referenced by ff_vk_create_imageview(), and ff_vk_create_imageviews().

◆ ff_vk_create_imageview()

int ff_vk_create_imageview ( FFVulkanContext s,
VkImageView *  img_view,
VkImageAspectFlags *  aspect,
AVFrame f,
int  plane,
enum FFVkShaderRepFormat  rep_fmt 
)

Create a single imageview for a given plane.

Definition at line 1907 of file vulkan.c.

◆ ff_vk_create_imageviews()

int ff_vk_create_imageviews ( FFVulkanContext s,
FFVkExecContext e,
VkImageView  views[AV_NUM_DATA_POINTERS],
AVFrame f,
enum FFVkShaderRepFormat  rep_fmt 
)

◆ ff_vk_frame_barrier()

void ff_vk_frame_barrier ( FFVulkanContext s,
FFVkExecContext e,
AVFrame pic,
VkImageMemoryBarrier2 *  bar,
int *  nb_bar,
VkPipelineStageFlags2  src_stage,
VkPipelineStageFlags2  dst_stage,
VkAccessFlagBits2  new_access,
VkImageLayout  new_layout,
uint32_t  new_qf 
)

◆ ff_vk_shader_load()

int ff_vk_shader_load ( FFVulkanShader shd,
VkPipelineStageFlags  stage,
VkSpecializationInfo *  spec,
uint32_t  wg_size[3],
uint32_t  required_subgroup_size 
)

◆ init_pipeline_layout()

static int init_pipeline_layout ( FFVulkanContext s,
FFVulkanShader shd 
)
static

Definition at line 2099 of file vulkan.c.

Referenced by ff_vk_shader_link().

◆ create_shader_module()

static int create_shader_module ( FFVulkanContext s,
FFVulkanShader shd,
VkShaderModule *  mod,
const uint8_t *  spirv,
size_t  spirv_len 
)
static

Definition at line 2125 of file vulkan.c.

Referenced by ff_vk_shader_link().

◆ init_compute_pipeline()

static int init_compute_pipeline ( FFVulkanContext s,
FFVulkanShader shd,
VkShaderModule  mod,
const char *  entrypoint 
)
static

Definition at line 2151 of file vulkan.c.

Referenced by ff_vk_shader_link().

◆ create_shader_object()

static int create_shader_object ( FFVulkanContext s,
FFVulkanShader shd,
const uint8_t *  spirv,
size_t  spirv_len,
size_t *  binary_size,
const char *  entrypoint 
)
static

Definition at line 2186 of file vulkan.c.

Referenced by ff_vk_shader_link().

◆ init_descriptors()

static int init_descriptors ( FFVulkanContext s,
FFVulkanShader shd 
)
static

Definition at line 2225 of file vulkan.c.

Referenced by ff_vk_shader_link().

◆ ff_vk_shader_link()

int ff_vk_shader_link ( FFVulkanContext s,
FFVulkanShader shd,
const char *  spirv,
size_t  spirv_len,
const char *  entrypoint 
)

◆ ff_vk_shader_add_descriptor_set()

void ff_vk_shader_add_descriptor_set ( FFVulkanContext s,
FFVulkanShader shd,
const FFVulkanDescriptorSetBinding desc,
int  nb,
int  singular 
)

◆ ff_vk_shader_register_exec()

int ff_vk_shader_register_exec ( FFVulkanContext s,
FFVkExecPool pool,
FFVulkanShader shd 
)

◆ get_shd_data()

static const FFVulkanShaderData* get_shd_data ( FFVkExecContext e,
const FFVulkanShader shd 
)
inlinestatic

Definition at line 2481 of file vulkan.c.

Referenced by ff_vk_exec_bind_shader(), and update_set_pool_write().

◆ update_set_pool_write()

static void update_set_pool_write ( FFVulkanContext s,
FFVkExecContext e,
FFVulkanShader shd,
int  set,
VkWriteDescriptorSet *  write_info 
)
inlinestatic

Definition at line 2490 of file vulkan.c.

Referenced by ff_vk_shader_update_desc_buffer(), and ff_vk_shader_update_img().

◆ ff_vk_shader_update_img()

int ff_vk_shader_update_img ( FFVulkanContext s,
FFVkExecContext e,
FFVulkanShader shd,
int  set,
int  bind,
int  offs,
VkImageView  view,
VkImageLayout  layout,
VkSampler  sampler 
)

Sets an image descriptor for specified shader and binding.

Definition at line 2517 of file vulkan.c.

Referenced by ff_vk_shader_update_img_array(), and vulkan_encode_prores_submit_frame().

◆ ff_vk_shader_update_img_array()

void ff_vk_shader_update_img_array ( FFVulkanContext s,
FFVkExecContext e,
FFVulkanShader shd,
AVFrame f,
VkImageView *  views,
int  set,
int  binding,
VkImageLayout  layout,
VkSampler  sampler 
)

◆ ff_vk_shader_update_desc_buffer()

int ff_vk_shader_update_desc_buffer ( FFVulkanContext s,
FFVkExecContext e,
FFVulkanShader shd,
int  set,
int  bind,
int  elem,
FFVkBuffer buf,
VkDeviceSize  offset,
VkDeviceSize  len,
VkFormat  fmt 
)

◆ ff_vk_shader_update_push_const()

void ff_vk_shader_update_push_const ( FFVulkanContext s,
FFVkExecContext e,
FFVulkanShader shd,
VkShaderStageFlagBits  stage,
int  offset,
size_t  size,
void *  src 
)

◆ ff_vk_exec_bind_shader()

void ff_vk_exec_bind_shader ( FFVulkanContext s,
FFVkExecContext e,
const FFVulkanShader shd 
)

◆ ff_vk_shader_free()

void ff_vk_shader_free ( FFVulkanContext s,
FFVulkanShader shd 
)

◆ ff_vk_uninit()

void ff_vk_uninit ( FFVulkanContext s)

◆ ff_vk_init()

int ff_vk_init ( FFVulkanContext s,
void *  log_parent,
AVBufferRef device_ref,
AVBufferRef frames_ref 
)

Initializes the AVClass, in case this context is not used as the main user's context.

May use either a frames context reference, or a device context reference.

Definition at line 2651 of file vulkan.c.

Referenced by encode_init(), ff_sws_vk_init(), ff_vk_decode_init(), vulkan_encode_apv_init(), and vulkan_encode_ffv1_init().

Variable Documentation

◆ ff_comp_identity_map

const VkComponentMapping ff_comp_identity_map
Initial value:
= {
.r = VK_COMPONENT_SWIZZLE_IDENTITY,
.g = VK_COMPONENT_SWIZZLE_IDENTITY,
.b = VK_COMPONENT_SWIZZLE_IDENTITY,
.a = VK_COMPONENT_SWIZZLE_IDENTITY,
}

Definition at line 33 of file vulkan.c.

Referenced by ff_vk_create_imageview(), and ff_vk_create_imageviews().

FF_VK_REP_NATIVE
@ FF_VK_REP_NATIVE
Definition: vulkan.h:429
FF_VK_REP_INT
@ FF_VK_REP_INT
Definition: vulkan.h:433
FF_VK_REP_FLOAT
@ FF_VK_REP_FLOAT
Definition: vulkan.h:431
dst
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition: dsp.h:87
FF_VK_REP_UINT
@ FF_VK_REP_UINT
Definition: vulkan.h:435
src
#define src
Definition: vp8dsp.c:248