Go to the documentation of this file.
19 #ifndef AVUTIL_VULKAN_H
20 #define AVUTIL_VULKAN_H
22 #define VK_NO_PROTOTYPES
24 #include <stdatomic.h>
35 #define INDENT(N) INDENT_##N
37 #define INDENT_1 INDENT_0 " "
38 #define INDENT_2 INDENT_1 INDENT_1
39 #define INDENT_3 INDENT_2 INDENT_1
40 #define INDENT_4 INDENT_3 INDENT_1
41 #define INDENT_5 INDENT_4 INDENT_1
42 #define INDENT_6 INDENT_5 INDENT_1
43 #define C(N, S) INDENT(N) #S "\n"
47 av_bprintf(&shd->src, C(N, S)); \
52 av_bprintf(&shd->src, __VA_ARGS__); \
55 #define GLSLF(N, S, ...) \
57 av_bprintf(&shd->src, C(N, S), __VA_ARGS__); \
62 av_bprintf(&shd->src, "\n"); \
63 av_bprint_append_data(&shd->src, D, strlen(D)); \
64 av_bprintf(&shd->src, "\n"); \
70 if ((err = (x)) < 0) \
74 #define DUP_SAMPLER(x) { x, x, x, x }
80 VkPipelineShaderStageCreateInfo
shader;
237 VkPhysicalDeviceExternalMemoryHostPropertiesEXT
hprops;
282 const VkBaseInStructure *in = chain;
284 if (in->sType == stype)
320 VkQueueFlagBits dev_family);
329 int nb_queries, VkQueryType query_type,
int query_64bit,
330 const void *query_create_pnext);
366 VkPipelineStageFlagBits2 wait_stage,
367 VkPipelineStageFlagBits2 signal_stage);
369 VkImageMemoryBarrier2 *bar, uint32_t *nb_img_bar);
371 VkSemaphore *dst, uint64_t *dst_val,
383 AVFrame *pic, VkImageMemoryBarrier2 *bar,
int *nb_bar,
384 VkPipelineStageFlags src_stage,
385 VkPipelineStageFlags dst_stage,
386 VkAccessFlagBits new_access,
387 VkImageLayout new_layout,
394 VkMemoryPropertyFlagBits req_flags,
void *alloc_extension,
395 VkMemoryPropertyFlagBits *mem_flags, VkDeviceMemory *mem);
397 void *pNext,
void *alloc_pNext,
398 VkBufferUsageFlags
usage, VkMemoryPropertyFlagBits
flags);
400 void *pNext,
void *alloc_pNext,
401 VkBufferUsageFlags
usage, VkMemoryPropertyFlagBits
flags);
407 int nb_buffers,
int invalidate);
431 void *create_pNext,
size_t size,
432 VkMemoryPropertyFlagBits mem_props);
438 int unnorm_coords, VkFilter
filt);
444 VkShaderStageFlags stage, uint32_t required_subgroup_size);
448 uint8_t *spirv,
size_t spirv_size,
const char *entrypoint);
455 VkShaderStageFlagBits stage);
458 VkShaderStageFlagBits stage,
467 int read_only,
int print_to_shader_only);
491 VkImageView view, VkImageLayout
layout, VkSampler sampler);
494 VkDeviceAddress addr, VkDeviceSize
len,
VkFormat fmt);
498 VkImageView *views,
int set,
int binding,
499 VkImageLayout
layout, VkSampler sampler);
VkPipelineBindPoint bind_point
AVPixelFormat
Pixel format.
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
AVVulkanFramesContext * hwfc
void ff_vk_uninit(FFVulkanContext *s)
Frees main context.
unsigned int frame_deps_alloc_size
int ff_vk_load_props(FFVulkanContext *s)
Loads props/mprops/driver_props.
VkPipelineLayout pipeline_layout
FFVkExecContext * contexts
void ff_vk_update_descriptor_img_array(FFVulkanContext *s, FFVulkanPipeline *pl, FFVkExecContext *e, AVFrame *f, VkImageView *views, int set, int binding, VkImageLayout layout, VkSampler sampler)
VkDeviceSize aligned_size
int ff_vk_add_push_constant(FFVulkanPipeline *pl, int offset, int size, VkShaderStageFlagBits stage)
Add/update push constants for execution.
VkPipelineStageFlags2 stage
int ff_vk_create_avbuf(FFVulkanContext *s, AVBufferRef **ref, size_t size, void *pNext, void *alloc_pNext, VkBufferUsageFlags usage, VkMemoryPropertyFlagBits flags)
This structure describes decoded (raw) audio or video data.
VkShaderStageFlags stages
int ff_vk_pipeline_descriptor_set_add(FFVulkanContext *s, FFVulkanPipeline *pl, FFVkSPIRVShader *shd, FFVulkanDescriptorSetBinding *desc, int nb, int read_only, int print_to_shader_only)
Add descriptor to a pipeline.
unsigned int sem_sig_alloc
int ff_vk_exec_submit(FFVulkanContext *s, FFVkExecContext *e)
void ff_vk_exec_update_frame(FFVulkanContext *s, FFVkExecContext *e, AVFrame *f, VkImageMemoryBarrier2 *bar, uint32_t *nb_img_bar)
VkSemaphoreSubmitInfo * sem_wait
int ff_vk_set_descriptor_sampler(FFVulkanContext *s, FFVulkanPipeline *pl, FFVkExecContext *e, int set, int bind, int offs, VkSampler *sampler)
int ff_vk_exec_mirror_sem_value(FFVulkanContext *s, FFVkExecContext *e, VkSemaphore *dst, uint64_t *dst_val, AVFrame *f)
unsigned int frame_update_alloc_size
VkPhysicalDeviceFeatures2 feats
static const void * ff_vk_find_struct(const void *chain, VkStructureType stype)
Allocated as AVHWFramesContext.hwctx, used to set pool-specific options.
void ff_vk_pipeline_free(FFVulkanContext *s, FFVulkanPipeline *pl)
int ff_vk_shader_create(FFVulkanContext *s, FFVkSPIRVShader *shd, uint8_t *spirv, size_t spirv_size, const char *entrypoint)
VkPhysicalDeviceSubgroupSizeControlProperties subgroup_props
VkDescriptorSetLayout layout
int ff_vk_exec_pool_init(FFVulkanContext *s, FFVkQueueFamilyCtx *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.
VkPhysicalDeviceShaderAtomicFloatFeaturesEXT atomic_float_feats
int ff_vk_unmap_buffers(FFVulkanContext *s, FFVkBuffer **buf, int nb_buffers, int flush)
This struct aggregates all the (hardware/vendor-specific) "high-level" state, i.e.
VkDescriptorSetLayoutBinding * binding
const char * ff_vk_shader_rep_fmt(enum AVPixelFormat pixfmt)
Returns the format to use for images in shaders.
int ff_vk_shader_init(FFVulkanPipeline *pl, FFVkSPIRVShader *shd, const char *name, VkShaderStageFlags stage, uint32_t required_subgroup_size)
Shader management.
int ff_vk_qf_init(FFVulkanContext *s, FFVkQueueFamilyCtx *qf, VkQueueFlagBits dev_family)
Chooses a QF and loads it into a context.
static void set(uint8_t *a[], int ch, int index, int ch_count, enum AVSampleFormat f, double v)
VkResult ff_vk_exec_get_query(FFVulkanContext *s, FFVkExecContext *e, void **data, int64_t *status)
Performs nb_queries queries and returns their results and statuses.
uint32_t * queue_family_dst
int ff_vk_create_imageviews(FFVulkanContext *s, FFVkExecContext *e, VkImageView views[AV_NUM_DATA_POINTERS], AVFrame *f)
Create an imageview and add it as a dependency to an execution.
VkPhysicalDeviceDriverProperties driver_props
static enum AVPixelFormat pix_fmt
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.
static int ff_vk_unmap_buffer(FFVulkanContext *s, FFVkBuffer *buf, int flush)
void ff_vk_shader_set_compute_sizes(FFVkSPIRVShader *shd, int x, int y, int z)
const struct FFVkExecPool * parent
FFVkExecContext * ff_vk_exec_get(FFVkExecPool *pool)
Retrieve an execution pool.
Main Vulkan context, allocated as AVHWDeviceContext.hwctx.
Describe the class of an AVClass context structure.
unsigned int sem_sig_val_dst_alloc
int ff_vk_init_compute_pipeline(FFVulkanContext *s, FFVulkanPipeline *pl, FFVkSPIRVShader *shd)
void ff_vk_exec_pool_free(FFVulkanContext *s, FFVkExecPool *pool)
unsigned int access_dst_alloc
VkPhysicalDeviceCooperativeMatrixPropertiesKHR coop_matrix_props
VkQueueFamilyProperties2 * qf_props
static int ff_vk_count_images(AVVkFrame *f)
int ff_vk_exec_add_dep_buf(FFVulkanContext *s, FFVkExecContext *e, AVBufferRef **deps, int nb_deps, int ref)
Execution dependency management.
void ff_vk_shader_free(FFVulkanContext *s, FFVkSPIRVShader *shd)
AVHWDeviceContext * device
int ff_vk_exec_start(FFVulkanContext *s, FFVkExecContext *e)
Start/submit/wait an execution.
VkImageLayout * layout_dst
unsigned int queue_family_dst_alloc
int ff_vk_map_buffers(FFVulkanContext *s, FFVkBuffer **buf, uint8_t *mem[], int nb_buffers, int invalidate)
Buffer management code.
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.
#define AV_NUM_DATA_POINTERS
void ff_vk_free_buf(FFVulkanContext *s, FFVkBuffer *buf)
int ff_vk_exec_add_dep_frame(FFVulkanContext *s, FFVkExecContext *e, AVFrame *f, VkPipelineStageFlagBits2 wait_stage, VkPipelineStageFlagBits2 signal_stage)
enum AVPixelFormat output_format
VkMemoryPropertyFlagBits flags
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
const VkComponentMapping ff_comp_identity_map
AVBufferRef * input_frames_ref
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel layout
const char * ff_vk_ret2str(VkResult res)
Converts Vulkan return values to strings.
void ff_vk_update_push_exec(FFVulkanContext *s, FFVkExecContext *e, FFVulkanPipeline *pl, VkShaderStageFlagBits stage, int offset, size_t size, void *src)
VkPushConstantRange * push_consts
int ff_vk_set_descriptor_image(FFVulkanContext *s, FFVulkanPipeline *pl, FFVkExecContext *e, int set, int bind, int offs, VkImageView view, VkImageLayout layout, VkSampler sampler)
VkPipelineShaderStageCreateInfo shader
unsigned int layout_dst_alloc
VkPhysicalDeviceExternalMemoryHostPropertiesEXT hprops
VkPhysicalDeviceProperties2 props
unsigned int frame_locked_alloc_size
static const int8_t filt[NUMTAPS *2]
FFVulkanExtensions extensions
VkPhysicalDeviceMemoryProperties mprops
VkDeviceSize * binding_offset
unsigned int sem_wait_alloc
This struct describes a set or pool of "hardware" frames (i.e.
intptr_t atomic_int_least64_t
VkPhysicalDeviceDescriptorBufferPropertiesEXT desc_buf_props
enum AVPixelFormat pixfmt
static int ff_vk_map_buffer(FFVulkanContext *s, FFVkBuffer *buf, uint8_t **mem, int invalidate)
void ff_vk_exec_wait(FFVulkanContext *s, FFVkExecContext *e)
VkSemaphoreSubmitInfo * sem_sig
int ff_vk_mt_is_np_rgb(enum AVPixelFormat pix_fmt)
Returns 1 if pixfmt is a usable RGB format.
enum AVPixelFormat input_format
uint32_t coop_mat_props_nb
FFVulkanDescriptorSet * desc_set
VkQueueFamilyVideoPropertiesKHR * video_props
static int ref[MAX_W *MAX_W]
void ff_vk_exec_discard_deps(FFVulkanContext *s, FFVkExecContext *e)
VkPipelineShaderStageRequiredSubgroupSizeCreateInfo subgroup_info
int ff_vk_exec_pipeline_register(FFVulkanContext *s, FFVkExecPool *pool, FFVulkanPipeline *pl)
Register a pipeline with an exec pool.
AVVulkanDeviceContext * hwctx
void(* flush)(AVBSFContext *ctx)
A reference to a data buffer.
VkCommandBuffer * cmd_bufs
VkPhysicalDeviceVulkan12Features feats_12
unsigned int buf_deps_alloc_size
int ff_vk_set_descriptor_buffer(FFVulkanContext *s, FFVulkanPipeline *pl, FFVkExecContext *e, int set, int bind, int offs, VkDeviceAddress addr, VkDeviceSize len, VkFormat fmt)
#define flags(name, subs,...)
AVHWFramesContext * frames
void ff_vk_frame_barrier(FFVulkanContext *s, FFVkExecContext *e, AVFrame *pic, VkImageMemoryBarrier2 *bar, int *nb_bar, VkPipelineStageFlags src_stage, VkPipelineStageFlags dst_stage, VkAccessFlagBits new_access, VkImageLayout new_layout, uint32_t new_qf)
void ff_vk_shader_print(void *ctx, FFVkSPIRVShader *shd, int prio)
VkDescriptorBufferBindingInfoEXT * desc_bind
int ff_vk_init_sampler(FFVulkanContext *s, VkSampler *sampler, int unnorm_coords, VkFilter filt)
Create a sampler.
uint64_t ** sem_sig_val_dst
VkQueueFamilyQueryResultStatusPropertiesKHR * query_props
int ff_vk_create_buf(FFVulkanContext *s, FFVkBuffer *buf, size_t size, void *pNext, void *alloc_pNext, VkBufferUsageFlags usage, VkMemoryPropertyFlagBits flags)
VkCommandPool cmd_buf_pool
VkCooperativeMatrixPropertiesKHR * coop_mat_props
uint32_t * bound_buffer_indices
void ff_vk_exec_bind_pipeline(FFVulkanContext *s, FFVkExecContext *e, FFVulkanPipeline *pl)
VkAccessFlagBits * access_dst