FFmpeg
Data Structures | Macros | Enumerations | Functions | Variables
vulkan.h File Reference
#include <stdatomic.h>
#include "pixdesc.h"
#include "bprint.h"
#include "hwcontext.h"
#include "vulkan_functions.h"
#include "hwcontext_vulkan.h"
#include "avassert.h"
#include "intreadwrite.h"

Go to the source code of this file.

Data Structures

struct  FFVulkanDescriptorSetBinding
 
struct  FFVkBuffer
 
struct  FFVkExecContext
 
struct  FFVulkanDescriptorSet
 
struct  FFVulkanShader
 
struct  FFVulkanDescriptorSetData
 
struct  FFVulkanShaderData
 
struct  FFVkExecPool
 
struct  FFVulkanContext
 

Macros

#define VK_NO_PROTOTYPES
 
#define INDENT(N)   INDENT_##N
 
#define INDENT_0
 
#define INDENT_1   INDENT_0 " "
 
#define INDENT_2   INDENT_1 INDENT_1
 
#define INDENT_3   INDENT_2 INDENT_1
 
#define INDENT_4   INDENT_3 INDENT_1
 
#define INDENT_5   INDENT_4 INDENT_1
 
#define INDENT_6   INDENT_5 INDENT_1
 
#define C(N, S)   INDENT(N) #S "\n"
 
#define GLSLC(N, S)
 
#define GLSLA(...)
 
#define GLSLF(N, S, ...)
 
#define GLSLD(D)
 
#define RET(x)
 
#define SPEC_LIST_MAX   256
 
#define SPEC_LIST_CREATE(name, max_length, max_size)
 
#define SPEC_LIST_ADD(name, idx, val_bits, val)
 
#define DUP_SAMPLER(x)   { x, x, x, x }
 
#define FF_VK_MAX_DESCRIPTOR_SETS   4
 
#define FF_VK_MAX_DESCRIPTOR_BINDINGS   16
 
#define FF_VK_MAX_DESCRIPTOR_TYPES   16
 
#define FF_VK_MAX_PUSH_CONSTS   4
 
#define FF_VK_MAX_SHADERS   16
 
#define FF_VK_STRUCT_EXT(CTX, BASE, STRUCT_P, EXT_FLAG, TYPE)
 
#define ff_vk_buf_barrier(dst, vkb, s_stage, s_access, s_access2, d_stage, d_access, d_access2, offs, bsz)
 

Enumerations

enum  FFVkShaderRepFormat { FF_VK_REP_NATIVE = 0, FF_VK_REP_FLOAT, FF_VK_REP_INT, FF_VK_REP_UINT }
 Returns the format to use for images in shaders. More...
 

Functions

static int ff_vk_count_images (AVVkFrame *f)
 
static const void * ff_vk_find_struct (const void *chain, VkStructureType stype)
 
static void ff_vk_link_struct (void *chain, const void *in)
 
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...
 
const char * ff_vk_ret2str (VkResult res)
 Converts Vulkan return values to strings. More...
 
VkImageUsageFlags ff_vk_map_feats_to_usage (VkFormatFeatureFlagBits2 feats)
 Map between usage and features. More...
 
VkFormatFeatureFlagBits2 ff_vk_map_usage_to_feats (VkImageUsageFlags usage)
 
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...
 
VkImageAspectFlags ff_vk_aspect_flag (AVFrame *f, int p)
 Get the aspect flag for a plane from an image. More...
 
const char * ff_vk_shader_rep_fmt (enum AVPixelFormat pix_fmt, enum FFVkShaderRepFormat rep_fmt)
 
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...
 
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...
 
void ff_vk_exec_pool_free (FFVulkanContext *s, FFVkExecPool *pool)
 
FFVkExecContextff_vk_exec_get (FFVulkanContext *s, FFVkExecPool *pool)
 Retrieve 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...
 
int ff_vk_exec_start (FFVulkanContext *s, FFVkExecContext *e)
 Start/submit/wait an execution. More...
 
int ff_vk_exec_submit (FFVulkanContext *s, FFVkExecContext *e)
 
void ff_vk_exec_wait (FFVulkanContext *s, FFVkExecContext *e)
 
int ff_vk_exec_add_dep_buf (FFVulkanContext *s, FFVkExecContext *e, AVBufferRef **deps, int nb_deps, int ref)
 Execution dependency management. More...
 
int ff_vk_exec_add_dep_wait_sem (FFVulkanContext *s, FFVkExecContext *e, VkSemaphore sem, uint64_t val, VkPipelineStageFlagBits2 stage)
 
int 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)
 
