Go to the documentation of this file.
19 #ifndef AVFILTER_VULKAN_H
20 #define AVFILTER_VULKAN_H
29 #define INDENT(N) INDENT_##N
31 #define INDENT_1 INDENT_0 " "
32 #define INDENT_2 INDENT_1 INDENT_1
33 #define INDENT_3 INDENT_2 INDENT_1
34 #define INDENT_4 INDENT_3 INDENT_1
35 #define INDENT_5 INDENT_4 INDENT_1
36 #define INDENT_6 INDENT_5 INDENT_1
37 #define C(N, S) INDENT(N) #S "\n"
38 #define GLSLC(N, S) av_bprintf(&shd->src, C(N, S))
39 #define GLSLA(...) av_bprintf(&shd->src, __VA_ARGS__)
40 #define GLSLF(N, S, ...) av_bprintf(&shd->src, C(N, S), __VA_ARGS__)
41 #define GLSLD(D) GLSLC(0, ); \
42 av_bprint_append_data(&shd->src, D, strlen(D)); \
48 if ((err = (x)) < 0) \
53 #define GET_QUEUE_COUNT(hwctx, graph, comp, tx) ( \
54 graph ? hwctx->nb_graphics_queues : \
55 comp ? (hwctx->nb_comp_queues ? \
56 hwctx->nb_comp_queues : hwctx->nb_graphics_queues) : \
57 tx ? (hwctx->nb_tx_queues ? hwctx->nb_tx_queues : \
58 (hwctx->nb_comp_queues ? \
59 hwctx->nb_comp_queues : hwctx->nb_graphics_queues)) : \
64 #define DUP_SAMPLER_ARRAY4(x) (VkSampler []){ x, x, x, x, }
70 VkPipelineShaderStageCreateInfo
shader;
234 VkImageView *v, VkImage
img, VkFormat fmt,
235 const VkComponentMapping
map);
242 int offset,
int size, VkShaderStageFlagBits stage);
254 const char *
name, VkShaderStageFlags stage);
267 int num,
int only_print_to_shader);
273 const char *entrypoint);
319 VkShaderStageFlagBits stage,
int offset,
343 AVFrame *
frame, VkPipelineStageFlagBits in_wait_dst_flag);
356 VkBufferUsageFlags
usage, VkMemoryPropertyFlagBits
flags);
363 int nb_buffers,
int invalidate);
static void usage(const char *program_name)
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.
void ff_vk_set_compute_shader_sizes(AVFilterContext *avctx, SPIRVShader *shd, int local_size[3])
Writes the workgroup size for a shader.
void ff_vk_bind_pipeline_exec(AVFilterContext *avctx, FFVkExecContext *e, VulkanPipeline *pl)
Add a command to bind the completed pipeline and its descriptor sets.
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
VkDescriptorUpdateTemplateCreateInfo * desc_template_info
VkPipelineLayout pipeline_layout
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.
void ff_vk_update_push_exec(AVFilterContext *avctx, FFVkExecContext *e, VkShaderStageFlagBits stage, int offset, size_t size, void *src)
Updates push constants.
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_filter_init(AVFilterContext *avctx)
int ff_vk_filter_query_formats(AVFilterContext *avctx)
General lavfi IO functions.
unsigned int scratch_size
VkPipelineStageFlagBits * sem_wait_dst
int ff_vk_create_exec_ctx(AVFilterContext *avctx, FFVkExecContext **ctx)
Init an execution context for command recording and queue submission.
enum AVPixelFormat output_format
int ff_vk_add_push_constant(AVFilterContext *avctx, VulkanPipeline *pl, int offset, int size, VkShaderStageFlagBits stage)
Define a push constant for a given stage into a pipeline.
This struct aggregates all the (hardware/vendor-specific) "high-level" state, i.e.
AVHWDeviceContext * device
VkPushConstantRange * push_consts
FFVkExecContext ** exec_ctx
VkDescriptorPool desc_pool
int ff_vk_init_compute_pipeline(AVFilterContext *avctx, VulkanPipeline *pl)
Initializes a compute pipeline.
VkShaderStageFlags stages
int ff_vk_create_imageview(AVFilterContext *avctx, FFVkExecContext *e, VkImageView *v, VkImage img, VkFormat fmt, const VkComponentMapping map)
Create an imageview.
static enum AVPixelFormat pix_fmt
Main Vulkan context, allocated as AVHWDeviceContext.hwctx.
Describe the class of an AVClass context structure.
static void flush(AVCodecContext *avctx)
enum AVPixelFormat input_format
VkPipelineShaderStageCreateInfo shader
void ff_vk_discard_exec_deps(AVFilterContext *avctx, FFVkExecContext *e)
Discards all queue dependencies.
int ff_vk_add_exec_dep(AVFilterContext *avctx, FFVkExecContext *e, AVFrame *frame, VkPipelineStageFlagBits in_wait_dst_flag)
Adds a frame as a queue dependency.
VkDescriptorSetLayout * desc_layout
int ff_vk_compile_shader(AVFilterContext *avctx, SPIRVShader *shd, const char *entrypoint)
Compiles the shader, entrypoint must be set to "main".
int ff_vk_filter_config_output(AVFilterLink *outlink)
int ff_vk_unmap_buffers(AVFilterContext *avctx, FFVkBuffer *buf, int nb_buffers, int flush)
Unmaps the buffer from userspace.
VulkanPipeline * bound_pl
static const int8_t filt[NUMTAPS]
VkMemoryPropertyFlagBits flags
int ff_vk_map_buffers(AVFilterContext *avctx, FFVkBuffer *buf, uint8_t *mem[], int nb_buffers, int invalidate)
Maps the buffer to userspace.
VkDescriptorPoolSize * pool_size_desc
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_filter_config_output_inplace(AVFilterLink *outlink)
VkDescriptorUpdateTemplate * desc_template
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.
VkDescriptorSet * desc_set
VkSampler * ff_vk_init_sampler(AVFilterContext *avctx, int unnorm_coords, VkFilter filt)
Create a Vulkan sampler, will be auto-freed in ff_vk_filter_uninit()
int ff_vk_filter_config_input(AVFilterLink *inlink)
AVVulkanDeviceContext * hwctx
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
int frame_deps_alloc_size
VulkanPipeline * ff_vk_create_pipeline(AVFilterContext *avctx)
Inits a pipeline.
VulkanPipeline ** pipelines
A reference to a data buffer.
void ff_vk_update_descriptor_set(AVFilterContext *avctx, VulkanPipeline *pl, int set_id)
Updates a descriptor set via the updaters defined.
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,...)
VkPipelineBindPoint bind_point
int ff_vk_init_pipeline_layout(AVFilterContext *avctx, VulkanPipeline *pl)
Initializes the pipeline layout after all shaders and descriptor sets have been finished.
const VkSampler * samplers
int ff_vk_add_descriptor_set(AVFilterContext *avctx, VulkanPipeline *pl, SPIRVShader *shd, VulkanDescriptorSetBinding *desc, int num, int only_print_to_shader)
Adds a descriptor set to the shader and registers them in the pipeline.
SPIRVShader * ff_vk_init_shader(AVFilterContext *avctx, VulkanPipeline *pl, const char *name, VkShaderStageFlags stage)
Inits a shader for a specific pipeline.