FFmpeg
Loading...
Searching...
No Matches
vulkan.h File Reference
#include <stdatomic.h>
#include "refstruct.h"
#include "thread.h"
#include "pixdesc.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  FFVkExecObjDep
 
struct  FFVkExecContext
 
struct  FFVulkanDescriptorSet
 
struct  FFVulkanShader
 
struct  FFVulkanDescriptorSetData
 
struct  FFVulkanShaderData
 
struct  FFVkExecPool
 
struct  FFVulkanContext
 
struct  FFVkImageViews
 

Macros

#define VK_NO_PROTOTYPES
 
#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)
 
#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_EXEC_MAX_FRAME_DEPS   64
 
#define FF_VK_EXEC_MAX_BUF_DEPS   256
 
#define FF_VK_EXEC_MAX_SW_FRAME_DEPS   16
 
#define FF_VK_EXEC_MAX_SEM_OPS   (FF_VK_EXEC_MAX_FRAME_DEPS*AV_NUM_DATA_POINTERS)
 
#define FF_VK_DEFAULT_EXEC_CONTEXTS   4
 
#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.
 
const char * ff_vk_ret2str (VkResult res)
 Converts Vulkan return values to strings.
 
VkImageUsageFlags ff_vk_map_feats_to_usage (VkFormatFeatureFlagBits2 feats)
 Map between usage and features.
 
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.
 
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.
 
VkImageAspectFlags ff_vk_aspect_flag (AVFrame *f, int p)
 Get the aspect flag for a plane from an image.
 
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.
 
AVVulkanDeviceQueueFamilyff_vk_qf_find (FFVulkanContext *s, VkQueueFlagBits dev_family, VkVideoCodecOperationFlagBitsKHR vid_ops)
 Chooses an appropriate QF.
 
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.
 
void ff_vk_exec_pool_free (FFVulkanContext *s, FFVkExecPool *pool)
 
FFVkExecContextff_vk_exec_get (FFVulkanContext *s, FFVkExecPool *pool)
 Retrieve an execution pool.
 
VkResult ff_vk_exec_get_query (FFVulkanContext *s, FFVkExecContext *e, void **data, VkQueryResultFlagBits flags)
 Performs nb_queries queries and returns their results and statuses.
 
int ff_vk_exec_start (FFVulkanContext *s, FFVkExecContext *e)
 Start/submit/wait an execution.
 
int ff_vk_exec_submit (FFVulkanContext *s, FFVkExecContext *e)
 
void ff_vk_exec_wait (FFVulkanContext *s, FFVkExecContext *e)
 
void ff_vk_exec_add_dep_refstruct (FFVulkanContext *s, FFVkExecContext *e, void *obj)
 Execution dependency management.
 
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)
 
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)
 
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 (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.
 
FFVkImageViewsff_vk_imageviews_alloc (FFVulkanContext *s, int nb_views)
 Allocate a reference-counted set of image views, zero-initialized for the caller to create.
 
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.
 
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_image_create (FFVulkanContext *s, VkImage *img, VkDeviceMemory *mem, int width, int height, VkFormat format, int nb_layers, VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags, void *create_pnext)
 Memory/buffer/image allocation helpers.
 
void ff_vk_image_free (FFVulkanContext *s, VkImage *img, VkDeviceMemory *mem)
 Free an image created by ff_vk_image_create(); all GPU use must have completed.
 
int ff_vk_alloc_mem (FFVulkanContext *s, VkMemoryRequirements *req, VkMemoryPropertyFlagBits req_flags, void *alloc_extension, VkMemoryPropertyFlagBits *mem_flags, VkDeviceMemory *mem)
 
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.
 
int ff_vk_map_buffers (FFVulkanContext *s, FFVkBuffer **buf, uint8_t *mem[], int nb_buffers, int invalidate)
 Buffer management code.
 
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, AVRefStructPool **buf_pool, FFVkBuffer **buf, VkBufferUsageFlags usage, void *create_pNext, size_t size, VkMemoryPropertyFlagBits mem_props)
 Initialize a pool and create AVBufferRefs containing FFVkBuffer.
 
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.
 
