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 flush(AVCodecContext *avctx)
static const int8_t filt[NUMTAPS *2]
Main libavfilter public API header.
#define flags(name, subs,...)
static enum AVPixelFormat pix_fmt
const VDPAUPixFmtMap * map
API-specific header for AV_HWDEVICE_TYPE_VULKAN.
enum AVPixelFormat pixfmt
AVPixelFormat
Pixel format.
A reference to a data buffer.
Describe the class of an AVClass context structure.
A link between two filters.
This structure describes decoded (raw) audio or video data.
This struct aggregates all the (hardware/vendor-specific) "high-level" state, i.e.
Main Vulkan context, allocated as AVHWDeviceContext.hwctx.
VkMemoryPropertyFlagBits flags
VulkanPipeline * bound_pl
VkPipelineStageFlagBits * sem_wait_dst
int frame_deps_alloc_size
VkPipelineShaderStageCreateInfo shader
const VkSampler * samplers
VkShaderStageFlags stages
VulkanPipeline ** pipelines
AVHWDeviceContext * device
unsigned int scratch_size
FFVkExecContext ** exec_ctx
AVVulkanDeviceContext * hwctx
enum AVPixelFormat input_format
enum AVPixelFormat output_format
VkPushConstantRange * push_consts
VkDescriptorUpdateTemplateCreateInfo * desc_template_info
VkDescriptorPool desc_pool
VkPipelineLayout pipeline_layout
VkDescriptorSetLayout * desc_layout
VkPipelineBindPoint bind_point
VkDescriptorPoolSize * pool_size_desc
VkDescriptorUpdateTemplate * desc_template
VkDescriptorSet * desc_set
static const uint8_t offset[127][2]
int ff_vk_unmap_buffers(AVFilterContext *avctx, FFVkBuffer *buf, int nb_buffers, int flush)
Unmaps the buffer from userspace.
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_map_buffers(AVFilterContext *avctx, FFVkBuffer *buf, uint8_t *mem[], int nb_buffers, int invalidate)
Maps the buffer to userspace.
int ff_vk_add_exec_dep(AVFilterContext *avctx, FFVkExecContext *e, AVFrame *frame, VkPipelineStageFlagBits in_wait_dst_flag)
Adds a frame as a queue dependency.
int ff_vk_filter_config_output_inplace(AVFilterLink *outlink)
int ff_vk_create_buf(AVFilterContext *avctx, FFVkBuffer *buf, size_t size, VkBufferUsageFlags usage, VkMemoryPropertyFlagBits flags)
Create a VkBuffer with the specified parameters.
const char * ff_vk_ret2str(VkResult res)
Converts Vulkan return values to strings.
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.
const char * ff_vk_shader_rep_fmt(enum AVPixelFormat pixfmt)
Gets the glsl format string for a pixel format.
void ff_vk_discard_exec_deps(AVFilterContext *avctx, FFVkExecContext *e)
Discards all queue dependencies.
void ff_vk_set_compute_shader_sizes(AVFilterContext *avctx, SPIRVShader *shd, int local_size[3])
Writes the workgroup size for a shader.
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_add_push_constant(AVFilterContext *avctx, VulkanPipeline *pl, int offset, int size, VkShaderStageFlagBits stage)
Define a push constant for a given stage into a pipeline.
int ff_vk_init_compute_pipeline(AVFilterContext *avctx, VulkanPipeline *pl)
Initializes a compute pipeline.
int ff_vk_filter_config_input(AVFilterLink *inlink)
void ff_vk_update_push_exec(AVFilterContext *avctx, FFVkExecContext *e, VkShaderStageFlagBits stage, int offset, size_t size, void *src)
Updates push constants.
int ff_vk_filter_config_output(AVFilterLink *outlink)
const VkComponentMapping ff_comp_identity_map
void ff_vk_filter_uninit(AVFilterContext *avctx)
SPIRVShader * ff_vk_init_shader(AVFilterContext *avctx, VulkanPipeline *pl, const char *name, VkShaderStageFlags stage)
Inits a shader for a specific pipeline.
int ff_vk_compile_shader(AVFilterContext *avctx, SPIRVShader *shd, const char *entrypoint)
Compiles the shader, entrypoint must be set to "main".
int ff_vk_create_exec_ctx(AVFilterContext *avctx, FFVkExecContext **ctx)
Init an execution context for command recording and queue submission.
VkCommandBuffer ff_vk_get_exec_buf(AVFilterContext *avctx, FFVkExecContext *e)
Gets the command buffer to use for this submission from the exe context.
void ff_vk_update_descriptor_set(AVFilterContext *avctx, VulkanPipeline *pl, int set_id)
Updates a descriptor set via the updaters defined.
void ff_vk_bind_pipeline_exec(AVFilterContext *avctx, FFVkExecContext *e, VulkanPipeline *pl)
Add a command to bind the completed pipeline and its descriptor sets.
int ff_vk_start_exec_recording(AVFilterContext *avctx, FFVkExecContext *e)
Begin recording to the command buffer.
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_init_pipeline_layout(AVFilterContext *avctx, VulkanPipeline *pl)
Initializes the pipeline layout after all shaders and descriptor sets have been finished.
void ff_vk_free_buf(AVFilterContext *avctx, FFVkBuffer *buf)
Frees a buffer.
int ff_vk_submit_exec_queue(AVFilterContext *avctx, FFVkExecContext *e)
Submits a command buffer to the queue for execution.
int ff_vk_filter_query_formats(AVFilterContext *avctx)
General lavfi IO functions.
int ff_vk_filter_init(AVFilterContext *avctx)
VulkanPipeline * ff_vk_create_pipeline(AVFilterContext *avctx)
Inits a pipeline.
int ff_vk_create_imageview(AVFilterContext *avctx, FFVkExecContext *e, VkImageView *v, VkImage img, VkFormat fmt, const VkComponentMapping map)
Create an imageview.