int ff_vk_exec_add_dep_sw_frame (FFVulkanContext *s, FFVkExecContext *e, AVFrame *f)
 
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)
 
void ff_vk_exec_discard_deps (FFVulkanContext *s, FFVkExecContext *e)
 
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_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_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_map_buffers (FFVulkanContext *s, FFVkBuffer **buf, uint8_t *mem[], int nb_buffers, int invalidate)
 Buffer management code. More...
 
int ff_vk_unmap_buffers (FFVulkanContext *s, FFVkBuffer **buf, int nb_buffers, int flush)
 
static int ff_vk_map_buffer (FFVulkanContext *s, FFVkBuffer *buf, uint8_t **mem, int invalidate)
 
static int ff_vk_unmap_buffer (FFVulkanContext *s, FFVkBuffer *buf, int flush)
 
void ff_vk_free_buf (FFVulkanContext *s, FFVkBuffer *buf)
 
int ff_vk_get_pooled_buffer (FFVulkanContext *ctx, AVBufferPool **buf_pool, AVBufferRef **buf, VkBufferUsageFlags usage, void *create_pNext, size_t size, VkMemoryPropertyFlagBits mem_props)
 Initialize a pool and create AVBufferRefs containing FFVkBuffer. More...
 
int ff_vk_host_map_buffer (FFVulkanContext *s, AVBufferRef **dst, uint8_t *src_data, const AVBufferRef *src_buf, VkBufferUsageFlags usage)
 Maps a system RAM buffer into a Vulkan buffer. More...
 
int ff_vk_init_sampler (FFVulkanContext *s, VkSampler *sampler, int unnorm_coords, VkFilter filt)
 Create a sampler. More...
 
int ff_vk_shader_init (FFVulkanContext *s, FFVulkanShader *shd, const char *name, VkPipelineStageFlags stage, const char *extensions[], int nb_extensions, int lg_x, int lg_y, int lg_z, uint32_t required_subgroup_size)
 Initialize a shader object, with a specific set of extensions, type+bind, local group size, and subgroup requirements. More...
 
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...
 
void ff_vk_shader_print (void *ctx, FFVulkanShader *shd, int prio)
 Output the shader code as logging data, with a specific priority. More...
 
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...
 
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_shader_add_descriptor_set (FFVulkanContext *s, FFVulkanShader *shd, const FFVulkanDescriptorSetBinding *desc, int nb, int singular, int print_to_shader_only)
 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...
 
void ff_vk_exec_bind_shader (FFVulkanContext *s, FFVkExecContext *e, FFVulkanShader *shd)
 Bind a shader. 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...
 
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...
 
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...
 
void ff_vk_shader_free (FFVulkanContext *s, FFVulkanShader *shd)
 Free a shader. More...
 
void ff_vk_uninit (FFVulkanContext *s)
 Frees main context. More...
 

Variables

const VkComponentMapping ff_comp_identity_map
 

Macro Definition Documentation

◆ VK_NO_PROTOTYPES

#define VK_NO_PROTOTYPES

Definition at line 22 of file vulkan.h.

◆ INDENT

#define INDENT (   N)    INDENT_##N

Definition at line 35 of file vulkan.h.

◆ INDENT_0

#define INDENT_0

Definition at line 36 of file vulkan.h.

◆ INDENT_1

#define INDENT_1   INDENT_0 " "

Definition at line 37 of file vulkan.h.

◆ INDENT_2

#define INDENT_2   INDENT_1 INDENT_1

Definition at line 38 of file vulkan.h.

◆ INDENT_3

#define INDENT_3   INDENT_2 INDENT_1

Definition at line 39 of file vulkan.h.

◆ INDENT_4

#define INDENT_4   INDENT_3 INDENT_1

Definition at line 40 of file vulkan.h.

◆ INDENT_5

#define INDENT_5   INDENT_4 INDENT_1

Definition at line 41 of file vulkan.h.

◆ INDENT_6

#define INDENT_6   INDENT_5 INDENT_1

Definition at line 42 of file vulkan.h.

◆ C

#define C (   N,
  S 
)    INDENT(N) #S "\n"

Definition at line 43 of file vulkan.h.

◆ GLSLC

#define GLSLC (   N,
  S 
)
Value:
do { \
av_bprintf(&shd->src, C(N, S)); \
} while (0)

Definition at line 45 of file vulkan.h.

◆ GLSLA

#define GLSLA (   ...)
Value:
do { \
av_bprintf(&shd->src, __VA_ARGS__); \
} while (0)

Definition at line 50 of file vulkan.h.

◆ GLSLF