int ff_vk_init_sampler (FFVulkanContext *s, VkSampler *sampler, int unnorm_coords, VkFilter filt)
 Create a sampler.
 
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.
 
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.
 
int ff_vk_shader_add_push_const (FFVulkanShader *shd, int offset, int size, VkShaderStageFlagBits stage)
 Add/update push constants for execution.
 
void ff_vk_shader_add_descriptor_set (FFVulkanContext *s, FFVulkanShader *shd, const FFVulkanDescriptorSetBinding *desc, int nb, int singular)
 Add descriptor to a shader.
 
int ff_vk_shader_register_exec (FFVulkanContext *s, FFVkExecPool *pool, FFVulkanShader *shd)
 Register a shader with an exec pool.
 
void ff_vk_exec_bind_shader (FFVulkanContext *s, FFVkExecContext *e, const FFVulkanShader *shd)
 Bind a shader.
 
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.
 
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.
 
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.
 
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.
 
void ff_vk_shader_free (FFVulkanContext *s, FFVulkanShader *shd)
 Free a shader.
 
void ff_vk_uninit (FFVulkanContext *s)
 Frees main context.
 

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.

◆ RET

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

Definition at line 37 of file vulkan.h.

Referenced by avgblur_vulkan_filter_frame(), blackdetect_vulkan_filter_frame(), blend_frame(), chromaber_vulkan_filter_frame(), config_props_output(), config_props_output(), encode_init(), ff_ffv1_vk_init_consts(), ff_init_hscaler_mmxext(), ff_vk_filter_process_2pass(), ff_vk_filter_process_Nin(), ff_vk_filter_process_simple(), filter_frame(), filter_frame(), gblur_vulkan_filter_frame(), init_alpha_data_pipeline(), init_compact_shader(), init_dct_shader(), init_debayer(), init_decode_shader(), init_decode_shader(), init_decode_shader(), init_decode_shader(), init_denoise_pipeline(), init_encode_shader(), init_encode_slice_pipeline(), init_entropy_shader(), init_estimate_slice_pipeline(), init_filter(), init_filter(), init_filter(), init_filter(), init_filter(), init_filter(), init_filter(), init_filter(), init_filter(), init_filter(), init_filter(), init_filter(), init_filter(), init_filter(), init_filter(), init_gather_pipeline(), init_gather_shader(), init_gblur_pipeline(), init_idct_shader(), init_idct_shader(), init_idct_shader(), init_integral_pipeline(), init_rct_search_shader(), init_remap_shader(), init_reset_shader(), init_reset_shader(), init_setup_shader(), init_setup_shader(), init_shader(), init_slice_data_pipeline(), init_sort32_shader(), init_trellis_node_pipeline(), init_vulkan(), init_vulkan(), init_weights_pipeline(), interlace_vulkan_filter_frame(), libplacebo_config_output(), libplacebo_init(), libplacebo_process_command(), libplacebo_query_format(), nlmeans_vulkan_filter_frame(), output_frame(), overlay_vulkan_blend(), scale_vulkan_filter_frame(), scdet_vulkan_filter_frame(), submit_frame(), update_settings(), v360_vulkan_filter_frame(), vk_apv_end_frame(), vk_decode_apv_init(), vk_decode_dpx_init(), vk_decode_ffv1_init(), vk_decode_prores_init(), vk_decode_prores_raw_init(), vk_dpx_end_frame(), vk_ffv1_end_frame(), vk_prores_end_frame(), vk_prores_raw_end_frame(), vk_prores_start_frame(), vulkan_encode_ffv1_init(), vulkan_encode_ffv1_submit_frame(), vulkan_encode_prores_submit_frame(), and xfade_frame().

