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