Go to the documentation of this file.
19 #ifndef AVUTIL_VULKAN_H
20 #define AVUTIL_VULKAN_H
29 #define FF_VK_DEFAULT_USAGE_FLAGS (VK_IMAGE_USAGE_SAMPLED_BIT | \
30 VK_IMAGE_USAGE_STORAGE_BIT | \
31 VK_IMAGE_USAGE_TRANSFER_SRC_BIT | \
32 VK_IMAGE_USAGE_TRANSFER_DST_BIT)
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"
44 #define GLSLC(N, S) av_bprintf(&shd->src, C(N, S))
45 #define GLSLA(...) av_bprintf(&shd->src, __VA_ARGS__)
46 #define GLSLF(N, S, ...) av_bprintf(&shd->src, C(N, S), __VA_ARGS__)
47 #define GLSLD(D) GLSLC(0, ); \
48 av_bprint_append_data(&shd->src, D, strlen(D)); \
54 if ((err = (x)) < 0) \
62 VkPipelineShaderStageCreateInfo
shader;
69 size_t *
size,
const char *entrypoint,
void **opaque);
251 VkQueueFlagBits dev_family,
int nb_queues);
271 const VkComponentMapping
map);
278 VkShaderStageFlagBits stage);
290 VkShaderStageFlags stage);
302 int num,
int only_print_to_shader);
308 const char *entrypoint);
360 VkShaderStageFlagBits stage,
int offset,
384 VkPipelineStageFlagBits in_wait_dst_flag);
397 VkBufferUsageFlags
usage, VkMemoryPropertyFlagBits
flags);
404 int nb_buffers,
int invalidate);
VkPipelineBindPoint bind_point
int ff_vk_map_buffers(FFVulkanContext *s, FFVkBuffer *buf, uint8_t *mem[], int nb_buffers, int invalidate)
Maps the buffer to userspace.
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 the main Vulkan context.
VkPipelineLayout pipeline_layout
int ff_vk_add_dep_exec_ctx(FFVulkanContext *s, FFVkExecContext *e, AVBufferRef **deps, int nb_deps)
Adds a generic AVBufferRef as a queue depenency.
int ff_vk_create_imageview(FFVulkanContext *s, FFVkExecContext *e, VkImageView *v, VkImage img, VkFormat fmt, const VkComponentMapping map)
Create an imageview.
void ff_vk_print_shader(void *ctx, FFVkSPIRVShader *shd, int prio)
Pretty print shader, mainly used by shader compilers.
int ff_vk_add_push_constant(FFVulkanPipeline *pl, int offset, int size, VkShaderStageFlagBits stage)
Define a push constant for a given stage into a pipeline.
int ff_vk_create_buf(FFVulkanContext *s, FFVkBuffer *buf, size_t size, VkBufferUsageFlags usage, VkMemoryPropertyFlagBits flags)
Create a VkBuffer with the specified parameters.
This structure describes decoded (raw) audio or video data.
VkShaderStageFlags stages
void ff_vk_bind_pipeline_exec(FFVulkanContext *s, FFVkExecContext *e, FFVulkanPipeline *pl)
Add a command to bind the completed pipeline and its descriptor sets.
void(* uninit)(struct FFVkSPIRVCompiler **ctx)
VkDescriptorPool desc_pool
FFVulkanPipeline * bound_pl
int ff_vk_start_exec_recording(FFVulkanContext *s, FFVkExecContext *e)
Begin recording to the command buffer.
VkPipelineStageFlagBits * sem_wait_dst
Allocated as AVHWFramesContext.hwctx, used to set pool-specific options.
VkCommandBuffer ff_vk_get_exec_buf(FFVkExecContext *e)
Gets the command buffer to use for this submission from the exe context.
FFVkSPIRVShader ** shaders
int sem_sig_val_dst_alloc
void ff_vk_update_descriptor_set(FFVulkanContext *s, FFVulkanPipeline *pl, int set_id)
Updates a descriptor set via the updaters defined.
This struct aggregates all the (hardware/vendor-specific) "high-level" state, i.e.
const char * ff_vk_shader_rep_fmt(enum AVPixelFormat pixfmt)
Gets the glsl format string for a pixel format.
FFVkExecContext ** exec_ctx
int ff_vk_create_exec_ctx(FFVulkanContext *s, FFVkExecContext **ctx, FFVkQueueFamilyCtx *qf)
Init an execution context for command recording and queue submission.
void ff_vk_qf_rotate(FFVkQueueFamilyCtx *qf)
Rotate through the queues in a queue family.
int ff_vk_init_pipeline_layout(FFVulkanContext *s, FFVulkanPipeline *pl)
Initializes the pipeline layout after all shaders and descriptor sets have been finished.
VkDescriptorUpdateTemplate * desc_template
FFVulkanPipeline ** pipelines
static enum AVPixelFormat pix_fmt
int(* compile_shader)(struct FFVkSPIRVCompiler *ctx, void *avctx, struct FFVkSPIRVShader *shd, uint8_t **data, size_t *size, const char *entrypoint, void **opaque)
VkDescriptorUpdateTemplateCreateInfo * desc_template_info
Main Vulkan context, allocated as AVHWDeviceContext.hwctx.
Describe the class of an AVClass context structure.
static void flush(AVCodecContext *avctx)
VkDescriptorSetLayoutBinding ** desc_binding
AVHWDeviceContext * device
int total_descriptor_sets
FFVkSPIRVCompiler * spirv_compiler
VkPhysicalDeviceProperties props
void ff_vk_free_buf(FFVulkanContext *s, FFVkBuffer *buf)
Frees a buffer.
enum AVPixelFormat output_format
FFVkSPIRVShader * ff_vk_init_shader(FFVulkanPipeline *pl, const char *name, VkShaderStageFlags stage)
Inits a shader for a specific pipeline.
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
VkDescriptorSet * desc_set
const VkComponentMapping ff_comp_identity_map
int ff_vk_submit_exec_queue(FFVulkanContext *s, FFVkExecContext *e)
Submits a command buffer to the queue for execution.
void ff_vk_set_compute_shader_sizes(FFVkSPIRVShader *shd, int local_size[3])
Writes the workgroup size for a shader.
const char * ff_vk_ret2str(VkResult res)
Converts Vulkan return values to strings.
VkDescriptorPoolSize * pool_size_desc
VkPushConstantRange * push_consts
VkPipelineShaderStageCreateInfo shader
void ff_vk_qf_init(FFVulkanContext *s, FFVkQueueFamilyCtx *qf, VkQueueFlagBits dev_family, int nb_queues)
Initialize a queue family with a specific number of queues.
static const int8_t filt[NUMTAPS *2]
FFVulkanExtensions extensions
void(* free_shader)(struct FFVkSPIRVCompiler *ctx, void **opaque)
VkPhysicalDeviceMemoryProperties mprops
This struct describes a set or pool of "hardware" frames (i.e.
int * desc_set_initialized
enum AVPixelFormat pixfmt
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
int ff_vk_unmap_buffers(FFVulkanContext *s, FFVkBuffer *buf, int nb_buffers, int flush)
Unmaps the buffer from userspace.
int ff_vk_mt_is_np_rgb(enum AVPixelFormat pix_fmt)
Returns 1 if the image is any sort of supported RGB.
FFVulkanPipeline * ff_vk_create_pipeline(FFVulkanContext *s, FFVkQueueFamilyCtx *qf)
Inits a pipeline.
enum AVPixelFormat input_format
int frame_deps_alloc_size
FFVkSampler * ff_vk_init_sampler(FFVulkanContext *s, int unnorm_coords, VkFilter filt)
Create a Vulkan sampler, will be auto-freed in ff_vk_filter_uninit()
int ff_vk_init_compute_pipeline(FFVulkanContext *s, FFVulkanPipeline *pl)
Initializes a compute pipeline.
AVVulkanDeviceContext * hwctx
A reference to a data buffer.
void ff_vk_update_push_exec(FFVulkanContext *s, FFVkExecContext *e, VkShaderStageFlagBits stage, int offset, size_t size, void *src)
Updates push constants.
const VDPAUPixFmtMap * map
int ff_vk_compile_shader(FFVulkanContext *s, FFVkSPIRVShader *shd, const char *entrypoint)
Compiles the shader, entrypoint must be set to "main".
#define flags(name, subs,...)
AVHWFramesContext * frames
int ff_vk_add_descriptor_set(FFVulkanContext *s, FFVulkanPipeline *pl, FFVkSPIRVShader *shd, FFVulkanDescriptorSetBinding *desc, int num, int only_print_to_shader)
Adds a descriptor set to the shader and registers them in the pipeline.
void ff_vk_discard_exec_deps(FFVkExecContext *e)
Discards all queue dependencies.
uint64_t ** sem_sig_val_dst
VkDescriptorSetLayout * desc_layout
unsigned int scratch_size
int ff_vk_add_exec_dep(FFVulkanContext *s, FFVkExecContext *e, AVFrame *frame, VkPipelineStageFlagBits in_wait_dst_flag)
Adds a frame as a queue dependency.