#define GLSLF (   N,
  S,
  ... 
)
Value:
do { \
av_bprintf(&shd->src, C(N, S), __VA_ARGS__); \
} while (0)

Definition at line 55 of file vulkan.h.

◆ GLSLD

#define GLSLD (   D)
Value:
do { \
av_bprintf(&shd->src, "\n"); \
av_bprint_append_data(&shd->src, D, strlen(D)); \
av_bprintf(&shd->src, "\n"); \
} while (0)

Definition at line 60 of file vulkan.h.

◆ RET

#define RET (   x)
Value:
do { \
if ((err = (x)) < 0) \
goto fail; \
} while (0)

Definition at line 68 of file vulkan.h.

◆ SPEC_LIST_MAX

#define SPEC_LIST_MAX   256

Definition at line 75 of file vulkan.h.

◆ SPEC_LIST_CREATE

#define SPEC_LIST_CREATE (   name,
  max_length,
  max_size 
)
Value:
av_assert1((max_length) < (SPEC_LIST_MAX - 3)); \
uint8_t name##_data[(max_size) + 3*sizeof(uint32_t)]; \
VkSpecializationMapEntry name##_entries[(max_length) + 3]; \
VkSpecializationInfo name##_info = { \
.pMapEntries = name##_entries, \
.pData = name##_data, \
}; \
VkSpecializationInfo *name = &name##_info;

Definition at line 76 of file vulkan.h.

◆ SPEC_LIST_ADD

#define SPEC_LIST_ADD (   name,
  idx,
  val_bits,
  val 
)
Value:
do { \
unsigned int name##_cnt = name->mapEntryCount; \
size_t name##_off = name->dataSize; \
uint8_t *name##_dp = (uint8_t *)name->pData; \
void *name##_ep = (void *)&name->pMapEntries[name##_cnt]; \
AV_WN(val_bits, name##_dp + name##_off, (val)); \
VkSpecializationMapEntry name##_new_entry = { \
.constantID = (idx), \
.offset = name##_off, \
.size = val_bits >> 3, \
}; \
memcpy(name##_ep, &name##_new_entry, \
sizeof(VkSpecializationMapEntry)); \
name->dataSize = name##_off + (val_bits >> 3); \
name->mapEntryCount = name##_cnt + 1; \
} while (0)

Definition at line 86 of file vulkan.h.

◆ DUP_SAMPLER

#define DUP_SAMPLER (   x)    { x, x, x, x }

Definition at line 104 of file vulkan.h.

◆ FF_VK_MAX_DESCRIPTOR_SETS

#define FF_VK_MAX_DESCRIPTOR_SETS   4

Definition at line 106 of file vulkan.h.

◆ FF_VK_MAX_DESCRIPTOR_BINDINGS

#define FF_VK_MAX_DESCRIPTOR_BINDINGS   16

Definition at line 107 of file vulkan.h.

◆ FF_VK_MAX_DESCRIPTOR_TYPES

#define FF_VK_MAX_DESCRIPTOR_TYPES   16

Definition at line 108 of file vulkan.h.

◆ FF_VK_MAX_PUSH_CONSTS

#define FF_VK_MAX_PUSH_CONSTS   4

Definition at line 109 of file vulkan.h.

◆ FF_VK_MAX_SHADERS

#define FF_VK_MAX_SHADERS   16

Definition at line 110 of file vulkan.h.

◆ FF_VK_STRUCT_EXT

#define FF_VK_STRUCT_EXT (   CTX,
  BASE,
  STRUCT_P,
  EXT_FLAG,
  TYPE 
)
Value:
do { \
if ((EXT_FLAG == FF_VK_EXT_NO_FLAG) || \
((CTX)->extensions & EXT_FLAG)) { \
(STRUCT_P)->sType = TYPE; \
ff_vk_link_struct(BASE, STRUCT_P); \
} \
} while (0)

Definition at line 398 of file vulkan.h.

◆ ff_vk_buf_barrier

#define ff_vk_buf_barrier (   dst,
  vkb,
  s_stage,
  s_access,
  s_access2,
  d_stage,
  d_access,
  d_access2,
  offs,
  bsz 
)
Value:
do { \
dst = (VkBufferMemoryBarrier2) { \
.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER_2, \
.srcStageMask = VK_PIPELINE_STAGE_2_ ##s_stage, \
.srcAccessMask = VK_ACCESS_2_ ##s_access | \
VK_ACCESS_2_ ##s_access2, \
.dstStageMask = VK_PIPELINE_STAGE_2_ ##d_stage, \
.dstAccessMask = VK_ACCESS_2_ ##d_access | \
VK_ACCESS_2_ ##d_access2, \
.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, \
.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, \
.buffer = vkb->buf, \
.offset = offs, \
.size = bsz \
}; \
} while(0)