◆ SPEC_LIST_MAX

#define SPEC_LIST_MAX   256

Definition at line 44 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;
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
Definition avassert.h:58
const char * name
Definition qsvenc.c:142
#define SPEC_LIST_MAX
Definition vulkan.h:44

Definition at line 45 of file vulkan.h.

Referenced by init_alpha_data_pipeline(), init_dct_shader(), init_debayer(), init_decode_shader(), init_encode_slice_pipeline(), init_estimate_slice_pipeline(), init_filter(), init_filter(), init_filter(), init_filter(), init_filter(), init_filter(), init_filter(), init_idct_shader(), init_idct_shader(), init_idct_shader(), init_shader(), init_slice_data_pipeline(), init_trellis_node_pipeline(), init_vulkan(), vk_decode_ffv1_init(), and vulkan_encode_ffv1_init().

◆ 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)
static double val(void *priv, double ch)
Definition aeval.c:77
unsigned offset
Definition libaomenc.c:763
int size

Definition at line 55 of file vulkan.h.

Referenced by ff_ffv1_vk_set_common_sl(), init_alpha_data_pipeline(), init_dct_shader(), init_debayer(), init_decode_shader(), init_encode_slice_pipeline(), init_estimate_slice_pipeline(), init_filter(), init_filter(), init_filter(), init_filter(), init_filter(), init_filter(), init_filter(), init_idct_shader(), init_idct_shader(), init_idct_shader(), init_shader(), init_slice_data_pipeline(), init_trellis_node_pipeline(), init_vulkan(), vk_decode_ffv1_init(), and vulkan_encode_ffv1_init().

◆ DUP_SAMPLER

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

Definition at line 73 of file vulkan.h.

Referenced by init_filter(), init_filter(), init_filter(), and init_vulkan().

◆ FF_VK_MAX_DESCRIPTOR_SETS

#define FF_VK_MAX_DESCRIPTOR_SETS   4

Definition at line 75 of file vulkan.h.

Referenced by ff_vk_shader_add_descriptor_set().

◆ FF_VK_MAX_DESCRIPTOR_BINDINGS

#define FF_VK_MAX_DESCRIPTOR_BINDINGS   16

Definition at line 76 of file vulkan.h.

Referenced by ff_vk_shader_add_descriptor_set().

◆ FF_VK_MAX_DESCRIPTOR_TYPES

#define FF_VK_MAX_DESCRIPTOR_TYPES   16

Definition at line 77 of file vulkan.h.

Referenced by ff_vk_shader_add_descriptor_set().

◆ FF_VK_MAX_PUSH_CONSTS

#define FF_VK_MAX_PUSH_CONSTS   4

Definition at line 78 of file vulkan.h.

Referenced by ff_vk_shader_add_push_const().

◆ FF_VK_MAX_SHADERS

#define FF_VK_MAX_SHADERS   16

Definition at line 79 of file vulkan.h.

Referenced by ff_vk_shader_register_exec().

◆ FF_VK_EXEC_MAX_FRAME_DEPS

#define FF_VK_EXEC_MAX_FRAME_DEPS   64

Definition at line 115 of file vulkan.h.

Referenced by ff_vk_exec_add_dep_frame().

◆ FF_VK_EXEC_MAX_BUF_DEPS

#define FF_VK_EXEC_MAX_BUF_DEPS   256

◆ FF_VK_EXEC_MAX_SW_FRAME_DEPS

#define FF_VK_EXEC_MAX_SW_FRAME_DEPS   16

Definition at line 117 of file vulkan.h.

Referenced by ff_vk_exec_add_dep_sw_frame().

◆ FF_VK_EXEC_MAX_SEM_OPS

◆ FF_VK_DEFAULT_EXEC_CONTEXTS

◆ 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)
#define BASE
Definition adler32.c:38
#define TYPE
Definition ffv1dec.c:90
#define FF_VK_EXT_NO_FLAG

