FFmpeg
Loading...
Searching...
No Matches
vulkan.c File Reference
#include "config.h"
#include "avassert.h"
#include "mem.h"
#include "random_seed.h"
#include "refstruct.h"
#include "vulkan.h"
#include "libavutil/vulkan_loader.h"

Go to the source code of this file.

Macros

#define CASE(VAL)
 
#define FN_MAP_TO(dst_t, dst_name, src_t, src_name)
 
#define MAP_TO(flag1, flag2)
 
#define MAP_TO(flag1, 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.
 
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.
 
AVVulkanDeviceQueueFamilyff_vk_qf_find (FFVulkanContext *s, VkQueueFlagBits dev_family, VkVideoCodecOperationFlagBitsKHR vid_ops)
 Chooses an appropriate QF.
 
static void exec_discard_deps (FFVulkanContext *s, FFVkExecContext *e)
 
void ff_vk_exec_pool_free (FFVulkanContext *s, FFVkExecPool *pool)
 
static void exec_pool_phase_seed (void)
 
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.
 
VkResult ff_vk_exec_get_query (FFVulkanContext *s, FFVkExecContext *e, void **data, VkQueryResultFlagBits flags)
 Performs nb_queries queries and returns their results and statuses.
 
FFVkExecContextff_vk_exec_get (FFVulkanContext *s, FFVkExecPool *pool)
 Retrieve an execution pool.
 
void ff_vk_exec_wait (FFVulkanContext *s, FFVkExecContext *e)
 
int ff_vk_exec_start (FFVulkanContext *s, FFVkExecContext *e)
 Start/submit/wait an execution.
 
void ff_vk_exec_discard (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)
 
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)
 
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_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.
 
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_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.
 
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.
 
int ff_vk_shader_add_push_const (FFVulkanShader *shd, int offset, int size, VkShaderStageFlagBits stage)
 Add/update push constants for execution.
 
int ff_vk_init_sampler (FFVulkanContext *s, VkSampler *sampler, int unnorm_coords, VkFilter filt)
 Create a sampler.
 
VkImageAspectFlags ff_vk_aspect_flag (AVFrame *f, int p)
 Get the aspect flag for a plane from an image.
 
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.
 
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.
 
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.
 
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_shader_load (FFVulkanShader *shd, VkPipelineStageFlags stage, VkSpecializationInfo *spec, uint32_t wg_size[3], uint32_t required_subgroup_size)
 Initialize a shader object.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
void ff_vk_exec_bind_shader (FFVulkanContext *s, FFVkExecContext *e, const FFVulkanShader *shd)
 Bind a shader.
 
void ff_vk_shader_free (FFVulkanContext *s, FFVulkanShader *shd)
 Free a shader.
 
void ff_vk_uninit (FFVulkanContext *s)
 Frees main context.
 
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.
 

Variables

const VkComponentMapping ff_comp_identity_map
 
static atomic_uint exec_pool_phase [FF_ARRAY_ELEMS(((AVVulkanDeviceContext *) NULL) ->qf)]
 
static AVOnce exec_pool_phase_seeded = AV_ONCE_INIT
 

Macro Definition Documentation

◆ CASE

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

Referenced by ff_vk_ret2str().

◆ 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; \
}
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition dsp.h:87
#define src
Definition vp8dsp.c:248

Definition at line 95 of file vulkan.c.

◆ MAP_TO [1/2]

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

Definition at line 122 of file vulkan.c.

◆ MAP_TO [2/2]

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

Definition at line 122 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,
@ FF_VK_REP_UINT
Definition vulkan.h:445
@ FF_VK_REP_INT
Definition vulkan.h:443
@ FF_VK_REP_NATIVE
Definition vulkan.h:439
@ FF_VK_REP_FLOAT
Definition vulkan.h:441

Referenced by map_fmt_to_rep().

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

Referenced by map_fmt_to_rep().

Function Documentation

◆ ff_vk_ret2str()

◆ load_enabled_qfs()

static void load_enabled_qfs ( FFVulkanContext * s)
static

Definition at line 130 of file vulkan.c.

Referenced by ff_vk_load_props().

◆ reset_imageviews()

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

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

◆ exec_discard_deps()

static void exec_discard_deps ( FFVulkanContext * s,
FFVkExecContext * e )
static

◆ ff_vk_exec_pool_free()

◆ exec_pool_phase_seed()

static void exec_pool_phase_seed ( void )
static

Definition at line 388 of file vulkan.c.

Referenced by ff_vk_exec_pool_init().

◆ 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_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_get()

◆ ff_vk_exec_wait()

◆ ff_vk_exec_start()

◆ ff_vk_exec_discard()

◆ 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_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_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_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_submit()

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

Referenced by ff_vk_unmap_buffer().

◆ ff_vk_free_buf()

◆ pooled_buf_free()

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

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

◆ 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 1471 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 1517 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 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_shader_add_push_const()

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

◆ map_fmt_to_rep()

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

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

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

◆ init_pipeline_layout()

static int init_pipeline_layout ( FFVulkanContext * s,
FFVulkanShader * shd )
static

Definition at line 2269 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 2295 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 2321 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 2356 of file vulkan.c.

Referenced by ff_vk_shader_link().

◆ init_descriptors()

static int init_descriptors ( FFVulkanContext * s,
FFVulkanShader * shd )
static

Definition at line 2395 of file vulkan.c.

Referenced by ff_vk_shader_link().

◆ ff_vk_shader_link()

◆ ff_vk_shader_add_descriptor_set()

◆ ff_vk_shader_register_exec()

◆ get_shd_data()

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

Definition at line 2651 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 2660 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 2687 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()

◆ ff_vk_shader_free()

◆ ff_vk_uninit()

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

Referenced by ff_vk_create_imageview(), and ff_vk_create_imageviews().

◆ exec_pool_phase

atomic_uint exec_pool_phase[FF_ARRAY_ELEMS(((AVVulkanDeviceContext *) NULL) ->qf)]
static

Definition at line 385 of file vulkan.c.

Referenced by exec_pool_phase_seed(), and ff_vk_exec_pool_init().

◆ exec_pool_phase_seeded

AVOnce exec_pool_phase_seeded = AV_ONCE_INIT
static

Definition at line 386 of file vulkan.c.

Referenced by ff_vk_exec_pool_init().