Definition at line 552 of file vulkan.h.

Enumeration Type Documentation

◆ FFVkShaderRepFormat

Returns the format to use for images in shaders.

Enumerator
FF_VK_REP_NATIVE 
FF_VK_REP_FLOAT 
FF_VK_REP_INT 
FF_VK_REP_UINT 

Definition at line 448 of file vulkan.h.

Function Documentation

◆ ff_vk_count_images()

static int ff_vk_count_images ( AVVkFrame f)
inlinestatic

◆ ff_vk_find_struct()

static const void* ff_vk_find_struct ( const void *  chain,
VkStructureType  stype 
)
inlinestatic

◆ ff_vk_link_struct()

static void ff_vk_link_struct ( void *  chain,
const void *  in 
)
inlinestatic

Definition at line 389 of file vulkan.h.

Referenced by create_frame().

◆ 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 3022 of file vulkan.c.

Referenced by ff_vk_decode_init(), and vulkan_encode_ffv1_init().

◆ ff_vk_ret2str()

const char* ff_vk_ret2str ( VkResult  res)

◆ ff_vk_map_feats_to_usage()

VkImageUsageFlags ff_vk_map_feats_to_usage ( VkFormatFeatureFlagBits2  feats)

Map between usage and features.

Referenced by vkfmt_from_pixfmt2().

◆ ff_vk_map_usage_to_feats()

VkFormatFeatureFlagBits2 ff_vk_map_usage_to_feats ( VkImageUsageFlags  usage)

◆ 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 1558 of file vulkan.c.

Referenced by ff_vk_aspect_flag(), run_rct_search(), scale_vulkan_config_output(), vk_ffv1_end_frame(), and vulkan_encode_ffv1_submit_frame().

◆ 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 1580 of file vulkan.c.

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

◆ 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 1541 of file vulkan.c.

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

◆ ff_vk_shader_rep_fmt()

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

◆ ff_vk_load_props()

int ff_vk_load_props ( FFVulkanContext s)

Loads props/mprops/driver_props.

Definition at line 147 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_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 366 of file vulkan.c.

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

◆ ff_vk_exec_pool_free()

void ff_vk_exec_pool_free ( FFVulkanContext s,
FFVkExecPool pool 
)

◆ ff_vk_exec_get()

FFVkExecContext* ff_vk_exec_get ( FFVulkanContext s,
FFVkExecPool pool 
)

◆ 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 529 of file vulkan.c.

Referenced by vulkan_encode_output().

◆ ff_vk_exec_start()

int ff_vk_exec_start ( FFVulkanContext s,
FFVkExecContext e 
)

◆ ff_vk_exec_submit()

int ff_vk_exec_submit ( FFVulkanContext s,
FFVkExecContext e 
)

◆ ff_vk_exec_wait()

void ff_vk_exec_wait ( FFVulkanContext s,
FFVkExecContext e 
)

◆ ff_vk_exec_add_dep_buf()

int ff_vk_exec_add_dep_buf ( FFVulkanContext s,
FFVkExecContext e,
AVBufferRef **  deps,
int  nb_deps,
int  ref 
)

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 629 of file vulkan.c.

Referenced by ff_vk_create_imageviews(), ff_vk_exec_add_dep_bool_sem(), nlmeans_vulkan_filter_frame(), transfer_slices(), vk_dpx_end_frame(), vk_ffv1_end_frame(), vk_prores_end_frame(), vk_prores_raw_end_frame(), vulkan_encode_ffv1_submit_frame(), vulkan_encode_issue(), and vulkan_transfer_frame().

◆ ff_vk_exec_add_dep_wait_sem()

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

Definition at line 706 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()

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

Definition at line 723 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_add_dep_sw_frame()

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

Definition at line 656 of file vulkan.c.

Referenced by vulkan_transfer_frame().

◆ 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 869 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 
)

◆ ff_vk_exec_discard_deps()

void ff_vk_exec_discard_deps ( FFVulkanContext s,
FFVkExecContext e 
)

◆ 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 1914 of file vulkan.c.

Referenced by ff_vk_decode_prepare_frame_sdr().

◆ 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_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 980 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_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 1180 of file vulkan.c.

Referenced by copy_buffer_data().

◆ 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 1133 of file vulkan.c.

Referenced by ff_vk_map_buffer().

◆ ff_vk_unmap_buffers()

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

Definition at line 1211 of file vulkan.c.

Referenced by ff_vk_unmap_buffer().

◆ ff_vk_map_buffer()

