Go to the documentation of this file.
19 #ifndef AVFILTER_VULKAN_H
20 #define AVFILTER_VULKAN_H
22 #define VK_NO_PROTOTYPES
23 #define VK_ENABLE_BETA_EXTENSIONS
33 #define INDENT(N) INDENT_##N
35 #define INDENT_1 INDENT_0 " "
36 #define INDENT_2 INDENT_1 INDENT_1
37 #define INDENT_3 INDENT_2 INDENT_1
38 #define INDENT_4 INDENT_3 INDENT_1
39 #define INDENT_5 INDENT_4 INDENT_1
40 #define INDENT_6 INDENT_5 INDENT_1
41 #define C(N, S) INDENT(N) #S "\n"
42 #define GLSLC(N, S) av_bprintf(&shd->src, C(N, S))
43 #define GLSLA(...) av_bprintf(&shd->src, __VA_ARGS__)
44 #define GLSLF(N, S, ...) av_bprintf(&shd->src, C(N, S), __VA_ARGS__)
45 #define GLSLD(D) GLSLC(0, ); \
46 av_bprint_append_data(&shd->src, D, strlen(D)); \
52 if ((err = (x)) < 0) \
60 VkPipelineShaderStageCreateInfo
shader;
243 VkQueueFlagBits dev_family,
int nb_queues);
262 VkImageView *v, VkImage
img, VkFormat fmt,
263 const VkComponentMapping
map);
270 int offset,
int size, VkShaderStageFlagBits stage);
283 const char *
name, VkShaderStageFlags stage);
296 int num,
int only_print_to_shader);
302 const char *entrypoint);
354 VkShaderStageFlagBits stage,
int offset,
378 AVFrame *
frame, VkPipelineStageFlagBits in_wait_dst_flag);
391 VkBufferUsageFlags
usage, VkMemoryPropertyFlagBits
flags);
398 int nb_buffers,
int invalidate);
int ff_vk_start_exec_recording(AVFilterContext *avctx, FFVkExecContext *e)
Begin recording to the command buffer.
const char * ff_vk_ret2str(VkResult res)
Converts Vulkan return values to strings.
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
VkPipelineLayout pipeline_layout
void ff_vk_bind_pipeline_exec(AVFilterContext *avctx, FFVkExecContext *e, FFVulkanPipeline *pl)
Add a command to bind the completed pipeline and its descriptor sets.
void ff_vk_filter_uninit(AVFilterContext *avctx)
The exact code depends on how similar the blocks are and how related they are to the and needs to apply these operations to the correct inlink or outlink if there are several Macros are available to factor that when no extra processing is inlink
This structure describes decoded (raw) audio or video data.
VkShaderStageFlags stages
FFSPIRVShader * ff_vk_init_shader(AVFilterContext *avctx, FFVulkanPipeline *pl, const char *name, VkShaderStageFlags stage)
Inits a shader for a specific pipeline.
void ff_vk_update_push_exec(AVFilterContext *avctx, FFVkExecContext *e, VkShaderStageFlagBits stage, int offset, size_t size, void *src)
Updates push constants.
VkDescriptorPool desc_pool
FFVulkanPipeline * bound_pl
A link between two filters.
int ff_vk_create_buf(AVFilterContext *avctx, FFVkBuffer *buf, size_t size, VkBufferUsageFlags usage, VkMemoryPropertyFlagBits flags)
Create a VkBuffer with the specified parameters.
int ff_vk_submit_exec_queue(AVFilterContext *avctx, FFVkExecContext *e)
Submits a command buffer to the queue for execution.
const char * ff_vk_shader_rep_fmt(enum AVPixelFormat pixfmt)
Gets the glsl format string for a pixel format.
void ff_vk_free_buf(AVFilterContext *avctx, FFVkBuffer *buf)
Frees a buffer.
int ff_vk_add_push_constant(AVFilterContext *avctx, FFVulkanPipeline *pl, int offset, int size, VkShaderStageFlagBits stage)
Define a push constant for a given stage into a pipeline.
int ff_vk_filter_init(AVFilterContext *avctx)
General lavfi IO functions.
VkPipelineStageFlagBits * sem_wait_dst
int sem_sig_val_dst_alloc
FFVkSampler * ff_vk_init_sampler(AVFilterContext *avctx, int unnorm_coords, VkFilter filt)
Create a Vulkan sampler, will be auto-freed in ff_vk_filter_uninit()
void ff_vk_set_compute_shader_sizes(AVFilterContext *avctx, FFSPIRVShader *shd, int local_size[3])
Writes the workgroup size for a shader.
This struct aggregates all the (hardware/vendor-specific) "high-level" state, i.e.
FFVkExecContext ** exec_ctx
VkDescriptorUpdateTemplate * desc_template
int ff_vk_create_imageview(AVFilterContext *avctx, FFVkExecContext *e, VkImageView *v, VkImage img, VkFormat fmt, const VkComponentMapping map)
Create an imageview.
FFVulkanPipeline ** pipelines
static enum AVPixelFormat pix_fmt
VkDescriptorUpdateTemplateCreateInfo * desc_template_info
int ff_vk_add_descriptor_set(AVFilterContext *avctx, FFVulkanPipeline *pl, FFSPIRVShader *shd, FFVulkanDescriptorSetBinding *desc, int num, int only_print_to_shader)
Adds a descriptor set to the shader and registers them in the pipeline.
Main Vulkan context, allocated as AVHWDeviceContext.hwctx.
Describe the class of an AVClass context structure.
static void flush(AVCodecContext *avctx)
void ff_vk_discard_exec_deps(AVFilterContext *avctx, FFVkExecContext *e)
Discards all queue dependencies.
VkDescriptorSetLayoutBinding ** desc_binding
int ff_vk_add_exec_dep(AVFilterContext *avctx, FFVkExecContext *e, AVFrame *frame, VkPipelineStageFlagBits in_wait_dst_flag)
Adds a frame as a queue dependency.
AVHWDeviceContext * device
void ff_vk_qf_init(AVFilterContext *avctx, FFVkQueueFamilyCtx *qf, VkQueueFlagBits dev_family, int nb_queues)
Initialize a queue family with a specific number of queues.
int total_descriptor_sets
int ff_vk_filter_config_output(AVFilterLink *outlink)
int ff_vk_init_compute_pipeline(AVFilterContext *avctx, FFVulkanPipeline *pl)
Initializes a compute pipeline.
int ff_vk_unmap_buffers(AVFilterContext *avctx, FFVkBuffer *buf, int nb_buffers, int flush)
Unmaps the buffer from userspace.
VkPhysicalDeviceProperties props
int ff_vk_create_exec_ctx(AVFilterContext *avctx, FFVkExecContext **ctx, FFVkQueueFamilyCtx *qf)
Init an execution context for command recording and queue submission.
enum AVPixelFormat output_format
VkMemoryPropertyFlagBits flags
int ff_vk_map_buffers(AVFilterContext *avctx, FFVkBuffer *buf, uint8_t *mem[], int nb_buffers, int invalidate)
Maps the buffer to userspace.
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
int ff_vk_init_pipeline_layout(AVFilterContext *avctx, FFVulkanPipeline *pl)
Initializes the pipeline layout after all shaders and descriptor sets have been finished.
VkDescriptorSet * desc_set
VkPipelineShaderStageCreateInfo shader
int ff_vk_filter_config_output_inplace(AVFilterLink *outlink)
FFVulkanPipeline * ff_vk_create_pipeline(AVFilterContext *avctx, FFVkQueueFamilyCtx *qf)
Inits a pipeline.
VkDescriptorPoolSize * pool_size_desc
VkPushConstantRange * push_consts
int ff_vk_mt_is_np_rgb(enum AVPixelFormat pix_fmt)
Returns 1 if the image is any sort of supported RGB.
int ff_vk_add_dep_exec_ctx(AVFilterContext *avctx, FFVkExecContext *e, AVBufferRef **deps, int nb_deps)
Adds a generic AVBufferRef as a queue depenency.
int ff_vk_compile_shader(AVFilterContext *avctx, FFSPIRVShader *shd, const char *entrypoint)
Compiles the shader, entrypoint must be set to "main".
static const int8_t filt[NUMTAPS *2]
FFVulkanExtensions extensions
VkPhysicalDeviceMemoryProperties mprops
int ff_vk_filter_config_input(AVFilterLink *inlink)
int * desc_set_initialized
void ff_vk_qf_rotate(FFVkQueueFamilyCtx *qf)
Rotate through the queues in a queue family.
enum AVPixelFormat pixfmt
const VkComponentMapping ff_comp_identity_map
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
void ff_vk_print_shader(AVFilterContext *avctx, FFSPIRVShader *shd, int prio)
Pretty print shader, mainly used by shader compilers.
enum AVPixelFormat input_format
int frame_deps_alloc_size
void ff_vk_update_descriptor_set(AVFilterContext *avctx, FFVulkanPipeline *pl, int set_id)
Updates a descriptor set via the updaters defined.
AVVulkanDeviceContext * hwctx
A reference to a data buffer.
const VDPAUPixFmtMap * map
VkCommandBuffer ff_vk_get_exec_buf(AVFilterContext *avctx, FFVkExecContext *e)
Gets the command buffer to use for this submission from the exe context.
#define flags(name, subs,...)
uint64_t ** sem_sig_val_dst
VkDescriptorSetLayout * desc_layout
unsigned int scratch_size