Definition at line 387 of file vulkan.h.

Referenced by device_features_init(), and ff_vk_load_props().

◆ 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)
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition dsp.h:87

Definition at line 575 of file vulkan.h.

Referenced by denoise_pass(), nlmeans_vulkan_filter_frame(), submit_frame(), vk_ffv1_end_frame(), vk_prores_end_frame(), and vulkan_encode_ffv1_submit_frame().

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 437 of file vulkan.h.

Function Documentation

◆ ff_vk_count_images()

◆ 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 378 of file vulkan.h.

Referenced by create_frame(), and vulkan_host_transfer_usable().

◆ 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 2831 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().

◆ ff_vk_ret2str()

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

Referenced by init_filter(), 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 1656 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 )

Definition at line 1750 of file vulkan.c.

◆ ff_vk_load_props()

int ff_vk_load_props ( FFVulkanContext * s)

Loads props/mprops/driver_props.

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

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

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

◆ ff_vk_exec_pool_free()

◆ ff_vk_exec_get()

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

Referenced by vulkan_encode_output().

◆ ff_vk_exec_start()

◆ ff_vk_exec_submit()

◆ ff_vk_exec_wait()

◆ 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. ff_vk_exec_discard() abandons a started, unsubmitted recording: call it exactly once, from the claiming thread. ff_vk_exec_submit() cleans up after its own failures.

Definition at line 779 of file vulkan.c.

Referenced by ff_vk_decode_frame(), 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()

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

Referenced by ff_vk_create_imageviews(), and ff_vk_exec_add_dep_bool_sem().

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

◆ ff_vk_exec_add_dep_frame()

◆ ff_vk_exec_add_dep_sw_frame()

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

Definition at line 811 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 925 of file vulkan.c.

Referenced by ff_vk_decode_frame(), 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 944 of file vulkan.c.

Referenced by vk_ffv1_end_frame().

◆ ff_vk_exec_discard()

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

Referenced by ff_vk_decode_prepare_frame().

◆ ff_vk_create_imageviews()

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

int ff_vk_image_create ( FFVulkanContext * s,
VkImage * img,
VkDeviceMemory * mem,
int width,
int height,
VkFormat format,
int nb_layers,
VkImageTiling tiling,
VkImageUsageFlags usage,
VkImageCreateFlags flags,
void * create_pnext )

Memory/buffer/image allocation helpers.

Create a standalone internal-use image: exclusive sharing, dedicated memory. Not for interop or mapping.

Definition at line 1095 of file vulkan.c.

Referenced by dpb_image_init().

◆ ff_vk_image_free()

void ff_vk_image_free ( FFVulkanContext * s,
VkImage * img,
VkDeviceMemory * mem )

Free an image created by ff_vk_image_create(); all GPU use must have completed.

Definition at line 1172 of file vulkan.c.

Referenced by dpb_image_init(), and ff_vk_image_create().

◆ ff_vk_alloc_mem()

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

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

Referenced by copy_buffer_data(), and vk_apv_end_frame().

◆ 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 1278 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 1358 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()

◆ 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 1426 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().

◆ 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 1522 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_init_sampler()

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

Create a sampler.

Definition at line 1624 of file vulkan.c.

Referenced by init_filter(), init_filter(), init_filter(), init_filter(), and init_vulkan().

◆ ff_vk_shader_load()

◆ ff_vk_shader_link()

◆ ff_vk_shader_add_push_const()

◆ ff_vk_shader_add_descriptor_set()

◆ ff_vk_shader_register_exec()

◆ ff_vk_exec_bind_shader()

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

◆ ff_vk_uninit()

Variable Documentation

◆ ff_comp_identity_map

const VkComponentMapping ff_comp_identity_map
extern

Definition at line 34 of file vulkan.c.

Referenced by ff_vk_create_imageview(), and ff_vk_create_imageviews().