static int ff_vk_map_buffer ( FFVulkanContext s,
FFVkBuffer buf,
uint8_t **  mem,
int  invalidate 
)
inlinestatic

◆ ff_vk_unmap_buffer()

static int ff_vk_unmap_buffer ( FFVulkanContext s,
FFVkBuffer buf,
int  flush 
)
inlinestatic

◆ ff_vk_free_buf()

void ff_vk_free_buf ( FFVulkanContext s,
FFVkBuffer buf 
)

◆ ff_vk_get_pooled_buffer()

int ff_vk_get_pooled_buffer ( FFVulkanContext ctx,
AVBufferPool **  buf_pool,
AVBufferRef **  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 1295 of file vulkan.c.

Referenced by blackdetect_vulkan_filter_frame(), ff_vk_decode_add_slice(), get_plane_buf(), host_upload_image(), nlmeans_vulkan_filter_frame(), scdet_vulkan_filter_frame(), vk_ffv1_start_frame(), vk_prores_raw_start_frame(), vk_prores_start_frame(), vulkan_encode_ffv1_submit_frame(), and vulkan_encode_issue().

◆ ff_vk_host_map_buffer()

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

Maps a system RAM buffer into a Vulkan buffer.

References the source buffer.

Definition at line 1400 of file vulkan.c.

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

◆ ff_vk_init_sampler()

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

Create a sampler.

Definition at line 1509 of file vulkan.c.

Referenced by init_filter(), and init_vulkan().

◆ ff_vk_shader_init()

int ff_vk_shader_init ( FFVulkanContext s,
FFVulkanShader shd,
const char *  name,
VkPipelineStageFlags  stage,
const char *  extensions[],
int  nb_extensions,
int  lg_x,
int  lg_y,
int  lg_z,
uint32_t  required_subgroup_size 
)

Initialize a shader object, with a specific set of extensions, type+bind, local group size, and subgroup requirements.

Definition at line 2120 of file vulkan.c.

Referenced by init_decode_shader(), init_denoise_pipeline(), init_encode_shader(), init_filter(), init_integral_pipeline(), init_rct_search_shader(), init_reset_shader(), init_setup_shader(), init_vulkan(), and init_weights_pipeline().

◆ 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 
)

Initialize a shader object.

If spec is non-null, it must have been created with SPEC_LIST_CREATE(). The IDs for the workgroup size must be 253, 254, 255.

Definition at line 2091 of file vulkan.c.

Referenced by ff_vk_shader_init(), init_debayer(), init_decode_shader(), init_filter(), init_idct_shader(), and init_shader().

◆ ff_vk_shader_print()

void ff_vk_shader_print ( void *  ctx,
FFVulkanShader shd,
int  prio 
)

Output the shader code as logging data, with a specific priority.

Definition at line 2184 of file vulkan.c.

Referenced by glslc_shader_compile(), and shdc_shader_compile().

◆ 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_push_const()

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

◆ ff_vk_shader_add_descriptor_set()

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

◆ ff_vk_shader_register_exec()

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

◆ ff_vk_exec_bind_shader()

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

◆ 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_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_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 2793 of file vulkan.c.

Referenced by ff_vk_shader_update_img_array().

◆ 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_free()

void ff_vk_shader_free ( FFVulkanContext s,
FFVulkanShader shd 
)

◆ ff_vk_uninit()

void ff_vk_uninit ( FFVulkanContext s)

Variable Documentation

◆ ff_comp_identity_map

const VkComponentMapping ff_comp_identity_map

Definition at line 32 of file vulkan.c.

Referenced by ff_vk_create_imageview(), and ff_vk_create_imageviews().

name
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default minimum maximum flags name is the option name
Definition: writing_filters.txt:88
D
D(D(float, sse)
Definition: rematrix_init.c:30
S
#define S(s, c, i)
Definition: flacdsp_template.c:46
fail
#define fail()
Definition: checkasm.h:216
BASE
#define BASE
Definition: adler32.c:38
val
static double val(void *priv, double ch)
Definition: aeval.c:77
TYPE
#define TYPE
Definition: ffv1dec.c:96
FF_VK_EXT_NO_FLAG
#define FF_VK_EXT_NO_FLAG
Definition: vulkan_functions.h:75
size
int size
Definition: twinvq_data.h:10344
offset
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf offset
Definition: writing_filters.txt:86
N
#define N
Definition: af_mcompand.c:54
SPEC_LIST_MAX
#define SPEC_LIST_MAX
Definition: vulkan.h:75
av_assert1
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
Definition: avassert.h:57
C
#define C(N, S)
Definition: vulkan.h:43